diff --git a/dist/bundles/can/test/test.css b/dist/bundles/can/test/test.css
new file mode 100644
index 00000000000..c34e2ab2848
--- /dev/null
+++ b/dist/bundles/can/test/test.css
@@ -0,0 +1,306 @@
+/*qunitjs@1.23.1#qunit/qunit.css!$css*/
+/*!
+ * QUnit 1.23.1
+ * https://qunitjs.com/
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license
+ * https://jquery.org/license
+ *
+ * Date: 2016-04-12T17:29Z
+ */
+
+/** Font Family and Sizes */
+
+#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
+}
+
+#qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
+#qunit-tests { font-size: smaller; }
+
+
+/** Resets */
+
+#qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
+ margin: 0;
+ padding: 0;
+}
+
+
+/** Header */
+
+#qunit-header {
+ padding: 0.5em 0 0.5em 1em;
+
+ color: #8699A4;
+ background-color: #0D3349;
+
+ font-size: 1.5em;
+ line-height: 1em;
+ font-weight: 400;
+
+ border-radius: 5px 5px 0 0;
+}
+
+#qunit-header a {
+ text-decoration: none;
+ color: #C2CCD1;
+}
+
+#qunit-header a:hover,
+#qunit-header a:focus {
+ color: #FFF;
+}
+
+#qunit-testrunner-toolbar label {
+ display: inline-block;
+ padding: 0 0.5em 0 0.1em;
+}
+
+#qunit-banner {
+ height: 5px;
+}
+
+#qunit-testrunner-toolbar {
+ padding: 0.5em 1em 0.5em 1em;
+ color: #5E740B;
+ background-color: #EEE;
+ overflow: hidden;
+}
+
+#qunit-filteredTest {
+ padding: 0.5em 1em 0.5em 1em;
+ background-color: #F4FF77;
+ color: #366097;
+}
+
+#qunit-userAgent {
+ padding: 0.5em 1em 0.5em 1em;
+ background-color: #2B81AF;
+ color: #FFF;
+ text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
+}
+
+#qunit-modulefilter-container {
+ float: right;
+ padding: 0.2em;
+}
+
+.qunit-url-config {
+ display: inline-block;
+ padding: 0.1em;
+}
+
+.qunit-filter {
+ display: block;
+ float: right;
+ margin-left: 1em;
+}
+
+/** Tests: Pass/Fail */
+
+#qunit-tests {
+ list-style-position: inside;
+}
+
+#qunit-tests li {
+ padding: 0.4em 1em 0.4em 1em;
+ border-bottom: 1px solid #FFF;
+ list-style-position: inside;
+}
+
+#qunit-tests > li {
+ display: none;
+}
+
+#qunit-tests li.running,
+#qunit-tests li.pass,
+#qunit-tests li.fail,
+#qunit-tests li.skipped {
+ display: list-item;
+}
+
+#qunit-tests.hidepass {
+ position: relative;
+}
+
+#qunit-tests.hidepass li.running,
+#qunit-tests.hidepass li.pass {
+ visibility: hidden;
+ position: absolute;
+ width: 0;
+ height: 0;
+ padding: 0;
+ border: 0;
+ margin: 0;
+}
+
+#qunit-tests li strong {
+ cursor: pointer;
+}
+
+#qunit-tests li.skipped strong {
+ cursor: default;
+}
+
+#qunit-tests li a {
+ padding: 0.5em;
+ color: #C2CCD1;
+ text-decoration: none;
+}
+
+#qunit-tests li p a {
+ padding: 0.25em;
+ color: #6B6464;
+}
+#qunit-tests li a:hover,
+#qunit-tests li a:focus {
+ color: #000;
+}
+
+#qunit-tests li .runtime {
+ float: right;
+ font-size: smaller;
+}
+
+.qunit-assert-list {
+ margin-top: 0.5em;
+ padding: 0.5em;
+
+ background-color: #FFF;
+
+ border-radius: 5px;
+}
+
+.qunit-source {
+ margin: 0.6em 0 0.3em;
+}
+
+.qunit-collapsed {
+ display: none;
+}
+
+#qunit-tests table {
+ border-collapse: collapse;
+ margin-top: 0.2em;
+}
+
+#qunit-tests th {
+ text-align: right;
+ vertical-align: top;
+ padding: 0 0.5em 0 0;
+}
+
+#qunit-tests td {
+ vertical-align: top;
+}
+
+#qunit-tests pre {
+ margin: 0;
+ white-space: pre-wrap;
+ word-wrap: break-word;
+}
+
+#qunit-tests del {
+ background-color: #E0F2BE;
+ color: #374E0C;
+ text-decoration: none;
+}
+
+#qunit-tests ins {
+ background-color: #FFCACA;
+ color: #500;
+ text-decoration: none;
+}
+
+/*** Test Counts */
+
+#qunit-tests b.counts { color: #000; }
+#qunit-tests b.passed { color: #5E740B; }
+#qunit-tests b.failed { color: #710909; }
+
+#qunit-tests li li {
+ padding: 5px;
+ background-color: #FFF;
+ border-bottom: none;
+ list-style-position: inside;
+}
+
+/*** Passing Styles */
+
+#qunit-tests li li.pass {
+ color: #3C510C;
+ background-color: #FFF;
+ border-left: 10px solid #C6E746;
+}
+
+#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
+#qunit-tests .pass .test-name { color: #366097; }
+
+#qunit-tests .pass .test-actual,
+#qunit-tests .pass .test-expected { color: #999; }
+
+#qunit-banner.qunit-pass { background-color: #C6E746; }
+
+/*** Failing Styles */
+
+#qunit-tests li li.fail {
+ color: #710909;
+ background-color: #FFF;
+ border-left: 10px solid #EE5757;
+ white-space: pre;
+}
+
+#qunit-tests > li:last-child {
+ border-radius: 0 0 5px 5px;
+}
+
+#qunit-tests .fail { color: #000; background-color: #EE5757; }
+#qunit-tests .fail .test-name,
+#qunit-tests .fail .module-name { color: #000; }
+
+#qunit-tests .fail .test-actual { color: #EE5757; }
+#qunit-tests .fail .test-expected { color: #008000; }
+
+#qunit-banner.qunit-fail { background-color: #EE5757; }
+
+/*** Skipped tests */
+
+#qunit-tests .skipped {
+ background-color: #EBECE9;
+}
+
+#qunit-tests .qunit-skipped-label {
+ background-color: #F4FF77;
+ display: inline-block;
+ font-style: normal;
+ color: #366097;
+ line-height: 1.8em;
+ padding: 0 0.5em;
+ margin: -0.4em 0.4em -0.4em 0;
+}
+
+/** Result */
+
+#qunit-testresult {
+ padding: 0.5em 1em 0.5em 1em;
+
+ color: #2B81AF;
+ background-color: #D2E0E6;
+
+ border-bottom: 1px solid #FFF;
+}
+#qunit-testresult .module-name {
+ font-weight: 700;
+}
+
+/** Fixture */
+
+#qunit-fixture {
+ position: absolute;
+ top: -10000px;
+ left: -10000px;
+ width: 1000px;
+ height: 1000px;
+}
diff --git a/dist/bundles/can/test/test.js b/dist/bundles/can/test/test.js
new file mode 100644
index 00000000000..559565e72a0
--- /dev/null
+++ b/dist/bundles/can/test/test.js
@@ -0,0 +1,74409 @@
+/*[system-bundles-config]*/
+System.bundles = {"bundles/can/test/test.css!":["qunitjs@1.23.1#qunit/qunit.css!$css"]};
+/*npm-utils*/
+define('npm-utils', function (require, exports, module) {
+ (function (global) {
+ var slice = Array.prototype.slice;
+ var npmModuleRegEx = /.+@.+\..+\..+#.+/;
+ var conditionalModuleRegEx = /#\{[^\}]+\}|#\?.+$/;
+ var utils = {
+ extend: function (d, s, deep) {
+ var val;
+ for (var prop in s) {
+ val = s[prop];
+ if (deep) {
+ if (utils.isArray(val)) {
+ d[prop] = slice.call(val);
+ } else if (utils.isObject(val)) {
+ d[prop] = utils.extend({}, val, deep);
+ } else {
+ d[prop] = s[prop];
+ }
+ } else {
+ d[prop] = s[prop];
+ }
+ }
+ return d;
+ },
+ map: function (arr, fn) {
+ var i = 0, len = arr.length, out = [];
+ for (; i < len; i++) {
+ out.push(fn.call(arr, arr[i]));
+ }
+ return out;
+ },
+ filter: function (arr, fn) {
+ var i = 0, len = arr.length, out = [], res;
+ for (; i < len; i++) {
+ res = fn.call(arr, arr[i]);
+ if (res) {
+ out.push(arr[i]);
+ }
+ }
+ return out;
+ },
+ forEach: function (arr, fn) {
+ var i = 0, len = arr.length;
+ for (; i < len; i++) {
+ fn.call(arr, arr[i], i);
+ }
+ },
+ isObject: function (obj) {
+ return typeof obj === 'object';
+ },
+ isArray: Array.isArray || function (arr) {
+ return Object.prototype.toString.call(arr) === '[object Array]';
+ },
+ isEnv: function (name) {
+ return this.isEnv ? this.isEnv(name) : this.env === name;
+ },
+ warnOnce: function (msg) {
+ var w = this._warnings = this._warnings || {};
+ if (w[msg])
+ return;
+ w[msg] = true;
+ this.warn(msg);
+ },
+ warn: function (msg) {
+ if (typeof steal !== 'undefined' && typeof console !== 'undefined' && console.warn) {
+ steal.done().then(function () {
+ if (steal.dev && steal.dev.warn) {
+ steal.dev.warn(msg);
+ } else if (console.warn) {
+ console.warn('steal.js WARNING: ' + msg);
+ } else {
+ console.log(msg);
+ }
+ });
+ }
+ },
+ relativeURI: function (baseURL, url) {
+ return typeof steal !== 'undefined' ? steal.relativeURI(baseURL, url) : url;
+ },
+ moduleName: {
+ create: function (descriptor, standard) {
+ if (standard) {
+ return descriptor.moduleName;
+ } else {
+ if (descriptor === '@empty') {
+ return descriptor;
+ }
+ var modulePath;
+ if (descriptor.modulePath) {
+ modulePath = descriptor.modulePath.substr(0, 2) === './' ? descriptor.modulePath.substr(2) : descriptor.modulePath;
+ }
+ return descriptor.packageName + (descriptor.version ? '@' + descriptor.version : '') + (modulePath ? '#' + modulePath : '') + (descriptor.plugin ? descriptor.plugin : '');
+ }
+ },
+ isNpm: function (moduleName) {
+ return npmModuleRegEx.test(moduleName);
+ },
+ isConditional: function (moduleName) {
+ return conditionalModuleRegEx.test(moduleName);
+ },
+ isFullyConvertedNpm: function (parsedModuleName) {
+ return !!(parsedModuleName.packageName && parsedModuleName.version && parsedModuleName.modulePath);
+ },
+ isScoped: function (moduleName) {
+ return moduleName[0] === '@';
+ },
+ parse: function (moduleName, currentPackageName, global) {
+ var pluginParts = moduleName.split('!');
+ var modulePathParts = pluginParts[0].split('#');
+ var versionParts = modulePathParts[0].split('@');
+ if (!modulePathParts[1] && !versionParts[0]) {
+ versionParts = ['@' + versionParts[1]];
+ }
+ if (versionParts.length === 3 && utils.moduleName.isScoped(moduleName)) {
+ versionParts.splice(0, 1);
+ versionParts[0] = '@' + versionParts[0];
+ }
+ var packageName, modulePath;
+ if (currentPackageName && utils.path.isRelative(moduleName)) {
+ packageName = currentPackageName;
+ modulePath = versionParts[0];
+ } else if (currentPackageName && utils.path.startsWithTildeSlash(moduleName)) {
+ packageName = currentPackageName;
+ modulePath = versionParts[0].split('/').slice(1).join('/');
+ } else {
+ if (modulePathParts[1]) {
+ packageName = versionParts[0];
+ modulePath = modulePathParts[1];
+ } else {
+ var folderParts = versionParts[0].split('/');
+ if (folderParts.length && folderParts[0][0] === '@') {
+ packageName = folderParts.splice(0, 2).join('/');
+ } else {
+ packageName = folderParts.shift();
+ }
+ modulePath = folderParts.join('/');
+ }
+ }
+ modulePath = utils.path.removeJS(modulePath);
+ return {
+ plugin: pluginParts.length === 2 ? '!' + pluginParts[1] : undefined,
+ version: versionParts[1],
+ modulePath: modulePath,
+ packageName: packageName,
+ moduleName: moduleName,
+ isGlobal: global
+ };
+ },
+ parseFromPackage: function (loader, refPkg, name, parentName) {
+ var packageName = utils.pkg.name(refPkg), parsedModuleName = utils.moduleName.parse(name, packageName), isRelative = utils.path.isRelative(parsedModuleName.modulePath);
+ if (isRelative && !parentName) {
+ throw new Error('Cannot resolve a relative module identifier ' + 'with no parent module:', name);
+ }
+ if (isRelative) {
+ var parentParsed = utils.moduleName.parse(parentName, packageName);
+ if (parentParsed.packageName === parsedModuleName.packageName && parentParsed.modulePath) {
+ var makePathRelative = true;
+ if (name === '../' || name === './' || name === '..') {
+ var relativePath = utils.path.relativeTo(parentParsed.modulePath, name);
+ var isInRoot = utils.path.isPackageRootDir(relativePath);
+ if (isInRoot) {
+ parsedModuleName.modulePath = utils.pkg.main(refPkg);
+ makePathRelative = false;
+ } else {
+ parsedModuleName.modulePath = name + (utils.path.endsWithSlash(name) ? '' : '/') + 'index';
+ }
+ }
+ if (makePathRelative) {
+ parsedModuleName.modulePath = utils.path.makeRelative(utils.path.joinURIs(parentParsed.modulePath, parsedModuleName.modulePath));
+ }
+ }
+ }
+ var mapName = utils.moduleName.create(parsedModuleName), refSteal = utils.pkg.config(refPkg), mappedName;
+ if (refPkg.browser && typeof refPkg.browser !== 'string' && mapName in refPkg.browser && (!refSteal || !refSteal.ignoreBrowser)) {
+ mappedName = refPkg.browser[mapName] === false ? '@empty' : refPkg.browser[mapName];
+ }
+ var global = loader && loader.globalBrowser && loader.globalBrowser[mapName];
+ if (global) {
+ mappedName = global.moduleName === false ? '@empty' : global.moduleName;
+ }
+ if (mappedName) {
+ return utils.moduleName.parse(mappedName, packageName, !!global);
+ } else {
+ return parsedModuleName;
+ }
+ },
+ nameAndVersion: function (parsedModuleName) {
+ return parsedModuleName.packageName + '@' + parsedModuleName.version;
+ }
+ },
+ pkg: {
+ name: function (pkg) {
+ var steal = utils.pkg.config(pkg);
+ return steal && steal.name || pkg.name;
+ },
+ main: function (pkg) {
+ var main;
+ var steal = utils.pkg.config(pkg);
+ if (steal && steal.main) {
+ main = steal.main;
+ } else if (typeof pkg.browser === 'string') {
+ if (utils.path.endsWithSlash(pkg.browser)) {
+ main = pkg.browser + 'index';
+ } else {
+ main = pkg.browser;
+ }
+ } else if (typeof pkg.jam === 'object') {
+ main = pkg.jam.main;
+ } else if (pkg.main) {
+ main = pkg.main;
+ } else {
+ main = 'index';
+ }
+ return utils.path.removeJS(utils.path.removeDotSlash(main));
+ },
+ rootDir: function (pkg, isRoot) {
+ var root = isRoot ? utils.path.removePackage(pkg.fileUrl) : utils.path.pkgDir(pkg.fileUrl);
+ var lib = utils.pkg.directoriesLib(pkg);
+ if (lib) {
+ root = utils.path.joinURIs(utils.path.addEndingSlash(root), lib);
+ }
+ return root;
+ },
+ isRoot: function (loader, pkg) {
+ var root = utils.pkg.getDefault(loader);
+ return pkg.name === root.name && pkg.version === root.version;
+ },
+ getDefault: function (loader) {
+ return loader.npmPaths.__default;
+ },
+ findByModuleNameOrAddress: function (loader, moduleName, moduleAddress) {
+ if (loader.npm) {
+ if (moduleName) {
+ var parsed = utils.moduleName.parse(moduleName);
+ if (parsed.version && parsed.packageName) {
+ var name = parsed.packageName + '@' + parsed.version;
+ if (name in loader.npm) {
+ return loader.npm[name];
+ }
+ }
+ }
+ if (moduleAddress) {
+ var startingAddress = utils.relativeURI(loader.baseURL, moduleAddress);
+ var packageFolder = utils.pkg.folderAddress(startingAddress);
+ return packageFolder ? loader.npmPaths[packageFolder] : utils.pkg.getDefault(loader);
+ } else {
+ return utils.pkg.getDefault(loader);
+ }
+ }
+ },
+ folderAddress: function (address) {
+ var nodeModules = '/node_modules/', nodeModulesIndex = address.lastIndexOf(nodeModules), nextSlash = address.indexOf('/', nodeModulesIndex + nodeModules.length);
+ if (nodeModulesIndex >= 0) {
+ return nextSlash >= 0 ? address.substr(0, nextSlash) : address;
+ }
+ },
+ findDep: function (loader, refPkg, name) {
+ if (loader.npm && refPkg && !utils.path.startsWithDotSlash(name)) {
+ var nameAndVersion = name + '@' + refPkg.resolutions[name];
+ var pkg = loader.npm[nameAndVersion];
+ return pkg;
+ }
+ },
+ findDepWalking: function (loader, refPackage, name) {
+ if (loader.npm && refPackage && !utils.path.startsWithDotSlash(name)) {
+ var curPackage = utils.path.depPackageDir(refPackage.fileUrl, name);
+ while (curPackage) {
+ var pkg = loader.npmPaths[curPackage];
+ if (pkg) {
+ return pkg;
+ }
+ var parentAddress = utils.path.parentNodeModuleAddress(curPackage);
+ if (!parentAddress) {
+ return;
+ }
+ curPackage = parentAddress + '/' + name;
+ }
+ }
+ },
+ findByName: function (loader, name) {
+ if (loader.npm && !utils.path.startsWithDotSlash(name)) {
+ return loader.npm[name];
+ }
+ },
+ findByNameAndVersion: function (loader, name, version) {
+ if (loader.npm && !utils.path.startsWithDotSlash(name)) {
+ var nameAndVersion = name + '@' + version;
+ return loader.npm[nameAndVersion];
+ }
+ },
+ findByUrl: function (loader, url) {
+ if (loader.npm) {
+ url = utils.pkg.folderAddress(url);
+ return loader.npmPaths[url];
+ }
+ },
+ directoriesLib: function (pkg) {
+ var steal = utils.pkg.config(pkg);
+ var lib = steal && steal.directories && steal.directories.lib;
+ var ignores = [
+ '.',
+ '/'
+ ], ignore;
+ if (!lib)
+ return undefined;
+ while (!!(ignore = ignores.shift())) {
+ if (lib[0] === ignore) {
+ lib = lib.substr(1);
+ }
+ }
+ return lib;
+ },
+ hasDirectoriesLib: function (pkg) {
+ var steal = utils.pkg.config(pkg);
+ return steal && steal.directories && !!steal.directories.lib;
+ },
+ findPackageInfo: function (context, pkg) {
+ var pkgInfo = context.pkgInfo;
+ if (pkgInfo) {
+ var out;
+ utils.forEach(pkgInfo, function (p) {
+ if (pkg.name === p.name && pkg.version === p.version) {
+ out = p;
+ }
+ });
+ return out;
+ }
+ },
+ saveResolution: function (context, refPkg, pkg) {
+ var npmPkg = utils.pkg.findPackageInfo(context, refPkg);
+ npmPkg.resolutions[pkg.name] = refPkg.resolutions[pkg.name] = pkg.version;
+ },
+ config: function (pkg) {
+ return pkg.steal || pkg.system;
+ }
+ },
+ path: {
+ makeRelative: function (path) {
+ if (utils.path.isRelative(path) && path.substr(0, 1) !== '/') {
+ return path;
+ } else {
+ return './' + path;
+ }
+ },
+ removeJS: function (path) {
+ return path.replace(/\.js(!|$)/, function (whole, part) {
+ return part;
+ });
+ },
+ removePackage: function (path) {
+ return path.replace(/\/package\.json.*/, '');
+ },
+ addJS: function (path) {
+ if (/\.js(on)?$/.test(path)) {
+ return path;
+ } else {
+ return path + '.js';
+ }
+ },
+ isRelative: function (path) {
+ return path.substr(0, 1) === '.';
+ },
+ startsWithTildeSlash: function (path) {
+ return path.substr(0, 2) === '~/';
+ },
+ joinURIs: function (base, href) {
+ function removeDotSegments(input) {
+ var output = [];
+ input.replace(/^(\.\.?(\/|$))+/, '').replace(/\/(\.(\/|$))+/g, '/').replace(/\/\.\.$/, '/../').replace(/\/?[^\/]*/g, function (p) {
+ if (p === '/..') {
+ output.pop();
+ } else {
+ output.push(p);
+ }
+ });
+ return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
+ }
+ href = parseURI(href || '');
+ base = parseURI(base || '');
+ return !href || !base ? null : (href.protocol || base.protocol) + (href.protocol || href.authority ? href.authority : base.authority) + removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : href.pathname ? (base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname : base.pathname) + (href.protocol || href.authority || href.pathname ? href.search : href.search || base.search) + href.hash;
+ },
+ startsWithDotSlash: function (path) {
+ return path.substr(0, 2) === './';
+ },
+ removeDotSlash: function (path) {
+ return utils.path.startsWithDotSlash(path) ? path.substr(2) : path;
+ },
+ endsWithSlash: function (path) {
+ return path[path.length - 1] === '/';
+ },
+ addEndingSlash: function (path) {
+ return utils.path.endsWithSlash(path) ? path : path + '/';
+ },
+ depPackage: function (parentPackageAddress, childName) {
+ var packageFolderName = parentPackageAddress.replace(/\/package\.json.*/, '');
+ return (packageFolderName ? packageFolderName + '/' : '') + 'node_modules/' + childName + '/package.json';
+ },
+ peerPackage: function (parentPackageAddress, childName) {
+ var packageFolderName = parentPackageAddress.replace(/\/package\.json.*/, '');
+ return packageFolderName.substr(0, packageFolderName.lastIndexOf('/')) + '/' + childName + '/package.json';
+ },
+ depPackageDir: function (parentPackageAddress, childName) {
+ return utils.path.depPackage(parentPackageAddress, childName).replace(/\/package\.json.*/, '');
+ },
+ peerNodeModuleAddress: function (address) {
+ var nodeModules = '/node_modules/', nodeModulesIndex = address.lastIndexOf(nodeModules);
+ if (nodeModulesIndex >= 0) {
+ return address.substr(0, nodeModulesIndex + nodeModules.length - 1);
+ }
+ },
+ parentNodeModuleAddress: function (address) {
+ var nodeModules = '/node_modules/', nodeModulesIndex = address.lastIndexOf(nodeModules), prevModulesIndex = address.lastIndexOf(nodeModules, nodeModulesIndex - 1);
+ if (prevModulesIndex >= 0) {
+ return address.substr(0, prevModulesIndex + nodeModules.length - 1);
+ }
+ },
+ pkgDir: function (address) {
+ var nodeModules = '/node_modules/', nodeModulesIndex = address.lastIndexOf(nodeModules), nextSlash = address.indexOf('/', nodeModulesIndex + nodeModules.length);
+ if (address[nodeModulesIndex + nodeModules.length] === '@') {
+ nextSlash = address.indexOf('/', nextSlash + 1);
+ }
+ if (nodeModulesIndex >= 0) {
+ return nextSlash >= 0 ? address.substr(0, nextSlash) : address;
+ }
+ },
+ basename: function (address) {
+ var parts = address.split('/');
+ return parts[parts.length - 1];
+ },
+ relativeTo: function (modulePath, rel) {
+ var parts = modulePath.split('/');
+ var idx = 1;
+ while (rel[idx] === '.') {
+ parts.pop();
+ idx++;
+ }
+ return parts.join('/');
+ },
+ isPackageRootDir: function (pth) {
+ return pth.indexOf('/') === -1;
+ }
+ },
+ json: {
+ transform: function (loader, load, data) {
+ var fn = loader.jsonOptions && loader.jsonOptions.transform;
+ if (!fn)
+ return data;
+ return fn.call(loader, load, data);
+ }
+ },
+ includeInBuild: true
+ };
+ function parseURI(url) {
+ var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ return m ? {
+ href: m[0] || '',
+ protocol: m[1] || '',
+ authority: m[2] || '',
+ host: m[3] || '',
+ hostname: m[4] || '',
+ port: m[5] || '',
+ pathname: m[6] || '',
+ search: m[7] || '',
+ hash: m[8] || ''
+ } : null;
+ }
+ module.exports = utils;
+ }(function () {
+ return this;
+ }()));
+});
+/*npm-extension*/
+define('npm-extension', function (require, exports, module) {
+ 'format cjs';
+ var utils = require('./npm-utils');
+ exports.includeInBuild = true;
+ var isNode = typeof process === 'object' && {}.toString.call(process) === '[object process]';
+ var isWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
+ var isBrowser = typeof window !== 'undefined' && !isNode && !isWorker;
+ exports.addExtension = function (System) {
+ if (System._extensions) {
+ System._extensions.push(exports.addExtension);
+ }
+ var oldNormalize = System.normalize;
+ System.normalize = function (name, parentName, parentAddress, pluginNormalize) {
+ if (parentName && this.npmParentMap && this.npmParentMap[parentName]) {
+ parentName = this.npmParentMap[parentName];
+ }
+ var hasNoParent = !parentName;
+ var nameIsRelative = utils.path.isRelative(name);
+ var parentIsNpmModule = utils.moduleName.isNpm(parentName);
+ var identifierEndsWithSlash = utils.path.endsWithSlash(name);
+ if (parentName && nameIsRelative && !parentIsNpmModule) {
+ return oldNormalize.call(this, name, parentName, parentAddress, pluginNormalize);
+ }
+ if (utils.moduleName.isConditional(name)) {
+ return oldNormalize.call(this, name, parentName, parentAddress, pluginNormalize);
+ }
+ var hasContextualMap = typeof this.map[parentName] === 'object' && this.map[parentName][name];
+ if (hasContextualMap) {
+ return oldNormalize.call(this, name, parentName, parentAddress, pluginNormalize);
+ }
+ var refPkg = utils.pkg.findByModuleNameOrAddress(this, parentName, parentAddress);
+ if (!refPkg) {
+ return oldNormalize.call(this, name, parentName, parentAddress, pluginNormalize);
+ }
+ var isPointingAtParentFolder = name === '../' || name === './';
+ if (parentIsNpmModule && isPointingAtParentFolder) {
+ var parsedParentModuleName = utils.moduleName.parse(parentName);
+ var parentModulePath = parsedParentModuleName.modulePath || '';
+ var relativePath = utils.path.relativeTo(parentModulePath, name);
+ var isInRoot = utils.path.isPackageRootDir(relativePath);
+ if (isInRoot) {
+ name = refPkg.name + '#' + utils.path.removeJS(refPkg.main);
+ } else {
+ name = name + 'index';
+ }
+ }
+ var parsedModuleName = utils.moduleName.parseFromPackage(this, refPkg, name, parentName);
+ var isRoot = utils.pkg.isRoot(this, refPkg);
+ var parsedPackageNameIsReferringPackage = parsedModuleName.packageName === refPkg.name;
+ var isRelativeToParentNpmModule = parentIsNpmModule && nameIsRelative && parsedPackageNameIsReferringPackage;
+ var depPkg, wantedPkg;
+ if (isRelativeToParentNpmModule) {
+ depPkg = refPkg;
+ }
+ var context = this.npmContext;
+ var crawl = context && context.crawl;
+ var isDev = !!crawl;
+ if (!depPkg) {
+ if (crawl && !isRoot) {
+ var parentPkg = nameIsRelative ? null : crawl.matchedVersion(context, refPkg.name, refPkg.version);
+ if (parentPkg) {
+ wantedPkg = crawl.getDependencyMap(this, parentPkg, isRoot)[parsedModuleName.packageName];
+ if (wantedPkg) {
+ var foundPkg = crawl.matchedVersion(this.npmContext, wantedPkg.name, wantedPkg.version);
+ if (foundPkg) {
+ depPkg = utils.pkg.findByUrl(this, foundPkg.fileUrl);
+ }
+ }
+ }
+ } else {
+ if (isRoot) {
+ depPkg = utils.pkg.findDepWalking(this, refPkg, parsedModuleName.packageName);
+ } else {
+ depPkg = utils.pkg.findDep(this, refPkg, parsedModuleName.packageName);
+ }
+ }
+ }
+ if (parsedPackageNameIsReferringPackage) {
+ depPkg = utils.pkg.findByNameAndVersion(this, parsedModuleName.packageName, refPkg.version);
+ }
+ var lookupByName = parsedModuleName.isGlobal || hasNoParent;
+ if (!depPkg) {
+ depPkg = utils.pkg.findByName(this, parsedModuleName.packageName);
+ }
+ var isThePackageWeWant = !isDev || !depPkg || (wantedPkg ? crawl.pkgSatisfies(depPkg, wantedPkg.version) : true);
+ if (!isThePackageWeWant) {
+ depPkg = undefined;
+ } else if (isDev && depPkg) {
+ utils.pkg.saveResolution(context, refPkg, depPkg);
+ }
+ if (!depPkg) {
+ var browserPackageName = this.globalBrowser[parsedModuleName.packageName];
+ if (browserPackageName) {
+ parsedModuleName.packageName = browserPackageName.moduleName;
+ depPkg = utils.pkg.findByName(this, parsedModuleName.packageName);
+ }
+ }
+ if (!depPkg && isRoot && name === refPkg.main && utils.pkg.hasDirectoriesLib(refPkg)) {
+ parsedModuleName.version = refPkg.version;
+ parsedModuleName.packageName = refPkg.name;
+ parsedModuleName.modulePath = utils.pkg.main(refPkg);
+ return oldNormalize.call(this, utils.moduleName.create(parsedModuleName), parentName, parentAddress, pluginNormalize);
+ }
+ var loader = this;
+ if (!depPkg) {
+ if (crawl) {
+ var parentPkg = crawl.matchedVersion(this.npmContext, refPkg.name, refPkg.version);
+ if (parentPkg) {
+ depPkg = crawl.getDependencyMap(this, parentPkg, isRoot)[parsedModuleName.packageName];
+ }
+ }
+ if (!depPkg) {
+ if (refPkg.browser && refPkg.browser[name]) {
+ return oldNormalize.call(this, refPkg.browser[name], parentName, parentAddress, pluginNormalize);
+ }
+ return oldNormalize.call(this, name, parentName, parentAddress, pluginNormalize);
+ }
+ return crawl.dep(this.npmContext, parentPkg, depPkg, isRoot).then(createModuleNameAndNormalize);
+ } else {
+ return createModuleNameAndNormalize(depPkg);
+ }
+ function createModuleNameAndNormalize(depPkg) {
+ parsedModuleName.version = depPkg.version;
+ if (!parsedModuleName.modulePath) {
+ parsedModuleName.modulePath = utils.pkg.main(depPkg);
+ }
+ var moduleName = utils.moduleName.create(parsedModuleName);
+ var steal = utils.pkg.config(refPkg);
+ if (steal && steal.map && typeof steal.map[moduleName] === 'string') {
+ moduleName = steal.map[moduleName];
+ }
+ var p = oldNormalize.call(loader, moduleName, parentName, parentAddress, pluginNormalize);
+ if (identifierEndsWithSlash) {
+ p.then(function (name) {
+ if (context && context.forwardSlashMap) {
+ context.forwardSlashMap[name] = true;
+ }
+ });
+ }
+ return p;
+ }
+ };
+ var oldLocate = System.locate;
+ System.locate = function (load) {
+ var parsedModuleName = utils.moduleName.parse(load.name), loader = this;
+ if (parsedModuleName.version && this.npm && !loader.paths[load.name]) {
+ var pkg = this.npm[utils.moduleName.nameAndVersion(parsedModuleName)];
+ if (pkg) {
+ return oldLocate.call(this, load).then(function (address) {
+ var expectedAddress = utils.path.joinURIs(System.baseURL, load.name);
+ if (isBrowser) {
+ expectedAddress = expectedAddress.replace(/#/g, '%23');
+ }
+ if (address !== expectedAddress + '.js' && address !== expectedAddress) {
+ return address;
+ }
+ var root = utils.pkg.rootDir(pkg, utils.pkg.isRoot(loader, pkg));
+ if (parsedModuleName.modulePath) {
+ var npmAddress = utils.path.joinURIs(utils.path.addEndingSlash(root), parsedModuleName.plugin ? parsedModuleName.modulePath : utils.path.addJS(parsedModuleName.modulePath));
+ address = typeof steal !== 'undefined' ? utils.path.joinURIs(loader.baseURL, npmAddress) : npmAddress;
+ }
+ return address;
+ });
+ }
+ }
+ return oldLocate.call(this, load);
+ };
+ var oldFetch = System.fetch;
+ System.fetch = function (load) {
+ if (load.metadata.dryRun) {
+ return oldFetch.apply(this, arguments);
+ }
+ var loader = this;
+ var context = loader.npmContext;
+ var fetchPromise = Promise.resolve(oldFetch.apply(this, arguments));
+ if (utils.moduleName.isNpm(load.name)) {
+ fetchPromise = fetchPromise.then(null, function (err) {
+ var types = [].slice.call(retryTypes);
+ return retryAll(types, err);
+ function retryAll(types, err) {
+ if (!types.length) {
+ throw err;
+ }
+ var type = types.shift();
+ if (!type.test(load)) {
+ throw err;
+ }
+ return Promise.resolve(retryFetch.call(loader, load, type)).then(null, function (err) {
+ return retryAll(types, err);
+ });
+ }
+ });
+ }
+ return fetchPromise;
+ };
+ var convertName = function (loader, name) {
+ var pkg = utils.pkg.findByName(loader, name.split('/')[0]);
+ if (pkg) {
+ var parsed = utils.moduleName.parse(name, pkg.name);
+ parsed.version = pkg.version;
+ if (!parsed.modulePath) {
+ parsed.modulePath = utils.pkg.main(pkg);
+ }
+ return utils.moduleName.create(parsed);
+ }
+ return name;
+ };
+ var configSpecial = {
+ map: function (map) {
+ var newMap = {}, val;
+ for (var name in map) {
+ val = map[name];
+ newMap[convertName(this, name)] = typeof val === 'object' ? configSpecial.map(val) : convertName(this, val);
+ }
+ return newMap;
+ },
+ meta: function (map) {
+ var newMap = {};
+ for (var name in map) {
+ newMap[convertName(this, name)] = map[name];
+ }
+ return newMap;
+ },
+ paths: function (paths) {
+ var newPaths = {};
+ for (var name in paths) {
+ newPaths[convertName(this, name)] = paths[name];
+ }
+ return newPaths;
+ }
+ };
+ var oldConfig = System.config;
+ System.config = function (cfg) {
+ var loader = this;
+ for (var name in cfg) {
+ if (configSpecial[name]) {
+ cfg[name] = configSpecial[name].call(loader, cfg[name]);
+ }
+ }
+ oldConfig.apply(loader, arguments);
+ };
+ function retryFetch(load, type) {
+ var loader = this;
+ var moduleName = typeof type.name === 'function' ? type.name(loader, load) : load.name + type.name;
+ var local = utils.extend({}, load);
+ local.name = moduleName;
+ local.metadata = { dryRun: true };
+ return Promise.resolve(loader.locate(local)).then(function (address) {
+ local.address = address;
+ return loader.fetch(local);
+ }).then(function (source) {
+ load.metadata.address = local.address;
+ loader.npmParentMap[load.name] = local.name;
+ var npmLoad = loader.npmContext && loader.npmContext.npmLoad;
+ if (npmLoad) {
+ npmLoad.saveLoadIfNeeded(loader.npmContext);
+ if (!isNode) {
+ utils.warnOnce('Some 404s were encountered ' + 'while loading. Don\'t panic! ' + 'These will only happen in dev ' + 'and are harmless.');
+ }
+ }
+ return source;
+ });
+ }
+ var retryTypes = [
+ {
+ name: function (loader, load) {
+ var context = loader.npmContext;
+ if (context.forwardSlashMap[load.name]) {
+ var parts = load.name.split('/');
+ parts.pop();
+ return parts.concat(['index']).join('/');
+ }
+ return load.name + '/index';
+ },
+ test: function () {
+ return true;
+ }
+ },
+ {
+ name: '.json',
+ test: function (load) {
+ return utils.moduleName.isNpm(load.name) && utils.path.basename(load.address) === 'package.js';
+ }
+ }
+ ];
+ };
+});
+/*npm-load*/
+define('npm-load', [], function(){ return {}; });
+/*semver*/
+define('semver', [], function(){ return {}; });
+/*npm-crawl*/
+define('npm-crawl', [], function(){ return {}; });
+/*npm-convert*/
+define('npm-convert', [], function(){ return {}; });
+/*npm*/
+define('npm', [], function(){ return {}; });
+/*package.json!npm*/
+define('package.json!npm', [
+ '@loader',
+ 'npm-extension',
+ 'module'
+], function (loader, npmExtension, module) {
+ npmExtension.addExtension(loader);
+ if (!loader.main) {
+ loader.main = 'can@3.0.0#can';
+ }
+ loader._npmExtensions = [].slice.call(arguments, 2);
+ (function (loader, packages, options) {
+ var g = loader.global;
+ if (!g.process) {
+ g.process = {
+ argv: [],
+ cwd: function () {
+ var baseURL = loader.baseURL;
+ return baseURL;
+ },
+ browser: true,
+ env: { NODE_ENV: loader.env },
+ version: '',
+ platform: navigator && navigator.userAgent && /Windows/.test(navigator.userAgent) ? 'win' : ''
+ };
+ }
+ if (!loader.npm) {
+ loader.npm = {};
+ loader.npmPaths = {};
+ loader.globalBrowser = {};
+ }
+ if (!loader.npmParentMap) {
+ loader.npmParentMap = options.npmParentMap || {};
+ }
+ var rootPkg = loader.npmPaths.__default = packages[0];
+ var rootConfig = rootPkg.steal || rootPkg.system;
+ var lib = rootConfig && rootConfig.directories && rootConfig.directories.lib;
+ var setGlobalBrowser = function (globals, pkg) {
+ for (var name in globals) {
+ loader.globalBrowser[name] = {
+ pkg: pkg,
+ moduleName: globals[name]
+ };
+ }
+ };
+ var setInNpm = function (name, pkg) {
+ if (!loader.npm[name]) {
+ loader.npm[name] = pkg;
+ }
+ loader.npm[name + '@' + pkg.version] = pkg;
+ };
+ var forEach = function (arr, fn) {
+ var i = 0, len = arr.length;
+ for (; i < len; i++) {
+ fn.call(arr, arr[i]);
+ }
+ };
+ var setupLiveReload = function () {
+ var hasLiveReload = !!(loader.liveReloadInstalled || loader._liveMap);
+ if (hasLiveReload) {
+ loader['import']('live-reload', { name: module.id }).then(function (reload) {
+ reload.dispose(function () {
+ delete loader.npm;
+ delete loader.npmPaths;
+ delete loader.npmParentMap;
+ delete loader.npmContext;
+ });
+ });
+ }
+ };
+ var ignoredConfig = [
+ 'bundle',
+ 'configDependencies',
+ 'transpiler'
+ ];
+ packages.reverse();
+ forEach(packages, function (pkg) {
+ var steal = pkg.steal || pkg.system;
+ if (steal) {
+ var main = steal.main;
+ delete steal.main;
+ var configDeps = steal.configDependencies;
+ if (pkg !== rootPkg) {
+ forEach(ignoredConfig, function (name) {
+ delete steal[name];
+ });
+ }
+ loader.config(steal);
+ if (pkg === rootPkg) {
+ steal.configDependencies = configDeps;
+ }
+ steal.main = main;
+ }
+ if (pkg.globalBrowser) {
+ var doNotApplyGlobalBrowser = pkg.name === 'steal' && rootConfig.builtins === false;
+ if (!doNotApplyGlobalBrowser) {
+ setGlobalBrowser(pkg.globalBrowser, pkg);
+ }
+ }
+ var systemName = steal && steal.name;
+ if (systemName) {
+ setInNpm(systemName, pkg);
+ } else {
+ setInNpm(pkg.name, pkg);
+ }
+ if (!loader.npm[pkg.name]) {
+ loader.npm[pkg.name] = pkg;
+ }
+ loader.npm[pkg.name + '@' + pkg.version] = pkg;
+ var pkgAddress = pkg.fileUrl.replace(/\/package\.json.*/, '');
+ loader.npmPaths[pkgAddress] = pkg;
+ });
+ forEach(loader._npmExtensions || [], function (ext) {
+ if (ext.systemConfig) {
+ loader.config(ext.systemConfig);
+ }
+ });
+ setupLiveReload();
+ }(loader, [
+ {
+ 'name': 'can',
+ 'version': '3.0.0',
+ 'fileUrl': './package.json',
+ 'main': 'can.js',
+ 'steal': {
+ 'npmAlgorithm': 'flat',
+ 'main': 'can',
+ 'npmIgnore': {
+ 'bit-docs': true,
+ 'testee': true,
+ 'async': true,
+ 'saucelabs': true,
+ 'wd': true,
+ 'http-server': true
+ }
+ },
+ 'resolutions': {
+ 'can': '3.0.0',
+ 'can-connect': '1.0.11',
+ 'can-construct-super': '3.0.0',
+ 'can-define': '1.0.4',
+ 'can-set': '1.0.2',
+ 'can-stache-converters': '3.0.3',
+ 'can-observation': '3.0.2',
+ 'can-view-callbacks': '3.0.1',
+ 'can-view-model': '3.0.0',
+ 'can-view-target': '3.0.3',
+ 'can-simple-dom': '1.0.2',
+ 'can-map-define': '3.0.0',
+ 'can-view-href': '3.0.1',
+ 'can-map-backup': '3.0.0',
+ 'can-fixture': '1.0.7',
+ 'can-construct': '3.0.3',
+ 'can-compute': '3.0.3',
+ 'can-component': '3.0.2',
+ 'can-view-import': '3.0.1',
+ 'can-util': '3.0.10',
+ 'can-event': '3.0.1',
+ 'can-stache': '3.0.7',
+ 'can-stache-bindings': '3.0.4',
+ 'can-view-live': '3.0.1',
+ 'can-view-scope': '3.0.1',
+ 'can-view-nodelist': '3.0.1',
+ 'can-view-parser': '3.0.1',
+ 'can-control': '3.0.3',
+ 'can-map': '3.0.2',
+ 'can-view-autorender': '3.0.1',
+ 'can-list': '3.0.0',
+ 'can-ejs': '3.0.0',
+ 'steal-qunit': '0.1.4',
+ 'funcunit': '3.1.0'
+ }
+ },
+ {
+ 'name': 'can-component',
+ 'version': '3.0.2',
+ 'fileUrl': './node_modules/can-component/package.json',
+ 'main': 'can-component',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-component': '3.0.2',
+ 'can-stache': '3.0.7',
+ 'steal-qunit': '0.1.4',
+ 'can-define': '1.0.4',
+ 'can-view-model': '3.0.0',
+ 'can-util': '3.0.10',
+ 'can-construct': '3.0.3',
+ 'can-compute': '3.0.3',
+ 'can-map': '3.0.2',
+ 'can-list': '3.0.0',
+ 'can-event': '3.0.1',
+ 'can-vdom': '3.0.1',
+ 'can-view-scope': '3.0.1',
+ 'can-view-callbacks': '3.0.1',
+ 'can-stache-bindings': '3.0.4',
+ 'can-view-nodelist': '3.0.1',
+ 'can-control': '3.0.3',
+ 'can-observation': '3.0.2'
+ }
+ },
+ {
+ 'name': 'can-compute',
+ 'version': '3.0.3',
+ 'fileUrl': './node_modules/can-compute/package.json',
+ 'main': 'can-compute',
+ 'steal': { 'npmAlgorithm': 'flat' },
+ 'resolutions': {
+ 'can-compute': '3.0.3',
+ 'steal-qunit': '0.1.4',
+ 'can-event': '3.0.1',
+ 'can-observation': '3.0.2',
+ 'can-define': '1.0.4',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-connect',
+ 'version': '1.0.11',
+ 'fileUrl': './node_modules/can-connect/package.json',
+ 'main': 'can-connect.js',
+ 'steal': {
+ 'ignoreBrowser': true,
+ 'npmIgnore': { 'devDependencies': true },
+ 'npmDependencies': {
+ 'steal-qunit': true,
+ 'can-fixture': true,
+ 'can-define': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {
+ 'can-connect#all': 'can-connect#dist/cjs/all',
+ 'can-connect#can-connect': 'can-connect#dist/cjs/can-connect',
+ 'can-connect#connect': 'can-connect#dist/cjs/connect',
+ 'can-connect#base/base': 'can-connect#dist/cjs/base/base',
+ 'can-connect#cache-requests/cache-requests': 'can-connect#dist/cjs/cache-requests/cache-requests',
+ 'can-connect#helpers/get-items': 'can-connect#dist/cjs/helpers/get-items',
+ 'can-connect#constructor/constructor': 'can-connect#dist/cjs/constructor/constructor',
+ 'can-connect#helpers/weak-reference-map': 'can-connect#dist/cjs/helpers/weak-reference-map',
+ 'can-connect#helpers/overwrite': 'can-connect#dist/cjs/helpers/overwrite',
+ 'can-connect#helpers/id-merge': 'can-connect#dist/cjs/helpers/id-merge',
+ 'can-connect#constructor/callbacks-once/callbacks-once': 'can-connect#dist/cjs/constructor/callbacks-once/callbacks-once',
+ 'can-connect#helpers/sorted-set-json': 'can-connect#dist/cjs/helpers/sorted-set-json',
+ 'can-connect#constructor/store/store': 'can-connect#dist/cjs/constructor/store/store',
+ 'can-connect#data/callbacks/callbacks': 'can-connect#dist/cjs/data/callbacks/callbacks',
+ 'can-connect#data/callbacks-cache/callbacks-cache': 'can-connect#dist/cjs/data/callbacks-cache/callbacks-cache',
+ 'can-connect#data/combine-requests/combine-requests': 'can-connect#dist/cjs/data/combine-requests/combine-requests',
+ 'can-connect#helpers/deferred': 'can-connect#dist/cjs/helpers/deferred',
+ 'can-connect#data/localstorage-cache/localstorage-cache': 'can-connect#dist/cjs/data/localstorage-cache/localstorage-cache',
+ 'can-connect#helpers/set-add': 'can-connect#dist/cjs/helpers/set-add',
+ 'can-connect#helpers/get-index-by-id': 'can-connect#dist/cjs/helpers/get-index-by-id',
+ 'can-connect#data/memory-cache/memory-cache': 'can-connect#dist/cjs/data/memory-cache/memory-cache',
+ 'can-connect#data/parse/parse': 'can-connect#dist/cjs/data/parse/parse',
+ 'can-connect#data/url/url': 'can-connect#dist/cjs/data/url/url',
+ 'can-connect#helpers/get-id-props': 'can-connect#dist/cjs/helpers/get-id-props',
+ 'can-connect#fall-through-cache/fall-through-cache': 'can-connect#dist/cjs/fall-through-cache/fall-through-cache',
+ 'can-connect#real-time/real-time': 'can-connect#dist/cjs/real-time/real-time',
+ 'can-connect#can/super-map/super-map': 'can-connect#dist/cjs/can/super-map/super-map',
+ 'can-connect#can/map/map': 'can-connect#dist/cjs/can/map/map',
+ 'can-connect#can/ref/ref': 'can-connect#dist/cjs/can/ref/ref',
+ 'can-connect#can/tag/tag': 'can-connect#dist/cjs/can/tag/tag',
+ 'can-connect#can/base-map/base-map': 'can-connect#dist/cjs/can/base-map/base-map'
+ },
+ 'resolutions': {
+ 'can-connect': '1.0.11',
+ 'steal-qunit': '0.1.4',
+ 'can-fixture': '1.0.7',
+ 'can-util': '3.0.10',
+ 'jquery': '2.2.4',
+ 'can-set': '1.0.2',
+ 'can-event': '3.0.1',
+ 'can-define': '1.0.4',
+ 'can-map': '3.0.2',
+ 'can-compute': '3.0.3',
+ 'can-list': '3.0.0',
+ 'steal-stache': '3.0.1',
+ 'can-observation': '3.0.2',
+ 'can-stache-bindings': '3.0.4',
+ 'can-stache': '3.0.7',
+ 'can-view-callbacks': '3.0.1',
+ 'can-view-nodelist': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-construct',
+ 'version': '3.0.3',
+ 'fileUrl': './node_modules/can-construct/package.json',
+ 'main': 'can-construct',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'steal-qunit': '0.1.4',
+ 'can-construct': '3.0.3',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-construct-super',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-construct-super/package.json',
+ 'main': 'can-construct-super',
+ 'steal': {
+ 'main': 'can-construct-super',
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ }
+ },
+ 'resolutions': {
+ 'can-construct-super': '3.0.0',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10',
+ 'can-construct': '3.0.3'
+ }
+ },
+ {
+ 'name': 'can-control',
+ 'version': '3.0.3',
+ 'fileUrl': './node_modules/can-control/package.json',
+ 'main': 'can-control',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-control': '3.0.3',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10',
+ 'can-event': '3.0.1',
+ 'can-map': '3.0.2',
+ 'can-define': '1.0.4',
+ 'can-construct': '3.0.3',
+ 'can-compute': '3.0.3',
+ 'can-observation': '3.0.2'
+ }
+ },
+ {
+ 'name': 'can-define',
+ 'version': '1.0.4',
+ 'fileUrl': './node_modules/can-define/package.json',
+ 'main': 'can-define.js',
+ 'steal': { 'npmAlgorithm': 'flat' },
+ 'resolutions': {
+ 'can-define': '1.0.4',
+ 'can-util': '3.0.10',
+ 'steal-qunit': '0.1.4',
+ 'can-observation': '3.0.2',
+ 'can-stache': '3.0.7',
+ 'can-compute': '3.0.3',
+ 'can-list': '3.0.0',
+ 'can-event': '3.0.1',
+ 'can-construct': '3.0.3'
+ }
+ },
+ {
+ 'name': 'can-define-stream',
+ 'version': '0.0.2',
+ 'fileUrl': './node_modules/can-define-stream/package.json',
+ 'main': 'can-define-stream',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'resolutions': {}
+ },
+ {
+ 'name': 'can-ejs',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-ejs/package.json',
+ 'main': 'dist/cjs/can-ejs',
+ 'steal': {
+ 'main': 'can-ejs',
+ 'ext': { 'ejs': 'src/system' },
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'steal-qunit': '0.1.4',
+ 'can-ejs': '3.0.0',
+ 'can-map': '3.0.2',
+ 'can-util': '3.0.10',
+ 'can-list': '3.0.0',
+ 'can-compute': '3.0.3',
+ 'can-legacy-view-helpers': '0.5.0',
+ 'can-observation': '3.0.2'
+ }
+ },
+ {
+ 'name': 'can-event',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-event/package.json',
+ 'main': 'can-event',
+ 'steal': { 'npmAlgorithm': 'flat' },
+ 'resolutions': {
+ 'can-util': '3.0.10',
+ 'can-event': '3.0.1',
+ 'steal-qunit': '0.1.4'
+ }
+ },
+ {
+ 'name': 'can-fixture',
+ 'version': '1.0.7',
+ 'fileUrl': './node_modules/can-fixture/package.json',
+ 'main': 'fixture.js',
+ 'steal': { 'npmAlgorithm': 'flat' },
+ 'resolutions': {
+ 'steal-qunit': '0.1.4',
+ 'can-fixture': '1.0.7',
+ 'can-set': '1.0.2',
+ 'jquery': '2.2.4',
+ 'can-util': '3.0.10',
+ 'can-connect': '1.0.11'
+ }
+ },
+ {
+ 'name': 'can-fixture-socket',
+ 'version': '0.5.7',
+ 'fileUrl': './node_modules/can-fixture-socket/package.json',
+ 'main': 'dist/cjs/can-fixture-socket',
+ 'steal': {
+ 'main': 'can-fixture-socket',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': [
+ 'documentjs',
+ 'testee',
+ 'generator-donejs',
+ 'donejs-cli',
+ 'steal-tools'
+ ],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {}
+ },
+ {
+ 'name': 'can-jquery',
+ 'version': '3.0.2',
+ 'fileUrl': './node_modules/can-jquery/package.json',
+ 'main': 'can-jquery.js',
+ 'steal': { 'npmAlgorithm': 'flat' },
+ 'resolutions': {}
+ },
+ {
+ 'name': 'can-list',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-list/package.json',
+ 'main': 'can-list',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-list': '3.0.0',
+ 'steal-qunit': '0.1.4',
+ 'can-observation': '3.0.2',
+ 'can-map': '3.0.2',
+ 'can-map-define': '3.0.0',
+ 'can-event': '3.0.1',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-map',
+ 'version': '3.0.2',
+ 'fileUrl': './node_modules/can-map/package.json',
+ 'main': 'can-map',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-map': '3.0.2',
+ 'steal-qunit': '0.1.4',
+ 'can-observation': '3.0.2',
+ 'can-construct': '3.0.3',
+ 'can-event': '3.0.1',
+ 'can-compute': '3.0.3',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-map-backup',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-map-backup/package.json',
+ 'main': 'dist/cjs/can-map-backup',
+ 'steal': {
+ 'main': 'can-map-backup',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-compute': '3.0.3',
+ 'can-map': '3.0.2',
+ 'can-map-backup': '3.0.0',
+ 'can-map-define': '3.0.0',
+ 'steal-qunit': '0.1.4',
+ 'can-set': '1.0.2',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-map-define',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-map-define/package.json',
+ 'main': 'dist/cjs/can-map-define',
+ 'steal': {
+ 'main': 'can-map-define',
+ 'npmAlgorithm': 'flat'
+ },
+ 'resolutions': {
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10',
+ 'can-map': '3.0.2',
+ 'can-list': '3.0.0',
+ 'can-compute': '3.0.3',
+ 'can-map-define': '3.0.0',
+ 'can-event': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-observation',
+ 'version': '3.0.2',
+ 'fileUrl': './node_modules/can-observation/package.json',
+ 'main': 'can-observation',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-observation': '3.0.2',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10',
+ 'can-event': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-route',
+ 'version': '3.0.3',
+ 'fileUrl': './node_modules/can-route/package.json',
+ 'main': 'can-route',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-event': '3.0.1',
+ 'can-observation': '3.0.2',
+ 'can-compute': '3.0.3',
+ 'can-util': '3.0.10',
+ 'can-route': '3.0.3'
+ }
+ },
+ {
+ 'name': 'can-route-pushstate',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-route-pushstate/package.json',
+ 'main': 'can-route-pushstate',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {}
+ },
+ {
+ 'name': 'can-set',
+ 'version': '1.0.2',
+ 'fileUrl': './node_modules/can-set/package.json',
+ 'main': 'src/set.js',
+ 'steal': { 'npmIgnore': { 'testee': true } },
+ 'resolutions': {
+ 'can-set': '1.0.2',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-simple-dom',
+ 'version': '1.0.2',
+ 'fileUrl': './node_modules/can-simple-dom/package.json',
+ 'main': 'dist/cjs/simple-dom.js',
+ 'steal': {
+ 'main': 'simple-dom.js',
+ 'directories': { 'lib': 'lib' },
+ 'npmIgnore': { 'testee': true }
+ },
+ 'resolutions': {
+ 'can-simple-dom': '1.0.2',
+ 'steal-qunit': '0.1.4',
+ 'he': '1.1.0',
+ 'simple-html-tokenizer': '0.2.5',
+ 'micro-location': '0.1.5'
+ }
+ },
+ {
+ 'name': 'can-simple-map',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-simple-map/package.json',
+ 'main': 'dist/cjs/can-simple-map',
+ 'steal': {
+ 'main': 'can-simple-map',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-construct': '3.0.3',
+ 'can-event': '3.0.1',
+ 'can-util': '3.0.10',
+ 'can-observation': '3.0.2'
+ }
+ },
+ {
+ 'name': 'can-stache',
+ 'version': '3.0.7',
+ 'fileUrl': './node_modules/can-stache/package.json',
+ 'main': 'can-stache',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-stache': '3.0.7',
+ 'steal-qunit': '0.1.4',
+ 'can-map': '3.0.2',
+ 'can-list': '3.0.0',
+ 'can-compute': '3.0.3',
+ 'can-define': '1.0.4',
+ 'can-view-callbacks': '3.0.1',
+ 'can-view-scope': '3.0.1',
+ 'can-view-parser': '3.0.1',
+ 'can-view-nodelist': '3.0.1',
+ 'can-event': '3.0.1',
+ 'can-vdom': '3.0.1',
+ 'can-util': '3.0.10',
+ 'can-view-target': '3.0.3',
+ 'can-observation': '3.0.2',
+ 'can-route': '3.0.3',
+ 'can-view-live': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-stache-bindings',
+ 'version': '3.0.4',
+ 'fileUrl': './node_modules/can-stache-bindings/package.json',
+ 'main': 'dist/cjs/can-stache-bindings',
+ 'steal': {
+ 'main': 'can-stache-bindings',
+ 'npmAlgorithm': 'flat'
+ },
+ 'resolutions': {
+ 'can-stache-bindings': '3.0.4',
+ 'steal-qunit': '0.1.4',
+ 'can-list': '3.0.0',
+ 'can-map': '3.0.2',
+ 'can-stache': '3.0.7',
+ 'can-event': '3.0.1',
+ 'can-view-callbacks': '3.0.1',
+ 'can-compute': '3.0.3',
+ 'can-view-model': '3.0.0',
+ 'can-util': '3.0.10',
+ 'can-vdom': '3.0.1',
+ 'can-define': '1.0.4',
+ 'can-view-live': '3.0.1',
+ 'can-view-scope': '3.0.1',
+ 'can-observation': '3.0.2',
+ 'can-view-nodelist': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-stache-converters',
+ 'version': '3.0.3',
+ 'fileUrl': './node_modules/can-stache-converters/package.json',
+ 'main': 'dist/cjs/can-stache-converters',
+ 'steal': {
+ 'main': 'can-stache-converters',
+ 'npmAlgorithm': 'flat'
+ },
+ 'resolutions': {
+ 'can-stache-converters': '3.0.3',
+ 'can-event': '3.0.1',
+ 'can-define': '1.0.4',
+ 'can-stache': '3.0.7',
+ 'can-util': '3.0.10',
+ 'steal-qunit': '0.1.4',
+ 'can-compute': '3.0.3',
+ 'can-stache-bindings': '3.0.4'
+ }
+ },
+ {
+ 'name': 'can-stream',
+ 'version': '0.0.5',
+ 'fileUrl': './node_modules/can-stream/package.json',
+ 'main': 'can-stream',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'resolutions': {}
+ },
+ {
+ 'name': 'can-util',
+ 'version': '3.0.10',
+ 'fileUrl': './node_modules/can-util/package.json',
+ 'main': 'can-util',
+ 'steal': { 'npmAlgorithm': 'flat' },
+ 'resolutions': {
+ 'can-util': '3.0.10',
+ 'steal-qunit': '0.1.4',
+ 'can-event': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-vdom',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-vdom/package.json',
+ 'main': 'can-vdom.js',
+ 'steal': {
+ 'main': 'can-vdom',
+ 'npmAlgorithm': 'flat',
+ 'map': { 'can-vdom@3.0.1#assert': 'chai/chai' },
+ 'meta': {
+ 'chai/chai': {
+ 'format': 'global',
+ 'exports': 'chai.assert'
+ }
+ }
+ },
+ 'resolutions': {
+ 'can-vdom': '3.0.1',
+ 'can-simple-dom': '0.4.8',
+ 'can-view-parser': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-view-autorender',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-autorender/package.json',
+ 'main': 'can-view-autorender',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': { 'steal-qunit': '0.1.4' }
+ },
+ {
+ 'name': 'can-view-callbacks',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-callbacks/package.json',
+ 'main': 'can-view-callbacks',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'steal-qunit': '0.1.4',
+ 'can-view-callbacks': '3.0.1',
+ 'can-util': '3.0.10',
+ 'can-observation': '3.0.2'
+ }
+ },
+ {
+ 'name': 'can-view-href',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-href/package.json',
+ 'main': 'dist/cjs/can-view-href',
+ 'steal': {
+ 'main': 'can-view-href',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-route': '3.0.3',
+ 'steal-qunit': '0.1.4',
+ 'can-view-href': '3.0.1',
+ 'can-stache': '3.0.7',
+ 'can-view-callbacks': '3.0.1',
+ 'can-compute': '3.0.3',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-view-import',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-import/package.json',
+ 'main': 'dist/cjs/can-view-import',
+ 'steal': {
+ 'main': 'can-view-import',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-map': '3.0.2',
+ 'can-component': '3.0.2',
+ 'can-stache': '3.0.7',
+ 'can-compute': '3.0.3',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10',
+ 'can-view-callbacks': '3.0.1',
+ 'can-view-import': '3.0.1',
+ 'can-view-nodelist': '3.0.1',
+ 'can-event': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-view-live',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-live/package.json',
+ 'main': 'dist/cjs/can-view-live',
+ 'steal': {
+ 'main': 'can-view-live',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-view-live': '3.0.1',
+ 'can-compute': '3.0.3',
+ 'can-map': '3.0.2',
+ 'can-list': '3.0.0',
+ 'can-view-nodelist': '3.0.1',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10',
+ 'can-view-parser': '3.0.1',
+ 'can-view-callbacks': '3.0.1',
+ 'can-event': '3.0.1'
+ }
+ },
+ {
+ 'name': 'can-view-model',
+ 'version': '3.0.0',
+ 'fileUrl': './node_modules/can-view-model/package.json',
+ 'main': 'dist/cjs/can-view-model',
+ 'steal': {
+ 'main': 'can-view-model',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-view-model': '3.0.0',
+ 'steal-qunit': '0.1.4',
+ 'can-simple-map': '3.0.0',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-view-nodelist',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-nodelist/package.json',
+ 'main': 'can-view-nodelist',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-view-nodelist': '3.0.1',
+ 'can-util': '3.0.10',
+ 'steal-qunit': '0.1.4'
+ }
+ },
+ {
+ 'name': 'can-view-parser',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-parser/package.json',
+ 'main': 'can-view-parser',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-view-parser': '3.0.1',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-view-scope',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/can-view-scope/package.json',
+ 'main': 'can-view-scope',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-view-scope': '3.0.1',
+ 'can-map': '3.0.2',
+ 'can-list': '3.0.0',
+ 'can-observation': '3.0.2',
+ 'can-compute': '3.0.3',
+ 'steal-qunit': '0.1.4',
+ 'can-define': '1.0.4',
+ 'can-util': '3.0.10',
+ 'can-simple-map': '3.0.0'
+ }
+ },
+ {
+ 'name': 'can-view-target',
+ 'version': '3.0.3',
+ 'fileUrl': './node_modules/can-view-target/package.json',
+ 'main': 'can-view-target',
+ 'steal': {
+ 'configDependencies': ['live-reload'],
+ 'npmAlgorithm': 'flat'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-view-target': '3.0.3',
+ 'can-simple-dom': '1.0.2',
+ 'steal-qunit': '0.1.4',
+ 'can-util': '3.0.10'
+ }
+ },
+ {
+ 'name': 'can-zone',
+ 'version': '0.6.0',
+ 'fileUrl': './node_modules/can-zone/package.json',
+ 'main': 'lib/zone.js',
+ 'steal': {
+ 'npmAlgorithm': 'flat',
+ 'npmDependencies': {
+ 'steal-mocha': true,
+ 'mocha': true,
+ 'chai': true
+ },
+ 'map': { 'can-zone@0.6.0#assert': 'chai/chai' },
+ 'meta': {
+ 'chai/chai': {
+ 'format': 'global',
+ 'exports': 'chai.assert'
+ }
+ }
+ },
+ 'resolutions': {}
+ },
+ {
+ 'name': 'funcunit',
+ 'version': '3.1.0',
+ 'fileUrl': './node_modules/funcunit/package.json',
+ 'main': 'dist/cjs/funcunit.js',
+ 'steal': {
+ 'main': 'funcunit',
+ 'map': { 'chai': 'chai/chai' },
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'steal': true,
+ 'steal-tools': true,
+ 'testee': true
+ }
+ },
+ 'resolutions': {
+ 'funcunit': '3.1.0',
+ 'syn': '0.2.2'
+ }
+ },
+ {
+ 'name': 'jquery',
+ 'version': '2.2.4',
+ 'fileUrl': './node_modules/jquery/package.json',
+ 'main': 'dist/jquery.js',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'jquery-ui',
+ 'version': '1.12.1',
+ 'fileUrl': './node_modules/jquery-ui/package.json',
+ 'main': 'ui/widget.js',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'socket.io-client',
+ 'version': '1.5.1',
+ 'fileUrl': './node_modules/socket.io-client/package.json',
+ 'main': './lib/index',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'steal',
+ 'version': '0.16.42',
+ 'fileUrl': './node_modules/steal/package.json',
+ 'main': 'main',
+ 'steal': { 'npmIgnore': { 'less': true } },
+ 'resolutions': {}
+ },
+ {
+ 'name': 'steal-qunit',
+ 'version': '0.1.4',
+ 'fileUrl': './node_modules/steal-qunit/package.json',
+ 'main': 'steal-qunit',
+ 'steal': {
+ 'npmIgnore': {
+ 'bower': true,
+ 'grunt': true,
+ 'grunt-cli': true,
+ 'grunt-contrib-copy': true,
+ 'grunt-contrib-watch': true,
+ 'steal': true,
+ 'steal-tools': true,
+ 'testee': true
+ },
+ 'meta': {
+ 'qunitjs@1.23.1#qunit/qunit': {
+ 'format': 'global',
+ 'exports': 'QUnit',
+ 'deps': ['steal-qunit/add-dom']
+ }
+ }
+ },
+ 'resolutions': { 'qunitjs': '1.23.1' },
+ 'system': {
+ 'npmIgnore': {
+ 'bower': true,
+ 'grunt': true,
+ 'grunt-cli': true,
+ 'grunt-contrib-copy': true,
+ 'grunt-contrib-watch': true,
+ 'steal': true,
+ 'steal-tools': true,
+ 'testee': true
+ },
+ 'meta': {
+ 'qunitjs@1.23.1#qunit/qunit': {
+ 'format': 'global',
+ 'exports': 'QUnit',
+ 'deps': ['steal-qunit/add-dom']
+ }
+ }
+ }
+ },
+ {
+ 'name': 'steal-stache',
+ 'version': '3.0.1',
+ 'fileUrl': './node_modules/steal-stache/package.json',
+ 'main': 'dist/cjs/steal-stache',
+ 'steal': {
+ 'main': 'steal-stache',
+ 'configDependencies': ['live-reload'],
+ 'npmIgnore': [
+ 'documentjs',
+ 'testee',
+ 'generator-donejs',
+ 'donejs-cli',
+ 'steal-tools'
+ ],
+ 'npmAlgorithm': 'flat',
+ 'ext': { 'stache': 'steal-stache' }
+ },
+ 'browser': {},
+ 'resolutions': {}
+ },
+ {
+ 'name': 'steal-systemjs',
+ 'version': '0.17.5',
+ 'fileUrl': './node_modules/steal-systemjs/package.json',
+ 'main': 'dist/system.src.js',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'system-json',
+ 'version': '0.1.0',
+ 'fileUrl': './node_modules/system-json/package.json',
+ 'main': 'json.js',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'qunitjs',
+ 'version': '1.23.1',
+ 'fileUrl': './node_modules/qunitjs/package.json',
+ 'main': 'qunit/qunit.js',
+ 'resolutions': { 'steal-qunit': '0.1.4' }
+ },
+ {
+ 'name': 'can-legacy-view-helpers',
+ 'version': '0.5.0',
+ 'fileUrl': './node_modules/can-legacy-view-helpers/package.json',
+ 'main': 'dist/cjs/can-legacy-view-helpers',
+ 'steal': {
+ 'npmIgnore': {
+ 'documentjs': true,
+ 'testee': true,
+ 'generator-donejs': true,
+ 'donejs-cli': true,
+ 'steal-tools': true
+ },
+ 'main': 'can-legacy-view-helpers'
+ },
+ 'browser': {},
+ 'resolutions': {
+ 'can-legacy-view-helpers': '0.5.0',
+ 'can-util': '3.0.10',
+ 'can-compute': '3.0.3',
+ 'can-view-callbacks': '3.0.1',
+ 'can-view-parser': '3.0.1',
+ 'can-event': '3.0.1'
+ }
+ },
+ {
+ 'name': 'syn',
+ 'version': '0.2.2',
+ 'fileUrl': './node_modules/syn/package.json',
+ 'main': 'dist/cjs/syn.js',
+ 'steal': {
+ 'directories': { 'lib': 'src' },
+ 'map': {},
+ 'ignoreBrowser': true,
+ 'main': 'syn'
+ },
+ 'resolutions': { 'syn': '0.2.2' }
+ },
+ {
+ 'name': 'can-simple-dom',
+ 'version': '0.4.8',
+ 'fileUrl': './node_modules/can-vdom/node_modules/can-simple-dom/package.json',
+ 'main': 'dist/cjs/simple-dom.js',
+ 'steal': {
+ 'directories': { 'lib': 'lib' },
+ 'npmIgnore': ['testee'],
+ 'main': 'simple-dom.js'
+ },
+ 'resolutions': { 'can-simple-dom': '0.4.8' }
+ },
+ {
+ 'name': 'he',
+ 'version': '1.1.0',
+ 'fileUrl': './node_modules/he/package.json',
+ 'main': 'he.js',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'simple-html-tokenizer',
+ 'version': '0.2.5',
+ 'fileUrl': './node_modules/simple-html-tokenizer/package.json',
+ 'main': 'dist/simple-html-tokenizer.js',
+ 'resolutions': { 'simple-html-tokenizer': '0.2.5' }
+ },
+ {
+ 'name': 'micro-location',
+ 'version': '0.1.5',
+ 'fileUrl': './node_modules/micro-location/package.json',
+ 'main': 'lib/micro-location.js',
+ 'resolutions': {}
+ },
+ {
+ 'name': 'jquery',
+ 'version': '1.11.0',
+ 'fileUrl': './node_modules/funcunit/node_modules/jquery/package.json',
+ 'main': 'dist/jquery.js',
+ 'resolutions': {}
+ }
+ ], { 'npmParentMap': {} }));
+});
+/*can-util@3.0.10#js/assign/assign*/
+define('can-util@3.0.10#js/assign/assign', function (require, exports, module) {
+ module.exports = function (d, s) {
+ for (var prop in s) {
+ d[prop] = s[prop];
+ }
+ return d;
+ };
+});
+/*can-util@3.0.10#js/is-array/is-array*/
+define('can-util@3.0.10#js/is-array/is-array', function (require, exports, module) {
+ module.exports = function (arr) {
+ return Array.isArray(arr);
+ };
+});
+/*can-util@3.0.10#js/is-function/is-function*/
+define('can-util@3.0.10#js/is-function/is-function', function (require, exports, module) {
+ var isFunction = function () {
+ if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') {
+ return function (value) {
+ return Object.prototype.toString.call(value) === '[object Function]';
+ };
+ }
+ return function (value) {
+ return typeof value === 'function';
+ };
+ }();
+ module.exports = isFunction;
+});
+/*can-util@3.0.10#js/is-plain-object/is-plain-object*/
+define('can-util@3.0.10#js/is-plain-object/is-plain-object', function (require, exports, module) {
+ var core_hasOwn = Object.prototype.hasOwnProperty;
+ function isWindow(obj) {
+ return obj !== null && obj == obj.window;
+ }
+ function isPlainObject(obj) {
+ if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) {
+ return false;
+ }
+ try {
+ if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) {
+ return false;
+ }
+ } catch (e) {
+ return false;
+ }
+ var key;
+ for (key in obj) {
+ }
+ return key === undefined || core_hasOwn.call(obj, key);
+ }
+ module.exports = isPlainObject;
+});
+/*can-util@3.0.10#js/deep-assign/deep-assign*/
+define('can-util@3.0.10#js/deep-assign/deep-assign', function (require, exports, module) {
+ var isArray = require('../is-array/is-array');
+ var isFunction = require('../is-function/is-function');
+ var isPlainObject = require('../is-plain-object/is-plain-object');
+ function deepAssign() {
+ var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length;
+ if (typeof target !== 'object' && !isFunction(target)) {
+ target = {};
+ }
+ if (length === i) {
+ target = this;
+ --i;
+ }
+ for (; i < length; i++) {
+ if ((options = arguments[i]) != null) {
+ for (name in options) {
+ src = target[name];
+ copy = options[name];
+ if (target === copy) {
+ continue;
+ }
+ if (copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
+ if (copyIsArray) {
+ copyIsArray = false;
+ clone = src && isArray(src) ? src : [];
+ } else {
+ clone = src && isPlainObject(src) ? src : {};
+ }
+ target[name] = deepAssign(clone, copy);
+ } else if (copy !== undefined) {
+ target[name] = copy;
+ }
+ }
+ }
+ }
+ return target;
+ }
+ module.exports = deepAssign;
+});
+/*can-util@3.0.10#js/dev/dev*/
+define('can-util@3.0.10#js/dev/dev', function (require, exports, module) {
+ module.exports = {
+ warnTimeout: 5000,
+ logLevel: 0,
+ warn: function (out) {
+ },
+ log: function (out) {
+ },
+ _logger: function (type, arr) {
+ }
+ };
+});
+/*can-util@3.0.10#js/is-array-like/is-array-like*/
+define('can-util@3.0.10#js/is-array-like/is-array-like', function (require, exports, module) {
+ function isArrayLike(obj) {
+ var type = typeof obj;
+ if (type === 'string') {
+ return true;
+ }
+ var length = obj && type !== 'boolean' && typeof obj !== 'number' && 'length' in obj && obj.length;
+ return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj);
+ }
+ module.exports = isArrayLike;
+});
+/*can-util@3.0.10#js/is-promise/is-promise*/
+define('can-util@3.0.10#js/is-promise/is-promise', function (require, exports, module) {
+ module.exports = function (obj) {
+ return obj instanceof Promise || Object.prototype.toString.call(obj) === '[object Promise]';
+ };
+});
+/*can-util@3.0.10#js/types/types*/
+define('can-util@3.0.10#js/types/types', function (require, exports, module) {
+ var isPromise = require('../is-promise/is-promise');
+ var types = {
+ isMapLike: function () {
+ return false;
+ },
+ isListLike: function () {
+ return false;
+ },
+ isPromise: function (obj) {
+ return isPromise(obj);
+ },
+ isConstructor: function (func) {
+ if (typeof func !== 'function') {
+ return false;
+ }
+ for (var prop in func.prototype) {
+ return true;
+ }
+ return false;
+ },
+ isCallableForValue: function (obj) {
+ return typeof obj === 'function' && !types.isConstructor(obj);
+ },
+ isCompute: function (obj) {
+ return obj && obj.isComputed;
+ },
+ iterator: typeof Symbol === 'function' && Symbol.iterator || '@@iterator',
+ DefaultMap: null,
+ DefaultList: null,
+ queueTask: function (task) {
+ var args = task[2] || [];
+ task[0].apply(task[1], args);
+ },
+ wrapElement: function (element) {
+ return element;
+ },
+ unwrapElement: function (element) {
+ return element;
+ }
+ };
+ module.exports = types;
+});
+/*can-util@3.0.10#js/is-iterable/is-iterable*/
+define('can-util@3.0.10#js/is-iterable/is-iterable', function (require, exports, module) {
+ var types = require('../types/types');
+ module.exports = function (obj) {
+ return obj && !!obj[types.iterator];
+ };
+});
+/*can-util@3.0.10#js/each/each*/
+define('can-util@3.0.10#js/each/each', function (require, exports, module) {
+ var isArrayLike = require('../is-array-like/is-array-like');
+ var has = Object.prototype.hasOwnProperty;
+ var isIterable = require('../is-iterable/is-iterable');
+ var types = require('../types/types');
+ function each(elements, callback, context) {
+ var i = 0, key, len, item;
+ if (elements) {
+ if (isArrayLike(elements)) {
+ for (len = elements.length; i < len; i++) {
+ item = elements[i];
+ if (callback.call(context || item, item, i, elements) === false) {
+ break;
+ }
+ }
+ } else if (isIterable(elements)) {
+ var iter = elements[types.iterator]();
+ var res, value;
+ while (!(res = iter.next()).done) {
+ value = res.value;
+ callback.call(context || elements, Array.isArray(value) ? value[1] : value, value[0]);
+ }
+ } else if (typeof elements === 'object') {
+ for (key in elements) {
+ if (has.call(elements, key) && callback.call(context || elements[key], elements[key], key, elements) === false) {
+ break;
+ }
+ }
+ }
+ }
+ return elements;
+ }
+ module.exports = each;
+});
+/*can-util@3.0.10#js/make-array/make-array*/
+define('can-util@3.0.10#js/make-array/make-array', function (require, exports, module) {
+ var each = require('../each/each');
+ function makeArray(arr) {
+ var ret = [];
+ each(arr, function (a, i) {
+ ret[i] = a;
+ });
+ return ret;
+ }
+ module.exports = makeArray;
+});
+/*can-util@3.0.10#namespace*/
+define('can-util@3.0.10#namespace', function (require, exports, module) {
+ module.exports = {};
+});
+/*can-util@3.0.10#js/is-container/is-container*/
+define('can-util@3.0.10#js/is-container/is-container', function (require, exports, module) {
+ module.exports = function (current) {
+ return /^f|^o/.test(typeof current);
+ };
+});
+/*can-util@3.0.10#js/get/get*/
+define('can-util@3.0.10#js/get/get', function (require, exports, module) {
+ var isContainer = require('../is-container/is-container');
+ function get(obj, name) {
+ var parts = typeof name !== 'undefined' ? (name + '').replace(/\[/g, '.').replace(/]/g, '').split('.') : [], length = parts.length, current, i, container;
+ if (!length) {
+ return obj;
+ }
+ current = obj;
+ for (i = 0; i < length && isContainer(current); i++) {
+ container = current;
+ current = container[parts[i]];
+ }
+ return current;
+ }
+ module.exports = get;
+});
+/*can-util@3.0.10#js/string/string*/
+define('can-util@3.0.10#js/string/string', function (require, exports, module) {
+ var get = require('../get/get');
+ var isContainer = require('../is-container/is-container');
+ var canDev = require('../dev/dev');
+ var isArray = require('../is-array/is-array');
+ var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, convertBadValues = function (content) {
+ var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN';
+ return '' + (isInvalid ? '' : content);
+ }, deleteAtPath = function (data, path) {
+ var parts = path ? path.replace(/\[/g, '.').replace(/]/g, '').split('.') : [];
+ var current = data;
+ for (var i = 0; i < parts.length - 1; i++) {
+ if (current) {
+ current = current[parts[i]];
+ }
+ }
+ if (current) {
+ delete current[parts[parts.length - 1]];
+ }
+ };
+ var string = {
+ esc: function (content) {
+ return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, ''');
+ },
+ getObject: function (name, roots) {
+ roots = isArray(roots) ? roots : [roots || window];
+ var result, l = roots.length;
+ for (var i = 0; i < l; i++) {
+ result = get(roots[i], name);
+ if (result) {
+ return result;
+ }
+ }
+ },
+ capitalize: function (s, cache) {
+ return s.charAt(0).toUpperCase() + s.slice(1);
+ },
+ camelize: function (str) {
+ return convertBadValues(str).replace(strHyphenMatch, function (match, chr) {
+ return chr ? chr.toUpperCase() : '';
+ });
+ },
+ hyphenate: function (str) {
+ return convertBadValues(str).replace(strCamelMatch, function (str, offset) {
+ return str.charAt(0) + '-' + str.charAt(1).toLowerCase();
+ });
+ },
+ underscore: function (s) {
+ return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase();
+ },
+ sub: function (str, data, remove) {
+ var obs = [];
+ str = str || '';
+ obs.push(str.replace(strReplacer, function (whole, inside) {
+ var ob = get(data, inside);
+ if (remove === true) {
+ deleteAtPath(data, inside);
+ }
+ if (ob === undefined || ob === null) {
+ obs = null;
+ return '';
+ }
+ if (isContainer(ob) && obs) {
+ obs.push(ob);
+ return '';
+ }
+ return '' + ob;
+ }));
+ return obs === null ? obs : obs.length <= 1 ? obs[0] : obs;
+ },
+ replacer: strReplacer,
+ undHash: strUndHash
+ };
+ module.exports = string;
+});
+/*can-construct@3.0.3#can-construct*/
+define('can-construct@3.0.3#can-construct', function (require, exports, module) {
+ 'use strict';
+ var assign = require('can-util/js/assign/assign');
+ var deepAssign = require('can-util/js/deep-assign/deep-assign');
+ var dev = require('can-util/js/dev/dev');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var types = require('can-util/js/types/types');
+ var namespace = require('can-util/namespace');
+ var initializing = 0;
+ var Construct = function () {
+ if (arguments.length) {
+ return Construct.extend.apply(Construct, arguments);
+ }
+ };
+ var canGetDescriptor;
+ try {
+ Object.getOwnPropertyDescriptor({});
+ canGetDescriptor = true;
+ } catch (e) {
+ canGetDescriptor = false;
+ }
+ var getDescriptor = function (newProps, name) {
+ var descriptor = Object.getOwnPropertyDescriptor(newProps, name);
+ if (descriptor && (descriptor.get || descriptor.set)) {
+ return descriptor;
+ }
+ return null;
+ }, inheritGetterSetter = function (newProps, oldProps, addTo) {
+ addTo = addTo || newProps;
+ var descriptor;
+ for (var name in newProps) {
+ if (descriptor = getDescriptor(newProps, name)) {
+ this._defineProperty(addTo, oldProps, name, descriptor);
+ } else {
+ Construct._overwrite(addTo, oldProps, name, newProps[name]);
+ }
+ }
+ }, simpleInherit = function (newProps, oldProps, addTo) {
+ addTo = addTo || newProps;
+ for (var name in newProps) {
+ Construct._overwrite(addTo, oldProps, name, newProps[name]);
+ }
+ };
+ assign(Construct, {
+ constructorExtends: true,
+ newInstance: function () {
+ var inst = this.instance(), args;
+ if (inst.setup) {
+ Object.defineProperty(inst, '__inSetup', {
+ configurable: true,
+ enumerable: false,
+ value: true,
+ writable: true
+ });
+ args = inst.setup.apply(inst, arguments);
+ inst.__inSetup = false;
+ }
+ if (inst.init) {
+ inst.init.apply(inst, args || arguments);
+ }
+ return inst;
+ },
+ _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit,
+ _defineProperty: function (what, oldProps, propName, descriptor) {
+ Object.defineProperty(what, propName, descriptor);
+ },
+ _overwrite: function (what, oldProps, propName, val) {
+ what[propName] = val;
+ },
+ setup: function (base) {
+ this.defaults = deepAssign(true, {}, base.defaults, this.defaults);
+ },
+ instance: function () {
+ initializing = 1;
+ var inst = new this();
+ initializing = 0;
+ return inst;
+ },
+ extend: function (name, staticProperties, instanceProperties) {
+ var shortName = name, klass = staticProperties, proto = instanceProperties;
+ if (typeof shortName !== 'string') {
+ proto = klass;
+ klass = shortName;
+ shortName = null;
+ }
+ if (!proto) {
+ proto = klass;
+ klass = null;
+ }
+ proto = proto || {};
+ var _super_class = this, _super = this.prototype, Constructor, prototype;
+ prototype = this.instance();
+ Construct._inherit(proto, _super, prototype);
+ if (shortName) {
+ } else if (klass && klass.shortName) {
+ shortName = klass.shortName;
+ } else if (this.shortName) {
+ shortName = this.shortName;
+ }
+ function init() {
+ if (!initializing) {
+ return (!this || this.constructor !== Constructor) && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments);
+ }
+ }
+ Constructor = typeof namedCtor === 'function' ? namedCtor(constructorName, init) : function () {
+ return init.apply(this, arguments);
+ };
+ for (var propName in _super_class) {
+ if (_super_class.hasOwnProperty(propName)) {
+ Constructor[propName] = _super_class[propName];
+ }
+ }
+ Construct._inherit(klass, _super_class, Constructor);
+ assign(Constructor, {
+ constructor: Constructor,
+ prototype: prototype
+ });
+ if (shortName !== undefined) {
+ Constructor.shortName = shortName;
+ }
+ Constructor.prototype.constructor = Constructor;
+ var t = [_super_class].concat(makeArray(arguments)), args = Constructor.setup.apply(Constructor, t);
+ if (Constructor.init) {
+ Constructor.init.apply(Constructor, args || t);
+ }
+ return Constructor;
+ }
+ });
+ Construct.prototype.setup = function () {
+ };
+ Construct.prototype.init = function () {
+ };
+ var oldIsConstructor = types.isConstructor;
+ types.isConstructor = function (obj) {
+ return obj.prototype instanceof Construct || oldIsConstructor.call(null, obj);
+ };
+ module.exports = namespace.Construct = Construct;
+});
+/*can-util@3.0.10#js/is-empty-object/is-empty-object*/
+define('can-util@3.0.10#js/is-empty-object/is-empty-object', function (require, exports, module) {
+ module.exports = function (obj) {
+ for (var prop in obj) {
+ return false;
+ }
+ return true;
+ };
+});
+/*can-util@3.0.10#dom/data/data*/
+define('can-util@3.0.10#dom/data/data', function (require, exports, module) {
+ var isEmptyObject = require('../../js/is-empty-object/is-empty-object');
+ var data = {};
+ var expando = 'can' + new Date();
+ var uuid = 0;
+ var setData = function (name, value) {
+ var id = this[expando] || (this[expando] = ++uuid), store = data[id] || (data[id] = {});
+ if (name !== undefined) {
+ store[name] = value;
+ }
+ return store;
+ };
+ module.exports = {
+ getCid: function () {
+ return this[expando];
+ },
+ cid: function () {
+ return this[expando] || (this[expando] = ++uuid);
+ },
+ expando: expando,
+ clean: function (prop) {
+ var id = this[expando];
+ if (data[id] && data[id][prop]) {
+ delete data[id][prop];
+ }
+ if (isEmptyObject(data[id])) {
+ delete data[id];
+ }
+ },
+ get: function (key) {
+ var id = this[expando], store = id && data[id];
+ return key === undefined ? store || setData(this) : store && store[key];
+ },
+ set: setData
+ };
+});
+/*can-util@3.0.10#dom/class-name/class-name*/
+define('can-util@3.0.10#dom/class-name/class-name', function (require, exports, module) {
+ var has = function (className) {
+ if (this.classList) {
+ return this.classList.contains(className);
+ } else {
+ return !!this.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
+ }
+ };
+ module.exports = {
+ has: has,
+ add: function (className) {
+ if (this.classList) {
+ this.classList.add(className);
+ } else if (!has.call(this, className)) {
+ this.className += ' ' + className;
+ }
+ },
+ remove: function (className) {
+ if (this.classList) {
+ this.classList.remove(className);
+ } else if (has.call(this, className)) {
+ var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
+ this.className = this.className.replace(reg, ' ');
+ }
+ }
+ };
+});
+/*can-util@3.0.10#js/global/global*/
+define('can-util@3.0.10#js/global/global', function (require, exports, module) {
+ var GLOBAL;
+ module.exports = function (setGlobal) {
+ if (setGlobal !== undefined) {
+ GLOBAL = setGlobal;
+ }
+ if (GLOBAL) {
+ return GLOBAL;
+ } else {
+ return GLOBAL = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : typeof process === 'object' && {}.toString.call(process) === '[object process]' ? global : window;
+ }
+ };
+});
+/*can-util@3.0.10#dom/document/document*/
+define('can-util@3.0.10#dom/document/document', function (require, exports, module) {
+ var global = require('../../js/global/global');
+ var setDocument;
+ module.exports = function (setDoc) {
+ if (setDoc) {
+ setDocument = setDoc;
+ }
+ return setDocument || global().document;
+ };
+});
+/*can-util@3.0.10#dom/events/events*/
+define('can-util@3.0.10#dom/events/events', function (require, exports, module) {
+ var assign = require('../../js/assign/assign');
+ var _document = require('../document/document');
+ module.exports = {
+ addEventListener: function () {
+ this.addEventListener.apply(this, arguments);
+ },
+ removeEventListener: function () {
+ this.removeEventListener.apply(this, arguments);
+ },
+ canAddEventListener: function () {
+ return this.nodeName && (this.nodeType === 1 || this.nodeType === 9) || this === window;
+ },
+ dispatch: function (event, args, bubbles) {
+ var doc = _document();
+ var ev = doc.createEvent('HTMLEvents');
+ var isString = typeof event === 'string';
+ ev.initEvent(isString ? event : event.type, bubbles === undefined ? true : bubbles, false);
+ if (!isString) {
+ assign(ev, event);
+ }
+ ev.args = args;
+ return this.dispatchEvent(ev);
+ }
+ };
+});
+/*can-util@3.0.10#js/cid/cid*/
+define('can-util@3.0.10#js/cid/cid', function (require, exports, module) {
+ var cid = 0;
+ module.exports = function (object, name) {
+ if (!object._cid) {
+ cid++;
+ object._cid = (name || '') + cid;
+ }
+ return object._cid;
+ };
+});
+/*can-util@3.0.10#dom/dispatch/dispatch*/
+define('can-util@3.0.10#dom/dispatch/dispatch', function (require, exports, module) {
+ var domEvents = require('../events/events');
+ module.exports = function () {
+ return domEvents.dispatch.apply(this, arguments);
+ };
+});
+/*can-util@3.0.10#dom/matches/matches*/
+define('can-util@3.0.10#dom/matches/matches', function (require, exports, module) {
+ var matchesMethod = function (element) {
+ return element.matches || element.webkitMatchesSelector || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || element.oMatchesSelector;
+ };
+ module.exports = function () {
+ var method = matchesMethod(this);
+ return method ? method.apply(this, arguments) : false;
+ };
+});
+/*can-util@3.0.10#dom/events/delegate/delegate*/
+define('can-util@3.0.10#dom/events/delegate/delegate', function (require, exports, module) {
+ var domEvents = require('../events');
+ var domData = require('../../data/data');
+ var domMatches = require('../../matches/matches');
+ var each = require('../../../js/each/each');
+ var isEmptyObject = require('../../../js/is-empty-object/is-empty-object');
+ var dataName = 'delegateEvents';
+ var useCapture = function (eventType) {
+ return eventType === 'focus' || eventType === 'blur';
+ };
+ var handleEvent = function (ev) {
+ var events = domData.get.call(this, dataName);
+ var eventTypeEvents = events[ev.type];
+ var matches = [];
+ if (eventTypeEvents) {
+ var selectorDelegates = [];
+ each(eventTypeEvents, function (delegates) {
+ selectorDelegates.push(delegates);
+ });
+ var cur = ev.target;
+ do {
+ selectorDelegates.forEach(function (delegates) {
+ if (domMatches.call(cur, delegates[0].selector)) {
+ matches.push({
+ target: cur,
+ delegates: delegates
+ });
+ }
+ });
+ cur = cur.parentNode;
+ } while (cur && cur !== ev.currentTarget);
+ }
+ var oldStopProp = ev.stopPropagation;
+ ev.stopPropagation = function () {
+ oldStopProp.apply(this, arguments);
+ this.cancelBubble = true;
+ };
+ for (var i = 0; i < matches.length; i++) {
+ var match = matches[i];
+ var delegates = match.delegates;
+ for (var d = 0, dLen = delegates.length; d < dLen; d++) {
+ if (delegates[d].handler.call(match.target, ev) === false) {
+ return false;
+ }
+ if (ev.cancelBubble) {
+ return;
+ }
+ }
+ }
+ };
+ domEvents.addDelegateListener = function (eventType, selector, handler) {
+ var events = domData.get.call(this, dataName), eventTypeEvents;
+ if (!events) {
+ domData.set.call(this, dataName, events = {});
+ }
+ if (!(eventTypeEvents = events[eventType])) {
+ eventTypeEvents = events[eventType] = {};
+ domEvents.addEventListener.call(this, eventType, handleEvent, useCapture(eventType));
+ }
+ if (!eventTypeEvents[selector]) {
+ eventTypeEvents[selector] = [];
+ }
+ eventTypeEvents[selector].push({
+ handler: handler,
+ selector: selector
+ });
+ };
+ domEvents.removeDelegateListener = function (eventType, selector, handler) {
+ var events = domData.get.call(this, dataName);
+ if (events[eventType] && events[eventType][selector]) {
+ var eventTypeEvents = events[eventType], delegates = eventTypeEvents[selector], i = 0;
+ while (i < delegates.length) {
+ if (delegates[i].handler === handler) {
+ delegates.splice(i, 1);
+ } else {
+ i++;
+ }
+ }
+ if (delegates.length === 0) {
+ delete eventTypeEvents[selector];
+ if (isEmptyObject(eventTypeEvents)) {
+ domEvents.removeEventListener.call(this, eventType, handleEvent, useCapture(eventType));
+ delete events[eventType];
+ if (isEmptyObject(events)) {
+ domData.clean.call(this, dataName);
+ }
+ }
+ }
+ }
+ };
+});
+/*can-event@3.0.1#can-event*/
+define('can-event@3.0.1#can-event', function (require, exports, module) {
+ var domEvents = require('can-util/dom/events/events');
+ var CID = require('can-util/js/cid/cid');
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ var domDispatch = require('can-util/dom/dispatch/dispatch');
+ var namespace = require('can-util/namespace');
+ require('can-util/dom/events/delegate/delegate');
+ function makeHandlerArgs(event, args) {
+ if (typeof event === 'string') {
+ event = { type: event };
+ }
+ var handlerArgs = [event];
+ if (args) {
+ handlerArgs.push.apply(handlerArgs, args);
+ }
+ return handlerArgs;
+ }
+ function getHandlers(eventName) {
+ var events = this.__bindEvents;
+ if (!events) {
+ return;
+ }
+ var handlers = events[eventName];
+ if (!handlers) {
+ return;
+ } else {
+ return handlers;
+ }
+ }
+ var canEvent = {
+ addEventListener: function (event, handler) {
+ var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []);
+ eventList.push(handler);
+ return this;
+ },
+ removeEventListener: function (event, fn) {
+ if (!this.__bindEvents) {
+ return this;
+ }
+ var handlers = this.__bindEvents[event] || [], i = 0, handler, isFunction = typeof fn === 'function';
+ while (i < handlers.length) {
+ handler = handlers[i];
+ if (isFunction && handler === fn || !isFunction && (handler.cid === fn || !fn)) {
+ handlers.splice(i, 1);
+ } else {
+ i++;
+ }
+ }
+ return this;
+ },
+ dispatchSync: function (event, args) {
+ var handlerArgs = makeHandlerArgs(event, args);
+ var handlers = getHandlers.call(this, handlerArgs[0].type);
+ if (!handlers) {
+ return;
+ }
+ handlers = handlers.slice(0);
+ for (var i = 0, len = handlers.length; i < len; i++) {
+ handlers[i].apply(this, handlerArgs);
+ }
+ return handlerArgs[0];
+ },
+ on: function (eventName, selector, handler) {
+ var method = typeof selector === 'string' ? 'addDelegateListener' : 'addEventListener';
+ var listenWithDOM = domEvents.canAddEventListener.call(this);
+ var eventBinder = listenWithDOM ? domEvents[method] : this[method] || canEvent[method];
+ return eventBinder.apply(this, arguments);
+ },
+ off: function (eventName, selector, handler) {
+ var method = typeof selector === 'string' ? 'removeDelegateListener' : 'removeEventListener';
+ var listenWithDOM = domEvents.canAddEventListener.call(this);
+ var eventBinder = listenWithDOM ? domEvents[method] : this[method] || canEvent[method];
+ return eventBinder.apply(this, arguments);
+ },
+ trigger: function () {
+ var listenWithDOM = domEvents.canAddEventListener.call(this);
+ var dispatch = listenWithDOM ? domDispatch : canEvent.dispatch;
+ return dispatch.apply(this, arguments);
+ },
+ one: function (event, handler) {
+ var one = function () {
+ canEvent.off.call(this, event, one);
+ return handler.apply(this, arguments);
+ };
+ canEvent.on.call(this, event, one);
+ return this;
+ },
+ listenTo: function (other, event, handler) {
+ var idedEvents = this.__listenToEvents;
+ if (!idedEvents) {
+ idedEvents = this.__listenToEvents = {};
+ }
+ var otherId = CID(other);
+ var othersEvents = idedEvents[otherId];
+ if (!othersEvents) {
+ othersEvents = idedEvents[otherId] = {
+ obj: other,
+ events: {}
+ };
+ }
+ var eventsEvents = othersEvents.events[event];
+ if (!eventsEvents) {
+ eventsEvents = othersEvents.events[event] = [];
+ }
+ eventsEvents.push(handler);
+ canEvent.on.call(other, event, handler);
+ },
+ stopListening: function (other, event, handler) {
+ var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0;
+ if (!idedEvents) {
+ return this;
+ }
+ if (other) {
+ var othercid = CID(other);
+ (iterIdedEvents = {})[othercid] = idedEvents[othercid];
+ if (!idedEvents[othercid]) {
+ return this;
+ }
+ }
+ for (var cid in iterIdedEvents) {
+ var othersEvents = iterIdedEvents[cid], eventsEvents;
+ other = idedEvents[cid].obj;
+ if (!event) {
+ eventsEvents = othersEvents.events;
+ } else {
+ (eventsEvents = {})[event] = othersEvents.events[event];
+ }
+ for (var eventName in eventsEvents) {
+ var handlers = eventsEvents[eventName] || [];
+ i = 0;
+ while (i < handlers.length) {
+ if (handler && handler === handlers[i] || !handler) {
+ canEvent.off.call(other, eventName, handlers[i]);
+ handlers.splice(i, 1);
+ } else {
+ i++;
+ }
+ }
+ if (!handlers.length) {
+ delete othersEvents.events[eventName];
+ }
+ }
+ if (isEmptyObject(othersEvents.events)) {
+ delete idedEvents[cid];
+ }
+ }
+ return this;
+ }
+ };
+ canEvent.addEvent = canEvent.bind = function () {
+ return canEvent.addEventListener.apply(this, arguments);
+ };
+ canEvent.unbind = canEvent.removeEvent = function () {
+ return canEvent.removeEventListener.apply(this, arguments);
+ };
+ canEvent.delegate = canEvent.on;
+ canEvent.undelegate = canEvent.off;
+ canEvent.dispatch = canEvent.dispatchSync;
+ Object.defineProperty(canEvent, 'makeHandlerArgs', {
+ enumerable: false,
+ value: makeHandlerArgs
+ });
+ Object.defineProperty(canEvent, 'handlers', {
+ enumerable: false,
+ value: getHandlers
+ });
+ Object.defineProperty(canEvent, 'flush', {
+ enumerable: false,
+ writable: true,
+ value: function () {
+ }
+ });
+ module.exports = namespace.event = canEvent;
+});
+/*can-util@3.0.10#js/last/last*/
+define('can-util@3.0.10#js/last/last', function (require, exports, module) {
+ module.exports = function (arr) {
+ return arr && arr[arr.length - 1];
+ };
+});
+/*can-event@3.0.1#batch/batch*/
+define('can-event@3.0.1#batch/batch', function (require, exports, module) {
+ 'use strict';
+ var canEvent = require('../can-event');
+ var last = require('can-util/js/last/last');
+ var namespace = require('can-util/namespace');
+ var canTypes = require('can-util/js/types/types');
+ var canDev = require('can-util/js/dev/dev');
+ var batchNum = 1, collectionQueue = null, queues = [], dispatchingQueues = false, makeHandlerArgs = canEvent.makeHandlerArgs, getHandlers = canEvent.handlers;
+ function addToCollectionQueue(item, event, args, handlers) {
+ var handlerArgs = makeHandlerArgs(event, args);
+ var tasks = [];
+ for (var i = 0, len = handlers.length; i < len; i++) {
+ tasks[i] = [
+ handlers[i],
+ item,
+ handlerArgs
+ ];
+ }
+ [].push.apply(collectionQueue.tasks, tasks);
+ }
+ var canBatch = {
+ transactions: 0,
+ start: function (batchStopHandler) {
+ canBatch.transactions++;
+ if (canBatch.transactions === 1) {
+ var queue = {
+ number: batchNum++,
+ index: 0,
+ tasks: [],
+ batchEnded: false,
+ callbacksIndex: 0,
+ callbacks: [],
+ complete: false
+ };
+ if (batchStopHandler) {
+ queue.callbacks.push(batchStopHandler);
+ }
+ collectionQueue = queue;
+ }
+ },
+ collecting: function () {
+ return collectionQueue;
+ },
+ dispatching: function () {
+ return queues[0];
+ },
+ stop: function (force, callStart) {
+ if (force) {
+ canBatch.transactions = 0;
+ } else {
+ canBatch.transactions--;
+ }
+ if (canBatch.transactions === 0) {
+ queues.push(collectionQueue);
+ collectionQueue = null;
+ if (!dispatchingQueues) {
+ canEvent.flush();
+ }
+ }
+ },
+ flush: function () {
+ dispatchingQueues = true;
+ while (queues.length) {
+ var queue = queues[0];
+ var tasks = queue.tasks, callbacks = queue.callbacks;
+ canBatch.batchNum = queue.number;
+ var len = tasks.length, index;
+ while (queue.index < len) {
+ index = queue.index++;
+ tasks[index][0].apply(tasks[index][1], tasks[index][2]);
+ }
+ if (!queue.batchEnded) {
+ queue.batchEnded = true;
+ canEvent.dispatchSync.call(canBatch, 'batchEnd', [queue.number]);
+ }
+ while (queue.callbacksIndex < callbacks.length) {
+ callbacks[queue.callbacksIndex++]();
+ }
+ if (!queue.complete) {
+ queue.complete = true;
+ canBatch.batchNum = undefined;
+ queues.shift();
+ }
+ }
+ dispatchingQueues = false;
+ },
+ dispatch: function (event, args) {
+ var item = this, handlers;
+ if (!item.__inSetup) {
+ event = typeof event === 'string' ? { type: event } : event;
+ if (event.batchNum) {
+ canEvent.dispatchSync.call(item, event, args);
+ } else if (collectionQueue) {
+ handlers = getHandlers.call(this, event.type);
+ if (handlers) {
+ event.batchNum = collectionQueue.number;
+ addToCollectionQueue(item, event, args, handlers);
+ }
+ } else if (queues.length) {
+ handlers = getHandlers.call(this, event.type);
+ if (handlers) {
+ canBatch.start();
+ event.batchNum = collectionQueue.number;
+ addToCollectionQueue(item, event, args, handlers);
+ last(queues).callbacks.push(canBatch.stop);
+ }
+ } else {
+ handlers = getHandlers.call(this, event.type);
+ if (handlers) {
+ canBatch.start();
+ event.batchNum = collectionQueue.number;
+ addToCollectionQueue(item, event, args, handlers);
+ canBatch.stop();
+ }
+ }
+ }
+ },
+ queue: function (task, inCurrentBatch) {
+ if (collectionQueue) {
+ collectionQueue.tasks.push(task);
+ } else if (queues.length) {
+ if (inCurrentBatch && queues[0].index < queues.tasks.length) {
+ queues[0].tasks.push(task);
+ } else {
+ canBatch.start();
+ collectionQueue.tasks.push(task);
+ last(queues).callbacks.push(canBatch.stop);
+ }
+ } else {
+ canBatch.start();
+ collectionQueue.tasks.push(task);
+ canBatch.stop();
+ }
+ },
+ queues: function () {
+ return queues;
+ },
+ afterPreviousEvents: function (handler) {
+ this.queue([handler]);
+ },
+ after: function (handler) {
+ var queue = collectionQueue || queues[0];
+ if (queue) {
+ queue.callbacks.push(handler);
+ } else {
+ handler({});
+ }
+ }
+ };
+ canEvent.flush = canBatch.flush;
+ canEvent.dispatch = canBatch.dispatch;
+ canBatch.trigger = function () {
+ console.warn('use canEvent.dispatch instead');
+ return canEvent.dispatch.apply(this, arguments);
+ };
+ canTypes.queueTask = canBatch.queue;
+ module.exports = namespace.batch = canBatch;
+});
+/*can-observation@3.0.2#can-observation*/
+define('can-observation@3.0.2#can-observation', function (require, exports, module) {
+ require('can-event');
+ var canEvent = require('can-event');
+ var canBatch = require('can-event/batch/batch');
+ var assign = require('can-util/js/assign/assign');
+ var namespace = require('can-util/namespace');
+ var remaining = {
+ updates: 0,
+ notifications: 0
+ };
+ function Observation(func, context, compute) {
+ this.newObserved = {};
+ this.oldObserved = null;
+ this.func = func;
+ this.context = context;
+ this.compute = compute.updater ? compute : { updater: compute };
+ this.onDependencyChange = this.onDependencyChange.bind(this);
+ this.childDepths = {};
+ this.ignore = 0;
+ this.needsUpdate = false;
+ }
+ var observationStack = [];
+ assign(Observation.prototype, {
+ get: function () {
+ if (this.bound) {
+ canEvent.flush();
+ if (remaining.updates) {
+ Observation.updateChildrenAndSelf(this);
+ }
+ return this.value;
+ } else {
+ return this.func.call(this.context);
+ }
+ },
+ getPrimaryDepth: function () {
+ return this.compute._primaryDepth || 0;
+ },
+ addEdge: function (objEv) {
+ objEv.obj.addEventListener(objEv.event, this.onDependencyChange);
+ if (objEv.obj.observation) {
+ this.depth = null;
+ }
+ },
+ removeEdge: function (objEv) {
+ objEv.obj.removeEventListener(objEv.event, this.onDependencyChange);
+ if (objEv.obj.observation) {
+ this.depth = null;
+ }
+ },
+ dependencyChange: function (ev) {
+ if (this.bound) {
+ if (ev.batchNum !== this.batchNum) {
+ Observation.registerUpdate(this, ev.batchNum);
+ this.batchNum = ev.batchNum;
+ }
+ }
+ },
+ onDependencyChange: function (ev, newVal, oldVal) {
+ this.dependencyChange(ev, newVal, oldVal);
+ },
+ update: function (batchNum) {
+ if (this.needsUpdate) {
+ remaining.updates--;
+ }
+ this.needsUpdate = false;
+ if (this.bound) {
+ var oldValue = this.value;
+ this.oldValue = null;
+ this.start();
+ if (oldValue !== this.value) {
+ this.compute.updater(this.value, oldValue, batchNum);
+ return true;
+ }
+ }
+ },
+ getValueAndBind: function () {
+ console.warn('can-observation: call start instead of getValueAndBind');
+ return this.start();
+ },
+ start: function () {
+ this.bound = true;
+ this.oldObserved = this.newObserved || {};
+ this.ignore = 0;
+ this.newObserved = {};
+ observationStack.push(this);
+ this.value = this.func.call(this.context);
+ observationStack.pop();
+ this.updateBindings();
+ },
+ updateBindings: function () {
+ var newObserved = this.newObserved, oldObserved = this.oldObserved, name, obEv;
+ for (name in newObserved) {
+ obEv = newObserved[name];
+ if (!oldObserved[name]) {
+ this.addEdge(obEv);
+ } else {
+ oldObserved[name] = null;
+ }
+ }
+ for (name in oldObserved) {
+ obEv = oldObserved[name];
+ if (obEv) {
+ this.removeEdge(obEv);
+ }
+ }
+ },
+ teardown: function () {
+ console.warn('can-observation: call stop instead of teardown');
+ return this.stop();
+ },
+ stop: function () {
+ this.bound = false;
+ for (var name in this.newObserved) {
+ var ob = this.newObserved[name];
+ this.removeEdge(ob);
+ }
+ this.newObserved = {};
+ }
+ });
+ var updateOrder = [], curPrimaryDepth = Infinity, maxPrimaryDepth = 0, currentBatchNum, isUpdating = false;
+ var updateUpdateOrder = function (observation) {
+ var primaryDepth = observation.getPrimaryDepth();
+ if (primaryDepth < curPrimaryDepth) {
+ curPrimaryDepth = primaryDepth;
+ }
+ if (primaryDepth > maxPrimaryDepth) {
+ maxPrimaryDepth = primaryDepth;
+ }
+ var primary = updateOrder[primaryDepth] || (updateOrder[primaryDepth] = []);
+ return primary;
+ };
+ Observation.registerUpdate = function (observation, batchNum) {
+ if (observation.needsUpdate) {
+ return;
+ }
+ remaining.updates++;
+ observation.needsUpdate = true;
+ var objs = updateUpdateOrder(observation);
+ objs.push(observation);
+ };
+ var afterCallbacks = [];
+ Observation.updateAndNotify = function (ev, batchNum) {
+ currentBatchNum = batchNum;
+ if (isUpdating) {
+ return;
+ }
+ isUpdating = true;
+ while (true) {
+ if (curPrimaryDepth <= maxPrimaryDepth) {
+ var primary = updateOrder[curPrimaryDepth];
+ var lastUpdate = primary && primary.pop();
+ if (lastUpdate) {
+ lastUpdate.update(currentBatchNum);
+ } else {
+ curPrimaryDepth++;
+ }
+ } else {
+ updateOrder = [];
+ curPrimaryDepth = Infinity;
+ maxPrimaryDepth = 0;
+ isUpdating = false;
+ var afterCB = afterCallbacks;
+ afterCallbacks = [];
+ afterCB.forEach(function (cb) {
+ cb();
+ });
+ return;
+ }
+ }
+ };
+ canEvent.addEventListener.call(canBatch, 'batchEnd', Observation.updateAndNotify);
+ Observation.afterUpdateAndNotify = function (callback) {
+ canBatch.after(function () {
+ if (isUpdating) {
+ afterCallbacks.push(callback);
+ } else {
+ callback();
+ }
+ });
+ };
+ Observation.updateChildrenAndSelf = function (observation) {
+ if (observation.needsUpdate) {
+ return Observation.unregisterAndUpdate(observation);
+ }
+ var childHasChanged;
+ for (var prop in observation.newObserved) {
+ if (observation.newObserved[prop].obj.observation) {
+ if (Observation.updateChildrenAndSelf(observation.newObserved[prop].obj.observation)) {
+ childHasChanged = true;
+ }
+ }
+ }
+ if (childHasChanged) {
+ return observation.update(currentBatchNum);
+ }
+ };
+ Observation.unregisterAndUpdate = function (observation) {
+ var primaryDepth = observation.getPrimaryDepth();
+ var primary = updateOrder[primaryDepth];
+ if (primary) {
+ var index = primary.indexOf(observation);
+ if (index !== -1) {
+ primary.splice(index, 1);
+ }
+ }
+ return observation.update(currentBatchNum);
+ };
+ Observation.add = function (obj, event) {
+ var top = observationStack[observationStack.length - 1];
+ if (top && !top.ignore) {
+ var evStr = event + '', name = obj._cid + '|' + evStr;
+ if (top.traps) {
+ top.traps.push({
+ obj: obj,
+ event: evStr,
+ name: name
+ });
+ } else {
+ top.newObserved[name] = {
+ obj: obj,
+ event: evStr
+ };
+ }
+ }
+ };
+ Observation.addAll = function (observes) {
+ var top = observationStack[observationStack.length - 1];
+ if (top) {
+ if (top.traps) {
+ top.traps.push.apply(top.traps, observes);
+ } else {
+ for (var i = 0, len = observes.length; i < len; i++) {
+ var trap = observes[i], name = trap.name;
+ if (!top.newObserved[name]) {
+ top.newObserved[name] = trap;
+ }
+ }
+ }
+ }
+ };
+ Observation.ignore = function (fn) {
+ return function () {
+ if (observationStack.length) {
+ var top = observationStack[observationStack.length - 1];
+ top.ignore++;
+ var res = fn.apply(this, arguments);
+ top.ignore--;
+ return res;
+ } else {
+ return fn.apply(this, arguments);
+ }
+ };
+ };
+ Observation.trap = function () {
+ if (observationStack.length) {
+ var top = observationStack[observationStack.length - 1];
+ var oldTraps = top.traps;
+ var traps = top.traps = [];
+ return function () {
+ top.traps = oldTraps;
+ return traps;
+ };
+ } else {
+ return function () {
+ return [];
+ };
+ }
+ };
+ Observation.trapsCount = function () {
+ if (observationStack.length) {
+ var top = observationStack[observationStack.length - 1];
+ return top.traps.length;
+ } else {
+ return 0;
+ }
+ };
+ Observation.isRecording = function () {
+ var len = observationStack.length;
+ var last = len && observationStack[len - 1];
+ return last && last.ignore === 0 && last;
+ };
+ module.exports = namespace.Observation = Observation;
+});
+/*can-event@3.0.1#lifecycle/lifecycle*/
+define('can-event@3.0.1#lifecycle/lifecycle', function (require, exports, module) {
+ var canEvent = require('can-event');
+ module.exports = {
+ addAndSetup: function () {
+ canEvent.addEventListener.apply(this, arguments);
+ if (!this.__inSetup) {
+ if (!this._bindings) {
+ this._bindings = 1;
+ if (this._eventSetup) {
+ this._eventSetup();
+ }
+ } else {
+ this._bindings++;
+ }
+ }
+ return this;
+ },
+ removeAndTeardown: function (event, handler) {
+ if (!this.__bindEvents) {
+ return this;
+ }
+ var handlers = this.__bindEvents[event] || [];
+ var handlerCount = handlers.length;
+ canEvent.removeEventListener.apply(this, arguments);
+ if (this._bindings === null) {
+ this._bindings = 0;
+ } else {
+ this._bindings = this._bindings - (handlerCount - handlers.length);
+ }
+ if (!this._bindings && this._eventTeardown) {
+ this._eventTeardown();
+ }
+ return this;
+ }
+ };
+});
+/*can-observation@3.0.2#reader/reader*/
+define('can-observation@3.0.2#reader/reader', function (require, exports, module) {
+ var Observation = require('can-observation');
+ var assign = require('can-util/js/assign/assign');
+ var CID = require('can-util/js/cid/cid');
+ var types = require('can-util/js/types/types');
+ var dev = require('can-util/js/dev/dev');
+ var canEvent = require('can-event');
+ var each = require('can-util/js/each/each');
+ var observeReader;
+ var isAt = function (index, reads) {
+ var prevRead = reads[index - 1];
+ return prevRead && prevRead.at;
+ };
+ var readValue = function (value, index, reads, options, state, prev) {
+ var usedValueReader;
+ do {
+ usedValueReader = false;
+ for (var i = 0, len = observeReader.valueReaders.length; i < len; i++) {
+ if (observeReader.valueReaders[i].test(value, index, reads, options)) {
+ value = observeReader.valueReaders[i].read(value, index, reads, options, state, prev);
+ }
+ }
+ } while (usedValueReader);
+ return value;
+ };
+ var specialRead = {
+ index: true,
+ key: true,
+ event: true,
+ element: true,
+ viewModel: true
+ };
+ var checkForObservableAndNotify = function (options, state, getObserves, value, index) {
+ if (options.foundObservable && !state.foundObservable) {
+ if (Observation.trapsCount()) {
+ Observation.addAll(getObserves());
+ options.foundObservable(value, index);
+ state.foundObservable = true;
+ }
+ }
+ };
+ observeReader = {
+ read: function (parent, reads, options) {
+ options = options || {};
+ var state = { foundObservable: false };
+ var getObserves;
+ if (options.foundObservable) {
+ getObserves = Observation.trap();
+ }
+ var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0, last;
+ checkForObservableAndNotify(options, state, getObserves, parent, 0);
+ while (i < readLength) {
+ prev = cur;
+ for (var r = 0, readersLength = observeReader.propertyReaders.length; r < readersLength; r++) {
+ var reader = observeReader.propertyReaders[r];
+ if (reader.test(cur)) {
+ cur = reader.read(cur, reads[i], i, options, state);
+ break;
+ }
+ }
+ checkForObservableAndNotify(options, state, getObserves, prev, i);
+ last = cur;
+ i = i + 1;
+ cur = readValue(cur, i, reads, options, state, prev);
+ checkForObservableAndNotify(options, state, getObserves, prev, i - 1);
+ type = typeof cur;
+ if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) {
+ if (options.earlyExit) {
+ options.earlyExit(prev, i - 1, cur);
+ }
+ return {
+ value: undefined,
+ parent: prev
+ };
+ }
+ }
+ if (cur === undefined) {
+ if (options.earlyExit) {
+ options.earlyExit(prev, i - 1);
+ }
+ }
+ return {
+ value: cur,
+ parent: prev
+ };
+ },
+ get: function (parent, reads, options) {
+ return observeReader.read(parent, observeReader.reads(reads), options || {}).value;
+ },
+ valueReadersMap: {},
+ valueReaders: [
+ {
+ name: 'function',
+ test: function (value, i, reads, options) {
+ return types.isCallableForValue(value) && !types.isCompute(value);
+ },
+ read: function (value, i, reads, options, state, prev) {
+ if (isAt(i, reads)) {
+ return i === reads.length ? value.bind(prev) : value;
+ } else if (options.callMethodsOnObservables && types.isMapLike(prev)) {
+ return value.apply(prev, options.args || []);
+ } else if (options.isArgument && i === reads.length) {
+ return options.proxyMethods !== false ? value.bind(prev) : value;
+ }
+ return value.apply(prev, options.args || []);
+ }
+ },
+ {
+ name: 'compute',
+ test: function (value, i, reads, options) {
+ return types.isCompute(value) && !isAt(i, reads);
+ },
+ read: function (value, i, reads, options, state) {
+ if (options.readCompute === false && i === reads.length) {
+ return value;
+ }
+ return value.get ? value.get() : value();
+ },
+ write: function (base, newVal) {
+ if (base.set) {
+ base.set(newVal);
+ } else {
+ base(newVal);
+ }
+ }
+ }
+ ],
+ propertyReadersMap: {},
+ propertyReaders: [
+ {
+ name: 'map',
+ test: function () {
+ return types.isMapLike.apply(this, arguments) || types.isListLike.apply(this, arguments);
+ },
+ read: function (value, prop, index, options, state) {
+ var res = value.get ? value.get(prop.key) : value.attr(prop.key);
+ if (res !== undefined) {
+ return res;
+ } else {
+ return value[prop.key];
+ }
+ },
+ write: function (base, prop, newVal) {
+ if (typeof base.set === 'function') {
+ base.set(prop, newVal);
+ } else {
+ base.attr(prop, newVal);
+ }
+ }
+ },
+ {
+ name: 'promise',
+ test: function (value) {
+ return types.isPromise(value);
+ },
+ read: function (value, prop, index, options, state) {
+ var observeData = value.__observeData;
+ if (!value.__observeData) {
+ observeData = value.__observeData = {
+ isPending: true,
+ state: 'pending',
+ isResolved: false,
+ isRejected: false,
+ value: undefined,
+ reason: undefined
+ };
+ CID(observeData);
+ assign(observeData, canEvent);
+ value.then(function (value) {
+ observeData.isPending = false;
+ observeData.isResolved = true;
+ observeData.value = value;
+ observeData.state = 'resolved';
+ observeData.dispatch('state', [
+ 'resolved',
+ 'pending'
+ ]);
+ }, function (reason) {
+ observeData.isPending = false;
+ observeData.isRejected = true;
+ observeData.reason = reason;
+ observeData.state = 'rejected';
+ observeData.dispatch('state', [
+ 'rejected',
+ 'pending'
+ ]);
+ });
+ }
+ Observation.add(observeData, 'state');
+ return prop.key in observeData ? observeData[prop.key] : value[prop.key];
+ }
+ },
+ {
+ name: 'object',
+ test: function () {
+ return true;
+ },
+ read: function (value, prop) {
+ if (value == null) {
+ return undefined;
+ } else {
+ if (typeof value === 'object') {
+ if (prop.key in value) {
+ return value[prop.key];
+ } else if (prop.at && specialRead[prop.key] && '@' + prop.key in value) {
+ return value['@' + prop.key];
+ }
+ } else {
+ return value[prop.key];
+ }
+ }
+ },
+ write: function (base, prop, newVal) {
+ base[prop] = newVal;
+ }
+ }
+ ],
+ reads: function (key) {
+ var keys = [];
+ var last = 0;
+ var at = false;
+ if (key.charAt(0) === '@') {
+ last = 1;
+ at = true;
+ }
+ var keyToAdd = '';
+ for (var i = last; i < key.length; i++) {
+ var character = key.charAt(i);
+ if (character === '.' || character === '@') {
+ if (key.charAt(i - 1) !== '\\') {
+ keys.push({
+ key: keyToAdd,
+ at: at
+ });
+ at = character === '@';
+ keyToAdd = '';
+ } else {
+ keyToAdd = keyToAdd.substr(0, keyToAdd.length - 1) + '.';
+ }
+ } else {
+ keyToAdd += character;
+ }
+ }
+ keys.push({
+ key: keyToAdd,
+ at: at
+ });
+ return keys;
+ },
+ write: function (parent, key, value, options) {
+ var keys = typeof key === 'string' ? observeReader.reads(key) : key;
+ var last;
+ if (keys.length > 1) {
+ last = keys.pop();
+ parent = observeReader.read(parent, keys, options).value;
+ keys.push(last);
+ } else {
+ last = keys[0];
+ }
+ if (observeReader.valueReadersMap.compute.test(parent[last.key], keys.length - 1, keys, options)) {
+ observeReader.valueReadersMap.compute.write(parent[last.key], value, options);
+ } else {
+ if (observeReader.valueReadersMap.compute.test(parent, keys.length - 1, keys, options)) {
+ parent = parent();
+ }
+ if (observeReader.propertyReadersMap.map.test(parent)) {
+ observeReader.propertyReadersMap.map.write(parent, last.key, value, options);
+ } else if (observeReader.propertyReadersMap.object.test(parent)) {
+ observeReader.propertyReadersMap.object.write(parent, last.key, value, options);
+ }
+ }
+ }
+ };
+ each(observeReader.propertyReaders, function (reader) {
+ observeReader.propertyReadersMap[reader.name] = reader;
+ });
+ each(observeReader.valueReaders, function (reader) {
+ observeReader.valueReadersMap[reader.name] = reader;
+ });
+ observeReader.set = observeReader.write;
+ module.exports = observeReader;
+});
+/*can-compute@3.0.3#proto-compute*/
+define('can-compute@3.0.3#proto-compute', function (require, exports, module) {
+ var Observation = require('can-observation');
+ var canEvent = require('can-event');
+ var eventLifecycle = require('can-event/lifecycle/lifecycle');
+ require('can-event/batch/batch');
+ var observeReader = require('can-observation/reader/reader');
+ var getObject = require('can-util/js/get/get');
+ var CID = require('can-util/js/cid/');
+ var assign = require('can-util/js/assign/');
+ var types = require('can-util/js/types/');
+ var isEmptyObject = require('can-util/js/is-empty-object/');
+ var Compute = function (getterSetter, context, eventName, bindOnce) {
+ CID(this, 'compute');
+ var args = [];
+ for (var i = 0, arglen = arguments.length; i < arglen; i++) {
+ args[i] = arguments[i];
+ }
+ var contextType = typeof args[1];
+ if (typeof args[0] === 'function') {
+ this._setupGetterSetterFn(args[0], args[1], args[2], args[3]);
+ } else if (args[1] !== undefined) {
+ if (contextType === 'string' || contextType === 'number') {
+ var isListLike = types.isListLike(args[0]);
+ if (types.isMapLike(args[0]) || isListLike) {
+ var map = args[0];
+ var propertyName = args[1];
+ var mapGetterSetter = function (newValue) {
+ if (arguments.length) {
+ observeReader.set(map, propertyName, newValue);
+ } else {
+ if (isListLike) {
+ observeReader.get(map, 'length');
+ }
+ return observeReader.get(map, '' + propertyName);
+ }
+ };
+ this._setupGetterSetterFn(mapGetterSetter, args[1], args[2], args[3]);
+ } else {
+ this._setupProperty(args[0], args[1], args[2]);
+ }
+ } else if (contextType === 'function') {
+ this._setupSetter(args[0], args[1], args[2]);
+ } else {
+ if (args[1] && args[1].fn) {
+ this._setupAsyncCompute(args[0], args[1]);
+ } else {
+ this._setupSettings(args[0], args[1]);
+ }
+ }
+ } else {
+ this._setupSimpleValue(args[0]);
+ }
+ this._args = args;
+ this._primaryDepth = 0;
+ this.isComputed = true;
+ };
+ var updateOnChange = function (compute, newValue, oldValue, batchNum) {
+ var valueChanged = newValue !== oldValue && !(newValue !== newValue && oldValue !== oldValue);
+ if (valueChanged) {
+ canEvent.dispatch.call(compute, {
+ type: 'change',
+ batchNum: batchNum
+ }, [
+ newValue,
+ oldValue
+ ]);
+ }
+ };
+ var setupComputeHandlers = function (compute, func, context) {
+ var observation = new Observation(func, context, compute);
+ compute.observation = observation;
+ return {
+ _on: function () {
+ observation.start();
+ compute.value = observation.value;
+ compute.hasDependencies = !isEmptyObject(observation.newObserved);
+ },
+ _off: function () {
+ observation.stop();
+ },
+ getDepth: function () {
+ return observation.getDepth();
+ }
+ };
+ };
+ assign(Compute.prototype, {
+ setPrimaryDepth: function (depth) {
+ this._primaryDepth = depth;
+ },
+ _setupGetterSetterFn: function (getterSetter, context, eventName) {
+ this._set = context ? getterSetter.bind(context) : getterSetter;
+ this._get = context ? getterSetter.bind(context) : getterSetter;
+ this._canObserve = eventName === false ? false : true;
+ var handlers = setupComputeHandlers(this, getterSetter, context || this);
+ assign(this, handlers);
+ },
+ _setupProperty: function (target, propertyName, eventName) {
+ var self = this, handler;
+ handler = function () {
+ self.updater(self._get(), self.value);
+ };
+ this._get = function () {
+ return getObject(target, propertyName);
+ };
+ this._set = function (value) {
+ var properties = propertyName.split('.'), leafPropertyName = properties.pop(), targetProperty = getObject(target, properties.join('.'));
+ targetProperty[leafPropertyName] = value;
+ };
+ this._on = function (update) {
+ canEvent.on.call(target, eventName || propertyName, handler);
+ this.value = this._get();
+ };
+ this._off = function () {
+ return canEvent.off.call(target, eventName || propertyName, handler);
+ };
+ },
+ _setupSetter: function (initialValue, setter, eventName) {
+ this.value = initialValue;
+ this._set = setter;
+ assign(this, eventName);
+ },
+ _setupSettings: function (initialValue, settings) {
+ this.value = initialValue;
+ this._set = settings.set || this._set;
+ this._get = settings.get || this._get;
+ if (!settings.__selfUpdater) {
+ var self = this, oldUpdater = this.updater;
+ this.updater = function () {
+ oldUpdater.call(self, self._get(), self.value);
+ };
+ }
+ this._on = settings.on ? settings.on : this._on;
+ this._off = settings.off ? settings.off : this._off;
+ },
+ _setupAsyncCompute: function (initialValue, settings) {
+ var self = this;
+ var getter = settings.fn;
+ var bindings;
+ this.value = initialValue;
+ this._setUpdates = true;
+ this.lastSetValue = new Compute(initialValue);
+ this._set = function (newVal) {
+ if (newVal === self.lastSetValue.get()) {
+ return this.value;
+ }
+ return self.lastSetValue.set(newVal);
+ };
+ this._get = function () {
+ return getter.call(settings.context, self.lastSetValue.get());
+ };
+ if (getter.length === 0) {
+ bindings = setupComputeHandlers(this, getter, settings.context);
+ } else if (getter.length === 1) {
+ bindings = setupComputeHandlers(this, function () {
+ return getter.call(settings.context, self.lastSetValue.get());
+ }, settings);
+ } else {
+ var oldUpdater = this.updater, resolve = Observation.ignore(function (newVal) {
+ oldUpdater.call(self, newVal, self.value);
+ });
+ this.updater = function (newVal) {
+ oldUpdater.call(self, newVal, self.value);
+ };
+ bindings = setupComputeHandlers(this, function () {
+ var res = getter.call(settings.context, self.lastSetValue.get(), resolve);
+ return res !== undefined ? res : this.value;
+ }, this);
+ }
+ assign(this, bindings);
+ },
+ _setupSimpleValue: function (initialValue) {
+ this.value = initialValue;
+ },
+ _eventSetup: Observation.ignore(function () {
+ this.bound = true;
+ this._on(this.updater);
+ }),
+ _eventTeardown: function () {
+ this._off(this.updater);
+ this.bound = false;
+ },
+ addEventListener: eventLifecycle.addAndSetup,
+ removeEventListener: eventLifecycle.removeAndTeardown,
+ clone: function (context) {
+ if (context && typeof this._args[0] === 'function') {
+ this._args[1] = context;
+ } else if (context) {
+ this._args[2] = context;
+ }
+ return new Compute(this._args[0], this._args[1], this._args[2], this._args[3]);
+ },
+ _on: function () {
+ },
+ _off: function () {
+ },
+ get: function () {
+ var recordingObservation = Observation.isRecording();
+ if (recordingObservation && this._canObserve !== false) {
+ Observation.add(this, 'change');
+ if (!this.bound) {
+ Compute.temporarilyBind(this);
+ }
+ }
+ if (this.bound) {
+ if (this.observation) {
+ return this.observation.get();
+ } else {
+ return this.value;
+ }
+ } else {
+ return this._get();
+ }
+ },
+ _get: function () {
+ return this.value;
+ },
+ set: function (newVal) {
+ var old = this.value;
+ var setVal = this._set(newVal, old);
+ if (this._setUpdates) {
+ return this.value;
+ }
+ if (this.hasDependencies) {
+ return this._get();
+ }
+ this.updater(setVal === undefined ? this._get() : setVal, old);
+ return this.value;
+ },
+ _set: function (newVal) {
+ return this.value = newVal;
+ },
+ updater: function (newVal, oldVal, batchNum) {
+ this.value = newVal;
+ if (this.observation) {
+ this.observation.value = newVal;
+ }
+ updateOnChange(this, newVal, oldVal, batchNum);
+ },
+ toFunction: function () {
+ return this._computeFn.bind(this);
+ },
+ _computeFn: function (newVal) {
+ if (arguments.length) {
+ return this.set(newVal);
+ }
+ return this.get();
+ }
+ });
+ Compute.prototype.on = Compute.prototype.bind = Compute.prototype.addEventListener;
+ Compute.prototype.off = Compute.prototype.unbind = Compute.prototype.removeEventListener;
+ var k = function () {
+ };
+ var computes;
+ var unbindComputes = function () {
+ for (var i = 0, len = computes.length; i < len; i++) {
+ computes[i].removeEventListener('change', k);
+ }
+ computes = null;
+ };
+ Compute.temporarilyBind = function (compute) {
+ var computeInstance = compute.computeInstance || compute;
+ computeInstance.addEventListener('change', k);
+ if (!computes) {
+ computes = [];
+ setTimeout(unbindComputes, 10);
+ }
+ computes.push(computeInstance);
+ };
+ Compute.async = function (initialValue, asyncComputer, context) {
+ return new Compute(initialValue, {
+ fn: asyncComputer,
+ context: context
+ });
+ };
+ Compute.truthy = function (compute) {
+ return new Compute(function () {
+ var res = compute.get();
+ if (typeof res === 'function') {
+ res = res.get();
+ }
+ return !!res;
+ });
+ };
+ module.exports = exports = Compute;
+});
+/*can-compute@3.0.3#can-compute*/
+define('can-compute@3.0.3#can-compute', function (require, exports, module) {
+ require('can-event');
+ require('can-event/batch/');
+ var Compute = require('./proto-compute');
+ var CID = require('can-util/js/cid/');
+ var namespace = require('can-util/namespace');
+ var addEventListener = function (ev, handler) {
+ var compute = this;
+ var computeHandler = handler && handler[compute.handlerKey];
+ if (handler && !computeHandler) {
+ computeHandler = handler[compute.handlerKey] = function () {
+ handler.apply(compute, arguments);
+ };
+ }
+ return compute.computeInstance.addEventListener(ev, computeHandler);
+ };
+ var removeEventListener = function (ev, handler) {
+ var compute = this;
+ var computeHandler = handler && handler[compute.handlerKey];
+ if (computeHandler) {
+ delete handler[compute.handlerKey];
+ return compute.computeInstance.removeEventListener(ev, computeHandler);
+ }
+ return compute.computeInstance.removeEventListener.apply(compute.computeInstance, arguments);
+ };
+ var COMPUTE = function (getterSetter, context, eventName, bindOnce) {
+ function compute(val) {
+ if (arguments.length) {
+ return compute.computeInstance.set(val);
+ }
+ return compute.computeInstance.get();
+ }
+ var cid = CID(compute, 'compute');
+ compute.computeInstance = new Compute(getterSetter, context, eventName, bindOnce);
+ compute.handlerKey = '__handler' + cid;
+ compute.on = compute.bind = compute.addEventListener = addEventListener;
+ compute.off = compute.unbind = compute.removeEventListener = removeEventListener;
+ compute.isComputed = compute.computeInstance.isComputed;
+ compute.clone = function (ctx) {
+ if (typeof getterSetter === 'function') {
+ context = ctx;
+ }
+ return COMPUTE(getterSetter, context, ctx, bindOnce);
+ };
+ return compute;
+ };
+ COMPUTE.truthy = function (compute) {
+ return COMPUTE(function () {
+ var res = compute();
+ if (typeof res === 'function') {
+ res = res();
+ }
+ return !!res;
+ });
+ };
+ COMPUTE.async = function (initialValue, asyncComputer, context) {
+ return COMPUTE(initialValue, {
+ fn: asyncComputer,
+ context: context
+ });
+ };
+ COMPUTE.temporarilyBind = Compute.temporarilyBind;
+ module.exports = namespace.compute = COMPUTE;
+});
+/*can-control@3.0.3#can-control*/
+define('can-control@3.0.3#can-control', function (require, exports, module) {
+ var Construct = require('can-construct');
+ var namespace = require('can-util/namespace');
+ var string = require('can-util/js/string/string');
+ var assign = require('can-util/js/assign/assign');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var each = require('can-util/js/each/each');
+ var dev = require('can-util/js/dev/dev');
+ var types = require('can-util/js/types/types');
+ var get = require('can-util/js/get/get');
+ var domData = require('can-util/dom/data/data');
+ var className = require('can-util/dom/class-name/class-name');
+ var domEvents = require('can-util/dom/events/events');
+ var canEvent = require('can-event');
+ var canCompute = require('can-compute');
+ var observeReader = require('can-observation/reader/reader');
+ var processors;
+ require('can-util/dom/dispatch/dispatch');
+ require('can-util/dom/events/delegate/delegate');
+ var bind = function (el, ev, callback) {
+ canEvent.on.call(el, ev, callback);
+ return function () {
+ canEvent.off.call(el, ev, callback);
+ };
+ }, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, delegate = function (el, selector, ev, callback) {
+ canEvent.on.call(el, ev, selector, callback);
+ return function () {
+ canEvent.off.call(el, ev, selector, callback);
+ };
+ }, binder = function (el, ev, callback, selector) {
+ return selector ? delegate(el, selector.trim(), ev, callback) : bind(el, ev, callback);
+ }, basicProcessor;
+ var Control = Construct.extend({
+ setup: function () {
+ Construct.setup.apply(this, arguments);
+ if (Control) {
+ var control = this, funcName;
+ control.actions = {};
+ for (funcName in control.prototype) {
+ if (control._isAction(funcName)) {
+ control.actions[funcName] = control._action(funcName);
+ }
+ }
+ }
+ },
+ _shifter: function (context, name) {
+ var method = typeof name === 'string' ? context[name] : name;
+ if (!isFunction(method)) {
+ method = context[method];
+ }
+ return function () {
+ var wrapped = types.wrapElement(this);
+ context.called = name;
+ return method.apply(context, [wrapped].concat(slice.call(arguments, 0)));
+ };
+ },
+ _isAction: function (methodName) {
+ var val = this.prototype[methodName], type = typeof val;
+ return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(Control.isSpecial(methodName) || processors[methodName] || /[^\w]/.test(methodName));
+ },
+ _action: function (methodName, options, controlInstance) {
+ var readyCompute;
+ paramReplacer.lastIndex = 0;
+ if (options || !paramReplacer.test(methodName)) {
+ readyCompute = canCompute(function () {
+ var delegate;
+ var name = methodName.replace(paramReplacer, function (matched, key) {
+ var value, parent;
+ if (this._isDelegate(options, key)) {
+ delegate = this._getDelegate(options, key);
+ return '';
+ }
+ key = this._removeDelegateFromKey(key);
+ parent = this._lookup(options)[0];
+ value = observeReader.read(parent, observeReader.reads(key), { readCompute: false }).value;
+ if (value === undefined && typeof window !== 'undefined') {
+ value = get(window, key);
+ }
+ if (!parent || !types.isMapLike(parent) && !value) {
+ return null;
+ }
+ if (typeof value === 'string') {
+ return value;
+ } else {
+ delegate = value;
+ return '';
+ }
+ }.bind(this));
+ name = name.trim();
+ var parts = name.split(/\s+/g), event = parts.pop();
+ return {
+ processor: this.processors[event] || basicProcessor,
+ parts: [
+ name,
+ parts.join(' '),
+ event
+ ],
+ delegate: delegate || undefined
+ };
+ }, this);
+ if (controlInstance) {
+ var handler = function (ev, ready) {
+ controlInstance._bindings.control[methodName](controlInstance.element);
+ controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance);
+ };
+ readyCompute.bind('change', handler);
+ controlInstance._bindings.readyComputes[methodName] = {
+ compute: readyCompute,
+ handler: handler
+ };
+ }
+ return readyCompute();
+ }
+ },
+ _lookup: function (options) {
+ return [
+ options,
+ window
+ ];
+ },
+ _removeDelegateFromKey: function (key) {
+ return key;
+ },
+ _isDelegate: function (options, key) {
+ return key === 'element';
+ },
+ _getDelegate: function (options, key) {
+ return undefined;
+ },
+ processors: {},
+ defaults: {},
+ convertElement: function (element) {
+ element = typeof element === 'string' ? document.querySelector(element) : element;
+ return types.wrapElement(element);
+ },
+ isSpecial: function (eventName) {
+ return eventName === 'inserted' || eventName === 'removed';
+ }
+ }, {
+ setup: function (element, options) {
+ var cls = this.constructor, pluginname = cls.pluginName || cls.shortName, arr;
+ this.element = cls.convertElement(element);
+ if (pluginname && pluginname !== 'can_control') {
+ className.add.call(element, pluginname);
+ }
+ arr = domData.get.call(this.element, 'controls');
+ if (!arr) {
+ arr = [];
+ domData.set.call(this.element, 'controls', arr);
+ }
+ arr.push(this);
+ if (types.isMapLike(options)) {
+ for (var prop in cls.defaults) {
+ if (!options.hasOwnProperty(prop)) {
+ observeReader.set(options, prop, cls.defaults[prop]);
+ }
+ }
+ this.options = options;
+ } else {
+ this.options = assign(assign({}, cls.defaults), options);
+ }
+ this.on();
+ return [
+ this.element,
+ this.options
+ ];
+ },
+ on: function (el, selector, eventName, func) {
+ if (!el) {
+ this.off();
+ var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = types.unwrapElement(this.element), destroyCB = Control._shifter(this, 'destroy'), funcName, ready;
+ for (funcName in actions) {
+ if (actions.hasOwnProperty(funcName)) {
+ ready = actions[funcName] || cls._action(funcName, this.options, this);
+ if (ready) {
+ bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this);
+ }
+ }
+ }
+ domEvents.addEventListener.call(element, 'removed', destroyCB);
+ bindings.user.push(function (el) {
+ domEvents.removeEventListener.call(el, 'removed', destroyCB);
+ });
+ return bindings.user.length;
+ }
+ if (typeof el === 'string') {
+ func = eventName;
+ eventName = selector;
+ selector = el;
+ el = this.element;
+ }
+ if (func === undefined) {
+ func = eventName;
+ eventName = selector;
+ selector = null;
+ }
+ if (typeof func === 'string') {
+ func = Control._shifter(this, func);
+ }
+ this._bindings.user.push(binder(el, eventName, func, selector));
+ return this._bindings.user.length;
+ },
+ off: function () {
+ var el = types.unwrapElement(this.element), bindings = this._bindings;
+ if (bindings) {
+ each(bindings.user || [], function (value) {
+ value(el);
+ });
+ each(bindings.control || {}, function (value) {
+ value(el);
+ });
+ each(bindings.readyComputes || {}, function (value) {
+ value.compute.unbind('change', value.handler);
+ });
+ }
+ this._bindings = {
+ user: [],
+ control: {},
+ readyComputes: {}
+ };
+ },
+ destroy: function () {
+ if (this.element === null) {
+ return;
+ }
+ var Class = this.constructor, pluginName = Class.pluginName || Class.shortName && string.underscore(Class.shortName), controls;
+ this.off();
+ if (pluginName && pluginName !== 'can_control') {
+ className.remove.call(this.element, pluginName);
+ }
+ controls = domData.get.call(this.element, 'controls');
+ controls.splice(controls.indexOf(this), 1);
+ canEvent.dispatch.call(this, 'destroyed');
+ this.element = null;
+ }
+ });
+ processors = Control.processors;
+ basicProcessor = function (el, event, selector, methodName, control) {
+ return binder(el, event, Control._shifter(control, methodName), selector);
+ };
+ each([
+ 'change',
+ 'click',
+ 'contextmenu',
+ 'dblclick',
+ 'keydown',
+ 'keyup',
+ 'keypress',
+ 'mousedown',
+ 'mousemove',
+ 'mouseout',
+ 'mouseover',
+ 'mouseup',
+ 'reset',
+ 'resize',
+ 'scroll',
+ 'select',
+ 'submit',
+ 'focusin',
+ 'focusout',
+ 'mouseenter',
+ 'mouseleave',
+ 'touchstart',
+ 'touchmove',
+ 'touchcancel',
+ 'touchend',
+ 'touchleave',
+ 'inserted',
+ 'removed',
+ 'dragstart',
+ 'dragenter',
+ 'dragover',
+ 'dragleave',
+ 'drag',
+ 'drop',
+ 'dragend'
+ ], function (v) {
+ processors[v] = basicProcessor;
+ });
+ module.exports = namespace.Control = Control;
+});
+/*can-component@3.0.2#control/control*/
+define('can-component@3.0.2#control/control', function (require, exports, module) {
+ var Control = require('can-control');
+ var canEach = require('can-util/js/each/each');
+ var string = require('can-util/js/string/string');
+ var canCompute = require('can-compute');
+ var observeReader = require('can-observation/reader/reader');
+ var paramReplacer = /\{([^\}]+)\}/g;
+ var ComponentControl = Control.extend({
+ _lookup: function (options) {
+ return [
+ options.scope,
+ options,
+ window
+ ];
+ },
+ _removeDelegateFromKey: function (key) {
+ return key.replace(/^(scope|^viewModel)\./, '');
+ },
+ _isDelegate: function (options, key) {
+ return key === 'scope' || key === 'viewModel';
+ },
+ _getDelegate: function (options, key) {
+ return options[key];
+ },
+ _action: function (methodName, options, controlInstance) {
+ var hasObjectLookup;
+ paramReplacer.lastIndex = 0;
+ hasObjectLookup = paramReplacer.test(methodName);
+ if (!controlInstance && hasObjectLookup) {
+ return;
+ } else {
+ return Control._action.apply(this, arguments);
+ }
+ }
+ }, {
+ setup: function (el, options) {
+ this.scope = options.scope;
+ this.viewModel = options.viewModel;
+ return Control.prototype.setup.call(this, el, options);
+ },
+ off: function () {
+ if (this._bindings) {
+ canEach(this._bindings.readyComputes || {}, function (value) {
+ value.compute.unbind('change', value.handler);
+ });
+ }
+ Control.prototype.off.apply(this, arguments);
+ this._bindings.readyComputes = {};
+ },
+ destroy: function () {
+ Control.prototype.destroy.apply(this, arguments);
+ if (typeof this.options.destroy === 'function') {
+ this.options.destroy.apply(this, arguments);
+ }
+ }
+ });
+ module.exports = ComponentControl;
+});
+/*can-simple-map@3.0.0#can-simple-map*/
+define('can-simple-map@3.0.0#can-simple-map', function (require, exports, module) {
+ var Construct = require('can-construct');
+ var canBatch = require('can-event/batch/batch');
+ var canEvent = require('can-event');
+ var assign = require('can-util/js/assign/assign');
+ var types = require('can-util/js/types/types');
+ var Observation = require('can-observation');
+ var SimpleMap = Construct.extend({
+ setup: function () {
+ this._data = {};
+ },
+ init: function (initialData) {
+ this.attr(initialData);
+ },
+ attr: function (prop, value) {
+ var self = this;
+ if (arguments.length > 1) {
+ var old = this._data[prop];
+ this._data[prop] = value;
+ canBatch.trigger.call(this, prop, [
+ value,
+ old
+ ]);
+ } else if (typeof prop === 'object') {
+ Object.keys(prop).forEach(function (key) {
+ self.attr(key, prop[key]);
+ });
+ } else {
+ if (prop !== 'constructor') {
+ Observation.add(this, prop);
+ return this._data[prop];
+ }
+ return this.constructor;
+ }
+ }
+ });
+ assign(SimpleMap.prototype, canEvent);
+ var oldIsMapLike = types.isMapLike;
+ types.isMapLike = function (obj) {
+ if (obj instanceof SimpleMap) {
+ return true;
+ }
+ return oldIsMapLike.call(this, obj);
+ };
+ if (!types.DefaultMap) {
+ types.DefaultMap = SimpleMap;
+ }
+ module.exports = SimpleMap;
+});
+/*can-view-scope@3.0.1#reference-map*/
+define('can-view-scope@3.0.1#reference-map', function (require, exports, module) {
+ var types = require('can-util/js/types/types');
+ var SimpleMap = require('can-simple-map');
+ var ReferenceMap = SimpleMap.extend({});
+ var oldIsMapLike = types.isMapLike;
+ types.isMapLike = function (obj) {
+ if (obj instanceof ReferenceMap) {
+ return true;
+ }
+ return oldIsMapLike.call(this, obj);
+ };
+ module.exports = ReferenceMap;
+});
+/*can-view-scope@3.0.1#compute_data*/
+define('can-view-scope@3.0.1#compute_data', function (require, exports, module) {
+ var Observation = require('can-observation');
+ var observeReader = require('can-observation/reader/reader');
+ var makeCompute = require('can-compute');
+ var types = require('can-util/js/types/types');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ var isFastPath = function (computeData) {
+ if (computeData.reads && computeData.reads.length === 1) {
+ var root = computeData.root;
+ if (types.isCompute(root)) {
+ root = root();
+ }
+ return types.isMapLike(root) && !isFunction(root[computeData.reads[0].key]);
+ }
+ return;
+ };
+ var scopeReader = function (scope, key, options, computeData, newVal) {
+ if (arguments.length > 4) {
+ var root = computeData.root || computeData.setRoot;
+ if (root) {
+ observeReader.write(root, computeData.reads, newVal, options);
+ } else {
+ scope.set(key, newVal, options);
+ }
+ } else {
+ if (computeData.root) {
+ return observeReader.read(computeData.root, computeData.reads, options).value;
+ }
+ var data = scope.read(key, options);
+ computeData.scope = data.scope;
+ computeData.initialValue = data.value;
+ computeData.reads = data.reads;
+ computeData.root = data.rootObserve;
+ computeData.setRoot = data.setRoot;
+ return data.value;
+ }
+ };
+ module.exports = function (scope, key, options) {
+ options = options || { args: [] };
+ var computeData = {}, scopeRead = function (newVal) {
+ if (arguments.length) {
+ return scopeReader(scope, key, options, computeData, newVal);
+ } else {
+ return scopeReader(scope, key, options, computeData);
+ }
+ }, compute = makeCompute(undefined, {
+ on: function () {
+ observation.start();
+ if (isFastPath(computeData)) {
+ observation.dependencyChange = function (ev, newVal) {
+ if (types.isMapLike(ev.target) && typeof newVal !== 'function') {
+ this.newVal = newVal;
+ } else {
+ observation.dependencyChange = Observation.prototype.dependencyChange;
+ observation.start = Observation.prototype.start;
+ compute.fastPath = false;
+ }
+ return Observation.prototype.dependencyChange.call(this, ev);
+ };
+ observation.start = function () {
+ this.value = this.newVal;
+ };
+ compute.fastPath = true;
+ }
+ compute.computeInstance.value = observation.value;
+ compute.computeInstance.hasDependencies = !isEmptyObject(observation.newObserved);
+ },
+ off: function () {
+ observation.stop();
+ },
+ set: scopeRead,
+ get: scopeRead,
+ __selfUpdater: true
+ }), observation = new Observation(scopeRead, null, compute.computeInstance);
+ compute.computeInstance.observation = observation;
+ computeData.compute = compute;
+ return computeData;
+ };
+});
+/*can-view-scope@3.0.1#can-view-scope*/
+define('can-view-scope@3.0.1#can-view-scope', function (require, exports, module) {
+ var observeReader = require('can-observation/reader/reader');
+ var Observation = require('can-observation');
+ var ReferenceMap = require('./reference-map');
+ var makeComputeData = require('./compute_data');
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var namespace = require('can-util/namespace');
+ function Scope(context, parent, meta) {
+ this._context = context;
+ this._parent = parent;
+ this._meta = meta || {};
+ this.__cache = {};
+ }
+ assign(Scope, {
+ read: observeReader.read,
+ Refs: ReferenceMap,
+ refsScope: function () {
+ return new Scope(new this.Refs());
+ }
+ });
+ assign(Scope.prototype, {
+ add: function (context, meta) {
+ if (context !== this._context) {
+ return new this.constructor(context, this, meta);
+ } else {
+ return this;
+ }
+ },
+ read: function (attr, options) {
+ if (attr === '%root') {
+ return { value: this.getRoot() };
+ }
+ var isInCurrentContext = attr.substr(0, 2) === './', isInParentContext = attr.substr(0, 3) === '../', isCurrentContext = attr === '.' || attr === 'this', isParentContext = attr === '..', isContextBased = isInCurrentContext || isInParentContext || isCurrentContext || isParentContext;
+ if (isContextBased && this._meta.notContext) {
+ return this._parent.read(attr, options);
+ }
+ var currentScopeOnly;
+ if (isInCurrentContext) {
+ currentScopeOnly = true;
+ attr = attr.substr(2);
+ } else if (isInParentContext) {
+ var parent = this._parent;
+ while (parent._meta.notContext) {
+ parent = parent._parent;
+ }
+ return parent.read(attr.substr(3) || '.', options);
+ } else if (isCurrentContext) {
+ return { value: this._context };
+ } else if (isParentContext) {
+ return { value: this._parent._context };
+ }
+ var keyReads = observeReader.reads(attr);
+ if (keyReads[0].key.charAt(0) === '*') {
+ return this.getRefs()._read(keyReads, options, true);
+ } else {
+ return this._read(keyReads, options, currentScopeOnly);
+ }
+ },
+ _read: function (keyReads, options, currentScopeOnly) {
+ var currentScope = this, currentContext, undefinedObserves = [], currentObserve, currentReads, setObserveDepth = -1, currentSetReads, currentSetObserve, readOptions = assign({
+ foundObservable: function (observe, nameIndex) {
+ currentObserve = observe;
+ currentReads = keyReads.slice(nameIndex);
+ },
+ earlyExit: function (parentValue, nameIndex) {
+ if (nameIndex > setObserveDepth || nameIndex === setObserveDepth && (typeof parentValue === 'object' && keyReads[nameIndex].key in parentValue)) {
+ currentSetObserve = currentObserve;
+ currentSetReads = currentReads;
+ setObserveDepth = nameIndex;
+ }
+ }
+ }, options);
+ while (currentScope) {
+ currentContext = currentScope._context;
+ if (currentContext !== null && (typeof currentContext === 'object' || typeof currentContext === 'function')) {
+ var getObserves = Observation.trap();
+ var data = observeReader.read(currentContext, keyReads, readOptions);
+ var observes = getObserves();
+ if (data.value !== undefined) {
+ Observation.addAll(observes);
+ return {
+ scope: currentScope,
+ rootObserve: currentObserve,
+ value: data.value,
+ reads: currentReads
+ };
+ } else {
+ undefinedObserves.push.apply(undefinedObserves, observes);
+ }
+ }
+ if (currentScopeOnly) {
+ currentScope = null;
+ } else {
+ currentScope = currentScope._parent;
+ }
+ }
+ Observation.addAll(undefinedObserves);
+ return {
+ setRoot: currentSetObserve,
+ reads: currentSetReads,
+ value: undefined
+ };
+ },
+ get: function (key, options) {
+ options = assign({ isArgument: true }, options);
+ var res = this.read(key, options);
+ return res.value;
+ },
+ peak: Observation.ignore(function (key, options) {
+ return this.get(key, options);
+ }),
+ getScope: function (tester) {
+ var scope = this;
+ while (scope) {
+ if (tester(scope)) {
+ return scope;
+ }
+ scope = scope._parent;
+ }
+ },
+ getContext: function (tester) {
+ var res = this.getScope(tester);
+ return res && res._context;
+ },
+ getRefs: function () {
+ return this.getScope(function (scope) {
+ return scope._context instanceof Scope.Refs;
+ });
+ },
+ getRoot: function () {
+ var cur = this, child = this;
+ while (cur._parent) {
+ child = cur;
+ cur = cur._parent;
+ }
+ if (cur._context instanceof Scope.Refs) {
+ cur = child;
+ }
+ return cur._context;
+ },
+ set: function (key, value, options) {
+ var dotIndex = key.lastIndexOf('.'), slashIndex = key.lastIndexOf('/'), contextPath, propName;
+ if (slashIndex > dotIndex) {
+ contextPath = key.substring(0, slashIndex);
+ propName = key.substring(slashIndex + 1, key.length);
+ } else {
+ if (dotIndex !== -1) {
+ contextPath = key.substring(0, dotIndex);
+ propName = key.substring(dotIndex + 1, key.length);
+ } else {
+ contextPath = '.';
+ propName = key;
+ }
+ }
+ if (key.charAt(0) === '*') {
+ observeReader.write(this.getRefs()._context, key, value, options);
+ } else {
+ var context = this.read(contextPath, options).value;
+ observeReader.write(context, propName, value, options);
+ }
+ },
+ attr: Observation.ignore(function (key, value, options) {
+ console.warn('can-view-scope::attr is deprecated, please use peak, get or set');
+ options = assign({ isArgument: true }, options);
+ if (arguments.length === 2) {
+ return this.set(key, value, options);
+ } else {
+ return this.get(key, options);
+ }
+ }),
+ computeData: function (key, options) {
+ return makeComputeData(this, key, options);
+ },
+ compute: function (key, options) {
+ return this.computeData(key, options).compute;
+ },
+ cloneFromRef: function () {
+ var contexts = [];
+ var scope = this, context, parent;
+ while (scope) {
+ context = scope._context;
+ if (context instanceof Scope.Refs) {
+ parent = scope._parent;
+ break;
+ }
+ contexts.unshift(context);
+ scope = scope._parent;
+ }
+ if (parent) {
+ each(contexts, function (context) {
+ parent = parent.add(context);
+ });
+ return parent;
+ } else {
+ return this;
+ }
+ }
+ });
+ function Options(data, parent, meta) {
+ if (!data.helpers && !data.partials && !data.tags) {
+ data = { helpers: data };
+ }
+ Scope.call(this, data, parent, meta);
+ }
+ Options.prototype = new Scope();
+ Options.prototype.constructor = Options;
+ Scope.Options = Options;
+ namespace.view = namespace.view || {};
+ module.exports = namespace.view.Scope = Scope;
+});
+/*can-stache@3.0.7#src/utils*/
+define('can-stache@3.0.7#src/utils', function (require, exports, module) {
+ var Scope = require('can-view-scope');
+ var Observation = require('can-observation');
+ var observationReader = require('can-observation/reader/reader');
+ var compute = require('can-compute');
+ var types = require('can-util/js/types/types');
+ var isArrayLike = require('can-util/js/is-array-like/is-array-like');
+ var Options = Scope.Options;
+ module.exports = {
+ isArrayLike: isArrayLike,
+ emptyHandler: function () {
+ },
+ jsonParse: function (str) {
+ if (str[0] === '\'') {
+ return str.substr(1, str.length - 2);
+ } else if (str === 'undefined') {
+ return undefined;
+ } else {
+ return JSON.parse(str);
+ }
+ },
+ mixins: {
+ last: function () {
+ return this.stack[this.stack.length - 1];
+ },
+ add: function (chars) {
+ this.last().add(chars);
+ },
+ subSectionDepth: function () {
+ return this.stack.length - 1;
+ }
+ },
+ convertToScopes: function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer, isStringOnly) {
+ if (truthyRenderer) {
+ helperOptions.fn = this.makeRendererConvertScopes(truthyRenderer, scope, options, nodeList, isStringOnly);
+ }
+ if (falseyRenderer) {
+ helperOptions.inverse = this.makeRendererConvertScopes(falseyRenderer, scope, options, nodeList, isStringOnly);
+ }
+ },
+ makeRendererConvertScopes: function (renderer, parentScope, parentOptions, nodeList, observeObservables) {
+ var rendererWithScope = function (ctx, opts, parentNodeList) {
+ return renderer(ctx || parentScope, opts, parentNodeList);
+ };
+ var convertedRenderer = function (newScope, newOptions, parentNodeList) {
+ if (newScope !== undefined && !(newScope instanceof Scope)) {
+ newScope = parentScope.add(newScope);
+ }
+ if (newOptions !== undefined && !(newOptions instanceof Options)) {
+ newOptions = parentOptions.add(newOptions);
+ }
+ var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList);
+ return result;
+ };
+ return observeObservables ? convertedRenderer : Observation.ignore(convertedRenderer);
+ },
+ getItemsStringContent: function (items, isObserveList, helperOptions, options) {
+ var txt = '', len = observationReader.get(items, 'length'), isObservable = types.isMapLike(items) || types.isListLike(items);
+ for (var i = 0; i < len; i++) {
+ var item = isObservable ? compute(items, '' + i) : items[i];
+ txt += helperOptions.fn(item, options);
+ }
+ return txt;
+ },
+ getItemsFragContent: function (items, helperOptions, scope, asVariable) {
+ var result = [], len = observationReader.get(items, 'length'), isObservable = types.isMapLike(items) || types.isListLike(items);
+ for (var i = 0; i < len; i++) {
+ var aliases = {
+ '%index': i,
+ '@index': i
+ };
+ var item = isObservable ? compute(items, '' + i) : items[i];
+ if (asVariable) {
+ aliases[asVariable] = item;
+ }
+ result.push(helperOptions.fn(scope.add(aliases, { notContext: true }).add(item)));
+ }
+ return result;
+ },
+ Options: Options
+ };
+});
+/*can-view-parser@3.0.1#can-view-parser*/
+define('can-view-parser@3.0.1#can-view-parser', function (require, exports, module) {
+ var namespace = require('can-util/namespace'), dev = require('can-util/js/dev/dev');
+ function each(items, callback) {
+ for (var i = 0; i < items.length; i++) {
+ callback(items[i], i);
+ }
+ }
+ function makeMap(str) {
+ var obj = {}, items = str.split(',');
+ each(items, function (name) {
+ obj[name] = true;
+ });
+ return obj;
+ }
+ function handleIntermediate(intermediate, handler) {
+ for (var i = 0, len = intermediate.length; i < len; i++) {
+ var item = intermediate[i];
+ handler[item.tokenType].apply(handler, item.args);
+ }
+ return intermediate;
+ }
+ var alphaNumeric = 'A-Za-z0-9', alphaNumericHU = '-:_' + alphaNumeric, camelCase = /([a-z])([A-Z])/g, stash = '\\{\\{([^\\}]*)\\}\\}\\}?', endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/, space = /\s/, alphaRegex = new RegExp('[' + alphaNumeric + ']');
+ var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed');
+ var caseMatters = makeMap('altGlyph,altGlyphDef,altGlyphItem,animateColor,animateMotion,animateTransform,clipPath,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,foreignObject,glyphRef,linearGradient,radialGradient,textPath');
+ var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr');
+ var special = makeMap('script');
+ var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(',');
+ var fn = function () {
+ };
+ var HTMLParser = function (html, handler, returnIntermediate) {
+ if (typeof html === 'object') {
+ return handleIntermediate(html, handler);
+ }
+ var intermediate = [];
+ handler = handler || {};
+ if (returnIntermediate) {
+ each(tokenTypes, function (name) {
+ var callback = handler[name] || fn;
+ handler[name] = function () {
+ if (callback.apply(this, arguments) !== false) {
+ intermediate.push({
+ tokenType: name,
+ args: [].slice.call(arguments, 0)
+ });
+ }
+ };
+ });
+ }
+ function parseStartTag(tag, tagName, rest, unary) {
+ tagName = caseMatters[tagName] ? tagName : tagName.toLowerCase();
+ if (closeSelf[tagName] && stack.last() === tagName) {
+ parseEndTag('', tagName);
+ }
+ unary = empty[tagName] || !!unary;
+ handler.start(tagName, unary);
+ if (!unary) {
+ stack.push(tagName);
+ }
+ HTMLParser.parseAttrs(rest, handler);
+ handler.end(tagName, unary);
+ }
+ function parseEndTag(tag, tagName) {
+ var pos;
+ if (!tagName) {
+ pos = 0;
+ } else {
+ tagName = caseMatters[tagName] ? tagName : tagName.toLowerCase();
+ for (pos = stack.length - 1; pos >= 0; pos--) {
+ if (stack[pos] === tagName) {
+ break;
+ }
+ }
+ }
+ if (pos >= 0) {
+ for (var i = stack.length - 1; i >= pos; i--) {
+ if (handler.close) {
+ handler.close(stack[i]);
+ }
+ }
+ stack.length = pos;
+ }
+ }
+ function parseMustache(mustache, inside) {
+ if (handler.special) {
+ handler.special(inside);
+ }
+ }
+ var callChars = function () {
+ if (charsText) {
+ if (handler.chars) {
+ handler.chars(charsText);
+ }
+ }
+ charsText = '';
+ };
+ var index, chars, match, stack = [], last = html, charsText = '';
+ stack.last = function () {
+ return this[this.length - 1];
+ };
+ while (html) {
+ chars = true;
+ if (!stack.last() || !special[stack.last()]) {
+ if (html.indexOf('');
+ if (index >= 0) {
+ callChars();
+ if (handler.comment) {
+ handler.comment(html.substring(4, index));
+ }
+ html = html.substring(index + 3);
+ chars = false;
+ }
+ } else if (html.indexOf('') === 0) {
+ match = html.match(endTag);
+ if (match) {
+ callChars();
+ html = html.substring(match[0].length);
+ match[0].replace(endTag, parseEndTag);
+ chars = false;
+ }
+ } else if (html.indexOf('<') === 0) {
+ var res = HTMLParser.searchStartTag(html);
+ if (res) {
+ callChars();
+ html = res.html;
+ parseStartTag.apply(null, res.match);
+ chars = false;
+ }
+ } else if (html.indexOf('{{') === 0) {
+ match = html.match(mustache);
+ if (match) {
+ callChars();
+ html = html.substring(match[0].length);
+ match[0].replace(mustache, parseMustache);
+ }
+ }
+ if (chars) {
+ index = html.search(txtBreak);
+ if (index === 0 && html === last) {
+ charsText += html.charAt(0);
+ html = html.substr(1);
+ index = html.search(txtBreak);
+ }
+ var text = index < 0 ? html : html.substring(0, index);
+ html = index < 0 ? '' : html.substring(index);
+ if (text) {
+ charsText += text;
+ }
+ }
+ } else {
+ html = html.replace(new RegExp('([\\s\\S]*?)' + stack.last() + '[^>]*>'), function (all, text) {
+ text = text.replace(/|/g, '$1$2');
+ if (handler.chars) {
+ handler.chars(text);
+ }
+ return '';
+ });
+ parseEndTag('', stack.last());
+ }
+ if (html === last) {
+ throw new Error('Parse Error: ' + html);
+ }
+ last = html;
+ }
+ callChars();
+ parseEndTag();
+ handler.done();
+ return intermediate;
+ };
+ var callAttrStart = function (state, curIndex, handler, rest) {
+ var attrName = rest.substring(typeof state.nameStart === 'number' ? state.nameStart : curIndex, curIndex), newAttrName = attrName, oldAttrName = attrName;
+ if (camelCase.test(attrName)) {
+ newAttrName = attrName.replace(camelCase, camelCaseToSpinalCase);
+ }
+ state.attrStart = newAttrName;
+ handler.attrStart(state.attrStart);
+ state.inName = false;
+ };
+ var callAttrEnd = function (state, curIndex, handler, rest) {
+ if (state.valueStart !== undefined && state.valueStart < curIndex) {
+ handler.attrValue(rest.substring(state.valueStart, curIndex));
+ } else if (!state.inValue) {
+ }
+ handler.attrEnd(state.attrStart);
+ state.attrStart = undefined;
+ state.valueStart = undefined;
+ state.inValue = false;
+ state.inName = false;
+ state.lookingForEq = false;
+ state.inQuote = false;
+ state.lookingForName = true;
+ };
+ var camelCaseToSpinalCase = function (match, lowerCaseChar, upperCaseChar) {
+ return lowerCaseChar + '-' + upperCaseChar.toLowerCase();
+ };
+ HTMLParser.parseAttrs = function (rest, handler) {
+ if (!rest) {
+ return;
+ }
+ var i = 0;
+ var curIndex;
+ var state = {
+ inDoubleCurly: false,
+ inName: false,
+ nameStart: undefined,
+ inValue: false,
+ valueStart: undefined,
+ inQuote: false,
+ attrStart: undefined,
+ lookingForName: true,
+ lookingForValue: false,
+ lookingForEq: false
+ };
+ while (i < rest.length) {
+ curIndex = i;
+ var cur = rest.charAt(i);
+ var next = rest.charAt(i + 1);
+ var nextNext = rest.charAt(i + 2);
+ i++;
+ if (cur === '{' && next === '{') {
+ if (state.inValue && curIndex > state.valueStart) {
+ handler.attrValue(rest.substring(state.valueStart, curIndex));
+ } else if (state.inName && state.nameStart < curIndex) {
+ callAttrStart(state, curIndex, handler, rest);
+ callAttrEnd(state, curIndex, handler, rest);
+ } else if (state.lookingForValue) {
+ state.inValue = true;
+ } else if (state.lookingForEq && state.attrStart) {
+ callAttrEnd(state, curIndex, handler, rest);
+ }
+ state.inDoubleCurly = true;
+ state.doubleCurlyStart = curIndex + 2;
+ i++;
+ } else if (state.inDoubleCurly) {
+ if (cur === '}' && next === '}') {
+ var isTriple = nextNext === '}' ? 1 : 0;
+ handler.special(rest.substring(state.doubleCurlyStart, curIndex));
+ state.inDoubleCurly = false;
+ if (state.inValue) {
+ state.valueStart = curIndex + 2 + isTriple;
+ }
+ i += 1 + isTriple;
+ }
+ } else if (state.inValue) {
+ if (state.inQuote) {
+ if (cur === state.inQuote) {
+ callAttrEnd(state, curIndex, handler, rest);
+ }
+ } else if (space.test(cur)) {
+ callAttrEnd(state, curIndex, handler, rest);
+ }
+ } else if (cur === '=' && (state.lookingForEq || state.lookingForName || state.inName)) {
+ if (!state.attrStart) {
+ callAttrStart(state, curIndex, handler, rest);
+ if (i === rest.length) {
+ callAttrEnd(state, curIndex, handler, rest);
+ }
+ }
+ state.lookingForValue = true;
+ state.lookingForEq = false;
+ state.lookingForName = false;
+ } else if (state.inName) {
+ if (space.test(cur)) {
+ callAttrStart(state, curIndex, handler, rest);
+ state.lookingForEq = true;
+ }
+ } else if (state.lookingForName) {
+ if (!space.test(cur)) {
+ if (state.attrStart) {
+ callAttrEnd(state, curIndex, handler, rest);
+ }
+ state.nameStart = curIndex;
+ state.inName = true;
+ }
+ } else if (state.lookingForValue) {
+ if (!space.test(cur)) {
+ state.lookingForValue = false;
+ state.inValue = true;
+ if (cur === '\'' || cur === '"') {
+ state.inQuote = cur;
+ state.valueStart = curIndex + 1;
+ } else {
+ state.valueStart = curIndex;
+ }
+ } else if (i === rest.length) {
+ callAttrEnd(state, curIndex, handler, rest);
+ }
+ }
+ }
+ if (state.inName) {
+ callAttrStart(state, curIndex + 1, handler, rest);
+ callAttrEnd(state, curIndex + 1, handler, rest);
+ } else if (state.lookingForEq) {
+ callAttrEnd(state, curIndex + 1, handler, rest);
+ } else if (state.inValue) {
+ callAttrEnd(state, curIndex + 1, handler, rest);
+ }
+ };
+ HTMLParser.searchStartTag = function (html) {
+ var closingIndex = html.indexOf('>');
+ if (closingIndex === -1 || !alphaRegex.test(html[1])) {
+ return null;
+ }
+ var tagName, tagContent, match, rest = '', unary = '';
+ var startTag = html.substring(0, closingIndex + 1);
+ var isUnary = startTag[startTag.length - 2] === '/';
+ var spaceIndex = startTag.search(space);
+ if (isUnary) {
+ unary = '/';
+ tagContent = startTag.substring(1, startTag.length - 2).trim();
+ } else {
+ tagContent = startTag.substring(1, startTag.length - 1).trim();
+ }
+ if (spaceIndex === -1) {
+ tagName = tagContent;
+ } else {
+ spaceIndex--;
+ tagName = tagContent.substring(0, spaceIndex);
+ rest = tagContent.substring(spaceIndex);
+ }
+ match = [
+ startTag,
+ tagName,
+ rest,
+ unary
+ ];
+ return {
+ match: match,
+ html: html.substring(startTag.length)
+ };
+ };
+ module.exports = namespace.HTMLParser = HTMLParser;
+});
+/*can-util@3.0.10#js/set-immediate/set-immediate*/
+define('can-util@3.0.10#js/set-immediate/set-immediate', function (require, exports, module) {
+ (function (global) {
+ var global = require('../global/global')();
+ module.exports = global.setImmediate || function (cb) {
+ return setTimeout(cb, 0);
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.0.10#dom/mutation-observer/mutation-observer*/
+define('can-util@3.0.10#dom/mutation-observer/mutation-observer', function (require, exports, module) {
+ (function (global) {
+ var global = require('../../js/global/global')();
+ var setMutationObserver;
+ module.exports = function (setMO) {
+ if (setMO !== undefined) {
+ setMutationObserver = setMO;
+ }
+ return setMutationObserver !== undefined ? setMutationObserver : global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver;
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.0.10#dom/child-nodes/child-nodes*/
+define('can-util@3.0.10#dom/child-nodes/child-nodes', function (require, exports, module) {
+ function childNodes(node) {
+ var childNodes = node.childNodes;
+ if ('length' in childNodes) {
+ return childNodes;
+ } else {
+ var cur = node.firstChild;
+ var nodes = [];
+ while (cur) {
+ nodes.push(cur);
+ cur = cur.nextSibling;
+ }
+ return nodes;
+ }
+ }
+ module.exports = childNodes;
+});
+/*can-util@3.0.10#dom/contains/contains*/
+define('can-util@3.0.10#dom/contains/contains', function (require, exports, module) {
+ module.exports = function (child) {
+ return this.contains(child);
+ };
+});
+/*can-util@3.0.10#dom/mutate/mutate*/
+define('can-util@3.0.10#dom/mutate/mutate', function (require, exports, module) {
+ var makeArray = require('../../js/make-array/make-array');
+ var setImmediate = require('../../js/set-immediate/set-immediate');
+ var CID = require('../../js/cid/cid');
+ var getMutationObserver = require('../mutation-observer/mutation-observer');
+ var childNodes = require('../child-nodes/child-nodes');
+ var domContains = require('../contains/contains');
+ var domDispatch = require('../dispatch/dispatch');
+ var DOCUMENT = require('../document/document');
+ var mutatedElements;
+ var checks = {
+ inserted: function (root, elem) {
+ return domContains.call(root, elem);
+ },
+ removed: function (root, elem) {
+ return !domContains.call(root, elem);
+ }
+ };
+ var fireOn = function (elems, root, check, event, dispatched) {
+ if (!elems.length) {
+ return;
+ }
+ var children, cid;
+ for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) {
+ cid = CID(elem);
+ if (elem.getElementsByTagName && check(root, elem) && !dispatched[cid]) {
+ dispatched[cid] = true;
+ children = makeArray(elem.getElementsByTagName('*'));
+ domDispatch.call(elem, event, [], false);
+ for (var j = 0, child; (child = children[j]) !== undefined; j++) {
+ cid = CID(child);
+ if (!dispatched[cid]) {
+ domDispatch.call(child, event, [], false);
+ dispatched[cid] = true;
+ }
+ }
+ }
+ }
+ };
+ var fireMutations = function () {
+ var mutations = mutatedElements;
+ mutatedElements = null;
+ var firstElement = mutations[0][1][0];
+ var doc = DOCUMENT() || firstElement.ownerDocument || firstElement;
+ var root = doc.contains ? doc : doc.body;
+ var dispatched = {
+ inserted: {},
+ removed: {}
+ };
+ mutations.forEach(function (mutation) {
+ fireOn(mutation[1], root, checks[mutation[0]], mutation[0], dispatched[mutation[0]]);
+ });
+ };
+ var mutated = function (elements, type) {
+ if (!getMutationObserver() && elements.length) {
+ var firstElement = elements[0];
+ var doc = DOCUMENT() || firstElement.ownerDocument || firstElement;
+ var root = doc.contains ? doc : doc.body;
+ if (checks.inserted(root, firstElement)) {
+ if (!mutatedElements) {
+ mutatedElements = [];
+ setImmediate(fireMutations);
+ }
+ mutatedElements.push([
+ type,
+ elements
+ ]);
+ }
+ }
+ };
+ module.exports = {
+ appendChild: function (child) {
+ if (getMutationObserver()) {
+ this.appendChild(child);
+ } else {
+ var children;
+ if (child.nodeType === 11) {
+ children = makeArray(childNodes(child));
+ } else {
+ children = [child];
+ }
+ this.appendChild(child);
+ mutated(children, 'inserted');
+ }
+ },
+ insertBefore: function (child, ref, document) {
+ if (getMutationObserver()) {
+ this.insertBefore(child, ref);
+ } else {
+ var children;
+ if (child.nodeType === 11) {
+ children = makeArray(childNodes(child));
+ } else {
+ children = [child];
+ }
+ this.insertBefore(child, ref);
+ mutated(children, 'inserted');
+ }
+ },
+ removeChild: function (child) {
+ if (getMutationObserver()) {
+ this.removeChild(child);
+ } else {
+ mutated([child], 'removed');
+ this.removeChild(child);
+ }
+ },
+ replaceChild: function (newChild, oldChild) {
+ if (getMutationObserver()) {
+ this.replaceChild(newChild, oldChild);
+ } else {
+ var children;
+ if (newChild.nodeType === 11) {
+ children = makeArray(childNodes(newChild));
+ } else {
+ children = [newChild];
+ }
+ mutated([oldChild], 'removed');
+ this.replaceChild(newChild, oldChild);
+ mutated(children, 'inserted');
+ }
+ },
+ inserted: function (elements) {
+ mutated(elements, 'inserted');
+ },
+ removed: function (elements) {
+ mutated(elements, 'removed');
+ }
+ };
+});
+/*can-util@3.0.10#js/cid-map/cid-map*/
+define('can-util@3.0.10#js/cid-map/cid-map', function (require, exports, module) {
+ var GLOBAL = require('can-util/js/global/global');
+ var each = require('can-util/js/each/each');
+ var CID = require('can-util/js/cid/cid');
+ var domData = require('can-util/dom/data/data');
+ var CIDSet;
+ var getCID = function (obj) {
+ if (typeof obj.nodeType === 'number') {
+ return domData.cid.call(obj);
+ } else {
+ return CID(obj);
+ }
+ };
+ if (GLOBAL().Map) {
+ CIDSet = GLOBAL().Map;
+ } else {
+ var CIDSet = function () {
+ this.values = {};
+ };
+ CIDSet.prototype.set = function (key, value) {
+ this.values[getCID(key)] = value;
+ };
+ CIDSet.prototype['delete'] = function (key) {
+ var has = getCID(key) in this.values;
+ if (has) {
+ delete this.values[getCID(key)];
+ }
+ return has;
+ };
+ CIDSet.prototype.forEach = function (cb, thisArg) {
+ each(this.values, cb, thisArg);
+ };
+ CIDSet.prototype.has = function (key) {
+ return getCID(key) in this.values;
+ };
+ CIDSet.prototype.get = function (key) {
+ return this.values[getCID(key)];
+ };
+ CIDSet.prototype.clear = function (key) {
+ return this.values = {};
+ };
+ Object.defineProperty(CIDSet.prototype, 'size', {
+ get: function () {
+ var size = 0;
+ each(this.values, function () {
+ size++;
+ });
+ return size;
+ }
+ });
+ }
+ module.exports = CIDSet;
+});
+/*can-view-nodelist@3.0.1#can-view-nodelist*/
+define('can-view-nodelist@3.0.1#can-view-nodelist', function (require, exports, module) {
+ var makeArray = require('can-util/js/make-array/make-array');
+ var each = require('can-util/js/each/each');
+ var namespace = require('can-util/namespace');
+ var domMutate = require('can-util/dom/mutate/mutate');
+ var CIDMap = require('can-util/js/cid-map/cid-map');
+ var nodeMap = new CIDMap(), splice = [].splice, push = [].push, itemsInChildListTree = function (list) {
+ var count = 0;
+ for (var i = 0, len = list.length; i < len; i++) {
+ var item = list[i];
+ if (item.nodeType) {
+ count++;
+ } else {
+ count += itemsInChildListTree(item);
+ }
+ }
+ return count;
+ }, replacementMap = function (replacements, idMap) {
+ var map = new CIDMap();
+ for (var i = 0, len = replacements.length; i < len; i++) {
+ var node = nodeLists.first(replacements[i]);
+ map.set(node, replacements[i]);
+ }
+ return map;
+ }, addUnfoundAsDeepChildren = function (list, rMap) {
+ rMap.forEach(function (replacement) {
+ list.newDeepChildren.push(replacement);
+ });
+ };
+ var nodeLists = {
+ update: function (nodeList, newNodes) {
+ var oldNodes = nodeLists.unregisterChildren(nodeList);
+ newNodes = makeArray(newNodes);
+ var oldListLength = nodeList.length;
+ splice.apply(nodeList, [
+ 0,
+ oldListLength
+ ].concat(newNodes));
+ if (nodeList.replacements) {
+ nodeLists.nestReplacements(nodeList);
+ nodeList.deepChildren = nodeList.newDeepChildren;
+ nodeList.newDeepChildren = [];
+ } else {
+ nodeLists.nestList(nodeList);
+ }
+ return oldNodes;
+ },
+ nestReplacements: function (list) {
+ var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length;
+ while (index < list.length && rCount) {
+ var node = list[index], replacement = rMap.get(node);
+ if (replacement) {
+ rMap['delete'](node);
+ list.splice(index, itemsInChildListTree(replacement), replacement);
+ rCount--;
+ }
+ index++;
+ }
+ if (rCount) {
+ addUnfoundAsDeepChildren(list, rMap);
+ }
+ list.replacements = [];
+ },
+ nestList: function (list) {
+ var index = 0;
+ while (index < list.length) {
+ var node = list[index], childNodeList = nodeMap.get(node);
+ if (childNodeList) {
+ if (childNodeList !== list) {
+ list.splice(index, itemsInChildListTree(childNodeList), childNodeList);
+ }
+ } else {
+ nodeMap.set(node, list);
+ }
+ index++;
+ }
+ },
+ last: function (nodeList) {
+ var last = nodeList[nodeList.length - 1];
+ if (last.nodeType) {
+ return last;
+ } else {
+ return nodeLists.last(last);
+ }
+ },
+ first: function (nodeList) {
+ var first = nodeList[0];
+ if (first.nodeType) {
+ return first;
+ } else {
+ return nodeLists.first(first);
+ }
+ },
+ flatten: function (nodeList) {
+ var items = [];
+ for (var i = 0; i < nodeList.length; i++) {
+ var item = nodeList[i];
+ if (item.nodeType) {
+ items.push(item);
+ } else {
+ items.push.apply(items, nodeLists.flatten(item));
+ }
+ }
+ return items;
+ },
+ register: function (nodeList, unregistered, parent, directlyNested) {
+ nodeList.unregistered = unregistered;
+ nodeList.parentList = parent;
+ nodeList.nesting = parent && typeof parent.nesting !== 'undefined' ? parent.nesting + 1 : 0;
+ if (parent) {
+ nodeList.deepChildren = [];
+ nodeList.newDeepChildren = [];
+ nodeList.replacements = [];
+ if (parent !== true) {
+ if (directlyNested) {
+ parent.replacements.push(nodeList);
+ } else {
+ parent.newDeepChildren.push(nodeList);
+ }
+ }
+ } else {
+ nodeLists.nestList(nodeList);
+ }
+ return nodeList;
+ },
+ unregisterChildren: function (nodeList) {
+ var nodes = [];
+ each(nodeList, function (node) {
+ if (node.nodeType) {
+ if (!nodeList.replacements) {
+ nodeMap['delete'](node);
+ }
+ nodes.push(node);
+ } else {
+ push.apply(nodes, nodeLists.unregister(node, true));
+ }
+ });
+ each(nodeList.deepChildren, function (nodeList) {
+ nodeLists.unregister(nodeList, true);
+ });
+ return nodes;
+ },
+ unregister: function (nodeList, isChild) {
+ var nodes = nodeLists.unregisterChildren(nodeList, true);
+ if (nodeList.unregistered) {
+ var unregisteredCallback = nodeList.unregistered;
+ nodeList.replacements = nodeList.unregistered = null;
+ if (!isChild) {
+ var deepChildren = nodeList.parentList && nodeList.parentList.deepChildren;
+ if (deepChildren) {
+ var index = deepChildren.indexOf(nodeList);
+ if (index !== -1) {
+ deepChildren.splice(index, 1);
+ }
+ }
+ }
+ unregisteredCallback();
+ }
+ return nodes;
+ },
+ after: function (oldElements, newFrag) {
+ var last = oldElements[oldElements.length - 1];
+ if (last.nextSibling) {
+ domMutate.insertBefore.call(last.parentNode, newFrag, last.nextSibling);
+ } else {
+ domMutate.appendChild.call(last.parentNode, newFrag);
+ }
+ },
+ replace: function (oldElements, newFrag) {
+ var selectedValue, parentNode = oldElements[0].parentNode;
+ if (parentNode.nodeName.toUpperCase() === 'SELECT' && parentNode.selectedIndex >= 0) {
+ selectedValue = parentNode.value;
+ }
+ if (oldElements.length === 1) {
+ domMutate.replaceChild.call(parentNode, newFrag, oldElements[0]);
+ } else {
+ nodeLists.after(oldElements, newFrag);
+ nodeLists.remove(oldElements);
+ }
+ if (selectedValue !== undefined) {
+ parentNode.value = selectedValue;
+ }
+ },
+ remove: function (elementsToBeRemoved) {
+ var parent = elementsToBeRemoved[0] && elementsToBeRemoved[0].parentNode;
+ each(elementsToBeRemoved, function (child) {
+ domMutate.removeChild.call(parent, child);
+ });
+ },
+ nodeMap: nodeMap
+ };
+ module.exports = namespace.nodeLists = nodeLists;
+});
+/*can-util@3.0.10#dom/fragment/fragment*/
+define('can-util@3.0.10#dom/fragment/fragment', function (require, exports, module) {
+ var getDocument = require('../document/document'), childNodes = require('../child-nodes/child-nodes');
+ var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name, doc) {
+ if (name === undefined) {
+ name = fragmentRE.test(html) && RegExp.$1;
+ }
+ if (html && toString.call(html.replace) === '[object Function]') {
+ html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>$2>');
+ }
+ var container = doc.createElement('div'), temp = doc.createElement('div');
+ if (name === 'tbody' || name === 'tfoot' || name === 'thead' || name === 'colgroup') {
+ temp.innerHTML = '
';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild;
+ } else if (name === 'col') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild;
+ } else if (name === 'tr') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild;
+ } else if (name === 'td' || name === 'th') {
+ temp.innerHTML = '';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild;
+ } else if (name === 'option') {
+ temp.innerHTML = '' + html + ' ';
+ container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild;
+ } else {
+ container.innerHTML = '' + html;
+ }
+ var tmp = {}, children = childNodes(container);
+ tmp.length = children.length;
+ for (var i = 0; i < children.length; i++) {
+ tmp[i] = children[i];
+ }
+ return [].slice.call(tmp);
+ };
+ var buildFragment = function (html, doc) {
+ if (html && html.nodeType === 11) {
+ return html;
+ }
+ if (!doc) {
+ doc = getDocument();
+ } else if (doc.length) {
+ doc = doc[0];
+ }
+ var parts = fragment(html, undefined, doc), frag = (doc || document).createDocumentFragment();
+ for (var i = 0, length = parts.length; i < length; i++) {
+ frag.appendChild(parts[i]);
+ }
+ return frag;
+ };
+ module.exports = buildFragment;
+});
+/*can-util@3.0.10#dom/frag/frag*/
+define('can-util@3.0.10#dom/frag/frag', function (require, exports, module) {
+ var getDocument = require('../document/document');
+ var fragment = require('../fragment/fragment');
+ var each = require('../../js/each/each');
+ var childNodes = require('../child-nodes/child-nodes');
+ var makeFrag = function (item, doc) {
+ var document = doc || getDocument();
+ var frag;
+ if (!item || typeof item === 'string') {
+ frag = fragment(item == null ? '' : '' + item, document);
+ if (!frag.childNodes.length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ } else if (item.nodeType === 11) {
+ return item;
+ } else if (typeof item.nodeType === 'number') {
+ frag = document.createDocumentFragment();
+ frag.appendChild(item);
+ return frag;
+ } else if (typeof item.length === 'number') {
+ frag = document.createDocumentFragment();
+ each(item, function (item) {
+ frag.appendChild(makeFrag(item));
+ });
+ if (!childNodes(frag).length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ } else {
+ frag = fragment('' + item, document);
+ if (!childNodes(frag).length) {
+ frag.appendChild(document.createTextNode(''));
+ }
+ return frag;
+ }
+ };
+ module.exports = makeFrag;
+});
+/*can-util@3.0.10#dom/mutation-observer/document/document*/
+define('can-util@3.0.10#dom/mutation-observer/document/document', function (require, exports, module) {
+ var getDocument = require('../../document/document');
+ var domData = require('../../data/data');
+ module.exports = {
+ add: function (handler) {
+ var documentElement = getDocument().documentElement;
+ var globalObserverData = domData.get.call(documentElement, 'globalObserverData');
+ if (!globalObserverData) {
+ var observer = new MutationObserver(function (mutations) {
+ globalObserverData.handlers.forEach(function (handler) {
+ handler(mutations);
+ });
+ });
+ observer.observe(documentElement, {
+ childList: true,
+ subtree: true
+ });
+ globalObserverData = {
+ observer: observer,
+ handlers: []
+ };
+ domData.set.call(documentElement, 'globalObserverData', globalObserverData);
+ }
+ globalObserverData.handlers.push(handler);
+ },
+ remove: function (handler) {
+ var documentElement = getDocument().documentElement;
+ var globalObserverData = domData.get.call(documentElement, 'globalObserverData');
+ if (globalObserverData) {
+ var index = globalObserverData.handlers.indexOf(handler);
+ if (index >= 0) {
+ globalObserverData.handlers.splice(index, 1);
+ }
+ if (globalObserverData.handlers.length === 0) {
+ globalObserverData.observer.disconnect();
+ domData.clean.call(documentElement, 'globalObserverData');
+ }
+ }
+ }
+ };
+});
+/*can-util@3.0.10#js/cid-set/cid-set*/
+define('can-util@3.0.10#js/cid-set/cid-set', function (require, exports, module) {
+ var GLOBAL = require('can-util/js/global/global');
+ var each = require('can-util/js/each/each');
+ var CID = require('can-util/js/cid/cid');
+ var domData = require('can-util/dom/data/data');
+ var CIDSet;
+ var getCID = function (obj) {
+ if (typeof obj.nodeType === 'number') {
+ return domData.cid.call(obj);
+ } else {
+ return CID(obj);
+ }
+ };
+ if (GLOBAL().Set) {
+ CIDSet = GLOBAL().Set;
+ } else {
+ var CIDSet = function () {
+ this.values = {};
+ };
+ CIDSet.prototype.add = function (value) {
+ this.values[getCID(value)] = value;
+ };
+ CIDSet.prototype['delete'] = function (key) {
+ var has = getCID(key) in this.values;
+ if (has) {
+ delete this.values[getCID(key)];
+ }
+ return has;
+ };
+ CIDSet.prototype.forEach = function (cb, thisArg) {
+ each(this.values, cb, thisArg);
+ };
+ CIDSet.prototype.has = function (value) {
+ return this.values[getCID(value)];
+ };
+ CIDSet.prototype.clear = function (key) {
+ return this.values = {};
+ };
+ Object.defineProperty(CIDSet.prototype, 'size', {
+ get: function () {
+ var size = 0;
+ each(this.values, function () {
+ size++;
+ });
+ return size;
+ }
+ });
+ }
+ module.exports = CIDSet;
+});
+/*can-util@3.0.10#dom/is-of-global-document/is-of-global-document*/
+define('can-util@3.0.10#dom/is-of-global-document/is-of-global-document', function (require, exports, module) {
+ var getDocument = require('../document/document');
+ module.exports = function (el) {
+ return (el.ownerDocument || el) === getDocument();
+ };
+});
+/*can-util@3.0.10#dom/events/make-mutation-event/make-mutation-event*/
+define('can-util@3.0.10#dom/events/make-mutation-event/make-mutation-event', function (require, exports, module) {
+ var each = require('../../../js/each/');
+ var makeArray = require('../../../js/make-array/make-array');
+ var events = require('../events');
+ var domData = require('../../data/');
+ var getMutationObserver = require('../../mutation-observer/');
+ var domDispatch = require('../../dispatch/');
+ var mutationDocument = require('../../mutation-observer/document/');
+ var getDocument = require('../../document/');
+ var CIDStore = require('../../../js/cid-set/cid-set');
+ require('../../is-of-global-document/');
+ module.exports = function (specialEventName, mutationNodesProperty) {
+ var originalAdd = events.addEventListener, originalRemove = events.removeEventListener;
+ var dispatchIfListening = function (mutatedNode, specialEventData, dispatched) {
+ var doDispatch = true;
+ if (dispatched.has(mutatedNode)) {
+ return true;
+ }
+ dispatched.add(mutatedNode);
+ if (specialEventName === 'removed') {
+ var documentElement = getDocument().documentElement;
+ if (documentElement.contains(mutatedNode)) {
+ doDispatch = false;
+ }
+ }
+ if (doDispatch && specialEventData.nodeIdsRespondingToInsert.has(mutatedNode)) {
+ domDispatch.call(mutatedNode, specialEventName, [], false);
+ }
+ };
+ events.addEventListener = function (eventName) {
+ if (eventName === specialEventName && getMutationObserver()) {
+ var documentElement = getDocument().documentElement;
+ var specialEventData = domData.get.call(documentElement, specialEventName + 'Data');
+ if (!specialEventData) {
+ specialEventData = {
+ handler: function (mutations) {
+ var dispatched = new CIDStore();
+ mutations.forEach(function (mutation) {
+ each(mutation[mutationNodesProperty], function (mutatedNode) {
+ var children = mutatedNode.getElementsByTagName && makeArray(mutatedNode.getElementsByTagName('*'));
+ var alreadyChecked = dispatchIfListening(mutatedNode, specialEventData, dispatched);
+ if (children && !alreadyChecked) {
+ for (var j = 0, child; (child = children[j]) !== undefined; j++) {
+ dispatchIfListening(child, specialEventData, dispatched);
+ }
+ }
+ });
+ });
+ },
+ nodeIdsRespondingToInsert: new CIDStore()
+ };
+ mutationDocument.add(specialEventData.handler);
+ domData.set.call(documentElement, specialEventName + 'Data', specialEventData);
+ }
+ specialEventData.nodeIdsRespondingToInsert.add(this);
+ }
+ return originalAdd.apply(this, arguments);
+ };
+ events.removeEventListener = function (eventName) {
+ if (eventName === specialEventName && getMutationObserver()) {
+ var documentElement = getDocument().documentElement;
+ var specialEventData = domData.get.call(documentElement, specialEventName + 'Data');
+ if (specialEventData) {
+ specialEventData.nodeIdsRespondingToInsert['delete'](this);
+ if (!specialEventData.nodeIdsRespondingToInsert.size) {
+ mutationDocument.remove(specialEventData.handler);
+ domData.clean.call(documentElement, specialEventName + 'Data');
+ }
+ }
+ }
+ return originalRemove.apply(this, arguments);
+ };
+ };
+});
+/*can-util@3.0.10#dom/events/removed/removed*/
+define('can-util@3.0.10#dom/events/removed/removed', function (require, exports, module) {
+ var makeMutationEvent = require('../make-mutation-event/make-mutation-event');
+ makeMutationEvent('removed', 'removedNodes');
+});
+/*can-view-live@3.0.1#lib/core*/
+define('can-view-live@3.0.1#lib/core', function (require, exports, module) {
+ var parser = require('can-view-parser');
+ var domEvents = require('can-util/dom/events/events');
+ var nodeLists = require('can-view-nodelist');
+ var makeFrag = require('can-util/dom/frag/frag');
+ var childNodes = require('can-util/dom/child-nodes/child-nodes');
+ require('can-util/dom/events/removed/removed');
+ var childMutationCallbacks = {};
+ var live = {
+ setup: function (el, bind, unbind) {
+ var tornDown = false, teardown = function () {
+ if (!tornDown) {
+ tornDown = true;
+ unbind(data);
+ domEvents.removeEventListener.call(el, 'removed', teardown);
+ }
+ return true;
+ }, data = {
+ teardownCheck: function (parent) {
+ return parent ? false : teardown();
+ }
+ };
+ domEvents.addEventListener.call(el, 'removed', teardown);
+ bind(data);
+ return data;
+ },
+ listen: function (el, compute, change) {
+ return live.setup(el, function () {
+ compute.computeInstance.addEventListener('change', change);
+ }, function (data) {
+ compute.computeInstance.removeEventListener('change', change);
+ if (data.nodeList) {
+ nodeLists.unregister(data.nodeList);
+ }
+ });
+ },
+ getAttributeParts: function (newVal) {
+ var attrs = {}, attr;
+ parser.parseAttrs(newVal, {
+ attrStart: function (name) {
+ attrs[name] = '';
+ attr = name;
+ },
+ attrValue: function (value) {
+ attrs[attr] += value;
+ },
+ attrEnd: function () {
+ }
+ });
+ return attrs;
+ },
+ isNode: function (obj) {
+ return obj && obj.nodeType;
+ },
+ addTextNodeIfNoChildren: function (frag) {
+ if (!frag.firstChild) {
+ frag.appendChild(frag.ownerDocument.createTextNode(''));
+ }
+ },
+ registerChildMutationCallback: function (tag, callback) {
+ if (callback) {
+ childMutationCallbacks[tag] = callback;
+ } else {
+ return childMutationCallbacks[tag];
+ }
+ },
+ callChildMutationCallback: function (el) {
+ var callback = el && childMutationCallbacks[el.nodeName.toLowerCase()];
+ if (callback) {
+ callback(el);
+ }
+ },
+ replace: function (nodes, val, teardown) {
+ var oldNodes = nodes.slice(0), frag = makeFrag(val);
+ nodeLists.register(nodes, teardown);
+ nodeLists.update(nodes, childNodes(frag));
+ nodeLists.replace(oldNodes, frag);
+ return nodes;
+ },
+ getParentNode: function (el, defaultParentNode) {
+ return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode;
+ },
+ makeString: function (txt) {
+ return txt == null ? '' : '' + txt;
+ }
+ };
+ module.exports = live;
+});
+/*can-util@3.0.10#dom/events/attributes/attributes*/
+define('can-util@3.0.10#dom/events/attributes/attributes', function (require, exports, module) {
+ var events = require('../events');
+ var isOfGlobalDocument = require('../../is-of-global-document/is-of-global-document');
+ var domData = require('../../data/data');
+ var getMutationObserver = require('../../mutation-observer/mutation-observer');
+ var assign = require('../../../js/assign/assign');
+ var domDispatch = require('../../dispatch/dispatch');
+ var originalAdd = events.addEventListener, originalRemove = events.removeEventListener;
+ events.addEventListener = function (eventName) {
+ if (eventName === 'attributes') {
+ var MutationObserver = getMutationObserver();
+ if (isOfGlobalDocument(this) && MutationObserver) {
+ var self = this;
+ var observer = new MutationObserver(function (mutations) {
+ mutations.forEach(function (mutation) {
+ var copy = assign({}, mutation);
+ domDispatch.call(self, copy, [], false);
+ });
+ });
+ observer.observe(this, {
+ attributes: true,
+ attributeOldValue: true
+ });
+ domData.set.call(this, 'canAttributesObserver', observer);
+ } else {
+ domData.set.call(this, 'canHasAttributesBindings', true);
+ }
+ }
+ return originalAdd.apply(this, arguments);
+ };
+ events.removeEventListener = function (eventName) {
+ if (eventName === 'attributes') {
+ var MutationObserver = getMutationObserver();
+ var observer;
+ if (isOfGlobalDocument(this) && MutationObserver) {
+ observer = domData.get.call(this, 'canAttributesObserver');
+ if (observer && observer.disconnect) {
+ observer.disconnect();
+ domData.clean.call(this, 'canAttributesObserver');
+ }
+ } else {
+ domData.clean.call(this, 'canHasAttributesBindings');
+ }
+ }
+ return originalRemove.apply(this, arguments);
+ };
+});
+/*can-util@3.0.10#dom/attr/attr*/
+define('can-util@3.0.10#dom/attr/attr', function (require, exports, module) {
+ (function (global) {
+ var setImmediate = require('../../js/set-immediate/set-immediate');
+ var getDocument = require('../document/document');
+ var global = require('../../js/global/global')();
+ var isOfGlobalDocument = require('../is-of-global-document/is-of-global-document');
+ var setData = require('../data/data');
+ var domContains = require('../contains/contains');
+ var domEvents = require('../events/events');
+ var domDispatch = require('../dispatch/dispatch');
+ var MUTATION_OBSERVER = require('../mutation-observer/mutation-observer');
+ var each = require('../../js/each/each');
+ var types = require('../../js/types/types');
+ require('../events/attributes/attributes');
+ var namespaces = { 'xlink': 'http://www.w3.org/1999/xlink' };
+ var formElements = {
+ 'INPUT': true,
+ 'TEXTAREA': true,
+ 'SELECT': true
+ }, toString = function (value) {
+ if (value == null) {
+ return '';
+ } else {
+ return '' + value;
+ }
+ }, isSVG = function (el) {
+ return el.namespaceURI === 'http://www.w3.org/2000/svg';
+ }, truthy = function () {
+ return true;
+ }, getSpecialTest = function (special) {
+ return special && special.test || truthy;
+ }, propProp = function (prop, obj) {
+ obj = obj || {};
+ obj.get = function () {
+ return this[prop];
+ };
+ obj.set = function (value) {
+ if (this[prop] !== value) {
+ this[prop] = value;
+ }
+ return value;
+ };
+ return obj;
+ }, booleanProp = function (prop) {
+ return {
+ isBoolean: true,
+ set: function (value) {
+ if (prop in this) {
+ this[prop] = value !== false;
+ } else {
+ this.setAttribute(prop, '');
+ }
+ },
+ remove: function () {
+ this[prop] = false;
+ }
+ };
+ }, setupMO = function (el, callback) {
+ var attrMO = setData.get.call(el, 'attrMO');
+ if (!attrMO) {
+ var onMutation = function () {
+ callback.call(el);
+ };
+ var MO = MUTATION_OBSERVER();
+ if (MO) {
+ var observer = new MO(onMutation);
+ observer.observe(el, {
+ childList: true,
+ subtree: true
+ });
+ setData.set.call(el, 'attrMO', observer);
+ } else {
+ setData.set.call(el, 'attrMO', true);
+ setData.set.call(el, 'canBindingCallback', { onMutation: onMutation });
+ }
+ }
+ }, setChildOptions = function (el, value) {
+ if (value != null) {
+ var child = el.firstChild, hasSelected = false;
+ while (child) {
+ if (child.nodeName === 'OPTION') {
+ if (value === child.value) {
+ hasSelected = child.selected = true;
+ break;
+ }
+ }
+ child = child.nextSibling;
+ }
+ if (!hasSelected) {
+ el.selectedIndex = -1;
+ }
+ } else {
+ el.selectedIndex = -1;
+ }
+ }, setChildOptionsOnChange = function (select, aEL) {
+ var handler = setData.get.call(select, 'attrSetChildOptions');
+ if (handler) {
+ return Function.prototype;
+ }
+ handler = function () {
+ setChildOptions(select, select.value);
+ };
+ setData.set.call(select, 'attrSetChildOptions', handler);
+ aEL.call(select, 'change', handler);
+ return function (rEL) {
+ setData.clean.call(select, 'attrSetChildOptions');
+ rEL.call(select, 'change', handler);
+ };
+ }, attr = {
+ special: {
+ checked: {
+ get: function () {
+ return this.checked;
+ },
+ set: function (val) {
+ var notFalse = !!val || val === undefined || val === '';
+ this.checked = notFalse;
+ if (notFalse && this.type === 'radio') {
+ this.defaultChecked = true;
+ }
+ return val;
+ },
+ remove: function () {
+ this.checked = false;
+ },
+ test: function () {
+ return this.nodeName === 'INPUT';
+ }
+ },
+ 'class': {
+ get: function () {
+ if (isSVG(this)) {
+ return this.getAttribute('class');
+ }
+ return this.className;
+ },
+ set: function (val) {
+ val = val || '';
+ if (isSVG(this)) {
+ this.setAttribute('class', '' + val);
+ } else {
+ this.className = val;
+ }
+ return val;
+ }
+ },
+ disabled: booleanProp('disabled'),
+ focused: {
+ get: function () {
+ return this === document.activeElement;
+ },
+ set: function (val) {
+ var cur = attr.get(this, 'focused');
+ if (cur !== val) {
+ var element = this;
+ types.queueTask([
+ function () {
+ if (val) {
+ element.focus();
+ } else {
+ element.blur();
+ }
+ },
+ this,
+ []
+ ]);
+ }
+ return !!val;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ aEL.call(this, 'focus', handler);
+ aEL.call(this, 'blur', handler);
+ return function (rEL) {
+ rEL.call(this, 'focus', handler);
+ rEL.call(this, 'blur', handler);
+ };
+ },
+ test: function () {
+ return this.nodeName === 'INPUT';
+ }
+ },
+ 'for': propProp('htmlFor'),
+ innertext: propProp('innerText'),
+ innerhtml: propProp('innerHTML'),
+ innerHTML: propProp('innerHTML', {
+ addEventListener: function (eventName, handler, aEL) {
+ var handlers = [];
+ var el = this;
+ each([
+ 'change',
+ 'blur'
+ ], function (eventName) {
+ var localHandler = function () {
+ handler.apply(this, arguments);
+ };
+ domEvents.addEventListener.call(el, eventName, localHandler);
+ handlers.push([
+ eventName,
+ localHandler
+ ]);
+ });
+ return function (rEL) {
+ each(handlers, function (info) {
+ rEL.call(el, info[0], info[1]);
+ });
+ };
+ }
+ }),
+ required: booleanProp('required'),
+ readonly: booleanProp('readOnly'),
+ selected: {
+ get: function () {
+ return this.selected;
+ },
+ set: function (val) {
+ val = !!val;
+ setData.set.call(this, 'lastSetValue', val);
+ return this.selected = val;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ var option = this;
+ var select = this.parentNode;
+ var lastVal = option.selected;
+ var localHandler = function (changeEvent) {
+ var curVal = option.selected;
+ lastVal = setData.get.call(option, 'lastSetValue') || lastVal;
+ if (curVal !== lastVal) {
+ lastVal = curVal;
+ domDispatch.call(option, eventName);
+ }
+ };
+ var removeChangeHandler = setChildOptionsOnChange(select, aEL);
+ domEvents.addEventListener.call(select, 'change', localHandler);
+ aEL.call(option, eventName, handler);
+ return function (rEL) {
+ removeChangeHandler(rEL);
+ domEvents.removeEventListener.call(select, 'change', localHandler);
+ rEL.call(option, eventName, handler);
+ };
+ },
+ test: function () {
+ return this.nodeName === 'OPTION' && this.parentNode && this.parentNode.nodeName === 'SELECT';
+ }
+ },
+ src: {
+ set: function (val) {
+ if (val == null || val === '') {
+ this.removeAttribute('src');
+ return null;
+ } else {
+ this.setAttribute('src', val);
+ return val;
+ }
+ }
+ },
+ style: {
+ set: function () {
+ var el = global.document && getDocument().createElement('div');
+ if (el && el.style && 'cssText' in el.style) {
+ return function (val) {
+ return this.style.cssText = val || '';
+ };
+ } else {
+ return function (val) {
+ return this.setAttribute('style', val);
+ };
+ }
+ }()
+ },
+ textcontent: propProp('textContent'),
+ value: {
+ get: function () {
+ var value = this.value;
+ if (this.nodeName === 'SELECT') {
+ if ('selectedIndex' in this && this.selectedIndex === -1) {
+ value = undefined;
+ }
+ }
+ return value;
+ },
+ set: function (value) {
+ var nodeName = this.nodeName.toLowerCase();
+ if (nodeName === 'input') {
+ value = toString(value);
+ }
+ if (this.value !== value || nodeName === 'option') {
+ this.value = value;
+ }
+ if (attr.defaultValue[nodeName]) {
+ this.defaultValue = value;
+ }
+ if (nodeName === 'select') {
+ setData.set.call(this, 'attrValueLastVal', value);
+ setChildOptions(this, value === null ? value : this.value);
+ var docEl = this.ownerDocument.documentElement;
+ if (!domContains.call(docEl, this)) {
+ var select = this;
+ var initialSetHandler = function () {
+ domEvents.removeEventListener.call(select, 'inserted', initialSetHandler);
+ setChildOptions(select, value === null ? value : select.value);
+ };
+ domEvents.addEventListener.call(this, 'inserted', initialSetHandler);
+ }
+ setupMO(this, function () {
+ var value = setData.get.call(this, 'attrValueLastVal');
+ attr.set(this, 'value', value);
+ domDispatch.call(this, 'change');
+ });
+ }
+ return value;
+ },
+ test: function () {
+ return formElements[this.nodeName];
+ }
+ },
+ values: {
+ get: function () {
+ var values = [];
+ var child = this.firstChild;
+ while (child) {
+ if (child.nodeName === 'OPTION' && child.selected) {
+ values.push(child.value);
+ }
+ child = child.nextSibling;
+ }
+ setData.set.call(this, 'valuesLastVal', values);
+ return values;
+ },
+ set: function (values) {
+ values = values || [];
+ var child = this.firstChild;
+ while (child) {
+ if (child.nodeName === 'OPTION') {
+ child.selected = values.indexOf(child.value) !== -1;
+ }
+ child = child.nextSibling;
+ }
+ setData.set.call(this, 'valuesLastVal', values);
+ setupMO(this, function () {
+ var lastVal = setData.get.call(this, 'valuesLastVal');
+ attr.set(this, 'values', lastVal);
+ domDispatch.call(this, 'values');
+ });
+ return values;
+ },
+ addEventListener: function (eventName, handler, aEL) {
+ var localHandler = function () {
+ domDispatch.call(this, 'values');
+ };
+ domEvents.addEventListener.call(this, 'change', localHandler);
+ aEL.call(this, eventName, handler);
+ return function (rEL) {
+ domEvents.removeEventListener.call(this, 'change', localHandler);
+ rEL.call(this, eventName, handler);
+ };
+ }
+ }
+ },
+ defaultValue: {
+ input: true,
+ textarea: true
+ },
+ setAttrOrProp: function (el, attrName, val) {
+ attrName = attrName.toLowerCase();
+ var special = attr.special[attrName];
+ if (special && special.isBoolean && !val) {
+ this.remove(el, attrName);
+ } else {
+ this.set(el, attrName, val);
+ }
+ },
+ set: function (el, attrName, val) {
+ var usingMutationObserver = isOfGlobalDocument(el) && MUTATION_OBSERVER();
+ attrName = attrName.toLowerCase();
+ var oldValue;
+ if (!usingMutationObserver) {
+ oldValue = attr.get(el, attrName);
+ }
+ var newValue;
+ var special = attr.special[attrName];
+ var setter = special && special.set;
+ var test = getSpecialTest(special);
+ if (typeof setter === 'function' && test.call(el)) {
+ newValue = setter.call(el, val);
+ } else {
+ attr.setAttribute(el, attrName, val);
+ }
+ if (!usingMutationObserver && newValue !== oldValue) {
+ attr.trigger(el, attrName, oldValue);
+ }
+ },
+ setSelectValue: function (el, value) {
+ attr.set(el, 'value', value);
+ },
+ setAttribute: function () {
+ var doc = getDocument();
+ if (doc && document.createAttribute) {
+ try {
+ doc.createAttribute('{}');
+ } catch (e) {
+ var invalidNodes = {}, attributeDummy = document.createElement('div');
+ return function (el, attrName, val) {
+ var first = attrName.charAt(0), cachedNode, node, attr;
+ if ((first === '{' || first === '(' || first === '*') && el.setAttributeNode) {
+ cachedNode = invalidNodes[attrName];
+ if (!cachedNode) {
+ attributeDummy.innerHTML = '
';
+ cachedNode = invalidNodes[attrName] = attributeDummy.childNodes[0].attributes[0];
+ }
+ node = cachedNode.cloneNode();
+ node.value = val;
+ el.setAttributeNode(node);
+ } else {
+ attr = attrName.split(':');
+ if (attr.length !== 1) {
+ el.setAttributeNS(namespaces[attr[0]], attrName, val);
+ } else {
+ el.setAttribute(attrName, val);
+ }
+ }
+ };
+ }
+ }
+ return function (el, attrName, val) {
+ el.setAttribute(attrName, val);
+ };
+ }(),
+ trigger: function (el, attrName, oldValue) {
+ if (setData.get.call(el, 'canHasAttributesBindings')) {
+ attrName = attrName.toLowerCase();
+ return setImmediate(function () {
+ domDispatch.call(el, {
+ type: 'attributes',
+ attributeName: attrName,
+ target: el,
+ oldValue: oldValue,
+ bubbles: false
+ }, []);
+ });
+ }
+ },
+ get: function (el, attrName) {
+ attrName = attrName.toLowerCase();
+ var special = attr.special[attrName];
+ var getter = special && special.get;
+ var test = getSpecialTest(special);
+ if (typeof getter === 'function' && test.call(el)) {
+ return getter.call(el);
+ } else {
+ return el.getAttribute(attrName);
+ }
+ },
+ remove: function (el, attrName) {
+ attrName = attrName.toLowerCase();
+ var oldValue;
+ if (!MUTATION_OBSERVER()) {
+ oldValue = attr.get(el, attrName);
+ }
+ var special = attr.special[attrName];
+ var setter = special && special.set;
+ var remover = special && special.remove;
+ var test = getSpecialTest(special);
+ if (typeof remover === 'function' && test.call(el)) {
+ remover.call(el);
+ } else if (typeof setter === 'function' && test.call(el)) {
+ setter.call(el, undefined);
+ } else {
+ el.removeAttribute(attrName);
+ }
+ if (!MUTATION_OBSERVER() && oldValue != null) {
+ attr.trigger(el, attrName, oldValue);
+ }
+ },
+ has: function () {
+ var el = getDocument() && document.createElement('div');
+ if (el && el.hasAttribute) {
+ return function (el, name) {
+ return el.hasAttribute(name);
+ };
+ } else {
+ return function (el, name) {
+ return el.getAttribute(name) !== null;
+ };
+ }
+ }()
+ };
+ var oldAddEventListener = domEvents.addEventListener;
+ domEvents.addEventListener = function (eventName, handler) {
+ var special = attr.special[eventName];
+ if (special && special.addEventListener) {
+ var teardown = special.addEventListener.call(this, eventName, handler, oldAddEventListener);
+ var teardowns = setData.get.call(this, 'attrTeardowns');
+ if (!teardowns) {
+ setData.set.call(this, 'attrTeardowns', teardowns = {});
+ }
+ if (!teardowns[eventName]) {
+ teardowns[eventName] = [];
+ }
+ teardowns[eventName].push({
+ teardown: teardown,
+ handler: handler
+ });
+ return;
+ }
+ return oldAddEventListener.apply(this, arguments);
+ };
+ var oldRemoveEventListener = domEvents.removeEventListener;
+ domEvents.removeEventListener = function (eventName, handler) {
+ var special = attr.special[eventName];
+ if (special && special.addEventListener) {
+ var teardowns = setData.get.call(this, 'attrTeardowns');
+ if (teardowns && teardowns[eventName]) {
+ var eventTeardowns = teardowns[eventName];
+ for (var i = 0, len = eventTeardowns.length; i < len; i++) {
+ if (eventTeardowns[i].handler === handler) {
+ eventTeardowns[i].teardown.call(this, oldRemoveEventListener);
+ eventTeardowns.splice(i, 1);
+ break;
+ }
+ }
+ if (eventTeardowns.length === 0) {
+ delete teardowns[eventName];
+ }
+ }
+ return;
+ }
+ return oldRemoveEventListener.apply(this, arguments);
+ };
+ module.exports = exports = attr;
+ }(function () {
+ return this;
+ }()));
+});
+/*can-view-live@3.0.1#lib/attr*/
+define('can-view-live@3.0.1#lib/attr', function (require, exports, module) {
+ var attr = require('can-util/dom/attr/attr');
+ var live = require('./core');
+ live.attr = function (el, attributeName, compute) {
+ live.listen(el, compute, function (ev, newVal) {
+ attr.set(el, attributeName, newVal);
+ });
+ attr.set(el, attributeName, compute());
+ };
+});
+/*can-view-callbacks@3.0.1#can-view-callbacks*/
+define('can-view-callbacks@3.0.1#can-view-callbacks', function (require, exports, module) {
+ var Observation = require('can-observation');
+ var dev = require('can-util/js/dev/dev');
+ var getGlobal = require('can-util/js/global/global');
+ var domMutate = require('can-util/dom/mutate/mutate');
+ var namespace = require('can-util/namespace');
+ var attr = function (attributeName, attrHandler) {
+ if (attrHandler) {
+ if (typeof attributeName === 'string') {
+ attributes[attributeName] = attrHandler;
+ } else {
+ regExpAttributes.push({
+ match: attributeName,
+ handler: attrHandler
+ });
+ }
+ } else {
+ var cb = attributes[attributeName];
+ if (!cb) {
+ for (var i = 0, len = regExpAttributes.length; i < len; i++) {
+ var attrMatcher = regExpAttributes[i];
+ if (attrMatcher.match.test(attributeName)) {
+ cb = attrMatcher.handler;
+ break;
+ }
+ }
+ }
+ return cb;
+ }
+ };
+ var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/;
+ var tag = function (tagName, tagHandler) {
+ if (tagHandler) {
+ if (getGlobal().html5) {
+ getGlobal().html5.elements += ' ' + tagName;
+ getGlobal().html5.shivDocument();
+ }
+ tags[tagName.toLowerCase()] = tagHandler;
+ } else {
+ var cb;
+ if (tagHandler === null) {
+ delete tags[tagName.toLowerCase()];
+ } else {
+ cb = tags[tagName.toLowerCase()];
+ }
+ if (!cb && automaticCustomElementCharacters.test(tagName)) {
+ cb = function () {
+ };
+ }
+ return cb;
+ }
+ };
+ var tags = {};
+ var callbacks = {
+ _tags: tags,
+ _attributes: attributes,
+ _regExpAttributes: regExpAttributes,
+ tag: tag,
+ attr: attr,
+ tagHandler: function (el, tagName, tagData) {
+ var helperTagCallback = tagData.options.get('tags.' + tagName, { proxyMethods: false }), tagCallback = helperTagCallback || tags[tagName];
+ var scope = tagData.scope, res;
+ if (tagCallback) {
+ res = Observation.ignore(tagCallback)(el, tagData);
+ } else {
+ res = scope;
+ }
+ if (res && tagData.subtemplate) {
+ if (scope !== res) {
+ scope = scope.add(res);
+ }
+ var result = tagData.subtemplate(scope, tagData.options);
+ var frag = typeof result === 'string' ? can.view.frag(result) : result;
+ domMutate.appendChild.call(el, frag);
+ }
+ }
+ };
+ namespace.view = namespace.view || {};
+ module.exports = namespace.view.callbacks = callbacks;
+});
+/*can-view-live@3.0.1#lib/attrs*/
+define('can-view-live@3.0.1#lib/attrs', function (require, exports, module) {
+ var live = require('./core');
+ var viewCallbacks = require('can-view-callbacks');
+ var attr = require('can-util/dom/attr/attr');
+ var domEvents = require('can-util/dom/events/events');
+ var types = require('can-util/js/types/types');
+ live.attrs = function (el, compute, scope, options) {
+ if (!types.isCompute(compute)) {
+ var attrs = live.getAttributeParts(compute);
+ for (var name in attrs) {
+ attr.set(el, name, attrs[name]);
+ }
+ return;
+ }
+ var oldAttrs = {};
+ var setAttrs = function (newVal) {
+ var newAttrs = live.getAttributeParts(newVal), name;
+ for (name in newAttrs) {
+ var newValue = newAttrs[name], oldValue = oldAttrs[name];
+ if (newValue !== oldValue) {
+ attr.set(el, name, newValue);
+ var callback = viewCallbacks.attr(name);
+ if (callback) {
+ callback(el, {
+ attributeName: name,
+ scope: scope,
+ options: options
+ });
+ }
+ }
+ delete oldAttrs[name];
+ }
+ for (name in oldAttrs) {
+ attr.remove(el, name);
+ }
+ oldAttrs = newAttrs;
+ };
+ var handler = function (ev, newVal) {
+ setAttrs(newVal);
+ };
+ compute.addEventListener('change', handler);
+ domEvents.addEventListener.call(el, 'removed', function () {
+ compute.removeEventListener('change', handler);
+ });
+ setAttrs(compute());
+ };
+});
+/*can-view-live@3.0.1#lib/html*/
+define('can-view-live@3.0.1#lib/html', function (require, exports, module) {
+ var live = require('./core');
+ var nodeLists = require('can-view-nodelist');
+ var makeFrag = require('can-util/dom/frag/frag');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var childNodes = require('can-util/dom/child-nodes/child-nodes');
+ live.html = function (el, compute, parentNode, nodeList) {
+ var data;
+ parentNode = live.getParentNode(el, parentNode);
+ data = live.listen(parentNode, compute, function (ev, newVal, oldVal) {
+ var attached = nodeLists.first(nodes).parentNode;
+ if (attached) {
+ makeAndPut(newVal);
+ }
+ var pn = nodeLists.first(nodes).parentNode;
+ data.teardownCheck(pn);
+ live.callChildMutationCallback(pn);
+ });
+ var nodes = nodeList || [el], makeAndPut = function (val) {
+ var isFunction = typeof val === 'function', aNode = live.isNode(val), frag = makeFrag(isFunction ? '' : val), oldNodes = makeArray(nodes);
+ live.addTextNodeIfNoChildren(frag);
+ oldNodes = nodeLists.update(nodes, childNodes(frag));
+ if (isFunction) {
+ val(frag.firstChild);
+ }
+ nodeLists.replace(oldNodes, frag);
+ };
+ data.nodeList = nodes;
+ if (!nodeList) {
+ nodeLists.register(nodes, data.teardownCheck);
+ } else {
+ nodeList.unregistered = data.teardownCheck;
+ }
+ makeAndPut(compute());
+ };
+});
+/*can-util@3.0.10#js/diff/diff*/
+define('can-util@3.0.10#js/diff/diff', function (require, exports, module) {
+ var slice = [].slice;
+ module.exports = exports = function (oldList, newList) {
+ var oldIndex = 0, newIndex = 0, oldLength = oldList.length, newLength = newList.length, patches = [];
+ while (oldIndex < oldLength && newIndex < newLength) {
+ var oldItem = oldList[oldIndex], newItem = newList[newIndex];
+ if (oldItem === newItem) {
+ oldIndex++;
+ newIndex++;
+ continue;
+ }
+ if (newIndex + 1 < newLength && newList[newIndex + 1] === oldItem) {
+ patches.push({
+ index: newIndex,
+ deleteCount: 0,
+ insert: [newList[newIndex]]
+ });
+ oldIndex++;
+ newIndex += 2;
+ continue;
+ } else if (oldIndex + 1 < oldLength && oldList[oldIndex + 1] === newItem) {
+ patches.push({
+ index: newIndex,
+ deleteCount: 1,
+ insert: []
+ });
+ oldIndex += 2;
+ newIndex++;
+ continue;
+ } else {
+ patches.push({
+ index: newIndex,
+ deleteCount: oldLength - oldIndex,
+ insert: slice.call(newList, newIndex)
+ });
+ return patches;
+ }
+ }
+ if (newIndex === newLength && oldIndex === oldLength) {
+ return patches;
+ }
+ patches.push({
+ index: newIndex,
+ deleteCount: oldLength - oldIndex,
+ insert: slice.call(newList, newIndex)
+ });
+ return patches;
+ };
+});
+/*can-view-live@3.0.1#lib/list*/
+define('can-view-live@3.0.1#lib/list', function (require, exports, module) {
+ var live = require('./core');
+ var nodeLists = require('can-view-nodelist');
+ var makeCompute = require('can-compute');
+ var canBatch = require('can-event/batch/batch');
+ var frag = require('can-util/dom/frag/frag');
+ var domMutate = require('can-util/dom/mutate/mutate');
+ var childNodes = require('can-util/dom/child-nodes/child-nodes');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var each = require('can-util/js/each/each');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var diff = require('can-util/js/diff/diff');
+ var splice = [].splice;
+ var renderAndAddToNodeLists = function (newNodeLists, parentNodeList, render, context, args) {
+ var itemNodeList = [];
+ if (parentNodeList) {
+ nodeLists.register(itemNodeList, null, parentNodeList, true);
+ itemNodeList.parentList = parentNodeList;
+ itemNodeList.expression = '#each SUBEXPRESSION';
+ }
+ var itemHTML = render.apply(context, args.concat([itemNodeList])), itemFrag = frag(itemHTML);
+ var children = makeArray(childNodes(itemFrag));
+ if (parentNodeList) {
+ nodeLists.update(itemNodeList, children);
+ newNodeLists.push(itemNodeList);
+ } else {
+ newNodeLists.push(nodeLists.register(children));
+ }
+ return itemFrag;
+ }, removeFromNodeList = function (masterNodeList, index, length) {
+ var removedMappings = masterNodeList.splice(index + 1, length), itemsToRemove = [];
+ each(removedMappings, function (nodeList) {
+ var nodesToRemove = nodeLists.unregister(nodeList);
+ [].push.apply(itemsToRemove, nodesToRemove);
+ });
+ return itemsToRemove;
+ }, addFalseyIfEmpty = function (list, falseyRender, masterNodeList, nodeList) {
+ if (falseyRender && list.length === 0) {
+ var falseyNodeLists = [];
+ var falseyFrag = renderAndAddToNodeLists(falseyNodeLists, nodeList, falseyRender, list, [list]);
+ nodeLists.after([masterNodeList[0]], falseyFrag);
+ masterNodeList.push(falseyNodeLists[0]);
+ }
+ };
+ live.list = function (el, compute, render, context, parentNode, nodeList, falseyRender) {
+ var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) {
+ if (!afterPreviousEvents) {
+ return;
+ }
+ var frag = text.ownerDocument.createDocumentFragment(), newNodeLists = [], newIndicies = [];
+ each(items, function (item, key) {
+ var itemIndex = makeCompute(key + index), itemCompute = makeCompute(function (newVal) {
+ if (arguments.length) {
+ if ('set' in list) {
+ list.set(itemIndex(), newVal);
+ } else {
+ list.attr(itemIndex(), newVal);
+ }
+ } else {
+ return item;
+ }
+ }), itemFrag = renderAndAddToNodeLists(newNodeLists, nodeList, render, context, [
+ itemCompute,
+ itemIndex
+ ]);
+ frag.appendChild(itemFrag);
+ newIndicies.push(itemIndex);
+ });
+ var masterListIndex = index + 1;
+ if (!indexMap.length) {
+ var falseyItemsToRemove = removeFromNodeList(masterNodeList, 0, masterNodeList.length - 1);
+ nodeLists.remove(falseyItemsToRemove);
+ }
+ if (!masterNodeList[masterListIndex]) {
+ nodeLists.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag);
+ } else {
+ var el = nodeLists.first(masterNodeList[masterListIndex]);
+ domMutate.insertBefore.call(el.parentNode, frag, el);
+ }
+ splice.apply(masterNodeList, [
+ masterListIndex,
+ 0
+ ].concat(newNodeLists));
+ splice.apply(indexMap, [
+ index,
+ 0
+ ].concat(newIndicies));
+ for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) {
+ indexMap[i](i);
+ }
+ if (ev.callChildMutationCallback !== false) {
+ live.callChildMutationCallback(text.parentNode);
+ }
+ }, set = function (ev, newVal, index) {
+ remove({}, { length: 1 }, index, true);
+ add({}, [newVal], index);
+ }, remove = function (ev, items, index, duringTeardown, fullTeardown) {
+ if (!afterPreviousEvents) {
+ return;
+ }
+ if (!duringTeardown && data.teardownCheck(text.parentNode)) {
+ return;
+ }
+ if (index < 0) {
+ index = indexMap.length + index;
+ }
+ var itemsToRemove = removeFromNodeList(masterNodeList, index, items.length);
+ indexMap.splice(index, items.length);
+ for (var i = index, len = indexMap.length; i < len; i++) {
+ indexMap[i](i);
+ }
+ if (!fullTeardown) {
+ addFalseyIfEmpty(list, falseyRender, masterNodeList, nodeList);
+ nodeLists.remove(itemsToRemove);
+ if (ev.callChildMutationCallback !== false) {
+ live.callChildMutationCallback(text.parentNode);
+ }
+ } else {
+ nodeLists.unregister(masterNodeList);
+ }
+ }, move = function (ev, item, newIndex, currentIndex) {
+ if (!afterPreviousEvents) {
+ return;
+ }
+ newIndex = newIndex + 1;
+ currentIndex = currentIndex + 1;
+ var referenceNodeList = masterNodeList[newIndex];
+ var movedElements = frag(nodeLists.flatten(masterNodeList[currentIndex]));
+ var referenceElement;
+ if (currentIndex < newIndex) {
+ referenceElement = nodeLists.last(referenceNodeList).nextSibling;
+ } else {
+ referenceElement = nodeLists.first(referenceNodeList);
+ }
+ var parentNode = masterNodeList[0].parentNode;
+ parentNode.insertBefore(movedElements, referenceElement);
+ var temp = masterNodeList[currentIndex];
+ [].splice.apply(masterNodeList, [
+ currentIndex,
+ 1
+ ]);
+ [].splice.apply(masterNodeList, [
+ newIndex,
+ 0,
+ temp
+ ]);
+ newIndex = newIndex - 1;
+ currentIndex = currentIndex - 1;
+ var indexCompute = indexMap[currentIndex];
+ [].splice.apply(indexMap, [
+ currentIndex,
+ 1
+ ]);
+ [].splice.apply(indexMap, [
+ newIndex,
+ 0,
+ indexCompute
+ ]);
+ var i = Math.min(currentIndex, newIndex);
+ var len = indexMap.length;
+ for (i, len; i < len; i++) {
+ indexMap[i](i);
+ }
+ if (ev.callChildMutationCallback !== false) {
+ live.callChildMutationCallback(text.parentNode);
+ }
+ }, text = el.ownerDocument.createTextNode(''), list, teardownList = function (fullTeardown) {
+ if (list && list.removeEventListener) {
+ list.removeEventListener('add', add);
+ list.removeEventListener('set', set);
+ list.removeEventListener('remove', remove);
+ list.removeEventListener('move', move);
+ }
+ remove({ callChildMutationCallback: !!fullTeardown }, { length: masterNodeList.length - 1 }, 0, true, fullTeardown);
+ }, updateList = function (ev, newList, oldList) {
+ if (isTornDown) {
+ return;
+ }
+ afterPreviousEvents = true;
+ if (newList && oldList) {
+ list = newList || [];
+ var patches = diff(oldList, newList);
+ if (oldList.removeEventListener) {
+ oldList.removeEventListener('add', add);
+ oldList.removeEventListener('set', set);
+ oldList.removeEventListener('remove', remove);
+ oldList.removeEventListener('move', move);
+ }
+ for (var i = 0, patchLen = patches.length; i < patchLen; i++) {
+ var patch = patches[i];
+ if (patch.deleteCount) {
+ remove({ callChildMutationCallback: false }, { length: patch.deleteCount }, patch.index, true);
+ }
+ if (patch.insert.length) {
+ add({ callChildMutationCallback: false }, patch.insert, patch.index);
+ }
+ }
+ } else {
+ if (oldList) {
+ teardownList();
+ }
+ list = newList || [];
+ add({ callChildMutationCallback: false }, list, 0);
+ addFalseyIfEmpty(list, falseyRender, masterNodeList, nodeList);
+ }
+ live.callChildMutationCallback(text.parentNode);
+ afterPreviousEvents = false;
+ if (list.addEventListener) {
+ list.addEventListener('add', add);
+ list.addEventListener('set', set);
+ list.addEventListener('remove', remove);
+ list.addEventListener('move', move);
+ }
+ canBatch.afterPreviousEvents(function () {
+ afterPreviousEvents = true;
+ });
+ };
+ parentNode = live.getParentNode(el, parentNode);
+ var data = live.setup(parentNode, function () {
+ if (isFunction(compute)) {
+ compute.addEventListener('change', updateList);
+ }
+ }, function () {
+ if (isFunction(compute)) {
+ compute.removeEventListener('change', updateList);
+ }
+ teardownList(true);
+ });
+ if (!nodeList) {
+ live.replace(masterNodeList, text, data.teardownCheck);
+ } else {
+ nodeLists.replace(masterNodeList, text);
+ nodeLists.update(masterNodeList, [text]);
+ nodeList.unregistered = function () {
+ data.teardownCheck();
+ isTornDown = true;
+ };
+ }
+ updateList({}, isFunction(compute) ? compute() : compute);
+ };
+});
+/*can-view-live@3.0.1#lib/text*/
+define('can-view-live@3.0.1#lib/text', function (require, exports, module) {
+ var live = require('./core');
+ var nodeLists = require('can-view-nodelist');
+ live.text = function (el, compute, parentNode, nodeList) {
+ var parent = live.getParentNode(el, parentNode);
+ var data = live.listen(parent, compute, function (ev, newVal, oldVal) {
+ if (typeof node.nodeValue !== 'unknown') {
+ node.nodeValue = live.makeString(newVal);
+ }
+ data.teardownCheck(node.parentNode);
+ });
+ var node = el.ownerDocument.createTextNode(live.makeString(compute()));
+ if (nodeList) {
+ nodeList.unregistered = data.teardownCheck;
+ data.nodeList = nodeList;
+ nodeLists.update(nodeList, [node]);
+ nodeLists.replace([el], node);
+ } else {
+ data.nodeList = live.replace([el], node, data.teardownCheck);
+ }
+ };
+});
+/*can-view-live@3.0.1#can-view-live*/
+define('can-view-live@3.0.1#can-view-live', function (require, exports, module) {
+ var live = require('./lib/core');
+ require('./lib/attr');
+ require('./lib/attrs');
+ require('./lib/html');
+ require('./lib/list');
+ require('./lib/text');
+ module.exports = live;
+});
+/*can-util@3.0.10#js/base-url/base-url*/
+define('can-util@3.0.10#js/base-url/base-url', function (require, exports, module) {
+ (function (global) {
+ var getGlobal = require('../global/global');
+ var setBaseUrl;
+ module.exports = function (setUrl) {
+ if (setUrl !== undefined) {
+ setBaseUrl = setUrl;
+ }
+ if (setBaseUrl !== undefined) {
+ return setBaseUrl;
+ }
+ var global = getGlobal();
+ if (global.location) {
+ var href = global.location.href;
+ var lastSlash = href.lastIndexOf('/');
+ return lastSlash !== -1 ? href.substr(0, lastSlash) : href;
+ } else if (typeof process !== 'undefined') {
+ return process.cwd();
+ }
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-util@3.0.10#js/parse-uri/parse-uri*/
+define('can-util@3.0.10#js/parse-uri/parse-uri', function (require, exports, module) {
+ module.exports = function (url) {
+ var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ return m ? {
+ href: m[0] || '',
+ protocol: m[1] || '',
+ authority: m[2] || '',
+ host: m[3] || '',
+ hostname: m[4] || '',
+ port: m[5] || '',
+ pathname: m[6] || '',
+ search: m[7] || '',
+ hash: m[8] || ''
+ } : null;
+ };
+});
+/*can-util@3.0.10#js/join-uris/join-uris*/
+define('can-util@3.0.10#js/join-uris/join-uris', function (require, exports, module) {
+ var parseURI = require('../parse-uri/parse-uri');
+ module.exports = function (base, href) {
+ function removeDotSegments(input) {
+ var output = [];
+ input.replace(/^(\.\.?(\/|$))+/, '').replace(/\/(\.(\/|$))+/g, '/').replace(/\/\.\.$/, '/../').replace(/\/?[^\/]*/g, function (p) {
+ if (p === '/..') {
+ output.pop();
+ } else {
+ output.push(p);
+ }
+ });
+ return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
+ }
+ href = parseURI(href || '');
+ base = parseURI(base || '');
+ return !href || !base ? null : (href.protocol || base.protocol) + (href.protocol || href.authority ? href.authority : base.authority) + removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : href.pathname ? (base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname : base.pathname) + (href.protocol || href.authority || href.pathname ? href.search : href.search || base.search) + href.hash;
+ };
+});
+/*can-stache@3.0.7#helpers/core*/
+define('can-stache@3.0.7#helpers/core', function (require, exports, module) {
+ var live = require('can-view-live');
+ var nodeLists = require('can-view-nodelist');
+ var compute = require('can-compute');
+ var utils = require('../src/utils');
+ var types = require('can-util/js/types/types');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var getBaseURL = require('can-util/js/base-url/base-url');
+ var joinURIs = require('can-util/js/join-uris/join-uris');
+ var each = require('can-util/js/each/each');
+ var assign = require('can-util/js/assign/assign');
+ var isIterable = require('can-util/js/is-iterable/is-iterable');
+ var domData = require('can-util/dom/data/data');
+ var looksLikeOptions = function (options) {
+ return options && typeof options.fn === 'function' && typeof options.inverse === 'function';
+ };
+ var resolve = function (value) {
+ if (isFunction(value)) {
+ return value();
+ } else {
+ return value;
+ }
+ };
+ var resolveHash = function (hash) {
+ var params = {};
+ for (var prop in hash) {
+ var value = hash[prop];
+ if (value && value.isComputed) {
+ params[prop] = value();
+ } else {
+ params[prop] = value;
+ }
+ }
+ return params;
+ };
+ var helpers = {
+ 'each': function (items) {
+ var args = [].slice.call(arguments), options = args.pop(), argsLen = args.length, argExprs = options.exprData.argExprs, resolved = resolve(items), asVariable, aliases, keys, key, i;
+ if (argsLen === 2 || argsLen === 3 && argExprs[1].key === 'as') {
+ asVariable = args[argsLen - 1];
+ if (typeof asVariable !== 'string') {
+ asVariable = argExprs[argsLen - 1].key;
+ }
+ }
+ if (types.isListLike(resolved) && !options.stringOnly) {
+ return function (el) {
+ var nodeList = [el];
+ nodeList.expression = 'live.list';
+ nodeLists.register(nodeList, null, options.nodeList, true);
+ nodeLists.update(options.nodeList, [el]);
+ var cb = function (item, index, parentNodeList) {
+ var aliases = {
+ '%index': index,
+ '@index': index
+ };
+ if (asVariable) {
+ aliases[asVariable] = item;
+ }
+ return options.fn(options.scope.add(aliases, { notContext: true }).add(item), options.options, parentNodeList);
+ };
+ live.list(el, items, cb, options.context, el.parentNode, nodeList, function (list, parentNodeList) {
+ return options.inverse(options.scope.add(list), options.options, parentNodeList);
+ });
+ };
+ }
+ var expr = resolved, result;
+ if (!!expr && utils.isArrayLike(expr)) {
+ result = utils.getItemsFragContent(expr, options, options.scope, asVariable);
+ return options.stringOnly ? result.join('') : result;
+ } else if (isIterable(expr)) {
+ result = [];
+ each(expr, function (value, key) {
+ aliases = { '%key': key };
+ if (asVariable) {
+ aliases[asVariable] = value;
+ }
+ result.push(options.fn(options.scope.add(aliases, { notContext: true }).add(value)));
+ });
+ return options.stringOnly ? result.join('') : result;
+ } else if (types.isMapLike(expr)) {
+ keys = expr.constructor.keys(expr);
+ result = [];
+ for (i = 0; i < keys.length; i++) {
+ key = keys[i];
+ var value = compute(expr, key);
+ aliases = {
+ '%key': key,
+ '@key': key
+ };
+ if (asVariable) {
+ aliases[asVariable] = expr[key];
+ }
+ result.push(options.fn(options.scope.add(aliases, { notContext: true }).add(value)));
+ }
+ return options.stringOnly ? result.join('') : result;
+ } else if (expr instanceof Object) {
+ result = [];
+ for (key in expr) {
+ aliases = {
+ '%key': key,
+ '@key': key
+ };
+ if (asVariable) {
+ aliases[asVariable] = expr[key];
+ }
+ result.push(options.fn(options.scope.add(aliases, { notContext: true }).add(expr[key])));
+ }
+ return options.stringOnly ? result.join('') : result;
+ }
+ },
+ '@index': function (offset, options) {
+ if (!options) {
+ options = offset;
+ offset = 0;
+ }
+ var index = options.scope.peak('@index');
+ return '' + ((isFunction(index) ? index() : index) + offset);
+ },
+ 'if': function (expr, options) {
+ var value;
+ if (isFunction(expr)) {
+ value = compute.truthy(expr)();
+ } else {
+ value = !!resolve(expr);
+ }
+ if (value) {
+ return options.fn(options.scope || this);
+ } else {
+ return options.inverse(options.scope || this);
+ }
+ },
+ 'is': function () {
+ var lastValue, curValue, options = arguments[arguments.length - 1];
+ if (arguments.length - 2 <= 0) {
+ return options.inverse();
+ }
+ var args = arguments;
+ var callFn = compute(function () {
+ for (var i = 0; i < args.length - 1; i++) {
+ curValue = resolve(args[i]);
+ curValue = isFunction(curValue) ? curValue() : curValue;
+ if (i > 0) {
+ if (curValue !== lastValue) {
+ return false;
+ }
+ }
+ lastValue = curValue;
+ }
+ return true;
+ });
+ return callFn() ? options.fn() : options.inverse();
+ },
+ 'eq': function () {
+ return helpers.is.apply(this, arguments);
+ },
+ 'unless': function (expr, options) {
+ return helpers['if'].apply(this, [
+ expr,
+ assign(assign({}, options), {
+ fn: options.inverse,
+ inverse: options.fn
+ })
+ ]);
+ },
+ 'with': function (expr, options) {
+ var ctx = expr;
+ expr = resolve(expr);
+ if (!!expr) {
+ return options.fn(ctx);
+ }
+ },
+ 'log': function (options) {
+ var logs = [];
+ each(arguments, function (val) {
+ if (!looksLikeOptions(val)) {
+ logs.push(val);
+ }
+ });
+ if (typeof console !== 'undefined' && console.log) {
+ if (!logs.length) {
+ console.log(options.context);
+ } else {
+ console.log.apply(console, logs);
+ }
+ }
+ },
+ 'data': function (attr) {
+ var data = arguments.length === 2 ? this : arguments[1];
+ return function (el) {
+ domData.set.call(el, attr, data || this.context);
+ };
+ },
+ 'switch': function (expression, options) {
+ resolve(expression);
+ var found = false;
+ var newOptions = options.helpers.add({
+ 'case': function (value, options) {
+ if (!found && resolve(expression) === resolve(value)) {
+ found = true;
+ return options.fn(options.scope || this);
+ }
+ },
+ 'default': function (options) {
+ if (!found) {
+ return options.fn(options.scope || this);
+ }
+ }
+ });
+ return options.fn(options.scope, newOptions);
+ },
+ 'joinBase': function (firstExpr) {
+ var args = [].slice.call(arguments);
+ var options = args.pop();
+ var moduleReference = args.map(function (expr) {
+ var value = resolve(expr);
+ return isFunction(value) ? value() : value;
+ }).join('');
+ var templateModule = options.helpers.peak('helpers.module');
+ var parentAddress = templateModule ? templateModule.uri : undefined;
+ var isRelative = moduleReference[0] === '.';
+ if (isRelative && parentAddress) {
+ return joinURIs(parentAddress, moduleReference);
+ } else {
+ var baseURL = typeof System !== 'undefined' && (System.renderingLoader && System.renderingLoader.baseURL || System.baseURL) || getBaseURL();
+ if (moduleReference[0] !== '/' && baseURL[baseURL.length - 1] !== '/') {
+ baseURL += '/';
+ }
+ return joinURIs(baseURL, moduleReference);
+ }
+ }
+ };
+ helpers.eachOf = helpers.each;
+ var registerHelper = function (name, callback) {
+ helpers[name] = callback;
+ };
+ var makeSimpleHelper = function (fn) {
+ return function () {
+ var realArgs = [];
+ each(arguments, function (val, i) {
+ if (i <= arguments.length) {
+ while (val && val.isComputed) {
+ val = val();
+ }
+ realArgs.push(val);
+ }
+ });
+ return fn.apply(this, realArgs);
+ };
+ };
+ module.exports = {
+ registerHelper: registerHelper,
+ registerSimpleHelper: function (name, callback) {
+ registerHelper(name, makeSimpleHelper(callback));
+ },
+ getHelper: function (name, options) {
+ var helper = options && options.get && options.get('helpers.' + name, { proxyMethods: false });
+ if (!helper) {
+ helper = helpers[name];
+ }
+ if (helper) {
+ return { fn: helper };
+ }
+ },
+ resolve: resolve,
+ resolveHash: resolveHash,
+ looksLikeOptions: looksLikeOptions
+ };
+});
+/*can-stache@3.0.7#src/expression*/
+define('can-stache@3.0.7#src/expression', function (require, exports, module) {
+ var Scope = require('can-view-scope');
+ var compute = require('can-compute');
+ var observeReader = require('can-observation/reader/reader');
+ var utils = require('./utils');
+ var mustacheHelpers = require('../helpers/core');
+ var each = require('can-util/js/each/each');
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ var dev = require('can-util/js/dev/dev');
+ var assign = require('can-util/js/assign/assign');
+ var last = require('can-util/js/last/last');
+ var getKeyComputeData = function (key, scope, readOptions) {
+ var data = scope.computeData(key, readOptions);
+ compute.temporarilyBind(data.compute);
+ return data;
+ }, lookupValue = function (key, scope, helperOptions, readOptions) {
+ var prop = getValueOfComputeOrFunction(key);
+ var computeData = getKeyComputeData(prop, scope, readOptions);
+ if (!computeData.compute.computeInstance.hasDependencies) {
+ return {
+ value: computeData.initialValue,
+ computeData: computeData
+ };
+ } else {
+ return {
+ value: computeData.compute,
+ computeData: computeData
+ };
+ }
+ }, lookupValueOrHelper = function (key, scope, helperOptions, readOptions) {
+ var res = lookupValue(key, scope, helperOptions, readOptions);
+ if (res.computeData.initialValue === undefined) {
+ if (key.charAt(0) === '@' && key !== '@index') {
+ key = key.substr(1);
+ }
+ var helper = mustacheHelpers.getHelper(key, helperOptions);
+ res.helper = helper && helper.fn;
+ }
+ return res;
+ }, lookupValueInResult = function (keyOrCompute, lookupOrCall, scope, helperOptions, readOptions) {
+ var result = lookupOrCall.value(scope, {}, {});
+ var c = compute(function (newVal) {
+ var key = getValueOfComputeOrFunction(keyOrCompute);
+ if (arguments.length) {
+ observeReader.write(result, observeReader.reads(key), newVal);
+ } else {
+ return observeReader.get(result, key);
+ }
+ });
+ return { value: c };
+ }, getValueOfComputeOrFunction = function (computeOrFunction) {
+ if (typeof computeOrFunction.value === 'function') {
+ return computeOrFunction.value();
+ }
+ if (typeof computeOrFunction === 'function') {
+ return computeOrFunction();
+ }
+ return computeOrFunction;
+ }, convertToArgExpression = function (expr) {
+ if (!(expr instanceof Arg) && !(expr instanceof Literal)) {
+ return new Arg(expr);
+ } else {
+ return expr;
+ }
+ };
+ var Bracket = function (key, root) {
+ this.root = root;
+ this.key = key;
+ };
+ Bracket.prototype.value = function (scope) {
+ var prop = this.key;
+ var obj = this.root;
+ if (prop instanceof Lookup) {
+ prop = lookupValue(prop.key, scope, {}, {});
+ } else if (prop instanceof Call) {
+ prop = prop.value(scope, {}, {});
+ }
+ if (!obj) {
+ return lookupValue(prop, scope, {}, {}).value;
+ } else {
+ return lookupValueInResult(prop, obj, scope, {}, {}).value;
+ }
+ };
+ var Literal = function (value) {
+ this._value = value;
+ };
+ Literal.prototype.value = function () {
+ return this._value;
+ };
+ var Lookup = function (key, root) {
+ this.key = key;
+ this.rootExpr = root;
+ };
+ Lookup.prototype.value = function (scope, helperOptions) {
+ var result = {};
+ if (this.rootExpr) {
+ result = lookupValueInResult(this.key, this.rootExpr, scope, {}, {});
+ } else {
+ result = lookupValueOrHelper(this.key, scope, helperOptions);
+ }
+ this.isHelper = result.helper && !result.helper.callAsMethod;
+ return result.helper || result.value;
+ };
+ var ScopeLookup = function (key, root) {
+ Lookup.apply(this, arguments);
+ };
+ ScopeLookup.prototype.value = function (scope, helperOptions) {
+ return lookupValue(this.key, scope, helperOptions).value;
+ };
+ var Arg = function (expression, modifiers) {
+ this.expr = expression;
+ this.modifiers = modifiers || {};
+ this.isCompute = false;
+ };
+ Arg.prototype.value = function () {
+ return this.expr.value.apply(this.expr, arguments);
+ };
+ var Hash = function () {
+ };
+ var Hashes = function (hashes) {
+ this.hashExprs = hashes;
+ };
+ Hashes.prototype.value = function (scope, helperOptions) {
+ var hash = {};
+ for (var prop in this.hashExprs) {
+ var val = convertToArgExpression(this.hashExprs[prop]), value = val.value.apply(val, arguments);
+ hash[prop] = {
+ call: value && value.isComputed && !val.modifiers.compute,
+ value: value
+ };
+ }
+ return compute(function () {
+ var finalHash = {};
+ for (var prop in hash) {
+ finalHash[prop] = hash[prop].call ? hash[prop].value() : hash[prop].value;
+ }
+ return finalHash;
+ });
+ };
+ var Call = function (methodExpression, argExpressions) {
+ this.methodExpr = methodExpression;
+ this.argExprs = argExpressions.map(convertToArgExpression);
+ };
+ Call.prototype.args = function (scope, helperOptions) {
+ var args = [];
+ for (var i = 0, len = this.argExprs.length; i < len; i++) {
+ var arg = this.argExprs[i];
+ var value = arg.value.apply(arg, arguments);
+ args.push({
+ call: value && value.isComputed && !arg.modifiers.compute,
+ value: value
+ });
+ }
+ return function () {
+ var finalArgs = [];
+ for (var i = 0, len = args.length; i < len; i++) {
+ finalArgs[i] = args[i].call ? args[i].value() : args[i].value;
+ }
+ return finalArgs;
+ };
+ };
+ Call.prototype.value = function (scope, helperScope, helperOptions) {
+ var method = this.methodExpr.value(scope, helperScope);
+ var isHelper = this.isHelper = this.methodExpr.isHelper;
+ var getArgs = this.args(scope, helperScope);
+ return compute(function (newVal) {
+ var func = method;
+ if (func && func.isComputed) {
+ func = func();
+ }
+ if (typeof func === 'function') {
+ var args = getArgs();
+ if (isHelper && helperOptions) {
+ args.push(helperOptions);
+ }
+ if (arguments.length) {
+ args.unshift(new expression.SetIdentifier(newVal));
+ }
+ return func.apply(null, args);
+ }
+ });
+ };
+ var HelperLookup = function () {
+ Lookup.apply(this, arguments);
+ };
+ HelperLookup.prototype.value = function (scope, helperOptions) {
+ var result = lookupValueOrHelper(this.key, scope, helperOptions, {
+ isArgument: true,
+ args: [
+ scope.peak('.'),
+ scope
+ ]
+ });
+ return result.helper || result.value;
+ };
+ var HelperScopeLookup = function () {
+ Lookup.apply(this, arguments);
+ };
+ HelperScopeLookup.prototype.value = function (scope, helperOptions) {
+ return lookupValue(this.key, scope, helperOptions, {
+ callMethodsOnObservables: true,
+ isArgument: true,
+ args: [
+ scope.peak('.'),
+ scope
+ ]
+ }).value;
+ };
+ var Helper = function (methodExpression, argExpressions, hashExpressions) {
+ this.methodExpr = methodExpression;
+ this.argExprs = argExpressions;
+ this.hashExprs = hashExpressions;
+ this.mode = null;
+ };
+ Helper.prototype.args = function (scope, helperOptions) {
+ var args = [];
+ for (var i = 0, len = this.argExprs.length; i < len; i++) {
+ var arg = this.argExprs[i];
+ args.push(arg.value.apply(arg, arguments));
+ }
+ return args;
+ };
+ Helper.prototype.hash = function (scope, helperOptions) {
+ var hash = {};
+ for (var prop in this.hashExprs) {
+ var val = this.hashExprs[prop];
+ hash[prop] = val.value.apply(val, arguments);
+ }
+ return hash;
+ };
+ Helper.prototype.helperAndValue = function (scope, helperOptions) {
+ var looksLikeAHelper = this.argExprs.length || !isEmptyObject(this.hashExprs), helper, value, methodKey = this.methodExpr instanceof Literal ? '' + this.methodExpr._value : this.methodExpr.key, initialValue, args;
+ if (looksLikeAHelper) {
+ helper = mustacheHelpers.getHelper(methodKey, helperOptions);
+ var context = scope.peak('.');
+ if (!helper && typeof context[methodKey] === 'function') {
+ helper = { fn: context[methodKey] };
+ }
+ }
+ if (!helper) {
+ args = this.args(scope, helperOptions);
+ var computeData = getKeyComputeData(methodKey, scope, {
+ isArgument: false,
+ args: args && args.length ? args : [
+ scope.peak('.'),
+ scope
+ ]
+ }), compute = computeData.compute;
+ initialValue = computeData.initialValue;
+ if (computeData.compute.computeInstance.hasDependencies) {
+ value = compute;
+ } else {
+ value = initialValue;
+ }
+ if (!looksLikeAHelper && initialValue === undefined) {
+ helper = mustacheHelpers.getHelper(methodKey, helperOptions);
+ }
+ }
+ return {
+ value: value,
+ args: args,
+ helper: helper && helper.fn
+ };
+ };
+ Helper.prototype.evaluator = function (helper, scope, helperOptions, readOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly) {
+ var helperOptionArg = {
+ fn: function () {
+ },
+ inverse: function () {
+ },
+ stringOnly: stringOnly
+ }, context = scope.peak('.'), args = this.args(scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly), hash = this.hash(scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ utils.convertToScopes(helperOptionArg, scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ assign(helperOptionArg, {
+ context: context,
+ scope: scope,
+ contexts: scope,
+ hash: hash,
+ nodeList: nodeList,
+ exprData: this,
+ helperOptions: helperOptions,
+ helpers: helperOptions
+ });
+ args.push(helperOptionArg);
+ return function () {
+ return helper.apply(context, args);
+ };
+ };
+ Helper.prototype.value = function (scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly) {
+ var helperAndValue = this.helperAndValue(scope, helperOptions);
+ var helper = helperAndValue.helper;
+ if (!helper) {
+ return helperAndValue.value;
+ }
+ var fn = this.evaluator(helper, scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ var computeValue = compute(fn);
+ compute.temporarilyBind(computeValue);
+ if (!computeValue.computeInstance.hasDependencies) {
+ return computeValue();
+ } else {
+ return computeValue;
+ }
+ };
+ var keyRegExp = /[\w\.\\\-_@\/\&%]+/, tokensRegExp = /('.*?'|".*?"|=|[\w\.\\\-_@\/*%\$]+|[\(\)]|,|\~|\[|\]|\s*(?=\[))/g, literalRegExp = /^('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)$/;
+ var isTokenKey = function (token) {
+ return keyRegExp.test(token);
+ };
+ var testDot = /^[\.@]\w/;
+ var isAddingToExpression = function (token) {
+ return isTokenKey(token) && testDot.test(token);
+ };
+ var ensureChildren = function (type) {
+ if (!type.children) {
+ type.children = [];
+ }
+ return type;
+ };
+ var Stack = function () {
+ this.root = {
+ children: [],
+ type: 'Root'
+ };
+ this.current = this.root;
+ this.stack = [this.root];
+ };
+ assign(Stack.prototype, {
+ top: function () {
+ return last(this.stack);
+ },
+ isRootTop: function () {
+ return this.top() === this.root;
+ },
+ popTo: function (types) {
+ this.popUntil(types);
+ if (!this.isRootTop()) {
+ this.stack.pop();
+ }
+ },
+ first: function (types) {
+ var curIndex = this.stack.length - 1;
+ while (curIndex > 0 && types.indexOf(this.stack[curIndex].type) === -1) {
+ curIndex--;
+ }
+ return this.stack[curIndex];
+ },
+ firstParent: function (types) {
+ var curIndex = this.stack.length - 2;
+ while (curIndex > 0 && types.indexOf(this.stack[curIndex].type) === -1) {
+ curIndex--;
+ }
+ return this.stack[curIndex];
+ },
+ popUntil: function (types) {
+ while (types.indexOf(this.top().type) === -1 && !this.isRootTop()) {
+ this.stack.pop();
+ }
+ return this.top();
+ },
+ addTo: function (types, type) {
+ var cur = this.popUntil(types);
+ ensureChildren(cur).children.push(type);
+ },
+ addToAndPush: function (types, type) {
+ this.addTo(types, type);
+ this.stack.push(type);
+ },
+ push: function (type) {
+ this.stack.push(type);
+ },
+ topLastChild: function () {
+ return last(this.top().children);
+ },
+ replaceTopLastChild: function (type) {
+ var children = ensureChildren(this.top()).children;
+ children.pop();
+ children.push(type);
+ return type;
+ },
+ replaceTopLastChildAndPush: function (type) {
+ this.replaceTopLastChild(type);
+ this.stack.push(type);
+ },
+ replaceTopAndPush: function (type) {
+ var children;
+ if (this.top() === this.root) {
+ children = ensureChildren(this.top()).children;
+ } else {
+ this.stack.pop();
+ children = ensureChildren(this.top()).children;
+ }
+ children.pop();
+ children.push(type);
+ this.stack.push(type);
+ return type;
+ }
+ });
+ var convertKeyToLookup = function (key) {
+ var lastPath = key.lastIndexOf('./');
+ var lastDot = key.lastIndexOf('.');
+ if (lastDot > lastPath) {
+ return key.substr(0, lastDot) + '@' + key.substr(lastDot + 1);
+ }
+ var firstNonPathCharIndex = lastPath === -1 ? 0 : lastPath + 2;
+ var firstNonPathChar = key.charAt(firstNonPathCharIndex);
+ if (firstNonPathChar === '.' || firstNonPathChar === '@') {
+ return key.substr(0, firstNonPathCharIndex) + '@' + key.substr(firstNonPathCharIndex + 1);
+ } else {
+ return key.substr(0, firstNonPathCharIndex) + '@' + key.substr(firstNonPathCharIndex);
+ }
+ };
+ var convertToAtLookup = function (ast) {
+ if (ast.type === 'Lookup') {
+ ast.key = convertKeyToLookup(ast.key);
+ }
+ return ast;
+ };
+ var convertToHelperIfTopIsLookup = function (stack) {
+ var top = stack.top();
+ if (top && top.type === 'Lookup') {
+ var base = stack.stack[stack.stack.length - 2];
+ if (base.type !== 'Helper' && base) {
+ stack.replaceTopAndPush({
+ type: 'Helper',
+ method: top
+ });
+ }
+ }
+ };
+ var expression = {
+ convertKeyToLookup: convertKeyToLookup,
+ Literal: Literal,
+ Lookup: Lookup,
+ ScopeLookup: ScopeLookup,
+ Arg: Arg,
+ Hash: Hash,
+ Hashes: Hashes,
+ Call: Call,
+ Helper: Helper,
+ HelperLookup: HelperLookup,
+ HelperScopeLookup: HelperScopeLookup,
+ Bracket: Bracket,
+ SetIdentifier: function (value) {
+ this.value = value;
+ },
+ tokenize: function (expression) {
+ var tokens = [];
+ (expression.trim() + ' ').replace(tokensRegExp, function (whole, arg) {
+ tokens.push(arg);
+ });
+ return tokens;
+ },
+ lookupRules: {
+ 'default': function (ast, methodType, isArg) {
+ var name = (methodType === 'Helper' && !ast.root ? 'Helper' : '') + (isArg ? 'Scope' : '') + 'Lookup';
+ return expression[name];
+ },
+ 'method': function (ast, methodType, isArg) {
+ return ScopeLookup;
+ }
+ },
+ methodRules: {
+ 'default': function (ast) {
+ return ast.type === 'Call' ? Call : Helper;
+ },
+ 'call': function (ast) {
+ return Call;
+ }
+ },
+ parse: function (expressionString, options) {
+ options = options || {};
+ var ast = this.ast(expressionString);
+ if (!options.lookupRule) {
+ options.lookupRule = 'default';
+ }
+ if (typeof options.lookupRule === 'string') {
+ options.lookupRule = expression.lookupRules[options.lookupRule];
+ }
+ if (!options.methodRule) {
+ options.methodRule = 'default';
+ }
+ if (typeof options.methodRule === 'string') {
+ options.methodRule = expression.methodRules[options.methodRule];
+ }
+ var expr = this.hydrateAst(ast, options, options.baseMethodType || 'Helper');
+ return expr;
+ },
+ hydrateAst: function (ast, options, methodType, isArg) {
+ if (ast.type === 'Lookup') {
+ return new (options.lookupRule(ast, methodType, isArg))(ast.key, ast.root && this.hydrateAst(ast.root, options, methodType));
+ } else if (ast.type === 'Literal') {
+ return new Literal(ast.value);
+ } else if (ast.type === 'Arg') {
+ return new Arg(this.hydrateAst(ast.children[0], options, methodType, isArg), { compute: true });
+ } else if (ast.type === 'Hash') {
+ throw new Error('');
+ } else if (ast.type === 'Hashes') {
+ var hashes = {};
+ each(ast.children, function (hash) {
+ hashes[hash.prop] = this.hydrateAst(hash.children[0], options, methodType, true);
+ }, this);
+ return new Hashes(hashes);
+ } else if (ast.type === 'Call' || ast.type === 'Helper') {
+ var hashes = {}, args = [], children = ast.children, ExpressionType = options.methodRule(ast);
+ if (children) {
+ for (var i = 0; i < children.length; i++) {
+ var child = children[i];
+ if (child.type === 'Hashes' && ast.type === 'Helper' && !(ExpressionType === Call)) {
+ each(child.children, function (hash) {
+ hashes[hash.prop] = this.hydrateAst(hash.children[0], options, ast.type, true);
+ }, this);
+ } else {
+ args.push(this.hydrateAst(child, options, ast.type, true));
+ }
+ }
+ }
+ return new ExpressionType(this.hydrateAst(ast.method, options, ast.type), args, hashes);
+ } else if (ast.type === 'Bracket') {
+ return new Bracket(this.hydrateAst(ast.children[0], options), ast.root ? this.hydrateAst(ast.root, options) : undefined);
+ }
+ },
+ ast: function (expression) {
+ var tokens = this.tokenize(expression);
+ return this.parseAst(tokens, { index: 0 });
+ },
+ parseAst: function (tokens, cursor) {
+ var stack = new Stack(), top;
+ while (cursor.index < tokens.length) {
+ var token = tokens[cursor.index], nextToken = tokens[cursor.index + 1];
+ cursor.index++;
+ if (literalRegExp.test(token)) {
+ convertToHelperIfTopIsLookup(stack);
+ var firstParent = stack.first([
+ 'Helper',
+ 'Call',
+ 'Hash',
+ 'Bracket'
+ ]);
+ if (firstParent.type === 'Hash' && (firstParent.children && firstParent.children.length > 0)) {
+ stack.addTo([
+ 'Helper',
+ 'Call',
+ 'Bracket'
+ ], {
+ type: 'Literal',
+ value: utils.jsonParse(token)
+ });
+ } else if (firstParent.type === 'Bracket' && (firstParent.children && firstParent.children.length > 0)) {
+ stack.addTo([
+ 'Helper',
+ 'Call',
+ 'Hash'
+ ], {
+ type: 'Literal',
+ value: utils.jsonParse(token)
+ });
+ } else {
+ stack.addTo([
+ 'Helper',
+ 'Call',
+ 'Hash',
+ 'Bracket'
+ ], {
+ type: 'Literal',
+ value: utils.jsonParse(token)
+ });
+ }
+ } else if (nextToken === '=') {
+ top = stack.top();
+ if (top && top.type === 'Lookup') {
+ var firstParent = stack.firstParent([
+ 'Call',
+ 'Helper',
+ 'Hash'
+ ]);
+ if (firstParent.type === 'Call' || firstParent.type === 'Root') {
+ stack.popUntil(['Call']);
+ top = stack.top();
+ stack.replaceTopAndPush({
+ type: 'Helper',
+ method: top.type === 'Root' ? last(top.children) : top
+ });
+ }
+ }
+ var firstParent = stack.firstParent([
+ 'Call',
+ 'Helper',
+ 'Hashes'
+ ]);
+ var hash = {
+ type: 'Hash',
+ prop: token
+ };
+ if (firstParent.type === 'Hashes') {
+ stack.addToAndPush(['Hashes'], hash);
+ } else {
+ var hash;
+ stack.addToAndPush([
+ 'Helper',
+ 'Call'
+ ], {
+ type: 'Hashes',
+ children: [hash]
+ });
+ stack.push(hash);
+ }
+ cursor.index++;
+ } else if (keyRegExp.test(token)) {
+ var lastToken = stack.topLastChild();
+ var firstParent = stack.first([
+ 'Helper',
+ 'Call',
+ 'Hash',
+ 'Bracket'
+ ]);
+ if (lastToken && lastToken.type === 'Call' && isAddingToExpression(token)) {
+ stack.replaceTopLastChildAndPush({
+ type: 'Lookup',
+ root: lastToken,
+ key: token.slice(1)
+ });
+ } else if (firstParent.type === 'Bracket' && !(firstParent.children && firstParent.children.length > 0)) {
+ stack.addToAndPush(['Bracket'], {
+ type: 'Lookup',
+ key: token
+ });
+ } else if (stack.first([
+ 'Helper',
+ 'Call',
+ 'Hash'
+ ]).type === 'Helper') {
+ stack.addToAndPush(['Helper'], {
+ type: 'Lookup',
+ key: token
+ });
+ } else {
+ convertToHelperIfTopIsLookup(stack);
+ stack.addToAndPush([
+ 'Helper',
+ 'Call',
+ 'Hash',
+ 'Arg',
+ 'Bracket'
+ ], {
+ type: 'Lookup',
+ key: token
+ });
+ }
+ } else if (token === '~') {
+ convertToHelperIfTopIsLookup(stack);
+ stack.addToAndPush([
+ 'Helper',
+ 'Call',
+ 'Hash'
+ ], {
+ type: 'Arg',
+ key: token
+ });
+ } else if (token === '(') {
+ top = stack.top();
+ if (top.type === 'Lookup') {
+ stack.replaceTopAndPush({
+ type: 'Call',
+ method: convertToAtLookup(top)
+ });
+ } else {
+ throw new Error('Unable to understand expression ' + tokens.join(''));
+ }
+ } else if (token === ')') {
+ stack.popTo(['Call']);
+ } else if (token === ',') {
+ stack.popUntil(['Call']);
+ } else if (token === '[') {
+ top = stack.top();
+ lastToken = stack.topLastChild();
+ if (lastToken && lastToken.type === 'Call') {
+ stack.replaceTopAndPush({
+ type: 'Bracket',
+ root: lastToken
+ });
+ } else if (top.type === 'Lookup') {
+ stack.replaceTopAndPush({
+ type: 'Bracket',
+ root: top
+ });
+ } else if (top.type === 'Call') {
+ stack.addToAndPush(['Call'], { type: 'Bracket' });
+ } else if (top === ' ') {
+ stack.popUntil(['Lookup']);
+ convertToHelperIfTopIsLookup(stack);
+ stack.addToAndPush([
+ 'Helper',
+ 'Call',
+ 'Hash'
+ ], { type: 'Bracket' });
+ } else {
+ stack.replaceTopAndPush({ type: 'Bracket' });
+ }
+ } else if (token === ' ') {
+ stack.push(token);
+ }
+ }
+ return stack.root.children[0];
+ }
+ };
+ module.exports = expression;
+});
+/*can-view-model@3.0.0#can-view-model*/
+define('can-view-model@3.0.0#can-view-model', function (require, exports, module) {
+ 'use strict';
+ var domData = require('can-util/dom/data/data');
+ var SimpleMap = require('can-simple-map');
+ var types = require('can-util/js/types/types');
+ var ns = require('can-util/namespace');
+ module.exports = ns.viewModel = function (el, attr, val) {
+ var scope = domData.get.call(el, 'viewModel');
+ if (!scope) {
+ scope = types.DefaultMap ? new types.DefaultMap() : new SimpleMap();
+ domData.set.call(el, 'viewModel', scope);
+ }
+ switch (arguments.length) {
+ case 0:
+ case 1:
+ return scope;
+ case 2:
+ return 'attr' in scope ? scope.attr(attr) : scope[attr];
+ default:
+ if ('attr' in scope) {
+ scope.attr(attr, val);
+ } else {
+ scope[attr] = val;
+ }
+ return el;
+ }
+ };
+});
+/*can-stache-bindings@3.0.4#can-stache-bindings*/
+define('can-stache-bindings@3.0.4#can-stache-bindings', function (require, exports, module) {
+ var expression = require('can-stache/src/expression');
+ var viewCallbacks = require('can-view-callbacks');
+ var live = require('can-view-live');
+ var Scope = require('can-view-scope');
+ var canViewModel = require('can-view-model');
+ var canEvent = require('can-event');
+ var canBatch = require('can-event/batch/batch');
+ var compute = require('can-compute');
+ var observeReader = require('can-observation/reader/reader');
+ var Observation = require('can-observation');
+ var assign = require('can-util/js/assign/assign');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var each = require('can-util/js/each/each');
+ var string = require('can-util/js/string/string');
+ var dev = require('can-util/js/dev/dev');
+ var types = require('can-util/js/types/types');
+ var last = require('can-util/js/last/last');
+ var getMutationObserver = require('can-util/dom/mutation-observer/mutation-observer');
+ var domEvents = require('can-util/dom/events/events');
+ require('can-util/dom/events/removed/removed');
+ var domData = require('can-util/dom/data/data');
+ var attr = require('can-util/dom/attr/attr');
+ var behaviors = {
+ viewModel: function (el, tagData, makeViewModel, initialViewModelData) {
+ initialViewModelData = initialViewModelData || {};
+ var bindingsSemaphore = {}, viewModel, onCompleteBindings = [], onTeardowns = {}, bindingInfos = {}, attributeViewModelBindings = assign({}, initialViewModelData);
+ each(makeArray(el.attributes), function (node) {
+ var dataBinding = makeDataBinding(node, el, {
+ templateType: tagData.templateType,
+ scope: tagData.scope,
+ semaphore: bindingsSemaphore,
+ getViewModel: function () {
+ return viewModel;
+ },
+ attributeViewModelBindings: attributeViewModelBindings,
+ alreadyUpdatedChild: true,
+ nodeList: tagData.parentNodeList
+ });
+ if (dataBinding) {
+ if (dataBinding.onCompleteBinding) {
+ if (dataBinding.bindingInfo.parentToChild && dataBinding.value !== undefined) {
+ initialViewModelData[cleanVMName(dataBinding.bindingInfo.childName)] = dataBinding.value;
+ }
+ onCompleteBindings.push(dataBinding.onCompleteBinding);
+ }
+ onTeardowns[node.name] = dataBinding.onTeardown;
+ }
+ });
+ viewModel = makeViewModel(initialViewModelData);
+ for (var i = 0, len = onCompleteBindings.length; i < len; i++) {
+ onCompleteBindings[i]();
+ }
+ domEvents.addEventListener.call(el, 'attributes', function (ev) {
+ var attrName = ev.attributeName, value = el.getAttribute(attrName);
+ if (onTeardowns[attrName]) {
+ onTeardowns[attrName]();
+ }
+ var parentBindingWasAttribute = bindingInfos[attrName] && bindingInfos[attrName].parent === 'attribute';
+ if (value !== null || parentBindingWasAttribute) {
+ var dataBinding = makeDataBinding({
+ name: attrName,
+ value: value
+ }, el, {
+ templateType: tagData.templateType,
+ scope: tagData.scope,
+ semaphore: {},
+ getViewModel: function () {
+ return viewModel;
+ },
+ attributeViewModelBindings: attributeViewModelBindings,
+ initializeValues: true,
+ nodeList: tagData.parentNodeList
+ });
+ if (dataBinding) {
+ if (dataBinding.onCompleteBinding) {
+ dataBinding.onCompleteBinding();
+ }
+ bindingInfos[attrName] = dataBinding.bindingInfo;
+ onTeardowns[attrName] = dataBinding.onTeardown;
+ }
+ }
+ });
+ return function () {
+ for (var attrName in onTeardowns) {
+ onTeardowns[attrName]();
+ }
+ };
+ },
+ data: function (el, attrData) {
+ if (domData.get.call(el, 'preventDataBindings')) {
+ return;
+ }
+ var viewModel = canViewModel(el), semaphore = {}, teardown;
+ var dataBinding = makeDataBinding({
+ name: attrData.attributeName,
+ value: el.getAttribute(attrData.attributeName),
+ nodeList: attrData.nodeList
+ }, el, {
+ templateType: attrData.templateType,
+ scope: attrData.scope,
+ semaphore: semaphore,
+ getViewModel: function () {
+ return viewModel;
+ }
+ });
+ if (dataBinding.onCompleteBinding) {
+ dataBinding.onCompleteBinding();
+ }
+ teardown = dataBinding.onTeardown;
+ canEvent.one.call(el, 'removed', function () {
+ teardown();
+ });
+ domEvents.addEventListener.call(el, 'attributes', function (ev) {
+ var attrName = ev.attributeName, value = el.getAttribute(attrName);
+ if (attrName === attrData.attributeName) {
+ if (teardown) {
+ teardown();
+ }
+ if (value !== null) {
+ var dataBinding = makeDataBinding({
+ name: attrName,
+ value: value
+ }, el, {
+ templateType: attrData.templateType,
+ scope: attrData.scope,
+ semaphore: semaphore,
+ getViewModel: function () {
+ return viewModel;
+ },
+ initializeValues: true,
+ nodeList: attrData.nodeList
+ });
+ if (dataBinding) {
+ if (dataBinding.onCompleteBinding) {
+ dataBinding.onCompleteBinding();
+ }
+ teardown = dataBinding.onTeardown;
+ }
+ }
+ }
+ });
+ },
+ reference: function (el, attrData) {
+ if (el.getAttribute(attrData.attributeName)) {
+ console.warn('*reference attributes can only export the view model.');
+ }
+ var name = string.camelize(attrData.attributeName.substr(1).toLowerCase());
+ var viewModel = canViewModel(el);
+ var refs = attrData.scope.getRefs();
+ refs._context.attr('*' + name, viewModel);
+ },
+ event: function (el, data) {
+ var attributeName = data.attributeName, legacyBinding = attributeName.indexOf('can-') === 0, event = attributeName.indexOf('can-') === 0 ? attributeName.substr('can-'.length) : removeBrackets(attributeName, '(', ')'), onBindElement = legacyBinding;
+ if (event.charAt(0) === '$') {
+ event = event.substr(1);
+ onBindElement = true;
+ }
+ var handler = function (ev) {
+ var attrVal = el.getAttribute(attributeName);
+ if (!attrVal) {
+ return;
+ }
+ var viewModel = canViewModel(el);
+ var expr = expression.parse(removeBrackets(attrVal), {
+ lookupRule: 'method',
+ methodRule: 'call'
+ });
+ if (!(expr instanceof expression.Call) && !(expr instanceof expression.Helper)) {
+ var defaultArgs = [
+ data.scope._context,
+ el
+ ].concat(makeArray(arguments)).map(function (data) {
+ return new expression.Arg(new expression.Literal(data));
+ });
+ expr = new expression.Call(expr, defaultArgs, {});
+ }
+ var localScope = data.scope.add({
+ '@element': el,
+ '@event': ev,
+ '@viewModel': viewModel,
+ '@scope': data.scope,
+ '@context': data.scope._context,
+ '%element': this,
+ '$element': types.wrapElement(el),
+ '%event': ev,
+ '%viewModel': viewModel,
+ '%scope': data.scope,
+ '%context': data.scope._context,
+ '%arguments': arguments
+ }, { notContext: true });
+ var scopeData = localScope.read(expr.methodExpr.key, { isArgument: true });
+ if (!scopeData.value) {
+ scopeData = localScope.read(expr.methodExpr.key, { isArgument: true });
+ return null;
+ }
+ var args = expr.args(localScope, null)();
+ return scopeData.value.apply(scopeData.parent, args);
+ };
+ if (special[event]) {
+ var specialData = special[event](data, el, handler);
+ handler = specialData.handler;
+ event = specialData.event;
+ }
+ canEvent.on.call(onBindElement ? el : canViewModel(el), event, handler);
+ var attributesHandler = function (ev) {
+ if (ev.attributeName === attributeName && !this.getAttribute(attributeName)) {
+ canEvent.off.call(onBindElement ? el : canViewModel(el), event, handler);
+ canEvent.off.call(el, 'attributes', attributesHandler);
+ }
+ };
+ canEvent.on.call(el, 'attributes', attributesHandler);
+ },
+ value: function (el, data) {
+ var propName = '$value', attrValue = removeBrackets(el.getAttribute('can-value')).trim(), nodeName = el.nodeName.toLowerCase(), elType = nodeName === 'input' && (el.type || el.getAttribute('type')), getterSetter;
+ if (nodeName === 'input' && (elType === 'checkbox' || elType === 'radio')) {
+ var property = getComputeFrom.scope(el, data.scope, attrValue, {}, true);
+ if (el.type === 'checkbox') {
+ var trueValue = attr.has(el, 'can-true-value') ? el.getAttribute('can-true-value') : true, falseValue = attr.has(el, 'can-false-value') ? el.getAttribute('can-false-value') : false;
+ getterSetter = compute(function (newValue) {
+ if (arguments.length) {
+ property(newValue ? trueValue : falseValue);
+ } else {
+ return property() == trueValue;
+ }
+ });
+ } else if (elType === 'radio') {
+ getterSetter = compute(function (newValue) {
+ if (arguments.length) {
+ if (newValue) {
+ property(el.value);
+ }
+ } else {
+ return property() == el.value;
+ }
+ });
+ }
+ propName = '$checked';
+ attrValue = 'getterSetter';
+ data.scope = new Scope({ getterSetter: getterSetter });
+ } else if (isContentEditable(el)) {
+ propName = '$innerHTML';
+ }
+ var dataBinding = makeDataBinding({
+ name: '{(' + propName + '})',
+ value: attrValue
+ }, el, {
+ templateType: data.templateType,
+ scope: data.scope,
+ semaphore: {},
+ initializeValues: true,
+ legacyBindings: true,
+ syncChildWithParent: true
+ });
+ canEvent.one.call(el, 'removed', function () {
+ dataBinding.onTeardown();
+ });
+ }
+ };
+ viewCallbacks.attr(/^\{[^\}]+\}$/, behaviors.data);
+ viewCallbacks.attr(/\*[\w\.\-_]+/, behaviors.reference);
+ viewCallbacks.attr(/^\([\$?\w\.]+\)$/, behaviors.event);
+ viewCallbacks.attr(/can-[\w\.]+/, behaviors.event);
+ viewCallbacks.attr('can-value', behaviors.value);
+ var getComputeFrom = {
+ scope: function (el, scope, scopeProp, bindingData, mustBeACompute, stickyCompute) {
+ if (!scopeProp) {
+ return compute();
+ } else {
+ if (mustBeACompute) {
+ var parentExpression = expression.parse(scopeProp, { baseMethodType: 'Call' });
+ return parentExpression.value(scope, new Scope.Options({}));
+ } else {
+ return function (newVal) {
+ scope.attr(cleanVMName(scopeProp), newVal);
+ };
+ }
+ }
+ },
+ viewModel: function (el, scope, vmName, bindingData, mustBeACompute, stickyCompute) {
+ var setName = cleanVMName(vmName);
+ if (mustBeACompute) {
+ return compute(function (newVal) {
+ var viewModel = bindingData.getViewModel();
+ if (arguments.length) {
+ if (types.isMapLike(viewModel)) {
+ observeReader.set(viewModel, setName, newVal);
+ } else {
+ viewModel[setName] = newVal;
+ }
+ } else {
+ return vmName === '.' ? viewModel : observeReader.read(viewModel, observeReader.reads(vmName), {}).value;
+ }
+ });
+ } else {
+ return function (newVal) {
+ var childCompute;
+ var viewModel = bindingData.getViewModel();
+ function updateViewModel(value, options) {
+ if (types.isMapLike(viewModel)) {
+ observeReader.set(viewModel, setName, value, options);
+ } else {
+ viewModel[setName] = value;
+ }
+ }
+ if (stickyCompute) {
+ childCompute = observeReader.get(viewModel, setName, { readCompute: false });
+ if (!childCompute || !childCompute.isComputed) {
+ childCompute = compute();
+ updateViewModel(childCompute, { readCompute: false });
+ }
+ childCompute(newVal);
+ } else {
+ updateViewModel(newVal);
+ }
+ };
+ }
+ },
+ attribute: function (el, scope, prop, bindingData, mustBeACompute, stickyCompute, event) {
+ if (!event) {
+ if (attr.special[prop] && attr.special[prop].addEventListener) {
+ event = prop;
+ } else {
+ event = 'change';
+ }
+ }
+ var hasChildren = el.nodeName.toLowerCase() === 'select', isMultiselectValue = prop === 'value' && hasChildren && el.multiple, set = function (newVal) {
+ if (bindingData.legacyBindings && hasChildren && 'selectedIndex' in el && prop === 'value') {
+ attr.setAttrOrProp(el, prop, newVal == null ? '' : newVal);
+ } else {
+ attr.setAttrOrProp(el, prop, newVal);
+ }
+ return newVal;
+ }, get = function () {
+ return attr.get(el, prop);
+ };
+ if (isMultiselectValue) {
+ prop = 'values';
+ }
+ return compute(get(), {
+ on: function (updater) {
+ canEvent.on.call(el, event, updater);
+ },
+ off: function (updater) {
+ canEvent.off.call(el, event, updater);
+ },
+ get: get,
+ set: set
+ });
+ }
+ };
+ var bind = {
+ childToParent: function (el, parentCompute, childCompute, bindingsSemaphore, attrName, syncChild) {
+ var parentUpdateIsFunction = typeof parentCompute === 'function';
+ var updateParent = function (ev, newVal) {
+ if (!bindingsSemaphore[attrName]) {
+ if (parentUpdateIsFunction) {
+ parentCompute(newVal);
+ if (syncChild) {
+ if (parentCompute() !== childCompute()) {
+ bindingsSemaphore[attrName] = (bindingsSemaphore[attrName] || 0) + 1;
+ childCompute(parentCompute());
+ Observation.afterUpdateAndNotify(function () {
+ --bindingsSemaphore[attrName];
+ });
+ }
+ }
+ } else if (types.isMapLike(parentCompute)) {
+ parentCompute.attr(newVal, true);
+ }
+ }
+ };
+ if (childCompute && childCompute.isComputed) {
+ childCompute.bind('change', updateParent);
+ }
+ return updateParent;
+ },
+ parentToChild: function (el, parentCompute, childUpdate, bindingsSemaphore, attrName) {
+ var updateChild = function (ev, newValue) {
+ bindingsSemaphore[attrName] = (bindingsSemaphore[attrName] || 0) + 1;
+ canBatch.start();
+ childUpdate(newValue);
+ Observation.afterUpdateAndNotify(function () {
+ --bindingsSemaphore[attrName];
+ });
+ canBatch.stop();
+ };
+ if (parentCompute && parentCompute.isComputed) {
+ parentCompute.bind('change', updateChild);
+ }
+ return updateChild;
+ }
+ };
+ var DOUBLE_CURLY_BRACE_REGEX = /\{\{/g;
+ var getBindingInfo = function (node, attributeViewModelBindings, templateType, tagName) {
+ var bindingInfo, attributeName = node.name, attributeValue = node.value || '';
+ var matches = attributeName.match(bindingsRegExp);
+ if (!matches) {
+ var ignoreAttribute = ignoreAttributesRegExp.test(attributeName);
+ var vmName = string.camelize(attributeName);
+ if (ignoreAttribute || viewCallbacks.attr(attributeName)) {
+ return;
+ }
+ var syntaxRight = attributeValue[0] === '{' && last(attributeValue) === '}';
+ var isAttributeToChild = templateType === 'legacy' ? attributeViewModelBindings[vmName] : !syntaxRight;
+ var scopeName = syntaxRight ? attributeValue.substr(1, attributeValue.length - 2) : attributeValue;
+ if (isAttributeToChild) {
+ return {
+ bindingAttributeName: attributeName,
+ parent: 'attribute',
+ parentName: attributeName,
+ child: 'viewModel',
+ childName: vmName,
+ parentToChild: true,
+ childToParent: true
+ };
+ } else {
+ return {
+ bindingAttributeName: attributeName,
+ parent: 'scope',
+ parentName: scopeName,
+ child: 'viewModel',
+ childName: vmName,
+ parentToChild: true,
+ childToParent: true
+ };
+ }
+ }
+ var twoWay = !!matches[1], childToParent = twoWay || !!matches[2], parentToChild = twoWay || !childToParent;
+ var childName = matches[3];
+ var isDOM = childName.charAt(0) === '$';
+ if (isDOM) {
+ bindingInfo = {
+ parent: 'scope',
+ child: 'attribute',
+ childToParent: childToParent,
+ parentToChild: parentToChild,
+ bindingAttributeName: attributeName,
+ childName: childName.substr(1),
+ parentName: attributeValue,
+ initializeValues: true
+ };
+ if (tagName === 'select') {
+ bindingInfo.stickyParentToChild = true;
+ }
+ return bindingInfo;
+ } else {
+ bindingInfo = {
+ parent: 'scope',
+ child: 'viewModel',
+ childToParent: childToParent,
+ parentToChild: parentToChild,
+ bindingAttributeName: attributeName,
+ childName: string.camelize(childName),
+ parentName: attributeValue,
+ initializeValues: true
+ };
+ if (attributeValue.trim().charAt(0) === '~') {
+ bindingInfo.stickyParentToChild = true;
+ }
+ return bindingInfo;
+ }
+ };
+ var bindingsRegExp = /\{(\()?(\^)?([^\}\)]+)\)?\}/, ignoreAttributesRegExp = /^(data-view-id|class|id|\[[\w\.-]+\]|#[\w\.-])$/i;
+ var makeDataBinding = function (node, el, bindingData) {
+ var bindingInfo = getBindingInfo(node, bindingData.attributeViewModelBindings, bindingData.templateType, el.nodeName.toLowerCase());
+ if (!bindingInfo) {
+ return;
+ }
+ bindingInfo.alreadyUpdatedChild = bindingData.alreadyUpdatedChild;
+ if (bindingData.initializeValues) {
+ bindingInfo.initializeValues = true;
+ }
+ var parentCompute = getComputeFrom[bindingInfo.parent](el, bindingData.scope, bindingInfo.parentName, bindingData, bindingInfo.parentToChild), childCompute = getComputeFrom[bindingInfo.child](el, bindingData.scope, bindingInfo.childName, bindingData, bindingInfo.childToParent, bindingInfo.stickyParentToChild && parentCompute), updateParent, updateChild, childLifecycle;
+ if (bindingData.nodeList) {
+ if (parentCompute && parentCompute.isComputed) {
+ parentCompute.computeInstance.setPrimaryDepth(bindingData.nodeList.nesting + 1);
+ }
+ if (childCompute && childCompute.isComputed) {
+ childCompute.computeInstance.setPrimaryDepth(bindingData.nodeList.nesting + 1);
+ }
+ }
+ if (bindingInfo.parentToChild) {
+ updateChild = bind.parentToChild(el, parentCompute, childCompute, bindingData.semaphore, bindingInfo.bindingAttributeName);
+ }
+ var completeBinding = function () {
+ if (bindingInfo.childToParent) {
+ updateParent = bind.childToParent(el, parentCompute, childCompute, bindingData.semaphore, bindingInfo.bindingAttributeName, bindingData.syncChildWithParent);
+ } else if (bindingInfo.stickyParentToChild) {
+ childCompute.bind('change', childLifecycle = function () {
+ });
+ }
+ if (bindingInfo.initializeValues) {
+ initializeValues(bindingInfo, childCompute, parentCompute, updateChild, updateParent);
+ }
+ };
+ var onTeardown = function () {
+ unbindUpdate(parentCompute, updateChild);
+ unbindUpdate(childCompute, updateParent);
+ unbindUpdate(childCompute, childLifecycle);
+ };
+ if (bindingInfo.child === 'viewModel') {
+ return {
+ value: bindingInfo.stickyParentToChild ? compute(getValue(parentCompute)) : getValue(parentCompute),
+ onCompleteBinding: completeBinding,
+ bindingInfo: bindingInfo,
+ onTeardown: onTeardown
+ };
+ } else {
+ completeBinding();
+ return {
+ bindingInfo: bindingInfo,
+ onTeardown: onTeardown
+ };
+ }
+ };
+ var initializeValues = function (bindingInfo, childCompute, parentCompute, updateChild, updateParent) {
+ var doUpdateParent = false;
+ if (bindingInfo.parentToChild && !bindingInfo.childToParent) {
+ } else if (!bindingInfo.parentToChild && bindingInfo.childToParent) {
+ doUpdateParent = true;
+ } else if (getValue(childCompute) === undefined) {
+ } else if (getValue(parentCompute) === undefined) {
+ doUpdateParent = true;
+ }
+ if (doUpdateParent) {
+ updateParent({}, getValue(childCompute));
+ } else {
+ if (!bindingInfo.alreadyUpdatedChild) {
+ updateChild({}, getValue(parentCompute));
+ }
+ }
+ };
+ if (!getMutationObserver()) {
+ var updateSelectValue = function (el) {
+ var bindingCallback = domData.get.call(el, 'canBindingCallback');
+ if (bindingCallback) {
+ bindingCallback.onMutation(el);
+ }
+ };
+ live.registerChildMutationCallback('select', updateSelectValue);
+ live.registerChildMutationCallback('optgroup', function (el) {
+ updateSelectValue(el.parentNode);
+ });
+ }
+ var isContentEditable = function () {
+ var values = {
+ '': true,
+ 'true': true,
+ 'false': false
+ };
+ var editable = function (el) {
+ if (!el || !el.getAttribute) {
+ return;
+ }
+ var attr = el.getAttribute('contenteditable');
+ return values[attr];
+ };
+ return function (el) {
+ var val = editable(el);
+ if (typeof val === 'boolean') {
+ return val;
+ } else {
+ return !!editable(el.parentNode);
+ }
+ };
+ }(), removeBrackets = function (value, open, close) {
+ open = open || '{';
+ close = close || '}';
+ if (value[0] === open && value[value.length - 1] === close) {
+ return value.substr(1, value.length - 2);
+ }
+ return value;
+ }, getValue = function (value) {
+ return value && value.isComputed ? value() : value;
+ }, unbindUpdate = function (compute, updateOther) {
+ if (compute && compute.isComputed && typeof updateOther === 'function') {
+ compute.unbind('change', updateOther);
+ }
+ }, cleanVMName = function (name) {
+ return name.replace(/@/g, '');
+ };
+ var special = {
+ enter: function (data, el, original) {
+ return {
+ event: 'keyup',
+ handler: function (ev) {
+ if (ev.keyCode === 13) {
+ return original.call(this, ev);
+ }
+ }
+ };
+ }
+ };
+ module.exports = {
+ behaviors: behaviors,
+ getBindingInfo: getBindingInfo,
+ special: special
+ };
+});
+/*can-util@3.0.10#dom/events/inserted/inserted*/
+define('can-util@3.0.10#dom/events/inserted/inserted', function (require, exports, module) {
+ var makeMutationEvent = require('../make-mutation-event/make-mutation-event');
+ makeMutationEvent('inserted', 'addedNodes');
+});
+/*can-component@3.0.2#can-component*/
+define('can-component@3.0.2#can-component', function (require, exports, module) {
+ var ComponentControl = require('./control/control');
+ var namespace = require('can-util/namespace');
+ var Construct = require('can-construct');
+ var stacheBindings = require('can-stache-bindings');
+ var Scope = require('can-view-scope');
+ var viewCallbacks = require('can-view-callbacks');
+ var nodeLists = require('can-view-nodelist');
+ var domData = require('can-util/dom/data/data');
+ var domMutate = require('can-util/dom/mutate/mutate');
+ var getChildNodes = require('can-util/dom/child-nodes/child-nodes');
+ var domDispatch = require('can-util/dom/dispatch/dispatch');
+ var types = require('can-util/js/types/types');
+ var string = require('can-util/js/string/string');
+ var canEach = require('can-util/js/each/each');
+ var isFunction = require('can-util/js/is-function/is-function');
+ require('can-util/dom/events/inserted/inserted');
+ require('can-util/dom/events/removed/removed');
+ require('can-view-model');
+ var Component = Construct.extend({
+ setup: function () {
+ Construct.setup.apply(this, arguments);
+ if (Component) {
+ var self = this;
+ this.Control = ComponentControl.extend(this.prototype.events);
+ var protoViewModel = this.prototype.viewModel || this.prototype.scope;
+ if (protoViewModel && this.prototype.ViewModel) {
+ throw new Error('Cannot provide both a ViewModel and a viewModel property');
+ }
+ var vmName = string.capitalize(string.camelize(this.prototype.tag)) + 'VM';
+ if (this.prototype.ViewModel) {
+ if (typeof this.prototype.ViewModel === 'function') {
+ this.ViewModel = this.prototype.ViewModel;
+ } else {
+ this.ViewModel = types.DefaultMap.extend(vmName, this.prototype.ViewModel);
+ }
+ } else {
+ if (protoViewModel) {
+ if (typeof protoViewModel === 'function') {
+ if (types.isMapLike(protoViewModel.prototype)) {
+ this.ViewModel = protoViewModel;
+ } else {
+ this.viewModelHandler = protoViewModel;
+ }
+ } else {
+ if (types.isMapLike(protoViewModel)) {
+ this.viewModelInstance = protoViewModel;
+ } else {
+ this.ViewModel = types.DefaultMap.extend(vmName, protoViewModel);
+ }
+ }
+ } else {
+ this.ViewModel = types.DefaultMap.extend(vmName, {});
+ }
+ }
+ if (this.prototype.template) {
+ this.renderer = this.prototype.template;
+ }
+ if (this.prototype.view) {
+ this.renderer = this.prototype.view;
+ }
+ viewCallbacks.tag(this.prototype.tag, function (el, options) {
+ new self(el, options);
+ });
+ }
+ }
+ }, {
+ setup: function (el, componentTagData) {
+ var component = this;
+ var lexicalContent = (typeof this.leakScope === 'undefined' ? true : !this.leakScope) && !!(this.template || this.view);
+ var teardownFunctions = [];
+ var initialViewModelData = {};
+ var callTeardownFunctions = function () {
+ for (var i = 0, len = teardownFunctions.length; i < len; i++) {
+ teardownFunctions[i]();
+ }
+ };
+ var setupBindings = !domData.get.call(el, 'preventDataBindings');
+ var viewModel, frag;
+ var teardownBindings;
+ if (setupBindings) {
+ var setupFn = componentTagData.setupBindings || function (el, callback, data) {
+ return stacheBindings.behaviors.viewModel(el, componentTagData, callback, data);
+ };
+ teardownBindings = setupFn(el, function (initialViewModelData) {
+ var ViewModel = component.constructor.ViewModel, viewModelHandler = component.constructor.viewModelHandler, viewModelInstance = component.constructor.viewModelInstance;
+ if (viewModelHandler) {
+ var scopeResult = viewModelHandler.call(component, initialViewModelData, componentTagData.scope, el);
+ if (types.isMapLike(scopeResult)) {
+ viewModelInstance = scopeResult;
+ } else if (types.isMapLike(scopeResult.prototype)) {
+ ViewModel = scopeResult;
+ } else {
+ ViewModel = types.DefaultMap.extend(scopeResult);
+ }
+ }
+ if (ViewModel) {
+ viewModelInstance = new component.constructor.ViewModel(initialViewModelData);
+ }
+ viewModel = viewModelInstance;
+ return viewModelInstance;
+ }, initialViewModelData);
+ }
+ this.viewModel = viewModel;
+ domData.set.call(el, 'viewModel', viewModel);
+ domData.set.call(el, 'preventDataBindings', true);
+ var shadowScope;
+ if (lexicalContent) {
+ shadowScope = Scope.refsScope().add(this.viewModel, { viewModel: true });
+ } else {
+ shadowScope = (this.constructor.renderer ? componentTagData.scope.add(new Scope.Refs()) : componentTagData.scope).add(this.viewModel, { viewModel: true });
+ }
+ var options = { helpers: {} }, addHelper = function (name, fn) {
+ options.helpers[name] = function () {
+ return fn.apply(viewModel, arguments);
+ };
+ };
+ canEach(this.helpers || {}, function (val, prop) {
+ if (isFunction(val)) {
+ addHelper(prop, val);
+ }
+ });
+ this._control = new this.constructor.Control(el, {
+ scope: this.viewModel,
+ viewModel: this.viewModel,
+ destroy: callTeardownFunctions
+ });
+ var nodeList = nodeLists.register([], function () {
+ domDispatch.call(el, 'beforeremove', [], false);
+ if (teardownBindings) {
+ teardownBindings();
+ }
+ }, componentTagData.parentNodeList || true, false);
+ nodeList.expression = '<' + this.tag + '>';
+ teardownFunctions.push(function () {
+ nodeLists.unregister(nodeList);
+ });
+ if (this.constructor.renderer) {
+ if (!options.tags) {
+ options.tags = {};
+ }
+ options.tags.content = function contentHookup(el, contentTagData) {
+ var subtemplate = componentTagData.subtemplate || contentTagData.subtemplate, renderingLightContent = subtemplate === componentTagData.subtemplate;
+ if (subtemplate) {
+ delete options.tags.content;
+ var lightTemplateData;
+ if (renderingLightContent) {
+ if (lexicalContent) {
+ lightTemplateData = componentTagData;
+ } else {
+ lightTemplateData = {
+ scope: contentTagData.scope.cloneFromRef(),
+ options: contentTagData.options
+ };
+ }
+ } else {
+ lightTemplateData = contentTagData;
+ }
+ if (contentTagData.parentNodeList) {
+ var frag = subtemplate(lightTemplateData.scope, lightTemplateData.options, contentTagData.parentNodeList);
+ nodeLists.replace([el], frag);
+ } else {
+ nodeLists.replace([el], subtemplate(lightTemplateData.scope, lightTemplateData.options));
+ }
+ options.tags.content = contentHookup;
+ }
+ };
+ frag = this.constructor.renderer(shadowScope, componentTagData.options.add(options), nodeList);
+ } else {
+ frag = componentTagData.subtemplate ? componentTagData.subtemplate(shadowScope, componentTagData.options.add(options), nodeList) : document.createDocumentFragment();
+ }
+ domMutate.appendChild.call(el, frag);
+ nodeLists.update(nodeList, getChildNodes(el));
+ }
+ });
+ viewCallbacks.tag('content', function (el, tagData) {
+ return tagData.scope;
+ });
+ module.exports = namespace.Component = Component;
+});
+/*can-view-target@3.0.3#can-view-target*/
+define('can-view-target@3.0.3#can-view-target', function (require, exports, module) {
+ var childNodes = require('can-util/dom/child-nodes/child-nodes');
+ var domAttr = require('can-util/dom/attr/attr');
+ var each = require('can-util/js/each/each');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var getDocument = require('can-util/dom/document/document');
+ var domMutate = require('can-util/dom/mutate/mutate');
+ var namespace = require('can-util/namespace');
+ var processNodes = function (nodes, paths, location, document) {
+ var frag = document.createDocumentFragment();
+ for (var i = 0, len = nodes.length; i < len; i++) {
+ var node = nodes[i];
+ frag.appendChild(processNode(node, paths, location.concat(i), document));
+ }
+ return frag;
+ }, keepsTextNodes = typeof document !== 'undefined' && function () {
+ var testFrag = document.createDocumentFragment();
+ var div = document.createElement('div');
+ div.appendChild(document.createTextNode(''));
+ div.appendChild(document.createTextNode(''));
+ testFrag.appendChild(div);
+ var cloned = testFrag.cloneNode(true);
+ return childNodes(cloned.firstChild).length === 2;
+ }(), clonesWork = typeof document !== 'undefined' && function () {
+ var el = document.createElement('a');
+ el.innerHTML = ' ';
+ var clone = el.cloneNode(true);
+ var works = clone.innerHTML === ' ';
+ if (works) {
+ el = document.createDocumentFragment();
+ el.appendChild(document.createTextNode('foo-bar'));
+ clone = el.cloneNode(true);
+ return clone.childNodes.length === 1;
+ }
+ return works;
+ }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS;
+ var cloneNode = clonesWork ? function (el) {
+ return el.cloneNode(true);
+ } : function (node) {
+ var document = node.ownerDocument;
+ var copy;
+ if (node.nodeType === 1) {
+ copy = document.createElement(node.nodeName);
+ } else if (node.nodeType === 3) {
+ copy = document.createTextNode(node.nodeValue);
+ } else if (node.nodeType === 8) {
+ copy = document.createComment(node.nodeValue);
+ } else if (node.nodeType === 11) {
+ copy = document.createDocumentFragment();
+ }
+ if (node.attributes) {
+ var attributes = makeArray(node.attributes);
+ each(attributes, function (node) {
+ if (node && node.specified) {
+ domAttr.setAttribute(copy, node.nodeName || node.name, node.nodeValue || node.value);
+ }
+ });
+ }
+ if (node && node.firstChild) {
+ var child = node.firstChild;
+ while (child) {
+ copy.appendChild(cloneNode(child));
+ child = child.nextSibling;
+ }
+ }
+ return copy;
+ };
+ function processNode(node, paths, location, document) {
+ var callback, loc = location, nodeType = typeof node, el, p, i, len;
+ var getCallback = function () {
+ if (!callback) {
+ callback = {
+ path: location,
+ callbacks: []
+ };
+ paths.push(callback);
+ loc = [];
+ }
+ return callback;
+ };
+ if (nodeType === 'object') {
+ if (node.tag) {
+ if (namespacesWork && node.namespace) {
+ el = document.createElementNS(node.namespace, node.tag);
+ } else {
+ el = document.createElement(node.tag);
+ }
+ if (node.attrs) {
+ for (var attrName in node.attrs) {
+ var value = node.attrs[attrName];
+ if (typeof value === 'function') {
+ getCallback().callbacks.push({ callback: value });
+ } else {
+ domAttr.setAttribute(el, attrName, value);
+ }
+ }
+ }
+ if (node.attributes) {
+ for (i = 0, len = node.attributes.length; i < len; i++) {
+ getCallback().callbacks.push({ callback: node.attributes[i] });
+ }
+ }
+ if (node.children && node.children.length) {
+ if (callback) {
+ p = callback.paths = [];
+ } else {
+ p = paths;
+ }
+ el.appendChild(processNodes(node.children, p, loc, document));
+ }
+ } else if (node.comment) {
+ el = document.createComment(node.comment);
+ if (node.callbacks) {
+ for (i = 0, len = node.attributes.length; i < len; i++) {
+ getCallback().callbacks.push({ callback: node.callbacks[i] });
+ }
+ }
+ }
+ } else if (nodeType === 'string') {
+ el = document.createTextNode(node);
+ } else if (nodeType === 'function') {
+ if (keepsTextNodes) {
+ el = document.createTextNode('');
+ getCallback().callbacks.push({ callback: node });
+ } else {
+ el = document.createComment('~');
+ getCallback().callbacks.push({
+ callback: function () {
+ var el = document.createTextNode('');
+ domMutate.replaceChild.call(this.parentNode, el, this);
+ return node.apply(el, arguments);
+ }
+ });
+ }
+ }
+ return el;
+ }
+ function getCallbacks(el, pathData, elementCallbacks) {
+ var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, child = el, pathLength = path ? path.length : 0, pathsLength = paths ? paths.length : 0;
+ for (var i = 0; i < pathLength; i++) {
+ child = child.childNodes.item(path[i]);
+ }
+ for (i = 0; i < pathsLength; i++) {
+ getCallbacks(child, paths[i], elementCallbacks);
+ }
+ elementCallbacks.push({
+ element: child,
+ callbacks: callbacks
+ });
+ }
+ function hydrateCallbacks(callbacks, args) {
+ var len = callbacks.length, callbacksLength, callbackElement, callbackData;
+ for (var i = 0; i < len; i++) {
+ callbackData = callbacks[i];
+ callbacksLength = callbackData.callbacks.length;
+ callbackElement = callbackData.element;
+ for (var c = 0; c < callbacksLength; c++) {
+ callbackData.callbacks[c].callback.apply(callbackElement, args);
+ }
+ }
+ }
+ function makeTarget(nodes, doc) {
+ var paths = [];
+ var frag = processNodes(nodes, paths, [], doc || getDocument());
+ return {
+ paths: paths,
+ clone: frag,
+ hydrate: function () {
+ var cloned = cloneNode(this.clone);
+ var args = makeArray(arguments);
+ var callbacks = [];
+ for (var i = 0; i < paths.length; i++) {
+ getCallbacks(cloned, paths[i], callbacks);
+ }
+ hydrateCallbacks(callbacks, args);
+ return cloned;
+ }
+ };
+ }
+ makeTarget.keepsTextNodes = keepsTextNodes;
+ makeTarget.cloneNode = cloneNode;
+ namespace.view = namespace.view || {};
+ module.exports = namespace.view.target = makeTarget;
+});
+/*can-stache@3.0.7#src/mustache_core*/
+define('can-stache@3.0.7#src/mustache_core', function (require, exports, module) {
+ var live = require('can-view-live');
+ var nodeLists = require('can-view-nodelist');
+ var compute = require('can-compute');
+ var Observation = require('can-observation');
+ var utils = require('./utils');
+ var expression = require('./expression');
+ var types = require('can-util/js/types/types');
+ var frag = require('can-util/dom/frag/frag');
+ var attr = require('can-util/dom/attr/attr');
+ var mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, k = function () {
+ };
+ var core = {
+ expression: expression,
+ makeEvaluator: function (scope, helperOptions, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) {
+ if (mode === '^') {
+ var temp = truthyRenderer;
+ truthyRenderer = falseyRenderer;
+ falseyRenderer = temp;
+ }
+ var value, helperOptionArg;
+ if (exprData instanceof expression.Call) {
+ helperOptionArg = {
+ fn: function () {
+ },
+ inverse: function () {
+ },
+ context: scope.peak('.'),
+ scope: scope,
+ nodeList: nodeList,
+ exprData: exprData,
+ helpersScope: helperOptions
+ };
+ utils.convertToScopes(helperOptionArg, scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ value = exprData.value(scope, helperOptions, helperOptionArg);
+ if (exprData.isHelper) {
+ return value;
+ }
+ } else if (exprData instanceof expression.Bracket) {
+ value = exprData.value(scope);
+ if (exprData.isHelper) {
+ return value;
+ }
+ } else if (exprData instanceof expression.Lookup) {
+ value = exprData.value(scope);
+ if (exprData.isHelper) {
+ return value;
+ }
+ } else if (exprData instanceof expression.Helper && exprData.methodExpr instanceof expression.Bracket) {
+ value = exprData.methodExpr.value(scope);
+ if (exprData.isHelper) {
+ return value;
+ }
+ } else {
+ var readOptions = {
+ isArgument: true,
+ args: [
+ scope.peak('.'),
+ scope
+ ],
+ asCompute: true
+ };
+ var helperAndValue = exprData.helperAndValue(scope, helperOptions, readOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ var helper = helperAndValue.helper;
+ value = helperAndValue.value;
+ if (helper) {
+ return exprData.evaluator(helper, scope, helperOptions, readOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ }
+ }
+ if (!mode) {
+ if (value && value.isComputed) {
+ return value;
+ } else {
+ return function () {
+ return '' + (value != null ? value : '');
+ };
+ }
+ } else if (mode === '#' || mode === '^') {
+ helperOptionArg = {
+ fn: function () {
+ },
+ inverse: function () {
+ }
+ };
+ utils.convertToScopes(helperOptionArg, scope, helperOptions, nodeList, truthyRenderer, falseyRenderer, stringOnly);
+ return function () {
+ var finalValue;
+ if (types.isCompute(value)) {
+ finalValue = value();
+ } else {
+ finalValue = value;
+ }
+ if (typeof finalValue === 'function') {
+ return finalValue;
+ } else if (typeof finalValue !== 'string' && utils.isArrayLike(finalValue)) {
+ var isObserveList = types.isMapLike(finalValue);
+ if (isObserveList ? finalValue.attr('length') : finalValue.length) {
+ if (stringOnly) {
+ return utils.getItemsStringContent(finalValue, isObserveList, helperOptionArg, helperOptions);
+ } else {
+ return frag(utils.getItemsFragContent(finalValue, helperOptionArg, scope));
+ }
+ } else {
+ return helperOptionArg.inverse(scope, helperOptions);
+ }
+ } else {
+ return finalValue ? helperOptionArg.fn(finalValue || scope, helperOptions) : helperOptionArg.inverse(scope, helperOptions);
+ }
+ };
+ } else {
+ }
+ },
+ makeLiveBindingPartialRenderer: function (expressionString, state) {
+ expressionString = expressionString.trim();
+ var exprData, partialName = expressionString.split(/\s+/).shift();
+ if (partialName !== expressionString) {
+ exprData = core.expression.parse(expressionString);
+ }
+ return function (scope, options, parentSectionNodeList) {
+ var nodeList = [this];
+ nodeList.expression = '>' + partialName;
+ nodeLists.register(nodeList, null, parentSectionNodeList || true, state.directlyNested);
+ var partialFrag = compute(function () {
+ var localPartialName = partialName;
+ if (exprData && exprData.argExprs.length === 1) {
+ var newContext = exprData.argExprs[0].value(scope, options)();
+ if (typeof newContext === 'undefined') {
+ } else {
+ scope = scope.add(newContext);
+ }
+ }
+ var partial = options.peak('partials.' + localPartialName), renderer;
+ if (partial) {
+ renderer = function () {
+ return partial.render ? partial.render(scope, options, nodeList) : partial(scope, options);
+ };
+ } else {
+ var scopePartialName = scope.read(localPartialName, { isArgument: true }).value;
+ if (scopePartialName === null || !scopePartialName && localPartialName[0] === '*') {
+ return frag('');
+ }
+ if (scopePartialName) {
+ localPartialName = scopePartialName;
+ }
+ renderer = function () {
+ if (typeof localPartialName === 'function') {
+ return localPartialName(scope, options, nodeList);
+ } else {
+ return core.getTemplateById(localPartialName)(scope, options, nodeList);
+ }
+ };
+ }
+ var res = Observation.ignore(renderer)();
+ return frag(res);
+ });
+ partialFrag.computeInstance.setPrimaryDepth(nodeList.nesting);
+ live.html(this, partialFrag, this.parentNode, nodeList);
+ };
+ },
+ makeStringBranchRenderer: function (mode, expressionString) {
+ var exprData = core.expression.parse(expressionString), fullExpression = mode + expressionString;
+ if (!(exprData instanceof expression.Helper) && !(exprData instanceof expression.Call)) {
+ exprData = new expression.Helper(exprData, [], {});
+ }
+ return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) {
+ var evaluator = scope.__cache[fullExpression];
+ if (mode || !evaluator) {
+ evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true);
+ if (!mode) {
+ scope.__cache[fullExpression] = evaluator;
+ }
+ }
+ var res = evaluator();
+ return res == null ? '' : '' + res;
+ };
+ },
+ makeLiveBindingBranchRenderer: function (mode, expressionString, state) {
+ var exprData = core.expression.parse(expressionString);
+ if (!(exprData instanceof expression.Helper) && !(exprData instanceof expression.Call) && !(exprData instanceof expression.Bracket) && !(exprData instanceof expression.Lookup)) {
+ exprData = new expression.Helper(exprData, [], {});
+ }
+ return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) {
+ var nodeList = [this];
+ nodeList.expression = expressionString;
+ nodeLists.register(nodeList, null, parentSectionNodeList || true, state.directlyNested);
+ var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag);
+ var gotCompute = evaluator.isComputed, computeValue;
+ if (gotCompute) {
+ computeValue = evaluator;
+ } else {
+ computeValue = compute(evaluator, null, false);
+ }
+ computeValue.computeInstance.setPrimaryDepth(nodeList.nesting);
+ computeValue.computeInstance.bind('change', k);
+ var value = computeValue();
+ if (typeof value === 'function') {
+ Observation.ignore(value)(this);
+ } else if (gotCompute || computeValue.computeInstance.hasDependencies) {
+ if (state.attr) {
+ live.attr(this, state.attr, computeValue);
+ } else if (state.tag) {
+ live.attrs(this, computeValue);
+ } else if (state.text && typeof value !== 'object') {
+ live.text(this, computeValue, this.parentNode, nodeList);
+ } else {
+ live.html(this, computeValue, this.parentNode, nodeList);
+ }
+ } else {
+ if (state.attr) {
+ attr.set(this, state.attr, value);
+ } else if (state.tag) {
+ live.attrs(this, value);
+ } else if (state.text && typeof value === 'string') {
+ this.nodeValue = value;
+ } else if (value != null) {
+ nodeLists.replace([this], frag(value, this.ownerDocument));
+ }
+ }
+ computeValue.computeInstance.unbind('change', k);
+ };
+ },
+ splitModeFromExpression: function (expression, state) {
+ expression = expression.trim();
+ var mode = expression.charAt(0);
+ if ('#/{&^>!'.indexOf(mode) >= 0) {
+ expression = expression.substr(1).trim();
+ } else {
+ mode = null;
+ }
+ if (mode === '{' && state.node) {
+ mode = null;
+ }
+ return {
+ mode: mode,
+ expression: expression
+ };
+ },
+ cleanLineEndings: function (template) {
+ return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) {
+ spaceAfter = spaceAfter || '';
+ returnBefore = returnBefore || '';
+ spaceBefore = spaceBefore || '';
+ var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {});
+ if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) {
+ return whole;
+ } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) {
+ return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : '');
+ } else {
+ return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : '');
+ }
+ });
+ },
+ Options: utils.Options,
+ getTemplateById: function () {
+ }
+ };
+ var makeEvaluator = core.makeEvaluator, splitModeFromExpression = core.splitModeFromExpression;
+ module.exports = core;
+});
+/*can-stache@3.0.7#src/html_section*/
+define('can-stache@3.0.7#src/html_section', function (require, exports, module) {
+ var target = require('can-view-target');
+ var Scope = require('can-view-scope');
+ var utils = require('./utils');
+ var mustacheCore = require('./mustache_core');
+ var getDocument = require('can-util/dom/document/document');
+ var assign = require('can-util/js/assign/assign');
+ var last = require('can-util/js/last/last');
+ var decodeHTML = typeof document !== 'undefined' && function () {
+ var el = getDocument().createElement('div');
+ return function (html) {
+ if (html.indexOf('&') === -1) {
+ return html.replace(/\r\n/g, '\n');
+ }
+ el.innerHTML = html;
+ return el.childNodes.length === 0 ? '' : el.childNodes.item(0).nodeValue;
+ };
+ }();
+ var HTMLSectionBuilder = function () {
+ this.stack = [new HTMLSection()];
+ };
+ assign(HTMLSectionBuilder.prototype, utils.mixins);
+ assign(HTMLSectionBuilder.prototype, {
+ startSubSection: function (process) {
+ var newSection = new HTMLSection(process);
+ this.stack.push(newSection);
+ return newSection;
+ },
+ endSubSectionAndReturnRenderer: function () {
+ if (this.last().isEmpty()) {
+ this.stack.pop();
+ return null;
+ } else {
+ var htmlSection = this.endSection();
+ return htmlSection.compiled.hydrate.bind(htmlSection.compiled);
+ }
+ },
+ startSection: function (process) {
+ var newSection = new HTMLSection(process);
+ this.last().add(newSection.targetCallback);
+ this.stack.push(newSection);
+ },
+ endSection: function () {
+ this.last().compile();
+ return this.stack.pop();
+ },
+ inverse: function () {
+ this.last().inverse();
+ },
+ compile: function () {
+ var compiled = this.stack.pop().compile();
+ return function (scope, options, nodeList) {
+ if (!(scope instanceof Scope)) {
+ scope = Scope.refsScope().add(scope || {});
+ }
+ if (!(options instanceof mustacheCore.Options)) {
+ options = new mustacheCore.Options(options || {});
+ }
+ return compiled.hydrate(scope, options, nodeList);
+ };
+ },
+ push: function (chars) {
+ this.last().push(chars);
+ },
+ pop: function () {
+ return this.last().pop();
+ }
+ });
+ var HTMLSection = function (process) {
+ this.data = 'targetData';
+ this.targetData = [];
+ this.targetStack = [];
+ var self = this;
+ this.targetCallback = function (scope, options, sectionNode) {
+ process.call(this, scope, options, sectionNode, self.compiled.hydrate.bind(self.compiled), self.inverseCompiled && self.inverseCompiled.hydrate.bind(self.inverseCompiled));
+ };
+ };
+ assign(HTMLSection.prototype, {
+ inverse: function () {
+ this.inverseData = [];
+ this.data = 'inverseData';
+ },
+ push: function (data) {
+ this.add(data);
+ this.targetStack.push(data);
+ },
+ pop: function () {
+ return this.targetStack.pop();
+ },
+ add: function (data) {
+ if (typeof data === 'string') {
+ data = decodeHTML(data);
+ }
+ if (this.targetStack.length) {
+ last(this.targetStack).children.push(data);
+ } else {
+ this[this.data].push(data);
+ }
+ },
+ compile: function () {
+ this.compiled = target(this.targetData, getDocument());
+ if (this.inverseData) {
+ this.inverseCompiled = target(this.inverseData, getDocument());
+ delete this.inverseData;
+ }
+ this.targetStack = this.targetData = null;
+ return this.compiled;
+ },
+ children: function () {
+ if (this.targetStack.length) {
+ return last(this.targetStack).children;
+ } else {
+ return this[this.data];
+ }
+ },
+ isEmpty: function () {
+ return !this.targetData.length;
+ }
+ });
+ HTMLSectionBuilder.HTMLSection = HTMLSection;
+ module.exports = HTMLSectionBuilder;
+});
+/*can-stache@3.0.7#src/text_section*/
+define('can-stache@3.0.7#src/text_section', function (require, exports, module) {
+ var compute = require('can-compute');
+ var live = require('can-view-live');
+ var utils = require('./utils');
+ var attr = require('can-util/dom/attr/attr');
+ var assign = require('can-util/js/assign/assign');
+ var noop = function () {
+ };
+ var TextSectionBuilder = function () {
+ this.stack = [new TextSection()];
+ };
+ assign(TextSectionBuilder.prototype, utils.mixins);
+ assign(TextSectionBuilder.prototype, {
+ startSection: function (process) {
+ var subSection = new TextSection();
+ this.last().add({
+ process: process,
+ truthy: subSection
+ });
+ this.stack.push(subSection);
+ },
+ endSection: function () {
+ this.stack.pop();
+ },
+ inverse: function () {
+ this.stack.pop();
+ var falseySection = new TextSection();
+ this.last().last().falsey = falseySection;
+ this.stack.push(falseySection);
+ },
+ compile: function (state) {
+ var renderer = this.stack[0].compile();
+ return function (scope, options) {
+ var computeValue = compute(function () {
+ return renderer(scope, options);
+ }, null, false);
+ computeValue.computeInstance.addEventListener('change', noop);
+ var value = computeValue();
+ if (computeValue.computeInstance.hasDependencies) {
+ if (state.textContentOnly) {
+ live.text(this, computeValue);
+ } else if (state.attr) {
+ live.attr(this, state.attr, computeValue);
+ } else {
+ live.attrs(this, computeValue, scope, options);
+ }
+ computeValue.computeInstance.removeEventListener('change', noop);
+ } else {
+ if (state.textContentOnly) {
+ this.nodeValue = value;
+ } else if (state.attr) {
+ attr.set(this, state.attr, value);
+ } else {
+ live.attrs(this, value);
+ }
+ }
+ };
+ }
+ });
+ var passTruthyFalsey = function (process, truthy, falsey) {
+ return function (scope, options) {
+ return process.call(this, scope, options, truthy, falsey);
+ };
+ };
+ var TextSection = function () {
+ this.values = [];
+ };
+ assign(TextSection.prototype, {
+ add: function (data) {
+ this.values.push(data);
+ },
+ last: function () {
+ return this.values[this.values.length - 1];
+ },
+ compile: function () {
+ var values = this.values, len = values.length;
+ for (var i = 0; i < len; i++) {
+ var value = this.values[i];
+ if (typeof value === 'object') {
+ values[i] = passTruthyFalsey(value.process, value.truthy && value.truthy.compile(), value.falsey && value.falsey.compile());
+ }
+ }
+ return function (scope, options) {
+ var txt = '', value;
+ for (var i = 0; i < len; i++) {
+ value = values[i];
+ txt += typeof value === 'string' ? value : value.call(this, scope, options);
+ }
+ return txt;
+ };
+ }
+ });
+ module.exports = TextSectionBuilder;
+});
+/*can-stache@3.0.7#helpers/converter*/
+define('can-stache@3.0.7#helpers/converter', function (require, exports, module) {
+ var helpers = require('./core');
+ var expression = require('../src/expression');
+ var makeArray = require('can-util/js/make-array/make-array');
+ helpers.registerConverter = function (name, getterSetter) {
+ getterSetter = getterSetter || {};
+ helpers.registerHelper(name, function (newVal, source) {
+ var args = makeArray(arguments);
+ if (newVal instanceof expression.SetIdentifier) {
+ return typeof getterSetter.set === 'function' ? getterSetter.set.apply(this, [newVal.value].concat(args.slice(1))) : source(newVal.value);
+ } else {
+ return typeof getterSetter.get === 'function' ? getterSetter.get.apply(this, args) : args[0];
+ }
+ });
+ };
+ module.exports = helpers;
+});
+/*can-stache@3.0.7#src/intermediate_and_imports*/
+define('can-stache@3.0.7#src/intermediate_and_imports', function (require, exports, module) {
+ var mustacheCore = require('./mustache_core');
+ var parser = require('can-view-parser');
+ module.exports = function (source) {
+ var template = mustacheCore.cleanLineEndings(source);
+ var imports = [], dynamicImports = [], ases = {}, inImport = false, inFrom = false, inAs = false, isUnary = false, currentAs = '', currentFrom = '';
+ var intermediate = parser(template, {
+ start: function (tagName, unary) {
+ isUnary = unary;
+ if (tagName === 'can-import') {
+ inImport = true;
+ } else if (inImport) {
+ inImport = false;
+ }
+ },
+ attrStart: function (attrName) {
+ if (attrName === 'from') {
+ inFrom = true;
+ } else if (attrName === 'as' || attrName === 'export-as') {
+ inAs = true;
+ }
+ },
+ attrEnd: function (attrName) {
+ if (attrName === 'from') {
+ inFrom = false;
+ } else if (attrName === 'as' || attrName === 'export-as') {
+ inAs = false;
+ }
+ },
+ attrValue: function (value) {
+ if (inFrom && inImport) {
+ imports.push(value);
+ if (!isUnary) {
+ dynamicImports.push(value);
+ }
+ currentFrom = value;
+ } else if (inAs && inImport) {
+ currentAs = value;
+ }
+ },
+ end: function (tagName) {
+ if (tagName === 'can-import') {
+ if (currentAs) {
+ ases[currentAs] = currentFrom;
+ currentAs = '';
+ }
+ }
+ },
+ close: function (tagName) {
+ if (tagName === 'can-import') {
+ imports.pop();
+ }
+ }
+ }, true);
+ return {
+ intermediate: intermediate,
+ imports: imports,
+ dynamicImports: dynamicImports,
+ ases: ases,
+ exports: ases
+ };
+ };
+});
+/*can-util@3.0.10#js/import/import*/
+define('can-util@3.0.10#js/import/import', function (require, exports, module) {
+ (function (global) {
+ var isFunction = require('../is-function/is-function');
+ var global = require('../global/global')();
+ module.exports = function (moduleName, parentName) {
+ return new Promise(function (resolve, reject) {
+ try {
+ if (typeof global.System === 'object' && isFunction(global.System['import'])) {
+ global.System['import'](moduleName, { name: parentName }).then(resolve, reject);
+ } else if (global.define && global.define.amd) {
+ global.require([moduleName], function (value) {
+ resolve(value);
+ });
+ } else if (global.require) {
+ resolve(global.require(moduleName));
+ } else {
+ resolve();
+ }
+ } catch (err) {
+ reject(err);
+ }
+ });
+ };
+ }(function () {
+ return this;
+ }()));
+});
+/*can-stache@3.0.7#can-stache*/
+define('can-stache@3.0.7#can-stache', function (require, exports, module) {
+ var parser = require('can-view-parser');
+ var viewCallbacks = require('can-view-callbacks');
+ var HTMLSectionBuilder = require('./src/html_section');
+ var TextSectionBuilder = require('./src/text_section');
+ var mustacheCore = require('./src/mustache_core');
+ var mustacheHelpers = require('../helpers/core');
+ require('../helpers/converter');
+ var getIntermediateAndImports = require('./src/intermediate_and_imports');
+ var namespace = require('can-util/namespace');
+ var DOCUMENT = require('can-util/dom/document/document');
+ var assign = require('can-util/js/assign/assign');
+ var last = require('can-util/js/last/last');
+ var importer = require('can-util/js/import/import');
+ require('can-view-target');
+ require('can-view-nodelist');
+ var svgNamespace = 'http://www.w3.org/2000/svg';
+ var namespaces = {
+ 'svg': svgNamespace,
+ 'g': svgNamespace
+ }, textContentOnlyTag = {
+ style: true,
+ script: true
+ };
+ function stache(template) {
+ if (typeof template === 'string') {
+ template = mustacheCore.cleanLineEndings(template);
+ }
+ var section = new HTMLSectionBuilder(), state = {
+ node: null,
+ attr: null,
+ sectionElementStack: [],
+ text: false,
+ namespaceStack: [],
+ textContentOnly: null
+ }, makeRendererAndUpdateSection = function (section, mode, stache) {
+ if (mode === '>') {
+ section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, copyState()));
+ } else if (mode === '/') {
+ section.endSection();
+ if (section instanceof HTMLSectionBuilder) {
+ state.sectionElementStack.pop();
+ }
+ } else if (mode === 'else') {
+ section.inverse();
+ } else {
+ var makeRenderer = section instanceof HTMLSectionBuilder ? mustacheCore.makeLiveBindingBranchRenderer : mustacheCore.makeStringBranchRenderer;
+ if (mode === '{' || mode === '&') {
+ section.add(makeRenderer(null, stache, copyState()));
+ } else if (mode === '#' || mode === '^') {
+ section.startSection(makeRenderer(mode, stache, copyState()));
+ if (section instanceof HTMLSectionBuilder) {
+ state.sectionElementStack.push('section');
+ }
+ } else {
+ section.add(makeRenderer(null, stache, copyState({ text: true })));
+ }
+ }
+ }, copyState = function (overwrites) {
+ var lastElement = state.sectionElementStack[state.sectionElementStack.length - 1];
+ var cur = {
+ tag: state.node && state.node.tag,
+ attr: state.attr && state.attr.name,
+ directlyNested: state.sectionElementStack.length ? lastElement === 'section' || lastElement === 'custom' : true,
+ textContentOnly: !!state.textContentOnly
+ };
+ return overwrites ? assign(cur, overwrites) : cur;
+ }, addAttributesCallback = function (node, callback) {
+ if (!node.attributes) {
+ node.attributes = [];
+ }
+ node.attributes.unshift(callback);
+ };
+ parser(template, {
+ start: function (tagName, unary) {
+ var matchedNamespace = namespaces[tagName];
+ if (matchedNamespace && !unary) {
+ state.namespaceStack.push(matchedNamespace);
+ }
+ state.node = {
+ tag: tagName,
+ children: [],
+ namespace: matchedNamespace || last(state.namespaceStack)
+ };
+ },
+ end: function (tagName, unary) {
+ var isCustomTag = viewCallbacks.tag(tagName);
+ if (unary) {
+ section.add(state.node);
+ if (isCustomTag) {
+ addAttributesCallback(state.node, function (scope, options, parentNodeList) {
+ viewCallbacks.tagHandler(this, tagName, {
+ scope: scope,
+ options: options,
+ subtemplate: null,
+ templateType: 'stache',
+ parentNodeList: parentNodeList
+ });
+ });
+ }
+ } else {
+ section.push(state.node);
+ state.sectionElementStack.push(isCustomTag ? 'custom' : tagName);
+ if (isCustomTag) {
+ section.startSubSection();
+ } else if (textContentOnlyTag[tagName]) {
+ state.textContentOnly = new TextSectionBuilder();
+ }
+ }
+ state.node = null;
+ },
+ close: function (tagName) {
+ var matchedNamespace = namespaces[tagName];
+ if (matchedNamespace) {
+ state.namespaceStack.pop();
+ }
+ var isCustomTag = viewCallbacks.tag(tagName), renderer;
+ if (isCustomTag) {
+ renderer = section.endSubSectionAndReturnRenderer();
+ }
+ if (textContentOnlyTag[tagName]) {
+ section.last().add(state.textContentOnly.compile(copyState()));
+ state.textContentOnly = null;
+ }
+ var oldNode = section.pop();
+ if (isCustomTag) {
+ addAttributesCallback(oldNode, function (scope, options, parentNodeList) {
+ viewCallbacks.tagHandler(this, tagName, {
+ scope: scope,
+ options: options,
+ subtemplate: renderer,
+ templateType: 'stache',
+ parentNodeList: parentNodeList
+ });
+ });
+ }
+ state.sectionElementStack.pop();
+ },
+ attrStart: function (attrName) {
+ if (state.node.section) {
+ state.node.section.add(attrName + '="');
+ } else {
+ state.attr = {
+ name: attrName,
+ value: ''
+ };
+ }
+ },
+ attrEnd: function (attrName) {
+ if (state.node.section) {
+ state.node.section.add('" ');
+ } else {
+ if (!state.node.attrs) {
+ state.node.attrs = {};
+ }
+ state.node.attrs[state.attr.name] = state.attr.section ? state.attr.section.compile(copyState()) : state.attr.value;
+ var attrCallback = viewCallbacks.attr(attrName);
+ if (attrCallback) {
+ if (!state.node.attributes) {
+ state.node.attributes = [];
+ }
+ state.node.attributes.push(function (scope, options, nodeList) {
+ attrCallback(this, {
+ attributeName: attrName,
+ scope: scope,
+ options: options,
+ nodeList: nodeList
+ });
+ });
+ }
+ state.attr = null;
+ }
+ },
+ attrValue: function (value) {
+ var section = state.node.section || state.attr.section;
+ if (section) {
+ section.add(value);
+ } else {
+ state.attr.value += value;
+ }
+ },
+ chars: function (text) {
+ (state.textContentOnly || section).add(text);
+ },
+ special: function (text) {
+ var firstAndText = mustacheCore.splitModeFromExpression(text, state), mode = firstAndText.mode, expression = firstAndText.expression;
+ if (expression === 'else') {
+ var inverseSection;
+ if (state.attr && state.attr.section) {
+ inverseSection = state.attr.section;
+ } else if (state.node && state.node.section) {
+ inverseSection = state.node.section;
+ } else {
+ inverseSection = state.textContentOnly || section;
+ }
+ inverseSection.inverse();
+ return;
+ }
+ if (mode === '!') {
+ return;
+ }
+ if (state.node && state.node.section) {
+ makeRendererAndUpdateSection(state.node.section, mode, expression);
+ if (state.node.section.subSectionDepth() === 0) {
+ state.node.attributes.push(state.node.section.compile(copyState()));
+ delete state.node.section;
+ }
+ } else if (state.attr) {
+ if (!state.attr.section) {
+ state.attr.section = new TextSectionBuilder();
+ if (state.attr.value) {
+ state.attr.section.add(state.attr.value);
+ }
+ }
+ makeRendererAndUpdateSection(state.attr.section, mode, expression);
+ } else if (state.node) {
+ if (!state.node.attributes) {
+ state.node.attributes = [];
+ }
+ if (!mode) {
+ state.node.attributes.push(mustacheCore.makeLiveBindingBranchRenderer(null, expression, copyState()));
+ } else if (mode === '#' || mode === '^') {
+ if (!state.node.section) {
+ state.node.section = new TextSectionBuilder();
+ }
+ makeRendererAndUpdateSection(state.node.section, mode, expression);
+ } else {
+ throw new Error(mode + ' is currently not supported within a tag.');
+ }
+ } else {
+ makeRendererAndUpdateSection(state.textContentOnly || section, mode, expression);
+ }
+ },
+ comment: function (text) {
+ section.add({ comment: text });
+ },
+ done: function () {
+ }
+ });
+ return section.compile();
+ }
+ assign(stache, mustacheHelpers);
+ stache.safeString = function (text) {
+ return {
+ toString: function () {
+ return text;
+ }
+ };
+ };
+ stache.async = function (source) {
+ var iAi = getIntermediateAndImports(source);
+ var importPromises = iAi.imports.map(function (moduleName) {
+ return importer(moduleName);
+ });
+ return Promise.all(importPromises).then(function () {
+ return stache(iAi.intermediate);
+ });
+ };
+ var templates = {};
+ stache.from = mustacheCore.getTemplateById = function (id) {
+ if (!templates[id]) {
+ var el = DOCUMENT().getElementById(id);
+ templates[id] = stache(el.innerHTML);
+ }
+ return templates[id];
+ };
+ stache.registerPartial = function (id, partial) {
+ templates[id] = typeof partial === 'string' ? stache(partial) : partial;
+ };
+ module.exports = namespace.stache = stache;
+});
+/*steal-qunit@0.1.4#add-dom*/
+define('steal-qunit@0.1.4#add-dom', function (require, exports, module) {
+ 'format cjs';
+ if (!document.getElementById('qunit')) {
+ var qunit = document.createElement('div');
+ qunit.id = 'qunit';
+ (document.body || document.documentElement).appendChild(qunit);
+ }
+});
+/*qunitjs@1.23.1#qunit/qunit*/
+define('qunitjs@1.23.1#qunit/qunit', [
+ 'module',
+ '@loader',
+ 'steal-qunit/add-dom'
+], function (module, loader) {
+ loader.get('@@global-helpers').prepareGlobal(module.id, ['steal-qunit/add-dom'], 'QUnit');
+ var define = loader.global.define;
+ var require = loader.global.require;
+ var source = '/*!\n * QUnit 1.23.1\n * https://qunitjs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * https://jquery.org/license\n *\n * Date: 2016-04-12T17:29Z\n */\n\n( function( global ) {\n\nvar QUnit = {};\n\nvar Date = global.Date;\nvar now = Date.now || function() {\n\treturn new Date().getTime();\n};\n\nvar setTimeout = global.setTimeout;\nvar clearTimeout = global.clearTimeout;\n\n// Store a local window from the global to allow direct references.\nvar window = global.window;\n\nvar defined = {\n\tdocument: window && window.document !== undefined,\n\tsetTimeout: setTimeout !== undefined,\n\tsessionStorage: ( function() {\n\t\tvar x = "qunit-test-string";\n\t\ttry {\n\t\t\tsessionStorage.setItem( x, x );\n\t\t\tsessionStorage.removeItem( x );\n\t\t\treturn true;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}() )\n};\n\nvar fileName = ( sourceFromStacktrace( 0 ) || "" ).replace( /(:\\d+)+\\)?/, "" ).replace( /.+\\//, "" );\nvar globalStartCalled = false;\nvar runStarted = false;\n\nvar toString = Object.prototype.toString,\n\thasOwn = Object.prototype.hasOwnProperty;\n\n// Returns a new Array with the elements that are in a but not in b\nfunction diff( a, b ) {\n\tvar i, j,\n\t\tresult = a.slice();\n\n\tfor ( i = 0; i < result.length; i++ ) {\n\t\tfor ( j = 0; j < b.length; j++ ) {\n\t\t\tif ( result[ i ] === b[ j ] ) {\n\t\t\t\tresult.splice( i, 1 );\n\t\t\t\ti--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn result;\n}\n\n// From jquery.js\nfunction inArray( elem, array ) {\n\tif ( array.indexOf ) {\n\t\treturn array.indexOf( elem );\n\t}\n\n\tfor ( var i = 0, length = array.length; i < length; i++ ) {\n\t\tif ( array[ i ] === elem ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n/**\n * Makes a clone of an object using only Array or Object as base,\n * and copies over the own enumerable properties.\n *\n * @param {Object} obj\n * @return {Object} New object with only the own properties (recursively).\n */\nfunction objectValues ( obj ) {\n\tvar key, val,\n\t\tvals = QUnit.is( "array", obj ) ? [] : {};\n\tfor ( key in obj ) {\n\t\tif ( hasOwn.call( obj, key ) ) {\n\t\t\tval = obj[ key ];\n\t\t\tvals[ key ] = val === Object( val ) ? objectValues( val ) : val;\n\t\t}\n\t}\n\treturn vals;\n}\n\nfunction extend( a, b, undefOnly ) {\n\tfor ( var prop in b ) {\n\t\tif ( hasOwn.call( b, prop ) ) {\n\n\t\t\t// Avoid "Member not found" error in IE8 caused by messing with window.constructor\n\t\t\t// This block runs on every environment, so `global` is being used instead of `window`\n\t\t\t// to avoid errors on node.\n\t\t\tif ( prop !== "constructor" || a !== global ) {\n\t\t\t\tif ( b[ prop ] === undefined ) {\n\t\t\t\t\tdelete a[ prop ];\n\t\t\t\t} else if ( !( undefOnly && typeof a[ prop ] !== "undefined" ) ) {\n\t\t\t\t\ta[ prop ] = b[ prop ];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn a;\n}\n\nfunction objectType( obj ) {\n\tif ( typeof obj === "undefined" ) {\n\t\treturn "undefined";\n\t}\n\n\t// Consider: typeof null === object\n\tif ( obj === null ) {\n\t\treturn "null";\n\t}\n\n\tvar match = toString.call( obj ).match( /^\\[object\\s(.*)\\]$/ ),\n\t\ttype = match && match[ 1 ];\n\n\tswitch ( type ) {\n\t\tcase "Number":\n\t\t\tif ( isNaN( obj ) ) {\n\t\t\t\treturn "nan";\n\t\t\t}\n\t\t\treturn "number";\n\t\tcase "String":\n\t\tcase "Boolean":\n\t\tcase "Array":\n\t\tcase "Set":\n\t\tcase "Map":\n\t\tcase "Date":\n\t\tcase "RegExp":\n\t\tcase "Function":\n\t\tcase "Symbol":\n\t\t\treturn type.toLowerCase();\n\t}\n\tif ( typeof obj === "object" ) {\n\t\treturn "object";\n\t}\n}\n\n// Safe object type checking\nfunction is( type, obj ) {\n\treturn QUnit.objectType( obj ) === type;\n}\n\n// Doesn\'t support IE6 to IE9, it will return undefined on these browsers\n// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack\nfunction extractStacktrace( e, offset ) {\n\toffset = offset === undefined ? 4 : offset;\n\n\tvar stack, include, i;\n\n\tif ( e.stack ) {\n\t\tstack = e.stack.split( "\\n" );\n\t\tif ( /^error$/i.test( stack[ 0 ] ) ) {\n\t\t\tstack.shift();\n\t\t}\n\t\tif ( fileName ) {\n\t\t\tinclude = [];\n\t\t\tfor ( i = offset; i < stack.length; i++ ) {\n\t\t\t\tif ( stack[ i ].indexOf( fileName ) !== -1 ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tinclude.push( stack[ i ] );\n\t\t\t}\n\t\t\tif ( include.length ) {\n\t\t\t\treturn include.join( "\\n" );\n\t\t\t}\n\t\t}\n\t\treturn stack[ offset ];\n\n\t// Support: Safari <=6 only\n\t} else if ( e.sourceURL ) {\n\n\t\t// Exclude useless self-reference for generated Error objects\n\t\tif ( /qunit.js$/.test( e.sourceURL ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For actual exceptions, this is useful\n\t\treturn e.sourceURL + ":" + e.line;\n\t}\n}\n\nfunction sourceFromStacktrace( offset ) {\n\tvar error = new Error();\n\n\t// Support: Safari <=7 only, IE <=10 - 11 only\n\t// Not all browsers generate the `stack` property for `new Error()`, see also #636\n\tif ( !error.stack ) {\n\t\ttry {\n\t\t\tthrow error;\n\t\t} catch ( err ) {\n\t\t\terror = err;\n\t\t}\n\t}\n\n\treturn extractStacktrace( error, offset );\n}\n\n/**\n * Config object: Maintain internal state\n * Later exposed as QUnit.config\n * `config` initialized at top of scope\n */\nvar config = {\n\n\t// The queue of tests to run\n\tqueue: [],\n\n\t// Block until document ready\n\tblocking: true,\n\n\t// By default, run previously failed tests first\n\t// very useful in combination with "Hide passed tests" checked\n\treorder: true,\n\n\t// By default, modify document.title when suite is done\n\taltertitle: true,\n\n\t// HTML Reporter: collapse every test except the first failing test\n\t// If false, all failing tests will be expanded\n\tcollapse: true,\n\n\t// By default, scroll to top of the page when suite is done\n\tscrolltop: true,\n\n\t// Depth up-to which object will be dumped\n\tmaxDepth: 5,\n\n\t// When enabled, all tests must call expect()\n\trequireExpects: false,\n\n\t// Placeholder for user-configurable form-exposed URL parameters\n\turlConfig: [],\n\n\t// Set of all modules.\n\tmodules: [],\n\n\t// Stack of nested modules\n\tmoduleStack: [],\n\n\t// The first unnamed module\n\tcurrentModule: {\n\t\tname: "",\n\t\ttests: []\n\t},\n\n\tcallbacks: {}\n};\n\n// Push a loose unnamed module to the modules collection\nconfig.modules.push( config.currentModule );\n\nvar loggingCallbacks = {};\n\n// Register logging callbacks\nfunction registerLoggingCallbacks( obj ) {\n\tvar i, l, key,\n\t\tcallbackNames = [ "begin", "done", "log", "testStart", "testDone",\n\t\t\t"moduleStart", "moduleDone" ];\n\n\tfunction registerLoggingCallback( key ) {\n\t\tvar loggingCallback = function( callback ) {\n\t\t\tif ( objectType( callback ) !== "function" ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t"QUnit logging methods require a callback function as their first parameters."\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconfig.callbacks[ key ].push( callback );\n\t\t};\n\n\t\t// DEPRECATED: This will be removed on QUnit 2.0.0+\n\t\t// Stores the registered functions allowing restoring\n\t\t// at verifyLoggingCallbacks() if modified\n\t\tloggingCallbacks[ key ] = loggingCallback;\n\n\t\treturn loggingCallback;\n\t}\n\n\tfor ( i = 0, l = callbackNames.length; i < l; i++ ) {\n\t\tkey = callbackNames[ i ];\n\n\t\t// Initialize key collection of logging callback\n\t\tif ( objectType( config.callbacks[ key ] ) === "undefined" ) {\n\t\t\tconfig.callbacks[ key ] = [];\n\t\t}\n\n\t\tobj[ key ] = registerLoggingCallback( key );\n\t}\n}\n\nfunction runLoggingCallbacks( key, args ) {\n\tvar i, l, callbacks;\n\n\tcallbacks = config.callbacks[ key ];\n\tfor ( i = 0, l = callbacks.length; i < l; i++ ) {\n\t\tcallbacks[ i ]( args );\n\t}\n}\n\n// DEPRECATED: This will be removed on 2.0.0+\n// This function verifies if the loggingCallbacks were modified by the user\n// If so, it will restore it, assign the given callback and print a console warning\nfunction verifyLoggingCallbacks() {\n\tvar loggingCallback, userCallback;\n\n\tfor ( loggingCallback in loggingCallbacks ) {\n\t\tif ( QUnit[ loggingCallback ] !== loggingCallbacks[ loggingCallback ] ) {\n\n\t\t\tuserCallback = QUnit[ loggingCallback ];\n\n\t\t\t// Restore the callback function\n\t\t\tQUnit[ loggingCallback ] = loggingCallbacks[ loggingCallback ];\n\n\t\t\t// Assign the deprecated given callback\n\t\t\tQUnit[ loggingCallback ]( userCallback );\n\n\t\t\tif ( global.console && global.console.warn ) {\n\t\t\t\tglobal.console.warn(\n\t\t\t\t\t"QUnit." + loggingCallback + " was replaced with a new value.\\n" +\n\t\t\t\t\t"Please, check out the documentation on how to apply logging callbacks.\\n" +\n\t\t\t\t\t"Reference: https://api.qunitjs.com/category/callbacks/"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n( function() {\n\tif ( !defined.document ) {\n\t\treturn;\n\t}\n\n\t// `onErrorFnPrev` initialized at top of scope\n\t// Preserve other handlers\n\tvar onErrorFnPrev = window.onerror;\n\n\t// Cover uncaught exceptions\n\t// Returning true will suppress the default browser handler,\n\t// returning false will let it run.\n\twindow.onerror = function( error, filePath, linerNr ) {\n\t\tvar ret = false;\n\t\tif ( onErrorFnPrev ) {\n\t\t\tret = onErrorFnPrev( error, filePath, linerNr );\n\t\t}\n\n\t\t// Treat return value as window.onerror itself does,\n\t\t// Only do our handling if not suppressed.\n\t\tif ( ret !== true ) {\n\t\t\tif ( QUnit.config.current ) {\n\t\t\t\tif ( QUnit.config.current.ignoreGlobalErrors ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tQUnit.pushFailure( error, filePath + ":" + linerNr );\n\t\t\t} else {\n\t\t\t\tQUnit.test( "global failure", extend( function() {\n\t\t\t\t\tQUnit.pushFailure( error, filePath + ":" + linerNr );\n\t\t\t\t}, { validTest: true } ) );\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\treturn ret;\n\t};\n}() );\n\n// Figure out if we\'re running the tests from a server or not\nQUnit.isLocal = !( defined.document && window.location.protocol !== "file:" );\n\n// Expose the current QUnit version\nQUnit.version = "1.23.1";\n\nextend( QUnit, {\n\n\t// Call on start of module test to prepend name to all tests\n\tmodule: function( name, testEnvironment, executeNow ) {\n\t\tvar module, moduleFns;\n\t\tvar currentModule = config.currentModule;\n\n\t\tif ( arguments.length === 2 ) {\n\t\t\tif ( objectType( testEnvironment ) === "function" ) {\n\t\t\t\texecuteNow = testEnvironment;\n\t\t\t\ttestEnvironment = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// DEPRECATED: handles setup/teardown functions,\n\t\t// beforeEach and afterEach should be used instead\n\t\tif ( testEnvironment && testEnvironment.setup ) {\n\t\t\ttestEnvironment.beforeEach = testEnvironment.setup;\n\t\t\tdelete testEnvironment.setup;\n\t\t}\n\t\tif ( testEnvironment && testEnvironment.teardown ) {\n\t\t\ttestEnvironment.afterEach = testEnvironment.teardown;\n\t\t\tdelete testEnvironment.teardown;\n\t\t}\n\n\t\tmodule = createModule();\n\n\t\tmoduleFns = {\n\t\t\tbeforeEach: setHook( module, "beforeEach" ),\n\t\t\tafterEach: setHook( module, "afterEach" )\n\t\t};\n\n\t\tif ( objectType( executeNow ) === "function" ) {\n\t\t\tconfig.moduleStack.push( module );\n\t\t\tsetCurrentModule( module );\n\t\t\texecuteNow.call( module.testEnvironment, moduleFns );\n\t\t\tconfig.moduleStack.pop();\n\t\t\tmodule = module.parentModule || currentModule;\n\t\t}\n\n\t\tsetCurrentModule( module );\n\n\t\tfunction createModule() {\n\t\t\tvar parentModule = config.moduleStack.length ?\n\t\t\t\tconfig.moduleStack.slice( -1 )[ 0 ] : null;\n\t\t\tvar moduleName = parentModule !== null ?\n\t\t\t\t[ parentModule.name, name ].join( " > " ) : name;\n\t\t\tvar module = {\n\t\t\t\tname: moduleName,\n\t\t\t\tparentModule: parentModule,\n\t\t\t\ttests: [],\n\t\t\t\tmoduleId: generateHash( moduleName )\n\t\t\t};\n\n\t\t\tvar env = {};\n\t\t\tif ( parentModule ) {\n\t\t\t\textend( env, parentModule.testEnvironment );\n\t\t\t\tdelete env.beforeEach;\n\t\t\t\tdelete env.afterEach;\n\t\t\t}\n\t\t\textend( env, testEnvironment );\n\t\t\tmodule.testEnvironment = env;\n\n\t\t\tconfig.modules.push( module );\n\t\t\treturn module;\n\t\t}\n\n\t\tfunction setCurrentModule( module ) {\n\t\t\tconfig.currentModule = module;\n\t\t}\n\n\t},\n\n\t// DEPRECATED: QUnit.asyncTest() will be removed in QUnit 2.0.\n\tasyncTest: asyncTest,\n\n\ttest: test,\n\n\tskip: skip,\n\n\tonly: only,\n\n\t// DEPRECATED: The functionality of QUnit.start() will be altered in QUnit 2.0.\n\t// In QUnit 2.0, invoking it will ONLY affect the `QUnit.config.autostart` blocking behavior.\n\tstart: function( count ) {\n\t\tvar globalStartAlreadyCalled = globalStartCalled;\n\n\t\tif ( !config.current ) {\n\t\t\tglobalStartCalled = true;\n\n\t\t\tif ( runStarted ) {\n\t\t\t\tthrow new Error( "Called start() outside of a test context while already started" );\n\t\t\t} else if ( globalStartAlreadyCalled || count > 1 ) {\n\t\t\t\tthrow new Error( "Called start() outside of a test context too many times" );\n\t\t\t} else if ( config.autostart ) {\n\t\t\t\tthrow new Error( "Called start() outside of a test context when " +\n\t\t\t\t\t"QUnit.config.autostart was true" );\n\t\t\t} else if ( !config.pageLoaded ) {\n\n\t\t\t\t// The page isn\'t completely loaded yet, so bail out and let `QUnit.load` handle it\n\t\t\t\tconfig.autostart = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\n\t\t\t// If a test is running, adjust its semaphore\n\t\t\tconfig.current.semaphore -= count || 1;\n\n\t\t\t// If semaphore is non-numeric, throw error\n\t\t\tif ( isNaN( config.current.semaphore ) ) {\n\t\t\t\tconfig.current.semaphore = 0;\n\n\t\t\t\tQUnit.pushFailure(\n\t\t\t\t\t"Called start() with a non-numeric decrement.",\n\t\t\t\t\tsourceFromStacktrace( 2 )\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don\'t start until equal number of stop-calls\n\t\t\tif ( config.current.semaphore > 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Throw an Error if start is called more often than stop\n\t\t\tif ( config.current.semaphore < 0 ) {\n\t\t\t\tconfig.current.semaphore = 0;\n\n\t\t\t\tQUnit.pushFailure(\n\t\t\t\t\t"Called start() while already started (test\'s semaphore was 0 already)",\n\t\t\t\t\tsourceFromStacktrace( 2 )\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tresumeProcessing();\n\t},\n\n\t// DEPRECATED: QUnit.stop() will be removed in QUnit 2.0.\n\tstop: function( count ) {\n\n\t\t// If there isn\'t a test running, don\'t allow QUnit.stop() to be called\n\t\tif ( !config.current ) {\n\t\t\tthrow new Error( "Called stop() outside of a test context" );\n\t\t}\n\n\t\t// If a test is running, adjust its semaphore\n\t\tconfig.current.semaphore += count || 1;\n\n\t\tpauseProcessing();\n\t},\n\n\tconfig: config,\n\n\tis: is,\n\n\tobjectType: objectType,\n\n\textend: extend,\n\n\tload: function() {\n\t\tconfig.pageLoaded = true;\n\n\t\t// Initialize the configuration options\n\t\textend( config, {\n\t\t\tstats: { all: 0, bad: 0 },\n\t\t\tmoduleStats: { all: 0, bad: 0 },\n\t\t\tstarted: 0,\n\t\t\tupdateRate: 1000,\n\t\t\tautostart: true,\n\t\t\tfilter: ""\n\t\t}, true );\n\n\t\tconfig.blocking = false;\n\n\t\tif ( config.autostart ) {\n\t\t\tresumeProcessing();\n\t\t}\n\t},\n\n\tstack: function( offset ) {\n\t\toffset = ( offset || 0 ) + 2;\n\t\treturn sourceFromStacktrace( offset );\n\t}\n} );\n\nregisterLoggingCallbacks( QUnit );\n\nfunction begin() {\n\tvar i, l,\n\t\tmodulesLog = [];\n\n\t// If the test run hasn\'t officially begun yet\n\tif ( !config.started ) {\n\n\t\t// Record the time of the test run\'s beginning\n\t\tconfig.started = now();\n\n\t\tverifyLoggingCallbacks();\n\n\t\t// Delete the loose unnamed module if unused.\n\t\tif ( config.modules[ 0 ].name === "" && config.modules[ 0 ].tests.length === 0 ) {\n\t\t\tconfig.modules.shift();\n\t\t}\n\n\t\t// Avoid unnecessary information by not logging modules\' test environments\n\t\tfor ( i = 0, l = config.modules.length; i < l; i++ ) {\n\t\t\tmodulesLog.push( {\n\t\t\t\tname: config.modules[ i ].name,\n\t\t\t\ttests: config.modules[ i ].tests\n\t\t\t} );\n\t\t}\n\n\t\t// The test run is officially beginning now\n\t\trunLoggingCallbacks( "begin", {\n\t\t\ttotalTests: Test.count,\n\t\t\tmodules: modulesLog\n\t\t} );\n\t}\n\n\tconfig.blocking = false;\n\tprocess( true );\n}\n\nfunction process( last ) {\n\tfunction next() {\n\t\tprocess( last );\n\t}\n\tvar start = now();\n\tconfig.depth = ( config.depth || 0 ) + 1;\n\n\twhile ( config.queue.length && !config.blocking ) {\n\t\tif ( !defined.setTimeout || config.updateRate <= 0 ||\n\t\t\t\t( ( now() - start ) < config.updateRate ) ) {\n\t\t\tif ( config.current ) {\n\n\t\t\t\t// Reset async tracking for each phase of the Test lifecycle\n\t\t\t\tconfig.current.usedAsync = false;\n\t\t\t}\n\t\t\tconfig.queue.shift()();\n\t\t} else {\n\t\t\tsetTimeout( next, 13 );\n\t\t\tbreak;\n\t\t}\n\t}\n\tconfig.depth--;\n\tif ( last && !config.blocking && !config.queue.length && config.depth === 0 ) {\n\t\tdone();\n\t}\n}\n\nfunction pauseProcessing() {\n\tconfig.blocking = true;\n\n\tif ( config.testTimeout && defined.setTimeout ) {\n\t\tclearTimeout( config.timeout );\n\t\tconfig.timeout = setTimeout( function() {\n\t\t\tif ( config.current ) {\n\t\t\t\tconfig.current.semaphore = 0;\n\t\t\t\tQUnit.pushFailure( "Test timed out", sourceFromStacktrace( 2 ) );\n\t\t\t} else {\n\t\t\t\tthrow new Error( "Test timed out" );\n\t\t\t}\n\t\t\tresumeProcessing();\n\t\t}, config.testTimeout );\n\t}\n}\n\nfunction resumeProcessing() {\n\trunStarted = true;\n\n\t// A slight delay to allow this iteration of the event loop to finish (more assertions, etc.)\n\tif ( defined.setTimeout ) {\n\t\tsetTimeout( function() {\n\t\t\tif ( config.current && config.current.semaphore > 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( config.timeout ) {\n\t\t\t\tclearTimeout( config.timeout );\n\t\t\t}\n\n\t\t\tbegin();\n\t\t}, 13 );\n\t} else {\n\t\tbegin();\n\t}\n}\n\nfunction done() {\n\tvar runtime, passed;\n\n\tconfig.autorun = true;\n\n\t// Log the last module results\n\tif ( config.previousModule ) {\n\t\trunLoggingCallbacks( "moduleDone", {\n\t\t\tname: config.previousModule.name,\n\t\t\ttests: config.previousModule.tests,\n\t\t\tfailed: config.moduleStats.bad,\n\t\t\tpassed: config.moduleStats.all - config.moduleStats.bad,\n\t\t\ttotal: config.moduleStats.all,\n\t\t\truntime: now() - config.moduleStats.started\n\t\t} );\n\t}\n\tdelete config.previousModule;\n\n\truntime = now() - config.started;\n\tpassed = config.stats.all - config.stats.bad;\n\n\trunLoggingCallbacks( "done", {\n\t\tfailed: config.stats.bad,\n\t\tpassed: passed,\n\t\ttotal: config.stats.all,\n\t\truntime: runtime\n\t} );\n}\n\nfunction setHook( module, hookName ) {\n\tif ( module.testEnvironment === undefined ) {\n\t\tmodule.testEnvironment = {};\n\t}\n\n\treturn function( callback ) {\n\t\tmodule.testEnvironment[ hookName ] = callback;\n\t};\n}\n\nvar focused = false;\nvar priorityCount = 0;\nvar unitSampler;\n\nfunction Test( settings ) {\n\tvar i, l;\n\n\t++Test.count;\n\n\textend( this, settings );\n\tthis.assertions = [];\n\tthis.semaphore = 0;\n\tthis.usedAsync = false;\n\tthis.module = config.currentModule;\n\tthis.stack = sourceFromStacktrace( 3 );\n\n\t// Register unique strings\n\tfor ( i = 0, l = this.module.tests; i < l.length; i++ ) {\n\t\tif ( this.module.tests[ i ].name === this.testName ) {\n\t\t\tthis.testName += " ";\n\t\t}\n\t}\n\n\tthis.testId = generateHash( this.module.name, this.testName );\n\n\tthis.module.tests.push( {\n\t\tname: this.testName,\n\t\ttestId: this.testId\n\t} );\n\n\tif ( settings.skip ) {\n\n\t\t// Skipped tests will fully ignore any sent callback\n\t\tthis.callback = function() {};\n\t\tthis.async = false;\n\t\tthis.expected = 0;\n\t} else {\n\t\tthis.assert = new Assert( this );\n\t}\n}\n\nTest.count = 0;\n\nTest.prototype = {\n\tbefore: function() {\n\t\tif (\n\n\t\t\t// Emit moduleStart when we\'re switching from one module to another\n\t\t\tthis.module !== config.previousModule ||\n\n\t\t\t\t// They could be equal (both undefined) but if the previousModule property doesn\'t\n\t\t\t\t// yet exist it means this is the first test in a suite that isn\'t wrapped in a\n\t\t\t\t// module, in which case we\'ll just emit a moduleStart event for \'undefined\'.\n\t\t\t\t// Without this, reporters can get testStart before moduleStart which is a problem.\n\t\t\t\t!hasOwn.call( config, "previousModule" )\n\t\t) {\n\t\t\tif ( hasOwn.call( config, "previousModule" ) ) {\n\t\t\t\trunLoggingCallbacks( "moduleDone", {\n\t\t\t\t\tname: config.previousModule.name,\n\t\t\t\t\ttests: config.previousModule.tests,\n\t\t\t\t\tfailed: config.moduleStats.bad,\n\t\t\t\t\tpassed: config.moduleStats.all - config.moduleStats.bad,\n\t\t\t\t\ttotal: config.moduleStats.all,\n\t\t\t\t\truntime: now() - config.moduleStats.started\n\t\t\t\t} );\n\t\t\t}\n\t\t\tconfig.previousModule = this.module;\n\t\t\tconfig.moduleStats = { all: 0, bad: 0, started: now() };\n\t\t\trunLoggingCallbacks( "moduleStart", {\n\t\t\t\tname: this.module.name,\n\t\t\t\ttests: this.module.tests\n\t\t\t} );\n\t\t}\n\n\t\tconfig.current = this;\n\n\t\tif ( this.module.testEnvironment ) {\n\t\t\tdelete this.module.testEnvironment.beforeEach;\n\t\t\tdelete this.module.testEnvironment.afterEach;\n\t\t}\n\t\tthis.testEnvironment = extend( {}, this.module.testEnvironment );\n\n\t\tthis.started = now();\n\t\trunLoggingCallbacks( "testStart", {\n\t\t\tname: this.testName,\n\t\t\tmodule: this.module.name,\n\t\t\ttestId: this.testId\n\t\t} );\n\n\t\tif ( !config.pollution ) {\n\t\t\tsaveGlobal();\n\t\t}\n\t},\n\n\trun: function() {\n\t\tvar promise;\n\n\t\tconfig.current = this;\n\n\t\tif ( this.async ) {\n\t\t\tQUnit.stop();\n\t\t}\n\n\t\tthis.callbackStarted = now();\n\n\t\tif ( config.notrycatch ) {\n\t\t\trunTest( this );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\trunTest( this );\n\t\t} catch ( e ) {\n\t\t\tthis.pushFailure( "Died on test #" + ( this.assertions.length + 1 ) + " " +\n\t\t\t\tthis.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );\n\n\t\t\t// Else next test will carry the responsibility\n\t\t\tsaveGlobal();\n\n\t\t\t// Restart the tests if they\'re blocking\n\t\t\tif ( config.blocking ) {\n\t\t\t\tQUnit.start();\n\t\t\t}\n\t\t}\n\n\t\tfunction runTest( test ) {\n\t\t\tpromise = test.callback.call( test.testEnvironment, test.assert );\n\t\t\ttest.resolvePromise( promise );\n\t\t}\n\t},\n\n\tafter: function() {\n\t\tcheckPollution();\n\t},\n\n\tqueueHook: function( hook, hookName ) {\n\t\tvar promise,\n\t\t\ttest = this;\n\t\treturn function runHook() {\n\t\t\tconfig.current = test;\n\t\t\tif ( config.notrycatch ) {\n\t\t\t\tcallHook();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tcallHook();\n\t\t\t} catch ( error ) {\n\t\t\t\ttest.pushFailure( hookName + " failed on " + test.testName + ": " +\n\t\t\t\t( error.message || error ), extractStacktrace( error, 0 ) );\n\t\t\t}\n\n\t\t\tfunction callHook() {\n\t\t\t\tpromise = hook.call( test.testEnvironment, test.assert );\n\t\t\t\ttest.resolvePromise( promise, hookName );\n\t\t\t}\n\t\t};\n\t},\n\n\t// Currently only used for module level hooks, can be used to add global level ones\n\thooks: function( handler ) {\n\t\tvar hooks = [];\n\n\t\tfunction processHooks( test, module ) {\n\t\t\tif ( module.parentModule ) {\n\t\t\t\tprocessHooks( test, module.parentModule );\n\t\t\t}\n\t\t\tif ( module.testEnvironment &&\n\t\t\t\tQUnit.objectType( module.testEnvironment[ handler ] ) === "function" ) {\n\t\t\t\thooks.push( test.queueHook( module.testEnvironment[ handler ], handler ) );\n\t\t\t}\n\t\t}\n\n\t\t// Hooks are ignored on skipped tests\n\t\tif ( !this.skip ) {\n\t\t\tprocessHooks( this, this.module );\n\t\t}\n\t\treturn hooks;\n\t},\n\n\tfinish: function() {\n\t\tconfig.current = this;\n\t\tif ( config.requireExpects && this.expected === null ) {\n\t\t\tthis.pushFailure( "Expected number of assertions to be defined, but expect() was " +\n\t\t\t\t"not called.", this.stack );\n\t\t} else if ( this.expected !== null && this.expected !== this.assertions.length ) {\n\t\t\tthis.pushFailure( "Expected " + this.expected + " assertions, but " +\n\t\t\t\tthis.assertions.length + " were run", this.stack );\n\t\t} else if ( this.expected === null && !this.assertions.length ) {\n\t\t\tthis.pushFailure( "Expected at least one assertion, but none were run - call " +\n\t\t\t\t"expect(0) to accept zero assertions.", this.stack );\n\t\t}\n\n\t\tvar i,\n\t\t\tbad = 0;\n\n\t\tthis.runtime = now() - this.started;\n\t\tconfig.stats.all += this.assertions.length;\n\t\tconfig.moduleStats.all += this.assertions.length;\n\n\t\tfor ( i = 0; i < this.assertions.length; i++ ) {\n\t\t\tif ( !this.assertions[ i ].result ) {\n\t\t\t\tbad++;\n\t\t\t\tconfig.stats.bad++;\n\t\t\t\tconfig.moduleStats.bad++;\n\t\t\t}\n\t\t}\n\n\t\trunLoggingCallbacks( "testDone", {\n\t\t\tname: this.testName,\n\t\t\tmodule: this.module.name,\n\t\t\tskipped: !!this.skip,\n\t\t\tfailed: bad,\n\t\t\tpassed: this.assertions.length - bad,\n\t\t\ttotal: this.assertions.length,\n\t\t\truntime: this.runtime,\n\n\t\t\t// HTML Reporter use\n\t\t\tassertions: this.assertions,\n\t\t\ttestId: this.testId,\n\n\t\t\t// Source of Test\n\t\t\tsource: this.stack,\n\n\t\t\t// DEPRECATED: this property will be removed in 2.0.0, use runtime instead\n\t\t\tduration: this.runtime\n\t\t} );\n\n\t\t// QUnit.reset() is deprecated and will be replaced for a new\n\t\t// fixture reset function on QUnit 2.0/2.1.\n\t\t// It\'s still called here for backwards compatibility handling\n\t\tQUnit.reset();\n\n\t\tconfig.current = undefined;\n\t},\n\n\tqueue: function() {\n\t\tvar priority,\n\t\t\ttest = this;\n\n\t\tif ( !this.valid() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction run() {\n\n\t\t\t// Each of these can by async\n\t\t\tsynchronize( [\n\t\t\t\tfunction() {\n\t\t\t\t\ttest.before();\n\t\t\t\t},\n\n\t\t\t\ttest.hooks( "beforeEach" ),\n\t\t\t\tfunction() {\n\t\t\t\t\ttest.run();\n\t\t\t\t},\n\n\t\t\t\ttest.hooks( "afterEach" ).reverse(),\n\n\t\t\t\tfunction() {\n\t\t\t\t\ttest.after();\n\t\t\t\t},\n\t\t\t\tfunction() {\n\t\t\t\t\ttest.finish();\n\t\t\t\t}\n\t\t\t] );\n\t\t}\n\n\t\t// Prioritize previously failed tests, detected from sessionStorage\n\t\tpriority = QUnit.config.reorder && defined.sessionStorage &&\n\t\t\t\t+sessionStorage.getItem( "qunit-test-" + this.module.name + "-" + this.testName );\n\n\t\treturn synchronize( run, priority, config.seed );\n\t},\n\n\tpushResult: function( resultInfo ) {\n\n\t\t// Destructure of resultInfo = { result, actual, expected, message, negative }\n\t\tvar source,\n\t\t\tdetails = {\n\t\t\t\tmodule: this.module.name,\n\t\t\t\tname: this.testName,\n\t\t\t\tresult: resultInfo.result,\n\t\t\t\tmessage: resultInfo.message,\n\t\t\t\tactual: resultInfo.actual,\n\t\t\t\texpected: resultInfo.expected,\n\t\t\t\ttestId: this.testId,\n\t\t\t\tnegative: resultInfo.negative || false,\n\t\t\t\truntime: now() - this.started\n\t\t\t};\n\n\t\tif ( !resultInfo.result ) {\n\t\t\tsource = sourceFromStacktrace();\n\n\t\t\tif ( source ) {\n\t\t\t\tdetails.source = source;\n\t\t\t}\n\t\t}\n\n\t\trunLoggingCallbacks( "log", details );\n\n\t\tthis.assertions.push( {\n\t\t\tresult: !!resultInfo.result,\n\t\t\tmessage: resultInfo.message\n\t\t} );\n\t},\n\n\tpushFailure: function( message, source, actual ) {\n\t\tif ( !( this instanceof Test ) ) {\n\t\t\tthrow new Error( "pushFailure() assertion outside test context, was " +\n\t\t\t\tsourceFromStacktrace( 2 ) );\n\t\t}\n\n\t\tvar details = {\n\t\t\t\tmodule: this.module.name,\n\t\t\t\tname: this.testName,\n\t\t\t\tresult: false,\n\t\t\t\tmessage: message || "error",\n\t\t\t\tactual: actual || null,\n\t\t\t\ttestId: this.testId,\n\t\t\t\truntime: now() - this.started\n\t\t\t};\n\n\t\tif ( source ) {\n\t\t\tdetails.source = source;\n\t\t}\n\n\t\trunLoggingCallbacks( "log", details );\n\n\t\tthis.assertions.push( {\n\t\t\tresult: false,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tresolvePromise: function( promise, phase ) {\n\t\tvar then, message,\n\t\t\ttest = this;\n\t\tif ( promise != null ) {\n\t\t\tthen = promise.then;\n\t\t\tif ( QUnit.objectType( then ) === "function" ) {\n\t\t\t\tQUnit.stop();\n\t\t\t\tthen.call(\n\t\t\t\t\tpromise,\n\t\t\t\t\tfunction() { QUnit.start(); },\n\t\t\t\t\tfunction( error ) {\n\t\t\t\t\t\tmessage = "Promise rejected " +\n\t\t\t\t\t\t\t( !phase ? "during" : phase.replace( /Each$/, "" ) ) +\n\t\t\t\t\t\t\t" " + test.testName + ": " + ( error.message || error );\n\t\t\t\t\t\ttest.pushFailure( message, extractStacktrace( error, 0 ) );\n\n\t\t\t\t\t\t// Else next test will carry the responsibility\n\t\t\t\t\t\tsaveGlobal();\n\n\t\t\t\t\t\t// Unblock\n\t\t\t\t\t\tQUnit.start();\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t},\n\n\tvalid: function() {\n\t\tvar filter = config.filter,\n\t\t\tregexFilter = /^(!?)\\/([\\w\\W]*)\\/(i?$)/.exec( filter ),\n\t\t\tmodule = config.module && config.module.toLowerCase(),\n\t\t\tfullName = ( this.module.name + ": " + this.testName );\n\n\t\tfunction moduleChainNameMatch( testModule ) {\n\t\t\tvar testModuleName = testModule.name ? testModule.name.toLowerCase() : null;\n\t\t\tif ( testModuleName === module ) {\n\t\t\t\treturn true;\n\t\t\t} else if ( testModule.parentModule ) {\n\t\t\t\treturn moduleChainNameMatch( testModule.parentModule );\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfunction moduleChainIdMatch( testModule ) {\n\t\t\treturn inArray( testModule.moduleId, config.moduleId ) > -1 ||\n\t\t\t\ttestModule.parentModule && moduleChainIdMatch( testModule.parentModule );\n\t\t}\n\n\t\t// Internally-generated tests are always valid\n\t\tif ( this.callback && this.callback.validTest ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( config.moduleId && config.moduleId.length > 0 &&\n\t\t\t!moduleChainIdMatch( this.module ) ) {\n\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( config.testId && config.testId.length > 0 &&\n\t\t\tinArray( this.testId, config.testId ) < 0 ) {\n\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( module && !moduleChainNameMatch( this.module ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( !filter ) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn regexFilter ?\n\t\t\tthis.regexFilter( !!regexFilter[ 1 ], regexFilter[ 2 ], regexFilter[ 3 ], fullName ) :\n\t\t\tthis.stringFilter( filter, fullName );\n\t},\n\n\tregexFilter: function( exclude, pattern, flags, fullName ) {\n\t\tvar regex = new RegExp( pattern, flags );\n\t\tvar match = regex.test( fullName );\n\n\t\treturn match !== exclude;\n\t},\n\n\tstringFilter: function( filter, fullName ) {\n\t\tfilter = filter.toLowerCase();\n\t\tfullName = fullName.toLowerCase();\n\n\t\tvar include = filter.charAt( 0 ) !== "!";\n\t\tif ( !include ) {\n\t\t\tfilter = filter.slice( 1 );\n\t\t}\n\n\t\t// If the filter matches, we need to honour include\n\t\tif ( fullName.indexOf( filter ) !== -1 ) {\n\t\t\treturn include;\n\t\t}\n\n\t\t// Otherwise, do the opposite\n\t\treturn !include;\n\t}\n};\n\n// Resets the test setup. Useful for tests that modify the DOM.\n/*\nDEPRECATED: Use multiple tests instead of resetting inside a test.\nUse testStart or testDone for custom cleanup.\nThis method will throw an error in 2.0, and will be removed in 2.1\n*/\nQUnit.reset = function() {\n\n\t// Return on non-browser environments\n\t// This is necessary to not break on node tests\n\tif ( !defined.document ) {\n\t\treturn;\n\t}\n\n\tvar fixture = defined.document && document.getElementById &&\n\t\t\tdocument.getElementById( "qunit-fixture" );\n\n\tif ( fixture ) {\n\t\tfixture.innerHTML = config.fixture;\n\t}\n};\n\nQUnit.pushFailure = function() {\n\tif ( !QUnit.config.current ) {\n\t\tthrow new Error( "pushFailure() assertion outside test context, in " +\n\t\t\tsourceFromStacktrace( 2 ) );\n\t}\n\n\t// Gets current test obj\n\tvar currentTest = QUnit.config.current;\n\n\treturn currentTest.pushFailure.apply( currentTest, arguments );\n};\n\n// Based on Java\'s String.hashCode, a simple but not\n// rigorously collision resistant hashing function\nfunction generateHash( module, testName ) {\n\tvar hex,\n\t\ti = 0,\n\t\thash = 0,\n\t\tstr = module + "\\x1C" + testName,\n\t\tlen = str.length;\n\n\tfor ( ; i < len; i++ ) {\n\t\thash = ( ( hash << 5 ) - hash ) + str.charCodeAt( i );\n\t\thash |= 0;\n\t}\n\n\t// Convert the possibly negative integer hash code into an 8 character hex string, which isn\'t\n\t// strictly necessary but increases user understanding that the id is a SHA-like hash\n\thex = ( 0x100000000 + hash ).toString( 16 );\n\tif ( hex.length < 8 ) {\n\t\thex = "0000000" + hex;\n\t}\n\n\treturn hex.slice( -8 );\n}\n\nfunction synchronize( callback, priority, seed ) {\n\tvar last = !priority,\n\t\tindex;\n\n\tif ( QUnit.objectType( callback ) === "array" ) {\n\t\twhile ( callback.length ) {\n\t\t\tsynchronize( callback.shift() );\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( priority ) {\n\t\tconfig.queue.splice( priorityCount++, 0, callback );\n\t} else if ( seed ) {\n\t\tif ( !unitSampler ) {\n\t\t\tunitSampler = unitSamplerGenerator( seed );\n\t\t}\n\n\t\t// Insert into a random position after all priority items\n\t\tindex = Math.floor( unitSampler() * ( config.queue.length - priorityCount + 1 ) );\n\t\tconfig.queue.splice( priorityCount + index, 0, callback );\n\t} else {\n\t\tconfig.queue.push( callback );\n\t}\n\n\tif ( config.autorun && !config.blocking ) {\n\t\tprocess( last );\n\t}\n}\n\nfunction unitSamplerGenerator( seed ) {\n\n\t// 32-bit xorshift, requires only a nonzero seed\n\t// http://excamera.com/sphinx/article-xorshift.html\n\tvar sample = parseInt( generateHash( seed ), 16 ) || -1;\n\treturn function() {\n\t\tsample ^= sample << 13;\n\t\tsample ^= sample >>> 17;\n\t\tsample ^= sample << 5;\n\n\t\t// ECMAScript has no unsigned number type\n\t\tif ( sample < 0 ) {\n\t\t\tsample += 0x100000000;\n\t\t}\n\n\t\treturn sample / 0x100000000;\n\t};\n}\n\nfunction saveGlobal() {\n\tconfig.pollution = [];\n\n\tif ( config.noglobals ) {\n\t\tfor ( var key in global ) {\n\t\t\tif ( hasOwn.call( global, key ) ) {\n\n\t\t\t\t// In Opera sometimes DOM element ids show up here, ignore them\n\t\t\t\tif ( /^qunit-test-output/.test( key ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconfig.pollution.push( key );\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkPollution() {\n\tvar newGlobals,\n\t\tdeletedGlobals,\n\t\told = config.pollution;\n\n\tsaveGlobal();\n\n\tnewGlobals = diff( config.pollution, old );\n\tif ( newGlobals.length > 0 ) {\n\t\tQUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join( ", " ) );\n\t}\n\n\tdeletedGlobals = diff( old, config.pollution );\n\tif ( deletedGlobals.length > 0 ) {\n\t\tQUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join( ", " ) );\n\t}\n}\n\n// Will be exposed as QUnit.asyncTest\nfunction asyncTest( testName, expected, callback ) {\n\tif ( arguments.length === 2 ) {\n\t\tcallback = expected;\n\t\texpected = null;\n\t}\n\n\tQUnit.test( testName, expected, callback, true );\n}\n\n// Will be exposed as QUnit.test\nfunction test( testName, expected, callback, async ) {\n\tif ( focused ) { return; }\n\n\tvar newTest;\n\n\tif ( arguments.length === 2 ) {\n\t\tcallback = expected;\n\t\texpected = null;\n\t}\n\n\tnewTest = new Test( {\n\t\ttestName: testName,\n\t\texpected: expected,\n\t\tasync: async,\n\t\tcallback: callback\n\t} );\n\n\tnewTest.queue();\n}\n\n// Will be exposed as QUnit.skip\nfunction skip( testName ) {\n\tif ( focused ) { return; }\n\n\tvar test = new Test( {\n\t\ttestName: testName,\n\t\tskip: true\n\t} );\n\n\ttest.queue();\n}\n\n// Will be exposed as QUnit.only\nfunction only( testName, expected, callback, async ) {\n\tvar newTest;\n\n\tif ( focused ) { return; }\n\n\tQUnit.config.queue.length = 0;\n\tfocused = true;\n\n\tif ( arguments.length === 2 ) {\n\t\tcallback = expected;\n\t\texpected = null;\n\t}\n\n\tnewTest = new Test( {\n\t\ttestName: testName,\n\t\texpected: expected,\n\t\tasync: async,\n\t\tcallback: callback\n\t} );\n\n\tnewTest.queue();\n}\n\nfunction Assert( testContext ) {\n\tthis.test = testContext;\n}\n\n// Assert helpers\nQUnit.assert = Assert.prototype = {\n\n\t// Specify the number of expected assertions to guarantee that failed test\n\t// (no assertions are run at all) don\'t slip through.\n\texpect: function( asserts ) {\n\t\tif ( arguments.length === 1 ) {\n\t\t\tthis.test.expected = asserts;\n\t\t} else {\n\t\t\treturn this.test.expected;\n\t\t}\n\t},\n\n\t// Increment this Test\'s semaphore counter, then return a function that\n\t// decrements that counter a maximum of once.\n\tasync: function( count ) {\n\t\tvar test = this.test,\n\t\t\tpopped = false,\n\t\t\tacceptCallCount = count;\n\n\t\tif ( typeof acceptCallCount === "undefined" ) {\n\t\t\tacceptCallCount = 1;\n\t\t}\n\n\t\ttest.semaphore += 1;\n\t\ttest.usedAsync = true;\n\t\tpauseProcessing();\n\n\t\treturn function done() {\n\n\t\t\tif ( popped ) {\n\t\t\t\ttest.pushFailure( "Too many calls to the `assert.async` callback",\n\t\t\t\t\tsourceFromStacktrace( 2 ) );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tacceptCallCount -= 1;\n\t\t\tif ( acceptCallCount > 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttest.semaphore -= 1;\n\t\t\tpopped = true;\n\t\t\tresumeProcessing();\n\t\t};\n\t},\n\n\t// Exports test.push() to the user API\n\t// Alias of pushResult.\n\tpush: function( result, actual, expected, message, negative ) {\n\t\tvar currentAssert = this instanceof Assert ? this : QUnit.config.current.assert;\n\t\treturn currentAssert.pushResult( {\n\t\t\tresult: result,\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message,\n\t\t\tnegative: negative\n\t\t} );\n\t},\n\n\tpushResult: function( resultInfo ) {\n\n\t\t// Destructure of resultInfo = { result, actual, expected, message, negative }\n\t\tvar assert = this,\n\t\t\tcurrentTest = ( assert instanceof Assert && assert.test ) || QUnit.config.current;\n\n\t\t// Backwards compatibility fix.\n\t\t// Allows the direct use of global exported assertions and QUnit.assert.*\n\t\t// Although, it\'s use is not recommended as it can leak assertions\n\t\t// to other tests from async tests, because we only get a reference to the current test,\n\t\t// not exactly the test where assertion were intended to be called.\n\t\tif ( !currentTest ) {\n\t\t\tthrow new Error( "assertion outside test context, in " + sourceFromStacktrace( 2 ) );\n\t\t}\n\n\t\tif ( currentTest.usedAsync === true && currentTest.semaphore === 0 ) {\n\t\t\tcurrentTest.pushFailure( "Assertion after the final `assert.async` was resolved",\n\t\t\t\tsourceFromStacktrace( 2 ) );\n\n\t\t\t// Allow this assertion to continue running anyway...\n\t\t}\n\n\t\tif ( !( assert instanceof Assert ) ) {\n\t\t\tassert = currentTest.assert;\n\t\t}\n\n\t\treturn assert.test.pushResult( resultInfo );\n\t},\n\n\tok: function( result, message ) {\n\t\tmessage = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " +\n\t\t\tQUnit.dump.parse( result ) );\n\t\tthis.pushResult( {\n\t\t\tresult: !!result,\n\t\t\tactual: result,\n\t\t\texpected: true,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tnotOk: function( result, message ) {\n\t\tmessage = message || ( !result ? "okay" : "failed, expected argument to be falsy, was: " +\n\t\t\tQUnit.dump.parse( result ) );\n\t\tthis.pushResult( {\n\t\t\tresult: !result,\n\t\t\tactual: result,\n\t\t\texpected: false,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tequal: function( actual, expected, message ) {\n\t\t/*jshint eqeqeq:false */\n\t\tthis.pushResult( {\n\t\t\tresult: expected == actual,\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tnotEqual: function( actual, expected, message ) {\n\t\t/*jshint eqeqeq:false */\n\t\tthis.pushResult( {\n\t\t\tresult: expected != actual,\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message,\n\t\t\tnegative: true\n\t\t} );\n\t},\n\n\tpropEqual: function( actual, expected, message ) {\n\t\tactual = objectValues( actual );\n\t\texpected = objectValues( expected );\n\t\tthis.pushResult( {\n\t\t\tresult: QUnit.equiv( actual, expected ),\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tnotPropEqual: function( actual, expected, message ) {\n\t\tactual = objectValues( actual );\n\t\texpected = objectValues( expected );\n\t\tthis.pushResult( {\n\t\t\tresult: !QUnit.equiv( actual, expected ),\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message,\n\t\t\tnegative: true\n\t\t} );\n\t},\n\n\tdeepEqual: function( actual, expected, message ) {\n\t\tthis.pushResult( {\n\t\t\tresult: QUnit.equiv( actual, expected ),\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tnotDeepEqual: function( actual, expected, message ) {\n\t\tthis.pushResult( {\n\t\t\tresult: !QUnit.equiv( actual, expected ),\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message,\n\t\t\tnegative: true\n\t\t} );\n\t},\n\n\tstrictEqual: function( actual, expected, message ) {\n\t\tthis.pushResult( {\n\t\t\tresult: expected === actual,\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message\n\t\t} );\n\t},\n\n\tnotStrictEqual: function( actual, expected, message ) {\n\t\tthis.pushResult( {\n\t\t\tresult: expected !== actual,\n\t\t\tactual: actual,\n\t\t\texpected: expected,\n\t\t\tmessage: message,\n\t\t\tnegative: true\n\t\t} );\n\t},\n\n\t"throws": function( block, expected, message ) {\n\t\tvar actual, expectedType,\n\t\t\texpectedOutput = expected,\n\t\t\tok = false,\n\t\t\tcurrentTest = ( this instanceof Assert && this.test ) || QUnit.config.current;\n\n\t\t// \'expected\' is optional unless doing string comparison\n\t\tif ( message == null && typeof expected === "string" ) {\n\t\t\tmessage = expected;\n\t\t\texpected = null;\n\t\t}\n\n\t\tcurrentTest.ignoreGlobalErrors = true;\n\t\ttry {\n\t\t\tblock.call( currentTest.testEnvironment );\n\t\t} catch ( e ) {\n\t\t\tactual = e;\n\t\t}\n\t\tcurrentTest.ignoreGlobalErrors = false;\n\n\t\tif ( actual ) {\n\t\t\texpectedType = QUnit.objectType( expected );\n\n\t\t\t// We don\'t want to validate thrown error\n\t\t\tif ( !expected ) {\n\t\t\t\tok = true;\n\t\t\t\texpectedOutput = null;\n\n\t\t\t// Expected is a regexp\n\t\t\t} else if ( expectedType === "regexp" ) {\n\t\t\t\tok = expected.test( errorString( actual ) );\n\n\t\t\t// Expected is a string\n\t\t\t} else if ( expectedType === "string" ) {\n\t\t\t\tok = expected === errorString( actual );\n\n\t\t\t// Expected is a constructor, maybe an Error constructor\n\t\t\t} else if ( expectedType === "function" && actual instanceof expected ) {\n\t\t\t\tok = true;\n\n\t\t\t// Expected is an Error object\n\t\t\t} else if ( expectedType === "object" ) {\n\t\t\t\tok = actual instanceof expected.constructor &&\n\t\t\t\t\tactual.name === expected.name &&\n\t\t\t\t\tactual.message === expected.message;\n\n\t\t\t// Expected is a validation function which returns true if validation passed\n\t\t\t} else if ( expectedType === "function" && expected.call( {}, actual ) === true ) {\n\t\t\t\texpectedOutput = null;\n\t\t\t\tok = true;\n\t\t\t}\n\t\t}\n\n\t\tcurrentTest.assert.pushResult( {\n\t\t\tresult: ok,\n\t\t\tactual: actual,\n\t\t\texpected: expectedOutput,\n\t\t\tmessage: message\n\t\t} );\n\t}\n};\n\n// Provide an alternative to assert.throws(), for environments that consider throws a reserved word\n// Known to us are: Closure Compiler, Narwhal\n( function() {\n\t/*jshint sub:true */\n\tAssert.prototype.raises = Assert.prototype [ "throws" ]; //jscs:ignore requireDotNotation\n}() );\n\nfunction errorString( error ) {\n\tvar name, message,\n\t\tresultErrorString = error.toString();\n\tif ( resultErrorString.substring( 0, 7 ) === "[object" ) {\n\t\tname = error.name ? error.name.toString() : "Error";\n\t\tmessage = error.message ? error.message.toString() : "";\n\t\tif ( name && message ) {\n\t\t\treturn name + ": " + message;\n\t\t} else if ( name ) {\n\t\t\treturn name;\n\t\t} else if ( message ) {\n\t\t\treturn message;\n\t\t} else {\n\t\t\treturn "Error";\n\t\t}\n\t} else {\n\t\treturn resultErrorString;\n\t}\n}\n\n// Test for equality any JavaScript type.\n// Author: Philippe Rathé \nQUnit.equiv = ( function() {\n\n\t// Stack to decide between skip/abort functions\n\tvar callers = [];\n\n\t// Stack to avoiding loops from circular referencing\n\tvar parents = [];\n\tvar parentsB = [];\n\n\tvar getProto = Object.getPrototypeOf || function( obj ) {\n\n\t\t/*jshint proto: true */\n\t\treturn obj.__proto__;\n\t};\n\n\tfunction useStrictEquality( b, a ) {\n\n\t\t// To catch short annotation VS \'new\' annotation of a declaration. e.g.:\n\t\t// `var i = 1;`\n\t\t// `var j = new Number(1);`\n\t\tif ( typeof a === "object" ) {\n\t\t\ta = a.valueOf();\n\t\t}\n\t\tif ( typeof b === "object" ) {\n\t\t\tb = b.valueOf();\n\t\t}\n\n\t\treturn a === b;\n\t}\n\n\tfunction compareConstructors( a, b ) {\n\t\tvar protoA = getProto( a );\n\t\tvar protoB = getProto( b );\n\n\t\t// Comparing constructors is more strict than using `instanceof`\n\t\tif ( a.constructor === b.constructor ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ref #851\n\t\t// If the obj prototype descends from a null constructor, treat it\n\t\t// as a null prototype.\n\t\tif ( protoA && protoA.constructor === null ) {\n\t\t\tprotoA = null;\n\t\t}\n\t\tif ( protoB && protoB.constructor === null ) {\n\t\t\tprotoB = null;\n\t\t}\n\n\t\t// Allow objects with no prototype to be equivalent to\n\t\t// objects with Object as their constructor.\n\t\tif ( ( protoA === null && protoB === Object.prototype ) ||\n\t\t\t\t( protoB === null && protoA === Object.prototype ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tfunction getRegExpFlags( regexp ) {\n\t\treturn "flags" in regexp ? regexp.flags : regexp.toString().match( /[gimuy]*$/ )[ 0 ];\n\t}\n\n\tvar callbacks = {\n\t\t"string": useStrictEquality,\n\t\t"boolean": useStrictEquality,\n\t\t"number": useStrictEquality,\n\t\t"null": useStrictEquality,\n\t\t"undefined": useStrictEquality,\n\t\t"symbol": useStrictEquality,\n\t\t"date": useStrictEquality,\n\n\t\t"nan": function() {\n\t\t\treturn true;\n\t\t},\n\n\t\t"regexp": function( b, a ) {\n\t\t\treturn a.source === b.source &&\n\n\t\t\t\t// Include flags in the comparison\n\t\t\t\tgetRegExpFlags( a ) === getRegExpFlags( b );\n\t\t},\n\n\t\t// - skip when the property is a method of an instance (OOP)\n\t\t// - abort otherwise,\n\t\t// initial === would have catch identical references anyway\n\t\t"function": function() {\n\t\t\tvar caller = callers[ callers.length - 1 ];\n\t\t\treturn caller !== Object && typeof caller !== "undefined";\n\t\t},\n\n\t\t"array": function( b, a ) {\n\t\t\tvar i, j, len, loop, aCircular, bCircular;\n\n\t\t\tlen = a.length;\n\t\t\tif ( len !== b.length ) {\n\n\t\t\t\t// Safe and faster\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Track reference to avoid circular references\n\t\t\tparents.push( a );\n\t\t\tparentsB.push( b );\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tloop = false;\n\t\t\t\tfor ( j = 0; j < parents.length; j++ ) {\n\t\t\t\t\taCircular = parents[ j ] === a[ i ];\n\t\t\t\t\tbCircular = parentsB[ j ] === b[ i ];\n\t\t\t\t\tif ( aCircular || bCircular ) {\n\t\t\t\t\t\tif ( a[ i ] === b[ i ] || aCircular && bCircular ) {\n\t\t\t\t\t\t\tloop = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tparents.pop();\n\t\t\t\t\t\t\tparentsB.pop();\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( !loop && !innerEquiv( a[ i ], b[ i ] ) ) {\n\t\t\t\t\tparents.pop();\n\t\t\t\t\tparentsB.pop();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tparents.pop();\n\t\t\tparentsB.pop();\n\t\t\treturn true;\n\t\t},\n\n\t\t"set": function( b, a ) {\n\t\t\tvar innerEq,\n\t\t\t\touterEq = true;\n\n\t\t\tif ( a.size !== b.size ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\ta.forEach( function( aVal ) {\n\t\t\t\tinnerEq = false;\n\n\t\t\t\tb.forEach( function( bVal ) {\n\t\t\t\t\tif ( innerEquiv( bVal, aVal ) ) {\n\t\t\t\t\t\tinnerEq = true;\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tif ( !innerEq ) {\n\t\t\t\t\touterEq = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn outerEq;\n\t\t},\n\n\t\t"map": function( b, a ) {\n\t\t\tvar innerEq,\n\t\t\t\touterEq = true;\n\n\t\t\tif ( a.size !== b.size ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\ta.forEach( function( aVal, aKey ) {\n\t\t\t\tinnerEq = false;\n\n\t\t\t\tb.forEach( function( bVal, bKey ) {\n\t\t\t\t\tif ( innerEquiv( [ bVal, bKey ], [ aVal, aKey ] ) ) {\n\t\t\t\t\t\tinnerEq = true;\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tif ( !innerEq ) {\n\t\t\t\t\touterEq = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn outerEq;\n\t\t},\n\n\t\t"object": function( b, a ) {\n\t\t\tvar i, j, loop, aCircular, bCircular;\n\n\t\t\t// Default to true\n\t\t\tvar eq = true;\n\t\t\tvar aProperties = [];\n\t\t\tvar bProperties = [];\n\n\t\t\tif ( compareConstructors( a, b ) === false ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Stack constructor before traversing properties\n\t\t\tcallers.push( a.constructor );\n\n\t\t\t// Track reference to avoid circular references\n\t\t\tparents.push( a );\n\t\t\tparentsB.push( b );\n\n\t\t\t// Be strict: don\'t ensure hasOwnProperty and go deep\n\t\t\tfor ( i in a ) {\n\t\t\t\tloop = false;\n\t\t\t\tfor ( j = 0; j < parents.length; j++ ) {\n\t\t\t\t\taCircular = parents[ j ] === a[ i ];\n\t\t\t\t\tbCircular = parentsB[ j ] === b[ i ];\n\t\t\t\t\tif ( aCircular || bCircular ) {\n\t\t\t\t\t\tif ( a[ i ] === b[ i ] || aCircular && bCircular ) {\n\t\t\t\t\t\t\tloop = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\teq = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taProperties.push( i );\n\t\t\t\tif ( !loop && !innerEquiv( a[ i ], b[ i ] ) ) {\n\t\t\t\t\teq = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tparents.pop();\n\t\t\tparentsB.pop();\n\n\t\t\t// Unstack, we are done\n\t\t\tcallers.pop();\n\n\t\t\tfor ( i in b ) {\n\n\t\t\t\t// Collect b\'s properties\n\t\t\t\tbProperties.push( i );\n\t\t\t}\n\n\t\t\t// Ensures identical properties name\n\t\t\treturn eq && innerEquiv( aProperties.sort(), bProperties.sort() );\n\t\t}\n\t};\n\n\tfunction typeEquiv( a, b ) {\n\t\tvar type = QUnit.objectType( a );\n\t\treturn QUnit.objectType( b ) === type && callbacks[ type ]( b, a );\n\t}\n\n\t// The real equiv function\n\tfunction innerEquiv( a, b ) {\n\n\t\t// We\'re done when there\'s nothing more to compare\n\t\tif ( arguments.length < 2 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Require type-specific equality\n\t\treturn ( a === b || typeEquiv( a, b ) ) &&\n\n\t\t\t// ...across all consecutive argument pairs\n\t\t\t( arguments.length === 2 || innerEquiv.apply( this, [].slice.call( arguments, 1 ) ) );\n\t}\n\n\treturn innerEquiv;\n}() );\n\n// Based on jsDump by Ariel Flesler\n// http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html\nQUnit.dump = ( function() {\n\tfunction quote( str ) {\n\t\treturn "\\"" + str.toString().replace( /\\\\/g, "\\\\\\\\" ).replace( /"/g, "\\\\\\"" ) + "\\"";\n\t}\n\tfunction literal( o ) {\n\t\treturn o + "";\n\t}\n\tfunction join( pre, arr, post ) {\n\t\tvar s = dump.separator(),\n\t\t\tbase = dump.indent(),\n\t\t\tinner = dump.indent( 1 );\n\t\tif ( arr.join ) {\n\t\t\tarr = arr.join( "," + s + inner );\n\t\t}\n\t\tif ( !arr ) {\n\t\t\treturn pre + post;\n\t\t}\n\t\treturn [ pre, inner + arr, base + post ].join( s );\n\t}\n\tfunction array( arr, stack ) {\n\t\tvar i = arr.length,\n\t\t\tret = new Array( i );\n\n\t\tif ( dump.maxDepth && dump.depth > dump.maxDepth ) {\n\t\t\treturn "[object Array]";\n\t\t}\n\n\t\tthis.up();\n\t\twhile ( i-- ) {\n\t\t\tret[ i ] = this.parse( arr[ i ], undefined, stack );\n\t\t}\n\t\tthis.down();\n\t\treturn join( "[", ret, "]" );\n\t}\n\n\tvar reName = /^function (\\w+)/,\n\t\tdump = {\n\n\t\t\t// The objType is used mostly internally, you can fix a (custom) type in advance\n\t\t\tparse: function( obj, objType, stack ) {\n\t\t\t\tstack = stack || [];\n\t\t\t\tvar res, parser, parserType,\n\t\t\t\t\tinStack = inArray( obj, stack );\n\n\t\t\t\tif ( inStack !== -1 ) {\n\t\t\t\t\treturn "recursion(" + ( inStack - stack.length ) + ")";\n\t\t\t\t}\n\n\t\t\t\tobjType = objType || this.typeOf( obj );\n\t\t\t\tparser = this.parsers[ objType ];\n\t\t\t\tparserType = typeof parser;\n\n\t\t\t\tif ( parserType === "function" ) {\n\t\t\t\t\tstack.push( obj );\n\t\t\t\t\tres = parser.call( this, obj, stack );\n\t\t\t\t\tstack.pop();\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\treturn ( parserType === "string" ) ? parser : this.parsers.error;\n\t\t\t},\n\t\t\ttypeOf: function( obj ) {\n\t\t\t\tvar type;\n\t\t\t\tif ( obj === null ) {\n\t\t\t\t\ttype = "null";\n\t\t\t\t} else if ( typeof obj === "undefined" ) {\n\t\t\t\t\ttype = "undefined";\n\t\t\t\t} else if ( QUnit.is( "regexp", obj ) ) {\n\t\t\t\t\ttype = "regexp";\n\t\t\t\t} else if ( QUnit.is( "date", obj ) ) {\n\t\t\t\t\ttype = "date";\n\t\t\t\t} else if ( QUnit.is( "function", obj ) ) {\n\t\t\t\t\ttype = "function";\n\t\t\t\t} else if ( obj.setInterval !== undefined &&\n\t\t\t\t\t\tobj.document !== undefined &&\n\t\t\t\t\t\tobj.nodeType === undefined ) {\n\t\t\t\t\ttype = "window";\n\t\t\t\t} else if ( obj.nodeType === 9 ) {\n\t\t\t\t\ttype = "document";\n\t\t\t\t} else if ( obj.nodeType ) {\n\t\t\t\t\ttype = "node";\n\t\t\t\t} else if (\n\n\t\t\t\t\t// Native arrays\n\t\t\t\t\ttoString.call( obj ) === "[object Array]" ||\n\n\t\t\t\t\t// NodeList objects\n\t\t\t\t\t( typeof obj.length === "number" && obj.item !== undefined &&\n\t\t\t\t\t( obj.length ? obj.item( 0 ) === obj[ 0 ] : ( obj.item( 0 ) === null &&\n\t\t\t\t\tobj[ 0 ] === undefined ) ) )\n\t\t\t\t) {\n\t\t\t\t\ttype = "array";\n\t\t\t\t} else if ( obj.constructor === Error.prototype.constructor ) {\n\t\t\t\t\ttype = "error";\n\t\t\t\t} else {\n\t\t\t\t\ttype = typeof obj;\n\t\t\t\t}\n\t\t\t\treturn type;\n\t\t\t},\n\n\t\t\tseparator: function() {\n\t\t\t\treturn this.multiline ? this.HTML ? " " : "\\n" : this.HTML ? " " : " ";\n\t\t\t},\n\n\t\t\t// Extra can be a number, shortcut for increasing-calling-decreasing\n\t\t\tindent: function( extra ) {\n\t\t\t\tif ( !this.multiline ) {\n\t\t\t\t\treturn "";\n\t\t\t\t}\n\t\t\t\tvar chr = this.indentChar;\n\t\t\t\tif ( this.HTML ) {\n\t\t\t\t\tchr = chr.replace( /\\t/g, " " ).replace( / /g, " " );\n\t\t\t\t}\n\t\t\t\treturn new Array( this.depth + ( extra || 0 ) ).join( chr );\n\t\t\t},\n\t\t\tup: function( a ) {\n\t\t\t\tthis.depth += a || 1;\n\t\t\t},\n\t\t\tdown: function( a ) {\n\t\t\t\tthis.depth -= a || 1;\n\t\t\t},\n\t\t\tsetParser: function( name, parser ) {\n\t\t\t\tthis.parsers[ name ] = parser;\n\t\t\t},\n\n\t\t\t// The next 3 are exposed so you can use them\n\t\t\tquote: quote,\n\t\t\tliteral: literal,\n\t\t\tjoin: join,\n\t\t\tdepth: 1,\n\t\t\tmaxDepth: QUnit.config.maxDepth,\n\n\t\t\t// This is the list of parsers, to modify them, use dump.setParser\n\t\t\tparsers: {\n\t\t\t\twindow: "[Window]",\n\t\t\t\tdocument: "[Document]",\n\t\t\t\terror: function( error ) {\n\t\t\t\t\treturn "Error(\\"" + error.message + "\\")";\n\t\t\t\t},\n\t\t\t\tunknown: "[Unknown]",\n\t\t\t\t"null": "null",\n\t\t\t\t"undefined": "undefined",\n\t\t\t\t"function": function( fn ) {\n\t\t\t\t\tvar ret = "function",\n\n\t\t\t\t\t\t// Functions never have name in IE\n\t\t\t\t\t\tname = "name" in fn ? fn.name : ( reName.exec( fn ) || [] )[ 1 ];\n\n\t\t\t\t\tif ( name ) {\n\t\t\t\t\t\tret += " " + name;\n\t\t\t\t\t}\n\t\t\t\t\tret += "(";\n\n\t\t\t\t\tret = [ ret, dump.parse( fn, "functionArgs" ), "){" ].join( "" );\n\t\t\t\t\treturn join( ret, dump.parse( fn, "functionCode" ), "}" );\n\t\t\t\t},\n\t\t\t\tarray: array,\n\t\t\t\tnodelist: array,\n\t\t\t\t"arguments": array,\n\t\t\t\tobject: function( map, stack ) {\n\t\t\t\t\tvar keys, key, val, i, nonEnumerableProperties,\n\t\t\t\t\t\tret = [];\n\n\t\t\t\t\tif ( dump.maxDepth && dump.depth > dump.maxDepth ) {\n\t\t\t\t\t\treturn "[object Object]";\n\t\t\t\t\t}\n\n\t\t\t\t\tdump.up();\n\t\t\t\t\tkeys = [];\n\t\t\t\t\tfor ( key in map ) {\n\t\t\t\t\t\tkeys.push( key );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Some properties are not always enumerable on Error objects.\n\t\t\t\t\tnonEnumerableProperties = [ "message", "name" ];\n\t\t\t\t\tfor ( i in nonEnumerableProperties ) {\n\t\t\t\t\t\tkey = nonEnumerableProperties[ i ];\n\t\t\t\t\t\tif ( key in map && inArray( key, keys ) < 0 ) {\n\t\t\t\t\t\t\tkeys.push( key );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tkeys.sort();\n\t\t\t\t\tfor ( i = 0; i < keys.length; i++ ) {\n\t\t\t\t\t\tkey = keys[ i ];\n\t\t\t\t\t\tval = map[ key ];\n\t\t\t\t\t\tret.push( dump.parse( key, "key" ) + ": " +\n\t\t\t\t\t\t\tdump.parse( val, undefined, stack ) );\n\t\t\t\t\t}\n\t\t\t\t\tdump.down();\n\t\t\t\t\treturn join( "{", ret, "}" );\n\t\t\t\t},\n\t\t\t\tnode: function( node ) {\n\t\t\t\t\tvar len, i, val,\n\t\t\t\t\t\topen = dump.HTML ? "<" : "<",\n\t\t\t\t\t\tclose = dump.HTML ? ">" : ">",\n\t\t\t\t\t\ttag = node.nodeName.toLowerCase(),\n\t\t\t\t\t\tret = open + tag,\n\t\t\t\t\t\tattrs = node.attributes;\n\n\t\t\t\t\tif ( attrs ) {\n\t\t\t\t\t\tfor ( i = 0, len = attrs.length; i < len; i++ ) {\n\t\t\t\t\t\t\tval = attrs[ i ].nodeValue;\n\n\t\t\t\t\t\t\t// IE6 includes all attributes in .attributes, even ones not explicitly\n\t\t\t\t\t\t\t// set. Those have values like undefined, null, 0, false, "" or\n\t\t\t\t\t\t\t// "inherit".\n\t\t\t\t\t\t\tif ( val && val !== "inherit" ) {\n\t\t\t\t\t\t\t\tret += " " + attrs[ i ].nodeName + "=" +\n\t\t\t\t\t\t\t\t\tdump.parse( val, "attribute" );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tret += close;\n\n\t\t\t\t\t// Show content of TextNode or CDATASection\n\t\t\t\t\tif ( node.nodeType === 3 || node.nodeType === 4 ) {\n\t\t\t\t\t\tret += node.nodeValue;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ret + open + "/" + tag + close;\n\t\t\t\t},\n\n\t\t\t\t// Function calls it internally, it\'s the arguments part of the function\n\t\t\t\tfunctionArgs: function( fn ) {\n\t\t\t\t\tvar args,\n\t\t\t\t\t\tl = fn.length;\n\n\t\t\t\t\tif ( !l ) {\n\t\t\t\t\t\treturn "";\n\t\t\t\t\t}\n\n\t\t\t\t\targs = new Array( l );\n\t\t\t\t\twhile ( l-- ) {\n\n\t\t\t\t\t\t// 97 is \'a\'\n\t\t\t\t\t\targs[ l ] = String.fromCharCode( 97 + l );\n\t\t\t\t\t}\n\t\t\t\t\treturn " " + args.join( ", " ) + " ";\n\t\t\t\t},\n\n\t\t\t\t// Object calls it internally, the key part of an item in a map\n\t\t\t\tkey: quote,\n\n\t\t\t\t// Function calls it internally, it\'s the content of the function\n\t\t\t\tfunctionCode: "[code]",\n\n\t\t\t\t// Node calls it internally, it\'s a html attribute value\n\t\t\t\tattribute: quote,\n\t\t\t\tstring: quote,\n\t\t\t\tdate: quote,\n\t\t\t\tregexp: literal,\n\t\t\t\tnumber: literal,\n\t\t\t\t"boolean": literal\n\t\t\t},\n\n\t\t\t// If true, entities are escaped ( <, >, \\t, space and \\n )\n\t\t\tHTML: false,\n\n\t\t\t// Indentation unit\n\t\t\tindentChar: " ",\n\n\t\t\t// If true, items in a collection, are separated by a \\n, else just a space.\n\t\t\tmultiline: true\n\t\t};\n\n\treturn dump;\n}() );\n\n// Back compat\nQUnit.jsDump = QUnit.dump;\n\n// Deprecated\n// Extend assert methods to QUnit for Backwards compatibility\n( function() {\n\tvar i,\n\t\tassertions = Assert.prototype;\n\n\tfunction applyCurrent( current ) {\n\t\treturn function() {\n\t\t\tvar assert = new Assert( QUnit.config.current );\n\t\t\tcurrent.apply( assert, arguments );\n\t\t};\n\t}\n\n\tfor ( i in assertions ) {\n\t\tQUnit[ i ] = applyCurrent( assertions[ i ] );\n\t}\n}() );\n\n// For browser, export only select globals\nif ( defined.document ) {\n\n\t( function() {\n\t\tvar i, l,\n\t\t\tkeys = [\n\t\t\t\t"test",\n\t\t\t\t"module",\n\t\t\t\t"expect",\n\t\t\t\t"asyncTest",\n\t\t\t\t"start",\n\t\t\t\t"stop",\n\t\t\t\t"ok",\n\t\t\t\t"notOk",\n\t\t\t\t"equal",\n\t\t\t\t"notEqual",\n\t\t\t\t"propEqual",\n\t\t\t\t"notPropEqual",\n\t\t\t\t"deepEqual",\n\t\t\t\t"notDeepEqual",\n\t\t\t\t"strictEqual",\n\t\t\t\t"notStrictEqual",\n\t\t\t\t"throws",\n\t\t\t\t"raises"\n\t\t\t];\n\n\t\tfor ( i = 0, l = keys.length; i < l; i++ ) {\n\t\t\twindow[ keys[ i ] ] = QUnit[ keys[ i ] ];\n\t\t}\n\t}() );\n\n\twindow.QUnit = QUnit;\n}\n\n// For nodejs\nif ( typeof module !== "undefined" && module && module.exports ) {\n\tmodule.exports = QUnit;\n\n\t// For consistency with CommonJS environments\' exports\n\tmodule.exports.QUnit = QUnit;\n}\n\n// For CommonJS with exports, but without module.exports, like Rhino\nif ( typeof exports !== "undefined" && exports ) {\n\texports.QUnit = QUnit;\n}\n\nif ( typeof define === "function" && define.amd ) {\n\tdefine( function() {\n\t\treturn QUnit;\n\t} );\n\tQUnit.config.autostart = false;\n}\n\n// Get a reference to the global object, like window in browsers\n}( ( function() {\n\treturn this;\n}() ) ) );\n\n( function() {\n\n// Only interact with URLs via window.location\nvar location = typeof window !== "undefined" && window.location;\nif ( !location ) {\n\treturn;\n}\n\nvar urlParams = getUrlParams();\n\nQUnit.urlParams = urlParams;\n\n// Match module/test by inclusion in an array\nQUnit.config.moduleId = [].concat( urlParams.moduleId || [] );\nQUnit.config.testId = [].concat( urlParams.testId || [] );\n\n// Exact case-insensitive match of the module name\nQUnit.config.module = urlParams.module;\n\n// Regular expression or case-insenstive substring match against "moduleName: testName"\nQUnit.config.filter = urlParams.filter;\n\n// Test order randomization\nif ( urlParams.seed === true ) {\n\n\t// Generate a random seed if the option is specified without a value\n\tQUnit.config.seed = Math.random().toString( 36 ).slice( 2 );\n} else if ( urlParams.seed ) {\n\tQUnit.config.seed = urlParams.seed;\n}\n\n// Add URL-parameter-mapped config values with UI form rendering data\nQUnit.config.urlConfig.push(\n\t{\n\t\tid: "hidepassed",\n\t\tlabel: "Hide passed tests",\n\t\ttooltip: "Only show tests and assertions that fail. Stored as query-strings."\n\t},\n\t{\n\t\tid: "noglobals",\n\t\tlabel: "Check for Globals",\n\t\ttooltip: "Enabling this will test if any test introduces new properties on the " +\n\t\t\t"global object (`window` in Browsers). Stored as query-strings."\n\t},\n\t{\n\t\tid: "notrycatch",\n\t\tlabel: "No try-catch",\n\t\ttooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging " +\n\t\t\t"exceptions in IE reasonable. Stored as query-strings."\n\t}\n);\n\nQUnit.begin( function() {\n\tvar i, option,\n\t\turlConfig = QUnit.config.urlConfig;\n\n\tfor ( i = 0; i < urlConfig.length; i++ ) {\n\n\t\t// Options can be either strings or objects with nonempty "id" properties\n\t\toption = QUnit.config.urlConfig[ i ];\n\t\tif ( typeof option !== "string" ) {\n\t\t\toption = option.id;\n\t\t}\n\n\t\tif ( QUnit.config[ option ] === undefined ) {\n\t\t\tQUnit.config[ option ] = urlParams[ option ];\n\t\t}\n\t}\n} );\n\nfunction getUrlParams() {\n\tvar i, param, name, value;\n\tvar urlParams = {};\n\tvar params = location.search.slice( 1 ).split( "&" );\n\tvar length = params.length;\n\n\tfor ( i = 0; i < length; i++ ) {\n\t\tif ( params[ i ] ) {\n\t\t\tparam = params[ i ].split( "=" );\n\t\t\tname = decodeURIComponent( param[ 0 ] );\n\n\t\t\t// Allow just a key to turn on a flag, e.g., test.html?noglobals\n\t\t\tvalue = param.length === 1 ||\n\t\t\t\tdecodeURIComponent( param.slice( 1 ).join( "=" ) ) ;\n\t\t\tif ( urlParams[ name ] ) {\n\t\t\t\turlParams[ name ] = [].concat( urlParams[ name ], value );\n\t\t\t} else {\n\t\t\t\turlParams[ name ] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn urlParams;\n}\n\n// Don\'t load the HTML Reporter on non-browser environments\nif ( typeof window === "undefined" || !window.document ) {\n\treturn;\n}\n\n// Deprecated QUnit.init - Ref #530\n// Re-initialize the configuration options\nQUnit.init = function() {\n\tvar config = QUnit.config;\n\n\tconfig.stats = { all: 0, bad: 0 };\n\tconfig.moduleStats = { all: 0, bad: 0 };\n\tconfig.started = 0;\n\tconfig.updateRate = 1000;\n\tconfig.blocking = false;\n\tconfig.autostart = true;\n\tconfig.autorun = false;\n\tconfig.filter = "";\n\tconfig.queue = [];\n\n\tappendInterface();\n};\n\nvar config = QUnit.config,\n\tdocument = window.document,\n\tcollapseNext = false,\n\thasOwn = Object.prototype.hasOwnProperty,\n\tunfilteredUrl = setUrl( { filter: undefined, module: undefined,\n\t\tmoduleId: undefined, testId: undefined } ),\n\tdefined = {\n\t\tsessionStorage: ( function() {\n\t\t\tvar x = "qunit-test-string";\n\t\t\ttry {\n\t\t\t\tsessionStorage.setItem( x, x );\n\t\t\t\tsessionStorage.removeItem( x );\n\t\t\t\treturn true;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}() )\n\t},\n\tmodulesList = [];\n\n/**\n* Escape text for attribute or text content.\n*/\nfunction escapeText( s ) {\n\tif ( !s ) {\n\t\treturn "";\n\t}\n\ts = s + "";\n\n\t// Both single quotes and double quotes (for attributes)\n\treturn s.replace( /[\'"<>&]/g, function( s ) {\n\t\tswitch ( s ) {\n\t\tcase "\'":\n\t\t\treturn "'";\n\t\tcase "\\"":\n\t\t\treturn """;\n\t\tcase "<":\n\t\t\treturn "<";\n\t\tcase ">":\n\t\t\treturn ">";\n\t\tcase "&":\n\t\t\treturn "&";\n\t\t}\n\t} );\n}\n\n/**\n * @param {HTMLElement} elem\n * @param {string} type\n * @param {Function} fn\n */\nfunction addEvent( elem, type, fn ) {\n\tif ( elem.addEventListener ) {\n\n\t\t// Standards-based browsers\n\t\telem.addEventListener( type, fn, false );\n\t} else if ( elem.attachEvent ) {\n\n\t\t// Support: IE <9\n\t\telem.attachEvent( "on" + type, function() {\n\t\t\tvar event = window.event;\n\t\t\tif ( !event.target ) {\n\t\t\t\tevent.target = event.srcElement || document;\n\t\t\t}\n\n\t\t\tfn.call( elem, event );\n\t\t} );\n\t}\n}\n\n/**\n * @param {Array|NodeList} elems\n * @param {string} type\n * @param {Function} fn\n */\nfunction addEvents( elems, type, fn ) {\n\tvar i = elems.length;\n\twhile ( i-- ) {\n\t\taddEvent( elems[ i ], type, fn );\n\t}\n}\n\nfunction hasClass( elem, name ) {\n\treturn ( " " + elem.className + " " ).indexOf( " " + name + " " ) >= 0;\n}\n\nfunction addClass( elem, name ) {\n\tif ( !hasClass( elem, name ) ) {\n\t\telem.className += ( elem.className ? " " : "" ) + name;\n\t}\n}\n\nfunction toggleClass( elem, name, force ) {\n\tif ( force || typeof force === "undefined" && !hasClass( elem, name ) ) {\n\t\taddClass( elem, name );\n\t} else {\n\t\tremoveClass( elem, name );\n\t}\n}\n\nfunction removeClass( elem, name ) {\n\tvar set = " " + elem.className + " ";\n\n\t// Class name may appear multiple times\n\twhile ( set.indexOf( " " + name + " " ) >= 0 ) {\n\t\tset = set.replace( " " + name + " ", " " );\n\t}\n\n\t// Trim for prettiness\n\telem.className = typeof set.trim === "function" ? set.trim() : set.replace( /^\\s+|\\s+$/g, "" );\n}\n\nfunction id( name ) {\n\treturn document.getElementById && document.getElementById( name );\n}\n\nfunction getUrlConfigHtml() {\n\tvar i, j, val,\n\t\tescaped, escapedTooltip,\n\t\tselection = false,\n\t\turlConfig = config.urlConfig,\n\t\turlConfigHtml = "";\n\n\tfor ( i = 0; i < urlConfig.length; i++ ) {\n\n\t\t// Options can be either strings or objects with nonempty "id" properties\n\t\tval = config.urlConfig[ i ];\n\t\tif ( typeof val === "string" ) {\n\t\t\tval = {\n\t\t\t\tid: val,\n\t\t\t\tlabel: val\n\t\t\t};\n\t\t}\n\n\t\tescaped = escapeText( val.id );\n\t\tescapedTooltip = escapeText( val.tooltip );\n\n\t\tif ( !val.value || typeof val.value === "string" ) {\n\t\t\turlConfigHtml += "" + val.label + " ";\n\t\t} else {\n\t\t\turlConfigHtml += "" + val.label +\n\t\t\t\t": ";\n\n\t\t\tif ( QUnit.is( "array", val.value ) ) {\n\t\t\t\tfor ( j = 0; j < val.value.length; j++ ) {\n\t\t\t\t\tescaped = escapeText( val.value[ j ] );\n\t\t\t\t\turlConfigHtml += "" + escaped + " ";\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( j in val.value ) {\n\t\t\t\t\tif ( hasOwn.call( val.value, j ) ) {\n\t\t\t\t\t\turlConfigHtml += "" + escapeText( val.value[ j ] ) + " ";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( config[ val.id ] && !selection ) {\n\t\t\t\tescaped = escapeText( config[ val.id ] );\n\t\t\t\turlConfigHtml += "" + escaped + " ";\n\t\t\t}\n\t\t\turlConfigHtml += " ";\n\t\t}\n\t}\n\n\treturn urlConfigHtml;\n}\n\n// Handle "click" events on toolbar checkboxes and "change" for select menus.\n// Updates the URL with the new state of `config.urlConfig` values.\nfunction toolbarChanged() {\n\tvar updatedUrl, value, tests,\n\t\tfield = this,\n\t\tparams = {};\n\n\t// Detect if field is a select menu or a checkbox\n\tif ( "selectedIndex" in field ) {\n\t\tvalue = field.options[ field.selectedIndex ].value || undefined;\n\t} else {\n\t\tvalue = field.checked ? ( field.defaultValue || true ) : undefined;\n\t}\n\n\tparams[ field.name ] = value;\n\tupdatedUrl = setUrl( params );\n\n\t// Check if we can apply the change without a page refresh\n\tif ( "hidepassed" === field.name && "replaceState" in window.history ) {\n\t\tQUnit.urlParams[ field.name ] = value;\n\t\tconfig[ field.name ] = value || false;\n\t\ttests = id( "qunit-tests" );\n\t\tif ( tests ) {\n\t\t\ttoggleClass( tests, "hidepass", value || false );\n\t\t}\n\t\twindow.history.replaceState( null, "", updatedUrl );\n\t} else {\n\t\twindow.location = updatedUrl;\n\t}\n}\n\nfunction setUrl( params ) {\n\tvar key, arrValue, i,\n\t\tquerystring = "?",\n\t\tlocation = window.location;\n\n\tparams = QUnit.extend( QUnit.extend( {}, QUnit.urlParams ), params );\n\n\tfor ( key in params ) {\n\n\t\t// Skip inherited or undefined properties\n\t\tif ( hasOwn.call( params, key ) && params[ key ] !== undefined ) {\n\n\t\t\t// Output a parameter for each value of this key (but usually just one)\n\t\t\tarrValue = [].concat( params[ key ] );\n\t\t\tfor ( i = 0; i < arrValue.length; i++ ) {\n\t\t\t\tquerystring += encodeURIComponent( key );\n\t\t\t\tif ( arrValue[ i ] !== true ) {\n\t\t\t\t\tquerystring += "=" + encodeURIComponent( arrValue[ i ] );\n\t\t\t\t}\n\t\t\t\tquerystring += "&";\n\t\t\t}\n\t\t}\n\t}\n\treturn location.protocol + "//" + location.host +\n\t\tlocation.pathname + querystring.slice( 0, -1 );\n}\n\nfunction applyUrlParams() {\n\tvar selectedModule,\n\t\tmodulesList = id( "qunit-modulefilter" ),\n\t\tfilter = id( "qunit-filter-input" ).value;\n\n\tselectedModule = modulesList ?\n\t\tdecodeURIComponent( modulesList.options[ modulesList.selectedIndex ].value ) :\n\t\tundefined;\n\n\twindow.location = setUrl( {\n\t\tmodule: ( selectedModule === "" ) ? undefined : selectedModule,\n\t\tfilter: ( filter === "" ) ? undefined : filter,\n\n\t\t// Remove moduleId and testId filters\n\t\tmoduleId: undefined,\n\t\ttestId: undefined\n\t} );\n}\n\nfunction toolbarUrlConfigContainer() {\n\tvar urlConfigContainer = document.createElement( "span" );\n\n\turlConfigContainer.innerHTML = getUrlConfigHtml();\n\taddClass( urlConfigContainer, "qunit-url-config" );\n\n\t// For oldIE support:\n\t// * Add handlers to the individual elements instead of the container\n\t// * Use "click" instead of "change" for checkboxes\n\taddEvents( urlConfigContainer.getElementsByTagName( "input" ), "click", toolbarChanged );\n\taddEvents( urlConfigContainer.getElementsByTagName( "select" ), "change", toolbarChanged );\n\n\treturn urlConfigContainer;\n}\n\nfunction toolbarLooseFilter() {\n\tvar filter = document.createElement( "form" ),\n\t\tlabel = document.createElement( "label" ),\n\t\tinput = document.createElement( "input" ),\n\t\tbutton = document.createElement( "button" );\n\n\taddClass( filter, "qunit-filter" );\n\n\tlabel.innerHTML = "Filter: ";\n\n\tinput.type = "text";\n\tinput.value = config.filter || "";\n\tinput.name = "filter";\n\tinput.id = "qunit-filter-input";\n\n\tbutton.innerHTML = "Go";\n\n\tlabel.appendChild( input );\n\n\tfilter.appendChild( label );\n\tfilter.appendChild( button );\n\taddEvent( filter, "submit", function( ev ) {\n\t\tapplyUrlParams();\n\n\t\tif ( ev && ev.preventDefault ) {\n\t\t\tev.preventDefault();\n\t\t}\n\n\t\treturn false;\n\t} );\n\n\treturn filter;\n}\n\nfunction toolbarModuleFilterHtml() {\n\tvar i,\n\t\tmoduleFilterHtml = "";\n\n\tif ( !modulesList.length ) {\n\t\treturn false;\n\t}\n\n\tmoduleFilterHtml += "Module: " +\n\t\t"< All Modules > ";\n\n\tfor ( i = 0; i < modulesList.length; i++ ) {\n\t\tmoduleFilterHtml += "" + escapeText( modulesList[ i ] ) + " ";\n\t}\n\tmoduleFilterHtml += " ";\n\n\treturn moduleFilterHtml;\n}\n\nfunction toolbarModuleFilter() {\n\tvar toolbar = id( "qunit-testrunner-toolbar" ),\n\t\tmoduleFilter = document.createElement( "span" ),\n\t\tmoduleFilterHtml = toolbarModuleFilterHtml();\n\n\tif ( !toolbar || !moduleFilterHtml ) {\n\t\treturn false;\n\t}\n\n\tmoduleFilter.setAttribute( "id", "qunit-modulefilter-container" );\n\tmoduleFilter.innerHTML = moduleFilterHtml;\n\n\taddEvent( moduleFilter.lastChild, "change", applyUrlParams );\n\n\ttoolbar.appendChild( moduleFilter );\n}\n\nfunction appendToolbar() {\n\tvar toolbar = id( "qunit-testrunner-toolbar" );\n\n\tif ( toolbar ) {\n\t\ttoolbar.appendChild( toolbarUrlConfigContainer() );\n\t\ttoolbar.appendChild( toolbarLooseFilter() );\n\t\ttoolbarModuleFilter();\n\t}\n}\n\nfunction appendHeader() {\n\tvar header = id( "qunit-header" );\n\n\tif ( header ) {\n\t\theader.innerHTML = "" + header.innerHTML +\n\t\t\t" ";\n\t}\n}\n\nfunction appendBanner() {\n\tvar banner = id( "qunit-banner" );\n\n\tif ( banner ) {\n\t\tbanner.className = "";\n\t}\n}\n\nfunction appendTestResults() {\n\tvar tests = id( "qunit-tests" ),\n\t\tresult = id( "qunit-testresult" );\n\n\tif ( result ) {\n\t\tresult.parentNode.removeChild( result );\n\t}\n\n\tif ( tests ) {\n\t\ttests.innerHTML = "";\n\t\tresult = document.createElement( "p" );\n\t\tresult.id = "qunit-testresult";\n\t\tresult.className = "result";\n\t\ttests.parentNode.insertBefore( result, tests );\n\t\tresult.innerHTML = "Running... ";\n\t}\n}\n\nfunction storeFixture() {\n\tvar fixture = id( "qunit-fixture" );\n\tif ( fixture ) {\n\t\tconfig.fixture = fixture.innerHTML;\n\t}\n}\n\nfunction appendFilteredTest() {\n\tvar testId = QUnit.config.testId;\n\tif ( !testId || testId.length <= 0 ) {\n\t\treturn "";\n\t}\n\treturn "Rerunning selected tests: " +\n\t\tescapeText( testId.join( ", " ) ) +\n\t\t"
Run all tests ";\n}\n\nfunction appendUserAgent() {\n\tvar userAgent = id( "qunit-userAgent" );\n\n\tif ( userAgent ) {\n\t\tuserAgent.innerHTML = "";\n\t\tuserAgent.appendChild(\n\t\t\tdocument.createTextNode(\n\t\t\t\t"QUnit " + QUnit.version + "; " + navigator.userAgent\n\t\t\t)\n\t\t);\n\t}\n}\n\nfunction appendInterface() {\n\tvar qunit = id( "qunit" );\n\n\tif ( qunit ) {\n\t\tqunit.innerHTML =\n\t\t\t"" +\n\t\t\t" " +\n\t\t\t"
" +\n\t\t\tappendFilteredTest() +\n\t\t\t" " +\n\t\t\t" ";\n\t}\n\n\tappendHeader();\n\tappendBanner();\n\tappendTestResults();\n\tappendUserAgent();\n\tappendToolbar();\n}\n\nfunction appendTestsList( modules ) {\n\tvar i, l, x, z, test, moduleObj;\n\n\tfor ( i = 0, l = modules.length; i < l; i++ ) {\n\t\tmoduleObj = modules[ i ];\n\n\t\tfor ( x = 0, z = moduleObj.tests.length; x < z; x++ ) {\n\t\t\ttest = moduleObj.tests[ x ];\n\n\t\t\tappendTest( test.name, test.testId, moduleObj.name );\n\t\t}\n\t}\n}\n\nfunction appendTest( name, testId, moduleName ) {\n\tvar title, rerunTrigger, testBlock, assertList,\n\t\ttests = id( "qunit-tests" );\n\n\tif ( !tests ) {\n\t\treturn;\n\t}\n\n\ttitle = document.createElement( "strong" );\n\ttitle.innerHTML = getNameHtml( name, moduleName );\n\n\trerunTrigger = document.createElement( "a" );\n\trerunTrigger.innerHTML = "Rerun";\n\trerunTrigger.href = setUrl( { testId: testId } );\n\n\ttestBlock = document.createElement( "li" );\n\ttestBlock.appendChild( title );\n\ttestBlock.appendChild( rerunTrigger );\n\ttestBlock.id = "qunit-test-output-" + testId;\n\n\tassertList = document.createElement( "ol" );\n\tassertList.className = "qunit-assert-list";\n\n\ttestBlock.appendChild( assertList );\n\n\ttests.appendChild( testBlock );\n}\n\n// HTML Reporter initialization and load\nQUnit.begin( function( details ) {\n\tvar i, moduleObj, tests;\n\n\t// Sort modules by name for the picker\n\tfor ( i = 0; i < details.modules.length; i++ ) {\n\t\tmoduleObj = details.modules[ i ];\n\t\tif ( moduleObj.name ) {\n\t\t\tmodulesList.push( moduleObj.name );\n\t\t}\n\t}\n\tmodulesList.sort( function( a, b ) {\n\t\treturn a.localeCompare( b );\n\t} );\n\n\t// Capture fixture HTML from the page\n\tstoreFixture();\n\n\t// Initialize QUnit elements\n\tappendInterface();\n\tappendTestsList( details.modules );\n\ttests = id( "qunit-tests" );\n\tif ( tests && config.hidepassed ) {\n\t\taddClass( tests, "hidepass" );\n\t}\n} );\n\nQUnit.done( function( details ) {\n\tvar i, key,\n\t\tbanner = id( "qunit-banner" ),\n\t\ttests = id( "qunit-tests" ),\n\t\thtml = [\n\t\t\t"Tests completed in ",\n\t\t\tdetails.runtime,\n\t\t\t" milliseconds. ",\n\t\t\t"",\n\t\t\tdetails.passed,\n\t\t\t" assertions of ",\n\t\t\tdetails.total,\n\t\t\t" passed, ",\n\t\t\tdetails.failed,\n\t\t\t" failed."\n\t\t].join( "" );\n\n\tif ( banner ) {\n\t\tbanner.className = details.failed ? "qunit-fail" : "qunit-pass";\n\t}\n\n\tif ( tests ) {\n\t\tid( "qunit-testresult" ).innerHTML = html;\n\t}\n\n\tif ( config.altertitle && document.title ) {\n\n\t\t// Show \u2716 for good, \u2714 for bad suite result in title\n\t\t// use escape sequences in case file gets loaded with non-utf-8-charset\n\t\tdocument.title = [\n\t\t\t( details.failed ? "\\u2716" : "\\u2714" ),\n\t\t\tdocument.title.replace( /^[\\u2714\\u2716] /i, "" )\n\t\t].join( " " );\n\t}\n\n\t// Clear own sessionStorage items if all tests passed\n\tif ( config.reorder && defined.sessionStorage && details.failed === 0 ) {\n\t\tfor ( i = 0; i < sessionStorage.length; i++ ) {\n\t\t\tkey = sessionStorage.key( i++ );\n\t\t\tif ( key.indexOf( "qunit-test-" ) === 0 ) {\n\t\t\t\tsessionStorage.removeItem( key );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Scroll back to top to show results\n\tif ( config.scrolltop && window.scrollTo ) {\n\t\twindow.scrollTo( 0, 0 );\n\t}\n} );\n\nfunction getNameHtml( name, module ) {\n\tvar nameHtml = "";\n\n\tif ( module ) {\n\t\tnameHtml = "" + escapeText( module ) + " : ";\n\t}\n\n\tnameHtml += "" + escapeText( name ) + " ";\n\n\treturn nameHtml;\n}\n\nQUnit.testStart( function( details ) {\n\tvar running, testBlock, bad;\n\n\ttestBlock = id( "qunit-test-output-" + details.testId );\n\tif ( testBlock ) {\n\t\ttestBlock.className = "running";\n\t} else {\n\n\t\t// Report later registered tests\n\t\tappendTest( details.name, details.testId, details.module );\n\t}\n\n\trunning = id( "qunit-testresult" );\n\tif ( running ) {\n\t\tbad = QUnit.config.reorder && defined.sessionStorage &&\n\t\t\t+sessionStorage.getItem( "qunit-test-" + details.module + "-" + details.name );\n\n\t\trunning.innerHTML = ( bad ?\n\t\t\t"Rerunning previously failed test: " :\n\t\t\t"Running: " ) +\n\t\t\tgetNameHtml( details.name, details.module );\n\t}\n\n} );\n\nfunction stripHtml( string ) {\n\n\t// Strip tags, html entity and whitespaces\n\treturn string.replace( /<\\/?[^>]+(>|$)/g, "" ).replace( /\\"/g, "" ).replace( /\\s+/g, "" );\n}\n\nQUnit.log( function( details ) {\n\tvar assertList, assertLi,\n\t\tmessage, expected, actual, diff,\n\t\tshowDiff = false,\n\t\ttestItem = id( "qunit-test-output-" + details.testId );\n\n\tif ( !testItem ) {\n\t\treturn;\n\t}\n\n\tmessage = escapeText( details.message ) || ( details.result ? "okay" : "failed" );\n\tmessage = "" + message + " ";\n\tmessage += "@ " + details.runtime + " ms ";\n\n\t// The pushFailure doesn\'t provide details.expected\n\t// when it calls, it\'s implicit to also not show expected and diff stuff\n\t// Also, we need to check details.expected existence, as it can exist and be undefined\n\tif ( !details.result && hasOwn.call( details, "expected" ) ) {\n\t\tif ( details.negative ) {\n\t\t\texpected = "NOT " + QUnit.dump.parse( details.expected );\n\t\t} else {\n\t\t\texpected = QUnit.dump.parse( details.expected );\n\t\t}\n\n\t\tactual = QUnit.dump.parse( details.actual );\n\t\tmessage += "Expected: " +\n\t\t\tescapeText( expected ) +\n\t\t\t" ";\n\n\t\tif ( actual !== expected ) {\n\n\t\t\tmessage += "Result: " +\n\t\t\t\tescapeText( actual ) + " ";\n\n\t\t\t// Don\'t show diff if actual or expected are booleans\n\t\t\tif ( !( /^(true|false)$/.test( actual ) ) &&\n\t\t\t\t\t!( /^(true|false)$/.test( expected ) ) ) {\n\t\t\t\tdiff = QUnit.diff( expected, actual );\n\t\t\t\tshowDiff = stripHtml( diff ).length !==\n\t\t\t\t\tstripHtml( expected ).length +\n\t\t\t\t\tstripHtml( actual ).length;\n\t\t\t}\n\n\t\t\t// Don\'t show diff if expected and actual are totally different\n\t\t\tif ( showDiff ) {\n\t\t\t\tmessage += "Diff: " +\n\t\t\t\t\tdiff + " ";\n\t\t\t}\n\t\t} else if ( expected.indexOf( "[object Array]" ) !== -1 ||\n\t\t\t\texpected.indexOf( "[object Object]" ) !== -1 ) {\n\t\t\tmessage += "Message: " +\n\t\t\t\t"Diff suppressed as the depth of object is more than current max depth (" +\n\t\t\t\tQUnit.config.maxDepth + ").Hint: Use QUnit.dump.maxDepth
to " +\n\t\t\t\t" run with a higher max depth or " +\n\t\t\t\t"Rerun without max depth.
";\n\t\t} else {\n\t\t\tmessage += "Message: " +\n\t\t\t\t"Diff suppressed as the expected and actual results have an equivalent" +\n\t\t\t\t" serialization ";\n\t\t}\n\n\t\tif ( details.source ) {\n\t\t\tmessage += "Source: " +\n\t\t\t\tescapeText( details.source ) + " ";\n\t\t}\n\n\t\tmessage += "
";\n\n\t// This occurs when pushFailure is set and we have an extracted stack trace\n\t} else if ( !details.result && details.source ) {\n\t\tmessage += "" +\n\t\t\t"Source: " +\n\t\t\tescapeText( details.source ) + " " +\n\t\t\t"
";\n\t}\n\n\tassertList = testItem.getElementsByTagName( "ol" )[ 0 ];\n\n\tassertLi = document.createElement( "li" );\n\tassertLi.className = details.result ? "pass" : "fail";\n\tassertLi.innerHTML = message;\n\tassertList.appendChild( assertLi );\n} );\n\nQUnit.testDone( function( details ) {\n\tvar testTitle, time, testItem, assertList,\n\t\tgood, bad, testCounts, skipped, sourceName,\n\t\ttests = id( "qunit-tests" );\n\n\tif ( !tests ) {\n\t\treturn;\n\t}\n\n\ttestItem = id( "qunit-test-output-" + details.testId );\n\n\tassertList = testItem.getElementsByTagName( "ol" )[ 0 ];\n\n\tgood = details.passed;\n\tbad = details.failed;\n\n\t// Store result when possible\n\tif ( config.reorder && defined.sessionStorage ) {\n\t\tif ( bad ) {\n\t\t\tsessionStorage.setItem( "qunit-test-" + details.module + "-" + details.name, bad );\n\t\t} else {\n\t\t\tsessionStorage.removeItem( "qunit-test-" + details.module + "-" + details.name );\n\t\t}\n\t}\n\n\tif ( bad === 0 ) {\n\n\t\t// Collapse the passing tests\n\t\taddClass( assertList, "qunit-collapsed" );\n\t} else if ( bad && config.collapse && !collapseNext ) {\n\n\t\t// Skip collapsing the first failing test\n\t\tcollapseNext = true;\n\t} else {\n\n\t\t// Collapse remaining tests\n\t\taddClass( assertList, "qunit-collapsed" );\n\t}\n\n\t// The testItem.firstChild is the test name\n\ttestTitle = testItem.firstChild;\n\n\ttestCounts = bad ?\n\t\t"" + bad + " , " + "" + good + " , " :\n\t\t"";\n\n\ttestTitle.innerHTML += " (" + testCounts +\n\t\tdetails.assertions.length + ") ";\n\n\tif ( details.skipped ) {\n\t\ttestItem.className = "skipped";\n\t\tskipped = document.createElement( "em" );\n\t\tskipped.className = "qunit-skipped-label";\n\t\tskipped.innerHTML = "skipped";\n\t\ttestItem.insertBefore( skipped, testTitle );\n\t} else {\n\t\taddEvent( testTitle, "click", function() {\n\t\t\ttoggleClass( assertList, "qunit-collapsed" );\n\t\t} );\n\n\t\ttestItem.className = bad ? "fail" : "pass";\n\n\t\ttime = document.createElement( "span" );\n\t\ttime.className = "runtime";\n\t\ttime.innerHTML = details.runtime + " ms";\n\t\ttestItem.insertBefore( time, assertList );\n\t}\n\n\t// Show the source of the test when showing assertions\n\tif ( details.source ) {\n\t\tsourceName = document.createElement( "p" );\n\t\tsourceName.innerHTML = "Source: " + details.source;\n\t\taddClass( sourceName, "qunit-source" );\n\t\tif ( bad === 0 ) {\n\t\t\taddClass( sourceName, "qunit-collapsed" );\n\t\t}\n\t\taddEvent( testTitle, "click", function() {\n\t\t\ttoggleClass( sourceName, "qunit-collapsed" );\n\t\t} );\n\t\ttestItem.appendChild( sourceName );\n\t}\n} );\n\n// Avoid readyState issue with phantomjs\n// Ref: #818\nvar notPhantom = ( function( p ) {\n\treturn !( p && p.version && p.version.major > 0 );\n} )( window.phantom );\n\nif ( notPhantom && document.readyState === "complete" ) {\n\tQUnit.load();\n} else {\n\taddEvent( window, "load", QUnit.load );\n}\n\n/*\n * This file is a modified version of google-diff-match-patch\'s JavaScript implementation\n * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js),\n * modifications are licensed as more fully set forth in LICENSE.txt.\n *\n * The original source of google-diff-match-patch is attributable and licensed as follows:\n *\n * Copyright 2006 Google Inc.\n * https://code.google.com/p/google-diff-match-patch/\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * More Info:\n * https://code.google.com/p/google-diff-match-patch/\n *\n * Usage: QUnit.diff(expected, actual)\n *\n */\nQUnit.diff = ( function() {\n\tfunction DiffMatchPatch() {\n\t}\n\n\t// DIFF FUNCTIONS\n\n\t/**\n\t * The data structure representing a diff is an array of tuples:\n\t * [[DIFF_DELETE, \'Hello\'], [DIFF_INSERT, \'Goodbye\'], [DIFF_EQUAL, \' world.\']]\n\t * which means: delete \'Hello\', add \'Goodbye\' and keep \' world.\'\n\t */\n\tvar DIFF_DELETE = -1,\n\t\tDIFF_INSERT = 1,\n\t\tDIFF_EQUAL = 0;\n\n\t/**\n\t * Find the differences between two texts. Simplifies the problem by stripping\n\t * any common prefix or suffix off the texts before diffing.\n\t * @param {string} text1 Old string to be diffed.\n\t * @param {string} text2 New string to be diffed.\n\t * @param {boolean=} optChecklines Optional speedup flag. If present and false,\n\t * then don\'t run a line-level diff first to identify the changed areas.\n\t * Defaults to true, which does a faster, slightly less optimal diff.\n\t * @return {!Array.} Array of diff tuples.\n\t */\n\tDiffMatchPatch.prototype.DiffMain = function( text1, text2, optChecklines ) {\n\t\tvar deadline, checklines, commonlength,\n\t\t\tcommonprefix, commonsuffix, diffs;\n\n\t\t// The diff must be complete in up to 1 second.\n\t\tdeadline = ( new Date() ).getTime() + 1000;\n\n\t\t// Check for null inputs.\n\t\tif ( text1 === null || text2 === null ) {\n\t\t\tthrow new Error( "Null input. (DiffMain)" );\n\t\t}\n\n\t\t// Check for equality (speedup).\n\t\tif ( text1 === text2 ) {\n\t\t\tif ( text1 ) {\n\t\t\t\treturn [\n\t\t\t\t\t[ DIFF_EQUAL, text1 ]\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tif ( typeof optChecklines === "undefined" ) {\n\t\t\toptChecklines = true;\n\t\t}\n\n\t\tchecklines = optChecklines;\n\n\t\t// Trim off common prefix (speedup).\n\t\tcommonlength = this.diffCommonPrefix( text1, text2 );\n\t\tcommonprefix = text1.substring( 0, commonlength );\n\t\ttext1 = text1.substring( commonlength );\n\t\ttext2 = text2.substring( commonlength );\n\n\t\t// Trim off common suffix (speedup).\n\t\tcommonlength = this.diffCommonSuffix( text1, text2 );\n\t\tcommonsuffix = text1.substring( text1.length - commonlength );\n\t\ttext1 = text1.substring( 0, text1.length - commonlength );\n\t\ttext2 = text2.substring( 0, text2.length - commonlength );\n\n\t\t// Compute the diff on the middle block.\n\t\tdiffs = this.diffCompute( text1, text2, checklines, deadline );\n\n\t\t// Restore the prefix and suffix.\n\t\tif ( commonprefix ) {\n\t\t\tdiffs.unshift( [ DIFF_EQUAL, commonprefix ] );\n\t\t}\n\t\tif ( commonsuffix ) {\n\t\t\tdiffs.push( [ DIFF_EQUAL, commonsuffix ] );\n\t\t}\n\t\tthis.diffCleanupMerge( diffs );\n\t\treturn diffs;\n\t};\n\n\t/**\n\t * Reduce the number of edits by eliminating operationally trivial equalities.\n\t * @param {!Array.} diffs Array of diff tuples.\n\t */\n\tDiffMatchPatch.prototype.diffCleanupEfficiency = function( diffs ) {\n\t\tvar changes, equalities, equalitiesLength, lastequality,\n\t\t\tpointer, preIns, preDel, postIns, postDel;\n\t\tchanges = false;\n\t\tequalities = []; // Stack of indices where equalities are found.\n\t\tequalitiesLength = 0; // Keeping our own length var is faster in JS.\n\t\t/** @type {?string} */\n\t\tlastequality = null;\n\n\t\t// Always equal to diffs[equalities[equalitiesLength - 1]][1]\n\t\tpointer = 0; // Index of current position.\n\n\t\t// Is there an insertion operation before the last equality.\n\t\tpreIns = false;\n\n\t\t// Is there a deletion operation before the last equality.\n\t\tpreDel = false;\n\n\t\t// Is there an insertion operation after the last equality.\n\t\tpostIns = false;\n\n\t\t// Is there a deletion operation after the last equality.\n\t\tpostDel = false;\n\t\twhile ( pointer < diffs.length ) {\n\n\t\t\t// Equality found.\n\t\t\tif ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) {\n\t\t\t\tif ( diffs[ pointer ][ 1 ].length < 4 && ( postIns || postDel ) ) {\n\n\t\t\t\t\t// Candidate found.\n\t\t\t\t\tequalities[ equalitiesLength++ ] = pointer;\n\t\t\t\t\tpreIns = postIns;\n\t\t\t\t\tpreDel = postDel;\n\t\t\t\t\tlastequality = diffs[ pointer ][ 1 ];\n\t\t\t\t} else {\n\n\t\t\t\t\t// Not a candidate, and can never become one.\n\t\t\t\t\tequalitiesLength = 0;\n\t\t\t\t\tlastequality = null;\n\t\t\t\t}\n\t\t\t\tpostIns = postDel = false;\n\n\t\t\t// An insertion or deletion.\n\t\t\t} else {\n\n\t\t\t\tif ( diffs[ pointer ][ 0 ] === DIFF_DELETE ) {\n\t\t\t\t\tpostDel = true;\n\t\t\t\t} else {\n\t\t\t\t\tpostIns = true;\n\t\t\t\t}\n\n\t\t\t\t/*\n\t\t\t\t * Five types to be split:\n\t\t\t\t * A BXYC D\n\t\t\t\t * A XC D\n\t\t\t\t * A BXC \n\t\t\t\t * AXC D\n\t\t\t\t * A BXC\n\t\t\t\t */\n\t\t\t\tif ( lastequality && ( ( preIns && preDel && postIns && postDel ) ||\n\t\t\t\t\t\t( ( lastequality.length < 2 ) &&\n\t\t\t\t\t\t( preIns + preDel + postIns + postDel ) === 3 ) ) ) {\n\n\t\t\t\t\t// Duplicate record.\n\t\t\t\t\tdiffs.splice(\n\t\t\t\t\t\tequalities[ equalitiesLength - 1 ],\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t[ DIFF_DELETE, lastequality ]\n\t\t\t\t\t);\n\n\t\t\t\t\t// Change second copy to insert.\n\t\t\t\t\tdiffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;\n\t\t\t\t\tequalitiesLength--; // Throw away the equality we just deleted;\n\t\t\t\t\tlastequality = null;\n\t\t\t\t\tif ( preIns && preDel ) {\n\n\t\t\t\t\t\t// No changes made which could affect previous entry, keep going.\n\t\t\t\t\t\tpostIns = postDel = true;\n\t\t\t\t\t\tequalitiesLength = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tequalitiesLength--; // Throw away the previous equality.\n\t\t\t\t\t\tpointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;\n\t\t\t\t\t\tpostIns = postDel = false;\n\t\t\t\t\t}\n\t\t\t\t\tchanges = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpointer++;\n\t\t}\n\n\t\tif ( changes ) {\n\t\t\tthis.diffCleanupMerge( diffs );\n\t\t}\n\t};\n\n\t/**\n\t * Convert a diff array into a pretty HTML report.\n\t * @param {!Array.} diffs Array of diff tuples.\n\t * @param {integer} string to be beautified.\n\t * @return {string} HTML representation.\n\t */\n\tDiffMatchPatch.prototype.diffPrettyHtml = function( diffs ) {\n\t\tvar op, data, x,\n\t\t\thtml = [];\n\t\tfor ( x = 0; x < diffs.length; x++ ) {\n\t\t\top = diffs[ x ][ 0 ]; // Operation (insert, delete, equal)\n\t\t\tdata = diffs[ x ][ 1 ]; // Text of change.\n\t\t\tswitch ( op ) {\n\t\t\tcase DIFF_INSERT:\n\t\t\t\thtml[ x ] = "" + escapeText( data ) + " ";\n\t\t\t\tbreak;\n\t\t\tcase DIFF_DELETE:\n\t\t\t\thtml[ x ] = "" + escapeText( data ) + "";\n\t\t\t\tbreak;\n\t\t\tcase DIFF_EQUAL:\n\t\t\t\thtml[ x ] = "" + escapeText( data ) + " ";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn html.join( "" );\n\t};\n\n\t/**\n\t * Determine the common prefix of two strings.\n\t * @param {string} text1 First string.\n\t * @param {string} text2 Second string.\n\t * @return {number} The number of characters common to the start of each\n\t * string.\n\t */\n\tDiffMatchPatch.prototype.diffCommonPrefix = function( text1, text2 ) {\n\t\tvar pointermid, pointermax, pointermin, pointerstart;\n\n\t\t// Quick check for common null cases.\n\t\tif ( !text1 || !text2 || text1.charAt( 0 ) !== text2.charAt( 0 ) ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Binary search.\n\t\t// Performance analysis: https://neil.fraser.name/news/2007/10/09/\n\t\tpointermin = 0;\n\t\tpointermax = Math.min( text1.length, text2.length );\n\t\tpointermid = pointermax;\n\t\tpointerstart = 0;\n\t\twhile ( pointermin < pointermid ) {\n\t\t\tif ( text1.substring( pointerstart, pointermid ) ===\n\t\t\t\t\ttext2.substring( pointerstart, pointermid ) ) {\n\t\t\t\tpointermin = pointermid;\n\t\t\t\tpointerstart = pointermin;\n\t\t\t} else {\n\t\t\t\tpointermax = pointermid;\n\t\t\t}\n\t\t\tpointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );\n\t\t}\n\t\treturn pointermid;\n\t};\n\n\t/**\n\t * Determine the common suffix of two strings.\n\t * @param {string} text1 First string.\n\t * @param {string} text2 Second string.\n\t * @return {number} The number of characters common to the end of each string.\n\t */\n\tDiffMatchPatch.prototype.diffCommonSuffix = function( text1, text2 ) {\n\t\tvar pointermid, pointermax, pointermin, pointerend;\n\n\t\t// Quick check for common null cases.\n\t\tif ( !text1 ||\n\t\t\t\t!text2 ||\n\t\t\t\ttext1.charAt( text1.length - 1 ) !== text2.charAt( text2.length - 1 ) ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Binary search.\n\t\t// Performance analysis: https://neil.fraser.name/news/2007/10/09/\n\t\tpointermin = 0;\n\t\tpointermax = Math.min( text1.length, text2.length );\n\t\tpointermid = pointermax;\n\t\tpointerend = 0;\n\t\twhile ( pointermin < pointermid ) {\n\t\t\tif ( text1.substring( text1.length - pointermid, text1.length - pointerend ) ===\n\t\t\t\t\ttext2.substring( text2.length - pointermid, text2.length - pointerend ) ) {\n\t\t\t\tpointermin = pointermid;\n\t\t\t\tpointerend = pointermin;\n\t\t\t} else {\n\t\t\t\tpointermax = pointermid;\n\t\t\t}\n\t\t\tpointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );\n\t\t}\n\t\treturn pointermid;\n\t};\n\n\t/**\n\t * Find the differences between two texts. Assumes that the texts do not\n\t * have any common prefix or suffix.\n\t * @param {string} text1 Old string to be diffed.\n\t * @param {string} text2 New string to be diffed.\n\t * @param {boolean} checklines Speedup flag. If false, then don\'t run a\n\t * line-level diff first to identify the changed areas.\n\t * If true, then run a faster, slightly less optimal diff.\n\t * @param {number} deadline Time when the diff should be complete by.\n\t * @return {!Array.} Array of diff tuples.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffCompute = function( text1, text2, checklines, deadline ) {\n\t\tvar diffs, longtext, shorttext, i, hm,\n\t\t\ttext1A, text2A, text1B, text2B,\n\t\t\tmidCommon, diffsA, diffsB;\n\n\t\tif ( !text1 ) {\n\n\t\t\t// Just add some text (speedup).\n\t\t\treturn [\n\t\t\t\t[ DIFF_INSERT, text2 ]\n\t\t\t];\n\t\t}\n\n\t\tif ( !text2 ) {\n\n\t\t\t// Just delete some text (speedup).\n\t\t\treturn [\n\t\t\t\t[ DIFF_DELETE, text1 ]\n\t\t\t];\n\t\t}\n\n\t\tlongtext = text1.length > text2.length ? text1 : text2;\n\t\tshorttext = text1.length > text2.length ? text2 : text1;\n\t\ti = longtext.indexOf( shorttext );\n\t\tif ( i !== -1 ) {\n\n\t\t\t// Shorter text is inside the longer text (speedup).\n\t\t\tdiffs = [\n\t\t\t\t[ DIFF_INSERT, longtext.substring( 0, i ) ],\n\t\t\t\t[ DIFF_EQUAL, shorttext ],\n\t\t\t\t[ DIFF_INSERT, longtext.substring( i + shorttext.length ) ]\n\t\t\t];\n\n\t\t\t// Swap insertions for deletions if diff is reversed.\n\t\t\tif ( text1.length > text2.length ) {\n\t\t\t\tdiffs[ 0 ][ 0 ] = diffs[ 2 ][ 0 ] = DIFF_DELETE;\n\t\t\t}\n\t\t\treturn diffs;\n\t\t}\n\n\t\tif ( shorttext.length === 1 ) {\n\n\t\t\t// Single character string.\n\t\t\t// After the previous speedup, the character can\'t be an equality.\n\t\t\treturn [\n\t\t\t\t[ DIFF_DELETE, text1 ],\n\t\t\t\t[ DIFF_INSERT, text2 ]\n\t\t\t];\n\t\t}\n\n\t\t// Check to see if the problem can be split in two.\n\t\thm = this.diffHalfMatch( text1, text2 );\n\t\tif ( hm ) {\n\n\t\t\t// A half-match was found, sort out the return data.\n\t\t\ttext1A = hm[ 0 ];\n\t\t\ttext1B = hm[ 1 ];\n\t\t\ttext2A = hm[ 2 ];\n\t\t\ttext2B = hm[ 3 ];\n\t\t\tmidCommon = hm[ 4 ];\n\n\t\t\t// Send both pairs off for separate processing.\n\t\t\tdiffsA = this.DiffMain( text1A, text2A, checklines, deadline );\n\t\t\tdiffsB = this.DiffMain( text1B, text2B, checklines, deadline );\n\n\t\t\t// Merge the results.\n\t\t\treturn diffsA.concat( [\n\t\t\t\t[ DIFF_EQUAL, midCommon ]\n\t\t\t], diffsB );\n\t\t}\n\n\t\tif ( checklines && text1.length > 100 && text2.length > 100 ) {\n\t\t\treturn this.diffLineMode( text1, text2, deadline );\n\t\t}\n\n\t\treturn this.diffBisect( text1, text2, deadline );\n\t};\n\n\t/**\n\t * Do the two texts share a substring which is at least half the length of the\n\t * longer text?\n\t * This speedup can produce non-minimal diffs.\n\t * @param {string} text1 First string.\n\t * @param {string} text2 Second string.\n\t * @return {Array.} Five element Array, containing the prefix of\n\t * text1, the suffix of text1, the prefix of text2, the suffix of\n\t * text2 and the common middle. Or null if there was no match.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffHalfMatch = function( text1, text2 ) {\n\t\tvar longtext, shorttext, dmp,\n\t\t\ttext1A, text2B, text2A, text1B, midCommon,\n\t\t\thm1, hm2, hm;\n\n\t\tlongtext = text1.length > text2.length ? text1 : text2;\n\t\tshorttext = text1.length > text2.length ? text2 : text1;\n\t\tif ( longtext.length < 4 || shorttext.length * 2 < longtext.length ) {\n\t\t\treturn null; // Pointless.\n\t\t}\n\t\tdmp = this; // \'this\' becomes \'window\' in a closure.\n\n\t\t/**\n\t\t * Does a substring of shorttext exist within longtext such that the substring\n\t\t * is at least half the length of longtext?\n\t\t * Closure, but does not reference any external variables.\n\t\t * @param {string} longtext Longer string.\n\t\t * @param {string} shorttext Shorter string.\n\t\t * @param {number} i Start index of quarter length substring within longtext.\n\t\t * @return {Array.} Five element Array, containing the prefix of\n\t\t * longtext, the suffix of longtext, the prefix of shorttext, the suffix\n\t\t * of shorttext and the common middle. Or null if there was no match.\n\t\t * @private\n\t\t */\n\t\tfunction diffHalfMatchI( longtext, shorttext, i ) {\n\t\t\tvar seed, j, bestCommon, prefixLength, suffixLength,\n\t\t\t\tbestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB;\n\n\t\t\t// Start with a 1/4 length substring at position i as a seed.\n\t\t\tseed = longtext.substring( i, i + Math.floor( longtext.length / 4 ) );\n\t\t\tj = -1;\n\t\t\tbestCommon = "";\n\t\t\twhile ( ( j = shorttext.indexOf( seed, j + 1 ) ) !== -1 ) {\n\t\t\t\tprefixLength = dmp.diffCommonPrefix( longtext.substring( i ),\n\t\t\t\t\tshorttext.substring( j ) );\n\t\t\t\tsuffixLength = dmp.diffCommonSuffix( longtext.substring( 0, i ),\n\t\t\t\t\tshorttext.substring( 0, j ) );\n\t\t\t\tif ( bestCommon.length < suffixLength + prefixLength ) {\n\t\t\t\t\tbestCommon = shorttext.substring( j - suffixLength, j ) +\n\t\t\t\t\t\tshorttext.substring( j, j + prefixLength );\n\t\t\t\t\tbestLongtextA = longtext.substring( 0, i - suffixLength );\n\t\t\t\t\tbestLongtextB = longtext.substring( i + prefixLength );\n\t\t\t\t\tbestShorttextA = shorttext.substring( 0, j - suffixLength );\n\t\t\t\t\tbestShorttextB = shorttext.substring( j + prefixLength );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( bestCommon.length * 2 >= longtext.length ) {\n\t\t\t\treturn [ bestLongtextA, bestLongtextB,\n\t\t\t\t\tbestShorttextA, bestShorttextB, bestCommon\n\t\t\t\t];\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// First check if the second quarter is the seed for a half-match.\n\t\thm1 = diffHalfMatchI( longtext, shorttext,\n\t\t\tMath.ceil( longtext.length / 4 ) );\n\n\t\t// Check again based on the third quarter.\n\t\thm2 = diffHalfMatchI( longtext, shorttext,\n\t\t\tMath.ceil( longtext.length / 2 ) );\n\t\tif ( !hm1 && !hm2 ) {\n\t\t\treturn null;\n\t\t} else if ( !hm2 ) {\n\t\t\thm = hm1;\n\t\t} else if ( !hm1 ) {\n\t\t\thm = hm2;\n\t\t} else {\n\n\t\t\t// Both matched. Select the longest.\n\t\t\thm = hm1[ 4 ].length > hm2[ 4 ].length ? hm1 : hm2;\n\t\t}\n\n\t\t// A half-match was found, sort out the return data.\n\t\ttext1A, text1B, text2A, text2B;\n\t\tif ( text1.length > text2.length ) {\n\t\t\ttext1A = hm[ 0 ];\n\t\t\ttext1B = hm[ 1 ];\n\t\t\ttext2A = hm[ 2 ];\n\t\t\ttext2B = hm[ 3 ];\n\t\t} else {\n\t\t\ttext2A = hm[ 0 ];\n\t\t\ttext2B = hm[ 1 ];\n\t\t\ttext1A = hm[ 2 ];\n\t\t\ttext1B = hm[ 3 ];\n\t\t}\n\t\tmidCommon = hm[ 4 ];\n\t\treturn [ text1A, text1B, text2A, text2B, midCommon ];\n\t};\n\n\t/**\n\t * Do a quick line-level diff on both strings, then rediff the parts for\n\t * greater accuracy.\n\t * This speedup can produce non-minimal diffs.\n\t * @param {string} text1 Old string to be diffed.\n\t * @param {string} text2 New string to be diffed.\n\t * @param {number} deadline Time when the diff should be complete by.\n\t * @return {!Array.} Array of diff tuples.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffLineMode = function( text1, text2, deadline ) {\n\t\tvar a, diffs, linearray, pointer, countInsert,\n\t\t\tcountDelete, textInsert, textDelete, j;\n\n\t\t// Scan the text on a line-by-line basis first.\n\t\ta = this.diffLinesToChars( text1, text2 );\n\t\ttext1 = a.chars1;\n\t\ttext2 = a.chars2;\n\t\tlinearray = a.lineArray;\n\n\t\tdiffs = this.DiffMain( text1, text2, false, deadline );\n\n\t\t// Convert the diff back to original text.\n\t\tthis.diffCharsToLines( diffs, linearray );\n\n\t\t// Eliminate freak matches (e.g. blank lines)\n\t\tthis.diffCleanupSemantic( diffs );\n\n\t\t// Rediff any replacement blocks, this time character-by-character.\n\t\t// Add a dummy entry at the end.\n\t\tdiffs.push( [ DIFF_EQUAL, "" ] );\n\t\tpointer = 0;\n\t\tcountDelete = 0;\n\t\tcountInsert = 0;\n\t\ttextDelete = "";\n\t\ttextInsert = "";\n\t\twhile ( pointer < diffs.length ) {\n\t\t\tswitch ( diffs[ pointer ][ 0 ] ) {\n\t\t\tcase DIFF_INSERT:\n\t\t\t\tcountInsert++;\n\t\t\t\ttextInsert += diffs[ pointer ][ 1 ];\n\t\t\t\tbreak;\n\t\t\tcase DIFF_DELETE:\n\t\t\t\tcountDelete++;\n\t\t\t\ttextDelete += diffs[ pointer ][ 1 ];\n\t\t\t\tbreak;\n\t\t\tcase DIFF_EQUAL:\n\n\t\t\t\t// Upon reaching an equality, check for prior redundancies.\n\t\t\t\tif ( countDelete >= 1 && countInsert >= 1 ) {\n\n\t\t\t\t\t// Delete the offending records and add the merged ones.\n\t\t\t\t\tdiffs.splice( pointer - countDelete - countInsert,\n\t\t\t\t\t\tcountDelete + countInsert );\n\t\t\t\t\tpointer = pointer - countDelete - countInsert;\n\t\t\t\t\ta = this.DiffMain( textDelete, textInsert, false, deadline );\n\t\t\t\t\tfor ( j = a.length - 1; j >= 0; j-- ) {\n\t\t\t\t\t\tdiffs.splice( pointer, 0, a[ j ] );\n\t\t\t\t\t}\n\t\t\t\t\tpointer = pointer + a.length;\n\t\t\t\t}\n\t\t\t\tcountInsert = 0;\n\t\t\t\tcountDelete = 0;\n\t\t\t\ttextDelete = "";\n\t\t\t\ttextInsert = "";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpointer++;\n\t\t}\n\t\tdiffs.pop(); // Remove the dummy entry at the end.\n\n\t\treturn diffs;\n\t};\n\n\t/**\n\t * Find the \'middle snake\' of a diff, split the problem in two\n\t * and return the recursively constructed diff.\n\t * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.\n\t * @param {string} text1 Old string to be diffed.\n\t * @param {string} text2 New string to be diffed.\n\t * @param {number} deadline Time at which to bail if not yet complete.\n\t * @return {!Array.} Array of diff tuples.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffBisect = function( text1, text2, deadline ) {\n\t\tvar text1Length, text2Length, maxD, vOffset, vLength,\n\t\t\tv1, v2, x, delta, front, k1start, k1end, k2start,\n\t\t\tk2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;\n\n\t\t// Cache the text lengths to prevent multiple calls.\n\t\ttext1Length = text1.length;\n\t\ttext2Length = text2.length;\n\t\tmaxD = Math.ceil( ( text1Length + text2Length ) / 2 );\n\t\tvOffset = maxD;\n\t\tvLength = 2 * maxD;\n\t\tv1 = new Array( vLength );\n\t\tv2 = new Array( vLength );\n\n\t\t// Setting all elements to -1 is faster in Chrome & Firefox than mixing\n\t\t// integers and undefined.\n\t\tfor ( x = 0; x < vLength; x++ ) {\n\t\t\tv1[ x ] = -1;\n\t\t\tv2[ x ] = -1;\n\t\t}\n\t\tv1[ vOffset + 1 ] = 0;\n\t\tv2[ vOffset + 1 ] = 0;\n\t\tdelta = text1Length - text2Length;\n\n\t\t// If the total number of characters is odd, then the front path will collide\n\t\t// with the reverse path.\n\t\tfront = ( delta % 2 !== 0 );\n\n\t\t// Offsets for start and end of k loop.\n\t\t// Prevents mapping of space beyond the grid.\n\t\tk1start = 0;\n\t\tk1end = 0;\n\t\tk2start = 0;\n\t\tk2end = 0;\n\t\tfor ( d = 0; d < maxD; d++ ) {\n\n\t\t\t// Bail out if deadline is reached.\n\t\t\tif ( ( new Date() ).getTime() > deadline ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Walk the front path one step.\n\t\t\tfor ( k1 = -d + k1start; k1 <= d - k1end; k1 += 2 ) {\n\t\t\t\tk1Offset = vOffset + k1;\n\t\t\t\tif ( k1 === -d || ( k1 !== d && v1[ k1Offset - 1 ] < v1[ k1Offset + 1 ] ) ) {\n\t\t\t\t\tx1 = v1[ k1Offset + 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tx1 = v1[ k1Offset - 1 ] + 1;\n\t\t\t\t}\n\t\t\t\ty1 = x1 - k1;\n\t\t\t\twhile ( x1 < text1Length && y1 < text2Length &&\n\t\t\t\t\ttext1.charAt( x1 ) === text2.charAt( y1 ) ) {\n\t\t\t\t\tx1++;\n\t\t\t\t\ty1++;\n\t\t\t\t}\n\t\t\t\tv1[ k1Offset ] = x1;\n\t\t\t\tif ( x1 > text1Length ) {\n\n\t\t\t\t\t// Ran off the right of the graph.\n\t\t\t\t\tk1end += 2;\n\t\t\t\t} else if ( y1 > text2Length ) {\n\n\t\t\t\t\t// Ran off the bottom of the graph.\n\t\t\t\t\tk1start += 2;\n\t\t\t\t} else if ( front ) {\n\t\t\t\t\tk2Offset = vOffset + delta - k1;\n\t\t\t\t\tif ( k2Offset >= 0 && k2Offset < vLength && v2[ k2Offset ] !== -1 ) {\n\n\t\t\t\t\t\t// Mirror x2 onto top-left coordinate system.\n\t\t\t\t\t\tx2 = text1Length - v2[ k2Offset ];\n\t\t\t\t\t\tif ( x1 >= x2 ) {\n\n\t\t\t\t\t\t\t// Overlap detected.\n\t\t\t\t\t\t\treturn this.diffBisectSplit( text1, text2, x1, y1, deadline );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Walk the reverse path one step.\n\t\t\tfor ( k2 = -d + k2start; k2 <= d - k2end; k2 += 2 ) {\n\t\t\t\tk2Offset = vOffset + k2;\n\t\t\t\tif ( k2 === -d || ( k2 !== d && v2[ k2Offset - 1 ] < v2[ k2Offset + 1 ] ) ) {\n\t\t\t\t\tx2 = v2[ k2Offset + 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tx2 = v2[ k2Offset - 1 ] + 1;\n\t\t\t\t}\n\t\t\t\ty2 = x2 - k2;\n\t\t\t\twhile ( x2 < text1Length && y2 < text2Length &&\n\t\t\t\t\ttext1.charAt( text1Length - x2 - 1 ) ===\n\t\t\t\t\ttext2.charAt( text2Length - y2 - 1 ) ) {\n\t\t\t\t\tx2++;\n\t\t\t\t\ty2++;\n\t\t\t\t}\n\t\t\t\tv2[ k2Offset ] = x2;\n\t\t\t\tif ( x2 > text1Length ) {\n\n\t\t\t\t\t// Ran off the left of the graph.\n\t\t\t\t\tk2end += 2;\n\t\t\t\t} else if ( y2 > text2Length ) {\n\n\t\t\t\t\t// Ran off the top of the graph.\n\t\t\t\t\tk2start += 2;\n\t\t\t\t} else if ( !front ) {\n\t\t\t\t\tk1Offset = vOffset + delta - k2;\n\t\t\t\t\tif ( k1Offset >= 0 && k1Offset < vLength && v1[ k1Offset ] !== -1 ) {\n\t\t\t\t\t\tx1 = v1[ k1Offset ];\n\t\t\t\t\t\ty1 = vOffset + x1 - k1Offset;\n\n\t\t\t\t\t\t// Mirror x2 onto top-left coordinate system.\n\t\t\t\t\t\tx2 = text1Length - x2;\n\t\t\t\t\t\tif ( x1 >= x2 ) {\n\n\t\t\t\t\t\t\t// Overlap detected.\n\t\t\t\t\t\t\treturn this.diffBisectSplit( text1, text2, x1, y1, deadline );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Diff took too long and hit the deadline or\n\t\t// number of diffs equals number of characters, no commonality at all.\n\t\treturn [\n\t\t\t[ DIFF_DELETE, text1 ],\n\t\t\t[ DIFF_INSERT, text2 ]\n\t\t];\n\t};\n\n\t/**\n\t * Given the location of the \'middle snake\', split the diff in two parts\n\t * and recurse.\n\t * @param {string} text1 Old string to be diffed.\n\t * @param {string} text2 New string to be diffed.\n\t * @param {number} x Index of split point in text1.\n\t * @param {number} y Index of split point in text2.\n\t * @param {number} deadline Time at which to bail if not yet complete.\n\t * @return {!Array.} Array of diff tuples.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffBisectSplit = function( text1, text2, x, y, deadline ) {\n\t\tvar text1a, text1b, text2a, text2b, diffs, diffsb;\n\t\ttext1a = text1.substring( 0, x );\n\t\ttext2a = text2.substring( 0, y );\n\t\ttext1b = text1.substring( x );\n\t\ttext2b = text2.substring( y );\n\n\t\t// Compute both diffs serially.\n\t\tdiffs = this.DiffMain( text1a, text2a, false, deadline );\n\t\tdiffsb = this.DiffMain( text1b, text2b, false, deadline );\n\n\t\treturn diffs.concat( diffsb );\n\t};\n\n\t/**\n\t * Reduce the number of edits by eliminating semantically trivial equalities.\n\t * @param {!Array.} diffs Array of diff tuples.\n\t */\n\tDiffMatchPatch.prototype.diffCleanupSemantic = function( diffs ) {\n\t\tvar changes, equalities, equalitiesLength, lastequality,\n\t\t\tpointer, lengthInsertions2, lengthDeletions2, lengthInsertions1,\n\t\t\tlengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;\n\t\tchanges = false;\n\t\tequalities = []; // Stack of indices where equalities are found.\n\t\tequalitiesLength = 0; // Keeping our own length var is faster in JS.\n\t\t/** @type {?string} */\n\t\tlastequality = null;\n\n\t\t// Always equal to diffs[equalities[equalitiesLength - 1]][1]\n\t\tpointer = 0; // Index of current position.\n\n\t\t// Number of characters that changed prior to the equality.\n\t\tlengthInsertions1 = 0;\n\t\tlengthDeletions1 = 0;\n\n\t\t// Number of characters that changed after the equality.\n\t\tlengthInsertions2 = 0;\n\t\tlengthDeletions2 = 0;\n\t\twhile ( pointer < diffs.length ) {\n\t\t\tif ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) { // Equality found.\n\t\t\t\tequalities[ equalitiesLength++ ] = pointer;\n\t\t\t\tlengthInsertions1 = lengthInsertions2;\n\t\t\t\tlengthDeletions1 = lengthDeletions2;\n\t\t\t\tlengthInsertions2 = 0;\n\t\t\t\tlengthDeletions2 = 0;\n\t\t\t\tlastequality = diffs[ pointer ][ 1 ];\n\t\t\t} else { // An insertion or deletion.\n\t\t\t\tif ( diffs[ pointer ][ 0 ] === DIFF_INSERT ) {\n\t\t\t\t\tlengthInsertions2 += diffs[ pointer ][ 1 ].length;\n\t\t\t\t} else {\n\t\t\t\t\tlengthDeletions2 += diffs[ pointer ][ 1 ].length;\n\t\t\t\t}\n\n\t\t\t\t// Eliminate an equality that is smaller or equal to the edits on both\n\t\t\t\t// sides of it.\n\t\t\t\tif ( lastequality && ( lastequality.length <=\n\t\t\t\t\t\tMath.max( lengthInsertions1, lengthDeletions1 ) ) &&\n\t\t\t\t\t\t( lastequality.length <= Math.max( lengthInsertions2,\n\t\t\t\t\t\t\tlengthDeletions2 ) ) ) {\n\n\t\t\t\t\t// Duplicate record.\n\t\t\t\t\tdiffs.splice(\n\t\t\t\t\t\tequalities[ equalitiesLength - 1 ],\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t[ DIFF_DELETE, lastequality ]\n\t\t\t\t\t);\n\n\t\t\t\t\t// Change second copy to insert.\n\t\t\t\t\tdiffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;\n\n\t\t\t\t\t// Throw away the equality we just deleted.\n\t\t\t\t\tequalitiesLength--;\n\n\t\t\t\t\t// Throw away the previous equality (it needs to be reevaluated).\n\t\t\t\t\tequalitiesLength--;\n\t\t\t\t\tpointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;\n\n\t\t\t\t\t// Reset the counters.\n\t\t\t\t\tlengthInsertions1 = 0;\n\t\t\t\t\tlengthDeletions1 = 0;\n\t\t\t\t\tlengthInsertions2 = 0;\n\t\t\t\t\tlengthDeletions2 = 0;\n\t\t\t\t\tlastequality = null;\n\t\t\t\t\tchanges = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpointer++;\n\t\t}\n\n\t\t// Normalize the diff.\n\t\tif ( changes ) {\n\t\t\tthis.diffCleanupMerge( diffs );\n\t\t}\n\n\t\t// Find any overlaps between deletions and insertions.\n\t\t// e.g: abcxxxxxxdef \n\t\t// -> abcxxxdef \n\t\t// e.g: xxxabcdefxxx \n\t\t// -> def xxxabc\n\t\t// Only extract an overlap if it is as big as the edit ahead or behind it.\n\t\tpointer = 1;\n\t\twhile ( pointer < diffs.length ) {\n\t\t\tif ( diffs[ pointer - 1 ][ 0 ] === DIFF_DELETE &&\n\t\t\t\t\tdiffs[ pointer ][ 0 ] === DIFF_INSERT ) {\n\t\t\t\tdeletion = diffs[ pointer - 1 ][ 1 ];\n\t\t\t\tinsertion = diffs[ pointer ][ 1 ];\n\t\t\t\toverlapLength1 = this.diffCommonOverlap( deletion, insertion );\n\t\t\t\toverlapLength2 = this.diffCommonOverlap( insertion, deletion );\n\t\t\t\tif ( overlapLength1 >= overlapLength2 ) {\n\t\t\t\t\tif ( overlapLength1 >= deletion.length / 2 ||\n\t\t\t\t\t\t\toverlapLength1 >= insertion.length / 2 ) {\n\n\t\t\t\t\t\t// Overlap found. Insert an equality and trim the surrounding edits.\n\t\t\t\t\t\tdiffs.splice(\n\t\t\t\t\t\t\tpointer,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t[ DIFF_EQUAL, insertion.substring( 0, overlapLength1 ) ]\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdiffs[ pointer - 1 ][ 1 ] =\n\t\t\t\t\t\t\tdeletion.substring( 0, deletion.length - overlapLength1 );\n\t\t\t\t\t\tdiffs[ pointer + 1 ][ 1 ] = insertion.substring( overlapLength1 );\n\t\t\t\t\t\tpointer++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif ( overlapLength2 >= deletion.length / 2 ||\n\t\t\t\t\t\t\toverlapLength2 >= insertion.length / 2 ) {\n\n\t\t\t\t\t\t// Reverse overlap found.\n\t\t\t\t\t\t// Insert an equality and swap and trim the surrounding edits.\n\t\t\t\t\t\tdiffs.splice(\n\t\t\t\t\t\t\tpointer,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t[ DIFF_EQUAL, deletion.substring( 0, overlapLength2 ) ]\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tdiffs[ pointer - 1 ][ 0 ] = DIFF_INSERT;\n\t\t\t\t\t\tdiffs[ pointer - 1 ][ 1 ] =\n\t\t\t\t\t\t\tinsertion.substring( 0, insertion.length - overlapLength2 );\n\t\t\t\t\t\tdiffs[ pointer + 1 ][ 0 ] = DIFF_DELETE;\n\t\t\t\t\t\tdiffs[ pointer + 1 ][ 1 ] =\n\t\t\t\t\t\t\tdeletion.substring( overlapLength2 );\n\t\t\t\t\t\tpointer++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpointer++;\n\t\t\t}\n\t\t\tpointer++;\n\t\t}\n\t};\n\n\t/**\n\t * Determine if the suffix of one string is the prefix of another.\n\t * @param {string} text1 First string.\n\t * @param {string} text2 Second string.\n\t * @return {number} The number of characters common to the end of the first\n\t * string and the start of the second string.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffCommonOverlap = function( text1, text2 ) {\n\t\tvar text1Length, text2Length, textLength,\n\t\t\tbest, length, pattern, found;\n\n\t\t// Cache the text lengths to prevent multiple calls.\n\t\ttext1Length = text1.length;\n\t\ttext2Length = text2.length;\n\n\t\t// Eliminate the null case.\n\t\tif ( text1Length === 0 || text2Length === 0 ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Truncate the longer string.\n\t\tif ( text1Length > text2Length ) {\n\t\t\ttext1 = text1.substring( text1Length - text2Length );\n\t\t} else if ( text1Length < text2Length ) {\n\t\t\ttext2 = text2.substring( 0, text1Length );\n\t\t}\n\t\ttextLength = Math.min( text1Length, text2Length );\n\n\t\t// Quick check for the worst case.\n\t\tif ( text1 === text2 ) {\n\t\t\treturn textLength;\n\t\t}\n\n\t\t// Start by looking for a single character match\n\t\t// and increase length until no match is found.\n\t\t// Performance analysis: https://neil.fraser.name/news/2010/11/04/\n\t\tbest = 0;\n\t\tlength = 1;\n\t\twhile ( true ) {\n\t\t\tpattern = text1.substring( textLength - length );\n\t\t\tfound = text2.indexOf( pattern );\n\t\t\tif ( found === -1 ) {\n\t\t\t\treturn best;\n\t\t\t}\n\t\t\tlength += found;\n\t\t\tif ( found === 0 || text1.substring( textLength - length ) ===\n\t\t\t\t\ttext2.substring( 0, length ) ) {\n\t\t\t\tbest = length;\n\t\t\t\tlength++;\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Split two texts into an array of strings. Reduce the texts to a string of\n\t * hashes where each Unicode character represents one line.\n\t * @param {string} text1 First string.\n\t * @param {string} text2 Second string.\n\t * @return {{chars1: string, chars2: string, lineArray: !Array.}}\n\t * An object containing the encoded text1, the encoded text2 and\n\t * the array of unique strings.\n\t * The zeroth element of the array of unique strings is intentionally blank.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffLinesToChars = function( text1, text2 ) {\n\t\tvar lineArray, lineHash, chars1, chars2;\n\t\tlineArray = []; // E.g. lineArray[4] === \'Hello\\n\'\n\t\tlineHash = {}; // E.g. lineHash[\'Hello\\n\'] === 4\n\n\t\t// \'\\x00\' is a valid character, but various debuggers don\'t like it.\n\t\t// So we\'ll insert a junk entry to avoid generating a null character.\n\t\tlineArray[ 0 ] = "";\n\n\t\t/**\n\t\t * Split a text into an array of strings. Reduce the texts to a string of\n\t\t * hashes where each Unicode character represents one line.\n\t\t * Modifies linearray and linehash through being a closure.\n\t\t * @param {string} text String to encode.\n\t\t * @return {string} Encoded string.\n\t\t * @private\n\t\t */\n\t\tfunction diffLinesToCharsMunge( text ) {\n\t\t\tvar chars, lineStart, lineEnd, lineArrayLength, line;\n\t\t\tchars = "";\n\n\t\t\t// Walk the text, pulling out a substring for each line.\n\t\t\t// text.split(\'\\n\') would would temporarily double our memory footprint.\n\t\t\t// Modifying text would create many large strings to garbage collect.\n\t\t\tlineStart = 0;\n\t\t\tlineEnd = -1;\n\n\t\t\t// Keeping our own length variable is faster than looking it up.\n\t\t\tlineArrayLength = lineArray.length;\n\t\t\twhile ( lineEnd < text.length - 1 ) {\n\t\t\t\tlineEnd = text.indexOf( "\\n", lineStart );\n\t\t\t\tif ( lineEnd === -1 ) {\n\t\t\t\t\tlineEnd = text.length - 1;\n\t\t\t\t}\n\t\t\t\tline = text.substring( lineStart, lineEnd + 1 );\n\t\t\t\tlineStart = lineEnd + 1;\n\n\t\t\t\tif ( lineHash.hasOwnProperty ? lineHash.hasOwnProperty( line ) :\n\t\t\t\t\t\t\t( lineHash[ line ] !== undefined ) ) {\n\t\t\t\t\tchars += String.fromCharCode( lineHash[ line ] );\n\t\t\t\t} else {\n\t\t\t\t\tchars += String.fromCharCode( lineArrayLength );\n\t\t\t\t\tlineHash[ line ] = lineArrayLength;\n\t\t\t\t\tlineArray[ lineArrayLength++ ] = line;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn chars;\n\t\t}\n\n\t\tchars1 = diffLinesToCharsMunge( text1 );\n\t\tchars2 = diffLinesToCharsMunge( text2 );\n\t\treturn {\n\t\t\tchars1: chars1,\n\t\t\tchars2: chars2,\n\t\t\tlineArray: lineArray\n\t\t};\n\t};\n\n\t/**\n\t * Rehydrate the text in a diff from a string of line hashes to real lines of\n\t * text.\n\t * @param {!Array.} diffs Array of diff tuples.\n\t * @param {!Array.} lineArray Array of unique strings.\n\t * @private\n\t */\n\tDiffMatchPatch.prototype.diffCharsToLines = function( diffs, lineArray ) {\n\t\tvar x, chars, text, y;\n\t\tfor ( x = 0; x < diffs.length; x++ ) {\n\t\t\tchars = diffs[ x ][ 1 ];\n\t\t\ttext = [];\n\t\t\tfor ( y = 0; y < chars.length; y++ ) {\n\t\t\t\ttext[ y ] = lineArray[ chars.charCodeAt( y ) ];\n\t\t\t}\n\t\t\tdiffs[ x ][ 1 ] = text.join( "" );\n\t\t}\n\t};\n\n\t/**\n\t * Reorder and merge like edit sections. Merge equalities.\n\t * Any edit section can move as long as it doesn\'t cross an equality.\n\t * @param {!Array.} diffs Array of diff tuples.\n\t */\n\tDiffMatchPatch.prototype.diffCleanupMerge = function( diffs ) {\n\t\tvar pointer, countDelete, countInsert, textInsert, textDelete,\n\t\t\tcommonlength, changes, diffPointer, position;\n\t\tdiffs.push( [ DIFF_EQUAL, "" ] ); // Add a dummy entry at the end.\n\t\tpointer = 0;\n\t\tcountDelete = 0;\n\t\tcountInsert = 0;\n\t\ttextDelete = "";\n\t\ttextInsert = "";\n\t\tcommonlength;\n\t\twhile ( pointer < diffs.length ) {\n\t\t\tswitch ( diffs[ pointer ][ 0 ] ) {\n\t\t\tcase DIFF_INSERT:\n\t\t\t\tcountInsert++;\n\t\t\t\ttextInsert += diffs[ pointer ][ 1 ];\n\t\t\t\tpointer++;\n\t\t\t\tbreak;\n\t\t\tcase DIFF_DELETE:\n\t\t\t\tcountDelete++;\n\t\t\t\ttextDelete += diffs[ pointer ][ 1 ];\n\t\t\t\tpointer++;\n\t\t\t\tbreak;\n\t\t\tcase DIFF_EQUAL:\n\n\t\t\t\t// Upon reaching an equality, check for prior redundancies.\n\t\t\t\tif ( countDelete + countInsert > 1 ) {\n\t\t\t\t\tif ( countDelete !== 0 && countInsert !== 0 ) {\n\n\t\t\t\t\t\t// Factor out any common prefixes.\n\t\t\t\t\t\tcommonlength = this.diffCommonPrefix( textInsert, textDelete );\n\t\t\t\t\t\tif ( commonlength !== 0 ) {\n\t\t\t\t\t\t\tif ( ( pointer - countDelete - countInsert ) > 0 &&\n\t\t\t\t\t\t\t\t\tdiffs[ pointer - countDelete - countInsert - 1 ][ 0 ] ===\n\t\t\t\t\t\t\t\t\tDIFF_EQUAL ) {\n\t\t\t\t\t\t\t\tdiffs[ pointer - countDelete - countInsert - 1 ][ 1 ] +=\n\t\t\t\t\t\t\t\t\ttextInsert.substring( 0, commonlength );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdiffs.splice( 0, 0, [ DIFF_EQUAL,\n\t\t\t\t\t\t\t\t\ttextInsert.substring( 0, commonlength )\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\tpointer++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttextInsert = textInsert.substring( commonlength );\n\t\t\t\t\t\t\ttextDelete = textDelete.substring( commonlength );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Factor out any common suffixies.\n\t\t\t\t\t\tcommonlength = this.diffCommonSuffix( textInsert, textDelete );\n\t\t\t\t\t\tif ( commonlength !== 0 ) {\n\t\t\t\t\t\t\tdiffs[ pointer ][ 1 ] = textInsert.substring( textInsert.length -\n\t\t\t\t\t\t\t\t\tcommonlength ) + diffs[ pointer ][ 1 ];\n\t\t\t\t\t\t\ttextInsert = textInsert.substring( 0, textInsert.length -\n\t\t\t\t\t\t\t\tcommonlength );\n\t\t\t\t\t\t\ttextDelete = textDelete.substring( 0, textDelete.length -\n\t\t\t\t\t\t\t\tcommonlength );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Delete the offending records and add the merged ones.\n\t\t\t\t\tif ( countDelete === 0 ) {\n\t\t\t\t\t\tdiffs.splice( pointer - countInsert,\n\t\t\t\t\t\t\tcountDelete + countInsert, [ DIFF_INSERT, textInsert ] );\n\t\t\t\t\t} else if ( countInsert === 0 ) {\n\t\t\t\t\t\tdiffs.splice( pointer - countDelete,\n\t\t\t\t\t\t\tcountDelete + countInsert, [ DIFF_DELETE, textDelete ] );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdiffs.splice(\n\t\t\t\t\t\t\tpointer - countDelete - countInsert,\n\t\t\t\t\t\t\tcountDelete + countInsert,\n\t\t\t\t\t\t\t[ DIFF_DELETE, textDelete ], [ DIFF_INSERT, textInsert ]\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tpointer = pointer - countDelete - countInsert +\n\t\t\t\t\t\t( countDelete ? 1 : 0 ) + ( countInsert ? 1 : 0 ) + 1;\n\t\t\t\t} else if ( pointer !== 0 && diffs[ pointer - 1 ][ 0 ] === DIFF_EQUAL ) {\n\n\t\t\t\t\t// Merge this equality with the previous one.\n\t\t\t\t\tdiffs[ pointer - 1 ][ 1 ] += diffs[ pointer ][ 1 ];\n\t\t\t\t\tdiffs.splice( pointer, 1 );\n\t\t\t\t} else {\n\t\t\t\t\tpointer++;\n\t\t\t\t}\n\t\t\t\tcountInsert = 0;\n\t\t\t\tcountDelete = 0;\n\t\t\t\ttextDelete = "";\n\t\t\t\ttextInsert = "";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( diffs[ diffs.length - 1 ][ 1 ] === "" ) {\n\t\t\tdiffs.pop(); // Remove the dummy entry at the end.\n\t\t}\n\n\t\t// Second pass: look for single edits surrounded on both sides by equalities\n\t\t// which can be shifted sideways to eliminate an equality.\n\t\t// e.g: ABA C -> AB AC\n\t\tchanges = false;\n\t\tpointer = 1;\n\n\t\t// Intentionally ignore the first and last element (don\'t need checking).\n\t\twhile ( pointer < diffs.length - 1 ) {\n\t\t\tif ( diffs[ pointer - 1 ][ 0 ] === DIFF_EQUAL &&\n\t\t\t\t\tdiffs[ pointer + 1 ][ 0 ] === DIFF_EQUAL ) {\n\n\t\t\t\tdiffPointer = diffs[ pointer ][ 1 ];\n\t\t\t\tposition = diffPointer.substring(\n\t\t\t\t\tdiffPointer.length - diffs[ pointer - 1 ][ 1 ].length\n\t\t\t\t);\n\n\t\t\t\t// This is a single edit surrounded by equalities.\n\t\t\t\tif ( position === diffs[ pointer - 1 ][ 1 ] ) {\n\n\t\t\t\t\t// Shift the edit over the previous equality.\n\t\t\t\t\tdiffs[ pointer ][ 1 ] = diffs[ pointer - 1 ][ 1 ] +\n\t\t\t\t\t\tdiffs[ pointer ][ 1 ].substring( 0, diffs[ pointer ][ 1 ].length -\n\t\t\t\t\t\t\tdiffs[ pointer - 1 ][ 1 ].length );\n\t\t\t\t\tdiffs[ pointer + 1 ][ 1 ] =\n\t\t\t\t\t\tdiffs[ pointer - 1 ][ 1 ] + diffs[ pointer + 1 ][ 1 ];\n\t\t\t\t\tdiffs.splice( pointer - 1, 1 );\n\t\t\t\t\tchanges = true;\n\t\t\t\t} else if ( diffPointer.substring( 0, diffs[ pointer + 1 ][ 1 ].length ) ===\n\t\t\t\t\t\tdiffs[ pointer + 1 ][ 1 ] ) {\n\n\t\t\t\t\t// Shift the edit over the next equality.\n\t\t\t\t\tdiffs[ pointer - 1 ][ 1 ] += diffs[ pointer + 1 ][ 1 ];\n\t\t\t\t\tdiffs[ pointer ][ 1 ] =\n\t\t\t\t\t\tdiffs[ pointer ][ 1 ].substring( diffs[ pointer + 1 ][ 1 ].length ) +\n\t\t\t\t\t\tdiffs[ pointer + 1 ][ 1 ];\n\t\t\t\t\tdiffs.splice( pointer + 1, 1 );\n\t\t\t\t\tchanges = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpointer++;\n\t\t}\n\n\t\t// If shifts were made, the diff needs reordering and another shift sweep.\n\t\tif ( changes ) {\n\t\t\tthis.diffCleanupMerge( diffs );\n\t\t}\n\t};\n\n\treturn function( o, n ) {\n\t\tvar diff, output, text;\n\t\tdiff = new DiffMatchPatch();\n\t\toutput = diff.DiffMain( o, n );\n\t\tdiff.diffCleanupEfficiency( output );\n\t\ttext = diff.diffPrettyHtml( output );\n\n\t\treturn text;\n\t};\n}() );\n\n}() );\n';
+ loader.global.define = undefined;
+ loader.global.module = undefined;
+ loader.global.exports = undefined;
+ loader.__exec({
+ 'source': source,
+ 'address': module.uri
+ });
+ loader.global.require = require;
+ loader.global.define = define;
+ return loader.get('@@global-helpers').retrieveGlobal(module.id, 'QUnit');
+});
+/*$css*/
+define('$css', function (require, exports, module) {
+ var loader = require('@loader');
+ var isNode = typeof process === 'object' && {}.toString.call(process) === '[object process]';
+ var importRegEx = /@import [^uU]['"]?([^'"\)]*)['"]?/g;
+ var resourceRegEx = /url\(['"]?([^'"\)]*)['"]?\)/g;
+ var waitSeconds = loader.cssOptions && loader.cssOptions.timeout ? parseInt(loader.cssOptions.timeout, 10) : 60;
+ var noop = function () {
+ };
+ var onloadCss = function (link, cb) {
+ var styleSheets = document.styleSheets, i = styleSheets.length;
+ while (i--) {
+ if (styleSheets[i].href === link.href) {
+ return cb();
+ }
+ }
+ setTimeout(function () {
+ onloadCss(link, cb);
+ });
+ };
+ if (isProduction()) {
+ exports.fetch = function (load) {
+ var styleSheets = document.styleSheets;
+ return new Promise(function (resolve, reject) {
+ var timeout = setTimeout(function () {
+ reject('Unable to load CSS');
+ }, waitSeconds * 1000);
+ for (var i = 0; i < styleSheets.length; ++i) {
+ if (load.address === styleSheets[i].href) {
+ resolve('');
+ return;
+ }
+ }
+ var link = document.createElement('link');
+ link.type = 'text/css';
+ link.rel = 'stylesheet';
+ link.href = load.address;
+ var loadCB = function (event) {
+ clearTimeout(timeout);
+ link.removeEventListener('load', loadCB);
+ link.removeEventListener('error', loadCB);
+ if (event && event.type === 'error') {
+ reject('Unable to load CSS');
+ } else {
+ resolve('');
+ }
+ };
+ if ('isApplicationInstalled' in navigator || !link.addEventListener) {
+ onloadCss(link, loadCB);
+ } else {
+ link.addEventListener('load', loadCB);
+ link.addEventListener('error', loadCB);
+ }
+ document.head.appendChild(link);
+ if (document.styleSheets.length === 0) {
+ loadCB();
+ }
+ });
+ };
+ } else {
+ exports.instantiate = function (load) {
+ var loader = this;
+ load.source = load.source.replace(importRegEx, function (whole, part) {
+ if (isNode) {
+ return '@import url(' + part + ')';
+ } else {
+ return '@import url(' + steal.joinURIs(load.address, part) + ')';
+ }
+ });
+ load.metadata.deps = [];
+ load.metadata.execute = function () {
+ var source = load.source + '/*# sourceURL=' + load.address + ' */';
+ source = source.replace(resourceRegEx, function (whole, part) {
+ return 'url(' + steal.joinURIs(load.address, part) + ')';
+ });
+ if (load.source && typeof document !== 'undefined') {
+ var doc = document.head ? document : document.getElementsByTagName ? document : document.documentElement;
+ var head = doc.head || doc.getElementsByTagName('head')[0], style = document.createElement('style');
+ if (!head) {
+ var docEl = doc.documentElement || doc;
+ head = document.createElement('head');
+ docEl.insertBefore(head, docEl.firstChild);
+ }
+ style.type = 'text/css';
+ if (style.styleSheet) {
+ style.styleSheet.cssText = source;
+ } else {
+ style.appendChild(document.createTextNode(source));
+ }
+ head.appendChild(style);
+ if (loader.has('live-reload')) {
+ var cssReload = loader['import']('live-reload', { name: '$css' });
+ Promise.resolve(cssReload).then(function (reload) {
+ loader['import'](load.name).then(function () {
+ reload.once(load.name, function () {
+ head.removeChild(style);
+ });
+ });
+ });
+ }
+ }
+ return System.newModule({ source: source });
+ };
+ load.metadata.format = 'css';
+ };
+ }
+ function isProduction() {
+ return loader.isEnv && loader.isEnv('production') || loader.env === 'production';
+ }
+ exports.locateScheme = true;
+ exports.buildType = 'css';
+ exports.includeInBuild = true;
+});
+/*steal-qunit@0.1.4#steal-qunit*/
+'format amd';
+define('steal-qunit@0.1.4#steal-qunit', [
+ '@loader',
+ 'qunitjs/qunit/qunit',
+ 'qunitjs/qunit/qunit.css!'
+], function (loader, QUnit) {
+ if (loader.has('live-reload')) {
+ setupLiveReload();
+ }
+ setupSauceLabsReporting();
+ function setupLiveReload() {
+ QUnit.done(updateResults);
+ function updateResults() {
+ var tests = document.getElementById('qunit-tests').children;
+ var node, passed = true;
+ for (var i = 0, len = tests.length; i < len; i++) {
+ node = tests.item(i);
+ removeAllButLast(node, 'runtime');
+ if (node.className !== 'pass') {
+ passed = false;
+ break;
+ }
+ }
+ document.getElementById('qunit-banner').className = passed ? 'qunit-pass' : 'qunit-fail';
+ }
+ function removeAllButLast(parent, className) {
+ var node, nodes = [];
+ var children = parent.children;
+ for (var i = 0, len = children.length; i < len; i++) {
+ node = children.item(i);
+ if (node.className === className)
+ nodes.push(node);
+ }
+ while (nodes.length > 1) {
+ node = nodes.shift();
+ parent.removeChild(node);
+ }
+ }
+ }
+ function setupSauceLabsReporting() {
+ var log = [];
+ QUnit.done(function (test_results) {
+ var tests = [];
+ for (var i = 0, len = log.length; i < len; i++) {
+ var details = log[i];
+ tests.push({
+ name: details.name,
+ result: details.result,
+ expected: details.expected,
+ actual: details.actual,
+ source: details.source
+ });
+ }
+ test_results.tests = tests;
+ window.global_test_results = test_results;
+ });
+ QUnit.testStart(function (testDetails) {
+ QUnit.log(function (details) {
+ if (!details.result) {
+ details.name = testDetails.name;
+ log.push(details);
+ }
+ });
+ });
+ }
+ QUnit.config.autorun = false;
+ steal.done().then(function () {
+ if (window.Testee && window.Testee.init) {
+ Testee.init();
+ }
+ QUnit.load();
+ });
+ return QUnit;
+});
+/*can-util@3.0.10#js/defaults/defaults*/
+define('can-util@3.0.10#js/defaults/defaults', function (require, exports, module) {
+ module.exports = function (target) {
+ var length = arguments.length;
+ for (var i = 1; i < length; i++) {
+ for (var prop in arguments[i]) {
+ if (target[prop] === undefined) {
+ target[prop] = arguments[i][prop];
+ }
+ }
+ }
+ return target;
+ };
+});
+/*can-define@1.0.4#can-define*/
+define('can-define@1.0.4#can-define', function (require, exports, module) {
+ 'use strict';
+ 'format cjs';
+ var event = require('can-event');
+ var eventLifecycle = require('can-event/lifecycle/lifecycle');
+ var canBatch = require('can-event/batch/batch');
+ var canEvent = require('can-event');
+ var compute = require('can-compute');
+ var Observation = require('can-observation');
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ var assign = require('can-util/js/assign/assign');
+ var dev = require('can-util/js/dev/dev');
+ var CID = require('can-util/js/cid/cid');
+ var isPlainObject = require('can-util/js/is-plain-object/is-plain-object');
+ var isArray = require('can-util/js/is-array/is-array');
+ var types = require('can-util/js/types/types');
+ var each = require('can-util/js/each/each');
+ var defaults = require('can-util/js/defaults/defaults');
+ var ns = require('can-util/namespace');
+ var eventsProto, define, make, makeDefinition, replaceWith, getDefinitionsAndMethods, isDefineType, getDefinitionOrMethod;
+ var defineConfigurableAndNotEnumerable = function (obj, prop, value) {
+ Object.defineProperty(obj, prop, {
+ configurable: true,
+ enumerable: false,
+ writable: true,
+ value: value
+ });
+ };
+ var eachPropertyDescriptor = function (map, cb) {
+ for (var prop in map) {
+ if (map.hasOwnProperty(prop)) {
+ cb(prop, Object.getOwnPropertyDescriptor(map, prop));
+ }
+ }
+ };
+ module.exports = define = ns.define = function (objPrototype, defines, baseDefine) {
+ var dataInitializers = Object.create(baseDefine ? baseDefine.dataInitializers : null), computedInitializers = Object.create(baseDefine ? baseDefine.computedInitializers : null);
+ var result = getDefinitionsAndMethods(defines, baseDefine);
+ result.dataInitializers = dataInitializers;
+ result.computedInitializers = computedInitializers;
+ each(result.definitions, function (definition, property) {
+ define.property(objPrototype, property, definition, dataInitializers, computedInitializers);
+ });
+ replaceWith(objPrototype, '_data', function () {
+ var map = this;
+ var data = {};
+ for (var prop in dataInitializers) {
+ replaceWith(data, prop, dataInitializers[prop].bind(map), true);
+ }
+ return data;
+ });
+ replaceWith(objPrototype, '_computed', function () {
+ var map = this;
+ var data = {};
+ for (var prop in computedInitializers) {
+ replaceWith(data, prop, computedInitializers[prop].bind(map));
+ }
+ return data;
+ });
+ for (var prop in eventsProto) {
+ Object.defineProperty(objPrototype, prop, {
+ enumerable: false,
+ value: eventsProto[prop],
+ configurable: true,
+ writable: true
+ });
+ }
+ Object.defineProperty(objPrototype, '_define', {
+ enumerable: false,
+ value: result,
+ configurable: true,
+ writable: true
+ });
+ if (!objPrototype[types.iterator]) {
+ defineConfigurableAndNotEnumerable(objPrototype, types.iterator, function () {
+ return new define.Iterator(this);
+ });
+ }
+ return result;
+ };
+ define.extensions = function () {
+ };
+ define.property = function (objPrototype, prop, definition, dataInitializers, computedInitializers) {
+ var propertyDefinition = define.extensions.apply(this, arguments);
+ if (propertyDefinition) {
+ definition = propertyDefinition;
+ }
+ var type = definition.type;
+ delete definition.type;
+ if (type && isEmptyObject(definition) && type === define.types['*']) {
+ definition.type = type;
+ Object.defineProperty(objPrototype, prop, {
+ get: make.get.data(prop),
+ set: make.set.events(prop, make.get.data(prop), make.set.data(prop), make.eventType.data(prop)),
+ enumerable: true
+ });
+ return;
+ }
+ definition.type = type;
+ var dataProperty = definition.get ? 'computed' : 'data', reader = make.read[dataProperty](prop), getter = make.get[dataProperty](prop), setter = make.set[dataProperty](prop), getInitialValue;
+ var typeConvert = function (val) {
+ return val;
+ };
+ if (definition.Type) {
+ typeConvert = make.set.Type(prop, definition.Type, typeConvert);
+ }
+ if (type) {
+ typeConvert = make.set.type(prop, type, typeConvert);
+ }
+ if (definition.value !== undefined || definition.Value !== undefined) {
+ getInitialValue = make.get.defaultValue(prop, definition, typeConvert);
+ }
+ if (definition.get) {
+ computedInitializers[prop] = make.compute(prop, definition.get, getInitialValue);
+ } else if (getInitialValue) {
+ dataInitializers[prop] = getInitialValue;
+ }
+ if (definition.get && definition.set) {
+ setter = make.set.setter(prop, definition.set, make.read.lastSet(prop), setter, true);
+ } else if (definition.set) {
+ setter = make.set.events(prop, reader, setter, make.eventType[dataProperty](prop));
+ setter = make.set.setter(prop, definition.set, reader, setter, false);
+ } else if (!definition.get) {
+ setter = make.set.events(prop, reader, setter, make.eventType[dataProperty](prop));
+ }
+ if (type) {
+ setter = make.set.type(prop, type, setter);
+ }
+ if (definition.Type) {
+ setter = make.set.Type(prop, definition.Type, setter);
+ }
+ Object.defineProperty(objPrototype, prop, {
+ get: getter,
+ set: setter,
+ enumerable: 'serialize' in definition ? !!definition.serialize : !definition.get
+ });
+ };
+ define.Constructor = function (defines) {
+ var constructor = function (props) {
+ define.setup.call(this, props);
+ };
+ define(constructor.prototype, defines);
+ return constructor;
+ };
+ make = {
+ compute: function (prop, get, defaultValueFn) {
+ return function () {
+ var map = this, defaultValue = defaultValueFn && defaultValueFn.call(this), computeFn;
+ if (defaultValue) {
+ computeFn = defaultValue.isComputed ? defaultValue : compute.async(defaultValue, get, map);
+ } else {
+ computeFn = compute.async(defaultValue, get, map);
+ }
+ return {
+ compute: computeFn,
+ count: 0,
+ handler: function (ev, newVal, oldVal) {
+ canEvent.dispatch.call(map, {
+ type: prop,
+ target: map
+ }, [
+ newVal,
+ oldVal
+ ]);
+ }
+ };
+ };
+ },
+ set: {
+ data: function (prop) {
+ return function (newVal) {
+ this._data[prop] = newVal;
+ };
+ },
+ computed: function (prop) {
+ return function (val) {
+ this._computed[prop].compute(val);
+ };
+ },
+ events: function (prop, getCurrent, setData, eventType) {
+ return function (newVal) {
+ var current = getCurrent.call(this);
+ if (newVal !== current) {
+ setData.call(this, newVal);
+ canEvent.dispatch.call(this, {
+ type: prop,
+ target: this
+ }, [
+ newVal,
+ current
+ ]);
+ }
+ };
+ },
+ setter: function (prop, setter, getCurrent, setEvents, hasGetter) {
+ return function (value) {
+ var self = this;
+ canBatch.start();
+ var setterCalled = false, current = getCurrent.call(this), setValue = setter.call(this, value, function (value) {
+ setEvents.call(self, value);
+ setterCalled = true;
+ }, current);
+ if (setterCalled) {
+ canBatch.stop();
+ } else {
+ if (hasGetter) {
+ if (setValue !== undefined) {
+ if (current !== setValue) {
+ setEvents.call(this, setValue);
+ }
+ canBatch.stop();
+ } else if (setter.length === 0) {
+ setEvents.call(this, value);
+ canBatch.stop();
+ return;
+ } else if (setter.length === 1) {
+ canBatch.stop();
+ } else {
+ canBatch.stop();
+ return;
+ }
+ } else {
+ if (setValue !== undefined) {
+ setEvents.call(this, setValue);
+ canBatch.stop();
+ } else if (setter.length === 0) {
+ setEvents.call(this, value);
+ canBatch.stop();
+ return;
+ } else if (setter.length === 1) {
+ setEvents.call(this, undefined);
+ canBatch.stop();
+ } else {
+ canBatch.stop();
+ return;
+ }
+ }
+ }
+ };
+ },
+ type: function (prop, type, set) {
+ if (typeof type === 'object') {
+ return make.set.Type(prop, type, set);
+ } else {
+ return function (newValue) {
+ return set.call(this, type.call(this, newValue, prop));
+ };
+ }
+ },
+ Type: function (prop, Type, set) {
+ if (isArray(Type) && types.DefineList) {
+ Type = types.DefineList.extend({ '#': Type[0] });
+ } else if (typeof Type === 'object') {
+ if (types.DefineMap) {
+ Type = types.DefineMap.extend(Type);
+ } else {
+ Type = define.constructor(Type);
+ }
+ }
+ return function (newValue) {
+ if (newValue instanceof Type || newValue == null) {
+ return set.call(this, newValue);
+ } else {
+ return set.call(this, new Type(newValue));
+ }
+ };
+ }
+ },
+ eventType: {
+ data: function (prop) {
+ return function (newVal, oldVal) {
+ return oldVal !== undefined || this._data.hasOwnProperty(prop) ? 'set' : 'add';
+ };
+ },
+ computed: function () {
+ return function () {
+ return 'set';
+ };
+ }
+ },
+ read: {
+ data: function (prop) {
+ return function () {
+ return this._data[prop];
+ };
+ },
+ computed: function (prop) {
+ return function () {
+ return this._computed[prop].compute();
+ };
+ },
+ lastSet: function (prop) {
+ return function () {
+ var lastSetValue = this._computed[prop].compute.computeInstance.lastSetValue;
+ return lastSetValue && lastSetValue.get();
+ };
+ }
+ },
+ get: {
+ defaultValue: function (prop, definition, typeConvert) {
+ return function () {
+ var value = definition.value;
+ if (value !== undefined) {
+ if (typeof value === 'function') {
+ value = value.call(this);
+ }
+ return typeConvert(value);
+ }
+ var Value = definition.Value;
+ if (Value) {
+ return typeConvert(new Value());
+ }
+ };
+ },
+ data: function (prop) {
+ return function () {
+ Observation.add(this, prop);
+ return this._data[prop];
+ };
+ },
+ computed: function (prop) {
+ return function () {
+ return this._computed[prop].compute();
+ };
+ }
+ }
+ };
+ define.behaviors = [
+ 'get',
+ 'set',
+ 'value',
+ 'Value',
+ 'type',
+ 'Type',
+ 'serialize'
+ ];
+ var addDefinition = function (definition, behavior, value) {
+ if (behavior === 'type') {
+ var behaviorDef = value;
+ if (typeof behaviorDef === 'string') {
+ behaviorDef = define.types[behaviorDef];
+ if (typeof behaviorDef === 'object') {
+ assign(definition, behaviorDef);
+ behaviorDef = behaviorDef[behavior];
+ }
+ }
+ definition[behavior] = behaviorDef;
+ } else {
+ definition[behavior] = value;
+ }
+ };
+ makeDefinition = function (prop, def, defaultDefinition) {
+ var definition = {};
+ each(def, function (value, behavior) {
+ addDefinition(definition, behavior, value);
+ });
+ each(defaultDefinition, function (value, prop) {
+ if (definition[prop] === undefined) {
+ if (prop !== 'type' && prop !== 'Type') {
+ definition[prop] = value;
+ }
+ }
+ });
+ if (!definition.type && !definition.Type) {
+ defaults(definition, defaultDefinition);
+ }
+ if (isEmptyObject(definition)) {
+ definition.type = define.types['*'];
+ }
+ return definition;
+ };
+ getDefinitionOrMethod = function (prop, value, defaultDefinition) {
+ var definition;
+ if (typeof value === 'string') {
+ definition = { type: value };
+ } else if (typeof value === 'function') {
+ if (types.isConstructor(value)) {
+ definition = { Type: value };
+ } else if (isDefineType(value)) {
+ definition = { type: value };
+ }
+ } else if (isArray(value)) {
+ definition = { Type: value };
+ } else if (isPlainObject(value)) {
+ definition = value;
+ }
+ if (definition) {
+ return makeDefinition(prop, definition, defaultDefinition);
+ } else {
+ return value;
+ }
+ };
+ getDefinitionsAndMethods = function (defines, baseDefines) {
+ var definitions = Object.create(baseDefines ? baseDefines.definitions : null);
+ var methods = {};
+ var defaults = defines['*'], defaultDefinition;
+ if (defaults) {
+ delete defines['*'];
+ defaultDefinition = getDefinitionOrMethod('*', defaults, {});
+ } else {
+ defaultDefinition = {};
+ }
+ eachPropertyDescriptor(defines, function (prop, propertyDescriptor) {
+ var value;
+ if (propertyDescriptor.get || propertyDescriptor.set) {
+ value = {
+ get: propertyDescriptor.get,
+ set: propertyDescriptor.set
+ };
+ } else {
+ value = propertyDescriptor.value;
+ }
+ if (prop === 'constructor') {
+ methods[prop] = value;
+ return;
+ } else {
+ var result = getDefinitionOrMethod(prop, value, defaultDefinition);
+ if (result && typeof result === 'object') {
+ definitions[prop] = result;
+ } else {
+ methods[prop] = result;
+ }
+ }
+ });
+ if (defaults) {
+ defines['*'] = defaults;
+ }
+ return {
+ definitions: definitions,
+ methods: methods,
+ defaultDefinition: defaultDefinition
+ };
+ };
+ replaceWith = function (obj, prop, cb, writable) {
+ Object.defineProperty(obj, prop, {
+ configurable: true,
+ get: function () {
+ var value = cb.call(this, obj, prop);
+ Object.defineProperty(this, prop, {
+ value: value,
+ writable: !!writable
+ });
+ return value;
+ }
+ });
+ };
+ eventsProto = assign({}, event);
+ assign(eventsProto, {
+ _eventSetup: function () {
+ },
+ _eventTeardown: function () {
+ },
+ addEventListener: function (eventName, handler) {
+ var computedBinding = this._computed && this._computed[eventName];
+ if (computedBinding && computedBinding.compute) {
+ if (!computedBinding.count) {
+ computedBinding.count = 1;
+ computedBinding.compute.addEventListener('change', computedBinding.handler);
+ } else {
+ computedBinding.count++;
+ }
+ }
+ return eventLifecycle.addAndSetup.apply(this, arguments);
+ },
+ removeEventListener: function (eventName, handler) {
+ var computedBinding = this._computed && this._computed[eventName];
+ if (computedBinding) {
+ if (computedBinding.count === 1) {
+ computedBinding.count = 0;
+ computedBinding.compute.removeEventListener('change', computedBinding.handler);
+ } else {
+ computedBinding.count--;
+ }
+ }
+ return eventLifecycle.removeAndTeardown.apply(this, arguments);
+ }
+ });
+ eventsProto.on = eventsProto.bind = eventsProto.addEventListener;
+ eventsProto.off = eventsProto.unbind = eventsProto.removeEventListener;
+ delete eventsProto.one;
+ define.setup = function (props, sealed) {
+ defineConfigurableAndNotEnumerable(this, '_cid');
+ defineConfigurableAndNotEnumerable(this, '__bindEvents', {});
+ defineConfigurableAndNotEnumerable(this, '_bindings', 0);
+ CID(this);
+ var definitions = this._define.definitions;
+ var instanceDefinitions = {};
+ var map = this;
+ each(props, function (value, prop) {
+ if (definitions[prop]) {
+ map[prop] = value;
+ } else {
+ var def = define.makeSimpleGetterSetter(prop);
+ instanceDefinitions[prop] = {};
+ Object.defineProperty(map, prop, def);
+ map[prop] = define.types.observable(value);
+ }
+ });
+ if (!isEmptyObject(instanceDefinitions)) {
+ defineConfigurableAndNotEnumerable(this, '_instanceDefinitions', instanceDefinitions);
+ }
+ };
+ define.replaceWith = replaceWith;
+ define.eventsProto = eventsProto;
+ define.defineConfigurableAndNotEnumerable = defineConfigurableAndNotEnumerable;
+ define.make = make;
+ define.getDefinitionOrMethod = getDefinitionOrMethod;
+ var simpleGetterSetters = {};
+ define.makeSimpleGetterSetter = function (prop) {
+ if (!simpleGetterSetters[prop]) {
+ var setter = make.set.events(prop, make.get.data(prop), make.set.data(prop), make.eventType.data(prop));
+ simpleGetterSetters[prop] = {
+ get: make.get.data(prop),
+ set: function (newVal) {
+ return setter.call(this, define.types.observable(newVal));
+ },
+ enumerable: true
+ };
+ }
+ return simpleGetterSetters[prop];
+ };
+ define.Iterator = function (obj) {
+ this.obj = obj;
+ this.definitions = Object.keys(obj._define.definitions);
+ this.instanceDefinitions = obj._instanceDefinitions ? Object.keys(obj._instanceDefinitions) : Object.keys(obj);
+ this.hasGet = typeof obj.get === 'function';
+ };
+ define.Iterator.prototype.next = function () {
+ var key;
+ if (this.definitions.length) {
+ key = this.definitions.shift();
+ var def = this.obj._define.definitions[key];
+ if (def.get) {
+ return this.next();
+ }
+ } else if (this.instanceDefinitions.length) {
+ key = this.instanceDefinitions.shift();
+ } else {
+ return {
+ value: undefined,
+ done: true
+ };
+ }
+ return {
+ value: [
+ key,
+ this.hasGet ? this.obj.get(key) : this.obj[key]
+ ],
+ done: false
+ };
+ };
+ isDefineType = function (func) {
+ return func && func.canDefineType === true;
+ };
+ define.types = {
+ 'date': function (str) {
+ var type = typeof str;
+ if (type === 'string') {
+ str = Date.parse(str);
+ return isNaN(str) ? null : new Date(str);
+ } else if (type === 'number') {
+ return new Date(str);
+ } else {
+ return str;
+ }
+ },
+ 'number': function (val) {
+ if (val == null) {
+ return val;
+ }
+ return +val;
+ },
+ 'boolean': function (val) {
+ if (val == null) {
+ return val;
+ }
+ if (val === 'false' || val === '0' || !val) {
+ return false;
+ }
+ return true;
+ },
+ 'observable': function (newVal) {
+ if (isArray(newVal) && types.DefineList) {
+ newVal = new types.DefineList(newVal);
+ } else if (isPlainObject(newVal) && types.DefineMap) {
+ newVal = new types.DefineMap(newVal);
+ }
+ return newVal;
+ },
+ 'stringOrObservable': function (newVal) {
+ if (isArray(newVal)) {
+ return new types.DefaultList(newVal);
+ } else if (isPlainObject(newVal)) {
+ return new types.DefaultMap(newVal);
+ } else {
+ return define.types.string(newVal);
+ }
+ },
+ 'htmlbool': function (val) {
+ return typeof val === 'string' || !!val;
+ },
+ '*': function (val) {
+ return val;
+ },
+ 'any': function (val) {
+ return val;
+ },
+ 'string': function (val) {
+ if (val == null) {
+ return val;
+ }
+ return '' + val;
+ },
+ 'compute': {
+ set: function (newValue, setVal, setErr, oldValue) {
+ if (newValue && newValue.isComputed) {
+ return newValue;
+ }
+ if (oldValue && oldValue.isComputed) {
+ oldValue(newValue);
+ return oldValue;
+ }
+ return newValue;
+ },
+ get: function (value) {
+ return value && value.isComputed ? value() : value;
+ }
+ }
+ };
+});
+/*can-define@1.0.4#define-helpers/define-helpers*/
+define('can-define@1.0.4#define-helpers/define-helpers', function (require, exports, module) {
+ var assign = require('can-util/js/assign/assign');
+ var CID = require('can-util/js/cid/cid');
+ var define = require('can-define');
+ var canBatch = require('can-event/batch/batch');
+ var canEvent = require('can-event');
+ var hasMethod = function (obj, method) {
+ return obj && typeof obj === 'object' && method in obj;
+ };
+ var defineHelpers = {
+ extendedSetup: function (props) {
+ assign(this, props);
+ },
+ toObject: function (map, props, where, Type) {
+ if (props instanceof Type) {
+ props.each(function (value, prop) {
+ where[prop] = value;
+ });
+ return where;
+ } else {
+ return props;
+ }
+ },
+ defineExpando: function (map, prop, value) {
+ var constructorDefines = map._define.definitions;
+ if (constructorDefines && constructorDefines[prop]) {
+ return;
+ }
+ var instanceDefines = map._instanceDefinitions;
+ if (!instanceDefines) {
+ instanceDefines = map._instanceDefinitions = {};
+ }
+ if (!instanceDefines[prop]) {
+ var defaultDefinition = map._define.defaultDefinition || { type: define.types.observable };
+ define.property(map, prop, defaultDefinition, {}, {});
+ map._data[prop] = defaultDefinition.type ? defaultDefinition.type(value) : define.types.observable(value);
+ instanceDefines[prop] = defaultDefinition;
+ canBatch.start();
+ canEvent.dispatch.call(map, {
+ type: '__keys',
+ target: map
+ });
+ if (map._data[prop] !== undefined) {
+ canEvent.dispatch.call(map, {
+ type: prop,
+ target: map
+ }, [
+ map._data[prop],
+ undefined
+ ]);
+ }
+ canBatch.stop();
+ return true;
+ }
+ },
+ getValue: function (map, name, val, how) {
+ if (how === 'serialize') {
+ var constructorDefinitions = map._define.definitions;
+ var propDef = constructorDefinitions[name];
+ if (propDef && typeof propDef.serialize === 'function') {
+ return propDef.serialize.call(map, val, name);
+ }
+ var defaultDefinition = map._define.defaultDefinition;
+ if (defaultDefinition && typeof defaultDefinition.serialize === 'function') {
+ return defaultDefinition.serialize.call(map, val, name);
+ }
+ }
+ if (hasMethod(val, how)) {
+ return val[how]();
+ } else {
+ return val;
+ }
+ },
+ serialize: function () {
+ var serializeMap = null;
+ return function (map, how, where) {
+ var cid = CID(map), firstSerialize = false;
+ if (!serializeMap) {
+ firstSerialize = true;
+ serializeMap = {
+ get: {},
+ serialize: {}
+ };
+ }
+ serializeMap[how][cid] = where;
+ map.each(function (val, name) {
+ var result, isObservable = hasMethod(val, how), serialized = isObservable && serializeMap[how][CID(val)];
+ if (serialized) {
+ result = serialized;
+ } else {
+ result = defineHelpers.getValue(map, name, val, how);
+ }
+ if (result !== undefined) {
+ where[name] = result;
+ }
+ });
+ if (firstSerialize) {
+ serializeMap = null;
+ }
+ return where;
+ };
+ }()
+ };
+ module.exports = defineHelpers;
+});
+/*can-define@1.0.4#map/map*/
+define('can-define@1.0.4#map/map', function (require, exports, module) {
+ var Construct = require('can-construct');
+ var define = require('can-define');
+ var assign = require('can-util/js/assign/assign');
+ var isArray = require('can-util/js/is-array/is-array');
+ var isPlainObject = require('can-util/js/is-plain-object/is-plain-object');
+ var defineHelpers = require('../define-helpers/define-helpers');
+ var Observation = require('can-observation');
+ var types = require('can-util/js/types/types');
+ var canBatch = require('can-event/batch/batch');
+ var ns = require('can-util/namespace');
+ var readWithoutObserve = Observation.ignore(function (map, prop) {
+ return map[prop];
+ });
+ var eachDefinition = function (map, cb, thisarg, definitions, observe) {
+ for (var prop in definitions) {
+ var definition = definitions[prop];
+ if (typeof definition !== 'object' || ('serialize' in definition ? !!definition.serialize : !definition.get)) {
+ var item = observe === false ? readWithoutObserve(map, prop) : map[prop];
+ if (cb.call(thisarg || item, item, prop, map) === false) {
+ return false;
+ }
+ }
+ }
+ };
+ var setProps = function (props, remove) {
+ props = assign({}, props);
+ var prop, self = this, newVal;
+ canBatch.start();
+ this.each(function (curVal, prop) {
+ if (prop === '_cid') {
+ return;
+ }
+ newVal = props[prop];
+ if (newVal === undefined) {
+ if (remove) {
+ self[prop] = undefined;
+ }
+ return;
+ }
+ if (typeof curVal !== 'object' || curVal === null) {
+ self.set(prop, newVal);
+ } else if ('set' in curVal && isPlainObject(newVal)) {
+ curVal.set(newVal, remove);
+ } else if ('attr' in curVal && (isPlainObject(newVal) || isArray(newVal))) {
+ curVal.attr(newVal, remove);
+ } else if ('replace' in curVal && isArray(newVal)) {
+ curVal.replace(newVal);
+ } else if (curVal !== newVal) {
+ self.set(prop, newVal);
+ }
+ delete props[prop];
+ }, this, false);
+ for (prop in props) {
+ if (prop !== '_cid') {
+ newVal = props[prop];
+ this.set(prop, newVal);
+ }
+ }
+ canBatch.stop();
+ return this;
+ };
+ var DefineMap = Construct.extend('DefineMap', {
+ setup: function (base) {
+ if (DefineMap) {
+ var prototype = this.prototype;
+ define(prototype, prototype, base.prototype._define);
+ this.prototype.setup = function (props) {
+ define.setup.call(this, defineHelpers.toObject(this, props, {}, DefineMap), this.constructor.seal);
+ };
+ }
+ }
+ }, {
+ setup: function (props, sealed) {
+ if (!this._define) {
+ Object.defineProperty(this, '_define', {
+ enumerable: false,
+ value: { definitions: {} }
+ });
+ Object.defineProperty(this, '_data', {
+ enumerable: false,
+ value: {}
+ });
+ }
+ define.setup.call(this, defineHelpers.toObject(this, props, {}, DefineMap), sealed === true);
+ },
+ get: function (prop) {
+ if (prop) {
+ var value = this[prop];
+ if (value !== undefined || prop in this || Object.isSealed(this)) {
+ return value;
+ } else {
+ Observation.add(this, prop);
+ return this[prop];
+ }
+ } else {
+ return defineHelpers.serialize(this, 'get', {});
+ }
+ },
+ set: function (prop, value) {
+ if (typeof prop === 'object') {
+ return setProps.call(this, prop, value);
+ }
+ var defined = defineHelpers.defineExpando(this, prop, value);
+ if (!defined) {
+ this[prop] = value;
+ }
+ return this;
+ },
+ serialize: function () {
+ return defineHelpers.serialize(this, 'serialize', {});
+ },
+ forEach: function (cb, thisarg, observe) {
+ if (observe !== false) {
+ Observation.add(this, '__keys');
+ }
+ var res;
+ var constructorDefinitions = this._define.definitions;
+ if (constructorDefinitions) {
+ res = eachDefinition(this, cb, thisarg, constructorDefinitions, observe);
+ }
+ if (res === false) {
+ return this;
+ }
+ if (this._instanceDefinitions) {
+ eachDefinition(this, cb, thisarg, this._instanceDefinitions, observe);
+ }
+ return this;
+ },
+ '*': { type: define.types.observable }
+ });
+ for (var prop in define.eventsProto) {
+ Object.defineProperty(DefineMap.prototype, prop, {
+ enumerable: false,
+ value: define.eventsProto[prop]
+ });
+ }
+ types.DefineMap = DefineMap;
+ types.DefaultMap = DefineMap;
+ DefineMap.prototype.toObject = function () {
+ console.warn('Use DefineMap::get instead of DefineMap::toObject');
+ return this.get();
+ };
+ DefineMap.prototype.each = DefineMap.prototype.forEach;
+ var oldIsMapLike = types.isMapLike;
+ types.isMapLike = function (obj) {
+ return obj instanceof DefineMap || oldIsMapLike.apply(this, arguments);
+ };
+ module.exports = ns.DefineMap = DefineMap;
+});
+/*can-component@3.0.2#test/component-define-test*/
+define('can-component@3.0.2#test/component-define-test', function (require, exports, module) {
+ var Component = require('can-component');
+ var stache = require('can-stache');
+ var QUnit = require('steal-qunit');
+ var define = require('can-define');
+ var DefineMap = require('can-define/map/map');
+ var viewModel = require('can-view-model');
+ var types = require('can-util/js/types/types');
+ QUnit.module('can-component with can-define');
+ QUnit.test('Works with can-define', function () {
+ var VM = define.Constructor({
+ firstName: { type: 'string' },
+ lastName: { type: 'string' },
+ fullName: {
+ get: function () {
+ return [
+ this.firstName,
+ this.lastName
+ ].join(' ');
+ }
+ }
+ });
+ Component.extend({
+ tag: 'can-define-component',
+ ViewModel: VM,
+ template: stache('Name: {{fullName}}')
+ });
+ var frag = stache(' ')({
+ firstName: 'Chris',
+ lastName: 'Gomez'
+ });
+ var vm = viewModel(frag.firstChild);
+ QUnit.ok(vm instanceof VM, 'Constructor was called');
+ QUnit.equal(vm.firstName, 'Chris', 'ViewModel was set from scope');
+ QUnit.equal(vm.lastName, 'Gomez', 'ViewModel was set from scope');
+ QUnit.equal(frag.firstChild.innerHTML, 'Name: Chris Gomez', 'Rendered fullName');
+ vm.firstName = 'Justin';
+ vm.lastName = 'Meyer';
+ QUnit.equal(frag.firstChild.innerHTML, 'Name: Justin Meyer', 'Rendered fullName after change');
+ });
+ QUnit.test('scope method works', function () {
+ Component.extend({
+ tag: 'my-element',
+ viewModel: function (properties, scope, element) {
+ QUnit.deepEqual(properties, {
+ first: 'Justin',
+ last: 'Meyer'
+ });
+ return new types.DefaultMap(properties);
+ }
+ });
+ stache('')({
+ firstName: 'Justin',
+ middleName: 'Barry'
+ });
+ });
+ QUnit.test('33 - works when instantiated with an object for ViewModel', function () {
+ Component.extend({
+ tag: 'test-element',
+ template: stache('{{someMethod}}'),
+ ViewModel: {
+ someMethod: function () {
+ ok(true, 'Function got called');
+ return true;
+ }
+ }
+ });
+ var template = stache('');
+ template();
+ });
+});
+/*can-map@3.0.2#bubble*/
+define('can-map@3.0.2#bubble', function (require, exports, module) {
+ var canEvent = require('can-event');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var types = require('can-util/js/types/types');
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ var bubble = {
+ bind: function (parent, eventName) {
+ if (!parent.__inSetup) {
+ var bubbleEvents = bubble.events(parent, eventName), len = bubbleEvents.length, bubbleEvent;
+ if (!parent._bubbleBindings) {
+ parent._bubbleBindings = {};
+ }
+ for (var i = 0; i < len; i++) {
+ bubbleEvent = bubbleEvents[i];
+ if (!parent._bubbleBindings[bubbleEvent]) {
+ parent._bubbleBindings[bubbleEvent] = 1;
+ bubble.childrenOf(parent, bubbleEvent);
+ } else {
+ parent._bubbleBindings[bubbleEvent]++;
+ }
+ }
+ }
+ },
+ unbind: function (parent, eventName) {
+ var bubbleEvents = bubble.events(parent, eventName), len = bubbleEvents.length, bubbleEvent;
+ for (var i = 0; i < len; i++) {
+ bubbleEvent = bubbleEvents[i];
+ if (parent._bubbleBindings) {
+ parent._bubbleBindings[bubbleEvent]--;
+ }
+ if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) {
+ delete parent._bubbleBindings[bubbleEvent];
+ bubble.teardownChildrenFrom(parent, bubbleEvent);
+ if (isEmptyObject(parent._bubbleBindings)) {
+ delete parent._bubbleBindings;
+ }
+ }
+ }
+ },
+ add: function (parent, child, prop) {
+ if (types.isMapLike(child) && parent._bubbleBindings) {
+ for (var eventName in parent._bubbleBindings) {
+ if (parent._bubbleBindings[eventName]) {
+ bubble.teardownFromParent(parent, child, eventName);
+ bubble.toParent(child, parent, prop, eventName);
+ }
+ }
+ }
+ },
+ addMany: function (parent, children) {
+ for (var i = 0, len = children.length; i < len; i++) {
+ bubble.add(parent, children[i], i);
+ }
+ },
+ remove: function (parent, child) {
+ if (types.isMapLike(child) && parent._bubbleBindings) {
+ for (var eventName in parent._bubbleBindings) {
+ if (parent._bubbleBindings[eventName]) {
+ bubble.teardownFromParent(parent, child, eventName);
+ }
+ }
+ }
+ },
+ removeMany: function (parent, children) {
+ for (var i = 0, len = children.length; i < len; i++) {
+ bubble.remove(parent, children[i]);
+ }
+ },
+ set: function (parent, prop, value, current) {
+ if (types.isMapLike(value)) {
+ bubble.add(parent, value, prop);
+ }
+ if (types.isMapLike(current)) {
+ bubble.remove(parent, current);
+ }
+ return value;
+ },
+ events: function (map, boundEventName) {
+ return map.constructor._bubbleRule(boundEventName, map);
+ },
+ toParent: function (child, parent, prop, eventName) {
+ canEvent.listenTo.call(parent, child, eventName, function () {
+ var args = makeArray(arguments), ev = args.shift();
+ args[0] = (types.isListLike(parent) ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : '');
+ ev.triggeredNS = ev.triggeredNS || {};
+ if (ev.triggeredNS[parent._cid]) {
+ return;
+ }
+ ev.triggeredNS[parent._cid] = true;
+ canEvent.dispatch.call(parent, ev, args);
+ if (eventName === 'change') {
+ canEvent.dispatch.call(parent, args[0], [
+ args[2],
+ args[3]
+ ]);
+ }
+ });
+ },
+ childrenOf: function (parent, eventName) {
+ parent._each(function (child, prop) {
+ if (child && child.bind) {
+ bubble.toParent(child, parent, prop, eventName);
+ }
+ });
+ },
+ teardownFromParent: function (parent, child, eventName) {
+ if (child && child.unbind) {
+ canEvent.stopListening.call(parent, child, eventName);
+ }
+ },
+ teardownChildrenFrom: function (parent, eventName) {
+ parent._each(function (child) {
+ bubble.teardownFromParent(parent, child, eventName);
+ });
+ },
+ isBubbling: function (parent, eventName) {
+ return parent._bubbleBindings && parent._bubbleBindings[eventName];
+ }
+ };
+ module.exports = bubble;
+});
+/*can-map@3.0.2#map-helpers*/
+define('can-map@3.0.2#map-helpers', function (require, exports, module) {
+ var isPlainObject = require('can-util/js/is-plain-object/is-plain-object');
+ var isArray = require('can-util/js/is-array/is-array');
+ var isPromise = require('can-util/js/is-promise/is-promise');
+ var CID = require('can-util/js/cid/cid');
+ var types = require('can-util/js/types/types');
+ var assign = require('can-util/js/assign/assign');
+ var madeMap = null;
+ var teardownMap = function () {
+ for (var cid in madeMap) {
+ if (madeMap[cid].added) {
+ delete madeMap[cid].obj._cid;
+ }
+ }
+ madeMap = null;
+ };
+ var mapHelpers = {
+ attrParts: function (attr, keepKey) {
+ if (keepKey) {
+ return [attr];
+ }
+ return typeof attr === 'object' ? attr : ('' + attr).split('.');
+ },
+ canMakeObserve: function (obj) {
+ return obj && !isPromise(obj) && (isArray(obj) || isPlainObject(obj));
+ },
+ serialize: function () {
+ var serializeMap = null;
+ return function (map, how, where) {
+ var cid = CID(map), firstSerialize = false;
+ if (!serializeMap) {
+ firstSerialize = true;
+ serializeMap = {
+ attr: {},
+ serialize: {}
+ };
+ }
+ serializeMap[how][cid] = where;
+ map.each(function (val, name) {
+ var result, isObservable = types.isMapLike(val), serialized = isObservable && serializeMap[how][CID(val)];
+ if (serialized) {
+ result = serialized;
+ } else {
+ if (map['___' + how]) {
+ result = map['___' + how](name, val);
+ } else {
+ result = mapHelpers.getValue(map, name, val, how);
+ }
+ }
+ if (result !== undefined) {
+ where[name] = result;
+ }
+ });
+ if (firstSerialize) {
+ serializeMap = null;
+ }
+ return where;
+ };
+ }(),
+ getValue: function (map, name, val, how) {
+ if (types.isMapLike(val)) {
+ return val[how]();
+ } else {
+ return val;
+ }
+ },
+ define: null,
+ addComputedAttr: function (map, attrName, compute) {
+ map._computedAttrs[attrName] = {
+ compute: compute,
+ count: 0,
+ handler: function (ev, newVal, oldVal) {
+ map._triggerChange(attrName, 'set', newVal, oldVal, ev.batchNum);
+ }
+ };
+ },
+ addToMap: function addToMap(obj, instance) {
+ var teardown;
+ if (!madeMap) {
+ teardown = teardownMap;
+ madeMap = {};
+ }
+ var hasCid = obj._cid;
+ var cid = CID(obj);
+ if (!madeMap[cid]) {
+ madeMap[cid] = {
+ obj: obj,
+ instance: instance,
+ added: !hasCid
+ };
+ }
+ return teardown;
+ },
+ getMapFromObject: function (obj) {
+ return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance;
+ },
+ twoLevelDeepExtend: function (destination, source) {
+ for (var prop in source) {
+ destination[prop] = destination[prop] || {};
+ assign(destination[prop], source[prop]);
+ }
+ }
+ };
+ module.exports = exports = mapHelpers;
+});
+/*can-map@3.0.2#can-map*/
+define('can-map@3.0.2#can-map', function (require, exports, module) {
+ var bubble = require('./bubble');
+ var mapHelpers = require('./map-helpers');
+ var canEvent = require('can-event');
+ var canBatch = require('can-event/batch/batch');
+ var eventLifecycle = require('can-event/lifecycle/lifecycle');
+ var Construct = require('can-construct');
+ var Observation = require('can-observation');
+ var ObserveReader = require('can-observation/reader/reader');
+ var canCompute = require('can-compute');
+ var namespace = require('can-util/namespace');
+ var dev = require('can-util/js/dev/dev');
+ var CID = require('can-util/js/cid/cid');
+ var deepAssign = require('can-util/js/deep-assign/deep-assign');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var assign = require('can-util/js/assign/assign');
+ var types = require('can-util/js/types/types');
+ var isArray = require('can-util/js/is-array/is-array');
+ var unobservable = { 'constructor': true };
+ var Map = Construct.extend({
+ setup: function (baseMap) {
+ Construct.setup.apply(this, arguments);
+ this._computedPropertyNames = [];
+ if (Map) {
+ if (!this.defaults) {
+ this.defaults = {};
+ }
+ for (var prop in this.prototype) {
+ if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof Construct)) {
+ this.defaults[prop] = this.prototype[prop];
+ } else if (this.prototype[prop].isComputed) {
+ this._computedPropertyNames.push(prop);
+ }
+ }
+ if (mapHelpers.define) {
+ mapHelpers.define(this, baseMap.prototype.define);
+ }
+ }
+ },
+ shortName: 'Map',
+ _bubbleRule: function (eventName) {
+ return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : [];
+ },
+ addEventListener: eventLifecycle.addAndSetup,
+ removeEventListener: eventLifecycle.removeAndTeardown,
+ keys: function (map) {
+ var keys = [];
+ Observation.add(map, '__keys');
+ for (var keyName in map._data) {
+ keys.push(keyName);
+ }
+ return keys;
+ }
+ }, {
+ setup: function (obj) {
+ if (obj instanceof Map) {
+ obj = obj.serialize();
+ }
+ this._data = {};
+ CID(this, '.map');
+ this._setupComputedProperties();
+ var teardownMapping = obj && mapHelpers.addToMap(obj, this);
+ var defaultValues = this._setupDefaults(obj);
+ var data = assign(deepAssign(true, {}, defaultValues), obj);
+ this.attr(data);
+ if (teardownMapping) {
+ teardownMapping();
+ }
+ },
+ _setupComputedProperties: function () {
+ this._computedAttrs = {};
+ var computes = this.constructor._computedPropertyNames;
+ for (var i = 0, len = computes.length; i < len; i++) {
+ var attrName = computes[i];
+ mapHelpers.addComputedAttr(this, attrName, this[attrName].clone(this));
+ }
+ },
+ _setupDefaults: function () {
+ return this.constructor.defaults || {};
+ },
+ attr: function (attr, val) {
+ var type = typeof attr;
+ if (attr === undefined) {
+ return this._getAttrs();
+ } else if (type !== 'string' && type !== 'number') {
+ return this._setAttrs(attr, val);
+ } else if (arguments.length === 1) {
+ return this._get(attr + '');
+ } else {
+ this._set(attr + '', val);
+ return this;
+ }
+ },
+ _get: function (attr) {
+ var dotIndex = attr.indexOf('.');
+ if (dotIndex >= 0) {
+ var value = this.___get(attr);
+ if (value !== undefined) {
+ Observation.add(this, attr);
+ return value;
+ }
+ var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1);
+ var current = this.__get(first);
+ return current && current._get ? current._get(second) : undefined;
+ } else {
+ return this.__get(attr);
+ }
+ },
+ __get: function (attr) {
+ if (!unobservable[attr] && !this._computedAttrs[attr]) {
+ Observation.add(this, attr);
+ }
+ return this.___get(attr);
+ },
+ ___get: function (attr) {
+ if (attr !== undefined) {
+ var computedAttr = this._computedAttrs[attr];
+ if (computedAttr && computedAttr.compute) {
+ return computedAttr.compute();
+ } else {
+ return this._data.hasOwnProperty(attr) ? this._data[attr] : undefined;
+ }
+ } else {
+ return this._data;
+ }
+ },
+ _set: function (attr, value, keepKey) {
+ var dotIndex = attr.indexOf('.'), current;
+ if (dotIndex >= 0 && !keepKey) {
+ var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1);
+ current = this.__inSetup ? undefined : this.___get(first);
+ if (types.isMapLike(current)) {
+ current._set(second, value);
+ } else {
+ throw new Error('can-map: Object does not exist');
+ }
+ } else {
+ current = this.__inSetup ? undefined : this.___get(attr);
+ if (this.__convert) {
+ value = this.__convert(attr, value);
+ }
+ this.__set(attr, this.__type(value, attr), current);
+ }
+ },
+ __type: function (value, prop) {
+ if (typeof value === 'object' && !types.isMapLike(value) && mapHelpers.canMakeObserve(value) && !isArray(value)) {
+ var cached = mapHelpers.getMapFromObject(value);
+ if (cached) {
+ return cached;
+ }
+ var MapConstructor = this.constructor.Map || Map;
+ return new MapConstructor(value);
+ }
+ return value;
+ },
+ __set: function (prop, value, current) {
+ if (value !== current) {
+ var computedAttr = this._computedAttrs[prop];
+ var changeType = computedAttr || current !== undefined || this.___get().hasOwnProperty(prop) ? 'set' : 'add';
+ this.___set(prop, typeof value === 'object' ? bubble.set(this, prop, value, current) : value);
+ if (!computedAttr || !computedAttr.count) {
+ this._triggerChange(prop, changeType, value, current);
+ }
+ if (typeof current === 'object') {
+ bubble.teardownFromParent(this, current);
+ }
+ }
+ },
+ ___set: function (prop, val) {
+ var computedAttr = this._computedAttrs[prop];
+ if (computedAttr) {
+ computedAttr.compute(val);
+ } else {
+ this._data[prop] = val;
+ }
+ if (typeof this.constructor.prototype[prop] !== 'function' && !computedAttr) {
+ this[prop] = val;
+ }
+ },
+ removeAttr: function (attr) {
+ return this._remove(attr);
+ },
+ _remove: function (attr) {
+ var parts = mapHelpers.attrParts(attr), prop = parts.shift(), current = this.___get(prop);
+ if (parts.length && current) {
+ return current.removeAttr(parts);
+ } else {
+ if (typeof attr === 'string' && !!~attr.indexOf('.')) {
+ prop = attr;
+ }
+ this.__remove(prop, current);
+ return current;
+ }
+ },
+ __remove: function (prop, current) {
+ if (prop in this._data) {
+ this.___remove(prop);
+ this._triggerChange(prop, 'remove', undefined, current);
+ }
+ },
+ ___remove: function (prop) {
+ delete this._data[prop];
+ if (!(prop in this.constructor.prototype)) {
+ delete this[prop];
+ }
+ },
+ ___serialize: function (name, val) {
+ return mapHelpers.getValue(this, name, val, 'serialize');
+ },
+ _getAttrs: function () {
+ return mapHelpers.serialize(this, 'attr', {});
+ },
+ _setAttrs: function (props, remove) {
+ props = assign({}, props);
+ var prop, self = this, newVal;
+ canBatch.start();
+ this._each(function (curVal, prop) {
+ if (prop === '_cid') {
+ return;
+ }
+ newVal = props[prop];
+ if (newVal === undefined) {
+ if (remove) {
+ self.removeAttr(prop);
+ }
+ return;
+ }
+ if (self.__convert) {
+ newVal = self.__convert(prop, newVal);
+ }
+ if (types.isMapLike(curVal) && mapHelpers.canMakeObserve(newVal)) {
+ curVal.attr(newVal, remove);
+ } else if (curVal !== newVal) {
+ self.__set(prop, self.__type(newVal, prop), curVal);
+ }
+ delete props[prop];
+ });
+ for (prop in props) {
+ if (prop !== '_cid') {
+ newVal = props[prop];
+ this._set(prop, newVal, true);
+ }
+ }
+ canBatch.stop();
+ return this;
+ },
+ serialize: function () {
+ return mapHelpers.serialize(this, 'serialize', {});
+ },
+ _triggerChange: function (attr, how, newVal, oldVal, batchNum) {
+ if (bubble.isBubbling(this, 'change')) {
+ canEvent.dispatch.call(this, {
+ type: 'change',
+ target: this,
+ batchNum: batchNum
+ }, [
+ attr,
+ how,
+ newVal,
+ oldVal
+ ]);
+ }
+ canEvent.dispatch.call(this, {
+ type: attr,
+ target: this,
+ batchNum: batchNum
+ }, [
+ newVal,
+ oldVal
+ ]);
+ if (how === 'remove' || how === 'add') {
+ canEvent.dispatch.call(this, {
+ type: '__keys',
+ target: this,
+ batchNum: batchNum
+ });
+ }
+ },
+ _eventSetup: function () {
+ },
+ _eventTeardown: function () {
+ },
+ one: canEvent.one,
+ addEventListener: function (eventName, handler) {
+ var computedBinding = this._computedAttrs && this._computedAttrs[eventName];
+ if (computedBinding && computedBinding.compute) {
+ if (!computedBinding.count) {
+ computedBinding.count = 1;
+ computedBinding.compute.addEventListener('change', computedBinding.handler);
+ } else {
+ computedBinding.count++;
+ }
+ }
+ bubble.bind(this, eventName);
+ return eventLifecycle.addAndSetup.apply(this, arguments);
+ },
+ removeEventListener: function (eventName, handler) {
+ var computedBinding = this._computedAttrs && this._computedAttrs[eventName];
+ if (computedBinding) {
+ if (computedBinding.count === 1) {
+ computedBinding.count = 0;
+ computedBinding.compute.removeEventListener('change', computedBinding.handler);
+ } else {
+ computedBinding.count--;
+ }
+ }
+ bubble.unbind(this, eventName);
+ return eventLifecycle.removeAndTeardown.apply(this, arguments);
+ },
+ compute: function (prop) {
+ if (isFunction(this.constructor.prototype[prop])) {
+ return canCompute(this[prop], this);
+ } else {
+ var reads = ObserveReader.reads(prop);
+ var last = reads.length - 1;
+ return canCompute(function (newVal) {
+ if (arguments.length) {
+ ObserveReader.write(this, reads[last].key, newVal);
+ } else {
+ return ObserveReader.get(this, prop);
+ }
+ }, this);
+ }
+ },
+ each: function (callback, context) {
+ var key, item;
+ var keys = Map.keys(this);
+ for (var i = 0, len = keys.length; i < len; i++) {
+ key = keys[i];
+ item = this.attr(key);
+ if (callback.call(context || item, item, key, this) === false) {
+ break;
+ }
+ }
+ return this;
+ },
+ _each: function (callback) {
+ var data = this.___get();
+ for (var prop in data) {
+ if (data.hasOwnProperty(prop)) {
+ callback(data[prop], prop);
+ }
+ }
+ },
+ dispatch: canEvent.dispatch
+ });
+ Map.prototype.on = Map.prototype.bind = Map.prototype.addEventListener;
+ Map.prototype.off = Map.prototype.unbind = Map.prototype.removeEventListener;
+ Map.on = Map.bind = Map.addEventListener;
+ Map.off = Map.unbind = Map.removeEventListener;
+ var oldIsMapLike = types.isMapLike;
+ types.isMapLike = function (obj) {
+ if (obj instanceof Map) {
+ return true;
+ } else {
+ return oldIsMapLike.call(this, obj);
+ }
+ };
+ if (!types.DefaultMap) {
+ types.DefaultMap = Map;
+ }
+ module.exports = namespace.Map = Map;
+});
+/*can-list@3.0.0#can-list*/
+define('can-list@3.0.0#can-list', function (require, exports, module) {
+ require('can-event');
+ var namespace = require('can-util/namespace');
+ var Map = require('can-map');
+ var bubble = require('can-map/bubble');
+ var mapHelpers = require('can-map/map-helpers');
+ var canBatch = require('can-event/batch/batch');
+ var canEvent = require('can-event');
+ var Observation = require('can-observation');
+ var CID = require('can-util/js/cid/cid');
+ var isPromise = require('can-util/js/is-promise/is-promise');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var assign = require('can-util/js/assign/assign');
+ var types = require('can-util/js/types/types');
+ var each = require('can-util/js/each/each');
+ var splice = [].splice, spliceRemovesProps = function () {
+ var obj = {
+ 0: 'a',
+ length: 1
+ };
+ splice.call(obj, 0, 1);
+ return !obj[0];
+ }();
+ var serializeNonTypes = function (MapType, arg, args) {
+ if (arg && arg.serialize && !(arg instanceof MapType)) {
+ args.push(new MapType(arg.serialize()));
+ } else {
+ args.push(arg);
+ }
+ };
+ var List = Map.extend({ Map: Map }, {
+ setup: function (instances, options) {
+ this.length = 0;
+ CID(this, '.map');
+ this._setupComputedProperties();
+ instances = instances || [];
+ var teardownMapping;
+ if (isPromise(instances)) {
+ this.replace(instances);
+ } else {
+ teardownMapping = instances.length && mapHelpers.addToMap(instances, this);
+ this.push.apply(this, makeArray(instances || []));
+ }
+ if (teardownMapping) {
+ teardownMapping();
+ }
+ assign(this, options);
+ },
+ _triggerChange: function (attr, how, newVal, oldVal) {
+ Map.prototype._triggerChange.apply(this, arguments);
+ var index = +attr;
+ if (!~('' + attr).indexOf('.') && !isNaN(index)) {
+ if (how === 'add') {
+ canEvent.dispatch.call(this, how, [
+ newVal,
+ index
+ ]);
+ canEvent.dispatch.call(this, 'length', [this.length]);
+ } else if (how === 'remove') {
+ canEvent.dispatch.call(this, how, [
+ oldVal,
+ index
+ ]);
+ canEvent.dispatch.call(this, 'length', [this.length]);
+ } else {
+ canEvent.dispatch.call(this, how, [
+ newVal,
+ index
+ ]);
+ }
+ }
+ },
+ ___get: function (attr) {
+ if (attr) {
+ var computedAttr = this._computedAttrs[attr];
+ if (computedAttr && computedAttr.compute) {
+ return computedAttr.compute();
+ }
+ if (this[attr] && this[attr].isComputed && typeof this.constructor.prototype[attr] === 'function') {
+ return this[attr]();
+ } else {
+ return this[attr];
+ }
+ } else {
+ return this;
+ }
+ },
+ __set: function (prop, value, current) {
+ prop = isNaN(+prop) || prop % 1 ? prop : +prop;
+ if (typeof prop === 'number') {
+ if (prop > this.length - 1) {
+ var newArr = new Array(prop + 1 - this.length);
+ newArr[newArr.length - 1] = value;
+ this.push.apply(this, newArr);
+ return newArr;
+ } else {
+ this.splice(prop, 1, value);
+ return this;
+ }
+ }
+ return Map.prototype.__set.call(this, '' + prop, value, current);
+ },
+ ___set: function (attr, val) {
+ this[attr] = val;
+ if (+attr >= this.length) {
+ this.length = +attr + 1;
+ }
+ },
+ __remove: function (prop, current) {
+ if (isNaN(+prop)) {
+ delete this[prop];
+ this._triggerChange(prop, 'remove', undefined, current);
+ } else {
+ this.splice(prop, 1);
+ }
+ },
+ _each: function (callback) {
+ var data = this.___get();
+ for (var i = 0; i < data.length; i++) {
+ callback(data[i], i);
+ }
+ },
+ serialize: function () {
+ return mapHelpers.serialize(this, 'serialize', []);
+ },
+ splice: function (index, howMany) {
+ var args = makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2;
+ index = index || 0;
+ for (i = 0, len = args.length - 2; i < len; i++) {
+ listIndex = i + 2;
+ args[listIndex] = this.__type(args[listIndex], listIndex);
+ added.push(args[listIndex]);
+ if (this[i + index] !== args[listIndex]) {
+ allSame = false;
+ }
+ }
+ if (allSame && this.length <= added.length) {
+ return added;
+ }
+ if (howMany === undefined) {
+ howMany = args[1] = this.length - index;
+ }
+ var removed = splice.apply(this, args);
+ if (!spliceRemovesProps) {
+ for (i = this.length; i < removed.length + this.length; i++) {
+ delete this[i];
+ }
+ }
+ canBatch.start();
+ if (howMany > 0) {
+ bubble.removeMany(this, removed);
+ this._triggerChange('' + index, 'remove', undefined, removed);
+ }
+ if (args.length > 2) {
+ bubble.addMany(this, added);
+ this._triggerChange('' + index, 'add', added, removed);
+ }
+ canBatch.stop();
+ return removed;
+ },
+ _getAttrs: function () {
+ return mapHelpers.serialize(this, 'attr', []);
+ },
+ _setAttrs: function (items, remove) {
+ items = makeArray(items);
+ canBatch.start();
+ this._updateAttrs(items, remove);
+ canBatch.stop();
+ },
+ _updateAttrs: function (items, remove) {
+ var len = Math.min(items.length, this.length);
+ for (var prop = 0; prop < len; prop++) {
+ var curVal = this[prop], newVal = items[prop];
+ if (types.isMapLike(curVal) && mapHelpers.canMakeObserve(newVal)) {
+ curVal.attr(newVal, remove);
+ } else if (curVal !== newVal) {
+ this._set(prop + '', newVal);
+ } else {
+ }
+ }
+ if (items.length > this.length) {
+ this.push.apply(this, items.slice(this.length));
+ } else if (items.length < this.length && remove) {
+ this.splice(items.length);
+ }
+ }
+ }), getArgs = function (args) {
+ return args[0] && Array.isArray(args[0]) ? args[0] : makeArray(args);
+ };
+ each({
+ push: 'length',
+ unshift: 0
+ }, function (where, name) {
+ var orig = [][name];
+ List.prototype[name] = function () {
+ var args = [], len = where ? this.length : 0, i = arguments.length, res, val;
+ while (i--) {
+ val = arguments[i];
+ args[i] = bubble.set(this, i, this.__type(val, i));
+ }
+ res = orig.apply(this, args);
+ if (!this.comparator || args.length) {
+ this._triggerChange('' + len, 'add', args, undefined);
+ }
+ return res;
+ };
+ });
+ each({
+ pop: 'length',
+ shift: 0
+ }, function (where, name) {
+ List.prototype[name] = function () {
+ if (!this.length) {
+ return undefined;
+ }
+ var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0;
+ var res = [][name].apply(this, args);
+ this._triggerChange('' + len, 'remove', undefined, [res]);
+ if (res && res.removeEventListener) {
+ bubble.remove(this, res);
+ }
+ return res;
+ };
+ });
+ assign(List.prototype, {
+ indexOf: function (item, fromIndex) {
+ Observation.add(this, 'length');
+ for (var i = fromIndex || 0, len = this.length; i < len; i++) {
+ if (this.attr(i) === item) {
+ return i;
+ }
+ }
+ return -1;
+ },
+ join: function () {
+ Observation.add(this, 'length');
+ return [].join.apply(this, arguments);
+ },
+ reverse: function () {
+ var list = [].reverse.call(makeArray(this));
+ return this.replace(list);
+ },
+ slice: function () {
+ Observation.add(this, 'length');
+ var temp = Array.prototype.slice.apply(this, arguments);
+ return new this.constructor(temp);
+ },
+ concat: function () {
+ var args = [], MapType = this.constructor.Map;
+ each(arguments, function (arg) {
+ if (types.isListLike(arg) || Array.isArray(arg)) {
+ var arr = types.isListLike(arg) ? makeArray(arg) : arg;
+ each(arr, function (innerArg) {
+ serializeNonTypes(MapType, innerArg, args);
+ });
+ } else {
+ serializeNonTypes(MapType, arg, args);
+ }
+ });
+ return new this.constructor(Array.prototype.concat.apply(makeArray(this), args));
+ },
+ forEach: function (cb, thisarg) {
+ var item;
+ for (var i = 0, len = this.attr('length'); i < len; i++) {
+ item = this.attr(i);
+ if (item !== undefined && cb.call(thisarg || item, item, i, this) === false) {
+ break;
+ }
+ }
+ return this;
+ },
+ replace: function (newList) {
+ if (isPromise(newList)) {
+ if (this._promise) {
+ this._promise.__isCurrentPromise = false;
+ }
+ var promise = this._promise = newList;
+ promise.__isCurrentPromise = true;
+ var self = this;
+ newList.then(function (newList) {
+ if (promise.__isCurrentPromise) {
+ self.replace(newList);
+ }
+ });
+ } else {
+ this.splice.apply(this, [
+ 0,
+ this.length
+ ].concat(makeArray(newList || [])));
+ }
+ return this;
+ },
+ filter: function (callback, thisArg) {
+ var filteredList = new this.constructor(), self = this, filtered;
+ this.each(function (item, index, list) {
+ filtered = callback.call(thisArg | self, item, index, self);
+ if (filtered) {
+ filteredList.push(item);
+ }
+ });
+ return filteredList;
+ },
+ map: function (callback, thisArg) {
+ var filteredList = new List(), self = this;
+ this.each(function (item, index, list) {
+ var mapped = callback.call(thisArg | self, item, index, self);
+ filteredList.push(mapped);
+ });
+ return filteredList;
+ }
+ });
+ var oldIsListLike = types.isListLike;
+ types.isListLike = function (obj) {
+ return obj instanceof List || oldIsListLike.apply(this, arguments);
+ };
+ var oldType = Map.prototype.__type;
+ Map.prototype.__type = function (value, prop) {
+ if (typeof value === 'object' && Array.isArray(value)) {
+ var cached = mapHelpers.getMapFromObject(value);
+ if (cached) {
+ return cached;
+ }
+ return new List(value);
+ }
+ return oldType.apply(this, arguments);
+ };
+ var oldSetup = Map.setup;
+ Map.setup = function () {
+ oldSetup.apply(this, arguments);
+ if (!(this.prototype instanceof List)) {
+ this.List = Map.List.extend({ Map: this }, {});
+ }
+ };
+ if (!types.DefaultList) {
+ types.DefaultList = List;
+ }
+ List.prototype.each = List.prototype.forEach;
+ Map.List = List;
+ module.exports = namespace.List = List;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/node*/
+define('can-simple-dom@0.4.8#simple-dom/document/node', ['exports'], function (exports) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ function Node(nodeType, nodeName, nodeValue, ownerDocument) {
+ this.nodeType = nodeType;
+ this.nodeName = nodeName;
+ this.nodeValue = nodeValue;
+ this.ownerDocument = ownerDocument;
+ this.childNodes = new ChildNodes(this);
+ this.parentNode = null;
+ this.previousSibling = null;
+ this.nextSibling = null;
+ this.firstChild = null;
+ this.lastChild = null;
+ }
+ Node.prototype._cloneNode = function () {
+ return new Node(this.nodeType, this.nodeName, this.nodeValue, this.ownerDocument);
+ };
+ Node.prototype.cloneNode = function (deep) {
+ var node = this._cloneNode();
+ if (deep) {
+ var child = this.firstChild, nextChild = child;
+ while (nextChild) {
+ nextChild = child.nextSibling;
+ node.appendChild(child.cloneNode(true));
+ child = nextChild;
+ }
+ }
+ return node;
+ };
+ Node.prototype.appendChild = function (node) {
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ insertFragment(node, this, this.lastChild, null);
+ return node;
+ }
+ if (node.parentNode) {
+ node.parentNode.removeChild(node);
+ }
+ node.parentNode = this;
+ var refNode = this.lastChild;
+ if (refNode === null) {
+ this.firstChild = node;
+ this.lastChild = node;
+ } else {
+ node.previousSibling = refNode;
+ refNode.nextSibling = node;
+ this.lastChild = node;
+ }
+ return node;
+ };
+ function insertFragment(fragment, newParent, before, after) {
+ if (!fragment.firstChild) {
+ return;
+ }
+ var firstChild = fragment.firstChild;
+ var lastChild = firstChild;
+ var node = firstChild;
+ firstChild.previousSibling = before;
+ if (before) {
+ before.nextSibling = firstChild;
+ } else {
+ newParent.firstChild = firstChild;
+ }
+ while (node) {
+ node.parentNode = newParent;
+ lastChild = node;
+ node = node.nextSibling;
+ }
+ lastChild.nextSibling = after;
+ if (after) {
+ after.previousSibling = lastChild;
+ } else {
+ newParent.lastChild = lastChild;
+ }
+ fragment.firstChild = null;
+ fragment.lastChild = null;
+ }
+ var nodeInsertBefore = Node.prototype.insertBefore = function (node, refNode) {
+ if (refNode == null) {
+ return this.appendChild(node);
+ }
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ insertFragment(node, this, refNode ? refNode.previousSibling : null, refNode);
+ return node;
+ }
+ if (node.parentNode) {
+ node.parentNode.removeChild(node);
+ }
+ node.parentNode = this;
+ var previousSibling = refNode.previousSibling;
+ if (previousSibling) {
+ previousSibling.nextSibling = node;
+ node.previousSibling = previousSibling;
+ }
+ refNode.previousSibling = node;
+ node.nextSibling = refNode;
+ if (this.firstChild === refNode) {
+ this.firstChild = node;
+ }
+ return node;
+ };
+ var nodeRemoveChild = Node.prototype.removeChild = function (refNode) {
+ if (this.firstChild === refNode) {
+ this.firstChild = refNode.nextSibling;
+ }
+ if (this.lastChild === refNode) {
+ this.lastChild = refNode.previousSibling;
+ }
+ if (refNode.previousSibling) {
+ refNode.previousSibling.nextSibling = refNode.nextSibling;
+ }
+ if (refNode.nextSibling) {
+ refNode.nextSibling.previousSibling = refNode.previousSibling;
+ }
+ refNode.parentNode = null;
+ refNode.nextSibling = null;
+ refNode.previousSibling = null;
+ return refNode;
+ };
+ Node.prototype.replaceChild = function (newChild, oldChild) {
+ nodeInsertBefore.call(this, newChild, oldChild);
+ nodeRemoveChild.call(this, oldChild);
+ return oldChild;
+ };
+ Node.prototype.addEventListener = function () {
+ };
+ Node.prototype.removeEventListener = function () {
+ };
+ Node.ELEMENT_NODE = 1;
+ Node.ATTRIBUTE_NODE = 2;
+ Node.TEXT_NODE = 3;
+ Node.CDATA_SECTION_NODE = 4;
+ Node.ENTITY_REFERENCE_NODE = 5;
+ Node.ENTITY_NODE = 6;
+ Node.PROCESSING_INSTRUCTION_NODE = 7;
+ Node.COMMENT_NODE = 8;
+ Node.DOCUMENT_NODE = 9;
+ Node.DOCUMENT_TYPE_NODE = 10;
+ Node.DOCUMENT_FRAGMENT_NODE = 11;
+ Node.NOTATION_NODE = 12;
+ function ChildNodes(node) {
+ this.node = node;
+ }
+ ChildNodes.prototype.item = function (index) {
+ var child = this.node.firstChild;
+ for (var i = 0; child && index !== i; i++) {
+ child = child.nextSibling;
+ }
+ return child;
+ };
+ exports.default = Node;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/element*/
+define('can-simple-dom@0.4.8#simple-dom/document/element', [
+ 'exports',
+ './node'
+], function (exports, _node) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _node2 = _interopRequireDefault(_node);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ var attrSpecial = {
+ 'class': function _class(element, value) {
+ element._className = value;
+ }
+ };
+ function Element(tagName, ownerDocument) {
+ tagName = tagName.toUpperCase();
+ this.nodeConstructor(1, tagName, null, ownerDocument);
+ this.style = new Style(this);
+ this.attributes = [];
+ this.tagName = tagName;
+ }
+ Element.prototype = Object.create(_node2.default.prototype);
+ Element.prototype.constructor = Element;
+ Element.prototype.nodeConstructor = _node2.default;
+ Element.prototype._cloneNode = function () {
+ var node = this.ownerDocument.createElement(this.tagName);
+ node.attributes = this.attributes.map(function (attr) {
+ return {
+ name: attr.name,
+ value: attr.value,
+ specified: attr.specified
+ };
+ });
+ return node;
+ };
+ Element.prototype.getAttribute = function (_name) {
+ var attributes = this.attributes;
+ var name = _name.toLowerCase();
+ var attr;
+ for (var i = 0, l = attributes.length; i < l; i++) {
+ attr = attributes[i];
+ if (attr.name === name) {
+ return attr.value;
+ }
+ }
+ return null;
+ };
+ Element.prototype.setAttribute = function () {
+ return this._setAttribute.apply(this, arguments);
+ };
+ Element.prototype._setAttribute = function (_name, value) {
+ var attributes = this.attributes;
+ var name = _name.toLowerCase();
+ var attr;
+ for (var i = 0, l = attributes.length; i < l; i++) {
+ attr = attributes[i];
+ if (attr.name === name) {
+ attr.value = value;
+ return;
+ }
+ }
+ attributes.push({
+ name: name,
+ value: value,
+ specified: true
+ });
+ attributes[name] = value;
+ var special = attrSpecial[name];
+ if (special) {
+ special(this, value);
+ }
+ };
+ Element.prototype.hasAttribute = function (_name) {
+ var attributes = this.attributes;
+ var name = _name.toLowerCase();
+ var attr;
+ for (var i = 0, len = attributes.length; i < len; i++) {
+ attr = attributes[i];
+ if (attr.name === name) {
+ return true;
+ }
+ }
+ return false;
+ };
+ Element.prototype.removeAttribute = function (name) {
+ var attributes = this.attributes;
+ for (var i = 0, l = attributes.length; i < l; i++) {
+ var attr = attributes[i];
+ if (attr.name === name) {
+ attributes.splice(i, 1);
+ delete attributes[name];
+ return;
+ }
+ }
+ };
+ Element.prototype.getElementsByTagName = function (name) {
+ name = name.toUpperCase();
+ var elements = [];
+ var cur = this.firstChild;
+ while (cur) {
+ if (cur.nodeType === _node2.default.ELEMENT_NODE) {
+ if (cur.nodeName === name || name === '*') {
+ elements.push(cur);
+ }
+ elements.push.apply(elements, cur.getElementsByTagName(name));
+ }
+ cur = cur.nextSibling;
+ }
+ return elements;
+ };
+ Element.prototype.contains = function (child) {
+ child = child.parentNode;
+ while (child) {
+ if (child === this) {
+ return true;
+ }
+ child = child.parentNode;
+ }
+ return false;
+ };
+ Element.prototype.getElementById = function (id) {
+ var cur = this.firstChild, child;
+ while (cur) {
+ if (cur.attributes && cur.attributes.length) {
+ var attr;
+ for (var i = 0, len = cur.attributes.length; i < len; i++) {
+ attr = cur.attributes[i];
+ if (attr.name === 'id' && attr.value === id) {
+ return cur;
+ }
+ }
+ }
+ if (cur.getElementById) {
+ child = cur.getElementById(id);
+ if (child) {
+ return child;
+ }
+ }
+ cur = cur.nextSibling;
+ }
+ };
+ function Style(node) {
+ this.__node = node;
+ }
+ if (Object.defineProperty) {
+ Object.defineProperty(Element.prototype, 'className', {
+ get: function get() {
+ return this._className || '';
+ },
+ set: function set(val) {
+ this._setAttribute('class', val);
+ this._className = val;
+ }
+ });
+ Object.defineProperty(Style.prototype, 'cssText', {
+ get: function get() {
+ return this.__node.getAttribute('style') || '';
+ },
+ set: function set(val) {
+ this.__node._setAttribute('style', val);
+ }
+ });
+ Object.defineProperty(Element.prototype, 'innerHTML', {
+ get: function get() {
+ var html = '';
+ var cur = this.firstChild;
+ while (cur) {
+ html += this.ownerDocument.__serializer.serialize(cur);
+ cur = cur.nextSibling;
+ }
+ return html;
+ },
+ set: function set(html) {
+ this.lastChild = this.firstChild = null;
+ var fragment;
+ if (this.nodeName === 'SCRIPT' || this.nodeName === 'STYLE') {
+ fragment = this.ownerDocument.createTextNode(html);
+ } else {
+ fragment = this.ownerDocument.__parser.parse(html);
+ }
+ this.appendChild(fragment);
+ }
+ });
+ Object.defineProperty(Element.prototype, 'outerHTML', {
+ get: function get() {
+ return this.ownerDocument.__serializer.serialize(this);
+ },
+ set: function set(html) {
+ this.parentNode.replaceChild(this.ownerDocument.__parser.parse(html), this);
+ }
+ });
+ }
+ exports.default = Element;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/text*/
+define('can-simple-dom@0.4.8#simple-dom/document/text', [
+ 'exports',
+ './node'
+], function (exports, _node) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _node2 = _interopRequireDefault(_node);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function Text(text, ownerDocument) {
+ this.nodeConstructor(3, '#text', text, ownerDocument);
+ }
+ Text.prototype._cloneNode = function () {
+ return this.ownerDocument.createTextNode(this.nodeValue);
+ };
+ Text.prototype = Object.create(_node2.default.prototype);
+ Text.prototype.constructor = Text;
+ Text.prototype.nodeConstructor = _node2.default;
+ exports.default = Text;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/comment*/
+define('can-simple-dom@0.4.8#simple-dom/document/comment', [
+ 'exports',
+ './node'
+], function (exports, _node) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _node2 = _interopRequireDefault(_node);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function Comment(text, ownerDocument) {
+ this.nodeConstructor(8, '#comment', text, ownerDocument);
+ }
+ Comment.prototype._cloneNode = function () {
+ return this.ownerDocument.createComment(this.nodeValue);
+ };
+ Comment.prototype = Object.create(_node2.default.prototype);
+ Comment.prototype.constructor = Comment;
+ Comment.prototype.nodeConstructor = _node2.default;
+ exports.default = Comment;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/document-fragment*/
+define('can-simple-dom@0.4.8#simple-dom/document/document-fragment', [
+ 'exports',
+ './node'
+], function (exports, _node) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _node2 = _interopRequireDefault(_node);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function DocumentFragment(ownerDocument) {
+ this.nodeConstructor(11, '#document-fragment', null, ownerDocument);
+ }
+ DocumentFragment.prototype._cloneNode = function () {
+ return this.ownerDocument.createDocumentFragment();
+ };
+ DocumentFragment.prototype = Object.create(_node2.default.prototype);
+ DocumentFragment.prototype.constructor = DocumentFragment;
+ DocumentFragment.prototype.nodeConstructor = _node2.default;
+ exports.default = DocumentFragment;
+});
+/*micro-location@0.1.5#lib/micro-location*/
+function Location() {
+ this.init.apply(this, arguments);
+}
+Location.prototype = {
+ init: function (protocol, host, hostname, port, pathname, search, hash) {
+ this.protocol = protocol;
+ this.host = host;
+ this.hostname = hostname;
+ this.port = port || '';
+ this.pathname = pathname || '';
+ this.search = search || '';
+ this.hash = hash || '';
+ if (protocol) {
+ with (this)
+ this.href = protocol + '//' + host + pathname + search + hash;
+ } else if (host) {
+ with (this)
+ this.href = '//' + host + pathname + search + hash;
+ } else {
+ with (this)
+ this.href = pathname + search + hash;
+ }
+ },
+ params: function (name) {
+ if (!this._params) {
+ var params = {};
+ var pairs = this.search.substring(1).split(/[;&]/);
+ for (var i = 0, len = pairs.length; i < len; i++) {
+ if (!pairs[i])
+ continue;
+ var pair = pairs[i].split(/=/);
+ var key = decodeURIComponent(pair[0].replace(/\+/g, '%20'));
+ var val = decodeURIComponent(pair[1].replace(/\+/g, '%20'));
+ if (!params[key])
+ params[key] = [];
+ params[key].push(val);
+ }
+ this._params = params;
+ }
+ switch (typeof name) {
+ case 'undefined':
+ return this._params;
+ case 'object':
+ return this.build(name);
+ }
+ return this._params[name] ? this._params[name][0] : null;
+ },
+ build: function (params) {
+ if (!params)
+ params = this._params;
+ var ret = new Location();
+ var _search = this.search;
+ if (params) {
+ var search = [];
+ for (var key in params)
+ if (params.hasOwnProperty(key)) {
+ var val = params[key];
+ switch (typeof val) {
+ case 'object':
+ for (var i = 0, len = val.length; i < len; i++) {
+ search.push(encodeURIComponent(key) + '=' + encodeURIComponent(val[i]));
+ }
+ break;
+ default:
+ search.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
+ }
+ }
+ _search = '?' + search.join('&');
+ }
+ with (this)
+ ret.init.apply(ret, [
+ protocol,
+ host,
+ hostname,
+ port,
+ pathname,
+ _search,
+ hash
+ ]);
+ return ret;
+ }
+};
+Location.regexp = new RegExp('^(?:(https?:)//(([^:/]+)(:[^/]+)?))?([^#?]*)(\\?[^#]*)?(#.*)?$');
+Location.parse = function (string) {
+ var matched = String(string).match(this.regexp);
+ var ret = new Location();
+ ret.init.apply(ret, matched.slice(1));
+ return ret;
+};
+(function (root, factory) {
+ if (typeof module === 'object' && module.exports) {
+ module.exports = { Location: factory() };
+ } else if (typeof define === 'function' && define.amd) {
+ define('micro-location@0.1.5#lib/micro-location', [], function () {
+ return { Location: factory() };
+ });
+ } else {
+ root.Location = factory();
+ }
+}(this, function () {
+ return Location;
+}));
+/*can-simple-dom@0.4.8#simple-dom/extend*/
+define('can-simple-dom@0.4.8#simple-dom/extend', ['exports'], function (exports) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ exports.default = function (a, b) {
+ for (var p in b) {
+ a[p] = b[p];
+ }
+ return a;
+ };
+ ;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/anchor-element*/
+define('can-simple-dom@0.4.8#simple-dom/document/anchor-element', [
+ 'exports',
+ './element',
+ 'micro-location',
+ '../extend'
+], function (exports, _element, _microLocation, _extend) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _element2 = _interopRequireDefault(_element);
+ var _microLocation2 = _interopRequireDefault(_microLocation);
+ var _extend2 = _interopRequireDefault(_extend);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ var Location = _microLocation2.default.Location || _microLocation2.default;
+ function AnchorElement(tagName, ownerDocument) {
+ this.elementConstructor(tagName, ownerDocument);
+ (0, _extend2.default)(this, Location.parse(''));
+ }
+ AnchorElement.prototype = Object.create(_element2.default.prototype);
+ AnchorElement.prototype.constructor = AnchorElement;
+ AnchorElement.prototype.elementConstructor = _element2.default;
+ AnchorElement.prototype.setAttribute = function (_name, value) {
+ _element2.default.prototype.setAttribute.apply(this, arguments);
+ if (_name.toLowerCase() === 'href') {
+ (0, _extend2.default)(this, Location.parse(value));
+ }
+ };
+ exports.default = AnchorElement;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/utils*/
+define('can-simple-dom@0.4.8#simple-dom/document/utils', ['exports'], function (exports) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ exports.propToAttr = propToAttr;
+ function propToAttr(Element, name) {
+ Object.defineProperty(Element.prototype, name, {
+ get: function get() {
+ return this.getAttribute(name);
+ },
+ set: function set(val) {
+ this.setAttribute(name, val);
+ }
+ });
+ }
+ ;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/input-element*/
+define('can-simple-dom@0.4.8#simple-dom/document/input-element', [
+ 'exports',
+ './element',
+ './utils.js'
+], function (exports, _element, _utils) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _element2 = _interopRequireDefault(_element);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function InputElement(tagName, ownerDocument) {
+ this.elementConstructor(tagName, ownerDocument);
+ }
+ InputElement.prototype = Object.create(_element2.default.prototype);
+ InputElement.prototype.constructor = InputElement;
+ InputElement.prototype.elementConstructor = _element2.default;
+ (0, _utils.propToAttr)(InputElement, 'type');
+ (0, _utils.propToAttr)(InputElement, 'value');
+ Object.defineProperty(InputElement.prototype, 'checked', {
+ get: function get() {
+ return this.hasAttribute('checked');
+ },
+ set: function set(value) {
+ if (value) {
+ this.setAttribute('checked', '');
+ } else {
+ this.removeAttribute('checked');
+ }
+ }
+ });
+ exports.default = InputElement;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/option-element*/
+define('can-simple-dom@0.4.8#simple-dom/document/option-element', [
+ 'exports',
+ './element',
+ './utils'
+], function (exports, _element, _utils) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _element2 = _interopRequireDefault(_element);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function OptionElement(tagName, ownerDocument) {
+ this.elementConstructor(tagName, ownerDocument);
+ }
+ OptionElement.prototype = Object.create(_element2.default.prototype);
+ OptionElement.prototype.constructor = OptionElement;
+ OptionElement.prototype.elementConstructor = _element2.default;
+ (0, _utils.propToAttr)(OptionElement, 'value');
+ Object.defineProperty(OptionElement.prototype, 'selected', {
+ get: function get() {
+ var val = this.value || '';
+ var parent = this.parentNode;
+ return parent && parent.value == val;
+ },
+ set: function set(val) {
+ if (val) {
+ var parent = this.parentNode;
+ if (parent) {
+ parent.value = this.value;
+ }
+ }
+ }
+ });
+ exports.default = OptionElement;
+});
+/*can-simple-dom@0.4.8#simple-dom/document/select-element*/
+define('can-simple-dom@0.4.8#simple-dom/document/select-element', [
+ 'exports',
+ './element',
+ './utils'
+], function (exports, _element, _utils) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _element2 = _interopRequireDefault(_element);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function SelectElement(tagName, ownerDocument) {
+ this.elementConstructor(tagName, ownerDocument);
+ this.selectedIndex = 0;
+ }
+ SelectElement.prototype = Object.create(_element2.default.prototype);
+ SelectElement.prototype.constructor = SelectElement;
+ SelectElement.prototype.elementConstructor = _element2.default;
+ (0, _utils.propToAttr)(SelectElement, 'value');
+ exports.default = SelectElement;
+});
+/*can-simple-dom@0.4.8#simple-dom/document*/
+define('can-simple-dom@0.4.8#simple-dom/document', [
+ 'exports',
+ './document/node',
+ './document/element',
+ './document/text',
+ './document/comment',
+ './document/document-fragment',
+ './document/anchor-element',
+ './document/input-element',
+ './document/option-element',
+ './document/select-element'
+], function (exports, _node, _element, _text, _comment, _documentFragment, _anchorElement, _inputElement, _optionElement, _selectElement) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _node2 = _interopRequireDefault(_node);
+ var _element2 = _interopRequireDefault(_element);
+ var _text2 = _interopRequireDefault(_text);
+ var _comment2 = _interopRequireDefault(_comment);
+ var _documentFragment2 = _interopRequireDefault(_documentFragment);
+ var _anchorElement2 = _interopRequireDefault(_anchorElement);
+ var _inputElement2 = _interopRequireDefault(_inputElement);
+ var _optionElement2 = _interopRequireDefault(_optionElement);
+ var _selectElement2 = _interopRequireDefault(_selectElement);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function Document() {
+ this.nodeConstructor(9, '#document', null, this);
+ this.documentElement = new _element2.default('html', this);
+ this.body = new _element2.default('body', this);
+ this.documentElement.appendChild(this.body);
+ this.appendChild(this.documentElement);
+ var self = this;
+ this.implementation = {
+ createHTMLDocument: function createHTMLDocument(content) {
+ var document = new Document();
+ var frag = self.__parser.parse(content);
+ var body = _element2.default.prototype.getElementsByTagName.call(frag, 'body')[0];
+ var head = _element2.default.prototype.getElementsByTagName.call(frag, 'head')[0];
+ if (!body && !head) {
+ document.body.appendChild(frag);
+ } else {
+ if (body) {
+ document.documentElement.replaceChild(body, document.body);
+ }
+ if (head) {
+ document.documentElement.replaceChild(head, document.head);
+ }
+ document.documentElement.appendChild(frag);
+ }
+ document.__addSerializerAndParser(self.__serializer, self.__parser);
+ return document;
+ }
+ };
+ }
+ Document.prototype = Object.create(_node2.default.prototype);
+ Document.prototype.constructor = Document;
+ Document.prototype.nodeConstructor = _node2.default;
+ var specialElements = {
+ 'a': _anchorElement2.default,
+ 'input': _inputElement2.default,
+ 'option': _optionElement2.default,
+ 'select': _selectElement2.default
+ };
+ Document.prototype.createElement = function (tagName) {
+ var Special = specialElements[tagName.toLowerCase()];
+ if (Special) {
+ return new Special(tagName, this);
+ }
+ return new _element2.default(tagName, this);
+ };
+ Document.prototype.createTextNode = function (text) {
+ return new _text2.default(text, this);
+ };
+ Document.prototype.createComment = function (text) {
+ return new _comment2.default(text, this);
+ };
+ Document.prototype.createDocumentFragment = function () {
+ return new _documentFragment2.default(this);
+ };
+ Document.prototype.getElementsByTagName = function (name) {
+ name = name.toUpperCase();
+ var elements = [];
+ var cur = this.firstChild;
+ while (cur) {
+ if (cur.nodeType === _node2.default.ELEMENT_NODE) {
+ if (cur.nodeName === name || name === '*') {
+ elements.push(cur);
+ }
+ elements.push.apply(elements, cur.getElementsByTagName(name));
+ }
+ cur = cur.nextSibling;
+ }
+ return elements;
+ };
+ Document.prototype.getElementById = function (id) {
+ return _element2.default.prototype.getElementById.apply(this.documentElement, arguments);
+ };
+ Document.prototype.__addSerializerAndParser = function (serializer, parser) {
+ this.__parser = parser;
+ this.__serializer = serializer;
+ };
+ if (Object.defineProperty) {
+ Object.defineProperty(Document.prototype, 'currentScript', {
+ get: function get() {
+ var scripts = this.getElementsByTagName('script');
+ var first = scripts[scripts.length - 1];
+ if (!first) {
+ first = this.createElement('script');
+ }
+ return first;
+ }
+ });
+ }
+ exports.default = Document;
+});
+/*can-simple-dom@0.4.8#simple-dom/event*/
+define('can-simple-dom@0.4.8#simple-dom/event', [
+ 'exports',
+ './document/node',
+ './document'
+], function (exports, _node, _document) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ var _node2 = _interopRequireDefault(_node);
+ var _document2 = _interopRequireDefault(_document);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ var Event = function Event() {
+ };
+ Event.prototype.initEvent = function (type, bubbles, cancelable) {
+ this.type = type;
+ this.bubbles = !!bubbles;
+ this.cancelable = !!cancelable;
+ };
+ Event.prototype.stopPropagation = function () {
+ this.isPropagationStopped = true;
+ };
+ Event.prototype.preventDefault = function () {
+ this.isDefaultPrevented = true;
+ };
+ _document2.default.prototype.createEvent = function (type) {
+ return new Event();
+ };
+ _node2.default.prototype.addEventListener = function (event, handler, capture) {
+ if (!this.__handlers) {
+ Object.defineProperty(this, '__handlers', {
+ value: {},
+ enumerable: false
+ });
+ }
+ var phase = capture ? 'capture' : 'bubble';
+ var handlersByType = this.__handlers[event + ' ' + phase];
+ if (!handlersByType) {
+ handlersByType = this.__handlers[event + ' ' + phase] = [];
+ }
+ handlersByType.push(handler);
+ };
+ _node2.default.prototype.removeEventListener = function (event, handler, capture) {
+ if (this.__handlers) {
+ var phase = capture ? 'capture' : 'bubble';
+ var handlersByType = this.__handlers[event + ' ' + phase];
+ if (handlersByType) {
+ var index = 0;
+ while (index < handlersByType.length) {
+ if (handlersByType[index] === handler) {
+ handlersByType.splice(index, 1);
+ } else {
+ index++;
+ }
+ }
+ }
+ }
+ };
+ _node2.default.prototype.dispatchEvent = function (event) {
+ event.target = this;
+ var cur = this;
+ var dispatchHandlers = [];
+ do {
+ var handlers = cur.__handlers && cur.__handlers[event.type + ' bubble'];
+ if (handlers) {
+ dispatchHandlers.push({
+ node: cur,
+ handlers: handlers
+ });
+ }
+ cur = cur.parentNode;
+ } while (event.bubbles && cur);
+ for (var i = 0; i < dispatchHandlers.length; i++) {
+ var dispatches = dispatchHandlers[i];
+ event.currentTarget = dispatches.node;
+ for (var h = 0; h < dispatches.handlers.length; h++) {
+ var handler = dispatches.handlers[h];
+ var res = handler.call(this, event);
+ if (res) {
+ event.stopPropagation();
+ event.preventDefault();
+ }
+ if (event.isImmediatePropagationStopped) {
+ return !event.isDefaultPrevented;
+ }
+ }
+ if (event.isPropagationStopped) {
+ return !event.isDefaultPrevented;
+ }
+ }
+ return !event.isDefaultPrevented;
+ };
+ exports.default = Event;
+});
+/*can-simple-dom@0.4.8#simple-dom/html-parser*/
+define('can-simple-dom@0.4.8#simple-dom/html-parser', ['exports'], function (exports) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ function HTMLParser(tokenize, document, voidMap) {
+ this.tokenize = tokenize;
+ this.document = document;
+ this.voidMap = voidMap;
+ this.parentStack = [];
+ }
+ HTMLParser.prototype.isVoid = function (element) {
+ return this.voidMap[element.nodeName] === true;
+ };
+ HTMLParser.prototype.pushElement = function (token) {
+ var el = this.document.createElement(token.tagName);
+ for (var i = 0; i < token.attributes.length; i++) {
+ var attr = token.attributes[i];
+ el.setAttribute(attr[0], attr[1]);
+ }
+ if (this.isVoid(el) || token.selfClosing) {
+ return this.appendChild(el);
+ }
+ this.parentStack.push(el);
+ };
+ HTMLParser.prototype.popElement = function (token) {
+ var el = this.parentStack.pop();
+ if (el.nodeName !== token.tagName.toUpperCase()) {
+ throw new Error('unbalanced tag');
+ }
+ this.appendChild(el);
+ };
+ HTMLParser.prototype.appendText = function (token) {
+ var text = this.document.createTextNode(token.chars);
+ this.appendChild(text);
+ };
+ HTMLParser.prototype.appendComment = function (token) {
+ var comment = this.document.createComment(token.chars);
+ this.appendChild(comment);
+ };
+ HTMLParser.prototype.appendChild = function (node) {
+ var parentNode = this.parentStack[this.parentStack.length - 1];
+ parentNode.appendChild(node);
+ };
+ HTMLParser.prototype.parse = function (html) {
+ var fragment = this.document.createDocumentFragment();
+ this.parentStack.push(fragment);
+ var tokens = this.tokenize(html);
+ for (var i = 0, l = tokens.length; i < l; i++) {
+ var token = tokens[i];
+ switch (token.type) {
+ case 'StartTag':
+ this.pushElement(token);
+ break;
+ case 'EndTag':
+ this.popElement(token);
+ break;
+ case 'Chars':
+ this.appendText(token);
+ break;
+ case 'Comment':
+ this.appendComment(token);
+ break;
+ }
+ }
+ return this.parentStack.pop();
+ };
+ exports.default = HTMLParser;
+});
+/*can-simple-dom@0.4.8#simple-dom/html-serializer*/
+define('can-simple-dom@0.4.8#simple-dom/html-serializer', ['exports'], function (exports) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ function HTMLSerializer(voidMap) {
+ this.voidMap = voidMap;
+ }
+ HTMLSerializer.prototype.openTag = function (element) {
+ return '<' + element.nodeName.toLowerCase() + this.attributes(element.attributes) + '>';
+ };
+ HTMLSerializer.prototype.closeTag = function (element) {
+ return '' + element.nodeName.toLowerCase() + '>';
+ };
+ HTMLSerializer.prototype.isVoid = function (element) {
+ return this.voidMap[element.nodeName] === true;
+ };
+ HTMLSerializer.prototype.attributes = function (namedNodeMap) {
+ var buffer = '';
+ for (var i = 0, l = namedNodeMap.length; i < l; i++) {
+ buffer += this.attr(namedNodeMap[i]);
+ }
+ return buffer;
+ };
+ HTMLSerializer.prototype.escapeAttrValue = function (attrValue) {
+ return attrValue.replace(/[&"]/g, function (match) {
+ switch (match) {
+ case '&':
+ return '&';
+ case '"':
+ return '"';
+ }
+ });
+ };
+ HTMLSerializer.prototype.attr = function (attr) {
+ if (!attr.specified) {
+ return '';
+ }
+ if (attr.value) {
+ return ' ' + attr.name + '="' + this.escapeAttrValue(attr.value) + '"';
+ }
+ return ' ' + attr.name;
+ };
+ HTMLSerializer.prototype.escapeText = function (textNodeValue) {
+ return textNodeValue.replace(/[&<>]/g, function (match) {
+ switch (match) {
+ case '&':
+ return '&';
+ case '<':
+ return '<';
+ case '>':
+ return '>';
+ }
+ });
+ };
+ HTMLSerializer.prototype.text = function (text) {
+ var parentNode = text.parentNode;
+ if (parentNode && (parentNode.nodeName === 'STYLE' || parentNode.nodeName === 'SCRIPT')) {
+ return text.nodeValue;
+ }
+ return this.escapeText(text.nodeValue);
+ };
+ HTMLSerializer.prototype.comment = function (comment) {
+ return '';
+ };
+ HTMLSerializer.prototype.serialize = function (node) {
+ var buffer = '';
+ var next;
+ switch (node.nodeType) {
+ case 1:
+ buffer += this.openTag(node);
+ break;
+ case 3:
+ buffer += this.text(node);
+ break;
+ case 8:
+ buffer += this.comment(node);
+ break;
+ default:
+ break;
+ }
+ next = node.firstChild;
+ if (next) {
+ while (next) {
+ buffer += this.serialize(next);
+ next = next.nextSibling;
+ }
+ } else if (node.nodeType === 1 && node.textContent) {
+ buffer += node.textContent;
+ }
+ if (node.nodeType === 1 && !this.isVoid(node)) {
+ buffer += this.closeTag(node);
+ }
+ return buffer;
+ };
+ exports.default = HTMLSerializer;
+});
+/*can-simple-dom@0.4.8#simple-dom/void-map*/
+define('can-simple-dom@0.4.8#simple-dom/void-map', ['exports'], function (exports) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ exports.default = {
+ AREA: true,
+ BASE: true,
+ BR: true,
+ COL: true,
+ COMMAND: true,
+ EMBED: true,
+ HR: true,
+ IMG: true,
+ INPUT: true,
+ KEYGEN: true,
+ LINK: true,
+ META: true,
+ PARAM: true,
+ SOURCE: true,
+ TRACK: true,
+ WBR: true
+ };
+});
+/*can-simple-dom@0.4.8#simple-dom/dom*/
+define('can-simple-dom@0.4.8#simple-dom/dom', [
+ 'exports',
+ './document/node',
+ './document/element',
+ './document',
+ './event',
+ './html-parser',
+ './html-serializer',
+ './void-map'
+], function (exports, _node, _element, _document, _event, _htmlParser, _htmlSerializer, _voidMap) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ exports.createDocument = exports.voidMap = exports.HTMLSerializer = exports.HTMLParser = exports.Event = exports.Document = exports.Element = exports.Node = undefined;
+ var _node2 = _interopRequireDefault(_node);
+ var _element2 = _interopRequireDefault(_element);
+ var _document2 = _interopRequireDefault(_document);
+ var _event2 = _interopRequireDefault(_event);
+ var _htmlParser2 = _interopRequireDefault(_htmlParser);
+ var _htmlSerializer2 = _interopRequireDefault(_htmlSerializer);
+ var _voidMap2 = _interopRequireDefault(_voidMap);
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : { default: obj };
+ }
+ function createDocument(serializer, parser) {
+ var doc = new _document2.default();
+ doc.__serializer = serializer;
+ doc.__parser = parser;
+ return doc;
+ }
+ exports.Node = _node2.default;
+ exports.Element = _element2.default;
+ exports.Document = _document2.default;
+ exports.Event = _event2.default;
+ exports.HTMLParser = _htmlParser2.default;
+ exports.HTMLSerializer = _htmlSerializer2.default;
+ exports.voidMap = _voidMap2.default;
+ exports.createDocument = createDocument;
+});
+/*can-simple-dom@0.4.8#simple-dom*/
+define('can-simple-dom@0.4.8#simple-dom', [
+ 'exports',
+ './simple-dom/dom'
+], function (exports, _dom) {
+ 'use strict';
+ Object.defineProperty(exports, '__esModule', { value: true });
+ Object.keys(_dom).forEach(function (key) {
+ if (key === 'default' || key === '__esModule')
+ return;
+ Object.defineProperty(exports, key, {
+ enumerable: true,
+ get: function () {
+ return _dom[key];
+ }
+ });
+ });
+ var SimpleDOM = _interopRequireWildcard(_dom);
+ function _interopRequireWildcard(obj) {
+ if (obj && obj.__esModule) {
+ return obj;
+ } else {
+ var newObj = {};
+ if (obj != null) {
+ for (var key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key))
+ newObj[key] = obj[key];
+ }
+ }
+ newObj.default = obj;
+ return newObj;
+ }
+ }
+ if (typeof window !== 'undefined') {
+ window.SimpleDOM = SimpleDOM;
+ }
+});
+/*can-vdom@3.0.1#make-parser/make-parser*/
+define('can-vdom@3.0.1#make-parser/make-parser', function (require, exports, module) {
+ var canParser = require('can-view-parser');
+ var simpleDOM = require('can-simple-dom');
+ module.exports = function (document) {
+ return new simpleDOM.HTMLParser(function (string) {
+ var tokens = [];
+ var currentTag, currentAttr;
+ canParser(string, {
+ start: function (tagName, unary) {
+ currentTag = {
+ type: 'StartTag',
+ attributes: [],
+ tagName: tagName
+ };
+ },
+ end: function (tagName, unary) {
+ tokens.push(currentTag);
+ currentTag = undefined;
+ },
+ close: function (tagName) {
+ tokens.push({
+ type: 'EndTag',
+ tagName: tagName
+ });
+ },
+ attrStart: function (attrName) {
+ currentAttr = [
+ attrName,
+ ''
+ ];
+ currentTag.attributes.push(currentAttr);
+ },
+ attrEnd: function (attrName) {
+ },
+ attrValue: function (value) {
+ currentAttr[1] += value;
+ },
+ chars: function (value) {
+ tokens.push({
+ type: 'Chars',
+ chars: value
+ });
+ },
+ comment: function (value) {
+ tokens.push({
+ type: 'Comment',
+ chars: value
+ });
+ },
+ special: function (value) {
+ },
+ done: function () {
+ }
+ });
+ return tokens;
+ }, document, simpleDOM.voidMap);
+ };
+});
+/*can-vdom@3.0.1#make-document/make-document*/
+define('can-vdom@3.0.1#make-document/make-document', function (require, exports, module) {
+ var simpleDOM = require('can-simple-dom');
+ var makeParser = require('../make-parser/make-parser');
+ function CanSimpleDocument() {
+ simpleDOM.Document.apply(this, arguments);
+ var serializer = new simpleDOM.HTMLSerializer(simpleDOM.voidMap);
+ var parser = makeParser(this);
+ this.__addSerializerAndParser(serializer, parser);
+ }
+ CanSimpleDocument.prototype = new simpleDOM.Document();
+ CanSimpleDocument.prototype.constructor = CanSimpleDocument;
+ module.exports = function () {
+ return new CanSimpleDocument();
+ };
+});
+/*can-component@3.0.2#test/component-map-test*/
+define('can-component@3.0.2#test/component-map-test', function (require, exports, module) {
+ require('./component-define-test');
+ var Component = require('can-component');
+ var stache = require('can-stache');
+ var QUnit = require('steal-qunit');
+ var Construct = require('can-construct');
+ var canCompute = require('can-compute');
+ var CanMap = require('can-map');
+ var CanList = require('can-list');
+ var canEvent = require('can-event');
+ var canViewModel = require('can-view-model');
+ var canBatch = require('can-event/batch/batch');
+ var attr = require('can-util/dom/attr/attr');
+ var className = require('can-util/dom/class-name/class-name');
+ var domMutate = require('can-util/dom/mutate/mutate');
+ var domData = require('can-util/dom/data/data');
+ var types = require('can-util/js/types/types');
+ var isPromise = require('can-util/js/is-promise/is-promise');
+ var makeDocument = require('can-vdom/make-document/make-document');
+ var MUTATION_OBSERVER = require('can-util/dom/mutation-observer/mutation-observer');
+ var DOCUMENT = require('can-util/dom/document/document');
+ var getFragment = require('can-util/dom/fragment/fragment');
+ var Scope = require('can-view-scope');
+ var viewCallbacks = require('can-view-callbacks');
+ var DOC = DOCUMENT();
+ var MUT_OBS = MUTATION_OBSERVER();
+ makeTest('can-component - map - dom', document, MUT_OBS);
+ makeTest('can-component - map - vdom', makeDocument(), null);
+ var innerHTML = function (node) {
+ if ('innerHTML' in node) {
+ return node.innerHTML;
+ }
+ };
+ var runTasks = function (tasks) {
+ var nextTask = function () {
+ var next = tasks.shift();
+ next();
+ if (tasks.length) {
+ setTimeout(nextTask, 10);
+ } else {
+ start();
+ }
+ };
+ setTimeout(nextTask, 10);
+ };
+ function makeTest(name, doc, mutObs) {
+ var oldDoc, oldDefaultMap;
+ QUnit.module(name, {
+ setup: function () {
+ DOCUMENT(doc);
+ MUTATION_OBSERVER(mutObs);
+ oldDefaultMap = types.DefaultMap;
+ types.DefaultMap = CanMap;
+ if (doc) {
+ this.fixture = doc.createElement('div');
+ doc.body.appendChild(this.fixture);
+ } else {
+ this.fixture = doc.getElementById('qunit-fixture');
+ }
+ },
+ teardown: function () {
+ doc.body.removeChild(this.fixture);
+ stop();
+ setTimeout(function () {
+ types.DefaultMap = oldDefaultMap;
+ start();
+ DOCUMENT(DOC);
+ MUTATION_OBSERVER(MUT_OBS);
+ }, 1);
+ }
+ });
+ var Paginate = CanMap.extend({
+ count: Infinity,
+ offset: 0,
+ limit: 100,
+ setCount: function (newCount, success, error) {
+ return newCount < 0 ? 0 : newCount;
+ },
+ setOffset: function (newOffset) {
+ return newOffset < 0 ? 0 : Math.min(newOffset, !isNaN(this.count - 1) ? this.count - 1 : Infinity);
+ },
+ next: function () {
+ this.attr('offset', this.offset + this.limit);
+ },
+ prev: function () {
+ this.attr('offset', this.offset - this.limit);
+ },
+ canNext: function () {
+ return this.attr('offset') < this.attr('count') - this.attr('limit');
+ },
+ canPrev: function () {
+ return this.attr('offset') > 0;
+ },
+ page: function (newVal) {
+ if (newVal === undefined) {
+ return Math.floor(this.attr('offset') / this.attr('limit')) + 1;
+ } else {
+ this.attr('offset', (parseInt(newVal) - 1) * this.attr('limit'));
+ }
+ },
+ pageCount: function () {
+ return this.attr('count') ? Math.ceil(this.attr('count') / this.attr('limit')) : null;
+ }
+ });
+ test('lexical scoping', function () {
+ Component.extend({
+ tag: 'hello-world',
+ template: stache('{{greeting}} World {{exclamation}}'),
+ viewModel: { greeting: 'Hello' }
+ });
+ var template = stache('{{greeting}} ');
+ var frag = template({
+ greeting: 'World',
+ exclamation: '!'
+ });
+ var hello = frag.firstChild;
+ equal(innerHTML(hello).trim(), 'Hello World');
+ Component.extend({
+ tag: 'hello-world-no-template',
+ leakScope: false,
+ viewModel: { greeting: 'Hello' }
+ });
+ template = stache('{{greeting}} ');
+ frag = template({
+ greeting: 'World',
+ exclamation: '!'
+ });
+ hello = frag.firstChild;
+ equal(innerHTML(hello).trim(), 'Hello', 'If no template is provided to Component, treat bindings as dynamic.');
+ });
+ test('dynamic scoping', function () {
+ Component.extend({
+ tag: 'hello-world',
+ leakScope: true,
+ template: stache('{{greeting}} World {{exclamation}}'),
+ viewModel: { greeting: 'Hello' }
+ });
+ var template = stache('{{greeting}} ');
+ var frag = template({
+ greeting: 'World',
+ exclamation: '!'
+ });
+ var hello = frag.firstChild;
+ equal(innerHTML(hello).trim(), 'Hello Hello!');
+ });
+ test('treecombo', function () {
+ var TreeComboViewModel = CanMap.extend({
+ items: [],
+ breadcrumb: [],
+ selected: [],
+ selectableItems: function () {
+ var breadcrumb = this.attr('breadcrumb');
+ if (breadcrumb.attr('length')) {
+ return breadcrumb.attr('' + (breadcrumb.length - 1) + '.children');
+ } else {
+ return this.attr('items');
+ }
+ },
+ showChildren: function (item, el, ev) {
+ ev.stopPropagation();
+ this.attr('breadcrumb').push(item);
+ },
+ emptyBreadcrumb: function () {
+ this.attr('breadcrumb').attr([], true);
+ },
+ updateBreadcrumb: function (item) {
+ var breadcrumb = this.attr('breadcrumb'), index = breadcrumb.indexOf(item);
+ breadcrumb.splice(index + 1, breadcrumb.length - index - 1);
+ },
+ toggle: function (item) {
+ var selected = this.attr('selected'), index = selected.indexOf(item);
+ if (index === -1) {
+ selected.push(item);
+ } else {
+ selected.splice(index, 1);
+ }
+ },
+ isSelected: function (item) {
+ return this.attr('selected').indexOf(item) > -1;
+ }
+ });
+ Component.extend({
+ tag: 'treecombo',
+ template: stache('' + '{{title}} ' + '{{#each breadcrumb}}' + '{{title}} ' + '{{/each}}' + ' ' + ''),
+ ViewModel: TreeComboViewModel
+ });
+ var template = stache(' ');
+ var base = new CanMap({});
+ var frag = template(base);
+ var root = doc.createElement('div');
+ root.appendChild(frag);
+ var items = [
+ {
+ id: 1,
+ title: 'Midwest',
+ children: [
+ {
+ id: 5,
+ title: 'Illinois',
+ children: [
+ {
+ id: 23423,
+ title: 'Chicago'
+ },
+ {
+ id: 4563,
+ title: 'Springfield'
+ },
+ {
+ id: 4564,
+ title: 'Naperville'
+ }
+ ]
+ },
+ {
+ id: 6,
+ title: 'Wisconsin',
+ children: [
+ {
+ id: 232423,
+ title: 'Milwaulkee'
+ },
+ {
+ id: 45463,
+ title: 'Green Bay'
+ },
+ {
+ id: 45464,
+ title: 'Madison'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ id: 2,
+ title: 'East Coast',
+ children: [
+ {
+ id: 25,
+ title: 'New York',
+ children: [
+ {
+ id: 3413,
+ title: 'New York'
+ },
+ {
+ id: 4613,
+ title: 'Rochester'
+ },
+ {
+ id: 4516,
+ title: 'Syracuse'
+ }
+ ]
+ },
+ {
+ id: 6,
+ title: 'Pennsylvania',
+ children: [
+ {
+ id: 2362423,
+ title: 'Philadelphia'
+ },
+ {
+ id: 454663,
+ title: 'Harrisburg'
+ },
+ {
+ id: 454664,
+ title: 'Scranton'
+ }
+ ]
+ }
+ ]
+ }
+ ];
+ stop();
+ setTimeout(function () {
+ base.attr('locations', items);
+ var itemsList = base.attr('locations');
+ var treecombo = root.firstChild, breadcrumb = treecombo.firstChild, breadcrumbLIs = function () {
+ return breadcrumb.getElementsByTagName('li');
+ }, options = treecombo.lastChild, optionsLis = function () {
+ return options.getElementsByTagName('li');
+ };
+ equal(breadcrumbLIs().length, 1, 'Only the default title is shown');
+ equal(innerHTML(breadcrumbLIs()[0]), 'Locations', 'The correct title from the attribute is shown');
+ equal(itemsList.length, optionsLis().length, 'first level items are displayed');
+ canEvent.trigger.call(optionsLis()[0], 'click');
+ equal(optionsLis()[0].className, 'active', 'toggling something not selected adds active');
+ ok(optionsLis()[0].getElementsByTagName('input')[0].checked, 'toggling something not selected checks checkbox');
+ equal(canViewModel(treecombo, 'selected').length, 1, 'there is one selected item');
+ equal(canViewModel(treecombo, 'selected.0'), itemsList.attr('0'), 'the midwest is in selected');
+ canViewModel(treecombo, 'selected').pop();
+ equal(optionsLis()[0].className, '', 'toggling something not selected adds active');
+ canEvent.trigger.call(optionsLis()[0].getElementsByTagName('button')[0], 'click');
+ equal(breadcrumbLIs().length, 2, 'Only the default title is shown');
+ equal(innerHTML(breadcrumbLIs()[1]), 'Midwest', 'The breadcrumb has an item in it');
+ ok(/Illinois/.test(innerHTML(optionsLis()[0])), 'A child of the top breadcrumb is displayed');
+ canEvent.trigger.call(optionsLis()[0].getElementsByTagName('button')[0], 'click');
+ ok(/Chicago/.test(innerHTML(optionsLis()[0])), 'A child of the top breadcrumb is displayed');
+ ok(!optionsLis()[0].getElementsByTagName('button').length, 'no show children button');
+ canEvent.trigger.call(breadcrumbLIs()[1], 'click');
+ equal(innerHTML(breadcrumbLIs()[1]), 'Midwest', 'The breadcrumb has an item in it');
+ ok(/Illinois/.test(innerHTML(optionsLis()[0])), 'A child of the top breadcrumb is displayed');
+ canEvent.trigger.call(breadcrumbLIs()[0], 'click');
+ equal(breadcrumbLIs().length, 1, 'Only the default title is shown');
+ equal(innerHTML(breadcrumbLIs()[0]), 'Locations', 'The correct title from the attribute is shown');
+ start();
+ }, 100);
+ });
+ test('deferred grid', function () {
+ var GridViewModel = CanMap.extend({
+ items: [],
+ waiting: true
+ });
+ Component.extend({
+ tag: 'grid',
+ ViewModel: GridViewModel,
+ template: stache(''),
+ leakScope: true,
+ events: {
+ init: function () {
+ this.update();
+ },
+ '{viewModel} deferreddata': 'update',
+ update: function () {
+ var deferred = this.viewModel.attr('deferreddata'), viewModel = this.viewModel;
+ if (isPromise(deferred)) {
+ this.viewModel.attr('waiting', true);
+ deferred.then(function (items) {
+ viewModel.attr('items').attr(items, true);
+ });
+ } else {
+ viewModel.attr('items').attr(deferred, true);
+ }
+ },
+ '{items} change': function () {
+ this.viewModel.attr('waiting', false);
+ }
+ }
+ });
+ var SimulatedScope = CanMap.extend({
+ set: 0,
+ deferredData: function () {
+ var deferred = {};
+ var promise = new Promise(function (resolve, reject) {
+ deferred.resolve = resolve;
+ deferred.reject = reject;
+ });
+ var set = this.attr('set');
+ if (set === 0) {
+ setTimeout(function () {
+ deferred.resolve([{
+ first: 'Justin',
+ last: 'Meyer'
+ }]);
+ }, 100);
+ } else if (set === 1) {
+ setTimeout(function () {
+ deferred.resolve([{
+ first: 'Brian',
+ last: 'Moschel'
+ }]);
+ }, 100);
+ }
+ return promise;
+ }
+ });
+ var viewModel = new SimulatedScope();
+ var template = stache('' + '{{#each items}}' + '' + '{{first}} ' + '{{last}} ' + ' ' + '{{/each}}' + ' ');
+ domMutate.appendChild.call(this.fixture, template({ viewModel: viewModel }));
+ var gridScope = canViewModel(this.fixture.firstChild);
+ equal(gridScope.attr('waiting'), true, 'The grid is initially waiting on the deferreddata to resolve');
+ stop();
+ var self = this;
+ var waitingHandler = function () {
+ gridScope.unbind('waiting', waitingHandler);
+ setTimeout(function () {
+ var tds = self.fixture.getElementsByTagName('td');
+ equal(tds.length, 2, 'there are 2 tds');
+ gridScope.bind('waiting', function (ev, newVal) {
+ if (newVal === false) {
+ setTimeout(function () {
+ equal(innerHTML(tds[0]), 'Brian', 'td changed to brian');
+ start();
+ }, 10);
+ }
+ });
+ viewModel.attr('set', 1);
+ }, 100);
+ };
+ gridScope.bind('waiting', waitingHandler);
+ });
+ test('nextprev', function () {
+ Component.extend({
+ tag: 'next-prev',
+ template: stache('Prev ' + 'Next ')
+ });
+ var paginator = new Paginate({
+ limit: 20,
+ offset: 0,
+ count: 100
+ });
+ var template = stache(' ');
+ var frag = template({ paginator: paginator });
+ var nextPrev = frag.firstChild;
+ var prev = nextPrev.firstChild, next = nextPrev.lastChild;
+ ok(!/enabled/.test(prev.className), 'prev is not enabled');
+ ok(/enabled/.test(next.className), 'next is enabled');
+ canEvent.trigger.call(next, 'click');
+ ok(/enabled/.test(prev.className), 'prev is enabled');
+ });
+ test('page-count', function () {
+ Component.extend({
+ tag: 'page-count',
+ template: stache('Page {{page}} .')
+ });
+ var paginator = new Paginate({
+ limit: 20,
+ offset: 0,
+ count: 100
+ });
+ var template = stache(' ');
+ var frag = template(new CanMap({ paginator: paginator }));
+ var span = frag.firstChild.getElementsByTagName('span')[0];
+ equal(span.firstChild.nodeValue, '1');
+ paginator.next();
+ equal(span.firstChild.nodeValue, '2');
+ paginator.next();
+ equal(span.firstChild.nodeValue, '3');
+ });
+ test('hello-world and whitespace around custom elements', function () {
+ Component.extend({
+ tag: 'hello-world',
+ template: stache('{{#if visible}}{{message}}{{else}}Click me{{/if}}'),
+ viewModel: {
+ visible: false,
+ message: 'Hello There!'
+ },
+ events: {
+ click: function () {
+ this.viewModel.attr('visible', true);
+ }
+ }
+ });
+ var template = stache(' ');
+ var frag = template({});
+ var helloWorld = frag.childNodes.item(1);
+ canEvent.trigger.call(helloWorld, 'click');
+ equal(innerHTML(helloWorld), 'Hello There!');
+ });
+ test('self closing content tags', function () {
+ Component.extend({
+ 'tag': 'my-greeting',
+ template: stache(' '),
+ viewModel: { title: 'Component' }
+ });
+ var template = stache('{{site}} - {{title}} ');
+ var frag = template({ site: 'CanJS' });
+ equal(frag.firstChild.getElementsByTagName('span').length, 1, 'there is an h1');
+ });
+ test('canViewModel utility', function () {
+ Component({
+ tag: 'my-taggy-tag',
+ template: stache('hello '),
+ viewModel: { foo: 'bar' }
+ });
+ var frag = stache(' ')();
+ var el = frag.firstChild;
+ equal(canViewModel(el), domData.get.call(el, 'viewModel'), 'one argument grabs the viewModel object');
+ equal(canViewModel(el, 'foo'), 'bar', 'two arguments fetches a value');
+ canViewModel(el, 'foo', 'baz');
+ equal(canViewModel(el, 'foo'), 'baz', 'Three arguments sets the value');
+ });
+ test('canViewModel creates one if it doesn\'t exist', function () {
+ var frag = stache('
')();
+ var el = frag.firstChild;
+ var viewModel = canViewModel(el);
+ ok(!!viewModel, 'viewModel created where it didn\'t exist.');
+ equal(viewModel, domData.get.call(el, 'viewModel'), 'viewModel is in the data.');
+ });
+ test('setting passed variables - two way binding', function () {
+ Component.extend({
+ tag: 'my-toggler',
+ template: stache('{{#if visible}} {{/if}}'),
+ leakScope: true,
+ viewModel: {
+ visible: true,
+ show: function () {
+ this.attr('visible', true);
+ },
+ hide: function () {
+ this.attr('visible', false);
+ }
+ }
+ });
+ Component.extend({
+ tag: 'my-app',
+ viewModel: {
+ visible: true,
+ show: function () {
+ this.attr('visible', true);
+ }
+ }
+ });
+ var template = stache('' + '{{^visible}}show {{/visible}}' + '' + 'content' + 'hide ' + ' ' + ' ');
+ var frag = template({});
+ var myApp = frag.firstChild, buttons = myApp.getElementsByTagName('button');
+ equal(buttons.length, 1, 'there is one button');
+ equal(innerHTML(buttons[0]), 'hide', 'the button\'s text is hide');
+ canEvent.trigger.call(buttons[0], 'click');
+ buttons = myApp.getElementsByTagName('button');
+ equal(buttons.length, 1, 'there is one button');
+ equal(innerHTML(buttons[0]), 'show', 'the button\'s text is show');
+ canEvent.trigger.call(buttons[0], 'click');
+ buttons = myApp.getElementsByTagName('button');
+ equal(buttons.length, 1, 'there is one button');
+ equal(innerHTML(buttons[0]), 'hide', 'the button\'s text is hide');
+ });
+ test('helpers reference the correct instance (#515)', function () {
+ expect(2);
+ Component({
+ tag: 'my-text',
+ template: stache('{{valueHelper}}
'),
+ helpers: {
+ valueHelper: function () {
+ return this.attr('value');
+ }
+ }
+ });
+ var template = stache(' ');
+ var frag = template({});
+ equal(frag.firstChild.firstChild.firstChild.nodeValue, 'value1');
+ equal(frag.lastChild.firstChild.firstChild.nodeValue, 'value2');
+ });
+ test('access hypenated attributes via camelCase or hypenated', function () {
+ Component({
+ tag: 'hyphen',
+ template: stache('{{valueHelper}}
'),
+ helpers: {
+ valueHelper: function () {
+ return this.attr('camelCase');
+ }
+ }
+ });
+ var template = stache(' ');
+ var frag = template({});
+ equal(frag.firstChild.firstChild.firstChild.nodeValue, 'value1');
+ });
+ test('a map as viewModel', function () {
+ var me = new CanMap({ name: 'Justin' });
+ Component.extend({
+ tag: 'my-viewmodel',
+ template: stache('{{name}}}'),
+ viewModel: me
+ });
+ var template = stache(' ');
+ equal(template().firstChild.firstChild.nodeValue, 'Justin');
+ });
+ test('a CanMap constructor as viewModel', function () {
+ var MyMap = CanMap.extend({ name: 'Matthew' });
+ Component.extend({
+ tag: 'can-map-viewmodel',
+ template: stache('{{name}}'),
+ viewModel: MyMap
+ });
+ var template = stache(' ');
+ equal(template().firstChild.firstChild.nodeValue, 'Matthew');
+ });
+ test('a CanMap constructor as scope', function () {
+ var MyMap = CanMap.extend({ name: 'Matthew' });
+ Component.extend({
+ tag: 'can-map-viewmodel',
+ template: stache('{{name}}'),
+ scope: MyMap
+ });
+ var template = stache(' ');
+ equal(template().firstChild.firstChild.nodeValue, 'Matthew');
+ });
+ test('an object is turned into a CanMap as viewModel', function () {
+ Component.extend({
+ tag: 'can-map-viewmodel',
+ template: stache('{{name}}'),
+ viewModel: { name: 'Matthew' }
+ });
+ var template = stache(' ');
+ var fragOne = template();
+ var vmOne = canViewModel(fragOne.firstChild);
+ var fragTwo = template();
+ var vmTwo = canViewModel(fragTwo.firstChild);
+ vmOne.attr('name', 'Wilbur');
+ equal(fragOne.firstChild.firstChild.nodeValue, 'Wilbur', 'The first map changed values');
+ equal(fragTwo.firstChild.firstChild.nodeValue, 'Matthew', 'The second map did not change');
+ });
+ test('Providing viewModel and ViewModel throws', function () {
+ try {
+ Component.extend({
+ tag: 'viewmodel-test',
+ template: stache('
'),
+ viewModel: {},
+ ViewModel: CanMap.extend({})
+ });
+ ok(false, 'Should have thrown because we provided both');
+ } catch (er) {
+ ok(true, 'It threw because we provided both viewModel and ViewModel');
+ }
+ });
+ test('content in a list', function () {
+ var template = stache('{{name}} ');
+ Component.extend({
+ tag: 'my-list',
+ template: stache('{{#each items}} {{/each}}'),
+ leakScope: true,
+ viewModel: {
+ items: new CanList([
+ { name: 'one' },
+ { name: 'two' }
+ ])
+ }
+ });
+ var lis = template().firstChild.getElementsByTagName('li');
+ equal(innerHTML(lis[0]), 'one', 'first li has correct content');
+ equal(innerHTML(lis[1]), 'two', 'second li has correct content');
+ });
+ test('don\'t update computes unnecessarily', function () {
+ var sourceAge = 30, timesComputeIsCalled = 0;
+ var age = canCompute(function (newVal) {
+ timesComputeIsCalled++;
+ if (timesComputeIsCalled === 1) {
+ ok(true, 'reading initial value to set as years');
+ } else if (timesComputeIsCalled === 2) {
+ equal(newVal, 31, 'updating value to 31');
+ } else if (timesComputeIsCalled === 3) {
+ ok(true, 'called back another time after set to get the value');
+ } else {
+ ok(false, 'You\'ve called the callback ' + timesComputeIsCalled + ' times');
+ }
+ if (arguments.length) {
+ sourceAge = newVal;
+ } else {
+ return sourceAge;
+ }
+ });
+ Component.extend({ tag: 'age-er' });
+ var template = stache(' ');
+ template({ age: age });
+ age(31);
+ });
+ test('component does not respect canCompute passed via attributes (#540)', function () {
+ var data = { compute: canCompute(30) };
+ Component.extend({
+ tag: 'my-component',
+ template: stache('{{blocks}} ')
+ });
+ var template = stache(' ');
+ var frag = template(data);
+ equal(innerHTML(frag.firstChild.firstChild), '30');
+ });
+ test('defined view models (#563)', function () {
+ var HelloWorldModel = CanMap.extend({
+ visible: true,
+ toggle: function () {
+ this.attr('visible', !this.attr('visible'));
+ }
+ });
+ Component.extend({
+ tag: 'my-helloworld',
+ template: stache('{{#if visible}}visible{{else}}invisible{{/if}} '),
+ ViewModel: HelloWorldModel
+ });
+ var template = stache(' ');
+ var frag = template({});
+ equal(innerHTML(frag.firstChild.firstChild), 'visible');
+ });
+ test('viewModel not rebound correctly (#550)', function () {
+ var nameChanges = 0;
+ Component.extend({
+ tag: 'viewmodel-rebinder',
+ events: {
+ '{name} change': function () {
+ nameChanges++;
+ }
+ }
+ });
+ var template = stache(' ');
+ var frag = template();
+ var viewModel = canViewModel(frag.firstChild);
+ var n1 = canCompute(), n2 = canCompute();
+ viewModel.attr('name', n1);
+ n1('updated');
+ viewModel.attr('name', n2);
+ n2('updated');
+ equal(nameChanges, 2);
+ });
+ test('content extension stack overflow error', function () {
+ Component({
+ tag: 'outer-tag',
+ template: stache('inner-tag CONTENT ')
+ });
+ Component({
+ tag: 'inner-tag',
+ template: stache('inner-tag TEMPLATE ')
+ });
+ var template = stache('outer-tag CONTENT ');
+ var frag = template();
+ equal(innerHTML(frag.firstChild.firstChild), 'inner-tag TEMPLATE inner-tag CONTENT outer-tag CONTENT');
+ });
+ test('inserted event fires twice if component inside live binding block', function () {
+ var inited = 0, inserted = 0;
+ Component.extend({
+ tag: 'child-tag',
+ ViewModel: CanMap.extend({
+ init: function () {
+ inited++;
+ }
+ }),
+ events: {
+ ' inserted': function () {
+ inserted++;
+ }
+ }
+ });
+ Component.extend({
+ tag: 'parent-tag',
+ template: stache('{{#shown}} {{/shown}}'),
+ viewModel: { shown: false },
+ events: {
+ ' inserted': function () {
+ this.viewModel.attr('shown', true);
+ }
+ }
+ });
+ var frag = stache(' ')({});
+ domMutate.appendChild.call(this.fixture, frag);
+ stop();
+ setTimeout(function () {
+ equal(inited, 1, 'inited');
+ equal(inserted, 1, 'inserted');
+ start();
+ }, 100);
+ });
+ test('@ keeps properties live now', function () {
+ Component.extend({
+ tag: 'attr-fun',
+ template: stache('{{fullName}} '),
+ ViewModel: CanMap.extend({
+ fullName: function () {
+ return this.attr('firstName') + ' ' + this.attr('lastName');
+ }
+ })
+ });
+ var frag = stache(' ')();
+ var attrFun = frag.firstChild;
+ this.fixture.appendChild(attrFun);
+ equal(innerHTML(attrFun.firstChild), 'Justin Meyer');
+ attr.set(attrFun, 'first-name', 'Brian');
+ stop();
+ setTimeout(function () {
+ equal(attrFun.firstChild.firstChild.nodeValue, 'Brian Meyer');
+ start();
+ }, 100);
+ });
+ test('id and class should work now (#694)', function () {
+ Component.extend({
+ tag: 'stay-classy',
+ ViewModel: CanMap.extend({
+ notid: 'foo',
+ notclass: 5,
+ notdataviewid: {}
+ })
+ });
+ var data = {
+ idData: 'id-success',
+ classData: 'class-success'
+ };
+ var frag = stache(' ')(data);
+ var stayClassy = frag.firstChild;
+ domMutate.appendChild.call(this.fixture, frag);
+ var viewModel = canViewModel(stayClassy);
+ equal(viewModel.attr('id'), 'id-success');
+ equal(viewModel.attr('class'), 'class-success');
+ });
+ test('Component can-click method should be not called while component\'s init', function () {
+ var called = false;
+ Component.extend({ tag: 'child-tag' });
+ Component.extend({
+ tag: 'parent-tag',
+ template: stache(' '),
+ viewModel: {
+ method: function () {
+ called = true;
+ }
+ }
+ });
+ stache(' ')();
+ equal(called, false);
+ });
+ test('Same component tag nested', function () {
+ Component({
+ 'tag': 'my-tag',
+ template: stache('
')
+ });
+ var template = stache('OutterInner
');
+ var template2 = stache('3210
');
+ var template3 = stache('First Second
');
+ equal(template({}).firstChild.getElementsByTagName('p').length, 2, 'proper number of p tags');
+ equal(template2({}).firstChild.getElementsByTagName('p').length, 4, 'proper number of p tags');
+ equal(template3({}).firstChild.getElementsByTagName('p').length, 2, 'proper number of p tags');
+ });
+ test('Component events bind to window', function () {
+ window.tempMap = new CanMap();
+ Component.extend({
+ tag: 'window-events',
+ events: {
+ '{tempMap} prop': function () {
+ ok(true, 'called templated event');
+ }
+ }
+ });
+ var template = stache(' ');
+ template();
+ window.tempMap.attr('prop', 'value');
+ window.tempMap = undefined;
+ try {
+ delete window.tempMap;
+ } catch (e) {
+ }
+ });
+ test('Construct are passed normally', function () {
+ var Constructed = Construct.extend({ foo: 'bar' }, {});
+ Component.extend({
+ tag: 'con-struct',
+ template: stache('{{con.foo}}')
+ });
+ var stached = stache(' ');
+ var res = stached({ Constructed: Constructed });
+ equal(innerHTML(res.firstChild), 'bar');
+ });
+ test('passing id works now', function () {
+ Component.extend({
+ tag: 'my-thing',
+ template: stache('hello')
+ });
+ var template = stache('');
+ var frag = template(new CanMap({ productId: 123 }));
+ equal(canViewModel(frag.firstChild).attr('id'), 123);
+ });
+ test('stache conditionally nested components calls inserted once (#967)', function () {
+ expect(1);
+ Component.extend({
+ tag: 'can-parent-stache',
+ viewModel: { shown: true },
+ template: stache('{{#if shown}} {{/if}}')
+ });
+ Component.extend({
+ tag: 'can-child',
+ events: {
+ inserted: function () {
+ ok(true, 'called inserted once');
+ }
+ }
+ });
+ var template = stache(' ');
+ domMutate.appendChild.call(this.fixture, template());
+ stop();
+ setTimeout(start, 100);
+ });
+ test('hyphen-less tag names', function () {
+ Component.extend({
+ tag: 'foobar',
+ template: stache('{{name}}
'),
+ viewModel: { name: 'Brian' }
+ });
+ var template = stache(' ');
+ var frag = template();
+ equal(frag.lastChild.firstChild.firstChild.nodeValue, 'Brian');
+ });
+ test('nested component within an #if is not live bound(#1025)', function () {
+ Component.extend({
+ tag: 'parent-component',
+ template: stache('{{#if shown}} {{/if}}'),
+ viewModel: { shown: false }
+ });
+ Component.extend({
+ tag: 'child-component',
+ template: stache('Hello world.')
+ });
+ var template = stache(' ');
+ var frag = template({});
+ equal(innerHTML(frag.firstChild), '', 'child component is not inserted');
+ canViewModel(frag.firstChild).attr('shown', true);
+ equal(innerHTML(frag.firstChild.firstChild), 'Hello world.', 'child component is inserted');
+ canViewModel(frag.firstChild).attr('shown', false);
+ equal(innerHTML(frag.firstChild), '', 'child component is removed');
+ });
+ test('component does not update viewModel on id, class, and data-view-id attribute changes (#1079)', function () {
+ Component.extend({ tag: 'x-app' });
+ var frag = stache(' ')({});
+ var el = frag.firstChild;
+ var viewModel = canViewModel(el);
+ domMutate.appendChild.call(this.fixture, frag);
+ className.add.call(el, 'foo');
+ stop();
+ setTimeout(function () {
+ equal(viewModel.attr('class'), undefined, 'the viewModel is not updated when the class attribute changes');
+ start();
+ }, 100);
+ });
+ test('viewModel objects with Constructor functions as properties do not get converted (#1261)', 1, function () {
+ stop();
+ var Test = CanMap.extend({ test: 'Yeah' });
+ Component.extend({
+ tag: 'my-app',
+ viewModel: { MyConstruct: Test },
+ events: {
+ '{MyConstruct} something': function () {
+ ok(true, 'Event got triggered');
+ start();
+ }
+ }
+ });
+ var frag = stache(' ')();
+ domMutate.appendChild.call(this.fixture, frag);
+ canEvent.trigger.call(Test, 'something');
+ });
+ test('removing bound viewModel properties on destroy #1415', function () {
+ var state = new CanMap({
+ product: {
+ id: 1,
+ name: 'Tom'
+ }
+ });
+ Component.extend({
+ tag: 'destroyable-component',
+ events: {
+ destroy: function () {
+ this.viewModel.attr('product', null);
+ }
+ }
+ });
+ var frag = stache(' ')(state);
+ domMutate.appendChild.call(this.fixture, frag);
+ domMutate.removeChild.call(this.fixture, this.fixture.firstChild);
+ stop();
+ setTimeout(function () {
+ ok(state.attr('product') == null, 'product was removed');
+ start();
+ }, 100);
+ });
+ test('changing viewModel property rebinds {viewModel.<...>} events (#1529)', 2, function () {
+ Component.extend({
+ tag: 'rebind-viewmodel',
+ events: {
+ init: function () {
+ this.viewModel.attr('item', {});
+ },
+ '{scope.item} change': function () {
+ ok(true, 'Change event on scope');
+ },
+ '{viewModel.item} change': function () {
+ ok(true, 'Change event on viewModel');
+ }
+ }
+ });
+ var frag = stache(' ')();
+ var rebind = frag.firstChild;
+ domMutate.appendChild.call(this.fixture, rebind);
+ canViewModel(rebind).attr('item.name', 'CDN');
+ });
+ test('Component two way binding loop (#1579)', function () {
+ var changeCount = 0;
+ Component.extend({
+ tag: 'product-swatch-color',
+ viewModel: { tag: 'product-swatch-color' }
+ });
+ Component.extend({
+ tag: 'product-swatch',
+ template: stache(' '),
+ ViewModel: CanMap.extend({
+ tag: 'product-swatch',
+ define: {
+ variations: {
+ set: function (variations) {
+ if (changeCount > 500) {
+ return;
+ }
+ changeCount++;
+ return new CanList(variations.attr());
+ }
+ }
+ }
+ })
+ });
+ var frag = stache(' ')(), productSwatch = frag.firstChild;
+ canBatch.start();
+ canViewModel(productSwatch).attr('variations', new CanList());
+ canBatch.stop();
+ ok(changeCount < 500, 'more than 500 events');
+ });
+ test('references scopes are available to bindings nested in components (#2029)', function () {
+ var template = stache(' ' + ' ');
+ Component.extend({ tag: 'wrap-er' });
+ Component.extend({
+ tag: 'export-er',
+ events: {
+ 'init': function () {
+ var self = this.viewModel;
+ stop();
+ setTimeout(function () {
+ self.attr('value', 100);
+ var wrapper = frag.lastChild, simpleExample = wrapper.firstChild, textNode = simpleExample.firstChild;
+ equal(textNode.nodeValue, '100', 'updated value with reference');
+ start();
+ }, 100);
+ }
+ }
+ });
+ Component.extend({
+ tag: 'simple-example',
+ template: stache('{{key}}'),
+ viewModel: {}
+ });
+ var frag = template({});
+ });
+ test('two-way binding syntax PRIOR to v2.3 shall NOT let a child property initialize an undefined parent property (#2020)', function () {
+ var renderer = stache(' ');
+ Component.extend({
+ tag: 'pa-rent',
+ template: stache(' ')
+ });
+ Component.extend({
+ tag: 'chi-ld',
+ viewModel: { childProp: 'bar' }
+ });
+ var frag = renderer({});
+ var parentVM = canViewModel(frag.firstChild);
+ var childVM = canViewModel(frag.firstChild.firstChild);
+ equal(parentVM.attr('parentProp'), undefined, 'parentProp is undefined');
+ equal(childVM.attr('childProp'), 'bar', 'childProp is bar');
+ parentVM.attr('parentProp', 'foo');
+ equal(parentVM.attr('parentProp'), 'foo', 'parentProp is foo');
+ equal(childVM.attr('childProp'), 'foo', 'childProp is foo');
+ childVM.attr('childProp', 'baz');
+ equal(parentVM.attr('parentProp'), 'baz', 'parentProp is baz');
+ equal(childVM.attr('childProp'), 'baz', 'childProp is baz');
+ });
+ test('two-way binding syntax INTRODUCED in v2.3 ALLOWS a child property to initialize an undefined parent property', function () {
+ var renderer = stache(' ');
+ Component.extend({
+ tag: 'pa-rent',
+ template: stache(' ')
+ });
+ Component.extend({
+ tag: 'chi-ld',
+ viewModel: { childProp: 'bar' }
+ });
+ var frag = renderer({});
+ var parentVM = canViewModel(frag.firstChild);
+ var childVM = canViewModel(frag.firstChild.firstChild);
+ equal(parentVM.attr('parentProp'), 'bar', 'parentProp is bar');
+ equal(childVM.attr('childProp'), 'bar', 'childProp is bar');
+ parentVM.attr('parentProp', 'foo');
+ equal(parentVM.attr('parentProp'), 'foo', 'parentProp is foo');
+ equal(childVM.attr('childProp'), 'foo', 'childProp is foo');
+ childVM.attr('childProp', 'baz');
+ equal(parentVM.attr('parentProp'), 'baz', 'parentProp is baz');
+ equal(childVM.attr('childProp'), 'baz', 'childProp is baz');
+ });
+ test('conditional attributes (#2077)', function () {
+ Component.extend({ tag: 'some-comp' });
+ var template = stache(' ');
+ var map = new CanMap({
+ preview: true,
+ nextPage: 2,
+ swapName: 'preview'
+ });
+ var frag = template(map);
+ var vm = canViewModel(frag.firstChild);
+ var threads = [
+ function () {
+ equal(vm.attr('next'), 2, 'has binidng');
+ equal(vm.attr('swap'), true, 'swap - has binding');
+ equal(vm.attr('checked'), '', 'attr - has binding');
+ map.attr('preview', false);
+ },
+ function () {
+ equal(vm.attr('swap'), false, 'swap - updated binidng');
+ ok(vm.attr('checked') === null, 'attr - value set to null');
+ map.attr('nextPage', 3);
+ equal(vm.attr('next'), 2, 'not updating after binding is torn down');
+ map.attr('preview', true);
+ },
+ function () {
+ equal(vm.attr('next'), 3, 're-initialized with binding');
+ equal(vm.attr('swap'), true, 'swap - updated binidng');
+ equal(vm.attr('checked'), '', 'attr - has binding set again');
+ map.attr('swapName', 'nextPage');
+ },
+ function () {
+ equal(vm.attr('swap'), 3, 'swap - updated binding key');
+ map.attr('nextPage', 4);
+ equal(vm.attr('swap'), 4, 'swap - updated binding');
+ }
+ ];
+ stop();
+ var index = 0;
+ var next = function () {
+ if (index < threads.length) {
+ threads[index]();
+ index++;
+ setTimeout(next, 100);
+ } else {
+ start();
+ }
+ };
+ setTimeout(next, 100);
+ });
+ test(' (#2151)', function () {
+ var mapInstance = new CanMap({
+ items: [
+ {
+ id: 1,
+ context: 'Item 1',
+ render: false
+ },
+ {
+ id: 2,
+ context: 'Item 2',
+ render: false
+ }
+ ]
+ });
+ Component.extend({
+ tag: 'list-items',
+ template: stache('' + '{{#items}}' + '{{#if render}}' + ' ' + '{{/if}}' + '{{/items}}' + ' '),
+ viewModel: mapInstance,
+ leakScope: true
+ });
+ Component.extend({
+ tag: 'list-item',
+ template: stache('{{item.context}}')
+ });
+ var template = stache(' ');
+ var frag = template();
+ canBatch.start();
+ canViewModel(frag.firstChild).attr('items').each(function (item, index) {
+ item.attr('render', true);
+ });
+ canBatch.stop();
+ var lis = frag.firstChild.getElementsByTagName('li');
+ ok(innerHTML(lis[0]).indexOf('Item 1') >= 0, 'Item 1 written out');
+ ok(innerHTML(lis[1]).indexOf('Item 2') >= 0, 'Item 2 written out');
+ });
+ test('one-way - child to parent - parent that does not leak scope, but has no template', function () {
+ Component.extend({
+ tag: 'outer-noleak',
+ viewModel: { isOuter: true },
+ leakScope: false
+ });
+ Component.extend({
+ tag: 'my-child',
+ viewModel: { isChild: true },
+ leakScope: false
+ });
+ var template = stache(' ');
+ var frag = template();
+ var vm = canViewModel(frag.firstChild);
+ ok(vm.attr('myChild') instanceof CanMap, 'got instance');
+ });
+ test('two-way - reference - with tag', function () {
+ Component.extend({
+ tag: 'other-export',
+ viewModel: { name: 'OTHER-EXPORT' }
+ });
+ Component.extend({
+ tag: 'ref-export',
+ view: stache('{{*otherExport}} ')
+ });
+ var t1 = stache(' ');
+ var f1 = t1();
+ equal(canViewModel(f1.firstChild.firstChild).attr('name'), 'OTHER-EXPORT', 'viewModel set correctly');
+ equal(f1.firstChild.lastChild.nodeValue, 'OTHER-EXPORT', 'content');
+ });
+ test('custom renderer can provide setupBindings', function () {
+ DOCUMENT(document);
+ var renderer = function (tmpl) {
+ var frag = getFragment(tmpl);
+ return function (scope, options) {
+ scope = scope || new Scope();
+ options = options || new Scope.Options({});
+ if (frag.firstChild.nodeName === 'CUSTOM-RENDERER') {
+ viewCallbacks.tagHandler(frag.firstChild, 'custom-renderer', {
+ scope: scope,
+ options: options,
+ templateType: 'my-renderer',
+ setupBindings: function (el, callback, data) {
+ callback({ foo: 'qux' });
+ }
+ });
+ } else {
+ var tn = frag.firstChild.firstChild;
+ tn.nodeValue = scope.read('foo').value;
+ }
+ return frag;
+ };
+ };
+ Component.extend({
+ tag: 'custom-renderer',
+ template: renderer('{{foo}}
'),
+ ViewModel: CanMap.extend({})
+ });
+ var template = renderer(' ');
+ var frag = template();
+ var tn = frag.firstChild.firstChild.firstChild;
+ equal(tn.nodeValue, 'qux', 'was bound!');
+ });
+ if (System.env !== 'canjs-test') {
+ test('basic tabs', function () {
+ var TabsViewModel = CanMap.extend({
+ init: function () {
+ this.attr('panels', []);
+ },
+ addPanel: function (panel) {
+ if (this.attr('panels').length === 0) {
+ this.makeActive(panel);
+ }
+ this.attr('panels').push(panel);
+ },
+ removePanel: function (panel) {
+ var panels = this.attr('panels');
+ canBatch.start();
+ var index = panels.indexOf(panel);
+ console.log(index);
+ panels.splice(index, 1);
+ if (panel === this.attr('active')) {
+ if (panels.length) {
+ this.makeActive(panels[0]);
+ } else {
+ this.removeAttr('active');
+ }
+ }
+ canBatch.stop();
+ },
+ makeActive: function (panel) {
+ this.attr('active', panel);
+ this.attr('panels').each(function (panel) {
+ panel.attr('active', false);
+ });
+ panel.attr('active', true);
+ },
+ isActive: function (panel) {
+ return this.attr('active') === panel;
+ }
+ });
+ Component.extend({
+ tag: 'tabs',
+ ViewModel: TabsViewModel,
+ template: stache('' + '{{#panels}}' + '{{title}} ' + '{{/panels}}' + ' ' + ' ')
+ });
+ Component.extend({
+ template: stache('{{#if active}} {{/if}}'),
+ tag: 'panel',
+ ViewModel: CanMap.extend({ active: false }),
+ events: {
+ ' inserted': function () {
+ canViewModel(this.element.parentNode).addPanel(this.viewModel);
+ },
+ ' beforeremove': function () {
+ console.log('I AM BEING REMOVED');
+ canViewModel(this.element.parentNode).removePanel(this.viewModel);
+ }
+ }
+ });
+ var template = stache('{{#each foodTypes}}{{content}} {{/each}} ');
+ var foodTypes = new CanList([
+ {
+ title: 'Fruits',
+ content: 'oranges, apples'
+ },
+ {
+ title: 'Breads',
+ content: 'pasta, cereal'
+ },
+ {
+ title: 'Sweets',
+ content: 'ice cream, candy'
+ }
+ ]);
+ var frag = template({ foodTypes: foodTypes });
+ domMutate.appendChild.call(this.fixture, frag);
+ var testArea = this.fixture;
+ stop();
+ runTasks([
+ function () {
+ var lis = testArea.getElementsByTagName('li');
+ equal(lis.length, 3, 'three lis added');
+ foodTypes.each(function (type, i) {
+ equal(innerHTML(lis[i]), type.attr('title'), 'li ' + i + ' has the right content');
+ });
+ foodTypes.push({
+ title: 'Vegies',
+ content: 'carrots, kale'
+ });
+ },
+ function () {
+ var lis = testArea.getElementsByTagName('li');
+ equal(lis.length, 4, 'li added');
+ foodTypes.each(function (type, i) {
+ equal(innerHTML(lis[i]), type.attr('title'), 'li ' + i + ' has the right content');
+ });
+ equal(testArea.getElementsByTagName('panel').length, 4, 'panel added');
+ console.log('SHIFTY');
+ foodTypes.shift();
+ },
+ function () {
+ var lis = testArea.getElementsByTagName('li');
+ equal(lis.length, 3, 'removed li after shifting a foodType');
+ foodTypes.each(function (type, i) {
+ equal(innerHTML(lis[i]), type.attr('title'), 'li ' + i + ' has the right content');
+ });
+ var panels = testArea.getElementsByTagName('panel');
+ equal(lis[0].className, 'active', 'the first element is active');
+ equal(innerHTML(panels[0]), 'pasta, cereal', 'the first content is shown');
+ equal(innerHTML(panels[1]), '', 'the second content is removed');
+ canEvent.trigger.call(lis[1], 'click');
+ lis = testArea.getElementsByTagName('li');
+ equal(lis[1].className, 'active', 'the second element is active');
+ equal(lis[0].className, '', 'the first element is not active');
+ equal(innerHTML(panels[0]), '', 'the second content is removed');
+ equal(innerHTML(panels[1]), 'ice cream, candy', 'the second content is shown');
+ }
+ ]);
+ });
+ test('DOM trees not releasing when referencing CanMap inside CanMap in template (#1593)', function () {
+ var baseTemplate = stache('{{#if show}} {{/if}}'), show = canCompute(true), state = new CanMap({ inner: 1 });
+ var removeCount = 0;
+ Component.extend({
+ tag: 'my-inside',
+ events: {
+ removed: function () {
+ removeCount++;
+ }
+ },
+ leakScope: true
+ });
+ Component.extend({
+ tag: 'my-outside',
+ template: stache('{{#if state.inner}} {{/if}}'),
+ leakScope: true
+ });
+ domMutate.appendChild.call(this.fixture, baseTemplate({
+ show: show,
+ state: state
+ }));
+ runTasks([
+ function () {
+ show(false);
+ },
+ function () {
+ state.removeAttr('inner');
+ },
+ function () {
+ equal(removeCount, 1, 'internal removed once');
+ show(true);
+ },
+ function () {
+ state.attr('inner', 2);
+ },
+ function () {
+ state.removeAttr('inner');
+ },
+ function () {
+ equal(removeCount, 2, 'internal removed twice');
+ }
+ ]);
+ stop();
+ });
+ }
+ }
+});
+/*can-component@3.0.2#test/component-test*/
+define('can-component@3.0.2#test/component-test', function (require, exports, module) {
+ require('./component-define-test');
+ require('./component-map-test');
+});
+/*can@3.0.0#component/component_test*/
+define('can@3.0.0#component/component_test', function (require, exports, module) {
+ require('can-component/test/component-test');
+});
+/*can-event@3.0.1#async/async*/
+define('can-event@3.0.1#async/async', function (require, exports, module) {
+ var canEvent = require('can-event');
+ var canBatch = require('can-event/batch/batch');
+ var setImmediate = require('can-util/js/set-immediate/set-immediate');
+ var GLOBAL = require('can-util/js/global/global')();
+ var assign = require('can-util/js/assign/assign');
+ var timeout;
+ var clearImmediate = GLOBAL.clearImmediate || GLOBAL.clearTimeout;
+ var syncBatchDispatch = canBatch.dispatch;
+ var syncBatchQueue = canBatch.queue;
+ var syncBatchFlush = canBatch.flush;
+ var asyncMethods = {
+ dispatch: function (ev) {
+ var batchNum = typeof ev === 'object' && ev.batchNum;
+ if (!canBatch.collecting() && (!batchNum || canBatch.batchNum !== batchNum)) {
+ canBatch.start();
+ timeout = setImmediate(canBatch.stop);
+ }
+ return syncBatchDispatch.apply(this, arguments);
+ },
+ queue: function () {
+ if (!canBatch.collecting()) {
+ canBatch.start();
+ timeout = setImmediate(canBatch.stop);
+ }
+ return syncBatchQueue.apply(this, arguments);
+ },
+ flush: function () {
+ if (isAsync && canBatch.collecting()) {
+ clearImmediate(timeout);
+ canBatch.stop();
+ }
+ canBatch.flush();
+ }
+ };
+ var syncMethods = assign({ flush: syncBatchFlush }, canEvent);
+ var isAsync = false;
+ var eventAsync = {
+ async: function () {
+ assign(canEvent, asyncMethods);
+ isAsync = true;
+ },
+ sync: function () {
+ if (canBatch.collecting()) {
+ clearImmediate(timeout);
+ canBatch.stop();
+ }
+ assign(canEvent, syncMethods);
+ isAsync = false;
+ }
+ };
+ assign(eventAsync, asyncMethods);
+ module.exports = eventAsync;
+});
+/*can-compute@3.0.3#can-compute-async-test*/
+define('can-compute@3.0.3#can-compute-async-test', function (require, exports, module) {
+ var compute = require('can-compute');
+ var QUnit = require('steal-qunit');
+ require('can-event/batch/batch');
+ var canAsync = require('can-event/async/async');
+ QUnit.module('can-compute async', {
+ setup: function () {
+ canAsync.async();
+ },
+ teardown: function () {
+ canAsync.sync();
+ }
+ });
+ QUnit.asyncTest('async basics', 2, function () {
+ var canAsync = require('can-event/async/async');
+ canAsync.async();
+ var first = compute('Justin');
+ var last = compute('Meyer');
+ var fullName = compute(function () {
+ return first() + ' ' + last();
+ });
+ fullName.on('change', function (ev, newVal, oldVal) {
+ QUnit.equal(newVal, 'Payal Shah', 'newVal');
+ QUnit.equal(oldVal, 'Justin Meyer', 'oldVal');
+ QUnit.start();
+ });
+ first('Payal');
+ last('Shah');
+ });
+ QUnit.asyncTest('async can immediately read', 4, function () {
+ var canAsync = require('can-event/async/async');
+ canAsync.async();
+ var compute = require('can-compute');
+ var first = compute('Justin');
+ var last = compute('Meyer');
+ var fullName = compute(function () {
+ return first() + ' ' + last();
+ });
+ var firedEvents = false;
+ fullName.on('change', function (ev, newVal, oldVal) {
+ QUnit.equal(newVal, 'Payal Shah', 'change newVal');
+ QUnit.equal(oldVal, 'Justin Meyer', 'change oldVal');
+ firedEvents = true;
+ QUnit.start();
+ });
+ first('Payal');
+ last('Shah');
+ QUnit.equal(fullName(), 'Payal Shah');
+ QUnit.ok(firedEvents, 'fired events');
+ });
+});
+/*can-define@1.0.4#list/list*/
+define('can-define@1.0.4#list/list', function (require, exports, module) {
+ var Construct = require('can-construct');
+ var define = require('can-define');
+ var make = define.make;
+ var canEvent = require('can-event');
+ var canBatch = require('can-event/batch/batch');
+ var Observation = require('can-observation');
+ var defineHelpers = require('../define-helpers/define-helpers');
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var isArray = require('can-util/js/is-array/is-array');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var types = require('can-util/js/types/types');
+ var ns = require('can-util/namespace');
+ var splice = [].splice;
+ var serializeNonTypes = function (MapType, arg, args) {
+ if (arg && arg.serialize && !(arg instanceof MapType)) {
+ args.push(new MapType(arg.serialize()));
+ } else {
+ args.push(arg);
+ }
+ };
+ var identity = function (x) {
+ return x;
+ };
+ var makeFilterCallback = function (props) {
+ return function (item) {
+ for (var prop in props) {
+ if (item[prop] !== props[prop]) {
+ return false;
+ }
+ }
+ return true;
+ };
+ };
+ var DefineList = Construct.extend('DefineList', {
+ setup: function (base) {
+ if (DefineList) {
+ var prototype = this.prototype;
+ var result = define(prototype, prototype, base.prototype._define);
+ var itemsDefinition = result.definitions['#'] || result.defaultDefinition;
+ if (itemsDefinition) {
+ if (itemsDefinition.Type) {
+ this.prototype.__type = make.set.Type('*', itemsDefinition.Type, identity);
+ } else if (itemsDefinition.type) {
+ this.prototype.__type = make.set.type('*', itemsDefinition.type, identity);
+ }
+ }
+ }
+ }
+ }, {
+ setup: function (items) {
+ if (!this._define) {
+ Object.defineProperty(this, '_define', {
+ enumerable: false,
+ value: { definitions: {} }
+ });
+ Object.defineProperty(this, '_data', {
+ enumerable: false,
+ value: {}
+ });
+ }
+ define.setup.call(this, {}, false);
+ this._length = 0;
+ if (items) {
+ this.splice.apply(this, [
+ 0,
+ 0
+ ].concat(defineHelpers.toObject(this, items, [], DefineList)));
+ }
+ },
+ __type: define.types.observable,
+ _triggerChange: function (attr, how, newVal, oldVal) {
+ canBatch.start();
+ var index = +attr;
+ if (!~('' + attr).indexOf('.') && !isNaN(index)) {
+ var itemsDefinition = this._define.definitions['#'];
+ if (how === 'add') {
+ if (itemsDefinition && typeof itemsDefinition.added === 'function') {
+ Observation.ignore(itemsDefinition.added).call(this, newVal, index);
+ }
+ canEvent.dispatch.call(this, how, [
+ newVal,
+ index
+ ]);
+ canEvent.dispatch.call(this, 'length', [this._length]);
+ } else if (how === 'remove') {
+ if (itemsDefinition && typeof itemsDefinition.removed === 'function') {
+ Observation.ignore(itemsDefinition.removed).call(this, oldVal, index);
+ }
+ canEvent.dispatch.call(this, how, [
+ oldVal,
+ index
+ ]);
+ canEvent.dispatch.call(this, 'length', [this._length]);
+ } else {
+ canEvent.dispatch.call(this, how, [
+ newVal,
+ index
+ ]);
+ }
+ } else {
+ canEvent.dispatch.call(this, {
+ type: '' + attr,
+ target: this
+ }, [
+ newVal,
+ oldVal
+ ]);
+ }
+ canBatch.stop();
+ },
+ get: function (index) {
+ if (arguments.length) {
+ Observation.add(this, '' + index);
+ return this[index];
+ } else {
+ return defineHelpers.serialize(this, 'get', []);
+ }
+ },
+ set: function (prop, value) {
+ if (typeof prop !== 'object') {
+ prop = isNaN(+prop) || prop % 1 ? prop : +prop;
+ if (typeof prop === 'number') {
+ if (typeof prop === 'number' && prop > this._length - 1) {
+ var newArr = new Array(prop + 1 - this._length);
+ newArr[newArr.length - 1] = value;
+ this.push.apply(this, newArr);
+ return newArr;
+ }
+ this.splice(prop, 1, value);
+ } else {
+ var defined = defineHelpers.defineExpando(this, prop, value);
+ if (!defined) {
+ this[prop] = value;
+ }
+ }
+ } else {
+ if (isArray(prop)) {
+ if (value) {
+ this.replace(prop);
+ } else {
+ this.splice.apply(this, [
+ 0,
+ prop.length
+ ].concat(prop));
+ }
+ } else {
+ each(prop, function (value, prop) {
+ this.set(prop, value);
+ }, this);
+ }
+ }
+ return this;
+ },
+ _items: function () {
+ var arr = [];
+ this._each(function (item) {
+ arr.push(item);
+ });
+ return arr;
+ },
+ _each: function (callback) {
+ for (var i = 0, len = this._length; i < len; i++) {
+ callback(this[i], i);
+ }
+ },
+ splice: function (index, howMany) {
+ var args = makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2;
+ index = index || 0;
+ for (i = 0, len = args.length - 2; i < len; i++) {
+ listIndex = i + 2;
+ args[listIndex] = this.__type(args[listIndex], listIndex);
+ added.push(args[listIndex]);
+ if (this[i + index] !== args[listIndex]) {
+ allSame = false;
+ }
+ }
+ if (allSame && this._length <= added.length) {
+ return added;
+ }
+ if (howMany === undefined) {
+ howMany = args[1] = this._length - index;
+ }
+ var removed = splice.apply(this, args);
+ canBatch.start();
+ if (howMany > 0) {
+ this._triggerChange('' + index, 'remove', undefined, removed);
+ }
+ if (args.length > 2) {
+ this._triggerChange('' + index, 'add', added, removed);
+ }
+ canBatch.stop();
+ return removed;
+ },
+ serialize: function () {
+ return defineHelpers.serialize(this, 'serialize', []);
+ }
+ });
+ var getArgs = function (args) {
+ return args[0] && Array.isArray(args[0]) ? args[0] : makeArray(args);
+ };
+ each({
+ push: 'length',
+ unshift: 0
+ }, function (where, name) {
+ var orig = [][name];
+ DefineList.prototype[name] = function () {
+ var args = [], len = where ? this._length : 0, i = arguments.length, res, val;
+ while (i--) {
+ val = arguments[i];
+ args[i] = this.__type(val, i);
+ }
+ res = orig.apply(this, args);
+ if (!this.comparator || args.length) {
+ this._triggerChange('' + len, 'add', args, undefined);
+ }
+ return res;
+ };
+ });
+ each({
+ pop: 'length',
+ shift: 0
+ }, function (where, name) {
+ DefineList.prototype[name] = function () {
+ if (!this._length) {
+ return undefined;
+ }
+ var args = getArgs(arguments), len = where && this._length ? this._length - 1 : 0;
+ var res = [][name].apply(this, args);
+ this._triggerChange('' + len, 'remove', undefined, [res]);
+ return res;
+ };
+ });
+ assign(DefineList.prototype, {
+ indexOf: function (item, fromIndex) {
+ for (var i = fromIndex || 0, len = this.length; i < len; i++) {
+ if (this.get(i) === item) {
+ return i;
+ }
+ }
+ return -1;
+ },
+ join: function () {
+ Observation.add(this, 'length');
+ return [].join.apply(this, arguments);
+ },
+ reverse: function () {
+ var list = [].reverse.call(this._items());
+ return this.replace(list);
+ },
+ slice: function () {
+ Observation.add(this, 'length');
+ var temp = Array.prototype.slice.apply(this, arguments);
+ return new this.constructor(temp);
+ },
+ concat: function () {
+ var args = [], MapType = this.constructor.DefineMap;
+ each(arguments, function (arg) {
+ if (types.isListLike(arg) || Array.isArray(arg)) {
+ var arr = types.isListLike(arg) ? makeArray(arg) : arg;
+ each(arr, function (innerArg) {
+ serializeNonTypes(MapType, innerArg, args);
+ });
+ } else {
+ serializeNonTypes(MapType, arg, args);
+ }
+ });
+ return new this.constructor(Array.prototype.concat.apply(makeArray(this), args));
+ },
+ forEach: function (cb, thisarg) {
+ var item;
+ for (var i = 0, len = this.length; i < len; i++) {
+ item = this.get(i);
+ if (cb.call(thisarg || item, item, i, this) === false) {
+ break;
+ }
+ }
+ return this;
+ },
+ replace: function (newList) {
+ this.splice.apply(this, [
+ 0,
+ this._length
+ ].concat(makeArray(newList || [])));
+ return this;
+ },
+ filter: function (callback, thisArg) {
+ var filteredList = [], self = this, filtered;
+ if (typeof callback === 'object') {
+ callback = makeFilterCallback(callback);
+ }
+ this.each(function (item, index, list) {
+ filtered = callback.call(thisArg | self, item, index, self);
+ if (filtered) {
+ filteredList.push(item);
+ }
+ });
+ return new this.constructor(filteredList);
+ },
+ map: function (callback, thisArg) {
+ var mappedList = [], self = this;
+ this.each(function (item, index, list) {
+ var mapped = callback.call(thisArg | self, item, index, self);
+ mappedList.push(mapped);
+ });
+ return new this.constructor(mappedList);
+ },
+ sort: function (compareFunction) {
+ Array.prototype.sort.call(this, compareFunction);
+ return this.replace(this.get());
+ }
+ });
+ for (var prop in define.eventsProto) {
+ Object.defineProperty(DefineList.prototype, prop, {
+ enumerable: false,
+ value: define.eventsProto[prop],
+ writable: true
+ });
+ }
+ Object.defineProperty(DefineList.prototype, 'length', {
+ get: function () {
+ if (!this.__inSetup) {
+ Observation.add(this, 'length');
+ }
+ return this._length;
+ },
+ set: function (newVal) {
+ this._length = newVal;
+ },
+ enumerable: true
+ });
+ var oldIsListLike = types.isListLike;
+ types.isListLike = function (obj) {
+ return obj instanceof DefineList || oldIsListLike.apply(this, arguments);
+ };
+ DefineList.prototype.each = DefineList.prototype.forEach;
+ DefineList.prototype.attr = function (prop, value) {
+ console.warn('DefineMap::attr shouldn\'t be called');
+ if (arguments.length === 0) {
+ return this.get();
+ } else if (prop && typeof prop === 'object') {
+ return this.set.apply(this, arguments);
+ } else if (arguments.length === 1) {
+ return this.get(prop);
+ } else {
+ return this.set(prop, value);
+ }
+ };
+ DefineList.prototype.item = function (index, value) {
+ if (arguments.length === 1) {
+ return this.get(index);
+ } else {
+ return this.set(index, value);
+ }
+ };
+ DefineList.prototype.items = function () {
+ console.warn('DefineList::get should should be used instead of DefineList::items');
+ return this.get();
+ };
+ types.DefineList = DefineList;
+ types.DefaultList = DefineList;
+ module.exports = ns.DefineList = DefineList;
+});
+/*can-compute@3.0.3#can-compute_test*/
+define('can-compute@3.0.3#can-compute_test', function (require, exports, module) {
+ require('./can-compute-async-test');
+ var compute = require('can-compute');
+ var Compute = require('can-compute/proto-compute');
+ var QUnit = require('steal-qunit');
+ var canBatch = require('can-event/batch/');
+ var Observation = require('can-observation');
+ var DefineMap = require('can-define/map/map');
+ var DefineList = require('can-define/list/list');
+ var domDispatch = require('can-util/dom/dispatch/dispatch');
+ QUnit.module('can/compute');
+ test('single value compute', function () {
+ var num = compute(1);
+ num.on('change', function (ev, newVal, oldVal) {
+ equal(newVal, 2, 'newVal');
+ equal(oldVal, 1, 'oldVal');
+ });
+ num(2);
+ });
+ test('inner computes values are not bound to', function () {
+ var num = compute(1);
+ var outer = compute(function () {
+ var inner = compute(function () {
+ return num() + 1;
+ });
+ return 2 * inner();
+ });
+ var handler = function () {
+ };
+ outer.on('change', handler);
+ stop();
+ setTimeout(function () {
+ equal(num.computeInstance._bindings, 1, 'inner compute only bound once');
+ equal(outer.computeInstance._bindings, 1, 'outer compute only bound once');
+ start();
+ }, 50);
+ });
+ test('compute.truthy', function () {
+ var result = 0;
+ var numValue;
+ var num = compute(numValue = 3);
+ var truthy = compute.truthy(num);
+ var tester = compute(function () {
+ if (truthy()) {
+ return ++result;
+ } else {
+ return ++result;
+ }
+ });
+ tester.addEventListener('change', function (ev, newVal, oldVal) {
+ if (num() === 0) {
+ equal(newVal, 2, '2 is the new val');
+ } else if (num() === -1) {
+ equal(newVal, 3, '3 is the new val');
+ } else {
+ ok(false, 'change should not be called');
+ }
+ });
+ equal(tester(), 1, 'on bind, we call tester once');
+ num(numValue = 2);
+ num(numValue = 1);
+ num(numValue = 0);
+ num(numValue = -1);
+ });
+ test('a binding compute does not double read', function () {
+ var sourceAge = 30, timesComputeIsCalled = 0;
+ var age = compute(function (newVal) {
+ timesComputeIsCalled++;
+ if (timesComputeIsCalled === 1) {
+ ok(true, 'reading age to get value');
+ } else if (timesComputeIsCalled === 2) {
+ equal(newVal, 31, 'the second time should be an update');
+ } else if (timesComputeIsCalled === 3) {
+ ok(true, 'called after set to get the value');
+ } else {
+ ok(false, 'You\'ve called the callback ' + timesComputeIsCalled + ' times');
+ }
+ if (arguments.length) {
+ sourceAge = newVal;
+ } else {
+ return sourceAge;
+ }
+ });
+ var info = compute(function () {
+ return 'I am ' + age();
+ });
+ var k = function () {
+ };
+ info.bind('change', k);
+ equal(info(), 'I am 30');
+ age(31);
+ equal(info(), 'I am 31');
+ });
+ test('cloning a setter compute (#547)', function () {
+ var name = compute('', function (newVal) {
+ return this.txt + newVal;
+ });
+ var cloned = name.clone({ txt: '.' });
+ cloned('-');
+ equal(cloned(), '.-');
+ });
+ test('compute updated method uses get and old value (#732)', function () {
+ expect(9);
+ var input = { value: 1 };
+ var value = compute('', {
+ get: function () {
+ return input.value;
+ },
+ set: function (newVal) {
+ input.value = newVal;
+ },
+ on: function (update) {
+ input.onchange = update;
+ },
+ off: function () {
+ delete input.onchange;
+ }
+ });
+ equal(value(), 1, 'original value');
+ ok(!input.onchange, 'nothing bound');
+ value(2);
+ equal(value(), 2, 'updated value');
+ equal(input.value, 2, 'updated input.value');
+ value.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 3, 'newVal');
+ equal(oldVal, 2, 'oldVal');
+ value.unbind('change', this.Constructor);
+ });
+ ok(input.onchange, 'binding to onchange');
+ input.value = 3;
+ input.onchange({});
+ ok(!input.onchange, 'removed binding');
+ equal(value(), 3);
+ });
+ test('a compute updated by source changes within a batch is part of that batch', function () {
+ var computeA = compute('a');
+ var computeB = compute('b');
+ var combined1 = compute(function () {
+ return computeA() + ' ' + computeB();
+ });
+ var combined2 = compute(function () {
+ return computeA() + ' ' + computeB();
+ });
+ var combo = compute(function () {
+ return combined1() + ' ' + combined2();
+ });
+ var callbacks = 0;
+ combo.bind('change', function () {
+ if (callbacks === 0) {
+ ok(true, 'called change once');
+ } else {
+ ok(false, 'called change multiple times');
+ }
+ callbacks++;
+ });
+ canBatch.start();
+ computeA('A');
+ computeB('B');
+ canBatch.stop();
+ });
+ test('compute.async can be like a normal getter', function () {
+ var first = compute('Justin'), last = compute('Meyer'), fullName = compute.async('', function () {
+ return first() + ' ' + last();
+ });
+ equal(fullName(), 'Justin Meyer');
+ });
+ test('compute.async operate on single value', function () {
+ var a = compute(1);
+ var b = compute(2);
+ var obj = compute.async({}, function (curVal) {
+ if (a()) {
+ curVal.a = a();
+ } else {
+ delete curVal.a;
+ }
+ if (b()) {
+ curVal.b = b();
+ } else {
+ delete curVal.b;
+ }
+ return curVal;
+ });
+ obj.bind('change', function () {
+ });
+ deepEqual(obj(), {
+ a: 1,
+ b: 2
+ }, 'object has all properties');
+ a(0);
+ deepEqual(obj(), { b: 2 }, 'removed a');
+ b(0);
+ deepEqual(obj(), {}, 'removed b');
+ });
+ test('compute.async async changing value', function () {
+ var a = compute(1);
+ var b = compute(2);
+ var async = compute.async(undefined, function (curVal, setVal) {
+ if (a()) {
+ setTimeout(function () {
+ setVal('a');
+ }, 10);
+ } else if (b()) {
+ setTimeout(function () {
+ setVal('b');
+ }, 10);
+ } else {
+ return null;
+ }
+ });
+ var changeArgs = [
+ {
+ newVal: 'a',
+ oldVal: undefined,
+ run: function () {
+ a(0);
+ }
+ },
+ {
+ newVal: 'b',
+ oldVal: 'a',
+ run: function () {
+ b(0);
+ }
+ },
+ {
+ newVal: null,
+ oldVal: 'b',
+ run: function () {
+ start();
+ }
+ }
+ ], changeNum = 0;
+ stop();
+ async.bind('change', function (ev, newVal, oldVal) {
+ var data = changeArgs[changeNum++];
+ equal(newVal, data.newVal, 'newVal is correct');
+ equal(oldVal, data.oldVal, 'oldVal is correct');
+ setTimeout(data.run, 10);
+ });
+ });
+ test('compute.async read without binding', function () {
+ var source = compute(1);
+ var async = compute.async([], function (curVal, setVal) {
+ curVal.push(source());
+ return curVal;
+ });
+ ok(async(), 'calling async worked');
+ });
+ QUnit.module('can/Compute');
+ test('single value compute', function () {
+ expect(2);
+ var num = new Compute(1);
+ num.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 2, 'newVal');
+ equal(oldVal, 1, 'oldVal');
+ });
+ num.set(2);
+ });
+ test('inner computes values are not bound to', function () {
+ var num = new Compute(1), numBind = num.addEventListener, numUnbind = num.removeEventListener;
+ var bindCount = 0;
+ num.addEventListener = function () {
+ bindCount++;
+ return numBind.apply(this, arguments);
+ };
+ num.removeEventListener = function () {
+ bindCount--;
+ return numUnbind.apply(this, arguments);
+ };
+ var outer = new Compute(function () {
+ var inner = new Compute(function () {
+ return num.get() + 1;
+ });
+ return 2 * inner.get();
+ });
+ var handler = function () {
+ };
+ outer.bind('change', handler);
+ stop();
+ setTimeout(function () {
+ equal(bindCount, 1, 'compute only bound to once');
+ start();
+ }, 50);
+ });
+ test('compute.truthy', function () {
+ var result = 0;
+ var num = new Compute(3);
+ var truthy = Compute.truthy(num);
+ var tester = new Compute(function () {
+ if (truthy.get()) {
+ return ++result;
+ } else {
+ return ++result;
+ }
+ });
+ tester.bind('change', function (ev, newVal, oldVal) {
+ if (num.get() === 0) {
+ equal(newVal, 2, '2 is the new val');
+ } else if (num.get() === -1) {
+ equal(newVal, 3, '3 is the new val');
+ } else {
+ ok(false, 'change should not be called');
+ }
+ });
+ equal(tester.get(), 1, 'on bind, we call tester once');
+ num.set(2);
+ num.set(1);
+ num.set(0);
+ num.set(-1);
+ });
+ test('a binding compute does not double read', function () {
+ var sourceAge = 30, timesComputeIsCalled = 0;
+ var age = new Compute(function (newVal) {
+ timesComputeIsCalled++;
+ if (timesComputeIsCalled === 1) {
+ ok(true, 'reading age to get value');
+ } else if (timesComputeIsCalled === 2) {
+ equal(newVal, 31, 'the second time should be an update');
+ } else if (timesComputeIsCalled === 3) {
+ ok(true, 'called after set to get the value');
+ } else {
+ ok(false, 'You\'ve called the callback ' + timesComputeIsCalled + ' times');
+ }
+ if (arguments.length) {
+ sourceAge = newVal;
+ } else {
+ return sourceAge;
+ }
+ });
+ var info = new Compute(function () {
+ return 'I am ' + age.get();
+ });
+ var k = function () {
+ };
+ info.bind('change', k);
+ equal(info.get(), 'I am 30');
+ age.set(31);
+ equal(info.get(), 'I am 31');
+ });
+ test('cloning a setter compute (#547)', function () {
+ var name = new Compute('', function (newVal) {
+ return this.txt + newVal;
+ });
+ var cloned = name.clone({ txt: '.' });
+ cloned.set('-');
+ equal(cloned.get(), '.-');
+ });
+ test('compute updated method uses get and old value (#732)', function () {
+ expect(9);
+ var input = { value: 1 };
+ var value = new Compute('', {
+ get: function () {
+ return input.value;
+ },
+ set: function (newVal) {
+ input.value = newVal;
+ },
+ on: function (update) {
+ input.onchange = update;
+ },
+ off: function () {
+ delete input.onchange;
+ }
+ });
+ equal(value.get(), 1, 'original value');
+ ok(!input.onchange, 'nothing bound');
+ value.set(2);
+ equal(value.get(), 2, 'updated value');
+ equal(input.value, 2, 'updated input.value');
+ value.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 3, 'newVal');
+ equal(oldVal, 2, 'oldVal');
+ value.unbind('change', this.Constructor);
+ });
+ ok(input.onchange, 'binding to onchange');
+ input.value = 3;
+ input.onchange({});
+ ok(!input.onchange, 'removed binding');
+ equal(value.get(), 3);
+ });
+ test('a compute updated by source changes within a batch is part of that batch', function () {
+ var computeA = new Compute('a');
+ var computeB = new Compute('b');
+ var combined1 = new Compute(function () {
+ return computeA.get() + ' ' + computeB.get();
+ });
+ var combined2 = new Compute(function () {
+ return computeA.get() + ' ' + computeB.get();
+ });
+ var combo = new Compute(function () {
+ return combined1.get() + ' ' + combined2.get();
+ });
+ var callbacks = 0;
+ combo.bind('change', function () {
+ if (callbacks === 0) {
+ ok(true, 'called change once');
+ } else {
+ ok(false, 'called change multiple times');
+ }
+ callbacks++;
+ });
+ canBatch.start();
+ computeA.set('A');
+ computeB.set('B');
+ canBatch.stop();
+ });
+ test('Compute.async can be like a normal getter', function () {
+ var first = new Compute('Justin'), last = new Compute('Meyer'), fullName = Compute.async('', function () {
+ return first.get() + ' ' + last.get();
+ });
+ equal(fullName.get(), 'Justin Meyer');
+ });
+ test('Compute.async operate on single value', function () {
+ var a = new Compute(1);
+ var b = new Compute(2);
+ var obj = Compute.async({}, function (curVal) {
+ if (a.get()) {
+ curVal.a = a.get();
+ } else {
+ delete curVal.a;
+ }
+ if (b.get()) {
+ curVal.b = b.get();
+ } else {
+ delete curVal.b;
+ }
+ return curVal;
+ });
+ obj.bind('change', function () {
+ });
+ deepEqual(obj.get(), {
+ a: 1,
+ b: 2
+ }, 'object has all properties');
+ a.set(0);
+ deepEqual(obj.get(), { b: 2 }, 'removed a');
+ b.set(0);
+ deepEqual(obj.get(), {}, 'removed b');
+ });
+ test('Compute.async async changing value', function () {
+ var a = new Compute(1);
+ var b = new Compute(2);
+ var async = Compute.async(undefined, function (curVal, setVal) {
+ if (a.get()) {
+ setTimeout(function () {
+ setVal('a');
+ }, 10);
+ } else if (b.get()) {
+ setTimeout(function () {
+ setVal('b');
+ }, 10);
+ } else {
+ return null;
+ }
+ });
+ var changeArgs = [
+ {
+ newVal: 'a',
+ oldVal: undefined,
+ run: function () {
+ a.set(0);
+ }
+ },
+ {
+ newVal: 'b',
+ oldVal: 'a',
+ run: function () {
+ b.set(0);
+ }
+ },
+ {
+ newVal: null,
+ oldVal: 'b',
+ run: function () {
+ start();
+ }
+ }
+ ], changeNum = 0;
+ stop();
+ async.bind('change', function (ev, newVal, oldVal) {
+ var data = changeArgs[changeNum++];
+ equal(newVal, data.newVal, 'newVal is correct');
+ equal(oldVal, data.oldVal, 'oldVal is correct');
+ setTimeout(data.run, 10);
+ });
+ });
+ test('Compute.async read without binding', function () {
+ var source = new Compute(1);
+ var async = Compute.async([], function (curVal, setVal) {
+ curVal.push(source.get());
+ return curVal;
+ });
+ ok(async.get(), 'calling async worked');
+ });
+ test('Compute.async set uses last set or initial value', function () {
+ var add = new Compute(1);
+ var fnCount = 0;
+ var async = Compute.async(10, function (curVal) {
+ switch (fnCount++) {
+ case 0:
+ equal(curVal, 10);
+ break;
+ case 1:
+ equal(curVal, 20);
+ break;
+ case 2:
+ equal(curVal, 30, 'on bind');
+ break;
+ case 3:
+ equal(curVal, 30, 'on bind');
+ break;
+ }
+ return curVal + add.get();
+ });
+ equal(async.get(), 11, 'initial value');
+ async.set(20);
+ async.bind('change', function () {
+ });
+ async.set(20);
+ async.set(30);
+ });
+ test('setting compute.async with a observable dependency gets a new value and can re-compute', 4, function () {
+ var c = compute(1);
+ var add;
+ var async = compute.async(1, function (curVal) {
+ add = curVal;
+ return c() + add;
+ });
+ equal(async(), 2, 'can read unbound');
+ async.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 3, 'change new val');
+ equal(oldVal, 2, 'change old val');
+ });
+ async(2);
+ equal(async(), 3, 'can read unbound');
+ });
+ test('compute.async getter has correct when length === 1', function () {
+ var m = {};
+ var getterCompute = compute.async(false, function (singleArg) {
+ equal(this, m, 'getter has the right context');
+ }, m);
+ getterCompute.bind('change', function () {
+ });
+ });
+ test('bug with nested computes and batch ordering (#1519)', function () {
+ var root = compute('a');
+ var isA = compute(function () {
+ return root() === 'a';
+ });
+ var isB = compute(function () {
+ return root() === 'b';
+ });
+ var combined = compute(function () {
+ var valA = isA(), valB = isB();
+ return valA || valB;
+ });
+ equal(combined(), true);
+ combined.bind('change', function () {
+ });
+ canBatch.start();
+ root('b');
+ canBatch.stop();
+ equal(combined(), true);
+ });
+ test('compute change handler context is set to the function not compute', function () {
+ var comp = compute(null);
+ comp.bind('change', function () {
+ equal(typeof this, 'function');
+ });
+ comp('test');
+ });
+ test('Calling .unbind() on un-bound compute does not throw an error', function () {
+ var count = compute(0);
+ count.unbind('change');
+ ok(true, 'No error was thrown');
+ });
+ test('dependent computes update in the right order (2093)', function () {
+ var root = compute('a'), childB = compute(function () {
+ return root();
+ }), combine = compute(function () {
+ return root() + childB();
+ });
+ combine.bind('change', function (ev, newVal) {
+ equal(newVal, 'bb', 'concat changed');
+ });
+ root('b');
+ });
+ test('dependent computes update in the right order with a batch (#2093)', function () {
+ var root = compute('a'), child = compute(function () {
+ return root();
+ }), child2 = compute(function () {
+ return root();
+ }), grandChild = compute(function () {
+ return child();
+ }), combine = compute(function () {
+ return child2() + grandChild();
+ });
+ combine.bind('change', function (ev, newVal) {
+ equal(newVal, 'bb', 'concat changed');
+ });
+ canBatch.start();
+ root('b');
+ canBatch.stop();
+ });
+ test('bug with nested computes and batch ordering (#1519)', function () {
+ var root = compute('a');
+ var isA = compute(function () {
+ return root() === 'a';
+ });
+ var isB = compute(function () {
+ return root() === 'b';
+ });
+ var combined = compute(function () {
+ var valA = isA(), valB = isB();
+ return valA || valB;
+ });
+ equal(combined(), true);
+ combined.bind('change', function () {
+ });
+ canBatch.start();
+ root('b');
+ canBatch.stop();
+ equal(combined(), true);
+ });
+ test('binding, unbinding, and rebinding works after a timeout (#2095)', function () {
+ var root = compute(1), derived = compute(function () {
+ return root();
+ });
+ var change = function () {
+ };
+ derived.bind('change', change);
+ derived.unbind('change', change);
+ stop();
+ setTimeout(function () {
+ derived.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 2, 'updated');
+ start();
+ });
+ root(2);
+ }, 10);
+ });
+ test('Observation.isRecording observes doesn\'t understand Observation.ignore (#2099)', function () {
+ expect(0);
+ var c = compute(1);
+ c.computeInstance.bind = function () {
+ ok(false);
+ };
+ var outer = compute(function () {
+ Observation.ignore(function () {
+ c();
+ })();
+ });
+ outer.bind('change', function () {
+ });
+ });
+ test('handles missing update order items (#2121)', function () {
+ var root1 = compute('root1'), child1 = compute(function () {
+ return root1();
+ }), root2 = compute('root2'), child2 = compute(function () {
+ return root2();
+ }), gc2 = compute(function () {
+ return child2();
+ }), res = compute(function () {
+ return child1() + gc2();
+ });
+ res.bind('change', function (ev, newVal) {
+ equal(newVal, 'ROOT1root2');
+ });
+ canBatch.start();
+ root1('ROOT1');
+ canBatch.stop();
+ });
+ test('compute should not fire event when NaN is set multiple times #2128', function () {
+ var c = compute(NaN);
+ compute.bind('change', function () {
+ ok(false, 'change event should not be fired');
+ });
+ ok(isNaN(c()));
+ c(NaN);
+ });
+ test('canBatch.afterPreviousEvents firing too late (#2198)', function () {
+ var compute1 = compute('a'), compute2 = compute('b');
+ var derived = compute(function () {
+ return compute1().toUpperCase();
+ });
+ derived.bind('change', function () {
+ var afterPrevious = false;
+ compute2.bind('change', function () {
+ ok(afterPrevious, 'after previous should have fired so we would respond to this event');
+ });
+ canBatch.start();
+ canBatch.stop();
+ canBatch.afterPreviousEvents(function () {
+ afterPrevious = true;
+ });
+ compute2('c');
+ });
+ canBatch.start();
+ compute1('x');
+ canBatch.stop();
+ });
+ test('Change propagation in a batch with late bindings (#2412)', function () {
+ console.clear();
+ var rootA = new Compute('a');
+ var rootB = new Compute('b');
+ var childA = new Compute(function () {
+ return 'childA' + rootA.get();
+ });
+ var grandChild = new Compute(function () {
+ var b = rootB.get();
+ if (b === 'b') {
+ return 'grandChild->b';
+ }
+ var a = childA.get();
+ return 'grandChild->' + a;
+ });
+ childA.bind('change', function (ev, newVal, oldVal) {
+ });
+ grandChild.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 'grandChild->childAA');
+ });
+ canBatch.start();
+ rootA.set('A');
+ rootB.set('B');
+ canBatch.stop();
+ });
+ if (Compute.prototype.trace) {
+ test('trace', function () {
+ var rootA = new Compute('a');
+ var rootB = new Compute('b');
+ var childA = new Compute(function () {
+ return 'childA' + rootA.get();
+ });
+ var fn = function () {
+ var b = rootB.get();
+ if (b === 'b') {
+ return 'grandChild->b';
+ }
+ var a = childA.get();
+ return 'grandChild->' + a;
+ };
+ var grandChild = new Compute(fn);
+ childA.bind('change', function (ev, newVal, oldVal) {
+ });
+ grandChild.bind('change', function (ev, newVal, oldVal) {
+ equal(newVal, 'grandChild->childAA');
+ });
+ var out = grandChild.trace();
+ equal(out.definition, fn, 'got the right function');
+ equal(out.computeValue, 'grandChild->b');
+ grandChild.log();
+ canBatch.start();
+ rootA.set('A');
+ rootB.set('B');
+ canBatch.stop();
+ grandChild.log();
+ });
+ }
+ test('compute(defineMap, \'property.names\') works (#20)', function () {
+ var map = new DefineMap();
+ var c = compute(map, 'foo.bar');
+ c.on('change', function (ev, newVal) {
+ QUnit.equal(newVal, 2);
+ });
+ map.set('foo', new DefineMap());
+ map.foo.set('bar', 2);
+ });
+ test('compute(DefineList, 0) works (#17)', function (assert) {
+ assert.expect(1);
+ var list = new DefineList([
+ 1,
+ 2,
+ 3
+ ]);
+ var c = compute(list, 0);
+ c.on('change', function (ev, newVal) {
+ assert.equal(newVal, 5);
+ });
+ list.set(0, 5);
+ });
+ test('Async getter causes infinite loop (#28)', function () {
+ var changeCount = 0;
+ var idCompute = compute(1);
+ stop();
+ var comp = compute.async(undefined, function (last, resolve) {
+ var id = idCompute();
+ setTimeout(function () {
+ resolve(changeCount + '|' + id);
+ });
+ resolve(changeCount + '|' + id);
+ }, null);
+ comp.bind('change', function (ev, newVal) {
+ changeCount++;
+ comp();
+ });
+ setTimeout(function () {
+ idCompute(2);
+ }, 50);
+ setTimeout(function () {
+ equal(changeCount, 4);
+ start();
+ }, 100);
+ });
+ test('Listening to input change', function () {
+ var input = document.createElement('input');
+ var comp = compute(input, 'value', 'input');
+ comp.on('change', function () {
+ ok(true, 'it changed');
+ });
+ input.value = 'foo';
+ domDispatch.call(input, 'input');
+ });
+});
+/*can@3.0.0#compute/compute_test*/
+define('can@3.0.0#compute/compute_test', function (require, exports, module) {
+ require('can-compute/can-compute_test');
+});
+/*can-connect@1.0.11#helpers/id-merge*/
+define('can-connect@1.0.11#helpers/id-merge', function (require, exports, module) {
+ var map = [].map;
+ module.exports = function (list, update, id, make) {
+ var listIndex = 0, updateIndex = 0;
+ while (listIndex < list.length && updateIndex < update.length) {
+ var listItem = list[listIndex], updateItem = update[updateIndex], lID = id(listItem), uID = id(updateItem);
+ if (id(listItem) === id(updateItem)) {
+ listIndex++;
+ updateIndex++;
+ continue;
+ }
+ if (updateIndex + 1 < update.length && id(update[updateIndex + 1]) === lID) {
+ list.splice(listIndex, 0, make(update[updateIndex]));
+ listIndex++;
+ updateIndex++;
+ continue;
+ } else if (listIndex + 1 < list.length && id(list[listIndex + 1]) === uID) {
+ list.splice(listIndex, 1);
+ listIndex++;
+ updateIndex++;
+ continue;
+ } else {
+ list.splice.apply(list, [
+ listIndex,
+ list.length - listIndex
+ ].concat(map.call(update.slice(updateIndex), make)));
+ return list;
+ }
+ }
+ if (updateIndex === update.length && listIndex === list.length) {
+ return;
+ }
+ list.splice.apply(list, [
+ listIndex,
+ list.length - listIndex
+ ].concat(map.call(update.slice(updateIndex), make)));
+ return;
+ };
+});
+/*can-connect@1.0.11#helpers/helpers_test*/
+define('can-connect@1.0.11#helpers/helpers_test', function (require, exports, module) {
+ var idMerge = require('can-connect/helpers/id-merge');
+ var QUnit = require('steal-qunit');
+ QUnit.module('helpers');
+ QUnit.test('id-merge', function () {
+ var onSplice = function (arr, fn) {
+ var splice = arr.splice;
+ arr.splice = function () {
+ fn.apply(this, arguments);
+ return splice.apply(this, arguments);
+ };
+ return arr;
+ };
+ var returnArg = function (arg) {
+ return arg;
+ };
+ var list;
+ idMerge(list = [], [
+ 1,
+ 2,
+ 3
+ ], returnArg, returnArg);
+ deepEqual(list, [
+ 1,
+ 2,
+ 3
+ ]);
+ list = onSplice([
+ 1,
+ 2,
+ 3
+ ], function () {
+ ok(false, 'splice called');
+ });
+ idMerge(list, [
+ 1,
+ 2,
+ 3
+ ], returnArg, returnArg);
+ deepEqual(list, [
+ 1,
+ 2,
+ 3
+ ]);
+ list = onSplice([
+ 1,
+ 2,
+ 4
+ ], function (index, howMany, insert) {
+ equal(index, 2);
+ equal(howMany, 0);
+ equal(insert, 3);
+ });
+ idMerge(list, [
+ 1,
+ 2,
+ 3,
+ 4
+ ], returnArg, returnArg);
+ deepEqual(list, [
+ 1,
+ 2,
+ 3,
+ 4
+ ]);
+ list = onSplice([
+ 1,
+ 2,
+ 3,
+ 4
+ ], function (index, howMany, insert) {
+ equal(index, 2);
+ equal(howMany, 1);
+ equal(insert, undefined);
+ });
+ idMerge(list, [
+ 1,
+ 2,
+ 4
+ ], returnArg, returnArg);
+ deepEqual(list, [
+ 1,
+ 2,
+ 4
+ ]);
+ idMerge(list = [
+ 'a',
+ 'b',
+ 'z',
+ 'f',
+ 'x'
+ ], [
+ 'a',
+ 'b',
+ 'f',
+ 'w',
+ 'z'
+ ], returnArg, returnArg);
+ deepEqual(list, [
+ 'a',
+ 'b',
+ 'f',
+ 'w',
+ 'z'
+ ]);
+ });
+});
+/*can-connect@1.0.11#connect*/
+define('can-connect@1.0.11#connect', function (require, exports, module) {
+ var assign = require('can-util/js/assign/assign');
+ var connect = function (behaviors, options) {
+ behaviors = behaviors.map(function (behavior, index) {
+ var sortedIndex = -1;
+ if (typeof behavior === 'string') {
+ sortedIndex = connect.order.indexOf(behavior);
+ behavior = behaviorsMap[behavior];
+ } else if (behavior.isBehavior) {
+ sortedIndex = connect.order.indexOf(behavior.behaviorName);
+ } else {
+ behavior = connect.behavior(behavior);
+ }
+ return {
+ originalIndex: index,
+ sortedIndex: sortedIndex,
+ behavior: behavior
+ };
+ }).sort(function (b1, b2) {
+ if (~b1.sortedIndex && ~b2.sortedIndex) {
+ return b1.sortedIndex - b2.sortedIndex;
+ }
+ return b1.originalIndex - b2.originalIndex;
+ });
+ behaviors = behaviors.map(function (b) {
+ return b.behavior;
+ });
+ var behavior = connect.base(connect.behavior('options', function () {
+ return options;
+ })());
+ behaviors.forEach(function (behave) {
+ behavior = behave(behavior);
+ });
+ if (behavior.init) {
+ behavior.init();
+ }
+ return behavior;
+ };
+ connect.order = [
+ 'data/localstorage-cache',
+ 'data/url',
+ 'data/parse',
+ 'cache-requests',
+ 'data/combine-requests',
+ 'constructor',
+ 'constructor/store',
+ 'can/map',
+ 'can/ref',
+ 'fall-through-cache',
+ 'data/worker',
+ 'real-time',
+ 'data/callbacks-cache',
+ 'data/callbacks',
+ 'constructor/callbacks-once'
+ ];
+ connect.behavior = function (name, behavior) {
+ if (typeof name !== 'string') {
+ behavior = name;
+ name = undefined;
+ }
+ var behaviorMixin = function (base) {
+ var Behavior = function () {
+ };
+ Behavior.name = name;
+ Behavior.prototype = base;
+ var newBehavior = new Behavior();
+ var res = typeof behavior === 'function' ? behavior.apply(newBehavior, arguments) : behavior;
+ assign(newBehavior, res);
+ newBehavior.__behaviorName = name;
+ return newBehavior;
+ };
+ if (name) {
+ behaviorMixin.behaviorName = name;
+ behaviorsMap[name] = behaviorMixin;
+ }
+ behaviorMixin.isBehavior = true;
+ return behaviorMixin;
+ };
+ var behaviorsMap = {};
+ module.exports = connect;
+});
+/*can-connect@1.0.11#base/base*/
+define('can-connect@1.0.11#base/base', function (require, exports, module) {
+ var connect = require('can-connect/connect');
+ module.exports = connect.behavior('base', function (base) {
+ return {
+ id: function (instance) {
+ var ids = [], algebra = this.algebra;
+ if (algebra && algebra.clauses && algebra.clauses.id) {
+ for (var prop in algebra.clauses.id) {
+ ids.push(instance[prop]);
+ }
+ }
+ if (this.idProp && !ids.length) {
+ ids.push(instance[this.idProp]);
+ }
+ if (!ids.length) {
+ ids.push(instance.id);
+ }
+ return ids.length > 1 ? ids.join('@|@') : ids[0];
+ },
+ idProp: base.idProp || 'id',
+ listSet: function (list) {
+ return list[this.listSetProp];
+ },
+ listSetProp: '__listSet',
+ init: function () {
+ }
+ };
+ });
+});
+/*can-connect@1.0.11#can-connect*/
+define('can-connect@1.0.11#can-connect', function (require, exports, module) {
+ var connect = require('can-connect/connect');
+ var base = require('can-connect/base/base');
+ var ns = require('can-util/namespace');
+ connect.base = base;
+ module.exports = ns.connect = connect;
+});
+/*can-set@1.0.2#src/helpers*/
+define('can-set@1.0.2#src/helpers', function (require, exports, module) {
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var last = require('can-util/js/last/last');
+ var IgnoreType = function () {
+ };
+ var helpers;
+ module.exports = helpers = {
+ eachInUnique: function (a, acb, b, bcb, defaultReturn) {
+ var bCopy = assign({}, b), res;
+ for (var prop in a) {
+ res = acb(a[prop], b[prop], a, b, prop);
+ if (res !== undefined) {
+ return res;
+ }
+ delete bCopy[prop];
+ }
+ for (prop in bCopy) {
+ res = bcb(undefined, b[prop], a, b, prop);
+ if (res !== undefined) {
+ return res;
+ }
+ }
+ return defaultReturn;
+ },
+ doubleLoop: function (arr, callbacks) {
+ if (typeof callbacks === 'function') {
+ callbacks = { iterate: callbacks };
+ }
+ var i = 0;
+ while (i < arr.length) {
+ if (callbacks.start) {
+ callbacks.start(arr[i]);
+ }
+ var j = i + 1;
+ while (j < arr.length) {
+ if (callbacks.iterate(arr[j], j, arr[i], i) === false) {
+ arr.splice(j, 1);
+ } else {
+ j++;
+ }
+ }
+ if (callbacks.end) {
+ callbacks.end(arr[i]);
+ }
+ i++;
+ }
+ },
+ identityMap: function (arr) {
+ var map = {};
+ each(arr, function (value) {
+ map[value] = 1;
+ });
+ return map;
+ },
+ arrayUnionIntersectionDifference: function (arr1, arr2) {
+ var map = {};
+ var intersection = [];
+ var union = [];
+ var difference = arr1.slice(0);
+ each(arr1, function (value) {
+ map[value] = true;
+ union.push(value);
+ });
+ each(arr2, function (value) {
+ if (map[value]) {
+ intersection.push(value);
+ var index = helpers.indexOf.call(difference, value);
+ if (index !== -1) {
+ difference.splice(index, 1);
+ }
+ } else {
+ union.push(value);
+ }
+ });
+ return {
+ intersection: intersection,
+ union: union,
+ difference: difference
+ };
+ },
+ arraySame: function (arr1, arr2) {
+ if (arr1.length !== arr2.length) {
+ return false;
+ }
+ var map = helpers.identityMap(arr1);
+ for (var i = 0; i < arr2.length; i++) {
+ var val = map[arr2[i]];
+ if (!val) {
+ return false;
+ } else if (val > 1) {
+ return false;
+ } else {
+ map[arr2[i]]++;
+ }
+ }
+ return true;
+ },
+ indexOf: Array.prototype.indexOf || function (item) {
+ for (var i = 0, thisLen = this.length; i < thisLen; i++) {
+ if (this[i] === item) {
+ return i;
+ }
+ }
+ return -1;
+ },
+ map: Array.prototype.map || function (cb) {
+ var out = [];
+ for (var i = 0, len = this.length; i < len; i++) {
+ out.push(cb(this[i], i, this));
+ }
+ return out;
+ },
+ filter: Array.prototype.filter || function (cb) {
+ var out = [];
+ for (var i = 0, len = this.length; i < len; i++) {
+ if (cb(this[i], i, this)) {
+ out.push(this[i]);
+ }
+ }
+ return out;
+ },
+ ignoreType: new IgnoreType(),
+ firstProp: function (set) {
+ for (var prop in set) {
+ return prop;
+ }
+ },
+ index: function (compare, items, props) {
+ if (!items || !items.length) {
+ return undefined;
+ }
+ if (compare(props, items[0]) === -1) {
+ return 0;
+ } else if (compare(props, last(items)) === 1) {
+ return items.length;
+ }
+ var low = 0, high = items.length;
+ while (low < high) {
+ var mid = low + high >>> 1, item = items[mid], computed = compare(props, item);
+ if (computed === -1) {
+ high = mid;
+ } else {
+ low = mid + 1;
+ }
+ }
+ return high;
+ },
+ defaultSort: function (sortPropValue, item1, item2) {
+ var parts = sortPropValue.split(' ');
+ var sortProp = parts[0];
+ var item1Value = item1[sortProp];
+ var item2Value = item2[sortProp];
+ var temp;
+ var desc = parts[1] || '';
+ desc = desc.toLowerCase() === 'desc';
+ if (desc) {
+ temp = item1Value;
+ item1Value = item2Value;
+ item2Value = temp;
+ }
+ if (item1Value < item2Value) {
+ return -1;
+ }
+ if (item1Value > item2Value) {
+ return 1;
+ }
+ return 0;
+ }
+ };
+});
+/*can-set@1.0.2#src/clause*/
+define('can-set@1.0.2#src/clause', function (require, exports, module) {
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var clause = {};
+ module.exports = clause;
+ clause.TYPES = [
+ 'where',
+ 'order',
+ 'paginate',
+ 'id'
+ ];
+ each(clause.TYPES, function (type) {
+ var className = type.charAt(0).toUpperCase() + type.substr(1);
+ clause[className] = function (compare) {
+ assign(this, compare);
+ };
+ clause[className].type = type;
+ });
+});
+/*can-set@1.0.2#src/compare*/
+define('can-set@1.0.2#src/compare', function (require, exports, module) {
+ var h = require('./helpers');
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var compareHelpers;
+ var loop = function (a, b, aParent, bParent, prop, compares, options) {
+ var checks = options.checks;
+ for (var i = 0; i < checks.length; i++) {
+ var res = checks[i](a, b, aParent, bParent, prop, compares || {}, options);
+ if (res !== undefined) {
+ return res;
+ }
+ }
+ return options['default'];
+ };
+ var addIntersectedPropertyToResult = function (a, b, aParent, bParent, prop, compares, options) {
+ var subsetCheck;
+ if (!(prop in aParent)) {
+ subsetCheck = 'subsetB';
+ } else if (prop in bParent) {
+ return false;
+ }
+ if (!(prop in bParent)) {
+ subsetCheck = 'subsetA';
+ }
+ if (subsetCheck === 'subsetB') {
+ options.result[prop] = b;
+ } else {
+ options.result[prop] = a;
+ }
+ return undefined;
+ };
+ var addToResult = function (fn, name) {
+ return function (a, b, aParent, bParent, prop, compares, options) {
+ var res = fn.apply(this, arguments);
+ if (res === true) {
+ if (prop !== undefined && !(prop in options.result)) {
+ options.result[prop] = a;
+ }
+ return true;
+ } else {
+ return res;
+ }
+ };
+ };
+ module.exports = compareHelpers = {
+ equal: function (a, b, aParent, bParent, prop, compares, options) {
+ options.checks = [
+ compareHelpers.equalComparesType,
+ compareHelpers.equalBasicTypes,
+ compareHelpers.equalArrayLike,
+ compareHelpers.equalObject
+ ];
+ options['default'] = false;
+ return loop(a, b, aParent, bParent, prop, compares, options);
+ },
+ equalComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ return compareResult;
+ } else if (compareResult && typeof compareResult === 'object') {
+ if ('intersection' in compareResult && !('difference' in compareResult)) {
+ var reverseResult = compares(b, a, bParent, aParent, prop, options);
+ return 'intersection' in reverseResult && !('difference' in reverseResult);
+ }
+ return false;
+ }
+ return compareResult;
+ }
+ },
+ equalBasicTypes: function (a, b, aParent, bParent, prop, compares, options) {
+ if (a === null || b === null) {
+ return a === b;
+ }
+ if (a instanceof Date || b instanceof Date) {
+ return a === b;
+ }
+ if (options.deep === -1) {
+ return typeof a === 'object' || a === b;
+ }
+ if (typeof a !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
+ return false;
+ }
+ if (a === b) {
+ return true;
+ }
+ },
+ equalArrayLike: function (a, b, aParent, bParent, prop, compares, options) {
+ if (Array.isArray(a) && Array.isArray(b)) {
+ if (a.length !== b.length) {
+ return false;
+ }
+ for (var i = 0; i < a.length; i++) {
+ var compare = compares[i] === undefined ? compares['*'] : compares[i];
+ if (!loop(a[i], b[i], a, b, i, compare, options)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ equalObject: function (a, b, aParent, bParent, parentProp, compares, options) {
+ var aType = typeof a;
+ if (aType === 'object' || aType === 'function') {
+ var bCopy = assign({}, b);
+ if (options.deep === false) {
+ options.deep = -1;
+ }
+ for (var prop in a) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ if (!loop(a[prop], b[prop], a, b, prop, compare, options)) {
+ return false;
+ }
+ delete bCopy[prop];
+ }
+ for (prop in bCopy) {
+ if (compares[prop] === undefined || !loop(undefined, b[prop], a, b, prop, compares[prop], options)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ subset: function (a, b, aParent, bParent, prop, compares, options) {
+ options.checks = [
+ compareHelpers.subsetComparesType,
+ compareHelpers.equalBasicTypes,
+ compareHelpers.equalArrayLike,
+ compareHelpers.subsetObject
+ ];
+ options.getSubsets = [];
+ options['default'] = false;
+ return loop(a, b, aParent, bParent, prop, compares, options);
+ },
+ subsetObject: function (a, b, aParent, bParent, parentProp, compares, options) {
+ var aType = typeof a;
+ if (aType === 'object' || aType === 'function') {
+ return h.eachInUnique(a, function (a, b, aParent, bParent, prop) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ if (!loop(a, b, aParent, bParent, prop, compare, options) && prop in bParent) {
+ return false;
+ }
+ }, b, function (a, b, aParent, bParent, prop) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ if (!loop(a, b, aParent, bParent, prop, compare, options)) {
+ return false;
+ }
+ }, true);
+ }
+ },
+ subsetComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ return compareResult;
+ } else if (compareResult && typeof compareResult === 'object') {
+ if (compareResult.getSubset) {
+ if (h.indexOf.call(options.getSubsets, compareResult.getSubset) === -1) {
+ options.getSubsets.push(compareResult.getSubset);
+ }
+ }
+ if (compareResult.intersection === h.ignoreType || compareResult.difference === h.ignoreType) {
+ return true;
+ }
+ if ('intersection' in compareResult && !('difference' in compareResult)) {
+ var reverseResult = compares(b, a, bParent, aParent, prop, options);
+ return 'intersection' in reverseResult;
+ }
+ return false;
+ }
+ return compareResult;
+ }
+ },
+ properSupersetObject: function (a, b, aParent, bParent, parentProp, compares, options) {
+ var bType = typeof b;
+ var hasAdditionalProp = false;
+ if (bType === 'object' || bType === 'function') {
+ var aCopy = assign({}, a);
+ if (options.deep === false) {
+ options.deep = -1;
+ }
+ for (var prop in b) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ var compareResult = loop(a[prop], b[prop], a, b, prop, compare, options);
+ if (compareResult === h.ignoreType) {
+ } else if (!(prop in a) || options.performedDifference) {
+ hasAdditionalProp = true;
+ } else if (!compareResult) {
+ return false;
+ }
+ delete aCopy[prop];
+ }
+ for (prop in aCopy) {
+ if (compares[prop] === undefined || !loop(a[prop], undefined, a, b, prop, compares[prop], options)) {
+ return false;
+ }
+ }
+ return hasAdditionalProp;
+ }
+ },
+ properSubsetComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ return compareResult;
+ } else if (compareResult && typeof compareResult === 'object') {
+ if ('intersection' in compareResult && !('difference' in compareResult)) {
+ var reverseResult = compares(b, a, bParent, aParent, prop, options);
+ return 'intersection' in reverseResult && 'difference' in reverseResult;
+ }
+ return false;
+ }
+ return compareResult;
+ }
+ },
+ difference: function (a, b, aParent, bParent, prop, compares, options) {
+ options.result = {};
+ options.performedDifference = 0;
+ options.checks = [
+ compareHelpers.differenceComparesType,
+ addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'),
+ addToResult(compareHelpers.equalArrayLike, 'equalArrayLike'),
+ addToResult(compareHelpers.properSupersetObject, 'properSubsetObject')
+ ];
+ options['default'] = true;
+ var res = loop(a, b, aParent, bParent, prop, compares, options);
+ if (res === true && options.performedDifference) {
+ return options.result;
+ }
+ return res;
+ },
+ differenceComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ if (compareResult === true) {
+ options.result[prop] = a;
+ return true;
+ } else {
+ return compareResult;
+ }
+ } else if (compareResult && typeof compareResult === 'object') {
+ if ('difference' in compareResult) {
+ if (compareResult.difference === h.ignoreType) {
+ return h.ignoreType;
+ } else if (compareResult.difference != null) {
+ options.result[prop] = compareResult.difference;
+ options.performedDifference++;
+ return true;
+ } else {
+ return true;
+ }
+ } else {
+ if (compareHelpers.equalComparesType.apply(this, arguments)) {
+ options.performedDifference++;
+ options.result[prop] = compareResult.union;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ },
+ union: function (a, b, aParent, bParent, prop, compares, options) {
+ options.result = {};
+ options.performedUnion = 0;
+ options.checks = [
+ compareHelpers.unionComparesType,
+ addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'),
+ addToResult(compareHelpers.unionArrayLike, 'unionArrayLike'),
+ addToResult(compareHelpers.unionObject, 'unionObject')
+ ];
+ options.getUnions = [];
+ options['default'] = false;
+ var res = loop(a, b, aParent, bParent, prop, compares, options);
+ if (res === true) {
+ return options.result;
+ }
+ return false;
+ },
+ unionComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ if (compareResult === true) {
+ options.result[prop] = a;
+ return true;
+ } else {
+ return compareResult;
+ }
+ } else if (compareResult && typeof compareResult === 'object') {
+ if (compareResult.getUnion) {
+ if (h.indexOf.call(options.getUnions, compareResult.getUnion) === -1) {
+ options.getUnions.push(compareResult.getUnion);
+ }
+ }
+ if ('union' in compareResult) {
+ if (compareResult.union === h.ignoreType) {
+ return compareResult.union;
+ }
+ if (compareResult.union !== undefined) {
+ options.result[prop] = compareResult.union;
+ }
+ options.performedUnion++;
+ return true;
+ }
+ }
+ }
+ },
+ unionObject: function (a, b, aParent, bParent, prop, compares, options) {
+ var subsetCompare = function (a, b, aParent, bParent, prop) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ if (!loop(a, b, aParent, bParent, prop, compare, options)) {
+ var subsetCheck;
+ if (!(prop in aParent)) {
+ subsetCheck = 'subsetB';
+ }
+ if (!(prop in bParent)) {
+ subsetCheck = 'subsetA';
+ }
+ if (subsetCheck) {
+ if (!options.subset) {
+ options.subset = subsetCheck;
+ }
+ return options.subset === subsetCheck ? undefined : false;
+ }
+ return false;
+ }
+ };
+ var aType = typeof a;
+ if (aType === 'object' || aType === 'function') {
+ return h.eachInUnique(a, subsetCompare, b, subsetCompare, true);
+ }
+ },
+ unionArrayLike: function (a, b, aParent, bParent, prop, compares, options) {
+ if (Array.isArray(a) && Array.isArray(b)) {
+ var combined = makeArray(a).concat(makeArray(b));
+ h.doubleLoop(combined, function (item, j, cur, i) {
+ var res = !compareHelpers.equal(cur, item, aParent, bParent, undefined, compares['*'], { 'default': false });
+ return res;
+ });
+ options.result[prop] = combined;
+ return true;
+ }
+ },
+ count: function (a, b, aParent, bParent, prop, compares, options) {
+ options.checks = [
+ compareHelpers.countComparesType,
+ compareHelpers.equalBasicTypes,
+ compareHelpers.equalArrayLike,
+ compareHelpers.loopObject
+ ];
+ options['default'] = false;
+ loop(a, b, aParent, bParent, prop, compares, options);
+ if (typeof options.count === 'number') {
+ return options.count;
+ }
+ return Infinity;
+ },
+ countComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ return true;
+ } else if (compareResult && typeof compareResult === 'object') {
+ if (typeof compareResult.count === 'number') {
+ if (!('count' in options) || compareResult.count === options.count) {
+ options.count = compareResult.count;
+ } else {
+ options.count = Infinity;
+ }
+ }
+ return true;
+ }
+ }
+ },
+ loopObject: function (a, b, aParent, bParent, prop, compares, options) {
+ var aType = typeof a;
+ if (aType === 'object' || aType === 'function') {
+ each(a, function (aValue, prop) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ loop(aValue, b[prop], a, b, prop, compare, options);
+ });
+ return true;
+ }
+ },
+ intersection: function (a, b, aParent, bParent, prop, compares, options) {
+ options.result = {};
+ options.performedIntersection = 0;
+ options.checks = [
+ compareHelpers.intersectionComparesType,
+ addToResult(compareHelpers.equalBasicTypes, 'equalBasicTypes'),
+ addToResult(compareHelpers.intersectionArrayLike, 'intersectionArrayLike'),
+ compareHelpers.intersectionObject
+ ];
+ options['default'] = false;
+ var res = loop(a, b, aParent, bParent, prop, compares, options);
+ if (res === true) {
+ return options.result;
+ }
+ return false;
+ },
+ intersectionComparesType: function (a, b, aParent, bParent, prop, compares, options) {
+ if (typeof compares === 'function') {
+ var compareResult = compares(a, b, aParent, bParent, prop, options);
+ if (typeof compareResult === 'boolean') {
+ if (compareResult === true) {
+ options.result[prop] = a;
+ return true;
+ } else {
+ return compareResult;
+ }
+ } else if (compareResult && typeof compareResult === 'object') {
+ if ('intersection' in compareResult) {
+ if (compareResult.intersection !== undefined) {
+ options.result[prop] = compareResult.intersection;
+ }
+ options.performedIntersection++;
+ return true;
+ }
+ }
+ }
+ },
+ intersectionObject: function (a, b, aParent, bParent, prop, compares, options) {
+ var subsetCompare = function (a, b, aParent, bParent, prop) {
+ var compare = compares[prop] === undefined ? compares['*'] : compares[prop];
+ if (!loop(a, b, aParent, bParent, prop, compare, options)) {
+ return addIntersectedPropertyToResult(a, b, aParent, bParent, prop, compares, options);
+ }
+ };
+ var aType = typeof a;
+ if (aType === 'object' || aType === 'function') {
+ return h.eachInUnique(a, subsetCompare, b, subsetCompare, true);
+ }
+ },
+ intersectionArrayLike: function (a, b, aParent, bParent, prop, compares, options) {
+ if (Array.isArray(a) && Array.isArray(b)) {
+ var intersection = [];
+ each(makeArray(a), function (cur) {
+ for (var i = 0; i < b.length; i++) {
+ if (compareHelpers.equal(cur, b[i], aParent, bParent, undefined, compares['*'], { 'default': false })) {
+ intersection.push(cur);
+ break;
+ }
+ }
+ });
+ options.result[prop] = intersection;
+ return true;
+ }
+ }
+ };
+});
+/*can-set@1.0.2#src/get*/
+define('can-set@1.0.2#src/get', function (require, exports, module) {
+ var compare = require('./compare');
+ var h = require('./helpers');
+ var each = require('can-util/js/each/each');
+ var filterData = function (data, clause, props) {
+ return h.filter.call(data, function (item) {
+ var isSubset = compare.subset(item, clause, undefined, undefined, undefined, props, {});
+ return isSubset;
+ });
+ };
+ module.exports = {
+ subsetData: function (a, b, bData, algebra) {
+ var aClauseProps = algebra.getClauseProperties(a);
+ var bClauseProps = algebra.getClauseProperties(b);
+ var options = {};
+ var aData = filterData(bData, aClauseProps.where, algebra.clauses.where);
+ if (aData.length && (aClauseProps.enabled.order || bClauseProps.enabled.order)) {
+ options = {};
+ var propName = h.firstProp(aClauseProps.order), compareOrder = algebra.clauses.order[propName];
+ aData = aData.sort(function (aItem, bItem) {
+ return compareOrder(a[propName], aItem, bItem);
+ });
+ }
+ if (aData.length && (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate)) {
+ options = {};
+ compare.subset(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, algebra.clauses.paginate, options);
+ each(options.getSubsets, function (filter) {
+ aData = filter(a, b, aData, algebra, options);
+ });
+ }
+ return aData;
+ }
+ };
+});
+/*can-set@1.0.2#src/set-core*/
+define('can-set@1.0.2#src/set-core', function (require, exports, module) {
+ var h = require('./helpers');
+ var clause = require('./clause');
+ var compare = require('./compare');
+ var get = require('./get');
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
+ function Translate(clause, options) {
+ if (typeof options === 'string') {
+ var path = options;
+ options = {
+ fromSet: function (set, setRemainder) {
+ return set[path] || {};
+ },
+ toSet: function (set, wheres) {
+ set[path] = wheres;
+ return set;
+ }
+ };
+ }
+ this.clause = clause;
+ assign(this, options);
+ }
+ var Algebra = function () {
+ var clauses = this.clauses = {
+ where: {},
+ order: {},
+ paginate: {},
+ id: {}
+ };
+ this.translators = {
+ where: new Translate('where', {
+ fromSet: function (set, setRemainder) {
+ return setRemainder;
+ },
+ toSet: function (set, wheres) {
+ return assign(set, wheres);
+ }
+ })
+ };
+ var self = this;
+ each(arguments, function (arg) {
+ if (arg) {
+ if (arg instanceof Translate) {
+ self.translators[arg.clause] = arg;
+ } else {
+ assign(clauses[arg.constructor.type || 'where'], arg);
+ }
+ }
+ });
+ };
+ Algebra.make = function (compare, count) {
+ if (compare instanceof Algebra) {
+ return compare;
+ } else {
+ return new Algebra(compare, count);
+ }
+ };
+ assign(Algebra.prototype, {
+ getClauseProperties: function (set, options) {
+ options = options || {};
+ var setClone = assign({}, set);
+ var clauses = this.clauses;
+ var checkClauses = [
+ 'order',
+ 'paginate',
+ 'id'
+ ];
+ var clauseProps = {
+ enabled: {
+ where: true,
+ order: false,
+ paginate: false,
+ id: false
+ }
+ };
+ if (options.omitClauses) {
+ checkClauses = h.arrayUnionIntersectionDifference(checkClauses, options.omitClauses).difference;
+ }
+ each(checkClauses, function (clauseName) {
+ var valuesForClause = {};
+ var prop;
+ for (prop in clauses[clauseName]) {
+ if (prop in setClone) {
+ valuesForClause[prop] = setClone[prop];
+ delete setClone[prop];
+ }
+ }
+ clauseProps[clauseName] = valuesForClause;
+ clauseProps.enabled[clauseName] = !isEmptyObject(valuesForClause);
+ });
+ clauseProps.where = options.isProperties ? setClone : this.translators.where.fromSet(set, setClone);
+ return clauseProps;
+ },
+ getDifferentClauseTypes: function (aClauses, bClauses) {
+ var self = this;
+ var differentTypes = [];
+ each(clause.TYPES, function (type) {
+ if (!self.evaluateOperator(compare.equal, aClauses[type], bClauses[type], { isProperties: true }, { isProperties: true })) {
+ differentTypes.push(type);
+ }
+ });
+ return differentTypes;
+ },
+ updateSet: function (set, clause, result, useSet) {
+ if (result && typeof result === 'object' && useSet !== false) {
+ if (this.translators[clause]) {
+ set = this.translators.where.toSet(set, result);
+ } else {
+ set = assign(set, result);
+ }
+ return true;
+ } else if (result) {
+ return useSet === undefined ? undefined : false;
+ } else {
+ return false;
+ }
+ },
+ evaluateOperator: function (operator, a, b, aOptions, bOptions, evaluateOptions) {
+ aOptions = aOptions || {};
+ bOptions = bOptions || {};
+ evaluateOptions = assign({
+ evaluateWhere: operator,
+ evaluatePaginate: operator,
+ evaluateOrder: operator,
+ shouldEvaluatePaginate: function (aClauseProps, bClauseProps) {
+ return aClauseProps.enabled.paginate || bClauseProps.enabled.paginate;
+ },
+ shouldEvaluateOrder: function (aClauseProps, bClauseProps) {
+ return aClauseProps.enabled.order && compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {});
+ }
+ }, evaluateOptions || {});
+ var aClauseProps = this.getClauseProperties(a, aOptions), bClauseProps = this.getClauseProperties(b, bOptions), set = {}, useSet;
+ var result = evaluateOptions.evaluateWhere(aClauseProps.where, bClauseProps.where, undefined, undefined, undefined, this.clauses.where, {});
+ useSet = this.updateSet(set, 'where', result, useSet);
+ if (result && evaluateOptions.shouldEvaluatePaginate(aClauseProps, bClauseProps)) {
+ if (evaluateOptions.shouldEvaluateOrder(aClauseProps, bClauseProps)) {
+ result = evaluateOptions.evaluateOrder(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {});
+ useSet = this.updateSet(set, 'order', result, useSet);
+ }
+ if (result) {
+ result = evaluateOptions.evaluatePaginate(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, this.clauses.paginate, {});
+ useSet = this.updateSet(set, 'paginate', result, useSet);
+ }
+ } else if (result && evaluateOptions.shouldEvaluateOrder(aClauseProps, bClauseProps)) {
+ result = operator(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {});
+ useSet = this.updateSet(set, 'order', result, useSet);
+ }
+ return result && useSet ? set : result;
+ },
+ equal: function (a, b) {
+ return this.evaluateOperator(compare.equal, a, b);
+ },
+ subset: function (a, b) {
+ var aClauseProps = this.getClauseProperties(a);
+ var bClauseProps = this.getClauseProperties(b);
+ var compatibleSort = true;
+ var result;
+ if (bClauseProps.enabled.paginate && (aClauseProps.enabled.order || bClauseProps.enabled.order)) {
+ compatibleSort = compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {});
+ }
+ if (!compatibleSort) {
+ result = false;
+ } else {
+ result = this.evaluateOperator(compare.subset, a, b);
+ }
+ return result;
+ },
+ properSubset: function (a, b) {
+ return this.subset(a, b) && !this.equal(a, b);
+ },
+ difference: function (a, b) {
+ var aClauseProps = this.getClauseProperties(a);
+ var bClauseProps = this.getClauseProperties(b);
+ var differentClauses = this.getDifferentClauseTypes(aClauseProps, bClauseProps);
+ var result;
+ switch (differentClauses.length) {
+ case 0: {
+ result = false;
+ break;
+ }
+ case 1: {
+ var clause = differentClauses[0];
+ result = compare.difference(aClauseProps[clause], bClauseProps[clause], undefined, undefined, undefined, this.clauses[clause], {});
+ if (this.translators[clause] && typeof result === 'object') {
+ result = this.translators[clause].toSet({}, result);
+ }
+ break;
+ }
+ }
+ return result;
+ },
+ union: function (a, b) {
+ return this.evaluateOperator(compare.union, a, b);
+ },
+ intersection: function (a, b) {
+ return this.evaluateOperator(compare.intersection, a, b);
+ },
+ count: function (set) {
+ return this.evaluateOperator(compare.count, set, {});
+ },
+ has: function (set, props) {
+ var aClauseProps = this.getClauseProperties(set);
+ var propsClauseProps = this.getClauseProperties(props, { isProperties: true });
+ var compatibleSort = true;
+ var result;
+ if ((propsClauseProps.enabled.paginate || aClauseProps.enabled.paginate) && (propsClauseProps.enabled.order || aClauseProps.enabled.order)) {
+ compatibleSort = compare.equal(propsClauseProps.order, aClauseProps.order, undefined, undefined, undefined, {}, {});
+ }
+ if (!compatibleSort) {
+ result = false;
+ } else {
+ result = this.evaluateOperator(compare.subset, props, set, { isProperties: true }, undefined);
+ }
+ return result;
+ },
+ index: function (set, items, item) {
+ var aClauseProps = this.getClauseProperties(set);
+ var propName = h.firstProp(aClauseProps.order), compare, orderValue;
+ if (propName) {
+ compare = this.clauses.order[propName];
+ orderValue = set[propName];
+ return h.index(function (itemA, itemB) {
+ return compare(orderValue, itemA, itemB);
+ }, items, item);
+ }
+ propName = h.firstProp(this.clauses.id);
+ if (propName) {
+ compare = h.defaultSort;
+ orderValue = propName;
+ return h.index(function (itemA, itemB) {
+ return compare(orderValue, itemA, itemB);
+ }, items, item);
+ }
+ return;
+ },
+ getSubset: function (a, b, bData) {
+ var aClauseProps = this.getClauseProperties(a);
+ var bClauseProps = this.getClauseProperties(b);
+ var isSubset = this.subset(assign({}, aClauseProps.where, aClauseProps.paginate), assign({}, bClauseProps.where, bClauseProps.paginate));
+ if (isSubset) {
+ return get.subsetData(a, b, bData, this);
+ }
+ },
+ getUnion: function (a, b, aItems, bItems) {
+ var aClauseProps = this.getClauseProperties(a);
+ var bClauseProps = this.getClauseProperties(b);
+ var algebra = this;
+ var options;
+ if (this.subset(a, b)) {
+ return bItems;
+ } else if (this.subset(b, a)) {
+ return aItems;
+ }
+ var combined;
+ if (aClauseProps.enabled.paginate || bClauseProps.enabled.paginate) {
+ options = {};
+ var isUnion = compare.union(aClauseProps.paginate, bClauseProps.paginate, undefined, undefined, undefined, this.clauses.paginate, options);
+ if (!isUnion) {
+ return;
+ } else {
+ each(options.getUnions, function (filter) {
+ var items = filter(a, b, aItems, bItems, algebra, options);
+ aItems = items[0];
+ bItems = items[1];
+ });
+ combined = aItems.concat(bItems);
+ }
+ } else {
+ combined = aItems.concat(bItems);
+ }
+ if (combined.length && aClauseProps.enabled.order && compare.equal(aClauseProps.order, bClauseProps.order, undefined, undefined, undefined, {}, {})) {
+ options = {};
+ var propName = h.firstProp(aClauseProps.order), compareOrder = algebra.clauses.order[propName];
+ combined = combined.sort(function (aItem, bItem) {
+ return compareOrder(a[propName], aItem, bItem);
+ });
+ }
+ return combined;
+ }
+ });
+ var callOnAlgebra = function (methodName, algebraArgNumber) {
+ return function () {
+ var args = makeArray(arguments).slice(0, algebraArgNumber);
+ var algebra = Algebra.make(arguments[algebraArgNumber]);
+ return algebra[methodName].apply(algebra, args);
+ };
+ };
+ module.exports = {
+ Algebra: Algebra,
+ Translate: Translate,
+ difference: callOnAlgebra('difference', 2),
+ equal: callOnAlgebra('equal', 2),
+ subset: callOnAlgebra('subset', 2),
+ properSubset: callOnAlgebra('properSubset', 2),
+ union: callOnAlgebra('union', 2),
+ intersection: callOnAlgebra('intersection', 2),
+ count: callOnAlgebra('count', 1),
+ has: callOnAlgebra('has', 2),
+ index: callOnAlgebra('index', 3),
+ getSubset: callOnAlgebra('getSubset', 3),
+ getUnion: callOnAlgebra('getUnion', 4)
+ };
+});
+/*can-set@1.0.2#src/props*/
+define('can-set@1.0.2#src/props', function (require, exports, module) {
+ var h = require('./helpers');
+ var clause = require('./clause');
+ var each = require('can-util/js/each/each');
+ var within = function (value, range) {
+ return value >= range[0] && value <= range[1];
+ };
+ var numericProperties = function (setA, setB, property1, property2) {
+ return {
+ sAv1: +setA[property1],
+ sAv2: +setA[property2],
+ sBv1: +setB[property1],
+ sBv2: +setB[property2]
+ };
+ };
+ var diff = function (setA, setB, property1, property2) {
+ var numProps = numericProperties(setA, setB, property1, property2);
+ var sAv1 = numProps.sAv1, sAv2 = numProps.sAv2, sBv1 = numProps.sBv1, sBv2 = numProps.sBv2, count = sAv2 - sAv1 + 1;
+ var after = {
+ difference: [
+ sBv2 + 1,
+ sAv2
+ ],
+ intersection: [
+ sAv1,
+ sBv2
+ ],
+ union: [
+ sBv1,
+ sAv2
+ ],
+ count: count,
+ meta: 'after'
+ };
+ var before = {
+ difference: [
+ sAv1,
+ sBv1 - 1
+ ],
+ intersection: [
+ sBv1,
+ sAv2
+ ],
+ union: [
+ sAv1,
+ sBv2
+ ],
+ count: count,
+ meta: 'before'
+ };
+ if (sAv1 === sBv1 && sAv2 === sBv2) {
+ return {
+ intersection: [
+ sAv1,
+ sAv2
+ ],
+ union: [
+ sAv1,
+ sAv2
+ ],
+ count: count,
+ meta: 'equal'
+ };
+ } else if (sAv1 === sBv1 && sBv2 < sAv2) {
+ return after;
+ } else if (sAv2 === sBv2 && sBv1 > sAv1) {
+ return before;
+ } else if (within(sAv1, [
+ sBv1,
+ sBv2
+ ]) && within(sAv2, [
+ sBv1,
+ sBv2
+ ])) {
+ return {
+ intersection: [
+ sAv1,
+ sAv2
+ ],
+ union: [
+ sBv1,
+ sBv2
+ ],
+ count: count,
+ meta: 'subset'
+ };
+ } else if (within(sBv1, [
+ sAv1,
+ sAv2
+ ]) && within(sBv2, [
+ sAv1,
+ sAv2
+ ])) {
+ return {
+ intersection: [
+ sBv1,
+ sBv2
+ ],
+ difference: [
+ null,
+ null
+ ],
+ union: [
+ sAv1,
+ sAv2
+ ],
+ count: count,
+ meta: 'superset'
+ };
+ } else if (sAv1 < sBv1 && within(sAv2, [
+ sBv1,
+ sBv2
+ ])) {
+ return before;
+ } else if (sBv1 < sAv1 && within(sBv2, [
+ sAv1,
+ sAv2
+ ])) {
+ return after;
+ } else if (sAv2 === sBv1 - 1) {
+ return {
+ difference: [
+ sAv1,
+ sAv2
+ ],
+ union: [
+ sAv1,
+ sBv2
+ ],
+ count: count,
+ meta: 'disjoint-before'
+ };
+ } else if (sBv2 === sAv1 - 1) {
+ return {
+ difference: [
+ sAv1,
+ sAv2
+ ],
+ union: [
+ sBv1,
+ sAv2
+ ],
+ count: count,
+ meta: 'disjoint-after'
+ };
+ }
+ if (!isNaN(count)) {
+ return {
+ count: count,
+ meta: 'disjoint'
+ };
+ }
+ };
+ var cleanUp = function (value, enumData) {
+ if (!value) {
+ return enumData;
+ }
+ if (!Array.isArray(value)) {
+ value = [value];
+ }
+ if (!value.length) {
+ return enumData;
+ }
+ return value;
+ };
+ var stringConvert = {
+ '0': false,
+ 'false': false,
+ 'null': undefined,
+ 'undefined': undefined
+ };
+ var convertToBoolean = function (value) {
+ if (typeof value === 'string') {
+ return value.toLowerCase() in stringConvert ? stringConvert[value.toLowerCase()] : true;
+ }
+ return value;
+ };
+ var props = {
+ 'enum': function (prop, enumData) {
+ var compares = new clause.Where({});
+ compares[prop] = function (vA, vB, A, B) {
+ vA = cleanUp(vA, enumData);
+ vB = cleanUp(vB, enumData);
+ var data = h.arrayUnionIntersectionDifference(vA, vB);
+ if (!data.difference.length) {
+ delete data.difference;
+ }
+ each(data, function (value, prop) {
+ if (Array.isArray(value)) {
+ if (h.arraySame(enumData, value)) {
+ data[prop] = undefined;
+ } else if (value.length === 1) {
+ data[prop] = value[0];
+ }
+ }
+ });
+ return data;
+ };
+ return compares;
+ },
+ paginate: function (propStart, propEnd, translateToStartEnd, reverseTranslate) {
+ var compares = {};
+ var makeResult = function (result, index) {
+ var res = {};
+ each([
+ 'intersection',
+ 'difference',
+ 'union'
+ ], function (prop) {
+ if (result[prop]) {
+ var set = {
+ start: result[prop][0],
+ end: result[prop][1]
+ };
+ res[prop] = reverseTranslate(set)[index === 0 ? propStart : propEnd];
+ }
+ });
+ if (result.count) {
+ res.count = result.count;
+ }
+ return res;
+ };
+ compares[propStart] = function (vA, vB, A, B) {
+ if (vA === undefined) {
+ return;
+ }
+ var res = diff(translateToStartEnd(A), translateToStartEnd(B), 'start', 'end');
+ var result = makeResult(res, 0);
+ result.getSubset = function (a, b, bItems, algebra, options) {
+ return bItems;
+ };
+ result.getUnion = function (a, b, aItems, bItems, algebra, options) {
+ return [
+ aItems,
+ bItems
+ ];
+ };
+ return result;
+ };
+ compares[propEnd] = function (vA, vB, A, B) {
+ if (vA === undefined) {
+ return;
+ }
+ var data = diff(translateToStartEnd(A), translateToStartEnd(B), 'start', 'end');
+ var res = makeResult(data, 1);
+ res.getSubset = function (a, b, bItems, algebra, options) {
+ var tA = translateToStartEnd(a);
+ var tB = translateToStartEnd(b);
+ var numProps = numericProperties(tA, tB, 'start', 'end');
+ var aStartValue = numProps.sAv1, aEndValue = numProps.sAv2;
+ var bStartValue = numProps.sBv1;
+ if (!('end' in tB) || !('end' in tA)) {
+ return bItems.slice(aStartValue, aEndValue + 1);
+ }
+ return bItems.slice(aStartValue - bStartValue, aEndValue - bStartValue + 1);
+ };
+ res.getUnion = function (a, b, aItems, bItems, algebra, options) {
+ var tA = translateToStartEnd(a);
+ var tB = translateToStartEnd(b);
+ if (data.meta.indexOf('after') >= 0) {
+ if (data.intersection) {
+ bItems = bItems.slice(0, data.intersection[0] - +tB.start);
+ }
+ return [
+ bItems,
+ aItems
+ ];
+ }
+ if (data.intersection) {
+ aItems = aItems.slice(0, data.intersection[0] - +tA.start);
+ }
+ return [
+ aItems,
+ bItems
+ ];
+ };
+ return res;
+ };
+ return new clause.Paginate(compares);
+ },
+ 'boolean': function (propertyName) {
+ var compares = new clause.Where({});
+ compares[propertyName] = function (propA, propB) {
+ propA = convertToBoolean(propA);
+ propB = convertToBoolean(propB);
+ var notA = !propA, notB = !propB;
+ if (propA === notB && propB === notA) {
+ return {
+ difference: !propB,
+ union: undefined
+ };
+ } else if (propA === undefined) {
+ return {
+ difference: !propB,
+ intersection: propB,
+ union: undefined
+ };
+ } else if (propA === propB) {
+ return true;
+ }
+ };
+ return compares;
+ },
+ 'sort': function (prop, sortFunc) {
+ if (!sortFunc) {
+ sortFunc = h.defaultSort;
+ }
+ var compares = {};
+ compares[prop] = sortFunc;
+ return new clause.Order(compares);
+ },
+ 'id': function (prop) {
+ var compares = {};
+ compares[prop] = prop;
+ return new clause.Id(compares);
+ }
+ };
+ var assignExcept = function (d, s, props) {
+ for (var prop in s) {
+ if (!props[prop]) {
+ d[prop] = s[prop];
+ }
+ }
+ return d;
+ };
+ var translateToOffsetLimit = function (set, offsetProp, limitProp) {
+ var newSet = assignExcept({}, set, {
+ start: 1,
+ end: 1
+ });
+ if ('start' in set) {
+ newSet[offsetProp] = set.start;
+ }
+ if ('end' in set) {
+ newSet[limitProp] = set.end - set.start + 1;
+ }
+ return newSet;
+ };
+ var translateToStartEnd = function (set, offsetProp, limitProp) {
+ var except = {};
+ except[offsetProp] = except[limitProp] = 1;
+ var newSet = assignExcept({}, set, except);
+ if (offsetProp in set) {
+ newSet.start = parseInt(set[offsetProp], 10);
+ }
+ if (limitProp in set) {
+ newSet.end = newSet.start + parseInt(set[limitProp]) - 1;
+ }
+ return newSet;
+ };
+ props.offsetLimit = function (offsetProp, limitProp) {
+ offsetProp = offsetProp || 'offset';
+ limitProp = limitProp || 'limit';
+ return props.paginate(offsetProp, limitProp, function (set) {
+ return translateToStartEnd(set, offsetProp, limitProp);
+ }, function (set) {
+ return translateToOffsetLimit(set, offsetProp, limitProp);
+ });
+ };
+ props.rangeInclusive = function (startIndexProperty, endIndexProperty) {
+ startIndexProperty = startIndexProperty || 'start';
+ endIndexProperty = endIndexProperty || 'end';
+ return props.paginate(startIndexProperty, endIndexProperty, function (set) {
+ var except = {};
+ except[startIndexProperty] = except[endIndexProperty] = 1;
+ var newSet = assignExcept({}, set, except);
+ if (startIndexProperty in set) {
+ newSet.start = set[startIndexProperty];
+ }
+ if (endIndexProperty in set) {
+ newSet.end = set[endIndexProperty];
+ }
+ return newSet;
+ }, function (set) {
+ var except = {
+ start: 1,
+ end: 1
+ };
+ var newSet = assignExcept({}, set, except);
+ newSet[startIndexProperty] = set.start;
+ newSet[endIndexProperty] = set.end;
+ return newSet;
+ });
+ };
+ module.exports = props;
+});
+/*can-set@1.0.2#src/set*/
+define('can-set@1.0.2#src/set', function (require, exports, module) {
+ var set = require('./set-core');
+ var ns = require('can-util/namespace');
+ var props = require('./props');
+ var clause = require('./clause');
+ set.comparators = props;
+ set.props = props;
+ set.helpers = require('./helpers');
+ set.clause = clause;
+ module.exports = ns.set = set;
+});
+/*can-connect@1.0.11#helpers/get-items*/
+define('can-connect@1.0.11#helpers/get-items', function (require, exports, module) {
+ var isArray = require('can-util/js/is-array/is-array');
+ module.exports = function (data) {
+ if (isArray(data)) {
+ return data;
+ } else {
+ return data.data;
+ }
+ };
+});
+/*can-connect@1.0.11#cache-requests/cache-requests*/
+define('can-connect@1.0.11#cache-requests/cache-requests', function (require, exports, module) {
+ var connect = require('can-connect');
+ var getItems = require('can-connect/helpers/get-items');
+ var canSet = require('can-set');
+ var forEach = [].forEach;
+ module.exports = connect.behavior('cache-requests', function (base) {
+ return {
+ getDiff: function (params, availableSets) {
+ var minSets, self = this;
+ forEach.call(availableSets, function (set) {
+ var curSets;
+ var difference = canSet.difference(params, set, self.algebra);
+ if (typeof difference === 'object') {
+ curSets = {
+ needed: difference,
+ cached: canSet.intersection(params, set, self.algebra),
+ count: canSet.count(difference, self.algebra)
+ };
+ } else if (canSet.subset(params, set, self.algebra)) {
+ curSets = {
+ cached: params,
+ count: 0
+ };
+ }
+ if (curSets) {
+ if (!minSets || curSets.count < minSets.count) {
+ minSets = curSets;
+ }
+ }
+ });
+ if (!minSets) {
+ return { needed: params };
+ } else {
+ return {
+ needed: minSets.needed,
+ cached: minSets.cached
+ };
+ }
+ },
+ getUnion: function (params, diff, neededItems, cachedItems) {
+ return { data: canSet.getUnion(diff.needed, diff.cached, getItems(neededItems), getItems(cachedItems), this.algebra) };
+ },
+ getListData: function (set) {
+ set = set || {};
+ var self = this;
+ return this.cacheConnection.getSets(set).then(function (sets) {
+ var diff = self.getDiff(set, sets);
+ if (!diff.needed) {
+ return self.cacheConnection.getListData(diff.cached);
+ } else if (!diff.cached) {
+ return base.getListData(diff.needed).then(function (data) {
+ return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () {
+ return data;
+ });
+ });
+ } else {
+ var cachedPromise = self.cacheConnection.getListData(diff.cached);
+ var needsPromise = base.getListData(diff.needed);
+ var savedPromise = needsPromise.then(function (data) {
+ return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () {
+ return data;
+ });
+ });
+ var combinedPromise = Promise.all([
+ cachedPromise,
+ needsPromise
+ ]).then(function (result) {
+ var cached = result[0], needed = result[1];
+ return self.getUnion(set, diff, needed, cached);
+ });
+ return Promise.all([
+ combinedPromise,
+ savedPromise
+ ]).then(function (data) {
+ return data[0];
+ });
+ }
+ });
+ }
+ };
+ });
+});
+/*can-connect@1.0.11#helpers/weak-reference-map*/
+define('can-connect@1.0.11#helpers/weak-reference-map', function (require, exports, module) {
+ var assign = require('can-util/js/assign/assign');
+ var WeakReferenceMap = function () {
+ this.set = {};
+ };
+ assign(WeakReferenceMap.prototype, {
+ has: function (key) {
+ return !!this.set[key];
+ },
+ addReference: function (key, item) {
+ var data = this.set[key];
+ if (!data) {
+ data = this.set[key] = {
+ item: item,
+ referenceCount: 0,
+ key: key
+ };
+ }
+ data.referenceCount++;
+ },
+ deleteReference: function (key) {
+ var data = this.set[key];
+ if (data) {
+ data.referenceCount--;
+ if (data.referenceCount === 0) {
+ delete this.set[key];
+ }
+ }
+ },
+ get: function (key) {
+ var data = this.set[key];
+ if (data) {
+ return data.item;
+ }
+ },
+ forEach: function (cb) {
+ for (var id in this.set) {
+ cb(this.set[id].item, id);
+ }
+ }
+ });
+ module.exports = WeakReferenceMap;
+});
+/*can-connect@1.0.11#helpers/overwrite*/
+define('can-connect@1.0.11#helpers/overwrite', function (require, exports, module) {
+ module.exports = function (d, s, id) {
+ for (var prop in d) {
+ if (prop !== id && !(prop in s)) {
+ delete d[prop];
+ }
+ }
+ for (prop in s) {
+ d[prop] = s[prop];
+ }
+ return d;
+ };
+});
+/*can-connect@1.0.11#constructor/constructor*/
+define('can-connect@1.0.11#constructor/constructor', function (require, exports, module) {
+ var isArray = require('can-util/js/is-array/is-array');
+ var makeArray = require('can-util/js/make-array/make-array');
+ var assign = require('can-util/js/assign/assign');
+ var connect = require('can-connect');
+ var WeakReferenceMap = require('can-connect/helpers/weak-reference-map');
+ var overwrite = require('can-connect/helpers/overwrite');
+ var idMerge = require('can-connect/helpers/id-merge');
+ module.exports = connect.behavior('constructor', function (baseConnect) {
+ var behavior = {
+ cidStore: new WeakReferenceMap(),
+ _cid: 0,
+ get: function (params) {
+ var self = this;
+ return this.getData(params).then(function (data) {
+ return self.hydrateInstance(data);
+ });
+ },
+ getList: function (set) {
+ set = set || {};
+ var self = this;
+ return this.getListData(set).then(function (data) {
+ return self.hydrateList(data, set);
+ });
+ },
+ hydrateList: function (listData, set) {
+ if (isArray(listData)) {
+ listData = { data: listData };
+ }
+ var arr = [];
+ for (var i = 0; i < listData.data.length; i++) {
+ arr.push(this.hydrateInstance(listData.data[i]));
+ }
+ listData.data = arr;
+ if (this.list) {
+ return this.list(listData, set);
+ } else {
+ var list = listData.data.slice(0);
+ list[this.listSetProp || '__listSet'] = set;
+ copyMetadata(listData, list);
+ return list;
+ }
+ },
+ hydrateInstance: function (props) {
+ if (this.instance) {
+ return this.instance(props);
+ } else {
+ return assign({}, props);
+ }
+ },
+ save: function (instance) {
+ var serialized = this.serializeInstance(instance);
+ var id = this.id(instance);
+ var self = this;
+ if (id === undefined) {
+ var cid = this._cid++;
+ this.cidStore.addReference(cid, instance);
+ return this.createData(serialized, cid).then(function (data) {
+ if (data !== undefined) {
+ self.createdInstance(instance, data);
+ }
+ self.cidStore.deleteReference(cid, instance);
+ return instance;
+ });
+ } else {
+ return this.updateData(serialized).then(function (data) {
+ if (data !== undefined) {
+ self.updatedInstance(instance, data);
+ }
+ return instance;
+ });
+ }
+ },
+ destroy: function (instance) {
+ var serialized = this.serializeInstance(instance), self = this;
+ return this.destroyData(serialized).then(function (data) {
+ if (data !== undefined) {
+ self.destroyedInstance(instance, data);
+ }
+ return instance;
+ });
+ },
+ createdInstance: function (instance, props) {
+ assign(instance, props);
+ },
+ updatedInstance: function (instance, data) {
+ overwrite(instance, data, this.idProp);
+ },
+ updatedList: function (list, listData, set) {
+ var instanceList = [];
+ for (var i = 0; i < listData.data.length; i++) {
+ instanceList.push(this.hydrateInstance(listData.data[i]));
+ }
+ idMerge(list, instanceList, this.id.bind(this), this.hydrateInstance.bind(this));
+ copyMetadata(listData, list);
+ },
+ destroyedInstance: function (instance, data) {
+ overwrite(instance, data, this.idProp);
+ },
+ serializeInstance: function (instance) {
+ return assign({}, instance);
+ },
+ serializeList: function (list) {
+ var self = this;
+ return makeArray(list).map(function (instance) {
+ return self.serializeInstance(instance);
+ });
+ },
+ isNew: function (instance) {
+ var id = this.id(instance);
+ return !(id || id === 0);
+ }
+ };
+ return behavior;
+ });
+ function copyMetadata(listData, list) {
+ for (var prop in listData) {
+ if (prop !== 'data') {
+ if (typeof list.set === 'function') {
+ list.set(prop, listData[prop]);
+ } else if (typeof list.attr === 'function') {
+ list.attr(prop, listData[prop]);
+ } else {
+ list[prop] = listData[prop];
+ }
+ }
+ }
+ }
+});
+/*can-connect@1.0.11#helpers/sorted-set-json*/
+define('can-connect@1.0.11#helpers/sorted-set-json', function (require, exports, module) {
+ var forEach = [].forEach;
+ var keys = Object.keys;
+ module.exports = function (set) {
+ if (set == null) {
+ return set;
+ } else {
+ var sorted = {};
+ forEach.call(keys(set).sort(), function (prop) {
+ sorted[prop] = set[prop];
+ });
+ return JSON.stringify(sorted);
+ }
+ };
+});
+/*can-connect@1.0.11#constructor/callbacks-once/callbacks-once*/
+define('can-connect@1.0.11#constructor/callbacks-once/callbacks-once', function (require, exports, module) {
+ var connect = require('can-connect');
+ var sortedSetJSON = require('can-connect/helpers/sorted-set-json');
+ var forEach = [].forEach;
+ var callbacks = [
+ 'createdInstance',
+ 'updatedInstance',
+ 'destroyedInstance'
+ ];
+ module.exports = connect.behavior('constructor/callbacks-once', function (baseConnect) {
+ var behavior = {};
+ forEach.call(callbacks, function (name) {
+ behavior[name] = function (instance, data) {
+ var lastSerialized = this.getInstanceMetaData(instance, 'last-data');
+ var serialize = sortedSetJSON(data), serialized = sortedSetJSON(this.serializeInstance(instance));
+ if (lastSerialized !== serialize && serialized !== serialize) {
+ var result = baseConnect[name].apply(this, arguments);
+ this.addInstanceMetaData(instance, 'last-data', serialize);
+ return result;
+ }
+ };
+ });
+ return behavior;
+ });
+});
+/*can-connect@1.0.11#constructor/store/store*/
+define('can-connect@1.0.11#constructor/store/store', function (require, exports, module) {
+ var connect = require('can-connect');
+ var WeakReferenceMap = require('can-connect/helpers/weak-reference-map');
+ var sortedSetJSON = require('can-connect/helpers/sorted-set-json');
+ var canEvent = require('can-event');
+ var assign = require('can-util/js/assign/assign');
+ var pendingRequests = 0;
+ var noRequestsTimer = null;
+ var requests = {
+ increment: function (connection) {
+ pendingRequests++;
+ clearTimeout(noRequestsTimer);
+ },
+ decrement: function (connection) {
+ pendingRequests--;
+ if (pendingRequests === 0) {
+ noRequestsTimer = setTimeout(function () {
+ requests.dispatch('end');
+ }, 10);
+ }
+ },
+ count: function () {
+ return pendingRequests;
+ }
+ };
+ assign(requests, canEvent);
+ var constructorStore = connect.behavior('constructor/store', function (baseConnect) {
+ var behavior = {
+ instanceStore: new WeakReferenceMap(),
+ listStore: new WeakReferenceMap(),
+ _requestInstances: {},
+ _requestLists: {},
+ _finishedRequest: function () {
+ var id;
+ requests.decrement(this);
+ if (requests.count() === 0) {
+ for (id in this._requestInstances) {
+ this.instanceStore.deleteReference(id);
+ }
+ this._requestInstances = {};
+ for (id in this._requestLists) {
+ this.listStore.deleteReference(id);
+ }
+ this._requestLists = {};
+ }
+ },
+ addInstanceReference: function (instance, id) {
+ this.instanceStore.addReference(id || this.id(instance), instance);
+ },
+ addInstanceMetaData: function (instance, name, value) {
+ var data = this.instanceStore.set[this.id(instance)];
+ if (data) {
+ data[name] = value;
+ }
+ },
+ getInstanceMetaData: function (instance, name) {
+ var data = this.instanceStore.set[this.id(instance)];
+ if (data) {
+ return data[name];
+ }
+ },
+ deleteInstanceMetaData: function (instance, name) {
+ var data = this.instanceStore.set[this.id(instance)];
+ delete data[name];
+ },
+ deleteInstanceReference: function (instance) {
+ this.instanceStore.deleteReference(this.id(instance), instance);
+ },
+ addListReference: function (list, set) {
+ var id = sortedSetJSON(set || this.listSet(list));
+ if (id) {
+ this.listStore.addReference(id, list);
+ }
+ },
+ deleteListReference: function (list, set) {
+ var id = sortedSetJSON(set || this.listSet(list));
+ if (id) {
+ this.listStore.deleteReference(id, list);
+ }
+ },
+ hydratedInstance: function (instance) {
+ if (requests.count() > 0) {
+ var id = this.id(instance);
+ if (!this._requestInstances[id]) {
+ this.addInstanceReference(instance);
+ this._requestInstances[id] = instance;
+ }
+ }
+ },
+ hydrateInstance: function (props) {
+ var id = this.id(props);
+ if ((id || id === 0) && this.instanceStore.has(id)) {
+ var storeInstance = this.instanceStore.get(id);
+ this.updatedInstance(storeInstance, props);
+ return storeInstance;
+ }
+ var instance = baseConnect.hydrateInstance.call(this, props);
+ this.hydratedInstance(instance);
+ return instance;
+ },
+ hydratedList: function (list, set) {
+ if (requests.count() > 0) {
+ var id = sortedSetJSON(set || this.listSet(list));
+ if (id) {
+ if (!this._requestLists[id]) {
+ this.addListReference(list, set);
+ this._requestLists[id] = list;
+ }
+ }
+ }
+ },
+ hydrateList: function (listData, set) {
+ set = set || this.listSet(listData);
+ var id = sortedSetJSON(set);
+ if (id && this.listStore.has(id)) {
+ var storeList = this.listStore.get(id);
+ this.updatedList(storeList, listData, set);
+ return storeList;
+ }
+ var list = baseConnect.hydrateList.call(this, listData, set);
+ this.hydratedList(list, set);
+ return list;
+ },
+ getList: function (params) {
+ var self = this;
+ requests.increment(this);
+ var promise = baseConnect.getList.call(this, params);
+ promise.then(function (instances) {
+ self._finishedRequest();
+ }, function () {
+ self._finishedRequest();
+ });
+ return promise;
+ },
+ get: function (params) {
+ var self = this;
+ requests.increment(this);
+ var promise = baseConnect.get.call(this, params);
+ promise.then(function (instance) {
+ self._finishedRequest();
+ }, function () {
+ self._finishedRequest();
+ });
+ return promise;
+ },
+ save: function (instance) {
+ var self = this;
+ requests.increment(this);
+ var updating = !this.isNew(instance);
+ if (updating) {
+ this.addInstanceReference(instance);
+ }
+ var promise = baseConnect.save.call(this, instance);
+ promise.then(function (instances) {
+ if (updating) {
+ self.deleteInstanceReference(instance);
+ }
+ self._finishedRequest();
+ }, function () {
+ self._finishedRequest();
+ });
+ return promise;
+ },
+ destroy: function (instance) {
+ var self = this;
+ requests.increment(this);
+ var promise = baseConnect.destroy.call(this, instance);
+ promise.then(function (instance) {
+ self._finishedRequest();
+ }, function () {
+ self._finishedRequest();
+ });
+ return promise;
+ }
+ };
+ return behavior;
+ });
+ constructorStore.requests = requests;
+ module.exports = constructorStore;
+});
+/*can-connect@1.0.11#data/callbacks/callbacks*/
+define('can-connect@1.0.11#data/callbacks/callbacks', function (require, exports, module) {
+ var connect = require('can-connect');
+ var each = require('can-util/js/each/each');
+ var pairs = {
+ getListData: 'gotListData',
+ createData: 'createdData',
+ updateData: 'updatedData',
+ destroyData: 'destroyedData'
+ };
+ module.exports = connect.behavior('data/callbacks', function (baseConnect) {
+ var behavior = {};
+ each(pairs, function (callbackName, name) {
+ behavior[name] = function (params, cid) {
+ var self = this;
+ return baseConnect[name].call(this, params).then(function (data) {
+ if (self[callbackName]) {
+ return self[callbackName].call(self, data, params, cid);
+ } else {
+ return data;
+ }
+ });
+ };
+ });
+ return behavior;
+ });
+});
+/*can-connect@1.0.11#data/callbacks-cache/callbacks-cache*/
+define('can-connect@1.0.11#data/callbacks-cache/callbacks-cache', function (require, exports, module) {
+ var connect = require('can-connect');
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var pairs = {
+ createdData: 'createData',
+ updatedData: 'updateData',
+ destroyedData: 'destroyData'
+ };
+ module.exports = connect.behavior('data/callbacks-cache', function (baseConnect) {
+ var behavior = {};
+ each(pairs, function (cacheCallback, dataCallbackName) {
+ behavior[dataCallbackName] = function (data, set, cid) {
+ this.cacheConnection[cacheCallback](assign(assign({}, set), data));
+ return baseConnect[dataCallbackName].call(this, data, set, cid);
+ };
+ });
+ return behavior;
+ });
+});
+/*can-connect@1.0.11#helpers/deferred*/
+define('can-connect@1.0.11#helpers/deferred', function (require, exports, module) {
+ module.exports = function () {
+ var def = {};
+ def.promise = new Promise(function (resolve, reject) {
+ def.resolve = resolve;
+ def.reject = reject;
+ });
+ return def;
+ };
+});
+/*can-connect@1.0.11#data/combine-requests/combine-requests*/
+define('can-connect@1.0.11#data/combine-requests/combine-requests', function (require, exports, module) {
+ var connect = require('can-connect');
+ var canSet = require('can-set');
+ var getItems = require('can-connect/helpers/get-items');
+ var deepAssign = require('can-util/js/deep-assign/deep-assign');
+ var makeDeferred = require('can-connect/helpers/deferred');
+ var forEach = [].forEach;
+ module.exports = connect.behavior('data/combine-requests', function (base) {
+ var pendingRequests;
+ return {
+ unionPendingRequests: function (pendingRequests) {
+ var self = this;
+ pendingRequests.sort(function (pReq1, pReq2) {
+ if (canSet.subset(pReq1.set, pReq2.set, self.algebra)) {
+ return 1;
+ } else if (canSet.subset(pReq2.set, pReq1.set, self.algebra)) {
+ return -1;
+ } else {
+ return 0;
+ }
+ });
+ var combineData = [];
+ var current;
+ doubleLoop(pendingRequests, {
+ start: function (pendingRequest) {
+ current = {
+ set: pendingRequest.set,
+ pendingRequests: [pendingRequest]
+ };
+ combineData.push(current);
+ },
+ iterate: function (pendingRequest) {
+ var combined = canSet.union(current.set, pendingRequest.set, self.algebra);
+ if (combined) {
+ current.set = combined;
+ current.pendingRequests.push(pendingRequest);
+ return true;
+ }
+ }
+ });
+ return Promise.resolve(combineData);
+ },
+ getSubset: function (set, unionSet, data) {
+ return canSet.getSubset(set, unionSet, data, this.algebra);
+ },
+ time: 1,
+ getListData: function (set) {
+ set = set || {};
+ var self = this;
+ if (!pendingRequests) {
+ pendingRequests = [];
+ setTimeout(function () {
+ var combineDataPromise = self.unionPendingRequests(pendingRequests);
+ pendingRequests = null;
+ combineDataPromise.then(function (combinedData) {
+ forEach.call(combinedData, function (combined) {
+ var combinedSet = deepAssign({}, combined.set);
+ base.getListData(combinedSet).then(function (data) {
+ if (combined.pendingRequests.length === 1) {
+ combined.pendingRequests[0].deferred.resolve(data);
+ } else {
+ forEach.call(combined.pendingRequests, function (pending) {
+ pending.deferred.resolve({ data: self.getSubset(pending.set, combined.set, getItems(data)) });
+ });
+ }
+ }, function (err) {
+ if (combined.pendingRequests.length === 1) {
+ combined.pendingRequests[0].deferred.reject(err);
+ } else {
+ forEach.call(combined.pendingRequests, function (pending) {
+ pending.deferred.reject(err);
+ });
+ }
+ });
+ });
+ });
+ }, this.time || 1);
+ }
+ var deferred = makeDeferred();
+ pendingRequests.push({
+ deferred: deferred,
+ set: set
+ });
+ return deferred.promise;
+ }
+ };
+ });
+ var doubleLoop = function (arr, callbacks) {
+ var i = 0;
+ while (i < arr.length) {
+ callbacks.start(arr[i]);
+ var j = i + 1;
+ while (j < arr.length) {
+ if (callbacks.iterate(arr[j]) === true) {
+ arr.splice(j, 1);
+ } else {
+ j++;
+ }
+ }
+ i++;
+ }
+ };
+});
+/*can-connect@1.0.11#helpers/set-add*/
+define('can-connect@1.0.11#helpers/set-add', function (require, exports, module) {
+ var canSet = require('can-set');
+ module.exports = function (connection, setItems, items, item, algebra) {
+ var index = canSet.index(setItems, items, item, algebra);
+ if (index === undefined) {
+ index = items.length;
+ }
+ var copy = items.slice(0);
+ copy.splice(index, 0, item);
+ return copy;
+ };
+});
+/*can-connect@1.0.11#helpers/get-index-by-id*/
+define('can-connect@1.0.11#helpers/get-index-by-id', function (require, exports, module) {
+ module.exports = function (connection, props, items) {
+ var id = connection.id(props);
+ for (var i = 0; i < items.length; i++) {
+ var connId = connection.id(items[i]);
+ if (id == connId) {
+ return i;
+ }
+ }
+ return -1;
+ };
+});
+/*can-connect@1.0.11#data/localstorage-cache/localstorage-cache*/
+define('can-connect@1.0.11#data/localstorage-cache/localstorage-cache', function (require, exports, module) {
+ var getItems = require('can-connect/helpers/get-items');
+ var connect = require('can-connect');
+ var sortedSetJSON = require('can-connect/helpers/sorted-set-json');
+ var canSet = require('can-set');
+ var forEach = [].forEach;
+ var map = [].map;
+ var setAdd = require('can-connect/helpers/set-add');
+ var indexOf = require('can-connect/helpers/get-index-by-id');
+ var assign = require('can-util/js/assign/assign');
+ var overwrite = require('can-connect/helpers/overwrite');
+ module.exports = connect.behavior('data/localstorage-cache', function (baseConnect) {
+ var behavior = {
+ _instances: {},
+ getSetData: function () {
+ var sets = {};
+ var self = this;
+ forEach.call(JSON.parse(localStorage.getItem(this.name + '-sets')) || [], function (set) {
+ var setKey = sortedSetJSON(set);
+ if (localStorage.getItem(self.name + '/set/' + setKey)) {
+ sets[setKey] = {
+ set: set,
+ setKey: setKey
+ };
+ }
+ });
+ return sets;
+ },
+ _getSets: function (setData) {
+ var sets = [];
+ setData = setData || this.getSetData();
+ for (var setKey in setData) {
+ sets.push(JSON.parse(setKey));
+ }
+ return sets;
+ },
+ getInstance: function (id) {
+ var res = localStorage.getItem(this.name + '/instance/' + id);
+ if (res) {
+ return JSON.parse(res);
+ }
+ },
+ updateInstance: function (props) {
+ var id = this.id(props);
+ var instance = this.getInstance(id);
+ if (!instance) {
+ instance = props;
+ } else {
+ overwrite(instance, props, this.idProp);
+ }
+ localStorage.setItem(this.name + '/instance/' + id, JSON.stringify(instance));
+ return instance;
+ },
+ getInstances: function (ids) {
+ var self = this;
+ return map.call(ids, function (id) {
+ return self.getInstance(id);
+ });
+ },
+ removeSet: function (setKey) {
+ var sets = this.getSetData();
+ localStorage.removeItem(this.name + '/set/' + setKey);
+ delete sets[setKey];
+ },
+ updateSets: function (sets) {
+ var setData = this._getSets(sets);
+ localStorage.setItem(this.name + '-sets', JSON.stringify(setData));
+ },
+ updateSet: function (setDatum, items, newSet) {
+ var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey;
+ if (newSet) {
+ if (newSetKey !== setDatum.setKey) {
+ var sets = this.getSetData();
+ localStorage.removeItem(this.name + '/set/' + setDatum.setKey);
+ delete sets[setDatum.setKey];
+ sets[newSetKey] = {
+ setKey: newSetKey,
+ set: newSet
+ };
+ this.updateSets(sets);
+ }
+ }
+ setDatum.items = items;
+ var self = this;
+ var ids = map.call(items, function (item) {
+ var id = self.id(item);
+ localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item));
+ return id;
+ });
+ localStorage.setItem(this.name + '/set/' + newSetKey, JSON.stringify(ids));
+ },
+ addSet: function (set, data) {
+ var items = getItems(data);
+ var sets = this.getSetData();
+ var setKey = sortedSetJSON(set);
+ sets[setKey] = {
+ setKey: setKey,
+ items: items,
+ set: set
+ };
+ var self = this;
+ var ids = map.call(items, function (item) {
+ var id = self.id(item);
+ localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item));
+ return id;
+ });
+ localStorage.setItem(this.name + '/set/' + setKey, JSON.stringify(ids));
+ this.updateSets(sets);
+ },
+ _eachSet: function (cb) {
+ var sets = this.getSetData();
+ var self = this;
+ var loop = function (setDatum, setKey) {
+ return cb.call(self, setDatum, setKey, function () {
+ if (!('items' in setDatum)) {
+ var ids = JSON.parse(localStorage.getItem(self.name + '/set/' + setKey));
+ setDatum.items = self.getInstances(ids);
+ }
+ return setDatum.items;
+ });
+ };
+ for (var setKey in sets) {
+ var setDatum = sets[setKey];
+ var result = loop(setDatum, setKey);
+ if (result !== undefined) {
+ return result;
+ }
+ }
+ },
+ clear: function () {
+ var sets = this.getSetData();
+ for (var setKey in sets) {
+ localStorage.removeItem(this.name + '/set/' + setKey);
+ }
+ localStorage.removeItem(this.name + '-sets');
+ var keys = [];
+ for (var i = 0, len = localStorage.length; i < len; ++i) {
+ if (localStorage.key(i).indexOf(this.name + '/instance/') === 0) {
+ keys.push(localStorage.key(i));
+ }
+ }
+ forEach.call(keys, function (key) {
+ localStorage.removeItem(key);
+ });
+ this._instances = {};
+ },
+ getSets: function () {
+ return Promise.resolve(this._getSets());
+ },
+ getListData: function (set) {
+ set = set || {};
+ var listData = this.getListDataSync(set);
+ if (listData) {
+ return Promise.resolve(listData);
+ }
+ return Promise.reject({
+ message: 'no data',
+ error: 404
+ });
+ },
+ getListDataSync: function (set) {
+ var sets = this._getSets();
+ for (var i = 0; i < sets.length; i++) {
+ var checkSet = sets[i];
+ if (canSet.subset(set, checkSet, this.algebra)) {
+ var items = canSet.getSubset(set, checkSet, this.__getListData(checkSet), this.algebra);
+ return { data: items };
+ }
+ }
+ },
+ __getListData: function (set) {
+ var setKey = sortedSetJSON(set);
+ var setDatum = this.getSetData()[setKey];
+ if (setDatum) {
+ var localData = localStorage.getItem(this.name + '/set/' + setKey);
+ if (localData) {
+ return this.getInstances(JSON.parse(localData));
+ }
+ }
+ },
+ getData: function (params) {
+ var id = this.id(params);
+ var res = localStorage.getItem(this.name + '/instance/' + id);
+ if (res) {
+ return Promise.resolve(JSON.parse(res));
+ } else {
+ return Promise.reject({
+ message: 'no data',
+ error: 404
+ });
+ }
+ },
+ updateListData: function (data, set) {
+ set = set || {};
+ var items = getItems(data);
+ var sets = this.getSetData();
+ var self = this;
+ for (var setKey in sets) {
+ var setDatum = sets[setKey];
+ var union = canSet.union(setDatum.set, set, this.algebra);
+ if (union) {
+ return this.getListData(setDatum.set).then(function (setData) {
+ self.updateSet(setDatum, canSet.getUnion(setDatum.set, set, getItems(setData), items, this.algebra), union);
+ });
+ }
+ }
+ this.addSet(set, data);
+ return Promise.resolve();
+ },
+ createData: function (props) {
+ var self = this;
+ var instance = this.updateInstance(props);
+ this._eachSet(function (setDatum, setKey, getItems) {
+ if (canSet.has(setDatum.set, instance, this.algebra)) {
+ self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set);
+ }
+ });
+ return Promise.resolve(assign({}, instance));
+ },
+ updateData: function (props) {
+ var self = this;
+ var instance = this.updateInstance(props);
+ this._eachSet(function (setDatum, setKey, getItems) {
+ var items = getItems();
+ var index = indexOf(self, instance, items);
+ if (canSet.has(setDatum.set, instance, this.algebra)) {
+ if (index === -1) {
+ self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra));
+ } else {
+ items.splice(index, 1, instance);
+ self.updateSet(setDatum, items);
+ }
+ } else if (index !== -1) {
+ items.splice(index, 1);
+ self.updateSet(setDatum, items);
+ }
+ });
+ return Promise.resolve(assign({}, instance));
+ },
+ destroyData: function (props) {
+ var self = this;
+ var instance = this.updateInstance(props);
+ this._eachSet(function (setDatum, setKey, getItems) {
+ var items = getItems();
+ var index = indexOf(self, instance, items);
+ if (index !== -1) {
+ items.splice(index, 1);
+ self.updateSet(setDatum, items);
+ }
+ });
+ var id = this.id(instance);
+ localStorage.removeItem(this.name + '/instance/' + id);
+ return Promise.resolve(assign({}, instance));
+ }
+ };
+ return behavior;
+ });
+});
+/*can-connect@1.0.11#data/memory-cache/memory-cache*/
+define('can-connect@1.0.11#data/memory-cache/memory-cache', function (require, exports, module) {
+ var getItems = require('can-connect/helpers/get-items');
+ var connect = require('can-connect');
+ var sortedSetJSON = require('can-connect/helpers/sorted-set-json');
+ var canSet = require('can-set');
+ var overwrite = require('can-connect/helpers/overwrite');
+ var setAdd = require('can-connect/helpers/set-add');
+ var indexOf = require('can-connect/helpers/get-index-by-id');
+ var assign = require('can-util/js/assign/assign');
+ module.exports = connect.behavior('data/memory-cache', function (baseConnect) {
+ var behavior = {
+ _sets: {},
+ getSetData: function () {
+ return this._sets;
+ },
+ __getListData: function (set) {
+ var setsData = this.getSetData();
+ var setData = setsData[sortedSetJSON(set)];
+ if (setData) {
+ return setData.items;
+ }
+ },
+ _instances: {},
+ getInstance: function (id) {
+ return this._instances[id];
+ },
+ removeSet: function (setKey, noUpdate) {
+ var sets = this.getSetData();
+ delete sets[setKey];
+ if (noUpdate !== true) {
+ this.updateSets();
+ }
+ },
+ updateSets: function () {
+ },
+ updateInstance: function (props) {
+ var id = this.id(props);
+ if (!(id in this._instances)) {
+ this._instances[id] = props;
+ } else {
+ overwrite(this._instances[id], props, this.idProp);
+ }
+ return this._instances[id];
+ },
+ updateSet: function (setDatum, items, newSet) {
+ var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey;
+ if (newSet) {
+ if (newSetKey !== setDatum.setKey) {
+ var sets = this.getSetData();
+ var oldSetKey = setDatum.setKey;
+ sets[newSetKey] = setDatum;
+ setDatum.setKey = newSetKey;
+ setDatum.set = assign({}, newSet);
+ this.removeSet(oldSetKey);
+ }
+ }
+ setDatum.items = items;
+ var self = this;
+ items.forEach(function (item) {
+ self.updateInstance(item);
+ });
+ },
+ addSet: function (set, data) {
+ var items = getItems(data);
+ var sets = this.getSetData();
+ var setKey = sortedSetJSON(set);
+ sets[setKey] = {
+ setKey: setKey,
+ items: items,
+ set: assign({}, set)
+ };
+ var self = this;
+ items.forEach(function (item) {
+ self.updateInstance(item);
+ });
+ this.updateSets();
+ },
+ _eachSet: function (cb) {
+ var sets = this.getSetData();
+ var self = this;
+ var loop = function (setDatum, setKey) {
+ return cb.call(self, setDatum, setKey, function () {
+ return setDatum.items;
+ });
+ };
+ for (var setKey in sets) {
+ var setDatum = sets[setKey];
+ var result = loop(setDatum, setKey);
+ if (result !== undefined) {
+ return result;
+ }
+ }
+ },
+ _getSets: function () {
+ var sets = [], setsData = this.getSetData();
+ for (var prop in setsData) {
+ sets.push(setsData[prop].set);
+ }
+ return sets;
+ },
+ getSets: function () {
+ return Promise.resolve(this._getSets());
+ },
+ clear: function () {
+ this._instances = {};
+ this._sets = {};
+ },
+ getListData: function (set) {
+ set = set || {};
+ var listData = this.getListDataSync(set);
+ if (listData) {
+ return Promise.resolve(listData);
+ }
+ return Promise.reject({
+ message: 'no data',
+ error: 404
+ });
+ },
+ getListDataSync: function (set) {
+ var sets = this._getSets();
+ for (var i = 0; i < sets.length; i++) {
+ var checkSet = sets[i];
+ if (canSet.subset(set, checkSet, this.algebra)) {
+ var source = this.__getListData(checkSet);
+ var items = canSet.getSubset(set, checkSet, source, this.algebra);
+ return {
+ data: items,
+ count: source.length
+ };
+ }
+ }
+ },
+ _getListData: function (set) {
+ return this.getListDataSync(set);
+ },
+ updateListData: function (data, set) {
+ set = set || {};
+ var items = getItems(data);
+ var sets = this.getSetData();
+ var self = this;
+ for (var setKey in sets) {
+ var setDatum = sets[setKey];
+ var union = canSet.union(setDatum.set, set, this.algebra);
+ if (union) {
+ var getSet = assign({}, setDatum.set);
+ return this.getListData(getSet).then(function (setData) {
+ self.updateSet(setDatum, canSet.getUnion(getSet, set, getItems(setData), items, self.algebra), union);
+ });
+ }
+ }
+ this.addSet(set, data);
+ return Promise.resolve();
+ },
+ getData: function (params) {
+ var id = this.id(params);
+ var res = this.getInstance(id);
+ if (res) {
+ return Promise.resolve(res);
+ } else {
+ return Promise.reject({
+ message: 'no data',
+ error: 404
+ });
+ }
+ },
+ createData: function (props) {
+ var self = this;
+ var instance = this.updateInstance(props);
+ this._eachSet(function (setDatum, setKey, getItems) {
+ if (canSet.has(setDatum.set, instance, this.algebra)) {
+ self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set);
+ }
+ });
+ return Promise.resolve(assign({}, instance));
+ },
+ updateData: function (props) {
+ var self = this;
+ var instance = this.updateInstance(props);
+ this._eachSet(function (setDatum, setKey, getItems) {
+ var items = getItems();
+ var index = indexOf(self, instance, items);
+ if (canSet.subset(instance, setDatum.set, this.algebra)) {
+ if (index === -1) {
+ self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra));
+ } else {
+ items.splice(index, 1, instance);
+ self.updateSet(setDatum, items);
+ }
+ } else if (index !== -1) {
+ items.splice(index, 1);
+ self.updateSet(setDatum, items);
+ }
+ });
+ return Promise.resolve(assign({}, instance));
+ },
+ destroyData: function (props) {
+ var self = this;
+ this._eachSet(function (setDatum, setKey, getItems) {
+ var items = getItems();
+ var index = indexOf(self, props, items);
+ if (index !== -1) {
+ items.splice(index, 1);
+ self.updateSet(setDatum, items);
+ }
+ });
+ var id = this.id(props);
+ delete this._instances[id];
+ return Promise.resolve(assign({}, props));
+ }
+ };
+ return behavior;
+ });
+});
+/*can-connect@1.0.11#data/parse/parse*/
+define('can-connect@1.0.11#data/parse/parse', function (require, exports, module) {
+ var connect = require('can-connect');
+ var each = require('can-util/js/each/each');
+ var isArray = require('can-util/js/is-array/is-array');
+ var string = require('can-util/js/string/string');
+ module.exports = connect.behavior('data/parse', function (baseConnect) {
+ var behavior = {
+ parseListData: function (responseData) {
+ if (baseConnect.parseListData) {
+ responseData = baseConnect.parseListData.apply(this, arguments);
+ }
+ var result;
+ if (isArray(responseData)) {
+ result = { data: responseData };
+ } else {
+ var prop = this.parseListProp || 'data';
+ responseData.data = string.getObject(prop, responseData);
+ result = responseData;
+ if (prop !== 'data') {
+ delete responseData[prop];
+ }
+ if (!isArray(result.data)) {
+ throw new Error('Could not get any raw data while converting using .parseListData');
+ }
+ }
+ var arr = [];
+ for (var i = 0; i < result.data.length; i++) {
+ arr.push(this.parseInstanceData(result.data[i]));
+ }
+ result.data = arr;
+ return result;
+ },
+ parseInstanceData: function (props) {
+ if (baseConnect.parseInstanceData) {
+ props = baseConnect.parseInstanceData.apply(this, arguments) || props;
+ }
+ return this.parseInstanceProp ? string.getObject(this.parseInstanceProp, props) || props : props;
+ }
+ };
+ each(pairs, function (parseFunction, name) {
+ behavior[name] = function (params) {
+ var self = this;
+ return baseConnect[name].call(this, params).then(function () {
+ return self[parseFunction].apply(self, arguments);
+ });
+ };
+ });
+ return behavior;
+ });
+ var pairs = {
+ getListData: 'parseListData',
+ getData: 'parseInstanceData',
+ createData: 'parseInstanceData',
+ updateData: 'parseInstanceData',
+ destroyData: 'parseInstanceData'
+ };
+});
+/*can-util@3.0.10#dom/ajax/ajax*/
+define('can-util@3.0.10#dom/ajax/ajax', function (require, exports, module) {
+ var Global = require('../../js/global/global');
+ var assign = require('../../js/assign/assign');
+ var namespace = require('../../namespace');
+ var parseURI = require('../../js/parse-uri/parse-uri');
+ var xhrs = [
+ function () {
+ return new XMLHttpRequest();
+ },
+ function () {
+ return new ActiveXObject('Microsoft.XMLHTTP');
+ },
+ function () {
+ return new ActiveXObject('MSXML2.XMLHTTP.3.0');
+ },
+ function () {
+ return new ActiveXObject('MSXML2.XMLHTTP');
+ }
+ ], _xhrf = null;
+ var originUrl = parseURI(Global().location.href);
+ var $ = {};
+ $.xhr = function () {
+ if (_xhrf != null) {
+ return _xhrf();
+ }
+ for (var i = 0, l = xhrs.length; i < l; i++) {
+ try {
+ var f = xhrs[i], req = f();
+ if (req != null) {
+ _xhrf = f;
+ return req;
+ }
+ } catch (e) {
+ continue;
+ }
+ }
+ return function () {
+ };
+ };
+ $._xhrResp = function (xhr, options) {
+ switch (options.dataType || xhr.getResponseHeader('Content-Type').split(';')[0]) {
+ case 'text/xml':
+ case 'xml':
+ return xhr.responseXML;
+ case 'text/json':
+ case 'application/json':
+ case 'text/javascript':
+ case 'application/javascript':
+ case 'application/x-javascript':
+ case 'json':
+ return JSON.parse(xhr.responseText);
+ default:
+ return xhr.responseText;
+ }
+ };
+ $._formData = function (o) {
+ var kvps = [], regEx = /%20/g;
+ for (var k in o) {
+ kvps.push(encodeURIComponent(k).replace(regEx, '+') + '=' + encodeURIComponent(o[k].toString()).replace(regEx, '+'));
+ }
+ return kvps.join('&');
+ };
+ module.exports = namespace.ajax = function (o) {
+ var xhr = $.xhr(), timer, n = 0;
+ var deferred = {};
+ var promise = new Promise(function (resolve, reject) {
+ deferred.resolve = resolve;
+ deferred.reject = reject;
+ });
+ var requestUrl;
+ promise.abort = function () {
+ xhr.abort();
+ };
+ o = assign({
+ userAgent: 'XMLHttpRequest',
+ lang: 'en',
+ type: 'GET',
+ data: null,
+ dataType: 'json'
+ }, o);
+ if (o.crossDomain == null) {
+ try {
+ requestUrl = parseURI(o.url);
+ o.crossDomain = originUrl.protocol + '//' + originUrl.host !== requestUrl.protocol + '//' + requestUrl.host;
+ } catch (e) {
+ o.crossDomain = true;
+ }
+ }
+ if (o.timeout) {
+ timer = setTimeout(function () {
+ xhr.abort();
+ if (o.timeoutFn) {
+ o.timeoutFn(o.url);
+ }
+ }, o.timeout);
+ }
+ xhr.onreadystatechange = function () {
+ try {
+ if (xhr.readyState === 4) {
+ if (timer) {
+ clearTimeout(timer);
+ }
+ if (xhr.status < 300) {
+ if (o.success) {
+ o.success($._xhrResp(xhr, o));
+ }
+ } else if (o.error) {
+ o.error(xhr, xhr.status, xhr.statusText);
+ }
+ if (o.complete) {
+ o.complete(xhr, xhr.statusText);
+ }
+ if (xhr.status >= 200 && xhr.status < 300) {
+ deferred.resolve($._xhrResp(xhr, o));
+ } else {
+ deferred.reject(xhr);
+ }
+ } else if (o.progress) {
+ o.progress(++n);
+ }
+ } catch (e) {
+ deferred.reject(e);
+ }
+ };
+ var url = o.url, data = null, type = o.type.toUpperCase();
+ var isPost = type === 'POST' || type === 'PUT';
+ if (!isPost && o.data) {
+ url += '?' + $._formData(o.data);
+ }
+ xhr.open(type, url);
+ if (isPost) {
+ var isJson = o.dataType.indexOf('json') >= 0;
+ data = isJson && !o.crossDomain ? typeof o.data === 'object' ? JSON.stringify(o.data) : o.data : $._formData(o.data);
+ xhr.setRequestHeader('Content-Type', isJson && !o.crossDomain ? 'application/json' : 'application/x-www-form-urlencoded');
+ }
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ xhr.send(data);
+ return promise;
+ };
+});
+/*can-connect@1.0.11#helpers/get-id-props*/
+define('can-connect@1.0.11#helpers/get-id-props', function (require, exports, module) {
+ module.exports = function (connection) {
+ var ids = [], algebra = this.algebra;
+ if (algebra && algebra.clauses && algebra.clauses.id) {
+ for (var prop in algebra.clauses.id) {
+ ids.push(prop);
+ }
+ }
+ if (connection.idProp && !ids.length) {
+ ids.push(connection.idProp);
+ }
+ if (!ids.length) {
+ ids.push('id');
+ }
+ return ids;
+ };
+});
+/*can-util@3.0.10#js/is-promise-like/is-promise-like*/
+define('can-util@3.0.10#js/is-promise-like/is-promise-like', function (require, exports, module) {
+ module.exports = function (obj) {
+ return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
+ };
+});
+/*can-util@3.0.10#js/make-promise/make-promise*/
+define('can-util@3.0.10#js/make-promise/make-promise', function (require, exports, module) {
+ var isPromiseLike = require('../is-promise-like/is-promise-like');
+ var isPromise = require('../is-promise/is-promise');
+ module.exports = function (obj) {
+ if (isPromiseLike(obj) && !isPromise(obj)) {
+ return new Promise(function (resolve, reject) {
+ obj.then(resolve, reject);
+ });
+ } else {
+ return obj;
+ }
+ };
+});
+/*can-connect@1.0.11#data/url/url*/
+define('can-connect@1.0.11#data/url/url', function (require, exports, module) {
+ var isArray = require('can-util/js/is-array/is-array');
+ var assign = require('can-util/js/assign/assign');
+ var each = require('can-util/js/each/each');
+ var ajax = require('can-util/dom/ajax/ajax');
+ var string = require('can-util/js/string/string');
+ var getIdProps = require('../../helpers/get-id-props');
+ var dev = require('can-util/js/dev/dev');
+ var connect = require('can-connect');
+ var makePromise = require('can-util/js/make-promise/make-promise');
+ module.exports = connect.behavior('data/url', function (baseConnect) {
+ var behavior = {};
+ each(pairs, function (reqOptions, name) {
+ behavior[name] = function (params) {
+ if (typeof this.url === 'object') {
+ if (typeof this.url[reqOptions.prop] === 'function') {
+ return makePromise(this.url[reqOptions.prop](params));
+ } else if (this.url[reqOptions.prop]) {
+ return makePromise(makeAjax(this.url[reqOptions.prop], params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions));
+ }
+ }
+ var resource = typeof this.url === 'string' ? this.url : this.url.resource;
+ if (resource) {
+ var idProps = getIdProps(this);
+ return makePromise(makeAjax(createURLFromResource(resource, idProps[0], reqOptions.prop), params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions));
+ }
+ return baseConnect[name].call(this, params);
+ };
+ });
+ return behavior;
+ });
+ var pairs = {
+ getListData: {
+ prop: 'getListData',
+ type: 'GET'
+ },
+ getData: {
+ prop: 'getData',
+ type: 'GET'
+ },
+ createData: {
+ prop: 'createData',
+ type: 'POST'
+ },
+ updateData: {
+ prop: 'updateData',
+ type: 'PUT'
+ },
+ destroyData: {
+ prop: 'destroyData',
+ type: 'DELETE',
+ includeData: false
+ }
+ };
+ var findContentType = function (url) {
+ if (typeof url === 'object' && url.contentType) {
+ var acceptableType = url.contentType === 'application/x-www-form-urlencoded' || url.contentType === 'application/json';
+ if (acceptableType) {
+ return url.contentType;
+ } else {
+ }
+ }
+ return 'application/json';
+ };
+ var makeAjax = function (ajaxOb, data, type, ajax, contentType, reqOptions) {
+ var params = {};
+ if (typeof ajaxOb === 'string') {
+ var parts = ajaxOb.split(/\s+/);
+ params.url = parts.pop();
+ if (parts.length) {
+ params.type = parts.pop();
+ }
+ } else {
+ assign(params, ajaxOb);
+ }
+ params.data = typeof data === 'object' && !isArray(data) ? assign(params.data || {}, data) : data;
+ params.url = string.sub(params.url, params.data, true);
+ var encodeJSON = contentType !== 'application/x-www-form-urlencoded' && (type && (type === 'POST' || type === 'PUT'));
+ if (encodeJSON) {
+ params.data = JSON.stringify(params.data);
+ params.contentType = contentType;
+ }
+ if (reqOptions.includeData === false) {
+ delete params.data;
+ }
+ return ajax(assign({
+ type: type || 'post',
+ dataType: 'json'
+ }, params));
+ };
+ var createURLFromResource = function (resource, idProp, name) {
+ var url = resource.replace(/\/+$/, '');
+ if (name === 'getListData' || name === 'createData') {
+ return url;
+ } else {
+ return url + '/{' + idProp + '}';
+ }
+ };
+});
+/*can-connect@1.0.11#fall-through-cache/fall-through-cache*/
+define('can-connect@1.0.11#fall-through-cache/fall-through-cache', function (require, exports, module) {
+ var connect = require('can-connect');
+ var sortedSetJSON = require('../helpers/sorted-set-json');
+ module.exports = connect.behavior('fall-through-cache', function (baseConnect) {
+ var behavior = {
+ hydrateList: function (listData, set) {
+ set = set || this.listSet(listData);
+ var id = sortedSetJSON(set);
+ var list = baseConnect.hydrateList.call(this, listData, set);
+ if (this._getHydrateListCallbacks[id]) {
+ this._getHydrateListCallbacks[id].shift()(list);
+ if (!this._getHydrateListCallbacks[id].length) {
+ delete this._getHydrateListCallbacks[id];
+ }
+ }
+ return list;
+ },
+ _getHydrateListCallbacks: {},
+ _getHydrateList: function (set, callback) {
+ var id = sortedSetJSON(set);
+ if (!this._getHydrateListCallbacks[id]) {
+ this._getHydrateListCallbacks[id] = [];
+ }
+ this._getHydrateListCallbacks[id].push(callback);
+ },
+ getListData: function (set) {
+ set = set || {};
+ var self = this;
+ return this.cacheConnection.getListData(set).then(function (data) {
+ self._getHydrateList(set, function (list) {
+ self.addListReference(list, set);
+ setTimeout(function () {
+ baseConnect.getListData.call(self, set).then(function (listData) {
+ self.cacheConnection.updateListData(listData, set);
+ self.updatedList(list, listData, set);
+ self.deleteListReference(list, set);
+ }, function (e) {
+ console.log('REJECTED', e);
+ });
+ }, 1);
+ });
+ return data;
+ }, function () {
+ var listData = baseConnect.getListData.call(self, set);
+ listData.then(function (listData) {
+ self.cacheConnection.updateListData(listData, set);
+ });
+ return listData;
+ });
+ },
+ hydrateInstance: function (props) {
+ var id = this.id(props);
+ var instance = baseConnect.hydrateInstance.apply(this, arguments);
+ if (this._getMakeInstanceCallbacks[id]) {
+ this._getMakeInstanceCallbacks[id].shift()(instance);
+ if (!this._getMakeInstanceCallbacks[id].length) {
+ delete this._getMakeInstanceCallbacks[id];
+ }
+ }
+ return instance;
+ },
+ _getMakeInstanceCallbacks: {},
+ _getMakeInstance: function (id, callback) {
+ if (!this._getMakeInstanceCallbacks[id]) {
+ this._getMakeInstanceCallbacks[id] = [];
+ }
+ this._getMakeInstanceCallbacks[id].push(callback);
+ },
+ getData: function (params) {
+ var self = this;
+ return this.cacheConnection.getData(params).then(function (instanceData) {
+ self._getMakeInstance(self.id(instanceData) || self.id(params), function (instance) {
+ self.addInstanceReference(instance);
+ setTimeout(function () {
+ baseConnect.getData.call(self, params).then(function (instanceData2) {
+ self.cacheConnection.updateData(instanceData2);
+ self.updatedInstance(instance, instanceData2);
+ self.deleteInstanceReference(instance);
+ }, function (e) {
+ console.log('REJECTED', e);
+ });
+ }, 1);
+ });
+ return instanceData;
+ }, function () {
+ var listData = baseConnect.getData.call(self, params);
+ listData.then(function (instanceData) {
+ self.cacheConnection.updateData(instanceData);
+ });
+ return listData;
+ });
+ }
+ };
+ return behavior;
+ });
+});
+/*can-connect@1.0.11#real-time/real-time*/
+define('can-connect@1.0.11#real-time/real-time', function (require, exports, module) {
+ var connect = require('../can-connect');
+ var canSet = require('can-set');
+ var setAdd = require('can-connect/helpers/set-add');
+ var indexOf = require('can-connect/helpers/get-index-by-id');
+ module.exports = connect.behavior('real-time', function (baseConnect) {
+ return {
+ createInstance: function (props) {
+ var id = this.id(props);
+ var instance = this.instanceStore.get(id);
+ var serialized;
+ if (instance) {
+ return this.updateInstance(props);
+ } else {
+ instance = this.hydrateInstance(props);
+ serialized = this.serializeInstance(instance);
+ var self = this;
+ this.addInstanceReference(instance);
+ return Promise.resolve(this.createdData(props, serialized)).then(function () {
+ self.deleteInstanceReference(instance);
+ return instance;
+ });
+ }
+ },
+ createdData: function (props, params, cid) {
+ var instance;
+ if (cid !== undefined) {
+ instance = this.cidStore.get(cid);
+ } else {
+ instance = this.instanceStore.get(this.id(props));
+ }
+ this.addInstanceReference(instance, this.id(props));
+ this.createdInstance(instance, props);
+ create.call(this, this.serializeInstance(instance));
+ this.deleteInstanceReference(instance);
+ return undefined;
+ },
+ updatedData: function (props, params) {
+ var instance = this.instanceStore.get(this.id(params));
+ this.updatedInstance(instance, props);
+ update.call(this, this.serializeInstance(instance));
+ return undefined;
+ },
+ updateInstance: function (props) {
+ var id = this.id(props);
+ var instance = this.instanceStore.get(id);
+ if (!instance) {
+ instance = this.hydrateInstance(props);
+ }
+ this.addInstanceReference(instance);
+ var serialized = this.serializeInstance(instance), self = this;
+ return Promise.resolve(this.updatedData(props, serialized)).then(function () {
+ self.deleteInstanceReference(instance);
+ return instance;
+ });
+ },
+ destroyedData: function (props, params) {
+ var id = this.id(params || props);
+ var instance = this.instanceStore.get(id);
+ if (!instance) {
+ instance = this.hydrateInstance(props);
+ }
+ var serialized = this.serializeInstance(instance);
+ destroy.call(this, serialized);
+ return undefined;
+ },
+ destroyInstance: function (props) {
+ var id = this.id(props);
+ var instance = this.instanceStore.get(id);
+ if (!instance) {
+ instance = this.hydrateInstance(props);
+ }
+ this.addInstanceReference(instance);
+ var serialized = this.serializeInstance(instance), self = this;
+ return Promise.resolve(this.destroyedData(props, serialized)).then(function () {
+ self.deleteInstanceReference(instance);
+ return instance;
+ });
+ }
+ };
+ });
+ var create = function (props) {
+ var self = this;
+ this.listStore.forEach(function (list, id) {
+ var set = JSON.parse(id);
+ var index = indexOf(self, props, list);
+ if (canSet.has(set, props, self.algebra)) {
+ if (index === -1) {
+ var items = self.serializeList(list);
+ self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set);
+ } else {
+ }
+ }
+ });
+ };
+ var update = function (props) {
+ var self = this;
+ this.listStore.forEach(function (list, id) {
+ var items;
+ var set = JSON.parse(id);
+ var index = indexOf(self, props, list);
+ if (canSet.has(set, props, self.algebra)) {
+ items = self.serializeList(list);
+ if (index === -1) {
+ self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set);
+ } else {
+ var sortedIndex = canSet.index(set, items, props, self.algebra);
+ if (sortedIndex !== undefined && sortedIndex !== index) {
+ var copy = items.slice(0);
+ if (index < sortedIndex) {
+ copy.splice(sortedIndex, 0, props);
+ copy.splice(index, 1);
+ } else {
+ copy.splice(index, 1);
+ copy.splice(sortedIndex, 0, props);
+ }
+ self.updatedList(list, { data: copy }, set);
+ }
+ }
+ } else if (index !== -1) {
+ items = self.serializeList(list);
+ items.splice(index, 1);
+ self.updatedList(list, { data: items }, set);
+ }
+ });
+ };
+ var destroy = function (props) {
+ var self = this;
+ this.listStore.forEach(function (list, id) {
+ var set = JSON.parse(id);
+ var index = indexOf(self, props, list);
+ if (index !== -1) {
+ var items = self.serializeList(list);
+ items.splice(index, 1);
+ self.updatedList(list, { data: items }, set);
+ }
+ });
+ };
+});
+/*can-connect@1.0.11#can/map/map*/
+define('can-connect@1.0.11#can/map/map', function (require, exports, module) {
+ 'use strict';
+ var each = require('can-util/js/each/each');
+ var connect = require('can-connect');
+ var canBatch = require('can-event/batch/batch');
+ var canEvent = require('can-event');
+ var Observation = require('can-observation');
+ var isPlainObject = require('can-util/js/is-plain-object/is-plain-object');
+ var isArray = require('can-util/js/is-array/is-array');
+ var types = require('can-util/js/types/types');
+ var each = require('can-util/js/each/each');
+ var isFunction = require('can-util/js/is-function/is-function');
+ var dev = require('can-util/js/dev/dev');
+ var setExpando = function (map, prop, value) {
+ if ('attr' in map) {
+ map[prop] = value;
+ } else {
+ map._data[prop] = value;
+ }
+ };
+ var getExpando = function (map, prop) {
+ if ('attr' in map) {
+ return map[prop];
+ } else {
+ return map._data[prop];
+ }
+ };
+ module.exports = connect.behavior('can/map', function (baseConnect) {
+ var behavior = {
+ init: function () {
+ this.Map = this.Map || types.DefaultMap.extend({});
+ this.List = this.List || types.DefaultList.extend({});
+ overwrite(this, this.Map, mapOverwrites, mapStaticOverwrites);
+ overwrite(this, this.List, listPrototypeOverwrites, listStaticOverwrites);
+ baseConnect.init.apply(this, arguments);
+ },
+ id: function (instance) {
+ if (!isPlainObject(instance)) {
+ var ids = [], algebra = this.algebra;
+ if (algebra && algebra.clauses && algebra.clauses.id) {
+ for (var prop in algebra.clauses.id) {
+ ids.push(readObservabe(instance, prop));
+ }
+ }
+ if (this.idProp && !ids.length) {
+ ids.push(readObservabe(instance, this.idProp));
+ }
+ if (!ids.length) {
+ ids.push(readObservabe(instance, 'id'));
+ }
+ return ids.length > 1 ? ids.join('@|@') : ids[0];
+ } else {
+ return baseConnect.id(instance);
+ }
+ },
+ serializeInstance: function (instance) {
+ return instance.serialize();
+ },
+ serializeList: function (list) {
+ return list.serialize();
+ },
+ instance: function (props) {
+ var _Map = this.Map || types.DefaultMap;
+ return new _Map(props);
+ },
+ list: function (listData, set) {
+ var _List = this.List || this.Map && this.Map.List || types.DefaultList;
+ var list = new _List(listData.data);
+ each(listData, function (val, prop) {
+ if (prop !== 'data') {
+ list[list.set ? 'set' : 'attr'](prop, val);
+ }
+ });
+ list.__listSet = set;
+ return list;
+ },
+ updatedList: function () {
+ canBatch.start();
+ var res = baseConnect.updatedList.apply(this, arguments);
+ canBatch.stop();
+ return res;
+ },
+ save: function (instance) {
+ setExpando(instance, '_saving', true);
+ canEvent.dispatch.call(instance, '_saving', [
+ true,
+ false
+ ]);
+ var done = function () {
+ setExpando(instance, '_saving', false);
+ canEvent.dispatch.call(instance, '_saving', [
+ false,
+ true
+ ]);
+ };
+ var base = baseConnect.save.apply(this, arguments);
+ base.then(done, done);
+ return base;
+ },
+ destroy: function (instance) {
+ setExpando(instance, '_destroying', true);
+ canEvent.dispatch.call(instance, '_destroying', [
+ true,
+ false
+ ]);
+ var done = function () {
+ setExpando(instance, '_destroying', false);
+ canEvent.dispatch.call(instance, '_destroying', [
+ false,
+ true
+ ]);
+ };
+ var base = baseConnect.destroy.apply(this, arguments);
+ base.then(done, done);
+ return base;
+ }
+ };
+ each([
+ 'created',
+ 'updated',
+ 'destroyed'
+ ], function (funcName) {
+ behavior[funcName + 'Instance'] = function (instance, props) {
+ var constructor = instance.constructor;
+ if (props && typeof props === 'object') {
+ if ('set' in instance) {
+ instance.set(isFunction(props.get) ? props.get() : props, this.constructor.removeAttr || false);
+ } else if ('attr' in instance) {
+ instance.attr(isFunction(props.attr) ? props.attr() : props, this.constructor.removeAttr || false);
+ } else {
+ canBatch.start();
+ each(props, function (value, prop) {
+ instance[prop] = value;
+ });
+ canBatch.stop();
+ }
+ }
+ canEvent.dispatch.call(instance, {
+ type: funcName,
+ target: instance
+ });
+ canEvent.dispatch.call(constructor, funcName, [instance]);
+ };
+ });
+ return behavior;
+ });
+ var callCanReadingOnIdRead = true;
+ var mapStaticOverwrites = {
+ getList: function (base, connection) {
+ return function (set) {
+ return connection.getList(set);
+ };
+ },
+ findAll: function (base, connection) {
+ return function (set) {
+ return connection.getList(set);
+ };
+ },
+ get: function (base, connection) {
+ return function (params) {
+ return connection.get(params);
+ };
+ },
+ findOne: function (base, connection) {
+ return function (params) {
+ return connection.get(params);
+ };
+ }
+ };
+ var mapOverwrites = {
+ _eventSetup: function (base, connection) {
+ return function () {
+ callCanReadingOnIdRead = false;
+ connection.addInstanceReference(this);
+ callCanReadingOnIdRead = true;
+ return base.apply(this, arguments);
+ };
+ },
+ _eventTeardown: function (base, connection) {
+ return function () {
+ callCanReadingOnIdRead = false;
+ connection.deleteInstanceReference(this);
+ callCanReadingOnIdRead = true;
+ return base.apply(this, arguments);
+ };
+ },
+ ___set: function (base, connection) {
+ return function (prop, val) {
+ base.apply(this, arguments);
+ if (prop === connection.idProp && this._bindings) {
+ connection.addInstanceReference(this);
+ }
+ };
+ },
+ isNew: function (base, connection) {
+ return function () {
+ var id = connection.id(this);
+ return !(id || id === 0);
+ };
+ },
+ isSaving: function (base, connection) {
+ return function () {
+ Observation.add(this, '_saving');
+ return !!getExpando(this, '_saving');
+ };
+ },
+ isDestroying: function (base, connection) {
+ return function () {
+ Observation.add(this, '_destroying');
+ return !!getExpando(this, '_destroying');
+ };
+ },
+ save: function (base, connection) {
+ return function (success, error) {
+ var promise = connection.save(this);
+ promise.then(success, error);
+ return promise;
+ };
+ },
+ destroy: function (base, connection) {
+ return function (success, error) {
+ var promise;
+ if (this.isNew()) {
+ promise = Promise.resolve(this);
+ connection.destroyedInstance(this, {});
+ } else {
+ promise = connection.destroy(this);
+ }
+ promise.then(success, error);
+ return promise;
+ };
+ }
+ };
+ var listPrototypeOverwrites = {
+ setup: function (base, connection) {
+ return function (params) {
+ if (isPlainObject(params) && !isArray(params)) {
+ this.__listSet = params;
+ base.apply(this);
+ this.replace(types.isPromise(params) ? params : connection.getList(params));
+ } else {
+ base.apply(this, arguments);
+ }
+ };
+ },
+ _eventSetup: function (base, connection) {
+ return function () {
+ connection.addListReference(this);
+ if (base) {
+ return base.apply(this, arguments);
+ }
+ };
+ },
+ _eventTeardown: function (base, connection) {
+ return function () {
+ connection.deleteListReference(this);
+ if (base) {
+ return base.apply(this, arguments);
+ }
+ };
+ }
+ };
+ var listStaticOverwrites = {
+ _bubbleRule: function (base, connection) {
+ return function (eventName, list) {
+ var bubbleRules = base(eventName, list);
+ bubbleRules.push('destroyed');
+ return bubbleRules;
+ };
+ }
+ };
+ var readObservabe = function (instance, prop) {
+ if ('__get' in instance) {
+ if (callCanReadingOnIdRead) {
+ Observation.add(instance, prop);
+ }
+ return instance.__get(prop);
+ } else {
+ if (callCanReadingOnIdRead) {
+ return instance[prop];
+ } else {
+ return Observation.ignore(function () {
+ return instance[prop];
+ })();
+ }
+ }
+ };
+ var overwrite = function (connection, Constructor, prototype, statics) {
+ var prop;
+ for (prop in prototype) {
+ Constructor.prototype[prop] = prototype[prop](Constructor.prototype[prop], connection);
+ }
+ if (statics) {
+ for (prop in statics) {
+ Constructor[prop] = statics[prop](Constructor[prop], connection);
+ }
+ }
+ };
+});
+/*can-connect@1.0.11#can/ref/ref*/
+define('can-connect@1.0.11#can/ref/ref', function (require, exports, module) {
+ var connect = require('can-connect');
+ var getIdProps = require('can-connect/helpers/get-id-props');
+ var WeakReferenceMap = require('can-connect/helpers/weak-reference-map');
+ var Observation = require('can-observation');
+ var constructorStore = require('can-connect/constructor/store/store');
+ var define = require('can-define');
+ var makeRef = function (connection) {
+ var idProp = getIdProps(connection)[0];
+ var Ref = function (id, value) {
+ if (Ref.store.has(id)) {
+ return Ref.store.get(id);
+ }
+ this[idProp] = id;
+ if (value) {
+ this._value = connection.hydrateInstance(value);
+ }
+ if (constructorStore.requests.count() > 0) {
+ if (!Ref._requestInstances[id]) {
+ Ref.store.addReference(id, this);
+ Ref._requestInstances[id] = this;
+ }
+ }
+ };
+ Ref.store = new WeakReferenceMap();
+ Ref._requestInstances = {};
+ Ref.type = function (ref) {
+ if (ref && typeof ref !== 'object') {
+ return new Ref(ref);
+ } else {
+ return new Ref(ref[idProp], ref);
+ }
+ };
+ var defs = {
+ promise: {
+ get: function () {
+ if (this._value) {
+ return Promise.resolve(this._value);
+ } else {
+ var props = {};
+ props[idProp] = this[idProp];
+ return connection.Map.get(props);
+ }
+ }
+ },
+ _state: {
+ get: function (lastSet, resolve) {
+ if (resolve) {
+ this.promise.then(function () {
+ resolve('resolved');
+ }, function () {
+ resolve('rejected');
+ });
+ }
+ return 'pending';
+ }
+ },
+ value: {
+ get: function (lastSet, resolve) {
+ if (this._value) {
+ return this._value;
+ } else if (resolve) {
+ this.promise.then(function (value) {
+ resolve(value);
+ });
+ }
+ }
+ },
+ reason: {
+ get: function (lastSet, resolve) {
+ if (this._value) {
+ return undefined;
+ } else {
+ this.promise.catch(function (value) {
+ resolve(value);
+ });
+ }
+ }
+ }
+ };
+ defs[idProp] = {
+ type: '*',
+ set: function () {
+ this._value = undefined;
+ }
+ };
+ define(Ref.prototype, defs);
+ Ref.prototype.unobservedId = Observation.ignore(function () {
+ return this[idProp];
+ });
+ Ref.prototype.isResolved = function () {
+ return !!this._value || this._state === 'resolved';
+ };
+ Ref.prototype.isRejected = function () {
+ return this._state === 'rejected';
+ };
+ Ref.prototype.isPending = function () {
+ return !this._value && (this._state !== 'resolved' || this._state !== 'rejected');
+ };
+ Ref.prototype.serialize = function () {
+ return this[idProp];
+ };
+ var baseEventSetup = Ref.prototype._eventSetup;
+ Ref.prototype._eventSetup = function () {
+ Ref.store.addReference(this.unobservedId(), this);
+ return baseEventSetup.apply(this, arguments);
+ };
+ var baseTeardown = Ref.prototype._eventTeardown;
+ Ref.prototype._eventTeardown = function () {
+ Ref.store.deleteReference(this.unobservedId(), this);
+ return baseTeardown.apply(this, arguments);
+ };
+ constructorStore.requests.on('end', function () {
+ for (var id in Ref._requestInstances) {
+ Ref.store.deleteReference(id);
+ }
+ Ref._requestInstances = {};
+ });
+ return Ref;
+ };
+ module.exports = connect.behavior('can/ref', function (baseConnect) {
+ return {
+ init: function () {
+ baseConnect.init.apply(this, arguments);
+ this.Map.Ref = makeRef(this);
+ }
+ };
+ });
+});
+/*jquery@2.2.4#dist/jquery*/
+(function (global, factory) {
+ if (typeof module === 'object' && typeof module.exports === 'object') {
+ module.exports = global.document ? factory(global, true) : function (w) {
+ if (!w.document) {
+ throw new Error('jQuery requires a window with a document');
+ }
+ return factory(w);
+ };
+ } else {
+ factory(global);
+ }
+}(typeof window !== 'undefined' ? window : this, function (window, noGlobal) {
+ var arr = [];
+ var document = window.document;
+ var slice = arr.slice;
+ var concat = arr.concat;
+ var push = arr.push;
+ var indexOf = arr.indexOf;
+ var class2type = {};
+ var toString = class2type.toString;
+ var hasOwn = class2type.hasOwnProperty;
+ var support = {};
+ var version = '2.2.4', jQuery = function (selector, context) {
+ return new jQuery.fn.init(selector, context);
+ }, rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, rmsPrefix = /^-ms-/, rdashAlpha = /-([\da-z])/gi, fcamelCase = function (all, letter) {
+ return letter.toUpperCase();
+ };
+ jQuery.fn = jQuery.prototype = {
+ jquery: version,
+ constructor: jQuery,
+ selector: '',
+ length: 0,
+ toArray: function () {
+ return slice.call(this);
+ },
+ get: function (num) {
+ return num != null ? num < 0 ? this[num + this.length] : this[num] : slice.call(this);
+ },
+ pushStack: function (elems) {
+ var ret = jQuery.merge(this.constructor(), elems);
+ ret.prevObject = this;
+ ret.context = this.context;
+ return ret;
+ },
+ each: function (callback) {
+ return jQuery.each(this, callback);
+ },
+ map: function (callback) {
+ return this.pushStack(jQuery.map(this, function (elem, i) {
+ return callback.call(elem, i, elem);
+ }));
+ },
+ slice: function () {
+ return this.pushStack(slice.apply(this, arguments));
+ },
+ first: function () {
+ return this.eq(0);
+ },
+ last: function () {
+ return this.eq(-1);
+ },
+ eq: function (i) {
+ var len = this.length, j = +i + (i < 0 ? len : 0);
+ return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
+ },
+ end: function () {
+ return this.prevObject || this.constructor();
+ },
+ push: push,
+ sort: arr.sort,
+ splice: arr.splice
+ };
+ jQuery.extend = jQuery.fn.extend = function () {
+ var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false;
+ if (typeof target === 'boolean') {
+ deep = target;
+ target = arguments[i] || {};
+ i++;
+ }
+ if (typeof target !== 'object' && !jQuery.isFunction(target)) {
+ target = {};
+ }
+ if (i === length) {
+ target = this;
+ i--;
+ }
+ for (; i < length; i++) {
+ if ((options = arguments[i]) != null) {
+ for (name in options) {
+ src = target[name];
+ copy = options[name];
+ if (target === copy) {
+ continue;
+ }
+ if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) {
+ if (copyIsArray) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+ target[name] = jQuery.extend(deep, clone, copy);
+ } else if (copy !== undefined) {
+ target[name] = copy;
+ }
+ }
+ }
+ }
+ return target;
+ };
+ jQuery.extend({
+ expando: 'jQuery' + (version + Math.random()).replace(/\D/g, ''),
+ isReady: true,
+ error: function (msg) {
+ throw new Error(msg);
+ },
+ noop: function () {
+ },
+ isFunction: function (obj) {
+ return jQuery.type(obj) === 'function';
+ },
+ isArray: Array.isArray,
+ isWindow: function (obj) {
+ return obj != null && obj === obj.window;
+ },
+ isNumeric: function (obj) {
+ var realStringObj = obj && obj.toString();
+ return !jQuery.isArray(obj) && realStringObj - parseFloat(realStringObj) + 1 >= 0;
+ },
+ isPlainObject: function (obj) {
+ var key;
+ if (jQuery.type(obj) !== 'object' || obj.nodeType || jQuery.isWindow(obj)) {
+ return false;
+ }
+ if (obj.constructor && !hasOwn.call(obj, 'constructor') && !hasOwn.call(obj.constructor.prototype || {}, 'isPrototypeOf')) {
+ return false;
+ }
+ for (key in obj) {
+ }
+ return key === undefined || hasOwn.call(obj, key);
+ },
+ isEmptyObject: function (obj) {
+ var name;
+ for (name in obj) {
+ return false;
+ }
+ return true;
+ },
+ type: function (obj) {
+ if (obj == null) {
+ return obj + '';
+ }
+ return typeof obj === 'object' || typeof obj === 'function' ? class2type[toString.call(obj)] || 'object' : typeof obj;
+ },
+ globalEval: function (code) {
+ var script, indirect = eval;
+ code = jQuery.trim(code);
+ if (code) {
+ if (code.indexOf('use strict') === 1) {
+ script = document.createElement('script');
+ script.text = code;
+ document.head.appendChild(script).parentNode.removeChild(script);
+ } else {
+ indirect(code);
+ }
+ }
+ },
+ camelCase: function (string) {
+ return string.replace(rmsPrefix, 'ms-').replace(rdashAlpha, fcamelCase);
+ },
+ nodeName: function (elem, name) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+ each: function (obj, callback) {
+ var length, i = 0;
+ if (isArrayLike(obj)) {
+ length = obj.length;
+ for (; i < length; i++) {
+ if (callback.call(obj[i], i, obj[i]) === false) {
+ break;
+ }
+ }
+ } else {
+ for (i in obj) {
+ if (callback.call(obj[i], i, obj[i]) === false) {
+ break;
+ }
+ }
+ }
+ return obj;
+ },
+ trim: function (text) {
+ return text == null ? '' : (text + '').replace(rtrim, '');
+ },
+ makeArray: function (arr, results) {
+ var ret = results || [];
+ if (arr != null) {
+ if (isArrayLike(Object(arr))) {
+ jQuery.merge(ret, typeof arr === 'string' ? [arr] : arr);
+ } else {
+ push.call(ret, arr);
+ }
+ }
+ return ret;
+ },
+ inArray: function (elem, arr, i) {
+ return arr == null ? -1 : indexOf.call(arr, elem, i);
+ },
+ merge: function (first, second) {
+ var len = +second.length, j = 0, i = first.length;
+ for (; j < len; j++) {
+ first[i++] = second[j];
+ }
+ first.length = i;
+ return first;
+ },
+ grep: function (elems, callback, invert) {
+ var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert;
+ for (; i < length; i++) {
+ callbackInverse = !callback(elems[i], i);
+ if (callbackInverse !== callbackExpect) {
+ matches.push(elems[i]);
+ }
+ }
+ return matches;
+ },
+ map: function (elems, callback, arg) {
+ var length, value, i = 0, ret = [];
+ if (isArrayLike(elems)) {
+ length = elems.length;
+ for (; i < length; i++) {
+ value = callback(elems[i], i, arg);
+ if (value != null) {
+ ret.push(value);
+ }
+ }
+ } else {
+ for (i in elems) {
+ value = callback(elems[i], i, arg);
+ if (value != null) {
+ ret.push(value);
+ }
+ }
+ }
+ return concat.apply([], ret);
+ },
+ guid: 1,
+ proxy: function (fn, context) {
+ var tmp, args, proxy;
+ if (typeof context === 'string') {
+ tmp = fn[context];
+ context = fn;
+ fn = tmp;
+ }
+ if (!jQuery.isFunction(fn)) {
+ return undefined;
+ }
+ args = slice.call(arguments, 2);
+ proxy = function () {
+ return fn.apply(context || this, args.concat(slice.call(arguments)));
+ };
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+ return proxy;
+ },
+ now: Date.now,
+ support: support
+ });
+ if (typeof Symbol === 'function') {
+ jQuery.fn[Symbol.iterator] = arr[Symbol.iterator];
+ }
+ jQuery.each('Boolean Number String Function Array Date RegExp Object Error Symbol'.split(' '), function (i, name) {
+ class2type['[object ' + name + ']'] = name.toLowerCase();
+ });
+ function isArrayLike(obj) {
+ var length = !!obj && 'length' in obj && obj.length, type = jQuery.type(obj);
+ if (type === 'function' || jQuery.isWindow(obj)) {
+ return false;
+ }
+ return type === 'array' || length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj;
+ }
+ var Sizzle = function (window) {
+ var i, support, Expr, getText, isXML, tokenize, compile, select, outermostContext, sortInput, hasDuplicate, setDocument, document, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, expando = 'sizzle' + 1 * new Date(), preferredDoc = window.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), sortOrder = function (a, b) {
+ if (a === b) {
+ hasDuplicate = true;
+ }
+ return 0;
+ }, MAX_NEGATIVE = 1 << 31, hasOwn = {}.hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push = arr.push, slice = arr.slice, indexOf = function (list, elem) {
+ var i = 0, len = list.length;
+ for (; i < len; i++) {
+ if (list[i] === elem) {
+ return i;
+ }
+ }
+ return -1;
+ }, booleans = 'checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped', whitespace = '[\\x20\\t\\r\\n\\f]', identifier = '(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+', attributes = '\\[' + whitespace + '*(' + identifier + ')(?:' + whitespace + '*([*^$|!~]?=)' + whitespace + '*(?:\'((?:\\\\.|[^\\\\\'])*)\'|"((?:\\\\.|[^\\\\"])*)"|(' + identifier + '))|)' + whitespace + '*\\]', pseudos = ':(' + identifier + ')(?:\\((' + '(\'((?:\\\\.|[^\\\\\'])*)\'|"((?:\\\\.|[^\\\\"])*)")|' + '((?:\\\\.|[^\\\\()[\\]]|' + attributes + ')*)|' + '.*' + ')\\)|)', rwhitespace = new RegExp(whitespace + '+', 'g'), rtrim = new RegExp('^' + whitespace + '+|((?:^|[^\\\\])(?:\\\\.)*)' + whitespace + '+$', 'g'), rcomma = new RegExp('^' + whitespace + '*,' + whitespace + '*'), rcombinators = new RegExp('^' + whitespace + '*([>+~]|' + whitespace + ')' + whitespace + '*'), rattributeQuotes = new RegExp('=' + whitespace + '*([^\\]\'"]*?)' + whitespace + '*\\]', 'g'), rpseudo = new RegExp(pseudos), ridentifier = new RegExp('^' + identifier + '$'), matchExpr = {
+ 'ID': new RegExp('^#(' + identifier + ')'),
+ 'CLASS': new RegExp('^\\.(' + identifier + ')'),
+ 'TAG': new RegExp('^(' + identifier + '|[*])'),
+ 'ATTR': new RegExp('^' + attributes),
+ 'PSEUDO': new RegExp('^' + pseudos),
+ 'CHILD': new RegExp('^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(' + whitespace + '*(even|odd|(([+-]|)(\\d*)n|)' + whitespace + '*(?:([+-]|)' + whitespace + '*(\\d+)|))' + whitespace + '*\\)|)', 'i'),
+ 'bool': new RegExp('^(?:' + booleans + ')$', 'i'),
+ 'needsContext': new RegExp('^' + whitespace + '*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(' + whitespace + '*((?:-\\d)?\\d*)' + whitespace + '*\\)|)(?=[^-]|$)', 'i')
+ }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rnative = /^[^{]+\{\s*\[native \w/, rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, rescape = /'|\\/g, runescape = new RegExp('\\\\([\\da-f]{1,6}' + whitespace + '?|(' + whitespace + ')|.)', 'ig'), funescape = function (_, escaped, escapedWhitespace) {
+ var high = '0x' + escaped - 65536;
+ return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
+ }, unloadHandler = function () {
+ setDocument();
+ };
+ try {
+ push.apply(arr = slice.call(preferredDoc.childNodes), preferredDoc.childNodes);
+ arr[preferredDoc.childNodes.length].nodeType;
+ } catch (e) {
+ push = {
+ apply: arr.length ? function (target, els) {
+ push_native.apply(target, slice.call(els));
+ } : function (target, els) {
+ var j = target.length, i = 0;
+ while (target[j++] = els[i++]) {
+ }
+ target.length = j - 1;
+ }
+ };
+ }
+ function Sizzle(selector, context, results, seed) {
+ var m, i, elem, nid, nidselect, match, groups, newSelector, newContext = context && context.ownerDocument, nodeType = context ? context.nodeType : 9;
+ results = results || [];
+ if (typeof selector !== 'string' || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
+ return results;
+ }
+ if (!seed) {
+ if ((context ? context.ownerDocument || context : preferredDoc) !== document) {
+ setDocument(context);
+ }
+ context = context || document;
+ if (documentIsHTML) {
+ if (nodeType !== 11 && (match = rquickExpr.exec(selector))) {
+ if (m = match[1]) {
+ if (nodeType === 9) {
+ if (elem = context.getElementById(m)) {
+ if (elem.id === m) {
+ results.push(elem);
+ return results;
+ }
+ } else {
+ return results;
+ }
+ } else {
+ if (newContext && (elem = newContext.getElementById(m)) && contains(context, elem) && elem.id === m) {
+ results.push(elem);
+ return results;
+ }
+ }
+ } else if (match[2]) {
+ push.apply(results, context.getElementsByTagName(selector));
+ return results;
+ } else if ((m = match[3]) && support.getElementsByClassName && context.getElementsByClassName) {
+ push.apply(results, context.getElementsByClassName(m));
+ return results;
+ }
+ }
+ if (support.qsa && !compilerCache[selector + ' '] && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
+ if (nodeType !== 1) {
+ newContext = context;
+ newSelector = selector;
+ } else if (context.nodeName.toLowerCase() !== 'object') {
+ if (nid = context.getAttribute('id')) {
+ nid = nid.replace(rescape, '\\$&');
+ } else {
+ context.setAttribute('id', nid = expando);
+ }
+ groups = tokenize(selector);
+ i = groups.length;
+ nidselect = ridentifier.test(nid) ? '#' + nid : '[id=\'' + nid + '\']';
+ while (i--) {
+ groups[i] = nidselect + ' ' + toSelector(groups[i]);
+ }
+ newSelector = groups.join(',');
+ newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
+ }
+ if (newSelector) {
+ try {
+ push.apply(results, newContext.querySelectorAll(newSelector));
+ return results;
+ } catch (qsaError) {
+ } finally {
+ if (nid === expando) {
+ context.removeAttribute('id');
+ }
+ }
+ }
+ }
+ }
+ }
+ return select(selector.replace(rtrim, '$1'), context, results, seed);
+ }
+ function createCache() {
+ var keys = [];
+ function cache(key, value) {
+ if (keys.push(key + ' ') > Expr.cacheLength) {
+ delete cache[keys.shift()];
+ }
+ return cache[key + ' '] = value;
+ }
+ return cache;
+ }
+ function markFunction(fn) {
+ fn[expando] = true;
+ return fn;
+ }
+ function assert(fn) {
+ var div = document.createElement('div');
+ try {
+ return !!fn(div);
+ } catch (e) {
+ return false;
+ } finally {
+ if (div.parentNode) {
+ div.parentNode.removeChild(div);
+ }
+ div = null;
+ }
+ }
+ function addHandle(attrs, handler) {
+ var arr = attrs.split('|'), i = arr.length;
+ while (i--) {
+ Expr.attrHandle[arr[i]] = handler;
+ }
+ }
+ function siblingCheck(a, b) {
+ var cur = b && a, diff = cur && a.nodeType === 1 && b.nodeType === 1 && (~b.sourceIndex || MAX_NEGATIVE) - (~a.sourceIndex || MAX_NEGATIVE);
+ if (diff) {
+ return diff;
+ }
+ if (cur) {
+ while (cur = cur.nextSibling) {
+ if (cur === b) {
+ return -1;
+ }
+ }
+ }
+ return a ? 1 : -1;
+ }
+ function createInputPseudo(type) {
+ return function (elem) {
+ var name = elem.nodeName.toLowerCase();
+ return name === 'input' && elem.type === type;
+ };
+ }
+ function createButtonPseudo(type) {
+ return function (elem) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === 'input' || name === 'button') && elem.type === type;
+ };
+ }
+ function createPositionalPseudo(fn) {
+ return markFunction(function (argument) {
+ argument = +argument;
+ return markFunction(function (seed, matches) {
+ var j, matchIndexes = fn([], seed.length, argument), i = matchIndexes.length;
+ while (i--) {
+ if (seed[j = matchIndexes[i]]) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+ }
+ function testContext(context) {
+ return context && typeof context.getElementsByTagName !== 'undefined' && context;
+ }
+ support = Sizzle.support = {};
+ isXML = Sizzle.isXML = function (elem) {
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== 'HTML' : false;
+ };
+ setDocument = Sizzle.setDocument = function (node) {
+ var hasCompare, parent, doc = node ? node.ownerDocument || node : preferredDoc;
+ if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {
+ return document;
+ }
+ document = doc;
+ docElem = document.documentElement;
+ documentIsHTML = !isXML(document);
+ if ((parent = document.defaultView) && parent.top !== parent) {
+ if (parent.addEventListener) {
+ parent.addEventListener('unload', unloadHandler, false);
+ } else if (parent.attachEvent) {
+ parent.attachEvent('onunload', unloadHandler);
+ }
+ }
+ support.attributes = assert(function (div) {
+ div.className = 'i';
+ return !div.getAttribute('className');
+ });
+ support.getElementsByTagName = assert(function (div) {
+ div.appendChild(document.createComment(''));
+ return !div.getElementsByTagName('*').length;
+ });
+ support.getElementsByClassName = rnative.test(document.getElementsByClassName);
+ support.getById = assert(function (div) {
+ docElem.appendChild(div).id = expando;
+ return !document.getElementsByName || !document.getElementsByName(expando).length;
+ });
+ if (support.getById) {
+ Expr.find['ID'] = function (id, context) {
+ if (typeof context.getElementById !== 'undefined' && documentIsHTML) {
+ var m = context.getElementById(id);
+ return m ? [m] : [];
+ }
+ };
+ Expr.filter['ID'] = function (id) {
+ var attrId = id.replace(runescape, funescape);
+ return function (elem) {
+ return elem.getAttribute('id') === attrId;
+ };
+ };
+ } else {
+ delete Expr.find['ID'];
+ Expr.filter['ID'] = function (id) {
+ var attrId = id.replace(runescape, funescape);
+ return function (elem) {
+ var node = typeof elem.getAttributeNode !== 'undefined' && elem.getAttributeNode('id');
+ return node && node.value === attrId;
+ };
+ };
+ }
+ Expr.find['TAG'] = support.getElementsByTagName ? function (tag, context) {
+ if (typeof context.getElementsByTagName !== 'undefined') {
+ return context.getElementsByTagName(tag);
+ } else if (support.qsa) {
+ return context.querySelectorAll(tag);
+ }
+ } : function (tag, context) {
+ var elem, tmp = [], i = 0, results = context.getElementsByTagName(tag);
+ if (tag === '*') {
+ while (elem = results[i++]) {
+ if (elem.nodeType === 1) {
+ tmp.push(elem);
+ }
+ }
+ return tmp;
+ }
+ return results;
+ };
+ Expr.find['CLASS'] = support.getElementsByClassName && function (className, context) {
+ if (typeof context.getElementsByClassName !== 'undefined' && documentIsHTML) {
+ return context.getElementsByClassName(className);
+ }
+ };
+ rbuggyMatches = [];
+ rbuggyQSA = [];
+ if (support.qsa = rnative.test(document.querySelectorAll)) {
+ assert(function (div) {
+ docElem.appendChild(div).innerHTML = ' ' + '' + ' ';
+ if (div.querySelectorAll('[msallowcapture^=\'\']').length) {
+ rbuggyQSA.push('[*^$]=' + whitespace + '*(?:\'\'|"")');
+ }
+ if (!div.querySelectorAll('[selected]').length) {
+ rbuggyQSA.push('\\[' + whitespace + '*(?:value|' + booleans + ')');
+ }
+ if (!div.querySelectorAll('[id~=' + expando + '-]').length) {
+ rbuggyQSA.push('~=');
+ }
+ if (!div.querySelectorAll(':checked').length) {
+ rbuggyQSA.push(':checked');
+ }
+ if (!div.querySelectorAll('a#' + expando + '+*').length) {
+ rbuggyQSA.push('.#.+[+~]');
+ }
+ });
+ assert(function (div) {
+ var input = document.createElement('input');
+ input.setAttribute('type', 'hidden');
+ div.appendChild(input).setAttribute('name', 'D');
+ if (div.querySelectorAll('[name=d]').length) {
+ rbuggyQSA.push('name' + whitespace + '*[*^$|!~]?=');
+ }
+ if (!div.querySelectorAll(':enabled').length) {
+ rbuggyQSA.push(':enabled', ':disabled');
+ }
+ div.querySelectorAll('*,:x');
+ rbuggyQSA.push(',.*:');
+ });
+ }
+ if (support.matchesSelector = rnative.test(matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)) {
+ assert(function (div) {
+ support.disconnectedMatch = matches.call(div, 'div');
+ matches.call(div, '[s!=\'\']:x');
+ rbuggyMatches.push('!=', pseudos);
+ });
+ }
+ rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join('|'));
+ rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join('|'));
+ hasCompare = rnative.test(docElem.compareDocumentPosition);
+ contains = hasCompare || rnative.test(docElem.contains) ? function (a, b) {
+ var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode;
+ return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));
+ } : function (a, b) {
+ if (b) {
+ while (b = b.parentNode) {
+ if (b === a) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+ sortOrder = hasCompare ? function (a, b) {
+ if (a === b) {
+ hasDuplicate = true;
+ return 0;
+ }
+ var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+ if (compare) {
+ return compare;
+ }
+ compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1;
+ if (compare & 1 || !support.sortDetached && b.compareDocumentPosition(a) === compare) {
+ if (a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {
+ return -1;
+ }
+ if (b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {
+ return 1;
+ }
+ return sortInput ? indexOf(sortInput, a) - indexOf(sortInput, b) : 0;
+ }
+ return compare & 4 ? -1 : 1;
+ } : function (a, b) {
+ if (a === b) {
+ hasDuplicate = true;
+ return 0;
+ }
+ var cur, i = 0, aup = a.parentNode, bup = b.parentNode, ap = [a], bp = [b];
+ if (!aup || !bup) {
+ return a === document ? -1 : b === document ? 1 : aup ? -1 : bup ? 1 : sortInput ? indexOf(sortInput, a) - indexOf(sortInput, b) : 0;
+ } else if (aup === bup) {
+ return siblingCheck(a, b);
+ }
+ cur = a;
+ while (cur = cur.parentNode) {
+ ap.unshift(cur);
+ }
+ cur = b;
+ while (cur = cur.parentNode) {
+ bp.unshift(cur);
+ }
+ while (ap[i] === bp[i]) {
+ i++;
+ }
+ return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0;
+ };
+ return document;
+ };
+ Sizzle.matches = function (expr, elements) {
+ return Sizzle(expr, null, null, elements);
+ };
+ Sizzle.matchesSelector = function (elem, expr) {
+ if ((elem.ownerDocument || elem) !== document) {
+ setDocument(elem);
+ }
+ expr = expr.replace(rattributeQuotes, '=\'$1\']');
+ if (support.matchesSelector && documentIsHTML && !compilerCache[expr + ' '] && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) {
+ try {
+ var ret = matches.call(elem, expr);
+ if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) {
+ return ret;
+ }
+ } catch (e) {
+ }
+ }
+ return Sizzle(expr, document, null, [elem]).length > 0;
+ };
+ Sizzle.contains = function (context, elem) {
+ if ((context.ownerDocument || context) !== document) {
+ setDocument(context);
+ }
+ return contains(context, elem);
+ };
+ Sizzle.attr = function (elem, name) {
+ if ((elem.ownerDocument || elem) !== document) {
+ setDocument(elem);
+ }
+ var fn = Expr.attrHandle[name.toLowerCase()], val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined;
+ return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null;
+ };
+ Sizzle.error = function (msg) {
+ throw new Error('Syntax error, unrecognized expression: ' + msg);
+ };
+ Sizzle.uniqueSort = function (results) {
+ var elem, duplicates = [], j = 0, i = 0;
+ hasDuplicate = !support.detectDuplicates;
+ sortInput = !support.sortStable && results.slice(0);
+ results.sort(sortOrder);
+ if (hasDuplicate) {
+ while (elem = results[i++]) {
+ if (elem === results[i]) {
+ j = duplicates.push(i);
+ }
+ }
+ while (j--) {
+ results.splice(duplicates[j], 1);
+ }
+ }
+ sortInput = null;
+ return results;
+ };
+ getText = Sizzle.getText = function (elem) {
+ var node, ret = '', i = 0, nodeType = elem.nodeType;
+ if (!nodeType) {
+ while (node = elem[i++]) {
+ ret += getText(node);
+ }
+ } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {
+ if (typeof elem.textContent === 'string') {
+ return elem.textContent;
+ } else {
+ for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
+ ret += getText(elem);
+ }
+ }
+ } else if (nodeType === 3 || nodeType === 4) {
+ return elem.nodeValue;
+ }
+ return ret;
+ };
+ Expr = Sizzle.selectors = {
+ cacheLength: 50,
+ createPseudo: markFunction,
+ match: matchExpr,
+ attrHandle: {},
+ find: {},
+ relative: {
+ '>': {
+ dir: 'parentNode',
+ first: true
+ },
+ ' ': { dir: 'parentNode' },
+ '+': {
+ dir: 'previousSibling',
+ first: true
+ },
+ '~': { dir: 'previousSibling' }
+ },
+ preFilter: {
+ 'ATTR': function (match) {
+ match[1] = match[1].replace(runescape, funescape);
+ match[3] = (match[3] || match[4] || match[5] || '').replace(runescape, funescape);
+ if (match[2] === '~=') {
+ match[3] = ' ' + match[3] + ' ';
+ }
+ return match.slice(0, 4);
+ },
+ 'CHILD': function (match) {
+ match[1] = match[1].toLowerCase();
+ if (match[1].slice(0, 3) === 'nth') {
+ if (!match[3]) {
+ Sizzle.error(match[0]);
+ }
+ match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === 'even' || match[3] === 'odd'));
+ match[5] = +(match[7] + match[8] || match[3] === 'odd');
+ } else if (match[3]) {
+ Sizzle.error(match[0]);
+ }
+ return match;
+ },
+ 'PSEUDO': function (match) {
+ var excess, unquoted = !match[6] && match[2];
+ if (matchExpr['CHILD'].test(match[0])) {
+ return null;
+ }
+ if (match[3]) {
+ match[2] = match[4] || match[5] || '';
+ } else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(')', unquoted.length - excess) - unquoted.length)) {
+ match[0] = match[0].slice(0, excess);
+ match[2] = unquoted.slice(0, excess);
+ }
+ return match.slice(0, 3);
+ }
+ },
+ filter: {
+ 'TAG': function (nodeNameSelector) {
+ var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();
+ return nodeNameSelector === '*' ? function () {
+ return true;
+ } : function (elem) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+ 'CLASS': function (className) {
+ var pattern = classCache[className + ' '];
+ return pattern || (pattern = new RegExp('(^|' + whitespace + ')' + className + '(' + whitespace + '|$)')) && classCache(className, function (elem) {
+ return pattern.test(typeof elem.className === 'string' && elem.className || typeof elem.getAttribute !== 'undefined' && elem.getAttribute('class') || '');
+ });
+ },
+ 'ATTR': function (name, operator, check) {
+ return function (elem) {
+ var result = Sizzle.attr(elem, name);
+ if (result == null) {
+ return operator === '!=';
+ }
+ if (!operator) {
+ return true;
+ }
+ result += '';
+ return operator === '=' ? result === check : operator === '!=' ? result !== check : operator === '^=' ? check && result.indexOf(check) === 0 : operator === '*=' ? check && result.indexOf(check) > -1 : operator === '$=' ? check && result.slice(-check.length) === check : operator === '~=' ? (' ' + result.replace(rwhitespace, ' ') + ' ').indexOf(check) > -1 : operator === '|=' ? result === check || result.slice(0, check.length + 1) === check + '-' : false;
+ };
+ },
+ 'CHILD': function (type, what, argument, first, last) {
+ var simple = type.slice(0, 3) !== 'nth', forward = type.slice(-4) !== 'last', ofType = what === 'of-type';
+ return first === 1 && last === 0 ? function (elem) {
+ return !!elem.parentNode;
+ } : function (elem, context, xml) {
+ var cache, uniqueCache, outerCache, node, nodeIndex, start, dir = simple !== forward ? 'nextSibling' : 'previousSibling', parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType, diff = false;
+ if (parent) {
+ if (simple) {
+ while (dir) {
+ node = elem;
+ while (node = node[dir]) {
+ if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
+ return false;
+ }
+ }
+ start = dir = type === 'only' && !start && 'nextSibling';
+ }
+ return true;
+ }
+ start = [forward ? parent.firstChild : parent.lastChild];
+ if (forward && useCache) {
+ node = parent;
+ outerCache = node[expando] || (node[expando] = {});
+ uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});
+ cache = uniqueCache[type] || [];
+ nodeIndex = cache[0] === dirruns && cache[1];
+ diff = nodeIndex && cache[2];
+ node = nodeIndex && parent.childNodes[nodeIndex];
+ while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {
+ if (node.nodeType === 1 && ++diff && node === elem) {
+ uniqueCache[type] = [
+ dirruns,
+ nodeIndex,
+ diff
+ ];
+ break;
+ }
+ }
+ } else {
+ if (useCache) {
+ node = elem;
+ outerCache = node[expando] || (node[expando] = {});
+ uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});
+ cache = uniqueCache[type] || [];
+ nodeIndex = cache[0] === dirruns && cache[1];
+ diff = nodeIndex;
+ }
+ if (diff === false) {
+ while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {
+ if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {
+ if (useCache) {
+ outerCache = node[expando] || (node[expando] = {});
+ uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});
+ uniqueCache[type] = [
+ dirruns,
+ diff
+ ];
+ }
+ if (node === elem) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ diff -= last;
+ return diff === first || diff % first === 0 && diff / first >= 0;
+ }
+ };
+ },
+ 'PSEUDO': function (pseudo, argument) {
+ var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error('unsupported pseudo: ' + pseudo);
+ if (fn[expando]) {
+ return fn(argument);
+ }
+ if (fn.length > 1) {
+ args = [
+ pseudo,
+ pseudo,
+ '',
+ argument
+ ];
+ return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function (seed, matches) {
+ var idx, matched = fn(seed, argument), i = matched.length;
+ while (i--) {
+ idx = indexOf(seed, matched[i]);
+ seed[idx] = !(matches[idx] = matched[i]);
+ }
+ }) : function (elem) {
+ return fn(elem, 0, args);
+ };
+ }
+ return fn;
+ }
+ },
+ pseudos: {
+ 'not': markFunction(function (selector) {
+ var input = [], results = [], matcher = compile(selector.replace(rtrim, '$1'));
+ return matcher[expando] ? markFunction(function (seed, matches, context, xml) {
+ var elem, unmatched = matcher(seed, null, xml, []), i = seed.length;
+ while (i--) {
+ if (elem = unmatched[i]) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) : function (elem, context, xml) {
+ input[0] = elem;
+ matcher(input, null, xml, results);
+ input[0] = null;
+ return !results.pop();
+ };
+ }),
+ 'has': markFunction(function (selector) {
+ return function (elem) {
+ return Sizzle(selector, elem).length > 0;
+ };
+ }),
+ 'contains': markFunction(function (text) {
+ text = text.replace(runescape, funescape);
+ return function (elem) {
+ return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1;
+ };
+ }),
+ 'lang': markFunction(function (lang) {
+ if (!ridentifier.test(lang || '')) {
+ Sizzle.error('unsupported lang: ' + lang);
+ }
+ lang = lang.replace(runescape, funescape).toLowerCase();
+ return function (elem) {
+ var elemLang;
+ do {
+ if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute('xml:lang') || elem.getAttribute('lang')) {
+ elemLang = elemLang.toLowerCase();
+ return elemLang === lang || elemLang.indexOf(lang + '-') === 0;
+ }
+ } while ((elem = elem.parentNode) && elem.nodeType === 1);
+ return false;
+ };
+ }),
+ 'target': function (elem) {
+ var hash = window.location && window.location.hash;
+ return hash && hash.slice(1) === elem.id;
+ },
+ 'root': function (elem) {
+ return elem === docElem;
+ },
+ 'focus': function (elem) {
+ return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
+ },
+ 'enabled': function (elem) {
+ return elem.disabled === false;
+ },
+ 'disabled': function (elem) {
+ return elem.disabled === true;
+ },
+ 'checked': function (elem) {
+ var nodeName = elem.nodeName.toLowerCase();
+ return nodeName === 'input' && !!elem.checked || nodeName === 'option' && !!elem.selected;
+ },
+ 'selected': function (elem) {
+ if (elem.parentNode) {
+ elem.parentNode.selectedIndex;
+ }
+ return elem.selected === true;
+ },
+ 'empty': function (elem) {
+ for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
+ if (elem.nodeType < 6) {
+ return false;
+ }
+ }
+ return true;
+ },
+ 'parent': function (elem) {
+ return !Expr.pseudos['empty'](elem);
+ },
+ 'header': function (elem) {
+ return rheader.test(elem.nodeName);
+ },
+ 'input': function (elem) {
+ return rinputs.test(elem.nodeName);
+ },
+ 'button': function (elem) {
+ var name = elem.nodeName.toLowerCase();
+ return name === 'input' && elem.type === 'button' || name === 'button';
+ },
+ 'text': function (elem) {
+ var attr;
+ return elem.nodeName.toLowerCase() === 'input' && elem.type === 'text' && ((attr = elem.getAttribute('type')) == null || attr.toLowerCase() === 'text');
+ },
+ 'first': createPositionalPseudo(function () {
+ return [0];
+ }),
+ 'last': createPositionalPseudo(function (matchIndexes, length) {
+ return [length - 1];
+ }),
+ 'eq': createPositionalPseudo(function (matchIndexes, length, argument) {
+ return [argument < 0 ? argument + length : argument];
+ }),
+ 'even': createPositionalPseudo(function (matchIndexes, length) {
+ var i = 0;
+ for (; i < length; i += 2) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ }),
+ 'odd': createPositionalPseudo(function (matchIndexes, length) {
+ var i = 1;
+ for (; i < length; i += 2) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ }),
+ 'lt': createPositionalPseudo(function (matchIndexes, length, argument) {
+ var i = argument < 0 ? argument + length : argument;
+ for (; --i >= 0;) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ }),
+ 'gt': createPositionalPseudo(function (matchIndexes, length, argument) {
+ var i = argument < 0 ? argument + length : argument;
+ for (; ++i < length;) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ })
+ }
+ };
+ Expr.pseudos['nth'] = Expr.pseudos['eq'];
+ for (i in {
+ radio: true,
+ checkbox: true,
+ file: true,
+ password: true,
+ image: true
+ }) {
+ Expr.pseudos[i] = createInputPseudo(i);
+ }
+ for (i in {
+ submit: true,
+ reset: true
+ }) {
+ Expr.pseudos[i] = createButtonPseudo(i);
+ }
+ function setFilters() {
+ }
+ setFilters.prototype = Expr.filters = Expr.pseudos;
+ Expr.setFilters = new setFilters();
+ tokenize = Sizzle.tokenize = function (selector, parseOnly) {
+ var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + ' '];
+ if (cached) {
+ return parseOnly ? 0 : cached.slice(0);
+ }
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+ while (soFar) {
+ if (!matched || (match = rcomma.exec(soFar))) {
+ if (match) {
+ soFar = soFar.slice(match[0].length) || soFar;
+ }
+ groups.push(tokens = []);
+ }
+ matched = false;
+ if (match = rcombinators.exec(soFar)) {
+ matched = match.shift();
+ tokens.push({
+ value: matched,
+ type: match[0].replace(rtrim, ' ')
+ });
+ soFar = soFar.slice(matched.length);
+ }
+ for (type in Expr.filter) {
+ if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {
+ matched = match.shift();
+ tokens.push({
+ value: matched,
+ type: type,
+ matches: match
+ });
+ soFar = soFar.slice(matched.length);
+ }
+ }
+ if (!matched) {
+ break;
+ }
+ }
+ return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) : tokenCache(selector, groups).slice(0);
+ };
+ function toSelector(tokens) {
+ var i = 0, len = tokens.length, selector = '';
+ for (; i < len; i++) {
+ selector += tokens[i].value;
+ }
+ return selector;
+ }
+ function addCombinator(matcher, combinator, base) {
+ var dir = combinator.dir, checkNonElements = base && dir === 'parentNode', doneName = done++;
+ return combinator.first ? function (elem, context, xml) {
+ while (elem = elem[dir]) {
+ if (elem.nodeType === 1 || checkNonElements) {
+ return matcher(elem, context, xml);
+ }
+ }
+ } : function (elem, context, xml) {
+ var oldCache, uniqueCache, outerCache, newCache = [
+ dirruns,
+ doneName
+ ];
+ if (xml) {
+ while (elem = elem[dir]) {
+ if (elem.nodeType === 1 || checkNonElements) {
+ if (matcher(elem, context, xml)) {
+ return true;
+ }
+ }
+ }
+ } else {
+ while (elem = elem[dir]) {
+ if (elem.nodeType === 1 || checkNonElements) {
+ outerCache = elem[expando] || (elem[expando] = {});
+ uniqueCache = outerCache[elem.uniqueID] || (outerCache[elem.uniqueID] = {});
+ if ((oldCache = uniqueCache[dir]) && oldCache[0] === dirruns && oldCache[1] === doneName) {
+ return newCache[2] = oldCache[2];
+ } else {
+ uniqueCache[dir] = newCache;
+ if (newCache[2] = matcher(elem, context, xml)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+ function elementMatcher(matchers) {
+ return matchers.length > 1 ? function (elem, context, xml) {
+ var i = matchers.length;
+ while (i--) {
+ if (!matchers[i](elem, context, xml)) {
+ return false;
+ }
+ }
+ return true;
+ } : matchers[0];
+ }
+ function multipleContexts(selector, contexts, results) {
+ var i = 0, len = contexts.length;
+ for (; i < len; i++) {
+ Sizzle(selector, contexts[i], results);
+ }
+ return results;
+ }
+ function condense(unmatched, map, filter, context, xml) {
+ var elem, newUnmatched = [], i = 0, len = unmatched.length, mapped = map != null;
+ for (; i < len; i++) {
+ if (elem = unmatched[i]) {
+ if (!filter || filter(elem, context, xml)) {
+ newUnmatched.push(elem);
+ if (mapped) {
+ map.push(i);
+ }
+ }
+ }
+ }
+ return newUnmatched;
+ }
+ function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
+ if (postFilter && !postFilter[expando]) {
+ postFilter = setMatcher(postFilter);
+ }
+ if (postFinder && !postFinder[expando]) {
+ postFinder = setMatcher(postFinder, postSelector);
+ }
+ return markFunction(function (seed, results, context, xml) {
+ var temp, i, elem, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts(selector || '*', context.nodeType ? [context] : context, []), matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems, matcherOut = matcher ? postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results : matcherIn;
+ if (matcher) {
+ matcher(matcherIn, matcherOut, context, xml);
+ }
+ if (postFilter) {
+ temp = condense(matcherOut, postMap);
+ postFilter(temp, [], context, xml);
+ i = temp.length;
+ while (i--) {
+ if (elem = temp[i]) {
+ matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem);
+ }
+ }
+ }
+ if (seed) {
+ if (postFinder || preFilter) {
+ if (postFinder) {
+ temp = [];
+ i = matcherOut.length;
+ while (i--) {
+ if (elem = matcherOut[i]) {
+ temp.push(matcherIn[i] = elem);
+ }
+ }
+ postFinder(null, matcherOut = [], temp, xml);
+ }
+ i = matcherOut.length;
+ while (i--) {
+ if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) {
+ seed[temp] = !(results[temp] = elem);
+ }
+ }
+ }
+ } else {
+ matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut);
+ if (postFinder) {
+ postFinder(null, results, matcherOut, xml);
+ } else {
+ push.apply(results, matcherOut);
+ }
+ }
+ });
+ }
+ function matcherFromTokens(tokens) {
+ var checkContext, matcher, j, len = tokens.length, leadingRelative = Expr.relative[tokens[0].type], implicitRelative = leadingRelative || Expr.relative[' '], i = leadingRelative ? 1 : 0, matchContext = addCombinator(function (elem) {
+ return elem === checkContext;
+ }, implicitRelative, true), matchAnyContext = addCombinator(function (elem) {
+ return indexOf(checkContext, elem) > -1;
+ }, implicitRelative, true), matchers = [function (elem, context, xml) {
+ var ret = !leadingRelative && (xml || context !== outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
+ checkContext = null;
+ return ret;
+ }];
+ for (; i < len; i++) {
+ if (matcher = Expr.relative[tokens[i].type]) {
+ matchers = [addCombinator(elementMatcher(matchers), matcher)];
+ } else {
+ matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);
+ if (matcher[expando]) {
+ j = ++i;
+ for (; j < len; j++) {
+ if (Expr.relative[tokens[j].type]) {
+ break;
+ }
+ }
+ return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === ' ' ? '*' : '' })).replace(rtrim, '$1'), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens(tokens = tokens.slice(j)), j < len && toSelector(tokens));
+ }
+ matchers.push(matcher);
+ }
+ }
+ return elementMatcher(matchers);
+ }
+ function matcherFromGroupMatchers(elementMatchers, setMatchers) {
+ var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function (seed, context, xml, results, outermost) {
+ var elem, j, matcher, matchedCount = 0, i = '0', unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && Expr.find['TAG']('*', outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1, len = elems.length;
+ if (outermost) {
+ outermostContext = context === document || context || outermost;
+ }
+ for (; i !== len && (elem = elems[i]) != null; i++) {
+ if (byElement && elem) {
+ j = 0;
+ if (!context && elem.ownerDocument !== document) {
+ setDocument(elem);
+ xml = !documentIsHTML;
+ }
+ while (matcher = elementMatchers[j++]) {
+ if (matcher(elem, context || document, xml)) {
+ results.push(elem);
+ break;
+ }
+ }
+ if (outermost) {
+ dirruns = dirrunsUnique;
+ }
+ }
+ if (bySet) {
+ if (elem = !matcher && elem) {
+ matchedCount--;
+ }
+ if (seed) {
+ unmatched.push(elem);
+ }
+ }
+ }
+ matchedCount += i;
+ if (bySet && i !== matchedCount) {
+ j = 0;
+ while (matcher = setMatchers[j++]) {
+ matcher(unmatched, setMatched, context, xml);
+ }
+ if (seed) {
+ if (matchedCount > 0) {
+ while (i--) {
+ if (!(unmatched[i] || setMatched[i])) {
+ setMatched[i] = pop.call(results);
+ }
+ }
+ }
+ setMatched = condense(setMatched);
+ }
+ push.apply(results, setMatched);
+ if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) {
+ Sizzle.uniqueSort(results);
+ }
+ }
+ if (outermost) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+ return unmatched;
+ };
+ return bySet ? markFunction(superMatcher) : superMatcher;
+ }
+ compile = Sizzle.compile = function (selector, match) {
+ var i, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + ' '];
+ if (!cached) {
+ if (!match) {
+ match = tokenize(selector);
+ }
+ i = match.length;
+ while (i--) {
+ cached = matcherFromTokens(match[i]);
+ if (cached[expando]) {
+ setMatchers.push(cached);
+ } else {
+ elementMatchers.push(cached);
+ }
+ }
+ cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
+ cached.selector = selector;
+ }
+ return cached;
+ };
+ select = Sizzle.select = function (selector, context, results, seed) {
+ var i, tokens, token, type, find, compiled = typeof selector === 'function' && selector, match = !seed && tokenize(selector = compiled.selector || selector);
+ results = results || [];
+ if (match.length === 1) {
+ tokens = match[0] = match[0].slice(0);
+ if (tokens.length > 2 && (token = tokens[0]).type === 'ID' && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) {
+ context = (Expr.find['ID'](token.matches[0].replace(runescape, funescape), context) || [])[0];
+ if (!context) {
+ return results;
+ } else if (compiled) {
+ context = context.parentNode;
+ }
+ selector = selector.slice(tokens.shift().value.length);
+ }
+ i = matchExpr['needsContext'].test(selector) ? 0 : tokens.length;
+ while (i--) {
+ token = tokens[i];
+ if (Expr.relative[type = token.type]) {
+ break;
+ }
+ if (find = Expr.find[type]) {
+ if (seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context)) {
+ tokens.splice(i, 1);
+ selector = seed.length && toSelector(tokens);
+ if (!selector) {
+ push.apply(results, seed);
+ return results;
+ }
+ break;
+ }
+ }
+ }
+ }
+ (compiled || compile(selector, match))(seed, context, !documentIsHTML, results, !context || rsibling.test(selector) && testContext(context.parentNode) || context);
+ return results;
+ };
+ support.sortStable = expando.split('').sort(sortOrder).join('') === expando;
+ support.detectDuplicates = !!hasDuplicate;
+ setDocument();
+ support.sortDetached = assert(function (div1) {
+ return div1.compareDocumentPosition(document.createElement('div')) & 1;
+ });
+ if (!assert(function (div) {
+ div.innerHTML = ' ';
+ return div.firstChild.getAttribute('href') === '#';
+ })) {
+ addHandle('type|href|height|width', function (elem, name, isXML) {
+ if (!isXML) {
+ return elem.getAttribute(name, name.toLowerCase() === 'type' ? 1 : 2);
+ }
+ });
+ }
+ if (!support.attributes || !assert(function (div) {
+ div.innerHTML = ' ';
+ div.firstChild.setAttribute('value', '');
+ return div.firstChild.getAttribute('value') === '';
+ })) {
+ addHandle('value', function (elem, name, isXML) {
+ if (!isXML && elem.nodeName.toLowerCase() === 'input') {
+ return elem.defaultValue;
+ }
+ });
+ }
+ if (!assert(function (div) {
+ return div.getAttribute('disabled') == null;
+ })) {
+ addHandle(booleans, function (elem, name, isXML) {
+ var val;
+ if (!isXML) {
+ return elem[name] === true ? name.toLowerCase() : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null;
+ }
+ });
+ }
+ return Sizzle;
+ }(window);
+ jQuery.find = Sizzle;
+ jQuery.expr = Sizzle.selectors;
+ jQuery.expr[':'] = jQuery.expr.pseudos;
+ jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
+ jQuery.text = Sizzle.getText;
+ jQuery.isXMLDoc = Sizzle.isXML;
+ jQuery.contains = Sizzle.contains;
+ var dir = function (elem, dir, until) {
+ var matched = [], truncate = until !== undefined;
+ while ((elem = elem[dir]) && elem.nodeType !== 9) {
+ if (elem.nodeType === 1) {
+ if (truncate && jQuery(elem).is(until)) {
+ break;
+ }
+ matched.push(elem);
+ }
+ }
+ return matched;
+ };
+ var siblings = function (n, elem) {
+ var matched = [];
+ for (; n; n = n.nextSibling) {
+ if (n.nodeType === 1 && n !== elem) {
+ matched.push(n);
+ }
+ }
+ return matched;
+ };
+ var rneedsContext = jQuery.expr.match.needsContext;
+ var rsingleTag = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/;
+ var risSimple = /^.[^:#\[\.,]*$/;
+ function winnow(elements, qualifier, not) {
+ if (jQuery.isFunction(qualifier)) {
+ return jQuery.grep(elements, function (elem, i) {
+ return !!qualifier.call(elem, i, elem) !== not;
+ });
+ }
+ if (qualifier.nodeType) {
+ return jQuery.grep(elements, function (elem) {
+ return elem === qualifier !== not;
+ });
+ }
+ if (typeof qualifier === 'string') {
+ if (risSimple.test(qualifier)) {
+ return jQuery.filter(qualifier, elements, not);
+ }
+ qualifier = jQuery.filter(qualifier, elements);
+ }
+ return jQuery.grep(elements, function (elem) {
+ return indexOf.call(qualifier, elem) > -1 !== not;
+ });
+ }
+ jQuery.filter = function (expr, elems, not) {
+ var elem = elems[0];
+ if (not) {
+ expr = ':not(' + expr + ')';
+ }
+ return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector(elem, expr) ? [elem] : [] : jQuery.find.matches(expr, jQuery.grep(elems, function (elem) {
+ return elem.nodeType === 1;
+ }));
+ };
+ jQuery.fn.extend({
+ find: function (selector) {
+ var i, len = this.length, ret = [], self = this;
+ if (typeof selector !== 'string') {
+ return this.pushStack(jQuery(selector).filter(function () {
+ for (i = 0; i < len; i++) {
+ if (jQuery.contains(self[i], this)) {
+ return true;
+ }
+ }
+ }));
+ }
+ for (i = 0; i < len; i++) {
+ jQuery.find(selector, self[i], ret);
+ }
+ ret = this.pushStack(len > 1 ? jQuery.unique(ret) : ret);
+ ret.selector = this.selector ? this.selector + ' ' + selector : selector;
+ return ret;
+ },
+ filter: function (selector) {
+ return this.pushStack(winnow(this, selector || [], false));
+ },
+ not: function (selector) {
+ return this.pushStack(winnow(this, selector || [], true));
+ },
+ is: function (selector) {
+ return !!winnow(this, typeof selector === 'string' && rneedsContext.test(selector) ? jQuery(selector) : selector || [], false).length;
+ }
+ });
+ var rootjQuery, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, init = jQuery.fn.init = function (selector, context, root) {
+ var match, elem;
+ if (!selector) {
+ return this;
+ }
+ root = root || rootjQuery;
+ if (typeof selector === 'string') {
+ if (selector[0] === '<' && selector[selector.length - 1] === '>' && selector.length >= 3) {
+ match = [
+ null,
+ selector,
+ null
+ ];
+ } else {
+ match = rquickExpr.exec(selector);
+ }
+ if (match && (match[1] || !context)) {
+ if (match[1]) {
+ context = context instanceof jQuery ? context[0] : context;
+ jQuery.merge(this, jQuery.parseHTML(match[1], context && context.nodeType ? context.ownerDocument || context : document, true));
+ if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) {
+ for (match in context) {
+ if (jQuery.isFunction(this[match])) {
+ this[match](context[match]);
+ } else {
+ this.attr(match, context[match]);
+ }
+ }
+ }
+ return this;
+ } else {
+ elem = document.getElementById(match[2]);
+ if (elem && elem.parentNode) {
+ this.length = 1;
+ this[0] = elem;
+ }
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+ } else if (!context || context.jquery) {
+ return (context || root).find(selector);
+ } else {
+ return this.constructor(context).find(selector);
+ }
+ } else if (selector.nodeType) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ } else if (jQuery.isFunction(selector)) {
+ return root.ready !== undefined ? root.ready(selector) : selector(jQuery);
+ }
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+ return jQuery.makeArray(selector, this);
+ };
+ init.prototype = jQuery.fn;
+ rootjQuery = jQuery(document);
+ var rparentsprev = /^(?:parents|prev(?:Until|All))/, guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+ jQuery.fn.extend({
+ has: function (target) {
+ var targets = jQuery(target, this), l = targets.length;
+ return this.filter(function () {
+ var i = 0;
+ for (; i < l; i++) {
+ if (jQuery.contains(this, targets[i])) {
+ return true;
+ }
+ }
+ });
+ },
+ closest: function (selectors, context) {
+ var cur, i = 0, l = this.length, matched = [], pos = rneedsContext.test(selectors) || typeof selectors !== 'string' ? jQuery(selectors, context || this.context) : 0;
+ for (; i < l; i++) {
+ for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) {
+ if (cur.nodeType < 11 && (pos ? pos.index(cur) > -1 : cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors))) {
+ matched.push(cur);
+ break;
+ }
+ }
+ }
+ return this.pushStack(matched.length > 1 ? jQuery.uniqueSort(matched) : matched);
+ },
+ index: function (elem) {
+ if (!elem) {
+ return this[0] && this[0].parentNode ? this.first().prevAll().length : -1;
+ }
+ if (typeof elem === 'string') {
+ return indexOf.call(jQuery(elem), this[0]);
+ }
+ return indexOf.call(this, elem.jquery ? elem[0] : elem);
+ },
+ add: function (selector, context) {
+ return this.pushStack(jQuery.uniqueSort(jQuery.merge(this.get(), jQuery(selector, context))));
+ },
+ addBack: function (selector) {
+ return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
+ }
+ });
+ function sibling(cur, dir) {
+ while ((cur = cur[dir]) && cur.nodeType !== 1) {
+ }
+ return cur;
+ }
+ jQuery.each({
+ parent: function (elem) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function (elem) {
+ return dir(elem, 'parentNode');
+ },
+ parentsUntil: function (elem, i, until) {
+ return dir(elem, 'parentNode', until);
+ },
+ next: function (elem) {
+ return sibling(elem, 'nextSibling');
+ },
+ prev: function (elem) {
+ return sibling(elem, 'previousSibling');
+ },
+ nextAll: function (elem) {
+ return dir(elem, 'nextSibling');
+ },
+ prevAll: function (elem) {
+ return dir(elem, 'previousSibling');
+ },
+ nextUntil: function (elem, i, until) {
+ return dir(elem, 'nextSibling', until);
+ },
+ prevUntil: function (elem, i, until) {
+ return dir(elem, 'previousSibling', until);
+ },
+ siblings: function (elem) {
+ return siblings((elem.parentNode || {}).firstChild, elem);
+ },
+ children: function (elem) {
+ return siblings(elem.firstChild);
+ },
+ contents: function (elem) {
+ return elem.contentDocument || jQuery.merge([], elem.childNodes);
+ }
+ }, function (name, fn) {
+ jQuery.fn[name] = function (until, selector) {
+ var matched = jQuery.map(this, fn, until);
+ if (name.slice(-5) !== 'Until') {
+ selector = until;
+ }
+ if (selector && typeof selector === 'string') {
+ matched = jQuery.filter(selector, matched);
+ }
+ if (this.length > 1) {
+ if (!guaranteedUnique[name]) {
+ jQuery.uniqueSort(matched);
+ }
+ if (rparentsprev.test(name)) {
+ matched.reverse();
+ }
+ }
+ return this.pushStack(matched);
+ };
+ });
+ var rnotwhite = /\S+/g;
+ function createOptions(options) {
+ var object = {};
+ jQuery.each(options.match(rnotwhite) || [], function (_, flag) {
+ object[flag] = true;
+ });
+ return object;
+ }
+ jQuery.Callbacks = function (options) {
+ options = typeof options === 'string' ? createOptions(options) : jQuery.extend({}, options);
+ var firing, memory, fired, locked, list = [], queue = [], firingIndex = -1, fire = function () {
+ locked = options.once;
+ fired = firing = true;
+ for (; queue.length; firingIndex = -1) {
+ memory = queue.shift();
+ while (++firingIndex < list.length) {
+ if (list[firingIndex].apply(memory[0], memory[1]) === false && options.stopOnFalse) {
+ firingIndex = list.length;
+ memory = false;
+ }
+ }
+ }
+ if (!options.memory) {
+ memory = false;
+ }
+ firing = false;
+ if (locked) {
+ if (memory) {
+ list = [];
+ } else {
+ list = '';
+ }
+ }
+ }, self = {
+ add: function () {
+ if (list) {
+ if (memory && !firing) {
+ firingIndex = list.length - 1;
+ queue.push(memory);
+ }
+ (function add(args) {
+ jQuery.each(args, function (_, arg) {
+ if (jQuery.isFunction(arg)) {
+ if (!options.unique || !self.has(arg)) {
+ list.push(arg);
+ }
+ } else if (arg && arg.length && jQuery.type(arg) !== 'string') {
+ add(arg);
+ }
+ });
+ }(arguments));
+ if (memory && !firing) {
+ fire();
+ }
+ }
+ return this;
+ },
+ remove: function () {
+ jQuery.each(arguments, function (_, arg) {
+ var index;
+ while ((index = jQuery.inArray(arg, list, index)) > -1) {
+ list.splice(index, 1);
+ if (index <= firingIndex) {
+ firingIndex--;
+ }
+ }
+ });
+ return this;
+ },
+ has: function (fn) {
+ return fn ? jQuery.inArray(fn, list) > -1 : list.length > 0;
+ },
+ empty: function () {
+ if (list) {
+ list = [];
+ }
+ return this;
+ },
+ disable: function () {
+ locked = queue = [];
+ list = memory = '';
+ return this;
+ },
+ disabled: function () {
+ return !list;
+ },
+ lock: function () {
+ locked = queue = [];
+ if (!memory) {
+ list = memory = '';
+ }
+ return this;
+ },
+ locked: function () {
+ return !!locked;
+ },
+ fireWith: function (context, args) {
+ if (!locked) {
+ args = args || [];
+ args = [
+ context,
+ args.slice ? args.slice() : args
+ ];
+ queue.push(args);
+ if (!firing) {
+ fire();
+ }
+ }
+ return this;
+ },
+ fire: function () {
+ self.fireWith(this, arguments);
+ return this;
+ },
+ fired: function () {
+ return !!fired;
+ }
+ };
+ return self;
+ };
+ jQuery.extend({
+ Deferred: function (func) {
+ var tuples = [
+ [
+ 'resolve',
+ 'done',
+ jQuery.Callbacks('once memory'),
+ 'resolved'
+ ],
+ [
+ 'reject',
+ 'fail',
+ jQuery.Callbacks('once memory'),
+ 'rejected'
+ ],
+ [
+ 'notify',
+ 'progress',
+ jQuery.Callbacks('memory')
+ ]
+ ], state = 'pending', promise = {
+ state: function () {
+ return state;
+ },
+ always: function () {
+ deferred.done(arguments).fail(arguments);
+ return this;
+ },
+ then: function () {
+ var fns = arguments;
+ return jQuery.Deferred(function (newDefer) {
+ jQuery.each(tuples, function (i, tuple) {
+ var fn = jQuery.isFunction(fns[i]) && fns[i];
+ deferred[tuple[1]](function () {
+ var returned = fn && fn.apply(this, arguments);
+ if (returned && jQuery.isFunction(returned.promise)) {
+ returned.promise().progress(newDefer.notify).done(newDefer.resolve).fail(newDefer.reject);
+ } else {
+ newDefer[tuple[0] + 'With'](this === promise ? newDefer.promise() : this, fn ? [returned] : arguments);
+ }
+ });
+ });
+ fns = null;
+ }).promise();
+ },
+ promise: function (obj) {
+ return obj != null ? jQuery.extend(obj, promise) : promise;
+ }
+ }, deferred = {};
+ promise.pipe = promise.then;
+ jQuery.each(tuples, function (i, tuple) {
+ var list = tuple[2], stateString = tuple[3];
+ promise[tuple[1]] = list.add;
+ if (stateString) {
+ list.add(function () {
+ state = stateString;
+ }, tuples[i ^ 1][2].disable, tuples[2][2].lock);
+ }
+ deferred[tuple[0]] = function () {
+ deferred[tuple[0] + 'With'](this === deferred ? promise : this, arguments);
+ return this;
+ };
+ deferred[tuple[0] + 'With'] = list.fireWith;
+ });
+ promise.promise(deferred);
+ if (func) {
+ func.call(deferred, deferred);
+ }
+ return deferred;
+ },
+ when: function (subordinate) {
+ var i = 0, resolveValues = slice.call(arguments), length = resolveValues.length, remaining = length !== 1 || subordinate && jQuery.isFunction(subordinate.promise) ? length : 0, deferred = remaining === 1 ? subordinate : jQuery.Deferred(), updateFunc = function (i, contexts, values) {
+ return function (value) {
+ contexts[i] = this;
+ values[i] = arguments.length > 1 ? slice.call(arguments) : value;
+ if (values === progressValues) {
+ deferred.notifyWith(contexts, values);
+ } else if (!--remaining) {
+ deferred.resolveWith(contexts, values);
+ }
+ };
+ }, progressValues, progressContexts, resolveContexts;
+ if (length > 1) {
+ progressValues = new Array(length);
+ progressContexts = new Array(length);
+ resolveContexts = new Array(length);
+ for (; i < length; i++) {
+ if (resolveValues[i] && jQuery.isFunction(resolveValues[i].promise)) {
+ resolveValues[i].promise().progress(updateFunc(i, progressContexts, progressValues)).done(updateFunc(i, resolveContexts, resolveValues)).fail(deferred.reject);
+ } else {
+ --remaining;
+ }
+ }
+ }
+ if (!remaining) {
+ deferred.resolveWith(resolveContexts, resolveValues);
+ }
+ return deferred.promise();
+ }
+ });
+ var readyList;
+ jQuery.fn.ready = function (fn) {
+ jQuery.ready.promise().done(fn);
+ return this;
+ };
+ jQuery.extend({
+ isReady: false,
+ readyWait: 1,
+ holdReady: function (hold) {
+ if (hold) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready(true);
+ }
+ },
+ ready: function (wait) {
+ if (wait === true ? --jQuery.readyWait : jQuery.isReady) {
+ return;
+ }
+ jQuery.isReady = true;
+ if (wait !== true && --jQuery.readyWait > 0) {
+ return;
+ }
+ readyList.resolveWith(document, [jQuery]);
+ if (jQuery.fn.triggerHandler) {
+ jQuery(document).triggerHandler('ready');
+ jQuery(document).off('ready');
+ }
+ }
+ });
+ function completed() {
+ document.removeEventListener('DOMContentLoaded', completed);
+ window.removeEventListener('load', completed);
+ jQuery.ready();
+ }
+ jQuery.ready.promise = function (obj) {
+ if (!readyList) {
+ readyList = jQuery.Deferred();
+ if (document.readyState === 'complete' || document.readyState !== 'loading' && !document.documentElement.doScroll) {
+ window.setTimeout(jQuery.ready);
+ } else {
+ document.addEventListener('DOMContentLoaded', completed);
+ window.addEventListener('load', completed);
+ }
+ }
+ return readyList.promise(obj);
+ };
+ jQuery.ready.promise();
+ var access = function (elems, fn, key, value, chainable, emptyGet, raw) {
+ var i = 0, len = elems.length, bulk = key == null;
+ if (jQuery.type(key) === 'object') {
+ chainable = true;
+ for (i in key) {
+ access(elems, fn, i, key[i], true, emptyGet, raw);
+ }
+ } else if (value !== undefined) {
+ chainable = true;
+ if (!jQuery.isFunction(value)) {
+ raw = true;
+ }
+ if (bulk) {
+ if (raw) {
+ fn.call(elems, value);
+ fn = null;
+ } else {
+ bulk = fn;
+ fn = function (elem, key, value) {
+ return bulk.call(jQuery(elem), value);
+ };
+ }
+ }
+ if (fn) {
+ for (; i < len; i++) {
+ fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key)));
+ }
+ }
+ }
+ return chainable ? elems : bulk ? fn.call(elems) : len ? fn(elems[0], key) : emptyGet;
+ };
+ var acceptData = function (owner) {
+ return owner.nodeType === 1 || owner.nodeType === 9 || !+owner.nodeType;
+ };
+ function Data() {
+ this.expando = jQuery.expando + Data.uid++;
+ }
+ Data.uid = 1;
+ Data.prototype = {
+ register: function (owner, initial) {
+ var value = initial || {};
+ if (owner.nodeType) {
+ owner[this.expando] = value;
+ } else {
+ Object.defineProperty(owner, this.expando, {
+ value: value,
+ writable: true,
+ configurable: true
+ });
+ }
+ return owner[this.expando];
+ },
+ cache: function (owner) {
+ if (!acceptData(owner)) {
+ return {};
+ }
+ var value = owner[this.expando];
+ if (!value) {
+ value = {};
+ if (acceptData(owner)) {
+ if (owner.nodeType) {
+ owner[this.expando] = value;
+ } else {
+ Object.defineProperty(owner, this.expando, {
+ value: value,
+ configurable: true
+ });
+ }
+ }
+ }
+ return value;
+ },
+ set: function (owner, data, value) {
+ var prop, cache = this.cache(owner);
+ if (typeof data === 'string') {
+ cache[data] = value;
+ } else {
+ for (prop in data) {
+ cache[prop] = data[prop];
+ }
+ }
+ return cache;
+ },
+ get: function (owner, key) {
+ return key === undefined ? this.cache(owner) : owner[this.expando] && owner[this.expando][key];
+ },
+ access: function (owner, key, value) {
+ var stored;
+ if (key === undefined || key && typeof key === 'string' && value === undefined) {
+ stored = this.get(owner, key);
+ return stored !== undefined ? stored : this.get(owner, jQuery.camelCase(key));
+ }
+ this.set(owner, key, value);
+ return value !== undefined ? value : key;
+ },
+ remove: function (owner, key) {
+ var i, name, camel, cache = owner[this.expando];
+ if (cache === undefined) {
+ return;
+ }
+ if (key === undefined) {
+ this.register(owner);
+ } else {
+ if (jQuery.isArray(key)) {
+ name = key.concat(key.map(jQuery.camelCase));
+ } else {
+ camel = jQuery.camelCase(key);
+ if (key in cache) {
+ name = [
+ key,
+ camel
+ ];
+ } else {
+ name = camel;
+ name = name in cache ? [name] : name.match(rnotwhite) || [];
+ }
+ }
+ i = name.length;
+ while (i--) {
+ delete cache[name[i]];
+ }
+ }
+ if (key === undefined || jQuery.isEmptyObject(cache)) {
+ if (owner.nodeType) {
+ owner[this.expando] = undefined;
+ } else {
+ delete owner[this.expando];
+ }
+ }
+ },
+ hasData: function (owner) {
+ var cache = owner[this.expando];
+ return cache !== undefined && !jQuery.isEmptyObject(cache);
+ }
+ };
+ var dataPriv = new Data();
+ var dataUser = new Data();
+ var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, rmultiDash = /[A-Z]/g;
+ function dataAttr(elem, key, data) {
+ var name;
+ if (data === undefined && elem.nodeType === 1) {
+ name = 'data-' + key.replace(rmultiDash, '-$&').toLowerCase();
+ data = elem.getAttribute(name);
+ if (typeof data === 'string') {
+ try {
+ data = data === 'true' ? true : data === 'false' ? false : data === 'null' ? null : +data + '' === data ? +data : rbrace.test(data) ? jQuery.parseJSON(data) : data;
+ } catch (e) {
+ }
+ dataUser.set(elem, key, data);
+ } else {
+ data = undefined;
+ }
+ }
+ return data;
+ }
+ jQuery.extend({
+ hasData: function (elem) {
+ return dataUser.hasData(elem) || dataPriv.hasData(elem);
+ },
+ data: function (elem, name, data) {
+ return dataUser.access(elem, name, data);
+ },
+ removeData: function (elem, name) {
+ dataUser.remove(elem, name);
+ },
+ _data: function (elem, name, data) {
+ return dataPriv.access(elem, name, data);
+ },
+ _removeData: function (elem, name) {
+ dataPriv.remove(elem, name);
+ }
+ });
+ jQuery.fn.extend({
+ data: function (key, value) {
+ var i, name, data, elem = this[0], attrs = elem && elem.attributes;
+ if (key === undefined) {
+ if (this.length) {
+ data = dataUser.get(elem);
+ if (elem.nodeType === 1 && !dataPriv.get(elem, 'hasDataAttrs')) {
+ i = attrs.length;
+ while (i--) {
+ if (attrs[i]) {
+ name = attrs[i].name;
+ if (name.indexOf('data-') === 0) {
+ name = jQuery.camelCase(name.slice(5));
+ dataAttr(elem, name, data[name]);
+ }
+ }
+ }
+ dataPriv.set(elem, 'hasDataAttrs', true);
+ }
+ }
+ return data;
+ }
+ if (typeof key === 'object') {
+ return this.each(function () {
+ dataUser.set(this, key);
+ });
+ }
+ return access(this, function (value) {
+ var data, camelKey;
+ if (elem && value === undefined) {
+ data = dataUser.get(elem, key) || dataUser.get(elem, key.replace(rmultiDash, '-$&').toLowerCase());
+ if (data !== undefined) {
+ return data;
+ }
+ camelKey = jQuery.camelCase(key);
+ data = dataUser.get(elem, camelKey);
+ if (data !== undefined) {
+ return data;
+ }
+ data = dataAttr(elem, camelKey, undefined);
+ if (data !== undefined) {
+ return data;
+ }
+ return;
+ }
+ camelKey = jQuery.camelCase(key);
+ this.each(function () {
+ var data = dataUser.get(this, camelKey);
+ dataUser.set(this, camelKey, value);
+ if (key.indexOf('-') > -1 && data !== undefined) {
+ dataUser.set(this, key, value);
+ }
+ });
+ }, null, value, arguments.length > 1, null, true);
+ },
+ removeData: function (key) {
+ return this.each(function () {
+ dataUser.remove(this, key);
+ });
+ }
+ });
+ jQuery.extend({
+ queue: function (elem, type, data) {
+ var queue;
+ if (elem) {
+ type = (type || 'fx') + 'queue';
+ queue = dataPriv.get(elem, type);
+ if (data) {
+ if (!queue || jQuery.isArray(data)) {
+ queue = dataPriv.access(elem, type, jQuery.makeArray(data));
+ } else {
+ queue.push(data);
+ }
+ }
+ return queue || [];
+ }
+ },
+ dequeue: function (elem, type) {
+ type = type || 'fx';
+ var queue = jQuery.queue(elem, type), startLength = queue.length, fn = queue.shift(), hooks = jQuery._queueHooks(elem, type), next = function () {
+ jQuery.dequeue(elem, type);
+ };
+ if (fn === 'inprogress') {
+ fn = queue.shift();
+ startLength--;
+ }
+ if (fn) {
+ if (type === 'fx') {
+ queue.unshift('inprogress');
+ }
+ delete hooks.stop;
+ fn.call(elem, next, hooks);
+ }
+ if (!startLength && hooks) {
+ hooks.empty.fire();
+ }
+ },
+ _queueHooks: function (elem, type) {
+ var key = type + 'queueHooks';
+ return dataPriv.get(elem, key) || dataPriv.access(elem, key, {
+ empty: jQuery.Callbacks('once memory').add(function () {
+ dataPriv.remove(elem, [
+ type + 'queue',
+ key
+ ]);
+ })
+ });
+ }
+ });
+ jQuery.fn.extend({
+ queue: function (type, data) {
+ var setter = 2;
+ if (typeof type !== 'string') {
+ data = type;
+ type = 'fx';
+ setter--;
+ }
+ if (arguments.length < setter) {
+ return jQuery.queue(this[0], type);
+ }
+ return data === undefined ? this : this.each(function () {
+ var queue = jQuery.queue(this, type, data);
+ jQuery._queueHooks(this, type);
+ if (type === 'fx' && queue[0] !== 'inprogress') {
+ jQuery.dequeue(this, type);
+ }
+ });
+ },
+ dequeue: function (type) {
+ return this.each(function () {
+ jQuery.dequeue(this, type);
+ });
+ },
+ clearQueue: function (type) {
+ return this.queue(type || 'fx', []);
+ },
+ promise: function (type, obj) {
+ var tmp, count = 1, defer = jQuery.Deferred(), elements = this, i = this.length, resolve = function () {
+ if (!--count) {
+ defer.resolveWith(elements, [elements]);
+ }
+ };
+ if (typeof type !== 'string') {
+ obj = type;
+ type = undefined;
+ }
+ type = type || 'fx';
+ while (i--) {
+ tmp = dataPriv.get(elements[i], type + 'queueHooks');
+ if (tmp && tmp.empty) {
+ count++;
+ tmp.empty.add(resolve);
+ }
+ }
+ resolve();
+ return defer.promise(obj);
+ }
+ });
+ var pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source;
+ var rcssNum = new RegExp('^(?:([+-])=|)(' + pnum + ')([a-z%]*)$', 'i');
+ var cssExpand = [
+ 'Top',
+ 'Right',
+ 'Bottom',
+ 'Left'
+ ];
+ var isHidden = function (elem, el) {
+ elem = el || elem;
+ return jQuery.css(elem, 'display') === 'none' || !jQuery.contains(elem.ownerDocument, elem);
+ };
+ function adjustCSS(elem, prop, valueParts, tween) {
+ var adjusted, scale = 1, maxIterations = 20, currentValue = tween ? function () {
+ return tween.cur();
+ } : function () {
+ return jQuery.css(elem, prop, '');
+ }, initial = currentValue(), unit = valueParts && valueParts[3] || (jQuery.cssNumber[prop] ? '' : 'px'), initialInUnit = (jQuery.cssNumber[prop] || unit !== 'px' && +initial) && rcssNum.exec(jQuery.css(elem, prop));
+ if (initialInUnit && initialInUnit[3] !== unit) {
+ unit = unit || initialInUnit[3];
+ valueParts = valueParts || [];
+ initialInUnit = +initial || 1;
+ do {
+ scale = scale || '.5';
+ initialInUnit = initialInUnit / scale;
+ jQuery.style(elem, prop, initialInUnit + unit);
+ } while (scale !== (scale = currentValue() / initial) && scale !== 1 && --maxIterations);
+ }
+ if (valueParts) {
+ initialInUnit = +initialInUnit || +initial || 0;
+ adjusted = valueParts[1] ? initialInUnit + (valueParts[1] + 1) * valueParts[2] : +valueParts[2];
+ if (tween) {
+ tween.unit = unit;
+ tween.start = initialInUnit;
+ tween.end = adjusted;
+ }
+ }
+ return adjusted;
+ }
+ var rcheckableType = /^(?:checkbox|radio)$/i;
+ var rtagName = /<([\w:-]+)/;
+ var rscriptType = /^$|\/(?:java|ecma)script/i;
+ var wrapMap = {
+ option: [
+ 1,
+ '',
+ ' '
+ ],
+ thead: [
+ 1,
+ ''
+ ],
+ col: [
+ 2,
+ ''
+ ],
+ tr: [
+ 2,
+ ''
+ ],
+ td: [
+ 3,
+ ''
+ ],
+ _default: [
+ 0,
+ '',
+ ''
+ ]
+ };
+ wrapMap.optgroup = wrapMap.option;
+ wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+ wrapMap.th = wrapMap.td;
+ function getAll(context, tag) {
+ var ret = typeof context.getElementsByTagName !== 'undefined' ? context.getElementsByTagName(tag || '*') : typeof context.querySelectorAll !== 'undefined' ? context.querySelectorAll(tag || '*') : [];
+ return tag === undefined || tag && jQuery.nodeName(context, tag) ? jQuery.merge([context], ret) : ret;
+ }
+ function setGlobalEval(elems, refElements) {
+ var i = 0, l = elems.length;
+ for (; i < l; i++) {
+ dataPriv.set(elems[i], 'globalEval', !refElements || dataPriv.get(refElements[i], 'globalEval'));
+ }
+ }
+ var rhtml = /<|?\w+;/;
+ function buildFragment(elems, context, scripts, selection, ignored) {
+ var elem, tmp, tag, wrap, contains, j, fragment = context.createDocumentFragment(), nodes = [], i = 0, l = elems.length;
+ for (; i < l; i++) {
+ elem = elems[i];
+ if (elem || elem === 0) {
+ if (jQuery.type(elem) === 'object') {
+ jQuery.merge(nodes, elem.nodeType ? [elem] : elem);
+ } else if (!rhtml.test(elem)) {
+ nodes.push(context.createTextNode(elem));
+ } else {
+ tmp = tmp || fragment.appendChild(context.createElement('div'));
+ tag = (rtagName.exec(elem) || [
+ '',
+ ''
+ ])[1].toLowerCase();
+ wrap = wrapMap[tag] || wrapMap._default;
+ tmp.innerHTML = wrap[1] + jQuery.htmlPrefilter(elem) + wrap[2];
+ j = wrap[0];
+ while (j--) {
+ tmp = tmp.lastChild;
+ }
+ jQuery.merge(nodes, tmp.childNodes);
+ tmp = fragment.firstChild;
+ tmp.textContent = '';
+ }
+ }
+ }
+ fragment.textContent = '';
+ i = 0;
+ while (elem = nodes[i++]) {
+ if (selection && jQuery.inArray(elem, selection) > -1) {
+ if (ignored) {
+ ignored.push(elem);
+ }
+ continue;
+ }
+ contains = jQuery.contains(elem.ownerDocument, elem);
+ tmp = getAll(fragment.appendChild(elem), 'script');
+ if (contains) {
+ setGlobalEval(tmp);
+ }
+ if (scripts) {
+ j = 0;
+ while (elem = tmp[j++]) {
+ if (rscriptType.test(elem.type || '')) {
+ scripts.push(elem);
+ }
+ }
+ }
+ }
+ return fragment;
+ }
+ (function () {
+ var fragment = document.createDocumentFragment(), div = fragment.appendChild(document.createElement('div')), input = document.createElement('input');
+ input.setAttribute('type', 'radio');
+ input.setAttribute('checked', 'checked');
+ input.setAttribute('name', 't');
+ div.appendChild(input);
+ support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked;
+ div.innerHTML = '';
+ support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
+ }());
+ var rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
+ function returnTrue() {
+ return true;
+ }
+ function returnFalse() {
+ return false;
+ }
+ function safeActiveElement() {
+ try {
+ return document.activeElement;
+ } catch (err) {
+ }
+ }
+ function on(elem, types, selector, data, fn, one) {
+ var origFn, type;
+ if (typeof types === 'object') {
+ if (typeof selector !== 'string') {
+ data = data || selector;
+ selector = undefined;
+ }
+ for (type in types) {
+ on(elem, type, selector, data, types[type], one);
+ }
+ return elem;
+ }
+ if (data == null && fn == null) {
+ fn = selector;
+ data = selector = undefined;
+ } else if (fn == null) {
+ if (typeof selector === 'string') {
+ fn = data;
+ data = undefined;
+ } else {
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if (fn === false) {
+ fn = returnFalse;
+ } else if (!fn) {
+ return elem;
+ }
+ if (one === 1) {
+ origFn = fn;
+ fn = function (event) {
+ jQuery().off(event);
+ return origFn.apply(this, arguments);
+ };
+ fn.guid = origFn.guid || (origFn.guid = jQuery.guid++);
+ }
+ return elem.each(function () {
+ jQuery.event.add(this, types, fn, data, selector);
+ });
+ }
+ jQuery.event = {
+ global: {},
+ add: function (elem, types, handler, data, selector) {
+ var handleObjIn, eventHandle, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = dataPriv.get(elem);
+ if (!elemData) {
+ return;
+ }
+ if (handler.handler) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+ if (!handler.guid) {
+ handler.guid = jQuery.guid++;
+ }
+ if (!(events = elemData.events)) {
+ events = elemData.events = {};
+ }
+ if (!(eventHandle = elemData.handle)) {
+ eventHandle = elemData.handle = function (e) {
+ return typeof jQuery !== 'undefined' && jQuery.event.triggered !== e.type ? jQuery.event.dispatch.apply(elem, arguments) : undefined;
+ };
+ }
+ types = (types || '').match(rnotwhite) || [''];
+ t = types.length;
+ while (t--) {
+ tmp = rtypenamespace.exec(types[t]) || [];
+ type = origType = tmp[1];
+ namespaces = (tmp[2] || '').split('.').sort();
+ if (!type) {
+ continue;
+ }
+ special = jQuery.event.special[type] || {};
+ type = (selector ? special.delegateType : special.bindType) || type;
+ special = jQuery.event.special[type] || {};
+ handleObj = jQuery.extend({
+ type: type,
+ origType: origType,
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test(selector),
+ namespace: namespaces.join('.')
+ }, handleObjIn);
+ if (!(handlers = events[type])) {
+ handlers = events[type] = [];
+ handlers.delegateCount = 0;
+ if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
+ if (elem.addEventListener) {
+ elem.addEventListener(type, eventHandle);
+ }
+ }
+ }
+ if (special.add) {
+ special.add.call(elem, handleObj);
+ if (!handleObj.handler.guid) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+ if (selector) {
+ handlers.splice(handlers.delegateCount++, 0, handleObj);
+ } else {
+ handlers.push(handleObj);
+ }
+ jQuery.event.global[type] = true;
+ }
+ },
+ remove: function (elem, types, handler, selector, mappedTypes) {
+ var j, origCount, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = dataPriv.hasData(elem) && dataPriv.get(elem);
+ if (!elemData || !(events = elemData.events)) {
+ return;
+ }
+ types = (types || '').match(rnotwhite) || [''];
+ t = types.length;
+ while (t--) {
+ tmp = rtypenamespace.exec(types[t]) || [];
+ type = origType = tmp[1];
+ namespaces = (tmp[2] || '').split('.').sort();
+ if (!type) {
+ for (type in events) {
+ jQuery.event.remove(elem, type + types[t], handler, selector, true);
+ }
+ continue;
+ }
+ special = jQuery.event.special[type] || {};
+ type = (selector ? special.delegateType : special.bindType) || type;
+ handlers = events[type] || [];
+ tmp = tmp[2] && new RegExp('(^|\\.)' + namespaces.join('\\.(?:.*\\.|)') + '(\\.|$)');
+ origCount = j = handlers.length;
+ while (j--) {
+ handleObj = handlers[j];
+ if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === '**' && handleObj.selector)) {
+ handlers.splice(j, 1);
+ if (handleObj.selector) {
+ handlers.delegateCount--;
+ }
+ if (special.remove) {
+ special.remove.call(elem, handleObj);
+ }
+ }
+ }
+ if (origCount && !handlers.length) {
+ if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) {
+ jQuery.removeEvent(elem, type, elemData.handle);
+ }
+ delete events[type];
+ }
+ }
+ if (jQuery.isEmptyObject(events)) {
+ dataPriv.remove(elem, 'handle events');
+ }
+ },
+ dispatch: function (event) {
+ event = jQuery.event.fix(event);
+ var i, j, ret, matched, handleObj, handlerQueue = [], args = slice.call(arguments), handlers = (dataPriv.get(this, 'events') || {})[event.type] || [], special = jQuery.event.special[event.type] || {};
+ args[0] = event;
+ event.delegateTarget = this;
+ if (special.preDispatch && special.preDispatch.call(this, event) === false) {
+ return;
+ }
+ handlerQueue = jQuery.event.handlers.call(this, event, handlers);
+ i = 0;
+ while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
+ event.currentTarget = matched.elem;
+ j = 0;
+ while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) {
+ if (!event.rnamespace || event.rnamespace.test(handleObj.namespace)) {
+ event.handleObj = handleObj;
+ event.data = handleObj.data;
+ ret = ((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args);
+ if (ret !== undefined) {
+ if ((event.result = ret) === false) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+ if (special.postDispatch) {
+ special.postDispatch.call(this, event);
+ }
+ return event.result;
+ },
+ handlers: function (event, handlers) {
+ var i, matches, sel, handleObj, handlerQueue = [], delegateCount = handlers.delegateCount, cur = event.target;
+ if (delegateCount && cur.nodeType && (event.type !== 'click' || isNaN(event.button) || event.button < 1)) {
+ for (; cur !== this; cur = cur.parentNode || this) {
+ if (cur.nodeType === 1 && (cur.disabled !== true || event.type !== 'click')) {
+ matches = [];
+ for (i = 0; i < delegateCount; i++) {
+ handleObj = handlers[i];
+ sel = handleObj.selector + ' ';
+ if (matches[sel] === undefined) {
+ matches[sel] = handleObj.needsContext ? jQuery(sel, this).index(cur) > -1 : jQuery.find(sel, this, null, [cur]).length;
+ }
+ if (matches[sel]) {
+ matches.push(handleObj);
+ }
+ }
+ if (matches.length) {
+ handlerQueue.push({
+ elem: cur,
+ handlers: matches
+ });
+ }
+ }
+ }
+ }
+ if (delegateCount < handlers.length) {
+ handlerQueue.push({
+ elem: this,
+ handlers: handlers.slice(delegateCount)
+ });
+ }
+ return handlerQueue;
+ },
+ props: ('altKey bubbles cancelable ctrlKey currentTarget detail eventPhase ' + 'metaKey relatedTarget shiftKey target timeStamp view which').split(' '),
+ fixHooks: {},
+ keyHooks: {
+ props: 'char charCode key keyCode'.split(' '),
+ filter: function (event, original) {
+ if (event.which == null) {
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
+ }
+ return event;
+ }
+ },
+ mouseHooks: {
+ props: ('button buttons clientX clientY offsetX offsetY pageX pageY ' + 'screenX screenY toElement').split(' '),
+ filter: function (event, original) {
+ var eventDoc, doc, body, button = original.button;
+ if (event.pageX == null && original.clientX != null) {
+ eventDoc = event.target.ownerDocument || document;
+ doc = eventDoc.documentElement;
+ body = eventDoc.body;
+ event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+ if (!event.which && button !== undefined) {
+ event.which = button & 1 ? 1 : button & 2 ? 3 : button & 4 ? 2 : 0;
+ }
+ return event;
+ }
+ },
+ fix: function (event) {
+ if (event[jQuery.expando]) {
+ return event;
+ }
+ var i, prop, copy, type = event.type, originalEvent = event, fixHook = this.fixHooks[type];
+ if (!fixHook) {
+ this.fixHooks[type] = fixHook = rmouseEvent.test(type) ? this.mouseHooks : rkeyEvent.test(type) ? this.keyHooks : {};
+ }
+ copy = fixHook.props ? this.props.concat(fixHook.props) : this.props;
+ event = new jQuery.Event(originalEvent);
+ i = copy.length;
+ while (i--) {
+ prop = copy[i];
+ event[prop] = originalEvent[prop];
+ }
+ if (!event.target) {
+ event.target = document;
+ }
+ if (event.target.nodeType === 3) {
+ event.target = event.target.parentNode;
+ }
+ return fixHook.filter ? fixHook.filter(event, originalEvent) : event;
+ },
+ special: {
+ load: { noBubble: true },
+ focus: {
+ trigger: function () {
+ if (this !== safeActiveElement() && this.focus) {
+ this.focus();
+ return false;
+ }
+ },
+ delegateType: 'focusin'
+ },
+ blur: {
+ trigger: function () {
+ if (this === safeActiveElement() && this.blur) {
+ this.blur();
+ return false;
+ }
+ },
+ delegateType: 'focusout'
+ },
+ click: {
+ trigger: function () {
+ if (this.type === 'checkbox' && this.click && jQuery.nodeName(this, 'input')) {
+ this.click();
+ return false;
+ }
+ },
+ _default: function (event) {
+ return jQuery.nodeName(event.target, 'a');
+ }
+ },
+ beforeunload: {
+ postDispatch: function (event) {
+ if (event.result !== undefined && event.originalEvent) {
+ event.originalEvent.returnValue = event.result;
+ }
+ }
+ }
+ }
+ };
+ jQuery.removeEvent = function (elem, type, handle) {
+ if (elem.removeEventListener) {
+ elem.removeEventListener(type, handle);
+ }
+ };
+ jQuery.Event = function (src, props) {
+ if (!(this instanceof jQuery.Event)) {
+ return new jQuery.Event(src, props);
+ }
+ if (src && src.type) {
+ this.originalEvent = src;
+ this.type = src.type;
+ this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined && src.returnValue === false ? returnTrue : returnFalse;
+ } else {
+ this.type = src;
+ }
+ if (props) {
+ jQuery.extend(this, props);
+ }
+ this.timeStamp = src && src.timeStamp || jQuery.now();
+ this[jQuery.expando] = true;
+ };
+ jQuery.Event.prototype = {
+ constructor: jQuery.Event,
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse,
+ isSimulated: false,
+ preventDefault: function () {
+ var e = this.originalEvent;
+ this.isDefaultPrevented = returnTrue;
+ if (e && !this.isSimulated) {
+ e.preventDefault();
+ }
+ },
+ stopPropagation: function () {
+ var e = this.originalEvent;
+ this.isPropagationStopped = returnTrue;
+ if (e && !this.isSimulated) {
+ e.stopPropagation();
+ }
+ },
+ stopImmediatePropagation: function () {
+ var e = this.originalEvent;
+ this.isImmediatePropagationStopped = returnTrue;
+ if (e && !this.isSimulated) {
+ e.stopImmediatePropagation();
+ }
+ this.stopPropagation();
+ }
+ };
+ jQuery.each({
+ mouseenter: 'mouseover',
+ mouseleave: 'mouseout',
+ pointerenter: 'pointerover',
+ pointerleave: 'pointerout'
+ }, function (orig, fix) {
+ jQuery.event.special[orig] = {
+ delegateType: fix,
+ bindType: fix,
+ handle: function (event) {
+ var ret, target = this, related = event.relatedTarget, handleObj = event.handleObj;
+ if (!related || related !== target && !jQuery.contains(target, related)) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply(this, arguments);
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+ });
+ jQuery.fn.extend({
+ on: function (types, selector, data, fn) {
+ return on(this, types, selector, data, fn);
+ },
+ one: function (types, selector, data, fn) {
+ return on(this, types, selector, data, fn, 1);
+ },
+ off: function (types, selector, fn) {
+ var handleObj, type;
+ if (types && types.preventDefault && types.handleObj) {
+ handleObj = types.handleObj;
+ jQuery(types.delegateTarget).off(handleObj.namespace ? handleObj.origType + '.' + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler);
+ return this;
+ }
+ if (typeof types === 'object') {
+ for (type in types) {
+ this.off(type, selector, types[type]);
+ }
+ return this;
+ }
+ if (selector === false || typeof selector === 'function') {
+ fn = selector;
+ selector = undefined;
+ }
+ if (fn === false) {
+ fn = returnFalse;
+ }
+ return this.each(function () {
+ jQuery.event.remove(this, types, fn, selector);
+ });
+ }
+ });
+ var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, rnoInnerhtml = /')}}else{var es6ModuleLoader=require("steal-es6-module-loader");$__global.System=es6ModuleLoader.System,$__global.Loader=es6ModuleLoader.Loader,$__global.upgradeSystemLoader(),module.exports=$__global.System;var vm=require("vm");doEval=function(a,b,c){vm.runInThisContext(a)}}}()}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:global),function(a){function b(a){function c(a){function b(){for(var b,c=[],e=0;ec;c++)b.call(a[c],a[c],c,a);else for(c in a)a.hasOwnProperty(c)&&b.call(a[c],a[c],c,a);return a},e=function(a,b){var c=[];return d(a,function(a,d){c[d]=b(a,d)}),c},f=function(a){return"string"==typeof a},g=function(a,b){return d(b,function(b,c){a[c]=b}),a},h=function(a){var b=a.lastIndexOf("/");return-1===b&&(b=a.lastIndexOf("\\")),-1!==b?a.substr(0,b):a},i=function(a){return a[a.length-1]},j=function(a){var b=String(a).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return b?{href:b[0]||"",protocol:b[1]||"",authority:b[2]||"",host:b[3]||"",hostname:b[4]||"",port:b[5]||"",pathname:b[6]||"",search:b[7]||"",hash:b[8]||""}:null},k=function(a,b){function c(a){var b=[];return a.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(a){"/.."===a?b.pop():b.push(a)}),b.join("").replace(/^\//,"/"===a.charAt(0)?"/":"")}return b=j(b||""),a=j(a||""),b&&a?(b.protocol||a.protocol)+(b.protocol||b.authority?b.authority:a.authority)+c(b.protocol||b.authority||"/"===b.pathname.charAt(0)?b.pathname:b.pathname?(a.authority&&!a.pathname?"/":"")+a.pathname.slice(0,a.pathname.lastIndexOf("/")+1)+b.pathname:a.pathname)+(b.protocol||b.authority||b.pathname?b.search:b.search||a.search)+b.hash:null},l=function(a,b){for(var c=b.split("/"),d=a.split("/"),e=[];c.length&&d.length&&c[0]==d[0];)c.shift(),d.shift();for(var f=0;fb.index)return!0;return!1}function c(c){for(;d=c.exec(a);)if(!b(f,d)&&!b(g,d)){var h=d[1];e.push(h)}}i.lastIndex=k.lastIndex=j.lastIndex=l.lastIndex=0;var d,e=[],f=[],g=[];if(a.length/a.split("\n").length<200){for(;d=l.exec(a);)f.push([d.index,d.index+d[0].length]);for(;d=k.exec(a);)b(f,d)||g.push([d.index,d.index+d[0].length])}return c(i),c(j),e}a._extensions&&a._extensions.push(n),a._traceData={loads:{},parentMap:{}},a.getDependencies=function(a){var b=this.getModuleLoad(a);return b?b.metadata.dependencies:void 0},a.getDependants=function(a){var c=[],d=this._traceData.parentMap[a]||{};return b(d,function(a){c.push(a)}),c},a.getModuleLoad=function(a){return this._traceData.loads[a]},a.getBundles=function(a,c){c=c||{},c[a]=!0;var d=this,e=d._traceData.parentMap,f=e[a];if(!f)return[a];var g=[];return b(f,function(a,b){c[a]||(g=g.concat(d.getBundles(a,c)))}),g},a._allowModuleExecution={},a.allowModuleExecution=function(a){var b=this;return b.normalize(a).then(function(a){b._allowModuleExecution[a]=!0})};var d=a.normalize;a.normalize=function(a,b){var c=d.apply(this,arguments);if(b){var e=this._traceData.parentMap;return c.then(function(a){return e[a]||(e[a]={}),e[a][b]=!0,a})}return c};var e=function(){return a.newModule({})},f={traceur:!0,babel:!0},g=function(a){return f[a.name]||this._allowModuleExecution[a.name]},h=[].map||function(a){for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c]));return b},i=/import [\s\S]*?["'](.+)["']/g,j=/export .+ from ["'](.+)["']/g,k=/(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,l=/(?:("|')[^\1\\\n\r]*(?:\\.[^\1\\\n\r]*)*\1|`[^`]*`)/g,m=a.instantiate;a.instantiate=function(a){function b(b){var c=d.preventModuleExecution&&!g.call(d,a),f=b?b.deps:a.metadata.deps;return Promise.all(h.call(f,function(b){return d.normalize(b,a.name)})).then(function(d){return a.metadata.deps=f,a.metadata.dependencies=d,c?{deps:f,execute:e}:b})}this._traceData.loads[a.name]=a;var d=this,f=Promise.resolve(m.apply(this,arguments));return f.then(function(d){if(!d){var e=c(a.source);a.metadata.deps=e}return b(d)})};var o=a.transpile;a.transpile=function(a){var b=a.metadata.transpiledSource;return b?(delete a.metadata.transpiledSource,Promise.resolve(b)):o.apply(this,arguments)},a.eachModule=function(a){for(var b in this._loader.modules)a.call(this,b,this.get(b))}}function p(a){function b(a){if(("json"===a.metadata.format||!a.metadata.format)&&c.test(a.source))try{return JSON.parse(a.source)}catch(b){}}var c=/^[\s\n\r]*[\{\[]/,d=/\.json$/i,e=/\.js$/i,f="undefined"==typeof window;a._extensions.push(p);var g=a.locate;a.locate=function(a){return g.apply(this,arguments).then(function(b){return d.test(a.name)?b.replace(e,""):b})};var h=function(a,b,c){var d=a.jsonOptions&&a.jsonOptions.transform;return d?d.call(a,b,c):c};if(f){var i=a.translate;return void(a.translate=function(a){if(d.test(a.name)){var c=b(a);if(c)return c=h(this,a,c),"define([], function(){\n return "+JSON.stringify(c)+"\n});"}return i.call(this,a)})}var j=a.instantiate;return a.instantiate=function(a){var c,d=this;return c=b(a),c&&(c=h(d,a,c),a.metadata.format="json",a.metadata.execute=function(){return c}),j.call(d,a)},a}function q(a){a._extensions.push(q),a.getEnv=function(){var a=(this.env||"").split("-");return a[1]||this.env},a.getPlatform=function(){var a=(this.env||"").split("-");return 2===a.length?a[0]:void 0},a.isEnv=function(a){return this.getEnv()===a},a.isPlatform=function(a){return this.getPlatform()===a}}a.set("@loader",a.newModule({"default":a,__useDefault:!0})),a.config({map:{"@loader/@loader":"@loader","@steal/@steal":"@steal"}});var r,s,t,u=function(){var b=arguments,c=function(){var a,c=[];d(b,function(b){f(b)?c.push(u.System["import"](o(b))):"function"==typeof b&&(a=b)});var e=Promise.all(c);return a?e.then(function(b){return a&&a.apply(null,b)}):e};return a.isEnv("production")?c():r.then(c,c)};a.set("@steal",a.newModule({"default":u,__useDefault:!0})),u.System=a,u.parseURI=j,u.joinURIs=k,u.normalize=o,u.relativeURI=l;var v=function(a){a._extensions&&a._extensions.push(v),a.ext={};var b=a.normalize,c=/\.(\w+)!?$/;a.normalize=function(d,e,f,g){if(g)return b.apply(this,arguments);var h,i=d.match(c),j=d;if(i&&a.ext[h=i[1]]){var k="!"===d[d.length-1];j=d+(k?"":"!")+a.ext[h]}return b.call(this,j,e,f)}};v(a);var w=function(a){a._extensions&&a._extensions.push(w);var b=a.normalize,c=/@.+#.+/;a.normalize=function(a,d,e,f){var g,h,i=a.length-1;return"/"===a[i]&&(g=a.substring(0,i).lastIndexOf("/"),h=a.substring(g+1,i),c.test(h)&&(h=h.substr(h.lastIndexOf("#")+1)),a+=h),b.call(this,a,d,e,f)}};w(a);var x=function(a){var b=function(a,b){var c=this;return Promise.resolve(c.normalize(a,b)).then(function(a){return c.locate({name:a,metadata:{}})}).then(function(a){return".js"===a.substr(a.length-3)&&(a=a.substr(0,a.length-3)),a})},c=function(a,b){for(var c=b.split("/"),d=a.split("/"),e=[];c.length&&d.length&&c[0]==d[0];)c.shift(),d.shift();for(var f=0;fi;i++)h.push(b.call(this,g[i].name,a.name));return Promise.all(h).then(function(b){for(var d=g.length-1;d>=0;d--)a.source=a.source.substr(0,g[d].start)+g[d].postLocate(b[d])+a.source.substr(g[d].end,a.source.length);return f.call(c,a)})}};"undefined"!=typeof a&&x(a),"undefined"!=typeof a&&b(a),"undefined"!=typeof a&&n(a),"undefined"!=typeof a&&p(a);var y=function(a,b){var c=a.config;a.config=function(e){var f=g({},e);d(b,function(b,c){if(b.set&&f[c]){var d=b.set.call(a,f[c],e);void 0!==d&&(a[c]=d),delete f[c]}}),c.call(this,f)}},z=function(a,b,c){a[b]||(a[b]=c)};a.configMain="@config",a.paths[a.configMain]="stealconfig.js",a.env=(isWebWorker?"worker":"window")+"-development",a.ext={css:"$css",less:"$less"},a.logLevel=0,a.transpiler="traceur";var A="bundles/*.css",B="bundles/*";z(a.paths,A,"dist/bundles/*css"),z(a.paths,B,"dist/bundles/*.js");var C,D={set:function(b){var c=m(b),d=h(b);isNode||(a.configPath=k(location.href,b)),a.configMain=c,a.paths[c]=c,J.call(this),this.config({baseURL:(d===b?".":d)+"/"})}},E={set:function(a){this.main=a,J.call(this)}},F=function(a){return isNode&&!/^file:/.test(a)?("."===a[0]&&("/"===a[1]||"."===a[1]&&"/"===a[2])&&(a=require("path").join(process.cwd(),a)),a?"file:"+a:a):a},G=function(a){return{set:function(b){this[a]=F(b)}}},H=function(a){var b=a.lastIndexOf("!");return-1!==b?a.substr(b+1):void 0},I=function(a){var b=a.lastIndexOf("!");return-1!==b?a.substr(0,b):void 0},J=function(){if(this.loadBundles&&this.main){var b=this.main,c=this.bundlesName||"bundles/",d=c+b;z(this.meta,d,{format:"amd"
+});var e=H(a.configMain),f=[b,a.configMain];if(e&&a.set(e,a.newModule({})),e=H(b)){var g=I(b);f.push(e),f.push(g),d=c+g.substr(0,g.indexOf("."))}this.bundles[d]=f}},K=function(){if(this.envs){var a=this.envs[this.env];a&&this.config(a)}},L=function(){if(this.liveReloadInstalled){var a=this;this["import"]("live-reload",{name:"@@steal"}).then(function(b){b(a.configMain,function(){K.call(a)})})}},M={map:!0,paths:!0,meta:!0};y(a,C={env:{set:function(a){this.env=a,this.isEnv("production")&&(this.loadBundles=!0),J.call(this)}},envs:{set:function(a){var b=this.envs;b||(b=this.envs={}),d(a,function(a,c){var e=b[c];e||(e=b[c]={}),d(a,function(a,b){M[b]&&e[b]?g(e[b],a):e[b]=a})})}},baseUrl:G("baseURL"),baseURL:G("baseURL"),root:G("baseURL"),config:D,configPath:D,loadBundles:{set:function(a){this.loadBundles=a,J.call(this)}},startId:{set:function(a){E.set.call(this,o(a))}},main:E,stealURL:{set:function(b,c){a.stealURL=b;var d=b.split("?"),e=d.shift(),f=d.join("?"),g=f.split("&"),h=e.split("/"),i=h.pop(),j=h.join("/"),k=this.getPlatform()||(isWebWorker?"worker":"window");if(this.stealBundled&&this.stealBundled===!0?this.config({env:k+"-production"}):(C.stealPath.set.call(this,j,c),i.indexOf("steal.production")>-1&&!c.env&&(this.config({env:k+"-production"}),J.call(this))),g.length&&g[0].length){for(var l,m={},n=0;n1)m[o[0]]=o.slice(1).join("=");else{u.dev&&u.dev.warn("Please use search params like ?main=main&env=production");var p=l.split(",");p[0]&&(m.startId=p[0]),p[1]&&(m.env=p[1])}}this.config(m)}}},stealPath:{set:function(b,c){b=F(b);var d=b.split("/");z(this.paths,"@dev",b+"/ext/dev.js"),z(this.paths,"$css",b+"/ext/css.js"),z(this.paths,"$less",b+"/ext/less.js"),z(this.paths,"@less-engine",b+"/ext/less-engine.js"),z(this.paths,"npm",b+"/ext/npm.js"),z(this.paths,"npm-extension",b+"/ext/npm-extension.js"),z(this.paths,"npm-utils",b+"/ext/npm-utils.js"),z(this.paths,"npm-crawl",b+"/ext/npm-crawl.js"),z(this.paths,"npm-load",b+"/ext/npm-load.js"),z(this.paths,"npm-convert",b+"/ext/npm-convert.js"),z(this.paths,"semver",b+"/ext/semver.js"),z(this.paths,"bower",b+"/ext/bower.js"),z(this.paths,"live-reload",b+"/ext/live-reload.js"),z(this.paths,"steal-clone",b+"/ext/steal-clone.js"),this.paths.traceur=b+"/ext/traceur.js",this.paths["traceur-runtime"]=b+"/ext/traceur-runtime.js",this.paths.babel=b+"/ext/babel.js",this.paths["babel-runtime"]=b+"/ext/babel-runtime.js",this.setContextual("steal-clone","steal-clone"),isNode?(a.register("@less-engine",[],!1,function(){var a=require;return a("less")}),"@config"===this.configMain&&"steal"===i(d)&&(d.pop(),"node_modules"===i(d)&&(this.configMain="package.json!npm",J.call(this),d.pop()))):(z(this.paths,"@less-engine",b+"/ext/less-engine.js"),c.root||c.baseUrl||c.baseURL||c.config||c.configPath||("steal"===i(d)&&(d.pop(),(i(d)===c.bowerPath||"bower_components"===i(d))&&(a.configMain="bower.json!bower",J.call(this),d.pop()),"node_modules"===i(d)&&(a.configMain="package.json!npm",J.call(this),d.pop())),this.config({baseURL:d.join("/")+"/"}))),a.stealPath=b}},bundle:{set:function(b){a.bundle=b}},bundlesPath:{set:function(a){return this.paths[A]=a+"/*css",this.paths[B]=a+"/*.js",a}},instantiated:{set:function(a){var b=this;d(a||{},function(a,c){b.set(c,b.newModule(a))})}},meta:{set:function(a){var b=this;d(a||{},function(a,c){if("object"==typeof a){var d=b.meta[c];if(d&&d.format===a.format){var e=a.deps;g(a,d),e&&(a.deps=e)}}}),g(this.meta,a)}}}),u.config=function(b){return"string"==typeof b?a[b]:void a.config(b)},"undefined"!=typeof a&&q(a);var N=function(){var a={},b=document.getElementsByTagName("script"),e=b[b.length-1];if(e){a.stealURL=e.src,d(e.attributes,function(b){var d=c(0===b.nodeName.indexOf("data-")?b.nodeName.replace("data-",""):b.nodeName);a[d]=""===b.value?!0:b.value});var f=e.innerHTML;/\S/.test(f)&&(a.mainSource=f)}return a};return u.startup=function(b){if(isWebWorker)var c={stealURL:location.href};else if(isBrowserWithWindow||isNW)var c=N();else var c={stealPath:__dirname};b&&a.config(b),a.config(c),K.call(this.System);if(a.loadBundles){if(!a.main&&a.isEnv("production")&&!a.stealBundled){var d=console&&console.warn||function(){};d.call(console,"Attribute 'main' is required in production environment. Please add it to the script tag.")}r=a["import"](a.configMain),t=r.then(function(b){return K.call(a),a.main?a["import"](a.main):b})}else r=a["import"](a.configMain),s=r.then(function(){return K.call(a),L.call(a),b&&a.config(b),a["import"]("@dev")},function(a){return u.System["import"]("@dev")}),t=s.then(function(){if(!a.main||"build"===a.env)return r;var b=a.main;return"string"==typeof b&&(b=[b]),Promise.all(e(b,function(b){return a["import"](b)}))});return a.mainSource&&(t=t.then(function(){return a.module(a.mainSource)})),t},u.done=function(){return t},u["import"]=function(){function a(){var a=[];return d(b,function(b){a.push(c["import"](b))}),a.length>1?Promise.all(a):a[0]}var b=arguments,c=this.System;return r||u.startup(),r.then(a)},u};if("undefined"!=typeof System&&b(System),isNode&&!isNW)require("steal-systemjs"),a.steal=q(System),a.steal.System=System,a.steal.dev=require("./ext/dev.js"),steal.clone=p,module.exports=a.steal,a.steal.addSteal=b,require("system-json");else{var r=a.steal;a.steal=q(System),a.steal.startup(r&&"object"==typeof r&&r).then(null,function(a){if("undefined"!=typeof console){var b=console,c=b.error?"error":"log";b[c](a,a.stack)}}),a.steal.clone=p,a.steal.addSteal=b}}("undefined"==typeof window?"undefined"==typeof global?this:global:window);
\ No newline at end of file