<?php
require_once "colors.php";
//



// i sdelal
require_once "addonsw/logger/logger_.php";
require_once "addonsw/changer/changer.php";
//NewLogger::info(json_encode(["$res", $res]));
//

$filePath = __FILE__;



class Feeds extends Handler_Protected {
	/** special feed for archived articles */
	const FEED_ARCHIVED = 0;

	/** special feed for starred articles */
	const FEED_STARRED = -1;

	/** special feed for published articles */
	const FEED_PUBLISHED = -2;

	/** special feed for archived articles */
	const FEED_FRESH = -3;

	/** special feed for all articles */
	const FEED_ALL = -4;

	/**
	 * -5 was FEED_DASHBOARD, intended to be used when there
	 * was nothing to show, but the related code was unused
	 */

	/** special feed for recently read articles */
	const FEED_RECENTLY_READ = -6;

	/** special feed for error scenarios (e.g. feed not found) */
	const FEED_ERROR = -7;

	/** special "category" for uncategorized articles */
	const CATEGORY_UNCATEGORIZED = 0;

	/** special category for "special" articles (e.g. Starred, Published, Archived, plugin-provided, etc.) */
	const CATEGORY_SPECIAL = -1;

	/** special category for labels */
	const CATEGORY_LABELS = -2;

	/** special category for all feeds, excluding virtual feeds (e.g. labels and such) */
	const CATEGORY_ALL_EXCEPT_VIRTUAL = -3;

	/** special category for all feeds, including virtual feeds (e.g. labels and such) */
	const CATEGORY_ALL = -4;

	const NEVER_GROUP_FEEDS = [ Feeds::FEED_RECENTLY_READ, Feeds::FEED_ARCHIVED ];
	const NEVER_GROUP_BY_DATE = [ Feeds::FEED_PUBLISHED, Feeds::FEED_STARRED, Feeds::FEED_FRESH ];

	function csrf_ignore(string $method): bool {
		$csrf_ignored = array("index");

		return array_search($method, $csrf_ignored) !== false;
	}

	/**
	 * @param string|int $feed
	 * @return array{0: array<int, int>, 1: int, 2: int, 3: bool, 4: array<string, mixed>} $topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply
	 */
	private function _format_headlines_list($feed, string $method, string $view_mode, int $limit, bool $cat_view,
					int $offset, string $override_order, bool $include_children, ?int $check_first_id = null,
					?bool $skip_first_id_check = false, ? string $order_by = ''): array {

		$disable_cache = false;

		$reply = [];
		$rgba_cache = [];
		$topmost_article_ids = [];

		if (!$offset) $offset = 0;
		if ($method == "undefined") $method = "";

		$method_split = explode(":", $method);

		if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
            $sth = $this->pdo->prepare("UPDATE ttrss_feeds
                            SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
                            WHERE id = ?");
            $sth->execute([$feed]);
		}

		if ($method_split[0] == "MarkAllReadGR")  {
			$this->_catchup($method_split[1], false);
		}

		// FIXME: might break tag display?

		if (is_numeric($feed) && $feed > 0 && !$cat_view) {
			$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? LIMIT 1");
			$sth->execute([$feed]);

			if (!$sth->fetch()) {
				$reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
			}
		}

		$search = $_REQUEST["query"] ?? "";
		$search_language = $_REQUEST["search_language"] ?? ""; // PGSQL only

		if ($search) {
			$disable_cache = true;
		}

		$qfh_ret = [];

		if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {

			/** @var IVirtualFeed|false $handler */
			$handler = PluginHost::getInstance()->get_feed_handler(
				PluginHost::feed_to_pfeed_id($feed));

			if ($handler) {
				$options = array(
					"limit" => $limit,
					"view_mode" => $view_mode,
					"cat_view" => $cat_view,
					"search" => $search,
					"override_order" => $override_order,
					"offset" => $offset,
					"owner_uid" => $_SESSION["uid"],
					"filter" => false,
					"since_id" => 0,
					"include_children" => $include_children,
					"order_by" => $order_by);

				$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
					$options);
			}

		} else {

			$params = array(
				"feed" => $feed,
				"limit" => $limit,
				"view_mode" => $view_mode,
				"cat_view" => $cat_view,
				"search" => $search,
				"search_language" => $search_language,
				"override_order" => $override_order,
				"offset" => $offset,
				"include_children" => $include_children,
				"check_first_id" => $check_first_id,
				"skip_first_id_check" => $skip_first_id_check,
                "order_by" => $order_by
			);

			$qfh_ret = $this->_get_headlines($params);
		}

		$vfeed_group_enabled = get_pref(Prefs::VFEED_GROUP_BY_FEED) &&
			!(in_array($feed, self::NEVER_GROUP_FEEDS) && !$cat_view);

		$result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed
		$feed_title = $qfh_ret[1];
		$feed_site_url = $qfh_ret[2];
		$last_error = $qfh_ret[3];
		$last_updated = strpos($qfh_ret[4] ?? "", '1970-') === false ?
			TimeHelper::make_local_datetime($qfh_ret[4], false) : __("Never");
		$highlight_words = $qfh_ret[5];
		$reply['first_id'] = $qfh_ret[6];
		$reply['is_vfeed'] = $qfh_ret[7];
		$query_error_override = $qfh_ret[8];

		$reply['search_query'] = [$search, $search_language];
		$reply['vfeed_group_enabled'] = $vfeed_group_enabled;


		$plugin_menu_items = "";
		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM2,
			function ($result) use (&$plugin_menu_items) {
				$plugin_menu_items .= $result;
			},
			$feed, $cat_view);

		$plugin_buttons = "";
		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON,
			function ($result) use (&$plugin_buttons) {
				$plugin_buttons .= $result;
			},
			$feed, $cat_view);

		$reply['toolbar'] = [
			'site_url' => $feed_site_url,
			'title' => strip_tags($feed_title),
			'error' => $last_error,
			'last_updated' => $last_updated,
			'plugin_menu_items' => $plugin_menu_items,
			'plugin_buttons' => $plugin_buttons,
		];

		$reply['content'] = [];

		if ($offset == 0)
			PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINES_BEFORE,
					function ($result) use (&$reply) {
						$reply['content'] .= $result;
					},
					$feed, $cat_view, $qfh_ret);

		$headlines_count = 0;

		if ($result instanceof PDOStatement) {
			while ($line = $result->fetch(PDO::FETCH_ASSOC)) {

				++$headlines_count;

				if (!get_pref(Prefs::SHOW_CONTENT_PREVIEW)) {
					$line["content_preview"] = "";
				} else {
					$line["content_preview"] =  "&mdash; " . truncate_string(strip_tags($line["content"]), 250);

					$max_excerpt_length = 250;

					PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_QUERY_HEADLINES,
						function ($result) use (&$line) {
							$line = $result;
						},
						$line, $max_excerpt_length);
				}

				$id = $line["id"];

				// frontend doesn't expect pdo returning booleans as strings on mysql
				if (Config::get(Config::DB_TYPE) == "mysql") {
					foreach (["unread", "marked", "published"] as $k) {
						if (is_integer($line[$k])) {
							$line[$k] = $line[$k] === 1;
						} else {
							$line[$k] = $line[$k] === "1";
						}
					}
				}

				// normalize archived feed
				if ($line['feed_id'] === null) {
					$line['feed_id'] = Feeds::FEED_ARCHIVED;
					$line["feed_title"] = __("Archived articles");
				}

				$feed_id = $line["feed_id"];

				if ($line["num_labels"] > 0) {
					$label_cache = $line["label_cache"];
					$labels = false;

					if ($label_cache) {
						$label_cache = json_decode($label_cache, true);

						if ($label_cache) {
							if ($label_cache["no-labels"] ?? 0 == 1)
								$labels = [];
							else
								$labels = $label_cache;
						}
					} else {
						$labels = Article::_get_labels($id);
					}

					$line["labels"] = $labels;
				} else {
					$line["labels"] = [];
				}

				if (count($topmost_article_ids) < 3) {
					array_push($topmost_article_ids, $id);
				}

				$line["feed_title"] = $line["feed_title"] ?? "";

				$button_doc = new DOMDocument();

				$line["buttons_left"] = "";
				PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_LEFT_BUTTON,
					function ($result, $plugin) use (&$line, &$button_doc) {
						if ($result && $button_doc->loadXML($result)) {

							/** @var DOMElement|null $child */
							$child = $button_doc->firstChild;

							if ($child) {
								do {
									/** @var DOMElement|null $child */
									$child->setAttribute('data-plugin-name', get_class($plugin));
								} while ($child = $child->nextSibling);

								$line["buttons_left"] .= $button_doc->saveXML($button_doc->firstChild);
							}
						} else if ($result) {
							user_error(get_class($plugin) .
								" plugin: content provided in HOOK_ARTICLE_LEFT_BUTTON is not valid XML: " .
								Errors::libxml_last_error() . " $result", E_USER_WARNING);
						}
					},
					$line);

				$line["buttons"] = "";

				PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_BUTTON,
					function ($result, $plugin) use (&$line, &$button_doc) {
						if ($result && $button_doc->loadXML($result)) {

							/** @var DOMElement|null $child */
							$child = $button_doc->firstChild;

							if ($child) {
								do {
									/** @var DOMElement|null $child */
									$child->setAttribute('data-plugin-name', get_class($plugin));
								} while ($child = $child->nextSibling);

								$line["buttons"] .= $button_doc->saveXML($button_doc->firstChild);
							}
						} else if ($result) {
							user_error(get_class($plugin) .
								" plugin: content provided in HOOK_ARTICLE_BUTTON is not valid XML: " .
								Errors::libxml_last_error() . " $result", E_USER_WARNING);
						}
					},
					$line);
// i sdelal
				//$line["content"] = Sanitizer::sanitize($line["content"],  // orig
				
				$line["content"] = Sanitizer::sanitize(
				    $line["content"], // orig
					$line['hide_images'],
					null, $line["site_url"],
					$highlight_words, $line["id"]
				);
				
				//$line["content"] = Sanitizer::sanitize(search_replace(search_ticker($line["link"], $line["content"])), // new
				
				//$line["content"] = Sanitizer::sanitize(
				    //modify_content($line), // new
					//$line['hide_images'],
					//null, $line["site_url"],
					//$highlight_words, $line["id"]
				//);

				if (!get_pref(Prefs::CDM_EXPANDED)) {
					$line["cdm_excerpt"] = "<span class='collapse'>
						<i class='material-icons' onclick='return Article.cdmUnsetActive(event)'
								title=\"" . __("Collapse article") . "\">remove_circle</i></span>";

					if (get_pref(Prefs::SHOW_CONTENT_PREVIEW)) {
						$line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>";
					}
				}

				if ($line["num_enclosures"] > 0) {
					$line["enclosures"] = Article::_format_enclosures($id,
						sql_bool_to_bool($line["always_display_enclosures"]),
						$line["content"],
						sql_bool_to_bool($line["hide_images"]));
				} else {
					$line["enclosures"] = [ 'formatted' => '', 'entries' => [] ];
				}

				$line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
				// $line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, null, false, true);   // orig // i sdelal
				$line["updated"] = T_sprintf('<font face="Calibri" color="#000" size="2.5">&nbsp;&nbsp;&nbsp; %s</font>', TimeHelper::make_local_datetime($line["updated"], false, false, true, false));  // new
				$line["updated"] .= T_sprintf('</Br><font face="Calibri" color="#000" size="2.5">&nbsp;&nbsp;&nbsp; %s</font> &nbsp;&nbsp; Imported', // new
				TimeHelper::make_local_datetime($line["date_entered"], false, false, true, false));   // new
				//
				
				//$line['imported'] = T_sprintf("Imported at %s",  // orig // i sdelal
					//TimeHelper::make_local_datetime($line["date_entered"], false));  // orig // i sdelal
				$line['imported'] = T_sprintf("Imported at &nbsp;&nbsp;&nbsp; %s",   // new
				TimeHelper::make_local_datetime($line["date_entered"], false, false, true, false));   // new
				//



				if ($line["tag_cache"])
					$tags = explode(",", $line["tag_cache"]);
				else
					$tags = [];

				$line["tags"] = $tags;

				//$line["tags"] = Article::_get_tags($line["id"], false, $line["tag_cache"]);

				$line['has_icon'] = self::_has_icon($feed_id);

			    //setting feed headline background color, needs to change text color based on dark/light
				$fav_color = $line['favicon_avg_color'] ?? false;

				require_once "colors.php";

				if (!isset($rgba_cache[$feed_id])) {
					if ($fav_color && $fav_color != 'fail') {
						$rgba_cache[$feed_id] = \Colors\_color_unpack($fav_color);
					} else {
						$rgba_cache[$feed_id] = \Colors\_color_unpack($this->_color_of($line['feed_title']));
					}
				}

				if (isset($rgba_cache[$feed_id])) {
				    $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)';
				}

				PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_CDM,
					function ($result, $plugin) use (&$line) {
						$line = $result;
					},
					$line);

				$line['content'] = DiskCache::rewrite_urls($line['content']);

				/* we don't need those */

				foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color",
								"uuid", "label_cache", "yyiw", "num_enclosures"] as $k)
					unset($line[$k]);

				array_push($reply['content'], $line);
			}
		}

		if (!$headlines_count) {

			if ($result instanceof PDOStatement) {

				if ($query_error_override) {
					$message = $query_error_override;
				} else {
					switch ($view_mode) {
						case "unread":
							$message = __("No unread articles found to display.");
							break;
						case "updated":
							$message = __("No updated articles found to display.");
							break;
						case "marked":
							$message = __("No starred articles found to display.");
							break;
						default:
							if ($feed < LABEL_BASE_INDEX) {
								$message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
							} else {
								$message = __("No articles found to display.");
							}
					}
				}

				if (!$offset && $message) {
					$reply['content'] = "<div class='whiteBox'>$message";

					$reply['content'] .= "<p><span class=\"text-muted\">";

					$sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
                        WHERE owner_uid = ?");
					$sth->execute([$_SESSION['uid']]);
					$row = $sth->fetch();

					$last_updated = TimeHelper::make_local_datetime($row["last_updated"], false);

					$reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);

					$num_errors = ORM::for_table('ttrss_feeds')
						->where_not_equal('last_error', '')
						->where('owner_uid', $_SESSION['uid'])
						->where_gte('update_interval', 0)
						->count('id');

					if ($num_errors > 0) {
						$reply['content'] .= "<br/>";
						$reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors(); return false\">" .
							__('Some feeds have update errors (click for details)') . "</a>";
					}
					$reply['content'] .= "</span></p></div>";

				}
			} else if (is_numeric($result) && $result == -1) {
				$reply['first_id_changed'] = true;
			}
		}

		return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply);
	}

	function catchupAll(): void {
		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
						last_read = NOW(), unread = false WHERE unread = true AND owner_uid = ?");
		$sth->execute([$_SESSION['uid']]);

		print json_encode(array("message" => "UPDATE_COUNTERS"));
	}

	function view(): void {
		$reply = array();

		$feed = $_REQUEST["feed"];
		$method = $_REQUEST["m"] ?? "";
		$view_mode = $_REQUEST["view_mode"] ?? "";
		$limit = 30;
		$cat_view = self::_param_to_bool($_REQUEST["cat"] ?? false);
		$next_unread_feed = $_REQUEST["nuf"] ?? 0;
		$offset = (int) ($_REQUEST["skip"] ?? 0);
		$order_by = $_REQUEST["order_by"] ?? "";
		$check_first_id = $_REQUEST["fid"] ?? 0;

		if (is_numeric($feed)) $feed = (int) $feed;

		$sth = false;
		if ($feed < LABEL_BASE_INDEX) {

			$label_feed = Labels::feed_to_label_id($feed);

			$sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2 WHERE
							id = ? AND owner_uid = ?");
			$sth->execute([$label_feed, $_SESSION['uid']]);

		} else if (!$cat_view && is_numeric($feed) && $feed > 0) {

			$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
							id = ? AND owner_uid = ?");
			$sth->execute([$feed, $_SESSION['uid']]);

		} else if ($cat_view && is_numeric($feed) && $feed > 0) {

			$sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE
							id = ? AND owner_uid = ?");

			$sth->execute([$feed, $_SESSION['uid']]);
		}

		if ($sth && !$sth->fetch()) {
			print json_encode($this->_generate_error_feed(__("Feed not found.")));
			return;
		}

		set_pref(Prefs::_DEFAULT_VIEW_MODE, $view_mode);
		set_pref(Prefs::_DEFAULT_VIEW_ORDER_BY, $order_by);

		/* bump login timestamp if needed */
		if (time() - $_SESSION["last_login_update"] > 3600) {
			$user = ORM::for_table('ttrss_users')->find_one($_SESSION["uid"]);
			$user->last_login = Db::NOW();
			$user->save();

			$_SESSION["last_login_update"] = time();
		}

		if (!$cat_view && is_numeric($feed) && $feed > 0) {
			$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET last_viewed = NOW()
							WHERE id = ? AND owner_uid = ?");
			$sth->execute([$feed, $_SESSION['uid']]);
		}

		$reply['headlines'] = [];

		list($override_order, $skip_first_id_check) = self::_order_to_override_query($order_by);

		$ret = $this->_format_headlines_list($feed, $method,
			$view_mode, $limit, $cat_view, $offset,
			$override_order, true, $check_first_id, $skip_first_id_check, $order_by);

		$headlines_count = $ret[1];
		$disable_cache = $ret[3];
		
		//$reply['headlines'] = $ret[4]; // orig
		$reply['headlines'] = changer($ret[4]);  // i sdelal

		if (!$next_unread_feed)
			$reply['headlines']['id'] = $feed;
		else
			$reply['headlines']['id'] = $next_unread_feed;

		$reply['headlines']['is_cat'] = $cat_view;

		$reply['headlines-info'] = ["count" => (int) $headlines_count,
            						"disable_cache" => (bool) $disable_cache];

		// this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc
		$reply['runtime-info'] = RPC::_make_runtime_info();

		if (!empty($_REQUEST["debug"])) {
			print "\n*** HEADLINE DATA ***\n";

			print json_encode($reply, JSON_PRETTY_PRINT);
		} else {
			print json_encode($reply);
		}
	}

	/**
	 * @return array<string, mixed>
	 */
	private function _generate_error_feed(string $error): array {
		$reply = array();

		$reply['headlines']['id'] = Feeds::FEED_ERROR;
		$reply['headlines']['is_cat'] = false;

		$reply['headlines']['toolbar'] = '';
		$reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";

		$reply['headlines-info'] = array("count" => 0,
			"unread" => 0,
			"disable_cache" => true);

		return $reply;
	}

	function subscribeToFeed(): void {
		print json_encode([
			"cat_select" => \Controls\select_feeds_cats("cat")
		]);
	}

	function search(): void {
		print json_encode([
			"show_language" => Config::get(Config::DB_TYPE) == "pgsql",
			"show_syntax_help" => count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0,
			"all_languages" => Pref_Feeds::get_ts_languages(),
			"default_language" => get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE)
		]);
	}

	function opensite(): void {
		$feed = ORM::for_table('ttrss_feeds')
			->find_one((int)$_REQUEST['feed_id']);

		if ($feed) {
			$site_url = UrlHelper::validate($feed->site_url);

			if ($site_url) {
				header("Location: $site_url");
				return;
			}
		}

		header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
		print "Feed not found or has an empty site URL.";
	}

	function updatedebugger(): void {
		header("Content-type: text/html");

		$xdebug = isset($_REQUEST["xdebug"]) ? (int)$_REQUEST["xdebug"] : Debug::LOG_VERBOSE;

		if (!in_array($xdebug, Debug::ALL_LOG_LEVELS)) {
			$xdebug = Debug::LOG_VERBOSE;
		}

		Debug::set_enabled(true);
		Debug::set_loglevel((int)Debug::map_loglevel($xdebug));

		$feed_id = (int)$_REQUEST["feed_id"];
		$do_update = ($_REQUEST["action"] ?? "") == "do_update";
		$csrf_token = $_POST["csrf_token"];

		$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
		$sth->execute([$feed_id, $_SESSION['uid']]);

		if (!$sth->fetch()) {
			print "Access denied.";
			return;
		}
		?>
		<!DOCTYPE html>
		<html>
		<head>
			<title>Feed Debugger</title>
			<style type='text/css'>
				@media (prefers-color-scheme: dark) {
					body {
						background : #222;
					}
				}
				body.css_loading * {
					display : none;
				}

				.feed-xml {
					color : green;
				}

				.log-timestamp {
					color : gray;
				}

				.log-timestamp::before {
					content: "["
				}

				.log-timestamp::after {
					content: "]"
				}

			</style>
			<script>
				dojoConfig = {
					async: true,
					cacheBust: "<?= get_scripts_timestamp(); ?>",
					packages: [
						{ name: "fox", location: "../../js" },
					]
				};
			</script>
			<?= javascript_tag("js/utility.js") ?>
			<?= javascript_tag("js/common.js") ?>
			<?= javascript_tag("lib/dojo/dojo.js") ?>
			<?= javascript_tag("lib/dojo/tt-rss-layer.js") ?>
			<?= Config::get_override_links() ?>
		</head>
		<body class="flat ttrss_utility feed_debugger css_loading">
		<script type="text/javascript">
			require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox', 'fox/form/Select', 'dijit/form/Form',
				'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser, ready){
				ready(function() {
					parser.parse();
				});
			});
		</script>

			<div class="container">
				<h1>Feed Debugger: <?= "$feed_id: " . $this->_get_title($feed_id) ?></h1>
				<div class="content">
					<form method="post" action="" dojoType="dijit.form.Form">
						<?= \Controls\hidden_tag("op", "Feeds") ?>
						<?= \Controls\hidden_tag("method", "updatedebugger") ?>
						<?= \Controls\hidden_tag("csrf_token", $csrf_token) ?>
						<?= \Controls\hidden_tag("action", "do_update") ?>
						<?= \Controls\hidden_tag("feed_id", (string)$feed_id) ?>

						<fieldset>
							<label>
							<?= \Controls\select_hash("xdebug", $xdebug,
									[Debug::LOG_VERBOSE => "LOG_VERBOSE", Debug::LOG_EXTENDED => "LOG_EXTENDED"]);
							?></label>
						</fieldset>

						<fieldset>
							<label class="checkbox"><?= \Controls\checkbox_tag("force_refetch", isset($_REQUEST["force_refetch"])) ?> Force refetch</label>
						</fieldset>

						<fieldset class="narrow">
							<label class="checkbox"><?= \Controls\checkbox_tag("force_rehash", isset($_REQUEST["force_rehash"])) ?> Force rehash</label>
						</fieldset>

						<fieldset class="narrow">
							<label class="checkbox"><?= \Controls\checkbox_tag("dump_feed_xml", isset($_REQUEST["dump_feed_xml"])) ?> Dump feed XML</label>
						</fieldset>

						<?= \Controls\submit_tag("Continue") ?>
					</form>

					<hr>

					<pre><?php

					if ($do_update) {
						RSSUtils::update_rss_feed($feed_id, true, true);
					}

					?></pre>
				</div>
			</div>
		</body>
		</html>
		<?php

	}

	/**
	 * @param array<int, string> $search
	 */
	static function _catchup(string $feed_id_or_tag_name, bool $cat_view, ?int $owner_uid = null, string $mode = 'all', ?array $search = null): void {

		if (!$owner_uid) $owner_uid = $_SESSION['uid'];

		$pdo = Db::pdo();

		if (is_array($search) && $search[0]) {
			$search_qpart = "";

			PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SEARCH,
				function ($result) use (&$search_qpart, &$search_words) {
					if (!empty($result)) {
						list($search_qpart, $search_words) = $result;
						return true;
					}
				},
				$search[0]);

			// fall back in case of no plugins
			if (empty($search_qpart)) {
				list($search_qpart, $search_words) = self::_search_to_sql($search[0], $search[1], $owner_uid);
			}
		} else {
			$search_qpart = "true";
		}

		// TODO: all this interval stuff needs some generic generator function

		switch ($mode) {
			case "1day":
				if (Config::get(Config::DB_TYPE) == "pgsql") {
					$date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
				} else {
					$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
				}
				break;
			case "1week":
				if (Config::get(Config::DB_TYPE) == "pgsql") {
					$date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
				} else {
					$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
				}
				break;
			case "2week":
				if (Config::get(Config::DB_TYPE) == "pgsql") {
					$date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
				} else {
					$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
				}
				break;
			default:
				$date_qpart = "true";
		}

		if (is_numeric($feed_id_or_tag_name)) {
			$feed_id = (int) $feed_id_or_tag_name;

			if ($cat_view) {

				if ($feed_id >= 0) {

					if ($feed_id == Feeds::CATEGORY_UNCATEGORIZED) {
						$cat_qpart = "cat_id IS NULL";
					} else {
						$children = self::_get_child_cats($feed_id, $owner_uid);
						array_push($children, $feed_id);
						$children = array_map("intval", $children);

						$children = join(",", $children);

						$cat_qpart = "cat_id IN ($children)";
					}

					$sth = $pdo->prepare("UPDATE ttrss_user_entries
						SET unread = false, last_read = NOW() WHERE ref_id IN
							(SELECT id FROM
								(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
									AND owner_uid = ? AND unread = true AND feed_id IN
										(SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart AND $search_qpart) as tmp)");
					$sth->execute([$owner_uid]);

				} else if ($feed_id == Feeds::CATEGORY_LABELS) {

					$sth = $pdo->prepare("UPDATE ttrss_user_entries
						SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
							FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart AND $search_qpart) > 0
							AND unread = true AND owner_uid = ?");
					$sth->execute([$owner_uid]);
				}

			} else if ($feed_id > 0) {

				$sth = $pdo->prepare("UPDATE ttrss_user_entries
					SET unread = false, last_read = NOW() WHERE ref_id IN
						(SELECT id FROM
							(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
								AND owner_uid = ? AND unread = true AND feed_id = ? AND $date_qpart AND $search_qpart) as tmp)");
				$sth->execute([$owner_uid, $feed_id]);

			} else if ($feed_id < 0 && $feed_id > LABEL_BASE_INDEX) { // special, like starred

				if ($feed_id == Feeds::FEED_STARRED) {
					$sth = $pdo->prepare("UPDATE ttrss_user_entries
						SET unread = false, last_read = NOW() WHERE ref_id IN
							(SELECT id FROM
								(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
									AND owner_uid = ? AND unread = true AND marked = true AND $date_qpart AND $search_qpart) as tmp)");
					$sth->execute([$owner_uid]);
				}

				if ($feed_id == Feeds::FEED_PUBLISHED) {
					$sth = $pdo->prepare("UPDATE ttrss_user_entries
						SET unread = false, last_read = NOW() WHERE ref_id IN
							(SELECT id FROM
								(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
									AND owner_uid = ? AND unread = true AND published = true AND $date_qpart AND $search_qpart) as tmp)");
					$sth->execute([$owner_uid]);
				}

				if ($feed_id == Feeds::FEED_FRESH) {

					$intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE);

					if (Config::get(Config::DB_TYPE) == "pgsql") {
						$match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
					} else {
						$match_part = "date_entered > DATE_SUB(NOW(),
							INTERVAL $intl HOUR) ";
					}

					$sth = $pdo->prepare("UPDATE ttrss_user_entries
						SET unread = false, last_read = NOW() WHERE ref_id IN
							(SELECT id FROM
								(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
									AND owner_uid = ? AND score >= 0 AND unread = true AND $date_qpart AND $match_part AND $search_qpart) as tmp)");
					$sth->execute([$owner_uid]);
				}

				if ($feed_id == Feeds::FEED_ALL) {
					$sth = $pdo->prepare("UPDATE ttrss_user_entries
						SET unread = false, last_read = NOW() WHERE ref_id IN
							(SELECT id FROM
								(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
									AND owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
					$sth->execute([$owner_uid]);
				}
			} else if ($feed_id < LABEL_BASE_INDEX) { // label

				$label_id = Labels::feed_to_label_id($feed_id);

				$sth = $pdo->prepare("UPDATE ttrss_user_entries
					SET unread = false, last_read = NOW() WHERE ref_id IN
						(SELECT id FROM
							(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
								AND label_id = ? AND ref_id = article_id
								AND owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
				$sth->execute([$label_id, $owner_uid]);
			}
		} else { // tag
			$tag_name = $feed_id_or_tag_name;

			$sth = $pdo->prepare("UPDATE ttrss_user_entries
				SET unread = false, last_read = NOW() WHERE ref_id IN
					(SELECT id FROM
						(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
							AND post_int_id = int_id AND tag_name = ?
							AND ttrss_user_entries.owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
			$sth->execute([$tag_name, $owner_uid]);
		}
	}

	/**
	 * @param int|string $feed feed id or tag name
	 * @param bool $is_cat
	 * @param bool $unread_only
	 * @param null|int $owner_uid
	 * @return int
	 * @throws PDOException
	 */
	static function _get_counters($feed, bool $is_cat = false, bool $unread_only = false, ?int $owner_uid = null): int {
		$n_feed = (int) $feed;
		$need_entries = false;

		$pdo = Db::pdo();

		if (!$owner_uid) $owner_uid = $_SESSION["uid"];

		if ($unread_only) {
			$unread_qpart = "unread = true";
		} else {
			$unread_qpart = "true";
		}

		$match_part = "";

		if ($is_cat) {
			return self::_get_cat_unread($n_feed, $owner_uid);
		} else if(is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { // virtual Feed
			$feed_id = PluginHost::feed_to_pfeed_id($feed);
			$handler = PluginHost::getInstance()->get_feed_handler($feed_id);
			if (implements_interface($handler, 'IVirtualFeed')) {
				/** @var IVirtualFeed $handler */
				return $handler->get_unread($feed_id);
			} else {
				return 0;
			}
		} else if ($n_feed == Feeds::FEED_RECENTLY_READ) {
			return 0;
		// tags
		} else if ($feed != "0" && $n_feed == 0) {

			$sth = $pdo->prepare("SELECT SUM((SELECT COUNT(int_id)
				FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
					AND ref_id = id AND $unread_qpart)) AS count FROM ttrss_tags
				WHERE owner_uid = ? AND tag_name = ?");

			$sth->execute([$owner_uid, $feed]);
			$row = $sth->fetch();

			// Handle 'SUM()' returning null if there are no results
			return $row["count"] ?? 0;

		} else if ($n_feed == Feeds::FEED_STARRED) {
			$match_part = "marked = true";
		} else if ($n_feed == Feeds::FEED_PUBLISHED) {
			$match_part = "published = true";
		} else if ($n_feed == Feeds::FEED_FRESH) {
			$match_part = "unread = true AND score >= 0";

			$intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE, $owner_uid);

			if (Config::get(Config::DB_TYPE) == "pgsql") {
				$match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
			} else {
				$match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
			}

			$need_entries = true;

		} else if ($n_feed == Feeds::FEED_ALL) {
			$match_part = "true";
		} else if ($n_feed >= 0) {

			if ($n_feed != Feeds::FEED_ARCHIVED) {
				$match_part = sprintf("feed_id = %d", $n_feed);
			} else {
				$match_part = "feed_id IS NULL";
			}

		} else if ($feed < LABEL_BASE_INDEX) {

			$label_id = Labels::feed_to_label_id($feed);

			return self::_get_label_unread($label_id, $owner_uid);
		}

		if ($match_part) {

			if ($need_entries) {
				$from_qpart = "ttrss_user_entries,ttrss_entries";
				$from_where = "ttrss_entries.id = ttrss_user_entries.ref_id AND";
			} else {
				$from_qpart = "ttrss_user_entries";
				$from_where = "";
			}

			$sth = $pdo->prepare("SELECT count(int_id) AS unread
				FROM $from_qpart WHERE
				$unread_qpart AND $from_where ($match_part) AND ttrss_user_entries.owner_uid = ?");
			$sth->execute([$owner_uid]);
			$row = $sth->fetch();

			return $row["unread"];

		} else {

			$sth = $pdo->prepare("SELECT COUNT(post_int_id) AS unread
				FROM ttrss_tags,ttrss_user_entries,ttrss_entries
				WHERE tag_name = ? AND post_int_id = int_id AND ref_id = ttrss_entries.id
				AND $unread_qpart AND ttrss_tags.owner_uid = ,");

			$sth->execute([$feed, $owner_uid]);
			$row = $sth->fetch();

			return $row["unread"];
		}
	}

	function add(): void {
		$feed = clean($_REQUEST['feed']);
		$cat = (int) clean($_REQUEST['cat'] ?? '');
		$need_auth = isset($_REQUEST['need_auth']);
		$login = $need_auth ? clean($_REQUEST['login']) : '';
		$pass = $need_auth ? clean($_REQUEST['pass']) : '';

		$rc = Feeds::_subscribe($feed, $cat, $login, $pass);

		print json_encode(array("result" => $rc));
	}

	/**
	 * @return array<string, mixed> (code => Status code, message => error message if available)
	 *
	 *                 0 - OK, Feed already exists
	 *                 1 - OK, Feed added
	 *                 2 - Invalid URL
	 *                 3 - URL content is HTML, no feeds available
	 *                 4 - URL content is HTML which contains multiple feeds.
	 *                     Here you should call extractfeedurls in rpc-backend
	 *                     to get all possible feeds.
	 *                 5 - Couldn't download the URL content.
	 *                 6 - Content is an invalid XML.
	 *                 7 - Error while creating feed database entry.
	 *                 8 - Permission denied (ACCESS_LEVEL_READONLY).
	 */
	static function _subscribe(string $url, int $cat_id = 0, string $auth_login = '', string $auth_pass = ''): array {

		$user = ORM::for_table("ttrss_users")->find_one($_SESSION['uid']);

		if ($user && $user->access_level == UserHelper::ACCESS_LEVEL_READONLY) {
			return ["code" => 8];
		}

		$url = UrlHelper::validate($url);

		if (!$url) return ["code" => 2];

		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_PRE_SUBSCRIBE,
			/** @phpstan-ignore-next-line */
			function ($result) use (&$url, &$auth_login, &$auth_pass) {
				// arguments are updated inside the hook (if needed)
			},
			$url, $auth_login, $auth_pass);

		$contents = UrlHelper::fetch(['url' => $url, 'login' => $auth_login, 'pass' => $auth_pass]);

		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SUBSCRIBE_FEED,
			function ($result) use (&$contents) {
				$contents = $result;
			},
			$contents, $url, $auth_login, $auth_pass);

		if (empty($contents)) {
			if (preg_match("/cloudflare\.com/", UrlHelper::$fetch_last_error_content)) {
				UrlHelper::$fetch_last_error .= " (feed behind Cloudflare)";
			}

			return array("code" => 5, "message" => UrlHelper::$fetch_last_error);
		}

		if (mb_strpos(UrlHelper::$fetch_last_content_type, "html") !== false && self::_is_html($contents)) {
			$feedUrls = self::_get_feeds_from_html($url, $contents);

			if (count($feedUrls) == 0) {
				return array("code" => 3);
			} else if (count($feedUrls) > 1) {
				return array("code" => 4, "feeds" => $feedUrls);
			}
			//use feed url as new URL
			$url = key($feedUrls);
		}

		$feed = ORM::for_table('ttrss_feeds')
			->where('feed_url', $url)
			->where('owner_uid', $_SESSION['uid'])
			->find_one();

		if ($feed) {
			return ["code" => 0, "feed_id" => $feed->id];
		} else {
			$feed = ORM::for_table('ttrss_feeds')->create();

			$feed->set([
				'owner_uid' => $_SESSION['uid'],
				'feed_url' => $url,
				'title' => "[Unknown]",
				'cat_id' => $cat_id ? $cat_id : null,
				'auth_login' => (string)$auth_login,
				'auth_pass' => (string)$auth_pass,
				'update_method' => 0,
				'auth_pass_encrypted' => false,
			]);

			if ($feed->save()) {
				RSSUtils::update_basic_info($feed->id);
				return ["code" => 1, "feed_id" => (int) $feed->id];
			}

			return ["code" => 7];
		}
	}

	static function _get_icon_file(int $feed_id): string {
		$favicon_cache = DiskCache::instance('feed-icons');

		return $favicon_cache->get_full_path((string)$feed_id);
	}

	static function _get_icon_url(int $feed_id, string $fallback_url = "") : string {
		if (self::_has_icon($feed_id)) {
			$icon_url = Config::get_self_url() . "/public.php?" . http_build_query([
				'op' => 'feed_icon',
				'id' => $feed_id,
			]);

			return $icon_url;
		}

		return $fallback_url;
	}

	static function _has_icon(int $feed_id): bool {
		$favicon_cache = DiskCache::instance('feed-icons');

		return $favicon_cache->exists((string)$feed_id);
	}

	/**
	 * @return false|string false if the icon ID was unrecognized, otherwise, the icon identifier string
	 */
	static function _get_icon(int $id) {
		switch ($id) {
			case Feeds::FEED_ARCHIVED:
				return "archive";
			case Feeds::FEED_STARRED:
				return "star";
			case Feeds::FEED_PUBLISHED:
				return "rss_feed";
			case Feeds::FEED_FRESH:
				return "whatshot";
			case Feeds::FEED_ALL:
				return "inbox";
			case Feeds::FEED_RECENTLY_READ:
				return "restore";
			default:
				if ($id < LABEL_BASE_INDEX) {
					return "label";
				} else {
					return self::_get_icon_url($id);
				}
		}
	}

	/**
	 * @return false|int false if the feed couldn't be found by URL+owner, otherwise the feed ID
	 */
	static function _find_by_url(string $feed_url, int $owner_uid) {
		$feed = ORM::for_table('ttrss_feeds')
			->where('owner_uid', $owner_uid)
			->where('feed_url', $feed_url)
			->find_one();

		if ($feed) {
			return $feed->id;
		} else {
			return false;
		}
	}

	/**
	 * $owner_uid defaults to $_SESSION['uid']
	 *
	 * @return false|int false if the category/feed couldn't be found by title, otherwise its ID
	 */
	static function _find_by_title(string $title, bool $cat = false, int $owner_uid = 0) {

		if ($cat) {
			$res = ORM::for_table('ttrss_feed_categories')
				->where('owner_uid', $owner_uid ? $owner_uid : $_SESSION['uid'])
				->where('title', $title)
				->find_one();
		} else {
			$res = ORM::for_table('ttrss_feeds')
				->where('owner_uid', $owner_uid ? $owner_uid : $_SESSION['uid'])
				->where('title', $title)
				->find_one();
		}

		if ($res) {
			return $res->id;
		} else {
			return false;
		}
	}

	/**
	 * @param string|int $id
	 */
	static function _get_title($id, bool $cat = false): string {
		$pdo = Db::pdo();

		if ($cat) {
			return self::_get_cat_title($id);
		} else if ($id == Feeds::FEED_STARRED) {
			return __("Starred articles");
		} else if ($id == Feeds::FEED_PUBLISHED) {
			return __("Published articles");
		} else if ($id == Feeds::FEED_FRESH) {
			return __("Fresh articles");
		} else if ($id == Feeds::FEED_ALL) {
			return __("All articles");
		} else if ($id === Feeds::FEED_ARCHIVED) {
			return __("Archived articles");
		} else if ($id == Feeds::FEED_RECENTLY_READ) {
			return __("Recently read");
		} else if ($id < LABEL_BASE_INDEX) {

			$label_id = Labels::feed_to_label_id($id);

			$sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ?");
			$sth->execute([$label_id]);

			if ($row = $sth->fetch()) {
				return $row["caption"];
			} else {
				return "Unknown label ($label_id)";
			}

		} else if (is_numeric($id) && $id > 0) {

		    $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?");
		    $sth->execute([$id]);

		    if ($row = $sth->fetch()) {
				return $row["title"];
			} else {
				return "Unknown feed ($id)";
			}

		} else {
			return "$id";
		}
	}

	// only real cats
	static function _get_cat_marked(int $cat, int $owner_uid = 0): int {

		if (!$owner_uid) $owner_uid = $_SESSION["uid"];

		$pdo = Db::pdo();

		if ($cat >= 0) {

			$sth = $pdo->prepare("SELECT SUM(CASE WHEN marked THEN 1 ELSE 0 END) AS marked
				FROM ttrss_user_entries
				WHERE feed_id IN (SELECT id FROM ttrss_feeds
                    WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL))
					AND owner_uid = :uid)
				AND owner_uid = :uid");

			$sth->execute(["cat" => $cat ? $cat : null, "uid" => $owner_uid]);

			if ($row = $sth->fetch()) {
				return (int) $row["marked"];
			}
		}
		return 0;
	}

	static function _get_cat_unread(int $cat, int $owner_uid = 0): int {

		if (!$owner_uid) $owner_uid = $_SESSION["uid"];

		$pdo = Db::pdo();

		if ($cat >= 0) {

			$sth = $pdo->prepare("SELECT SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS unread
				FROM ttrss_user_entries
				WHERE feed_id IN (SELECT id FROM ttrss_feeds
					WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL))
					AND owner_uid = :uid)
				AND owner_uid = :uid");

			$sth->execute(["cat" => $cat ? $cat : null, "uid" => $owner_uid]);

			if ($row = $sth->fetch()) {
				return (int) $row["unread"];
			}
		} else if ($cat == Feeds::CATEGORY_SPECIAL) {
			return 0;
		} else if ($cat == Feeds::CATEGORY_LABELS) {

			$sth = $pdo->prepare("SELECT COUNT(DISTINCT article_id) AS unread
				FROM ttrss_user_entries ue, ttrss_user_labels2 l
				WHERE article_id = ref_id AND unread IS true AND ue.owner_uid = :uid");

			$sth->execute(["uid" => $owner_uid]);

			if ($row = $sth->fetch()) {
				return (int) $row["unread"];
			}
		}

		return 0;
	}

	// only accepts real cats (>= 0)
	static function _get_cat_children_unread(int $cat, int $owner_uid = 0): int {
		if (!$owner_uid) $owner_uid = $_SESSION["uid"];

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE parent_cat = ?
				AND owner_uid = ?");
		$sth->execute([$cat, $owner_uid]);

		$unread = 0;

		while ($line = $sth->fetch()) {
			$unread += self::_get_cat_unread($line["id"], $owner_uid);
			$unread += self::_get_cat_children_unread($line["id"], $owner_uid);
		}

		return $unread;
	}

	static function _get_global_unread(int $user_id = 0): int {

		if (!$user_id) $user_id = $_SESSION["uid"];

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS count
			FROM ttrss_user_entries ue
			WHERE ue.owner_uid = ?");

		$sth->execute([$user_id]);
		$row = $sth->fetch();

		// Handle 'SUM()' returning null if there are no articles/results (e.g. admin user with no feeds)
		return $row["count"] ?? 0;
	}

	static function _get_cat_title(int $cat_id): string {
		switch ($cat_id) {
			case Feeds::CATEGORY_UNCATEGORIZED:
				return __("Uncategorized");
			case Feeds::CATEGORY_SPECIAL:
				return __("Special");
			case Feeds::CATEGORY_LABELS:
				return __("Labels");
			default:
				$cat = ORM::for_table('ttrss_feed_categories')
					->find_one($cat_id);

				if ($cat) {
					return $cat->title;
				} else {
					return "UNKNOWN";
				}
		}
	}

	private static function _get_label_unread(int $label_id, ?int $owner_uid = null): int {
		if (!$owner_uid) $owner_uid = $_SESSION["uid"];

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2
			WHERE owner_uid = ? AND unread = true AND label_id = ? AND article_id = ref_id");

		$sth->execute([$owner_uid, $label_id]);

		if ($row = $sth->fetch()) {
			return $row["unread"];
		} else {
			return 0;
		}
	}

	/**
	 * @param array<string, mixed> $params
	 * @return array<int, mixed> $result, $feed_title, $feed_site_url, $last_error, $last_updated, $highlight_words, $first_id, $is_vfeed, $query_error_override
	 */
	static function _get_headlines($params): array {
		$pdo = Db::pdo();

		// WARNING: due to highly dynamic nature of this query its going to quote parameters
		// right before adding them to SQL part

		$feed = $params["feed"];
		$limit = $params["limit"] ?? 30;
		$view_mode = $params["view_mode"];
		$cat_view = $params["cat_view"] ?? false;
		$search = $params["search"] ?? false;
		$search_language = $params["search_language"] ?? "";
		$override_order = $params["override_order"] ?? false;
		$offset = $params["offset"] ?? 0;
		$owner_uid = $params["owner_uid"] ?? $_SESSION["uid"];
		$since_id = $params["since_id"] ?? 0;
		$include_children = $params["include_children"] ?? false;
		$ignore_vfeed_group = $params["ignore_vfeed_group"] ?? false;
		$override_strategy = $params["override_strategy"] ?? false;
		$override_vfeed = $params["override_vfeed"] ?? false;
		$start_ts = $params["start_ts"] ?? false;
		$check_first_id = $params["check_first_id"] ?? false;
		$skip_first_id_check = $params["skip_first_id_check"] ?? false;
		//$order_by = $params["order_by"] ?? false;

		$ext_tables_part = "";
		$limit_query_part = "";
		$query_error_override = "";

		$search_words = [];

		if ($search) {
			$search_query_part = "";

			PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SEARCH,
				function ($result) use (&$search_query_part, &$search_words) {
					if (!empty($result)) {
						list($search_query_part, $search_words) = $result;
						return true;
					}
				},
				$search);

			// fall back in case of no plugins
			if (!$search_query_part) {
				list($search_query_part, $search_words) = self::_search_to_sql($search, $search_language, $owner_uid);
			}
//i sdelal
			//if (Config::get(Config::DB_TYPE) == "pgsql") {
				//$test_sth = $pdo->prepare("select $search_query_part
					//FROM ttrss_entries, ttrss_user_entries WHERE id = ref_id limit 1");

				//try {
					//$test_sth->execute();
				//} catch (PDOException $e) {
					//// looks like tsquery syntax is invalid
					//$search_query_part = "false";

					//$query_error_override = T_sprintf("Incorrect search syntax: %s.", implode(" ", $search_words));
				//}
			//}

			$search_query_part .= " AND ";
		} else {
			$search_query_part = "";
		}

		if ($since_id) {
			$since_id_part = "ttrss_entries.id > ".$pdo->quote($since_id)." AND ";
		} else {
			$since_id_part = "";
		}

		$view_query_part = "";

		if ($view_mode == "adaptive") {
			if ($search) {
				$view_query_part = " ";
			} else if ($feed != -1) {
				// not Feeds::FEED_STARRED or Feeds::CATEGORY_SPECIAL

				$unread = Feeds::_get_counters($feed, $cat_view, true);

				if ($cat_view && $feed > 0 && $include_children)
					$unread += self::_get_cat_children_unread($feed);

				if ($unread > 0) {
					$view_query_part = " unread = true AND ";
				}
			}
		}

		if ($view_mode == "marked") {
			$view_query_part = " marked = true AND ";
		}

		if ($view_mode == "has_note") {
			$view_query_part = " (note IS NOT NULL AND note != '') AND ";
		}

		if ($view_mode == "published") {
			$view_query_part = " published = true AND ";
		}

		if ($view_mode == "unread" && $feed != Feeds::FEED_RECENTLY_READ) {
			$view_query_part = " unread = true AND ";
		}

		if ($limit > 0) {
			$limit_query_part = "LIMIT " . (int)$limit;
		}

		$allow_archived = false;

		$vfeed_query_part = "";

		/* tags */
		if (!is_numeric($feed)) {
			$query_strategy_part = "true";
			$vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
					id = feed_id) as feed_title,";
		} else if ($feed > 0) {

			if ($cat_view) {

				if ($feed > 0) {
					if ($include_children) {
						# sub-cats
						$subcats = self::_get_child_cats($feed, $owner_uid);
						array_push($subcats, $feed);
						$subcats = array_map("intval", $subcats);

						$query_strategy_part = "cat_id IN (".
							implode(",", $subcats).")";

					} else {
						$query_strategy_part = "cat_id = " . $pdo->quote((string)$feed);
					}

				} else {
					$query_strategy_part = "cat_id IS NULL";
				}

				$vfeed_query_part = "ttrss_feeds.title AS feed_title,";

			} else {
				$query_strategy_part = "feed_id = " . $pdo->quote((string)$feed);
			}
		} else if ($feed == Feeds::FEED_ARCHIVED && !$cat_view) { // archive virtual feed
			$query_strategy_part = "feed_id IS NULL";
			$allow_archived = true;
		} else if ($feed == Feeds::CATEGORY_UNCATEGORIZED && $cat_view) { // uncategorized
			$query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL";
			$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
		} else if ($feed == -1) { // starred virtual feed, Feeds::FEED_STARRED or Feeds::CATEGORY_SPECIAL
			$query_strategy_part = "marked = true";
			$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
			$allow_archived = true;

			if (!$override_order) {
				$override_order = "last_marked DESC, date_entered DESC, updated DESC";
			}

		} else if ($feed == -2) { // published virtual feed (Feeds::FEED_PUBLISHED) OR labels category (Feeds::CATEGORY_LABELS)

			if (!$cat_view) {
				$query_strategy_part = "published = true";
				$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
				$allow_archived = true;

				if (!$override_order) {
					$override_order = "last_published DESC, date_entered DESC, updated DESC";
				}

			} else {
				$vfeed_query_part = "ttrss_feeds.title AS feed_title,";

				$ext_tables_part = "ttrss_labels2,ttrss_user_labels2,";

				$query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND
						ttrss_user_labels2.article_id = ref_id";

			}
		} else if ($feed == Feeds::FEED_RECENTLY_READ) { // recently read
			$query_strategy_part = "unread = false AND last_read IS NOT NULL";

			if (Config::get(Config::DB_TYPE) == "pgsql") {
				$query_strategy_part .= " AND last_read > NOW() - INTERVAL '1 DAY' ";
			} else {
				$query_strategy_part .= " AND last_read > DATE_SUB(NOW(), INTERVAL 1 DAY) ";
			}

			$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
			$allow_archived = true;
			$ignore_vfeed_group = true;

			if (!$override_order) $override_order = "last_read DESC";

		} else if ($feed == Feeds::FEED_FRESH) { // fresh virtual feed
			$query_strategy_part = "unread = true AND score >= 0";

			$intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE, $owner_uid);

			if (Config::get(Config::DB_TYPE) == "pgsql") {
				$query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
			} else {
				$query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
			}

			$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
		} else if ($feed == Feeds::FEED_ALL) { // all articles virtual feed
			$allow_archived = true;
			$query_strategy_part = "true";
			$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
		} else if ($feed <= LABEL_BASE_INDEX) { // labels
			$label_id = Labels::feed_to_label_id($feed);

			$query_strategy_part = "label_id = $label_id AND
					ttrss_labels2.id = ttrss_user_labels2.label_id AND
					ttrss_user_labels2.article_id = ref_id";

			$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
			$ext_tables_part = "ttrss_labels2,ttrss_user_labels2,";
			$allow_archived = true;

		} else {
			$query_strategy_part = "true";
		}

		$order_by = "score DESC, date_entered DESC, updated DESC";

		if ($override_order) {
			$order_by = $override_order;
		}

		if ($override_strategy) {
			$query_strategy_part = $override_strategy;
		}

		if ($override_vfeed) {
			$vfeed_query_part = $override_vfeed;
		}

		$feed_site_url = "";
		$last_error = "";
		$last_updated = "";

		if ($search) {
			$feed_title = T_sprintf("Search results: %s", $search);
		} else {
			if ($cat_view) {
				$feed_title = self::_get_cat_title($feed);
			} else {
				if (is_numeric($feed) && $feed > 0) {
					$ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated
							FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
					$ssth->execute([$feed, $owner_uid]);
                    $row = $ssth->fetch();

					$feed_title = $row["title"];
					$feed_site_url = $row["site_url"];
					$last_error = $row["last_error"];
					$last_updated = $row["last_updated"];
				} else {
					$feed_title = self::_get_title($feed);
				}
			}
		}

		$content_query_part = "content, ";

		if ($limit_query_part) {
			$offset_query_part = "OFFSET " . (int)$offset;
		} else {
			$offset_query_part = "";
		}

		if ($start_ts) {
			$start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts));
			$start_ts_query_part = "date_entered >= '$start_ts_formatted' AND";
		} else {
			$start_ts_query_part = "";
		}

		$first_id = 0;

		if (Config::get(Config::DB_TYPE) == "pgsql") {
			$yyiw_qpart = "to_char(date_entered, 'IYYY-IW') AS yyiw";
		} else {
			$yyiw_qpart = "date_format(date_entered, '%Y-%u') AS yyiw";
		}

		if (is_numeric($feed)) {
			// proper override_order applied above
			if ($vfeed_query_part && !$ignore_vfeed_group && get_pref(Prefs::VFEED_GROUP_BY_FEED, $owner_uid)) {

				if (!(in_array($feed, self::NEVER_GROUP_BY_DATE) && !$cat_view)) {
					$yyiw_desc = $order_by == "date_reverse" ? "" : "desc";
					$yyiw_order_qpart = "yyiw $yyiw_desc, ";
				} else {
					$yyiw_order_qpart = "";
				}

				if (!$override_order) {
					$order_by = "$yyiw_order_qpart ttrss_feeds.title, $order_by";
				} else {
					$order_by = "$yyiw_order_qpart ttrss_feeds.title, $override_order";
				}
			}

			if (!$allow_archived) {
				$from_qpart = "{$ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id), ttrss_feeds";
				$feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND";

			} else {
				$from_qpart = "{$ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id)
						LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)";
				$feed_check_qpart = "";
			}

			if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,";

			$first_id_query_strategy_part = $query_strategy_part;

			if ($feed == Feeds::FEED_FRESH)
				$first_id_query_strategy_part = "true";

			if (Config::get(Config::DB_TYPE) == "pgsql") {
				$sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND";

				$distinct_columns = str_replace("desc", "", strtolower($order_by));
				$distinct_qpart = "DISTINCT ON (id, $distinct_columns)";
			} else {
				$sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND";
				$distinct_qpart = "DISTINCT"; //fallback
			}

			// except for Labels category
			if (get_pref(Prefs::HEADLINES_NO_DISTINCT, $owner_uid) && !($feed == Feeds::CATEGORY_LABELS && $cat_view)) {
				$distinct_qpart = "";
			}

			if (!$search && !$skip_first_id_check) {
				// if previous topmost article id changed that means our current pagination is no longer valid
				$query = "SELECT
							ttrss_entries.id,
							date_entered,
							$yyiw_qpart,
							guid,
							ttrss_entries.title,
							ttrss_feeds.title,
							updated,
							score,
							marked,
							published,
							last_marked,
							last_published,
							last_read
						FROM
							$from_qpart
						WHERE
						$feed_check_qpart
						ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
						$search_query_part
						$start_ts_query_part
						$since_id_part
						$sanity_interval_qpart
						$first_id_query_strategy_part ORDER BY $order_by LIMIT 1";

				if (!empty($_REQUEST["debug"])) {
					print "\n*** FIRST ID QUERY ***\n$query\n";
				}

				$res = $pdo->query($query);

				if (!empty($res) && $row = $res->fetch()) {
					$first_id = (int)$row["id"];

					if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) {
						return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override);
					}
				}
			}

			$query = "SELECT $distinct_qpart
						ttrss_entries.id AS id,
						date_entered,
						$yyiw_qpart,
						guid,
						ttrss_entries.title,
						updated,
						label_cache,
						tag_cache,
						always_display_enclosures,
						site_url,
						note,
						num_comments,
						comments,
						int_id,
						uuid,
						lang,
						hide_images,
						unread,feed_id,marked,published,link,last_read,
						last_marked, last_published,
						$vfeed_query_part
						$content_query_part
						author,score,
						(SELECT count(label_id) FROM ttrss_user_labels2 WHERE article_id = ttrss_entries.id) AS num_labels,
						(SELECT count(id) FROM ttrss_enclosures WHERE post_id = ttrss_entries.id) AS num_enclosures
					FROM
						$from_qpart
					WHERE
					$feed_check_qpart
					ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
					$search_query_part
					$start_ts_query_part
					$view_query_part
					$since_id_part
					$query_strategy_part ORDER BY $order_by
					$limit_query_part $offset_query_part";

			//if ($_REQUEST["debug"]) print $query;

			if (!empty($_REQUEST["debug"])) {
				print "\n*** HEADLINES QUERY ***\n$query\n";
			}

			$res = $pdo->query($query);

		} else {
			// browsing by tag

			if (get_pref(Prefs::HEADLINES_NO_DISTINCT, $owner_uid)) {
				$distinct_qpart = "";
			} else {
				if (Config::get(Config::DB_TYPE) == "pgsql") {
					$distinct_columns = str_replace("desc", "", strtolower($order_by));
					$distinct_qpart = "DISTINCT ON (id, $distinct_columns)";
				} else {
					$distinct_qpart = "DISTINCT"; //fallback
				}
			}

			$query = "SELECT $distinct_qpart
							ttrss_entries.id AS id,
							date_entered,
							$yyiw_qpart,
							guid,
							ttrss_entries.title,
							updated,
							label_cache,
							tag_cache,
							always_display_enclosures,
							site_url,
							note,
							num_comments,
							comments,
							int_id,
							uuid,
							lang,
							hide_images,
							unread,feed_id,marked,published,link,last_read,
							last_marked, last_published,
							$since_id_part
							$vfeed_query_part
							$content_query_part
							author, score,
							(SELECT count(label_id) FROM ttrss_user_labels2 WHERE article_id = ttrss_entries.id) AS num_labels,
							(SELECT count(id) FROM ttrss_enclosures WHERE post_id = ttrss_entries.id) AS num_enclosures
						FROM ttrss_entries,
							ttrss_user_entries LEFT JOIN ttrss_feeds ON (ttrss_feeds.id = ttrss_user_entries.feed_id),
							ttrss_tags
						WHERE
							ref_id = ttrss_entries.id AND
							ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
							post_int_id = int_id AND
							tag_name = ".$pdo->quote($feed)." AND
							$view_query_part
							$search_query_part
							$start_ts_query_part
							$query_strategy_part ORDER BY $order_by
							$limit_query_part $offset_query_part";

			//if ($_REQUEST["debug"]) print $query;

			if (!empty($_REQUEST["debug"])) {
				print "\n*** TAGS QUERY ***\n$query\n";
			}

			$res = $pdo->query($query);
		}

		return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override);
	}

	/**
	 * @return array<int, int>
	 */
	static function _get_parent_cats(int $cat, int $owner_uid): array {
		$rv = array();

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT parent_cat FROM ttrss_feed_categories
			WHERE id = ? AND parent_cat IS NOT NULL AND owner_uid = ?");
		$sth->execute([$cat, $owner_uid]);

		while ($line = $sth->fetch()) {
			$cat = (int) $line["parent_cat"];
			array_push($rv, $cat, ...self::_get_parent_cats($cat, $owner_uid));
		}

		return $rv;
	}

	/**
	 * @return array<int, int>
	 */
	static function _get_child_cats(int $cat, int $owner_uid): array {
		$rv = array();

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories
			WHERE parent_cat = ? AND owner_uid = ?");
		$sth->execute([$cat, $owner_uid]);

		while ($line = $sth->fetch()) {
			array_push($rv, $line["id"], ...self::_get_child_cats($line["id"], $owner_uid));
		}

		return $rv;
	}

	/**
	 * @param array<int, int> $feeds
	 * @return array<int, int>
	 */
	static function _cats_of(array $feeds, int $owner_uid, bool $with_parents = false): array {
		if (count($feeds) == 0)
			return [];

		$pdo = Db::pdo();

		$feeds_qmarks = arr_qmarks($feeds);

		$sth = $pdo->prepare("SELECT DISTINCT cat_id, fc.parent_cat FROM ttrss_feeds f LEFT JOIN ttrss_feed_categories fc
				ON (fc.id = f.cat_id)
				WHERE f.owner_uid = ? AND f.id IN ($feeds_qmarks)");
		$sth->execute([$owner_uid, ...$feeds]);

		$rv = [];

		if ($row = $sth->fetch()) {
			$cat_id = (int) $row["cat_id"];
			$rv[] = $cat_id;
			array_push($rv, (int)$row["cat_id"]);

			if ($with_parents && $row["parent_cat"]) {
				array_push($rv, ...self::_get_parent_cats($cat_id, $owner_uid));
			}
		}

		$rv = array_unique($rv);

		return $rv;
	}

	// returns Uncategorized as 0
	static function _cat_of(int $feed) : int {
		$feed = ORM::for_table('ttrss_feeds')->find_one($feed);

		if ($feed) {
			return (int)$feed->cat_id;
		} else {
			return -1;
		}
	}

	private function _color_of(string $name): string {
		$colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b",
			"#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416",
			"#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ];

		$sum = 0;

		for ($i = 0; $i < strlen($name); $i++) {
			$sum += ord($name[$i]);
		}

		$sum %= count($colormap);

		return $colormap[$sum];
	}

	/**
	 * @return array<string, string> array of feed URL -> feed title
	 */
	private static function _get_feeds_from_html(string $url, string $content): array {
		$url = UrlHelper::validate($url);
		$baseUrl = substr($url, 0, strrpos($url, '/') + 1);

		$feedUrls = [];

		$doc = new DOMDocument();
		if (@$doc->loadHTML($content)) {
			$xpath = new DOMXPath($doc);
			$entries = $xpath->query('/html/*[self::head or self::body]/link[@rel="alternate" and '.
				'(contains(@type,"rss") or contains(@type,"atom"))]|/html/*[self::head or self::body]/link[@rel="feed"]');

			/** @var DOMElement|null $entry */
			foreach ($entries as $entry) {
				if ($entry->hasAttribute('href')) {
					$title = $entry->getAttribute('title');
					if ($title == '') {
						$title = $entry->getAttribute('type');
					}
					$feedUrl = UrlHelper::rewrite_relative($baseUrl, $entry->getAttribute('href'));
					$feedUrls[$feedUrl] = $title;
				}
			}
		}
		return $feedUrls;
	}

	static function _is_html(string $content): bool {
		return preg_match("/<html|DOCTYPE html/i", substr($content, 0, 8192)) !== 0;
	}

	static function _remove_cat(int $id, int $owner_uid): void {
		$cat = ORM::for_table('ttrss_feed_categories')
			->where('owner_uid', $owner_uid)
			->find_one($id);

		if ($cat)
			$cat->delete();
	}

	static function _add_cat(string $title, int $owner_uid, ?int $parent_cat = null, int $order_id = 0): bool {

		$cat = ORM::for_table('ttrss_feed_categories')
			->where('owner_uid', $owner_uid)
			->where('parent_cat', $parent_cat)
			->where('title', $title)
			->find_one();

		if (!$cat) {
			$cat = ORM::for_table('ttrss_feed_categories')->create();

			$cat->set([
				'owner_uid' => $owner_uid,
				'parent_cat' => $parent_cat,
				'order_id' => $order_id,
				'title' => $title,
			]);

			return $cat->save();
		}

		return false;
	}

	static function _clear_access_keys(int $owner_uid): void {
		ORM::for_table('ttrss_access_keys')
			->where('owner_uid', $owner_uid)
			->delete_many();
	}

	/**
	 * @param string $feed_id may be a feed ID or tag
	 *
	 * @see Handler_Public#generate_syndicated_feed()
	 */
	static function _update_access_key(string $feed_id, bool $is_cat, int $owner_uid): ?string {
		ORM::for_table('ttrss_access_keys')
			->where('owner_uid', $owner_uid)
			->where('feed_id', $feed_id)
			->where('is_cat', $is_cat)
			->delete_many();

		return self::_get_access_key($feed_id, $is_cat, $owner_uid);
	}

	/**
	 * @param string $feed_id may be a feed ID or tag
	 *
	 * @see Handler_Public#generate_syndicated_feed()
	 */
	static function _get_access_key(string $feed_id, bool $is_cat, int $owner_uid): ?string {
		$key = ORM::for_table('ttrss_access_keys')
			->where('owner_uid', $owner_uid)
			->where('feed_id', $feed_id)
			->where('is_cat', $is_cat)
			->find_one();

		if ($key) {
			return $key->access_key;
		}

		$key = ORM::for_table('ttrss_access_keys')->create();

		$key->owner_uid = $owner_uid;
		$key->feed_id = $feed_id;
		$key->is_cat = $is_cat;
		$key->access_key = uniqid_short();

		if ($key->save()) {
			return $key->access_key;
		}

		return null;
	}

	static function _purge(int $feed_id, int $purge_interval): ?int {

		if (!$purge_interval) $purge_interval = self::_get_purge_interval($feed_id);

		$pdo = Db::pdo();
		$rows_deleted = 0;

		$sth = $pdo->prepare("SELECT owner_uid FROM ttrss_feeds WHERE id = ?");
		$sth->execute([$feed_id]);

		if ($row = $sth->fetch()) {
			$owner_uid = $row["owner_uid"];

			if (Config::get(Config::FORCE_ARTICLE_PURGE) != 0) {
				Debug::log("purge_feed: FORCE_ARTICLE_PURGE is set, overriding interval to " . Config::get(Config::FORCE_ARTICLE_PURGE), Debug::LOG_VERBOSE);
				$purge_unread = true;
				$purge_interval = Config::get(Config::FORCE_ARTICLE_PURGE);
			} else {
				$purge_unread = get_pref(Prefs::PURGE_UNREAD_ARTICLES, $owner_uid);
			}

			$purge_interval = (int) $purge_interval;

			Debug::log("purge_feed: interval $purge_interval days for feed $feed_id, owner: $owner_uid, purge unread: $purge_unread", Debug::LOG_VERBOSE);

			if ($purge_interval <= 0) {
				Debug::log("purge_feed: purging disabled for this feed, nothing to do.", Debug::LOG_VERBOSE);
				return null;
			}

			if (!$purge_unread)
				$query_limit = " unread = false AND ";
			else
				$query_limit = "";

			if (Config::get(Config::DB_TYPE) == "pgsql") {
				$sth = $pdo->prepare("DELETE FROM ttrss_user_entries
					USING ttrss_entries
					WHERE ttrss_entries.id = ref_id AND
					marked = false AND
					feed_id = ? AND
					$query_limit
					ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
				$sth->execute([$feed_id]);

			} else {
				$sth  = $pdo->prepare("DELETE FROM ttrss_user_entries
					USING ttrss_user_entries, ttrss_entries
					WHERE ttrss_entries.id = ref_id AND
					marked = false AND
					feed_id = ? AND
					$query_limit
					ttrss_entries.date_updated < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
				$sth->execute([$feed_id]);

			}

			$rows_deleted = $sth->rowCount();

			Debug::log("purge_feed: deleted $rows_deleted articles.", Debug::LOG_VERBOSE);

		} else {
			Debug::log("purge_feed: owner of $feed_id not found", Debug::LOG_VERBOSE);
		}

		return $rows_deleted;
	}

	private static function _get_purge_interval(int $feed_id): int {
		$feed = ORM::for_table('ttrss_feeds')->find_one($feed_id);

		if ($feed) {
			if ($feed->purge_interval != 0)
				return $feed->purge_interval;
			else
				return get_pref(Prefs::PURGE_OLD_DAYS, $feed->owner_uid);
		} else {
			return -1;
		}
	}

	/**
	 * @return array{0: string, 1: array<int, string>} [$search_query_part, $search_words]
	 */
	private static function _search_to_sql(string $search, string $search_language, int $owner_uid): array {
		// Modify the search string so that 'keyword:"foo bar"' becomes '"keyword:foo bar"'.
		// This is needed so potential command pairs are grouped correctly.
		$search_csv_str = preg_replace('/(-?\w+)\:"(\w+)/', '"$1:$2', trim($search));

		// $keywords will be an array like ['"title:hello world"', 'some', 'words']
		$keywords = str_getcsv($search_csv_str, ' ', '"', '');

		$query_keywords = array();
		$search_words = array();
		$search_query_leftover = array();

		$pdo = Db::pdo();
		
//i sdelal
		//$search_language = $pdo->quote(mb_strtolower($search_language ?: get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE, $owner_uid)));

		/** @var string $k a keyword pair (not yet split) or standalone value */
		foreach ($keywords as $k) {
			if (strpos($k, "-") === 0) {
				$k = substr($k, 1);
				$not = "NOT";
			} else {
				$not = "";
			}

			$keyword_pair = explode(':', mb_strtolower($k), 2);
			$keyword_name = $keyword_pair[0];
			$keyword_value = empty($keyword_pair[1]) ? '' : trim($keyword_pair[1]);

			// NOTE: If there's a keyword match but no keyword value we fall back to doing
			// a search in article title and content.
			switch ($keyword_name) {
				case "title":
					if ($keyword_value) {
						array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ".
							$pdo->quote("%{$keyword_value}%") ."))");
					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						array_push($search_words, $k);
					}
					break;
				case "author":
					if ($keyword_value) {
						array_push($query_keywords, "($not (LOWER(author) LIKE ".
							$pdo->quote("%{$keyword_value}%")."))");
					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						array_push($search_words, $k);
					}
					break;
				case "note":
					if ($keyword_value) {
						if ($keyword_value == "true")
							array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
						else if ($keyword_value == "false")
							array_push($query_keywords, "($not (note IS NULL OR note = ''))");
						else
							array_push($query_keywords, "($not (LOWER(note) LIKE ".
								$pdo->quote("%{$keyword_value}%")."))");
					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						if (!$not) array_push($search_words, $k);
					}
					break;
				case "star":
					if ($keyword_value) {
						if ($keyword_value == "true")
							array_push($query_keywords, "($not (marked = true))");
						else
							array_push($query_keywords, "($not (marked = false))");
					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						if (!$not) array_push($search_words, $k);
					}
					break;
				case "pub":
					if ($keyword_value) {
						if ($keyword_value == "true")
							array_push($query_keywords, "($not (published = true))");
						else
							array_push($query_keywords, "($not (published = false))");
					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						if (!$not) array_push($search_words, $k);
					}
					break;
				case "label":
					if ($keyword_value) {
						$label_id = Labels::find_id($keyword_value, $_SESSION["uid"]);

						if ($label_id) {
							array_push($query_keywords, "($not
								(ttrss_entries.id IN (
									SELECT article_id FROM ttrss_user_labels2 WHERE
										label_id = $label_id)))");
						} else {
							array_push($query_keywords, "(false)");
						}
					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						if (!$not) array_push($search_words, $k);
					}
					break;
				case "unread":
					if ($keyword_value) {
						if ($keyword_value == "true")
							array_push($query_keywords, "($not (unread = true))");
						else
							array_push($query_keywords, "($not (unread = false))");

					} else {
						array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						if (!$not) array_push($search_words, $k);
					}
					break;
				default:
					// @{date} handling
					if (strpos($k, "@") === 0) {
						$user_tz_string = get_pref(Prefs::USER_TIMEZONE, $_SESSION['uid']);
						$orig_ts = strtotime(substr($k, 1));
						$k = date("Y-m-d", TimeHelper::convert_timestamp($orig_ts, $user_tz_string, 'UTC'));

						//$k = date("Y-m-d", strtotime(substr($k, 1)));

						array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH(".$pdo->quote($k).")) $not = ".$pdo->quote($k).")");
					} else {
						// treat as leftover text

						// TODO: handle multiword strings in the fulltext search
						$k = mb_strtolower($k);

						if (Config::get(Config::DB_TYPE) == "pgsql") {
							//i sdelal  postavil odinakovie stroki
							//array_push($search_query_leftover, $not ? "!$k" : $k); // orig
							array_push($search_query_leftover, $not ? "-$k" : $k);
						} else {
							array_push($search_query_leftover, $not ? "-$k" : $k);

							//array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
							//	OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
						}

						if (!$not) array_push($search_words, $k);
					}
			}
		}

//i sdelal
		//if (count($search_query_leftover) > 0) {

			//if (Config::get(Config::DB_TYPE) == "pgsql") {

				//// if there's no joiners consider this a "simple" search and
				//// concatenate everything with &, otherwise don't try to mess with tsquery syntax
				//if (preg_match("/[&|]/", implode(" " , $search_query_leftover))) {
					//$tsquery = $pdo->quote(implode(" ", $search_query_leftover));
				//} else {
					//$tsquery = $pdo->quote(implode(" & ", $search_query_leftover));
				//}

				//array_push($query_keywords,
					//"(tsvector_combined @@ to_tsquery($search_language, $tsquery))");
			//} else {
				//$ft_query = $pdo->quote(implode(" ", $search_query_leftover));

				//array_push($query_keywords,
					//"MATCH (ttrss_entries.title, ttrss_entries.content) AGAINST ($ft_query IN BOOLEAN MODE)");
			//}
		//}
//
		if (count($query_keywords) > 0)
			$search_query_part = implode("AND ", $query_keywords);
		else
			$search_query_part = "false";

		if (!empty($_REQUEST["debug"])) {
			print "\n*** SEARCH_TO_SQL ***\n";
			print "QUERY: $search_query_part\n";
			print "WORDS: " . json_encode($search_words) . "\n";
		}

		return array($search_query_part, $search_words);
	}

	/**
	 * @return array{0: string, 1: bool}
	 */
	static function _order_to_override_query(string $order): array {
		$query = "";
		$skip_first_id = false;

		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE,
			function ($result) use (&$query, &$skip_first_id) {
				list ($query, $skip_first_id) = $result;

				// run until first hard match
				return !empty($query);
			},
			$order);

		if (is_string($query) && $query !== "") {
			return [$query, $skip_first_id];
		}

		switch ($order) {
			case "title":
				$query = "ttrss_entries.title, date_entered, updated";
				break;
			case "date_reverse":
				$query = "updated";
				$skip_first_id = true;
				break;
			case "feed_dates":
				$query = "updated DESC";
				break;
		}

		return [$query, $skip_first_id];
	}

}

<?php
class Pref_Feeds extends Handler_Protected {
	const E_ICON_FILE_TOO_LARGE = 'E_ICON_FILE_TOO_LARGE';
	const E_ICON_RENAME_FAILED = 'E_ICON_RENAME_FAILED';
	const E_ICON_UPLOAD_FAILED = 'E_ICON_UPLOAD_FAILED';
	const E_ICON_UPLOAD_SUCCESS = 'E_ICON_UPLOAD_SUCCESS';

	function csrf_ignore(string $method): bool {
		$csrf_ignored = array("index", "getfeedtree", "savefeedorder");

		return array_search($method, $csrf_ignored) !== false;
	}

	/**
	 * @return array<int, string>
	 */
	public static function get_ts_languages(): array {
		if (Config::get(Config::DB_TYPE) == 'pgsql') {
			return array_map('ucfirst',
				array_column(ORM::for_table('pg_ts_config')->select('cfgname')->find_array(), 'cfgname'));
		}

		return [];
	}

	function renameCat(): void {
		$cat = ORM::for_table("ttrss_feed_categories")
			->where("owner_uid", $_SESSION["uid"])
			->find_one($_REQUEST['id']);

		$title = clean($_REQUEST['title']);

		if ($cat && $title) {
			$cat->title = $title;
			$cat->save();
		}
	}

	/**
	 * @return array<int, array<string, bool|int|string>>
	 */
	private function get_category_items(int $cat_id, string $search): array {

		// first one is set by API
		$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? false) ||
			(clean($_REQUEST['mode'] ?? 0) != 2 && !$search);

		$items = [];

		$feed_categories = ORM::for_table('ttrss_feed_categories')
			->select_many('id', 'title')
			->where(['owner_uid' => $_SESSION['uid'], 'parent_cat' => $cat_id])
			->order_by_asc('order_id')
			->order_by_asc('title')
			->find_many();

		foreach ($feed_categories as $feed_category) {
			$cat = [
				'id' => 'CAT:' . $feed_category->id,
				'bare_id' => (int)$feed_category->id,
				'name' => $feed_category->title,
				'items' => $this->get_category_items($feed_category->id, $search),
				'checkbox' => false,
				'type' => 'category',
				'unread' => -1,
				'child_unread' => -1,
				'auxcounter' => -1,
				'parent_id' => $cat_id,
			];

			$num_children = $this->calculate_children_count($cat);
			$cat['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);

			if ($num_children > 0 || $show_empty_cats)
				array_push($items, $cat);
		}

		$feeds_obj = ORM::for_table('ttrss_feeds')
			->select_many('id', 'title', 'last_error', 'update_interval')
			->select_expr(SUBSTRING_FOR_DATE.'(last_updated,1,19)', 'last_updated')
			->where(['cat_id' => $cat_id, 'owner_uid' => $_SESSION['uid']])
			->order_by_asc('order_id')
			->order_by_asc('title');

		if ($search) {
			$feeds_obj->where_raw('(LOWER(title) LIKE ? OR LOWER(feed_url) LIKE LOWER(?))', ["%$search%", "%$search%"]);
		}

		foreach ($feeds_obj->find_many() as $feed) {
			array_push($items, [
				'id' => 'FEED:' . $feed->id,
				'bare_id' => (int) $feed->id,
				'auxcounter' => -1,
				'name' => $feed->title,
				'checkbox' => false,
				'unread' => -1,
				'error' => $feed->last_error,
				'icon' => Feeds::_get_icon($feed->id),
				'param' => TimeHelper::make_local_datetime($feed->last_updated, true),
				'updates_disabled' => (int)($feed->update_interval < 0),
			]);
		}

		return $items;
	}

	function getfeedtree(): void {
		print json_encode($this->_makefeedtree());
	}

	/**
	 * @return array<string, array<int|string, mixed>|string>
	 */
	function _makefeedtree(): array {

		if (clean($_REQUEST['mode'] ?? 0) != 2)
			$search = $_SESSION["prefs_feed_search"] ?? "";
		else
			$search = $_REQUEST['search'] ?? '';

		$root = array();
		$root['id'] = 'root';
		$root['name'] = __('Feeds');
		$root['items'] = array();
		$root['param'] = 0;
		$root['type'] = 'category';

		$enable_cats = get_pref(Prefs::ENABLE_FEED_CATS);

		if (clean($_REQUEST['mode'] ?? 0) == 2) {

			if ($enable_cats) {
				$cat = $this->feedlist_init_cat(Feeds::CATEGORY_SPECIAL);
			} else {
				$cat['items'] = array();
			}

			foreach ([Feeds::FEED_ALL, Feeds::FEED_FRESH, Feeds::FEED_STARRED, Feeds::FEED_PUBLISHED,
				Feeds::FEED_ARCHIVED, Feeds::FEED_RECENTLY_READ] as $feed_id) {
				array_push($cat['items'], $this->feedlist_init_feed($feed_id));
			}

			/* Plugin feeds for -1 (Feeds::CATEGORY_SPECIAL) */

			$feeds = PluginHost::getInstance()->get_feeds(Feeds::CATEGORY_SPECIAL);

			if ($feeds) {
				foreach ($feeds as $feed) {
					$feed_id = PluginHost::pfeed_to_feed_id($feed['id']);

					$item = array();
					$item['id'] = 'FEED:' . $feed_id;
					$item['bare_id'] = (int)$feed_id;
					$item['auxcounter'] = -1;
					$item['name'] = $feed['title'];
					$item['checkbox'] = false;
					$item['error'] = '';
					$item['icon'] = $feed['icon'];

					$item['param'] = '';
					$item['unread'] = -1;
					$item['type'] = 'feed';

					array_push($cat['items'], $item);
				}
			}

			if ($enable_cats) {
				array_push($root['items'], $cat);
			} else {
				array_push($root['items'], ...$cat['items']);
			}

			$sth = $this->pdo->prepare("SELECT * FROM
				ttrss_labels2 WHERE owner_uid = ? ORDER by caption");
			$sth->execute([$_SESSION['uid']]);

			if (get_pref(Prefs::ENABLE_FEED_CATS)) {
				$cat = $this->feedlist_init_cat(Feeds::CATEGORY_LABELS);
			} else {
				$cat['items'] = [];
			}

			$labels = ORM::for_table('ttrss_labels2')
				->where('owner_uid', $_SESSION['uid'])
				->order_by_asc('caption')
				->find_many();

			if (count($labels)) {
				foreach ($labels as $label) {
					$label_id = Labels::label_to_feed_id($label->id);
					$feed = $this->feedlist_init_feed($label_id, null, false);
					$feed['fg_color'] = $label->fg_color;
					$feed['bg_color'] = $label->bg_color;
					array_push($cat['items'], $feed);
				}

				if ($enable_cats) {
					array_push($root['items'], $cat);
				} else {
					array_push($root['items'], ...$cat['items']);
				}
			}
		}

		if ($enable_cats) {
			$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? false) ||
				(clean($_REQUEST['mode'] ?? 0) != 2 && !$search);

			$feed_categories = ORM::for_table('ttrss_feed_categories')
				->select_many('id', 'title')
				->where('owner_uid', $_SESSION['uid'])
				->where_null('parent_cat')
				->order_by_asc('order_id')
				->order_by_asc('title')
				->find_many();

			foreach ($feed_categories as $feed_category) {
				$cat = [
					'id' => 'CAT:' . $feed_category->id,
					'bare_id' => (int) $feed_category->id,
					'auxcounter' => -1,
					'name' => $feed_category->title,
					'items' => $this->get_category_items($feed_category->id, $search),
					'checkbox' => false,
					'type' => 'category',
					'unread' => -1,
					'child_unread' => -1,
				];

				$num_children = $this->calculate_children_count($cat);
				$cat['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);

				if ($num_children > 0 || $show_empty_cats)
					array_push($root['items'], $cat);

				//$root['param'] += count($cat['items']);
			}

			/**
			 * Uncategorized is a special case.
			 *
			 * Define a minimal array shape to help PHPStan with the type of $cat['items']
			 * @var array{items: array<int, array<string, mixed>>} $cat
			 */
			$cat = [
				'id' => 'CAT:0',
				'bare_id' => 0,
				'auxcounter' => -1,
				'name' => __('Uncategorized'),
				'items' => [],
				'type' => 'category',
				'checkbox' => false,
				'unread' => -1,
				'child_unread' => -1,
			];

			$feeds_obj = ORM::for_table('ttrss_feeds')
				->select_many('id', 'title', 'last_error', 'update_interval')
				->select_expr(SUBSTRING_FOR_DATE.'(last_updated,1,19)', 'last_updated')
				->where('owner_uid', $_SESSION['uid'])
				->where_null('cat_id')
				->order_by_asc('order_id')
				->order_by_asc('title');

			if ($search) {
				$feeds_obj->where_raw('(LOWER(title) LIKE ? OR LOWER(feed_url) LIKE LOWER(?))', ["%$search%", "%$search%"]);
			}

			foreach ($feeds_obj->find_many() as $feed) {
				array_push($cat['items'], [
					'id' => 'FEED:' . $feed->id,
					'bare_id' => (int) $feed->id,
					'auxcounter' => -1,
					'name' => $feed->title,
					'checkbox' => false,
					'error' => $feed->last_error,
					'icon' => Feeds::_get_icon($feed->id),
					'param' => TimeHelper::make_local_datetime($feed->last_updated, true),
					'unread' => -1,
					'type' => 'feed',
					'updates_disabled' => (int)($feed->update_interval < 0),
				]);
			}

			$cat['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));

			if (count($cat['items']) > 0 || $show_empty_cats)
				array_push($root['items'], $cat);

			$num_children = $this->calculate_children_count($root);
			$root['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);

		} else {
			$feeds_obj = ORM::for_table('ttrss_feeds')
				->select_many('id', 'title', 'last_error', 'update_interval')
				->select_expr(SUBSTRING_FOR_DATE.'(last_updated,1,19)', 'last_updated')
				->where('owner_uid', $_SESSION['uid'])
				->order_by_asc('order_id')
				->order_by_asc('title');

			if ($search) {
				$feeds_obj->where_raw('(LOWER(title) LIKE ? OR LOWER(feed_url) LIKE LOWER(?))', ["%$search%", "%$search%"]);
			}

			foreach ($feeds_obj->find_many() as $feed) {
				array_push($root['items'], [
					'id' => 'FEED:' . $feed->id,
					'bare_id' => (int) $feed->id,
					'auxcounter' => -1,
					'name' => $feed->title,
					'checkbox' => false,
					'error' => $feed->last_error,
					'icon' => Feeds::_get_icon($feed->id),
					'param' => TimeHelper::make_local_datetime($feed->last_updated, true),
					'unread' => -1,
					'type' => 'feed',
					'updates_disabled' => (int)($feed->update_interval < 0),
				]);
			}

			$root['param'] = sprintf(_ngettext('(%d feed)', '(%d feeds)', count($root['items'])), count($root['items']));
		}

		return [
			'identifier' => 'id',
			'label' => 'name',
			'items' => clean($_REQUEST['mode'] ?? 0) != 2 ? [$root] : $root['items'],
		];
	}

	function catsortreset(): void {
		$sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
				SET order_id = 0 WHERE owner_uid = ?");
		$sth->execute([$_SESSION['uid']]);
	}

	function feedsortreset(): void {
		$sth = $this->pdo->prepare("UPDATE ttrss_feeds
				SET order_id = 0 WHERE owner_uid = ?");
		$sth->execute([$_SESSION['uid']]);
	}

	/**
	 * @param array<string, mixed> $data_map
	 */
	private function process_category_order(array &$data_map, string $item_id = '', string $parent_id = '', int $nest_level = 0): void {

		$prefix = "";
		for ($i = 0; $i < $nest_level; $i++)
			$prefix .= "   ";

		Debug::log("$prefix C: $item_id P: $parent_id");

		$bare_item_id = substr($item_id, strpos($item_id, ':')+1);

		if ($item_id != 'root') {
			if ($parent_id && $parent_id != 'root') {
				$parent_bare_id = substr($parent_id, strpos($parent_id, ':')+1);
				$parent_qpart = $parent_bare_id;
			} else {
				$parent_qpart = null;
			}

			$feed_category = ORM::for_table('ttrss_feed_categories')
				->where('owner_uid', $_SESSION['uid'])
				->find_one($bare_item_id);

			if ($feed_category) {
				$feed_category->parent_cat = $parent_qpart;
				$feed_category->save();
			}
		}

		$order_id = 1;

		$cat = ($data_map[$item_id] ?? false);

		if ($cat && is_array($cat)) {
			foreach ($cat as $item) {
				$id = $item['_reference'];
				$bare_id = substr($id, strpos($id, ':')+1);

				Debug::log("$prefix [$order_id] $id/$bare_id");

				if ($item['_reference']) {

					if (strpos($id, "FEED") === 0) {

						$feed = ORM::for_table('ttrss_feeds')
							->where('owner_uid', $_SESSION['uid'])
							->find_one($bare_id);

						if ($feed) {
							$feed->order_id = $order_id;
							$feed->cat_id = ($item_id != "root" && $bare_item_id) ? $bare_item_id : null;
							$feed->save();
						}
					} else if (strpos($id, "CAT:") === 0) {
						$this->process_category_order($data_map, $item['_reference'], $item_id,
							$nest_level+1);

						$feed_category = ORM::for_table('ttrss_feed_categories')
							->where('owner_uid', $_SESSION['uid'])
							->find_one($bare_id);

						if ($feed_category) {
							$feed_category->order_id = $order_id;
							$feed_category->save();
						}
					}
				}

				++$order_id;
			}
		}
	}

	function savefeedorder(): void {
		$data = json_decode($_POST['payload'], true);

		#file_put_contents("/tmp/saveorder.json", clean($_POST['payload']));
		#$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);

		if (!is_array($data['items']))
			$data['items'] = json_decode($data['items'], true);

#		print_r($data['items']);

		if (is_array($data) && is_array($data['items'])) {
#			$cat_order_id = 0;

			/** @var array<int, mixed> */
			$data_map = array();
			$root_item = '';

			foreach ($data['items'] as $item) {

#				if ($item['id'] != 'root') {
					if (is_array($item['items'] ?? false)) {
						if (isset($item['items']['_reference'])) {
							$data_map[$item['id']] = array($item['items']);
						} else {
							$data_map[$item['id']] = $item['items'];
						}
					}
				if ($item['id'] == 'root') {
					$root_item = $item['id'];
				}
			}

			$this->process_category_order($data_map, $root_item);
		}
	}

	function removeIcon(): void {
		$feed_id = (int) $_REQUEST["feed_id"];

		$cache = DiskCache::instance('feed-icons');

		$feed = ORM::for_table('ttrss_feeds')
			->where('owner_uid', $_SESSION['uid'])
			->find_one($feed_id);

		if ($feed && $cache->exists((string)$feed_id)) {
			if ($cache->remove((string)$feed_id)) {
				$feed->set([
					'favicon_avg_color' => null,
					'favicon_last_checked' => '1970-01-01',
					'favicon_is_custom' => false,
				]);
				$feed->save();
			}
		}
	}

	function uploadIcon(): void {
		$feed_id = (int) $_REQUEST['feed_id'];
		$tmp_file = tempnam(Config::get(Config::CACHE_DIR) . '/upload', 'icon');

		// default value
		$rc = self::E_ICON_UPLOAD_FAILED;

		$feed = ORM::for_table('ttrss_feeds')
			->where('owner_uid', $_SESSION['uid'])
			->find_one($feed_id);

		if ($feed && $tmp_file && move_uploaded_file($_FILES['icon_file']['tmp_name'], $tmp_file)) {
			if (filesize($tmp_file) < Config::get(Config::MAX_FAVICON_FILE_SIZE)) {

				$cache = DiskCache::instance('feed-icons');

				if ($cache->put((string)$feed_id, file_get_contents($tmp_file))) {

					$feed->set([
						'favicon_avg_color' => null,
						'favicon_is_custom' => true,
					]);

					if ($feed->save()) {
						$rc = self::E_ICON_UPLOAD_SUCCESS;
					}

				} else {
					$rc = self::E_ICON_RENAME_FAILED;
				}

				@unlink($tmp_file);

			} else {
				$rc = self::E_ICON_FILE_TOO_LARGE;
			}
		}

		if (file_exists($tmp_file))
			unlink($tmp_file);

		print json_encode(['rc' => $rc, 'icon_url' =>
			Feeds::_get_icon($feed_id) . "?ts=" . time() ]);
	}

	function editfeed(): void {
		global $purge_intervals;
		global $update_intervals;

		$feed_id = (int)clean($_REQUEST["id"]);

		$row = ORM::for_table('ttrss_feeds')
			->where("owner_uid", $_SESSION["uid"])
			->find_one($feed_id)->as_array();

		if ($row) {

			ob_start();
			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_EDIT_FEED, $feed_id);
			$plugin_data = trim((string)ob_get_contents());
			ob_end_clean();

			$row["icon"] = Feeds::_get_icon($feed_id);

			$local_update_intervals = $update_intervals;
			$local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref(Prefs::DEFAULT_UPDATE_INTERVAL)]);

			if (Config::get(Config::FORCE_ARTICLE_PURGE) == 0) {
				$local_purge_intervals = $purge_intervals;
				$default_purge_interval = get_pref(Prefs::PURGE_OLD_DAYS);

				if ($default_purge_interval > 0)
				$local_purge_intervals[0] .= " " . T_nsprintf('(%d day)', '(%d days)', $default_purge_interval, $default_purge_interval);
			else
				$local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled"));

			} else {
				$purge_interval = Config::get(Config::FORCE_ARTICLE_PURGE);
				$local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ];
			}

			$user = ORM::for_table("ttrss_users")->find_one($_SESSION["uid"]);

			print json_encode([
				"feed" => $row,
				"cats" => [
					"enabled" => get_pref(Prefs::ENABLE_FEED_CATS),
					"select" => \Controls\select_feeds_cats("cat_id", $row["cat_id"]),
				],
				"plugin_data" => $plugin_data,
				"force_purge" => (int)Config::get(Config::FORCE_ARTICLE_PURGE),
				"intervals" => [
					"update" => $local_update_intervals,
					"purge" => $local_purge_intervals,
				],
				"user" => [
					"access_level" => $user->access_level
				],
				"lang" => [
					"enabled" => Config::get(Config::DB_TYPE) == "pgsql",
					"default" => get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE),
					"all" => $this::get_ts_languages(),
					]
				]);
		}
	}

	private function _batch_toggle_checkbox(string $name): string {
		return \Controls\checkbox_tag("", false, "",
					["data-control-for" => $name, "title" => __("Check to enable field"), "onchange" => "App.dialogOf(this).toggleField(this)"]);
	}

	function editfeeds(): void {
		global $purge_intervals;
		global $update_intervals;

		$feed_ids = clean($_REQUEST["ids"]);

		$local_update_intervals = $update_intervals;
		$local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref(Prefs::DEFAULT_UPDATE_INTERVAL)]);

		$local_purge_intervals = $purge_intervals;
		$default_purge_interval = get_pref(Prefs::PURGE_OLD_DAYS);

		if ($default_purge_interval > 0)
			$local_purge_intervals[0] .= " " . T_sprintf("(%d days)", $default_purge_interval);
		else
			$local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled"));

		$options = [
			"include_in_digest" => __('Include in e-mail digest'),
			"always_display_enclosures" => __('Always display image attachments'),
			"hide_images" => __('Do not embed media'),
			"cache_images" => __('Cache media'),
			"mark_unread_on_update" => __('Mark updated articles as unread')
		];

		print_notice("Enable the options you wish to apply using checkboxes on the right.");
		?>

		<?= \Controls\hidden_tag("ids", $feed_ids) ?>
		<?= \Controls\hidden_tag("op", "Pref_Feeds") ?>
		<?= \Controls\hidden_tag("method", "batchEditSave") ?>

		<div dojoType="dijit.layout.TabContainer" style="height : 450px">
			<div dojoType="dijit.layout.ContentPane" title="<?= __('General') ?>">
				<section>
				<?php if (get_pref(Prefs::ENABLE_FEED_CATS)) { ?>
					<fieldset>
						<label><?= __('Place in category:') ?></label>
						<?= \Controls\select_feeds_cats("cat_id", null, ['disabled' => '1']) ?>
						<?= $this->_batch_toggle_checkbox("cat_id") ?>
					</fieldset>
				<?php } ?>

				<?php	if (Config::get(Config::DB_TYPE) == "pgsql") { ?>
					<fieldset>
						<label><?= __('Language:') ?></label>
						<?= \Controls\select_tag("feed_language", "", $this::get_ts_languages(), ["disabled"=> 1]) ?>
						<?= $this->_batch_toggle_checkbox("feed_language") ?>
					</fieldset>
				<?php } ?>
				</section>

				<hr/>

				<section>
					<fieldset>
						<label><?= __("Update interval:") ?></label>
						<?= \Controls\select_hash("update_interval", "", $local_update_intervals, ["disabled" => 1]) ?>
						<?= $this->_batch_toggle_checkbox("update_interval") ?>
					</fieldset>

					<?php if (Config::get(Config::FORCE_ARTICLE_PURGE) == 0) { ?>
						<fieldset>
							<label><?= __('Article purging:') ?></label>
							<?= \Controls\select_hash("purge_interval", "", $local_purge_intervals, ["disabled" => 1]) ?>
							<?= $this->_batch_toggle_checkbox("purge_interval") ?>
						</fieldset>
					<?php } ?>
				</section>
			</div>
			<div dojoType="dijit.layout.ContentPane" title="<?= __('Authentication') ?>">
				<section>
					<fieldset>
						<label><?= __("Login:") ?></label>
						<input dojoType='dijit.form.TextBox'
							disabled='1' autocomplete='new-password' name='auth_login' value=''>
						<?= $this->_batch_toggle_checkbox("auth_login") ?>
					</fieldset>
					<fieldset>
						<label><?= __("Password:") ?></label>
						<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
							autocomplete='new-password' disabled='1' value=''>
						<?= $this->_batch_toggle_checkbox("auth_pass") ?>
					</fieldset>
				</section>
			</div>
			<div dojoType="dijit.layout.ContentPane" title="<?= __('Options') ?>">
			<?php
				foreach ($options as $name => $caption) {
					?>
						<fieldset class='narrow'>
							<label class="checkbox text-muted">
								<?= \Controls\checkbox_tag($name, false, "", ["disabled" => "1"]) ?>
								<?= $caption ?>
								<?= $this->_batch_toggle_checkbox($name) ?>
							</label>
						</fieldset>
			<?php } ?>
			</div>
		</div>

		<footer>
			<?= \Controls\submit_tag(__("Save")) ?>
			<?= \Controls\cancel_dialog_tag(__("Cancel")) ?>
		</footer>
		<?php
	}

	function batchEditSave(): void {
		$this->editsaveops(true);
	}

	function editSave(): void {
		$this->editsaveops(false);
	}

	private function editsaveops(bool $batch): void {

		$feed_title = clean($_POST["title"] ?? "");
		$feed_url = clean($_POST["feed_url"] ?? "");
		$site_url = clean($_POST["site_url"] ?? "");
		$upd_intl = (int) clean($_POST["update_interval"] ?? 0);
		$purge_intl = (int) clean($_POST["purge_interval"] ?? 0);
		$feed_id = (int) clean($_POST["id"] ?? 0); /* editSave */
		$feed_ids = explode(",", clean($_POST["ids"] ?? "")); /* batchEditSave */
		$cat_id = (int) clean($_POST["cat_id"] ?? 0);
		$auth_login = clean($_POST["auth_login"] ?? "");
		$auth_pass = clean($_POST["auth_pass"] ?? "");
		$private = checkbox_to_sql_bool($_POST["private"] ?? "");
		$include_in_digest = checkbox_to_sql_bool($_POST["include_in_digest"] ?? "");
		$cache_images = checkbox_to_sql_bool($_POST["cache_images"] ?? "");
		$hide_images = checkbox_to_sql_bool($_POST["hide_images"] ?? "");
		$always_display_enclosures = checkbox_to_sql_bool($_POST["always_display_enclosures"] ?? "");
		$mark_unread_on_update = checkbox_to_sql_bool($_POST["mark_unread_on_update"] ?? "");

		$feed_language = clean($_POST["feed_language"] ?? "");

		if (!$batch) {

			/* $sth = $this->pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?");
			$sth->execute([$feed_id]);
			$row = $sth->fetch();$orig_feed_url = $row["feed_url"];

			$reset_basic_info = $orig_feed_url != $feed_url; */

			$feed = ORM::for_table('ttrss_feeds')
				->where('owner_uid', $_SESSION['uid'])
				->find_one($feed_id);

			if ($feed) {

				$feed->title = 							$feed_title;
				$feed->cat_id = 							$cat_id ? $cat_id : null;
				$feed->feed_url = 						$feed_url;
				$feed->site_url = 						$site_url;
				$feed->update_interval =				$upd_intl;
				$feed->purge_interval =					$purge_intl;
				$feed->auth_login = 						$auth_login;
				$feed->auth_pass = 						$auth_pass;
				$feed->private = 							(int)$private;
				$feed->cache_images = 					(int)$cache_images;
				$feed->hide_images = 					(int)$hide_images;
				$feed->feed_language = 					$feed_language;
				$feed->include_in_digest = 			(int)$include_in_digest;
				$feed->always_display_enclosures =	(int)$always_display_enclosures;
				$feed->mark_unread_on_update = 		(int)$mark_unread_on_update;

				$feed->save();

				PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_SAVE_FEED, $feed_id);
			}

		} else {
			$feed_data = array();

			foreach (array_keys($_POST) as $k) {
				if ($k != "op" && $k != "method" && $k != "ids") {
					$feed_data[$k] = clean($_POST[$k]);
				}
			}

			$this->pdo->beginTransaction();

			$feed_ids_qmarks = arr_qmarks($feed_ids);

			foreach (array_keys($feed_data) as $k) {

				$qpart = "";
				$qparams = [];

				switch ($k) {
					case "update_interval":
						$qpart = "update_interval = ?";
						$qparams = [$upd_intl];
						break;

					case "purge_interval":
						$qpart = "purge_interval = ?";
						$qparams = [$purge_intl];
						break;

					case "auth_login":
						$qpart = "auth_login = ?";
						$qparams = [$auth_login];
						break;

					case "auth_pass":
						$qpart = "auth_pass = ?, auth_pass_encrypted = false";
						$qparams = [$auth_pass];
						break;

					case "private":
						$qpart = "private = ?";
						$qparams = [$private];
						break;

					case "include_in_digest":
						$qpart = "include_in_digest = ?";
						$qparams = [$include_in_digest];
						break;

					case "always_display_enclosures":
						$qpart = "always_display_enclosures = ?";
						$qparams = [$always_display_enclosures];
						break;

					case "mark_unread_on_update":
						$qpart = "mark_unread_on_update = ?";
						$qparams = [$mark_unread_on_update];
						break;

					case "cache_images":
						$qpart = "cache_images = ?";
						$qparams = [$cache_images];
						break;

					case "hide_images":
						$qpart = "hide_images = ?";
						$qparams = [$hide_images];
						break;

					case "cat_id":
						if (get_pref(Prefs::ENABLE_FEED_CATS)) {
							$qpart = "cat_id = ?";
							$qparams = $cat_id ? [$cat_id] : [null];
						}
						break;

					case "feed_language":
						$qpart = "feed_language = ?";
						$qparams = [$feed_language];
						break;

				}

				if ($qpart) {
					$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids_qmarks)
						AND owner_uid = ?");
					$sth->execute([...$qparams, ...$feed_ids, $_SESSION['uid']]);
				}
			}

			$this->pdo->commit();
		}
	}

	function remove(): void {
		/** @var array<int, int> */
		$ids = array_map('intval', explode(",", clean($_REQUEST["ids"])));

		foreach ($ids as $id) {
			self::remove_feed($id, $_SESSION["uid"]);
		}
	}

	function removeCat(): void {
		$ids = explode(",", clean($_REQUEST["ids"]));
		foreach ($ids as $id) {
			Feeds::_remove_cat((int)$id, $_SESSION["uid"]);
		}
	}

	function addCat(): void {
		$feed_cat = clean($_REQUEST["cat"]);

		Feeds::_add_cat($feed_cat, $_SESSION['uid']);
	}

	function importOpml(): void {
		$opml = new OPML($_REQUEST);
		$opml->opml_import($_SESSION["uid"]);
	}

	private function index_feeds(): void {
		$error_button = "<button dojoType='dijit.form.Button'
				id='pref_feeds_errors_btn' style='display : none'
				onclick='CommonDialogs.showFeedsWithErrors()'>".
			__("Feeds with errors")."</button>";

		$inactive_button = "<button dojoType='dijit.form.Button'
				id='pref_feeds_inactive_btn'
				style='display : none'
				onclick=\"dijit.byId('feedTree').showInactiveFeeds()\">" .
				__("Inactive feeds") . "</button>";

		$feed_search = clean($_REQUEST["search"] ?? "");

		if (array_key_exists("search", $_REQUEST)) {
			$_SESSION["prefs_feed_search"] = $feed_search;
		} else {
			$feed_search = $_SESSION["prefs_feed_search"] ?? "";
		}

		?>

		<div dojoType="dijit.layout.BorderContainer" gutters="false">
			<div region='top' dojoType="fox.Toolbar">
				<div style='float : right'>
					<form dojoType="dijit.form.Form" onsubmit="dijit.byId('feedTree').reload(); return false;">
						<input dojoType="dijit.form.TextBox" id="feed_search" size="20" type="search"
							value="<?= htmlspecialchars($feed_search) ?>">
						<button dojoType="dijit.form.Button" type="submit">
							<?= __('Search') ?></button>
					</form>
				</div>

				<div dojoType="fox.form.DropDownButton">
					<span><?= __('Select') ?></span>
					<div dojoType="dijit.Menu" style="display: none;">
						<div onclick="dijit.byId('feedTree').model.setAllChecked(true)"
							dojoType="dijit.MenuItem"><?= __('All') ?></div>
						<div onclick="dijit.byId('feedTree').model.setAllChecked(false)"
							dojoType="dijit.MenuItem"><?= __('None') ?></div>
					</div>
				</div>

				<div dojoType="fox.form.DropDownButton">
					<span><?= __('Feeds') ?></span>
					<div dojoType="dijit.Menu" style="display: none">
						<div onclick="CommonDialogs.subscribeToFeed()"
							dojoType="dijit.MenuItem"><?= __('Subscribe to feed') ?></div>
						<div onclick="dijit.byId('feedTree').editSelectedFeed()"
							dojoType="dijit.MenuItem"><?= __('Edit selected feeds') ?></div>
						<div onclick="dijit.byId('feedTree').resetFeedOrder()"
							dojoType="dijit.MenuItem"><?= __('Reset sort order') ?></div>
						<div onclick="dijit.byId('feedTree').batchSubscribe()"
							dojoType="dijit.MenuItem"><?= __('Batch subscribe') ?></div>
						<div dojoType="dijit.MenuItem" onclick="dijit.byId('feedTree').removeSelectedFeeds()">
							<?= __('Unsubscribe') ?></div>
					</div>
				</div>

				<?php if (get_pref(Prefs::ENABLE_FEED_CATS)) { ?>
					<div dojoType="fox.form.DropDownButton">
						<span><?= __('Categories') ?></span>
						<div dojoType="dijit.Menu" style="display: none">
							<div onclick="dijit.byId('feedTree').createCategory()"
								dojoType="dijit.MenuItem"><?= __('Add category') ?></div>
							<div onclick="dijit.byId('feedTree').resetCatOrder()"
								dojoType="dijit.MenuItem"><?= __('Reset sort order') ?></div>
							<div onclick="dijit.byId('feedTree').removeSelectedCategories()"
								dojoType="dijit.MenuItem"><?= __('Remove selected') ?></div>
						</div>
					</div>
				<?php } ?>
				<?= $error_button ?>
				<?= $inactive_button ?>
			</div>
			<div style="padding : 0px" dojoType="dijit.layout.ContentPane" region="center">
				<div dojoType="fox.PrefFeedStore" jsId="feedStore"
					url="backend.php?op=Pref_Feeds&method=getfeedtree">
				</div>

				<div dojoType="lib.CheckBoxStoreModel" jsId="feedModel" store="feedStore"
					query="{id:'root'}" rootId="root" rootLabel="Feeds" childrenAttrs="items"
					checkboxStrict="false" checkboxAll="false">
				</div>

				<div dojoType="fox.PrefFeedTree" id="feedTree"
					dndController="dijit.tree.dndSource"
					betweenThreshold="5"
					autoExpand="<?= (!empty($feed_search) ? "true" : "false") ?>"
					persist="true"
					model="feedModel"
					openOnClick="false">
				</div>
			</div>
		</div>
	<?php

	}

	private function index_opml(): void {
		?>

		<form id='opml_import_form' method='post' enctype='multipart/form-data'>
			<label class='dijitButton'><?= __("Choose file...") ?>
				<input style='display : none' id='opml_file' name='opml_file' type='file'>
			</label>
			<input type='hidden' name='op' value='Pref_Feeds'>
			<input type='hidden' name='csrf_token' value="<?= $_SESSION['csrf_token'] ?>">
			<input type='hidden' name='method' value='importOpml'>
			<button dojoType='dijit.form.Button' class='alt-primary' onclick="return Helpers.OPML.import()" type="submit">
			<?= \Controls\icon("file_upload") ?>
				<?= __('Import OPML') ?>
			</button>
		</form>

		<hr/>

		<?php print_notice("Only main settings profile can be migrated using OPML.") ?>

		<form dojoType='dijit.form.Form' id='opmlExportForm' style='display : inline-block'>
			<button dojoType='dijit.form.Button' onclick='Helpers.OPML.export()'>
				<?= \Controls\icon("file_download") ?>
				<?= __('Export OPML') ?>
			</button>

			<label class='checkbox'>
				<?= \Controls\checkbox_tag("include_settings", true, "1") ?>
				<?= __("Include tt-rss settings") ?>
			</label>
		</form>

		<?php
		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsOPML");
	}

	private function index_shared(): void {
		?>

		<?= format_notice('Published articles can be subscribed by anyone who knows the following URL:') ?></h3>

		<button dojoType='dijit.form.Button' class='alt-primary'
			onclick="CommonDialogs.generatedFeed(<?= Feeds::FEED_PUBLISHED ?>, false)">
			<?= \Controls\icon('share') ?>
			<?= __('Display URL') ?>
		</button>

		<button class='alt-danger' dojoType='dijit.form.Button' onclick='return Helpers.Feeds.clearFeedAccessKeys()'>
			<?= \Controls\icon('delete') ?>
			<?= __('Clear all generated URLs') ?>
		</button>

		<?php
		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated");
	}

	function index(): void {
		?>

		<div dojoType='dijit.layout.TabContainer' tabPosition='left-h'>
			<div style='padding : 0px' dojoType='dijit.layout.ContentPane'
				title="<i class='material-icons'>rss_feed</i> <?= __('My feeds') ?>">
				<?php $this->index_feeds() ?>
			</div>

			<div dojoType='dijit.layout.ContentPane'
						title="<i class='material-icons'>import_export</i> <?= __('OPML') ?>">
						<?php $this->index_opml() ?>
					</div>

			<div dojoType="dijit.layout.ContentPane"
				title="<i class='material-icons'>share</i> <?= __('Sharing') ?>">
				<?php $this->index_shared() ?>
			</div>

			<?php
				ob_start();
				PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFeeds");
				$plugin_data = trim((string)ob_get_contents());
				ob_end_clean();
			?>

			<?php if ($plugin_data) { ?>
				<div dojoType='dijit.layout.ContentPane'
					title="<i class='material-icons'>extension</i> <?= __('Plugins') ?>">

					<div dojoType='dijit.layout.AccordionContainer' region='center'>
						<?= $plugin_data ?>
					</div>
				</div>
			<?php } ?>
		</div>
		<?php
	}

	/**
	 * @return array<string, mixed>
	 */
	private function feedlist_init_cat(int $cat_id): array {
		return [
			'id' => 'CAT:' . $cat_id,
			'items' => array(),
			'name' => Feeds::_get_cat_title($cat_id),
			'type' => 'category',
			'unread' => -1, //(int) Feeds::_get_cat_unread($cat_id);
			'bare_id' => $cat_id,
		];
	}

	/**
	 * @return array<string, mixed>
	 */
	private function feedlist_init_feed(int $feed_id, ?string $title = null, bool $unread = false, string $error = '', string $updated = ''): array {
		if (!$title)
			$title = Feeds::_get_title($feed_id, false);

		if ($unread === false)
			$unread = Feeds::_get_counters($feed_id, false, true);

		return [
			'id' => 'FEED:' . $feed_id,
			'name' => $title,
			'unread' => (int) $unread,
			'type' => 'feed',
			'error' => $error,
			'updated' => $updated,
			'icon' => Feeds::_get_icon($feed_id),
			'bare_id' => $feed_id,
			'auxcounter' => 0,
		];
	}
// i sdelal
	function inactiveFeeds(): void {

		//if (Config::get(Config::DB_TYPE) == "pgsql") {
			//$interval_qpart = "NOW() - INTERVAL '3 months'";
		//} else {
			//$interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
		//}

		//$inactive_feeds = ORM::for_table('ttrss_feeds')
			//->table_alias('f')
			//->select_many('f.id', 'f.title', 'f.site_url', 'f.feed_url')
			//->select_expr('MAX(e.updated)', 'last_article')
			//->join('ttrss_user_entries', [ 'ue.feed_id', '=', 'f.id'], 'ue')
			//->join('ttrss_entries', ['e.id', '=', 'ue.ref_id'], 'e')
			//->where('f.owner_uid', $_SESSION['uid'])
			//->where_raw(
				//"(SELECT MAX(ttrss_entries.updated)
				//FROM ttrss_entries
				//JOIN ttrss_user_entries ON ttrss_entries.id = ttrss_user_entries.ref_id
				//WHERE ttrss_user_entries.feed_id = f.id) < $interval_qpart")
			//->group_by('f.title')
			//->group_by('f.id')
			//->group_by('f.site_url')
			//->group_by('f.feed_url')
			//->order_by_asc('last_article')
			//->find_array();

		//foreach ($inactive_feeds as $inactive_feed) {
			//$inactive_feed['last_article'] = TimeHelper::make_local_datetime($inactive_feed['last_article'], false);
		//}

		//print json_encode($inactive_feeds);
	}

	function feedsWithErrors(): void {
		print json_encode(ORM::for_table('ttrss_feeds')
			->select_many('id', 'title', 'feed_url', 'last_error', 'site_url')
			->where_not_equal('last_error', '')
			->where('owner_uid', $_SESSION['uid'])
			->where_gte('update_interval', 0)
			->find_array());
	}

	static function remove_feed(int $id, int $owner_uid): void {

		if (PluginHost::getInstance()->run_hooks_until(PluginHost::HOOK_UNSUBSCRIBE_FEED, true, $id, $owner_uid))
			return;

		$pdo = Db::pdo();

		if ($id > 0) {
			$pdo->beginTransaction();

			/* save starred articles in Archived feed */

			$sth = $pdo->prepare("UPDATE ttrss_user_entries SET
					feed_id = NULL, orig_feed_id = NULL
				WHERE feed_id = ? AND marked = true AND owner_uid = ?");

			$sth->execute([$id, $owner_uid]);

			/* Remove access key for the feed */

			$sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE
				feed_id = ? AND owner_uid = ?");
			$sth->execute([$id, $owner_uid]);

			/* remove the feed */

			$sth = $pdo->prepare("DELETE FROM ttrss_feeds
				WHERE id = ? AND owner_uid = ?");
			$sth->execute([$id, $owner_uid]);

			$pdo->commit();

			$favicon_cache = DiskCache::instance('feed-icons');

			if ($favicon_cache->exists((string)$id))
				$favicon_cache->remove((string)$id);

		} else {
			Labels::remove(Labels::feed_to_label_id($id), $owner_uid);
		}
	}

	function batchSubscribe(): void {
		print json_encode([
			"enable_cats" => (int)get_pref(Prefs::ENABLE_FEED_CATS),
			"cat_select" => \Controls\select_feeds_cats("cat")
		]);
	}

	function batchAddFeeds(): void {
		$cat_id = clean($_REQUEST['cat']);
		$feeds = explode("\n", clean($_REQUEST['feeds']));
		$login = clean($_REQUEST['login']);
		$pass = clean($_REQUEST['pass']);

		$user = ORM::for_table('ttrss_users')->find_one($_SESSION["uid"]);

		// TODO: we should return some kind of error code to frontend here
		if ($user->access_level == UserHelper::ACCESS_LEVEL_READONLY) {
			return;
		}

		$csth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
						WHERE feed_url = ? AND owner_uid = ?");

		$isth = $this->pdo->prepare("INSERT INTO ttrss_feeds
							(owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
						VALUES (?, ?, '[Unknown]', ?, ?, ?, 0, false)");

		foreach ($feeds as $feed) {
			$feed = trim($feed);

			if (UrlHelper::validate($feed)) {

				$this->pdo->beginTransaction();

				$csth->execute([$feed, $_SESSION['uid']]);

				if (!$csth->fetch()) {
					$isth->execute([$_SESSION['uid'], $feed, $cat_id ? $cat_id : null, $login, $pass]);
				}

				$this->pdo->commit();
			}
		}
	}

	function clearKeys(): void {
		Feeds::_clear_access_keys($_SESSION['uid']);
	}

	function regenFeedKey(): void {
		$feed_id = clean($_REQUEST['id']);
		$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? false);

		$new_key = Feeds::_update_access_key($feed_id, $is_cat, $_SESSION["uid"]);

		print json_encode(["link" => $new_key]);
	}

	function getSharedURL(): void {
		$feed_id = clean($_REQUEST['id']);
		$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? false);
		$search = clean($_REQUEST['search']);

		$link = Config::get_self_url() . "/public.php?" . http_build_query([
			'op' => 'rss',
			'id' => $feed_id,
			'is_cat' => (int)$is_cat,
			'q' => $search,
			'key' => Feeds::_get_access_key($feed_id, $is_cat, $_SESSION["uid"])
		]);

		print json_encode([
			"title" => Feeds::_get_title($feed_id, $is_cat),
			"link" => $link
		]);
	}

	/**
	 * @param array<string, mixed> $cat
	 */
	private function calculate_children_count(array $cat): int {
		$c = 0;

		foreach ($cat['items'] ?? [] as $child) {
			if (($child['type'] ?? '') == 'category') {
				$c += $this->calculate_children_count($child);
			} else {
				$c += 1;
			}
		}

		return $c;
	}

}
<?php
class Prefs {
	// (this is the database-backed version of Config.php)

	const PURGE_OLD_DAYS = "PURGE_OLD_DAYS";
	const DEFAULT_UPDATE_INTERVAL = "DEFAULT_UPDATE_INTERVAL";
	//const DEFAULT_ARTICLE_LIMIT = "DEFAULT_ARTICLE_LIMIT";
	//const ALLOW_DUPLICATE_POSTS = "ALLOW_DUPLICATE_POSTS";
	const ENABLE_FEED_CATS = "ENABLE_FEED_CATS";
	const SHOW_CONTENT_PREVIEW = "SHOW_CONTENT_PREVIEW";
	const SHORT_DATE_FORMAT = "SHORT_DATE_FORMAT";
	const LONG_DATE_FORMAT = "LONG_DATE_FORMAT";
	const COMBINED_DISPLAY_MODE = "COMBINED_DISPLAY_MODE";
	const HIDE_READ_FEEDS = "HIDE_READ_FEEDS";
	const ON_CATCHUP_SHOW_NEXT_FEED = "ON_CATCHUP_SHOW_NEXT_FEED";
	const FEEDS_SORT_BY_UNREAD = "FEEDS_SORT_BY_UNREAD";
	const REVERSE_HEADLINES = "REVERSE_HEADLINES";
	const DIGEST_ENABLE = "DIGEST_ENABLE";
	const CONFIRM_FEED_CATCHUP = "CONFIRM_FEED_CATCHUP";
	const CDM_AUTO_CATCHUP = "CDM_AUTO_CATCHUP";
	const _DEFAULT_VIEW_MODE = "_DEFAULT_VIEW_MODE";
	const _DEFAULT_VIEW_LIMIT = "_DEFAULT_VIEW_LIMIT";
	//const _PREFS_ACTIVE_TAB = "_PREFS_ACTIVE_TAB";
	//const STRIP_UNSAFE_TAGS = "STRIP_UNSAFE_TAGS";
	const BLACKLISTED_TAGS = "BLACKLISTED_TAGS";
	const FRESH_ARTICLE_MAX_AGE = "FRESH_ARTICLE_MAX_AGE";
	const DIGEST_CATCHUP = "DIGEST_CATCHUP";
	const CDM_EXPANDED = "CDM_EXPANDED";
	const PURGE_UNREAD_ARTICLES = "PURGE_UNREAD_ARTICLES";
	const HIDE_READ_SHOWS_SPECIAL = "HIDE_READ_SHOWS_SPECIAL";
	const VFEED_GROUP_BY_FEED = "VFEED_GROUP_BY_FEED";
	const STRIP_IMAGES = "STRIP_IMAGES";
	const _DEFAULT_VIEW_ORDER_BY = "_DEFAULT_VIEW_ORDER_BY";
	const ENABLE_API_ACCESS = "ENABLE_API_ACCESS";
	//const _COLLAPSED_SPECIAL = "_COLLAPSED_SPECIAL";
	//const _COLLAPSED_LABELS = "_COLLAPSED_LABELS";
	//const _COLLAPSED_UNCAT = "_COLLAPSED_UNCAT";
	//const _COLLAPSED_FEEDLIST = "_COLLAPSED_FEEDLIST";
	//const _MOBILE_ENABLE_CATS = "_MOBILE_ENABLE_CATS";
	//const _MOBILE_SHOW_IMAGES = "_MOBILE_SHOW_IMAGES";
	//const _MOBILE_HIDE_READ = "_MOBILE_HIDE_READ";
	//const _MOBILE_SORT_FEEDS_UNREAD = "_MOBILE_SORT_FEEDS_UNREAD";
	//const _MOBILE_BROWSE_CATS = "_MOBILE_BROWSE_CATS";
	//const _THEME_ID = "_THEME_ID";
	const USER_TIMEZONE = "USER_TIMEZONE";
	const USER_STYLESHEET = "USER_STYLESHEET";
	//const SORT_HEADLINES_BY_FEED_DATE = "SORT_HEADLINES_BY_FEED_DATE";
	const SSL_CERT_SERIAL = "SSL_CERT_SERIAL";
	const DIGEST_PREFERRED_TIME = "DIGEST_PREFERRED_TIME";
	//const _PREFS_SHOW_EMPTY_CATS = "_PREFS_SHOW_EMPTY_CATS";
	const _DEFAULT_INCLUDE_CHILDREN = "_DEFAULT_INCLUDE_CHILDREN";
	//const AUTO_ASSIGN_LABELS = "AUTO_ASSIGN_LABELS";
	const _ENABLED_PLUGINS = "_ENABLED_PLUGINS";
	//const _MOBILE_REVERSE_HEADLINES = "_MOBILE_REVERSE_HEADLINES";
	const USER_CSS_THEME = "USER_CSS_THEME";
	const USER_LANGUAGE = "USER_LANGUAGE";
	const DEFAULT_SEARCH_LANGUAGE = "DEFAULT_SEARCH_LANGUAGE";
	const _PREFS_MIGRATED = "_PREFS_MIGRATED";
	const HEADLINES_NO_DISTINCT = "HEADLINES_NO_DISTINCT";
	const DEBUG_HEADLINE_IDS = "DEBUG_HEADLINE_IDS";
	const DISABLE_CONDITIONAL_COUNTERS = "DISABLE_CONDITIONAL_COUNTERS";
	const WIDESCREEN_MODE = "WIDESCREEN_MODE";
	const CDM_ENABLE_GRID = "CDM_ENABLE_GRID";
	const DIGEST_MIN_SCORE = "DIGEST_MIN_SCORE";

	private const _DEFAULTS = [
		Prefs::PURGE_OLD_DAYS => [ 60, Config::T_INT ],
		Prefs::DEFAULT_UPDATE_INTERVAL => [ 30, Config::T_INT ],
		//Prefs::DEFAULT_ARTICLE_LIMIT => [ 30, Config::T_INT ],
		//Prefs::ALLOW_DUPLICATE_POSTS => [ false, Config::T_BOOL ],
		Prefs::ENABLE_FEED_CATS => [ true, Config::T_BOOL ],
		Prefs::SHOW_CONTENT_PREVIEW => [ true, Config::T_BOOL ],
		Prefs::SHORT_DATE_FORMAT => [ "M d, G:i", Config::T_STRING ],
		Prefs::LONG_DATE_FORMAT => [ "D, M d Y - G:i", Config::T_STRING ],
		Prefs::COMBINED_DISPLAY_MODE => [ true, Config::T_BOOL ],
		Prefs::HIDE_READ_FEEDS => [ false, Config::T_BOOL ],
		Prefs::ON_CATCHUP_SHOW_NEXT_FEED => [ false, Config::T_BOOL ],
		Prefs::FEEDS_SORT_BY_UNREAD => [ false, Config::T_BOOL ],
		Prefs::REVERSE_HEADLINES => [ false, Config::T_BOOL ],
		Prefs::DIGEST_ENABLE => [ false, Config::T_BOOL ],
		Prefs::CONFIRM_FEED_CATCHUP => [ true, Config::T_BOOL ],
		Prefs::CDM_AUTO_CATCHUP => [ false, Config::T_BOOL ],
		Prefs::_DEFAULT_VIEW_MODE => [ "adaptive", Config::T_STRING ],
		Prefs::_DEFAULT_VIEW_LIMIT => [ 30, Config::T_INT ],
		//Prefs::_PREFS_ACTIVE_TAB => [ "", Config::T_STRING ],
		//Prefs::STRIP_UNSAFE_TAGS => [ true, Config::T_BOOL ],
		Prefs::BLACKLISTED_TAGS => [ 'main, generic, misc, uncategorized, blog, blogroll, general, news', Config::T_STRING ],
		Prefs::FRESH_ARTICLE_MAX_AGE => [ 24, Config::T_INT ],
		Prefs::DIGEST_CATCHUP => [ false, Config::T_BOOL ],
		Prefs::CDM_EXPANDED => [ true, Config::T_BOOL ],
		Prefs::PURGE_UNREAD_ARTICLES => [ true, Config::T_BOOL ],
		Prefs::HIDE_READ_SHOWS_SPECIAL => [ true, Config::T_BOOL ],
		Prefs::VFEED_GROUP_BY_FEED => [ false, Config::T_BOOL ],
		Prefs::STRIP_IMAGES => [ false, Config::T_BOOL ],
		Prefs::_DEFAULT_VIEW_ORDER_BY => [ "default", Config::T_STRING ],
		Prefs::ENABLE_API_ACCESS => [ false, Config::T_BOOL ],
		//Prefs::_COLLAPSED_SPECIAL => [ false, Config::T_BOOL ],
		//Prefs::_COLLAPSED_LABELS => [ false, Config::T_BOOL ],
		//Prefs::_COLLAPSED_UNCAT => [ false, Config::T_BOOL ],
		//Prefs::_COLLAPSED_FEEDLIST => [ false, Config::T_BOOL ],
		//Prefs::_MOBILE_ENABLE_CATS => [ false, Config::T_BOOL ],
		//Prefs::_MOBILE_SHOW_IMAGES => [ false, Config::T_BOOL ],
		//Prefs::_MOBILE_HIDE_READ => [ false, Config::T_BOOL ],
		//Prefs::_MOBILE_SORT_FEEDS_UNREAD => [ false, Config::T_BOOL ],
		//Prefs::_MOBILE_BROWSE_CATS => [ true, Config::T_BOOL ],
		//Prefs::_THEME_ID => [ 0, Config::T_BOOL ],
		Prefs::USER_TIMEZONE => [ "Automatic", Config::T_STRING ],
		Prefs::USER_STYLESHEET => [ "", Config::T_STRING ],
		//Prefs::SORT_HEADLINES_BY_FEED_DATE => [ false, Config::T_BOOL ],
		Prefs::SSL_CERT_SERIAL => [ "", Config::T_STRING ],
		Prefs::DIGEST_PREFERRED_TIME => [ "00:00", Config::T_STRING ],
		//Prefs::_PREFS_SHOW_EMPTY_CATS => [ false, Config::T_BOOL ],
		Prefs::_DEFAULT_INCLUDE_CHILDREN => [ false, Config::T_BOOL ],
		//Prefs::AUTO_ASSIGN_LABELS => [ false, Config::T_BOOL ],
		Prefs::_ENABLED_PLUGINS => [ "", Config::T_STRING ],
		//Prefs::_MOBILE_REVERSE_HEADLINES => [ false, Config::T_BOOL ],
		Prefs::USER_CSS_THEME => [ "" , Config::T_STRING ],
		Prefs::USER_LANGUAGE => [ "" , Config::T_STRING ],
		Prefs::DEFAULT_SEARCH_LANGUAGE => [ "" , Config::T_STRING ],
		Prefs::_PREFS_MIGRATED => [ false, Config::T_BOOL ],
		Prefs::HEADLINES_NO_DISTINCT => [ false, Config::T_BOOL ],
		Prefs::DEBUG_HEADLINE_IDS => [ false, Config::T_BOOL ],
		Prefs::DISABLE_CONDITIONAL_COUNTERS => [ false, Config::T_BOOL ],
		Prefs::WIDESCREEN_MODE => [ false, Config::T_BOOL ],
		Prefs::CDM_ENABLE_GRID => [ false, Config::T_BOOL ],
		Prefs::DIGEST_MIN_SCORE => [ 0, Config::T_INT ],
	];

	const _PROFILE_BLACKLIST = [
		//Prefs::ALLOW_DUPLICATE_POSTS,
		Prefs::PURGE_OLD_DAYS,
		Prefs::PURGE_UNREAD_ARTICLES,
		Prefs::DIGEST_ENABLE,
		Prefs::DIGEST_CATCHUP,
		Prefs::BLACKLISTED_TAGS,
		Prefs::ENABLE_API_ACCESS,
		//Prefs::UPDATE_POST_ON_CHECKSUM_CHANGE,
		Prefs::DEFAULT_UPDATE_INTERVAL,
		Prefs::USER_TIMEZONE,
		//Prefs::SORT_HEADLINES_BY_FEED_DATE,
		Prefs::SSL_CERT_SERIAL,
		Prefs::DIGEST_PREFERRED_TIME,
		Prefs::DIGEST_MIN_SCORE,
		Prefs::_PREFS_MIGRATED
	];

	/** @var Prefs|null */
	private static $instance;

	/** @var array<string, bool|int|string> */
	private $cache = [];

	/** @var PDO */
	private $pdo;

	public static function get_instance() : Prefs {
		if (self::$instance == null)
			self::$instance = new self();

		return self::$instance;
	}

	static function is_valid(string $pref_name): bool {
		return isset(self::_DEFAULTS[$pref_name]);
	}

	/**
	 * @return bool|int|null|string
	 */
	static function get_default(string $pref_name) {
		if (self::is_valid($pref_name))
			return self::_DEFAULTS[$pref_name][0];
		else
			return null;
	}

	function __construct() {
		$this->pdo = Db::pdo();

		if (!empty($_SESSION["uid"])) {
			$owner_uid = (int) $_SESSION["uid"];
			$profile_id = $_SESSION["profile"] ?? null;

			$this->cache_all($owner_uid, $profile_id);
			$this->migrate($owner_uid, $profile_id);
		};
	}

	private function __clone() {
		//
	}

	/**
	 * @return array<int, array<string, bool|int|null|string>>
	 */
	static function get_all(int $owner_uid, ?int $profile_id = null) {
		return self::get_instance()->_get_all($owner_uid, $profile_id);
	}

	/**
	 * @return array<int, array<string, bool|int|null|string>>
	 */
	private function _get_all(int $owner_uid, ?int $profile_id = null) {
		$rv = [];

		$ref = new ReflectionClass(get_class($this));

		foreach ($ref->getConstants() as $const => $cvalue) {
			if (isset($this::_DEFAULTS[$const])) {
				list ($def_val, $type_hint) = $this::_DEFAULTS[$const];

				array_push($rv, [
					"pref_name" => $const,
					"value" => $this->_get($const, $owner_uid, $profile_id),
					"type_hint" => $type_hint,
				]);
			}
		}

		return $rv;
	}

	private function cache_all(int $owner_uid, ?int $profile_id): void {
		if (!$profile_id) $profile_id = null;

		// fill cache with defaults
		$ref = new ReflectionClass(get_class($this));
		foreach ($ref->getConstants() as $const => $cvalue) {
			if (isset($this::_DEFAULTS[$const])) {
				list ($def_val, $type_hint) = $this::_DEFAULTS[$const];

				$this->_set_cache($const, $def_val, $owner_uid, $profile_id);
			}
		}

		if (Config::get_schema_version() >= 141) {
			// fill in any overrides from the database
			$sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs2
									WHERE owner_uid = :uid AND
										(profile = :profile OR (:profile IS NULL AND profile IS NULL))");

			$sth->execute(["uid" => $owner_uid, "profile" => $profile_id]);

			while ($row = $sth->fetch()) {
				$this->_set_cache($row["pref_name"], $row["value"], $owner_uid, $profile_id);
			}
		}
	}

	/**
	 * @return bool|int|null|string
	 */
	static function get(string $pref_name, int $owner_uid, ?int $profile_id = null) {
		return self::get_instance()->_get($pref_name, $owner_uid, $profile_id);
	}

	/**
	 * @return bool|int|null|string
	 */
	private function _get(string $pref_name, int $owner_uid, ?int $profile_id) {
		if (isset(self::_DEFAULTS[$pref_name])) {
			if (!$profile_id || in_array($pref_name, self::_PROFILE_BLACKLIST)) $profile_id = null;

			list ($def_val, $type_hint) = self::_DEFAULTS[$pref_name];

			if ($this->_is_cached($pref_name, $owner_uid, $profile_id)) {
				$cached_value = $this->_get_cache($pref_name, $owner_uid, $profile_id);
				return Config::cast_to($cached_value, $type_hint);
			} else if (Config::get_schema_version() >= 141) {
				$sth = $this->pdo->prepare("SELECT value FROM ttrss_user_prefs2
								WHERE pref_name = :name AND owner_uid = :uid AND
								(profile = :profile OR (:profile IS NULL AND profile IS NULL))");

				$sth->execute(["uid" => $owner_uid, "profile" => $profile_id, "name" => $pref_name ]);

				if ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
					$this->_set_cache($pref_name, $row["value"], $owner_uid, $profile_id);

					return Config::cast_to($row["value"], $type_hint);
				} else {
					$this->_set_cache($pref_name, $def_val, $owner_uid, $profile_id);

					return $def_val;
				}
			} else {
				return Config::cast_to($def_val, $type_hint);

			}
		} else {
			user_error("Attempt to get invalid preference key: $pref_name (UID: $owner_uid, profile: $profile_id)", E_USER_WARNING);
		}

		return null;
	}

	private function _is_cached(string $pref_name, int $owner_uid, ?int $profile_id): bool {
		$cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name);
		return isset($this->cache[$cache_key]);
	}

	/**
	 * @return bool|int|null|string
	 */
	private function _get_cache(string $pref_name, int $owner_uid, ?int $profile_id) {
		$cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name);
		return $this->cache[$cache_key] ?? null;
	}

	/**
	 * @param bool|int|string $value
	 */
	private function _set_cache(string $pref_name, $value, int $owner_uid, ?int $profile_id): void {
		$cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name);

		$this->cache[$cache_key] = $value;
	}

	/**
	 * @param bool|int|string $value
	 */
	static function set(string $pref_name, $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool {
		return self::get_instance()->_set($pref_name, $value, $owner_uid, $profile_id);
	}

	/**
	 * @param bool|int|string $value
	 */
	private function _set(string $pref_name, $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool {
		if (!$profile_id) $profile_id = null;

		if ($profile_id && in_array($pref_name, self::_PROFILE_BLACKLIST))
			return false;

		if (isset(self::_DEFAULTS[$pref_name])) {
			list ($def_val, $type_hint) = self::_DEFAULTS[$pref_name];

			if ($strip_tags)
				$value = trim(strip_tags($value));

			$value = Config::cast_to($value, $type_hint);

			if ($value == $this->_get($pref_name, $owner_uid, $profile_id))
				return true; // no need to actually set this to the same value, let's just say we did

			$this->_set_cache($pref_name, $value, $owner_uid, $profile_id);

			$sth = $this->pdo->prepare("SELECT COUNT(pref_name) AS count FROM ttrss_user_prefs2
				WHERE pref_name = :name AND owner_uid = :uid AND
				(profile = :profile OR (:profile IS NULL AND profile IS NULL))");
			$sth->execute(["uid" => $owner_uid, "profile" => $profile_id, "name" => $pref_name ]);

			if ($row = $sth->fetch()) {
				if ($row["count"] == 0) {
					$sth = $this->pdo->prepare("INSERT INTO ttrss_user_prefs2
						(pref_name, value, owner_uid, profile)
						VALUES
						(:name, :value, :uid, :profile)");

					return $sth->execute(["uid" => $owner_uid, "profile" => $profile_id, "name" => $pref_name, "value" => $value ]);

				} else {
					$sth = $this->pdo->prepare("UPDATE ttrss_user_prefs2
						SET value = :value
						WHERE pref_name = :name AND owner_uid = :uid AND
							(profile = :profile OR (:profile IS NULL AND profile IS NULL))");

					return $sth->execute(["uid" => $owner_uid, "profile" => $profile_id, "name" => $pref_name, "value" => $value ]);
				}
			}
		} else {
			user_error("Attempt to set invalid preference key: $pref_name (UID: $owner_uid, profile: $profile_id)", E_USER_WARNING);
		}

		return false;
	}

	function migrate(int $owner_uid, ?int $profile_id): void {
		if (Config::get_schema_version() < 141)
			return;

		if (!$profile_id) $profile_id = null;

		if (!$this->_get(Prefs::_PREFS_MIGRATED, $owner_uid, $profile_id)) {

			$in_nested_tr = false;

			try {
				$this->pdo->beginTransaction();
			} catch (PDOException $e) {
				$in_nested_tr = true;
			}

			$sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs
				WHERE owner_uid = :uid AND
					(profile = :profile OR (:profile IS NULL AND profile IS NULL))");
			$sth->execute(["uid" => $owner_uid, "profile" => $profile_id]);

			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
				if (isset(self::_DEFAULTS[$row["pref_name"]])) {
					list ($def_val, $type_hint) = self::_DEFAULTS[$row["pref_name"]];

					$user_val = Config::cast_to($row["value"], $type_hint);

					if ($user_val != $def_val) {
						$this->_set($row["pref_name"], $user_val, $owner_uid, $profile_id);
					}
				}
			}

			$this->_set(Prefs::_PREFS_MIGRATED, "1", $owner_uid, $profile_id);

			if (!$in_nested_tr)
				$this->pdo->commit();

			Logger::log(E_USER_NOTICE, sprintf("Migrated preferences of user %d (profile %d)", $owner_uid, $profile_id));
		}
	}

	static function reset(int $owner_uid, ?int $profile_id): void {
		if (!$profile_id) $profile_id = null;

		$sth = Db::pdo()->prepare("DELETE FROM ttrss_user_prefs2
								WHERE owner_uid = :uid AND pref_name != :mig_key AND
								(profile = :profile OR (:profile IS NULL AND profile IS NULL))");

		$sth->execute(["uid" => $owner_uid, "mig_key" => self::_PREFS_MIGRATED, "profile" => $profile_id]);
	}
}
<?php
class RPC extends Handler_Protected {

	/*function csrf_ignore(string $method): bool {
		$csrf_ignored = array("completelabels");

		return array_search($method, $csrf_ignored) !== false;
	}*/

	/**
	 * @return array<string, string>
	 */
	private function _translations_as_array(): array {

		global $text_domains;

		$rv = [];

		foreach (array_keys($text_domains) as $domain) {

			/** @var gettext_reader $l10n */
			$l10n = _get_reader($domain);

			for ($i = 0; $i < $l10n->total; $i++) {
				if (isset($l10n->table_originals[$i * 2 + 2]) && $orig = $l10n->get_original_string($i)) {
					if(strpos($orig, "\000") !== false) { // Plural forms
						$key = explode(chr(0), $orig);

						$rv[$key[0]] = _ngettext($key[0], $key[1], 1); // Singular
						$rv[$key[1]] = _ngettext($key[0], $key[1], 2); // Plural
					} else {
						$translation = _dgettext($domain,$orig);
						$rv[$orig] = $translation;
					}
				}
			}
		}

		return $rv;
	}


	function togglepref(): void {
		$key = clean($_REQUEST["key"]);
		set_pref($key, !get_pref($key));
		$value = get_pref($key);

		print json_encode(array("param" =>$key, "value" => $value));
	}

	function setpref(): void {
		// set_pref escapes input, so no need to double escape it here
		$key = clean($_REQUEST['key']);
		$value = $_REQUEST['value'];

		set_pref($key, $value, $_SESSION["uid"], $key != 'USER_STYLESHEET');

		print json_encode(array("param" =>$key, "value" => $value));
	}

	function mark(): void {
		$mark = clean($_REQUEST["mark"]);
		$id = clean($_REQUEST["id"]);

		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET marked = ?,
					last_marked = NOW()
					WHERE ref_id = ? AND owner_uid = ?");

		$sth->execute([$mark, $id, $_SESSION['uid']]);

		print json_encode(array("message" => "UPDATE_COUNTERS"));
	}

	function delete(): void {
		$ids = explode(",", clean($_REQUEST["ids"]));
		$ids_qmarks = arr_qmarks($ids);

		$sth = $this->pdo->prepare("DELETE FROM ttrss_user_entries
			WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		$sth->execute([...$ids, $_SESSION['uid']]);

		Article::_purge_orphans();

		print json_encode(array("message" => "UPDATE_COUNTERS"));
	}

	function publ(): void {
		$pub = clean($_REQUEST["pub"]);
		$id = clean($_REQUEST["id"]);

		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
			published = ?, last_published = NOW()
			WHERE ref_id = ? AND owner_uid = ?");

		$sth->execute([$pub, $id, $_SESSION['uid']]);

		print json_encode(array("message" => "UPDATE_COUNTERS"));
	}

	function getRuntimeInfo(): void {
		$reply = [
			'runtime-info' => $this->_make_runtime_info()
		];

		print json_encode($reply);
	}

	function getAllCounters(): void {
		@$seq = (int) $_REQUEST['seq'];

		$feed_id_count = (int) ($_REQUEST["feed_id_count"] ?? -1);
		$label_id_count = (int) ($_REQUEST["label_id_count"] ?? -1);

		// it seems impossible to distinguish empty array [] from a null - both become unset in $_REQUEST
		// so, count is >= 0 means we had an array, -1 means null
		// we need null because it means "return all counters"; [] would return nothing
		if ($feed_id_count == -1)
			$feed_ids = null;
		else
			$feed_ids = array_map("intval", clean($_REQUEST["feed_ids"] ?? []));

		if ($label_id_count == -1)
			$label_ids = null;
		else
			$label_ids = array_map("intval", clean($_REQUEST["label_ids"] ?? []));

		$counters = is_array($feed_ids) && !get_pref(Prefs::DISABLE_CONDITIONAL_COUNTERS) ?
			Counters::get_conditional($feed_ids, $label_ids) : Counters::get_all();

		$reply = [
			'counters' => $counters,
			'seq' => $seq
		];

		print json_encode($reply);
	}

	/* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
	function catchupSelected(): void {
		$ids = array_map("intval", clean($_REQUEST["ids"] ?? []));
		$cmode = (int)clean($_REQUEST["cmode"]);

		if (count($ids) > 0)
			Article::_catchup_by_id($ids, $cmode);

		print json_encode(["message" => "UPDATE_COUNTERS",
			"labels" => Article::_labels_of($ids),
			"feeds" => Article::_feeds_of($ids)]);
	}

	function markSelected(): void {
		$ids = array_map("intval", clean($_REQUEST["ids"] ?? []));
		$cmode = (int)clean($_REQUEST["cmode"]);

		if (count($ids) > 0)
			$this->markArticlesById($ids, $cmode);

		print json_encode(["message" => "UPDATE_COUNTERS",
		"labels" => Article::_labels_of($ids),
			"feeds" => Article::_feeds_of($ids)]);
	}

	function publishSelected(): void {
		$ids = array_map("intval", clean($_REQUEST["ids"] ?? []));
		$cmode = (int)clean($_REQUEST["cmode"]);

		if (count($ids) > 0)
			$this->publishArticlesById($ids, $cmode);

		print json_encode(["message" => "UPDATE_COUNTERS",
			"labels" => Article::_labels_of($ids),
			"feeds" => Article::_feeds_of($ids)]);
	}

	function sanityCheck(): void {
		$_SESSION["hasSandbox"] = self::_param_to_bool($_REQUEST["hasSandbox"] ?? false);
		$_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]);

		$client_location = $_REQUEST["clientLocation"];

		$error = Errors::E_SUCCESS;
		$error_params = [];

		$client_scheme = parse_url($client_location, PHP_URL_SCHEME);
		$server_scheme = parse_url(Config::get_self_url(), PHP_URL_SCHEME);

		if (Config::is_migration_needed()) {
			$error = Errors::E_SCHEMA_MISMATCH;
		} else if ($client_scheme != $server_scheme) {
			$error = Errors::E_URL_SCHEME_MISMATCH;
			$error_params["client_scheme"] = $client_scheme;
			$error_params["server_scheme"] = $server_scheme;
			$error_params["self_url_path"] = Config::get_self_url();
		}

		if ($error == Errors::E_SUCCESS) {
			$reply = [];

			$reply['init-params'] = $this->_make_init_params();
			$reply['runtime-info'] = $this->_make_runtime_info();
			$reply['translations'] = $this->_translations_as_array();

			print json_encode($reply);
		} else {
			print Errors::to_json($error, $error_params);
		}
	}

	/*function completeLabels() {
		$search = clean($_REQUEST["search"]);

		$sth = $this->pdo->prepare("SELECT DISTINCT caption FROM
				ttrss_labels2
				WHERE owner_uid = ? AND
				LOWER(caption) LIKE LOWER(?) ORDER BY caption
				LIMIT 5");
		$sth->execute([$_SESSION['uid'], "%$search%"]);

		print "<ul>";
		while ($line = $sth->fetch()) {
			print "<li>" . $line["caption"] . "</li>";
		}
		print "</ul>";
	}*/

	function catchupFeed(): void {
		$feed_id = clean($_REQUEST['feed_id']);
		$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? false);
		$mode = clean($_REQUEST['mode'] ?? '');
		$search_query = clean($_REQUEST['search_query']);
		$search_lang = clean($_REQUEST['search_lang']);

		Feeds::_catchup($feed_id, $is_cat, null, $mode, [$search_query, $search_lang]);

		// return counters here synchronously so that frontend can figure out next unread feed properly
		print json_encode(['counters' => Counters::get_all()]);

		//print json_encode(array("message" => "UPDATE_COUNTERS"));
	}

	function setWidescreen(): void {
		$wide = (int) clean($_REQUEST["wide"]);

		set_pref(Prefs::WIDESCREEN_MODE, $wide);

		print json_encode(["wide" => $wide]);
	}

	static function updaterandomfeed_real(): void {
		$default_interval = (int) Prefs::get_default(Prefs::DEFAULT_UPDATE_INTERVAL);

		// Test if the feed need a update (update interval exceded).
		if (Config::get(Config::DB_TYPE) == "pgsql") {
			$update_limit_qpart = "AND ((
					update_interval = 0
						AND (p.value IS NULL OR p.value != '-1')
						AND last_updated < NOW() - CAST((COALESCE(p.value, '$default_interval') || ' minutes') AS INTERVAL)
				) OR (
					update_interval > 0
						AND last_updated < NOW() - CAST((update_interval || ' minutes') AS INTERVAL)
				) OR (
					update_interval >= 0
						AND (p.value IS NULL OR p.value != '-1')
						AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL)
				))";
		} else {
			$update_limit_qpart = "AND ((
					update_interval = 0
						AND (p.value IS NULL OR p.value != '-1')
						AND last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(COALESCE(p.value, '$default_interval'), SIGNED INTEGER) MINUTE)
				) OR (
					update_interval > 0
						AND last_updated < DATE_SUB(NOW(), INTERVAL update_interval MINUTE)
				) OR (
					update_interval >= 0
						AND (p.value IS NULL OR p.value != '-1')
						AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL)
				))";
		}

		// Test if feed is currently being updated by another process.
		if (Config::get(Config::DB_TYPE) == "pgsql") {
			$updstart_thresh_qpart = "AND (last_update_started IS NULL OR last_update_started < NOW() - INTERVAL '5 minutes')";
		} else {
			$updstart_thresh_qpart = "AND (last_update_started IS NULL OR last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
		}

		$random_qpart = Db::sql_random_function();

		$pdo = Db::pdo();

		// we could be invoked from public.php with no active session
		if (!empty($_SESSION["uid"])) {
			$owner_check_qpart = "AND f.owner_uid = ".$pdo->quote($_SESSION["uid"]);
		} else {
			$owner_check_qpart = "";
		}

		$query = "SELECT f.feed_url,f.id
			FROM
				ttrss_feeds f, ttrss_users u LEFT JOIN ttrss_user_prefs2 p ON
					(p.owner_uid = u.id AND profile IS NULL AND pref_name = 'DEFAULT_UPDATE_INTERVAL')
			WHERE
				f.owner_uid = u.id AND
				u.access_level NOT IN (".sprintf("%d, %d", UserHelper::ACCESS_LEVEL_DISABLED, UserHelper::ACCESS_LEVEL_READONLY).")
				$owner_check_qpart
				$update_limit_qpart
				$updstart_thresh_qpart
			ORDER BY $random_qpart LIMIT 30";

		$res = $pdo->query($query);

		$num_updated = 0;

		$tstart = time();

		while ($line = $res->fetch()) {
			$feed_id = $line["id"];

			if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
				RSSUtils::update_rss_feed($feed_id, true);
				++$num_updated;
			} else {
				break;
			}
		}

		// Purge orphans and cleanup tags
		Article::_purge_orphans();
		//cleanup_tags(14, 50000);

		if ($num_updated > 0) {
			print json_encode(array("message" => "UPDATE_COUNTERS",
				"num_updated" => $num_updated));
		} else {
			print json_encode(array("message" => "NOTHING_TO_UPDATE"));
		}
	}

	function updaterandomfeed(): void {
		self::updaterandomfeed_real();
	}

	/**
	 * @param array<int, int> $ids
	 */
	private function markArticlesById(array $ids, int $cmode): void {

		$ids_qmarks = arr_qmarks($ids);

		if ($cmode == Article::CATCHUP_MODE_MARK_AS_READ) {
			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
				marked = false, last_marked = NOW()
					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		} else if ($cmode == Article::CATCHUP_MODE_MARK_AS_UNREAD) {
			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
				marked = true, last_marked = NOW()
					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		} else {
			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
				marked = NOT marked,last_marked = NOW()
					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		}

		$sth->execute([...$ids, $_SESSION['uid']]);
	}

	/**
	 * @param array<int, int> $ids
	 */
	private function publishArticlesById(array $ids, int $cmode): void {

		$ids_qmarks = arr_qmarks($ids);

		if ($cmode == Article::CATCHUP_MODE_MARK_AS_READ) {
			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
				published = false, last_published = NOW()
					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		} else if ($cmode == Article::CATCHUP_MODE_MARK_AS_UNREAD) {
			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
				published = true, last_published = NOW()
					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		} else {
			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
				published = NOT published,last_published = NOW()
					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
		}

		$sth->execute([...$ids, $_SESSION['uid']]);
	}

	function log(): void {
		$msg = clean($_REQUEST['msg'] ?? "");
		$file = basename(clean($_REQUEST['file'] ?? ""));
		$line = (int) clean($_REQUEST['line'] ?? 0);
		$context = clean($_REQUEST['context'] ?? "");

		if ($msg) {
			Logger::log_error(E_USER_WARNING,
				$msg, 'client-js:' . $file, $line, $context);

			echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
		}
	}

	function checkforupdates(): void {
		$rv = ["changeset" => [], "plugins" => []];

		$version = Config::get_version(false);

		$git_timestamp = $version["timestamp"] ?? false;
		$git_commit = $version["commit"] ?? false;

		if (Config::get(Config::CHECK_FOR_UPDATES) && $_SESSION["access_level"] >= UserHelper::ACCESS_LEVEL_ADMIN && $git_timestamp) {
			$content = @UrlHelper::fetch(["url" => "https://tt-rss.org/version.json"]);

			if ($content) {
				$content = json_decode($content, true);

				if ($content && isset($content["changeset"])) {
					if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
						$git_commit != $content["changeset"]["id"]) {

						$rv["changeset"] = $content["changeset"];
					}
				}
			}

			$rv["plugins"] = Pref_Prefs::_get_updated_plugins();
		}

		print json_encode($rv);
	}

	/**
	 * @return array<string, mixed>
	 */
	private function _make_init_params(): array {
		$params = array();

		foreach ([Prefs::ON_CATCHUP_SHOW_NEXT_FEED, Prefs::HIDE_READ_FEEDS,
			Prefs::ENABLE_FEED_CATS, Prefs::FEEDS_SORT_BY_UNREAD,
			Prefs::CONFIRM_FEED_CATCHUP,  Prefs::CDM_AUTO_CATCHUP,
			Prefs::FRESH_ARTICLE_MAX_AGE, Prefs::HIDE_READ_SHOWS_SPECIAL,
			Prefs::COMBINED_DISPLAY_MODE, Prefs::DEBUG_HEADLINE_IDS, Prefs::CDM_ENABLE_GRID] as $param) {

			$params[strtolower($param)] = (int) get_pref($param);
		}

		$params["safe_mode"] = !empty($_SESSION["safe_mode"]);
		$params["check_for_updates"] = Config::get(Config::CHECK_FOR_UPDATES);
		$params["icons_url"] = Config::get_self_url() . '/public.php';
		$params["cookie_lifetime"] = Config::get(Config::SESSION_COOKIE_LIFETIME);
		$params["default_view_mode"] = get_pref(Prefs::_DEFAULT_VIEW_MODE);
		$params["default_view_limit"] = (int) get_pref(Prefs::_DEFAULT_VIEW_LIMIT);
		$params["default_view_order_by"] = get_pref(Prefs::_DEFAULT_VIEW_ORDER_BY);
		$params["bw_limit"] = (int) ($_SESSION["bw_limit"] ?? false);
		$params["is_default_pw"] = UserHelper::is_default_password();
		$params["label_base_index"] = LABEL_BASE_INDEX;

		$theme = get_pref(Prefs::USER_CSS_THEME);
		$params["theme"] = theme_exists($theme) ? $theme : "";

		$params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names());

		$params["php_platform"] = PHP_OS;
		$params["php_version"] = PHP_VERSION;

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
				ttrss_feeds WHERE owner_uid = ?");
		$sth->execute([$_SESSION['uid']]);
		$row = $sth->fetch();

		$max_feed_id = $row["mid"];
		$num_feeds = $row["nf"];

		$params["self_url_prefix"] = Config::get_self_url();
		$params["max_feed_id"] = (int) $max_feed_id;
		$params["num_feeds"] = (int) $num_feeds;
		$params["hotkeys"] = $this->get_hotkeys_map();
		$params["widescreen"] = (int) get_pref(Prefs::WIDESCREEN_MODE);
		$params['simple_update'] = Config::get(Config::SIMPLE_UPDATE_MODE);
		$params["icon_indicator_white"] = $this->image_to_base64("images/indicator_white.gif");
		$params["icon_oval"] = $this->image_to_base64("images/oval.svg");
		$params["icon_three_dots"] = $this->image_to_base64("images/three-dots.svg");
		$params["icon_blank"] = $this->image_to_base64("images/blank_icon.gif");
		$params["labels"] = Labels::get_all($_SESSION["uid"]);

		return $params;
	}

	private function image_to_base64(string $filename): string {
		if (file_exists($filename)) {
			$ext = pathinfo($filename, PATHINFO_EXTENSION);

			if ($ext == "svg") $ext = "svg+xml";

			return "data:image/$ext;base64," . base64_encode((string)file_get_contents($filename));
		} else {
			return "";
		}
	}

	/**
	 * @return array<string, mixed>
	 */
	static function _make_runtime_info(): array {
		$data = array();

		$pdo = Db::pdo();

		$sth = $pdo->prepare("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
				ttrss_feeds WHERE owner_uid = ?");
		$sth->execute([$_SESSION['uid']]);
		$row = $sth->fetch();

		$max_feed_id = $row['mid'];
		$num_feeds = $row['nf'];

		$data["max_feed_id"] = (int) $max_feed_id;
		$data["num_feeds"] = (int) $num_feeds;
		$data['cdm_expanded'] = get_pref(Prefs::CDM_EXPANDED);
		$data["labels"] = Labels::get_all($_SESSION["uid"]);

		if (Config::get(Config::LOG_DESTINATION) == 'sql' && $_SESSION['access_level'] >= UserHelper::ACCESS_LEVEL_ADMIN) {
			if (Config::get(Config::DB_TYPE) == 'pgsql') {
				$log_interval = "created_at > NOW() - interval '1 hour'";
			} else {
				$log_interval = "created_at > DATE_SUB(NOW(), INTERVAL 1 HOUR)";
			}

			$sth = $pdo->prepare("SELECT COUNT(id) AS cid
				FROM ttrss_error_log
			WHERE
				errno NOT IN (".E_USER_NOTICE.", ".E_USER_DEPRECATED.") AND
				$log_interval AND
				errstr NOT LIKE '%Returning bool from comparison function is deprecated%' AND
				errstr NOT LIKE '%imagecreatefromstring(): Data is not in a recognized format%'");
			$sth->execute();

			if ($row = $sth->fetch()) {
				$data['recent_log_events'] = $row['cid'];
			}
		}

		if (file_exists(Config::get(Config::LOCK_DIRECTORY) . "/update_daemon.lock")) {

			$data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock");

			if (time() - ($_SESSION["daemon_stamp_check"] ?? 0) > 30) {

				$stamp = (int) @file_get_contents(Config::get(Config::LOCK_DIRECTORY) . "/update_daemon.stamp");

				if ($stamp) {
					$stamp_delta = time() - $stamp;

					if ($stamp_delta > 1800) {
						$stamp_check = 0;
					} else {
						$stamp_check = 1;
						$_SESSION["daemon_stamp_check"] = time();
					}

					$data['daemon_stamp_ok'] = $stamp_check;

					$stamp_fmt = date("Y.m.d, G:i", $stamp);

					$data['daemon_stamp'] = $stamp_fmt;
				}
			}
		}

		return $data;
	}

	/**
	 * @return array<string, array<string, string>>
	 */
	static function get_hotkeys_info(): array {
		$hotkeys = array(
			__("Navigation") => array(
				"next_feed" => __("Open next feed"),
				"next_unread_feed" => __("Open next unread feed"),
				"prev_feed" => __("Open previous feed"),
				"prev_unread_feed" => __("Open previous unread feed"),
				"next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"),
				"prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"),
				"next_headlines_page" => __("Scroll headlines by one page down"),
				"prev_headlines_page" => __("Scroll headlines by one page up"),
				"next_article_noscroll" => __("Open next article"),
				"prev_article_noscroll" => __("Open previous article"),
				"next_article_noexpand" => __("Move to next article (don't expand)"),
				"prev_article_noexpand" => __("Move to previous article (don't expand)"),
				"search_dialog" => __("Show search dialog"),
				"cancel_search" => __("Cancel active search")),
			__("Article") => array(
				"toggle_mark" => __("Toggle starred"),
				"toggle_publ" => __("Toggle published"),
				"toggle_unread" => __("Toggle unread"),
				"edit_tags" => __("Edit tags"),
				"open_in_new_window" => __("Open in new window"),
				"catchup_below" => __("Mark below as read"),
				"catchup_above" => __("Mark above as read"),
				"article_scroll_down" => __("Scroll down"),
				"article_scroll_up" => __("Scroll up"),
				"article_page_down" => __("Scroll down page"),
				"article_page_up" => __("Scroll up page"),
				"select_article_cursor" => __("Select article under cursor"),
				"email_article" => __("Email article"),
				"close_article" => __("Close/collapse article"),
				"toggle_expand" => __("Toggle article expansion (combined mode)"),
				"toggle_widescreen" => __("Toggle widescreen mode"),
				"toggle_full_text" => __("Toggle full article text via Readability")),
			__("Article selection") => array(
				"select_all" => __("Select all articles"),
				"select_unread" => __("Select unread"),
				"select_marked" => __("Select starred"),
				"select_published" => __("Select published"),
				"select_invert" => __("Invert selection"),
				"select_none" => __("Deselect everything")),
			__("Feed") => array(
				"feed_refresh" => __("Refresh current feed"),
				"feed_unhide_read" => __("Un/hide read feeds"),
				"feed_subscribe" => __("Subscribe to feed"),
				"feed_edit" => __("Edit feed"),
				"feed_catchup" => __("Mark as read"),
				"feed_reverse" => __("Reverse headlines"),
				"feed_toggle_vgroup" => __("Toggle headline grouping"),
				"feed_toggle_grid" => __("Toggle grid view"),
				"feed_debug_update" => __("Debug feed update"),
				"feed_debug_viewfeed" => __("Debug viewfeed()"),
				"catchup_all" => __("Mark all feeds as read"),
				"cat_toggle_collapse" => __("Un/collapse current category"),
				"toggle_cdm_expanded" => __("Toggle auto expand in combined mode"),
				"toggle_combined_mode" => __("Toggle combined mode")),
			__("Go to") => array(
				"goto_all" => __("All articles"),
				"goto_fresh" => __("Fresh"),
				"goto_marked" => __("Starred"),
				"goto_published" => __("Published"),
				"goto_read" => __("Recently read"),
				"goto_prefs" => __("Preferences")),
			__("Other") => array(
				"create_label" => __("Create label"),
				"create_filter" => __("Create filter"),
				"collapse_sidebar" => __("Un/collapse sidebar"),
				"help_dialog" => __("Show help dialog"))
		);

		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HOTKEY_INFO,
			function ($result) use (&$hotkeys) {
				$hotkeys = $result;
			},
			$hotkeys);

		return $hotkeys;
	}

	/**
	 * {3} - 3 panel mode only
	 * {C} - combined mode only
	 *
	 * @return array{0: array<int, string>, 1: array<string, string>} $prefixes, $hotkeys
	 */
	static function get_hotkeys_map() {
		$hotkeys = array(
			"k" => "next_feed",
			"K" => "next_unread_feed",
			"j" => "prev_feed",
			"J" => "prev_unread_feed",
			"n" => "next_article_noscroll",
			"p" => "prev_article_noscroll",
			"N" => "article_page_down",
			"P" => "article_page_up",
			"*(33)|Shift+PgUp" => "article_page_up",
			"*(34)|Shift+PgDn" => "article_page_down",
			"{3}(38)|Up" => "prev_article_or_scroll",
			"{3}(40)|Down" => "next_article_or_scroll",
			"*(38)|Shift+Up" => "article_scroll_up",
			"*(40)|Shift+Down" => "article_scroll_down",
			"^(38)|Ctrl+Up" => "prev_article_noscroll",
			"^(40)|Ctrl+Down" => "next_article_noscroll",
			"/" => "search_dialog",
			"\\" => "cancel_search",
			"s" => "toggle_mark",
			"S" => "toggle_publ",
			"u" => "toggle_unread",
			"T" => "edit_tags",
			"o" => "open_in_new_window",
			"c p" => "catchup_below",
			"c n" => "catchup_above",
			"a W" => "toggle_widescreen",
			"a e" => "toggle_full_text",
			"e" => "email_article",
			"a q" => "close_article",
			"a s" => "article_span_grid",
			"a a" => "select_all",
			"a u" => "select_unread",
			"a U" => "select_marked",
			"a p" => "select_published",
			"a i" => "select_invert",
			"a n" => "select_none",
			"f r" => "feed_refresh",
			"f a" => "feed_unhide_read",
			"f s" => "feed_subscribe",
			"f e" => "feed_edit",
			"f q" => "feed_catchup",
			"f x" => "feed_reverse",
			"f g" => "feed_toggle_vgroup",
			"f G" => "feed_toggle_grid",
			"f D" => "feed_debug_update",
			"f %" => "feed_debug_viewfeed",
			"f C" => "toggle_combined_mode",
			"f c" => "toggle_cdm_expanded",
			"Q" => "catchup_all",
			"x" => "cat_toggle_collapse",
			"g a" => "goto_all",
			"g f" => "goto_fresh",
			"g s" => "goto_marked",
			"g p" => "goto_published",
			"g r" => "goto_read",
			"g P" => "goto_prefs",
			"r" => "select_article_cursor",
			"c l" => "create_label",
			"c f" => "create_filter",
			"c s" => "collapse_sidebar",
			"?" => "help_dialog",
		);

		PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HOTKEY_MAP,
			function ($result) use (&$hotkeys) {
				$hotkeys = $result;
			},
			$hotkeys);

		$prefixes = array();

		foreach (array_keys($hotkeys) as $hotkey) {
			$pair = explode(" ", (string)$hotkey, 2);

			if (count($pair) > 1 && !in_array($pair[0], $prefixes)) {
				array_push($prefixes, $pair[0]);
			}
		}

		return array($prefixes, $hotkeys);
	}

	function hotkeyHelp(): void {
		$info = self::get_hotkeys_info();
		$imap = self::get_hotkeys_map();
		$omap = [];

		foreach ($imap[1] as $sequence => $action) {
			$omap[$action] ??= [];
			$omap[$action][] = $sequence;
		}

		?>
		<ul class='panel panel-scrollable hotkeys-help' style='height : 300px'>
		<?php

		foreach ($info as $section => $hotkeys) {
			?>
			<li><h3><?= $section ?></h3></li>
			<?php

			foreach ($hotkeys as $action => $description) {

				if (!empty($omap[$action])) {
					foreach ($omap[$action] as $sequence) {
						if (strpos($sequence, "|") !== false) {
							$sequence = substr($sequence,
								strpos($sequence, "|")+1,
								strlen($sequence));
						} else {
							$keys = explode(" ", $sequence);

							for ($i = 0; $i < count($keys); $i++) {
								if (strlen($keys[$i]) > 1) {
									$tmp = '';
									foreach (str_split($keys[$i]) as $c) {
										switch ($c) {
											case '*':
												$tmp .= __('Shift') . '+';
												break;
											case '^':
												$tmp .= __('Ctrl') . '+';
												break;
											default:
												$tmp .= $c;
										}
									}
									$keys[$i] = $tmp;
								}
							}
							$sequence = join(" ", $keys);
						}

						?>
						<li>
							<div class='hk'><code><?= $sequence ?></code></div>
							<div class='desc'><?= $description ?></div>
						</li>
						<?php
					}
				}
			}
		}
		?>
		</ul>
	<footer class='text-center'>
		<?= \Controls\submit_tag(__('Close this window')) ?>
	</footer>
	<?php
	}
}
'use strict'

/* global __, App, Headlines, xhr, dojo, dijit, fox, PluginHost, Notify, fox */

const	Feeds = {
	FEED_ARCHIVED: 0,
	FEED_STARRED: -1,
	FEED_PUBLISHED: -2,
	FEED_FRESH: -3,
	FEED_ALL: -4,
	FEED_RECENTLY_READ: -6,
	FEED_ERROR: -7,
	CATEGORY_UNCATEGORIZED: 0,
	CATEGORY_SPECIAL: -1,
	CATEGORY_LABELS: -2,
	CATEGORY_ALL_EXCEPT_VIRTUAL: -3,
	CATEGORY_ALL: -4,
	_default_feed_id: -3,
	counters_last_request: 0,
	_active_feed_id: undefined,
	_active_feed_is_cat: false,
	infscroll_in_progress: 0,
	infscroll_disabled: 0,
	_infscroll_timeout: false,
	_filter_query: false, // TODO: figure out the UI for this
	_search_query: false,
	last_search_query: [],
	_viewfeed_wait_timeout: false,
	_feeds_holder_observer: new IntersectionObserver(
		(entries/*, observer*/) => {
			entries.forEach((entry) => {
				//console.log('feeds',entry.target, entry.intersectionRatio);

				if (entry.intersectionRatio == 0)
					Feeds.onHide(entry);
				else
					Feeds.onShow(entry);
			});
		},
		{threshold: [0, 1], root: document.querySelector("body")}
	),
	_counters_prev: [],
	// NOTE: this implementation is incomplete
	// for general objects but good enough for counters
	// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
	counterEquals: function(a, b) {
		// Create arrays of property names
		const aProps = Object.getOwnPropertyNames(a);
		const bProps = Object.getOwnPropertyNames(b);

		// If number of properties is different,
		// objects are not equivalent
		if (aProps.length != bProps.length) {
			return false;
		}

		for (let i = 0; i < aProps.length; i++) {
			const propName = aProps[i];

			// If values of same property are not equal,
			// objects are not equivalent
			if (a[propName] !== b[propName]) {
				return false;
			}
		}

		// If we made it this far, objects
		// are considered equivalent
		return true;
	},
	resetCounters: function () {
		this._counters_prev = [];
	},
	parseCounters: function (elems) {
		PluginHost.run(PluginHost.HOOK_COUNTERS_RECEIVED, elems);

		for (let l = 0; l < elems.length; l++) {

			if (Feeds._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) {
				continue;
			}

			const id = elems[l].id;
			const kind = elems[l].kind;
			const ctr = parseInt(elems[l].counter);
			const error = elems[l].error;
			const ts = elems[l].ts;
			const updated = elems[l].updated;

			if (id == "global-unread") {
				App.global_unread = ctr;
				App.updateTitle();
				continue;
			}

			if (id == "subscribed-feeds") {
				/* feeds_found = ctr; */
				continue;
			}

			/*if (this.getUnread(id, (kind == "cat")) != ctr ||
					(kind == "cat")) {
			}*/

			this.setUnread(id, (kind == "cat"), ctr);
			this.setValue(id, (kind == "cat"), 'auxcounter', parseInt(elems[l].auxcounter));
			this.setValue(id, (kind == "cat"), 'markedcounter', parseInt(elems[l].markedcounter));

			if (kind != "cat") {
				this.setValue(id, false, 'error', error);
				this.setValue(id, false, 'updated', updated);

				if (id > 0) {
					if (ts) {
						this.setIcon(id, false,
							App.getInitParam("icons_url") + '?' + dojo.objectToQuery({op: 'feed_icon', id: id, ts: ts}));
					} else {
						this.setIcon(id, false, 'images/blank_icon.gif');
					}
				}
			}
		}

		Headlines.updateCurrentUnread();

		this.hideOrShowFeeds(App.getInitParam("hide_read_feeds"));
		this._counters_prev = elems;

		PluginHost.run(PluginHost.HOOK_COUNTERS_PROCESSED, elems);
	},
	reloadCurrent: function(method) {
		if (this.getActive() != undefined) {
			console.log("reloadCurrent", this.getActive(), this.activeIsCat(), method);

			this.open({feed: this.getActive(), is_cat: this.activeIsCat(), method: method});
		}
	},
	openDefaultFeed: function() {
		this.open({feed: this._default_feed_id});
	},
   onViewModeChanged: function() {
		// TODO: is this still needed?
      App.find("body").setAttribute("view-mode",
			dijit.byId("toolbar-main").getValues().view_mode);

      return Feeds.reloadCurrent('');
   },
	openNextUnread: function() {
		const [feed, is_cat] = this.getNextUnread(this.getActive(), this.activeIsCat());

		if (feed !== false)
			this.open({feed: feed, is_cat: is_cat});
	},
	toggle: function() {
		Element.toggle("feeds-holder");
	},
	cancelFilter: function() {
		this._filter_query = "";
		this.reload();
	},
	cancelSearch: function() {
		this._search_query = "";
		this.reloadCurrent();
	},
	// null = get all data, [] would give empty response for specific type
	requestCounters: function(feed_ids = null, label_ids = null) {
		xhr.json("backend.php", {op: "RPC",
							method: "getAllCounters",
							"feed_ids[]": feed_ids,
							"feed_id_count": feed_ids ? feed_ids.length : -1,
							"label_ids[]": label_ids,
							"label_id_count": label_ids ? label_ids.length : -1,
							seq: App.next_seq()});
	},
	reload: function() {
		try {
			Element.show("feedlistLoading");

			this.resetCounters();

			if (dijit.byId("feedTree")) {
				dijit.byId("feedTree").destroyRecursive();
			}

			let query = {op: 'Pref_Feeds', method: 'getfeedtree', mode: 2};

			if (this._filter_query) {
				query = Object.assign(query, this._filter_query);
			}

			const store = new dojo.data.ItemFileWriteStore({
				url: "backend.php?" + dojo.objectToQuery(query)
			});

			// noinspection JSUnresolvedFunction
			const treeModel = new fox.FeedStoreModel({
				store: store,
				query: {
					"type": App.getInitParam('enable_feed_cats') ? "category" : "feed"
				},
				rootId: "root",
				rootLabel: "Feeds",
				childrenAttrs: ["items"]
			});

			// noinspection JSUnresolvedFunction
			const tree = new fox.FeedTree({
				model: treeModel,
				onClick: function (item/*, node*/) {
					const id = String(item.id);
					const is_cat = id.match("^CAT:");
					const feed = id.substr(id.indexOf(":") + 1);
					Feeds.open({feed: feed, is_cat: is_cat});
					return false;
				},
				openOnClick: false,
				showRoot: false,
				persist: true,
				id: "feedTree",
			}, "feedTree");

			const tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) {
				console.log(dijit.getEnclosingWidget(event.target));
				dojo.disconnect(tmph);
			});

			App.byId("feeds-holder").appendChild(tree.domNode);

			const tmph2 = dojo.connect(tree, 'onLoad', function () {
				dojo.disconnect(tmph2);
				Element.hide("feedlistLoading");

				try {
					Feeds.init();
					App.setLoadingProgress(25);
				} catch (e) {
					App.Error.report(e);
				}
			});

			tree.startup();
		} catch (e) {
			App.Error.report(e);
		}
	},
	onHide: function() {
		App.byId("feeds-holder_splitter").hide();

		dijit.byId("main").resize();
		Headlines.updateCurrentUnread();
	},
	onShow: function() {
		App.byId("feeds-holder_splitter").show();

		dijit.byId("main").resize();
		Headlines.updateCurrentUnread();
	},
	init: function() {
		console.log("in feedlist init");

		this._feeds_holder_observer.observe(App.byId("feeds-holder"));

		App.setLoadingProgress(50);

		//document.onkeydown = (event) => { return App.hotkeyHandler(event) };
		//document.onkeypress = (event) => { return App.hotkeyHandler(event) };
		window.onresize = () => { Headlines.scrollHandler(); }

		const hash = App.Hash.get();

		console.log('got hash', hash);

		if (hash.f != undefined) {
			this.open({feed: parseInt(hash.f), is_cat: parseInt(hash.c)});
		} else {
			this.openDefaultFeed();
		}

		this.hideOrShowFeeds(App.getInitParam("hide_read_feeds"));

		if (App.getInitParam("is_default_pw")) {
			console.warn("user password is at default value");

			const dialog = new fox.SingleUseDialog({
				title: __("Your password is at default value"),
				content: `<div class='alert alert-error'>
					${__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")}
				</div>

				<footer class='text-center'>
					<button dojoType='dijit.form.Button' class='alt-primary' onclick="document.location.href = 'prefs.php'">
						${__('Open Preferences')}
					</button>
					<button dojoType='dijit.form.Button' onclick="App.dialogOf(this).hide()">
						${__('Close this window')}
					</button>
				</footer>`
			});

			dialog.show();
		}

		if (App.getInitParam("safe_mode")) {
			/* global CommonDialogs */
			CommonDialogs.safeModeWarning();
		}

		dojo.connect(dijit.byId("main-catchup-dropdown"), 'onItemClick',
			(item) => Feeds.catchupCurrent(item.option.value)
		);

		// bw_limit disables timeout() so we request initial counters separately
		if (App.getInitParam("bw_limit")) {
			this.requestCounters();
		} else {
			setTimeout(() => {
				this.requestCounters();
				//setInterval(() => { this.requestCounters(); }, 60 * 1000)
				// i sdelal
				setInterval(() => { this.requestCounters(); }, 5 * 1000)
			}, 250);
		}
		
		this.get_alerts_forreaderlables();  //i sdelal start function
	},
	 //i sdelal function
		// https://stackoverflow.com/questions/24564030/is-an-eventsource-sse-supposed-to-try-to-reconnect-indefinitely
	reconnectFrequencySeconds: 1,
		//evtSource: undefined,

		// Putting these functions in extra variables is just for the sake of readability
	waitFunc: function() { return this.reconnectFrequencySeconds * 1000 },
	
	tryToSetupFunc: function() {
			this.get_alerts_forreaderlables();
			this.reconnectFrequencySeconds *= 2;
			if (this.reconnectFrequencySeconds >= 10) {
				this.reconnectFrequencySeconds = 10;
			}
	},
	
	//TypeError: this.get_alerts_forreaderlables() is not a function
	//https://stackoverflow.com/questions/42238984/uncaught-typeerror-this-method-is-not-a-function-node-js-class-export
	// need usage: .bind(this)
	// change: setTimeout(this.tryToSetupFunc, this.waitFunc())
	// to: setTimeout(this.tryToSetupFunc.bind(this), this.waitFunc())
	reconnectFunc: function() { setTimeout(this.tryToSetupFunc.bind(this), this.waitFunc()) },

	//i sdelal function
    get_alerts_forreaderlables: function() {
		//const AlertSSE_ForReaderLables = require('./settings_AlertSSE_ForReaderLables');
		const AlertSSE_ForReaderLables = "//192.168.0.100:8080"
		
        const evtSource = new EventSource(AlertSSE_ForReaderLables + "/alerts_forreaderlables/");
			evtSource.onmessage = (event) => {
			var fdata = JSON.parse(event.data);
			var changed_label_id = -1024 - 1 - Math.abs(fdata.label_id);    // LABEL_BASE_INDEX = -1024	
			this.setUnread(changed_label_id, false, 1);
		};
		
		evtSource.onopen = (event) => {
			this.reconnectFrequencySeconds = 1;
			console.log('EventSource("/alerts_forreaderlables/"): CONNECTED');
			console.log("set reconnectFrequencySeconds = 1");
		};
		evtSource.onerror = (event) => {
			evtSource.close();
			console.log('error, EventSource("/alerts_forreaderlables/"): CLOSED');
			console.log(
				'reconnect EventSource("/alerts_forreaderlables/"): reconnectFrequencySeconds: ',
				this.reconnectFrequencySeconds
			);
			this.reconnectFunc();
		};
			
	},
	activeIsCat: function() {
		return !!this._active_feed_is_cat;
	},
	getActive: function() {
		return this._active_feed_id;
	},
	setActive: function(id, is_cat) {
		console.log('setActive', id, is_cat);

		window.requestIdleCallback(() => {
			App.Hash.set({f: id, c: is_cat ? 1 : 0});
		});

		this._active_feed_id = id;
		this._active_feed_is_cat = is_cat;

		const container = App.byId("headlines-frame");

		// TODO @deprecated: these two should be removed (replaced with data- attributes below)
		container.setAttribute("feed-id", id);
		container.setAttribute("is-cat", is_cat ? 1 : 0);
		// ^

		container.setAttribute("data-feed-id", id);
		container.setAttribute("data-is-cat", is_cat ? "true" : "false");

		this.select(id, is_cat);

		PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, [this._active_feed_id, this._active_feed_is_cat]);
	},
	select: function(feed, is_cat) {
		const tree = dijit.byId("feedTree");

		if (tree) return tree.selectFeed(feed, is_cat);
	},
	toggleUnread: function() {
		const hide = !App.getInitParam("hide_read_feeds");

		xhr.post("backend.php", {op: "RPC", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => {
			this.hideOrShowFeeds(hide);
			App.setInitParam("hide_read_feeds", hide);
		});
	},
	hideOrShowFeeds: function (hide) {
		/*const tree = dijit.byId("feedTree");

		if (tree)
			return tree.hideRead(hide, App.getInitParam("hide_read_shows_special"));*/

		App.findAll("body")[0].setAttribute("hide-read-feeds", !!hide);
		App.findAll("body")[0].setAttribute("hide-read-shows-special", !!App.getInitParam("hide_read_shows_special"));
	},
	open: function(params) {
		const feed = params.feed;
		const is_cat = !!params.is_cat || false;
		const offset = params.offset || 0;
		const append = params.append || false;
		const method = params.method;
		// this is used to quickly switch between feeds, sets active but xhr is on a timeout
		const delayed = params.delayed || false;

		if (offset != 0) {
			if (this.infscroll_in_progress)
				return;

			this.infscroll_in_progress = 1;

			window.clearTimeout(this._infscroll_timeout);
			this._infscroll_timeout = window.setTimeout(() => {
				console.log('infscroll request timed out, aborting');
				this.infscroll_in_progress = 0;

				// call scroll handler to maybe repeat infscroll request
				Headlines.scrollHandler();
			}, 10 * 1000);
		}

		let query = {...{op: "Feeds", method: "view", feed: feed}, ...dojo.formToObject("toolbar-main")};

		if (method) query.m = method;

		if (offset > 0) {
			if (Headlines.current_first_id) {
				query.fid = Headlines.current_first_id;
			}
		}

		if (this._search_query) {
			query = Object.assign(query, this._search_query);
		}

		if (offset != 0) {
			query.skip = offset;
		} else if (!is_cat && feed == this.getActive() && !params.method) {
			query.m = "ForceUpdate";
		}

		query.cat = is_cat;

		this.setActive(feed, is_cat);

		window.clearTimeout(this._viewfeed_wait_timeout);
		this._viewfeed_wait_timeout = window.setTimeout(() => {

			this.showLoading(feed, is_cat, true);
			//Notify.progress("Loading, please wait...", true);*/

			xhr.json("backend.php", query, (reply) => {
				try {
					window.clearTimeout(this._infscroll_timeout);
					this.showLoading(feed, is_cat, false);
					Headlines.onLoaded(reply, offset, append);
					PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
				} catch (e) {
					App.Error.report(e);
				}
			});
		}, delayed ? 250 : 0);
	},
	catchupAll: function() {
		const str = __("Mark all articles as read?");

		if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {

			Notify.progress("Marking all feeds as read...");

			xhr.json("backend.php", {op: "Feeds", method: "catchupAll"}, () => {
				this.reloadCurrent();
			});

			App.global_unread = 0;
			App.updateTitle();
		}
	},
	catchupFeed: function(feed, is_cat, mode) {
		is_cat = is_cat || false;

		let str = false;

		switch (mode) {
			case "1day":
				str = __("Mark %w in %s older than 1 day as read?");
				break;
			case "1week":
				str = __("Mark %w in %s older than 1 week as read?");
				break;
			case "2week":
				str = __("Mark %w in %s older than 2 weeks as read?");
				break;
			default:
				str = __("Mark %w in %s as read?");
		}

		const mark_what = this.last_search_query && this.last_search_query[0] ? __("search results") : __("all articles");
		const fn = this.getName(feed, is_cat);

		str = str.replace("%s", fn)
			.replace("%w", mark_what);

		if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) {
			return;
		}

		const catchup_query = {
			op: 'RPC', method: 'catchupFeed', feed_id: feed,
			is_cat: is_cat, mode: mode, search_query: this.last_search_query[0],
			search_lang: this.last_search_query[1]
		};

		Notify.progress("Loading, please wait...", true);

		xhr.json("backend.php", catchup_query, () => {
			const show_next_feed = App.getInitParam("on_catchup_show_next_feed");

			// only select next unread feed if catching up entirely (as opposed to last week etc)
			if (show_next_feed && !mode) {
				const [next_feed, next_is_cat] = this.getNextUnread(feed, is_cat);

				if (next_feed !== false) {
					this.open({feed: next_feed, is_cat: next_is_cat});
				}
			} else if (feed == this.getActive() && is_cat == this.activeIsCat()) {
				this.reloadCurrent();
			}

			Notify.close();
		});
	},
	catchupCurrent: function(mode) {
		this.catchupFeed(this.getActive(), this.activeIsCat(), mode);
	},
	catchupFeedInGroup: function(id) {
		const title = this.getName(id);

		const str = __("Mark all articles in %s as read?").replace("%s", title);

		if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {

			const rows = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread][data-orig-feed-id='" + id + "']");

			rows.forEach((row) => {
				row.removeClassName("Unread");
			})
		}
	},
	getUnread: function(feed, is_cat) {
		try {
			const tree = dijit.byId("feedTree");

			if (tree && tree.model)
				return tree.model.getFeedUnread(feed, is_cat);

		} catch (e) {
			//
		}

		return -1;
	},
	getCategory: function(feed) {
		try {
			const tree = dijit.byId("feedTree");

			if (tree && tree.model)
				return tree.getFeedCategory(feed);

		} catch (e) {
			//
		}

		return false;
	},
	getName: function(feed, is_cat) {
		if (isNaN(feed)) return feed; // it's a tag

		const tree = dijit.byId("feedTree");

		if (tree && tree.model)
			return tree.model.getFeedValue(feed, is_cat, 'name');
	},
	setUnread: function(feed, is_cat, unread) {
		const tree = dijit.byId("feedTree");

		if (tree && tree.model)
			return tree.model.setFeedUnread(feed, is_cat, unread);
	},
	setValue: function(feed, is_cat, key, value) {
		try {
			const tree = dijit.byId("feedTree");

			if (tree && tree.model)
				return tree.model.setFeedValue(feed, is_cat, key, value);

		} catch (e) {
			//
		}
	},
	getValue: function(feed, is_cat, key) {
		try {
			const tree = dijit.byId("feedTree");

			if (tree && tree.model)
				return tree.model.getFeedValue(feed, is_cat, key);

		} catch (e) {
			//
		}
		return '';
	},
	setIcon: function(feed, is_cat, src) {
		const tree = dijit.byId("feedTree");

		if (tree) return tree.setIcon(feed, is_cat, src);
	},
	showLoading: function(feed, is_cat, show) {
		const tree = dijit.byId("feedTree");

		if (tree) return tree.showLoading(feed, is_cat, show);

		return false;
	},
	getNextFeed: function(feed, is_cat, unread_only = false) {
		const tree = dijit.byId("feedTree");

		if (tree) return tree.getNextFeed(feed, is_cat, unread_only);

		return [false, false];
	},
	getPreviousFeed: function(feed, is_cat, unread_only = false) {
		const tree = dijit.byId("feedTree");

		if (tree) return tree.getPreviousFeed(feed, is_cat, unread_only);

		return [false, false];
	},
	getNextUnread: function(feed, is_cat) {
		const tree = dijit.byId("feedTree");

		if (tree) return tree.getNextUnread(feed, is_cat);

		return [false, false];
	},
	search: function() {
		xhr.json("backend.php",
					{op: "Feeds", method: "search"},
					(reply) => {
						try {
							const dialog = new fox.SingleUseDialog({
								content: `
									<form onsubmit='return false'>
										<section>
											<fieldset>
												<input dojoType='dijit.form.ValidationTextBox' id='search_query'
													style='font-size : 16px; width : 540px;'
													placeHolder="${__("Search %s...").replace("%s", Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()))}"
													name='query' type='search' value=''>
											</fieldset>

											${reply.show_language ?
												`
												<fieldset>
													<label class='inline'>${__("Language:")}</label>
													${App.FormFields.select_tag("search_language", reply.default_language, reply.all_languages,
															{title: __('Used for word stemming')}, "search_language")}
												</fieldset>
												` : ''}
										</section>

										<footer>
											${reply.show_syntax_help ?
												`${App.FormFields.button_tag(App.FormFields.icon("help") + " " + __("Search syntax"), "",
													{class: 'alt-info pull-left', onclick: "window.open('https://tt-rss.org/wiki/SearchSyntax')"})}
													` : ''}

											${App.FormFields.submit_tag(App.FormFields.icon("search") + " " + __('Search'), {onclick: "App.dialogOf(this).execute()"})}
											${App.FormFields.cancel_dialog_tag(__('Cancel'))}
										</footer>
									</form>
								`,
								title: __("Search"),
								execute: function () {
									if (this.validate()) {
										Feeds._search_query = this.attr('value');

										// disallow empty queries
										if (!Feeds._search_query.query)
											Feeds._search_query = false;

										this.hide();
										Feeds.reloadCurrent();
									}
								},
							});

							const tmph = dojo.connect(dialog, 'onShow', function () {
								dojo.disconnect(tmph);

								if (Feeds._search_query) {
									if (Feeds._search_query.query)
										dijit.byId('search_query')
											.attr('value', Feeds._search_query.query);

									if (Feeds._search_query.search_language)
										dijit.byId('search_language')
											.attr('value', Feeds._search_query.search_language);
								}
							});

							dialog.show();
						} catch (e) {
							App.Error.report(e);
						}
					});

	},
	filter: function() {
		const dialog = new fox.SingleUseDialog({
			content: `
				<form onsubmit='return false'>
					<section>
						<fieldset>
							<input dojoType='dijit.form.ValidationTextBox' id='filter_query'
								style='font-size : 16px; width : 540px;'
								placeHolder="${__("Show feeds matching...")}"
								name='search' type='search' value=''>
						</fieldset>
					</section>

					<footer>
						${App.FormFields.submit_tag(App.FormFields.icon("search") + " " + __('Search'), {onclick: "App.dialogOf(this).execute()"})}
						${App.FormFields.cancel_dialog_tag(__('Cancel'))}
					</footer>
				</form>
			`,
			title: __("Search feeds"),
			execute: function () {
				if (this.validate()) {
					Feeds._filter_query = this.attr('value');

					this.hide();
					Feeds.reload();
				}
			},
		});

		const tmph = dojo.connect(dialog, 'onShow', function () {
			dojo.disconnect(tmph);

			if (Feeds._filter_query && Feeds._filter_query.search) {
				dijit.byId('filter_query')
					.attr('value', Feeds._filter_query.search);
			}
		});

		dialog.show();

	},
	updateRandom: function() {
		console.log("in update_random_feed");

		xhr.json("backend.php", {op: "RPC", method: "updaterandomfeed"}, () => {
			//
		});
	},
	renderIcon: function(feed_id, exists) {
		const icon_url = App.getInitParam("icons_url") + '?' + dojo.objectToQuery({op: 'feed_icon', id: feed_id});

		return feed_id && exists ?
			`<img class="icon" src="${App.escapeHtml(icon_url)}">` :
				`<i class='icon-no-feed material-icons'>rss_feed</i>`;
	}
};
/* global define, dijit */

define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) {

	return declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
		getItemsInCategory: function (id) {
			if (!this.store._itemsByIdentity) return undefined;

			const cat = this.store._itemsByIdentity['CAT:' + id];

			if (cat && cat.items)
				return cat.items;
			else
				return undefined;

		},
		getItemById: function (id) {
			return this.store._itemsByIdentity[id];
		},
		getFeedValue: function (feed, is_cat, key) {
			if (!this.store._itemsByIdentity) return undefined;

			let treeItem;

			if (is_cat)
				treeItem = this.store._itemsByIdentity['CAT:' + feed];
			else
				treeItem = this.store._itemsByIdentity['FEED:' + feed];

			if (treeItem)
				return this.store.getValue(treeItem, key);
		},
		getFeedName: function (feed, is_cat) {
			return this.getFeedValue(feed, is_cat, 'name');
		},
		getFeedUnread: function (feed, is_cat) {
			const unread = parseInt(this.getFeedValue(feed, is_cat, 'unread'));
			return (isNaN(unread)) ? -1 : unread;
		},
		setFeedUnread: function (feed, is_cat, unread) {
			return this.setFeedValue(feed, is_cat, 'unread', parseInt(unread));
		},
		setFeedValue: function (feed, is_cat, key, value) {
			if (!value) value = '';
			if (!this.store._itemsByIdentity) return undefined;

			let treeItem;

			if (is_cat)
				treeItem = this.store._itemsByIdentity['CAT:' + feed];
			else
				treeItem = this.store._itemsByIdentity['FEED:' + feed];

			if (treeItem)
				return this.store.setValue(treeItem, key, value);
		},
		hasCats: function () {
			if (this.store && this.store._itemsByIdentity)
				return this.store._itemsByIdentity['CAT:-1'] != undefined;
			else
				return false;
		},

	});
});


/* eslint-disable prefer-rest-params */
/* global __, dojo, dijit, define, App, Feeds, CommonDialogs */

define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/cookie", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct, array, cookie) {

	return declare("fox.FeedTree", dijit.Tree, {
		// save state in localStorage instead of cookies
		// reference: https://stackoverflow.com/a/27968996
		_saveExpandedNodes: function(){
			if (this.persist && this.cookieName){
				const ary = [];
				for (const id in this._openedNodes){
					ary.push(id);
				}
				// Was:
				// cookie(this.cookieName, ary.join(","), {expires: 365});
				localStorage.setItem(this.cookieName, ary.join(","));
			}
		},
		_initState: function(){
			// summary:
			//    Load in which nodes should be opened automatically
			this._openedNodes = {};
			if (this.persist && this.cookieName){
				// Was:
				// var oreo = cookie(this.cookieName);
				let oreo = localStorage.getItem(this.cookieName);
				// migrate old data if nothing in localStorage
				if (oreo == null || oreo === '') {
					oreo = cookie(this.cookieName);
					cookie(this.cookieName, null, { expires: -1 });
				}
				if (oreo){
					array.forEach(oreo.split(','), function(item){
						this._openedNodes[item] = true;
					}, this);
				}
			}
		},
		_onContainerKeydown: function(/* Event */ /* e */) {
			return; // Stop dijit.Tree from interpreting keystrokes
		},
		_onContainerKeypress: function(/* Event */ /* e */) {
			return; // Stop dijit.Tree from interpreting keystrokes
		},
		_createTreeNode: function(args) {
			const tnode = new dijit._TreeNode(args);

			const iconName = args.item.icon ? String(args.item.icon[0]) : null;
			let iconNode;

			if (iconName) {
				if (iconName.indexOf("/") == -1) {
					iconNode = dojo.create("i", { className: "material-icons icon icon-" + iconName, innerHTML: iconName });
				} else {
					iconNode = dojo.create('img', { className: 'icon' });
					if (args.item.icon && args.item.icon[0]) {
						iconNode.src = args.item.icon[0];
					} else {
						iconNode.src = 'images/blank_icon.gif';
					}
				}
			}

			if (iconNode)
				domConstruct.place(iconNode, tnode.iconNode, 'only');

			const id = args.item.id[0];
			const bare_id = parseInt(id.substr(id.indexOf(':')+1));

			if (bare_id < App.LABEL_BASE_INDEX) {
				const label = dojo.create('i', { className: "material-icons icon icon-label", innerHTML: "label" });

				//const fg_color = args.item.fg_color[0];
				const bg_color = args.item.bg_color[0];

				label.setStyle({
					color: bg_color,
					});

				domConstruct.place(label, tnode.iconNode, 'only');
			}

			if (id.match("FEED:")) {
				tnode.rowNode.setAttribute('data-feed-id', bare_id);
				tnode.rowNode.setAttribute('data-is-cat', "false");

				const menu = new dijit.Menu();
				menu.row_id = bare_id;

				menu.addChild(new dijit.MenuItem({
					label: __("Mark as read"),
					onClick: function() {
						Feeds.catchupFeed(this.getParent().row_id);
					}}));

				if (bare_id > 0) {
					menu.addChild(new dijit.MenuItem({
						label: __("Edit feed"),
						onClick: function() {
							CommonDialogs.editFeed(this.getParent().row_id, false);
						}}));

					menu.addChild(new dijit.MenuItem({
						label: __("Open site"),
						onClick: function() {
							App.postOpenWindow("backend.php", {op: "Feeds", method: "opensite",
								feed_id: this.getParent().row_id, csrf_token: __csrf_token});
						}}));

					menu.addChild(new dijit.MenuSeparator());

					menu.addChild(new dijit.MenuItem({
						label: __("Debug feed"),
						onClick: function() {
							/* global __csrf_token */
							App.postOpenWindow("backend.php", {op: "Feeds", method: "updatedebugger",
								feed_id: this.getParent().row_id, csrf_token: __csrf_token});
						}}));
				}

				menu.bindDomNode(tnode.domNode);
				tnode._menu = menu;
			}

			if (id.match("CAT:") && bare_id >= 0) {
				const menu = new dijit.Menu();
				menu.row_id = bare_id;

				menu.addChild(new dijit.MenuItem({
					label: __("Mark as read"),
					onClick: function() {
						Feeds.catchupFeed(this.getParent().row_id, true);
					}}));

				menu.addChild(new dijit.MenuItem({
					label: __("(Un)collapse"),
					onClick: function() {
						dijit.byId("feedTree").collapseCat(this.getParent().row_id);
					}}));

				menu.bindDomNode(tnode.domNode);
				tnode._menu = menu;
			}

			if (id.match("CAT:")) {
				tnode.rowNode.setAttribute('data-feed-id', bare_id);
				tnode.rowNode.setAttribute('data-is-cat', "true");

				tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: App.getInitParam('icon_blank')});
				domConstruct.place(tnode.loadingNode, tnode.labelNode, 'after');
			}

			if (id.match("FEED:")) {
				tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: App.getInitParam('icon_blank')});
				domConstruct.place(tnode.loadingNode, tnode.expandoNode, 'only');
			}

			if (id.match("CAT:") && bare_id == -1) {
				const menu = new dijit.Menu();
				menu.row_id = bare_id;

				menu.addChild(new dijit.MenuItem({
					label: __("Mark all feeds as read"),
					onClick: function() {
						Feeds.catchupAll();
					}}));

				menu.bindDomNode(tnode.domNode);
				tnode._menu = menu;
			}

			tnode.markedCounterNode = dojo.create('span', { className: 'counterNode marked', innerHTML: args.item.markedcounter });
			domConstruct.place(tnode.markedCounterNode, tnode.rowNode, 'first');

			tnode.auxCounterNode = dojo.create('span', { className: 'counterNode aux', innerHTML: args.item.auxcounter });
			domConstruct.place(tnode.auxCounterNode, tnode.rowNode, 'first');

			tnode.unreadCounterNode = dojo.create('span', { className: 'counterNode unread', innerHTML: args.item.unread });
			domConstruct.place(tnode.unreadCounterNode, tnode.rowNode, 'first');
         
			return tnode;
		},
		postCreate: function() {
			this.connect(this.model, "onChange", "updateCounter");
			this.inherited(arguments);
		},
		updateCounter: function (item) {
			const tree = this;
        
            //i sdelal , collapse label_special
            const label_special = this._itemNodesMap['CAT:-1'] && this._itemNodesMap['CAT:-1'][0];
             if (label_special && label_special.isExpanded) {
                 console.log("vvvvv____special: ", label_special); 
                this._collapseNode(label_special);
             }
             //

			//console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree);

			let treeNode = tree._itemNodesMap[item.id];

			if (treeNode) {
				treeNode = treeNode[0];

				treeNode.unreadCounterNode.innerHTML = item.unread;
				treeNode.auxCounterNode.innerHTML = item.auxcounter;
				treeNode.markedCounterNode.innerHTML = item.markedcounter;
			}
		},
		getTooltip: function (item) {
			return [item.updated, item.error].filter((x) => x && x != "").join(" - ");
		},
		getIconClass: function (item, opened) {
			// eslint-disable-next-line no-nested-ternary
			return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon";
		},
		getLabelClass: function (item/* , opened */) {
			return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
		},
		getRowClass: function (item/*, opened */) {
			let rc = "dijitTreeRow dijitTreeRowFlex";

			const is_cat = String(item.id).indexOf('CAT:') != -1;

			if (is_cat)
				rc += " Is_Cat";
			else
				rc += " Is_Feed";

			if (!is_cat && item.error != '') rc += " Error";
			if (item.unread > 0) rc += " Unread";
			if (item.auxcounter > 0) rc += " Has_Aux";
			if (item.markedcounter > 0) rc += " Has_Marked";
			if (item.updates_disabled > 0) rc += " UpdatesDisabled";
			if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == Feeds.FEED_ARCHIVED && !is_cat) rc += " Special";
			if (item.bare_id == Feeds.CATEGORY_SPECIAL && is_cat) rc += " AlwaysVisible";
			if (item.bare_id < App.LABEL_BASE_INDEX) rc += " Label";

			return rc;
		},
		getLabel: function(item) {
			let name = String(item.name);

			/* Horrible */
			name = name.replace(/&quot;/g, "\"");
			name = name.replace(/&amp;/g, "&");
			name = name.replace(/&mdash;/g, "-");
			name = name.replace(/&lt;/g, "<");
			name = name.replace(/&gt;/g, ">");

			return name;
		},
		expandParentNodes: function(feed, is_cat, list) {
			try {
				for (let i = 0; i < list.length; i++) {
					const id = String(list[i].id);
					let item = this._itemNodesMap[id];

					if (item) {
						item = item[0];
						this._expandNode(item);
					}
				}
			} catch (e) {
				App.Error.report(e);
			}
		},
		findNodeParentsAndExpandThem: function(feed, is_cat, root, parents) {
			// expands all parents of specified feed to properly mark it as active
			// my fav thing about frameworks is doing everything myself
			try {
				const test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed;

				if (!root) {
					if (!this.model || !this.model.store) return false;

					const items = this.model.store._arrayOfTopLevelItems;

					for (let i = 0; i < items.length; i++) {
						if (String(items[i].id) == test_id) {
							this.expandParentNodes(feed, is_cat, parents);
						} else {
							this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []);
						}
					}
				} else if (root.items) {
						parents.push(root);

						for (let i = 0; i < root.items.length; i++) {
							if (String(root.items[i].id) == test_id) {
								this.expandParentNodes(feed, is_cat, parents);
							} else {
								this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0));
							}
						}
					} else if (String(root.id) == test_id) {
							this.expandParentNodes(feed, is_cat, parents.slice(0));
						}
			} catch (e) {
				App.Error.report(e);
			}
		},
		selectFeed: function(feed, is_cat) {
			this.findNodeParentsAndExpandThem(feed, is_cat, false, false);

			let treeNode;

			if (is_cat)
				treeNode = this._itemNodesMap['CAT:' + feed];
			else
				treeNode = this._itemNodesMap['FEED:' + feed];

			if (treeNode) {
				treeNode = treeNode[0];
				if (!is_cat) this._expandNode(treeNode);
				this.set("selectedNodes", [treeNode]);
				this.focusNode(treeNode);

				// focus headlines to route key events there
				setTimeout(() => {
					App.byId("headlines-frame").focus();

					if (treeNode) {
						const node = treeNode.rowNode;
						const tree = this.domNode;

						if (node && tree) {
							// scroll tree to selection if needed
							if (node.offsetTop < tree.scrollTop || node.offsetTop > tree.scrollTop + tree.clientHeight) {
								App.byId("feedTree").scrollTop = node.offsetTop;
							}
						}
					}

				}, 0);
			}
		},
		setIcon: function(feed, is_cat, src) {
			let treeNode;

			if (is_cat)
				treeNode = this._itemNodesMap['CAT:' + feed];
			else
				treeNode = this._itemNodesMap['FEED:' + feed];

			if (treeNode) {
				treeNode = treeNode[0];

				// could be <i material>
				const icon = treeNode.iconNode.querySelector('img.icon');

				if (icon) {
					icon.src = src;

					return true;
				}
			}
			return false;
		},
		showLoading: function(feed, is_cat, show) {
			let treeNode;

			if (is_cat)
				treeNode = this._itemNodesMap['CAT:' + feed];
			else
				treeNode = this._itemNodesMap['FEED:' + feed];

			if (treeNode) {
				treeNode = treeNode[0];

				if (show) {
					treeNode.loadingNode.addClassName("visible");
					treeNode.loadingNode.setAttribute("src",
						is_cat ? App.getInitParam("icon_three_dots") : App.getInitParam("icon_oval"));
				} else {
					treeNode.loadingNode.removeClassName("visible");
					treeNode.loadingNode.setAttribute("src", App.getInitParam("icon_blank"))
				}

				return true
			}

			return false;
		},
		hasCats: function() {
			return this.model.hasCats();
		},
		collapseCat: function(id) {
			if (!this.model.hasCats()) return;

			const tree = this;

			const node = tree._itemNodesMap['CAT:' + id][0];
			const item = tree.model.store._itemsByIdentity['CAT:' + id];

			if (node && item) {
				if (!node.isExpanded)
					tree._expandNode(node);
				else
					tree._collapseNode(node);

			}
		},
		getNextUnread: function(feed, is_cat) {
			return this.getNextFeed(feed, is_cat, true);
		},
		_nextTreeItemFromIndex: function (start, unread_only) {
			const items = this.model.store._arrayOfAllItems;

			for (let i = start+1; i < items.length; i++) {
				const id = String(items[i].id);
				const box = this._itemNodesMap[id];
				const unread = parseInt(items[i].unread);

				if (box && (!unread_only || unread > 0)) {
					const row = box[0].rowNode;
					const cat = box[0].rowNode.parentNode.parentNode;

					if (Element.visible(cat) && Element.visible(row)) {
						return items[i];
					}
				}
			}
		},
		getNextFeed: function (feed, is_cat, unread_only = false) {
			let treeItem;

			if (is_cat) {
				treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
			} else {
				treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
			}

			const items = this.model.store._arrayOfAllItems;
			const start = items.indexOf(treeItem);

			if (start != -1) {
				let item = this._nextTreeItemFromIndex(start, unread_only);

				// let's try again from the top
				// 0 (instead of -1) to skip Special category
				if (!item) {
					item = this._nextTreeItemFromIndex(0, unread_only);
				}

				if (item)
					return [this.model.store.getValue(item, 'bare_id'),
						!this.model.store.getValue(item, 'id').match('FEED:')];
			}

			return [false, false];
		},
		_prevTreeItemFromIndex: function (start, unread_only) {
			const items = this.model.store._arrayOfAllItems;

			for (let i = start-1; i > 0; i--) {
				const id = String(items[i].id);
				const box = this._itemNodesMap[id];
				const unread = parseInt(items[i].unread);

				if (box && (!unread_only || unread > 0)) {
					const row = box[0].rowNode;
					const cat = box[0].rowNode.parentNode.parentNode;

					if (Element.visible(cat) && Element.visible(row)) {
						return items[i];
					}
				}
			}
		},
		getPreviousFeed: function (feed, is_cat, unread_only = false) {
			let treeItem;

			if (is_cat) {
				treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
			} else {
				treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
			}

			const items = this.model.store._arrayOfAllItems;
			const start = items.indexOf(treeItem);

			if (start != -1) {
				let item = this._prevTreeItemFromIndex(start, unread_only);

				// wrap from the bottom
				if (!item) {
					item = this._prevTreeItemFromIndex(items.length, unread_only);
				}

				if (item)
					return [this.model.store.getValue(item, 'bare_id'),
						!this.model.store.getValue(item, 'id').match('FEED:')];
			}

			return [false, false];
		},
		getFeedCategory: function(feed) {
			try {
				return this.getNodesByItem(this.model.store.
					_itemsByIdentity["FEED:" + feed])[0].
				getParent().item.bare_id[0];

			} catch (e) {
				return false;
			}
		},
	});
});

'use strict';

/* global __, ngettext, Article, App */
/* global dojo, dijit, PluginHost, Notify, xhr, Feeds */
/* global CommonDialogs */

const Headlines = {
	vgroup_last_feed: undefined,
	_headlines_scroll_timeout: 0,
	//_observer_counters_timeout: 0,
	headlines: [],
	current_first_id: 0,
	_scroll_reset_timeout: false,
	default_force_previous: false,
	default_force_to_top: false,
	default_move_on_expand: true,
	line_scroll_offset: 120, /* px */
	sticky_header_observer: new IntersectionObserver(
		(entries, observer) => {
			entries.forEach((entry) => {
				const header = entry.target.closest('.cdm').querySelector(".header");

				if (entry.isIntersecting) {
					header.removeAttribute("data-is-stuck");
				} else {
					header.setAttribute("data-is-stuck", "true");
				}

				//console.log(entry.target, entry.intersectionRatio, entry.isIntersecting, entry.boundingClientRect.top);
			});
		},
		{threshold: [0, 1], root: document.querySelector("#headlines-frame")}
	),
	sticky_content_observer: new IntersectionObserver(
		(entries, observer) => {
			entries.forEach((entry) => {
				const header = entry.target.closest('.cdm').querySelector(".header");

				header.style.position = entry.isIntersecting ? "sticky" : "unset";

				//console.log(entry.target, entry.intersectionRatio, entry.isIntersecting, entry.boundingClientRect.top);
			});
		},
		{threshold: [0, 1], root: document.querySelector("#headlines-frame")}
	),
	unpack_observer: new IntersectionObserver(
		(entries, observer) => {
			entries.forEach((entry) => {
				if (entry.intersectionRatio > 0)
					Article.unpack(entry.target);
			});
		},
		{threshold: [0], root: document.querySelector("#headlines-frame")}
	),
	row_observer: new MutationObserver((mutations) => {
		const modified = [];

		mutations.forEach((m) => {
			if (m.type == 'attributes' && ['class', 'data-score'].indexOf(m.attributeName) != -1) {

				const row = m.target;
				const id = row.getAttribute("data-article-id");

				if (Headlines.headlines[id]) {
					const hl = Headlines.headlines[id];

					if (hl) {
						const hl_old = {...{}, ...hl};

						hl.unread = row.hasClassName("Unread");
						hl.marked = row.hasClassName("marked");
						hl.published = row.hasClassName("published");

						// not sent by backend
						hl.selected = row.hasClassName("Selected");
						hl.active = row.hasClassName("active");

						hl.score = row.getAttribute("data-score");

						modified.push({id: hl.id, new: hl, old: hl_old, row: row});
					}
				}
			}
		});

		PluginHost.run(PluginHost.HOOK_HEADLINE_MUTATIONS, mutations);

		Headlines.updateSelectedPrompt();

		window.requestIdleCallback(() => {
			Headlines.syncModified(modified);
		});
	}),
	syncModified: function (modified) {
		const ops = {
			tmark: [],
			tpub: [],
			read: [],
			unread: [],
			select: [],
			deselect: [],
			activate: [],
			deactivate: [],
			rescore: {},
		};

		modified.forEach(function (m) {
			if (m.old.marked != m.new.marked)
				ops.tmark.push(m.id);

			if (m.old.published != m.new.published)
				ops.tpub.push(m.id);

			if (m.old.unread != m.new.unread)
				m.new.unread ? ops.unread.push(m.id) : ops.read.push(m.id);

			if (m.old.selected != m.new.selected)
				m.new.selected ? ops.select.push(m.row) : ops.deselect.push(m.row);

			if (m.old.active != m.new.active)
				m.new.active ? ops.activate.push(m.row) : ops.deactivate.push(m.row);

			if (m.old.score != m.new.score) {
				const score = m.new.score;

				ops.rescore[score] = ops.rescore[score] || [];
				ops.rescore[score].push(m.id);
			}
		});

		ops.select.forEach((row) => {
			const cb = dijit.getEnclosingWidget(row.querySelector(".rchk"));

			if (cb)
				cb.attr('checked', true);
		});

		ops.deselect.forEach((row) => {
			const cb = dijit.getEnclosingWidget(row.querySelector(".rchk"));

			if (cb && !row.hasClassName("active"))
				cb.attr('checked', false);
		});

		ops.activate.forEach((row) => {
			const cb = dijit.getEnclosingWidget(row.querySelector(".rchk"));

			if (cb)
				cb.attr('checked', true);
		});

		ops.deactivate.forEach((row) => {
			const cb = dijit.getEnclosingWidget(row.querySelector(".rchk"));

			if (cb && !row.hasClassName("Selected"))
				cb.attr('checked', false);
		});

		const promises = [];

		if (ops.tmark.length != 0)
			promises.push(xhr.post("backend.php",
				{op: "RPC", method: "markSelected", "ids[]": ops.tmark, cmode: 2}));

		if (ops.tpub.length != 0)
			promises.push(xhr.post("backend.php",
				{op: "RPC", method: "publishSelected", "ids[]": ops.tpub, cmode: 2}));

		if (ops.read.length != 0)
			promises.push(xhr.post("backend.php",
				{op: "RPC", method: "catchupSelected", "ids[]": ops.read, cmode: 0}));

		if (ops.unread.length != 0)
			promises.push(xhr.post("backend.php",
				{op: "RPC", method: "catchupSelected", "ids[]": ops.unread, cmode: 1}));

		const scores = Object.keys(ops.rescore);

		if (scores.length != 0) {
			scores.forEach((score) => {
				promises.push(xhr.post("backend.php",
					{op: "Article", method: "setScore", "ids[]": ops.rescore[score], score: score}));
			});
		}

		Promise.allSettled(promises).then((results) => {
			let feeds = [];
			let labels = [];

			results.forEach((res) => {
				console.log('requesting counters for: res: ', res);
				if (res) {
					try {
						const obj = JSON.parse(res.value);

						if (obj.feeds)
							feeds = feeds.concat(obj.feeds);

						if (obj.labels)
							labels = labels.concat(obj.labels);

					} catch (e) {
						console.warn(e, res);
					}
				}
			});

			if (feeds.length > 0) {
				console.log('requesting counters for', feeds, labels);
				Feeds.requestCounters(feeds, labels);
			}

			PluginHost.run(PluginHost.HOOK_HEADLINE_MUTATIONS_SYNCED, results);
		});
	},
	click: function (event, id, in_body) {
		in_body = in_body || false;

		if (event.shiftKey && Article.getActive()) {
			Headlines.select('none');

			const ids = Headlines.getRange(Article.getActive(), id);

			console.log(Article.getActive(), id, ids);

			for (let i = 0; i < ids.length; i++)
				Headlines.select('all', ids[i]);

		} else if (event.ctrlKey) {
			Headlines.select('invert', id);
		} else {
			// eslint-disable-next-line no-lonely-if
			if (App.isCombinedMode()) {

				if (event.altKey && !in_body) {

					Article.openInNewWindow(id);
					Headlines.toggleUnread(id, 0);

				} else if (Article.getActive() != id) {

					Headlines.select('none');

					const scroll_position_A = App.byId(`RROW-${id}`).offsetTop - App.byId("headlines-frame").scrollTop;

					Article.setActive(id);

					if (App.getInitParam("cdm_expanded")) {

						if (!in_body)
							Article.openInNewWindow(id);

						Headlines.toggleUnread(id, 0);
					} else {
						const scroll_position_B = App.byId(`RROW-${id}`).offsetTop - App.byId("headlines-frame").scrollTop;

						// this would only work if there's enough space
						App.byId("headlines-frame").scrollTop -= scroll_position_A-scroll_position_B;

						if (this.default_move_on_expand)
							Article.cdmMoveToId(id);
					}

				} else if (in_body) {
					Headlines.toggleUnread(id, 0);
				} else { /* !in body */
					Article.openInNewWindow(id);
				}

				return in_body;
			} else {
				// eslint-disable-next-line no-lonely-if
				if (event.altKey) {
					Article.openInNewWindow(id);
					Headlines.toggleUnread(id, 0);
				} else {
					Headlines.select('none');
					Article.view(id);
				}
			}
		}

		return false;
	},
	initScrollHandler: function () {
		App.byId("headlines-frame").onscroll = (event) => {
			clearTimeout(this._headlines_scroll_timeout);
			this._headlines_scroll_timeout = window.setTimeout(function () {
				//console.log('done scrolling', event);
				Headlines.scrollHandler(event);
			}, 50);
		}
	},
	loadMore: function () {
		const view_mode = dijit.byId("toolbar-main").getValues().view_mode;
		const unread_in_buffer = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread]").length;
		const num_all = App.findAll("#headlines-frame > div[id*=RROW]").length;
		const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat());

		// TODO implement marked & published

		let offset = num_all;

		switch (view_mode) {
			case "marked":
			case "published":
				console.warn("loadMore: ", view_mode, "not implemented");
				break;
			case "unread":
				offset = unread_in_buffer;
				break;
			case "adaptive":
				if (!(Feeds.getActive() == Feeds.FEED_STARRED && !Feeds.activeIsCat()))
					offset = num_unread > 0 ? unread_in_buffer : num_all;
				break;
		}

		console.log("loadMore, offset=", offset);

		Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), offset: offset, append: true});
	},
	isChildVisible: function (elem) {
		return App.Scrollable.isChildVisible(elem, App.byId("headlines-frame"));
	},
	firstVisible: function () {
		const rows = App.findAll("#headlines-frame > div[id*=RROW]");

		for (let i = 0; i < rows.length; i++) {
			const row = rows[i];

			if (this.isChildVisible(row)) {
				return row.getAttribute("data-article-id");
			}
		}
	},
	unpackVisible: function(container) {
		const rows = App.findAll("#headlines-frame > div[id*=RROW][data-content].cdm");

		for (let i = 0; i < rows.length; i++) {
			if (App.Scrollable.isChildVisible(rows[i], container)) {
				console.log('force unpacking:', rows[i].getAttribute('id'));
				Article.unpack(rows[i]);
			}
		}
	},
	scrollHandler: function (/*event*/) {
		try {
			if (!Feeds.infscroll_disabled && !Feeds.infscroll_in_progress) {
				const hsp = App.byId("headlines-spacer");
				const container = App.byId("headlines-frame");

				if (hsp && hsp.previousSibling) {
					const last_row = hsp.previousSibling;

					// invoke lazy load if last article in buffer is nearly visible OR is active
					if (Article.getActive() == last_row.getAttribute("data-article-id") || last_row.offsetTop - 250 <= container.scrollTop + container.offsetHeight) {
						hsp.innerHTML = `<span class='text-muted text-small text-center'><img class="icon-three-dots" src="${App.getInitParam('icon_three_dots')}"> ${__("Loading, please wait...")}</span>`;

						Headlines.loadMore();
						return;
					}
				}
			}

			if (App.isCombinedMode() && App.getInitParam("cdm_expanded")) {
				const container = App.byId("headlines-frame")

				/* don't do anything until there was some scrolling */
				if (container.scrollTop > 0)
					Headlines.unpackVisible(container);
			}

			if (App.getInitParam("cdm_auto_catchup")) {

				const rows = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread]");

				for (let i = 0; i < rows.length; i++) {
					const row = rows[i];

					if (App.byId("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight / 2)) {
						row.removeClassName("Unread");
					} else {
						break;
					}
				}
			}

			PluginHost.run(PluginHost.HOOK_HEADLINES_SCROLL_HANDLER);

		} catch (e) {
			console.warn("scrollHandler", e);
		}
	},
	objectById: function (id) {
		return this.headlines[id];
	},
	setCommonClasses: function (headlines_count) {
		const container = App.byId("headlines-frame");

		container.removeClassName("cdm");
		container.removeClassName("normal");

		container.addClassName(App.isCombinedMode() ? "cdm" : "normal");
		container.setAttribute("data-enable-grid", App.getInitParam("cdm_enable_grid") ? "true" : "false");
		container.setAttribute("data-headlines-count", parseInt(headlines_count));
		container.setAttribute("data-is-cdm", App.isCombinedMode() ? "true" : "false");
		container.setAttribute("data-is-cdm-expanded", App.getInitParam("cdm_expanded"));

		// for floating title because it's placed outside of headlines-frame
		App.byId("main").removeClassName("expandable");
		App.byId("main").removeClassName("expanded");

		if (App.isCombinedMode())
			App.byId("main").addClassName(App.getInitParam("cdm_expanded") ? "expanded" : "expandable");
	},
	renderAgain: function () {
		// TODO: wrap headline elements into a knockoutjs model to prevent all this stuff
		Headlines.setCommonClasses(this.headlines.filter((h) => h.id).length);

		App.findAll("#headlines-frame > div[id*=RROW]").forEach((row) => {
			const id = row.getAttribute("data-article-id");
			const hl = this.headlines[id];

			if (hl) {
				const new_row = this.render({}, hl);

				row.parentNode.replaceChild(new_row, row);

				if (hl.active) {
					new_row.addClassName("active");
					Article.unpack(new_row);

					if (App.isCombinedMode())
						Article.cdmMoveToId(id, {noscroll: true});
					else
						Article.view(id);
				}

				if (hl.selected) this.select("all", id);
			}
		});

		App.findAll(".cdm .header-sticky-guard").forEach((e) => {
			this.sticky_header_observer.observe(e)
		});

		App.findAll(".cdm .content").forEach((e) => {
			this.sticky_content_observer.observe(e)
		});

		if (App.getInitParam("cdm_expanded"))
			App.findAll("#headlines-frame > div[id*=RROW].cdm").forEach((e) => {
				this.unpack_observer.observe(e)
			});

		dijit.byId('main').resize();

		PluginHost.run(PluginHost.HOOK_HEADLINES_RENDERED);
	},
	render: function (headlines, hl) {
		let row = null;

		let row_class = "";

		if (hl.marked) row_class += " marked";
		if (hl.published) row_class += " published";
		if (hl.unread) row_class += " Unread";
		if (headlines.vfeed_group_enabled) row_class += " vgrlf";

		if (headlines.vfeed_group_enabled && hl.feed_title && this.vgroup_last_feed != hl.feed_id) {
			const vgrhdr = `<div data-feed-id='${hl.feed_id}' class='feed-title'>
									<div class="pull-right icon-feed" title="${App.escapeHtml(hl.feed_title)}"
										onclick="Feeds.open({feed:${hl.feed_id}})">${Feeds.renderIcon(hl.feed_id, hl.has_icon)}</div>
									<a class="title" title="${__('Open site')}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.site_url)}">${hl.feed_title}</a>
									<a class="catchup" title="${__('mark feed as read')}" onclick="Feeds.catchupFeedInGroup(${hl.feed_id})" href="#">
										<i class="icon-done material-icons">done_all</i>
									</a>
								</div>`

			const tmp = document.createElement("div");
			tmp.innerHTML = vgrhdr;

			App.byId("headlines-frame").appendChild(tmp.firstChild);

			this.vgroup_last_feed = hl.feed_id;
		}

		if (App.isCombinedMode()) {
			row_class += App.getInitParam("cdm_expanded") ? " expanded" : " expandable";

			const comments = Article.formatComments(hl);

			row = `<div class="cdm ${row_class} ${Article.getScoreClass(hl.score)}"
						id="RROW-${hl.id}"
						data-article-id="${hl.id}"
						data-orig-feed-id="${hl.feed_id}"
						data-orig-feed-title="${App.escapeHtml(hl.feed_title)}"
						data-is-packed="1"
						data-content="${App.escapeHtml(hl.content)}"
						data-rendered-enclosures="${App.escapeHtml(Article.renderEnclosures(hl.enclosures))}"
						data-score="${hl.score}"
						data-article-title="${App.escapeHtml(hl.title)}"
						onmouseover="Article.mouseIn(${hl.id})"
						onmouseout="Article.mouseOut(${hl.id})">
						<div class="header-sticky-guard"></div>
						<div class="header">
							<div class="left">
								<input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'>
								<i class="marked-pic marked-${hl.id} material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i>
								<i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i>
							</div>

							<span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach">
								${App.getInitParam("debug_headline_ids") ? `<span class="text-muted small">A: ${hl.id} F: ${hl.feed_id}</span>` : ""}
								<a class="title" title="${App.escapeHtml(hl.title)}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.link)}">
									${hl.title}</a>
								<span class="author">${hl.author}</span>
								${Article.renderLabels(hl.id, hl.labels)}
								${hl.cdm_excerpt ? hl.cdm_excerpt : ""}
							</span>

							<a class="feed vfeedMenuAttach" style="background-color: ${hl.feed_bg_color}" data-feed-id="${hl.feed_id}"
								title="${__('Open site')}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.site_url)}">${hl.feed_title}</a>

							<span class="updated" title="${hl.imported}">${hl.updated}</span>

							<div class="right">
								<i class="material-icons icon-grid-span" title="${__("Span all columns")}" onclick="Article.cdmToggleGridSpan(${hl.id})">fullscreen</i>
								<i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i>

								<span class="icon-feed" title="${App.escapeHtml(hl.feed_title)}" onclick="Feeds.open({feed:${hl.feed_id}})">
									${Feeds.renderIcon(hl.feed_id, hl.has_icon)}
								</span>
							</div>

						</div>

						<div class="content" onclick="return Headlines.click(event, ${hl.id}, true);">
							${Article.renderNote(hl.id, hl.note)}
							<div class="content-inner" lang="${hl.lang ? hl.lang : 'en'}">
								<div class="text-center text-muted">
									${__("Loading, please wait...")}
								</div>
							</div>

							<!-- intermediate: unstyled, kept for compatibility -->
							<div class="intermediate"></div>

							<div class="footer" onclick="event.stopPropagation()">

								<div class="left">
									${hl.buttons_left}
									<i class="material-icons">label_outline</i>
									${Article.renderTags(hl.id, hl.tags)}
									<a title="${__("Edit tags for this article")}" href="#"
										onclick="Article.editTags(${hl.id})">(+)</a>
									${comments}
								</div>

								<div class="right">
									${hl.buttons}
								</div>
							</div>
						</div>
					</div>`;


		} else {
			row = `<div class="hl ${row_class} ${Article.getScoreClass(hl.score)}"
				id="RROW-${hl.id}"
				data-orig-feed-id="${hl.feed_id}"
				data-orig-feed-title="${App.escapeHtml(hl.feed_title)}"
				data-article-id="${hl.id}"
				data-score="${hl.score}"
				data-article-title="${App.escapeHtml(hl.title)}"
				onmouseover="Article.mouseIn(${hl.id})"
				onmouseout="Article.mouseOut(${hl.id})">
			<div class="left">
				<input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'>
					<i class="marked-pic marked-${hl.id} material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i>
					<i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i>
			</div>
			<div onclick="return Headlines.click(event, ${hl.id})" class="title">
				${App.getInitParam("debug_headline_ids") ? `<span class="text-muted small">A: ${hl.id} F: ${hl.feed_id}</span>` : ""}
				<span data-article-id="${hl.id}" class="hl-content hlMenuAttach">
					<a class="title" href="${App.escapeHtml(hl.link)}">${hl.title} <span class="preview">${hl.content_preview}</span></a>
					<span class="author">${hl.author}</span>
					${Article.renderLabels(hl.id, hl.labels)}
				</span>
			</div>
			<span class="feed vfeedMenuAttach" data-feed-id="${hl.feed_id}">
				<a title="${__('Open site')}" style="background : ${hl.feed_bg_color}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.site_url)}">${hl.feed_title}</a>
			</span>
			<div title="${hl.imported}">
				<span class="updated">${hl.updated}</span>
			</div>
			<div class="right">
				<i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i>
				<span onclick="Feeds.open({feed:${hl.feed_id}})" class="icon-feed" title="${App.escapeHtml(hl.feed_title)}">${Feeds.renderIcon(hl.feed_id, hl.has_icon)}</span>
			</div>
			</div>
		`;
		}

		const tmp = document.createElement("div");
		tmp.innerHTML = row;
		dojo.parser.parse(tmp);

		this.row_observer.observe(tmp.firstChild, {attributes: true});

		PluginHost.run(PluginHost.HOOK_HEADLINE_RENDERED, tmp.firstChild);

		return tmp.firstChild;
	},
	updateCurrentUnread: function () {
		if (App.byId("feed_current_unread")) {
			const feed_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat());

			if (feed_unread > 0 && !Element.visible("feeds-holder")) {
				App.byId("feed_current_unread").innerText = feed_unread;
				Element.show("feed_current_unread");
			} else {
				Element.hide("feed_current_unread");
			}
		}
	},
	renderToolbar: function(headlines) {

		const tb = headlines['toolbar'];
		const search_query = Feeds._search_query ? Feeds._search_query.query : "";
		const target = dijit.byId('toolbar-headlines');

		// TODO: is this needed? destroyDescendants() below might take care of it (?)
		if (this._headlinesSelectClickHandle)
			dojo.disconnect(this._headlinesSelectClickHandle);

		target.destroyDescendants();

		if (tb && typeof tb == 'object') {
			target.attr('innerHTML',
			`
				<span class='left'>
					<a href="#" title="${__("Show as feed")}"
						onclick='CommonDialogs.generatedFeed("${headlines.id}", ${headlines.is_cat}, "${App.escapeHtml(search_query)}")'>
						<i class='icon-syndicate material-icons'>rss_feed</i>
					</a>
					${tb.site_url ?
						`<a class="feed_title" target="_blank" href="${App.escapeHtml(tb.site_url)}" title="${tb.last_updated}">${tb.title}</a>` :
							`${search_query ? `<a href="#" onclick="Feeds.search(); return false" class="feed_title" title="${App.escapeHtml(search_query)}">${tb.title}</a>
							<span class="cancel_search">(<a href="#" onclick="Feeds.cancelSearch(); return false">${__("Cancel search")}</a>)</span>` :
								`<span class="feed_title">${tb.title}</span>`}`}
					${tb.error ? `<i title="${App.escapeHtml(tb.error)}" class='material-icons icon-error'>error</i>` : ''}
					<span id='feed_current_unread' style='display: none'></span>
				</span>
				<span class='right'>
					<span id='selected_prompt'></span>

					<select class='select-articles-dropdown'
						id='headlines-select-articles-dropdown'
						data-prevent-value-change="true"
						data-dropdown-skip-first="true"
						dojoType="fox.form.Select"
						title="${__('Show articles')}">
						<option value='' selected="selected">${__("Select...")}</option>
						<option value='headlines_select_all'>${__('All')}</option>
						<option value='headlines_select_unread'>${__('Unread')}</option>
						<option value='headlines_select_invert'>${__('Invert')}</option>
						<option value='headlines_select_none'>${__('None')}</option>
						<option></option>
						<option value='headlines_selectionToggleUnread'>${__('Toggle unread')}</option>
						<option value='headlines_selectionToggleMarked'>${__('Toggle starred')}</option>
						<option value='headlines_selectionTogglePublished'>${__('Toggle published')}</option>
						<option></option>
						<option value='headlines_catchupSelection'>${__('Mark as read')}</option>
						<option value='article_selectionSetScore'>${__('Set score')}</option>
						${tb.plugin_menu_items != '' ?
							`
							<option></option>
							${tb.plugin_menu_items}
						` : ''}
						${headlines.id === 0 && !headlines.is_cat ?
							`
							<option></option>
							<option class='text-error' value='headlines_deleteSelection'>${__('Delete permanently')}</option>
							` : ''}
					</select>

					${tb.plugin_buttons}
				</span>
			`);
		} else {
			target.attr('innerHTML', '');
		}

		dojo.parser.parse(target.domNode);

		this._headlinesSelectClickHandle = dojo.connect(dijit.byId("headlines-select-articles-dropdown"), 'onItemClick',
			(item) => {
				const action = item.option.value;

				switch (action) {
					case 'headlines_select_all':
						Headlines.select('all');
						break;
					case 'headlines_select_unread':
						Headlines.select('unread');
						break;
					case 'headlines_select_invert':
						Headlines.select('invert');
						break;
					case 'headlines_select_none':
						Headlines.select('none');
						break;
					case 'headlines_selectionToggleUnread':
						Headlines.selectionToggleUnread();
						break;
					case 'headlines_selectionToggleMarked':
						Headlines.selectionToggleMarked();
						break;
					case 'headlines_selectionTogglePublished':
						Headlines.selectionTogglePublished();
						break;
					case 'headlines_catchupSelection':
						Headlines.catchupSelection();
						break;
					case 'article_selectionSetScore':
						Article.selectionSetScore();
						break;
					case 'headlines_deleteSelection':
						Headlines.deleteSelection();
						break;
					default:
						if (!PluginHost.run_until(PluginHost.HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM2, true, action))
							console.warn('unknown headlines action', action);
				}
			}
		);
	},
	onLoaded: function (reply, offset, append) {
		console.log("Headlines.onLoaded: offset=", offset, "append=", append);
        //console.log("Headlines.onLoaded: reply", reply);  // entray poin from Feeds.php

		let is_cat = false;
		let feed_id = false;

		if (reply) {

			is_cat = reply['headlines']['is_cat'];
			feed_id = reply['headlines']['id'];
			Feeds.last_search_query = reply['headlines']['search_query'];

			if (feed_id != Feeds.FEED_ERROR && (feed_id != Feeds.getActive() || is_cat != Feeds.activeIsCat()))
				return;

			const headlines_count = reply['headlines-info']['count'];

			//this.vgroup_last_feed = reply['headlines-info']['vgroup_last_feed'];
			this.current_first_id = reply['headlines']['first_id'];

			console.log('received', headlines_count, 'headlines');

			if (!append) {
				Feeds.infscroll_disabled = parseInt(headlines_count) != 30;
				console.log('infscroll_disabled=', Feeds.infscroll_disabled);

				// also called in renderAgain() after view mode switch
				Headlines.setCommonClasses(headlines_count);

				/** TODO: remove @deprecated */
				App.byId("headlines-frame").setAttribute("is-vfeed",
					reply['headlines']['is_vfeed'] ? 1 : 0);

				App.byId("headlines-frame").setAttribute("data-is-vfeed",
					reply['headlines']['is_vfeed'] ? "true" : "false");

				Article.setActive(0);

				try {
					App.byId("headlines-frame").removeClassName("smooth-scroll");
					App.byId("headlines-frame").scrollTop = 0;
					App.byId("headlines-frame").addClassName("smooth-scroll");
				} catch (e) {
					console.warn(e);
				}

				this.headlines = [];
				this.vgroup_last_feed = undefined;

				/*dojo.html.set(App.byId("toolbar-headlines"),
					reply['headlines']['toolbar'],
					{parseContent: true});*/

				Headlines.renderToolbar(reply['headlines']);

				if (typeof reply['headlines']['content'] == 'string') {
					App.byId("headlines-frame").innerHTML = reply['headlines']['content'];
				} else {
					App.byId("headlines-frame").innerHTML = '';

					for (let i = 0; i < reply['headlines']['content'].length; i++) {
						const hl = reply['headlines']['content'][i];

						App.byId("headlines-frame").appendChild(this.render(reply['headlines'], hl));

						this.headlines[parseInt(hl.id)] = hl;
					}
				}

				let hsp = App.byId("headlines-spacer");

				if (!hsp) {
					hsp = document.createElement("div");
					hsp.id = "headlines-spacer";
				}

				// clear out hsp contents in case there's a power-hungry svg icon rotating there
				hsp.innerHTML = "";

				dijit.byId('headlines-frame').domNode.appendChild(hsp);

				this.initHeadlinesMenu();

				if (Feeds.infscroll_disabled)
					hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" +
						__("Click to open next unread feed.") + "</a>";

				/*
				if (Feeds._search_query) {
					App.byId("feed_title").innerHTML += "<span id='cancel_search'>" +
						" (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" +
						"</span>";
				} */

				Headlines.updateCurrentUnread();

			} else if (headlines_count > 0 && feed_id == Feeds.getActive() && is_cat == Feeds.activeIsCat()) {
				const c = dijit.byId("headlines-frame");

				let hsp = App.byId("headlines-spacer");

				if (hsp)
					c.domNode.removeChild(hsp);

				let headlines_appended = 0;

				if (typeof reply['headlines']['content'] == 'string') {
					App.byId("headlines-frame").innerHTML = reply['headlines']['content'];
				} else {
					for (let i = 0; i < reply['headlines']['content'].length; i++) {
						const hl = reply['headlines']['content'][i];

						if (!this.headlines[parseInt(hl.id)]) {
							App.byId("headlines-frame").appendChild(this.render(reply['headlines'], hl));

							this.headlines[parseInt(hl.id)] = hl;
							++headlines_appended;
						}
					}
				}

				Feeds.infscroll_disabled = headlines_appended == 0;

				console.log('appended', headlines_appended, 'headlines, infscroll_disabled=', Feeds.infscroll_disabled);

				if (!hsp) {
					hsp = document.createElement("div");
					hsp.id = "headlines-spacer";
				}

				// clear out hsp contents in case there's a power-hungry svg icon rotating there
				hsp.innerHTML = "";

				c.domNode.appendChild(hsp);

				this.initHeadlinesMenu();

				if (Feeds.infscroll_disabled) {
					hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" +
						__("Click to open next unread feed.") + "</a>";
				}

			} else {
				Feeds.infscroll_disabled = true;
				const first_id_changed = reply['headlines']['first_id_changed'];

				console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed);

				const hsp = App.byId("headlines-spacer");

				if (hsp) {
					if (first_id_changed) {
						hsp.innerHTML = "<a href='#' onclick='Feeds.reloadCurrent()'>" +
							__("New articles found, reload feed to continue.") + "</a>";
					} else {
						hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" +
							__("Click to open next unread feed.") + "</a>";
					}
				}
			}

			App.findAll(".cdm .header-sticky-guard").forEach((e) => {
				this.sticky_header_observer.observe(e)
			});

			App.findAll(".cdm .content").forEach((e) => {
				this.sticky_content_observer.observe(e)
			});

			if (App.getInitParam("cdm_expanded"))
				App.findAll("#headlines-frame > div[id*=RROW].cdm").forEach((e) => {
					this.unpack_observer.observe(e)
				});

		} else {
			dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
				__('Could not update headlines (invalid object received - see error console for details)') +
				"</div>");
		}

		Feeds.infscroll_in_progress = 0;

		// this is used to auto-catchup articles if needed after infscroll request has finished,
		// unpack visible articles, fill buffer more, etc
		this.scrollHandler();

		dijit.byId('main').resize();

		PluginHost.run(PluginHost.HOOK_HEADLINES_RENDERED);

		Notify.close();
	},
	reverse: function () {
		const toolbar = dijit.byId("toolbar-main");
		let order_by = toolbar.getValues().order_by;

		if (order_by != "date_reverse")
			order_by = "date_reverse";
		else
			order_by = App.getInitParam("default_view_order_by");

		toolbar.setValues({order_by: order_by});
	},
	selectionToggleUnread: function (params = {}) {
		const cmode = params.cmode != undefined ? params.cmode : 2;
		const no_error = params.no_error || false;
		const ids = params.ids || Headlines.getSelected();

		if (ids.length == 0) {
			if (!no_error)
				alert(__("No articles selected."));

			return;
		}

		ids.forEach((id) => {
			const row = App.byId(`RROW-${id}`);

			if (row) {
				switch (cmode) {
					case 0:
						row.removeClassName("Unread");
						break;
					case 1:
						row.addClassName("Unread");
						break;
					case 2:
						row.toggleClassName("Unread");
				}
			}
		});
	},
	selectionToggleMarked: function (ids) {
		ids = ids || Headlines.getSelected();

		if (ids.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		ids.forEach((id) => {
			this.toggleMark(id);
		});
	},
	selectionTogglePublished: function (ids) {
		ids = ids || Headlines.getSelected();

		if (ids.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		ids.forEach((id) => {
			this.togglePub(id);
		});
	},
	toggleMark: function (id) {
		const row = App.byId(`RROW-${id}`);

		if (row)
			row.toggleClassName("marked");

	},
	togglePub: function (id) {
		const row = App.byId(`RROW-${id}`);

		if (row)
			row.toggleClassName("published");
	},
	move: function (mode, params = {}) {
		const no_expand = params.no_expand || false;
		const force_previous = params.force_previous || this.default_force_previous;
		const force_to_top = params.force_to_top || this.default_force_to_top;

		let prev_id = false;
		let next_id = false;
		let current_id = Article.getActive();

		if (!Headlines.isChildVisible(App.byId(`RROW-${current_id}`))) {
			console.log('active article is obscured, resetting to first visible...');
			current_id = Headlines.firstVisible();
			prev_id = current_id;
			next_id = current_id;
		} else {
			const rows = Headlines.getLoaded();

			for (let i = 0; i < rows.length; i++) {
				if (rows[i] == current_id) {

					// Account for adjacent identical article ids.
					if (i > 0) prev_id = rows[i - 1];

					for (let j = i + 1; j < rows.length; j++) {
						if (rows[j] != current_id) {
							next_id = rows[j];
							break;
						}
					}
					break;
				}
			}
		}

		console.log("cur: " + current_id + " next: " + next_id + " prev:" + prev_id);

		if (mode === "next") {
			if (next_id) {
				if (App.isCombinedMode()) {
					window.requestAnimationFrame(() => {
						Article.setActive(next_id);
						Article.cdmMoveToId(next_id, {force_to_top: force_to_top});
					});
				} else {
					Article.view(next_id, no_expand);
				}
			} else if (App.isCombinedMode()) {
				// try to show hsp if no next article exists, in case there's useful information like first_id_changed etc
				const row = App.byId(`RROW-${current_id}`);
				const ctr = App.byId("headlines-frame");

				if (row) {
					const next = row.nextSibling;

					// hsp has half-screen height in auto catchup mode therefore we use its first child (normally A element)
					if (next && Element.visible(next) && next.id == "headlines-spacer" && next.firstChild) {
						const offset = App.byId("headlines-spacer").offsetTop - App.byId("headlines-frame").offsetHeight + next.firstChild.offsetHeight;

						// don't jump back either
						if (ctr.scrollTop < offset)
							ctr.scrollTop = offset;
					}
				}
			}
		} else if (mode === "prev") {
			if (prev_id || current_id) {
				if (App.isCombinedMode()) {
					window.requestAnimationFrame(() => {
						const row = App.byId(`RROW-${current_id}`);
						const ctr = App.byId("headlines-frame");
						const delta_px = Math.round(row.offsetTop) - Math.round(ctr.scrollTop);

						console.log('moving back, delta_px', delta_px);

						if (!force_previous && row && delta_px < -8) {
							Article.setActive(current_id);
							Article.cdmMoveToId(current_id, {force_to_top: force_to_top});
						} else if (prev_id) {
							Article.setActive(prev_id);
							Article.cdmMoveToId(prev_id, {force_to_top: force_to_top});
						}
					});
				} else if (prev_id) {
					Article.view(prev_id, no_expand);
				}
			}
		}
	},
	updateSelectedPrompt: function () {
		const count = Headlines.getSelected().length;
		const elem = App.byId("selected_prompt");

		if (elem) {
			elem.innerHTML = ngettext("%d article selected",
				"%d articles selected", count).replace("%d", count);

			count > 0 ? Element.show(elem) : Element.hide(elem);
		}
	},
	toggleUnread: function (id, cmode) {
		const row = App.byId(`RROW-${id}`);

		if (row) {
			if (typeof cmode == "undefined") cmode = 2;

			switch (cmode) {
				case 0:
					row.removeClassName("Unread");
					break;
				case 1:
					row.addClassName("Unread");
					break;
				case 2:
					row.toggleClassName("Unread");
					break;
			}
		}
	},
	selectionRemoveLabel: function (id, ids) {
		if (!ids) ids = Headlines.getSelected();

		if (ids.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		const query = {
			op: "Article", method: "removeFromLabel",
			ids: ids.toString(), lid: id
		};

		xhr.json("backend.php", query, (reply) => {
			this.onLabelsUpdated(reply);
		});
	},
	selectionAssignLabel: function (id, ids) {
		if (!ids) ids = Headlines.getSelected();

		if (ids.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		const query = {
			op: "Article", method: "assignToLabel",
			ids: ids.toString(), lid: id
		};

		xhr.json("backend.php", query, (reply) => {
			this.onLabelsUpdated(reply);
		});
	},
	deleteSelection: function () {
		const rows = Headlines.getSelected();

		if (rows.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat());
		let str;

		if (Feeds.getActive() != 0) {
			str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?", rows.length);
		} else {
			str = ngettext("Delete %d selected article?", "Delete %d selected articles?", rows.length);
		}

		str = str.replace("%d", rows.length);
		str = str.replace("%s", fn);

		if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) {
			return;
		}

		const query = {op: "RPC", method: "delete", ids: rows.toString()};

		xhr.json("backend.php", query, () => {
			Feeds.reloadCurrent();
		});
	},
	getSelected: function () {
		const rv = [];

		App.findAll("#headlines-frame > div[id*=RROW][class*=Selected]").forEach(
			function (child) {
				rv.push(child.getAttribute("data-article-id"));
			});

		// consider active article a honorary member of selected articles
		if (Article.getActive())
			rv.push(Article.getActive());

		return rv.uniq();
	},
	getLoaded: function () {
		const rv = [];

		const children = App.findAll("#headlines-frame > div[id*=RROW-]");

		children.forEach(function (child) {
			if (Element.visible(child)) {
				rv.push(child.getAttribute("data-article-id"));
			}
		});

		return rv;
	},
	onRowChecked: function (elem) {
		const row = elem.domNode.closest("div[id*=RROW]");

		// do not allow unchecking active article checkbox
		if (row.hasClassName("active")) {
			elem.attr("checked", 1);
			return;
		}

		if (elem.attr("checked")) {
			row.addClassName("Selected");
		} else {
			row.removeClassName("Selected");
		}
	},
	getRange: function (start, stop) {
		if (start == stop)
			return [start];

		const rows = App.findAll("#headlines-frame > div[id*=RROW]");
		const results = [];
		let collecting = false;

		for (let i = 0; i < rows.length; i++) {
			const row = rows[i];
			const id = row.getAttribute('data-article-id');

			if (id == start || id == stop) {
				if (!collecting) {
					collecting = true;
				} else {
					results.push(id);
					break;
				}
			}

			if (collecting)
				results.push(id);
		}

		return results;
	},
	select: function (mode, articleId) {
		// mode = all,none,unread,invert,marked,published
		let query = "#headlines-frame > div[id*=RROW]";

		if (articleId) query += `[data-article-id="${articleId}"]`;

		switch (mode) {
			case "none":
			case "all":
			case "invert":
				break;
			case "marked":
				query += "[class*=marked]";
				break;
			case "published":
				query += "[class*=published]";
				break;
			case "unread":
				query += "[class*=Unread]";
				break;
			default:
				console.warn("select: unknown mode", mode);
		}

		App.findAll(query).forEach((row) => {

			switch (mode) {
				case "none":
					row.removeClassName("Selected");
					break;
				case "invert":
					row.toggleClassName("Selected");
					break;
				default:
					row.addClassName("Selected");
			}
		});
	},
	catchupSelection: function () {
		const rows = Headlines.getSelected();

		if (rows.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat());

		let str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length);

		str = str.replace("%d", rows.length);
		str = str.replace("%s", fn);

		if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) {
			return;
		}

		Headlines.selectionToggleUnread({ids: rows, cmode: 0});
	},
	catchupRelativeTo: function (below, id) {

		if (!id) id = Article.getActive();

		if (!id) {
			alert(__("No article is selected."));
			return;
		}

		const visible_ids = this.getLoaded();

		const ids_to_mark = [];

		if (!below) {
			for (let i = 0; i < visible_ids.length; i++) {
				if (visible_ids[i] != id) {
					const e = App.byId(`RROW-${visible_ids[i]}`);

					if (e && e.hasClassName("Unread")) {
						ids_to_mark.push(visible_ids[i]);
					}
				} else {
					break;
				}
			}
		} else {
			for (let i = visible_ids.length - 1; i >= 0; i--) {
				if (visible_ids[i] != id) {
					const e = App.byId(`RROW-${visible_ids[i]}`);

					if (e && e.hasClassName("Unread")) {
						ids_to_mark.push(visible_ids[i]);
					}
				} else {
					break;
				}
			}
		}

		if (ids_to_mark.length == 0) {
			alert(__("No articles found to mark"));
		} else {
			const msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);

			if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {

				for (let i = 0; i < ids_to_mark.length; i++) {
					const e = App.byId(`RROW-${ids_to_mark[i]}`);
					e.removeClassName("Unread");
				}
			}
		}
	},
	onTagsUpdated: function (data) {
		if (data) {
			if (this.headlines[data.id]) {
				this.headlines[data.id].tags = data.tags;
			}

			App.findAll(`span[data-tags-for="${data.id}"`).forEach((ctr) => {
				ctr.innerHTML = Article.renderTags(data.id, data.tags);
			});
		}
	},
	// TODO: maybe this should cause article to be rendered again, although it might cause flicker etc
	onLabelsUpdated: function (data) {
		if (data) {
			data["labels-for"].forEach((row) => {
				if (this.headlines[row.id]) {
					this.headlines[row.id].labels = row.labels;
				}

				App.findAll(`span[data-labels-for="${row.id}"]`).forEach((ctr) => {
					ctr.innerHTML = Article.renderLabels(row.id, row.labels);
				});
			});
		}
	},
	scrollToArticleId: function (id) {
		const container = App.byId("headlines-frame");
		const row = App.byId(`RROW-${id}`);

		if (!container || !row) return;

		const viewport = container.offsetHeight;

		const rel_offset_top = row.offsetTop - container.scrollTop;
		const rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;

		//console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
		//console.log("Vport: " + viewport);

		if (rel_offset_top <= 0 || rel_offset_top > viewport) {
			container.scrollTop = row.offsetTop;
		} else if (rel_offset_bottom > viewport) {
			container.scrollTop = row.offsetTop + row.offsetHeight - viewport;
		}
	},
	headlinesMenuCommon: function (menu) {

		menu.addChild(new dijit.MenuItem({
			label: __("Open original article"),
			onClick: function (/* event */) {
				Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
			}
		}));

		menu.addChild(new dijit.MenuItem({
			label: __("Display article URL"),
			onClick: function (/* event */) {
				Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
			}
		}));

		menu.addChild(new dijit.MenuSeparator());

		menu.addChild(new dijit.MenuItem({
			label: __("Toggle unread"),
			onClick: function () {

				let ids = Headlines.getSelected();
				// cast to string
				const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
				ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];

				Headlines.selectionToggleUnread({ids: ids, no_error: 1});
			}
		}));

		menu.addChild(new dijit.MenuItem({
			label: __("Toggle starred"),
			onClick: function () {
				let ids = Headlines.getSelected();
				// cast to string
				const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
				ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];

				Headlines.selectionToggleMarked(ids);
			}
		}));

		menu.addChild(new dijit.MenuItem({
			label: __("Toggle published"),
			onClick: function () {
				let ids = Headlines.getSelected();
				// cast to string
				const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
				ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];

				Headlines.selectionTogglePublished(ids);
			}
		}));

		menu.addChild(new dijit.MenuSeparator());

		menu.addChild(new dijit.MenuItem({
			label: __("Mark above as read"),
			onClick: function () {
				Headlines.catchupRelativeTo(0, this.getParent().currentTarget.getAttribute("data-article-id"));
			}
		}));

		menu.addChild(new dijit.MenuItem({
			label: __("Mark below as read"),
			onClick: function () {
				Headlines.catchupRelativeTo(1, this.getParent().currentTarget.getAttribute("data-article-id"));
			}
		}));


		const labels = App.getInitParam("labels");

		if (labels && labels.length) {

			menu.addChild(new dijit.MenuSeparator());

			const labelAddMenu = new dijit.Menu({ownerMenu: menu});
			const labelDelMenu = new dijit.Menu({ownerMenu: menu});

			labels.forEach(function (label) {
				const bare_id = label.id;
				const name = label.caption;

				labelAddMenu.addChild(new dijit.MenuItem({
					label: name,
					labelId: bare_id,
					onClick: function () {

						let ids = Headlines.getSelected();
						// cast to string
						const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";

						ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];

						Headlines.selectionAssignLabel(this.labelId, ids);
					}
				}));

				labelDelMenu.addChild(new dijit.MenuItem({
					label: name,
					labelId: bare_id,
					onClick: function () {
						let ids = Headlines.getSelected();
						// cast to string
						const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";

						ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];

						Headlines.selectionRemoveLabel(this.labelId, ids);
					}
				}));

			});

			menu.addChild(new dijit.PopupMenuItem({
				label: __("Assign label"),
				popup: labelAddMenu
			}));

			menu.addChild(new dijit.PopupMenuItem({
				label: __("Remove label"),
				popup: labelDelMenu
			}));

		}
	},
	scrollByPages: function (page_offset) {
		App.Scrollable.scrollByPages(App.byId("headlines-frame"), page_offset);
	},
	scroll: function (offset) {
		App.Scrollable.scroll(App.byId("headlines-frame"), offset);
	},
	initHeadlinesMenu: function () {
		if (!dijit.byId("headlinesMenu")) {

			const menu = new dijit.Menu({
				id: "headlinesMenu",
				targetNodeIds: ["headlines-frame"],
				selector: ".hlMenuAttach"
			});

			this.headlinesMenuCommon(menu);

			menu.startup();
		}

		/* vfeed menu */

		if (!dijit.byId("vfeedMenu")) {

			const menu = new dijit.Menu({
				id: "vfeedMenu",
				targetNodeIds: ["headlines-frame"],
				selector: ".vfeedMenuAttach"
			});

			menu.addChild(new dijit.MenuItem({
				label: __("Mark as read"),
				onClick: function() {
					Feeds.catchupFeed(this.getParent().currentTarget.getAttribute("data-feed-id"));
				}}));

			menu.addChild(new dijit.MenuItem({
				label: __("Edit feed"),
				onClick: function() {
					CommonDialogs.editFeed(this.getParent().currentTarget.getAttribute("data-feed-id"), false);
				}}));

			menu.addChild(new dijit.MenuItem({
				label: __("Open site"),
				onClick: function() {
					App.postOpenWindow("backend.php", {op: "Feeds", method: "opensite",
						feed_id: this.getParent().currentTarget.getAttribute("data-feed-id"), csrf_token: __csrf_token});
				}}));

			menu.addChild(new dijit.MenuSeparator());

			menu.addChild(new dijit.MenuItem({
				label: __("Debug feed"),
				onClick: function() {
					/* global __csrf_token */
					App.postOpenWindow("backend.php", {op: "Feeds", method: "updatedebugger",
						feed_id: this.getParent().currentTarget.getAttribute("data-feed-id"), csrf_token: __csrf_token});
				}}));

			menu.startup();
		}

		/* vgroup feed title menu */

		if (!dijit.byId("headlinesFeedTitleMenu")) {

			const menu = new dijit.Menu({
				id: "headlinesFeedTitleMenu",
				targetNodeIds: ["headlines-frame"],
				selector: "div.cdmFeedTitle"
			});

			menu.addChild(new dijit.MenuItem({
				label: __("Select articles in group"),
				onClick: function (/* event */) {
					Headlines.select("all",
						"#headlines-frame > div[id*=RROW]" +
						"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");

				}
			}));

			menu.addChild(new dijit.MenuItem({
				label: __("Mark group as read"),
				onClick: function () {
					Headlines.select("none");
					Headlines.select("all",
						"#headlines-frame > div[id*=RROW]" +
						"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");

					Headlines.catchupSelection();
				}
			}));

			menu.addChild(new dijit.MenuItem({
				label: __("Mark feed as read"),
				onClick: function () {
					Feeds.catchupFeedInGroup(this.getParent().currentTarget.getAttribute("data-feed-id"));
				}
			}));

			menu.addChild(new dijit.MenuItem({
				label: __("Edit feed"),
				onClick: function () {
					CommonDialogs.editFeed(this.getParent().currentTarget.getAttribute("data-feed-id"));
				}
			}));

			menu.startup();
		}
	}
}
/* global define, dojo */

define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {

	return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {

		_saveEverything: function(saveCompleteCallback, saveFailedCallback, newFileContentString) {

			dojo.xhrPost({
				url: "backend.php",
				content: {op: "Pref_Feeds", method: "savefeedorder",
					payload: newFileContentString},
				error: saveFailedCallback,
				load: saveCompleteCallback});
		},

	});

});


/* eslint-disable prefer-rest-params */
/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhr, fox, App */

define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"],
	function (declare, domConstruct, checkBoxTree, array, cookie) {

	return declare("fox.PrefFeedTree", lib.CheckBoxTree, {
		postCreate: function() {
			this.inherited(arguments);

			const tmph = dojo.connect(this, 'onLoad', () => {
				dojo.disconnect(tmph);

				this.checkInactiveFeeds();
				this.checkErrorFeeds();
			});

			dojo.connect(this, 'onClick', (item) => {
				const id = String(item.id);
				const bare_id = id.substr(id.indexOf(':')+1);

				if (id.match('FEED:')) {
					CommonDialogs.editFeed(bare_id);
				} else if (id.match('CAT:')) {
					dijit.byId('feedTree').editCategory(bare_id, item);
				}
			});
		},
		// save state in localStorage instead of cookies
		// reference: https://stackoverflow.com/a/27968996
		_saveExpandedNodes: function(){
			if (this.persist && this.cookieName){
				const ary = [];
				for (const id in this._openedNodes){
					ary.push(id);
				}
				// Was:
				// cookie(this.cookieName, ary.join(","), {expires: 365});
				localStorage.setItem(this.cookieName, ary.join(","));
			}
		},
		_initState: function(){
			this.cookieName = 'prefs:' + this.cookieName;
			// summary:
			//    Load in which nodes should be opened automatically
			this._openedNodes = {};
			if (this.persist && this.cookieName){
				// Was:
				// var oreo = cookie(this.cookieName);
				let oreo = localStorage.getItem(this.cookieName);
				// migrate old data if nothing in localStorage
				if (oreo == null || oreo === '') {
					oreo = cookie(this.cookieName);
					cookie(this.cookieName, null, { expires: -1 });
				}
				if (oreo){
					array.forEach(oreo.split(','), function(item){
						this._openedNodes[item] = true;
					}, this);
				}
			}
		},
		_createTreeNode: function(args) {
			const tnode = this.inherited(arguments);

			const icon = dojo.doc.createElement('img');
			if (args.item.icon && args.item.icon[0]) {
				icon.src = args.item.icon[0];
			} else {
				icon.src = 'images/blank_icon.gif';
			}
			icon.className = 'icon';
			domConstruct.place(icon, tnode.iconNode, 'only');

			let param = this.model.store.getValue(args.item, 'param');

			if (param) {
				param = dojo.doc.createElement('span');
				param.className = 'feedParam';
				param.innerHTML = args.item.param[0];
				//domConstruct.place(param, tnode.labelNode, 'after');
				domConstruct.place(param, tnode.rowNode, 'first');
			}

			const id = args.item.id[0];
			const bare_id = parseInt(id.substr(id.indexOf(':')+1));

			if (id.match("CAT:") && bare_id > 0) {
				const menu = new dijit.Menu();
				menu.row_id = bare_id;
				menu.item = args.item;

				menu.addChild(new dijit.MenuItem({
					label: __("Edit category"),
					onClick: function() {
						dijit.byId("feedTree").editCategory(this.getParent().row_id, this.getParent().item, null);
					}}));


				menu.addChild(new dijit.MenuItem({
					label: __("Remove category"),
					onClick: function() {
						dijit.byId("feedTree").removeCategory(this.getParent().row_id, this.getParent().item);
					}}));

				menu.bindDomNode(tnode.domNode);
				tnode._menu = menu;
			} else if (id.match("FEED:")) {
				const menu = new dijit.Menu();
				menu.row_id = bare_id;
				menu.item = args.item;

				menu.addChild(new dijit.MenuItem({
					label: __("Edit feed"),
					onClick: function() {
						CommonDialogs.editFeed(this.getParent().row_id);
					}}));

				menu.addChild(new dijit.MenuItem({
					label: __("Unsubscribe"),
					onClick: function() {
						CommonDialogs.unsubscribeFeed(this.getParent().row_id, this.getParent().item.name);
					}}));

				menu.bindDomNode(tnode.domNode);
				tnode._menu = menu;

			}

			return tnode;
		},
		onDndDrop: function() {
			this.inherited(arguments);
			this.tree.model.store.save();
		},
		// eslint-disable-next-line no-unused-vars
		getRowClass: function (item, opened) {
			let rc = (!item.error || item.error == '') ? "dijitTreeRow" :
				"dijitTreeRow Error";

			if (item.updates_disabled > 0) rc += " UpdatesDisabled";

			return rc;
		},
		getIconClass: function (item, opened) {
			// eslint-disable-next-line no-nested-ternary
			return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon";
		},
		reload: function() {
			const searchElem = App.byId("feed_search");
			const search = (searchElem) ? searchElem.value : "";

			xhr.post("backend.php", { op: "Pref_Feeds", search: search }, (reply) => {
				dijit.byId('feedsTab').attr('content', reply);
				Notify.close();
			});
		},
		checkItemAcceptance: function(target, source, position) {
			const item = dijit.getEnclosingWidget(target).item;

			// disable copying items
			source.copyState = function() { return false; };

			let source_item = false;

			source.forInSelectedItems(function(node) {
				source_item = node.data.item;
			});

			if (!source_item || !item) return false;

			const id = this.tree.model.store.getValue(item, 'id');
			const source_id = source.tree.model.store.getValue(source_item, 'id');

			//console.log(id + " " + position + " " + source_id);

			if (source_id.match("FEED:")) {
				return ((id.match("CAT:") && position == "over") ||
				(id.match("FEED:") && position != "over"));
			} else if (source_id.match("CAT:")) {
				return ((id.match("CAT:") && !id.match("CAT:0")) ||
				(id.match("root") && position == "over"));
			}
		},
		resetFeedOrder: function() {
			Notify.progress("Loading, please wait...");

			xhr.post("backend.php", {op: "Pref_Feeds", method: "feedsortreset"}, () => {
				this.reload();
			});
		},
		resetCatOrder: function() {
			Notify.progress("Loading, please wait...");

			xhr.post("backend.php", {op: "Pref_Feeds", method: "catsortreset"}, () => {
				this.reload();
			});
		},
		removeCategory: function(id, item) {
			if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) {
				Notify.progress("Removing category...");

				xhr.post("backend.php", {op: "Pref_Feeds", method: "removeCat", ids: id}, () => {
					Notify.close();
					this.reload();
				});
			}
		},
		removeSelectedFeeds: function() {
			const sel_rows = this.getSelectedFeeds();

			if (sel_rows.length > 0) {
				if (confirm(__("Unsubscribe from selected feeds?"))) {

					Notify.progress("Unsubscribing from selected feeds...", true);

					const query = {
						op: "Pref_Feeds", method: "remove",
						ids: sel_rows.toString()
					};

					xhr.post("backend.php", query, () => {
						this.reload();
					});
				}

			} else {
				alert(__("No feeds selected."));
			}

			return false;
		},
		checkErrorFeeds: function() {
			xhr.json("backend.php", {op: "Pref_Feeds", method: "feedsWithErrors"}, (reply) => {
				if (reply.length > 0) {
					Element.show(dijit.byId("pref_feeds_errors_btn").domNode);
				}
			});
		},
		checkInactiveFeeds: function() {
			xhr.json("backend.php", {op: "Pref_Feeds", method: "inactivefeeds"}, (reply) => {
				if (reply.length > 0) {
					Element.show(dijit.byId("pref_feeds_inactive_btn").domNode);
				}
			});
		},
		getSelectedCategories: function() {
			const tree = this;
			const items = tree.model.getCheckedItems();
			const rv = [];

			items.forEach(function (item) {
				if (item.id[0].match("CAT:"))
					rv.push(tree.model.store.getValue(item, 'bare_id'));
			});

			return rv;
		},
		removeSelectedCategories: function() {
			const sel_rows = this.getSelectedCategories();

			if (sel_rows.length > 0) {
				if (confirm(__("Remove selected categories?"))) {
					Notify.progress("Removing selected categories...");

					const query = {
						op: "Pref_Feeds", method: "removeCat",
						ids: sel_rows.toString()
					};

					xhr.post("backend.php", query, () => {
						this.reload();
					});
				}
			} else {
				alert(__("No categories selected."));
			}

			return false;
		},
		getSelectedFeeds: function() {
			const tree = this;
			const items = tree.model.getCheckedItems();
			const rv = [];

			items.forEach(function (item) {
				if (item.id[0].match("FEED:"))
					rv.push(tree.model.store.getValue(item, 'bare_id'));
			});

			return rv;
		},
		editSelectedFeed: function() {
			const rows = this.getSelectedFeeds();

			if (rows.length == 0) {
				alert(__("No feeds selected."));
				return;
			}

			Notify.close();

			if (rows.length > 1) {
				return this.editMultiple();
			} else {
				CommonDialogs.editFeed(rows[0], {});
			}
		},
		editMultiple: function() {
			const rows = this.getSelectedFeeds();

			if (rows.length == 0) {
				alert(__("No feeds selected."));
				return;
			}

			Notify.progress("Loading, please wait...");

			xhr.post("backend.php", {op: "Pref_Feeds", method: "editfeeds", ids: rows.toString()}, (reply) => {
				Notify.close();

				try {
					const dialog = new fox.SingleUseDialog({
						title: __("Edit multiple feeds"),
						/*getChildByName: function (name) {
							let rv = null;
							this.getChildren().forEach(
								function (child) {
									if (child.name == name) {
										rv = child;
										return;
									}
								});
							return rv;
						},*/
						toggleField: function (checkbox) {
							const name = checkbox.attr("data-control-for");
							const target = dijit.getEnclosingWidget(dialog.domNode.querySelector(`input[name="${name}"]`));

							target.attr('disabled', !checkbox.attr('checked'));
							console.log(target, target.attr('type'));

							if (target.attr('type') == "checkbox") {
								const label = checkbox.domNode.closest("label");

								if (checkbox.attr('checked'))
									label.removeClassName('text-muted');
								else
									label.addClassName('text-muted');
							}
						},
						execute: function () {
							if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
								const query = this.attr('value');

								/* normalize unchecked checkboxes because [] is not serialized */

								Object.keys(query).forEach((key) => {
									const val = query[key];

									if (typeof val == "object" && val.length == 0)
										query[key] = ["off"];
								});

								Notify.progress("Saving data...", true);

								xhr.post("backend.php", query, () => {
									dialog.hide();

									const tree = dijit.byId("feedTree");

									if (tree) tree.reload();
								});
							}
						},
						content: reply
					});

					dialog.show();
				} catch (e) {
					App.Error.report(e);
				}
			});
		},
		editCategory: function(id, item) {
			// uncategorized
			if (String(item.id) == "CAT:0")
				return;

			const new_name = prompt(__('Rename category to:'), item.name);

			if (new_name && new_name != item.name) {

				Notify.progress("Loading, please wait...");

				xhr.post("backend.php", { op: 'Pref_Feeds', method: 'renamecat', id: id, title: new_name }, () => {
					this.reload();
				});
			}
		},
		createCategory: function() {
			const title = prompt(__("Category title:"));

			if (title) {
				Notify.progress("Creating category...");

				xhr.post("backend.php", {op: "Pref_Feeds", method: "addCat", cat: title}, () => {
					Notify.close();
					this.reload();
				});
			}
		},
		batchSubscribe: function() {
			xhr.json("backend.php", {op: 'Pref_Feeds', method: 'batchSubscribe'}, (reply) => {
				const dialog = new fox.SingleUseDialog({
					id: "batchSubDlg",
					title: __("Batch subscribe"),
					execute: function () {
						if (this.validate()) {
							Notify.progress(__("Subscribing to feeds..."), true);

							xhr.post("backend.php", this.attr('value'), () => {
								Notify.close();

								const tree = dijit.byId("feedTree");
								if (tree) tree.reload();

								dialog.hide();
							});
						}
					},
					content: `
						<form onsubmit='return false'>
							${App.FormFields.hidden_tag("op", "Pref_Feeds")}
							${App.FormFields.hidden_tag("method", "batchaddfeeds")}

							<header class='horizontal'>
								${__("One valid feed per line (no detection is done)")}
							</header>

							<section>
								<textarea style='font-size : 12px; width : 98%; height: 200px;'
									dojoType='fox.form.ValidationTextArea' required='1' name='feeds'></textarea>

								${reply.enable_cats ?
									`<fieldset>
											<label>${__('Place in category:')}</label>
											${reply.cat_select}
									</fieldset>
									` : ''
								}
							</section>

							<div id='feedDlg_loginContainer' style='display : none'>
								<header>${__("Authentication")}</header>
								<section>
									<input dojoType='dijit.form.TextBox' name='login' placeHolder="${__("Login")}">
									<input placeHolder="${__("Password")}" dojoType="dijit.form.TextBox" type='password'
										autocomplete='new-password' name='pass'></div>
								</section>
							</div>

							<fieldset class='narrow'>
								<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox'
										onclick='App.displayIfChecked(this, "feedDlg_loginContainer")'>
									${__('Feeds require authentication.')}
								</label>
							</fieldset>

							<footer>
								<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).execute()' type='submit' class='alt-primary'>
									${__('Subscribe')}
								</button>
								<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>
									${__('Cancel')}
								</button>
							</footer>
						</form>
					`
				});

				dialog.show();

			});
		},
		showInactiveFeeds: function() {
			xhr.json("backend.php", {op: 'Pref_Feeds', method: 'inactivefeeds'}, function (reply) {

				const dialog = new fox.SingleUseDialog({
					id: "inactiveFeedsDlg",
					title: __("Feeds without recent updates"),
					getSelectedFeeds: function () {
						return Tables.getSelected("inactive-feeds-list");
					},
					removeSelected: function () {
						const sel_rows = this.getSelectedFeeds();

						if (sel_rows.length > 0) {
							if (confirm(__("Remove selected feeds?"))) {
								Notify.progress("Removing selected feeds...", true);

								const query = {
									op: "Pref_Feeds", method: "remove",
									ids: sel_rows.toString()
								};

								xhr.post("backend.php", query, () => {
									Notify.close();

									const tree = dijit.byId("feedTree");
									if (tree) tree.reload();

									dialog.hide();
								});
							}

						} else {
							alert(__("No feeds selected."));
						}
					},
					content: `
						<div dojoType='fox.Toolbar'>
							<div dojoType='fox.form.DropDownButton'>
								<span>${__('Select')}</span>
								<div dojoType='dijit.Menu' style='display: none'>
								<div onclick="Tables.select('inactive-feeds-list', true)"
									dojoType='dijit.MenuItem'>${__('All')}</div>
								<div onclick="Tables.select('inactive-feeds-list', false)"
									dojoType='dijit.MenuItem'>${__('None')}</div>
								</div>
							</div>
						</div>

						<div class='panel panel-scrollable'>
							<table width='100%' id='inactive-feeds-list'>
								${reply.map((row) => `<tr data-row-id='${row.id}'>
									<td class='checkbox'>
										<input onclick='Tables.onRowChecked(this)' dojoType='dijit.form.CheckBox' type='checkbox'>
									</td>
									<td>
										<a href='#' "title="${__("Click to edit feed")}" onclick="CommonDialogs.editFeed(${row.id})">
											${App.escapeHtml(row.title)}
										</a>
									</td>
									<td class='text-muted' align='right'>
										${row.last_article}
									</td>
								</tr>
								`).join("")}
							</table>
						</div>

						<footer>
							<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' onclick='App.dialogOf(this).removeSelected()'>
								${__('Unsubscribe from selected feeds')}
							</button>
							<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>
								${__('Close this window')}
							</button>
						</footer>
					`
				});

				dialog.show();

			});

		}
	});
});

'use strict'

/* global require, App */

/* exported Plugins */
const Plugins = {};

require(["dojo/_base/kernel",
	"dojo/_base/declare",
	"dojo/ready",
	"dojo/parser",
	"fox/App",
	"dojo/_base/loader",
	"dojo/_base/html",
	"dijit/ColorPalette",
	"dijit/Dialog",
	"dijit/form/Button",
	"dijit/form/CheckBox",
	"dijit/form/DropDownButton",
	"dijit/form/FilteringSelect",
	"dijit/form/MultiSelect",
	"dijit/form/Form",
	"dijit/form/RadioButton",
	"dijit/form/ComboButton",
	"dijit/form/Select",
	"dijit/form/SimpleTextarea",
	"dijit/form/TextBox",
	"dijit/form/NumberSpinner",
	"dijit/form/ValidationTextBox",
	"dijit/InlineEditBox",
	"dijit/layout/AccordionContainer",
	"dijit/layout/AccordionPane",
	"dijit/layout/BorderContainer",
	"dijit/layout/ContentPane",
	"dijit/layout/TabContainer",
	"dijit/Menu",
	"dijit/ProgressBar",
	"dijit/Toolbar",
	"dijit/Tree",
	"dijit/tree/dndSource",
	"dojo/data/ItemFileWriteStore",
	"lib/CheckBoxStoreModel",
	"lib/CheckBoxTree",
	"fox/PluginHost",
	"fox/CommonDialogs",
	"fox/CommonFilters",
	"fox/PrefUsers",
	"fox/PrefHelpers",
	"fox/PrefFeedStore",
	"fox/PrefFilterStore",
	"fox/PrefFeedTree",
	"fox/PrefFilterTree",
    "fox/PrefHighlightStore", // i sdelal
    "fox/PrefHighlightTree", // i sdelal
    "fox/CommonHighlight", // i sdelal
	"fox/PrefLabelTree",
	"fox/Toolbar",
	"fox/SingleUseDialog",
	"fox/form/ValidationMultiSelect",
	"fox/form/ValidationTextArea",
	"fox/form/Select",
	"fox/form/ComboButton",
	"fox/form/DropDownButton"], function (dojo, declare, ready, parser) {

	ready(function () {
		try {
			App.init(parser, true);
		} catch (e) {
			if (typeof App != "undefined" && App.Error)
				App.Error.report(e);
			else
				alert(e + "\n\n" + e.stack);
		}
	});
});
'use strict'

/* global require, App, dojo */

/* exported Plugins */
const Plugins = {};

require(["dojo/_base/kernel",
	"dojo/_base/declare",
	"dojo/ready",
	"dojo/parser",
	"fox/App",
	"dojo/_base/loader",
	"dojo/_base/html",
	"dojo/query",
	"dijit/ProgressBar",
	"dijit/ColorPalette",
	"dijit/Dialog",
	"dijit/form/Button",
	"dijit/form/ComboButton",
	"dijit/form/CheckBox",
	"dijit/form/DropDownButton",
	"dijit/form/FilteringSelect",
	"dijit/form/Form",
	"dijit/form/RadioButton",
	"dijit/form/Select",
	"dijit/form/MultiSelect",
	"dijit/form/SimpleTextarea",
	"dijit/form/TextBox",
	"dijit/form/ComboBox",
	"dijit/form/ValidationTextBox",
	"dijit/InlineEditBox",
	"dijit/layout/AccordionContainer",
	"dijit/layout/BorderContainer",
	"dijit/layout/ContentPane",
	"dijit/layout/TabContainer",
	"dijit/PopupMenuItem",
	"dijit/Menu",
	"dijit/Toolbar",
	"dijit/Tree",
	"dijit/tree/dndSource",
	"dijit/tree/ForestStoreModel",
	"dojo/data/ItemFileWriteStore",
	"fox/PluginHost",
	"fox/CommonFilters",
    "fox/CommonHighlight", // i sdelal
	"fox/CommonDialogs",
	"fox/Feeds",
	"fox/Headlines",
	"fox/Article",
	"fox/FeedStoreModel",
	"fox/FeedTree",
	"fox/Toolbar",
	"fox/SingleUseDialog",
	"fox/form/ValidationMultiSelect",
	"fox/form/ValidationTextArea",
	"fox/form/Select",
	"fox/form/ComboButton",
	"fox/form/DropDownButton"], function (dojo, declare, ready, parser) {

	ready(function () {
		try {
			App.init(parser, false);
		} catch (e) {
			if (typeof App != "undefined" && App.Error)
				App.Error.report(e);
			else
				alert(e + "\n\n" + e.stack);
		}
	});
});

/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
require({cache:{"dojo/_base/url":function(){define(["./kernel"],function(_1){var _2=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"),_3=new RegExp("^((([^\\[:]+):)?([^@]+)@)?(\\[([^\\]]+)\\]|([^\\[:]*))(:([0-9]+))?$"),_4=function(){var n=null,_5=arguments,_6=[_5[0]];for(var i=1;i<_5.length;i++){if(!_5[i]){continue;}var _7=new _4(_5[i]+""),_8=new _4(_6[0]+"");if(_7.path==""&&!_7.scheme&&!_7.authority&&!_7.query){if(_7.fragment!=n){_8.fragment=_7.fragment;}_7=_8;}else{if(!_7.scheme){_7.scheme=_8.scheme;if(!_7.authority){_7.authority=_8.authority;if(_7.path.charAt(0)!="/"){var _9=_8.path.substring(0,_8.path.lastIndexOf("/")+1)+_7.path;var _a=_9.split("/");for(var j=0;j<_a.length;j++){if(_a[j]=="."){if(j==_a.length-1){_a[j]="";}else{_a.splice(j,1);j--;}}else{if(j>0&&!(j==1&&_a[0]=="")&&_a[j]==".."&&_a[j-1]!=".."){if(j==(_a.length-1)){_a.splice(j,1);_a[j-1]="";}else{_a.splice(j-1,2);j-=2;}}}}_7.path=_a.join("/");}}}}_6=[];if(_7.scheme){_6.push(_7.scheme,":");}if(_7.authority){_6.push("//",_7.authority);}_6.push(_7.path);if(_7.query){_6.push("?",_7.query);}if(_7.fragment){_6.push("#",_7.fragment);}}this.uri=_6.join("");var r=this.uri.match(_2);this.scheme=r[2]||(r[1]?"":n);this.authority=r[4]||(r[3]?"":n);this.path=r[5];this.query=r[7]||(r[6]?"":n);this.fragment=r[9]||(r[8]?"":n);if(this.authority!=n){r=this.authority.match(_3);this.user=r[3]||n;this.password=r[4]||n;this.host=r[6]||r[7];this.port=r[9]||n;}};_4.prototype.toString=function(){return this.uri;};return _1._Url=_4;});},"dojo/cache":function(){define(["./_base/kernel","./text"],function(_b){return _b.cache;});},"dojo/text":function(){define(["./_base/kernel","require","./has","./request"],function(_c,_d,_e,_f){var _10;if(1){_10=function(url,_11,_12){_f(url,{sync:!!_11,headers:{"X-Requested-With":null}}).then(_12);};}else{if(_d.getText){_10=_d.getText;}else{console.error("dojo/text plugin failed to load because loader does not support getText");}}var _13={},_14=function(_15){if(_15){_15=_15.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,"");var _16=_15.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);if(_16){_15=_16[1];}}else{_15="";}return _15;},_17={},_18={};_c.cache=function(_19,url,_1a){var key;if(typeof _19=="string"){if(/\//.test(_19)){key=_19;_1a=url;}else{key=_d.toUrl(_19.replace(/\./g,"/")+(url?("/"+url):""));}}else{key=_19+"";_1a=url;}var val=(_1a!=undefined&&typeof _1a!="string")?_1a.value:_1a,_1b=_1a&&_1a.sanitize;if(typeof val=="string"){_13[key]=val;return _1b?_14(val):val;}else{if(val===null){delete _13[key];return null;}else{if(!(key in _13)){_10(key,true,function(_1c){_13[key]=_1c;});}return _1b?_14(_13[key]):_13[key];}}};return {dynamic:true,normalize:function(id,_1d){var _1e=id.split("!"),url=_1e[0];return (/^\./.test(url)?_1d(url):url)+(_1e[1]?"!"+_1e[1]:"");},load:function(id,_1f,_20){var _21=id.split("!"),_22=_21.length>1,_23=_21[0],url=_1f.toUrl(_21[0]),_24="url:"+url,_25=_17,_26=function(_27){_20(_22?_14(_27):_27);};if(_23 in _13){_25=_13[_23];}else{if(_1f.cache&&_24 in _1f.cache){_25=_1f.cache[_24];}else{if(url in _13){_25=_13[url];}}}if(_25===_17){if(_18[url]){_18[url].push(_26);}else{var _28=_18[url]=[_26];_10(url,!_1f.async,function(_29){_13[_23]=_13[url]=_29;for(var i=0;i<_28.length;){_28[i++](_29);}delete _18[url];});}}else{_26(_25);}}};});},"dojo/request":function(){define(["./request/default!"],function(_2a){return _2a;});},"dojo/request/default":function(){define(["exports","require","../has"],function(_2b,_2c,has){var _2d=has("config-requestProvider"),_2e;if(1||has("host-webworker")){_2e="./xhr";}else{if(0){_2e="./node";}}if(!_2d){_2d=_2e;}_2b.getPlatformDefaultId=function(){return _2e;};_2b.load=function(id,_2f,_30,_31){_2c([id=="platform"?_2e:_2d],function(_32){_30(_32);});};});},"dojo/parser":function(){define(["require","./_base/kernel","./_base/lang","./_base/array","./_base/config","./dom","./_base/window","./_base/url","./aspect","./promise/all","./date/stamp","./Deferred","./has","./query","./on","./ready"],function(_33,_34,_35,_36,_37,dom,_38,_39,_3a,all,_3b,_3c,has,_3d,don,_3e){new Date("X");function _3f(_40){return eval("("+_40+")");};var _41=0;_3a.after(_35,"extend",function(){_41++;},true);function _42(_43){var map=_43._nameCaseMap,_44=_43.prototype;if(!map||map._extendCnt<_41){map=_43._nameCaseMap={};for(var _45 in _44){if(_45.charAt(0)==="_"){continue;}map[_45.toLowerCase()]=_45;}map._extendCnt=_41;}return map;};function _46(_47,_48){if(!_48){_48=_33;}var _49=_48._dojoParserCtorMap||(_48._dojoParserCtorMap={});var ts=_47.join();if(!_49[ts]){var _4a=[];for(var i=0,l=_47.length;i<l;i++){var t=_47[i];_4a[_4a.length]=(_49[t]=_49[t]||(_35.getObject(t)||(~t.indexOf("/")&&_48(t))));}var _4b=_4a.shift();_49[ts]=_4a.length?(_4b.createSubclass?_4b.createSubclass(_4a):_4b.extend.apply(_4b,_4a)):_4b;}return _49[ts];};var _4c={_clearCache:function(){_41++;_ctorMap={};},_functionFromScript:function(_4d,_4e){var _4f="",_50="",_51=(_4d.getAttribute(_4e+"args")||_4d.getAttribute("args")),_52=_4d.getAttribute("with");var _53=(_51||"").split(/\s*,\s*/);if(_52&&_52.length){_36.forEach(_52.split(/\s*,\s*/),function(_54){_4f+="with("+_54+"){";_50+="}";});}return new Function(_53,_4f+_4d.innerHTML+_50);},instantiate:function(_55,_56,_57){_56=_56||{};_57=_57||{};var _58=(_57.scope||_34._scopeName)+"Type",_59="data-"+(_57.scope||_34._scopeName)+"-",_5a=_59+"type",_5b=_59+"mixins";var _5c=[];_36.forEach(_55,function(_5d){var _5e=_58 in _56?_56[_58]:_5d.getAttribute(_5a)||_5d.getAttribute(_58);if(_5e){var _5f=_5d.getAttribute(_5b),_60=_5f?[_5e].concat(_5f.split(/\s*,\s*/)):[_5e];_5c.push({node:_5d,types:_60});}});return this._instantiate(_5c,_56,_57);},_instantiate:function(_61,_62,_63,_64){var _65=_36.map(_61,function(obj){var _66=obj.ctor||_46(obj.types,_63.contextRequire);if(!_66){throw new Error("Unable to resolve constructor for: '"+obj.types.join()+"'");}return this.construct(_66,obj.node,_62,_63,obj.scripts,obj.inherited);},this);function _67(_68){if(!_62._started&&!_63.noStart){_36.forEach(_68,function(_69){if(typeof _69.startup==="function"&&!_69._started){_69.startup();}});}return _68;};if(_64){return all(_65).then(_67);}else{return _67(_65);}},construct:function(_6a,_6b,_6c,_6d,_6e,_6f){var _70=_6a&&_6a.prototype;_6d=_6d||{};var _71={};if(_6d.defaults){_35.mixin(_71,_6d.defaults);}if(_6f){_35.mixin(_71,_6f);}var _72;if(has("dom-attributes-explicit")){_72=_6b.attributes;}else{if(has("dom-attributes-specified-flag")){_72=_36.filter(_6b.attributes,function(a){return a.specified;});}else{var _73=/^input$|^img$/i.test(_6b.nodeName)?_6b:_6b.cloneNode(false),_74=_73.outerHTML.replace(/=[^\s"']+|="[^"]*"|='[^']*'/g,"").replace(/^\s*<[a-zA-Z0-9]*\s*/,"").replace(/\s*>.*$/,"");_72=_36.map(_74.split(/\s+/),function(_75){var _76=_75.toLowerCase();return {name:_75,value:(_6b.nodeName=="LI"&&_75=="value")||_76=="enctype"?_6b.getAttribute(_76):_6b.getAttributeNode(_76).value};});}}var _77=_6d.scope||_34._scopeName,_78="data-"+_77+"-",_79={};if(_77!=="dojo"){_79[_78+"props"]="data-dojo-props";_79[_78+"type"]="data-dojo-type";_79[_78+"mixins"]="data-dojo-mixins";_79[_77+"type"]="dojotype";_79[_78+"id"]="data-dojo-id";}var i=0,_7a,_7b=[],_7c,_7d;while(_7a=_72[i++]){var _7e=_7a.name,_7f=_7e.toLowerCase(),_80=_7a.value;switch(_79[_7f]||_7f){case "data-dojo-type":case "dojotype":case "data-dojo-mixins":break;case "data-dojo-props":_7d=_80;break;case "data-dojo-id":case "jsid":_7c=_80;break;case "data-dojo-attach-point":case "dojoattachpoint":_71.dojoAttachPoint=_80;break;case "data-dojo-attach-event":case "dojoattachevent":_71.dojoAttachEvent=_80;break;case "class":_71["class"]=_6b.className;break;case "style":_71["style"]=_6b.style&&_6b.style.cssText;break;default:if(!(_7e in _70)){var map=_42(_6a);_7e=map[_7f]||_7e;}if(_7e in _70){switch(typeof _70[_7e]){case "string":_71[_7e]=_80;break;case "number":_71[_7e]=_80.length?Number(_80):NaN;break;case "boolean":_71[_7e]=_80.toLowerCase()!="false";break;case "function":if(_80===""||_80.search(/[^\w\.]+/i)!=-1){_71[_7e]=new Function(_80);}else{_71[_7e]=_35.getObject(_80,false)||new Function(_80);}_7b.push(_7e);break;default:var _81=_70[_7e];_71[_7e]=(_81&&"length" in _81)?(_80?_80.split(/\s*,\s*/):[]):(_81 instanceof Date)?(_80==""?new Date(""):_80=="now"?new Date():_3b.fromISOString(_80)):(_81 instanceof _39)?(_34.baseUrl+_80):_3f(_80);}}else{_71[_7e]=_80;}}}for(var j=0;j<_7b.length;j++){var _82=_7b[j].toLowerCase();_6b.removeAttribute(_82);_6b[_82]=null;}if(_7d){try{_7d=_3f.call(_6d.propsThis,"{"+_7d+"}");_35.mixin(_71,_7d);}catch(e){throw new Error(e.toString()+" in data-dojo-props='"+_7d+"'");}}_35.mixin(_71,_6c);if(!_6e){_6e=(_6a&&(_6a._noScript||_70._noScript)?[]:_3d("> script[type^='dojo/']",_6b));}var _83=[],_84=[],_85=[],ons=[];if(_6e){for(i=0;i<_6e.length;i++){var _86=_6e[i];_6b.removeChild(_86);var _87=(_86.getAttribute(_78+"event")||_86.getAttribute("event")),_88=_86.getAttribute(_78+"prop"),_89=_86.getAttribute(_78+"method"),_8a=_86.getAttribute(_78+"advice"),_8b=_86.getAttribute("type"),nf=this._functionFromScript(_86,_78);if(_87){if(_8b=="dojo/connect"){_83.push({method:_87,func:nf});}else{if(_8b=="dojo/on"){ons.push({event:_87,func:nf});}else{_71[_87]=nf;}}}else{if(_8b=="dojo/aspect"){_83.push({method:_89,advice:_8a,func:nf});}else{if(_8b=="dojo/watch"){_85.push({prop:_88,func:nf});}else{_84.push(nf);}}}}}var _8c=_6a.markupFactory||_70.markupFactory;var _8d=_8c?_8c(_71,_6b,_6a):new _6a(_71,_6b);function _8e(_8f){if(_7c){_35.setObject(_7c,_8f);}for(i=0;i<_83.length;i++){_3a[_83[i].advice||"after"](_8f,_83[i].method,_35.hitch(_8f,_83[i].func),true);}for(i=0;i<_84.length;i++){_84[i].call(_8f);}for(i=0;i<_85.length;i++){_8f.watch(_85[i].prop,_85[i].func);}for(i=0;i<ons.length;i++){don(_8f,ons[i].event,ons[i].func);}return _8f;};if(_8d.then){return _8d.then(_8e);}else{return _8e(_8d);}},scan:function(_90,_91){var _92=[],_93=[],_94={};var _95=(_91.scope||_34._scopeName)+"Type",_96="data-"+(_91.scope||_34._scopeName)+"-",_97=_96+"type",_98=_96+"textdir",_99=_96+"mixins";var _9a=_90.firstChild;var _9b=_91.inherited;if(!_9b){function _9c(_9d,_9e){return (_9d.getAttribute&&_9d.getAttribute(_9e))||(_9d.parentNode&&_9c(_9d.parentNode,_9e));};_9b={dir:_9c(_90,"dir"),lang:_9c(_90,"lang"),textDir:_9c(_90,_98)};for(var key in _9b){if(!_9b[key]){delete _9b[key];}}}var _9f={inherited:_9b};var _a0;var _a1;function _a2(_a3){if(!_a3.inherited){_a3.inherited={};var _a4=_a3.node,_a5=_a2(_a3.parent);var _a6={dir:_a4.getAttribute("dir")||_a5.dir,lang:_a4.getAttribute("lang")||_a5.lang,textDir:_a4.getAttribute(_98)||_a5.textDir};for(var key in _a6){if(_a6[key]){_a3.inherited[key]=_a6[key];}}}return _a3.inherited;};while(true){if(!_9a){if(!_9f||!_9f.node){break;}_9a=_9f.node.nextSibling;_a1=false;_9f=_9f.parent;_a0=_9f.scripts;continue;}if(_9a.nodeType!=1){_9a=_9a.nextSibling;continue;}if(_a0&&_9a.nodeName.toLowerCase()=="script"){_a7=_9a.getAttribute("type");if(_a7&&/^dojo\/\w/i.test(_a7)){_a0.push(_9a);}_9a=_9a.nextSibling;continue;}if(_a1){_9a=_9a.nextSibling;continue;}var _a7=_9a.getAttribute(_97)||_9a.getAttribute(_95);var _a8=_9a.firstChild;if(!_a7&&(!_a8||(_a8.nodeType==3&&!_a8.nextSibling))){_9a=_9a.nextSibling;continue;}var _a9;var _aa=null;if(_a7){var _ab=_9a.getAttribute(_99),_ac=_ab?[_a7].concat(_ab.split(/\s*,\s*/)):[_a7];try{_aa=_46(_ac,_91.contextRequire);}catch(e){}if(!_aa){_36.forEach(_ac,function(t){if(~t.indexOf("/")&&!_94[t]){_94[t]=true;_93[_93.length]=t;}});}var _ad=_aa&&!_aa.prototype._noScript?[]:null;_a9={types:_ac,ctor:_aa,parent:_9f,node:_9a,scripts:_ad};_a9.inherited=_a2(_a9);_92.push(_a9);}else{_a9={node:_9a,scripts:_a0,parent:_9f};}_a0=_ad;_a1=_9a.stopParser||(_aa&&_aa.prototype.stopParser&&!(_91.template));_9f=_a9;_9a=_a8;}var d=new _3c();if(_93.length){if(has("dojo-debug-messages")){console.warn("WARNING: Modules being Auto-Required: "+_93.join(", "));}var r=_91.contextRequire||_33;r(_93,function(){d.resolve(_36.filter(_92,function(_ae){if(!_ae.ctor){try{_ae.ctor=_46(_ae.types,_91.contextRequire);}catch(e){}}var _af=_ae.parent;while(_af&&!_af.types){_af=_af.parent;}var _b0=_ae.ctor&&_ae.ctor.prototype;_ae.instantiateChildren=!(_b0&&_b0.stopParser&&!(_91.template));_ae.instantiate=!_af||(_af.instantiate&&_af.instantiateChildren);return _ae.instantiate;}));});}else{d.resolve(_92);}return d.promise;},_require:function(_b1,_b2){var _b3=_3f("{"+_b1.innerHTML+"}"),_b4=[],_b5=[],d=new _3c();var _b6=(_b2&&_b2.contextRequire)||_33;for(var _b7 in _b3){_b4.push(_b7);_b5.push(_b3[_b7]);}_b6(_b5,function(){for(var i=0;i<_b4.length;i++){_35.setObject(_b4[i],arguments[i]);}d.resolve(arguments);});return d.promise;},_scanAmd:function(_b8,_b9){var _ba=new _3c(),_bb=_ba.promise;_ba.resolve(true);var _bc=this;_3d("script[type='dojo/require']",_b8).forEach(function(_bd){_bb=_bb.then(function(){return _bc._require(_bd,_b9);});_bd.parentNode.removeChild(_bd);});return _bb;},parse:function(_be,_bf){if(_be&&typeof _be!="string"&&!("nodeType" in _be)){_bf=_be;_be=_bf.rootNode;}var _c0=_be?dom.byId(_be):_38.body();_bf=_bf||{};var _c1=_bf.template?{template:true}:{},_c2=[],_c3=this;var p=this._scanAmd(_c0,_bf).then(function(){return _c3.scan(_c0,_bf);}).then(function(_c4){return _c3._instantiate(_c4,_c1,_bf,true);}).then(function(_c5){return _c2=_c2.concat(_c5);}).otherwise(function(e){console.error("dojo/parser::parse() error",e);throw e;});_35.mixin(_c2,p);return _c2;}};if(1){_34.parser=_4c;}if(_37.parseOnLoad){_3e(100,_4c,"parse");}return _4c;});},"dojo/promise/all":function(){define(["../_base/array","../_base/lang","../Deferred","../when"],function(_c6,_c7,_c8,_c9){"use strict";var _ca=_c6.some;return function all(_cb){var _cc,_c6;if(_c7.isArray(_cb)){_c6=_cb;}else{if(_cb&&typeof _cb==="object"){_cc=_cb;}}var _cd;var _ce=[];if(_cc){_c6=[];for(var key in _cc){if(Object.hasOwnProperty.call(_cc,key)){_ce.push(key);_c6.push(_cc[key]);}}_cd={};}else{if(_c6){_cd=[];}}if(!_c6||!_c6.length){return new _c8().resolve(_cd);}var _cf=new _c8();_cf.promise.always(function(){_cd=_ce=null;});var _d0=_c6.length;_ca(_c6,function(_d1,_d2){if(!_cc){_ce.push(_d2);}_c9(_d1,function(_d3){if(!_cf.isFulfilled()){_cd[_ce[_d2]]=_d3;if(--_d0===0){_cf.resolve(_cd);}}},_cf.reject);return _cf.isFulfilled();});return _cf.promise;};});},"dojo/date/stamp":function(){define(["../_base/lang","../_base/array"],function(_d4,_d5){var _d6={};_d4.setObject("dojo.date.stamp",_d6);_d6.fromISOString=function(_d7,_d8){if(!_d6._isoRegExp){_d6._isoRegExp=/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?((?:[+-](\d{2}):(\d{2}))|Z)?)?$/;}var _d9=_d6._isoRegExp.exec(_d7),_da=null;if(_d9){_d9.shift();if(_d9[1]){_d9[1]--;}if(_d9[6]){_d9[6]*=1000;}if(_d8){_d8=new Date(_d8);_d5.forEach(_d5.map(["FullYear","Month","Date","Hours","Minutes","Seconds","Milliseconds"],function(_db){return _d8["get"+_db]();}),function(_dc,_dd){_d9[_dd]=_d9[_dd]||_dc;});}_da=new Date(_d9[0]||1970,_d9[1]||0,_d9[2]||1,_d9[3]||0,_d9[4]||0,_d9[5]||0,_d9[6]||0);if(_d9[0]<100){_da.setFullYear(_d9[0]||1970);}var _de=0,_df=_d9[7]&&_d9[7].charAt(0);if(_df!="Z"){_de=((_d9[8]||0)*60)+(Number(_d9[9])||0);if(_df!="-"){_de*=-1;}}if(_df){_de-=_da.getTimezoneOffset();}if(_de){_da.setTime(_da.getTime()+_de*60000);}}return _da;};_d6.toISOString=function(_e0,_e1){var _e2=function(n){return (n<10)?"0"+n:n;};_e1=_e1||{};var _e3=[],_e4=_e1.zulu?"getUTC":"get",_e5="";if(_e1.selector!="time"){var _e6=_e0[_e4+"FullYear"]();_e5=["0000".substr((_e6+"").length)+_e6,_e2(_e0[_e4+"Month"]()+1),_e2(_e0[_e4+"Date"]())].join("-");}_e3.push(_e5);if(_e1.selector!="date"){var _e7=[_e2(_e0[_e4+"Hours"]()),_e2(_e0[_e4+"Minutes"]()),_e2(_e0[_e4+"Seconds"]())].join(":");var _e8=_e0[_e4+"Milliseconds"]();if(_e1.milliseconds){_e7+="."+(_e8<100?"0":"")+_e2(_e8);}if(_e1.zulu){_e7+="Z";}else{if(_e1.selector!="time"){var _e9=_e0.getTimezoneOffset();var _ea=Math.abs(_e9);_e7+=(_e9>0?"-":"+")+_e2(Math.floor(_ea/60))+":"+_e2(_ea%60);}}_e3.push(_e7);}return _e3.join("T");};return _d6;});},"dojo/node":function(){define(["./_base/kernel","./has","require"],function(_eb,has,_ec){var _ed=_eb.global.require&&_eb.global.require.nodeRequire;if(!_ed){throw new Error("Cannot find the Node.js require");}var _ee=_ed("module");return {load:function(id,_ef,_f0){if(_ee._findPath&&_ee._nodeModulePaths){var _f1=_ee._findPath(id,_ee._nodeModulePaths(_ef.toUrl(".")));if(_f1!==false){id=_f1;}}var _f2=define,_f3;define=undefined;try{_f3=_ed(id);}finally{define=_f2;}_f0(_f3);},normalize:function(id,_f4){if(id.charAt(0)==="."){id=_ec.toUrl(_f4("./"+id));}return id;}};});},"dojo/data/ItemFileWriteStore":function(){define(["../_base/lang","../_base/declare","../_base/array","../_base/json","../_base/kernel","./ItemFileReadStore","../date/stamp"],function(_f5,_f6,_f7,_f8,_f9,_fa,_fb){return _f6("dojo.data.ItemFileWriteStore",_fa,{constructor:function(_fc){this._features["dojo.data.api.Write"]=true;this._features["dojo.data.api.Notification"]=true;this._pending={_newItems:{},_modifiedItems:{},_deletedItems:{}};if(!this._datatypeMap["Date"].serialize){this._datatypeMap["Date"].serialize=function(obj){return _fb.toISOString(obj,{zulu:true});};}if(_fc&&(_fc.referenceIntegrity===false)){this.referenceIntegrity=false;}this._saveInProgress=false;},referenceIntegrity:true,_assert:function(_fd){if(!_fd){throw new Error("assertion failed in ItemFileWriteStore");}},_getIdentifierAttribute:function(){return this.getFeatures()["dojo.data.api.Identity"];},newItem:function(_fe,_ff){this._assert(!this._saveInProgress);if(!this._loadFinished){this._forceLoad();}if(typeof _fe!="object"&&typeof _fe!="undefined"){throw new Error("newItem() was passed something other than an object");}var _100=null;var _101=this._getIdentifierAttribute();if(_101===Number){_100=this._arrayOfAllItems.length;}else{_100=_fe[_101];if(typeof _100==="undefined"){throw new Error("newItem() was not passed an identity for the new item");}if(_f5.isArray(_100)){throw new Error("newItem() was not passed an single-valued identity");}}if(this._itemsByIdentity){this._assert(typeof this._itemsByIdentity[_100]==="undefined");}this._assert(typeof this._pending._newItems[_100]==="undefined");this._assert(typeof this._pending._deletedItems[_100]==="undefined");var _102={};_102[this._storeRefPropName]=this;_102[this._itemNumPropName]=this._arrayOfAllItems.length;if(this._itemsByIdentity){this._itemsByIdentity[_100]=_102;_102[_101]=[_100];}this._arrayOfAllItems.push(_102);var _103=null;if(_ff&&_ff.parent&&_ff.attribute){_103={item:_ff.parent,attribute:_ff.attribute,oldValue:undefined};var _104=this.getValues(_ff.parent,_ff.attribute);if(_104&&_104.length>0){var _105=_104.slice(0,_104.length);if(_104.length===1){_103.oldValue=_104[0];}else{_103.oldValue=_104.slice(0,_104.length);}_105.push(_102);this._setValueOrValues(_ff.parent,_ff.attribute,_105,false);_103.newValue=this.getValues(_ff.parent,_ff.attribute);}else{this._setValueOrValues(_ff.parent,_ff.attribute,_102,false);_103.newValue=_102;}}else{_102[this._rootItemPropName]=true;this._arrayOfTopLevelItems.push(_102);}this._pending._newItems[_100]=_102;for(var key in _fe){if(key===this._storeRefPropName||key===this._itemNumPropName){throw new Error("encountered bug in ItemFileWriteStore.newItem");}var _106=_fe[key];if(!_f5.isArray(_106)){_106=[_106];}_102[key]=_106;if(this.referenceIntegrity){for(var i=0;i<_106.length;i++){var val=_106[i];if(this.isItem(val)){this._addReferenceToMap(val,_102,key);}}}}this.onNew(_102,_103);return _102;},_removeArrayElement:function(_107,_108){var _109=_f7.indexOf(_107,_108);if(_109!=-1){_107.splice(_109,1);return true;}return false;},deleteItem:function(item){this._assert(!this._saveInProgress);this._assertIsItem(item);var _10a=item[this._itemNumPropName];var _10b=this.getIdentity(item);if(this.referenceIntegrity){var _10c=this.getAttributes(item);if(item[this._reverseRefMap]){item["backup_"+this._reverseRefMap]=_f5.clone(item[this._reverseRefMap]);}_f7.forEach(_10c,function(_10d){_f7.forEach(this.getValues(item,_10d),function(_10e){if(this.isItem(_10e)){if(!item["backupRefs_"+this._reverseRefMap]){item["backupRefs_"+this._reverseRefMap]=[];}item["backupRefs_"+this._reverseRefMap].push({id:this.getIdentity(_10e),attr:_10d});this._removeReferenceFromMap(_10e,item,_10d);}},this);},this);var _10f=item[this._reverseRefMap];if(_10f){for(var _110 in _10f){var _111=null;if(this._itemsByIdentity){_111=this._itemsByIdentity[_110];}else{_111=this._arrayOfAllItems[_110];}if(_111){for(var _112 in _10f[_110]){var _113=this.getValues(_111,_112)||[];var _114=_f7.filter(_113,function(_115){return !(this.isItem(_115)&&this.getIdentity(_115)==_10b);},this);this._removeReferenceFromMap(item,_111,_112);if(_114.length<_113.length){this._setValueOrValues(_111,_112,_114,true);}}}}}}this._arrayOfAllItems[_10a]=null;item[this._storeRefPropName]=null;if(this._itemsByIdentity){delete this._itemsByIdentity[_10b];}this._pending._deletedItems[_10b]=item;if(item[this._rootItemPropName]){this._removeArrayElement(this._arrayOfTopLevelItems,item);}this.onDelete(item);return true;},setValue:function(item,_116,_117){return this._setValueOrValues(item,_116,_117,true);},setValues:function(item,_118,_119){return this._setValueOrValues(item,_118,_119,true);},unsetAttribute:function(item,_11a){return this._setValueOrValues(item,_11a,[],true);},_setValueOrValues:function(item,_11b,_11c,_11d){this._assert(!this._saveInProgress);this._assertIsItem(item);this._assert(_f5.isString(_11b));this._assert(typeof _11c!=="undefined");var _11e=this._getIdentifierAttribute();if(_11b==_11e){throw new Error("ItemFileWriteStore does not have support for changing the value of an item's identifier.");}var _11f=this._getValueOrValues(item,_11b);var _120=this.getIdentity(item);if(!this._pending._modifiedItems[_120]){var _121={};for(var key in item){if((key===this._storeRefPropName)||(key===this._itemNumPropName)||(key===this._rootItemPropName)){_121[key]=item[key];}else{if(key===this._reverseRefMap){_121[key]=_f5.clone(item[key]);}else{_121[key]=item[key].slice(0,item[key].length);}}}this._pending._modifiedItems[_120]=_121;}var _122=false;if(_f5.isArray(_11c)&&_11c.length===0){_122=delete item[_11b];_11c=undefined;if(this.referenceIntegrity&&_11f){var _123=_11f;if(!_f5.isArray(_123)){_123=[_123];}for(var i=0;i<_123.length;i++){var _124=_123[i];if(this.isItem(_124)){this._removeReferenceFromMap(_124,item,_11b);}}}}else{var _125;if(_f5.isArray(_11c)){_125=_11c.slice(0,_11c.length);}else{_125=[_11c];}if(this.referenceIntegrity){if(_11f){var _123=_11f;if(!_f5.isArray(_123)){_123=[_123];}var map={};_f7.forEach(_123,function(_126){if(this.isItem(_126)){var id=this.getIdentity(_126);map[id.toString()]=true;}},this);_f7.forEach(_125,function(_127){if(this.isItem(_127)){var id=this.getIdentity(_127);if(map[id.toString()]){delete map[id.toString()];}else{this._addReferenceToMap(_127,item,_11b);}}},this);for(var rId in map){var _128;if(this._itemsByIdentity){_128=this._itemsByIdentity[rId];}else{_128=this._arrayOfAllItems[rId];}this._removeReferenceFromMap(_128,item,_11b);}}else{for(var i=0;i<_125.length;i++){var _124=_125[i];if(this.isItem(_124)){this._addReferenceToMap(_124,item,_11b);}}}}item[_11b]=_125;_122=true;}if(_11d){this.onSet(item,_11b,_11f,_11c);}return _122;},_addReferenceToMap:function(_129,_12a,_12b){var _12c=this.getIdentity(_12a);var _12d=_129[this._reverseRefMap];if(!_12d){_12d=_129[this._reverseRefMap]={};}var _12e=_12d[_12c];if(!_12e){_12e=_12d[_12c]={};}_12e[_12b]=true;},_removeReferenceFromMap:function(_12f,_130,_131){var _132=this.getIdentity(_130);var _133=_12f[this._reverseRefMap];var _134;if(_133){for(_134 in _133){if(_134==_132){delete _133[_134][_131];if(this._isEmpty(_133[_134])){delete _133[_134];}}}if(this._isEmpty(_133)){delete _12f[this._reverseRefMap];}}},_dumpReferenceMap:function(){var i;for(i=0;i<this._arrayOfAllItems.length;i++){var item=this._arrayOfAllItems[i];if(item&&item[this._reverseRefMap]){}}},_getValueOrValues:function(item,_135){var _136=undefined;if(this.hasAttribute(item,_135)){var _137=this.getValues(item,_135);if(_137.length==1){_136=_137[0];}else{_136=_137;}}return _136;},_flatten:function(_138){if(this.isItem(_138)){return {_reference:this.getIdentity(_138)};}else{if(typeof _138==="object"){for(var type in this._datatypeMap){var _139=this._datatypeMap[type];if(_f5.isObject(_139)&&!_f5.isFunction(_139)){if(_138 instanceof _139.type){if(!_139.serialize){throw new Error("ItemFileWriteStore:  No serializer defined for type mapping: ["+type+"]");}return {_type:type,_value:_139.serialize(_138)};}}else{if(_138 instanceof _139){return {_type:type,_value:_138.toString()};}}}}return _138;}},_getNewFileContentString:function(){var _13a={};var _13b=this._getIdentifierAttribute();if(_13b!==Number){_13a.identifier=_13b;}if(this._labelAttr){_13a.label=this._labelAttr;}_13a.items=[];for(var i=0;i<this._arrayOfAllItems.length;++i){var item=this._arrayOfAllItems[i];if(item!==null){var _13c={};for(var key in item){if(key!==this._storeRefPropName&&key!==this._itemNumPropName&&key!==this._reverseRefMap&&key!==this._rootItemPropName){var _13d=this.getValues(item,key);if(_13d.length==1){_13c[key]=this._flatten(_13d[0]);}else{var _13e=[];for(var j=0;j<_13d.length;++j){_13e.push(this._flatten(_13d[j]));_13c[key]=_13e;}}}}_13a.items.push(_13c);}}var _13f=true;return _f8.toJson(_13a,_13f);},_isEmpty:function(_140){var _141=true;if(_f5.isObject(_140)){var i;for(i in _140){_141=false;break;}}else{if(_f5.isArray(_140)){if(_140.length>0){_141=false;}}}return _141;},save:function(_142){this._assert(!this._saveInProgress);this._saveInProgress=true;var self=this;var _143=function(){self._pending={_newItems:{},_modifiedItems:{},_deletedItems:{}};self._saveInProgress=false;if(_142&&_142.onComplete){var _144=_142.scope||_f9.global;_142.onComplete.call(_144);}};var _145=function(err){self._saveInProgress=false;if(_142&&_142.onError){var _146=_142.scope||_f9.global;_142.onError.call(_146,err);}};if(this._saveEverything){var _147=this._getNewFileContentString();this._saveEverything(_143,_145,_147);}if(this._saveCustom){this._saveCustom(_143,_145);}if(!this._saveEverything&&!this._saveCustom){_143();}},revert:function(){this._assert(!this._saveInProgress);var _148;for(_148 in this._pending._modifiedItems){var _149=this._pending._modifiedItems[_148];var _14a=null;if(this._itemsByIdentity){_14a=this._itemsByIdentity[_148];}else{_14a=this._arrayOfAllItems[_148];}_149[this._storeRefPropName]=this;for(var key in _14a){delete _14a[key];}_f5.mixin(_14a,_149);}var _14b;for(_148 in this._pending._deletedItems){_14b=this._pending._deletedItems[_148];_14b[this._storeRefPropName]=this;var _14c=_14b[this._itemNumPropName];if(_14b["backup_"+this._reverseRefMap]){_14b[this._reverseRefMap]=_14b["backup_"+this._reverseRefMap];delete _14b["backup_"+this._reverseRefMap];}this._arrayOfAllItems[_14c]=_14b;if(this._itemsByIdentity){this._itemsByIdentity[_148]=_14b;}if(_14b[this._rootItemPropName]){this._arrayOfTopLevelItems.push(_14b);}}for(_148 in this._pending._deletedItems){_14b=this._pending._deletedItems[_148];if(_14b["backupRefs_"+this._reverseRefMap]){_f7.forEach(_14b["backupRefs_"+this._reverseRefMap],function(_14d){var _14e;if(this._itemsByIdentity){_14e=this._itemsByIdentity[_14d.id];}else{_14e=this._arrayOfAllItems[_14d.id];}this._addReferenceToMap(_14e,_14b,_14d.attr);},this);delete _14b["backupRefs_"+this._reverseRefMap];}}for(_148 in this._pending._newItems){var _14f=this._pending._newItems[_148];_14f[this._storeRefPropName]=null;this._arrayOfAllItems[_14f[this._itemNumPropName]]=null;if(_14f[this._rootItemPropName]){this._removeArrayElement(this._arrayOfTopLevelItems,_14f);}if(this._itemsByIdentity){delete this._itemsByIdentity[_148];}}this._pending={_newItems:{},_modifiedItems:{},_deletedItems:{}};return true;},isDirty:function(item){if(item){var _150=this.getIdentity(item);return new Boolean(this._pending._newItems[_150]||this._pending._modifiedItems[_150]||this._pending._deletedItems[_150]).valueOf();}else{return !this._isEmpty(this._pending._newItems)||!this._isEmpty(this._pending._modifiedItems)||!this._isEmpty(this._pending._deletedItems);}},onSet:function(item,_151,_152,_153){},onNew:function(_154,_155){},onDelete:function(_156){},close:function(_157){if(this.clearOnClose){if(!this.isDirty()){this.inherited(arguments);}else{throw new Error("dojo.data.ItemFileWriteStore: There are unsaved changes present in the store.  Please save or revert the changes before invoking close.");}}}});});},"dojo/data/ItemFileReadStore":function(){define(["../_base/kernel","../_base/lang","../_base/declare","../_base/array","../_base/xhr","../Evented","./util/filter","./util/simpleFetch","../date/stamp"],function(_158,lang,_159,_15a,xhr,_15b,_15c,_15d,_15e){var _15f=_159("dojo.data.ItemFileReadStore",[_15b],{constructor:function(_160){this._arrayOfAllItems=[];this._arrayOfTopLevelItems=[];this._loadFinished=false;this._jsonFileUrl=_160.url;this._ccUrl=_160.url;this.url=_160.url;this._jsonData=_160.data;this.data=null;this._datatypeMap=_160.typeMap||{};if(!this._datatypeMap["Date"]){this._datatypeMap["Date"]={type:Date,deserialize:function(_161){return _15e.fromISOString(_161);}};}this._features={"dojo.data.api.Read":true,"dojo.data.api.Identity":true};this._itemsByIdentity=null;this._storeRefPropName="_S";this._itemNumPropName="_0";this._rootItemPropName="_RI";this._reverseRefMap="_RRM";this._loadInProgress=false;this._queuedFetches=[];if(_160.urlPreventCache!==undefined){this.urlPreventCache=_160.urlPreventCache?true:false;}if(_160.hierarchical!==undefined){this.hierarchical=_160.hierarchical?true:false;}if(_160.clearOnClose){this.clearOnClose=true;}if("failOk" in _160){this.failOk=_160.failOk?true:false;}},url:"",_ccUrl:"",data:null,typeMap:null,clearOnClose:false,urlPreventCache:false,failOk:false,hierarchical:true,_assertIsItem:function(item){if(!this.isItem(item)){throw new Error(this.declaredClass+": Invalid item argument.");}},_assertIsAttribute:function(_162){if(typeof _162!=="string"){throw new Error(this.declaredClass+": Invalid attribute argument.");}},getValue:function(item,_163,_164){var _165=this.getValues(item,_163);return (_165.length>0)?_165[0]:_164;},getValues:function(item,_166){this._assertIsItem(item);this._assertIsAttribute(_166);return (item[_166]||[]).slice(0);},getAttributes:function(item){this._assertIsItem(item);var _167=[];for(var key in item){if((key!==this._storeRefPropName)&&(key!==this._itemNumPropName)&&(key!==this._rootItemPropName)&&(key!==this._reverseRefMap)){_167.push(key);}}return _167;},hasAttribute:function(item,_168){this._assertIsItem(item);this._assertIsAttribute(_168);return (_168 in item);},containsValue:function(item,_169,_16a){var _16b=undefined;if(typeof _16a==="string"){_16b=_15c.patternToRegExp(_16a,false);}return this._containsValue(item,_169,_16a,_16b);},_containsValue:function(item,_16c,_16d,_16e){return _15a.some(this.getValues(item,_16c),function(_16f){if(_16f!==null&&!lang.isObject(_16f)&&_16e){if(_16f.toString().match(_16e)){return true;}}else{if(_16d===_16f){return true;}}});},isItem:function(_170){if(_170&&_170[this._storeRefPropName]===this){if(this._arrayOfAllItems[_170[this._itemNumPropName]]===_170){return true;}}return false;},isItemLoaded:function(_171){return this.isItem(_171);},loadItem:function(_172){this._assertIsItem(_172.item);},getFeatures:function(){return this._features;},getLabel:function(item){if(this._labelAttr&&this.isItem(item)){return this.getValue(item,this._labelAttr);}return undefined;},getLabelAttributes:function(item){if(this._labelAttr){return [this._labelAttr];}return null;},filter:function(_173,_174,_175){var _176=[],i,key;if(_173.query){var _177,_178=_173.queryOptions?_173.queryOptions.ignoreCase:false;var _179={};for(key in _173.query){_177=_173.query[key];if(typeof _177==="string"){_179[key]=_15c.patternToRegExp(_177,_178);}else{if(_177 instanceof RegExp){_179[key]=_177;}}}for(i=0;i<_174.length;++i){var _17a=true;var _17b=_174[i];if(_17b===null){_17a=false;}else{for(key in _173.query){_177=_173.query[key];if(!this._containsValue(_17b,key,_177,_179[key])){_17a=false;}}}if(_17a){_176.push(_17b);}}_175(_176,_173);}else{for(i=0;i<_174.length;++i){var item=_174[i];if(item!==null){_176.push(item);}}_175(_176,_173);}},_fetchItems:function(_17c,_17d,_17e){var self=this;if(this._loadFinished){this.filter(_17c,this._getItemsArray(_17c.queryOptions),_17d);}else{if(this._jsonFileUrl!==this._ccUrl){_158.deprecated(this.declaredClass+": ","To change the url, set the url property of the store,"+" not _jsonFileUrl.  _jsonFileUrl support will be removed in 2.0");this._ccUrl=this._jsonFileUrl;this.url=this._jsonFileUrl;}else{if(this.url!==this._ccUrl){this._jsonFileUrl=this.url;this._ccUrl=this.url;}}if(this.data!=null){this._jsonData=this.data;this.data=null;}if(this._jsonFileUrl){if(this._loadInProgress){this._queuedFetches.push({args:_17c,filter:lang.hitch(self,"filter"),findCallback:lang.hitch(self,_17d)});}else{this._loadInProgress=true;var _17f={url:self._jsonFileUrl,handleAs:"json-comment-optional",preventCache:this.urlPreventCache,failOk:this.failOk};var _180=xhr.get(_17f);_180.addCallback(function(data){try{self._getItemsFromLoadedData(data);self._loadFinished=true;self._loadInProgress=false;self.filter(_17c,self._getItemsArray(_17c.queryOptions),_17d);self._handleQueuedFetches();}catch(e){self._loadFinished=true;self._loadInProgress=false;_17e(e,_17c);}});_180.addErrback(function(_181){self._loadInProgress=false;_17e(_181,_17c);});var _182=null;if(_17c.abort){_182=_17c.abort;}_17c.abort=function(){var df=_180;if(df&&df.fired===-1){df.cancel();df=null;}if(_182){_182.call(_17c);}};}}else{if(this._jsonData){try{this._loadFinished=true;this._getItemsFromLoadedData(this._jsonData);this._jsonData=null;self.filter(_17c,this._getItemsArray(_17c.queryOptions),_17d);}catch(e){_17e(e,_17c);}}else{_17e(new Error(this.declaredClass+": No JSON source data was provided as either URL or a nested Javascript object."),_17c);}}}},_handleQueuedFetches:function(){if(this._queuedFetches.length>0){for(var i=0;i<this._queuedFetches.length;i++){var _183=this._queuedFetches[i],_184=_183.args,_185=_183.filter,_186=_183.findCallback;if(_185){_185(_184,this._getItemsArray(_184.queryOptions),_186);}else{this.fetchItemByIdentity(_184);}}this._queuedFetches=[];}},_getItemsArray:function(_187){if(_187&&_187.deep){return this._arrayOfAllItems;}return this._arrayOfTopLevelItems;},close:function(_188){if(this.clearOnClose&&this._loadFinished&&!this._loadInProgress){if(((this._jsonFileUrl==""||this._jsonFileUrl==null)&&(this.url==""||this.url==null))&&this.data==null){}this._arrayOfAllItems=[];this._arrayOfTopLevelItems=[];this._loadFinished=false;this._itemsByIdentity=null;this._loadInProgress=false;this._queuedFetches=[];}},_getItemsFromLoadedData:function(_189){var _18a=false,self=this;function _18b(_18c){return (_18c!==null)&&(typeof _18c==="object")&&(!lang.isArray(_18c)||_18a)&&(!lang.isFunction(_18c))&&(_18c.constructor==Object||lang.isArray(_18c))&&(typeof _18c._reference==="undefined")&&(typeof _18c._type==="undefined")&&(typeof _18c._value==="undefined")&&self.hierarchical;};function _18d(_18e){self._arrayOfAllItems.push(_18e);for(var _18f in _18e){var _190=_18e[_18f];if(_190){if(lang.isArray(_190)){var _191=_190;for(var k=0;k<_191.length;++k){var _192=_191[k];if(_18b(_192)){_18d(_192);}}}else{if(_18b(_190)){_18d(_190);}}}}};this._labelAttr=_189.label;var i,item;this._arrayOfAllItems=[];this._arrayOfTopLevelItems=_189.items;for(i=0;i<this._arrayOfTopLevelItems.length;++i){item=this._arrayOfTopLevelItems[i];if(lang.isArray(item)){_18a=true;}_18d(item);item[this._rootItemPropName]=true;}var _193={},key;for(i=0;i<this._arrayOfAllItems.length;++i){item=this._arrayOfAllItems[i];for(key in item){if(key!==this._rootItemPropName){var _194=item[key];if(_194!==null){if(!lang.isArray(_194)){item[key]=[_194];}}else{item[key]=[null];}}_193[key]=key;}}while(_193[this._storeRefPropName]){this._storeRefPropName+="_";}while(_193[this._itemNumPropName]){this._itemNumPropName+="_";}while(_193[this._reverseRefMap]){this._reverseRefMap+="_";}var _195;var _196=_189.identifier;if(_196){this._itemsByIdentity={};this._features["dojo.data.api.Identity"]=_196;for(i=0;i<this._arrayOfAllItems.length;++i){item=this._arrayOfAllItems[i];_195=item[_196];var _197=_195[0];if(!Object.hasOwnProperty.call(this._itemsByIdentity,_197)){this._itemsByIdentity[_197]=item;}else{if(this._jsonFileUrl){throw new Error(this.declaredClass+":  The json data as specified by: ["+this._jsonFileUrl+"] is malformed.  Items within the list have identifier: ["+_196+"].  Value collided: ["+_197+"]");}else{if(this._jsonData){throw new Error(this.declaredClass+":  The json data provided by the creation arguments is malformed.  Items within the list have identifier: ["+_196+"].  Value collided: ["+_197+"]");}}}}}else{this._features["dojo.data.api.Identity"]=Number;}for(i=0;i<this._arrayOfAllItems.length;++i){item=this._arrayOfAllItems[i];item[this._storeRefPropName]=this;item[this._itemNumPropName]=i;}for(i=0;i<this._arrayOfAllItems.length;++i){item=this._arrayOfAllItems[i];for(key in item){_195=item[key];for(var j=0;j<_195.length;++j){_194=_195[j];if(_194!==null&&typeof _194=="object"){if(("_type" in _194)&&("_value" in _194)){var type=_194._type;var _198=this._datatypeMap[type];if(!_198){throw new Error("dojo.data.ItemFileReadStore: in the typeMap constructor arg, no object class was specified for the datatype '"+type+"'");}else{if(lang.isFunction(_198)){_195[j]=new _198(_194._value);}else{if(lang.isFunction(_198.deserialize)){_195[j]=_198.deserialize(_194._value);}else{throw new Error("dojo.data.ItemFileReadStore: Value provided in typeMap was neither a constructor, nor a an object with a deserialize function");}}}}if(_194._reference){var _199=_194._reference;if(!lang.isObject(_199)){_195[j]=this._getItemByIdentity(_199);}else{for(var k=0;k<this._arrayOfAllItems.length;++k){var _19a=this._arrayOfAllItems[k],_19b=true;for(var _19c in _199){if(_19a[_19c]!=_199[_19c]){_19b=false;}}if(_19b){_195[j]=_19a;}}}if(this.referenceIntegrity){var _19d=_195[j];if(this.isItem(_19d)){this._addReferenceToMap(_19d,item,key);}}}else{if(this.isItem(_194)){if(this.referenceIntegrity){this._addReferenceToMap(_194,item,key);}}}}}}}},_addReferenceToMap:function(_19e,_19f,_1a0){},getIdentity:function(item){var _1a1=this._features["dojo.data.api.Identity"];if(_1a1===Number){return item[this._itemNumPropName];}else{var _1a2=item[_1a1];if(_1a2){return _1a2[0];}}return null;},fetchItemByIdentity:function(_1a3){var item,_1a4;if(!this._loadFinished){var self=this;if(this._jsonFileUrl!==this._ccUrl){_158.deprecated(this.declaredClass+": ","To change the url, set the url property of the store,"+" not _jsonFileUrl.  _jsonFileUrl support will be removed in 2.0");this._ccUrl=this._jsonFileUrl;this.url=this._jsonFileUrl;}else{if(this.url!==this._ccUrl){this._jsonFileUrl=this.url;this._ccUrl=this.url;}}if(this.data!=null&&this._jsonData==null){this._jsonData=this.data;this.data=null;}if(this._jsonFileUrl){if(this._loadInProgress){this._queuedFetches.push({args:_1a3});}else{this._loadInProgress=true;var _1a5={url:self._jsonFileUrl,handleAs:"json-comment-optional",preventCache:this.urlPreventCache,failOk:this.failOk};var _1a6=xhr.get(_1a5);_1a6.addCallback(function(data){var _1a7=_1a3.scope?_1a3.scope:_158.global;try{self._getItemsFromLoadedData(data);self._loadFinished=true;self._loadInProgress=false;item=self._getItemByIdentity(_1a3.identity);if(_1a3.onItem){_1a3.onItem.call(_1a7,item);}self._handleQueuedFetches();}catch(error){self._loadInProgress=false;if(_1a3.onError){_1a3.onError.call(_1a7,error);}}});_1a6.addErrback(function(_1a8){self._loadInProgress=false;if(_1a3.onError){var _1a9=_1a3.scope?_1a3.scope:_158.global;_1a3.onError.call(_1a9,_1a8);}});}}else{if(this._jsonData){self._getItemsFromLoadedData(self._jsonData);self._jsonData=null;self._loadFinished=true;item=self._getItemByIdentity(_1a3.identity);if(_1a3.onItem){_1a4=_1a3.scope?_1a3.scope:_158.global;_1a3.onItem.call(_1a4,item);}}}}else{item=this._getItemByIdentity(_1a3.identity);if(_1a3.onItem){_1a4=_1a3.scope?_1a3.scope:_158.global;_1a3.onItem.call(_1a4,item);}}},_getItemByIdentity:function(_1aa){var item=null;if(this._itemsByIdentity){if(Object.hasOwnProperty.call(this._itemsByIdentity,_1aa)){item=this._itemsByIdentity[_1aa];}}else{if(Object.hasOwnProperty.call(this._arrayOfAllItems,_1aa)){item=this._arrayOfAllItems[_1aa];}}if(item===undefined){item=null;}return item;},getIdentityAttributes:function(item){var _1ab=this._features["dojo.data.api.Identity"];if(_1ab===Number){return null;}else{return [_1ab];}},_forceLoad:function(){var self=this;if(this._jsonFileUrl!==this._ccUrl){_158.deprecated(this.declaredClass+": ","To change the url, set the url property of the store,"+" not _jsonFileUrl.  _jsonFileUrl support will be removed in 2.0");this._ccUrl=this._jsonFileUrl;this.url=this._jsonFileUrl;}else{if(this.url!==this._ccUrl){this._jsonFileUrl=this.url;this._ccUrl=this.url;}}if(this.data!=null){this._jsonData=this.data;this.data=null;}if(this._jsonFileUrl){var _1ac={url:this._jsonFileUrl,handleAs:"json-comment-optional",preventCache:this.urlPreventCache,failOk:this.failOk,sync:true};var _1ad=xhr.get(_1ac);_1ad.addCallback(function(data){try{if(self._loadInProgress!==true&&!self._loadFinished){self._getItemsFromLoadedData(data);self._loadFinished=true;}else{if(self._loadInProgress){throw new Error(this.declaredClass+":  Unable to perform a synchronous load, an async load is in progress.");}}}catch(e){throw e;}});_1ad.addErrback(function(_1ae){throw _1ae;});}else{if(this._jsonData){self._getItemsFromLoadedData(self._jsonData);self._jsonData=null;self._loadFinished=true;}}}});lang.extend(_15f,_15d);return _15f;});},"dojo/data/util/filter":function(){define(["../../_base/lang"],function(lang){var _1af={};lang.setObject("dojo.data.util.filter",_1af);_1af.patternToRegExp=function(_1b0,_1b1){var rxp="^";var c=null;for(var i=0;i<_1b0.length;i++){c=_1b0.charAt(i);switch(c){case "\\":rxp+=c;i++;rxp+=_1b0.charAt(i);break;case "*":rxp+=".*";break;case "?":rxp+=".";break;case "$":case "^":case "/":case "+":case ".":case "|":case "(":case ")":case "{":case "}":case "[":case "]":rxp+="\\";default:rxp+=c;}}rxp+="$";if(_1b1){return new RegExp(rxp,"mi");}else{return new RegExp(rxp,"m");}};return _1af;});},"dojo/data/util/simpleFetch":function(){define(["../../_base/lang","../../_base/kernel","./sorter"],function(lang,_1b2,_1b3){var _1b4={};lang.setObject("dojo.data.util.simpleFetch",_1b4);_1b4.errorHandler=function(_1b5,_1b6){if(_1b6.onError){var _1b7=_1b6.scope||_1b2.global;_1b6.onError.call(_1b7,_1b5,_1b6);}};_1b4.fetchHandler=function(_1b8,_1b9){var _1ba=_1b9.abort||null,_1bb=false,_1bc=_1b9.start?_1b9.start:0,_1bd=(_1b9.count&&(_1b9.count!==Infinity))?(_1bc+_1b9.count):_1b8.length;_1b9.abort=function(){_1bb=true;if(_1ba){_1ba.call(_1b9);}};var _1be=_1b9.scope||_1b2.global;if(!_1b9.store){_1b9.store=this;}if(_1b9.onBegin){_1b9.onBegin.call(_1be,_1b8.length,_1b9);}if(_1b9.sort){_1b8.sort(_1b3.createSortFunction(_1b9.sort,this));}if(_1b9.onItem){for(var i=_1bc;(i<_1b8.length)&&(i<_1bd);++i){var item=_1b8[i];if(!_1bb){_1b9.onItem.call(_1be,item,_1b9);}}}if(_1b9.onComplete&&!_1bb){var _1bf=null;if(!_1b9.onItem){_1bf=_1b8.slice(_1bc,_1bd);}_1b9.onComplete.call(_1be,_1bf,_1b9);}};_1b4.fetch=function(_1c0){_1c0=_1c0||{};if(!_1c0.store){_1c0.store=this;}this._fetchItems(_1c0,lang.hitch(this,"fetchHandler"),lang.hitch(this,"errorHandler"));return _1c0;};return _1b4;});},"dojo/data/util/sorter":function(){define(["../../_base/lang"],function(lang){var _1c1={};lang.setObject("dojo.data.util.sorter",_1c1);_1c1.basicComparator=function(a,b){var r=-1;if(a===null){a=undefined;}if(b===null){b=undefined;}if(a==b){r=0;}else{if(a>b||a==null){r=1;}}return r;};_1c1.createSortFunction=function(_1c2,_1c3){var _1c4=[];function _1c5(attr,dir,comp,s){return function(_1c6,_1c7){var a=s.getValue(_1c6,attr);var b=s.getValue(_1c7,attr);return dir*comp(a,b);};};var _1c8;var map=_1c3.comparatorMap;var bc=_1c1.basicComparator;for(var i=0;i<_1c2.length;i++){_1c8=_1c2[i];var attr=_1c8.attribute;if(attr){var dir=(_1c8.descending)?-1:1;var comp=bc;if(map){if(typeof attr!=="string"&&("toString" in attr)){attr=attr.toString();}comp=map[attr]||bc;}_1c4.push(_1c5(attr,dir,comp,_1c3));}}return function(rowA,rowB){var i=0;while(i<_1c4.length){var ret=_1c4[i++](rowA,rowB);if(ret!==0){return ret;}}return 0;};};return _1c1;});},"dojo/selector/acme":function(){define(["../dom","../sniff","../_base/array","../_base/lang","../_base/window"],function(dom,has,_1c9,lang,win){var trim=lang.trim;var each=_1c9.forEach;var _1ca=function(){return win.doc;};var _1cb=(_1ca().compatMode)=="BackCompat";var _1cc=">~+";var _1cd=false;var _1ce=function(){return true;};var _1cf=function(_1d0){if(_1cc.indexOf(_1d0.slice(-1))>=0){_1d0+=" * ";}else{_1d0+=" ";}var ts=function(s,e){return trim(_1d0.slice(s,e));};var _1d1=[];var _1d2=-1,_1d3=-1,_1d4=-1,_1d5=-1,_1d6=-1,inId=-1,_1d7=-1,_1d8,lc="",cc="",_1d9;var x=0,ql=_1d0.length,_1da=null,_1db=null;var _1dc=function(){if(_1d7>=0){var tv=(_1d7==x)?null:ts(_1d7,x);_1da[(_1cc.indexOf(tv)<0)?"tag":"oper"]=tv;_1d7=-1;}};var _1dd=function(){if(inId>=0){_1da.id=ts(inId,x).replace(/\\/g,"");inId=-1;}};var _1de=function(){if(_1d6>=0){_1da.classes.push(ts(_1d6+1,x).replace(/\\/g,""));_1d6=-1;}};var _1df=function(){_1dd();_1dc();_1de();};var _1e0=function(){_1df();if(_1d5>=0){_1da.pseudos.push({name:ts(_1d5+1,x)});}_1da.loops=(_1da.pseudos.length||_1da.attrs.length||_1da.classes.length);_1da.oquery=_1da.query=ts(_1d9,x);_1da.otag=_1da.tag=(_1da["oper"])?null:(_1da.tag||"*");if(_1da.tag){_1da.tag=_1da.tag.toUpperCase();}if(_1d1.length&&(_1d1[_1d1.length-1].oper)){_1da.infixOper=_1d1.pop();_1da.query=_1da.infixOper.query+" "+_1da.query;}_1d1.push(_1da);_1da=null;};for(;lc=cc,cc=_1d0.charAt(x),x<ql;x++){if(lc=="\\"){continue;}if(!_1da){_1d9=x;_1da={query:null,pseudos:[],attrs:[],classes:[],tag:null,oper:null,id:null,getTag:function(){return _1cd?this.otag:this.tag;}};_1d7=x;}if(_1d8){if(cc==_1d8){_1d8=null;}continue;}else{if(cc=="'"||cc=="\""){_1d8=cc;continue;}}if(_1d2>=0){if(cc=="]"){if(!_1db.attr){_1db.attr=ts(_1d2+1,x);}else{_1db.matchFor=ts((_1d4||_1d2+1),x);}var cmf=_1db.matchFor;if(cmf){if((cmf.charAt(0)=="\"")||(cmf.charAt(0)=="'")){_1db.matchFor=cmf.slice(1,-1);}}if(_1db.matchFor){_1db.matchFor=_1db.matchFor.replace(/\\/g,"");}_1da.attrs.push(_1db);_1db=null;_1d2=_1d4=-1;}else{if(cc=="="){var _1e1=("|~^$*".indexOf(lc)>=0)?lc:"";_1db.type=_1e1+cc;_1db.attr=ts(_1d2+1,x-_1e1.length);_1d4=x+1;}}}else{if(_1d3>=0){if(cc==")"){if(_1d5>=0){_1db.value=ts(_1d3+1,x);}_1d5=_1d3=-1;}}else{if(cc=="#"){_1df();inId=x+1;}else{if(cc=="."){_1df();_1d6=x;}else{if(cc==":"){_1df();_1d5=x;}else{if(cc=="["){_1df();_1d2=x;_1db={};}else{if(cc=="("){if(_1d5>=0){_1db={name:ts(_1d5+1,x),value:null};_1da.pseudos.push(_1db);}_1d3=x;}else{if((cc==" ")&&(lc!=cc)){_1e0();}}}}}}}}}return _1d1;};var _1e2=function(_1e3,_1e4){if(!_1e3){return _1e4;}if(!_1e4){return _1e3;}return function(){return _1e3.apply(window,arguments)&&_1e4.apply(window,arguments);};};var _1e5=function(i,arr){var r=arr||[];if(i){r.push(i);}return r;};var _1e6=function(n){return (1==n.nodeType);};var _1e7="";var _1e8=function(elem,attr){if(!elem){return _1e7;}if(attr=="class"){return elem.className||_1e7;}if(attr=="for"){return elem.htmlFor||_1e7;}if(attr=="style"){return elem.style.cssText||_1e7;}return (_1cd?elem.getAttribute(attr):elem.getAttribute(attr,2))||_1e7;};var _1e9={"*=":function(attr,_1ea){return function(elem){return (_1e8(elem,attr).indexOf(_1ea)>=0);};},"^=":function(attr,_1eb){return function(elem){return (_1e8(elem,attr).indexOf(_1eb)==0);};},"$=":function(attr,_1ec){return function(elem){var ea=" "+_1e8(elem,attr);var _1ed=ea.lastIndexOf(_1ec);return _1ed>-1&&(_1ed==(ea.length-_1ec.length));};},"~=":function(attr,_1ee){var tval=" "+_1ee+" ";return function(elem){var ea=" "+_1e8(elem,attr)+" ";return (ea.indexOf(tval)>=0);};},"|=":function(attr,_1ef){var _1f0=_1ef+"-";return function(elem){var ea=_1e8(elem,attr);return ((ea==_1ef)||(ea.indexOf(_1f0)==0));};},"=":function(attr,_1f1){return function(elem){return (_1e8(elem,attr)==_1f1);};}};var _1f2=_1ca().documentElement;var _1f3=!(_1f2.nextElementSibling||"nextElementSibling" in _1f2);var _1f4=!_1f3?"nextElementSibling":"nextSibling";var _1f5=!_1f3?"previousElementSibling":"previousSibling";var _1f6=(_1f3?_1e6:_1ce);var _1f7=function(node){while(node=node[_1f5]){if(_1f6(node)){return false;}}return true;};var _1f8=function(node){while(node=node[_1f4]){if(_1f6(node)){return false;}}return true;};var _1f9=function(node){var root=node.parentNode;root=root.nodeType!=7?root:root.nextSibling;var i=0,tret=root.children||root.childNodes,ci=(node["_i"]||node.getAttribute("_i")||-1),cl=(root["_l"]||(typeof root.getAttribute!=="undefined"?root.getAttribute("_l"):-1));if(!tret){return -1;}var l=tret.length;if(cl==l&&ci>=0&&cl>=0){return ci;}if(has("ie")&&typeof root.setAttribute!=="undefined"){root.setAttribute("_l",l);}else{root["_l"]=l;}ci=-1;for(var te=root["firstElementChild"]||root["firstChild"];te;te=te[_1f4]){if(_1f6(te)){if(has("ie")){te.setAttribute("_i",++i);}else{te["_i"]=++i;}if(node===te){ci=i;}}}return ci;};var _1fa=function(elem){return !((_1f9(elem))%2);};var _1fb=function(elem){return ((_1f9(elem))%2);};var _1fc={"checked":function(name,_1fd){return function(elem){return !!("checked" in elem?elem.checked:elem.selected);};},"disabled":function(name,_1fe){return function(elem){return elem.disabled;};},"enabled":function(name,_1ff){return function(elem){return !elem.disabled;};},"first-child":function(){return _1f7;},"last-child":function(){return _1f8;},"only-child":function(name,_200){return function(node){return _1f7(node)&&_1f8(node);};},"empty":function(name,_201){return function(elem){var cn=elem.childNodes;var cnl=elem.childNodes.length;for(var x=cnl-1;x>=0;x--){var nt=cn[x].nodeType;if((nt===1)||(nt==3)){return false;}}return true;};},"contains":function(name,_202){var cz=_202.charAt(0);if(cz=="\""||cz=="'"){_202=_202.slice(1,-1);}return function(elem){return (elem.innerHTML.indexOf(_202)>=0);};},"not":function(name,_203){var p=_1cf(_203)[0];var _204={el:1};if(p.tag!="*"){_204.tag=1;}if(!p.classes.length){_204.classes=1;}var ntf=_205(p,_204);return function(elem){return (!ntf(elem));};},"nth-child":function(name,_206){var pi=parseInt;if(_206=="odd"){return _1fb;}else{if(_206=="even"){return _1fa;}}if(_206.indexOf("n")!=-1){var _207=_206.split("n",2);var pred=_207[0]?((_207[0]=="-")?-1:pi(_207[0])):1;var idx=_207[1]?pi(_207[1]):0;var lb=0,ub=-1;if(pred>0){if(idx<0){idx=(idx%pred)&&(pred+(idx%pred));}else{if(idx>0){if(idx>=pred){lb=idx-idx%pred;}idx=idx%pred;}}}else{if(pred<0){pred*=-1;if(idx>0){ub=idx;idx=idx%pred;}}}if(pred>0){return function(elem){var i=_1f9(elem);return (i>=lb)&&(ub<0||i<=ub)&&((i%pred)==idx);};}else{_206=idx;}}var _208=pi(_206);return function(elem){return (_1f9(elem)==_208);};}};var _209=(has("ie")<9||has("ie")==9&&has("quirks"))?function(cond){var clc=cond.toLowerCase();if(clc=="class"){cond="className";}return function(elem){return (_1cd?elem.getAttribute(cond):elem[cond]||elem[clc]);};}:function(cond){return function(elem){return (elem&&elem.getAttribute&&elem.hasAttribute(cond));};};var _205=function(_20a,_20b){if(!_20a){return _1ce;}_20b=_20b||{};var ff=null;if(!("el" in _20b)){ff=_1e2(ff,_1e6);}if(!("tag" in _20b)){if(_20a.tag!="*"){ff=_1e2(ff,function(elem){return (elem&&((_1cd?elem.tagName:elem.tagName.toUpperCase())==_20a.getTag()));});}}if(!("classes" in _20b)){each(_20a.classes,function(_20c,idx,arr){var re=new RegExp("(?:^|\\s)"+_20c+"(?:\\s|$)");ff=_1e2(ff,function(elem){return re.test(elem.className);});ff.count=idx;});}if(!("pseudos" in _20b)){each(_20a.pseudos,function(_20d){var pn=_20d.name;if(_1fc[pn]){ff=_1e2(ff,_1fc[pn](pn,_20d.value));}});}if(!("attrs" in _20b)){each(_20a.attrs,function(attr){var _20e;var a=attr.attr;if(attr.type&&_1e9[attr.type]){_20e=_1e9[attr.type](a,attr.matchFor);}else{if(a.length){_20e=_209(a);}}if(_20e){ff=_1e2(ff,_20e);}});}if(!("id" in _20b)){if(_20a.id){ff=_1e2(ff,function(elem){return (!!elem&&(elem.id==_20a.id));});}}if(!ff){if(!("default" in _20b)){ff=_1ce;}}return ff;};var _20f=function(_210){return function(node,ret,bag){while(node=node[_1f4]){if(_1f3&&(!_1e6(node))){continue;}if((!bag||_211(node,bag))&&_210(node)){ret.push(node);}break;}return ret;};};var _212=function(_213){return function(root,ret,bag){var te=root[_1f4];while(te){if(_1f6(te)){if(bag&&!_211(te,bag)){break;}if(_213(te)){ret.push(te);}}te=te[_1f4];}return ret;};};var _214=function(_215,_216){var _217=function(_218){var _219=[];try{_219=Array.prototype.slice.call(_218);}catch(e){for(var i=0,len=_218.length;i<len;i++){_219.push(_218[i]);}}return _219;};_215=_215||_1ce;return function(root,ret,bag){var te,x=0,tret=[];tret=_217(root.children||root.childNodes);if(_216){_1c9.forEach(tret,function(node){if(node.nodeType===1){tret=tret.concat(_217(node.getElementsByTagName("*")));}});}while(te=tret[x++]){if(_1f6(te)&&(!bag||_211(te,bag))&&(_215(te,x))){ret.push(te);}}return ret;};};var _21a=function(node,root){var pn=node.parentNode;while(pn){if(pn==root){break;}pn=pn.parentNode;}return !!pn;};var _21b={};var _21c=function(_21d){var _21e=_21b[_21d.query];if(_21e){return _21e;}var io=_21d.infixOper;var oper=(io?io.oper:"");var _21f=_205(_21d,{el:1});var qt=_21d.tag;var _220=("*"==qt);var ecs=_1ca()["getElementsByClassName"];if(!oper){if(_21d.id){_21f=(!_21d.loops&&_220)?_1ce:_205(_21d,{el:1,id:1});_21e=function(root,arr){var te=dom.byId(_21d.id,(root.ownerDocument||root));if(root.ownerDocument&&!_21a(root,root.ownerDocument)){var _221=root.nodeType===11?root.childNodes:[root];_1c9.some(_221,function(_222){var _223=_214(function(node){return node.id===_21d.id;},true)(_222,[]);if(_223.length){te=_223[0];return false;}});}if(!te||!_21f(te)){return;}if(9==root.nodeType){return _1e5(te,arr);}else{if(_21a(te,root)){return _1e5(te,arr);}}};}else{if(ecs&&/\{\s*\[native code\]\s*\}/.test(String(ecs))&&_21d.classes.length&&!_1cb){_21f=_205(_21d,{el:1,classes:1,id:1});var _224=_21d.classes.join(" ");_21e=function(root,arr,bag){var ret=_1e5(0,arr),te,x=0;var tret=root.getElementsByClassName(_224);while((te=tret[x++])){if(_21f(te,root)&&_211(te,bag)){ret.push(te);}}return ret;};}else{if(!_220&&!_21d.loops){_21e=function(root,arr,bag){var ret=_1e5(0,arr),te,x=0;var tag=_21d.getTag(),tret=tag?root.getElementsByTagName(tag):[];while((te=tret[x++])){if(_211(te,bag)){ret.push(te);}}return ret;};}else{_21f=_205(_21d,{el:1,tag:1,id:1});_21e=function(root,arr,bag){var ret=_1e5(0,arr),te,x=0;var tag=_21d.getTag(),tret=tag?root.getElementsByTagName(tag):[];while((te=tret[x++])){if(_21f(te,root)&&_211(te,bag)){ret.push(te);}}return ret;};}}}}else{var _225={el:1};if(_220){_225.tag=1;}_21f=_205(_21d,_225);if("+"==oper){_21e=_20f(_21f);}else{if("~"==oper){_21e=_212(_21f);}else{if(">"==oper){_21e=_214(_21f);}}}}return _21b[_21d.query]=_21e;};var _226=function(root,_227){var _228=_1e5(root),qp,x,te,qpl=_227.length,bag,ret;for(var i=0;i<qpl;i++){ret=[];qp=_227[i];x=_228.length-1;if(x>0){bag={};ret.nozip=true;}var gef=_21c(qp);for(var j=0;(te=_228[j]);j++){gef(te,ret,bag);}if(!ret.length){break;}_228=ret;}return ret;};var _229={},_22a={};var _22b=function(_22c){var _22d=_1cf(trim(_22c));if(_22d.length==1){var tef=_21c(_22d[0]);return function(root){var r=tef(root,[]);if(r){r.nozip=true;}return r;};}return function(root){return _226(root,_22d);};};var _22e=has("ie")?"commentStrip":"nozip";var qsa="querySelectorAll";var _22f=!!_1ca()[qsa];var _230=/\\[>~+]|n\+\d|([^ \\])?([>~+])([^ =])?/g;var _231=function(_232,pre,ch,post){return ch?(pre?pre+" ":"")+ch+(post?" "+post:""):_232;};var _233=/([^[]*)([^\]]*])?/g;var _234=function(_235,_236,att){return _236.replace(_230,_231)+(att||"");};var _237=function(_238,_239){_238=_238.replace(_233,_234);if(_22f){var _23a=_22a[_238];if(_23a&&!_239){return _23a;}}var _23b=_229[_238];if(_23b){return _23b;}var qcz=_238.charAt(0);var _23c=(-1==_238.indexOf(" "));if((_238.indexOf("#")>=0)&&(_23c)){_239=true;}var _23d=(_22f&&(!_239)&&(_1cc.indexOf(qcz)==-1)&&(!has("ie")||(_238.indexOf(":")==-1))&&(!(_1cb&&(_238.indexOf(".")>=0)))&&(_238.indexOf(":contains")==-1)&&(_238.indexOf(":checked")==-1)&&(_238.indexOf("|=")==-1));if(_23d){var tq=(_1cc.indexOf(_238.charAt(_238.length-1))>=0)?(_238+" *"):_238;return _22a[_238]=function(root){if(9==root.nodeType||_23c){try{var r=root[qsa](tq);r[_22e]=true;return r;}catch(e){}}return _237(_238,true)(root);};}else{var _23e=_238.match(/([^\s,](?:"(?:\\.|[^"])+"|'(?:\\.|[^'])+'|[^,])*)/g);return _229[_238]=((_23e.length<2)?_22b(_238):function(root){var _23f=0,ret=[],tp;while((tp=_23e[_23f++])){ret=ret.concat(_22b(tp)(root));}return ret;});}};var _240=0;var _241=has("ie")?function(node){if(_1cd){return (node.getAttribute("_uid")||node.setAttribute("_uid",++_240)||_240);}else{return node.uniqueID;}}:function(node){return (node._uid||(node._uid=++_240));};var _211=function(node,bag){if(!bag){return 1;}var id=_241(node);if(!bag[id]){return bag[id]=1;}return 0;};var _242="_zipIdx";var _243=function(arr){if(arr&&arr.nozip){return arr;}if(!arr||!arr.length){return [];}if(arr.length<2){return [arr[0]];}var ret=[];_240++;var x,te;if(has("ie")&&_1cd){var _244=_240+"";for(x=0;x<arr.length;x++){if((te=arr[x])&&te.getAttribute(_242)!=_244){ret.push(te);te.setAttribute(_242,_244);}}}else{if(has("ie")&&arr.commentStrip){try{for(x=0;x<arr.length;x++){if((te=arr[x])&&_1e6(te)){ret.push(te);}}}catch(e){}}else{for(x=0;x<arr.length;x++){if((te=arr[x])&&te[_242]!=_240){ret.push(te);te[_242]=_240;}}}}return ret;};var _245=function(_246,root){root=root||_1ca();var od=root.ownerDocument||root;_1cd=(od.createElement("div").tagName==="div");var r=_237(_246)(root);if(r&&r.nozip){return r;}return _243(r);};_245.filter=function(_247,_248,root){var _249=[],_24a=_1cf(_248),_24b=(_24a.length==1&&!/[^\w#\.]/.test(_248))?_205(_24a[0]):function(node){return _1c9.indexOf(_245(_248,dom.byId(root)),node)!=-1;};for(var x=0,te;te=_247[x];x++){if(_24b(te)){_249.push(te);}}return _249;};return _245;});},"dojo/selector/lite":function(){define(["../has","../_base/kernel"],function(has,dojo){"use strict";var _24c=document.createElement("div");var _24d=_24c.matches||_24c.webkitMatchesSelector||_24c.mozMatchesSelector||_24c.msMatchesSelector||_24c.oMatchesSelector;var _24e=_24c.querySelectorAll;var _24f=/([^\s,](?:"(?:\\.|[^"])+"|'(?:\\.|[^'])+'|[^,])*)/g;has.add("dom-matches-selector",!!_24d);has.add("dom-qsa",!!_24e);var _250=function(_251,root){if(_252&&_251.indexOf(",")>-1){return _252(_251,root);}var doc=root?root.ownerDocument||root:dojo.doc||document,_253=(_24e?/^([\w]*)#([\w\-]+$)|^(\.)([\w\-\*]+$)|^(\w+$)/:/^([\w]*)#([\w\-]+)(?:\s+(.*))?$|(?:^|(>|.+\s+))([\w\-\*]+)(\S*$)/).exec(_251);root=root||doc;if(_253){var _254=has("ie")===8&&has("quirks")?root.nodeType===doc.nodeType:root.parentNode!==null&&root.nodeType!==9&&root.parentNode===doc;if(_253[2]&&_254){var _255=dojo.byId?dojo.byId(_253[2],doc):doc.getElementById(_253[2]);if(!_255||(_253[1]&&_253[1]!=_255.tagName.toLowerCase())){return [];}if(root!=doc){var _256=_255;while(_256!=root){_256=_256.parentNode;if(!_256){return [];}}}return _253[3]?_250(_253[3],_255):[_255];}if(_253[3]&&root.getElementsByClassName){return root.getElementsByClassName(_253[4]);}var _255;if(_253[5]){_255=root.getElementsByTagName(_253[5]);if(_253[4]||_253[6]){_251=(_253[4]||"")+_253[6];}else{return _255;}}}if(_24e){if(root.nodeType===1&&root.nodeName.toLowerCase()!=="object"){return _257(root,_251,root.querySelectorAll);}else{return root.querySelectorAll(_251);}}else{if(!_255){_255=root.getElementsByTagName("*");}}var _258=[];for(var i=0,l=_255.length;i<l;i++){var node=_255[i];if(node.nodeType==1&&_259(node,_251,root)){_258.push(node);}}return _258;};var _257=function(_25a,_25b,_25c){var _25d=_25a,old=_25a.getAttribute("id"),nid=old||"__dojo__",_25e=_25a.parentNode,_25f=/^\s*[+~]/.test(_25b);if(_25f&&!_25e){return [];}if(!old){_25a.setAttribute("id",nid);}else{nid=nid.replace(/'/g,"\\$&");}if(_25f&&_25e){_25a=_25a.parentNode;}var _260=_25b.match(_24f);for(var i=0;i<_260.length;i++){_260[i]="[id='"+nid+"'] "+_260[i];}_25b=_260.join(",");try{return _25c.call(_25a,_25b);}finally{if(!old){_25d.removeAttribute("id");}}};if(!has("dom-matches-selector")){var _259=(function(){var _261=_24c.tagName=="div"?"toLowerCase":"toUpperCase";var _262={"":function(_263){_263=_263[_261]();return function(node){return node.tagName==_263;};},".":function(_264){var _265=" "+_264+" ";return function(node){return node.className.indexOf(_264)>-1&&(" "+node.className+" ").indexOf(_265)>-1;};},"#":function(id){return function(node){return node.id==id;};}};var _266={"^=":function(_267,_268){return _267.indexOf(_268)==0;},"*=":function(_269,_26a){return _269.indexOf(_26a)>-1;},"$=":function(_26b,_26c){return _26b.substring(_26b.length-_26c.length,_26b.length)==_26c;},"~=":function(_26d,_26e){return (" "+_26d+" ").indexOf(" "+_26e+" ")>-1;},"|=":function(_26f,_270){return (_26f+"-").indexOf(_270+"-")==0;},"=":function(_271,_272){return _271==_272;},"":function(_273,_274){return true;}};function attr(name,_275,type){var _276=_275.charAt(0);if(_276=="\""||_276=="'"){_275=_275.slice(1,-1);}_275=_275.replace(/\\/g,"");var _277=_266[type||""];return function(node){var _278=node.getAttribute(name);return _278&&_277(_278,_275);};};function _279(_27a){return function(node,root){while((node=node.parentNode)!=root){if(_27a(node,root)){return true;}}};};function _27b(_27c){return function(node,root){node=node.parentNode;return _27c?node!=root&&_27c(node,root):node==root;};};var _27d={};function and(_27e,next){return _27e?function(node,root){return next(node)&&_27e(node,root);}:next;};return function(node,_27f,root){var _280=_27d[_27f];if(!_280){if(_27f.replace(/(?:\s*([> ])\s*)|(#|\.)?((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(.?=)?\s*("(?:\\.|[^"])+"|'(?:\\.|[^'])+'|(?:\\.|[^\]])*)\s*\]/g,function(t,_281,type,_282,_283,_284,_285){if(_282){_280=and(_280,_262[type||""](_282.replace(/\\/g,"")));}else{if(_281){_280=(_281==" "?_279:_27b)(_280);}else{if(_283){_280=and(_280,attr(_283,_285,_284));}}}return "";})){throw new Error("Syntax error in query");}if(!_280){return true;}_27d[_27f]=_280;}return _280(node,root);};})();}if(!has("dom-qsa")){var _252=function(_286,root){var _287=_286.match(_24f);var _288=[];for(var i=0;i<_287.length;i++){_286=new String(_287[i].replace(/\s*$/,""));_286.indexOf=escape;var _289=_250(_286,root);for(var j=0,l=_289.length;j<l;j++){var node=_289[j];_288[node.sourceIndex]=node;}}var _28a=[];for(i in _288){_28a.push(_288[i]);}return _28a;};}_250.match=_24d?function(node,_28b,root){if(root&&root.nodeType!=9){return _257(root,_28b,function(_28c){return _24d.call(node,_28c);});}return _24d.call(node,_28b);}:_259;return _250;});},"dojo/Stateful":function(){define(["./_base/declare","./_base/lang","./_base/array","./when"],function(_28d,lang,_28e,when){return _28d("dojo.Stateful",null,{_attrPairNames:{},_getAttrNames:function(name){var apn=this._attrPairNames;if(apn[name]){return apn[name];}return (apn[name]={s:"_"+name+"Setter",g:"_"+name+"Getter"});},postscript:function(_28f){if(_28f){this.set(_28f);}},_get:function(name,_290){return typeof this[_290.g]==="function"?this[_290.g]():this[name];},get:function(name){return this._get(name,this._getAttrNames(name));},set:function(name,_291){if(typeof name==="object"){for(var x in name){if(name.hasOwnProperty(x)&&x!="_watchCallbacks"){this.set(x,name[x]);}}return this;}var _292=this._getAttrNames(name),_293=this._get(name,_292),_294=this[_292.s],_295;if(typeof _294==="function"){_295=_294.apply(this,Array.prototype.slice.call(arguments,1));}else{this[name]=_291;}if(this._watchCallbacks){var self=this;when(_295,function(){self._watchCallbacks(name,_293,_291);});}return this;},_changeAttrValue:function(name,_296){var _297=this.get(name);this[name]=_296;if(this._watchCallbacks){this._watchCallbacks(name,_297,_296);}return this;},watch:function(name,_298){var _299=this._watchCallbacks;if(!_299){var self=this;_299=this._watchCallbacks=function(name,_29a,_29b,_29c){var _29d=function(_29e){if(_29e){_29e=_29e.slice();for(var i=0,l=_29e.length;i<l;i++){_29e[i].call(self,name,_29a,_29b);}}};_29d(_299["_"+name]);if(!_29c){_29d(_299["*"]);}};}if(!_298&&typeof name==="function"){_298=name;name="*";}else{name="_"+name;}var _29f=_299[name];if(typeof _29f!=="object"){_29f=_299[name]=[];}_29f.push(_298);var _2a0={};_2a0.unwatch=_2a0.remove=function(){var _2a1=_28e.indexOf(_29f,_298);if(_2a1>-1){_29f.splice(_2a1,1);}};return _2a0;}});});},"dojo/string":function(){define(["./_base/kernel","./_base/lang"],function(_2a2,lang){var _2a3=/[&<>'"\/]/g;var _2a4={"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","'":"&#x27;","/":"&#x2F;"};var _2a5={};lang.setObject("dojo.string",_2a5);_2a5.escape=function(str){if(!str){return "";}return str.replace(_2a3,function(c){return _2a4[c];});};_2a5.rep=function(str,num){if(num<=0||!str){return "";}var buf=[];for(;;){if(num&1){buf.push(str);}if(!(num>>=1)){break;}str+=str;}return buf.join("");};_2a5.pad=function(text,size,ch,end){if(!ch){ch="0";}var out=String(text),pad=_2a5.rep(ch,Math.ceil((size-out.length)/ch.length));return end?out+pad:pad+out;};_2a5.substitute=function(_2a6,map,_2a7,_2a8){_2a8=_2a8||_2a2.global;_2a7=_2a7?lang.hitch(_2a8,_2a7):function(v){return v;};return _2a6.replace(/\$\{([^\s\:\}]*)(?:\:([^\s\:\}]+))?\}/g,function(_2a9,key,_2aa){if(key==""){return "$";}var _2ab=lang.getObject(key,false,map);if(_2aa){_2ab=lang.getObject(_2aa,false,_2a8).call(_2a8,_2ab,key);}var _2ac=_2a7(_2ab,key);if(typeof _2ac==="undefined"){throw new Error("string.substitute could not find key \""+key+"\" in template");}return _2ac.toString();});};_2a5.trim=String.prototype.trim?lang.trim:function(str){str=str.replace(/^\s+/,"");for(var i=str.length-1;i>=0;i--){if(/\S/.test(str.charAt(i))){str=str.substring(0,i+1);break;}}return str;};return _2a5;});},"dojo/touch":function(){define(["./_base/kernel","./aspect","./dom","./dom-class","./_base/lang","./on","./has","./mouse","./domReady","./_base/window"],function(dojo,_2ad,dom,_2ae,lang,on,has,_2af,_2b0,win){var ios4=has("ios")<5;var _2b1=has("pointer-events")||has("MSPointer"),_2b2=(function(){var _2b3={};for(var type in {down:1,move:1,up:1,cancel:1,over:1,out:1}){_2b3[type]=has("MSPointer")?"MSPointer"+type.charAt(0).toUpperCase()+type.slice(1):"pointer"+type;}return _2b3;})();var _2b4=has("touch-events");var _2b5,_2b6,_2b7=false,_2b8,_2b9,_2ba,_2bb,_2bc,_2bd;var _2be;function _2bf(_2c0,_2c1,_2c2){if(_2b1&&_2c2){return function(node,_2c3){return on(node,_2c2,_2c3);};}else{if(_2b4){return function(node,_2c4){var _2c5=on(node,_2c1,function(evt){_2c4.call(this,evt);_2be=(new Date()).getTime();}),_2c6=on(node,_2c0,function(evt){if(!_2be||(new Date()).getTime()>_2be+1000){_2c4.call(this,evt);}});return {remove:function(){_2c5.remove();_2c6.remove();}};};}else{return function(node,_2c7){return on(node,_2c0,_2c7);};}}};function _2c8(node){do{if(node.dojoClick!==undefined){return node;}}while(node=node.parentNode);};function _2c9(e,_2ca,_2cb){if(_2af.isRight(e)){return;}var _2cc=_2c8(e.target);_2b6=!e.target.disabled&&_2cc&&_2cc.dojoClick;if(_2b6){_2b7=(_2b6=="useTarget");_2b8=(_2b7?_2cc:e.target);if(_2b7){e.preventDefault();}_2b9=e.changedTouches?e.changedTouches[0].pageX-win.global.pageXOffset:e.clientX;_2ba=e.changedTouches?e.changedTouches[0].pageY-win.global.pageYOffset:e.clientY;_2bb=(typeof _2b6=="object"?_2b6.x:(typeof _2b6=="number"?_2b6:0))||4;_2bc=(typeof _2b6=="object"?_2b6.y:(typeof _2b6=="number"?_2b6:0))||4;if(!_2b5){_2b5=true;function _2cd(e){if(_2b7){_2b6=dom.isDescendant(win.doc.elementFromPoint((e.changedTouches?e.changedTouches[0].pageX-win.global.pageXOffset:e.clientX),(e.changedTouches?e.changedTouches[0].pageY-win.global.pageYOffset:e.clientY)),_2b8);}else{_2b6=_2b6&&(e.changedTouches?e.changedTouches[0].target:e.target)==_2b8&&Math.abs((e.changedTouches?e.changedTouches[0].pageX-win.global.pageXOffset:e.clientX)-_2b9)<=_2bb&&Math.abs((e.changedTouches?e.changedTouches[0].pageY-win.global.pageYOffset:e.clientY)-_2ba)<=_2bc;}};win.doc.addEventListener(_2ca,function(e){if(_2af.isRight(e)){return;}_2cd(e);if(_2b7){e.preventDefault();}},true);win.doc.addEventListener(_2cb,function(e){if(_2af.isRight(e)){return;}_2cd(e);if(_2b6){_2bd=(new Date()).getTime();var _2ce=(_2b7?_2b8:e.target);if(_2ce.tagName==="LABEL"){_2ce=dom.byId(_2ce.getAttribute("for"))||_2ce;}var src=(e.changedTouches)?e.changedTouches[0]:e;function _2cf(type){var evt=document.createEvent("MouseEvents");evt._dojo_click=true;evt.initMouseEvent(type,true,true,e.view,e.detail,src.screenX,src.screenY,src.clientX,src.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null);return evt;};var _2d0=_2cf("mousedown");var _2d1=_2cf("mouseup");var _2d2=_2cf("click");setTimeout(function(){on.emit(_2ce,"mousedown",_2d0);on.emit(_2ce,"mouseup",_2d1);on.emit(_2ce,"click",_2d2);_2bd=(new Date()).getTime();},0);}},true);function _2d3(type){win.doc.addEventListener(type,function(e){var _2d4=e.target;if(_2b6&&!e._dojo_click&&(new Date()).getTime()<=_2bd+1000&&!(_2d4.tagName=="INPUT"&&_2ae.contains(_2d4,"dijitOffScreen"))){e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();if(type=="click"&&(_2d4.tagName!="INPUT"||(_2d4.type=="radio"&&(_2ae.contains(_2d4,"dijitCheckBoxInput")||_2ae.contains(_2d4,"mblRadioButton")))||(_2d4.type=="checkbox"&&(_2ae.contains(_2d4,"dijitCheckBoxInput")||_2ae.contains(_2d4,"mblCheckBox"))))&&_2d4.tagName!="TEXTAREA"&&_2d4.tagName!="AUDIO"&&_2d4.tagName!="VIDEO"){e.preventDefault();}}},true);};_2d3("click");_2d3("mousedown");_2d3("mouseup");}}};var _2d5;if(has("touch")){if(_2b1){_2b0(function(){win.doc.addEventListener(_2b2.down,function(evt){_2c9(evt,_2b2.move,_2b2.up);},true);});}else{_2b0(function(){_2d5=win.body();win.doc.addEventListener("touchstart",function(evt){_2be=(new Date()).getTime();var _2d6=_2d5;_2d5=evt.target;on.emit(_2d6,"dojotouchout",{relatedTarget:_2d5,bubbles:true});on.emit(_2d5,"dojotouchover",{relatedTarget:_2d6,bubbles:true});_2c9(evt,"touchmove","touchend");},true);function _2d7(evt){var _2d8=lang.delegate(evt,{bubbles:true});if(has("ios")>=6){_2d8.touches=evt.touches;_2d8.altKey=evt.altKey;_2d8.changedTouches=evt.changedTouches;_2d8.ctrlKey=evt.ctrlKey;_2d8.metaKey=evt.metaKey;_2d8.shiftKey=evt.shiftKey;_2d8.targetTouches=evt.targetTouches;}return _2d8;};on(win.doc,"touchmove",function(evt){_2be=(new Date()).getTime();var _2d9=win.doc.elementFromPoint(evt.pageX-(ios4?0:win.global.pageXOffset),evt.pageY-(ios4?0:win.global.pageYOffset));if(_2d9){if(_2d5!==_2d9){on.emit(_2d5,"dojotouchout",{relatedTarget:_2d9,bubbles:true});on.emit(_2d9,"dojotouchover",{relatedTarget:_2d5,bubbles:true});_2d5=_2d9;}if(!on.emit(_2d9,"dojotouchmove",_2d7(evt))){evt.preventDefault();}}});on(win.doc,"touchend",function(evt){_2be=(new Date()).getTime();var node=win.doc.elementFromPoint(evt.pageX-(ios4?0:win.global.pageXOffset),evt.pageY-(ios4?0:win.global.pageYOffset))||win.body();on.emit(node,"dojotouchend",_2d7(evt));});});}}var _2da={press:_2bf("mousedown","touchstart",_2b2.down),move:_2bf("mousemove","dojotouchmove",_2b2.move),release:_2bf("mouseup","dojotouchend",_2b2.up),cancel:_2bf(_2af.leave,"touchcancel",_2b1?_2b2.cancel:null),over:_2bf("mouseover","dojotouchover",_2b2.over),out:_2bf("mouseout","dojotouchout",_2b2.out),enter:_2af._eventHandler(_2bf("mouseover","dojotouchover",_2b2.over)),leave:_2af._eventHandler(_2bf("mouseout","dojotouchout",_2b2.out))};1&&(dojo.touch=_2da);return _2da;});},"dojo/uacss":function(){define(["./dom-geometry","./_base/lang","./domReady","./sniff","./_base/window"],function(_2db,lang,_2dc,has,_2dd){var html=_2dd.doc.documentElement,ie=has("ie"),_2de=has("trident"),_2df=has("opera"),maj=Math.floor,ff=has("ff"),_2e0=_2db.boxModel.replace(/-/,""),_2e1={"dj_quirks":has("quirks"),"dj_opera":_2df,"dj_khtml":has("khtml"),"dj_webkit":has("webkit"),"dj_safari":has("safari"),"dj_chrome":has("chrome"),"dj_edge":has("edge"),"dj_gecko":has("mozilla"),"dj_ios":has("ios"),"dj_android":has("android")};if(ie){_2e1["dj_ie"]=true;_2e1["dj_ie"+maj(ie)]=true;_2e1["dj_iequirks"]=has("quirks");}if(_2de){_2e1["dj_trident"]=true;_2e1["dj_trident"+maj(_2de)]=true;}if(ff){_2e1["dj_ff"+maj(ff)]=true;}_2e1["dj_"+_2e0]=true;var _2e2="";for(var clz in _2e1){if(_2e1[clz]){_2e2+=clz+" ";}}html.className=lang.trim(html.className+" "+_2e2);_2dc(function(){if(!_2db.isBodyLtr()){var _2e3="dj_rtl dijitRtl "+_2e2.replace(/ /g,"-rtl ");html.className=lang.trim(html.className+" "+_2e3+"dj_rtl dijitRtl "+_2e2.replace(/ /g,"-rtl "));}});return has;});},"dojo/window":function(){define(["./_base/lang","./sniff","./_base/window","./dom","./dom-geometry","./dom-style","./dom-construct"],function(lang,has,_2e4,dom,geom,_2e5,_2e6){has.add("rtl-adjust-position-for-verticalScrollBar",function(win,doc){var body=_2e4.body(doc),_2e7=_2e6.create("div",{style:{overflow:"scroll",overflowX:"visible",direction:"rtl",visibility:"hidden",position:"absolute",left:"0",top:"0",width:"64px",height:"64px"}},body,"last"),div=_2e6.create("div",{style:{overflow:"hidden",direction:"ltr"}},_2e7,"last"),ret=geom.position(div).x!=0;_2e7.removeChild(div);body.removeChild(_2e7);return ret;});has.add("position-fixed-support",function(win,doc){var body=_2e4.body(doc),_2e8=_2e6.create("span",{style:{visibility:"hidden",position:"fixed",left:"1px",top:"1px"}},body,"last"),_2e9=_2e6.create("span",{style:{position:"fixed",left:"0",top:"0"}},_2e8,"last"),ret=geom.position(_2e9).x!=geom.position(_2e8).x;_2e8.removeChild(_2e9);body.removeChild(_2e8);return ret;});var _2ea={getBox:function(doc){doc=doc||_2e4.doc;var _2eb=(doc.compatMode=="BackCompat")?_2e4.body(doc):doc.documentElement,_2ec=geom.docScroll(doc),w,h;if(has("touch")){var _2ed=_2ea.get(doc);w=_2ed.innerWidth||_2eb.clientWidth;h=_2ed.innerHeight||_2eb.clientHeight;}else{w=_2eb.clientWidth;h=_2eb.clientHeight;}return {l:_2ec.x,t:_2ec.y,w:w,h:h};},get:function(doc){if(has("ie")&&_2ea!==document.parentWindow){doc.parentWindow.execScript("document._parentWindow = window;","Javascript");var win=doc._parentWindow;doc._parentWindow=null;return win;}return doc.parentWindow||doc.defaultView;},scrollIntoView:function(node,pos){try{node=dom.byId(node);var doc=node.ownerDocument||_2e4.doc,body=_2e4.body(doc),html=doc.documentElement||body.parentNode,isIE=has("ie")||has("trident"),isWK=has("webkit");if(node==body||node==html){return;}if(!(has("mozilla")||isIE||isWK||has("opera")||has("trident")||has("edge"))&&("scrollIntoView" in node)){node.scrollIntoView(false);return;}var _2ee=doc.compatMode=="BackCompat",_2ef=Math.min(body.clientWidth||html.clientWidth,html.clientWidth||body.clientWidth),_2f0=Math.min(body.clientHeight||html.clientHeight,html.clientHeight||body.clientHeight),_2f1=(isWK||_2ee)?body:html,_2f2=pos||geom.position(node),el=node.parentNode,_2f3=function(el){return (isIE<=6||(isIE==7&&_2ee))?false:(has("position-fixed-support")&&(_2e5.get(el,"position").toLowerCase()=="fixed"));},self=this,_2f4=function(el,x,y){if(el.tagName=="BODY"||el.tagName=="HTML"){self.get(el.ownerDocument).scrollBy(x,y);}else{x&&(el.scrollLeft+=x);y&&(el.scrollTop+=y);}};if(_2f3(node)){return;}while(el){if(el==body){el=_2f1;}var _2f5=geom.position(el),_2f6=_2f3(el),rtl=_2e5.getComputedStyle(el).direction.toLowerCase()=="rtl";if(el==_2f1){_2f5.w=_2ef;_2f5.h=_2f0;if(_2f1==html&&(isIE||has("trident"))&&rtl){_2f5.x+=_2f1.offsetWidth-_2f5.w;}_2f5.x=0;_2f5.y=0;}else{var pb=geom.getPadBorderExtents(el);_2f5.w-=pb.w;_2f5.h-=pb.h;_2f5.x+=pb.l;_2f5.y+=pb.t;var _2f7=el.clientWidth,_2f8=_2f5.w-_2f7;if(_2f7>0&&_2f8>0){if(rtl&&has("rtl-adjust-position-for-verticalScrollBar")){_2f5.x+=_2f8;}_2f5.w=_2f7;}_2f7=el.clientHeight;_2f8=_2f5.h-_2f7;if(_2f7>0&&_2f8>0){_2f5.h=_2f7;}}if(_2f6){if(_2f5.y<0){_2f5.h+=_2f5.y;_2f5.y=0;}if(_2f5.x<0){_2f5.w+=_2f5.x;_2f5.x=0;}if(_2f5.y+_2f5.h>_2f0){_2f5.h=_2f0-_2f5.y;}if(_2f5.x+_2f5.w>_2ef){_2f5.w=_2ef-_2f5.x;}}var l=_2f2.x-_2f5.x,t=_2f2.y-_2f5.y,r=l+_2f2.w-_2f5.w,bot=t+_2f2.h-_2f5.h;var s,old;if(r*l>0&&(!!el.scrollLeft||el==_2f1||el.scrollWidth>el.offsetHeight)){s=Math[l<0?"max":"min"](l,r);if(rtl&&((isIE==8&&!_2ee)||has("trident")>=5)){s=-s;}old=el.scrollLeft;_2f4(el,s,0);s=el.scrollLeft-old;_2f2.x-=s;}if(bot*t>0&&(!!el.scrollTop||el==_2f1||el.scrollHeight>el.offsetHeight)){s=Math.ceil(Math[t<0?"max":"min"](t,bot));old=el.scrollTop;_2f4(el,0,s);s=el.scrollTop-old;_2f2.y-=s;}el=(el!=_2f1)&&!_2f6&&el.parentNode;}}catch(error){console.error("scrollIntoView: "+error);node.scrollIntoView(false);}}};1&&lang.setObject("dojo.window",_2ea);return _2ea;});},"dojo/NodeList-fx":function(){define(["./query","./_base/lang","./aspect","./_base/fx","./fx"],function(_2f9,lang,_2fa,_2fb,_2fc){var _2fd=_2f9.NodeList;lang.extend(_2fd,{_anim:function(obj,_2fe,args){args=args||{};var a=_2fc.combine(this.map(function(item){var _2ff={node:item};lang.mixin(_2ff,args);return obj[_2fe](_2ff);}));return args.auto?a.play()&&this:a;},wipeIn:function(args){return this._anim(_2fc,"wipeIn",args);},wipeOut:function(args){return this._anim(_2fc,"wipeOut",args);},slideTo:function(args){return this._anim(_2fc,"slideTo",args);},fadeIn:function(args){return this._anim(_2fb,"fadeIn",args);},fadeOut:function(args){return this._anim(_2fb,"fadeOut",args);},animateProperty:function(args){return this._anim(_2fb,"animateProperty",args);},anim:function(_300,_301,_302,_303,_304){var _305=_2fc.combine(this.map(function(item){return _2fb.animateProperty({node:item,properties:_300,duration:_301||350,easing:_302});}));if(_303){_2fa.after(_305,"onEnd",_303,true);}return _305.play(_304||0);}});return _2fd;});},"dojo/fx":function(){define(["./_base/lang","./Evented","./_base/kernel","./_base/array","./aspect","./_base/fx","./dom","./dom-style","./dom-geometry","./ready","require"],function(lang,_306,dojo,_307,_308,_309,dom,_30a,geom,_30b,_30c){if(!dojo.isAsync){_30b(0,function(){var _30d=["./fx/Toggler"];_30c(_30d);});}var _30e=dojo.fx={};var _30f={_fire:function(evt,args){if(this[evt]){this[evt].apply(this,args||[]);}return this;}};var _310=function(_311){this._index=-1;this._animations=_311||[];this._current=this._onAnimateCtx=this._onEndCtx=null;this.duration=0;_307.forEach(this._animations,function(a){if(a){if(typeof a.duration!="undefined"){this.duration+=a.duration;}if(a.delay){this.duration+=a.delay;}}},this);};_310.prototype=new _306();lang.extend(_310,{_onAnimate:function(){this._fire("onAnimate",arguments);},_onEnd:function(){this._onAnimateCtx.remove();this._onEndCtx.remove();this._onAnimateCtx=this._onEndCtx=null;if(this._index+1==this._animations.length){this._fire("onEnd");}else{this._current=this._animations[++this._index];this._onAnimateCtx=_308.after(this._current,"onAnimate",lang.hitch(this,"_onAnimate"),true);this._onEndCtx=_308.after(this._current,"onEnd",lang.hitch(this,"_onEnd"),true);this._current.play(0,true);}},play:function(_312,_313){if(!this._current){this._current=this._animations[this._index=0];}if(!_313&&this._current.status()=="playing"){return this;}var _314=_308.after(this._current,"beforeBegin",lang.hitch(this,function(){this._fire("beforeBegin");}),true),_315=_308.after(this._current,"onBegin",lang.hitch(this,function(arg){this._fire("onBegin",arguments);}),true),_316=_308.after(this._current,"onPlay",lang.hitch(this,function(arg){this._fire("onPlay",arguments);_314.remove();_315.remove();_316.remove();}));if(this._onAnimateCtx){this._onAnimateCtx.remove();}this._onAnimateCtx=_308.after(this._current,"onAnimate",lang.hitch(this,"_onAnimate"),true);if(this._onEndCtx){this._onEndCtx.remove();}this._onEndCtx=_308.after(this._current,"onEnd",lang.hitch(this,"_onEnd"),true);this._current.play.apply(this._current,arguments);return this;},pause:function(){if(this._current){var e=_308.after(this._current,"onPause",lang.hitch(this,function(arg){this._fire("onPause",arguments);e.remove();}),true);this._current.pause();}return this;},gotoPercent:function(_317,_318){this.pause();var _319=this.duration*_317;this._current=null;_307.some(this._animations,function(a,_31a){if(_319<=a.duration){this._current=a;this._index=_31a;return true;}_319-=a.duration;return false;},this);if(this._current){this._current.gotoPercent(_319/this._current.duration);}if(_318){this.play();}return this;},stop:function(_31b){if(this._current){if(_31b){for(;this._index+1<this._animations.length;++this._index){this._animations[this._index].stop(true);}this._current=this._animations[this._index];}var e=_308.after(this._current,"onStop",lang.hitch(this,function(arg){this._fire("onStop",arguments);e.remove();}),true);this._current.stop();}return this;},status:function(){return this._current?this._current.status():"stopped";},destroy:function(){this.stop();if(this._onAnimateCtx){this._onAnimateCtx.remove();}if(this._onEndCtx){this._onEndCtx.remove();}}});lang.extend(_310,_30f);_30e.chain=function(_31c){return new _310(lang.isArray(_31c)?_31c:Array.prototype.slice.call(_31c,0));};var _31d=function(_31e){this._animations=_31e||[];this._connects=[];this._finished=0;this.duration=0;_307.forEach(_31e,function(a){var _31f=a.duration;if(a.delay){_31f+=a.delay;}if(this.duration<_31f){this.duration=_31f;}this._connects.push(_308.after(a,"onEnd",lang.hitch(this,"_onEnd"),true));},this);this._pseudoAnimation=new _309.Animation({curve:[0,1],duration:this.duration});var self=this;_307.forEach(["beforeBegin","onBegin","onPlay","onAnimate","onPause","onStop","onEnd"],function(evt){self._connects.push(_308.after(self._pseudoAnimation,evt,function(){self._fire(evt,arguments);},true));});};lang.extend(_31d,{_doAction:function(_320,args){_307.forEach(this._animations,function(a){a[_320].apply(a,args);});return this;},_onEnd:function(){if(++this._finished>this._animations.length){this._fire("onEnd");}},_call:function(_321,args){var t=this._pseudoAnimation;t[_321].apply(t,args);},play:function(_322,_323){this._finished=0;this._doAction("play",arguments);this._call("play",arguments);return this;},pause:function(){this._doAction("pause",arguments);this._call("pause",arguments);return this;},gotoPercent:function(_324,_325){var ms=this.duration*_324;_307.forEach(this._animations,function(a){a.gotoPercent(a.duration<ms?1:(ms/a.duration),_325);});this._call("gotoPercent",arguments);return this;},stop:function(_326){this._doAction("stop",arguments);this._call("stop",arguments);return this;},status:function(){return this._pseudoAnimation.status();},destroy:function(){this.stop();_307.forEach(this._connects,function(_327){_327.remove();});}});lang.extend(_31d,_30f);_30e.combine=function(_328){return new _31d(lang.isArray(_328)?_328:Array.prototype.slice.call(_328,0));};_30e.wipeIn=function(args){var node=args.node=dom.byId(args.node),s=node.style,o;var anim=_309.animateProperty(lang.mixin({properties:{height:{start:function(){o=s.overflow;s.overflow="hidden";if(s.visibility=="hidden"||s.display=="none"){s.height="1px";s.display="";s.visibility="";return 1;}else{var _329=_30a.get(node,"height");return Math.max(_329,1);}},end:function(){return node.scrollHeight;}}}},args));var fini=function(){s.height="auto";s.overflow=o;};_308.after(anim,"onStop",fini,true);_308.after(anim,"onEnd",fini,true);return anim;};_30e.wipeOut=function(args){var node=args.node=dom.byId(args.node),s=node.style,o;var anim=_309.animateProperty(lang.mixin({properties:{height:{end:1}}},args));_308.after(anim,"beforeBegin",function(){o=s.overflow;s.overflow="hidden";s.display="";},true);var fini=function(){s.overflow=o;s.height="auto";s.display="none";};_308.after(anim,"onStop",fini,true);_308.after(anim,"onEnd",fini,true);return anim;};_30e.slideTo=function(args){var node=args.node=dom.byId(args.node),top=null,left=null;var init=(function(n){return function(){var cs=_30a.getComputedStyle(n);var pos=cs.position;top=(pos=="absolute"?n.offsetTop:parseInt(cs.top)||0);left=(pos=="absolute"?n.offsetLeft:parseInt(cs.left)||0);if(pos!="absolute"&&pos!="relative"){var ret=geom.position(n,true);top=ret.y;left=ret.x;n.style.position="absolute";n.style.top=top+"px";n.style.left=left+"px";}};})(node);init();var anim=_309.animateProperty(lang.mixin({properties:{top:args.top||0,left:args.left||0}},args));_308.after(anim,"beforeBegin",init,true);return anim;};return _30e;});},"dojo/dnd/Moveable":function(){define(["../_base/array","../_base/declare","../_base/lang","../dom","../dom-class","../Evented","../has","../on","../topic","../touch","./common","./Mover","../_base/window"],function(_32a,_32b,lang,dom,_32c,_32d,has,on,_32e,_32f,dnd,_330,win){var _331;var _332=function(){};function _333(){if("touchAction" in document.body.style){_331="touchAction";}else{if("msTouchAction" in document.body.style){_331="msTouchAction";}}_332=function _332(node,_334){node.style[_331]=_334;};_332(arguments[0],arguments[1]);};if(has("touch-action")){_332=_333;}var _335=_32b("dojo.dnd.Moveable",[_32d],{handle:"",delay:0,skip:false,constructor:function(node,_336){this.node=dom.byId(node);_332(this.node,"none");if(!_336){_336={};}this.handle=_336.handle?dom.byId(_336.handle):null;if(!this.handle){this.handle=this.node;}this.delay=_336.delay>0?_336.delay:0;this.skip=_336.skip;this.mover=_336.mover?_336.mover:_330;this.events=[on(this.handle,_32f.press,lang.hitch(this,"onMouseDown")),on(this.handle,"dragstart",lang.hitch(this,"onSelectStart")),on(this.handle,"selectstart",lang.hitch(this,"onSelectStart"))];},markupFactory:function(_337,node,Ctor){return new Ctor(node,_337);},destroy:function(){_32a.forEach(this.events,function(_338){_338.remove();});_332(this.node,"");this.events=this.node=this.handle=null;},onMouseDown:function(e){if(this.skip&&dnd.isFormElement(e)){return;}if(this.delay){this.events.push(on(this.handle,_32f.move,lang.hitch(this,"onMouseMove")),on(this.handle.ownerDocument,_32f.release,lang.hitch(this,"onMouseUp")));this._lastX=e.pageX;this._lastY=e.pageY;}else{this.onDragDetected(e);}e.stopPropagation();e.preventDefault();},onMouseMove:function(e){if(Math.abs(e.pageX-this._lastX)>this.delay||Math.abs(e.pageY-this._lastY)>this.delay){this.onMouseUp(e);this.onDragDetected(e);}e.stopPropagation();e.preventDefault();},onMouseUp:function(e){for(var i=0;i<2;++i){this.events.pop().remove();}e.stopPropagation();e.preventDefault();},onSelectStart:function(e){if(!this.skip||!dnd.isFormElement(e)){e.stopPropagation();e.preventDefault();}},onDragDetected:function(e){new this.mover(this.node,e,this);},onMoveStart:function(_339){_32e.publish("/dnd/move/start",_339);_32c.add(win.body(),"dojoMove");_32c.add(this.node,"dojoMoveItem");},onMoveStop:function(_33a){_32e.publish("/dnd/move/stop",_33a);_32c.remove(win.body(),"dojoMove");_32c.remove(this.node,"dojoMoveItem");},onFirstMove:function(){},onMove:function(_33b,_33c){this.onMoving(_33b,_33c);var s=_33b.node.style;s.left=_33c.l+"px";s.top=_33c.t+"px";this.onMoved(_33b,_33c);},onMoving:function(){},onMoved:function(){}});return _335;});},"dojo/dnd/common":function(){define(["../sniff","../_base/kernel","../_base/lang","../dom"],function(has,_33d,lang,dom){var _33e=lang.getObject("dojo.dnd",true);_33e.getCopyKeyState=function(evt){return evt[has("mac")?"metaKey":"ctrlKey"];};_33e._uniqueId=0;_33e.getUniqueId=function(){var id;do{id=_33d._scopeName+"Unique"+(++_33e._uniqueId);}while(dom.byId(id));return id;};_33e._empty={};_33e.isFormElement=function(e){var t=e.target;if(t.nodeType==3){t=t.parentNode;}return " a button textarea input select option ".indexOf(" "+t.tagName.toLowerCase()+" ")>=0;};return _33e;});},"dojo/dnd/Mover":function(){define(["../_base/array","../_base/declare","../_base/lang","../sniff","../_base/window","../dom","../dom-geometry","../dom-style","../Evented","../on","../touch","./common","./autoscroll"],function(_33f,_340,lang,has,win,dom,_341,_342,_343,on,_344,dnd,_345){return _340("dojo.dnd.Mover",[_343],{constructor:function(node,e,host){this.node=dom.byId(node);this.marginBox={l:e.pageX,t:e.pageY};this.mouseButton=e.button;var h=(this.host=host),d=node.ownerDocument;function _346(e){e.preventDefault();e.stopPropagation();};this.events=[on(d,_344.move,lang.hitch(this,"onFirstMove")),on(d,_344.move,lang.hitch(this,"onMouseMove")),on(d,_344.release,lang.hitch(this,"onMouseUp")),on(d,"dragstart",_346),on(d.body,"selectstart",_346)];_345.autoScrollStart(d);if(h&&h.onMoveStart){h.onMoveStart(this);}},onMouseMove:function(e){_345.autoScroll(e);var m=this.marginBox;this.host.onMove(this,{l:m.l+e.pageX,t:m.t+e.pageY},e);e.preventDefault();e.stopPropagation();},onMouseUp:function(e){if(has("webkit")&&has("mac")&&this.mouseButton==2?e.button==0:this.mouseButton==e.button){this.destroy();}e.preventDefault();e.stopPropagation();},onFirstMove:function(e){var s=this.node.style,l,t,h=this.host;switch(s.position){case "relative":case "absolute":l=Math.round(parseFloat(s.left))||0;t=Math.round(parseFloat(s.top))||0;break;default:s.position="absolute";var m=_341.getMarginBox(this.node);var b=win.doc.body;var bs=_342.getComputedStyle(b);var bm=_341.getMarginBox(b,bs);var bc=_341.getContentBox(b,bs);l=m.l-(bc.l-bm.l);t=m.t-(bc.t-bm.t);break;}this.marginBox.l=l-this.marginBox.l;this.marginBox.t=t-this.marginBox.t;if(h&&h.onFirstMove){h.onFirstMove(this,e);}this.events.shift().remove();},destroy:function(){_33f.forEach(this.events,function(_347){_347.remove();});var h=this.host;if(h&&h.onMoveStop){h.onMoveStop(this);}this.events=this.node=this.host=null;}});});},"dojo/dnd/autoscroll":function(){define(["../_base/lang","../sniff","../_base/window","../dom-geometry","../dom-style","../window"],function(lang,has,win,_348,_349,_34a){var _34b={};lang.setObject("dojo.dnd.autoscroll",_34b);_34b.getViewport=_34a.getBox;_34b.V_TRIGGER_AUTOSCROLL=32;_34b.H_TRIGGER_AUTOSCROLL=32;_34b.V_AUTOSCROLL_VALUE=16;_34b.H_AUTOSCROLL_VALUE=16;var _34c,doc=win.doc,_34d=Infinity,_34e=Infinity;_34b.autoScrollStart=function(d){doc=d;_34c=_34a.getBox(doc);var html=win.body(doc).parentNode;_34d=Math.max(html.scrollHeight-_34c.h,0);_34e=Math.max(html.scrollWidth-_34c.w,0);};_34b.autoScroll=function(e){var v=_34c||_34a.getBox(doc),html=win.body(doc).parentNode,dx=0,dy=0;if(e.clientX<_34b.H_TRIGGER_AUTOSCROLL){dx=-_34b.H_AUTOSCROLL_VALUE;}else{if(e.clientX>v.w-_34b.H_TRIGGER_AUTOSCROLL){dx=Math.min(_34b.H_AUTOSCROLL_VALUE,_34e-html.scrollLeft);}}if(e.clientY<_34b.V_TRIGGER_AUTOSCROLL){dy=-_34b.V_AUTOSCROLL_VALUE;}else{if(e.clientY>v.h-_34b.V_TRIGGER_AUTOSCROLL){dy=Math.min(_34b.V_AUTOSCROLL_VALUE,_34d-html.scrollTop);}}window.scrollBy(dx,dy);};_34b._validNodes={"div":1,"p":1,"td":1};_34b._validOverflow={"auto":1,"scroll":1};_34b.autoScrollNodes=function(e){var b,t,w,h,rx,ry,dx=0,dy=0,_34f,_350;for(var n=e.target;n;){if(n.nodeType==1&&(n.tagName.toLowerCase() in _34b._validNodes)){var s=_349.getComputedStyle(n),_351=(s.overflowX.toLowerCase() in _34b._validOverflow),_352=(s.overflowY.toLowerCase() in _34b._validOverflow);if(_351||_352){b=_348.getContentBox(n,s);t=_348.position(n,true);}if(_351){w=Math.min(_34b.H_TRIGGER_AUTOSCROLL,b.w/2);rx=e.pageX-t.x;if(has("webkit")||has("opera")){rx+=win.body().scrollLeft;}dx=0;if(rx>0&&rx<b.w){if(rx<w){dx=-w;}else{if(rx>b.w-w){dx=w;}}_34f=n.scrollLeft;n.scrollLeft=n.scrollLeft+dx;}}if(_352){h=Math.min(_34b.V_TRIGGER_AUTOSCROLL,b.h/2);ry=e.pageY-t.y;if(has("webkit")||has("opera")){ry+=win.body().scrollTop;}dy=0;if(ry>0&&ry<b.h){if(ry<h){dy=-h;}else{if(ry>b.h-h){dy=h;}}_350=n.scrollTop;n.scrollTop=n.scrollTop+dy;}}if(dx||dy){return;}}try{n=n.parentNode;}catch(x){n=null;}}_34b.autoScroll(e);};return _34b;});},"dojo/dnd/move":function(){define(["../_base/declare","../dom-geometry","../dom-style","./common","./Mover","./Moveable"],function(_353,_354,_355,dnd,_356,_357){var _358=_353("dojo.dnd.move.constrainedMoveable",_357,{constraints:function(){},within:false,constructor:function(node,_359){if(!_359){_359={};}this.constraints=_359.constraints;this.within=_359.within;},onFirstMove:function(_35a){var c=this.constraintBox=this.constraints.call(this,_35a);c.r=c.l+c.w;c.b=c.t+c.h;if(this.within){var mb=_354.getMarginSize(_35a.node);c.r-=mb.w;c.b-=mb.h;}},onMove:function(_35b,_35c){var c=this.constraintBox,s=_35b.node.style;this.onMoving(_35b,_35c);_35c.l=_35c.l<c.l?c.l:c.r<_35c.l?c.r:_35c.l;_35c.t=_35c.t<c.t?c.t:c.b<_35c.t?c.b:_35c.t;s.left=_35c.l+"px";s.top=_35c.t+"px";this.onMoved(_35b,_35c);}});var _35d=_353("dojo.dnd.move.boxConstrainedMoveable",_358,{box:{},constructor:function(node,_35e){var box=_35e&&_35e.box;this.constraints=function(){return box;};}});var _35f=_353("dojo.dnd.move.parentConstrainedMoveable",_358,{area:"content",constructor:function(node,_360){var area=_360&&_360.area;this.constraints=function(){var n=this.node.parentNode,s=_355.getComputedStyle(n),mb=_354.getMarginBox(n,s);if(area=="margin"){return mb;}var t=_354.getMarginExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;if(area=="border"){return mb;}t=_354.getBorderExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;if(area=="padding"){return mb;}t=_354.getPadExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;return mb;};}});return {constrainedMoveable:_358,boxConstrainedMoveable:_35d,parentConstrainedMoveable:_35f};});},"dojo/dnd/TimedMoveable":function(){define(["../_base/declare","./Moveable"],function(_361,_362){var _363=_362.prototype.onMove;return _361("dojo.dnd.TimedMoveable",_362,{timeout:40,constructor:function(node,_364){if(!_364){_364={};}if(_364.timeout&&typeof _364.timeout=="number"&&_364.timeout>=0){this.timeout=_364.timeout;}},onMoveStop:function(_365){if(_365._timer){clearTimeout(_365._timer);_363.call(this,_365,_365._leftTop);}_362.prototype.onMoveStop.apply(this,arguments);},onMove:function(_366,_367){_366._leftTop=_367;if(!_366._timer){var _368=this;_366._timer=setTimeout(function(){_366._timer=null;_363.call(_368,_366,_366._leftTop);},this.timeout);}}});});},"dojo/fx/Toggler":function(){define(["../_base/lang","../_base/declare","../_base/fx","../aspect"],function(lang,_369,_36a,_36b){return _369("dojo.fx.Toggler",null,{node:null,showFunc:_36a.fadeIn,hideFunc:_36a.fadeOut,showDuration:200,hideDuration:200,constructor:function(args){var _36c=this;lang.mixin(_36c,args);_36c.node=args.node;_36c._showArgs=lang.mixin({},args);_36c._showArgs.node=_36c.node;_36c._showArgs.duration=_36c.showDuration;_36c.showAnim=_36c.showFunc(_36c._showArgs);_36c._hideArgs=lang.mixin({},args);_36c._hideArgs.node=_36c.node;_36c._hideArgs.duration=_36c.hideDuration;_36c.hideAnim=_36c.hideFunc(_36c._hideArgs);_36b.after(_36c.showAnim,"beforeBegin",lang.hitch(_36c.hideAnim,"stop",true),true);_36b.after(_36c.hideAnim,"beforeBegin",lang.hitch(_36c.showAnim,"stop",true),true);},show:function(_36d){return this.showAnim.play(_36d||0);},hide:function(_36e){return this.hideAnim.play(_36e||0);}});});},"dojo/html":function(){define(["./_base/kernel","./_base/lang","./_base/array","./_base/declare","./dom","./dom-construct","./parser"],function(_36f,lang,_370,_371,dom,_372,_373){var _374=0;var html={_secureForInnerHtml:function(cont){return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig,"");},_emptyNode:_372.empty,_setNodeContent:function(node,cont){_372.empty(node);if(cont){if(typeof cont=="number"){cont=cont.toString();}if(typeof cont=="string"){cont=_372.toDom(cont,node.ownerDocument);}if(!cont.nodeType&&lang.isArrayLike(cont)){for(var _375=cont.length,i=0;i<cont.length;i=_375==cont.length?i+1:0){_372.place(cont[i],node,"last");}}else{_372.place(cont,node,"last");}}return node;},_ContentSetter:_371("dojo.html._ContentSetter",null,{node:"",content:"",id:"",cleanContent:false,extractContent:false,parseContent:false,parserScope:_36f._scopeName,startup:true,constructor:function(_376,node){lang.mixin(this,_376||{});node=this.node=dom.byId(this.node||node);if(!this.id){this.id=["Setter",(node)?node.id||node.tagName:"",_374++].join("_");}},set:function(cont,_377){if(undefined!==cont){this.content=cont;}if(typeof cont=="number"){cont=cont.toString();}if(_377){this._mixin(_377);}this.onBegin();this.setContent();var ret=this.onEnd();if(ret&&ret.then){return ret;}else{return this.node;}},setContent:function(){var node=this.node;if(!node){throw new Error(this.declaredClass+": setContent given no node");}try{node=html._setNodeContent(node,this.content);}catch(e){var _378=this.onContentError(e);try{node.innerHTML=_378;}catch(e){console.error("Fatal "+this.declaredClass+".setContent could not change content due to "+e.message,e);}}this.node=node;},empty:function(){if(this.parseDeferred){if(!this.parseDeferred.isResolved()){this.parseDeferred.cancel();}delete this.parseDeferred;}if(this.parseResults&&this.parseResults.length){_370.forEach(this.parseResults,function(w){if(w.destroy){w.destroy();}});delete this.parseResults;}_372.empty(this.node);},onBegin:function(){var cont=this.content;if(lang.isString(cont)){if(this.cleanContent){cont=html._secureForInnerHtml(cont);}if(this.extractContent){var _379=cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);if(_379){cont=_379[1];}}}this.empty();this.content=cont;return this.node;},onEnd:function(){if(this.parseContent){this._parse();}return this.node;},tearDown:function(){delete this.parseResults;delete this.parseDeferred;delete this.node;delete this.content;},onContentError:function(err){return "Error occurred setting content: "+err;},onExecError:function(err){return "Error occurred executing scripts: "+err;},_mixin:function(_37a){var _37b={},key;for(key in _37a){if(key in _37b){continue;}this[key]=_37a[key];}},_parse:function(){var _37c=this.node;try{var _37d={};_370.forEach(["dir","lang","textDir"],function(name){if(this[name]){_37d[name]=this[name];}},this);var self=this;this.parseDeferred=_373.parse({rootNode:_37c,noStart:!this.startup,inherited:_37d,scope:this.parserScope}).then(function(_37e){return self.parseResults=_37e;},function(e){self._onError("Content",e,"Error parsing in _ContentSetter#"+self.id);});}catch(e){this._onError("Content",e,"Error parsing in _ContentSetter#"+this.id);}},_onError:function(type,err,_37f){var _380=this["on"+type+"Error"].call(this,err);if(_37f){console.error(_37f,err);}else{if(_380){html._setNodeContent(this.node,_380,true);}}}}),set:function(node,cont,_381){if(undefined==cont){console.warn("dojo.html.set: no cont argument provided, using empty string");cont="";}if(typeof cont=="number"){cont=cont.toString();}if(!_381){return html._setNodeContent(node,cont,true);}else{var op=new html._ContentSetter(lang.mixin(_381,{content:cont,node:node}));return op.set();}}};lang.setObject("dojo.html",html);return html;});},"dojo/i18n":function(){define(["./_base/kernel","require","./has","./_base/array","./_base/config","./_base/lang","./_base/xhr","./json","module"],function(dojo,_382,has,_383,_384,lang,xhr,json,_385){has.add("dojo-preload-i18n-Api",1);1||has.add("dojo-v1x-i18n-Api",1);var _386=dojo.i18n={},_387=/(^.*(^|\/)nls)(\/|$)([^\/]*)\/?([^\/]*)/,_388=function(root,_389,_38a,_38b){for(var _38c=[_38a+_38b],_38d=_389.split("-"),_38e="",i=0;i<_38d.length;i++){_38e+=(_38e?"-":"")+_38d[i];if(!root||root[_38e]){_38c.push(_38a+_38e+"/"+_38b);_38c.specificity=_38e;}}return _38c;},_38f={},_390=function(_391,_392,_393){_393=_393?_393.toLowerCase():dojo.locale;_391=_391.replace(/\./g,"/");_392=_392.replace(/\./g,"/");return (/root/i.test(_393))?(_391+"/nls/"+_392):(_391+"/nls/"+_393+"/"+_392);},_394=dojo.getL10nName=function(_395,_396,_397){return _395=_385.id+"!"+_390(_395,_396,_397);},_398=function(_399,_39a,_39b,_39c,_39d,load){_399([_39a],function(root){var _39e=lang.clone(root.root||root.ROOT),_39f=_388(!root._v1x&&root,_39d,_39b,_39c);_399(_39f,function(){for(var i=1;i<_39f.length;i++){_39e=lang.mixin(lang.clone(_39e),arguments[i]);}var _3a0=_39a+"/"+_39d;_38f[_3a0]=_39e;_39e.$locale=_39f.specificity;load();});});},_3a1=function(id,_3a2){return /^\./.test(id)?_3a2(id):id;},_3a3=function(_3a4){var list=_384.extraLocale||[];list=lang.isArray(list)?list:[list];list.push(_3a4);return list;},load=function(id,_3a5,load){var _3a6=_387.exec(id),_3a7=_3a6[1]+"/",_3a8=_3a6[5]||_3a6[4],_3a9=_3a7+_3a8,_3aa=(_3a6[5]&&_3a6[4]),_3ab=_3aa||dojo.locale||"",_3ac=_3a9+"/"+_3ab,_3ad=_3aa?[_3ab]:_3a3(_3ab),_3ae=_3ad.length,_3af=function(){if(!--_3ae){load(lang.delegate(_38f[_3ac]));}},_3b0=id.split("*"),_3b1=_3b0[1]=="preload";if(has("dojo-preload-i18n-Api")){if(_3b1){if(!_38f[id]){_38f[id]=1;_3bb(_3b0[2],json.parse(_3b0[3]),1,_3a5);}load(1);}if(_3b1||(_3d8(id,_3a5,load)&&!_38f[_3ac])){return;}}else{if(_3b1){load(1);return;}}_383.forEach(_3ad,function(_3b2){var _3b3=_3a9+"/"+_3b2;if(has("dojo-preload-i18n-Api")){_3b4(_3b3);}if(!_38f[_3b3]){_398(_3a5,_3a9,_3a7,_3a8,_3b2,_3af);}else{_3af();}});};if(has("dojo-preload-i18n-Api")||1){var _3b5=_386.normalizeLocale=function(_3b6){var _3b7=_3b6?_3b6.toLowerCase():dojo.locale;return _3b7=="root"?"ROOT":_3b7;},isXd=function(mid,_3b8){return (1&&1)?_3b8.isXdUrl(_382.toUrl(mid+".js")):true;},_3b9=0,_3ba=[],_3bb=_386._preloadLocalizations=function(_3bc,_3bd,_3be,_3bf){_3bf=_3bf||_382;function _3c0(mid,_3c1){if(isXd(mid,_3bf)||_3be){_3bf([mid],_3c1);}else{_3dd([mid],_3c1,_3bf);}};function _3c2(_3c3,func){var _3c4=_3c3.split("-");while(_3c4.length){if(func(_3c4.join("-"))){return;}_3c4.pop();}func("ROOT");};function _3c5(){_3b9++;};function _3c6(){--_3b9;while(!_3b9&&_3ba.length){load.apply(null,_3ba.shift());}};function _3c7(path,name,loc,_3c8){return _3c8.toAbsMid(path+name+"/"+loc);};function _3c9(_3ca){_3ca=_3b5(_3ca);_3c2(_3ca,function(loc){if(_383.indexOf(_3bd,loc)>=0){var mid=_3bc.replace(/\./g,"/")+"_"+loc;_3c5();_3c0(mid,function(_3cb){for(var p in _3cb){var _3cc=_3cb[p],_3cd=p.match(/(.+)\/([^\/]+)$/),_3ce,_3cf;if(!_3cd){continue;}_3ce=_3cd[2];_3cf=_3cd[1]+"/";if(!_3cc._localized){continue;}var _3d0;if(loc==="ROOT"){var root=_3d0=_3cc._localized;delete _3cc._localized;root.root=_3cc;_38f[_382.toAbsMid(p)]=root;}else{_3d0=_3cc._localized;_38f[_3c7(_3cf,_3ce,loc,_382)]=_3cc;}if(loc!==_3ca){function _3d1(_3d2,_3d3,_3d4,_3d5){var _3d6=[],_3d7=[];_3c2(_3ca,function(loc){if(_3d5[loc]){_3d6.push(_382.toAbsMid(_3d2+loc+"/"+_3d3));_3d7.push(_3c7(_3d2,_3d3,loc,_382));}});if(_3d6.length){_3c5();_3bf(_3d6,function(){for(var i=_3d6.length-1;i>=0;i--){_3d4=lang.mixin(lang.clone(_3d4),arguments[i]);_38f[_3d7[i]]=_3d4;}_38f[_3c7(_3d2,_3d3,_3ca,_382)]=lang.clone(_3d4);_3c6();});}else{_38f[_3c7(_3d2,_3d3,_3ca,_382)]=_3d4;}};_3d1(_3cf,_3ce,_3cc,_3d0);}}_3c6();});return true;}return false;});};_3c9();_383.forEach(dojo.config.extraLocale,_3c9);},_3d8=function(id,_3d9,load){if(_3b9){_3ba.push([id,_3d9,load]);}return _3b9;},_3b4=function(){};}if(1){var _3da={},_3db={},_3dc,_3dd=function(deps,_3de,_3df){var _3e0=[];_383.forEach(deps,function(mid){var url=_3df.toUrl(mid+".js");function load(text){if(!_3dc){_3dc=new Function("__bundle","__checkForLegacyModules","__mid","__amdValue","var define = function(mid, factory){define.called = 1; __amdValue.result = factory || mid;},"+"\t   require = function(){define.called = 1;};"+"try{"+"define.called = 0;"+"eval(__bundle);"+"if(define.called==1)"+"return __amdValue;"+"if((__checkForLegacyModules = __checkForLegacyModules(__mid)))"+"return __checkForLegacyModules;"+"}catch(e){}"+"try{"+"return eval('('+__bundle+')');"+"}catch(e){"+"return e;"+"}");}var _3e1=_3dc(text,_3b4,mid,_3da);if(_3e1===_3da){_3e0.push(_38f[url]=_3da.result);}else{if(_3e1 instanceof Error){console.error("failed to evaluate i18n bundle; url="+url,_3e1);_3e1={};}_3e0.push(_38f[url]=(/nls\/[^\/]+\/[^\/]+$/.test(url)?_3e1:{root:_3e1,_v1x:1}));}};if(_38f[url]){_3e0.push(_38f[url]);}else{var _3e2=_3df.syncLoadNls(mid);if(!_3e2){_3e2=_3b4(mid.replace(/nls\/([^\/]*)\/([^\/]*)$/,"nls/$2/$1"));}if(_3e2){_3e0.push(_3e2);}else{if(!xhr){try{_3df.getText(url,true,load);}catch(e){_3e0.push(_38f[url]={});}}else{xhr.get({url:url,sync:true,load:load,error:function(){_3e0.push(_38f[url]={});}});}}}});_3de&&_3de.apply(null,_3e0);};_3b4=function(_3e3){for(var _3e4,_3e5=_3e3.split("/"),_3e6=dojo.global[_3e5[0]],i=1;_3e6&&i<_3e5.length-1;_3e6=_3e6[_3e5[i++]]){}if(_3e6){_3e4=_3e6[_3e5[i]];if(!_3e4){_3e4=_3e6[_3e5[i].replace(/-/g,"_")];}if(_3e4){_38f[_3e3]=_3e4;}}return _3e4;};_386.getLocalization=function(_3e7,_3e8,_3e9){var _3ea,_3eb=_390(_3e7,_3e8,_3e9);if(_3db[_3eb]){return _3db[_3eb];}load(_3eb,(!isXd(_3eb,_382)?function(deps,_3ec){_3dd(deps,_3ec,_382);}:_382),function(_3ed){_3db[_3eb]=_3ed;_3ea=_3ed;});return _3ea;};}else{_386.getLocalization=function(_3ee,_3ef,_3f0){var key=_3ee.replace(/\./g,"/")+"/nls/"+_3ef+"/"+(_3f0||_384.locale);return this.cache[key];};}return lang.mixin(_386,{dynamic:true,normalize:_3a1,load:load,cache:_38f,getL10nName:_394});});},"dijit/dijit":function(){define(["./main","./_base","dojo/parser","./_Widget","./_TemplatedMixin","./_Container","./layout/_LayoutWidget","./form/_FormWidget","./form/_FormValueWidget"],function(_3f1){return _3f1;});},"dijit/main":function(){define(["dojo/_base/kernel"],function(dojo){return dojo.dijit;});},"dijit/_base":function(){define(["./main","./a11y","./WidgetSet","./_base/focus","./_base/manager","./_base/place","./_base/popup","./_base/scroll","./_base/sniff","./_base/typematic","./_base/wai","./_base/window"],function(_3f2){return _3f2._base;});},"dijit/a11y":function(){define(["dojo/_base/array","dojo/dom","dojo/dom-attr","dojo/dom-style","dojo/_base/lang","dojo/sniff","./main"],function(_3f3,dom,_3f4,_3f5,lang,has,_3f6){var _3f7;var a11y={_isElementShown:function(elem){var s=_3f5.get(elem);return (s.visibility!="hidden")&&(s.visibility!="collapsed")&&(s.display!="none")&&(_3f4.get(elem,"type")!="hidden");},hasDefaultTabStop:function(elem){switch(elem.nodeName.toLowerCase()){case "a":return _3f4.has(elem,"href");case "area":case "button":case "input":case "object":case "select":case "textarea":return true;case "iframe":var body;try{var _3f8=elem.contentDocument;if("designMode" in _3f8&&_3f8.designMode=="on"){return true;}body=_3f8.body;}catch(e1){try{body=elem.contentWindow.document.body;}catch(e2){return false;}}return body&&(body.contentEditable=="true"||(body.firstChild&&body.firstChild.contentEditable=="true"));default:return elem.contentEditable=="true";}},effectiveTabIndex:function(elem){if(_3f4.get(elem,"disabled")){return _3f7;}else{if(_3f4.has(elem,"tabIndex")){return +_3f4.get(elem,"tabIndex");}else{return a11y.hasDefaultTabStop(elem)?0:_3f7;}}},isTabNavigable:function(elem){return a11y.effectiveTabIndex(elem)>=0;},isFocusable:function(elem){return a11y.effectiveTabIndex(elem)>=-1;},_getTabNavigable:function(root){var _3f9,last,_3fa,_3fb,_3fc,_3fd,_3fe={};function _3ff(node){return node&&node.tagName.toLowerCase()=="input"&&node.type&&node.type.toLowerCase()=="radio"&&node.name&&node.name.toLowerCase();};var _400=a11y._isElementShown,_401=a11y.effectiveTabIndex;var _402=function(_403){for(var _404=_403.firstChild;_404;_404=_404.nextSibling){if(_404.nodeType!=1||(has("ie")<=9&&_404.scopeName!=="HTML")||!_400(_404)){continue;}var _405=_401(_404);if(_405>=0){if(_405==0){if(!_3f9){_3f9=_404;}last=_404;}else{if(_405>0){if(!_3fa||_405<_3fb){_3fb=_405;_3fa=_404;}if(!_3fc||_405>=_3fd){_3fd=_405;_3fc=_404;}}}var rn=_3ff(_404);if(_3f4.get(_404,"checked")&&rn){_3fe[rn]=_404;}}if(_404.nodeName.toUpperCase()!="SELECT"){_402(_404);}}};if(_400(root)){_402(root);}function rs(node){return _3fe[_3ff(node)]||node;};return {first:rs(_3f9),last:rs(last),lowest:rs(_3fa),highest:rs(_3fc)};},getFirstInTabbingOrder:function(root,doc){var _406=a11y._getTabNavigable(dom.byId(root,doc));return _406.lowest?_406.lowest:_406.first;},getLastInTabbingOrder:function(root,doc){var _407=a11y._getTabNavigable(dom.byId(root,doc));return _407.last?_407.last:_407.highest;}};1&&lang.mixin(_3f6,a11y);return a11y;});},"dijit/WidgetSet":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/_base/kernel","./registry"],function(_408,_409,_40a,_40b){var _40c=_409("dijit.WidgetSet",null,{constructor:function(){this._hash={};this.length=0;},add:function(_40d){if(this._hash[_40d.id]){throw new Error("Tried to register widget with id=="+_40d.id+" but that id is already registered");}this._hash[_40d.id]=_40d;this.length++;},remove:function(id){if(this._hash[id]){delete this._hash[id];this.length--;}},forEach:function(func,_40e){_40e=_40e||_40a.global;var i=0,id;for(id in this._hash){func.call(_40e,this._hash[id],i++,this._hash);}return this;},filter:function(_40f,_410){_410=_410||_40a.global;var res=new _40c(),i=0,id;for(id in this._hash){var w=this._hash[id];if(_40f.call(_410,w,i++,this._hash)){res.add(w);}}return res;},byId:function(id){return this._hash[id];},byClass:function(cls){var res=new _40c(),id,_411;for(id in this._hash){_411=this._hash[id];if(_411.declaredClass==cls){res.add(_411);}}return res;},toArray:function(){var ar=[];for(var id in this._hash){ar.push(this._hash[id]);}return ar;},map:function(func,_412){return _408.map(this.toArray(),func,_412);},every:function(func,_413){_413=_413||_40a.global;var x=0,i;for(i in this._hash){if(!func.call(_413,this._hash[i],x++,this._hash)){return false;}}return true;},some:function(func,_414){_414=_414||_40a.global;var x=0,i;for(i in this._hash){if(func.call(_414,this._hash[i],x++,this._hash)){return true;}}return false;}});_408.forEach(["forEach","filter","byClass","map","every","some"],function(func){_40b[func]=_40c.prototype[func];});return _40c;});},"dijit/registry":function(){define(["dojo/_base/array","dojo/_base/window","./main"],function(_415,win,_416){var _417={},hash={};var _418={length:0,add:function(_419){if(hash[_419.id]){throw new Error("Tried to register widget with id=="+_419.id+" but that id is already registered");}hash[_419.id]=_419;this.length++;},remove:function(id){if(hash[id]){delete hash[id];this.length--;}},byId:function(id){return typeof id=="string"?hash[id]:id;},byNode:function(node){return hash[node.getAttribute("widgetId")];},toArray:function(){var ar=[];for(var id in hash){ar.push(hash[id]);}return ar;},getUniqueId:function(_41a){var id;do{id=_41a+"_"+(_41a in _417?++_417[_41a]:_417[_41a]=0);}while(hash[id]);return _416._scopeName=="dijit"?id:_416._scopeName+"_"+id;},findWidgets:function(root,_41b){var _41c=[];function _41d(root){for(var node=root.firstChild;node;node=node.nextSibling){if(node.nodeType==1){var _41e=node.getAttribute("widgetId");if(_41e){var _41f=hash[_41e];if(_41f){_41c.push(_41f);}}else{if(node!==_41b){_41d(node);}}}}};_41d(root);return _41c;},_destroyAll:function(){_416._curFocus=null;_416._prevFocus=null;_416._activeStack=[];_415.forEach(_418.findWidgets(win.body()),function(_420){if(!_420._destroyed){if(_420.destroyRecursive){_420.destroyRecursive();}else{if(_420.destroy){_420.destroy();}}}});},getEnclosingWidget:function(node){while(node){var id=node.nodeType==1&&node.getAttribute("widgetId");if(id){return hash[id];}node=node.parentNode;}return null;},_hash:hash};_416.registry=_418;return _418;});},"dijit/_base/focus":function(){define(["dojo/_base/array","dojo/dom","dojo/_base/lang","dojo/topic","dojo/_base/window","../focus","../selection","../main"],function(_421,dom,lang,_422,win,_423,_424,_425){var _426={_curFocus:null,_prevFocus:null,isCollapsed:function(){return _425.getBookmark().isCollapsed;},getBookmark:function(){var sel=win.global==window?_424:new _424.SelectionManager(win.global);return sel.getBookmark();},moveToBookmark:function(_427){var sel=win.global==window?_424:new _424.SelectionManager(win.global);return sel.moveToBookmark(_427);},getFocus:function(menu,_428){var node=!_423.curNode||(menu&&dom.isDescendant(_423.curNode,menu.domNode))?_425._prevFocus:_423.curNode;return {node:node,bookmark:node&&(node==_423.curNode)&&win.withGlobal(_428||win.global,_425.getBookmark),openedForWindow:_428};},_activeStack:[],registerIframe:function(_429){return _423.registerIframe(_429);},unregisterIframe:function(_42a){_42a&&_42a.remove();},registerWin:function(_42b,_42c){return _423.registerWin(_42b,_42c);},unregisterWin:function(_42d){_42d&&_42d.remove();}};_423.focus=function(_42e){if(!_42e){return;}var node="node" in _42e?_42e.node:_42e,_42f=_42e.bookmark,_430=_42e.openedForWindow,_431=_42f?_42f.isCollapsed:false;if(node){var _432=(node.tagName.toLowerCase()=="iframe")?node.contentWindow:node;if(_432&&_432.focus){try{_432.focus();}catch(e){}}_423._onFocusNode(node);}if(_42f&&win.withGlobal(_430||win.global,_425.isCollapsed)&&!_431){if(_430){_430.focus();}try{win.withGlobal(_430||win.global,_425.moveToBookmark,null,[_42f]);}catch(e2){}}};_423.watch("curNode",function(name,_433,_434){_425._curFocus=_434;_425._prevFocus=_433;if(_434){_422.publish("focusNode",_434);}});_423.watch("activeStack",function(name,_435,_436){_425._activeStack=_436;});_423.on("widget-blur",function(_437,by){_422.publish("widgetBlur",_437,by);});_423.on("widget-focus",function(_438,by){_422.publish("widgetFocus",_438,by);});lang.mixin(_425,_426);return _425;});},"dijit/focus":function(){define(["dojo/aspect","dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/Evented","dojo/_base/lang","dojo/on","dojo/domReady","dojo/sniff","dojo/Stateful","dojo/_base/window","dojo/window","./a11y","./registry","./main"],function(_439,_43a,dom,_43b,_43c,_43d,_43e,lang,on,_43f,has,_440,win,_441,a11y,_442,_443){var _444;var _445;var _446=_43a([_440,_43e],{curNode:null,activeStack:[],constructor:function(){var _447=lang.hitch(this,function(node){if(dom.isDescendant(this.curNode,node)){this.set("curNode",null);}if(dom.isDescendant(this.prevNode,node)){this.set("prevNode",null);}});_439.before(_43d,"empty",_447);_439.before(_43d,"destroy",_447);},registerIframe:function(_448){return this.registerWin(_448.contentWindow,_448);},registerWin:function(_449,_44a){var _44b=this,body=_449.document&&_449.document.body;if(body){var _44c=has("pointer-events")?"pointerdown":has("MSPointer")?"MSPointerDown":has("touch-events")?"mousedown, touchstart":"mousedown";var mdh=on(_449.document,_44c,function(evt){if(evt&&evt.target&&evt.target.parentNode==null){return;}_44b._onTouchNode(_44a||evt.target,"mouse");});var fih=on(body,"focusin",function(evt){if(!evt.target.tagName){return;}var tag=evt.target.tagName.toLowerCase();if(tag=="#document"||tag=="body"){return;}if(a11y.isFocusable(evt.target)){_44b._onFocusNode(_44a||evt.target);}else{_44b._onTouchNode(_44a||evt.target);}});var foh=on(body,"focusout",function(evt){_44b._onBlurNode(_44a||evt.target);});return {remove:function(){mdh.remove();fih.remove();foh.remove();mdh=fih=foh=null;body=null;}};}},_onBlurNode:function(node){var now=(new Date()).getTime();if(now<_444+100){return;}if(this._clearFocusTimer){clearTimeout(this._clearFocusTimer);}this._clearFocusTimer=setTimeout(lang.hitch(this,function(){this.set("prevNode",this.curNode);this.set("curNode",null);}),0);if(this._clearActiveWidgetsTimer){clearTimeout(this._clearActiveWidgetsTimer);}if(now<_445+100){return;}this._clearActiveWidgetsTimer=setTimeout(lang.hitch(this,function(){delete this._clearActiveWidgetsTimer;this._setStack([]);}),0);},_onTouchNode:function(node,by){_445=(new Date()).getTime();if(this._clearActiveWidgetsTimer){clearTimeout(this._clearActiveWidgetsTimer);delete this._clearActiveWidgetsTimer;}if(_43c.contains(node,"dijitPopup")){node=node.firstChild;}var _44d=[];try{while(node){var _44e=_43b.get(node,"dijitPopupParent");if(_44e){node=_442.byId(_44e).domNode;}else{if(node.tagName&&node.tagName.toLowerCase()=="body"){if(node===win.body()){break;}node=_441.get(node.ownerDocument).frameElement;}else{var id=node.getAttribute&&node.getAttribute("widgetId"),_44f=id&&_442.byId(id);if(_44f&&!(by=="mouse"&&_44f.get("disabled"))){_44d.unshift(id);}node=node.parentNode;}}}}catch(e){}this._setStack(_44d,by);},_onFocusNode:function(node){if(!node){return;}if(node.nodeType==9){return;}_444=(new Date()).getTime();if(this._clearFocusTimer){clearTimeout(this._clearFocusTimer);delete this._clearFocusTimer;}this._onTouchNode(node);if(node==this.curNode){return;}this.set("prevNode",this.curNode);this.set("curNode",node);},_setStack:function(_450,by){var _451=this.activeStack,_452=_451.length-1,_453=_450.length-1;if(_450[_453]==_451[_452]){return;}this.set("activeStack",_450);var _454,i;for(i=_452;i>=0&&_451[i]!=_450[i];i--){_454=_442.byId(_451[i]);if(_454){_454._hasBeenBlurred=true;_454.set("focused",false);if(_454._focusManager==this){_454._onBlur(by);}this.emit("widget-blur",_454,by);}}for(i++;i<=_453;i++){_454=_442.byId(_450[i]);if(_454){_454.set("focused",true);if(_454._focusManager==this){_454._onFocus(by);}this.emit("widget-focus",_454,by);}}},focus:function(node){if(node){try{node.focus();}catch(e){}}}});var _455=new _446();_43f(function(){var _456=_455.registerWin(_441.get(document));if(has("ie")){on(window,"unload",function(){if(_456){_456.remove();_456=null;}});}});_443.focus=function(node){_455.focus(node);};for(var attr in _455){if(!/^_/.test(attr)){_443.focus[attr]=typeof _455[attr]=="function"?lang.hitch(_455,attr):_455[attr];}}_455.watch(function(attr,_457,_458){_443.focus[attr]=_458;});return _455;});},"dijit/selection":function(){define(["dojo/_base/array","dojo/dom","dojo/_base/lang","dojo/sniff","dojo/_base/window","dijit/focus"],function(_459,dom,lang,has,_45a,_45b){var _45c=function(win){var doc=win.document;this.getType=function(){if(doc.getSelection){var _45d="text";var oSel;try{oSel=win.getSelection();}catch(e){}if(oSel&&oSel.rangeCount==1){var _45e=oSel.getRangeAt(0);if((_45e.startContainer==_45e.endContainer)&&((_45e.endOffset-_45e.startOffset)==1)&&(_45e.startContainer.nodeType!=3)){_45d="control";}}return _45d;}else{return doc.selection.type.toLowerCase();}};this.getSelectedText=function(){if(doc.getSelection){var _45f=win.getSelection();return _45f?_45f.toString():"";}else{if(this.getType()=="control"){return null;}return doc.selection.createRange().text;}};this.getSelectedHtml=function(){if(doc.getSelection){var _460=win.getSelection();if(_460&&_460.rangeCount){var i;var html="";for(i=0;i<_460.rangeCount;i++){var frag=_460.getRangeAt(i).cloneContents();var div=doc.createElement("div");div.appendChild(frag);html+=div.innerHTML;}return html;}return null;}else{if(this.getType()=="control"){return null;}return doc.selection.createRange().htmlText;}};this.getSelectedElement=function(){if(this.getType()=="control"){if(doc.getSelection){var _461=win.getSelection();return _461.anchorNode.childNodes[_461.anchorOffset];}else{var _462=doc.selection.createRange();if(_462&&_462.item){return doc.selection.createRange().item(0);}}}return null;};this.getParentElement=function(){if(this.getType()=="control"){var p=this.getSelectedElement();if(p){return p.parentNode;}}else{if(doc.getSelection){var _463=doc.getSelection();if(_463){var node=_463.anchorNode;while(node&&(node.nodeType!=1)){node=node.parentNode;}return node;}}else{var r=doc.selection.createRange();r.collapse(true);return r.parentElement();}}return null;};this.hasAncestorElement=function(_464){return this.getAncestorElement.apply(this,arguments)!=null;};this.getAncestorElement=function(_465){var node=this.getSelectedElement()||this.getParentElement();return this.getParentOfType(node,arguments);};this.isTag=function(node,tags){if(node&&node.tagName){var _466=node.tagName.toLowerCase();for(var i=0;i<tags.length;i++){var _467=String(tags[i]).toLowerCase();if(_466==_467){return _467;}}}return "";};this.getParentOfType=function(node,tags){while(node){if(this.isTag(node,tags).length){return node;}node=node.parentNode;}return null;};this.collapse=function(_468){if(doc.getSelection){var _469=win.getSelection();if(_469.removeAllRanges){if(_468){_469.collapseToStart();}else{_469.collapseToEnd();}}else{_469.collapse(_468);}}else{var _46a=doc.selection.createRange();_46a.collapse(_468);_46a.select();}};this.remove=function(){var sel=doc.selection;if(doc.getSelection){sel=win.getSelection();sel.deleteFromDocument();return sel;}else{if(sel.type.toLowerCase()!="none"){sel.clear();}return sel;}};this.selectElementChildren=function(_46b,_46c){var _46d;_46b=dom.byId(_46b);if(doc.getSelection){var _46e=win.getSelection();if(has("opera")){if(_46e.rangeCount){_46d=_46e.getRangeAt(0);}else{_46d=doc.createRange();}_46d.setStart(_46b,0);_46d.setEnd(_46b,(_46b.nodeType==3)?_46b.length:_46b.childNodes.length);_46e.addRange(_46d);}else{_46e.selectAllChildren(_46b);}}else{_46d=_46b.ownerDocument.body.createTextRange();_46d.moveToElementText(_46b);if(!_46c){try{_46d.select();}catch(e){}}}};this.selectElement=function(_46f,_470){var _471;_46f=dom.byId(_46f);if(doc.getSelection){var _472=doc.getSelection();_471=doc.createRange();if(_472.removeAllRanges){if(has("opera")){if(_472.getRangeAt(0)){_471=_472.getRangeAt(0);}}_471.selectNode(_46f);_472.removeAllRanges();_472.addRange(_471);}}else{try{var tg=_46f.tagName?_46f.tagName.toLowerCase():"";if(tg==="img"||tg==="table"){_471=_45a.body(doc).createControlRange();}else{_471=_45a.body(doc).createRange();}_471.addElement(_46f);if(!_470){_471.select();}}catch(e){this.selectElementChildren(_46f,_470);}}};this.inSelection=function(node){if(node){var _473;var _474;if(doc.getSelection){var sel=win.getSelection();if(sel&&sel.rangeCount>0){_474=sel.getRangeAt(0);}if(_474&&_474.compareBoundaryPoints&&doc.createRange){try{_473=doc.createRange();_473.setStart(node,0);if(_474.compareBoundaryPoints(_474.START_TO_END,_473)===1){return true;}}catch(e){}}}else{_474=doc.selection.createRange();try{_473=node.ownerDocument.body.createTextRange();_473.moveToElementText(node);}catch(e2){}if(_474&&_473){if(_474.compareEndPoints("EndToStart",_473)===1){return true;}}}}return false;};this.getBookmark=function(){var bm,rg,tg,sel=doc.selection,cf=_45b.curNode;if(doc.getSelection){sel=win.getSelection();if(sel){if(sel.isCollapsed){tg=cf?cf.tagName:"";if(tg){tg=tg.toLowerCase();if(tg=="textarea"||(tg=="input"&&(!cf.type||cf.type.toLowerCase()=="text"))){sel={start:cf.selectionStart,end:cf.selectionEnd,node:cf,pRange:true};return {isCollapsed:(sel.end<=sel.start),mark:sel};}}bm={isCollapsed:true};if(sel.rangeCount){bm.mark=sel.getRangeAt(0).cloneRange();}}else{rg=sel.getRangeAt(0);bm={isCollapsed:false,mark:rg.cloneRange()};}}}else{if(sel){tg=cf?cf.tagName:"";tg=tg.toLowerCase();if(cf&&tg&&(tg=="button"||tg=="textarea"||tg=="input")){if(sel.type&&sel.type.toLowerCase()=="none"){return {isCollapsed:true,mark:null};}else{rg=sel.createRange();return {isCollapsed:rg.text&&rg.text.length?false:true,mark:{range:rg,pRange:true}};}}bm={};try{rg=sel.createRange();bm.isCollapsed=!(sel.type=="Text"?rg.htmlText.length:rg.length);}catch(e){bm.isCollapsed=true;return bm;}if(sel.type.toUpperCase()=="CONTROL"){if(rg.length){bm.mark=[];var i=0,len=rg.length;while(i<len){bm.mark.push(rg.item(i++));}}else{bm.isCollapsed=true;bm.mark=null;}}else{bm.mark=rg.getBookmark();}}else{console.warn("No idea how to store the current selection for this browser!");}}return bm;};this.moveToBookmark=function(_475){var mark=_475.mark;if(mark){if(doc.getSelection){var sel=win.getSelection();if(sel&&sel.removeAllRanges){if(mark.pRange){var n=mark.node;n.selectionStart=mark.start;n.selectionEnd=mark.end;}else{sel.removeAllRanges();sel.addRange(mark);}}else{console.warn("No idea how to restore selection for this browser!");}}else{if(doc.selection&&mark){var rg;if(mark.pRange){rg=mark.range;}else{if(lang.isArray(mark)){rg=doc.body.createControlRange();_459.forEach(mark,function(n){rg.addElement(n);});}else{rg=doc.body.createTextRange();rg.moveToBookmark(mark);}}rg.select();}}}};this.isCollapsed=function(){return this.getBookmark().isCollapsed;};};var _476=new _45c(window);_476.SelectionManager=_45c;return _476;});},"dijit/_base/manager":function(){define(["dojo/_base/array","dojo/_base/config","dojo/_base/lang","../registry","../main"],function(_477,_478,lang,_479,_47a){var _47b={};_477.forEach(["byId","getUniqueId","findWidgets","_destroyAll","byNode","getEnclosingWidget"],function(name){_47b[name]=_479[name];});lang.mixin(_47b,{defaultDuration:_478["defaultDuration"]||200});lang.mixin(_47a,_47b);return _47a;});},"dijit/_base/place":function(){define(["dojo/_base/array","dojo/_base/lang","dojo/window","../place","../main"],function(_47c,lang,_47d,_47e,_47f){var _480={};_480.getViewport=function(){return _47d.getBox();};_480.placeOnScreen=_47e.at;_480.placeOnScreenAroundElement=function(node,_481,_482,_483){var _484;if(lang.isArray(_482)){_484=_482;}else{_484=[];for(var key in _482){_484.push({aroundCorner:key,corner:_482[key]});}}return _47e.around(node,_481,_484,true,_483);};_480.placeOnScreenAroundNode=_480.placeOnScreenAroundElement;_480.placeOnScreenAroundRectangle=_480.placeOnScreenAroundElement;_480.getPopupAroundAlignment=function(_485,_486){var _487={};_47c.forEach(_485,function(pos){var ltr=_486;switch(pos){case "after":_487[_486?"BR":"BL"]=_486?"BL":"BR";break;case "before":_487[_486?"BL":"BR"]=_486?"BR":"BL";break;case "below-alt":ltr=!ltr;case "below":_487[ltr?"BL":"BR"]=ltr?"TL":"TR";_487[ltr?"BR":"BL"]=ltr?"TR":"TL";break;case "above-alt":ltr=!ltr;case "above":default:_487[ltr?"TL":"TR"]=ltr?"BL":"BR";_487[ltr?"TR":"TL"]=ltr?"BR":"BL";break;}});return _487;};lang.mixin(_47f,_480);return _47f;});},"dijit/place":function(){define(["dojo/_base/array","dojo/dom-geometry","dojo/dom-style","dojo/_base/kernel","dojo/_base/window","./Viewport","./main"],function(_488,_489,_48a,_48b,win,_48c,_48d){function _48e(node,_48f,_490,_491){var view=_48c.getEffectiveBox(node.ownerDocument);if(!node.parentNode||String(node.parentNode.tagName).toLowerCase()!="body"){win.body(node.ownerDocument).appendChild(node);}var best=null;_488.some(_48f,function(_492){var _493=_492.corner;var pos=_492.pos;var _494=0;var _495={w:{"L":view.l+view.w-pos.x,"R":pos.x-view.l,"M":view.w}[_493.charAt(1)],h:{"T":view.t+view.h-pos.y,"B":pos.y-view.t,"M":view.h}[_493.charAt(0)]};var s=node.style;s.left=s.right="auto";if(_490){var res=_490(node,_492.aroundCorner,_493,_495,_491);_494=typeof res=="undefined"?0:res;}var _496=node.style;var _497=_496.display;var _498=_496.visibility;if(_496.display=="none"){_496.visibility="hidden";_496.display="";}var bb=_489.position(node);_496.display=_497;_496.visibility=_498;var _499={"L":pos.x,"R":pos.x-bb.w,"M":Math.max(view.l,Math.min(view.l+view.w,pos.x+(bb.w>>1))-bb.w)}[_493.charAt(1)],_49a={"T":pos.y,"B":pos.y-bb.h,"M":Math.max(view.t,Math.min(view.t+view.h,pos.y+(bb.h>>1))-bb.h)}[_493.charAt(0)],_49b=Math.max(view.l,_499),_49c=Math.max(view.t,_49a),endX=Math.min(view.l+view.w,_499+bb.w),endY=Math.min(view.t+view.h,_49a+bb.h),_49d=endX-_49b,_49e=endY-_49c;_494+=(bb.w-_49d)+(bb.h-_49e);if(best==null||_494<best.overflow){best={corner:_493,aroundCorner:_492.aroundCorner,x:_49b,y:_49c,w:_49d,h:_49e,overflow:_494,spaceAvailable:_495};}return !_494;});if(best.overflow&&_490){_490(node,best.aroundCorner,best.corner,best.spaceAvailable,_491);}var top=best.y,side=best.x,body=win.body(node.ownerDocument);if(/relative|absolute/.test(_48a.get(body,"position"))){top-=_48a.get(body,"marginTop");side-=_48a.get(body,"marginLeft");}var s=node.style;s.top=top+"px";s.left=side+"px";s.right="auto";return best;};var _49f={"TL":"BR","TR":"BL","BL":"TR","BR":"TL"};var _4a0={at:function(node,pos,_4a1,_4a2,_4a3){var _4a4=_488.map(_4a1,function(_4a5){var c={corner:_4a5,aroundCorner:_49f[_4a5],pos:{x:pos.x,y:pos.y}};if(_4a2){c.pos.x+=_4a5.charAt(1)=="L"?_4a2.x:-_4a2.x;c.pos.y+=_4a5.charAt(0)=="T"?_4a2.y:-_4a2.y;}return c;});return _48e(node,_4a4,_4a3);},around:function(node,_4a6,_4a7,_4a8,_4a9){var _4aa;if(typeof _4a6=="string"||"offsetWidth" in _4a6||"ownerSVGElement" in _4a6){_4aa=_489.position(_4a6,true);if(/^(above|below)/.test(_4a7[0])){var _4ab=_489.getBorderExtents(_4a6),_4ac=_4a6.firstChild?_489.getBorderExtents(_4a6.firstChild):{t:0,l:0,b:0,r:0},_4ad=_489.getBorderExtents(node),_4ae=node.firstChild?_489.getBorderExtents(node.firstChild):{t:0,l:0,b:0,r:0};_4aa.y+=Math.min(_4ab.t+_4ac.t,_4ad.t+_4ae.t);_4aa.h-=Math.min(_4ab.t+_4ac.t,_4ad.t+_4ae.t)+Math.min(_4ab.b+_4ac.b,_4ad.b+_4ae.b);}}else{_4aa=_4a6;}if(_4a6.parentNode){var _4af=_48a.getComputedStyle(_4a6).position=="absolute";var _4b0=_4a6.parentNode;while(_4b0&&_4b0.nodeType==1&&_4b0.nodeName!="BODY"){var _4b1=_489.position(_4b0,true),pcs=_48a.getComputedStyle(_4b0);if(/relative|absolute/.test(pcs.position)){_4af=false;}if(!_4af&&/hidden|auto|scroll/.test(pcs.overflow)){var _4b2=Math.min(_4aa.y+_4aa.h,_4b1.y+_4b1.h);var _4b3=Math.min(_4aa.x+_4aa.w,_4b1.x+_4b1.w);_4aa.x=Math.max(_4aa.x,_4b1.x);_4aa.y=Math.max(_4aa.y,_4b1.y);_4aa.h=_4b2-_4aa.y;_4aa.w=_4b3-_4aa.x;}if(pcs.position=="absolute"){_4af=true;}_4b0=_4b0.parentNode;}}var x=_4aa.x,y=_4aa.y,_4b4="w" in _4aa?_4aa.w:(_4aa.w=_4aa.width),_4b5="h" in _4aa?_4aa.h:(_48b.deprecated("place.around: dijit/place.__Rectangle: { x:"+x+", y:"+y+", height:"+_4aa.height+", width:"+_4b4+" } has been deprecated.  Please use { x:"+x+", y:"+y+", h:"+_4aa.height+", w:"+_4b4+" }","","2.0"),_4aa.h=_4aa.height);var _4b6=[];function push(_4b7,_4b8){_4b6.push({aroundCorner:_4b7,corner:_4b8,pos:{x:{"L":x,"R":x+_4b4,"M":x+(_4b4>>1)}[_4b7.charAt(1)],y:{"T":y,"B":y+_4b5,"M":y+(_4b5>>1)}[_4b7.charAt(0)]}});};_488.forEach(_4a7,function(pos){var ltr=_4a8;switch(pos){case "above-centered":push("TM","BM");break;case "below-centered":push("BM","TM");break;case "after-centered":ltr=!ltr;case "before-centered":push(ltr?"ML":"MR",ltr?"MR":"ML");break;case "after":ltr=!ltr;case "before":push(ltr?"TL":"TR",ltr?"TR":"TL");push(ltr?"BL":"BR",ltr?"BR":"BL");break;case "below-alt":ltr=!ltr;case "below":push(ltr?"BL":"BR",ltr?"TL":"TR");push(ltr?"BR":"BL",ltr?"TR":"TL");break;case "above-alt":ltr=!ltr;case "above":push(ltr?"TL":"TR",ltr?"BL":"BR");push(ltr?"TR":"TL",ltr?"BR":"BL");break;default:push(pos.aroundCorner,pos.corner);}});var _4b9=_48e(node,_4b6,_4a9,{w:_4b4,h:_4b5});_4b9.aroundNodePos=_4aa;return _4b9;}};return _48d.place=_4a0;});},"dijit/Viewport":function(){define(["dojo/Evented","dojo/on","dojo/domReady","dojo/sniff","dojo/window"],function(_4ba,on,_4bb,has,_4bc){var _4bd=new _4ba();var _4be;_4bb(function(){var _4bf=_4bc.getBox();_4bd._rlh=on(window,"resize",function(){var _4c0=_4bc.getBox();if(_4bf.h==_4c0.h&&_4bf.w==_4c0.w){return;}_4bf=_4c0;_4bd.emit("resize");});if(has("ie")==8){var _4c1=screen.deviceXDPI;setInterval(function(){if(screen.deviceXDPI!=_4c1){_4c1=screen.deviceXDPI;_4bd.emit("resize");}},500);}if(has("ios")){on(document,"focusin",function(evt){_4be=evt.target;});on(document,"focusout",function(evt){_4be=null;});}});_4bd.getEffectiveBox=function(doc){var box=_4bc.getBox(doc);var tag=_4be&&_4be.tagName&&_4be.tagName.toLowerCase();if(has("ios")&&_4be&&!_4be.readOnly&&(tag=="textarea"||(tag=="input"&&/^(color|email|number|password|search|tel|text|url)$/.test(_4be.type)))){box.h*=(orientation==0||orientation==180?0.66:0.4);var rect=_4be.getBoundingClientRect();box.h=Math.max(box.h,rect.top+rect.height);}return box;};return _4bd;});},"dijit/_base/popup":function(){define(["dojo/dom-class","dojo/_base/window","../popup","../BackgroundIframe"],function(_4c2,win,_4c3){var _4c4=_4c3._createWrapper;_4c3._createWrapper=function(_4c5){if(!_4c5.declaredClass){_4c5={_popupWrapper:(_4c5.parentNode&&_4c2.contains(_4c5.parentNode,"dijitPopup"))?_4c5.parentNode:null,domNode:_4c5,destroy:function(){},ownerDocument:_4c5.ownerDocument,ownerDocumentBody:win.body(_4c5.ownerDocument)};}return _4c4.call(this,_4c5);};var _4c6=_4c3.open;_4c3.open=function(args){if(args.orient&&typeof args.orient!="string"&&!("length" in args.orient)){var ary=[];for(var key in args.orient){ary.push({aroundCorner:key,corner:args.orient[key]});}args.orient=ary;}return _4c6.call(this,args);};return _4c3;});},"dijit/popup":function(){define(["dojo/_base/array","dojo/aspect","dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-construct","dojo/dom-geometry","dojo/dom-style","dojo/has","dojo/keys","dojo/_base/lang","dojo/on","./place","./BackgroundIframe","./Viewport","./main","dojo/touch"],function(_4c7,_4c8,_4c9,dom,_4ca,_4cb,_4cc,_4cd,has,keys,lang,on,_4ce,_4cf,_4d0,_4d1){function _4d2(){if(this._popupWrapper){_4cb.destroy(this._popupWrapper);delete this._popupWrapper;}};var _4d3=_4c9(null,{_stack:[],_beginZIndex:1000,_idGen:1,_repositionAll:function(){if(this._firstAroundNode){var _4d4=this._firstAroundPosition,_4d5=_4cc.position(this._firstAroundNode,true),dx=_4d5.x-_4d4.x,dy=_4d5.y-_4d4.y;if(dx||dy){this._firstAroundPosition=_4d5;for(var i=0;i<this._stack.length;i++){var _4d6=this._stack[i].wrapper.style;_4d6.top=(parseFloat(_4d6.top)+dy)+"px";if(_4d6.right=="auto"){_4d6.left=(parseFloat(_4d6.left)+dx)+"px";}else{_4d6.right=(parseFloat(_4d6.right)-dx)+"px";}}}this._aroundMoveListener=setTimeout(lang.hitch(this,"_repositionAll"),dx||dy?10:50);}},_createWrapper:function(_4d7){var _4d8=_4d7._popupWrapper,node=_4d7.domNode;if(!_4d8){_4d8=_4cb.create("div",{"class":"dijitPopup",style:{display:"none"},role:"region","aria-label":_4d7["aria-label"]||_4d7.label||_4d7.name||_4d7.id},_4d7.ownerDocumentBody);_4d8.appendChild(node);var s=node.style;s.display="";s.visibility="";s.position="";s.top="0px";_4d7._popupWrapper=_4d8;_4c8.after(_4d7,"destroy",_4d2,true);if("ontouchend" in document){on(_4d8,"touchend",function(evt){if(!/^(input|button|textarea)$/i.test(evt.target.tagName)){evt.preventDefault();}});}_4d8.dojoClick=true;}return _4d8;},moveOffScreen:function(_4d9){var _4da=this._createWrapper(_4d9);var ltr=_4cc.isBodyLtr(_4d9.ownerDocument),_4db={visibility:"hidden",top:"-9999px",display:""};_4db[ltr?"left":"right"]="-9999px";_4db[ltr?"right":"left"]="auto";_4cd.set(_4da,_4db);return _4da;},hide:function(_4dc){var _4dd=this._createWrapper(_4dc);_4cd.set(_4dd,{display:"none",height:"auto",overflowY:"visible",border:""});var node=_4dc.domNode;if("_originalStyle" in node){node.style.cssText=node._originalStyle;}},getTopPopup:function(){var _4de=this._stack;for(var pi=_4de.length-1;pi>0&&_4de[pi].parent===_4de[pi-1].widget;pi--){}return _4de[pi];},open:function(args){var _4df=this._stack,_4e0=args.popup,node=_4e0.domNode,_4e1=args.orient||["below","below-alt","above","above-alt"],ltr=args.parent?args.parent.isLeftToRight():_4cc.isBodyLtr(_4e0.ownerDocument),_4e2=args.around,id=(args.around&&args.around.id)?(args.around.id+"_dropdown"):("popup_"+this._idGen++);while(_4df.length&&(!args.parent||!dom.isDescendant(args.parent.domNode,_4df[_4df.length-1].widget.domNode))){this.close(_4df[_4df.length-1].widget);}var _4e3=this.moveOffScreen(_4e0);if(_4e0.startup&&!_4e0._started){_4e0.startup();}var _4e4,_4e5=_4cc.position(node);if("maxHeight" in args&&args.maxHeight!=-1){_4e4=args.maxHeight||Infinity;}else{var _4e6=_4d0.getEffectiveBox(this.ownerDocument),_4e7=_4e2?_4cc.position(_4e2,false):{y:args.y-(args.padding||0),h:(args.padding||0)*2};_4e4=Math.floor(Math.max(_4e7.y,_4e6.h-(_4e7.y+_4e7.h)));}if(_4e5.h>_4e4){var cs=_4cd.getComputedStyle(node),_4e8=cs.borderLeftWidth+" "+cs.borderLeftStyle+" "+cs.borderLeftColor;_4cd.set(_4e3,{overflowY:"scroll",height:_4e4+"px",border:_4e8});node._originalStyle=node.style.cssText;node.style.border="none";}_4ca.set(_4e3,{id:id,style:{zIndex:this._beginZIndex+_4df.length},"class":"dijitPopup "+(_4e0.baseClass||_4e0["class"]||"").split(" ")[0]+"Popup",dijitPopupParent:args.parent?args.parent.id:""});if(_4df.length==0&&_4e2){this._firstAroundNode=_4e2;this._firstAroundPosition=_4cc.position(_4e2,true);this._aroundMoveListener=setTimeout(lang.hitch(this,"_repositionAll"),50);}if(has("config-bgIframe")&&!_4e0.bgIframe){_4e0.bgIframe=new _4cf(_4e3);}var _4e9=_4e0.orient?lang.hitch(_4e0,"orient"):null,best=_4e2?_4ce.around(_4e3,_4e2,_4e1,ltr,_4e9):_4ce.at(_4e3,args,_4e1=="R"?["TR","BR","TL","BL"]:["TL","BL","TR","BR"],args.padding,_4e9);_4e3.style.visibility="visible";node.style.visibility="visible";var _4ea=[];_4ea.push(on(_4e3,"keydown",lang.hitch(this,function(evt){if(evt.keyCode==keys.ESCAPE&&args.onCancel){evt.stopPropagation();evt.preventDefault();args.onCancel();}else{if(evt.keyCode==keys.TAB){evt.stopPropagation();evt.preventDefault();var _4eb=this.getTopPopup();if(_4eb&&_4eb.onCancel){_4eb.onCancel();}}}})));if(_4e0.onCancel&&args.onCancel){_4ea.push(_4e0.on("cancel",args.onCancel));}_4ea.push(_4e0.on(_4e0.onExecute?"execute":"change",lang.hitch(this,function(){var _4ec=this.getTopPopup();if(_4ec&&_4ec.onExecute){_4ec.onExecute();}})));_4df.push({widget:_4e0,wrapper:_4e3,parent:args.parent,onExecute:args.onExecute,onCancel:args.onCancel,onClose:args.onClose,handlers:_4ea});if(_4e0.onOpen){_4e0.onOpen(best);}return best;},close:function(_4ed){var _4ee=this._stack;while((_4ed&&_4c7.some(_4ee,function(elem){return elem.widget==_4ed;}))||(!_4ed&&_4ee.length)){var top=_4ee.pop(),_4ef=top.widget,_4f0=top.onClose;if(_4ef.bgIframe){_4ef.bgIframe.destroy();delete _4ef.bgIframe;}if(_4ef.onClose){_4ef.onClose();}var h;while(h=top.handlers.pop()){h.remove();}if(_4ef&&_4ef.domNode){this.hide(_4ef);}if(_4f0){_4f0();}}if(_4ee.length==0&&this._aroundMoveListener){clearTimeout(this._aroundMoveListener);this._firstAroundNode=this._firstAroundPosition=this._aroundMoveListener=null;}}});return (_4d1.popup=new _4d3());});},"dijit/BackgroundIframe":function(){define(["require","./main","dojo/_base/config","dojo/dom-construct","dojo/dom-style","dojo/_base/lang","dojo/on","dojo/sniff"],function(_4f1,_4f2,_4f3,_4f4,_4f5,lang,on,has){has.add("config-bgIframe",(has("ie")||has("trident"))&&!/IEMobile\/10\.0/.test(navigator.userAgent));var _4f6=new function(){var _4f7=[];this.pop=function(){var _4f8;if(_4f7.length){_4f8=_4f7.pop();_4f8.style.display="";}else{if(has("ie")<9){var burl=_4f3["dojoBlankHtmlUrl"]||_4f1.toUrl("dojo/resources/blank.html")||"javascript:\"\"";var html="<iframe src='"+burl+"' role='presentation'"+" style='position: absolute; left: 0px; top: 0px;"+"z-index: -1; filter:Alpha(Opacity=\"0\");'>";_4f8=document.createElement(html);}else{_4f8=_4f4.create("iframe");_4f8.src="javascript:\"\"";_4f8.className="dijitBackgroundIframe";_4f8.setAttribute("role","presentation");_4f5.set(_4f8,"opacity",0.1);}_4f8.tabIndex=-1;}return _4f8;};this.push=function(_4f9){_4f9.style.display="none";_4f7.push(_4f9);};}();_4f2.BackgroundIframe=function(node){if(!node.id){throw new Error("no id");}if(has("config-bgIframe")){var _4fa=(this.iframe=_4f6.pop());node.appendChild(_4fa);if(has("ie")<7||has("quirks")){this.resize(node);this._conn=on(node,"resize",lang.hitch(this,"resize",node));}else{_4f5.set(_4fa,{width:"100%",height:"100%"});}}};lang.extend(_4f2.BackgroundIframe,{resize:function(node){if(this.iframe){_4f5.set(this.iframe,{width:node.offsetWidth+"px",height:node.offsetHeight+"px"});}},destroy:function(){if(this._conn){this._conn.remove();this._conn=null;}if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);_4f6.push(this.iframe);delete this.iframe;}}});return _4f2.BackgroundIframe;});},"dijit/_base/scroll":function(){define(["dojo/window","../main"],function(_4fb,_4fc){_4fc.scrollIntoView=function(node,pos){_4fb.scrollIntoView(node,pos);};});},"dijit/_base/sniff":function(){define(["dojo/uacss"],function(){});},"dijit/_base/typematic":function(){define(["../typematic"],function(){});},"dijit/typematic":function(){define(["dojo/_base/array","dojo/_base/connect","dojo/_base/lang","dojo/on","dojo/sniff","./main"],function(_4fd,_4fe,lang,on,has,_4ff){var _500=(_4ff.typematic={_fireEventAndReload:function(){this._timer=null;this._callback(++this._count,this._node,this._evt);this._currentTimeout=Math.max(this._currentTimeout<0?this._initialDelay:(this._subsequentDelay>1?this._subsequentDelay:Math.round(this._currentTimeout*this._subsequentDelay)),this._minDelay);this._timer=setTimeout(lang.hitch(this,"_fireEventAndReload"),this._currentTimeout);},trigger:function(evt,_501,node,_502,obj,_503,_504,_505){if(obj!=this._obj){this.stop();this._initialDelay=_504||500;this._subsequentDelay=_503||0.9;this._minDelay=_505||10;this._obj=obj;this._node=node;this._currentTimeout=-1;this._count=-1;this._callback=lang.hitch(_501,_502);this._evt={faux:true};for(var attr in evt){if(attr!="layerX"&&attr!="layerY"){var v=evt[attr];if(typeof v!="function"&&typeof v!="undefined"){this._evt[attr]=v;}}}this._fireEventAndReload();}},stop:function(){if(this._timer){clearTimeout(this._timer);this._timer=null;}if(this._obj){this._callback(-1,this._node,this._evt);this._obj=null;}},addKeyListener:function(node,_506,_507,_508,_509,_50a,_50b){var type="keyCode" in _506?"keydown":"charCode" in _506?"keypress":_4fe._keypress,attr="keyCode" in _506?"keyCode":"charCode" in _506?"charCode":"charOrCode";var _50c=[on(node,type,lang.hitch(this,function(evt){if(evt[attr]==_506[attr]&&(_506.ctrlKey===undefined||_506.ctrlKey==evt.ctrlKey)&&(_506.altKey===undefined||_506.altKey==evt.altKey)&&(_506.metaKey===undefined||_506.metaKey==(evt.metaKey||false))&&(_506.shiftKey===undefined||_506.shiftKey==evt.shiftKey)){evt.stopPropagation();evt.preventDefault();_500.trigger(evt,_507,node,_508,_506,_509,_50a,_50b);}else{if(_500._obj==_506){_500.stop();}}})),on(node,"keyup",lang.hitch(this,function(){if(_500._obj==_506){_500.stop();}}))];return {remove:function(){_4fd.forEach(_50c,function(h){h.remove();});}};},addMouseListener:function(node,_50d,_50e,_50f,_510,_511){var _512=[on(node,"mousedown",lang.hitch(this,function(evt){evt.preventDefault();_500.trigger(evt,_50d,node,_50e,node,_50f,_510,_511);})),on(node,"mouseup",lang.hitch(this,function(evt){if(this._obj){evt.preventDefault();}_500.stop();})),on(node,"mouseout",lang.hitch(this,function(evt){if(this._obj){evt.preventDefault();}_500.stop();})),on(node,"dblclick",lang.hitch(this,function(evt){evt.preventDefault();if(has("ie")<9){_500.trigger(evt,_50d,node,_50e,node,_50f,_510,_511);setTimeout(lang.hitch(this,_500.stop),50);}}))];return {remove:function(){_4fd.forEach(_512,function(h){h.remove();});}};},addListener:function(_513,_514,_515,_516,_517,_518,_519,_51a){var _51b=[this.addKeyListener(_514,_515,_516,_517,_518,_519,_51a),this.addMouseListener(_513,_516,_517,_518,_519,_51a)];return {remove:function(){_4fd.forEach(_51b,function(h){h.remove();});}};}});return _500;});},"dijit/_base/wai":function(){define(["dojo/dom-attr","dojo/_base/lang","../main","../hccss"],function(_51c,lang,_51d){var _51e={hasWaiRole:function(elem,role){var _51f=this.getWaiRole(elem);return role?(_51f.indexOf(role)>-1):(_51f.length>0);},getWaiRole:function(elem){return lang.trim((_51c.get(elem,"role")||"").replace("wairole:",""));},setWaiRole:function(elem,role){_51c.set(elem,"role",role);},removeWaiRole:function(elem,role){var _520=_51c.get(elem,"role");if(!_520){return;}if(role){var t=lang.trim((" "+_520+" ").replace(" "+role+" "," "));_51c.set(elem,"role",t);}else{elem.removeAttribute("role");}},hasWaiState:function(elem,_521){return elem.hasAttribute?elem.hasAttribute("aria-"+_521):!!elem.getAttribute("aria-"+_521);},getWaiState:function(elem,_522){return elem.getAttribute("aria-"+_522)||"";},setWaiState:function(elem,_523,_524){elem.setAttribute("aria-"+_523,_524);},removeWaiState:function(elem,_525){elem.removeAttribute("aria-"+_525);}};lang.mixin(_51d,_51e);return _51d;});},"dijit/hccss":function(){define(["dojo/dom-class","dojo/hccss","dojo/domReady","dojo/_base/window"],function(_526,has,_527,win){_527(function(){if(has("highcontrast")){_526.add(win.body(),"dijit_a11y");}});return has;});},"dojo/hccss":function(){define(["require","./_base/config","./dom-class","./dom-style","./has","./domReady","./_base/window"],function(_528,_529,_52a,_52b,has,_52c,win){has.add("highcontrast",function(){var div=win.doc.createElement("div");try{div.style.cssText="border: 1px solid; border-color:red green; position: absolute; height: 5px; top: -999px;"+"background-image: url(\""+(_529.blankGif||_528.toUrl("./resources/blank.gif"))+"\");";win.body().appendChild(div);var cs=_52b.getComputedStyle(div),_52d=cs.backgroundImage;return cs.borderTopColor==cs.borderRightColor||(_52d&&(_52d=="none"||_52d=="url(invalid-url:)"));}catch(e){console.warn("hccss: exception detecting high-contrast mode, document is likely hidden: "+e.toString());return false;}finally{if(has("ie")<=8){div.outerHTML="";}else{win.body().removeChild(div);}}});_52c(function(){if(has("highcontrast")){_52a.add(win.body(),"dj_a11y");}});return has;});},"dijit/_base/window":function(){define(["dojo/window","../main"],function(_52e,_52f){_52f.getDocumentWindow=function(doc){return _52e.get(doc);};});},"dijit/_Widget":function(){define(["dojo/aspect","dojo/_base/config","dojo/_base/connect","dojo/_base/declare","dojo/has","dojo/_base/kernel","dojo/_base/lang","dojo/query","dojo/ready","./registry","./_WidgetBase","./_OnDijitClickMixin","./_FocusMixin","dojo/uacss","./hccss"],function(_530,_531,_532,_533,has,_534,lang,_535,_536,_537,_538,_539,_53a){function _53b(){};function _53c(_53d){return function(obj,_53e,_53f,_540){if(obj&&typeof _53e=="string"&&obj[_53e]==_53b){return obj.on(_53e.substring(2).toLowerCase(),lang.hitch(_53f,_540));}return _53d.apply(_532,arguments);};};_530.around(_532,"connect",_53c);if(_534.connect){_530.around(_534,"connect",_53c);}var _541=_533("dijit._Widget",[_538,_539,_53a],{onClick:_53b,onDblClick:_53b,onKeyDown:_53b,onKeyPress:_53b,onKeyUp:_53b,onMouseDown:_53b,onMouseMove:_53b,onMouseOut:_53b,onMouseOver:_53b,onMouseLeave:_53b,onMouseEnter:_53b,onMouseUp:_53b,constructor:function(_542){this._toConnect={};for(var name in _542){if(this[name]===_53b){this._toConnect[name.replace(/^on/,"").toLowerCase()]=_542[name];delete _542[name];}}},postCreate:function(){this.inherited(arguments);for(var name in this._toConnect){this.on(name,this._toConnect[name]);}delete this._toConnect;},on:function(type,func){if(this[this._onMap(type)]===_53b){return _532.connect(this.domNode,type.toLowerCase(),this,func);}return this.inherited(arguments);},_setFocusedAttr:function(val){this._focused=val;this._set("focused",val);},setAttribute:function(attr,_543){_534.deprecated(this.declaredClass+"::setAttribute(attr, value) is deprecated. Use set() instead.","","2.0");this.set(attr,_543);},attr:function(name,_544){var args=arguments.length;if(args>=2||typeof name==="object"){return this.set.apply(this,arguments);}else{return this.get(name);}},getDescendants:function(){_534.deprecated(this.declaredClass+"::getDescendants() is deprecated. Use getChildren() instead.","","2.0");return this.containerNode?_535("[widgetId]",this.containerNode).map(_537.byNode):[];},_onShow:function(){this.onShow();},onShow:function(){},onHide:function(){},onClose:function(){return true;}});if(has("dijit-legacy-requires")){_536(0,function(){var _545=["dijit/_base"];require(_545);});}return _541;});},"dijit/_WidgetBase":function(){define(["require","dojo/_base/array","dojo/aspect","dojo/_base/config","dojo/_base/connect","dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","dojo/dom-style","dojo/has","dojo/_base/kernel","dojo/_base/lang","dojo/on","dojo/ready","dojo/Stateful","dojo/topic","dojo/_base/window","./Destroyable","dojo/has!dojo-bidi?./_BidiMixin","./registry"],function(_546,_547,_548,_549,_54a,_54b,dom,_54c,_54d,_54e,_54f,_550,has,_551,lang,on,_552,_553,_554,win,_555,_556,_557){has.add("dijit-legacy-requires",!_551.isAsync);has.add("dojo-bidi",false);if(has("dijit-legacy-requires")){_552(0,function(){var _558=["dijit/_base/manager"];_546(_558);});}var _559={};function _55a(obj){var ret={};for(var attr in obj){ret[attr.toLowerCase()]=true;}return ret;};function _55b(attr){return function(val){_54c[val?"set":"remove"](this.domNode,attr,val);this._set(attr,val);};};function _55c(a,b){return a===b||(a!==a&&b!==b);};var _55d=_54b("dijit._WidgetBase",[_553,_555],{id:"",_setIdAttr:"domNode",lang:"",_setLangAttr:_55b("lang"),dir:"",_setDirAttr:_55b("dir"),"class":"",_setClassAttr:{node:"domNode",type:"class"},_setTypeAttr:null,style:"",title:"",tooltip:"",baseClass:"",srcNodeRef:null,domNode:null,containerNode:null,ownerDocument:null,_setOwnerDocumentAttr:function(val){this._set("ownerDocument",val);},attributeMap:{},_blankGif:_549.blankGif||_546.toUrl("dojo/resources/blank.gif"),textDir:"",_introspect:function(){var ctor=this.constructor;if(!ctor._setterAttrs){var _55e=ctor.prototype,_55f=ctor._setterAttrs=[],_560=(ctor._onMap={});for(var name in _55e.attributeMap){_55f.push(name);}for(name in _55e){if(/^on/.test(name)){_560[name.substring(2).toLowerCase()]=name;}if(/^_set[A-Z](.*)Attr$/.test(name)){name=name.charAt(4).toLowerCase()+name.substr(5,name.length-9);if(!_55e.attributeMap||!(name in _55e.attributeMap)){_55f.push(name);}}}}},postscript:function(_561,_562){this.create(_561,_562);},create:function(_563,_564){this._introspect();this.srcNodeRef=dom.byId(_564);this._connects=[];this._supportingWidgets=[];if(this.srcNodeRef&&this.srcNodeRef.id&&(typeof this.srcNodeRef.id=="string")){this.id=this.srcNodeRef.id;}if(_563){this.params=_563;lang.mixin(this,_563);}this.postMixInProperties();if(!this.id){this.id=_557.getUniqueId(this.declaredClass.replace(/\./g,"_"));if(this.params){delete this.params.id;}}this.ownerDocument=this.ownerDocument||(this.srcNodeRef?this.srcNodeRef.ownerDocument:document);this.ownerDocumentBody=win.body(this.ownerDocument);_557.add(this);this.buildRendering();var _565;if(this.domNode){this._applyAttributes();var _566=this.srcNodeRef;if(_566&&_566.parentNode&&this.domNode!==_566){_566.parentNode.replaceChild(this.domNode,_566);_565=true;}this.domNode.setAttribute("widgetId",this.id);}this.postCreate();if(_565){delete this.srcNodeRef;}this._created=true;},_applyAttributes:function(){var _567={};for(var key in this.params||{}){_567[key]=this._get(key);}_547.forEach(this.constructor._setterAttrs,function(key){if(!(key in _567)){var val=this._get(key);if(val){this.set(key,val);}}},this);for(key in _567){this.set(key,_567[key]);}},postMixInProperties:function(){},buildRendering:function(){if(!this.domNode){this.domNode=this.srcNodeRef||this.ownerDocument.createElement("div");}if(this.baseClass){var _568=this.baseClass.split(" ");if(!this.isLeftToRight()){_568=_568.concat(_547.map(_568,function(name){return name+"Rtl";}));}_54d.add(this.domNode,_568);}},postCreate:function(){},startup:function(){if(this._started){return;}this._started=true;_547.forEach(this.getChildren(),function(obj){if(!obj._started&&!obj._destroyed&&lang.isFunction(obj.startup)){obj.startup();obj._started=true;}});},destroyRecursive:function(_569){this._beingDestroyed=true;this.destroyDescendants(_569);this.destroy(_569);},destroy:function(_56a){this._beingDestroyed=true;this.uninitialize();function _56b(w){if(w.destroyRecursive){w.destroyRecursive(_56a);}else{if(w.destroy){w.destroy(_56a);}}};_547.forEach(this._connects,lang.hitch(this,"disconnect"));_547.forEach(this._supportingWidgets,_56b);if(this.domNode){_547.forEach(_557.findWidgets(this.domNode,this.containerNode),_56b);}this.destroyRendering(_56a);_557.remove(this.id);this._destroyed=true;},destroyRendering:function(_56c){if(this.bgIframe){this.bgIframe.destroy(_56c);delete this.bgIframe;}if(this.domNode){if(_56c){_54c.remove(this.domNode,"widgetId");}else{_54e.destroy(this.domNode);}delete this.domNode;}if(this.srcNodeRef){if(!_56c){_54e.destroy(this.srcNodeRef);}delete this.srcNodeRef;}},destroyDescendants:function(_56d){_547.forEach(this.getChildren(),function(_56e){if(_56e.destroyRecursive){_56e.destroyRecursive(_56d);}});},uninitialize:function(){return false;},_setStyleAttr:function(_56f){var _570=this.domNode;if(lang.isObject(_56f)){_550.set(_570,_56f);}else{if(_570.style.cssText){_570.style.cssText+="; "+_56f;}else{_570.style.cssText=_56f;}}this._set("style",_56f);},_attrToDom:function(attr,_571,_572){_572=arguments.length>=3?_572:this.attributeMap[attr];_547.forEach(lang.isArray(_572)?_572:[_572],function(_573){var _574=this[_573.node||_573||"domNode"];var type=_573.type||"attribute";switch(type){case "attribute":if(lang.isFunction(_571)){_571=lang.hitch(this,_571);}var _575=_573.attribute?_573.attribute:(/^on[A-Z][a-zA-Z]*$/.test(attr)?attr.toLowerCase():attr);if(_574.tagName){_54c.set(_574,_575,_571);}else{_574.set(_575,_571);}break;case "innerText":_574.innerHTML="";_574.appendChild(this.ownerDocument.createTextNode(_571));break;case "textContent":_574.textContent=_571;break;case "innerHTML":_574.innerHTML=_571;break;case "class":_54d.replace(_574,_571,this[attr]);break;case "toggleClass":_54d.toggle(_574,_573.className||attr,_571);break;}},this);},get:function(name){var _576=this._getAttrNames(name);return this[_576.g]?this[_576.g]():this._get(name);},set:function(name,_577){if(typeof name==="object"){for(var x in name){this.set(x,name[x]);}return this;}var _578=this._getAttrNames(name),_579=this[_578.s];if(lang.isFunction(_579)){var _57a=_579.apply(this,Array.prototype.slice.call(arguments,1));}else{var _57b=this.focusNode&&!lang.isFunction(this.focusNode)?"focusNode":"domNode",tag=this[_57b]&&this[_57b].tagName,_57c=tag&&(_559[tag]||(_559[tag]=_55a(this[_57b]))),map=name in this.attributeMap?this.attributeMap[name]:_578.s in this?this[_578.s]:((_57c&&_578.l in _57c&&typeof _577!="function")||/^aria-|^data-|^role$/.test(name))?_57b:null;if(map!=null){this._attrToDom(name,_577,map);}this._set(name,_577);}return _57a||this;},_attrPairNames:{},_getAttrNames:function(name){var apn=this._attrPairNames;if(apn[name]){return apn[name];}var uc=name.replace(/^[a-z]|-[a-zA-Z]/g,function(c){return c.charAt(c.length-1).toUpperCase();});return (apn[name]={n:name+"Node",s:"_set"+uc+"Attr",g:"_get"+uc+"Attr",l:uc.toLowerCase()});},_set:function(name,_57d){var _57e=this[name];this[name]=_57d;if(this._created&&!_55c(_57e,_57d)){if(this._watchCallbacks){this._watchCallbacks(name,_57e,_57d);}this.emit("attrmodified-"+name,{detail:{prevValue:_57e,newValue:_57d}});}},_get:function(name){return this[name];},emit:function(type,_57f,_580){_57f=_57f||{};if(_57f.bubbles===undefined){_57f.bubbles=true;}if(_57f.cancelable===undefined){_57f.cancelable=true;}if(!_57f.detail){_57f.detail={};}_57f.detail.widget=this;var ret,_581=this["on"+type];if(_581){ret=_581.apply(this,_580?_580:[_57f]);}if(this._started&&!this._beingDestroyed){on.emit(this.domNode,type.toLowerCase(),_57f);}return ret;},on:function(type,func){var _582=this._onMap(type);if(_582){return _548.after(this,_582,func,true);}return this.own(on(this.domNode,type,func))[0];},_onMap:function(type){var ctor=this.constructor,map=ctor._onMap;if(!map){map=(ctor._onMap={});for(var attr in ctor.prototype){if(/^on/.test(attr)){map[attr.replace(/^on/,"").toLowerCase()]=attr;}}}return map[typeof type=="string"&&type.toLowerCase()];},toString:function(){return "[Widget "+this.declaredClass+", "+(this.id||"NO ID")+"]";},getChildren:function(){return this.containerNode?_557.findWidgets(this.containerNode):[];},getParent:function(){return _557.getEnclosingWidget(this.domNode.parentNode);},connect:function(obj,_583,_584){return this.own(_54a.connect(obj,_583,this,_584))[0];},disconnect:function(_585){_585.remove();},subscribe:function(t,_586){return this.own(_554.subscribe(t,lang.hitch(this,_586)))[0];},unsubscribe:function(_587){_587.remove();},isLeftToRight:function(){return this.dir?(this.dir.toLowerCase()=="ltr"):_54f.isBodyLtr(this.ownerDocument);},isFocusable:function(){return this.focus&&(_550.get(this.domNode,"display")!="none");},placeAt:function(_588,_589){var _58a=!_588.tagName&&_557.byId(_588);if(_58a&&_58a.addChild&&(!_589||typeof _589==="number")){_58a.addChild(this,_589);}else{var ref=_58a&&("domNode" in _58a)?(_58a.containerNode&&!/after|before|replace/.test(_589||"")?_58a.containerNode:_58a.domNode):dom.byId(_588,this.ownerDocument);_54e.place(this.domNode,ref,_589);if(!this._started&&(this.getParent()||{})._started){this.startup();}}return this;},defer:function(fcn,_58b){var _58c=setTimeout(lang.hitch(this,function(){if(!_58c){return;}_58c=null;if(!this._destroyed){lang.hitch(this,fcn)();}}),_58b||0);return {remove:function(){if(_58c){clearTimeout(_58c);_58c=null;}return null;}};}});if(has("dojo-bidi")){_55d.extend(_556);}return _55d;});},"dijit/Destroyable":function(){define(["dojo/_base/array","dojo/aspect","dojo/_base/declare"],function(_58d,_58e,_58f){return _58f("dijit.Destroyable",null,{destroy:function(_590){this._destroyed=true;},own:function(){var _591=["destroyRecursive","destroy","remove"];_58d.forEach(arguments,function(_592){var _593;var odh=_58e.before(this,"destroy",function(_594){_592[_593](_594);});var hdhs=[];function _595(){odh.remove();_58d.forEach(hdhs,function(hdh){hdh.remove();});};if(_592.then){_593="cancel";_592.then(_595,_595);}else{_58d.forEach(_591,function(_596){if(typeof _592[_596]==="function"){if(!_593){_593=_596;}hdhs.push(_58e.after(_592,_596,_595,true));}});}},this);return arguments;}});});},"dijit/_OnDijitClickMixin":function(){define(["dojo/on","dojo/_base/array","dojo/keys","dojo/_base/declare","dojo/has","./a11yclick"],function(on,_597,keys,_598,has,_599){var ret=_598("dijit._OnDijitClickMixin",null,{connect:function(obj,_59a,_59b){return this.inherited(arguments,[obj,_59a=="ondijitclick"?_599:_59a,_59b]);}});ret.a11yclick=_599;return ret;});},"dijit/a11yclick":function(){define(["dojo/keys","dojo/mouse","dojo/on","dojo/touch"],function(keys,_59c,on,_59d){function _59e(e){if((e.keyCode===keys.ENTER||e.keyCode===keys.SPACE)&&!/input|button|textarea/i.test(e.target.nodeName)){for(var node=e.target;node;node=node.parentNode){if(node.dojoClick){return true;}}}};var _59f;on(document,"keydown",function(e){if(_59e(e)){_59f=e.target;e.preventDefault();}else{_59f=null;}});on(document,"keyup",function(e){if(_59e(e)&&e.target==_59f){_59f=null;on.emit(e.target,"click",{cancelable:true,bubbles:true,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,altKey:e.altKey,_origType:e.type});}});var _5a0=function(node,_5a1){node.dojoClick=true;return on(node,"click",_5a1);};_5a0.click=_5a0;_5a0.press=function(node,_5a2){var _5a3=on(node,_59d.press,function(evt){if(evt.type=="mousedown"&&!_59c.isLeft(evt)){return;}_5a2(evt);}),_5a4=on(node,"keydown",function(evt){if(evt.keyCode===keys.ENTER||evt.keyCode===keys.SPACE){_5a2(evt);}});return {remove:function(){_5a3.remove();_5a4.remove();}};};_5a0.release=function(node,_5a5){var _5a6=on(node,_59d.release,function(evt){if(evt.type=="mouseup"&&!_59c.isLeft(evt)){return;}_5a5(evt);}),_5a7=on(node,"keyup",function(evt){if(evt.keyCode===keys.ENTER||evt.keyCode===keys.SPACE){_5a5(evt);}});return {remove:function(){_5a6.remove();_5a7.remove();}};};_5a0.move=_59d.move;return _5a0;});},"dijit/_FocusMixin":function(){define(["./focus","./_WidgetBase","dojo/_base/declare","dojo/_base/lang"],function(_5a8,_5a9,_5aa,lang){lang.extend(_5a9,{focused:false,onFocus:function(){},onBlur:function(){},_onFocus:function(){this.onFocus();},_onBlur:function(){this.onBlur();}});return _5aa("dijit._FocusMixin",null,{_focusManager:_5a8});});},"dijit/_TemplatedMixin":function(){define(["dojo/cache","dojo/_base/declare","dojo/dom-construct","dojo/_base/lang","dojo/on","dojo/sniff","dojo/string","./_AttachMixin"],function(_5ab,_5ac,_5ad,lang,on,has,_5ae,_5af){var _5b0=_5ac("dijit._TemplatedMixin",_5af,{templateString:null,templatePath:null,_skipNodeCache:false,searchContainerNode:true,_stringRepl:function(tmpl){var _5b1=this.declaredClass,_5b2=this;return _5ae.substitute(tmpl,this,function(_5b3,key){if(key.charAt(0)=="!"){_5b3=lang.getObject(key.substr(1),false,_5b2);}if(typeof _5b3=="undefined"){throw new Error(_5b1+" template:"+key);}if(_5b3==null){return "";}return key.charAt(0)=="!"?_5b3:this._escapeValue(""+_5b3);},this);},_escapeValue:function(val){return val.replace(/["'<>&]/g,function(val){return {"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","'":"&#x27;"}[val];});},buildRendering:function(){if(!this._rendered){if(!this.templateString){this.templateString=_5ab(this.templatePath,{sanitize:true});}var _5b4=_5b0.getCachedTemplate(this.templateString,this._skipNodeCache,this.ownerDocument);var node;if(lang.isString(_5b4)){node=_5ad.toDom(this._stringRepl(_5b4),this.ownerDocument);if(node.nodeType!=1){throw new Error("Invalid template: "+_5b4);}}else{node=_5b4.cloneNode(true);}this.domNode=node;}this.inherited(arguments);if(!this._rendered){this._fillContent(this.srcNodeRef);}this._rendered=true;},_fillContent:function(_5b5){var dest=this.containerNode;if(_5b5&&dest){while(_5b5.hasChildNodes()){dest.appendChild(_5b5.firstChild);}}}});_5b0._templateCache={};_5b0.getCachedTemplate=function(_5b6,_5b7,doc){var _5b8=_5b0._templateCache;var key=_5b6;var _5b9=_5b8[key];if(_5b9){try{if(!_5b9.ownerDocument||_5b9.ownerDocument==(doc||document)){return _5b9;}}catch(e){}_5ad.destroy(_5b9);}_5b6=_5ae.trim(_5b6);if(_5b7||_5b6.match(/\$\{([^\}]+)\}/g)){return (_5b8[key]=_5b6);}else{var node=_5ad.toDom(_5b6,doc);if(node.nodeType!=1){throw new Error("Invalid template: "+_5b6);}return (_5b8[key]=node);}};if(has("ie")){on(window,"unload",function(){var _5ba=_5b0._templateCache;for(var key in _5ba){var _5bb=_5ba[key];if(typeof _5bb=="object"){_5ad.destroy(_5bb);}delete _5ba[key];}});}return _5b0;});},"dijit/_AttachMixin":function(){define(["require","dojo/_base/array","dojo/_base/connect","dojo/_base/declare","dojo/_base/lang","dojo/mouse","dojo/on","dojo/touch","./_WidgetBase"],function(_5bc,_5bd,_5be,_5bf,lang,_5c0,on,_5c1,_5c2){var _5c3=lang.delegate(_5c1,{"mouseenter":_5c0.enter,"mouseleave":_5c0.leave,"keypress":_5be._keypress});var _5c4;var _5c5=_5bf("dijit._AttachMixin",null,{constructor:function(){this._attachPoints=[];this._attachEvents=[];},buildRendering:function(){this.inherited(arguments);this._attachTemplateNodes(this.domNode);this._beforeFillContent();},_beforeFillContent:function(){},_attachTemplateNodes:function(_5c6){var node=_5c6;while(true){if(node.nodeType==1&&(this._processTemplateNode(node,function(n,p){return n.getAttribute(p);},this._attach)||this.searchContainerNode)&&node.firstChild){node=node.firstChild;}else{if(node==_5c6){return;}while(!node.nextSibling){node=node.parentNode;if(node==_5c6){return;}}node=node.nextSibling;}}},_processTemplateNode:function(_5c7,_5c8,_5c9){var ret=true;var _5ca=this.attachScope||this,_5cb=_5c8(_5c7,"dojoAttachPoint")||_5c8(_5c7,"data-dojo-attach-point");if(_5cb){var _5cc,_5cd=_5cb.split(/\s*,\s*/);while((_5cc=_5cd.shift())){if(lang.isArray(_5ca[_5cc])){_5ca[_5cc].push(_5c7);}else{_5ca[_5cc]=_5c7;}ret=(_5cc!="containerNode");this._attachPoints.push(_5cc);}}var _5ce=_5c8(_5c7,"dojoAttachEvent")||_5c8(_5c7,"data-dojo-attach-event");if(_5ce){var _5cf,_5d0=_5ce.split(/\s*,\s*/);var trim=lang.trim;while((_5cf=_5d0.shift())){if(_5cf){var _5d1=null;if(_5cf.indexOf(":")!=-1){var _5d2=_5cf.split(":");_5cf=trim(_5d2[0]);_5d1=trim(_5d2[1]);}else{_5cf=trim(_5cf);}if(!_5d1){_5d1=_5cf;}this._attachEvents.push(_5c9(_5c7,_5cf,lang.hitch(_5ca,_5d1)));}}}return ret;},_attach:function(node,type,func){type=type.replace(/^on/,"").toLowerCase();if(type=="dijitclick"){type=_5c4||(_5c4=_5bc("./a11yclick"));}else{type=_5c3[type]||type;}return on(node,type,func);},_detachTemplateNodes:function(){var _5d3=this.attachScope||this;_5bd.forEach(this._attachPoints,function(_5d4){delete _5d3[_5d4];});this._attachPoints=[];_5bd.forEach(this._attachEvents,function(_5d5){_5d5.remove();});this._attachEvents=[];},destroyRendering:function(){this._detachTemplateNodes();this.inherited(arguments);}});lang.extend(_5c2,{dojoAttachEvent:"",dojoAttachPoint:""});return _5c5;});},"dijit/_Container":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-construct","dojo/_base/kernel"],function(_5d6,_5d7,_5d8,_5d9){return _5d7("dijit._Container",null,{buildRendering:function(){this.inherited(arguments);if(!this.containerNode){this.containerNode=this.domNode;}},addChild:function(_5da,_5db){var _5dc=this.containerNode;if(_5db>0){_5dc=_5dc.firstChild;while(_5db>0){if(_5dc.nodeType==1){_5db--;}_5dc=_5dc.nextSibling;}if(_5dc){_5db="before";}else{_5dc=this.containerNode;_5db="last";}}_5d8.place(_5da.domNode,_5dc,_5db);if(this._started&&!_5da._started){_5da.startup();}},removeChild:function(_5dd){if(typeof _5dd=="number"){_5dd=this.getChildren()[_5dd];}if(_5dd){var node=_5dd.domNode;if(node&&node.parentNode){node.parentNode.removeChild(node);}}},hasChildren:function(){return this.getChildren().length>0;},_getSiblingOfChild:function(_5de,dir){var _5df=this.getChildren(),idx=_5d6.indexOf(_5df,_5de);return _5df[idx+dir];},getIndexOfChild:function(_5e0){return _5d6.indexOf(this.getChildren(),_5e0);}});});},"dijit/layout/_LayoutWidget":function(){define(["dojo/_base/lang","../_Widget","../_Container","../_Contained","../Viewport","dojo/_base/declare","dojo/dom-class","dojo/dom-geometry","dojo/dom-style"],function(lang,_5e1,_5e2,_5e3,_5e4,_5e5,_5e6,_5e7,_5e8){return _5e5("dijit.layout._LayoutWidget",[_5e1,_5e2,_5e3],{baseClass:"dijitLayoutContainer",isLayoutContainer:true,_setTitleAttr:null,buildRendering:function(){this.inherited(arguments);_5e6.add(this.domNode,"dijitContainer");},startup:function(){if(this._started){return;}this.inherited(arguments);var _5e9=this.getParent&&this.getParent();if(!(_5e9&&_5e9.isLayoutContainer)){this.resize();this.own(_5e4.on("resize",lang.hitch(this,"resize")));}},resize:function(_5ea,_5eb){var node=this.domNode;if(_5ea){_5e7.setMarginBox(node,_5ea);}var mb=_5eb||{};lang.mixin(mb,_5ea||{});if(!("h" in mb)||!("w" in mb)){mb=lang.mixin(_5e7.getMarginBox(node),mb);}var cs=_5e8.getComputedStyle(node);var me=_5e7.getMarginExtents(node,cs);var be=_5e7.getBorderExtents(node,cs);var bb=(this._borderBox={w:mb.w-(me.w+be.w),h:mb.h-(me.h+be.h)});var pe=_5e7.getPadExtents(node,cs);this._contentBox={l:_5e8.toPixelValue(node,cs.paddingLeft),t:_5e8.toPixelValue(node,cs.paddingTop),w:bb.w-pe.w,h:bb.h-pe.h};this.layout();},layout:function(){},_setupChild:function(_5ec){var cls=this.baseClass+"-child "+(_5ec.baseClass?this.baseClass+"-"+_5ec.baseClass:"");_5e6.add(_5ec.domNode,cls);},addChild:function(_5ed,_5ee){this.inherited(arguments);if(this._started){this._setupChild(_5ed);}},removeChild:function(_5ef){var cls=this.baseClass+"-child"+(_5ef.baseClass?" "+this.baseClass+"-"+_5ef.baseClass:"");_5e6.remove(_5ef.domNode,cls);this.inherited(arguments);}});});},"dijit/_Contained":function(){define(["dojo/_base/declare","./registry"],function(_5f0,_5f1){return _5f0("dijit._Contained",null,{_getSibling:function(_5f2){var p=this.getParent();return (p&&p._getSiblingOfChild&&p._getSiblingOfChild(this,_5f2=="previous"?-1:1))||null;},getPreviousSibling:function(){return this._getSibling("previous");},getNextSibling:function(){return this._getSibling("next");},getIndexInParent:function(){var p=this.getParent();if(!p||!p.getIndexOfChild){return -1;}return p.getIndexOfChild(this);}});});},"dijit/form/_FormWidget":function(){define(["dojo/_base/declare","dojo/sniff","dojo/_base/kernel","dojo/ready","../_Widget","../_CssStateMixin","../_TemplatedMixin","./_FormWidgetMixin"],function(_5f3,has,_5f4,_5f5,_5f6,_5f7,_5f8,_5f9){if(has("dijit-legacy-requires")){_5f5(0,function(){var _5fa=["dijit/form/_FormValueWidget"];require(_5fa);});}return _5f3("dijit.form._FormWidget",[_5f6,_5f8,_5f7,_5f9],{setDisabled:function(_5fb){_5f4.deprecated("setDisabled("+_5fb+") is deprecated. Use set('disabled',"+_5fb+") instead.","","2.0");this.set("disabled",_5fb);},setValue:function(_5fc){_5f4.deprecated("dijit.form._FormWidget:setValue("+_5fc+") is deprecated.  Use set('value',"+_5fc+") instead.","","2.0");this.set("value",_5fc);},getValue:function(){_5f4.deprecated(this.declaredClass+"::getValue() is deprecated. Use get('value') instead.","","2.0");return this.get("value");},postMixInProperties:function(){this.nameAttrSetting=(this.name&&!has("msapp"))?("name=\""+this.name.replace(/"/g,"&quot;")+"\""):"";this.inherited(arguments);}});});},"dijit/_CssStateMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom","dojo/dom-class","dojo/has","dojo/_base/lang","dojo/on","dojo/domReady","dojo/touch","dojo/_base/window","./a11yclick","./registry"],function(_5fd,_5fe,dom,_5ff,has,lang,on,_600,_601,win,_602,_603){var _604=_5fe("dijit._CssStateMixin",[],{hovering:false,active:false,_applyAttributes:function(){this.inherited(arguments);_5fd.forEach(["disabled","readOnly","checked","selected","focused","state","hovering","active","_opened"],function(attr){this.watch(attr,lang.hitch(this,"_setStateClass"));},this);for(var ap in this.cssStateNodes||{}){this._trackMouseState(this[ap],this.cssStateNodes[ap]);}this._trackMouseState(this.domNode,this.baseClass);this._setStateClass();},_cssMouseEvent:function(_605){if(!this.disabled){switch(_605.type){case "mouseover":case "MSPointerOver":case "pointerover":this._set("hovering",true);this._set("active",this._mouseDown);break;case "mouseout":case "MSPointerOut":case "pointerout":this._set("hovering",false);this._set("active",false);break;case "mousedown":case "touchstart":case "MSPointerDown":case "pointerdown":case "keydown":this._set("active",true);break;case "mouseup":case "dojotouchend":case "MSPointerUp":case "pointerup":case "keyup":this._set("active",false);break;}}},_setStateClass:function(){var _606=this.baseClass.split(" ");function _607(_608){_606=_606.concat(_5fd.map(_606,function(c){return c+_608;}),"dijit"+_608);};if(!this.isLeftToRight()){_607("Rtl");}var _609=this.checked=="mixed"?"Mixed":(this.checked?"Checked":"");if(this.checked){_607(_609);}if(this.state){_607(this.state);}if(this.selected){_607("Selected");}if(this._opened){_607("Opened");}if(this.disabled){_607("Disabled");}else{if(this.readOnly){_607("ReadOnly");}else{if(this.active){_607("Active");}else{if(this.hovering){_607("Hover");}}}}if(this.focused){_607("Focused");}var tn=this.stateNode||this.domNode,_60a={};_5fd.forEach(tn.className.split(" "),function(c){_60a[c]=true;});if("_stateClasses" in this){_5fd.forEach(this._stateClasses,function(c){delete _60a[c];});}_5fd.forEach(_606,function(c){_60a[c]=true;});var _60b=[];for(var c in _60a){_60b.push(c);}tn.className=_60b.join(" ");this._stateClasses=_606;},_subnodeCssMouseEvent:function(node,_60c,evt){if(this.disabled||this.readOnly){return;}function _60d(_60e){_5ff.toggle(node,_60c+"Hover",_60e);};function _60f(_610){_5ff.toggle(node,_60c+"Active",_610);};function _611(_612){_5ff.toggle(node,_60c+"Focused",_612);};switch(evt.type){case "mouseover":case "MSPointerOver":case "pointerover":_60d(true);break;case "mouseout":case "MSPointerOut":case "pointerout":_60d(false);_60f(false);break;case "mousedown":case "touchstart":case "MSPointerDown":case "pointerdown":case "keydown":_60f(true);break;case "mouseup":case "MSPointerUp":case "pointerup":case "dojotouchend":case "keyup":_60f(false);break;case "focus":case "focusin":_611(true);break;case "blur":case "focusout":_611(false);break;}},_trackMouseState:function(node,_613){node._cssState=_613;}});_600(function(){function _614(evt,_615,_616){if(_616&&dom.isDescendant(_616,_615)){return;}for(var node=_615;node&&node!=_616;node=node.parentNode){if(node._cssState){var _617=_603.getEnclosingWidget(node);if(_617){if(node==_617.domNode){_617._cssMouseEvent(evt);}else{_617._subnodeCssMouseEvent(node,node._cssState,evt);}}}}};var body=win.body(),_618;on(body,_601.over,function(evt){_614(evt,evt.target,evt.relatedTarget);});on(body,_601.out,function(evt){_614(evt,evt.target,evt.relatedTarget);});on(body,_602.press,function(evt){_618=evt.target;_614(evt,_618);});on(body,_602.release,function(evt){_614(evt,_618);_618=null;});on(body,"focusin, focusout",function(evt){var node=evt.target;if(node._cssState&&!node.getAttribute("widgetId")){var _619=_603.getEnclosingWidget(node);if(_619){_619._subnodeCssMouseEvent(node,node._cssState,evt);}}});});return _604;});},"dijit/form/_FormWidgetMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-attr","dojo/dom-style","dojo/_base/lang","dojo/mouse","dojo/on","dojo/sniff","dojo/window","../a11y"],function(_61a,_61b,_61c,_61d,lang,_61e,on,has,_61f,a11y){return _61b("dijit.form._FormWidgetMixin",null,{name:"",alt:"",value:"",type:"text","aria-label":"focusNode",tabIndex:"0",_setTabIndexAttr:"focusNode",disabled:false,intermediateChanges:false,scrollOnFocus:true,_setIdAttr:"focusNode",_setDisabledAttr:function(_620){this._set("disabled",_620);if(/^(button|input|select|textarea|optgroup|option|fieldset)$/i.test(this.focusNode.tagName)){_61c.set(this.focusNode,"disabled",_620);if(has("trident")&&"readOnly" in this){_61c.set(this.focusNode,"readonly",_620||this.readOnly);}}else{this.focusNode.setAttribute("aria-disabled",_620?"true":"false");}if(this.valueNode){_61c.set(this.valueNode,"disabled",_620);}if(_620){this._set("hovering",false);this._set("active",false);var _621="tabIndex" in this.attributeMap?this.attributeMap.tabIndex:("_setTabIndexAttr" in this)?this._setTabIndexAttr:"focusNode";_61a.forEach(lang.isArray(_621)?_621:[_621],function(_622){var node=this[_622];if(has("webkit")||a11y.hasDefaultTabStop(node)){node.setAttribute("tabIndex","-1");}else{node.removeAttribute("tabIndex");}},this);}else{if(this.tabIndex!=""){this.set("tabIndex",this.tabIndex);}}},_onFocus:function(by){if(by=="mouse"&&this.isFocusable()){var _623=this.own(on(this.focusNode,"focus",function(){_624.remove();_623.remove();}))[0];var _625=has("pointer-events")?"pointerup":has("MSPointer")?"MSPointerUp":has("touch-events")?"touchend, mouseup":"mouseup";var _624=this.own(on(this.ownerDocumentBody,_625,lang.hitch(this,function(evt){_624.remove();_623.remove();if(this.focused){if(evt.type=="touchend"){this.defer("focus");}else{this.focus();}}})))[0];}if(this.scrollOnFocus){this.defer(function(){_61f.scrollIntoView(this.domNode);});}this.inherited(arguments);},isFocusable:function(){return !this.disabled&&this.focusNode&&(_61d.get(this.domNode,"display")!="none");},focus:function(){if(!this.disabled&&this.focusNode.focus){try{this.focusNode.focus();}catch(e){}}},compare:function(val1,val2){if(typeof val1=="number"&&typeof val2=="number"){return (isNaN(val1)&&isNaN(val2))?0:val1-val2;}else{if(val1>val2){return 1;}else{if(val1<val2){return -1;}else{return 0;}}}},onChange:function(){},_onChangeActive:false,_handleOnChange:function(_626,_627){if(this._lastValueReported==undefined&&(_627===null||!this._onChangeActive)){this._resetValue=this._lastValueReported=_626;}this._pendingOnChange=this._pendingOnChange||(typeof _626!=typeof this._lastValueReported)||(this.compare(_626,this._lastValueReported)!=0);if((this.intermediateChanges||_627||_627===undefined)&&this._pendingOnChange){this._lastValueReported=_626;this._pendingOnChange=false;if(this._onChangeActive){if(this._onChangeHandle){this._onChangeHandle.remove();}this._onChangeHandle=this.defer(function(){this._onChangeHandle=null;this.onChange(_626);});}}},create:function(){this.inherited(arguments);this._onChangeActive=true;},destroy:function(){if(this._onChangeHandle){this._onChangeHandle.remove();this.onChange(this._lastValueReported);}this.inherited(arguments);}});});},"dijit/form/_FormValueWidget":function(){define(["dojo/_base/declare","dojo/sniff","./_FormWidget","./_FormValueMixin"],function(_628,has,_629,_62a){return _628("dijit.form._FormValueWidget",[_629,_62a],{_layoutHackIE7:function(){if(has("ie")==7){var _62b=this.domNode;var _62c=_62b.parentNode;var _62d=_62b.firstChild||_62b;var _62e=_62d.style.filter;var _62f=this;while(_62c&&_62c.clientHeight==0){(function ping(){var _630=_62f.connect(_62c,"onscroll",function(){_62f.disconnect(_630);_62d.style.filter=(new Date()).getMilliseconds();_62f.defer(function(){_62d.style.filter=_62e;});});})();_62c=_62c.parentNode;}}}});});},"dijit/form/_FormValueMixin":function(){define(["dojo/_base/declare","dojo/dom-attr","dojo/keys","dojo/_base/lang","dojo/on","dojo/sniff","./_FormWidgetMixin"],function(_631,_632,keys,lang,on,has,_633){return _631("dijit.form._FormValueMixin",_633,{readOnly:false,_setReadOnlyAttr:function(_634){if(has("trident")&&"disabled" in this){_632.set(this.focusNode,"readOnly",_634||this.disabled);}else{_632.set(this.focusNode,"readOnly",_634);}this._set("readOnly",_634);},postCreate:function(){this.inherited(arguments);if(this._resetValue===undefined){this._lastValueReported=this._resetValue=this.value;}},_setValueAttr:function(_635,_636){this._handleOnChange(_635,_636);},_handleOnChange:function(_637,_638){this._set("value",_637);this.inherited(arguments);},undo:function(){this._setValueAttr(this._lastValueReported,false);},reset:function(){this._hasBeenBlurred=false;this._setValueAttr(this._resetValue,true);}});});},"dijit/ColorPalette":function(){define(["require","dojo/text!./templates/ColorPalette.html","./_Widget","./_TemplatedMixin","./_PaletteMixin","./hccss","dojo/i18n","dojo/_base/Color","dojo/_base/declare","dojo/dom-construct","dojo/string","dojo/i18n!dojo/nls/colors","dojo/colors"],function(_639,_63a,_63b,_63c,_63d,has,i18n,_63e,_63f,_640,_641){var _642=_63f("dijit.ColorPalette",[_63b,_63c,_63d],{palette:"7x10",_palettes:{"7x10":[["white","seashell","cornsilk","lemonchiffon","lightyellow","palegreen","paleturquoise","lightcyan","lavender","plum"],["lightgray","pink","bisque","moccasin","khaki","lightgreen","lightseagreen","lightskyblue","cornflowerblue","violet"],["silver","lightcoral","sandybrown","orange","palegoldenrod","chartreuse","mediumturquoise","skyblue","mediumslateblue","orchid"],["gray","red","orangered","darkorange","yellow","limegreen","darkseagreen","royalblue","slateblue","mediumorchid"],["dimgray","crimson","chocolate","coral","gold","forestgreen","seagreen","blue","blueviolet","darkorchid"],["darkslategray","firebrick","saddlebrown","sienna","olive","green","darkcyan","mediumblue","darkslateblue","darkmagenta"],["black","darkred","maroon","brown","darkolivegreen","darkgreen","midnightblue","navy","indigo","purple"]],"3x4":[["white","lime","green","blue"],["silver","yellow","fuchsia","navy"],["gray","red","purple","black"]]},templateString:_63a,baseClass:"dijitColorPalette",_dyeFactory:function(_643,row,col,_644){return new this._dyeClass(_643,row,col,_644);},buildRendering:function(){this.inherited(arguments);this._dyeClass=_63f(_642._Color,{palette:this.palette});this._preparePalette(this._palettes[this.palette],i18n.getLocalization("dojo","colors",this.lang));}});_642._Color=_63f("dijit._Color",_63e,{template:"<span class='dijitInline dijitPaletteImg'>"+"<img src='${blankGif}' alt='${alt}' title='${title}' class='dijitColorPaletteSwatch' style='background-color: ${color}'/>"+"</span>",hcTemplate:"<span class='dijitInline dijitPaletteImg' style='position: relative; overflow: hidden; height: 12px; width: 14px;'>"+"<img src='${image}' alt='${alt}' title='${title}' style='position: absolute; left: ${left}px; top: ${top}px; ${size}'/>"+"</span>",_imagePaths:{"7x10":_639.toUrl("./themes/a11y/colors7x10.png"),"3x4":_639.toUrl("./themes/a11y/colors3x4.png")},constructor:function(_645,row,col,_646){this._title=_646;this._row=row;this._col=col;this.setColor(_63e.named[_645]);},getValue:function(){return this.toHex();},fillCell:function(cell,_647){var html=_641.substitute(has("highcontrast")?this.hcTemplate:this.template,{color:this.toHex(),blankGif:_647,alt:this._title,title:this._title,image:this._imagePaths[this.palette].toString(),left:this._col*-20-5,top:this._row*-20-5,size:this.palette=="7x10"?"height: 145px; width: 206px":"height: 64px; width: 86px"});_640.place(html,cell);}});return _642;});},"dijit/_PaletteMixin":function(){define(["dojo/_base/declare","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/keys","dojo/_base/lang","dojo/on","./_CssStateMixin","./a11yclick","./focus","./typematic"],function(_648,_649,_64a,_64b,keys,lang,on,_64c,_64d,_64e,_64f){var _650=_648("dijit._PaletteMixin",_64c,{defaultTimeout:500,timeoutChangeRate:0.9,value:"",_selectedCell:-1,tabIndex:"0",cellClass:"dijitPaletteCell",dyeClass:null,_dyeFactory:function(_651){var _652=typeof this.dyeClass=="string"?lang.getObject(this.dyeClass):this.dyeClass;return new _652(_651);},_preparePalette:function(_653,_654){this._cells=[];var url=this._blankGif;this.own(on(this.gridNode,_64d,lang.hitch(this,"_onCellClick")));for(var row=0;row<_653.length;row++){var _655=_64b.create("tr",{tabIndex:"-1",role:"row"},this.gridNode);for(var col=0;col<_653[row].length;col++){var _656=_653[row][col];if(_656){var _657=this._dyeFactory(_656,row,col,_654[_656]);var _658=_64b.create("td",{"class":this.cellClass,tabIndex:"-1",title:_654[_656],role:"gridcell"},_655);_657.fillCell(_658,url);_658.idx=this._cells.length;this._cells.push({node:_658,dye:_657});}}}this._xDim=_653[0].length;this._yDim=_653.length;var _659={UP_ARROW:-this._xDim,DOWN_ARROW:this._xDim,RIGHT_ARROW:this.isLeftToRight()?1:-1,LEFT_ARROW:this.isLeftToRight()?-1:1};for(var key in _659){this.own(_64f.addKeyListener(this.domNode,{keyCode:keys[key],ctrlKey:false,altKey:false,shiftKey:false},this,function(){var _65a=_659[key];return function(_65b){this._navigateByKey(_65a,_65b);};}(),this.timeoutChangeRate,this.defaultTimeout));}},postCreate:function(){this.inherited(arguments);this._setCurrent(this._cells[0].node);},focus:function(){_64e.focus(this._currentFocus);},_onCellClick:function(evt){var _65c=evt.target;while(_65c.tagName!="TD"){if(!_65c.parentNode||_65c==this.gridNode){return;}_65c=_65c.parentNode;}var _65d=this._getDye(_65c).getValue();this._setCurrent(_65c);_64e.focus(_65c);this._setValueAttr(_65d,true);evt.stopPropagation();evt.preventDefault();},_setCurrent:function(node){if("_currentFocus" in this){_649.set(this._currentFocus,"tabIndex","-1");}this._currentFocus=node;if(node){_649.set(node,"tabIndex",this.tabIndex);}},_setValueAttr:function(_65e,_65f){if(this._selectedCell>=0){_64a.remove(this._cells[this._selectedCell].node,this.cellClass+"Selected");}this._selectedCell=-1;if(_65e){for(var i=0;i<this._cells.length;i++){if(_65e==this._cells[i].dye.getValue()){this._selectedCell=i;_64a.add(this._cells[i].node,this.cellClass+"Selected");break;}}}this._set("value",this._selectedCell>=0?_65e:null);if(_65f||_65f===undefined){this.onChange(_65e);}},onChange:function(){},_navigateByKey:function(_660,_661){if(_661==-1){return;}var _662=this._currentFocus.idx+_660;if(_662<this._cells.length&&_662>-1){var _663=this._cells[_662].node;this._setCurrent(_663);this.defer(lang.hitch(_64e,"focus",_663));}},_getDye:function(cell){return this._cells[cell.idx].dye;}});return _650;});},"dojo/colors":function(){define(["./_base/kernel","./_base/lang","./_base/Color","./_base/array"],function(dojo,lang,_664,_665){var _666={};lang.setObject("dojo.colors",_666);var _667=function(m1,m2,h){if(h<0){++h;}if(h>1){--h;}var h6=6*h;if(h6<1){return m1+(m2-m1)*h6;}if(2*h<1){return m2;}if(3*h<2){return m1+(m2-m1)*(2/3-h)*6;}return m1;};dojo.colorFromRgb=_664.fromRgb=function(_668,obj){var m=_668.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(m){var c=m[2].split(/\s*,\s*/),l=c.length,t=m[1],a;if((t=="rgb"&&l==3)||(t=="rgba"&&l==4)){var r=c[0];if(r.charAt(r.length-1)=="%"){a=_665.map(c,function(x){return parseFloat(x)*2.56;});if(l==4){a[3]=c[3];}return _664.fromArray(a,obj);}return _664.fromArray(c,obj);}if((t=="hsl"&&l==3)||(t=="hsla"&&l==4)){var H=((parseFloat(c[0])%360)+360)%360/360,S=parseFloat(c[1])/100,L=parseFloat(c[2])/100,m2=L<=0.5?L*(S+1):L+S-L*S,m1=2*L-m2;a=[_667(m1,m2,H+1/3)*256,_667(m1,m2,H)*256,_667(m1,m2,H-1/3)*256,1];if(l==4){a[3]=c[3];}return _664.fromArray(a,obj);}}return null;};var _669=function(c,low,high){c=Number(c);return isNaN(c)?high:c<low?low:c>high?high:c;};_664.prototype.sanitize=function(){var t=this;t.r=Math.round(_669(t.r,0,255));t.g=Math.round(_669(t.g,0,255));t.b=Math.round(_669(t.b,0,255));t.a=_669(t.a,0,1);return this;};_666.makeGrey=_664.makeGrey=function(g,a){return _664.fromArray([g,g,g,a]);};lang.mixin(_664.named,{"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"blanchedalmond":[255,235,205],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"oldlace":[253,245,230],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"whitesmoke":[245,245,245],"yellowgreen":[154,205,50]});return _664;});},"dijit/Dialog":function(){define(["require","dojo/_base/array","dojo/aspect","dojo/_base/declare","dojo/Deferred","dojo/dom","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/_base/fx","dojo/i18n","dojo/keys","dojo/_base/lang","dojo/on","dojo/ready","dojo/sniff","dojo/touch","dojo/window","dojo/dnd/Moveable","dojo/dnd/TimedMoveable","./focus","./_base/manager","./_Widget","./_TemplatedMixin","./_CssStateMixin","./form/_FormMixin","./_DialogMixin","./DialogUnderlay","./layout/ContentPane","./layout/utils","dojo/text!./templates/Dialog.html","./a11yclick","dojo/i18n!./nls/common"],function(_66a,_66b,_66c,_66d,_66e,dom,_66f,_670,_671,fx,i18n,keys,lang,on,_672,has,_673,_674,_675,_676,_677,_678,_679,_67a,_67b,_67c,_67d,_67e,_67f,_680,_681){var _682=new _66e();_682.resolve(true);function nop(){};var _683=_66d("dijit._DialogBase"+(has("dojo-bidi")?"_NoBidi":""),[_67a,_67c,_67d,_67b],{templateString:_681,baseClass:"dijitDialog",cssStateNodes:{closeButtonNode:"dijitDialogCloseIcon"},_setTitleAttr:{node:"titleNode",type:"innerHTML"},open:false,duration:_678.defaultDuration,refocus:true,autofocus:true,_firstFocusItem:null,_lastFocusItem:null,draggable:true,_setDraggableAttr:function(val){this._set("draggable",val);},maxRatio:0.9,closable:true,_setClosableAttr:function(val){this.closeButtonNode.style.display=val?"":"none";this._set("closable",val);},postMixInProperties:function(){var _684=i18n.getLocalization("dijit","common");lang.mixin(this,_684);this.inherited(arguments);},postCreate:function(){_671.set(this.domNode,{display:"none",position:"absolute"});this.ownerDocumentBody.appendChild(this.domNode);this.inherited(arguments);_66c.after(this,"onExecute",lang.hitch(this,"hide"),true);_66c.after(this,"onCancel",lang.hitch(this,"hide"),true);on(this.closeButtonNode,_673.press,function(e){e.stopPropagation();});this._modalconnects=[];},onLoad:function(){this.resize();this._position();if(this.autofocus&&_685.isTop(this)){this._getFocusItems();_677.focus(this._firstFocusItem);}this.inherited(arguments);},focus:function(){this._getFocusItems();_677.focus(this._firstFocusItem);},_endDrag:function(){var _686=_670.position(this.domNode),_687=_674.getBox(this.ownerDocument);_686.y=Math.min(Math.max(_686.y,0),(_687.h-_686.h));_686.x=Math.min(Math.max(_686.x,0),(_687.w-_686.w));this._relativePosition=_686;this._position();},_setup:function(){var node=this.domNode;if(this.titleBar&&this.draggable){this._moveable=new ((has("ie")==6)?_676:_675)(node,{handle:this.titleBar});_66c.after(this._moveable,"onMoveStop",lang.hitch(this,"_endDrag"),true);}else{_66f.add(node,"dijitDialogFixed");}this.underlayAttrs={dialogId:this.id,"class":_66b.map(this["class"].split(/\s/),function(s){return s+"_underlay";}).join(" "),_onKeyDown:lang.hitch(this,"_onKey"),ownerDocument:this.ownerDocument};},_size:function(){this.resize();},_position:function(){if(!_66f.contains(this.ownerDocumentBody,"dojoMove")){var node=this.domNode,_688=_674.getBox(this.ownerDocument),p=this._relativePosition,bb=_670.position(node),l=Math.floor(_688.l+(p?Math.min(p.x,_688.w-bb.w):(_688.w-bb.w)/2)),t=Math.floor(_688.t+(p?Math.min(p.y,_688.h-bb.h):(_688.h-bb.h)/2));_671.set(node,{left:l+"px",top:t+"px"});}},_onKey:function(evt){if(evt.keyCode==keys.TAB){this._getFocusItems();var node=evt.target;if(this._firstFocusItem==this._lastFocusItem){evt.stopPropagation();evt.preventDefault();}else{if(node==this._firstFocusItem&&evt.shiftKey){_677.focus(this._lastFocusItem);evt.stopPropagation();evt.preventDefault();}else{if(node==this._lastFocusItem&&!evt.shiftKey){_677.focus(this._firstFocusItem);evt.stopPropagation();evt.preventDefault();}}}}else{if(this.closable&&evt.keyCode==keys.ESCAPE){this.onCancel();evt.stopPropagation();evt.preventDefault();}}},show:function(){if(this.open){return _682.promise;}if(!this._started){this.startup();}if(!this._alreadyInitialized){this._setup();this._alreadyInitialized=true;}if(this._fadeOutDeferred){this._fadeOutDeferred.cancel();_685.hide(this);}var win=_674.get(this.ownerDocument);this._modalconnects.push(on(win,"scroll",lang.hitch(this,"resize",null)));this._modalconnects.push(on(this.domNode,"keydown",lang.hitch(this,"_onKey")));_671.set(this.domNode,{opacity:0,display:""});this._set("open",true);this._onShow();this.resize();this._position();var _689;this._fadeInDeferred=new _66e(lang.hitch(this,function(){_689.stop();delete this._fadeInDeferred;}));this._fadeInDeferred.then(undefined,nop);var _68a=this._fadeInDeferred.promise;_689=fx.fadeIn({node:this.domNode,duration:this.duration,beforeBegin:lang.hitch(this,function(){_685.show(this,this.underlayAttrs);}),onEnd:lang.hitch(this,function(){if(this.autofocus&&_685.isTop(this)){this._getFocusItems();_677.focus(this._firstFocusItem);}this._fadeInDeferred.resolve(true);delete this._fadeInDeferred;})}).play();return _68a;},hide:function(){if(!this._alreadyInitialized||!this.open){return _682.promise;}if(this._fadeInDeferred){this._fadeInDeferred.cancel();}var _68b;this._fadeOutDeferred=new _66e(lang.hitch(this,function(){_68b.stop();delete this._fadeOutDeferred;}));this._fadeOutDeferred.then(undefined,nop);this._fadeOutDeferred.then(lang.hitch(this,"onHide"));var _68c=this._fadeOutDeferred.promise;_68b=fx.fadeOut({node:this.domNode,duration:this.duration,onEnd:lang.hitch(this,function(){this.domNode.style.display="none";_685.hide(this);this._fadeOutDeferred.resolve(true);delete this._fadeOutDeferred;})}).play();if(this._scrollConnected){this._scrollConnected=false;}var h;while(h=this._modalconnects.pop()){h.remove();}if(this._relativePosition){delete this._relativePosition;}this._set("open",false);return _68c;},resize:function(dim){if(this.domNode.style.display!="none"){this._checkIfSingleChild();if(!dim){if(this._shrunk){if(this._singleChild){if(typeof this._singleChildOriginalStyle!="undefined"){this._singleChild.domNode.style.cssText=this._singleChildOriginalStyle;delete this._singleChildOriginalStyle;}}_66b.forEach([this.domNode,this.containerNode,this.titleBar,this.actionBarNode],function(node){if(node){_671.set(node,{position:"static",width:"auto",height:"auto"});}});this.domNode.style.position="absolute";}var _68d=_674.getBox(this.ownerDocument);_68d.w*=this.maxRatio;_68d.h*=this.maxRatio;var bb=_670.position(this.domNode);this._shrunk=false;if(bb.w>=_68d.w){dim={w:_68d.w};_670.setMarginBox(this.domNode,dim);bb=_670.position(this.domNode);this._shrunk=true;}if(bb.h>=_68d.h){if(!dim){dim={w:bb.w};}dim.h=_68d.h;this._shrunk=true;}if(dim){if(!dim.w){dim.w=bb.w;}if(!dim.h){dim.h=bb.h;}}}if(dim){_670.setMarginBox(this.domNode,dim);var _68e=[];if(this.titleBar){_68e.push({domNode:this.titleBar,region:"top"});}if(this.actionBarNode){_68e.push({domNode:this.actionBarNode,region:"bottom"});}var _68f={domNode:this.containerNode,region:"center"};_68e.push(_68f);var _690=_680.marginBox2contentBox(this.domNode,dim);_680.layoutChildren(this.domNode,_690,_68e);if(this._singleChild){var cb=_680.marginBox2contentBox(this.containerNode,_68f);this._singleChild.resize({w:cb.w,h:cb.h});}else{this.containerNode.style.overflow="auto";this._layoutChildren();}}else{this._layoutChildren();}if(!has("touch")&&!dim){this._position();}}},_layoutChildren:function(){_66b.forEach(this.getChildren(),function(_691){if(_691.resize){_691.resize();}});},destroy:function(){if(this._fadeInDeferred){this._fadeInDeferred.cancel();}if(this._fadeOutDeferred){this._fadeOutDeferred.cancel();}if(this._moveable){this._moveable.destroy();}var h;while(h=this._modalconnects.pop()){h.remove();}_685.hide(this);this.inherited(arguments);}});if(has("dojo-bidi")){_683=_66d("dijit._DialogBase",_683,{_setTitleAttr:function(_692){this._set("title",_692);this.titleNode.innerHTML=_692;this.applyTextDir(this.titleNode);},_setTextDirAttr:function(_693){if(this._created&&this.textDir!=_693){this._set("textDir",_693);this.set("title",this.title);}}});}var _694=_66d("dijit.Dialog",[_67f,_683],{});_694._DialogBase=_683;var _685=_694._DialogLevelManager={_beginZIndex:950,show:function(_695,_696){ds[ds.length-1].focus=_677.curNode;var _697=ds[ds.length-1].dialog?ds[ds.length-1].zIndex+2:_694._DialogLevelManager._beginZIndex;_671.set(_695.domNode,"zIndex",_697);_67e.show(_696,_697-1);ds.push({dialog:_695,underlayAttrs:_696,zIndex:_697});},hide:function(_698){if(ds[ds.length-1].dialog==_698){ds.pop();var pd=ds[ds.length-1];if(ds.length==1){_67e.hide();}else{_67e.show(pd.underlayAttrs,pd.zIndex-1);}if(_698.refocus){var _699=pd.focus;if(pd.dialog&&(!_699||!dom.isDescendant(_699,pd.dialog.domNode))){pd.dialog._getFocusItems();_699=pd.dialog._firstFocusItem;}if(_699){try{_699.focus();}catch(e){}}}}else{var idx=_66b.indexOf(_66b.map(ds,function(elem){return elem.dialog;}),_698);if(idx!=-1){ds.splice(idx,1);}}},isTop:function(_69a){return ds[ds.length-1].dialog==_69a;}};var ds=_694._dialogStack=[{dialog:null,focus:null,underlayAttrs:null}];_677.watch("curNode",function(attr,_69b,node){var _69c=ds[ds.length-1].dialog;if(node&&_69c&&!_69c._fadeOutDeferred&&node.ownerDocument==_69c.ownerDocument){do{if(node==_69c.domNode||_66f.contains(node,"dijitPopup")){return;}}while(node=node.parentNode);_69c.focus();}});if(has("dijit-legacy-requires")){_672(0,function(){var _69d=["dijit/TooltipDialog"];_66a(_69d);});}return _694;});},"dijit/form/_FormMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/_base/kernel","dojo/_base/lang","dojo/on","dojo/window"],function(_69e,_69f,_6a0,lang,on,_6a1){return _69f("dijit.form._FormMixin",null,{state:"",_getDescendantFormWidgets:function(_6a2){var res=[];_69e.forEach(_6a2||this.getChildren(),function(_6a3){if("value" in _6a3){res.push(_6a3);}else{res=res.concat(this._getDescendantFormWidgets(_6a3.getChildren()));}},this);return res;},reset:function(){_69e.forEach(this._getDescendantFormWidgets(),function(_6a4){if(_6a4.reset){_6a4.reset();}});},validate:function(){var _6a5=false;return _69e.every(_69e.map(this._getDescendantFormWidgets(),function(_6a6){_6a6._hasBeenBlurred=true;var _6a7=_6a6.disabled||!_6a6.validate||_6a6.validate();if(!_6a7&&!_6a5){_6a1.scrollIntoView(_6a6.containerNode||_6a6.domNode);_6a6.focus();_6a5=true;}return _6a7;}),function(item){return item;});},setValues:function(val){_6a0.deprecated(this.declaredClass+"::setValues() is deprecated. Use set('value', val) instead.","","2.0");return this.set("value",val);},_setValueAttr:function(obj){var map={};_69e.forEach(this._getDescendantFormWidgets(),function(_6a8){if(!_6a8.name){return;}var _6a9=map[_6a8.name]||(map[_6a8.name]=[]);_6a9.push(_6a8);});for(var name in map){if(!map.hasOwnProperty(name)){continue;}var _6aa=map[name],_6ab=lang.getObject(name,false,obj);if(_6ab===undefined){continue;}_6ab=[].concat(_6ab);if(typeof _6aa[0].checked=="boolean"){_69e.forEach(_6aa,function(w){w.set("value",_69e.indexOf(_6ab,w._get("value"))!=-1);});}else{if(_6aa[0].multiple){_6aa[0].set("value",_6ab);}else{_69e.forEach(_6aa,function(w,i){w.set("value",_6ab[i]);});}}}},getValues:function(){_6a0.deprecated(this.declaredClass+"::getValues() is deprecated. Use get('value') instead.","","2.0");return this.get("value");},_getValueAttr:function(){var obj={};_69e.forEach(this._getDescendantFormWidgets(),function(_6ac){var name=_6ac.name;if(!name||_6ac.disabled){return;}var _6ad=_6ac.get("value");if(typeof _6ac.checked=="boolean"){if(/Radio/.test(_6ac.declaredClass)){if(_6ad!==false){lang.setObject(name,_6ad,obj);}else{_6ad=lang.getObject(name,false,obj);if(_6ad===undefined){lang.setObject(name,null,obj);}}}else{var ary=lang.getObject(name,false,obj);if(!ary){ary=[];lang.setObject(name,ary,obj);}if(_6ad!==false){ary.push(_6ad);}}}else{var prev=lang.getObject(name,false,obj);if(typeof prev!="undefined"){if(lang.isArray(prev)){prev.push(_6ad);}else{lang.setObject(name,[prev,_6ad],obj);}}else{lang.setObject(name,_6ad,obj);}}});return obj;},isValid:function(){return this.state=="";},onValidStateChange:function(){},_getState:function(){var _6ae=_69e.map(this._descendants,function(w){return w.get("state")||"";});return _69e.indexOf(_6ae,"Error")>=0?"Error":_69e.indexOf(_6ae,"Incomplete")>=0?"Incomplete":"";},disconnectChildren:function(){},connectChildren:function(_6af){this._descendants=this._getDescendantFormWidgets();_69e.forEach(this._descendants,function(_6b0){if(!_6b0._started){_6b0.startup();}});if(!_6af){this._onChildChange();}},_onChildChange:function(attr){if(!attr||attr=="state"||attr=="disabled"){this._set("state",this._getState());}if(!attr||attr=="value"||attr=="disabled"||attr=="checked"){if(this._onChangeDelayTimer){this._onChangeDelayTimer.remove();}this._onChangeDelayTimer=this.defer(function(){delete this._onChangeDelayTimer;this._set("value",this.get("value"));},10);}},startup:function(){this.inherited(arguments);this._descendants=this._getDescendantFormWidgets();this.value=this.get("value");this.state=this._getState();var self=this;this.own(on(this.containerNode,"attrmodified-state, attrmodified-disabled, attrmodified-value, attrmodified-checked",function(evt){if(evt.target==self.domNode){return;}self._onChildChange(evt.type.replace("attrmodified-",""));}));this.watch("state",function(attr,_6b1,_6b2){this.onValidStateChange(_6b2=="");});},destroy:function(){this.inherited(arguments);}});});},"dijit/_DialogMixin":function(){define(["dojo/_base/declare","./a11y"],function(_6b3,a11y){return _6b3("dijit._DialogMixin",null,{actionBarTemplate:"",execute:function(){},onCancel:function(){},onExecute:function(){},_onSubmit:function(){this.onExecute();this.execute(this.get("value"));},_getFocusItems:function(){var _6b4=a11y._getTabNavigable(this.domNode);this._firstFocusItem=_6b4.lowest||_6b4.first||this.closeButtonNode||this.domNode;this._lastFocusItem=_6b4.last||_6b4.highest||this._firstFocusItem;}});});},"dijit/DialogUnderlay":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/aspect","dojo/dom-attr","dojo/dom-style","dojo/on","dojo/window","./_Widget","./_TemplatedMixin","./BackgroundIframe","./Viewport","./main"],function(_6b5,lang,_6b6,_6b7,_6b8,on,_6b9,_6ba,_6bb,_6bc,_6bd,_6be){var _6bf=_6b5("dijit.DialogUnderlay",[_6ba,_6bb],{templateString:"<div class='dijitDialogUnderlayWrapper'><div class='dijitDialogUnderlay' tabIndex='-1' data-dojo-attach-point='node'></div></div>",dialogId:"","class":"",_modalConnects:[],_setDialogIdAttr:function(id){_6b7.set(this.node,"id",id+"_underlay");this._set("dialogId",id);},_setClassAttr:function(_6c0){this.node.className="dijitDialogUnderlay "+_6c0;this._set("class",_6c0);},postCreate:function(){this.ownerDocumentBody.appendChild(this.domNode);this.own(on(this.domNode,"keydown",lang.hitch(this,"_onKeyDown")));this.inherited(arguments);},layout:function(){var is=this.node.style,os=this.domNode.style;os.display="none";var _6c1=_6b9.getBox(this.ownerDocument);os.top=_6c1.t+"px";os.left=_6c1.l+"px";is.width=_6c1.w+"px";is.height=_6c1.h+"px";os.display="block";},show:function(){this.domNode.style.display="block";this.open=true;this.layout();this.bgIframe=new _6bc(this.domNode);var win=_6b9.get(this.ownerDocument);this._modalConnects=[_6bd.on("resize",lang.hitch(this,"layout")),on(win,"scroll",lang.hitch(this,"layout"))];},hide:function(){this.bgIframe.destroy();delete this.bgIframe;this.domNode.style.display="none";while(this._modalConnects.length){(this._modalConnects.pop()).remove();}this.open=false;},destroy:function(){while(this._modalConnects.length){(this._modalConnects.pop()).remove();}this.inherited(arguments);},_onKeyDown:function(){}});_6bf.show=function(_6c2,_6c3){var _6c4=_6bf._singleton;if(!_6c4||_6c4._destroyed){_6c4=_6be._underlay=_6bf._singleton=new _6bf(_6c2);}else{if(_6c2){_6c4.set(_6c2);}}_6b8.set(_6c4.domNode,"zIndex",_6c3);if(!_6c4.open){_6c4.show();}};_6bf.hide=function(){var _6c5=_6bf._singleton;if(_6c5&&!_6c5._destroyed){_6c5.hide();}};return _6bf;});},"dijit/layout/ContentPane":function(){define(["dojo/_base/kernel","dojo/_base/lang","../_Widget","../_Container","./_ContentPaneResizeMixin","dojo/string","dojo/html","dojo/_base/array","dojo/_base/declare","dojo/_base/Deferred","dojo/dom","dojo/dom-attr","dojo/dom-construct","dojo/_base/xhr","dojo/i18n","dojo/when","dojo/i18n!../nls/loading"],function(_6c6,lang,_6c7,_6c8,_6c9,_6ca,html,_6cb,_6cc,_6cd,dom,_6ce,_6cf,xhr,i18n,when){return _6cc("dijit.layout.ContentPane",[_6c7,_6c8,_6c9],{href:"",content:"",extractContent:false,parseOnLoad:true,parserScope:_6c6._scopeName,preventCache:false,preload:false,refreshOnShow:false,loadingMessage:"<span class='dijitContentPaneLoading'><span class='dijitInline dijitIconLoading'></span>${loadingState}</span>",errorMessage:"<span class='dijitContentPaneError'><span class='dijitInline dijitIconError'></span>${errorState}</span>",isLoaded:false,baseClass:"dijitContentPane",ioArgs:{},onLoadDeferred:null,_setTitleAttr:null,stopParser:true,template:false,markupFactory:function(_6d0,node,ctor){var self=new ctor(_6d0,node);return !self.href&&self._contentSetter&&self._contentSetter.parseDeferred&&!self._contentSetter.parseDeferred.isFulfilled()?self._contentSetter.parseDeferred.then(function(){return self;}):self;},create:function(_6d1,_6d2){if((!_6d1||!_6d1.template)&&_6d2&&!("href" in _6d1)&&!("content" in _6d1)){_6d2=dom.byId(_6d2);var df=_6d2.ownerDocument.createDocumentFragment();while(_6d2.firstChild){df.appendChild(_6d2.firstChild);}_6d1=lang.delegate(_6d1,{content:df});}this.inherited(arguments,[_6d1,_6d2]);},postMixInProperties:function(){this.inherited(arguments);var _6d3=i18n.getLocalization("dijit","loading",this.lang);this.loadingMessage=_6ca.substitute(this.loadingMessage,_6d3);this.errorMessage=_6ca.substitute(this.errorMessage,_6d3);},buildRendering:function(){this.inherited(arguments);if(!this.containerNode){this.containerNode=this.domNode;}this.domNode.removeAttribute("title");},startup:function(){this.inherited(arguments);if(this._contentSetter){_6cb.forEach(this._contentSetter.parseResults,function(obj){if(!obj._started&&!obj._destroyed&&lang.isFunction(obj.startup)){obj.startup();obj._started=true;}},this);}},_startChildren:function(){_6cb.forEach(this.getChildren(),function(obj){if(!obj._started&&!obj._destroyed&&lang.isFunction(obj.startup)){obj.startup();obj._started=true;}});if(this._contentSetter){_6cb.forEach(this._contentSetter.parseResults,function(obj){if(!obj._started&&!obj._destroyed&&lang.isFunction(obj.startup)){obj.startup();obj._started=true;}},this);}},setHref:function(href){_6c6.deprecated("dijit.layout.ContentPane.setHref() is deprecated. Use set('href', ...) instead.","","2.0");return this.set("href",href);},_setHrefAttr:function(href){this.cancel();this.onLoadDeferred=new _6cd(lang.hitch(this,"cancel"));this.onLoadDeferred.then(lang.hitch(this,"onLoad"));this._set("href",href);if(this.preload||(this._created&&this._isShown())){this._load();}else{this._hrefChanged=true;}return this.onLoadDeferred;},setContent:function(data){_6c6.deprecated("dijit.layout.ContentPane.setContent() is deprecated.  Use set('content', ...) instead.","","2.0");this.set("content",data);},_setContentAttr:function(data){this._set("href","");this.cancel();this.onLoadDeferred=new _6cd(lang.hitch(this,"cancel"));if(this._created){this.onLoadDeferred.then(lang.hitch(this,"onLoad"));}this._setContent(data||"");this._isDownloaded=false;return this.onLoadDeferred;},_getContentAttr:function(){return this.containerNode.innerHTML;},cancel:function(){if(this._xhrDfd&&(this._xhrDfd.fired==-1)){this._xhrDfd.cancel();}delete this._xhrDfd;this.onLoadDeferred=null;},destroy:function(){this.cancel();this.inherited(arguments);},destroyRecursive:function(_6d4){if(this._beingDestroyed){return;}this.inherited(arguments);},_onShow:function(){this.inherited(arguments);if(this.href){if(!this._xhrDfd&&(!this.isLoaded||this._hrefChanged||this.refreshOnShow)){return this.refresh();}}},refresh:function(){this.cancel();this.onLoadDeferred=new _6cd(lang.hitch(this,"cancel"));this.onLoadDeferred.then(lang.hitch(this,"onLoad"));this._load();return this.onLoadDeferred;},_load:function(){this._setContent(this.onDownloadStart(),true);var self=this;var _6d5={preventCache:(this.preventCache||this.refreshOnShow),url:this.href,handleAs:"text"};if(lang.isObject(this.ioArgs)){lang.mixin(_6d5,this.ioArgs);}var hand=(this._xhrDfd=(this.ioMethod||xhr.get)(_6d5)),_6d6;hand.then(function(html){_6d6=html;try{self._isDownloaded=true;return self._setContent(html,false);}catch(err){self._onError("Content",err);}},function(err){if(!hand.canceled){self._onError("Download",err);}delete self._xhrDfd;return err;}).then(function(){self.onDownloadEnd();delete self._xhrDfd;return _6d6;});delete this._hrefChanged;},_onLoadHandler:function(data){this._set("isLoaded",true);try{this.onLoadDeferred.resolve(data);}catch(e){console.error("Error "+(this.widgetId||this.id)+" running custom onLoad code: "+e.message);}},_onUnloadHandler:function(){this._set("isLoaded",false);try{this.onUnload();}catch(e){console.error("Error "+this.widgetId+" running custom onUnload code: "+e.message);}},destroyDescendants:function(_6d7){if(this.isLoaded){this._onUnloadHandler();}var _6d8=this._contentSetter;_6cb.forEach(this.getChildren(),function(_6d9){if(_6d9.destroyRecursive){_6d9.destroyRecursive(_6d7);}else{if(_6d9.destroy){_6d9.destroy(_6d7);}}_6d9._destroyed=true;});if(_6d8){_6cb.forEach(_6d8.parseResults,function(_6da){if(!_6da._destroyed){if(_6da.destroyRecursive){_6da.destroyRecursive(_6d7);}else{if(_6da.destroy){_6da.destroy(_6d7);}}_6da._destroyed=true;}});delete _6d8.parseResults;}if(!_6d7){_6cf.empty(this.containerNode);}delete this._singleChild;},_setContent:function(cont,_6db){cont=this.preprocessContent(cont);this.destroyDescendants();var _6dc=this._contentSetter;if(!(_6dc&&_6dc instanceof html._ContentSetter)){_6dc=this._contentSetter=new html._ContentSetter({node:this.containerNode,_onError:lang.hitch(this,this._onError),onContentError:lang.hitch(this,function(e){var _6dd=this.onContentError(e);try{this.containerNode.innerHTML=_6dd;}catch(e){console.error("Fatal "+this.id+" could not change content due to "+e.message,e);}})});}var _6de=lang.mixin({cleanContent:this.cleanContent,extractContent:this.extractContent,parseContent:!cont.domNode&&this.parseOnLoad,parserScope:this.parserScope,startup:false,dir:this.dir,lang:this.lang,textDir:this.textDir},this._contentSetterParams||{});var p=_6dc.set((lang.isObject(cont)&&cont.domNode)?cont.domNode:cont,_6de);var self=this;return when(p&&p.then?p:_6dc.parseDeferred,function(){delete self._contentSetterParams;if(!_6db){if(self._started){self._startChildren();self._scheduleLayout();}self._onLoadHandler(cont);}});},preprocessContent:function(_6df){return _6df;},_onError:function(type,err,_6e0){this.onLoadDeferred.reject(err);var _6e1=this["on"+type+"Error"].call(this,err);if(_6e0){console.error(_6e0,err);}else{if(_6e1){this._setContent(_6e1,true);}}},onLoad:function(){},onUnload:function(){},onDownloadStart:function(){return this.loadingMessage;},onContentError:function(){},onDownloadError:function(){return this.errorMessage;},onDownloadEnd:function(){}});});},"dijit/layout/_ContentPaneResizeMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/_base/lang","dojo/query","../registry","../Viewport","./utils"],function(_6e2,_6e3,_6e4,_6e5,_6e6,lang,_6e7,_6e8,_6e9,_6ea){return _6e3("dijit.layout._ContentPaneResizeMixin",null,{doLayout:true,isLayoutContainer:true,startup:function(){if(this._started){return;}var _6eb=this.getParent();this._childOfLayoutWidget=_6eb&&_6eb.isLayoutContainer;this._needLayout=!this._childOfLayoutWidget;this.inherited(arguments);if(this._isShown()){this._onShow();}if(!this._childOfLayoutWidget){this.own(_6e9.on("resize",lang.hitch(this,"resize")));}},_checkIfSingleChild:function(){if(!this.doLayout){return;}var _6ec=[],_6ed=false;_6e7("> *",this.containerNode).some(function(node){var _6ee=_6e8.byNode(node);if(_6ee&&_6ee.resize){_6ec.push(_6ee);}else{if(!/script|link|style/i.test(node.nodeName)&&node.offsetHeight){_6ed=true;}}});this._singleChild=_6ec.length==1&&!_6ed?_6ec[0]:null;_6e4.toggle(this.containerNode,this.baseClass+"SingleChild",!!this._singleChild);},resize:function(_6ef,_6f0){this._resizeCalled=true;this._scheduleLayout(_6ef,_6f0);},_scheduleLayout:function(_6f1,_6f2){if(this._isShown()){this._layout(_6f1,_6f2);}else{this._needLayout=true;this._changeSize=_6f1;this._resultSize=_6f2;}},_layout:function(_6f3,_6f4){delete this._needLayout;if(!this._wasShown&&this.open!==false){this._onShow();}if(_6f3){_6e5.setMarginBox(this.domNode,_6f3);}var cn=this.containerNode;if(cn===this.domNode){var mb=_6f4||{};lang.mixin(mb,_6f3||{});if(!("h" in mb)||!("w" in mb)){mb=lang.mixin(_6e5.getMarginBox(cn),mb);}this._contentBox=_6ea.marginBox2contentBox(cn,mb);}else{this._contentBox=_6e5.getContentBox(cn);}this._layoutChildren();},_layoutChildren:function(){this._checkIfSingleChild();if(this._singleChild&&this._singleChild.resize){var cb=this._contentBox||_6e5.getContentBox(this.containerNode);this._singleChild.resize({w:cb.w,h:cb.h});}else{var _6f5=this.getChildren(),_6f6,i=0;while(_6f6=_6f5[i++]){if(_6f6.resize){_6f6.resize();}}}},_isShown:function(){if(this._childOfLayoutWidget){if(this._resizeCalled&&"open" in this){return this.open;}return this._resizeCalled;}else{if("open" in this){return this.open;}else{var node=this.domNode,_6f7=this.domNode.parentNode;return (node.style.display!="none")&&(node.style.visibility!="hidden")&&!_6e4.contains(node,"dijitHidden")&&_6f7&&_6f7.style&&(_6f7.style.display!="none");}}},_onShow:function(){this._wasShown=true;if(this._needLayout){this._layout(this._changeSize,this._resultSize);}this.inherited(arguments);}});});},"dijit/layout/utils":function(){define(["dojo/_base/array","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/_base/lang"],function(_6f8,_6f9,_6fa,_6fb,lang){function _6fc(word){return word.substring(0,1).toUpperCase()+word.substring(1);};function size(_6fd,dim){var _6fe=_6fd.resize?_6fd.resize(dim):_6fa.setMarginBox(_6fd.domNode,dim);if(_6fe){lang.mixin(_6fd,_6fe);}else{lang.mixin(_6fd,_6fa.getMarginBox(_6fd.domNode));lang.mixin(_6fd,dim);}};var _6ff={marginBox2contentBox:function(node,mb){var cs=_6fb.getComputedStyle(node);var me=_6fa.getMarginExtents(node,cs);var pb=_6fa.getPadBorderExtents(node,cs);return {l:_6fb.toPixelValue(node,cs.paddingLeft),t:_6fb.toPixelValue(node,cs.paddingTop),w:mb.w-(me.w+pb.w),h:mb.h-(me.h+pb.h)};},layoutChildren:function(_700,dim,_701,_702,_703){dim=lang.mixin({},dim);_6f9.add(_700,"dijitLayoutContainer");_701=_6f8.filter(_701,function(item){return item.region!="center"&&item.layoutAlign!="client";}).concat(_6f8.filter(_701,function(item){return item.region=="center"||item.layoutAlign=="client";}));_6f8.forEach(_701,function(_704){var elm=_704.domNode,pos=(_704.region||_704.layoutAlign);if(!pos){throw new Error("No region setting for "+_704.id);}var _705=elm.style;_705.left=dim.l+"px";_705.top=dim.t+"px";_705.position="absolute";_6f9.add(elm,"dijitAlign"+_6fc(pos));var _706={};if(_702&&_702==_704.id){_706[_704.region=="top"||_704.region=="bottom"?"h":"w"]=_703;}if(pos=="leading"){pos=_704.isLeftToRight()?"left":"right";}if(pos=="trailing"){pos=_704.isLeftToRight()?"right":"left";}if(pos=="top"||pos=="bottom"){_706.w=dim.w;size(_704,_706);dim.h-=_704.h;if(pos=="top"){dim.t+=_704.h;}else{_705.top=dim.t+dim.h+"px";}}else{if(pos=="left"||pos=="right"){_706.h=dim.h;size(_704,_706);dim.w-=_704.w;if(pos=="left"){dim.l+=_704.w;}else{_705.left=dim.l+dim.w+"px";}}else{if(pos=="client"||pos=="center"){size(_704,dim);}}}});}};lang.setObject("dijit.layout.utils",_6ff);return _6ff;});},"dijit/form/Button":function(){define(["require","dojo/_base/declare","dojo/dom-class","dojo/has","dojo/_base/kernel","dojo/_base/lang","dojo/ready","./_FormWidget","./_ButtonMixin","dojo/text!./templates/Button.html","../a11yclick"],function(_707,_708,_709,has,_70a,lang,_70b,_70c,_70d,_70e){if(has("dijit-legacy-requires")){_70b(0,function(){var _70f=["dijit/form/DropDownButton","dijit/form/ComboButton","dijit/form/ToggleButton"];_707(_70f);});}var _710=_708("dijit.form.Button"+(has("dojo-bidi")?"_NoBidi":""),[_70c,_70d],{showLabel:true,iconClass:"dijitNoIcon",_setIconClassAttr:{node:"iconNode",type:"class"},baseClass:"dijitButton",templateString:_70e,_setValueAttr:"valueNode",_setNameAttr:function(name){if(this.valueNode){this.valueNode.setAttribute("name",name);}},postCreate:function(){this.inherited(arguments);this._setLabelFromContainer();},_setLabelFromContainer:function(){if(this.containerNode&&!this.label){this.label=lang.trim(this.containerNode.innerHTML);this.onLabelSet();}},_setShowLabelAttr:function(val){if(this.containerNode){_709.toggle(this.containerNode,"dijitDisplayNone",!val);}this._set("showLabel",val);},setLabel:function(_711){_70a.deprecated("dijit.form.Button.setLabel() is deprecated.  Use set('label', ...) instead.","","2.0");this.set("label",_711);},onLabelSet:function(){this.inherited(arguments);if(!this.showLabel&&!("title" in this.params)){this.titleNode.title=lang.trim(this.containerNode.innerText||this.containerNode.textContent||"");}}});if(has("dojo-bidi")){_710=_708("dijit.form.Button",_710,{onLabelSet:function(){this.inherited(arguments);if(this.titleNode.title){this.applyTextDir(this.titleNode,this.titleNode.title);}},_setTextDirAttr:function(_712){if(this._created&&this.textDir!=_712){this._set("textDir",_712);this._setLabelAttr(this.label);}}});}return _710;});},"dijit/form/_ButtonMixin":function(){define(["dojo/_base/declare","dojo/dom","dojo/has","../registry"],function(_713,dom,has,_714){var _715=_713("dijit.form._ButtonMixin"+(has("dojo-bidi")?"_NoBidi":""),null,{label:"",type:"button",__onClick:function(e){e.stopPropagation();e.preventDefault();if(!this.disabled){this.valueNode.click(e);}return false;},_onClick:function(e){if(this.disabled){e.stopPropagation();e.preventDefault();return false;}if(this.onClick(e)===false){e.preventDefault();}var _716=e.defaultPrevented;if(!_716&&this.type=="submit"&&!(this.valueNode||this.focusNode).form){for(var node=this.domNode;node.parentNode;node=node.parentNode){var _717=_714.byNode(node);if(_717&&typeof _717._onSubmit=="function"){_717._onSubmit(e);e.preventDefault();_716=true;break;}}}return !_716;},postCreate:function(){this.inherited(arguments);dom.setSelectable(this.focusNode,false);},onClick:function(){return true;},_setLabelAttr:function(_718){this._set("label",_718);var _719=this.containerNode||this.focusNode;_719.innerHTML=_718;this.onLabelSet();},onLabelSet:function(){}});if(has("dojo-bidi")){_715=_713("dijit.form._ButtonMixin",_715,{onLabelSet:function(){this.inherited(arguments);var _71a=this.containerNode||this.focusNode;this.applyTextDir(_71a);}});}return _715;});},"dijit/form/CheckBox":function(){define(["require","dojo/_base/declare","dojo/dom-attr","dojo/has","dojo/query","dojo/ready","./ToggleButton","./_CheckBoxMixin","dojo/text!./templates/CheckBox.html","dojo/NodeList-dom","../a11yclick"],function(_71b,_71c,_71d,has,_71e,_71f,_720,_721,_722){if(has("dijit-legacy-requires")){_71f(0,function(){var _723=["dijit/form/RadioButton"];_71b(_723);});}return _71c("dijit.form.CheckBox",[_720,_721],{templateString:_722,baseClass:"dijitCheckBox",_setValueAttr:function(_724,_725){if(typeof _724=="string"){this.inherited(arguments);_724=true;}if(this._created){this.set("checked",_724,_725);}},_getValueAttr:function(){return this.checked&&this._get("value");},_setIconClassAttr:null,_setNameAttr:"focusNode",postMixInProperties:function(){this.inherited(arguments);this.checkedAttrSetting="";},_fillContent:function(){},_onFocus:function(){if(this.id){_71e("label[for='"+this.id+"']").addClass("dijitFocusedLabel");}this.inherited(arguments);},_onBlur:function(){if(this.id){_71e("label[for='"+this.id+"']").removeClass("dijitFocusedLabel");}this.inherited(arguments);}});});},"dijit/form/ToggleButton":function(){define(["dojo/_base/declare","dojo/_base/kernel","./Button","./_ToggleButtonMixin"],function(_726,_727,_728,_729){return _726("dijit.form.ToggleButton",[_728,_729],{baseClass:"dijitToggleButton",setChecked:function(_72a){_727.deprecated("setChecked("+_72a+") is deprecated. Use set('checked',"+_72a+") instead.","","2.0");this.set("checked",_72a);}});});},"dijit/form/_ToggleButtonMixin":function(){define(["dojo/_base/declare","dojo/dom-attr"],function(_72b,_72c){return _72b("dijit.form._ToggleButtonMixin",null,{checked:false,_aria_attr:"aria-pressed",_onClick:function(evt){var _72d=this.checked;this._set("checked",!_72d);var ret=this.inherited(arguments);this.set("checked",ret?this.checked:_72d);return ret;},_setCheckedAttr:function(_72e,_72f){this._set("checked",_72e);var node=this.focusNode||this.domNode;if(this._created){if(_72c.get(node,"checked")!=!!_72e){_72c.set(node,"checked",!!_72e);}}node.setAttribute(this._aria_attr,String(_72e));this._handleOnChange(_72e,_72f);},postCreate:function(){this.inherited(arguments);var node=this.focusNode||this.domNode;if(this.checked){node.setAttribute("checked","checked");}if(this._resetValue===undefined){this._lastValueReported=this._resetValue=this.checked;}},reset:function(){this._hasBeenBlurred=false;this.set("checked",this.params.checked||false);}});});},"dijit/form/_CheckBoxMixin":function(){define(["dojo/_base/declare","dojo/dom-attr"],function(_730,_731){return _730("dijit.form._CheckBoxMixin",null,{type:"checkbox",value:"on",readOnly:false,_aria_attr:"aria-checked",_setReadOnlyAttr:function(_732){this._set("readOnly",_732);_731.set(this.focusNode,"readOnly",_732);},_setLabelAttr:undefined,_getSubmitValue:function(_733){return (_733==null||_733==="")?"on":_733;},_setValueAttr:function(_734){_734=this._getSubmitValue(_734);this._set("value",_734);_731.set(this.focusNode,"value",_734);},reset:function(){this.inherited(arguments);this._set("value",this._getSubmitValue(this.params.value));_731.set(this.focusNode,"value",this.value);},_onClick:function(e){if(this.readOnly){e.stopPropagation();e.preventDefault();return false;}return this.inherited(arguments);}});});},"dijit/form/ComboButton":function(){define(["dojo/_base/declare","dojo/keys","../focus","./DropDownButton","dojo/text!./templates/ComboButton.html","../a11yclick"],function(_735,keys,_736,_737,_738){return _735("dijit.form.ComboButton",_737,{templateString:_738,_setIdAttr:"",_setTabIndexAttr:["focusNode","titleNode"],_setTitleAttr:"titleNode",optionsTitle:"",baseClass:"dijitComboButton",cssStateNodes:{"buttonNode":"dijitButtonNode","titleNode":"dijitButtonContents","_popupStateNode":"dijitDownArrowButton"},_focusedNode:null,_onButtonKeyDown:function(evt){if(evt.keyCode==keys[this.isLeftToRight()?"RIGHT_ARROW":"LEFT_ARROW"]){_736.focus(this._popupStateNode);evt.stopPropagation();evt.preventDefault();}},_onArrowKeyDown:function(evt){if(evt.keyCode==keys[this.isLeftToRight()?"LEFT_ARROW":"RIGHT_ARROW"]){_736.focus(this.titleNode);evt.stopPropagation();evt.preventDefault();}},focus:function(_739){if(!this.disabled){_736.focus(_739=="start"?this.titleNode:this._popupStateNode);}}});});},"dijit/form/DropDownButton":function(){define(["dojo/_base/declare","dojo/_base/kernel","dojo/_base/lang","dojo/query","../registry","../popup","./Button","../_Container","../_HasDropDown","dojo/text!./templates/DropDownButton.html","../a11yclick"],function(_73a,_73b,lang,_73c,_73d,_73e,_73f,_740,_741,_742){return _73a("dijit.form.DropDownButton",[_73f,_740,_741],{baseClass:"dijitDropDownButton",templateString:_742,_fillContent:function(){var _743=this.srcNodeRef;var dest=this.containerNode;if(_743&&dest){while(_743.hasChildNodes()){var _744=_743.firstChild;if(_744.hasAttribute&&(_744.hasAttribute("data-dojo-type")||_744.hasAttribute("dojoType")||_744.hasAttribute("data-"+_73b._scopeName+"-type")||_744.hasAttribute(_73b._scopeName+"Type"))){this.dropDownContainer=this.ownerDocument.createElement("div");this.dropDownContainer.appendChild(_744);}else{dest.appendChild(_744);}}}},startup:function(){if(this._started){return;}if(!this.dropDown&&this.dropDownContainer){this.dropDown=_73d.byNode(this.dropDownContainer.firstChild);delete this.dropDownContainer;}if(this.dropDown){_73e.hide(this.dropDown);}this.inherited(arguments);},isLoaded:function(){var _745=this.dropDown;return (!!_745&&(!_745.href||_745.isLoaded));},loadDropDown:function(_746){var _747=this.dropDown;var _748=_747.on("load",lang.hitch(this,function(){_748.remove();_746();}));_747.refresh();},isFocusable:function(){return this.inherited(arguments)&&!this._mouseDown;}});});},"dijit/_HasDropDown":function(){define(["dojo/_base/declare","dojo/_base/Deferred","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/has","dojo/keys","dojo/_base/lang","dojo/on","dojo/touch","./registry","./focus","./popup","./_FocusMixin"],function(_749,_74a,dom,_74b,_74c,_74d,_74e,has,keys,lang,on,_74f,_750,_751,_752,_753){return _749("dijit._HasDropDown",_753,{_buttonNode:null,_arrowWrapperNode:null,_popupStateNode:null,_aroundNode:null,dropDown:null,autoWidth:true,forceWidth:false,maxHeight:-1,dropDownPosition:["below","above"],_stopClickEvents:true,_onDropDownMouseDown:function(e){if(this.disabled||this.readOnly){return;}if(e.type!="MSPointerDown"){e.preventDefault();}this.own(on.once(this.ownerDocument,_74f.release,lang.hitch(this,"_onDropDownMouseUp")));this.toggleDropDown();},_onDropDownMouseUp:function(e){var _754=this.dropDown,_755=false;if(e&&this._opened){var c=_74d.position(this._buttonNode,true);if(!(e.pageX>=c.x&&e.pageX<=c.x+c.w)||!(e.pageY>=c.y&&e.pageY<=c.y+c.h)){var t=e.target;while(t&&!_755){if(_74c.contains(t,"dijitPopup")){_755=true;}else{t=t.parentNode;}}if(_755){t=e.target;if(_754.onItemClick){var _756;while(t&&!(_756=_750.byNode(t))){t=t.parentNode;}if(_756&&_756.onClick&&_756.getParent){_756.getParent().onItemClick(_756,e);}}return;}}}if(this._opened){if(_754.focus&&(_754.autoFocus!==false||(e.type=="mouseup"&&!this.hovering))){this._focusDropDownTimer=this.defer(function(){_754.focus();delete this._focusDropDownTimer;});}}else{if(this.focus){this.defer("focus");}}},_onDropDownClick:function(e){if(this._stopClickEvents){e.stopPropagation();e.preventDefault();}},buildRendering:function(){this.inherited(arguments);this._buttonNode=this._buttonNode||this.focusNode||this.domNode;this._popupStateNode=this._popupStateNode||this.focusNode||this._buttonNode;var _757={"after":this.isLeftToRight()?"Right":"Left","before":this.isLeftToRight()?"Left":"Right","above":"Up","below":"Down","left":"Left","right":"Right"}[this.dropDownPosition[0]]||this.dropDownPosition[0]||"Down";_74c.add(this._arrowWrapperNode||this._buttonNode,"dijit"+_757+"ArrowButton");},postCreate:function(){this.inherited(arguments);var _758=this.focusNode||this.domNode;this.own(on(this._buttonNode,_74f.press,lang.hitch(this,"_onDropDownMouseDown")),on(this._buttonNode,"click",lang.hitch(this,"_onDropDownClick")),on(_758,"keydown",lang.hitch(this,"_onKey")),on(_758,"keyup",lang.hitch(this,"_onKeyUp")));},destroy:function(){if(this._opened){this.closeDropDown(true);}if(this.dropDown){if(!this.dropDown._destroyed){this.dropDown.destroyRecursive();}delete this.dropDown;}this.inherited(arguments);},_onKey:function(e){if(this.disabled||this.readOnly){return;}var d=this.dropDown,_759=e.target;if(d&&this._opened&&d.handleKey){if(d.handleKey(e)===false){e.stopPropagation();e.preventDefault();return;}}if(d&&this._opened&&e.keyCode==keys.ESCAPE){this.closeDropDown();e.stopPropagation();e.preventDefault();}else{if(!this._opened&&(e.keyCode==keys.DOWN_ARROW||((e.keyCode==keys.ENTER||(e.keyCode==keys.SPACE&&(!this._searchTimer||(e.ctrlKey||e.altKey||e.metaKey))))&&((_759.tagName||"").toLowerCase()!=="input"||(_759.type&&_759.type.toLowerCase()!=="text"))))){this._toggleOnKeyUp=true;e.stopPropagation();e.preventDefault();}}},_onKeyUp:function(){if(this._toggleOnKeyUp){delete this._toggleOnKeyUp;this.toggleDropDown();var d=this.dropDown;if(d&&d.focus){this.defer(lang.hitch(d,"focus"),1);}}},_onBlur:function(){this.closeDropDown(false);this.inherited(arguments);},isLoaded:function(){return true;},loadDropDown:function(_75a){_75a();},loadAndOpenDropDown:function(){var d=new _74a(),_75b=lang.hitch(this,function(){this.openDropDown();d.resolve(this.dropDown);});if(!this.isLoaded()){this.loadDropDown(_75b);}else{_75b();}return d;},toggleDropDown:function(){if(this.disabled||this.readOnly){return;}if(!this._opened){this.loadAndOpenDropDown();}else{this.closeDropDown(true);}},openDropDown:function(){var _75c=this.dropDown,_75d=_75c.domNode,_75e=this._aroundNode||this.domNode,self=this;var _75f=_752.open({parent:this,popup:_75c,around:_75e,orient:this.dropDownPosition,maxHeight:this.maxHeight,onExecute:function(){self.closeDropDown(true);},onCancel:function(){self.closeDropDown(true);},onClose:function(){_74b.set(self._popupStateNode,"popupActive",false);_74c.remove(self._popupStateNode,"dijitHasDropDownOpen");self._set("_opened",false);}});if(this.forceWidth||(this.autoWidth&&_75e.offsetWidth>_75c._popupWrapper.offsetWidth)){var _760=_75e.offsetWidth-_75c._popupWrapper.offsetWidth;var _761={w:_75c.domNode.offsetWidth+_760};this._origStyle=_75d.style.cssText;if(lang.isFunction(_75c.resize)){_75c.resize(_761);}else{_74d.setMarginBox(_75d,_761);}if(_75f.corner[1]=="R"){_75c._popupWrapper.style.left=(_75c._popupWrapper.style.left.replace("px","")-_760)+"px";}}_74b.set(this._popupStateNode,"popupActive","true");_74c.add(this._popupStateNode,"dijitHasDropDownOpen");this._set("_opened",true);this._popupStateNode.setAttribute("aria-expanded","true");this._popupStateNode.setAttribute("aria-owns",_75c.id);if(_75d.getAttribute("role")!=="presentation"&&!_75d.getAttribute("aria-labelledby")){_75d.setAttribute("aria-labelledby",this.id);}return _75f;},closeDropDown:function(_762){if(this._focusDropDownTimer){this._focusDropDownTimer.remove();delete this._focusDropDownTimer;}if(this._opened){this._popupStateNode.setAttribute("aria-expanded","false");if(_762&&this.focus){this.focus();}_752.close(this.dropDown);this._opened=false;}if(this._origStyle){this.dropDown.domNode.style.cssText=this._origStyle;delete this._origStyle;}}});});},"dijit/form/FilteringSelect":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/when","./MappedTextBox","./ComboBoxMixin"],function(_763,lang,when,_764,_765){return _763("dijit.form.FilteringSelect",[_764,_765],{required:true,_lastDisplayedValue:"",_isValidSubset:function(){return this._opened;},isValid:function(){return !!this.item||(!this.required&&this.get("displayedValue")=="");},_refreshState:function(){if(!this.searchTimer){this.inherited(arguments);}},_callbackSetLabel:function(_766,_767,_768,_769){if((_767&&_767[this.searchAttr]!==this._lastQuery)||(!_767&&_766.length&&this.store.getIdentity(_766[0])!=this._lastQuery)){return;}if(!_766.length){this.set("value","",_769||(_769===undefined&&!this.focused),this.textbox.value,null);}else{this.set("item",_766[0],_769);}},_openResultList:function(_76a,_76b,_76c){if(_76b[this.searchAttr]!==this._lastQuery){return;}this.inherited(arguments);if(this.item===undefined){this.validate(true);}},_getValueAttr:function(){return this.valueNode.value;},_getValueField:function(){return "value";},_setValueAttr:function(_76d,_76e,_76f,item){if(!this._onChangeActive){_76e=null;}if(item===undefined){if(_76d===null||_76d===""){_76d="";if(!lang.isString(_76f)){this._setDisplayedValueAttr(_76f||"",_76e);return;}}var self=this;this._lastQuery=_76d;when(this.store.get(_76d),function(item){self._callbackSetLabel(item?[item]:[],undefined,undefined,_76e);});}else{this.valueNode.value=_76d;this.inherited(arguments,[_76d,_76e,_76f,item]);}},_setItemAttr:function(item,_770,_771){this.inherited(arguments);this._lastDisplayedValue=this.textbox.value;},_getDisplayQueryString:function(text){return text.replace(/([\\\*\?])/g,"\\$1");},_setDisplayedValueAttr:function(_772,_773){if(_772==null){_772="";}if(!this._created){if(!("displayedValue" in this.params)){return;}_773=false;}if(this.store){this.closeDropDown();var _774=lang.clone(this.query);var qs=this._getDisplayQueryString(_772),q;if(this.store._oldAPI){q=qs;}else{q=this._patternToRegExp(qs);q.toString=function(){return qs;};}this._lastQuery=_774[this.searchAttr]=q;this.textbox.value=_772;this._lastDisplayedValue=_772;this._set("displayedValue",_772);var _775=this;var _776={queryOptions:{ignoreCase:this.ignoreCase,deep:true}};lang.mixin(_776,this.fetchProperties);this._fetchHandle=this.store.query(_774,_776);when(this._fetchHandle,function(_777){_775._fetchHandle=null;_775._callbackSetLabel(_777||[],_774,_776,_773);},function(err){_775._fetchHandle=null;if(!_775._cancelingQuery){console.error("dijit.form.FilteringSelect: "+err.toString());}});}},undo:function(){this.set("displayedValue",this._lastDisplayedValue);}});});},"dijit/form/MappedTextBox":function(){define(["dojo/_base/declare","dojo/sniff","dojo/dom-construct","./ValidationTextBox"],function(_778,has,_779,_77a){return _778("dijit.form.MappedTextBox",_77a,{postMixInProperties:function(){this.inherited(arguments);this.nameAttrSetting="";},_setNameAttr:"valueNode",serialize:function(val){return val.toString?val.toString():"";},toString:function(){var val=this.filter(this.get("value"));return val!=null?(typeof val=="string"?val:this.serialize(val,this.constraints)):"";},validate:function(){this.valueNode.value=this.toString();return this.inherited(arguments);},buildRendering:function(){this.inherited(arguments);this.valueNode=_779.place("<input type='hidden'"+((this.name&&!has("msapp"))?" name=\""+this.name.replace(/"/g,"&quot;")+"\"":"")+"/>",this.textbox,"after");},reset:function(){this.valueNode.value="";this.inherited(arguments);}});});},"dijit/form/ValidationTextBox":function(){define(["dojo/_base/declare","dojo/_base/kernel","dojo/_base/lang","dojo/i18n","./TextBox","../Tooltip","dojo/text!./templates/ValidationTextBox.html","dojo/i18n!./nls/validate"],function(_77b,_77c,lang,i18n,_77d,_77e,_77f){var _780=_77b("dijit.form.ValidationTextBox",_77d,{templateString:_77f,required:false,promptMessage:"",invalidMessage:"$_unset_$",missingMessage:"$_unset_$",message:"",constraints:{},pattern:".*",regExp:"",regExpGen:function(){},state:"",tooltipPosition:[],_deprecateRegExp:function(attr,_781){if(_781!=_780.prototype[attr]){_77c.deprecated("ValidationTextBox id="+this.id+", set('"+attr+"', ...) is deprecated.  Use set('pattern', ...) instead.","","2.0");this.set("pattern",_781);}},_setRegExpGenAttr:function(_782){this._deprecateRegExp("regExpGen",_782);this._set("regExpGen",this._computeRegexp);},_setRegExpAttr:function(_783){this._deprecateRegExp("regExp",_783);},_setValueAttr:function(){this.inherited(arguments);this._refreshState();},validator:function(_784,_785){return (new RegExp("^(?:"+this._computeRegexp(_785)+")"+(this.required?"":"?")+"$")).test(_784)&&(!this.required||!this._isEmpty(_784))&&(this._isEmpty(_784)||this.parse(_784,_785)!==undefined);},_isValidSubset:function(){return this.textbox.value.search(this._partialre)==0;},isValid:function(){return this.validator(this.textbox.value,this.get("constraints"));},_isEmpty:function(_786){return (this.trim?/^\s*$/:/^$/).test(_786);},getErrorMessage:function(){var _787=this.invalidMessage=="$_unset_$"?this.messages.invalidMessage:!this.invalidMessage?this.promptMessage:this.invalidMessage;var _788=this.missingMessage=="$_unset_$"?this.messages.missingMessage:!this.missingMessage?_787:this.missingMessage;return (this.required&&this._isEmpty(this.textbox.value))?_788:_787;},getPromptMessage:function(){return this.promptMessage;},_maskValidSubsetError:true,validate:function(_789){var _78a="";var _78b=this.disabled||this.isValid(_789);if(_78b){this._maskValidSubsetError=true;}var _78c=this._isEmpty(this.textbox.value);var _78d=!_78b&&_789&&this._isValidSubset();this._set("state",_78b?"":(((((!this._hasBeenBlurred||_789)&&_78c)||_78d)&&(this._maskValidSubsetError||(_78d&&!this._hasBeenBlurred&&_789)))?"Incomplete":"Error"));this.focusNode.setAttribute("aria-invalid",this.state=="Error"?"true":"false");if(this.state=="Error"){this._maskValidSubsetError=_789&&_78d;_78a=this.getErrorMessage(_789);}else{if(this.state=="Incomplete"){_78a=this.getPromptMessage(_789);this._maskValidSubsetError=!this._hasBeenBlurred||_789;}else{if(_78c){_78a=this.getPromptMessage(_789);}}}this.set("message",_78a);return _78b;},displayMessage:function(_78e){if(_78e&&this.focused){_77e.show(_78e,this.domNode,this.tooltipPosition,!this.isLeftToRight());}else{_77e.hide(this.domNode);}},_refreshState:function(){if(this._created){this.validate(this.focused);}this.inherited(arguments);},constructor:function(_78f){this.constraints=lang.clone(this.constraints);this.baseClass+=" dijitValidationTextBox";},startup:function(){this.inherited(arguments);this._refreshState();},_setConstraintsAttr:function(_790){if(!_790.locale&&this.lang){_790.locale=this.lang;}this._set("constraints",_790);this._refreshState();},_setPatternAttr:function(_791){this._set("pattern",_791);this._refreshState();},_computeRegexp:function(_792){var p=this.pattern;if(typeof p=="function"){p=p.call(this,_792);}if(p!=this._lastRegExp){var _793="";this._lastRegExp=p;if(p!=".*"){p.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,function(re){switch(re.charAt(0)){case "{":case "+":case "?":case "*":case "^":case "$":case "|":case "(":_793+=re;break;case ")":_793+="|$)";break;default:_793+="(?:"+re+"|$)";break;}});}try{"".search(_793);}catch(e){_793=this.pattern;console.warn("RegExp error in "+this.declaredClass+": "+this.pattern);}this._partialre="^(?:"+_793+")$";}return p;},postMixInProperties:function(){this.inherited(arguments);this.messages=i18n.getLocalization("dijit.form","validate",this.lang);this._setConstraintsAttr(this.constraints);},_setDisabledAttr:function(_794){this.inherited(arguments);this._refreshState();},_setRequiredAttr:function(_795){this._set("required",_795);this.focusNode.setAttribute("aria-required",_795);this._refreshState();},_setMessageAttr:function(_796){this._set("message",_796);this.displayMessage(_796);},reset:function(){this._maskValidSubsetError=true;this.inherited(arguments);},_onBlur:function(){this.displayMessage("");this.inherited(arguments);},destroy:function(){_77e.hide(this.domNode);this.inherited(arguments);}});return _780;});},"dijit/form/TextBox":function(){define(["dojo/_base/declare","dojo/dom-construct","dojo/dom-style","dojo/_base/kernel","dojo/_base/lang","dojo/on","dojo/sniff","./_FormValueWidget","./_TextBoxMixin","dojo/text!./templates/TextBox.html","../main"],function(_797,_798,_799,_79a,lang,on,has,_79b,_79c,_79d,_79e){var _79f=_797("dijit.form.TextBox"+(has("dojo-bidi")?"_NoBidi":""),[_79b,_79c],{templateString:_79d,_singleNodeTemplate:"<input class=\"dijit dijitReset dijitLeft dijitInputField\" data-dojo-attach-point=\"textbox,focusNode\" autocomplete=\"off\" type=\"${type}\" ${!nameAttrSetting} />",_buttonInputDisabled:has("ie")?"disabled":"",baseClass:"dijitTextBox",postMixInProperties:function(){var type=this.type.toLowerCase();if(this.templateString&&this.templateString.toLowerCase()=="input"||((type=="hidden"||type=="file")&&this.templateString==this.constructor.prototype.templateString)){this.templateString=this._singleNodeTemplate;}this.inherited(arguments);},postCreate:function(){this.inherited(arguments);if(has("ie")<9){this.defer(function(){try{var s=_799.getComputedStyle(this.domNode);if(s){var ff=s.fontFamily;if(ff){var _7a0=this.domNode.getElementsByTagName("INPUT");if(_7a0){for(var i=0;i<_7a0.length;i++){_7a0[i].style.fontFamily=ff;}}}}}catch(e){}});}},_setPlaceHolderAttr:function(v){this._set("placeHolder",v);if(!this._phspan){this._attachPoints.push("_phspan");this._phspan=_798.create("span",{className:"dijitPlaceHolder dijitInputField"},this.textbox,"after");this.own(on(this._phspan,"mousedown",function(evt){evt.preventDefault();}),on(this._phspan,"touchend, pointerup, MSPointerUp",lang.hitch(this,function(){this.focus();})));}this._phspan.innerHTML="";this._phspan.appendChild(this._phspan.ownerDocument.createTextNode(v));this._updatePlaceHolder();},_onInput:function(evt){this.inherited(arguments);this._updatePlaceHolder();},_updatePlaceHolder:function(){if(this._phspan){this._phspan.style.display=(this.placeHolder&&!this.textbox.value)?"":"none";}},_setValueAttr:function(_7a1,_7a2,_7a3){this.inherited(arguments);this._updatePlaceHolder();},getDisplayedValue:function(){_79a.deprecated(this.declaredClass+"::getDisplayedValue() is deprecated. Use get('displayedValue') instead.","","2.0");return this.get("displayedValue");},setDisplayedValue:function(_7a4){_79a.deprecated(this.declaredClass+"::setDisplayedValue() is deprecated. Use set('displayedValue', ...) instead.","","2.0");this.set("displayedValue",_7a4);},_onBlur:function(e){if(this.disabled){return;}this.inherited(arguments);this._updatePlaceHolder();if(has("mozilla")){if(this.selectOnClick){this.textbox.selectionStart=this.textbox.selectionEnd=undefined;}}},_onFocus:function(by){if(this.disabled||this.readOnly){return;}this.inherited(arguments);this._updatePlaceHolder();}});if(has("ie")<9){_79f.prototype._isTextSelected=function(){var _7a5=this.ownerDocument.selection.createRange();var _7a6=_7a5.parentElement();return _7a6==this.textbox&&_7a5.text.length>0;};_79e._setSelectionRange=_79c._setSelectionRange=function(_7a7,_7a8,stop){if(_7a7.createTextRange){var r=_7a7.createTextRange();r.collapse(true);r.moveStart("character",-99999);r.moveStart("character",_7a8);r.moveEnd("character",stop-_7a8);r.select();}};}if(has("dojo-bidi")){_79f=_797("dijit.form.TextBox",_79f,{_setPlaceHolderAttr:function(v){this.inherited(arguments);this.applyTextDir(this._phspan);}});}return _79f;});},"dijit/form/_TextBoxMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom","dojo/sniff","dojo/keys","dojo/_base/lang","dojo/on","../main"],function(_7a9,_7aa,dom,has,keys,lang,on,_7ab){var _7ac=_7aa("dijit.form._TextBoxMixin"+(has("dojo-bidi")?"_NoBidi":""),null,{trim:false,uppercase:false,lowercase:false,propercase:false,maxLength:"",selectOnClick:false,placeHolder:"",_getValueAttr:function(){return this.parse(this.get("displayedValue"),this.constraints);},_setValueAttr:function(_7ad,_7ae,_7af){var _7b0;if(_7ad!==undefined){_7b0=this.filter(_7ad);if(typeof _7af!="string"){if(_7b0!==null&&((typeof _7b0!="number")||!isNaN(_7b0))){_7af=this.filter(this.format(_7b0,this.constraints));}else{_7af="";}if(this.compare(_7b0,this.filter(this.parse(_7af,this.constraints)))!=0){_7af=null;}}}if(_7af!=null&&((typeof _7af)!="number"||!isNaN(_7af))&&this.textbox.value!=_7af){this.textbox.value=_7af;this._set("displayedValue",this.get("displayedValue"));}this.inherited(arguments,[_7b0,_7ae]);},displayedValue:"",_getDisplayedValueAttr:function(){return this.filter(this.textbox.value);},_setDisplayedValueAttr:function(_7b1){if(_7b1==null){_7b1="";}else{if(typeof _7b1!="string"){_7b1=String(_7b1);}}this.textbox.value=_7b1;this._setValueAttr(this.get("value"),undefined);this._set("displayedValue",this.get("displayedValue"));},format:function(_7b2){return _7b2==null?"":(_7b2.toString?_7b2.toString():_7b2);},parse:function(_7b3){return _7b3;},_refreshState:function(){},onInput:function(){},_onInput:function(evt){this._lastInputEventValue=this.textbox.value;this._processInput(this._lastInputProducingEvent||evt);delete this._lastInputProducingEvent;if(this.intermediateChanges){this._handleOnChange(this.get("value"),false);}},_processInput:function(){this._refreshState();this._set("displayedValue",this.get("displayedValue"));},postCreate:function(){this.textbox.setAttribute("value",this.textbox.value);this.inherited(arguments);function _7b4(e){var _7b5;if(e.type=="keydown"&&e.keyCode!=229){_7b5=e.keyCode;switch(_7b5){case keys.SHIFT:case keys.ALT:case keys.CTRL:case keys.META:case keys.CAPS_LOCK:case keys.NUM_LOCK:case keys.SCROLL_LOCK:return;}if(!e.ctrlKey&&!e.metaKey&&!e.altKey){switch(_7b5){case keys.NUMPAD_0:case keys.NUMPAD_1:case keys.NUMPAD_2:case keys.NUMPAD_3:case keys.NUMPAD_4:case keys.NUMPAD_5:case keys.NUMPAD_6:case keys.NUMPAD_7:case keys.NUMPAD_8:case keys.NUMPAD_9:case keys.NUMPAD_MULTIPLY:case keys.NUMPAD_PLUS:case keys.NUMPAD_ENTER:case keys.NUMPAD_MINUS:case keys.NUMPAD_PERIOD:case keys.NUMPAD_DIVIDE:return;}if((_7b5>=65&&_7b5<=90)||(_7b5>=48&&_7b5<=57)||_7b5==keys.SPACE){return;}var _7b6=false;for(var i in keys){if(keys[i]===e.keyCode){_7b6=true;break;}}if(!_7b6){return;}}}_7b5=e.charCode>=32?String.fromCharCode(e.charCode):e.charCode;if(!_7b5){_7b5=(e.keyCode>=65&&e.keyCode<=90)||(e.keyCode>=48&&e.keyCode<=57)||e.keyCode==keys.SPACE?String.fromCharCode(e.keyCode):e.keyCode;}if(!_7b5){_7b5=229;}if(e.type=="keypress"){if(typeof _7b5!="string"){return;}if((_7b5>="a"&&_7b5<="z")||(_7b5>="A"&&_7b5<="Z")||(_7b5>="0"&&_7b5<="9")||(_7b5===" ")){if(e.ctrlKey||e.metaKey||e.altKey){return;}}}var faux={faux:true},attr;for(attr in e){if(!/^(layer[XY]|returnValue|keyLocation)$/.test(attr)){var v=e[attr];if(typeof v!="function"&&typeof v!="undefined"){faux[attr]=v;}}}lang.mixin(faux,{charOrCode:_7b5,_wasConsumed:false,preventDefault:function(){faux._wasConsumed=true;e.preventDefault();},stopPropagation:function(){e.stopPropagation();}});this._lastInputProducingEvent=faux;if(this.onInput(faux)===false){faux.preventDefault();faux.stopPropagation();}if(faux._wasConsumed){return;}if(has("ie")<=9){switch(e.keyCode){case keys.TAB:case keys.ESCAPE:case keys.DOWN_ARROW:case keys.UP_ARROW:case keys.LEFT_ARROW:case keys.RIGHT_ARROW:break;default:if(e.keyCode==keys.ENTER&&this.textbox.tagName.toLowerCase()!="textarea"){break;}this.defer(function(){if(this.textbox.value!==this._lastInputEventValue){on.emit(this.textbox,"input",{bubbles:true});}});}}};this.own(on(this.textbox,"keydown, keypress, paste, cut, compositionend",lang.hitch(this,_7b4)),on(this.textbox,"input",lang.hitch(this,"_onInput")),on(this.domNode,"keypress",function(e){e.stopPropagation();}));},_blankValue:"",filter:function(val){if(val===null){return this._blankValue;}if(typeof val!="string"){return val;}if(this.trim){val=lang.trim(val);}if(this.uppercase){val=val.toUpperCase();}if(this.lowercase){val=val.toLowerCase();}if(this.propercase){val=val.replace(/[^\s]+/g,function(word){return word.substring(0,1).toUpperCase()+word.substring(1);});}return val;},_setBlurValue:function(){this._setValueAttr(this.get("value"),true);},_onBlur:function(e){if(this.disabled){return;}this._setBlurValue();this.inherited(arguments);},_isTextSelected:function(){return this.textbox.selectionStart!=this.textbox.selectionEnd;},_onFocus:function(by){if(this.disabled||this.readOnly){return;}if(this.selectOnClick&&by=="mouse"){this._selectOnClickHandle=on.once(this.domNode,"mouseup, touchend",lang.hitch(this,function(evt){if(!this._isTextSelected()){_7ac.selectInputText(this.textbox);}}));this.own(this._selectOnClickHandle);this.defer(function(){if(this._selectOnClickHandle){this._selectOnClickHandle.remove();this._selectOnClickHandle=null;}},500);}this.inherited(arguments);this._refreshState();},reset:function(){this.textbox.value="";this.inherited(arguments);}});if(has("dojo-bidi")){_7ac=_7aa("dijit.form._TextBoxMixin",_7ac,{_setValueAttr:function(){this.inherited(arguments);this.applyTextDir(this.focusNode);},_setDisplayedValueAttr:function(){this.inherited(arguments);this.applyTextDir(this.focusNode);},_onInput:function(){this.applyTextDir(this.focusNode);this.inherited(arguments);}});}_7ac._setSelectionRange=_7ab._setSelectionRange=function(_7b7,_7b8,stop){if(_7b7.setSelectionRange){_7b7.setSelectionRange(_7b8,stop);}};_7ac.selectInputText=_7ab.selectInputText=function(_7b9,_7ba,stop){_7b9=dom.byId(_7b9);if(isNaN(_7ba)){_7ba=0;}if(isNaN(stop)){stop=_7b9.value?_7b9.value.length:0;}try{_7b9.focus();_7ac._setSelectionRange(_7b9,_7ba,stop);}catch(e){}};return _7ac;});},"dijit/Tooltip":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/_base/fx","dojo/dom","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/_base/lang","dojo/mouse","dojo/on","dojo/sniff","./_base/manager","./place","./_Widget","./_TemplatedMixin","./BackgroundIframe","dojo/text!./templates/Tooltip.html","./main"],function(_7bb,_7bc,fx,dom,_7bd,_7be,_7bf,lang,_7c0,on,has,_7c1,_7c2,_7c3,_7c4,_7c5,_7c6,_7c7){var _7c8=_7bc("dijit._MasterTooltip",[_7c3,_7c4],{duration:_7c1.defaultDuration,templateString:_7c6,postCreate:function(){this.ownerDocumentBody.appendChild(this.domNode);this.bgIframe=new _7c5(this.domNode);this.fadeIn=fx.fadeIn({node:this.domNode,duration:this.duration,onEnd:lang.hitch(this,"_onShow")});this.fadeOut=fx.fadeOut({node:this.domNode,duration:this.duration,onEnd:lang.hitch(this,"_onHide")});},show:function(_7c9,_7ca,_7cb,rtl,_7cc,_7cd,_7ce){if(this.aroundNode&&this.aroundNode===_7ca&&this.containerNode.innerHTML==_7c9){return;}if(this.fadeOut.status()=="playing"){this._onDeck=arguments;return;}this.containerNode.innerHTML=_7c9;if(_7cc){this.set("textDir",_7cc);}this.containerNode.align=rtl?"right":"left";var pos=_7c2.around(this.domNode,_7ca,_7cb&&_7cb.length?_7cb:_7cf.defaultPosition,!rtl,lang.hitch(this,"orient"));var _7d0=pos.aroundNodePos;if(pos.corner.charAt(0)=="M"&&pos.aroundCorner.charAt(0)=="M"){this.connectorNode.style.top=_7d0.y+((_7d0.h-this.connectorNode.offsetHeight)>>1)-pos.y+"px";this.connectorNode.style.left="";}else{if(pos.corner.charAt(1)=="M"&&pos.aroundCorner.charAt(1)=="M"){this.connectorNode.style.left=_7d0.x+((_7d0.w-this.connectorNode.offsetWidth)>>1)-pos.x+"px";}else{this.connectorNode.style.left="";this.connectorNode.style.top="";}}_7bf.set(this.domNode,"opacity",0);this.fadeIn.play();this.isShowingNow=true;this.aroundNode=_7ca;this.onMouseEnter=_7cd||noop;this.onMouseLeave=_7ce||noop;},orient:function(node,_7d1,_7d2,_7d3,_7d4){this.connectorNode.style.top="";var _7d5=_7d3.h,_7d6=_7d3.w;node.className="dijitTooltip "+{"MR-ML":"dijitTooltipRight","ML-MR":"dijitTooltipLeft","TM-BM":"dijitTooltipAbove","BM-TM":"dijitTooltipBelow","BL-TL":"dijitTooltipBelow dijitTooltipABLeft","TL-BL":"dijitTooltipAbove dijitTooltipABLeft","BR-TR":"dijitTooltipBelow dijitTooltipABRight","TR-BR":"dijitTooltipAbove dijitTooltipABRight","BR-BL":"dijitTooltipRight","BL-BR":"dijitTooltipLeft"}[_7d1+"-"+_7d2];this.domNode.style.width="auto";var size=_7be.position(this.domNode);if(has("ie")||has("trident")){size.w+=2;}var _7d7=Math.min((Math.max(_7d6,1)),size.w);_7be.setMarginBox(this.domNode,{w:_7d7});if(_7d2.charAt(0)=="B"&&_7d1.charAt(0)=="B"){var bb=_7be.position(node);var _7d8=this.connectorNode.offsetHeight;if(bb.h>_7d5){var _7d9=_7d5-((_7d4.h+_7d8)>>1);this.connectorNode.style.top=_7d9+"px";this.connectorNode.style.bottom="";}else{this.connectorNode.style.bottom=Math.min(Math.max(_7d4.h/2-_7d8/2,0),bb.h-_7d8)+"px";this.connectorNode.style.top="";}}else{this.connectorNode.style.top="";this.connectorNode.style.bottom="";}return Math.max(0,size.w-_7d6);},_onShow:function(){if(has("ie")){this.domNode.style.filter="";}},hide:function(_7da){if(this._onDeck&&this._onDeck[1]==_7da){this._onDeck=null;}else{if(this.aroundNode===_7da){this.fadeIn.stop();this.isShowingNow=false;this.aroundNode=null;this.fadeOut.play();}else{}}this.onMouseEnter=this.onMouseLeave=noop;},_onHide:function(){this.domNode.style.cssText="";this.containerNode.innerHTML="";if(this._onDeck){this.show.apply(this,this._onDeck);this._onDeck=null;}}});if(has("dojo-bidi")){_7c8.extend({_setAutoTextDir:function(node){this.applyTextDir(node);_7bb.forEach(node.children,function(_7db){this._setAutoTextDir(_7db);},this);},_setTextDirAttr:function(_7dc){this._set("textDir",_7dc);if(_7dc=="auto"){this._setAutoTextDir(this.containerNode);}else{this.containerNode.dir=this.textDir;}}});}_7c7.showTooltip=function(_7dd,_7de,_7df,rtl,_7e0,_7e1,_7e2){if(_7df){_7df=_7bb.map(_7df,function(val){return {after:"after-centered",before:"before-centered"}[val]||val;});}if(!_7cf._masterTT){_7c7._masterTT=_7cf._masterTT=new _7c8();}return _7cf._masterTT.show(_7dd,_7de,_7df,rtl,_7e0,_7e1,_7e2);};_7c7.hideTooltip=function(_7e3){return _7cf._masterTT&&_7cf._masterTT.hide(_7e3);};var _7e4="DORMANT",_7e5="SHOW TIMER",_7e6="SHOWING",_7e7="HIDE TIMER";function noop(){};var _7cf=_7bc("dijit.Tooltip",_7c3,{label:"",showDelay:400,hideDelay:400,connectId:[],position:[],selector:"",_setConnectIdAttr:function(_7e8){_7bb.forEach(this._connections||[],function(_7e9){_7bb.forEach(_7e9,function(_7ea){_7ea.remove();});},this);this._connectIds=_7bb.filter(lang.isArrayLike(_7e8)?_7e8:(_7e8?[_7e8]:[]),function(id){return dom.byId(id,this.ownerDocument);},this);this._connections=_7bb.map(this._connectIds,function(id){var node=dom.byId(id,this.ownerDocument),_7eb=this.selector,_7ec=_7eb?function(_7ed){return on.selector(_7eb,_7ed);}:function(_7ee){return _7ee;},self=this;return [on(node,_7ec(_7c0.enter),function(){self._onHover(this);}),on(node,_7ec("focusin"),function(){self._onHover(this);}),on(node,_7ec(_7c0.leave),lang.hitch(self,"_onUnHover")),on(node,_7ec("focusout"),lang.hitch(self,"set","state",_7e4))];},this);this._set("connectId",_7e8);},addTarget:function(node){var id=node.id||node;if(_7bb.indexOf(this._connectIds,id)==-1){this.set("connectId",this._connectIds.concat(id));}},removeTarget:function(node){var id=node.id||node,idx=_7bb.indexOf(this._connectIds,id);if(idx>=0){this._connectIds.splice(idx,1);this.set("connectId",this._connectIds);}},buildRendering:function(){this.inherited(arguments);_7bd.add(this.domNode,"dijitTooltipData");},startup:function(){this.inherited(arguments);var ids=this.connectId;_7bb.forEach(lang.isArrayLike(ids)?ids:[ids],this.addTarget,this);},getContent:function(node){return this.label||this.domNode.innerHTML;},state:_7e4,_setStateAttr:function(val){if(this.state==val||(val==_7e5&&this.state==_7e6)||(val==_7e7&&this.state==_7e4)){return;}if(this._hideTimer){this._hideTimer.remove();delete this._hideTimer;}if(this._showTimer){this._showTimer.remove();delete this._showTimer;}switch(val){case _7e4:if(this._connectNode){_7cf.hide(this._connectNode);delete this._connectNode;this.onHide();}break;case _7e5:if(this.state!=_7e6){this._showTimer=this.defer(function(){this.set("state",_7e6);},this.showDelay);}break;case _7e6:var _7ef=this.getContent(this._connectNode);if(!_7ef){this.set("state",_7e4);return;}_7cf.show(_7ef,this._connectNode,this.position,!this.isLeftToRight(),this.textDir,lang.hitch(this,"set","state",_7e6),lang.hitch(this,"set","state",_7e7));this.onShow(this._connectNode,this.position);break;case _7e7:this._hideTimer=this.defer(function(){this.set("state",_7e4);},this.hideDelay);break;}this._set("state",val);},_onHover:function(_7f0){if(this._connectNode&&_7f0!=this._connectNode){this.set("state",_7e4);}this._connectNode=_7f0;this.set("state",_7e5);},_onUnHover:function(_7f1){this.set("state",_7e7);},open:function(_7f2){this.set("state",_7e4);this._connectNode=_7f2;this.set("state",_7e6);},close:function(){this.set("state",_7e4);},onShow:function(){},onHide:function(){},destroy:function(){this.set("state",_7e4);_7bb.forEach(this._connections||[],function(_7f3){_7bb.forEach(_7f3,function(_7f4){_7f4.remove();});},this);this.inherited(arguments);}});_7cf._MasterTooltip=_7c8;_7cf.show=_7c7.showTooltip;_7cf.hide=_7c7.hideTooltip;_7cf.defaultPosition=["after-centered","before-centered"];return _7cf;});},"dijit/form/ComboBoxMixin":function(){define(["dojo/_base/declare","dojo/Deferred","dojo/_base/kernel","dojo/_base/lang","dojo/store/util/QueryResults","./_AutoCompleterMixin","./_ComboBoxMenu","../_HasDropDown","dojo/text!./templates/DropDownBox.html"],function(_7f5,_7f6,_7f7,lang,_7f8,_7f9,_7fa,_7fb,_7fc){return _7f5("dijit.form.ComboBoxMixin",[_7fb,_7f9],{dropDownClass:_7fa,hasDownArrow:true,templateString:_7fc,baseClass:"dijitTextBox dijitComboBox",cssStateNodes:{"_buttonNode":"dijitDownArrowButton"},_setHasDownArrowAttr:function(val){this._set("hasDownArrow",val);this._buttonNode.style.display=val?"":"none";},_showResultList:function(){this.displayMessage("");this.inherited(arguments);},_setStoreAttr:function(_7fd){if(!_7fd.get){lang.mixin(_7fd,{_oldAPI:true,get:function(id){var _7fe=new _7f6();this.fetchItemByIdentity({identity:id,onItem:function(_7ff){_7fe.resolve(_7ff);},onError:function(_800){_7fe.reject(_800);}});return _7fe.promise;},query:function(_801,_802){var _803=new _7f6(function(){_804.abort&&_804.abort();});_803.total=new _7f6();var _804=this.fetch(lang.mixin({query:_801,onBegin:function(_805){_803.total.resolve(_805);},onComplete:function(_806){_803.resolve(_806);},onError:function(_807){_803.reject(_807);}},_802));return _7f8(_803);}});}this._set("store",_7fd);},postMixInProperties:function(){var _808=this.params.store||this.store;if(_808){this._setStoreAttr(_808);}this.inherited(arguments);if(!this.params.store&&this.store&&!this.store._oldAPI){var _809=this.declaredClass;lang.mixin(this.store,{getValue:function(item,attr){_7f7.deprecated(_809+".store.getValue(item, attr) is deprecated for builtin store.  Use item.attr directly","","2.0");return item[attr];},getLabel:function(item){_7f7.deprecated(_809+".store.getLabel(item) is deprecated for builtin store.  Use item.label directly","","2.0");return item.name;},fetch:function(args){_7f7.deprecated(_809+".store.fetch() is deprecated for builtin store.","Use store.query()","2.0");var shim=["dojo/data/ObjectStore"];require(shim,lang.hitch(this,function(_80a){new _80a({objectStore:this}).fetch(args);}));}});}},buildRendering:function(){this.inherited(arguments);this.focusNode.setAttribute("aria-autocomplete",this.autoComplete?"both":"list");}});});},"dojo/store/util/QueryResults":function(){define(["../../_base/array","../../_base/lang","../../when"],function(_80b,lang,when){var _80c=function(_80d){if(!_80d){return _80d;}var _80e=!!_80d.then;if(_80e){_80d=lang.delegate(_80d);}function _80f(_810){_80d[_810]=function(){var args=arguments;var _811=when(_80d,function(_812){Array.prototype.unshift.call(args,_812);return _80c(_80b[_810].apply(_80b,args));});if(_810!=="forEach"||_80e){return _811;}};};_80f("forEach");_80f("filter");_80f("map");if(_80d.total==null){_80d.total=when(_80d,function(_813){return _813.length;});}return _80d;};lang.setObject("dojo.store.util.QueryResults",_80c);return _80c;});},"dijit/form/_AutoCompleterMixin":function(){define(["dojo/aspect","dojo/_base/declare","dojo/dom-attr","dojo/keys","dojo/_base/lang","dojo/query","dojo/regexp","dojo/sniff","./DataList","./_TextBoxMixin","./_SearchMixin"],function(_814,_815,_816,keys,lang,_817,_818,has,_819,_81a,_81b){var _81c=_815("dijit.form._AutoCompleterMixin",_81b,{item:null,autoComplete:true,highlightMatch:"first",labelAttr:"",labelType:"text",maxHeight:-1,_stopClickEvents:false,_getCaretPos:function(_81d){var pos=0;if(typeof (_81d.selectionStart)=="number"){pos=_81d.selectionStart;}else{if(has("ie")){var tr=_81d.ownerDocument.selection.createRange().duplicate();var ntr=_81d.createTextRange();tr.move("character",0);ntr.move("character",0);try{ntr.setEndPoint("EndToEnd",tr);pos=String(ntr.text).replace(/\r/g,"").length;}catch(e){}}}return pos;},_setCaretPos:function(_81e,_81f){_81f=parseInt(_81f);_81a.selectInputText(_81e,_81f,_81f);},_setDisabledAttr:function(_820){this.inherited(arguments);this.domNode.setAttribute("aria-disabled",_820?"true":"false");},_onKey:function(evt){if(evt.charCode>=32){return;}var key=evt.charCode||evt.keyCode;if(key==keys.ALT||key==keys.CTRL||key==keys.META||key==keys.SHIFT){return;}var pw=this.dropDown;var _821=null;this._abortQuery();this.inherited(arguments);if(evt.altKey||evt.ctrlKey||evt.metaKey){return;}if(this._opened){_821=pw.getHighlightedOption();}switch(key){case keys.PAGE_DOWN:case keys.DOWN_ARROW:case keys.PAGE_UP:case keys.UP_ARROW:if(this._opened){this._announceOption(_821);}evt.stopPropagation();evt.preventDefault();break;case keys.ENTER:if(_821){if(_821==pw.nextButton){this._nextSearch(1);evt.stopPropagation();evt.preventDefault();break;}else{if(_821==pw.previousButton){this._nextSearch(-1);evt.stopPropagation();evt.preventDefault();break;}}evt.stopPropagation();evt.preventDefault();}else{this._setBlurValue();this._setCaretPos(this.focusNode,this.focusNode.value.length);}case keys.TAB:var _822=this.get("displayedValue");if(pw&&(_822==pw._messages["previousMessage"]||_822==pw._messages["nextMessage"])){break;}if(_821){this._selectOption(_821);}case keys.ESCAPE:if(this._opened){this._lastQuery=null;this.closeDropDown();}break;}},_autoCompleteText:function(text){var fn=this.focusNode;_81a.selectInputText(fn,fn.value.length);var _823=this.ignoreCase?"toLowerCase":"substr";if(text[_823](0).indexOf(this.focusNode.value[_823](0))==0){var cpos=this.autoComplete?this._getCaretPos(fn):fn.value.length;if((cpos+1)>fn.value.length){fn.value=text;_81a.selectInputText(fn,cpos);}}else{fn.value=text;_81a.selectInputText(fn);}},_openResultList:function(_824,_825,_826){var _827=this.dropDown.getHighlightedOption();this.dropDown.clearResultList();if(!_824.length&&_826.start==0){this.closeDropDown();return;}this._nextSearch=this.dropDown.onPage=lang.hitch(this,function(_828){_824.nextPage(_828!==-1);this.focus();});this.dropDown.createOptions(_824,_826,lang.hitch(this,"_getMenuLabelFromItem"));this._showResultList();if("direction" in _826){if(_826.direction){this.dropDown.highlightFirstOption();}else{if(!_826.direction){this.dropDown.highlightLastOption();}}if(_827){this._announceOption(this.dropDown.getHighlightedOption());}}else{if(this.autoComplete&&!this._prev_key_backspace&&!/^[*]+$/.test(_825[this.searchAttr].toString())){this._announceOption(this.dropDown.containerNode.firstChild.nextSibling);}}},_showResultList:function(){this.closeDropDown(true);this.openDropDown();this.domNode.setAttribute("aria-expanded","true");},loadDropDown:function(){this._startSearchAll();},isLoaded:function(){return false;},closeDropDown:function(){this._abortQuery();if(this._opened){this.inherited(arguments);this.domNode.setAttribute("aria-expanded","false");}},_setBlurValue:function(){var _829=this.get("displayedValue");var pw=this.dropDown;if(pw&&(_829==pw._messages["previousMessage"]||_829==pw._messages["nextMessage"])){this._setValueAttr(this._lastValueReported,true);}else{if(typeof this.item=="undefined"){this.item=null;this.set("displayedValue",_829);}else{if(this.value!=this._lastValueReported){this._handleOnChange(this.value,true);}this._refreshState();}}this.focusNode.removeAttribute("aria-activedescendant");},_setItemAttr:function(item,_82a,_82b){var _82c="";if(item){if(!_82b){_82b=this.store._oldAPI?this.store.getValue(item,this.searchAttr):item[this.searchAttr];}_82c=this._getValueField()!=this.searchAttr?this.store.getIdentity(item):_82b;}this.set("value",_82c,_82a,_82b,item);},_announceOption:function(node){if(!node){return;}var _82d;if(node==this.dropDown.nextButton||node==this.dropDown.previousButton){_82d=node.innerHTML;this.item=undefined;this.value="";}else{var item=this.dropDown.items[node.getAttribute("item")];_82d=(this.store._oldAPI?this.store.getValue(item,this.searchAttr):item[this.searchAttr]).toString();this.set("item",item,false,_82d);}this.focusNode.value=this.focusNode.value.substring(0,this._lastInput.length);this.focusNode.setAttribute("aria-activedescendant",_816.get(node,"id"));this._autoCompleteText(_82d);},_selectOption:function(_82e){this.closeDropDown();if(_82e){this._announceOption(_82e);}this._setCaretPos(this.focusNode,this.focusNode.value.length);this._handleOnChange(this.value,true);this.focusNode.removeAttribute("aria-activedescendant");},_startSearchAll:function(){this._startSearch("");},_startSearchFromInput:function(){this.item=undefined;this.inherited(arguments);},_startSearch:function(key){if(!this.dropDown){var _82f=this.id+"_popup",_830=lang.isString(this.dropDownClass)?lang.getObject(this.dropDownClass,false):this.dropDownClass;this.dropDown=new _830({onChange:lang.hitch(this,this._selectOption),id:_82f,dir:this.dir,textDir:this.textDir});}this._lastInput=key;this.inherited(arguments);},_getValueField:function(){return this.searchAttr;},postMixInProperties:function(){this.inherited(arguments);if(!this.store&&this.srcNodeRef){var _831=this.srcNodeRef;this.store=new _819({},_831);if(!("value" in this.params)){var item=(this.item=this.store.fetchSelectedItem());if(item){var _832=this._getValueField();this.value=this.store._oldAPI?this.store.getValue(item,_832):item[_832];}}}},postCreate:function(){var _833=_817("label[for=\""+this.id+"\"]");if(_833.length){if(!_833[0].id){_833[0].id=this.id+"_label";}this.domNode.setAttribute("aria-labelledby",_833[0].id);}this.inherited(arguments);_814.after(this,"onSearch",lang.hitch(this,"_openResultList"),true);},_getMenuLabelFromItem:function(item){var _834=this.labelFunc(item,this.store),_835=this.labelType;if(this.highlightMatch!="none"&&this.labelType=="text"&&this._lastInput){_834=this.doHighlight(_834,this._lastInput);_835="html";}return {html:_835=="html",label:_834};},doHighlight:function(_836,find){var _837=(this.ignoreCase?"i":"")+(this.highlightMatch=="all"?"g":""),i=this.queryExpr.indexOf("${0}");find=_818.escapeString(find);return this._escapeHtml(_836.replace(new RegExp((i==0?"^":"")+"("+find+")"+(i==(this.queryExpr.length-4)?"$":""),_837),"\uffff$1\uffff")).replace(/\uFFFF([^\uFFFF]+)\uFFFF/g,"<span class=\"dijitComboBoxHighlightMatch\">$1</span>");},_escapeHtml:function(str){str=String(str).replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;").replace(/"/gm,"&quot;");return str;},reset:function(){this.item=null;this.inherited(arguments);},labelFunc:function(item,_838){return (_838._oldAPI?_838.getValue(item,this.labelAttr||this.searchAttr):item[this.labelAttr||this.searchAttr]).toString();},_setValueAttr:function(_839,_83a,_83b,item){this._set("item",item||null);if(_839==null){_839="";}this.inherited(arguments);}});if(has("dojo-bidi")){_81c.extend({_setTextDirAttr:function(_83c){this.inherited(arguments);if(this.dropDown){this.dropDown._set("textDir",_83c);}}});}return _81c;});},"dojo/regexp":function(){define(["./_base/kernel","./_base/lang"],function(dojo,lang){var _83d={};lang.setObject("dojo.regexp",_83d);_83d.escapeString=function(str,_83e){return str.replace(/([\.$?*|{}\(\)\[\]\\\/\+\-^])/g,function(ch){if(_83e&&_83e.indexOf(ch)!=-1){return ch;}return "\\"+ch;});};_83d.buildGroupRE=function(arr,re,_83f){if(!(arr instanceof Array)){return re(arr);}var b=[];for(var i=0;i<arr.length;i++){b.push(re(arr[i]));}return _83d.group(b.join("|"),_83f);};_83d.group=function(_840,_841){return "("+(_841?"?:":"")+_840+")";};return _83d;});},"dijit/form/DataList":function(){define(["dojo/_base/declare","dojo/dom","dojo/_base/lang","dojo/query","dojo/store/Memory","../registry"],function(_842,dom,lang,_843,_844,_845){function _846(_847){return {id:_847.value,value:_847.value,name:lang.trim(_847.innerText||_847.textContent||"")};};return _842("dijit.form.DataList",_844,{constructor:function(_848,_849){this.domNode=dom.byId(_849);lang.mixin(this,_848);if(this.id){_845.add(this);}this.domNode.style.display="none";this.inherited(arguments,[{data:_843("option",this.domNode).map(_846)}]);},destroy:function(){_845.remove(this.id);},fetchSelectedItem:function(){var _84a=_843("> option[selected]",this.domNode)[0]||_843("> option",this.domNode)[0];return _84a&&_846(_84a);}});});},"dojo/store/Memory":function(){define(["../_base/declare","./util/QueryResults","./util/SimpleQueryEngine"],function(_84b,_84c,_84d){var base=null;return _84b("dojo.store.Memory",base,{constructor:function(_84e){for(var i in _84e){this[i]=_84e[i];}this.setData(this.data||[]);},data:null,idProperty:"id",index:null,queryEngine:_84d,get:function(id){return this.data[this.index[id]];},getIdentity:function(_84f){return _84f[this.idProperty];},put:function(_850,_851){var data=this.data,_852=this.index,_853=this.idProperty;var id=_850[_853]=(_851&&"id" in _851)?_851.id:_853 in _850?_850[_853]:Math.random();if(id in _852){if(_851&&_851.overwrite===false){throw new Error("Object already exists");}data[_852[id]]=_850;}else{_852[id]=data.push(_850)-1;}return id;},add:function(_854,_855){(_855=_855||{}).overwrite=false;return this.put(_854,_855);},remove:function(id){var _856=this.index;var data=this.data;if(id in _856){data.splice(_856[id],1);this.setData(data);return true;}},query:function(_857,_858){return _84c(this.queryEngine(_857,_858)(this.data));},setData:function(data){if(data.items){this.idProperty=data.identifier||this.idProperty;data=this.data=data.items;}else{this.data=data;}this.index={};for(var i=0,l=data.length;i<l;i++){this.index[data[i][this.idProperty]]=i;}}});});},"dojo/store/util/SimpleQueryEngine":function(){define(["../../_base/array"],function(_859){return function(_85a,_85b){switch(typeof _85a){default:throw new Error("Can not query with a "+typeof _85a);case "object":case "undefined":var _85c=_85a;_85a=function(_85d){for(var key in _85c){var _85e=_85c[key];if(_85e&&_85e.test){if(!_85e.test(_85d[key],_85d)){return false;}}else{if(_85e!=_85d[key]){return false;}}}return true;};break;case "string":if(!this[_85a]){throw new Error("No filter function "+_85a+" was found in store");}_85a=this[_85a];case "function":}function _85f(_860){var _861=_859.filter(_860,_85a);var _862=_85b&&_85b.sort;if(_862){_861.sort(typeof _862=="function"?_862:function(a,b){for(var sort,i=0;sort=_862[i];i++){var _863=a[sort.attribute];var _864=b[sort.attribute];_863=_863!=null?_863.valueOf():_863;_864=_864!=null?_864.valueOf():_864;if(_863!=_864){return !!sort.descending==(_863==null||_863>_864)?-1:1;}}return 0;});}if(_85b&&(_85b.start||_85b.count)){var _865=_861.length;_861=_861.slice(_85b.start||0,(_85b.start||0)+(_85b.count||Infinity));_861.total=_865;}return _861;};_85f.matches=_85a;return _85f;};});},"dijit/form/_SearchMixin":function(){define(["dojo/_base/declare","dojo/keys","dojo/_base/lang","dojo/query","dojo/string","dojo/when","../registry"],function(_866,keys,lang,_867,_868,when,_869){return _866("dijit.form._SearchMixin",null,{pageSize:Infinity,store:null,fetchProperties:{},query:{},list:"",_setListAttr:function(list){this._set("list",list);},searchDelay:200,searchAttr:"name",queryExpr:"${0}*",ignoreCase:true,_patternToRegExp:function(_86a){return new RegExp("^"+_86a.replace(/(\\.)|(\*)|(\?)|\W/g,function(str,_86b,star,_86c){return star?".*":_86c?".":_86b?_86b:"\\"+str;})+"$",this.ignoreCase?"mi":"m");},_abortQuery:function(){if(this.searchTimer){this.searchTimer=this.searchTimer.remove();}if(this._queryDeferHandle){this._queryDeferHandle=this._queryDeferHandle.remove();}if(this._fetchHandle){if(this._fetchHandle.abort){this._cancelingQuery=true;this._fetchHandle.abort();this._cancelingQuery=false;}if(this._fetchHandle.cancel){this._cancelingQuery=true;this._fetchHandle.cancel();this._cancelingQuery=false;}this._fetchHandle=null;}},_processInput:function(evt){if(this.disabled||this.readOnly){return;}var key=evt.charOrCode;this._prev_key_backspace=false;if(key===keys.DELETE||key===keys.BACKSPACE){this._prev_key_backspace=true;this._maskValidSubsetError=true;}if(!this.store){this.onSearch();}else{this.searchTimer=this.defer("_startSearchFromInput",1);}},onSearch:function(){},_startSearchFromInput:function(){this._startSearch(this.focusNode.value);},_startSearch:function(text){this._abortQuery();var _86d=this,_867=lang.clone(this.query),_86e={start:0,count:this.pageSize,queryOptions:{ignoreCase:this.ignoreCase,deep:true}},qs=_868.substitute(this.queryExpr,[text.replace(/([\\\*\?])/g,"\\$1")]),q,_86f=function(){var _870=_86d._fetchHandle=_86d.store.query(_867,_86e);if(_86d.disabled||_86d.readOnly||(q!==_86d._lastQuery)){return;}when(_870,function(res){_86d._fetchHandle=null;if(!_86d.disabled&&!_86d.readOnly&&(q===_86d._lastQuery)){when(_870.total,function(_871){res.total=_871;var _872=_86d.pageSize;if(isNaN(_872)||_872>res.total){_872=res.total;}res.nextPage=function(_873){_86e.direction=_873=_873!==false;_86e.count=_872;if(_873){_86e.start+=res.length;if(_86e.start>=res.total){_86e.count=0;}}else{_86e.start-=_872;if(_86e.start<0){_86e.count=Math.max(_872+_86e.start,0);_86e.start=0;}}if(_86e.count<=0){res.length=0;_86d.onSearch(res,_867,_86e);}else{_86f();}};_86d.onSearch(res,_867,_86e);});}},function(err){_86d._fetchHandle=null;if(!_86d._cancelingQuery){console.error(_86d.declaredClass+" "+err.toString());}});};lang.mixin(_86e,this.fetchProperties);if(this.store._oldAPI){q=qs;}else{q=this._patternToRegExp(qs);q.toString=function(){return qs;};}this._lastQuery=_867[this.searchAttr]=q;this._queryDeferHandle=this.defer(_86f,this.searchDelay);},constructor:function(){this.query={};this.fetchProperties={};},postMixInProperties:function(){if(!this.store){var list=this.list;if(list){this.store=_869.byId(list);}}this.inherited(arguments);}});});},"dijit/form/_ComboBoxMenu":function(){define(["dojo/_base/declare","dojo/dom-class","dojo/dom-style","dojo/keys","../_WidgetBase","../_TemplatedMixin","./_ComboBoxMenuMixin","./_ListMouseMixin"],function(_874,_875,_876,keys,_877,_878,_879,_87a){return _874("dijit.form._ComboBoxMenu",[_877,_878,_87a,_879],{templateString:"<div class='dijitReset dijitMenu' data-dojo-attach-point='containerNode' style='overflow: auto; overflow-x: hidden;' role='listbox'>"+"<div class='dijitMenuItem dijitMenuPreviousButton' data-dojo-attach-point='previousButton' role='option'></div>"+"<div class='dijitMenuItem dijitMenuNextButton' data-dojo-attach-point='nextButton' role='option'></div>"+"</div>",baseClass:"dijitComboBoxMenu",postCreate:function(){this.inherited(arguments);if(!this.isLeftToRight()){_875.add(this.previousButton,"dijitMenuItemRtl");_875.add(this.nextButton,"dijitMenuItemRtl");}this.containerNode.setAttribute("role","listbox");},_createMenuItem:function(){var item=this.ownerDocument.createElement("div");item.className="dijitReset dijitMenuItem"+(this.isLeftToRight()?"":" dijitMenuItemRtl");item.setAttribute("role","option");return item;},onHover:function(node){_875.add(node,"dijitMenuItemHover");},onUnhover:function(node){_875.remove(node,"dijitMenuItemHover");},onSelect:function(node){_875.add(node,"dijitMenuItemSelected");},onDeselect:function(node){_875.remove(node,"dijitMenuItemSelected");},_page:function(up){var _87b=0;var _87c=this.domNode.scrollTop;var _87d=_876.get(this.domNode,"height");if(!this.getHighlightedOption()){this.selectNextNode();}while(_87b<_87d){var _87e=this.getHighlightedOption();if(up){if(!_87e.previousSibling||_87e.previousSibling.style.display=="none"){break;}this.selectPreviousNode();}else{if(!_87e.nextSibling||_87e.nextSibling.style.display=="none"){break;}this.selectNextNode();}var _87f=this.domNode.scrollTop;_87b+=(_87f-_87c)*(up?-1:1);_87c=_87f;}},handleKey:function(evt){switch(evt.keyCode){case keys.DOWN_ARROW:this.selectNextNode();return false;case keys.PAGE_DOWN:this._page(false);return false;case keys.UP_ARROW:this.selectPreviousNode();return false;case keys.PAGE_UP:this._page(true);return false;default:return true;}}});});},"dijit/form/_ComboBoxMenuMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-attr","dojo/has","dojo/i18n","dojo/i18n!./nls/ComboBox"],function(_880,_881,_882,has,i18n){var _883=_881("dijit.form._ComboBoxMenuMixin"+(has("dojo-bidi")?"_NoBidi":""),null,{_messages:null,postMixInProperties:function(){this.inherited(arguments);this._messages=i18n.getLocalization("dijit.form","ComboBox",this.lang);},buildRendering:function(){this.inherited(arguments);this.previousButton.innerHTML=this._messages["previousMessage"];this.nextButton.innerHTML=this._messages["nextMessage"];},_setValueAttr:function(_884){this._set("value",_884);this.onChange(_884);},onClick:function(node){if(node==this.previousButton){this._setSelectedAttr(null);this.onPage(-1);}else{if(node==this.nextButton){this._setSelectedAttr(null);this.onPage(1);}else{this.onChange(node);}}},onChange:function(){},onPage:function(){},onClose:function(){this._setSelectedAttr(null);},_createOption:function(item,_885){var _886=this._createMenuItem();var _887=_885(item);if(_887.html){_886.innerHTML=_887.label;}else{_886.appendChild(_886.ownerDocument.createTextNode(_887.label));}if(_886.innerHTML==""){_886.innerHTML="&#160;";}return _886;},createOptions:function(_888,_889,_88a){this.items=_888;this.previousButton.style.display=(_889.start==0)?"none":"";_882.set(this.previousButton,"id",this.id+"_prev");_880.forEach(_888,function(item,i){var _88b=this._createOption(item,_88a);_88b.setAttribute("item",i);_882.set(_88b,"id",this.id+i);this.nextButton.parentNode.insertBefore(_88b,this.nextButton);},this);var _88c=false;if(_888.total&&!_888.total.then&&_888.total!=-1){if((_889.start+_889.count)<_888.total){_88c=true;}else{if((_889.start+_889.count)>_888.total&&_889.count==_888.length){_88c=true;}}}else{if(_889.count==_888.length){_88c=true;}}this.nextButton.style.display=_88c?"":"none";_882.set(this.nextButton,"id",this.id+"_next");},clearResultList:function(){var _88d=this.containerNode;while(_88d.childNodes.length>2){_88d.removeChild(_88d.childNodes[_88d.childNodes.length-2]);}this._setSelectedAttr(null);},highlightFirstOption:function(){this.selectFirstNode();},highlightLastOption:function(){this.selectLastNode();},selectFirstNode:function(){this.inherited(arguments);if(this.getHighlightedOption()==this.previousButton){this.selectNextNode();}},selectLastNode:function(){this.inherited(arguments);if(this.getHighlightedOption()==this.nextButton){this.selectPreviousNode();}},getHighlightedOption:function(){return this.selected;}});if(has("dojo-bidi")){_883=_881("dijit.form._ComboBoxMenuMixin",_883,{_createOption:function(){var _88e=this.inherited(arguments);this.applyTextDir(_88e);return _88e;}});}return _883;});},"dijit/form/_ListMouseMixin":function(){define(["dojo/_base/declare","dojo/on","dojo/touch","./_ListBase"],function(_88f,on,_890,_891){return _88f("dijit.form._ListMouseMixin",_891,{postCreate:function(){this.inherited(arguments);this.domNode.dojoClick=true;this._listConnect("click","_onClick");this._listConnect("mousedown","_onMouseDown");this._listConnect("mouseup","_onMouseUp");this._listConnect("mouseover","_onMouseOver");this._listConnect("mouseout","_onMouseOut");},_onClick:function(evt,_892){this._setSelectedAttr(_892,false);if(this._deferredClick){this._deferredClick.remove();}this._deferredClick=this.defer(function(){this._deferredClick=null;this.onClick(_892);});},_onMouseDown:function(evt,_893){if(this._hoveredNode){this.onUnhover(this._hoveredNode);this._hoveredNode=null;}this._isDragging=true;this._setSelectedAttr(_893,false);},_onMouseUp:function(evt,_894){this._isDragging=false;var _895=this.selected;var _896=this._hoveredNode;if(_895&&_894==_895){this.defer(function(){this._onClick(evt,_895);});}else{if(_896){this.defer(function(){this._onClick(evt,_896);});}}},_onMouseOut:function(evt,_897){if(this._hoveredNode){this.onUnhover(this._hoveredNode);this._hoveredNode=null;}if(this._isDragging){this._cancelDrag=(new Date()).getTime()+1000;}},_onMouseOver:function(evt,_898){if(this._cancelDrag){var time=(new Date()).getTime();if(time>this._cancelDrag){this._isDragging=false;}this._cancelDrag=null;}this._hoveredNode=_898;this.onHover(_898);if(this._isDragging){this._setSelectedAttr(_898,false);}}});});},"dijit/form/_ListBase":function(){define(["dojo/_base/declare","dojo/on","dojo/window"],function(_899,on,_89a){return _899("dijit.form._ListBase",null,{selected:null,_listConnect:function(_89b,_89c){var self=this;return self.own(on(self.containerNode,on.selector(function(_89d,_89e,_89f){return _89d.parentNode==_89f;},_89b),function(evt){self[_89c](evt,this);}));},selectFirstNode:function(){var _8a0=this.containerNode.firstChild;while(_8a0&&_8a0.style.display=="none"){_8a0=_8a0.nextSibling;}this._setSelectedAttr(_8a0,true);},selectLastNode:function(){var last=this.containerNode.lastChild;while(last&&last.style.display=="none"){last=last.previousSibling;}this._setSelectedAttr(last,true);},selectNextNode:function(){var _8a1=this.selected;if(!_8a1){this.selectFirstNode();}else{var next=_8a1.nextSibling;while(next&&next.style.display=="none"){next=next.nextSibling;}if(!next){this.selectFirstNode();}else{this._setSelectedAttr(next,true);}}},selectPreviousNode:function(){var _8a2=this.selected;if(!_8a2){this.selectLastNode();}else{var prev=_8a2.previousSibling;while(prev&&prev.style.display=="none"){prev=prev.previousSibling;}if(!prev){this.selectLastNode();}else{this._setSelectedAttr(prev,true);}}},_setSelectedAttr:function(node,_8a3){if(this.selected!=node){var _8a4=this.selected;if(_8a4){this.onDeselect(_8a4);}if(node){if(_8a3){_89a.scrollIntoView(node);}this.onSelect(node);}this._set("selected",node);}else{if(node){this.onSelect(node);}}}});});},"dijit/form/Form":function(){define(["dojo/_base/declare","dojo/dom-attr","dojo/_base/kernel","dojo/sniff","../_Widget","../_TemplatedMixin","./_FormMixin","../layout/_ContentPaneResizeMixin"],function(_8a5,_8a6,_8a7,has,_8a8,_8a9,_8aa,_8ab){return _8a5("dijit.form.Form",[_8a8,_8a9,_8aa,_8ab],{name:"",action:"",method:"",encType:"","accept-charset":"",accept:"",target:"",templateString:"<form data-dojo-attach-point='containerNode' data-dojo-attach-event='onreset:_onReset,onsubmit:_onSubmit' ${!nameAttrSetting}></form>",postMixInProperties:function(){this.nameAttrSetting=this.name?("name='"+this.name+"'"):"";this.inherited(arguments);},execute:function(){},onExecute:function(){},_setEncTypeAttr:function(_8ac){_8a6.set(this.domNode,"encType",_8ac);if(has("ie")){this.domNode.encoding=_8ac;}this._set("encType",_8ac);},reset:function(e){var faux={returnValue:true,preventDefault:function(){this.returnValue=false;},stopPropagation:function(){},currentTarget:e?e.target:this.domNode,target:e?e.target:this.domNode};if(!(this.onReset(faux)===false)&&faux.returnValue){this.inherited(arguments,[]);}},onReset:function(){return true;},_onReset:function(e){this.reset(e);e.stopPropagation();e.preventDefault();return false;},_onSubmit:function(e){var fp=this.constructor.prototype;if(this.execute!=fp.execute||this.onExecute!=fp.onExecute){_8a7.deprecated("dijit.form.Form:execute()/onExecute() are deprecated. Use onSubmit() instead.","","2.0");this.onExecute();this.execute(this.getValues());}if(this.onSubmit(e)===false){e.stopPropagation();e.preventDefault();}},onSubmit:function(){return this.isValid();},submit:function(){if(!(this.onSubmit()===false)){this.containerNode.submit();}}});});},"dijit/form/RadioButton":function(){define(["dojo/_base/declare","./CheckBox","./_RadioButtonMixin"],function(_8ad,_8ae,_8af){return _8ad("dijit.form.RadioButton",[_8ae,_8af],{baseClass:"dijitRadio"});});},"dijit/form/_RadioButtonMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-attr","dojo/_base/lang","dojo/query!css2","../registry"],function(_8b0,_8b1,_8b2,lang,_8b3,_8b4){return _8b1("dijit.form._RadioButtonMixin",null,{type:"radio",_getRelatedWidgets:function(){var ary=[];_8b3("input[type=radio]",this.focusNode.form||this.ownerDocument).forEach(lang.hitch(this,function(_8b5){if(_8b5.name==this.name&&_8b5.form==this.focusNode.form){var _8b6=_8b4.getEnclosingWidget(_8b5);if(_8b6){ary.push(_8b6);}}}));return ary;},_setCheckedAttr:function(_8b7){this.inherited(arguments);if(!this._created){return;}if(_8b7){_8b0.forEach(this._getRelatedWidgets(),lang.hitch(this,function(_8b8){if(_8b8!=this&&_8b8.checked){_8b8.set("checked",false);}}));}},_getSubmitValue:function(_8b9){return _8b9==null?"on":_8b9;},_onClick:function(e){if(this.checked||this.disabled){e.stopPropagation();e.preventDefault();return false;}if(this.readOnly){e.stopPropagation();e.preventDefault();_8b0.forEach(this._getRelatedWidgets(),lang.hitch(this,function(_8ba){_8b2.set(this.focusNode||this.domNode,"checked",_8ba.checked);}));return false;}var _8bb=false;var _8bc;_8b0.some(this._getRelatedWidgets(),function(_8bd){if(_8bd.checked){_8bc=_8bd;return true;}return false;});this.checked=true;_8bc&&(_8bc.checked=false);if(this.onClick(e)===false||e.defaultPrevented){_8bb=true;}this.checked=false;_8bc&&(_8bc.checked=true);if(_8bb){e.preventDefault();}else{this.set("checked",true);}return !_8bb;}});});},"dijit/form/Select":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-attr","dojo/dom-class","dojo/dom-geometry","dojo/i18n","dojo/keys","dojo/_base/lang","dojo/on","dojo/sniff","./_FormSelectWidget","../_HasDropDown","../DropDownMenu","../MenuItem","../MenuSeparator","../Tooltip","../_KeyNavMixin","../registry","dojo/text!./templates/Select.html","dojo/i18n!./nls/validate"],function(_8be,_8bf,_8c0,_8c1,_8c2,i18n,keys,lang,on,has,_8c3,_8c4,_8c5,_8c6,_8c7,_8c8,_8c9,_8ca,_8cb){var _8cc=_8bf("dijit.form._SelectMenu",_8c5,{autoFocus:true,buildRendering:function(){this.inherited(arguments);this.domNode.setAttribute("role","listbox");},postCreate:function(){this.inherited(arguments);this.own(on(this.domNode,"selectstart",function(evt){evt.preventDefault();evt.stopPropagation();}));},focus:function(){var _8cd=false,val=this.parentWidget.value;if(lang.isArray(val)){val=val[val.length-1];}if(val){_8be.forEach(this.parentWidget._getChildren(),function(_8ce){if(_8ce.option&&(val===_8ce.option.value)){_8cd=true;this.focusChild(_8ce,false);}},this);}if(!_8cd){this.inherited(arguments);}}});var _8cf=_8bf("dijit.form.Select"+(has("dojo-bidi")?"_NoBidi":""),[_8c3,_8c4,_8c9],{baseClass:"dijitSelect dijitValidationTextBox",templateString:_8cb,_buttonInputDisabled:has("ie")?"disabled":"",required:false,state:"",message:"",tooltipPosition:[],emptyLabel:"&#160;",_isLoaded:false,_childrenLoaded:false,labelType:"html",_fillContent:function(){this.inherited(arguments);if(this.options.length&&!this.value&&this.srcNodeRef){var si=this.srcNodeRef.selectedIndex||0;this._set("value",this.options[si>=0?si:0].value);}this.dropDown=new _8cc({id:this.id+"_menu",parentWidget:this});_8c1.add(this.dropDown.domNode,this.baseClass.replace(/\s+|$/g,"Menu "));},_getMenuItemForOption:function(_8d0){if(!_8d0.value&&!_8d0.label){return new _8c7({ownerDocument:this.ownerDocument});}else{var _8d1=lang.hitch(this,"_setValueAttr",_8d0);var item=new _8c6({option:_8d0,label:(this.labelType==="text"?(_8d0.label||"").toString().replace(/&/g,"&amp;").replace(/</g,"&lt;"):_8d0.label)||this.emptyLabel,onClick:_8d1,ownerDocument:this.ownerDocument,dir:this.dir,textDir:this.textDir,disabled:_8d0.disabled||false});item.focusNode.setAttribute("role","option");return item;}},_addOptionItem:function(_8d2){if(this.dropDown){this.dropDown.addChild(this._getMenuItemForOption(_8d2));}},_getChildren:function(){if(!this.dropDown){return [];}return this.dropDown.getChildren();},focus:function(){if(!this.disabled&&this.focusNode.focus){try{this.focusNode.focus();}catch(e){}}},focusChild:function(_8d3){if(_8d3){this.set("value",_8d3.option);}},_getFirst:function(){var _8d4=this._getChildren();return _8d4.length?_8d4[0]:null;},_getLast:function(){var _8d5=this._getChildren();return _8d5.length?_8d5[_8d5.length-1]:null;},childSelector:function(node){var node=_8ca.byNode(node);return node&&node.getParent()==this.dropDown;},onKeyboardSearch:function(item,evt,_8d6,_8d7){if(item){this.focusChild(item);}},_loadChildren:function(_8d8){if(_8d8===true){if(this.dropDown){delete this.dropDown.focusedChild;this.focusedChild=null;}if(this.options.length){this.inherited(arguments);}else{_8be.forEach(this._getChildren(),function(_8d9){_8d9.destroyRecursive();});var item=new _8c6({ownerDocument:this.ownerDocument,label:this.emptyLabel});this.dropDown.addChild(item);}}else{this._updateSelection();}this._isLoaded=false;this._childrenLoaded=true;if(!this._loadingStore){this._setValueAttr(this.value,false);}},_refreshState:function(){if(this._started){this.validate(this.focused);}},startup:function(){this.inherited(arguments);this._refreshState();},_setValueAttr:function(_8da){this.inherited(arguments);_8c0.set(this.valueNode,"value",this.get("value"));this._refreshState();},_setNameAttr:"valueNode",_setDisabledAttr:function(_8db){this.inherited(arguments);this._refreshState();},_setRequiredAttr:function(_8dc){this._set("required",_8dc);this.focusNode.setAttribute("aria-required",_8dc);this._refreshState();},_setOptionsAttr:function(_8dd){this._isLoaded=false;this._set("options",_8dd);},_setDisplay:function(_8de){var lbl=(this.labelType==="text"?(_8de||"").replace(/&/g,"&amp;").replace(/</g,"&lt;"):_8de)||this.emptyLabel;this.containerNode.innerHTML="<span role=\"option\" aria-selected=\"true\" class=\"dijitReset dijitInline "+this.baseClass.replace(/\s+|$/g,"Label ")+"\">"+lbl+"</span>";},validate:function(_8df){var _8e0=this.disabled||this.isValid(_8df);this._set("state",_8e0?"":(this._hasBeenBlurred?"Error":"Incomplete"));this.focusNode.setAttribute("aria-invalid",_8e0?"false":"true");var _8e1=_8e0?"":this._missingMsg;if(_8e1&&this.focused&&this._hasBeenBlurred){_8c8.show(_8e1,this.domNode,this.tooltipPosition,!this.isLeftToRight());}else{_8c8.hide(this.domNode);}this._set("message",_8e1);return _8e0;},isValid:function(){return (!this.required||this.value===0||!(/^\s*$/.test(this.value||"")));},reset:function(){this.inherited(arguments);_8c8.hide(this.domNode);this._refreshState();},postMixInProperties:function(){this.inherited(arguments);this._missingMsg=i18n.getLocalization("dijit.form","validate",this.lang).missingMessage;},postCreate:function(){this.inherited(arguments);this.own(on(this.domNode,"selectstart",function(evt){evt.preventDefault();evt.stopPropagation();}));this.domNode.setAttribute("aria-expanded","false");var _8e2=this._keyNavCodes;delete _8e2[keys.LEFT_ARROW];delete _8e2[keys.RIGHT_ARROW];},_setStyleAttr:function(_8e3){this.inherited(arguments);_8c1.toggle(this.domNode,this.baseClass.replace(/\s+|$/g,"FixedWidth "),!!this.domNode.style.width);},isLoaded:function(){return this._isLoaded;},loadDropDown:function(_8e4){this._loadChildren(true);this._isLoaded=true;_8e4();},destroy:function(_8e5){if(this.dropDown&&!this.dropDown._destroyed){this.dropDown.destroyRecursive(_8e5);delete this.dropDown;}_8c8.hide(this.domNode);this.inherited(arguments);},_onFocus:function(){this.validate(true);},_onBlur:function(){_8c8.hide(this.domNode);this.inherited(arguments);this.validate(false);}});if(has("dojo-bidi")){_8cf=_8bf("dijit.form.Select",_8cf,{_setDisplay:function(_8e6){this.inherited(arguments);this.applyTextDir(this.containerNode);}});}_8cf._Menu=_8cc;function _8e7(_8e8){return function(evt){if(!this._isLoaded){this.loadDropDown(lang.hitch(this,_8e8,evt));}else{this.inherited(_8e8,arguments);}};};_8cf.prototype._onContainerKeydown=_8e7("_onContainerKeydown");_8cf.prototype._onContainerKeypress=_8e7("_onContainerKeypress");return _8cf;});},"dijit/form/_FormSelectWidget":function(){define(["dojo/_base/array","dojo/_base/Deferred","dojo/aspect","dojo/data/util/sorter","dojo/_base/declare","dojo/dom","dojo/dom-class","dojo/_base/kernel","dojo/_base/lang","dojo/query","dojo/when","dojo/store/util/QueryResults","./_FormValueWidget"],function(_8e9,_8ea,_8eb,_8ec,_8ed,dom,_8ee,_8ef,lang,_8f0,when,_8f1,_8f2){var _8f3=_8ed("dijit.form._FormSelectWidget",_8f2,{multiple:false,options:null,store:null,_setStoreAttr:function(val){if(this._created){this._deprecatedSetStore(val);}},query:null,_setQueryAttr:function(_8f4){if(this._created){this._deprecatedSetStore(this.store,this.selectedValue,{query:_8f4});}},queryOptions:null,_setQueryOptionsAttr:function(_8f5){if(this._created){this._deprecatedSetStore(this.store,this.selectedValue,{queryOptions:_8f5});}},labelAttr:"",onFetch:null,sortByLabel:true,loadChildrenOnOpen:false,onLoadDeferred:null,getOptions:function(_8f6){var opts=this.options||[];if(_8f6==null){return opts;}if(lang.isArrayLike(_8f6)){return _8e9.map(_8f6,function(item){return this.getOptions(item);},this);}if(lang.isString(_8f6)){_8f6={value:_8f6};}if(lang.isObject(_8f6)){if(!_8e9.some(opts,function(_8f7,idx){for(var a in _8f6){if(!(a in _8f7)||_8f7[a]!=_8f6[a]){return false;}}_8f6=idx;return true;})){_8f6=-1;}}if(_8f6>=0&&_8f6<opts.length){return opts[_8f6];}return null;},addOption:function(_8f8){_8e9.forEach(lang.isArrayLike(_8f8)?_8f8:[_8f8],function(i){if(i&&lang.isObject(i)){this.options.push(i);}},this);this._loadChildren();},removeOption:function(_8f9){var _8fa=this.getOptions(lang.isArrayLike(_8f9)?_8f9:[_8f9]);_8e9.forEach(_8fa,function(_8fb){if(_8fb){this.options=_8e9.filter(this.options,function(node){return (node.value!==_8fb.value||node.label!==_8fb.label);});this._removeOptionItem(_8fb);}},this);this._loadChildren();},updateOption:function(_8fc){_8e9.forEach(lang.isArrayLike(_8fc)?_8fc:[_8fc],function(i){var _8fd=this.getOptions({value:i.value}),k;if(_8fd){for(k in i){_8fd[k]=i[k];}}},this);this._loadChildren();},setStore:function(_8fe,_8ff,_900){_8ef.deprecated(this.declaredClass+"::setStore(store, selectedValue, fetchArgs) is deprecated. Use set('query', fetchArgs.query), set('queryOptions', fetchArgs.queryOptions), set('store', store), or set('value', selectedValue) instead.","","2.0");this._deprecatedSetStore(_8fe,_8ff,_900);},_deprecatedSetStore:function(_901,_902,_903){var _904=this.store;_903=_903||{};if(_904!==_901){var h;while((h=this._notifyConnections.pop())){h.remove();}if(!_901.get){lang.mixin(_901,{_oldAPI:true,get:function(id){var _905=new _8ea();this.fetchItemByIdentity({identity:id,onItem:function(_906){_905.resolve(_906);},onError:function(_907){_905.reject(_907);}});return _905.promise;},query:function(_908,_909){var _90a=new _8ea(function(){if(_90b.abort){_90b.abort();}});_90a.total=new _8ea();var _90b=this.fetch(lang.mixin({query:_908,onBegin:function(_90c){_90a.total.resolve(_90c);},onComplete:function(_90d){_90a.resolve(_90d);},onError:function(_90e){_90a.reject(_90e);}},_909));return new _8f1(_90a);}});if(_901.getFeatures()["dojo.data.api.Notification"]){this._notifyConnections=[_8eb.after(_901,"onNew",lang.hitch(this,"_onNewItem"),true),_8eb.after(_901,"onDelete",lang.hitch(this,"_onDeleteItem"),true),_8eb.after(_901,"onSet",lang.hitch(this,"_onSetItem"),true)];}}this._set("store",_901);}if(this.options&&this.options.length){this.removeOption(this.options);}if(this._queryRes&&this._queryRes.close){this._queryRes.close();}if(this._observeHandle&&this._observeHandle.remove){this._observeHandle.remove();this._observeHandle=null;}if(_903.query){this._set("query",_903.query);}if(_903.queryOptions){this._set("queryOptions",_903.queryOptions);}if(_901&&_901.query){this._loadingStore=true;this.onLoadDeferred=new _8ea();this._queryRes=_901.query(this.query,this.queryOptions);when(this._queryRes,lang.hitch(this,function(_90f){if(this.sortByLabel&&!_903.sort&&_90f.length){if(_901.getValue){_90f.sort(_8ec.createSortFunction([{attribute:_901.getLabelAttributes(_90f[0])[0]}],_901));}else{var _910=this.labelAttr;_90f.sort(function(a,b){return a[_910]>b[_910]?1:b[_910]>a[_910]?-1:0;});}}if(_903.onFetch){_90f=_903.onFetch.call(this,_90f,_903);}_8e9.forEach(_90f,function(i){this._addOptionForItem(i);},this);if(this._queryRes.observe){this._observeHandle=this._queryRes.observe(lang.hitch(this,function(_911,_912,_913){if(_912==_913){this._onSetItem(_911);}else{if(_912!=-1){this._onDeleteItem(_911);}if(_913!=-1){this._onNewItem(_911);}}}),true);}this._loadingStore=false;this.set("value","_pendingValue" in this?this._pendingValue:_902);delete this._pendingValue;if(!this.loadChildrenOnOpen){this._loadChildren();}else{this._pseudoLoadChildren(_90f);}this.onLoadDeferred.resolve(true);this.onSetStore();}),lang.hitch(this,function(err){console.error("dijit.form.Select: "+err.toString());this.onLoadDeferred.reject(err);}));}return _904;},_setValueAttr:function(_914,_915){if(!this._onChangeActive){_915=null;}if(this._loadingStore){this._pendingValue=_914;return;}if(_914==null){return;}if(lang.isArrayLike(_914)){_914=_8e9.map(_914,function(_916){return lang.isObject(_916)?_916:{value:_916};});}else{if(lang.isObject(_914)){_914=[_914];}else{_914=[{value:_914}];}}_914=_8e9.filter(this.getOptions(_914),function(i){return i&&i.value;});var opts=this.getOptions()||[];if(!this.multiple&&(!_914[0]||!_914[0].value)&&!!opts.length){_914[0]=opts[0];}_8e9.forEach(opts,function(opt){opt.selected=_8e9.some(_914,function(v){return v.value===opt.value;});});var val=_8e9.map(_914,function(opt){return opt.value;});if(typeof val=="undefined"||typeof val[0]=="undefined"){return;}var disp=_8e9.map(_914,function(opt){return opt.label;});this._setDisplay(this.multiple?disp:disp[0]);this.inherited(arguments,[this.multiple?val:val[0],_915]);this._updateSelection();},_getDisplayedValueAttr:function(){var ret=_8e9.map([].concat(this.get("selectedOptions")),function(v){if(v&&"label" in v){return v.label;}else{if(v){return v.value;}}return null;},this);return this.multiple?ret:ret[0];},_setDisplayedValueAttr:function(_917){this.set("value",this.getOptions(typeof _917=="string"?{label:_917}:_917));},_loadChildren:function(){if(this._loadingStore){return;}_8e9.forEach(this._getChildren(),function(_918){_918.destroyRecursive();});_8e9.forEach(this.options,this._addOptionItem,this);this._updateSelection();},_updateSelection:function(){this.focusedChild=null;this._set("value",this._getValueFromOpts());var val=[].concat(this.value);if(val&&val[0]){var self=this;_8e9.forEach(this._getChildren(),function(_919){var _91a=_8e9.some(val,function(v){return _919.option&&(v===_919.option.value);});if(_91a&&!self.multiple){self.focusedChild=_919;}_8ee.toggle(_919.domNode,this.baseClass.replace(/\s+|$/g,"SelectedOption "),_91a);_919.domNode.setAttribute("aria-selected",_91a?"true":"false");},this);}},_getValueFromOpts:function(){var opts=this.getOptions()||[];if(!this.multiple&&opts.length){var opt=_8e9.filter(opts,function(i){return i.selected;})[0];if(opt&&opt.value){return opt.value;}else{opts[0].selected=true;return opts[0].value;}}else{if(this.multiple){return _8e9.map(_8e9.filter(opts,function(i){return i.selected;}),function(i){return i.value;})||[];}}return "";},_onNewItem:function(item,_91b){if(!_91b||!_91b.parent){this._addOptionForItem(item);}},_onDeleteItem:function(item){var _91c=this.store;this.removeOption({value:_91c.getIdentity(item)});},_onSetItem:function(item){this.updateOption(this._getOptionObjForItem(item));},_getOptionObjForItem:function(item){var _91d=this.store,_91e=(this.labelAttr&&this.labelAttr in item)?item[this.labelAttr]:_91d.getLabel(item),_91f=(_91e?_91d.getIdentity(item):null);return {value:_91f,label:_91e,item:item};},_addOptionForItem:function(item){var _920=this.store;if(_920.isItemLoaded&&!_920.isItemLoaded(item)){_920.loadItem({item:item,onItem:function(i){this._addOptionForItem(i);},scope:this});return;}var _921=this._getOptionObjForItem(item);this.addOption(_921);},constructor:function(_922){this._oValue=(_922||{}).value||null;this._notifyConnections=[];},buildRendering:function(){this.inherited(arguments);dom.setSelectable(this.focusNode,false);},_fillContent:function(){if(!this.options){this.options=this.srcNodeRef?_8f0("> *",this.srcNodeRef).map(function(node){if(node.getAttribute("type")==="separator"){return {value:"",label:"",selected:false,disabled:false};}return {value:(node.getAttribute("data-"+_8ef._scopeName+"-value")||node.getAttribute("value")),label:String(node.innerHTML),selected:node.getAttribute("selected")||false,disabled:node.getAttribute("disabled")||false};},this):[];}if(!this.value){this._set("value",this._getValueFromOpts());}else{if(this.multiple&&typeof this.value=="string"){this._set("value",this.value.split(","));}}},postCreate:function(){this.inherited(arguments);_8eb.after(this,"onChange",lang.hitch(this,"_updateSelection"));var _923=this.store;if(_923&&(_923.getIdentity||_923.getFeatures()["dojo.data.api.Identity"])){this.store=null;this._deprecatedSetStore(_923,this._oValue,{query:this.query,queryOptions:this.queryOptions});}this._storeInitialized=true;},startup:function(){this._loadChildren();this.inherited(arguments);},destroy:function(){var h;while((h=this._notifyConnections.pop())){h.remove();}if(this._queryRes&&this._queryRes.close){this._queryRes.close();}if(this._observeHandle&&this._observeHandle.remove){this._observeHandle.remove();this._observeHandle=null;}this.inherited(arguments);},_addOptionItem:function(){},_removeOptionItem:function(){},_setDisplay:function(){},_getChildren:function(){return [];},_getSelectedOptionsAttr:function(){return this.getOptions({selected:true});},_pseudoLoadChildren:function(){},onSetStore:function(){}});return _8f3;});},"dijit/DropDownMenu":function(){define(["dojo/_base/declare","dojo/keys","dojo/text!./templates/Menu.html","./_MenuBase"],function(_924,keys,_925,_926){return _924("dijit.DropDownMenu",_926,{templateString:_925,baseClass:"dijitMenu",_onUpArrow:function(){this.focusPrev();},_onDownArrow:function(){this.focusNext();},_onRightArrow:function(evt){this._moveToPopup(evt);evt.stopPropagation();evt.preventDefault();},_onLeftArrow:function(evt){if(this.parentMenu){if(this.parentMenu._isMenuBar){this.parentMenu.focusPrev();}else{this.onCancel(false);}}else{evt.stopPropagation();evt.preventDefault();}}});});},"dijit/_MenuBase":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/_base/lang","dojo/mouse","dojo/on","dojo/window","./a11yclick","./registry","./_Widget","./_CssStateMixin","./_KeyNavContainer","./_TemplatedMixin"],function(_927,_928,dom,_929,_92a,lang,_92b,on,_92c,_92d,_92e,_92f,_930,_931,_932){return _928("dijit._MenuBase",[_92f,_932,_931,_930],{selected:null,_setSelectedAttr:function(item){if(this.selected!=item){if(this.selected){this.selected._setSelected(false);this._onChildDeselect(this.selected);}if(item){item._setSelected(true);}this._set("selected",item);}},activated:false,_setActivatedAttr:function(val){_92a.toggle(this.domNode,"dijitMenuActive",val);_92a.toggle(this.domNode,"dijitMenuPassive",!val);this._set("activated",val);},parentMenu:null,popupDelay:500,passivePopupDelay:Infinity,autoFocus:false,childSelector:function(node){var _933=_92e.byNode(node);return node.parentNode==this.containerNode&&_933&&_933.focus;},postCreate:function(){var self=this,_934=typeof this.childSelector=="string"?this.childSelector:lang.hitch(this,"childSelector");this.own(on(this.containerNode,on.selector(_934,_92b.enter),function(){self.onItemHover(_92e.byNode(this));}),on(this.containerNode,on.selector(_934,_92b.leave),function(){self.onItemUnhover(_92e.byNode(this));}),on(this.containerNode,on.selector(_934,_92d),function(evt){self.onItemClick(_92e.byNode(this),evt);evt.stopPropagation();}),on(this.containerNode,on.selector(_934,"focusin"),function(){self._onItemFocus(_92e.byNode(this));}));this.inherited(arguments);},onKeyboardSearch:function(item,evt,_935,_936){this.inherited(arguments);if(!!item&&(_936==-1||(!!item.popup&&_936==1))){this.onItemClick(item,evt);}},_keyboardSearchCompare:function(item,_937){if(!!item.shortcutKey){return _937==item.shortcutKey.toLowerCase()?-1:0;}return this.inherited(arguments)?1:0;},onExecute:function(){},onCancel:function(){},_moveToPopup:function(evt){if(this.focusedChild&&this.focusedChild.popup&&!this.focusedChild.disabled){this.onItemClick(this.focusedChild,evt);}else{var _938=this._getTopMenu();if(_938&&_938._isMenuBar){_938.focusNext();}}},_onPopupHover:function(){this.set("selected",this.currentPopupItem);this._stopPendingCloseTimer();},onItemHover:function(item){if(this.activated){this.set("selected",item);if(item.popup&&!item.disabled&&!this.hover_timer){this.hover_timer=this.defer(function(){this._openItemPopup(item);},this.popupDelay);}}else{if(this.passivePopupDelay<Infinity){if(this.passive_hover_timer){this.passive_hover_timer.remove();}this.passive_hover_timer=this.defer(function(){this.onItemClick(item,{type:"click"});},this.passivePopupDelay);}}this._hoveredChild=item;item._set("hovering",true);},_onChildDeselect:function(item){this._stopPopupTimer();if(this.currentPopupItem==item){this._stopPendingCloseTimer();this._pendingClose_timer=this.defer(function(){this._pendingClose_timer=null;this.currentPopupItem=null;item._closePopup();},this.popupDelay);}},onItemUnhover:function(item){if(this._hoveredChild==item){this._hoveredChild=null;}if(this.passive_hover_timer){this.passive_hover_timer.remove();this.passive_hover_timer=null;}item._set("hovering",false);},_stopPopupTimer:function(){if(this.hover_timer){this.hover_timer=this.hover_timer.remove();}},_stopPendingCloseTimer:function(){if(this._pendingClose_timer){this._pendingClose_timer=this._pendingClose_timer.remove();}},_getTopMenu:function(){for(var top=this;top.parentMenu;top=top.parentMenu){}return top;},onItemClick:function(item,evt){if(this.passive_hover_timer){this.passive_hover_timer.remove();}this.focusChild(item);if(item.disabled){return false;}if(item.popup){this.set("selected",item);this.set("activated",true);var _939=/^key/.test(evt._origType||evt.type)||(evt.clientX==0&&evt.clientY==0);this._openItemPopup(item,_939);}else{this.onExecute();item._onClick?item._onClick(evt):item.onClick(evt);}},_openItemPopup:function(_93a,_93b){if(_93a==this.currentPopupItem){return;}if(this.currentPopupItem){this._stopPendingCloseTimer();this.currentPopupItem._closePopup();}this._stopPopupTimer();var _93c=_93a.popup;_93c.parentMenu=this;this.own(this._mouseoverHandle=on.once(_93c.domNode,"mouseover",lang.hitch(this,"_onPopupHover")));var self=this;_93a._openPopup({parent:this,orient:this._orient||["after","before"],onCancel:function(){if(_93b){self.focusChild(_93a);}self._cleanUp();},onExecute:lang.hitch(this,"_cleanUp",true),onClose:function(){if(self._mouseoverHandle){self._mouseoverHandle.remove();delete self._mouseoverHandle;}}},_93b);this.currentPopupItem=_93a;},onOpen:function(){this.isShowingNow=true;this.set("activated",true);},onClose:function(){this.set("activated",false);this.set("selected",null);this.isShowingNow=false;this.parentMenu=null;},_closeChild:function(){this._stopPopupTimer();if(this.currentPopupItem){if(this.focused){_929.set(this.selected.focusNode,"tabIndex",this.tabIndex);this.selected.focusNode.focus();}this.currentPopupItem._closePopup();this.currentPopupItem=null;}},_onItemFocus:function(item){if(this._hoveredChild&&this._hoveredChild!=item){this.onItemUnhover(this._hoveredChild);}this.set("selected",item);},_onBlur:function(){this._cleanUp(true);this.inherited(arguments);},_cleanUp:function(_93d){this._closeChild();if(typeof this.isShowingNow=="undefined"){this.set("activated",false);}if(_93d){this.set("selected",null);}}});});},"dijit/_KeyNavContainer":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-attr","dojo/_base/kernel","dojo/keys","dojo/_base/lang","./registry","./_Container","./_FocusMixin","./_KeyNavMixin"],function(_93e,_93f,_940,_941,keys,lang,_942,_943,_944,_945){return _93f("dijit._KeyNavContainer",[_944,_945,_943],{connectKeyNavHandlers:function(_946,_947){var _948=(this._keyNavCodes={});var prev=lang.hitch(this,"focusPrev");var next=lang.hitch(this,"focusNext");_93e.forEach(_946,function(code){_948[code]=prev;});_93e.forEach(_947,function(code){_948[code]=next;});_948[keys.HOME]=lang.hitch(this,"focusFirstChild");_948[keys.END]=lang.hitch(this,"focusLastChild");},startupKeyNavChildren:function(){_941.deprecated("startupKeyNavChildren() call no longer needed","","2.0");},startup:function(){this.inherited(arguments);_93e.forEach(this.getChildren(),lang.hitch(this,"_startupChild"));},addChild:function(_949,_94a){this.inherited(arguments);this._startupChild(_949);},_startupChild:function(_94b){_94b.set("tabIndex","-1");},_getFirst:function(){var _94c=this.getChildren();return _94c.length?_94c[0]:null;},_getLast:function(){var _94d=this.getChildren();return _94d.length?_94d[_94d.length-1]:null;},focusNext:function(){this.focusChild(this._getNextFocusableChild(this.focusedChild,1));},focusPrev:function(){this.focusChild(this._getNextFocusableChild(this.focusedChild,-1),true);},childSelector:function(node){var node=_942.byNode(node);return node&&node.getParent()==this;}});});},"dijit/_KeyNavMixin":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-attr","dojo/keys","dojo/_base/lang","dojo/on","dijit/registry","dijit/_FocusMixin"],function(_94e,_94f,_950,keys,lang,on,_951,_952){return _94f("dijit._KeyNavMixin",_952,{tabIndex:"0",childSelector:null,postCreate:function(){this.inherited(arguments);_950.set(this.domNode,"tabIndex",this.tabIndex);if(!this._keyNavCodes){var _953=this._keyNavCodes={};_953[keys.HOME]=lang.hitch(this,"focusFirstChild");_953[keys.END]=lang.hitch(this,"focusLastChild");_953[this.isLeftToRight()?keys.LEFT_ARROW:keys.RIGHT_ARROW]=lang.hitch(this,"_onLeftArrow");_953[this.isLeftToRight()?keys.RIGHT_ARROW:keys.LEFT_ARROW]=lang.hitch(this,"_onRightArrow");_953[keys.UP_ARROW]=lang.hitch(this,"_onUpArrow");_953[keys.DOWN_ARROW]=lang.hitch(this,"_onDownArrow");}var self=this,_954=typeof this.childSelector=="string"?this.childSelector:lang.hitch(this,"childSelector");this.own(on(this.domNode,"keypress",lang.hitch(this,"_onContainerKeypress")),on(this.domNode,"keydown",lang.hitch(this,"_onContainerKeydown")),on(this.domNode,"focus",lang.hitch(this,"_onContainerFocus")),on(this.containerNode,on.selector(_954,"focusin"),function(evt){self._onChildFocus(_951.getEnclosingWidget(this),evt);}));},_onLeftArrow:function(){},_onRightArrow:function(){},_onUpArrow:function(){},_onDownArrow:function(){},focus:function(){this.focusFirstChild();},_getFirstFocusableChild:function(){return this._getNextFocusableChild(null,1);},_getLastFocusableChild:function(){return this._getNextFocusableChild(null,-1);},focusFirstChild:function(){this.focusChild(this._getFirstFocusableChild());},focusLastChild:function(){this.focusChild(this._getLastFocusableChild());},focusChild:function(_955,last){if(!_955){return;}if(this.focusedChild&&_955!==this.focusedChild){this._onChildBlur(this.focusedChild);}_955.set("tabIndex",this.tabIndex);_955.focus(last?"end":"start");},_onContainerFocus:function(evt){if(evt.target!==this.domNode||this.focusedChild){return;}this.focus();},_onFocus:function(){_950.set(this.domNode,"tabIndex","-1");this.inherited(arguments);},_onBlur:function(evt){_950.set(this.domNode,"tabIndex",this.tabIndex);if(this.focusedChild){this.focusedChild.set("tabIndex","-1");this.lastFocusedChild=this.focusedChild;this._set("focusedChild",null);}this.inherited(arguments);},_onChildFocus:function(_956){if(_956&&_956!=this.focusedChild){if(this.focusedChild&&!this.focusedChild._destroyed){this.focusedChild.set("tabIndex","-1");}_956.set("tabIndex",this.tabIndex);this.lastFocused=_956;this._set("focusedChild",_956);}},_searchString:"",multiCharSearchDuration:1000,onKeyboardSearch:function(item,evt,_957,_958){if(item){this.focusChild(item);}},_keyboardSearchCompare:function(item,_959){var _95a=item.domNode,text=item.label||(_95a.focusNode?_95a.focusNode.label:"")||_95a.innerText||_95a.textContent||"",_95b=text.replace(/^\s+/,"").substr(0,_959.length).toLowerCase();return (!!_959.length&&_95b==_959)?-1:0;},_onContainerKeydown:function(evt){var func=this._keyNavCodes[evt.keyCode];if(func){func(evt,this.focusedChild);evt.stopPropagation();evt.preventDefault();this._searchString="";}else{if(evt.keyCode==keys.SPACE&&this._searchTimer&&!(evt.ctrlKey||evt.altKey||evt.metaKey)){evt.stopImmediatePropagation();evt.preventDefault();this._keyboardSearch(evt," ");}}},_onContainerKeypress:function(evt){if(evt.charCode<=keys.SPACE||evt.ctrlKey||evt.altKey||evt.metaKey){return;}evt.preventDefault();evt.stopPropagation();this._keyboardSearch(evt,String.fromCharCode(evt.charCode).toLowerCase());},_keyboardSearch:function(evt,_95c){var _95d=null,_95e,_95f=0,_960=lang.hitch(this,function(){if(this._searchTimer){this._searchTimer.remove();}this._searchString+=_95c;var _961=/^(.)\1*$/.test(this._searchString);var _962=_961?1:this._searchString.length;_95e=this._searchString.substr(0,_962);this._searchTimer=this.defer(function(){this._searchTimer=null;this._searchString="";},this.multiCharSearchDuration);var _963=this.focusedChild||null;if(_962==1||!_963){_963=this._getNextFocusableChild(_963,1);if(!_963){return;}}var stop=_963;do{var rc=this._keyboardSearchCompare(_963,_95e);if(!!rc&&_95f++==0){_95d=_963;}if(rc==-1){_95f=-1;break;}_963=this._getNextFocusableChild(_963,1);}while(_963&&_963!=stop);});_960();this.onKeyboardSearch(_95d,evt,_95e,_95f);},_onChildBlur:function(){},_getNextFocusableChild:function(_964,dir){var _965=_964;do{if(!_964){_964=this[dir>0?"_getFirst":"_getLast"]();if(!_964){break;}}else{_964=this._getNext(_964,dir);}if(_964!=null&&_964!=_965&&_964.isFocusable()){return _964;}}while(_964!=_965);return null;},_getFirst:function(){return null;},_getLast:function(){return null;},_getNext:function(_966,dir){if(_966){_966=_966.domNode;while(_966){_966=_966[dir<0?"previousSibling":"nextSibling"];if(_966&&"getAttribute" in _966){var w=_951.byNode(_966);if(w){return w;}}}}return null;}});});},"dijit/MenuItem":function(){define(["dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/_base/kernel","dojo/sniff","dojo/_base/lang","./_Widget","./_TemplatedMixin","./_Contained","./_CssStateMixin","dojo/text!./templates/MenuItem.html"],function(_967,dom,_968,_969,_96a,has,lang,_96b,_96c,_96d,_96e,_96f){var _970=_967("dijit.MenuItem"+(has("dojo-bidi")?"_NoBidi":""),[_96b,_96c,_96d,_96e],{templateString:_96f,baseClass:"dijitMenuItem",label:"",_setLabelAttr:function(val){this._set("label",val);var _971="";var text;var ndx=val.search(/{\S}/);if(ndx>=0){_971=val.charAt(ndx+1);var _972=val.substr(0,ndx);var _973=val.substr(ndx+3);text=_972+_971+_973;val=_972+"<span class=\"dijitMenuItemShortcutKey\">"+_971+"</span>"+_973;}else{text=val;}this.domNode.setAttribute("aria-label",text+" "+this.accelKey);this.containerNode.innerHTML=val;this._set("shortcutKey",_971);},iconClass:"dijitNoIcon",_setIconClassAttr:{node:"iconNode",type:"class"},accelKey:"",disabled:false,_fillContent:function(_974){if(_974&&!("label" in this.params)){this._set("label",_974.innerHTML);}},buildRendering:function(){this.inherited(arguments);var _975=this.id+"_text";_968.set(this.containerNode,"id",_975);if(this.accelKeyNode){_968.set(this.accelKeyNode,"id",this.id+"_accel");}dom.setSelectable(this.domNode,false);},onClick:function(){},focus:function(){try{if(has("ie")==8){this.containerNode.focus();}this.focusNode.focus();}catch(e){}},_setSelected:function(_976){_969.toggle(this.domNode,"dijitMenuItemSelected",_976);},setLabel:function(_977){_96a.deprecated("dijit.MenuItem.setLabel() is deprecated.  Use set('label', ...) instead.","","2.0");this.set("label",_977);},setDisabled:function(_978){_96a.deprecated("dijit.Menu.setDisabled() is deprecated.  Use set('disabled', bool) instead.","","2.0");this.set("disabled",_978);},_setDisabledAttr:function(_979){this.focusNode.setAttribute("aria-disabled",_979?"true":"false");this._set("disabled",_979);},_setAccelKeyAttr:function(_97a){if(this.accelKeyNode){this.accelKeyNode.style.display=_97a?"":"none";this.accelKeyNode.innerHTML=_97a;_968.set(this.containerNode,"colSpan",_97a?"1":"2");}this._set("accelKey",_97a);}});if(has("dojo-bidi")){_970=_967("dijit.MenuItem",_970,{_setLabelAttr:function(val){this.inherited(arguments);if(this.textDir==="auto"){this.applyTextDir(this.textDirNode);}}});}return _970;});},"dijit/MenuSeparator":function(){define(["dojo/_base/declare","dojo/dom","./_WidgetBase","./_TemplatedMixin","./_Contained","dojo/text!./templates/MenuSeparator.html"],function(_97b,dom,_97c,_97d,_97e,_97f){return _97b("dijit.MenuSeparator",[_97c,_97d,_97e],{templateString:_97f,buildRendering:function(){this.inherited(arguments);dom.setSelectable(this.domNode,false);},isFocusable:function(){return false;}});});},"dijit/form/SimpleTextarea":function(){define(["dojo/_base/declare","dojo/dom-class","dojo/sniff","./TextBox"],function(_980,_981,has,_982){return _980("dijit.form.SimpleTextarea",_982,{baseClass:"dijitTextBox dijitTextArea",rows:"3",cols:"20",templateString:"<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>",postMixInProperties:function(){if(!this.value&&this.srcNodeRef){this.value=this.srcNodeRef.value;}this.inherited(arguments);},buildRendering:function(){this.inherited(arguments);if(has("ie")&&this.cols){_981.add(this.textbox,"dijitTextAreaCols");}},filter:function(_983){if(_983){_983=_983.replace(/\r/g,"");}return this.inherited(arguments);},_onInput:function(e){if(this.maxLength){var _984=parseInt(this.maxLength);var _985=this.textbox.value.replace(/\r/g,"");var _986=_985.length-_984;if(_986>0){var _987=this.textbox;if(_987.selectionStart){var pos=_987.selectionStart;var cr=0;if(has("opera")){cr=(this.textbox.value.substring(0,pos).match(/\r/g)||[]).length;}this.textbox.value=_985.substring(0,pos-_986-cr)+_985.substring(pos-cr);_987.setSelectionRange(pos-_986,pos-_986);}else{if(this.ownerDocument.selection){_987.focus();var _988=this.ownerDocument.selection.createRange();_988.moveStart("character",-_986);_988.text="";_988.select();}}}}this.inherited(arguments);}});});},"dijit/form/MultiSelect":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-geometry","dojo/sniff","dojo/query","./_FormValueWidget","dojo/NodeList-dom"],function(_989,_98a,_98b,has,_98c,_98d){var _98e=_98a("dijit.form.MultiSelect"+(has("dojo-bidi")?"_NoBidi":""),_98d,{size:7,baseClass:"dijitMultiSelect",templateString:"<select multiple='multiple' ${!nameAttrSetting} data-dojo-attach-point='containerNode,focusNode' data-dojo-attach-event='onchange: _onChange'></select>",addSelected:function(_98f){_98f.getSelected().forEach(function(n){this.containerNode.appendChild(n);this.domNode.scrollTop=this.domNode.offsetHeight;var _990=_98f.domNode.scrollTop;_98f.domNode.scrollTop=0;_98f.domNode.scrollTop=_990;},this);this._set("value",this.get("value"));},getSelected:function(){return _98c("option",this.containerNode).filter(function(n){return n.selected;});},_getValueAttr:function(){return _989.map(this.getSelected(),function(n){return n.value;});},multiple:true,_setMultipleAttr:function(val){},_setValueAttr:function(_991){if(has("android")){_98c("option",this.containerNode).orphan().forEach(function(n){var _992=n.ownerDocument.createElement("option");_992.value=n.value;_992.selected=(_989.indexOf(_991,n.value)!=-1);_992.text=n.text;_992.originalText=n.originalText;this.containerNode.appendChild(_992);},this);}else{_98c("option",this.containerNode).forEach(function(n){n.selected=(_989.indexOf(_991,n.value)!=-1);});}this.inherited(arguments);},invertSelection:function(_993){var val=[];_98c("option",this.containerNode).forEach(function(n){if(!n.selected){val.push(n.value);}});this._setValueAttr(val,!(_993===false||_993==null));},_onChange:function(){this._handleOnChange(this.get("value"),true);},resize:function(size){if(size){_98b.setMarginBox(this.domNode,size);}},postCreate:function(){this._set("value",this.get("value"));this.inherited(arguments);}});if(has("dojo-bidi")){_98e=_98a("dijit.form.MultiSelect",_98e,{addSelected:function(_994){_994.getSelected().forEach(function(n){n.text=this.enforceTextDirWithUcc(this.restoreOriginalText(n),n.text);},this);this.inherited(arguments);},_setTextDirAttr:function(_995){if((this.textDir!=_995||!this._created)&&this.enforceTextDirWithUcc){this._set("textDir",_995);_98c("option",this.containerNode).forEach(function(_996){if(!this._created&&_996.value===_996.text){_996.value=_996.text;}_996.text=this.enforceTextDirWithUcc(_996,_996.originalText||_996.text);},this);}}});}return _98e;});},"dijit/form/ComboBox":function(){define(["dojo/_base/declare","./ValidationTextBox","./ComboBoxMixin"],function(_997,_998,_999){return _997("dijit.form.ComboBox",[_998,_999],{});});},"dijit/InlineEditBox":function(){define(["require","dojo/_base/array","dojo/aspect","dojo/_base/declare","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/dom-style","dojo/i18n","dojo/_base/kernel","dojo/keys","dojo/_base/lang","dojo/on","dojo/sniff","dojo/when","./a11yclick","./focus","./_Widget","./_TemplatedMixin","./_WidgetsInTemplateMixin","./_Container","./form/Button","./form/_TextBoxMixin","./form/TextBox","dojo/text!./templates/InlineEditBox.html","dojo/i18n!./nls/common"],function(_99a,_99b,_99c,_99d,_99e,_99f,_9a0,_9a1,i18n,_9a2,keys,lang,on,has,when,_9a3,fm,_9a4,_9a5,_9a6,_9a7,_9a8,_9a9,_9aa,_9ab){var _9ac=_99d("dijit._InlineEditor",[_9a4,_9a5,_9a6],{templateString:_9ab,contextRequire:_99a,postMixInProperties:function(){this.inherited(arguments);this.messages=i18n.getLocalization("dijit","common",this.lang);_99b.forEach(["buttonSave","buttonCancel"],function(prop){if(!this[prop]){this[prop]=this.messages[prop];}},this);},buildRendering:function(){this.inherited(arguments);var Cls=typeof this.editor=="string"?(lang.getObject(this.editor)||_99a(this.editor)):this.editor;var _9ad=this.sourceStyle,_9ae="line-height:"+_9ad.lineHeight+";",_9af=_9a1.getComputedStyle(this.domNode);_99b.forEach(["Weight","Family","Size","Style"],function(prop){var _9b0=_9ad["font"+prop],_9b1=_9af["font"+prop];if(_9b1!=_9b0){_9ae+="font-"+prop+":"+_9ad["font"+prop]+";";}},this);_99b.forEach(["marginTop","marginBottom","marginLeft","marginRight","position","left","top","right","bottom","float","clear","display"],function(prop){this.domNode.style[prop]=_9ad[prop];},this);var _9b2=this.inlineEditBox.width;if(_9b2=="100%"){_9ae+="width:100%;";this.domNode.style.display="block";}else{_9ae+="width:"+(_9b2+(Number(_9b2)==_9b2?"px":""))+";";}var _9b3=lang.delegate(this.inlineEditBox.editorParams,{style:_9ae,dir:this.dir,lang:this.lang,textDir:this.textDir});this.editWidget=new Cls(_9b3,this.editorPlaceholder);if(this.inlineEditBox.autoSave){this.saveButton.destroy();this.cancelButton.destroy();this.saveButton=this.cancelButton=null;_9a0.destroy(this.buttonContainer);}},postCreate:function(){this.inherited(arguments);var ew=this.editWidget;if(this.inlineEditBox.autoSave){this.own(_99c.after(ew,"onChange",lang.hitch(this,"_onChange"),true),on(ew,"keydown",lang.hitch(this,"_onKeyDown")));}else{if("intermediateChanges" in ew){ew.set("intermediateChanges",true);this.own(_99c.after(ew,"onChange",lang.hitch(this,"_onIntermediateChange"),true));this.saveButton.set("disabled",true);}}},startup:function(){this.editWidget.startup();this.inherited(arguments);},_onIntermediateChange:function(){this.saveButton.set("disabled",(this.getValue()==this._resetValue)||!this.enableSave());},destroy:function(){this.editWidget.destroy(true);this.inherited(arguments);},getValue:function(){var ew=this.editWidget;return String(ew.get(("displayedValue" in ew||"_getDisplayedValueAttr" in ew)?"displayedValue":"value"));},_onKeyDown:function(e){if(this.inlineEditBox.autoSave&&this.inlineEditBox.editing){if(e.altKey||e.ctrlKey){return;}if(e.keyCode==keys.ESCAPE){e.stopPropagation();e.preventDefault();this.cancel(true);}else{if(e.keyCode==keys.ENTER&&e.target.tagName=="INPUT"){e.stopPropagation();e.preventDefault();this._onChange();}}}},_onBlur:function(){this.inherited(arguments);if(this.inlineEditBox.autoSave&&this.inlineEditBox.editing){if(this.getValue()==this._resetValue){this.cancel(false);}else{if(this.enableSave()){this.save(false);}}}},_onChange:function(){if(this.inlineEditBox.autoSave&&this.inlineEditBox.editing&&this.enableSave()){fm.focus(this.inlineEditBox.displayNode);}},enableSave:function(){return this.editWidget.isValid?this.editWidget.isValid():true;},focus:function(){this.editWidget.focus();if(this.editWidget.focusNode){fm._onFocusNode(this.editWidget.focusNode);if(this.editWidget.focusNode.tagName=="INPUT"){this.defer(function(){_9a9.selectInputText(this.editWidget.focusNode);});}}}});var _9b4=_99d("dijit.InlineEditBox"+(has("dojo-bidi")?"_NoBidi":""),_9a4,{editing:false,autoSave:true,buttonSave:"",buttonCancel:"",renderAsHtml:false,editor:_9aa,editorWrapper:_9ac,editorParams:{},disabled:false,onChange:function(){},onCancel:function(){},width:"100%",value:"",noValueIndicator:has("ie")<=6?"<span style='font-family: wingdings; text-decoration: underline;'>&#160;&#160;&#160;&#160;&#x270d;&#160;&#160;&#160;&#160;</span>":"<span style='text-decoration: underline;'>&#160;&#160;&#160;&#160;&#x270d;&#160;&#160;&#160;&#160;</span>",constructor:function(){this.editorParams={};},postMixInProperties:function(){this.inherited(arguments);this.displayNode=this.srcNodeRef;this.own(on(this.displayNode,_9a3,lang.hitch(this,"_onClick")),on(this.displayNode,"mouseover, focus",lang.hitch(this,"_onMouseOver")),on(this.displayNode,"mouseout, blur",lang.hitch(this,"_onMouseOut")));this.displayNode.setAttribute("role","button");if(!this.displayNode.getAttribute("tabIndex")){this.displayNode.setAttribute("tabIndex",0);}if(!this.value&&!("value" in this.params)){this.value=lang.trim(this.renderAsHtml?this.displayNode.innerHTML:(this.displayNode.innerText||this.displayNode.textContent||""));}if(!this.value){this.displayNode.innerHTML=this.noValueIndicator;}_99f.add(this.displayNode,"dijitInlineEditBoxDisplayMode");},setDisabled:function(_9b5){_9a2.deprecated("dijit.InlineEditBox.setDisabled() is deprecated.  Use set('disabled', bool) instead.","","2.0");this.set("disabled",_9b5);},_setDisabledAttr:function(_9b6){this.domNode.setAttribute("aria-disabled",_9b6?"true":"false");if(_9b6){this.displayNode.removeAttribute("tabIndex");}else{this.displayNode.setAttribute("tabIndex",0);}_99f.toggle(this.displayNode,"dijitInlineEditBoxDisplayModeDisabled",_9b6);this._set("disabled",_9b6);},_onMouseOver:function(){if(!this.disabled){_99f.add(this.displayNode,"dijitInlineEditBoxDisplayModeHover");}},_onMouseOut:function(){_99f.remove(this.displayNode,"dijitInlineEditBoxDisplayModeHover");},_onClick:function(e){if(this.disabled){return;}if(e){e.stopPropagation();e.preventDefault();}this._onMouseOut();this.defer("edit");},edit:function(){if(this.disabled||this.editing){return;}this._set("editing",true);this._savedTabIndex=_99e.get(this.displayNode,"tabIndex")||"0";if(!this.wrapperWidget){var _9b7=_9a0.create("span",null,this.domNode,"before");var Ewc=typeof this.editorWrapper=="string"?lang.getObject(this.editorWrapper):this.editorWrapper;this.wrapperWidget=new Ewc({value:this.value,buttonSave:this.buttonSave,buttonCancel:this.buttonCancel,dir:this.dir,lang:this.lang,tabIndex:this._savedTabIndex,editor:this.editor,inlineEditBox:this,sourceStyle:_9a1.getComputedStyle(this.displayNode),save:lang.hitch(this,"save"),cancel:lang.hitch(this,"cancel"),textDir:this.textDir},_9b7);if(!this.wrapperWidget._started){this.wrapperWidget.startup();}if(!this._started){this.startup();}}var ww=this.wrapperWidget;_99f.add(this.displayNode,"dijitOffScreen");_99f.remove(ww.domNode,"dijitOffScreen");_9a1.set(ww.domNode,{visibility:"visible"});_99e.set(this.displayNode,"tabIndex","-1");var ew=ww.editWidget;var self=this;when(ew.onLoadDeferred,lang.hitch(ww,function(){ew.set(("displayedValue" in ew||"_setDisplayedValueAttr" in ew)?"displayedValue":"value",self.value);this.defer(function(){if(ww.saveButton){ww.saveButton.set("disabled","intermediateChanges" in ew);}this.focus();this._resetValue=this.getValue();});}));},_onBlur:function(){this.inherited(arguments);if(!this.editing){}},destroy:function(){if(this.wrapperWidget&&!this.wrapperWidget._destroyed){this.wrapperWidget.destroy();delete this.wrapperWidget;}this.inherited(arguments);},_showText:function(_9b8){var ww=this.wrapperWidget;_9a1.set(ww.domNode,{visibility:"hidden"});_99f.add(ww.domNode,"dijitOffScreen");_99f.remove(this.displayNode,"dijitOffScreen");_99e.set(this.displayNode,"tabIndex",this._savedTabIndex);if(_9b8){fm.focus(this.displayNode);}},save:function(_9b9){if(this.disabled||!this.editing){return;}this._set("editing",false);var ww=this.wrapperWidget;var _9ba=ww.getValue();this.set("value",_9ba);this._showText(_9b9);},setValue:function(val){_9a2.deprecated("dijit.InlineEditBox.setValue() is deprecated.  Use set('value', ...) instead.","","2.0");return this.set("value",val);},_setValueAttr:function(val){val=lang.trim(val);var _9bb=this.renderAsHtml?val:val.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;").replace(/"/gm,"&quot;").replace(/\n/g,"<br>");if(this.editorParams&&this.editorParams.type==="password"){this.displayNode.innerHTML="********";}else{this.displayNode.innerHTML=_9bb||this.noValueIndicator;}this._set("value",val);if(this._started){this.defer(function(){this.onChange(val);});}},getValue:function(){_9a2.deprecated("dijit.InlineEditBox.getValue() is deprecated.  Use get('value') instead.","","2.0");return this.get("value");},cancel:function(_9bc){if(this.disabled||!this.editing){return;}this._set("editing",false);this.defer("onCancel");this._showText(_9bc);}});if(has("dojo-bidi")){_9b4=_99d("dijit.InlineEditBox",_9b4,{_setValueAttr:function(){this.inherited(arguments);this.applyTextDir(this.displayNode);}});}_9b4._InlineEditor=_9ac;return _9b4;});},"dijit/_WidgetsInTemplateMixin":function(){define(["dojo/_base/array","dojo/aspect","dojo/_base/declare","dojo/_base/lang","dojo/parser"],function(_9bd,_9be,_9bf,lang,_9c0){return _9bf("dijit._WidgetsInTemplateMixin",null,{_earlyTemplatedStartup:false,contextRequire:null,_beforeFillContent:function(){if(/dojoType|data-dojo-type/i.test(this.domNode.innerHTML)){var node=this.domNode;if(this.containerNode&&!this.searchContainerNode){this.containerNode.stopParser=true;}_9c0.parse(node,{noStart:!this._earlyTemplatedStartup,template:true,inherited:{dir:this.dir,lang:this.lang,textDir:this.textDir},propsThis:this,contextRequire:this.contextRequire,scope:"dojo"}).then(lang.hitch(this,function(_9c1){this._startupWidgets=_9c1;for(var i=0;i<_9c1.length;i++){this._processTemplateNode(_9c1[i],function(n,p){return n[p];},function(_9c2,type,_9c3){if(type in _9c2){return _9c2.connect(_9c2,type,_9c3);}else{return _9c2.on(type,_9c3,true);}});}if(this.containerNode&&this.containerNode.stopParser){delete this.containerNode.stopParser;}}));if(!this._startupWidgets){throw new Error(this.declaredClass+": parser returned unfilled promise (probably waiting for module auto-load), "+"unsupported by _WidgetsInTemplateMixin.   Must pre-load all supporting widgets before instantiation.");}}},_processTemplateNode:function(_9c4,_9c5,_9c6){if(_9c5(_9c4,"dojoType")||_9c5(_9c4,"data-dojo-type")){return true;}return this.inherited(arguments);},startup:function(){_9bd.forEach(this._startupWidgets,function(w){if(w&&!w._started&&w.startup){w.startup();}});this._startupWidgets=null;this.inherited(arguments);}});});},"dijit/ToolbarSeparator":function(){define(["dojo/_base/declare","dojo/dom","./_Widget","./_TemplatedMixin"],function(_9c7,dom,_9c8,_9c9){return _9c7("dijit.ToolbarSeparator",[_9c8,_9c9],{templateString:"<div class=\"dijitToolbarSeparator dijitInline\" role=\"presentation\"></div>",buildRendering:function(){this.inherited(arguments);dom.setSelectable(this.domNode,false);},isFocusable:function(){return false;}});});},"dijit/PopupMenuItem":function(){define(["dojo/_base/declare","dojo/dom-style","dojo/_base/lang","dojo/query","./popup","./registry","./MenuItem","./hccss"],function(_9ca,_9cb,lang,_9cc,pm,_9cd,_9ce){return _9ca("dijit.PopupMenuItem",_9ce,{baseClass:"dijitMenuItem dijitPopupMenuItem",_fillContent:function(){if(this.srcNodeRef){var _9cf=_9cc("*",this.srcNodeRef);this.inherited(arguments,[_9cf[0]]);this.dropDownContainer=this.srcNodeRef;}},_openPopup:function(_9d0,_9d1){var _9d2=this.popup;pm.open(lang.delegate(_9d0,{popup:this.popup,around:this.domNode}));if(_9d1&&_9d2.focus){_9d2.focus();}},_closePopup:function(){pm.close(this.popup);this.popup.parentMenu=null;},startup:function(){if(this._started){return;}this.inherited(arguments);if(!this.popup){var node=_9cc("[widgetId]",this.dropDownContainer)[0];this.popup=_9cd.byNode(node);}this.ownerDocumentBody.appendChild(this.popup.domNode);this.popup.domNode.setAttribute("aria-labelledby",this.containerNode.id);this.popup.startup();this.popup.domNode.style.display="none";if(this.arrowWrapper){_9cb.set(this.arrowWrapper,"visibility","");}this.focusNode.setAttribute("aria-haspopup","true");},destroyDescendants:function(_9d3){if(this.popup){if(!this.popup._destroyed){this.popup.destroyRecursive(_9d3);}delete this.popup;}this.inherited(arguments);}});});},"dijit/CheckedMenuItem":function(){define(["dojo/_base/declare","dojo/dom-class","./MenuItem","dojo/text!./templates/CheckedMenuItem.html","./hccss"],function(_9d4,_9d5,_9d6,_9d7){return _9d4("dijit.CheckedMenuItem",_9d6,{baseClass:"dijitMenuItem dijitCheckedMenuItem",templateString:_9d7,checked:false,_setCheckedAttr:function(_9d8){this.domNode.setAttribute("aria-checked",_9d8?"true":"false");this._set("checked",_9d8);},iconClass:"",role:"menuitemcheckbox",checkedChar:"&#10003;",onChange:function(){},_onClick:function(evt){if(!this.disabled){this.set("checked",!this.checked);this.onChange(this.checked);}this.onClick(evt);}});});},"dijit/layout/AccordionContainer":function(){define(["require","dojo/_base/array","dojo/_base/declare","dojo/_base/fx","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","dojo/keys","dojo/_base/lang","dojo/sniff","dojo/topic","../focus","../_base/manager","dojo/ready","../_Widget","../_Container","../_TemplatedMixin","../_CssStateMixin","./StackContainer","./ContentPane","dojo/text!./templates/AccordionButton.html","../a11yclick"],function(_9d9,_9da,_9db,fx,dom,_9dc,_9dd,_9de,_9df,keys,lang,has,_9e0,_9e1,_9e2,_9e3,_9e4,_9e5,_9e6,_9e7,_9e8,_9e9,_9ea){function size(_9eb,dim){_9eb.resize?_9eb.resize(dim):_9df.setMarginBox(_9eb.domNode,dim);};var _9ec=_9db("dijit.layout._AccordionButton",[_9e4,_9e6,_9e7],{templateString:_9ea,label:"",_setLabelAttr:{node:"titleTextNode",type:"innerHTML"},title:"",_setTitleAttr:{node:"titleTextNode",type:"attribute",attribute:"title"},iconClassAttr:"",_setIconClassAttr:{node:"iconNode",type:"class"},baseClass:"dijitAccordionTitle",getParent:function(){return this.parent;},buildRendering:function(){this.inherited(arguments);var _9ed=this.id.replace(" ","_");_9dc.set(this.titleTextNode,"id",_9ed+"_title");this.focusNode.setAttribute("aria-labelledby",_9dc.get(this.titleTextNode,"id"));dom.setSelectable(this.domNode,false);},getTitleHeight:function(){return _9df.getMarginSize(this.domNode).h;},_onTitleClick:function(){var _9ee=this.getParent();_9ee.selectChild(this.contentWidget,true);_9e1.focus(this.focusNode);},_onTitleKeyDown:function(evt){return this.getParent()._onKeyDown(evt,this.contentWidget);},_setSelectedAttr:function(_9ef){this._set("selected",_9ef);this.focusNode.setAttribute("aria-expanded",_9ef?"true":"false");this.focusNode.setAttribute("aria-selected",_9ef?"true":"false");this.focusNode.setAttribute("tabIndex",_9ef?"0":"-1");}});if(has("dojo-bidi")){_9ec.extend({_setLabelAttr:function(_9f0){this._set("label",_9f0);_9dc.set(this.titleTextNode,"innerHTML",_9f0);this.applyTextDir(this.titleTextNode);},_setTitleAttr:function(_9f1){this._set("title",_9f1);_9dc.set(this.titleTextNode,"title",_9f1);this.applyTextDir(this.titleTextNode);}});}var _9f2=_9db("dijit.layout._AccordionInnerContainer"+(has("dojo-bidi")?"_NoBidi":""),[_9e4,_9e7],{baseClass:"dijitAccordionInnerContainer",isLayoutContainer:true,buildRendering:function(){this.domNode=_9de.place("<div class='"+this.baseClass+"' role='presentation'>",this.contentWidget.domNode,"after");var _9f3=this.contentWidget,cls=lang.isString(this.buttonWidget)?lang.getObject(this.buttonWidget):this.buttonWidget;this.button=_9f3._buttonWidget=(new cls({contentWidget:_9f3,label:_9f3.title,title:_9f3.tooltip,dir:_9f3.dir,lang:_9f3.lang,textDir:_9f3.textDir||this.textDir,iconClass:_9f3.iconClass,id:_9f3.id+"_button",parent:this.parent})).placeAt(this.domNode);this.containerNode=_9de.place("<div class='dijitAccordionChildWrapper' role='tabpanel' style='display:none'>",this.domNode);this.containerNode.setAttribute("aria-labelledby",this.button.id);_9de.place(this.contentWidget.domNode,this.containerNode);},postCreate:function(){this.inherited(arguments);var _9f4=this.button,cw=this.contentWidget;this._contentWidgetWatches=[cw.watch("title",lang.hitch(this,function(name,_9f5,_9f6){_9f4.set("label",_9f6);})),cw.watch("tooltip",lang.hitch(this,function(name,_9f7,_9f8){_9f4.set("title",_9f8);})),cw.watch("iconClass",lang.hitch(this,function(name,_9f9,_9fa){_9f4.set("iconClass",_9fa);}))];},_setSelectedAttr:function(_9fb){this._set("selected",_9fb);this.button.set("selected",_9fb);if(_9fb){var cw=this.contentWidget;if(cw.onSelected){cw.onSelected();}}},startup:function(){this.contentWidget.startup();},destroy:function(){this.button.destroyRecursive();_9da.forEach(this._contentWidgetWatches||[],function(w){w.unwatch();});delete this.contentWidget._buttonWidget;delete this.contentWidget._wrapperWidget;this.inherited(arguments);},destroyDescendants:function(_9fc){this.contentWidget.destroyRecursive(_9fc);}});if(has("dojo-bidi")){_9f2=_9db("dijit.layout._AccordionInnerContainer",_9f2,{postCreate:function(){this.inherited(arguments);var _9fd=this.button;this._contentWidgetWatches.push(this.contentWidget.watch("textDir",function(name,_9fe,_9ff){_9fd.set("textDir",_9ff);}));}});}var _a00=_9db("dijit.layout.AccordionContainer",_9e8,{duration:_9e2.defaultDuration,buttonWidget:_9ec,baseClass:"dijitAccordionContainer",buildRendering:function(){this.inherited(arguments);this.domNode.style.overflow="hidden";this.domNode.setAttribute("role","tablist");},startup:function(){if(this._started){return;}this.inherited(arguments);if(this.selectedChildWidget){this.selectedChildWidget._wrapperWidget.set("selected",true);}},layout:function(){var _a01=this.selectedChildWidget;if(!_a01){return;}var _a02=_a01._wrapperWidget.domNode,_a03=_9df.getMarginExtents(_a02),_a04=_9df.getPadBorderExtents(_a02),_a05=_a01._wrapperWidget.containerNode,_a06=_9df.getMarginExtents(_a05),_a07=_9df.getPadBorderExtents(_a05),_a08=this._contentBox;var _a09=0;_9da.forEach(this.getChildren(),function(_a0a){if(_a0a!=_a01){_a09+=_9df.getMarginSize(_a0a._wrapperWidget.domNode).h;}});this._verticalSpace=_a08.h-_a09-_a03.h-_a04.h-_a06.h-_a07.h-_a01._buttonWidget.getTitleHeight();this._containerContentBox={h:this._verticalSpace,w:this._contentBox.w-_a03.w-_a04.w-_a06.w-_a07.w};if(_a01){size(_a01,this._containerContentBox);}},_setupChild:function(_a0b){_a0b._wrapperWidget=_9f2({contentWidget:_a0b,buttonWidget:this.buttonWidget,id:_a0b.id+"_wrapper",dir:_a0b.dir,lang:_a0b.lang,textDir:_a0b.textDir||this.textDir,parent:this});this.inherited(arguments);_9de.place(_a0b.domNode,_a0b._wrapper,"replace");},removeChild:function(_a0c){if(_a0c._wrapperWidget){_9de.place(_a0c.domNode,_a0c._wrapperWidget.domNode,"after");_a0c._wrapperWidget.destroy();delete _a0c._wrapperWidget;}_9dd.remove(_a0c.domNode,"dijitHidden");this.inherited(arguments);},getChildren:function(){return _9da.map(this.inherited(arguments),function(_a0d){return _a0d.declaredClass=="dijit.layout._AccordionInnerContainer"?_a0d.contentWidget:_a0d;},this);},destroy:function(){if(this._animation){this._animation.stop();}_9da.forEach(this.getChildren(),function(_a0e){if(_a0e._wrapperWidget){_a0e._wrapperWidget.destroy();}else{_a0e.destroyRecursive();}});this.inherited(arguments);},_showChild:function(_a0f){_a0f._wrapperWidget.containerNode.style.display="block";return this.inherited(arguments);},_hideChild:function(_a10){_a10._wrapperWidget.containerNode.style.display="none";this.inherited(arguments);},_transition:function(_a11,_a12,_a13){if(has("ie")<8){_a13=false;}if(this._animation){this._animation.stop(true);delete this._animation;}var self=this;if(_a11){_a11._wrapperWidget.set("selected",true);var d=this._showChild(_a11);if(this.doLayout){size(_a11,this._containerContentBox);}}if(_a12){_a12._wrapperWidget.set("selected",false);if(!_a13){this._hideChild(_a12);}}if(_a13){var _a14=_a11._wrapperWidget.containerNode,_a15=_a12._wrapperWidget.containerNode;var _a16=_a11._wrapperWidget.containerNode,_a17=_9df.getMarginExtents(_a16),_a18=_9df.getPadBorderExtents(_a16),_a19=_a17.h+_a18.h;_a15.style.height=(self._verticalSpace-_a19)+"px";this._animation=new fx.Animation({node:_a14,duration:this.duration,curve:[1,this._verticalSpace-_a19-1],onAnimate:function(_a1a){_a1a=Math.floor(_a1a);_a14.style.height=_a1a+"px";_a15.style.height=(self._verticalSpace-_a19-_a1a)+"px";},onEnd:function(){delete self._animation;_a14.style.height="auto";_a12._wrapperWidget.containerNode.style.display="none";_a15.style.height="auto";self._hideChild(_a12);}});this._animation.onStop=this._animation.onEnd;this._animation.play();}return d;},_onKeyDown:function(e,_a1b){if(this.disabled||e.altKey||!(_a1b||e.ctrlKey)){return;}var c=e.keyCode;if((_a1b&&(c==keys.LEFT_ARROW||c==keys.UP_ARROW))||(e.ctrlKey&&c==keys.PAGE_UP)){this._adjacent(false)._buttonWidget._onTitleClick();e.stopPropagation();e.preventDefault();}else{if((_a1b&&(c==keys.RIGHT_ARROW||c==keys.DOWN_ARROW))||(e.ctrlKey&&(c==keys.PAGE_DOWN||c==keys.TAB))){this._adjacent(true)._buttonWidget._onTitleClick();e.stopPropagation();e.preventDefault();}}}});if(has("dijit-legacy-requires")){_9e3(0,function(){var _a1c=["dijit/layout/AccordionPane"];_9d9(_a1c);});}_a00._InnerContainer=_9f2;_a00._Button=_9ec;return _a00;});},"dijit/layout/StackContainer":function(){define(["dojo/_base/array","dojo/cookie","dojo/_base/declare","dojo/dom-class","dojo/dom-construct","dojo/has","dojo/_base/lang","dojo/on","dojo/ready","dojo/topic","dojo/when","../registry","../_WidgetBase","./_LayoutWidget"],function(_a1d,_a1e,_a1f,_a20,_a21,has,lang,on,_a22,_a23,when,_a24,_a25,_a26){if(has("dijit-legacy-requires")){_a22(0,function(){var _a27=["dijit/layout/StackController"];require(_a27);});}var _a28=_a1f("dijit.layout.StackContainer",_a26,{doLayout:true,persist:false,baseClass:"dijitStackContainer",buildRendering:function(){this.inherited(arguments);_a20.add(this.domNode,"dijitLayoutContainer");},postCreate:function(){this.inherited(arguments);this.own(on(this.domNode,"keydown",lang.hitch(this,"_onKeyDown")));},startup:function(){if(this._started){return;}var _a29=this.getChildren();_a1d.forEach(_a29,this._setupChild,this);if(this.persist){this.selectedChildWidget=_a24.byId(_a1e(this.id+"_selectedChild"));}else{_a1d.some(_a29,function(_a2a){if(_a2a.selected){this.selectedChildWidget=_a2a;}return _a2a.selected;},this);}var _a2b=this.selectedChildWidget;if(!_a2b&&_a29[0]){_a2b=this.selectedChildWidget=_a29[0];_a2b.selected=true;}_a23.publish(this.id+"-startup",{children:_a29,selected:_a2b,textDir:this.textDir});this.inherited(arguments);},resize:function(){if(!this._hasBeenShown){this._hasBeenShown=true;var _a2c=this.selectedChildWidget;if(_a2c){this._showChild(_a2c);}}this.inherited(arguments);},_setupChild:function(_a2d){var _a2e=_a2d.domNode,_a2f=_a21.place("<div role='tabpanel' class='"+this.baseClass+"ChildWrapper dijitHidden'>",_a2d.domNode,"replace"),_a30=_a2d["aria-label"]||_a2d.title||_a2d.label;if(_a30){_a2f.setAttribute("aria-label",_a30);}_a21.place(_a2e,_a2f);_a2d._wrapper=_a2f;this.inherited(arguments);if(_a2e.style.display=="none"){_a2e.style.display="block";}_a2d.domNode.removeAttribute("title");},addChild:function(_a31,_a32){this.inherited(arguments);if(this._started){_a23.publish(this.id+"-addChild",_a31,_a32);this.layout();if(!this.selectedChildWidget){this.selectChild(_a31);}}},removeChild:function(page){var idx=_a1d.indexOf(this.getChildren(),page);this.inherited(arguments);_a21.destroy(page._wrapper);delete page._wrapper;if(this._started){_a23.publish(this.id+"-removeChild",page);}if(this._descendantsBeingDestroyed){return;}if(this.selectedChildWidget===page){this.selectedChildWidget=undefined;if(this._started){var _a33=this.getChildren();if(_a33.length){this.selectChild(_a33[Math.max(idx-1,0)]);}}}if(this._started){this.layout();}},selectChild:function(page,_a34){var d;page=_a24.byId(page);if(this.selectedChildWidget!=page){d=this._transition(page,this.selectedChildWidget,_a34);this._set("selectedChildWidget",page);_a23.publish(this.id+"-selectChild",page,this._focused);if(this.persist){_a1e(this.id+"_selectedChild",this.selectedChildWidget.id);}}return when(d||true);},_transition:function(_a35,_a36){if(_a36){this._hideChild(_a36);}var d=this._showChild(_a35);if(_a35.resize){if(this.doLayout){_a35.resize(this._containerContentBox||this._contentBox);}else{_a35.resize();}}return d;},_adjacent:function(_a37){var _a38=this.getChildren();var _a39=_a1d.indexOf(_a38,this.selectedChildWidget);_a39+=_a37?1:_a38.length-1;return _a38[_a39%_a38.length];},forward:function(){return this.selectChild(this._adjacent(true),true);},back:function(){return this.selectChild(this._adjacent(false),true);},_onKeyDown:function(e){_a23.publish(this.id+"-containerKeyDown",{e:e,page:this});},layout:function(){var _a3a=this.selectedChildWidget;if(_a3a&&_a3a.resize){if(this.doLayout){_a3a.resize(this._containerContentBox||this._contentBox);}else{_a3a.resize();}}},_showChild:function(page){var _a3b=this.getChildren();page.isFirstChild=(page==_a3b[0]);page.isLastChild=(page==_a3b[_a3b.length-1]);page._set("selected",true);if(page._wrapper){_a20.replace(page._wrapper,"dijitVisible","dijitHidden");}return (page._onShow&&page._onShow())||true;},_hideChild:function(page){page._set("selected",false);if(page._wrapper){_a20.replace(page._wrapper,"dijitHidden","dijitVisible");}page.onHide&&page.onHide();},closeChild:function(page){var _a3c=!page.onClose||page.onClose(this,page);if(_a3c){this.removeChild(page);page.destroyRecursive();}},destroyDescendants:function(_a3d){this._descendantsBeingDestroyed=true;this.selectedChildWidget=undefined;_a1d.forEach(this.getChildren(),function(_a3e){if(!_a3d){this.removeChild(_a3e);}_a3e.destroyRecursive(_a3d);},this);this._descendantsBeingDestroyed=false;}});_a28.ChildWidgetProperties={selected:false,disabled:false,closable:false,iconClass:"dijitNoIcon",showTitle:true};lang.extend(_a25,_a28.ChildWidgetProperties);return _a28;});},"dojo/cookie":function(){define(["./_base/kernel","./regexp"],function(dojo,_a3f){dojo.cookie=function(name,_a40,_a41){var c=document.cookie,ret;if(arguments.length==1){var _a42=c.match(new RegExp("(?:^|; )"+_a3f.escapeString(name)+"=([^;]*)"));ret=_a42?decodeURIComponent(_a42[1]):undefined;}else{_a41=_a41||{};var exp=_a41.expires;if(typeof exp=="number"){var d=new Date();d.setTime(d.getTime()+exp*24*60*60*1000);exp=_a41.expires=d;}if(exp&&exp.toUTCString){_a41.expires=exp.toUTCString();}_a40=encodeURIComponent(_a40);var _a43=name+"="+_a40,_a44;for(_a44 in _a41){_a43+="; "+_a44;var _a45=_a41[_a44];if(_a45!==true){_a43+="="+_a45;}}document.cookie=_a43;}return ret;};dojo.cookie.isSupported=function(){if(!("cookieEnabled" in navigator)){this("__djCookieTest__","CookiesAllowed");navigator.cookieEnabled=this("__djCookieTest__")=="CookiesAllowed";if(navigator.cookieEnabled){this("__djCookieTest__","",{expires:-1});}}return navigator.cookieEnabled;};return dojo.cookie;});},"dijit/layout/AccordionPane":function(){define(["dojo/_base/declare","dojo/_base/kernel","./ContentPane"],function(_a46,_a47,_a48){return _a46("dijit.layout.AccordionPane",_a48,{constructor:function(){_a47.deprecated("dijit.layout.AccordionPane deprecated, use ContentPane instead","","2.0");},onSelected:function(){}});});},"dijit/layout/BorderContainer":function(){define(["dojo/_base/array","dojo/cookie","dojo/_base/declare","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","dojo/dom-style","dojo/keys","dojo/_base/lang","dojo/on","dojo/touch","../_WidgetBase","../_Widget","../_TemplatedMixin","./LayoutContainer","./utils"],function(_a49,_a4a,_a4b,_a4c,_a4d,_a4e,_a4f,keys,lang,on,_a50,_a51,_a52,_a53,_a54,_a55){var _a56=_a4b("dijit.layout._Splitter",[_a52,_a53],{live:true,templateString:"<div class=\"dijitSplitter\" data-dojo-attach-event=\"onkeydown:_onKeyDown,press:_startDrag,onmouseenter:_onMouse,onmouseleave:_onMouse\" tabIndex=\"0\" role=\"separator\"><div class=\"dijitSplitterThumb\"></div></div>",constructor:function(){this._handlers=[];},postMixInProperties:function(){this.inherited(arguments);this.horizontal=/top|bottom/.test(this.region);this._factor=/top|left/.test(this.region)?1:-1;this._cookieName=this.container.id+"_"+this.region;},buildRendering:function(){this.inherited(arguments);_a4c.add(this.domNode,"dijitSplitter"+(this.horizontal?"H":"V"));if(this.container.persist){var _a57=_a4a(this._cookieName);if(_a57){this.child.domNode.style[this.horizontal?"height":"width"]=_a57;}}},_computeMaxSize:function(){var dim=this.horizontal?"h":"w",_a58=_a4e.getMarginBox(this.child.domNode)[dim],_a59=_a49.filter(this.container.getChildren(),function(_a5a){return _a5a.region=="center";})[0];var _a5b=_a4e.getContentBox(_a59.domNode)[dim]-10;return Math.min(this.child.maxSize,_a58+_a5b);},_startDrag:function(e){if(!this.cover){this.cover=_a4d.place("<div class=dijitSplitterCover></div>",this.child.domNode,"after");}_a4c.add(this.cover,"dijitSplitterCoverActive");if(this.fake){_a4d.destroy(this.fake);}if(!(this._resize=this.live)){(this.fake=this.domNode.cloneNode(true)).removeAttribute("id");_a4c.add(this.domNode,"dijitSplitterShadow");_a4d.place(this.fake,this.domNode,"after");}_a4c.add(this.domNode,"dijitSplitterActive dijitSplitter"+(this.horizontal?"H":"V")+"Active");if(this.fake){_a4c.remove(this.fake,"dijitSplitterHover dijitSplitter"+(this.horizontal?"H":"V")+"Hover");}var _a5c=this._factor,_a5d=this.horizontal,axis=_a5d?"pageY":"pageX",_a5e=e[axis],_a5f=this.domNode.style,dim=_a5d?"h":"w",_a60=_a4f.getComputedStyle(this.child.domNode),_a61=_a4e.getMarginBox(this.child.domNode,_a60)[dim],max=this._computeMaxSize(),min=Math.max(this.child.minSize,_a4e.getPadBorderExtents(this.child.domNode,_a60)[dim]+10),_a62=this.region,_a63=_a62=="top"||_a62=="bottom"?"top":"left",_a64=parseInt(_a5f[_a63],10),_a65=this._resize,_a66=lang.hitch(this.container,"_layoutChildren",this.child.id),de=this.ownerDocument;this._handlers=this._handlers.concat([on(de,_a50.move,this._drag=function(e,_a67){var _a68=e[axis]-_a5e,_a69=_a5c*_a68+_a61,_a6a=Math.max(Math.min(_a69,max),min);if(_a65||_a67){_a66(_a6a);}_a5f[_a63]=_a68+_a64+_a5c*(_a6a-_a69)+"px";}),on(de,"dragstart",function(e){e.stopPropagation();e.preventDefault();}),on(this.ownerDocumentBody,"selectstart",function(e){e.stopPropagation();e.preventDefault();}),on(de,_a50.release,lang.hitch(this,"_stopDrag"))]);e.stopPropagation();e.preventDefault();},_onMouse:function(e){var o=(e.type=="mouseover"||e.type=="mouseenter");_a4c.toggle(this.domNode,"dijitSplitterHover",o);_a4c.toggle(this.domNode,"dijitSplitter"+(this.horizontal?"H":"V")+"Hover",o);},_stopDrag:function(e){try{if(this.cover){_a4c.remove(this.cover,"dijitSplitterCoverActive");}if(this.fake){_a4d.destroy(this.fake);}_a4c.remove(this.domNode,"dijitSplitterActive dijitSplitter"+(this.horizontal?"H":"V")+"Active dijitSplitterShadow");this._drag(e);this._drag(e,true);}finally{this._cleanupHandlers();delete this._drag;}if(this.container.persist){_a4a(this._cookieName,this.child.domNode.style[this.horizontal?"height":"width"],{expires:365});}},_cleanupHandlers:function(){var h;while(h=this._handlers.pop()){h.remove();}},_onKeyDown:function(e){this._resize=true;var _a6b=this.horizontal;var tick=1;switch(e.keyCode){case _a6b?keys.UP_ARROW:keys.LEFT_ARROW:tick*=-1;case _a6b?keys.DOWN_ARROW:keys.RIGHT_ARROW:break;default:return;}var _a6c=_a4e.getMarginSize(this.child.domNode)[_a6b?"h":"w"]+this._factor*tick;this.container._layoutChildren(this.child.id,Math.max(Math.min(_a6c,this._computeMaxSize()),this.child.minSize));e.stopPropagation();e.preventDefault();},destroy:function(){this._cleanupHandlers();delete this.child;delete this.container;delete this.cover;delete this.fake;this.inherited(arguments);}});var _a6d=_a4b("dijit.layout._Gutter",[_a52,_a53],{templateString:"<div class=\"dijitGutter\" role=\"presentation\"></div>",postMixInProperties:function(){this.inherited(arguments);this.horizontal=/top|bottom/.test(this.region);},buildRendering:function(){this.inherited(arguments);_a4c.add(this.domNode,"dijitGutter"+(this.horizontal?"H":"V"));}});var _a6e=_a4b("dijit.layout.BorderContainer",_a54,{gutters:true,liveSplitters:true,persist:false,baseClass:"dijitBorderContainer",_splitterClass:_a56,postMixInProperties:function(){if(!this.gutters){this.baseClass+="NoGutter";}this.inherited(arguments);},_setupChild:function(_a6f){this.inherited(arguments);var _a70=_a6f.region,ltr=_a6f.isLeftToRight();if(_a70=="leading"){_a70=ltr?"left":"right";}if(_a70=="trailing"){_a70=ltr?"right":"left";}if(_a70){if(_a70!="center"&&(_a6f.splitter||this.gutters)&&!_a6f._splitterWidget){var _a71=_a6f.splitter?this._splitterClass:_a6d;if(lang.isString(_a71)){_a71=lang.getObject(_a71);}var _a72=new _a71({id:_a6f.id+"_splitter",container:this,child:_a6f,region:_a70,live:this.liveSplitters});_a72.isSplitter=true;_a6f._splitterWidget=_a72;var _a73=_a70=="bottom"||_a70==(this.isLeftToRight()?"right":"left");_a4d.place(_a72.domNode,_a6f.domNode,_a73?"before":"after");_a72.startup();}}},layout:function(){this._layoutChildren();},removeChild:function(_a74){var _a75=_a74._splitterWidget;if(_a75){_a75.destroy();delete _a74._splitterWidget;}this.inherited(arguments);},getChildren:function(){return _a49.filter(this.inherited(arguments),function(_a76){return !_a76.isSplitter;});},getSplitter:function(_a77){return _a49.filter(this.getChildren(),function(_a78){return _a78.region==_a77;})[0]._splitterWidget;},resize:function(_a79,_a7a){if(!this.cs||!this.pe){var node=this.domNode;this.cs=_a4f.getComputedStyle(node);this.pe=_a4e.getPadExtents(node,this.cs);this.pe.r=_a4f.toPixelValue(node,this.cs.paddingRight);this.pe.b=_a4f.toPixelValue(node,this.cs.paddingBottom);_a4f.set(node,"padding","0px");}this.inherited(arguments);},_layoutChildren:function(_a7b,_a7c){if(!this._borderBox||!this._borderBox.h){return;}var _a7d=[];_a49.forEach(this._getOrderedChildren(),function(pane){_a7d.push(pane);if(pane._splitterWidget){_a7d.push(pane._splitterWidget);}});var dim={l:this.pe.l,t:this.pe.t,w:this._borderBox.w-this.pe.w,h:this._borderBox.h-this.pe.h};_a55.layoutChildren(this.domNode,dim,_a7d,_a7b,_a7c);},destroyRecursive:function(){_a49.forEach(this.getChildren(),function(_a7e){var _a7f=_a7e._splitterWidget;if(_a7f){_a7f.destroy();}delete _a7e._splitterWidget;});this.inherited(arguments);}});_a6e.ChildWidgetProperties={splitter:false,minSize:0,maxSize:Infinity};lang.mixin(_a6e.ChildWidgetProperties,_a54.ChildWidgetProperties);lang.extend(_a51,_a6e.ChildWidgetProperties);_a6e._Splitter=_a56;_a6e._Gutter=_a6d;return _a6e;});},"dijit/layout/LayoutContainer":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-class","dojo/dom-style","dojo/_base/lang","../_WidgetBase","./_LayoutWidget","./utils"],function(_a80,_a81,_a82,_a83,lang,_a84,_a85,_a86){var _a87=_a81("dijit.layout.LayoutContainer",_a85,{design:"headline",baseClass:"dijitLayoutContainer",startup:function(){if(this._started){return;}_a80.forEach(this.getChildren(),this._setupChild,this);this.inherited(arguments);},_setupChild:function(_a88){this.inherited(arguments);var _a89=_a88.region;if(_a89){_a82.add(_a88.domNode,this.baseClass+"Pane");}},_getOrderedChildren:function(){var _a8a=_a80.map(this.getChildren(),function(_a8b,idx){return {pane:_a8b,weight:[_a8b.region=="center"?Infinity:0,_a8b.layoutPriority,(this.design=="sidebar"?1:-1)*(/top|bottom/.test(_a8b.region)?1:-1),idx]};},this);_a8a.sort(function(a,b){var aw=a.weight,bw=b.weight;for(var i=0;i<aw.length;i++){if(aw[i]!=bw[i]){return aw[i]-bw[i];}}return 0;});return _a80.map(_a8a,function(w){return w.pane;});},layout:function(){_a86.layoutChildren(this.domNode,this._contentBox,this._getOrderedChildren());},addChild:function(_a8c,_a8d){this.inherited(arguments);if(this._started){this.layout();}},removeChild:function(_a8e){this.inherited(arguments);if(this._started){this.layout();}_a82.remove(_a8e.domNode,this.baseClass+"Pane");_a83.set(_a8e.domNode,{top:"auto",bottom:"auto",left:"auto",right:"auto",position:"static"});_a83.set(_a8e.domNode,/top|bottom/.test(_a8e.region)?"width":"height","auto");}});_a87.ChildWidgetProperties={region:"",layoutAlign:"",layoutPriority:0};lang.extend(_a84,_a87.ChildWidgetProperties);return _a87;});},"dijit/layout/TabContainer":function(){define(["dojo/_base/lang","dojo/_base/declare","./_TabContainerBase","./TabController","./ScrollingTabController"],function(lang,_a8f,_a90,_a91,_a92){return _a8f("dijit.layout.TabContainer",_a90,{useMenu:true,useSlider:true,controllerWidget:"",_makeController:function(_a93){var cls=this.baseClass+"-tabs"+(this.doLayout?"":" dijitTabNoLayout"),_a91=typeof this.controllerWidget=="string"?lang.getObject(this.controllerWidget):this.controllerWidget;return new _a91({id:this.id+"_tablist",ownerDocument:this.ownerDocument,dir:this.dir,lang:this.lang,textDir:this.textDir,tabPosition:this.tabPosition,doLayout:this.doLayout,containerId:this.id,"class":cls,nested:this.nested,useMenu:this.useMenu,useSlider:this.useSlider,tabStripClass:this.tabStrip?this.baseClass+(this.tabStrip?"":"No")+"Strip":null},_a93);},postMixInProperties:function(){this.inherited(arguments);if(!this.controllerWidget){this.controllerWidget=(this.tabPosition=="top"||this.tabPosition=="bottom")&&!this.nested?_a92:_a91;}}});});},"dijit/layout/_TabContainerBase":function(){define(["dojo/_base/declare","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","./StackContainer","./utils","../_TemplatedMixin","dojo/text!./templates/TabContainer.html"],function(_a94,_a95,_a96,_a97,_a98,_a99,_a9a,_a9b){return _a94("dijit.layout._TabContainerBase",[_a98,_a9a],{tabPosition:"top",baseClass:"dijitTabContainer",tabStrip:false,nested:false,templateString:_a9b,postMixInProperties:function(){this.baseClass+=this.tabPosition.charAt(0).toUpperCase()+this.tabPosition.substr(1).replace(/-.*/,"");this.srcNodeRef&&_a97.set(this.srcNodeRef,"visibility","hidden");this.inherited(arguments);},buildRendering:function(){this.inherited(arguments);this.tablist=this._makeController(this.tablistNode);if(!this.doLayout){_a95.add(this.domNode,"dijitTabContainerNoLayout");}if(this.nested){_a95.add(this.domNode,"dijitTabContainerNested");_a95.add(this.tablist.containerNode,"dijitTabContainerTabListNested");_a95.add(this.tablistSpacer,"dijitTabContainerSpacerNested");_a95.add(this.containerNode,"dijitTabPaneWrapperNested");}else{_a95.add(this.domNode,"tabStrip-"+(this.tabStrip?"enabled":"disabled"));}},_setupChild:function(tab){_a95.add(tab.domNode,"dijitTabPane");this.inherited(arguments);},removeChild:function(_a9c){_a95.remove(_a9c.domNode,"dijitTabPane");this.inherited(arguments);},startup:function(){if(this._started){return;}this.tablist.startup();this.inherited(arguments);},layout:function(){if(!this._contentBox||typeof (this._contentBox.l)=="undefined"){return;}var sc=this.selectedChildWidget;if(this.doLayout){var _a9d=this.tabPosition.replace(/-h/,"");this.tablist.region=_a9d;var _a9e=[this.tablist,{domNode:this.tablistSpacer,region:_a9d},{domNode:this.containerNode,region:"center"}];_a99.layoutChildren(this.domNode,this._contentBox,_a9e);this._containerContentBox=_a99.marginBox2contentBox(this.containerNode,_a9e[2]);if(sc&&sc.resize){sc.resize(this._containerContentBox);}}else{if(this.tablist.resize){var s=this.tablist.domNode.style;s.width="0";var _a9f=_a96.getContentBox(this.domNode).w;s.width="";this.tablist.resize({w:_a9f});}if(sc&&sc.resize){sc.resize();}}},destroy:function(_aa0){if(this.tablist){this.tablist.destroy(_aa0);}this.inherited(arguments);}});});},"dijit/layout/TabController":function(){define(["dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/has","dojo/i18n","dojo/_base/lang","./StackController","../registry","../Menu","../MenuItem","dojo/text!./templates/_TabButton.html","dojo/i18n!../nls/common"],function(_aa1,dom,_aa2,_aa3,has,i18n,lang,_aa4,_aa5,Menu,_aa6,_aa7){var _aa8=_aa1("dijit.layout._TabButton"+(has("dojo-bidi")?"_NoBidi":""),_aa4.StackButton,{baseClass:"dijitTab",cssStateNodes:{closeNode:"dijitTabCloseButton"},templateString:_aa7,_setNameAttr:"focusNode",scrollOnFocus:false,buildRendering:function(){this.inherited(arguments);dom.setSelectable(this.containerNode,false);},startup:function(){this.inherited(arguments);var n=this.domNode;this.defer(function(){n.className=n.className;},1);},_setCloseButtonAttr:function(disp){this._set("closeButton",disp);_aa3.toggle(this.domNode,"dijitClosable",disp);this.closeNode.style.display=disp?"":"none";if(disp){var _aa9=i18n.getLocalization("dijit","common");if(this.closeNode){_aa2.set(this.closeNode,"title",_aa9.itemClose);}}},_setDisabledAttr:function(_aaa){this.inherited(arguments);if(this.closeNode){if(_aaa){_aa2.remove(this.closeNode,"title");}else{var _aab=i18n.getLocalization("dijit","common");_aa2.set(this.closeNode,"title",_aab.itemClose);}}},_setLabelAttr:function(_aac){this.inherited(arguments);if(!this.showLabel&&!this.params.title){this.iconNode.alt=lang.trim(this.containerNode.innerText||this.containerNode.textContent||"");}}});if(has("dojo-bidi")){_aa8=_aa1("dijit.layout._TabButton",_aa8,{_setLabelAttr:function(_aad){this.inherited(arguments);this.applyTextDir(this.iconNode,this.iconNode.alt);}});}var _aae=_aa1("dijit.layout.TabController",_aa4,{baseClass:"dijitTabController",templateString:"<div role='tablist' data-dojo-attach-event='onkeydown:onkeydown'></div>",tabPosition:"top",buttonWidget:_aa8,buttonWidgetCloseClass:"dijitTabCloseButton",postCreate:function(){this.inherited(arguments);var _aaf=new Menu({id:this.id+"_Menu",ownerDocument:this.ownerDocument,dir:this.dir,lang:this.lang,textDir:this.textDir,targetNodeIds:[this.domNode],selector:function(node){return _aa3.contains(node,"dijitClosable")&&!_aa3.contains(node,"dijitTabDisabled");}});this.own(_aaf);var _ab0=i18n.getLocalization("dijit","common"),_ab1=this;_aaf.addChild(new _aa6({label:_ab0.itemClose,ownerDocument:this.ownerDocument,dir:this.dir,lang:this.lang,textDir:this.textDir,onClick:function(evt){var _ab2=_aa5.byNode(this.getParent().currentTarget);_ab1.onCloseButtonClick(_ab2.page);}}));}});_aae.TabButton=_aa8;return _aae;});},"dijit/layout/StackController":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-class","dojo/dom-construct","dojo/keys","dojo/_base/lang","dojo/on","dojo/topic","../focus","../registry","../_Widget","../_TemplatedMixin","../_Container","../form/ToggleButton","dojo/touch"],function(_ab3,_ab4,_ab5,_ab6,keys,lang,on,_ab7,_ab8,_ab9,_aba,_abb,_abc,_abd){var _abe=_ab4("dijit.layout._StackButton",_abd,{tabIndex:"-1",closeButton:false,_aria_attr:"aria-selected",buildRendering:function(evt){this.inherited(arguments);(this.focusNode||this.domNode).setAttribute("role","tab");}});var _abf=_ab4("dijit.layout.StackController",[_aba,_abb,_abc],{baseClass:"dijitStackController",templateString:"<span role='tablist' data-dojo-attach-event='onkeydown'></span>",containerId:"",buttonWidget:_abe,buttonWidgetCloseClass:"dijitStackCloseButton",pane2button:function(id){return _ab9.byId(this.id+"_"+id);},postCreate:function(){this.inherited(arguments);this.own(_ab7.subscribe(this.containerId+"-startup",lang.hitch(this,"onStartup")),_ab7.subscribe(this.containerId+"-addChild",lang.hitch(this,"onAddChild")),_ab7.subscribe(this.containerId+"-removeChild",lang.hitch(this,"onRemoveChild")),_ab7.subscribe(this.containerId+"-selectChild",lang.hitch(this,"onSelectChild")),_ab7.subscribe(this.containerId+"-containerKeyDown",lang.hitch(this,"onContainerKeyDown")));this.containerNode.dojoClick=true;this.own(on(this.containerNode,"click",lang.hitch(this,function(evt){var _ac0=_ab9.getEnclosingWidget(evt.target);if(_ac0!=this.containerNode&&!_ac0.disabled&&_ac0.page){for(var _ac1=evt.target;_ac1!==this.containerNode;_ac1=_ac1.parentNode){if(_ab5.contains(_ac1,this.buttonWidgetCloseClass)){this.onCloseButtonClick(_ac0.page);break;}else{if(_ac1==_ac0.domNode){this.onButtonClick(_ac0.page);break;}}}}})));},onStartup:function(info){this.textDir=info.textDir;_ab3.forEach(info.children,this.onAddChild,this);if(info.selected){this.onSelectChild(info.selected);}var _ac2=_ab9.byId(this.containerId).containerNode,_ac3=lang.hitch(this,"pane2button"),_ac4={"title":"label","showtitle":"showLabel","iconclass":"iconClass","closable":"closeButton","tooltip":"title","disabled":"disabled","textdir":"textdir"},_ac5=function(attr,_ac6){return on(_ac2,"attrmodified-"+attr,function(evt){var _ac7=_ac3(evt.detail&&evt.detail.widget&&evt.detail.widget.id);if(_ac7){_ac7.set(_ac6,evt.detail.newValue);}});};for(var attr in _ac4){this.own(_ac5(attr,_ac4[attr]));}},destroy:function(_ac8){this.destroyDescendants(_ac8);this.inherited(arguments);},onAddChild:function(page,_ac9){var Cls=lang.isString(this.buttonWidget)?lang.getObject(this.buttonWidget):this.buttonWidget;var _aca=new Cls({id:this.id+"_"+page.id,name:this.id+"_"+page.id,label:page.title,disabled:page.disabled,ownerDocument:this.ownerDocument,dir:page.dir,lang:page.lang,textDir:page.textDir||this.textDir,showLabel:page.showTitle,iconClass:page.iconClass,closeButton:page.closable,title:page.tooltip,page:page});this.addChild(_aca,_ac9);page.controlButton=_aca;if(!this._currentChild){this.onSelectChild(page);}var _acb=page._wrapper.getAttribute("aria-labelledby")?page._wrapper.getAttribute("aria-labelledby")+" "+_aca.id:_aca.id;page._wrapper.removeAttribute("aria-label");page._wrapper.setAttribute("aria-labelledby",_acb);},onRemoveChild:function(page){if(this._currentChild===page){this._currentChild=null;}var _acc=this.pane2button(page.id);if(_acc){this.removeChild(_acc);_acc.destroy();}delete page.controlButton;},onSelectChild:function(page){if(!page){return;}if(this._currentChild){var _acd=this.pane2button(this._currentChild.id);_acd.set("checked",false);_acd.focusNode.setAttribute("tabIndex","-1");}var _ace=this.pane2button(page.id);_ace.set("checked",true);this._currentChild=page;_ace.focusNode.setAttribute("tabIndex","0");var _acf=_ab9.byId(this.containerId);},onButtonClick:function(page){var _ad0=this.pane2button(page.id);_ab8.focus(_ad0.focusNode);if(this._currentChild&&this._currentChild.id===page.id){_ad0.set("checked",true);}var _ad1=_ab9.byId(this.containerId);_ad1.selectChild(page);},onCloseButtonClick:function(page){var _ad2=_ab9.byId(this.containerId);_ad2.closeChild(page);if(this._currentChild){var b=this.pane2button(this._currentChild.id);if(b){_ab8.focus(b.focusNode||b.domNode);}}},adjacent:function(_ad3){if(!this.isLeftToRight()&&(!this.tabPosition||/top|bottom/.test(this.tabPosition))){_ad3=!_ad3;}var _ad4=this.getChildren();var idx=_ab3.indexOf(_ad4,this.pane2button(this._currentChild.id)),_ad5=_ad4[idx];var _ad6;do{idx=(idx+(_ad3?1:_ad4.length-1))%_ad4.length;_ad6=_ad4[idx];}while(_ad6.disabled&&_ad6!=_ad5);return _ad6;},onkeydown:function(e,_ad7){if(this.disabled||e.altKey){return;}var _ad8=null;if(e.ctrlKey||!e._djpage){switch(e.keyCode){case keys.LEFT_ARROW:case keys.UP_ARROW:if(!e._djpage){_ad8=false;}break;case keys.PAGE_UP:if(e.ctrlKey){_ad8=false;}break;case keys.RIGHT_ARROW:case keys.DOWN_ARROW:if(!e._djpage){_ad8=true;}break;case keys.PAGE_DOWN:if(e.ctrlKey){_ad8=true;}break;case keys.HOME:var _ad9=this.getChildren();for(var idx=0;idx<_ad9.length;idx++){var _ada=_ad9[idx];if(!_ada.disabled){this.onButtonClick(_ada.page);break;}}e.stopPropagation();e.preventDefault();break;case keys.END:var _ad9=this.getChildren();for(var idx=_ad9.length-1;idx>=0;idx--){var _ada=_ad9[idx];if(!_ada.disabled){this.onButtonClick(_ada.page);break;}}e.stopPropagation();e.preventDefault();break;case keys.DELETE:case "W".charCodeAt(0):if(this._currentChild.closable&&(e.keyCode==keys.DELETE||e.ctrlKey)){this.onCloseButtonClick(this._currentChild);e.stopPropagation();e.preventDefault();}break;case keys.TAB:if(e.ctrlKey){this.onButtonClick(this.adjacent(!e.shiftKey).page);e.stopPropagation();e.preventDefault();}break;}if(_ad8!==null){this.onButtonClick(this.adjacent(_ad8).page);e.stopPropagation();e.preventDefault();}}},onContainerKeyDown:function(info){info.e._djpage=info.page;this.onkeydown(info.e);}});_abf.StackButton=_abe;return _abf;});},"dijit/Menu":function(){define(["require","dojo/_base/array","dojo/_base/declare","dojo/dom","dojo/dom-attr","dojo/dom-geometry","dojo/dom-style","dojo/keys","dojo/_base/lang","dojo/on","dojo/sniff","dojo/_base/window","dojo/window","./popup","./DropDownMenu","dojo/ready"],function(_adb,_adc,_add,dom,_ade,_adf,_ae0,keys,lang,on,has,win,_ae1,pm,_ae2,_ae3){if(has("dijit-legacy-requires")){_ae3(0,function(){var _ae4=["dijit/MenuItem","dijit/PopupMenuItem","dijit/CheckedMenuItem","dijit/MenuSeparator"];_adb(_ae4);});}return _add("dijit.Menu",_ae2,{constructor:function(){this._bindings=[];},targetNodeIds:[],selector:"",contextMenuForWindow:false,leftClickToOpen:false,refocus:true,postCreate:function(){if(this.contextMenuForWindow){this.bindDomNode(this.ownerDocumentBody);}else{_adc.forEach(this.targetNodeIds,this.bindDomNode,this);}this.inherited(arguments);},_iframeContentWindow:function(_ae5){return _ae1.get(this._iframeContentDocument(_ae5))||this._iframeContentDocument(_ae5)["__parent__"]||(_ae5.name&&document.frames[_ae5.name])||null;},_iframeContentDocument:function(_ae6){return _ae6.contentDocument||(_ae6.contentWindow&&_ae6.contentWindow.document)||(_ae6.name&&document.frames[_ae6.name]&&document.frames[_ae6.name].document)||null;},bindDomNode:function(node){node=dom.byId(node,this.ownerDocument);var cn;if(node.tagName.toLowerCase()=="iframe"){var _ae7=node,_ae8=this._iframeContentWindow(_ae7);cn=win.body(_ae8.document);}else{cn=(node==win.body(this.ownerDocument)?this.ownerDocument.documentElement:node);}var _ae9={node:node,iframe:_ae7};_ade.set(node,"_dijitMenu"+this.id,this._bindings.push(_ae9));var _aea=lang.hitch(this,function(cn){var _aeb=this.selector,_aec=_aeb?function(_aed){return on.selector(_aeb,_aed);}:function(_aee){return _aee;},self=this;return [on(cn,_aec(this.leftClickToOpen?"click":"contextmenu"),function(evt){evt.stopPropagation();evt.preventDefault();if((new Date()).getTime()<self._lastKeyDown+500){return;}self._scheduleOpen(this,_ae7,{x:evt.pageX,y:evt.pageY},evt.target);}),on(cn,_aec("keydown"),function(evt){if(evt.keyCode==93||(evt.shiftKey&&evt.keyCode==keys.F10)||(self.leftClickToOpen&&evt.keyCode==keys.SPACE)){evt.stopPropagation();evt.preventDefault();self._scheduleOpen(this,_ae7,null,evt.target);self._lastKeyDown=(new Date()).getTime();}})];});_ae9.connects=cn?_aea(cn):[];if(_ae7){_ae9.onloadHandler=lang.hitch(this,function(){var _aef=this._iframeContentWindow(_ae7),cn=win.body(_aef.document);_ae9.connects=_aea(cn);});if(_ae7.addEventListener){_ae7.addEventListener("load",_ae9.onloadHandler,false);}else{_ae7.attachEvent("onload",_ae9.onloadHandler);}}},unBindDomNode:function(_af0){var node;try{node=dom.byId(_af0,this.ownerDocument);}catch(e){return;}var _af1="_dijitMenu"+this.id;if(node&&_ade.has(node,_af1)){var bid=_ade.get(node,_af1)-1,b=this._bindings[bid],h;while((h=b.connects.pop())){h.remove();}var _af2=b.iframe;if(_af2){if(_af2.removeEventListener){_af2.removeEventListener("load",b.onloadHandler,false);}else{_af2.detachEvent("onload",b.onloadHandler);}}_ade.remove(node,_af1);delete this._bindings[bid];}},_scheduleOpen:function(_af3,_af4,_af5,_af6){if(!this._openTimer){this._openTimer=this.defer(function(){delete this._openTimer;this._openMyself({target:_af6,delegatedTarget:_af3,iframe:_af4,coords:_af5});},1);}},_openMyself:function(args){var _af7=args.target,_af8=args.iframe,_af9=args.coords,_afa=!_af9;this.currentTarget=args.delegatedTarget;if(_af9){if(_af8){var ifc=_adf.position(_af8,true),_afb=this._iframeContentWindow(_af8),_afc=_adf.docScroll(_afb.document);var cs=_ae0.getComputedStyle(_af8),tp=_ae0.toPixelValue,left=(has("ie")&&has("quirks")?0:tp(_af8,cs.paddingLeft))+(has("ie")&&has("quirks")?tp(_af8,cs.borderLeftWidth):0),top=(has("ie")&&has("quirks")?0:tp(_af8,cs.paddingTop))+(has("ie")&&has("quirks")?tp(_af8,cs.borderTopWidth):0);_af9.x+=ifc.x+left-_afc.x;_af9.y+=ifc.y+top-_afc.y;}}else{_af9=_adf.position(_af7,true);_af9.x+=10;_af9.y+=10;}var self=this;var _afd=this._focusManager.get("prevNode");var _afe=this._focusManager.get("curNode");var _aff=!_afe||(dom.isDescendant(_afe,this.domNode))?_afd:_afe;function _b00(){if(self.refocus&&_aff){_aff.focus();}pm.close(self);};pm.open({popup:this,x:_af9.x,y:_af9.y,onExecute:_b00,onCancel:_b00,orient:this.isLeftToRight()?"L":"R"});this.focus();if(!_afa){this.defer(function(){this._cleanUp(true);});}this._onBlur=function(){this.inherited("_onBlur",arguments);pm.close(this);};},destroy:function(){_adc.forEach(this._bindings,function(b){if(b){this.unBindDomNode(b.node);}},this);this.inherited(arguments);}});});},"dijit/layout/ScrollingTabController":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/_base/fx","dojo/_base/lang","dojo/on","dojo/query","dojo/sniff","../registry","dojo/text!./templates/ScrollingTabController.html","dojo/text!./templates/_ScrollingTabControllerButton.html","./TabController","./utils","../_WidgetsInTemplateMixin","../Menu","../MenuItem","../form/Button","../_HasDropDown","dojo/NodeList-dom","../a11yclick"],function(_b01,_b02,_b03,_b04,_b05,fx,lang,on,_b06,has,_b07,_b08,_b09,_b0a,_b0b,_b0c,Menu,_b0d,_b0e,_b0f){var _b10=_b02("dijit.layout.ScrollingTabController",[_b0a,_b0c],{baseClass:"dijitTabController dijitScrollingTabController",templateString:_b08,useMenu:true,useSlider:true,tabStripClass:"",_minScroll:5,_setClassAttr:{node:"containerNode",type:"class"},buildRendering:function(){this.inherited(arguments);var n=this.domNode;this.scrollNode=this.tablistWrapper;this._initButtons();if(!this.tabStripClass){this.tabStripClass="dijitTabContainer"+this.tabPosition.charAt(0).toUpperCase()+this.tabPosition.substr(1).replace(/-.*/,"")+"None";_b03.add(n,"tabStrip-disabled");}_b03.add(this.tablistWrapper,this.tabStripClass);},onStartup:function(){this.inherited(arguments);_b05.set(this.domNode,"visibility","");this._postStartup=true;this.own(on(this.containerNode,"attrmodified-label, attrmodified-iconclass",lang.hitch(this,function(evt){if(this._dim){this.resize(this._dim);}})));},onAddChild:function(page,_b11){this.inherited(arguments);_b05.set(this.containerNode,"width",(_b05.get(this.containerNode,"width")+200)+"px");},onRemoveChild:function(page,_b12){var _b13=this.pane2button(page.id);if(this._selectedTab===_b13.domNode){this._selectedTab=null;}this.inherited(arguments);},_initButtons:function(){this._btnWidth=0;this._buttons=_b06("> .tabStripButton",this.domNode).filter(function(btn){if((this.useMenu&&btn==this._menuBtn.domNode)||(this.useSlider&&(btn==this._rightBtn.domNode||btn==this._leftBtn.domNode))){this._btnWidth+=_b04.getMarginSize(btn).w;return true;}else{_b05.set(btn,"display","none");return false;}},this);},_getTabsWidth:function(){var _b14=this.getChildren();if(_b14.length){var _b15=_b14[this.isLeftToRight()?0:_b14.length-1].domNode,_b16=_b14[this.isLeftToRight()?_b14.length-1:0].domNode;return _b16.offsetLeft+_b16.offsetWidth-_b15.offsetLeft;}else{return 0;}},_enableBtn:function(_b17){var _b18=this._getTabsWidth();_b17=_b17||_b05.get(this.scrollNode,"width");return _b18>0&&_b17<_b18;},resize:function(dim){this._dim=dim;this.scrollNode.style.height="auto";var cb=this._contentBox=_b0b.marginBox2contentBox(this.domNode,{h:0,w:dim.w});cb.h=this.scrollNode.offsetHeight;_b04.setContentSize(this.domNode,cb);var _b19=this._enableBtn(this._contentBox.w);this._buttons.style("display",_b19?"":"none");this._leftBtn.region="left";this._rightBtn.region="right";this._menuBtn.region=this.isLeftToRight()?"right":"left";_b0b.layoutChildren(this.domNode,this._contentBox,[this._menuBtn,this._leftBtn,this._rightBtn,{domNode:this.scrollNode,region:"center"}]);if(this._selectedTab){if(this._anim&&this._anim.status()=="playing"){this._anim.stop();}this.scrollNode.scrollLeft=this._convertToScrollLeft(this._getScrollForSelectedTab());}this._setButtonClass(this._getScroll());this._postResize=true;return {h:this._contentBox.h,w:dim.w};},_getScroll:function(){return (this.isLeftToRight()||has("ie")<8||(has("trident")&&has("quirks"))||has("webkit"))?this.scrollNode.scrollLeft:_b05.get(this.containerNode,"width")-_b05.get(this.scrollNode,"width")+(has("trident")||has("edge")?-1:1)*this.scrollNode.scrollLeft;},_convertToScrollLeft:function(val){if(this.isLeftToRight()||has("ie")<8||(has("trident")&&has("quirks"))||has("webkit")){return val;}else{var _b1a=_b05.get(this.containerNode,"width")-_b05.get(this.scrollNode,"width");return (has("trident")||has("edge")?-1:1)*(val-_b1a);}},onSelectChild:function(page,_b1b){var tab=this.pane2button(page.id);if(!tab){return;}var node=tab.domNode;if(node!=this._selectedTab){this._selectedTab=node;if(this._postResize){var sl=this._getScroll();if(sl>node.offsetLeft||sl+_b05.get(this.scrollNode,"width")<node.offsetLeft+_b05.get(node,"width")){var anim=this.createSmoothScroll();if(_b1b){anim.onEnd=function(){tab.focus();};}anim.play();}else{if(_b1b){tab.focus();}}}}this.inherited(arguments);},_getScrollBounds:function(){var _b1c=this.getChildren(),_b1d=_b05.get(this.scrollNode,"width"),_b1e=_b05.get(this.containerNode,"width"),_b1f=_b1e-_b1d,_b20=this._getTabsWidth();if(_b1c.length&&_b20>_b1d){return {min:this.isLeftToRight()?0:_b1c[_b1c.length-1].domNode.offsetLeft,max:this.isLeftToRight()?(_b1c[_b1c.length-1].domNode.offsetLeft+_b1c[_b1c.length-1].domNode.offsetWidth)-_b1d:_b1f};}else{var _b21=this.isLeftToRight()?0:_b1f;return {min:_b21,max:_b21};}},_getScrollForSelectedTab:function(){var w=this.scrollNode,n=this._selectedTab,_b22=_b05.get(this.scrollNode,"width"),_b23=this._getScrollBounds();var pos=(n.offsetLeft+_b05.get(n,"width")/2)-_b22/2;pos=Math.min(Math.max(pos,_b23.min),_b23.max);return pos;},createSmoothScroll:function(x){if(arguments.length>0){var _b24=this._getScrollBounds();x=Math.min(Math.max(x,_b24.min),_b24.max);}else{x=this._getScrollForSelectedTab();}if(this._anim&&this._anim.status()=="playing"){this._anim.stop();}var self=this,w=this.scrollNode,anim=new fx.Animation({beforeBegin:function(){if(this.curve){delete this.curve;}var oldS=w.scrollLeft,newS=self._convertToScrollLeft(x);anim.curve=new fx._Line(oldS,newS);},onAnimate:function(val){w.scrollLeft=val;}});this._anim=anim;this._setButtonClass(x);return anim;},_getBtnNode:function(e){var n=e.target;while(n&&!_b03.contains(n,"tabStripButton")){n=n.parentNode;}return n;},doSlideRight:function(e){this.doSlide(1,this._getBtnNode(e));},doSlideLeft:function(e){this.doSlide(-1,this._getBtnNode(e));},doSlide:function(_b25,node){if(node&&_b03.contains(node,"dijitTabDisabled")){return;}var _b26=_b05.get(this.scrollNode,"width");var d=(_b26*0.75)*_b25;var to=this._getScroll()+d;this._setButtonClass(to);this.createSmoothScroll(to).play();},_setButtonClass:function(_b27){var _b28=this._getScrollBounds();this._leftBtn.set("disabled",_b27<=_b28.min);this._rightBtn.set("disabled",_b27>=_b28.max);}});var _b29=_b02("dijit.layout._ScrollingTabControllerButtonMixin",null,{baseClass:"dijitTab tabStripButton",templateString:_b09,tabIndex:"",isFocusable:function(){return false;}});_b02("dijit.layout._ScrollingTabControllerButton",[_b0e,_b29]);_b02("dijit.layout._ScrollingTabControllerMenuButton",[_b0e,_b0f,_b29],{containerId:"",tabIndex:"-1",isLoaded:function(){return false;},loadDropDown:function(_b2a){this.dropDown=new Menu({id:this.containerId+"_menu",ownerDocument:this.ownerDocument,dir:this.dir,lang:this.lang,textDir:this.textDir});var _b2b=_b07.byId(this.containerId);_b01.forEach(_b2b.getChildren(),function(page){var _b2c=new _b0d({id:page.id+"_stcMi",label:page.title,iconClass:page.iconClass,disabled:page.disabled,ownerDocument:this.ownerDocument,dir:page.dir,lang:page.lang,textDir:page.textDir||_b2b.textDir,onClick:function(){_b2b.selectChild(page);}});this.dropDown.addChild(_b2c);},this);_b2a();},closeDropDown:function(_b2d){this.inherited(arguments);if(this.dropDown){this._popupStateNode.removeAttribute("aria-owns");this.dropDown.destroyRecursive();delete this.dropDown;}}});return _b10;});},"dijit/ProgressBar":function(){define(["require","dojo/_base/declare","dojo/dom-class","dojo/_base/lang","dojo/number","./_Widget","./_TemplatedMixin","dojo/text!./templates/ProgressBar.html"],function(_b2e,_b2f,_b30,lang,_b31,_b32,_b33,_b34){return _b2f("dijit.ProgressBar",[_b32,_b33],{progress:"0",value:"",maximum:100,places:0,indeterminate:false,label:"",name:"",templateString:_b34,_indeterminateHighContrastImagePath:_b2e.toUrl("./themes/a11y/indeterminate_progress.gif"),postMixInProperties:function(){this.inherited(arguments);if(!(this.params&&"value" in this.params)){this.value=this.indeterminate?Infinity:this.progress;}},buildRendering:function(){this.inherited(arguments);this.indeterminateHighContrastImage.setAttribute("src",this._indeterminateHighContrastImagePath.toString());this.update();},_setDirAttr:function(val){var rtl=val.toLowerCase()=="rtl";_b30.toggle(this.domNode,"dijitProgressBarRtl",rtl);_b30.toggle(this.domNode,"dijitProgressBarIndeterminateRtl",this.indeterminate&&rtl);this.inherited(arguments);},update:function(_b35){lang.mixin(this,_b35||{});var tip=this.internalProgress,ap=this.domNode;var _b36=1;if(this.indeterminate){ap.removeAttribute("aria-valuenow");}else{if(String(this.progress).indexOf("%")!=-1){_b36=Math.min(parseFloat(this.progress)/100,1);this.progress=_b36*this.maximum;}else{this.progress=Math.min(this.progress,this.maximum);_b36=this.maximum?this.progress/this.maximum:0;}ap.setAttribute("aria-valuenow",this.progress);}ap.setAttribute("aria-labelledby",this.labelNode.id);ap.setAttribute("aria-valuemin",0);ap.setAttribute("aria-valuemax",this.maximum);this.labelNode.innerHTML=this.report(_b36);_b30.toggle(this.domNode,"dijitProgressBarIndeterminate",this.indeterminate);_b30.toggle(this.domNode,"dijitProgressBarIndeterminateRtl",this.indeterminate&&!this.isLeftToRight());tip.style.width=(_b36*100)+"%";this.onChange();},_setValueAttr:function(v){this._set("value",v);if(v==Infinity){this.update({indeterminate:true});}else{this.update({indeterminate:false,progress:v});}},_setLabelAttr:function(_b37){this._set("label",_b37);this.update();},_setIndeterminateAttr:function(_b38){this._set("indeterminate",_b38);this.update();},report:function(_b39){return this.label?this.label:(this.indeterminate?"&#160;":_b31.format(_b39,{type:"percent",places:this.places,locale:this.lang}));},onChange:function(){}});});},"dojo/number":function(){define(["./_base/lang","./i18n","./i18n!./cldr/nls/number","./string","./regexp"],function(lang,i18n,_b3a,_b3b,_b3c){var _b3d={};lang.setObject("dojo.number",_b3d);_b3d.format=function(_b3e,_b3f){_b3f=lang.mixin({},_b3f||{});var _b40=i18n.normalizeLocale(_b3f.locale),_b41=i18n.getLocalization("dojo.cldr","number",_b40);_b3f.customs=_b41;var _b42=_b3f.pattern||_b41[(_b3f.type||"decimal")+"Format"];if(isNaN(_b3e)||Math.abs(_b3e)==Infinity){return null;}return _b3d._applyPattern(_b3e,_b42,_b3f);};_b3d._numberPatternRE=/[#0,]*[#0](?:\.0*#*)?/;_b3d._applyPattern=function(_b43,_b44,_b45){_b45=_b45||{};var _b46=_b45.customs.group,_b47=_b45.customs.decimal,_b48=_b44.split(";"),_b49=_b48[0];_b44=_b48[(_b43<0)?1:0]||("-"+_b49);if(_b44.indexOf("%")!=-1){_b43*=100;}else{if(_b44.indexOf("‰")!=-1){_b43*=1000;}else{if(_b44.indexOf("¤")!=-1){_b46=_b45.customs.currencyGroup||_b46;_b47=_b45.customs.currencyDecimal||_b47;_b44=_b44.replace(/([\s\xa0\u202f]*)(\u00a4{1,3})([\s\xa0\u202f]*)/,function(_b4a,_b4b,_b4c,_b4d){var prop=["symbol","currency","displayName"][_b4c.length-1],_b4e=_b45[prop]||_b45.currency||"";if(!_b4e){return "";}return _b4b+_b4e+_b4d;});}else{if(_b44.indexOf("E")!=-1){throw new Error("exponential notation not supported");}}}}var _b4f=_b3d._numberPatternRE;var _b50=_b49.match(_b4f);if(!_b50){throw new Error("unable to find a number expression in pattern: "+_b44);}if(_b45.fractional===false){_b45.places=0;}return _b44.replace(_b4f,_b3d._formatAbsolute(_b43,_b50[0],{decimal:_b47,group:_b46,places:_b45.places,round:_b45.round}));};_b3d.round=function(_b51,_b52,_b53){var _b54=10/(_b53||10);return (_b54*+_b51).toFixed(_b52)/_b54;};if((0.9).toFixed()==0){var _b55=_b3d.round;_b3d.round=function(v,p,m){var d=Math.pow(10,-p||0),a=Math.abs(v);if(!v||a>=d){d=0;}else{a/=d;if(a<0.5||a>=0.95){d=0;}}return _b55(v,p,m)+(v>0?d:-d);};}_b3d._formatAbsolute=function(_b56,_b57,_b58){_b58=_b58||{};if(_b58.places===true){_b58.places=0;}if(_b58.places===Infinity){_b58.places=6;}var _b59=_b57.split("."),_b5a=typeof _b58.places=="string"&&_b58.places.indexOf(","),_b5b=_b58.places;if(_b5a){_b5b=_b58.places.substring(_b5a+1);}else{if(!(_b5b>=0)){_b5b=(_b59[1]||[]).length;}}if(!(_b58.round<0)){_b56=_b3d.round(_b56,_b5b,_b58.round);}var _b5c=String(Math.abs(_b56)).split("."),_b5d=_b5c[1]||"";if(_b59[1]||_b58.places){if(_b5a){_b58.places=_b58.places.substring(0,_b5a);}var pad=_b58.places!==undefined?_b58.places:(_b59[1]&&_b59[1].lastIndexOf("0")+1);if(pad>_b5d.length){_b5c[1]=_b3b.pad(_b5d,pad,"0",true);}if(_b5b<_b5d.length){_b5c[1]=_b5d.substr(0,_b5b);}}else{if(_b5c[1]){_b5c.pop();}}var _b5e=_b59[0].replace(",","");pad=_b5e.indexOf("0");if(pad!=-1){pad=_b5e.length-pad;if(pad>_b5c[0].length){_b5c[0]=_b3b.pad(_b5c[0],pad);}if(_b5e.indexOf("#")==-1){_b5c[0]=_b5c[0].substr(_b5c[0].length-pad);}}var _b5f=_b59[0].lastIndexOf(","),_b60,_b61;if(_b5f!=-1){_b60=_b59[0].length-_b5f-1;var _b62=_b59[0].substr(0,_b5f);_b5f=_b62.lastIndexOf(",");if(_b5f!=-1){_b61=_b62.length-_b5f-1;}}var _b63=[];for(var _b64=_b5c[0];_b64;){var off=_b64.length-_b60;_b63.push((off>0)?_b64.substr(off):_b64);_b64=(off>0)?_b64.slice(0,off):"";if(_b61){_b60=_b61;_b61=undefined;}}_b5c[0]=_b63.reverse().join(_b58.group||",");return _b5c.join(_b58.decimal||".");};_b3d.regexp=function(_b65){return _b3d._parseInfo(_b65).regexp;};_b3d._parseInfo=function(_b66){_b66=_b66||{};var _b67=i18n.normalizeLocale(_b66.locale),_b68=i18n.getLocalization("dojo.cldr","number",_b67),_b69=_b66.pattern||_b68[(_b66.type||"decimal")+"Format"],_b6a=_b68.group,_b6b=_b68.decimal,_b6c=1;if(_b69.indexOf("%")!=-1){_b6c/=100;}else{if(_b69.indexOf("‰")!=-1){_b6c/=1000;}else{var _b6d=_b69.indexOf("¤")!=-1;if(_b6d){_b6a=_b68.currencyGroup||_b6a;_b6b=_b68.currencyDecimal||_b6b;}}}var _b6e=_b69.split(";");if(_b6e.length==1){_b6e.push("-"+_b6e[0]);}var re=_b3c.buildGroupRE(_b6e,function(_b6f){_b6f="(?:"+_b3c.escapeString(_b6f,".")+")";return _b6f.replace(_b3d._numberPatternRE,function(_b70){var _b71={signed:false,separator:_b66.strict?_b6a:[_b6a,""],fractional:_b66.fractional,decimal:_b6b,exponent:false},_b72=_b70.split("."),_b73=_b66.places;if(_b72.length==1&&_b6c!=1){_b72[1]="###";}if(_b72.length==1||_b73===0){_b71.fractional=false;}else{if(_b73===undefined){_b73=_b66.pattern?_b72[1].lastIndexOf("0")+1:Infinity;}if(_b73&&_b66.fractional==undefined){_b71.fractional=true;}if(!_b66.places&&(_b73<_b72[1].length)){_b73+=","+_b72[1].length;}_b71.places=_b73;}var _b74=_b72[0].split(",");if(_b74.length>1){_b71.groupSize=_b74.pop().length;if(_b74.length>1){_b71.groupSize2=_b74.pop().length;}}return "("+_b3d._realNumberRegexp(_b71)+")";});},true);if(_b6d){re=re.replace(/([\s\xa0\u202f]*)(\u00a4{1,3})([\s\xa0\u202f]*)/g,function(_b75,_b76,_b77,_b78){var prop=["symbol","currency","displayName"][_b77.length-1],_b79=_b3c.escapeString(_b66[prop]||_b66.currency||"");if(!_b79){return "";}_b76=_b76?"[\\s\\xa0\\u202f]":"";_b78=_b78?"[\\s\\xa0\\u202f]":"";if(!_b66.strict){if(_b76){_b76+="*";}if(_b78){_b78+="*";}return "(?:"+_b76+_b79+_b78+")?";}return _b76+_b79+_b78;});}return {regexp:re.replace(/[\xa0\u202f ]/g,"[\\s\\xa0\\u202f]"),group:_b6a,decimal:_b6b,factor:_b6c};};_b3d.parse=function(_b7a,_b7b){var info=_b3d._parseInfo(_b7b),_b7c=(new RegExp("^"+info.regexp+"$")).exec(_b7a);if(!_b7c){return NaN;}var _b7d=_b7c[1];if(!_b7c[1]){if(!_b7c[2]){return NaN;}_b7d=_b7c[2];info.factor*=-1;}_b7d=_b7d.replace(new RegExp("["+info.group+"\\s\\xa0\\u202f"+"]","g"),"").replace(info.decimal,".");return _b7d*info.factor;};_b3d._realNumberRegexp=function(_b7e){_b7e=_b7e||{};if(!("places" in _b7e)){_b7e.places=Infinity;}if(typeof _b7e.decimal!="string"){_b7e.decimal=".";}if(!("fractional" in _b7e)||/^0/.test(_b7e.places)){_b7e.fractional=[true,false];}if(!("exponent" in _b7e)){_b7e.exponent=[true,false];}if(!("eSigned" in _b7e)){_b7e.eSigned=[true,false];}var _b7f=_b3d._integerRegexp(_b7e),_b80=_b3c.buildGroupRE(_b7e.fractional,function(q){var re="";if(q&&(_b7e.places!==0)){re="\\"+_b7e.decimal;if(_b7e.places==Infinity){re="(?:"+re+"\\d+)?";}else{re+="\\d{"+_b7e.places+"}";}}return re;},true);var _b81=_b3c.buildGroupRE(_b7e.exponent,function(q){if(q){return "([eE]"+_b3d._integerRegexp({signed:_b7e.eSigned})+")";}return "";});var _b82=_b7f+_b80;if(_b80){_b82="(?:(?:"+_b82+")|(?:"+_b80+"))";}return _b82+_b81;};_b3d._integerRegexp=function(_b83){_b83=_b83||{};if(!("signed" in _b83)){_b83.signed=[true,false];}if(!("separator" in _b83)){_b83.separator="";}else{if(!("groupSize" in _b83)){_b83.groupSize=3;}}var _b84=_b3c.buildGroupRE(_b83.signed,function(q){return q?"[-+]":"";},true);var _b85=_b3c.buildGroupRE(_b83.separator,function(sep){if(!sep){return "(?:\\d+)";}sep=_b3c.escapeString(sep);if(sep==" "){sep="\\s";}else{if(sep==" "){sep="\\s\\xa0";}else{if(sep==" "){sep="\\s\\u202f";}}}var grp=_b83.groupSize,grp2=_b83.groupSize2;if(grp2){var _b86="(?:0|[1-9]\\d{0,"+(grp2-1)+"}(?:["+sep+"]\\d{"+grp2+"})*["+sep+"]\\d{"+grp+"})";return ((grp-grp2)>0)?"(?:"+_b86+"|(?:0|[1-9]\\d{0,"+(grp-1)+"}))":_b86;}return "(?:0|[1-9]\\d{0,"+(grp-1)+"}(?:["+sep+"]\\d{"+grp+"})*)";},true);return _b84+_b85;};return _b3d;});},"dijit/Toolbar":function(){define(["require","dojo/_base/declare","dojo/has","dojo/keys","dojo/ready","./_Widget","./_KeyNavContainer","./_TemplatedMixin"],function(_b87,_b88,has,keys,_b89,_b8a,_b8b,_b8c){if(has("dijit-legacy-requires")){_b89(0,function(){var _b8d=["dijit/ToolbarSeparator"];_b87(_b8d);});}return _b88("dijit.Toolbar",[_b8a,_b8c,_b8b],{templateString:"<div class=\"dijit\" role=\"toolbar\" tabIndex=\"${tabIndex}\" data-dojo-attach-point=\"containerNode\">"+"</div>",baseClass:"dijitToolbar",_onLeftArrow:function(){this.focusPrev();},_onRightArrow:function(){this.focusNext();}});});},"dijit/TooltipDialog":function(){define(["dojo/_base/declare","dojo/dom-class","dojo/has","dojo/keys","dojo/_base/lang","dojo/on","./focus","./layout/ContentPane","./_DialogMixin","./form/_FormMixin","./_TemplatedMixin","dojo/text!./templates/TooltipDialog.html","./main"],function(_b8e,_b8f,has,keys,lang,on,_b90,_b91,_b92,_b93,_b94,_b95,_b96){var _b97=_b8e("dijit.TooltipDialog",[_b91,_b94,_b93,_b92],{title:"",doLayout:false,autofocus:true,baseClass:"dijitTooltipDialog",_firstFocusItem:null,_lastFocusItem:null,templateString:_b95,_setTitleAttr:"containerNode",postCreate:function(){this.inherited(arguments);this.own(on(this.domNode,"keydown",lang.hitch(this,"_onKey")));},orient:function(node,_b98,_b99){var newC={"MR-ML":"dijitTooltipRight","ML-MR":"dijitTooltipLeft","TM-BM":"dijitTooltipAbove","BM-TM":"dijitTooltipBelow","BL-TL":"dijitTooltipBelow dijitTooltipABLeft","TL-BL":"dijitTooltipAbove dijitTooltipABLeft","BR-TR":"dijitTooltipBelow dijitTooltipABRight","TR-BR":"dijitTooltipAbove dijitTooltipABRight","BR-BL":"dijitTooltipRight","BL-BR":"dijitTooltipLeft","BR-TL":"dijitTooltipBelow dijitTooltipABLeft","BL-TR":"dijitTooltipBelow dijitTooltipABRight","TL-BR":"dijitTooltipAbove dijitTooltipABRight","TR-BL":"dijitTooltipAbove dijitTooltipABLeft"}[_b98+"-"+_b99];_b8f.replace(this.domNode,newC,this._currentOrientClass||"");this._currentOrientClass=newC;},focus:function(){this._getFocusItems();_b90.focus(this._firstFocusItem);},onOpen:function(pos){this.orient(this.domNode,pos.aroundCorner,pos.corner);var _b9a=pos.aroundNodePos;if(pos.corner.charAt(0)=="M"&&pos.aroundCorner.charAt(0)=="M"){this.connectorNode.style.top=_b9a.y+((_b9a.h-this.connectorNode.offsetHeight)>>1)-pos.y+"px";this.connectorNode.style.left="";}else{if(pos.corner.charAt(1)=="M"&&pos.aroundCorner.charAt(1)=="M"){this.connectorNode.style.left=_b9a.x+((_b9a.w-this.connectorNode.offsetWidth)>>1)-pos.x+"px";}}this._onShow();},onClose:function(){this.onHide();},_onKey:function(evt){if(evt.keyCode==keys.ESCAPE){this.defer("onCancel");evt.stopPropagation();evt.preventDefault();}else{if(evt.keyCode==keys.TAB){var node=evt.target;this._getFocusItems();if(this._firstFocusItem==this._lastFocusItem){evt.stopPropagation();evt.preventDefault();}else{if(node==this._firstFocusItem&&evt.shiftKey){_b90.focus(this._lastFocusItem);evt.stopPropagation();evt.preventDefault();}else{if(node==this._lastFocusItem&&!evt.shiftKey){_b90.focus(this._firstFocusItem);evt.stopPropagation();evt.preventDefault();}else{evt.stopPropagation();}}}}}}});if(has("dojo-bidi")){_b97.extend({_setTitleAttr:function(_b9b){this.containerNode.title=(this.textDir&&this.enforceTextDirWithUcc)?this.enforceTextDirWithUcc(null,_b9b):_b9b;this._set("title",_b9b);},_setTextDirAttr:function(_b9c){if(!this._created||this.textDir!=_b9c){this._set("textDir",_b9c);if(this.textDir&&this.title){this.containerNode.title=this.enforceTextDirWithUcc(null,this.title);}}}});}return _b97;});},"dijit/Tree":function(){define(["dojo/_base/array","dojo/aspect","dojo/cookie","dojo/_base/declare","dojo/Deferred","dojo/promise/all","dojo/dom","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/errors/create","dojo/fx","dojo/has","dojo/_base/kernel","dojo/keys","dojo/_base/lang","dojo/on","dojo/topic","dojo/touch","dojo/when","./a11yclick","./focus","./registry","./_base/manager","./_Widget","./_TemplatedMixin","./_Container","./_Contained","./_CssStateMixin","./_KeyNavMixin","dojo/text!./templates/TreeNode.html","dojo/text!./templates/Tree.html","./tree/TreeStoreModel","./tree/ForestStoreModel","./tree/_dndSelector","dojo/query!css2"],function(_b9d,_b9e,_b9f,_ba0,_ba1,all,dom,_ba2,_ba3,_ba4,_ba5,_ba6,has,_ba7,keys,lang,on,_ba8,_ba9,when,_baa,_bab,_bac,_bad,_bae,_baf,_bb0,_bb1,_bb2,_bb3,_bb4,_bb5,_bb6,_bb7,_bb8){function _bb9(d){return lang.delegate(d.promise||d,{addCallback:function(_bba){this.then(_bba);},addErrback:function(_bbb){this.otherwise(_bbb);}});};var _bbc=_ba0("dijit._TreeNode",[_bae,_baf,_bb0,_bb1,_bb2],{item:null,isTreeNode:true,label:"",_setLabelAttr:function(val){this.labelNode[this.labelType=="html"?"innerHTML":"innerText" in this.labelNode?"innerText":"textContent"]=val;this._set("label",val);if(has("dojo-bidi")){this.applyTextDir(this.labelNode);}},labelType:"text",isExpandable:null,isExpanded:false,state:"NotLoaded",templateString:_bb4,baseClass:"dijitTreeNode",cssStateNodes:{rowNode:"dijitTreeRow"},_setTooltipAttr:{node:"rowNode",type:"attribute",attribute:"title"},buildRendering:function(){this.inherited(arguments);this._setExpando();this._updateItemClasses(this.item);if(this.isExpandable){this.labelNode.setAttribute("aria-expanded",this.isExpanded);}this.setSelected(false);},_setIndentAttr:function(_bbd){var _bbe=(Math.max(_bbd,0)*this.tree._nodePixelIndent)+"px";_ba4.set(this.domNode,"backgroundPosition",_bbe+" 0px");_ba4.set(this.rowNode,this.isLeftToRight()?"paddingLeft":"paddingRight",_bbe);_b9d.forEach(this.getChildren(),function(_bbf){_bbf.set("indent",_bbd+1);});this._set("indent",_bbd);},markProcessing:function(){this.state="Loading";this._setExpando(true);},unmarkProcessing:function(){this._setExpando(false);},_updateItemClasses:function(item){var tree=this.tree,_bc0=tree.model;if(tree._v10Compat&&item===_bc0.root){item=null;}this._applyClassAndStyle(item,"icon","Icon");this._applyClassAndStyle(item,"label","Label");this._applyClassAndStyle(item,"row","Row");this.tree._startPaint(true);},_applyClassAndStyle:function(item,_bc1,_bc2){var _bc3="_"+_bc1+"Class";var _bc4=_bc1+"Node";var _bc5=this[_bc3];this[_bc3]=this.tree["get"+_bc2+"Class"](item,this.isExpanded);_ba2.replace(this[_bc4],this[_bc3]||"",_bc5||"");_ba4.set(this[_bc4],this.tree["get"+_bc2+"Style"](item,this.isExpanded)||{});},_updateLayout:function(){var _bc6=this.getParent(),_bc7=!_bc6||!_bc6.rowNode||_bc6.rowNode.style.display=="none";_ba2.toggle(this.domNode,"dijitTreeIsRoot",_bc7);_ba2.toggle(this.domNode,"dijitTreeIsLast",!_bc7&&!this.getNextSibling());},_setExpando:function(_bc8){var _bc9=["dijitTreeExpandoLoading","dijitTreeExpandoOpened","dijitTreeExpandoClosed","dijitTreeExpandoLeaf"],_bca=["*","-","+","*"],idx=_bc8?0:(this.isExpandable?(this.isExpanded?1:2):3);_ba2.replace(this.expandoNode,_bc9[idx],_bc9);this.expandoNodeText.innerHTML=_bca[idx];},expand:function(){if(this._expandDeferred){return _bb9(this._expandDeferred);}if(this._collapseDeferred){this._collapseDeferred.cancel();delete this._collapseDeferred;}this.isExpanded=true;this.labelNode.setAttribute("aria-expanded","true");if(this.tree.showRoot||this!==this.tree.rootNode){this.containerNode.setAttribute("role","group");}_ba2.add(this.contentNode,"dijitTreeContentExpanded");this._setExpando();this._updateItemClasses(this.item);if(this==this.tree.rootNode&&this.tree.showRoot){this.tree.domNode.setAttribute("aria-expanded","true");}var _bcb=_ba6.wipeIn({node:this.containerNode,duration:_bad.defaultDuration});var def=(this._expandDeferred=new _ba1(function(){_bcb.stop();}));_b9e.after(_bcb,"onEnd",function(){def.resolve(true);},true);_bcb.play();return _bb9(def);},collapse:function(){if(this._collapseDeferred){return _bb9(this._collapseDeferred);}if(this._expandDeferred){this._expandDeferred.cancel();delete this._expandDeferred;}this.isExpanded=false;this.labelNode.setAttribute("aria-expanded","false");if(this==this.tree.rootNode&&this.tree.showRoot){this.tree.domNode.setAttribute("aria-expanded","false");}_ba2.remove(this.contentNode,"dijitTreeContentExpanded");this._setExpando();this._updateItemClasses(this.item);var _bcc=_ba6.wipeOut({node:this.containerNode,duration:_bad.defaultDuration});var def=(this._collapseDeferred=new _ba1(function(){_bcc.stop();}));_b9e.after(_bcc,"onEnd",function(){def.resolve(true);},true);_bcc.play();return _bb9(def);},indent:0,setChildItems:function(_bcd){var tree=this.tree,_bce=tree.model,defs=[];var _bcf=tree.focusedChild;var _bd0=this.getChildren();_b9d.forEach(_bd0,function(_bd1){_bb0.prototype.removeChild.call(this,_bd1);},this);this.defer(function(){_b9d.forEach(_bd0,function(node){if(!node._destroyed&&!node.getParent()){tree.dndController.removeTreeNode(node);function _bd2(node){var id=_bce.getIdentity(node.item),ary=tree._itemNodesMap[id];if(ary.length==1){delete tree._itemNodesMap[id];}else{var _bd3=_b9d.indexOf(ary,node);if(_bd3!=-1){ary.splice(_bd3,1);}}_b9d.forEach(node.getChildren(),_bd2);};_bd2(node);if(tree.persist){var _bd4=_b9d.map(node.getTreePath(),function(item){return tree.model.getIdentity(item);}).join("/");for(var path in tree._openedNodes){if(path.substr(0,_bd4.length)==_bd4){delete tree._openedNodes[path];}}tree._saveExpandedNodes();}if(tree.lastFocusedChild&&!dom.isDescendant(tree.lastFocusedChild.domNode,tree.domNode)){delete tree.lastFocusedChild;}if(_bcf&&!dom.isDescendant(_bcf.domNode,tree.domNode)){tree.focus();}node.destroyRecursive();}});});this.state="Loaded";if(_bcd&&_bcd.length>0){this.isExpandable=true;_b9d.forEach(_bcd,function(item){var id=_bce.getIdentity(item),_bd5=tree._itemNodesMap[id],node;if(_bd5){for(var i=0;i<_bd5.length;i++){if(_bd5[i]&&!_bd5[i].getParent()){node=_bd5[i];node.set("indent",this.indent+1);break;}}}if(!node){node=this.tree._createTreeNode({item:item,tree:tree,isExpandable:_bce.mayHaveChildren(item),label:tree.getLabel(item),labelType:(tree.model&&tree.model.labelType)||"text",tooltip:tree.getTooltip(item),ownerDocument:tree.ownerDocument,dir:tree.dir,lang:tree.lang,textDir:tree.textDir,indent:this.indent+1});if(_bd5){_bd5.push(node);}else{tree._itemNodesMap[id]=[node];}}this.addChild(node);if(this.tree.autoExpand||this.tree._state(node)){defs.push(tree._expandNode(node));}},this);_b9d.forEach(this.getChildren(),function(_bd6){_bd6._updateLayout();});}else{this.isExpandable=false;}if(this._setExpando){this._setExpando(false);}this._updateItemClasses(this.item);var def=all(defs);this.tree._startPaint(def);return _bb9(def);},getTreePath:function(){var node=this;var path=[];while(node&&node!==this.tree.rootNode){path.unshift(node.item);node=node.getParent();}path.unshift(this.tree.rootNode.item);return path;},getIdentity:function(){return this.tree.model.getIdentity(this.item);},removeChild:function(node){this.inherited(arguments);var _bd7=this.getChildren();if(_bd7.length==0){this.isExpandable=false;this.collapse();}_b9d.forEach(_bd7,function(_bd8){_bd8._updateLayout();});},makeExpandable:function(){this.isExpandable=true;this._setExpando(false);},setSelected:function(_bd9){this.labelNode.setAttribute("aria-selected",_bd9?"true":"false");_ba2.toggle(this.rowNode,"dijitTreeRowSelected",_bd9);},focus:function(){_bab.focus(this.focusNode);}});if(has("dojo-bidi")){_bbc.extend({_setTextDirAttr:function(_bda){if(_bda&&((this.textDir!=_bda)||!this._created)){this._set("textDir",_bda);this.applyTextDir(this.labelNode);_b9d.forEach(this.getChildren(),function(_bdb){_bdb.set("textDir",_bda);},this);}}});}var Tree=_ba0("dijit.Tree",[_bae,_bb3,_baf,_bb2],{baseClass:"dijitTree",store:null,model:null,query:null,label:"",showRoot:true,childrenAttr:["children"],paths:[],path:[],selectedItems:null,selectedItem:null,openOnClick:false,openOnDblClick:false,templateString:_bb5,persist:false,autoExpand:false,dndController:_bb8,dndParams:["onDndDrop","itemCreator","onDndCancel","checkAcceptance","checkItemAcceptance","dragThreshold","betweenThreshold"],onDndDrop:null,itemCreator:null,onDndCancel:null,checkAcceptance:null,checkItemAcceptance:null,dragThreshold:5,betweenThreshold:0,_nodePixelIndent:19,_publish:function(_bdc,_bdd){_ba8.publish(this.id,lang.mixin({tree:this,event:_bdc},_bdd||{}));},postMixInProperties:function(){this.tree=this;if(this.autoExpand){this.persist=false;}this._itemNodesMap={};if(!this.cookieName&&this.id){this.cookieName=this.id+"SaveStateCookie";}this.expandChildrenDeferred=new _ba1();this.pendingCommandsPromise=this.expandChildrenDeferred.promise;this.inherited(arguments);},postCreate:function(){this._initState();var self=this;this.own(on(this.containerNode,on.selector(".dijitTreeNode",_ba9.enter),function(evt){self._onNodeMouseEnter(_bac.byNode(this),evt);}),on(this.containerNode,on.selector(".dijitTreeNode",_ba9.leave),function(evt){self._onNodeMouseLeave(_bac.byNode(this),evt);}),on(this.containerNode,on.selector(".dijitTreeRow",_baa.press),function(evt){self._onNodePress(_bac.getEnclosingWidget(this),evt);}),on(this.containerNode,on.selector(".dijitTreeRow",_baa),function(evt){self._onClick(_bac.getEnclosingWidget(this),evt);}),on(this.containerNode,on.selector(".dijitTreeRow","dblclick"),function(evt){self._onDblClick(_bac.getEnclosingWidget(this),evt);}));if(!this.model){this._store2model();}this.own(_b9e.after(this.model,"onChange",lang.hitch(this,"_onItemChange"),true),_b9e.after(this.model,"onChildrenChange",lang.hitch(this,"_onItemChildrenChange"),true),_b9e.after(this.model,"onDelete",lang.hitch(this,"_onItemDelete"),true));this.inherited(arguments);if(this.dndController){if(lang.isString(this.dndController)){this.dndController=lang.getObject(this.dndController);}var _bde={};for(var i=0;i<this.dndParams.length;i++){if(this[this.dndParams[i]]){_bde[this.dndParams[i]]=this[this.dndParams[i]];}}this.dndController=new this.dndController(this,_bde);}this._load();this.onLoadDeferred=_bb9(this.pendingCommandsPromise);this.onLoadDeferred.then(lang.hitch(this,"onLoad"));},_store2model:function(){this._v10Compat=true;_ba7.deprecated("Tree: from version 2.0, should specify a model object rather than a store/query");var _bdf={id:this.id+"_ForestStoreModel",store:this.store,query:this.query,childrenAttrs:this.childrenAttr};if(this.params.mayHaveChildren){_bdf.mayHaveChildren=lang.hitch(this,"mayHaveChildren");}if(this.params.getItemChildren){_bdf.getChildren=lang.hitch(this,function(item,_be0,_be1){this.getItemChildren((this._v10Compat&&item===this.model.root)?null:item,_be0,_be1);});}this.model=new _bb7(_bdf);this.showRoot=Boolean(this.label);},onLoad:function(){},_load:function(){this.model.getRoot(lang.hitch(this,function(item){var rn=(this.rootNode=this.tree._createTreeNode({item:item,tree:this,isExpandable:true,label:this.label||this.getLabel(item),labelType:this.model.labelType||"text",textDir:this.textDir,indent:this.showRoot?0:-1}));if(!this.showRoot){rn.rowNode.style.display="none";this.domNode.setAttribute("role","presentation");this.domNode.removeAttribute("aria-expanded");this.domNode.removeAttribute("aria-multiselectable");if(this["aria-label"]){rn.containerNode.setAttribute("aria-label",this["aria-label"]);this.domNode.removeAttribute("aria-label");}else{if(this["aria-labelledby"]){rn.containerNode.setAttribute("aria-labelledby",this["aria-labelledby"]);this.domNode.removeAttribute("aria-labelledby");}}rn.labelNode.setAttribute("role","presentation");rn.labelNode.removeAttribute("aria-selected");rn.containerNode.setAttribute("role","tree");rn.containerNode.setAttribute("aria-expanded","true");rn.containerNode.setAttribute("aria-multiselectable",!this.dndController.singular);}else{this.domNode.setAttribute("aria-multiselectable",!this.dndController.singular);this.rootLoadingIndicator.style.display="none";}this.containerNode.appendChild(rn.domNode);var _be2=this.model.getIdentity(item);if(this._itemNodesMap[_be2]){this._itemNodesMap[_be2].push(rn);}else{this._itemNodesMap[_be2]=[rn];}rn._updateLayout();this._expandNode(rn).then(lang.hitch(this,function(){if(!this._destroyed){this.rootLoadingIndicator.style.display="none";this.expandChildrenDeferred.resolve(true);}}));}),lang.hitch(this,function(err){console.error(this,": error loading root: ",err);}));},getNodesByItem:function(item){if(!item){return [];}var _be3=lang.isString(item)?item:this.model.getIdentity(item);return [].concat(this._itemNodesMap[_be3]);},_setSelectedItemAttr:function(item){this.set("selectedItems",[item]);},_setSelectedItemsAttr:function(_be4){var tree=this;return this.pendingCommandsPromise=this.pendingCommandsPromise.always(lang.hitch(this,function(){var _be5=_b9d.map(_be4,function(item){return (!item||lang.isString(item))?item:tree.model.getIdentity(item);});var _be6=[];_b9d.forEach(_be5,function(id){_be6=_be6.concat(tree._itemNodesMap[id]||[]);});this.set("selectedNodes",_be6);}));},_setPathAttr:function(path){if(path.length){return _bb9(this.set("paths",[path]).then(function(_be7){return _be7[0];}));}else{return _bb9(this.set("paths",[]).then(function(_be8){return _be8[0];}));}},_setPathsAttr:function(_be9){var tree=this;function _bea(path,_beb){var _bec=path.shift();var _bed=_b9d.filter(_beb,function(node){return node.getIdentity()==_bec;})[0];if(!!_bed){if(path.length){return tree._expandNode(_bed).then(function(){return _bea(path,_bed.getChildren());});}else{return _bed;}}else{throw new Tree.PathError("Could not expand path at "+_bec);}};return _bb9(this.pendingCommandsPromise=this.pendingCommandsPromise.always(function(){return all(_b9d.map(_be9,function(path){path=_b9d.map(path,function(item){return item&&lang.isObject(item)?tree.model.getIdentity(item):item;});if(path.length){return _bea(path,[tree.rootNode]);}else{throw new Tree.PathError("Empty path");}}));}).then(function setNodes(_bee){tree.set("selectedNodes",_bee);return tree.paths;}));},_setSelectedNodeAttr:function(node){this.set("selectedNodes",[node]);},_setSelectedNodesAttr:function(_bef){this.dndController.setSelection(_bef);},expandAll:function(){var _bf0=this;function _bf1(node){return _bf0._expandNode(node).then(function(){var _bf2=_b9d.filter(node.getChildren()||[],function(node){return node.isExpandable;});return all(_b9d.map(_bf2,_bf1));});};return _bb9(_bf1(this.rootNode));},collapseAll:function(){var _bf3=this;function _bf4(node){var _bf5=_b9d.filter(node.getChildren()||[],function(node){return node.isExpandable;}),defs=all(_b9d.map(_bf5,_bf4));if(!node.isExpanded||(node==_bf3.rootNode&&!_bf3.showRoot)){return defs;}else{return defs.then(function(){return _bf3._collapseNode(node);});}};return _bb9(_bf4(this.rootNode));},mayHaveChildren:function(){},getItemChildren:function(){},getLabel:function(item){return this.model.getLabel(item);},getIconClass:function(item,_bf6){return (!item||this.model.mayHaveChildren(item))?(_bf6?"dijitFolderOpened":"dijitFolderClosed"):"dijitLeaf";},getLabelClass:function(){},getRowClass:function(){},getIconStyle:function(){},getLabelStyle:function(){},getRowStyle:function(){},getTooltip:function(){return "";},_onDownArrow:function(evt,node){var _bf7=this._getNext(node);if(_bf7&&_bf7.isTreeNode){this.focusNode(_bf7);}},_onUpArrow:function(evt,node){var _bf8=node.getPreviousSibling();if(_bf8){node=_bf8;while(node.isExpandable&&node.isExpanded&&node.hasChildren()){var _bf9=node.getChildren();node=_bf9[_bf9.length-1];}}else{var _bfa=node.getParent();if(!(!this.showRoot&&_bfa===this.rootNode)){node=_bfa;}}if(node&&node.isTreeNode){this.focusNode(node);}},_onRightArrow:function(evt,node){if(node.isExpandable&&!node.isExpanded){this._expandNode(node);}else{if(node.hasChildren()){node=node.getChildren()[0];if(node&&node.isTreeNode){this.focusNode(node);}}}},_onLeftArrow:function(evt,node){if(node.isExpandable&&node.isExpanded){this._collapseNode(node);}else{var _bfb=node.getParent();if(_bfb&&_bfb.isTreeNode&&!(!this.showRoot&&_bfb===this.rootNode)){this.focusNode(_bfb);}}},focusLastChild:function(){var node=this._getLast();if(node&&node.isTreeNode){this.focusNode(node);}},_getFirst:function(){return this.showRoot?this.rootNode:this.rootNode.getChildren()[0];},_getLast:function(){var node=this.rootNode;while(node.isExpanded){var c=node.getChildren();if(!c.length){break;}node=c[c.length-1];}return node;},_getNext:function(node){if(node.isExpandable&&node.isExpanded&&node.hasChildren()){return node.getChildren()[0];}else{while(node&&node.isTreeNode){var _bfc=node.getNextSibling();if(_bfc){return _bfc;}node=node.getParent();}return null;}},childSelector:".dijitTreeRow",isExpandoNode:function(node,_bfd){return dom.isDescendant(node,_bfd.expandoNode)||dom.isDescendant(node,_bfd.expandoNodeText);},_onNodePress:function(_bfe,e){this.focusNode(_bfe);},__click:function(_bff,e,_c00,func){var _c01=e.target,_c02=this.isExpandoNode(_c01,_bff);if(_bff.isExpandable&&(_c00||_c02)){this._onExpandoClick({node:_bff});}else{this._publish("execute",{item:_bff.item,node:_bff,evt:e});this[func](_bff.item,_bff,e);this.focusNode(_bff);}e.stopPropagation();e.preventDefault();},_onClick:function(_c03,e){this.__click(_c03,e,this.openOnClick,"onClick");},_onDblClick:function(_c04,e){this.__click(_c04,e,this.openOnDblClick,"onDblClick");},_onExpandoClick:function(_c05){var node=_c05.node;this.focusNode(node);if(node.isExpanded){this._collapseNode(node);}else{this._expandNode(node);}},onClick:function(){},onDblClick:function(){},onOpen:function(){},onClose:function(){},_getNextNode:function(node){_ba7.deprecated(this.declaredClass+"::_getNextNode(node) is deprecated. Use _getNext(node) instead.","","2.0");return this._getNext(node);},_getRootOrFirstNode:function(){_ba7.deprecated(this.declaredClass+"::_getRootOrFirstNode() is deprecated. Use _getFirst() instead.","","2.0");return this._getFirst();},_collapseNode:function(node){if(node._expandNodeDeferred){delete node._expandNodeDeferred;}if(node.state=="Loading"){return;}if(node.isExpanded){var ret=node.collapse();this.onClose(node.item,node);this._state(node,false);this._startPaint(ret);return ret;}},_expandNode:function(node){if(node._expandNodeDeferred){return node._expandNodeDeferred;}var _c06=this.model,item=node.item,_c07=this;if(!node._loadDeferred){node.markProcessing();node._loadDeferred=new _ba1();_c06.getChildren(item,function(_c08){node.unmarkProcessing();node.setChildItems(_c08).then(function(){node._loadDeferred.resolve(_c08);});},function(err){console.error(_c07,": error loading "+node.label+" children: ",err);node._loadDeferred.reject(err);});}var def=node._loadDeferred.then(lang.hitch(this,function(){var def2=node.expand();this.onOpen(node.item,node);this._state(node,true);return def2;}));this._startPaint(def);return def;},focusNode:function(node){var tmp=[];for(var _c09=this.domNode;_c09&&_c09.tagName&&_c09.tagName.toUpperCase()!=="IFRAME";_c09=_c09.parentNode){tmp.push({domNode:_c09.contentWindow||_c09,scrollLeft:_c09.scrollLeft||0,scrollTop:_c09.scrollTop||0});}this.focusChild(node);this.defer(function(){for(var i=0,max=tmp.length;i<max;i++){tmp[i].domNode.scrollLeft=tmp[i].scrollLeft;tmp[i].domNode.scrollTop=tmp[i].scrollTop;}},0);},_onNodeMouseEnter:function(){},_onNodeMouseLeave:function(){},_onItemChange:function(item){var _c0a=this.model,_c0b=_c0a.getIdentity(item),_c0c=this._itemNodesMap[_c0b];if(_c0c){var _c0d=this.getLabel(item),_c0e=this.getTooltip(item);_b9d.forEach(_c0c,function(node){node.set({item:item,label:_c0d,tooltip:_c0e});node._updateItemClasses(item);});}},_onItemChildrenChange:function(_c0f,_c10){var _c11=this.model,_c12=_c11.getIdentity(_c0f),_c13=this._itemNodesMap[_c12];if(_c13){_b9d.forEach(_c13,function(_c14){_c14.setChildItems(_c10);});}},_onItemDelete:function(item){var _c15=this.model,_c16=_c15.getIdentity(item),_c17=this._itemNodesMap[_c16];if(_c17){_b9d.forEach(_c17,function(node){this.dndController.removeTreeNode(node);var _c18=node.getParent();if(_c18){_c18.removeChild(node);}if(this.lastFocusedChild&&!dom.isDescendant(this.lastFocusedChild.domNode,this.domNode)){delete this.lastFocusedChild;}if(this.focusedChild&&!dom.isDescendant(this.focusedChild.domNode,this.domNode)){this.focus();}node.destroyRecursive();},this);delete this._itemNodesMap[_c16];}},_initState:function(){this._openedNodes={};if(this.persist&&this.cookieName){var oreo=_b9f(this.cookieName);if(oreo){_b9d.forEach(oreo.split(","),function(item){this._openedNodes[item]=true;},this);}}},_state:function(node,_c19){if(!this.persist){return false;}var path=_b9d.map(node.getTreePath(),function(item){return this.model.getIdentity(item);},this).join("/");if(arguments.length===1){return this._openedNodes[path];}else{if(_c19){this._openedNodes[path]=true;}else{delete this._openedNodes[path];}this._saveExpandedNodes();}},_saveExpandedNodes:function(){if(this.persist&&this.cookieName){var ary=[];for(var id in this._openedNodes){ary.push(id);}_b9f(this.cookieName,ary.join(","),{expires:365});}},destroy:function(){if(this._curSearch){this._curSearch.timer.remove();delete this._curSearch;}if(this.rootNode){this.rootNode.destroyRecursive();}if(this.dndController&&!lang.isString(this.dndController)){this.dndController.destroy();}this.rootNode=null;this.inherited(arguments);},destroyRecursive:function(){this.destroy();},resize:function(_c1a){if(_c1a){_ba3.setMarginBox(this.domNode,_c1a);}this._nodePixelIndent=_ba3.position(this.tree.indentDetector).w||this._nodePixelIndent;this.expandChildrenDeferred.then(lang.hitch(this,function(){this.rootNode.set("indent",this.showRoot?0:-1);this._adjustWidths();}));},_outstandingPaintOperations:0,_startPaint:function(p){this._outstandingPaintOperations++;if(this._adjustWidthsTimer){this._adjustWidthsTimer.remove();delete this._adjustWidthsTimer;}var oc=lang.hitch(this,function(){this._outstandingPaintOperations--;if(this._outstandingPaintOperations<=0&&!this._adjustWidthsTimer&&this._started){this._adjustWidthsTimer=this.defer("_adjustWidths");}});when(p,oc,oc);},_adjustWidths:function(){if(this._adjustWidthsTimer){this._adjustWidthsTimer.remove();delete this._adjustWidthsTimer;}this.containerNode.style.width="auto";this.containerNode.style.width=this.domNode.scrollWidth>this.domNode.offsetWidth?"auto":"100%";},_createTreeNode:function(args){return new _bbc(args);},focus:function(){if(this.lastFocusedChild){this.focusNode(this.lastFocusedChild);}else{this.focusFirstChild();}}});if(has("dojo-bidi")){Tree.extend({_setTextDirAttr:function(_c1b){if(_c1b&&this.textDir!=_c1b){this._set("textDir",_c1b);this.rootNode.set("textDir",_c1b);}}});}Tree.PathError=_ba5("TreePathError");Tree._TreeNode=_bbc;return Tree;});},"dijit/tree/TreeStoreModel":function(){define(["dojo/_base/array","dojo/aspect","dojo/_base/declare","dojo/_base/lang"],function(_c1c,_c1d,_c1e,lang){return _c1e("dijit.tree.TreeStoreModel",null,{store:null,childrenAttrs:["children"],newItemIdAttr:"id",labelAttr:"",root:null,query:null,deferItemLoadingUntilExpand:false,constructor:function(args){lang.mixin(this,args);this.connects=[];var _c1f=this.store;if(!_c1f.getFeatures()["dojo.data.api.Identity"]){throw new Error("dijit.tree.TreeStoreModel: store must support dojo.data.Identity");}if(_c1f.getFeatures()["dojo.data.api.Notification"]){this.connects=this.connects.concat([_c1d.after(_c1f,"onNew",lang.hitch(this,"onNewItem"),true),_c1d.after(_c1f,"onDelete",lang.hitch(this,"onDeleteItem"),true),_c1d.after(_c1f,"onSet",lang.hitch(this,"onSetItem"),true)]);}},destroy:function(){var h;while(h=this.connects.pop()){h.remove();}},getRoot:function(_c20,_c21){if(this.root){_c20(this.root);}else{this.store.fetch({query:this.query,onComplete:lang.hitch(this,function(_c22){if(_c22.length!=1){throw new Error("dijit.tree.TreeStoreModel: root query returned "+_c22.length+" items, but must return exactly one");}this.root=_c22[0];_c20(this.root);}),onError:_c21});}},mayHaveChildren:function(item){return _c1c.some(this.childrenAttrs,function(attr){return this.store.hasAttribute(item,attr);},this);},getChildren:function(_c23,_c24,_c25){var _c26=this.store;if(!_c26.isItemLoaded(_c23)){var _c27=lang.hitch(this,arguments.callee);_c26.loadItem({item:_c23,onItem:function(_c28){_c27(_c28,_c24,_c25);},onError:_c25});return;}var _c29=[];for(var i=0;i<this.childrenAttrs.length;i++){var vals=_c26.getValues(_c23,this.childrenAttrs[i]);_c29=_c29.concat(vals);}var _c2a=0;if(!this.deferItemLoadingUntilExpand){_c1c.forEach(_c29,function(item){if(!_c26.isItemLoaded(item)){_c2a++;}});}if(_c2a==0){_c24(_c29);}else{_c1c.forEach(_c29,function(item,idx){if(!_c26.isItemLoaded(item)){_c26.loadItem({item:item,onItem:function(item){_c29[idx]=item;if(--_c2a==0){_c24(_c29);}},onError:_c25});}});}},isItem:function(_c2b){return this.store.isItem(_c2b);},fetchItemByIdentity:function(_c2c){this.store.fetchItemByIdentity(_c2c);},getIdentity:function(item){return this.store.getIdentity(item);},getLabel:function(item){if(this.labelAttr){return this.store.getValue(item,this.labelAttr);}else{return this.store.getLabel(item);}},newItem:function(args,_c2d,_c2e){var _c2f={parent:_c2d,attribute:this.childrenAttrs[0]},_c30;if(this.newItemIdAttr&&args[this.newItemIdAttr]){this.fetchItemByIdentity({identity:args[this.newItemIdAttr],scope:this,onItem:function(item){if(item){this.pasteItem(item,null,_c2d,true,_c2e);}else{_c30=this.store.newItem(args,_c2f);if(_c30&&(_c2e!=undefined)){this.pasteItem(_c30,_c2d,_c2d,false,_c2e);}}}});}else{_c30=this.store.newItem(args,_c2f);if(_c30&&(_c2e!=undefined)){this.pasteItem(_c30,_c2d,_c2d,false,_c2e);}}},pasteItem:function(_c31,_c32,_c33,_c34,_c35){var _c36=this.store,_c37=this.childrenAttrs[0];if(_c32){_c1c.forEach(this.childrenAttrs,function(attr){if(_c36.containsValue(_c32,attr,_c31)){if(!_c34){var _c38=_c1c.filter(_c36.getValues(_c32,attr),function(x){return x!=_c31;});_c36.setValues(_c32,attr,_c38);}_c37=attr;}});}if(_c33){if(typeof _c35=="number"){var _c39=_c36.getValues(_c33,_c37).slice();_c39.splice(_c35,0,_c31);_c36.setValues(_c33,_c37,_c39);}else{_c36.setValues(_c33,_c37,_c36.getValues(_c33,_c37).concat(_c31));}}},onChange:function(){},onChildrenChange:function(){},onDelete:function(){},onNewItem:function(item,_c3a){if(!_c3a){return;}this.getChildren(_c3a.item,lang.hitch(this,function(_c3b){this.onChildrenChange(_c3a.item,_c3b);}));},onDeleteItem:function(item){this.onDelete(item);},onSetItem:function(item,_c3c){if(_c1c.indexOf(this.childrenAttrs,_c3c)!=-1){this.getChildren(item,lang.hitch(this,function(_c3d){this.onChildrenChange(item,_c3d);}));}else{this.onChange(item);}}});});},"dijit/tree/ForestStoreModel":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/_base/kernel","dojo/_base/lang","./TreeStoreModel"],function(_c3e,_c3f,_c40,lang,_c41){return _c3f("dijit.tree.ForestStoreModel",_c41,{rootId:"$root$",rootLabel:"ROOT",query:null,constructor:function(_c42){this.root={store:this,root:true,id:_c42.rootId,label:_c42.rootLabel,children:_c42.rootChildren};},mayHaveChildren:function(item){return item===this.root||this.inherited(arguments);},getChildren:function(_c43,_c44,_c45){if(_c43===this.root){if(this.root.children){_c44(this.root.children);}else{this.store.fetch({query:this.query,onComplete:lang.hitch(this,function(_c46){this.root.children=_c46;_c44(_c46);}),onError:_c45});}}else{this.inherited(arguments);}},isItem:function(_c47){return (_c47===this.root)?true:this.inherited(arguments);},fetchItemByIdentity:function(_c48){if(_c48.identity==this.root.id){var _c49=_c48.scope||_c40.global;if(_c48.onItem){_c48.onItem.call(_c49,this.root);}}else{this.inherited(arguments);}},getIdentity:function(item){return (item===this.root)?this.root.id:this.inherited(arguments);},getLabel:function(item){return (item===this.root)?this.root.label:this.inherited(arguments);},newItem:function(args,_c4a,_c4b){if(_c4a===this.root){this.onNewRootItem(args);return this.store.newItem(args);}else{return this.inherited(arguments);}},onNewRootItem:function(){},pasteItem:function(_c4c,_c4d,_c4e,_c4f,_c50){if(_c4d===this.root){if(!_c4f){this.onLeaveRoot(_c4c);}}this.inherited(arguments,[_c4c,_c4d===this.root?null:_c4d,_c4e===this.root?null:_c4e,_c4f,_c50]);if(_c4e===this.root){this.onAddToRoot(_c4c);}},onAddToRoot:function(item){},onLeaveRoot:function(item){},_requeryTop:function(){var _c51=this.root.children||[];this.store.fetch({query:this.query,onComplete:lang.hitch(this,function(_c52){this.root.children=_c52;if(_c51.length!=_c52.length||_c3e.some(_c51,function(item,idx){return _c52[idx]!=item;})){this.onChildrenChange(this.root,_c52);}})});},onNewItem:function(item,_c53){this._requeryTop();this.inherited(arguments);},onDeleteItem:function(item){if(_c3e.indexOf(this.root.children,item)!=-1){this._requeryTop();}this.inherited(arguments);},onSetItem:function(item,_c54,_c55,_c56){this._requeryTop();this.inherited(arguments);}});});},"dijit/tree/_dndSelector":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/_base/kernel","dojo/_base/lang","dojo/dnd/common","dojo/dom","dojo/mouse","dojo/on","dojo/touch","../a11yclick","./_dndContainer"],function(_c57,_c58,_c59,lang,_c5a,dom,_c5b,on,_c5c,_c5d,_c5e){return _c58("dijit.tree._dndSelector",_c5e,{constructor:function(){this.selection={};this.anchor=null;this.events.push(on(this.tree.domNode,_c5c.press,lang.hitch(this,"onMouseDown")),on(this.tree.domNode,_c5c.release,lang.hitch(this,"onMouseUp")),on(this.tree.domNode,_c5c.move,lang.hitch(this,"onMouseMove")),on(this.tree.domNode,_c5d.press,lang.hitch(this,"onClickPress")),on(this.tree.domNode,_c5d.release,lang.hitch(this,"onClickRelease")));},singular:false,getSelectedTreeNodes:function(){var _c5f=[],sel=this.selection;for(var i in sel){_c5f.push(sel[i]);}return _c5f;},selectNone:function(){this.setSelection([]);return this;},destroy:function(){this.inherited(arguments);this.selection=this.anchor=null;},addTreeNode:function(node,_c60){this.setSelection(this.getSelectedTreeNodes().concat([node]));if(_c60){this.anchor=node;}return node;},removeTreeNode:function(node){var _c61=_c57.filter(this.getSelectedTreeNodes(),function(_c62){return !dom.isDescendant(_c62.domNode,node.domNode);});this.setSelection(_c61);return node;},isTreeNodeSelected:function(node){return node.id&&!!this.selection[node.id];},setSelection:function(_c63){var _c64=this.getSelectedTreeNodes();_c57.forEach(this._setDifference(_c64,_c63),lang.hitch(this,function(node){node.setSelected(false);if(this.anchor==node){delete this.anchor;}delete this.selection[node.id];}));_c57.forEach(this._setDifference(_c63,_c64),lang.hitch(this,function(node){node.setSelected(true);this.selection[node.id]=node;}));this._updateSelectionProperties();},_setDifference:function(xs,ys){_c57.forEach(ys,function(y){y.__exclude__=true;});var ret=_c57.filter(xs,function(x){return !x.__exclude__;});_c57.forEach(ys,function(y){delete y["__exclude__"];});return ret;},_updateSelectionProperties:function(){var _c65=this.getSelectedTreeNodes();var _c66=[],_c67=[];_c57.forEach(_c65,function(node){var ary=node.getTreePath();_c67.push(node);_c66.push(ary);},this);var _c68=_c57.map(_c67,function(node){return node.item;});this.tree._set("paths",_c66);this.tree._set("path",_c66[0]||[]);this.tree._set("selectedNodes",_c67);this.tree._set("selectedNode",_c67[0]||null);this.tree._set("selectedItems",_c68);this.tree._set("selectedItem",_c68[0]||null);},onClickPress:function(e){if(this.current&&this.current.isExpandable&&this.tree.isExpandoNode(e.target,this.current)){return;}if(e.type=="mousedown"&&_c5b.isLeft(e)){e.preventDefault();}var _c69=e.type=="keydown"?this.tree.focusedChild:this.current;if(!_c69){return;}var copy=_c5a.getCopyKeyState(e),id=_c69.id;if(!this.singular&&!e.shiftKey&&this.selection[id]){this._doDeselect=true;return;}else{this._doDeselect=false;}this.userSelect(_c69,copy,e.shiftKey);},onClickRelease:function(e){if(!this._doDeselect){return;}this._doDeselect=false;this.userSelect(e.type=="keyup"?this.tree.focusedChild:this.current,_c5a.getCopyKeyState(e),e.shiftKey);},onMouseMove:function(){this._doDeselect=false;},onMouseDown:function(){},onMouseUp:function(){},_compareNodes:function(n1,n2){if(n1===n2){return 0;}if("sourceIndex" in document.documentElement){return n1.sourceIndex-n2.sourceIndex;}else{if("compareDocumentPosition" in document.documentElement){return n1.compareDocumentPosition(n2)&2?1:-1;}else{if(document.createRange){var r1=doc.createRange();r1.setStartBefore(n1);var r2=doc.createRange();r2.setStartBefore(n2);return r1.compareBoundaryPoints(r1.END_TO_END,r2);}else{throw Error("dijit.tree._compareNodes don't know how to compare two different nodes in this browser");}}}},userSelect:function(node,_c6a,_c6b){if(this.singular){if(this.anchor==node&&_c6a){this.selectNone();}else{this.setSelection([node]);this.anchor=node;}}else{if(_c6b&&this.anchor){var cr=this._compareNodes(this.anchor.rowNode,node.rowNode),_c6c,end,_c6d=this.anchor;if(cr<0){_c6c=_c6d;end=node;}else{_c6c=node;end=_c6d;}var _c6e=[];while(_c6c!=end){_c6e.push(_c6c);_c6c=this.tree._getNext(_c6c);}_c6e.push(end);this.setSelection(_c6e);}else{if(this.selection[node.id]&&_c6a){this.removeTreeNode(node);}else{if(_c6a){this.addTreeNode(node,true);}else{this.setSelection([node]);this.anchor=node;}}}}},getItem:function(key){var _c6f=this.selection[key];return {data:_c6f,type:["treeNode"]};},forInSelectedItems:function(f,o){o=o||_c59.global;for(var id in this.selection){f.call(o,this.getItem(id),id,this);}}});});},"dijit/tree/_dndContainer":function(){define(["dojo/aspect","dojo/_base/declare","dojo/dom-class","dojo/_base/lang","dojo/on","dojo/touch"],function(_c70,_c71,_c72,lang,on,_c73){return _c71("dijit.tree._dndContainer",null,{constructor:function(tree,_c74){this.tree=tree;this.node=tree.domNode;lang.mixin(this,_c74);this.containerState="";_c72.add(this.node,"dojoDndContainer");this.events=[on(this.node,_c73.enter,lang.hitch(this,"onOverEvent")),on(this.node,_c73.leave,lang.hitch(this,"onOutEvent")),_c70.after(this.tree,"_onNodeMouseEnter",lang.hitch(this,"onMouseOver"),true),_c70.after(this.tree,"_onNodeMouseLeave",lang.hitch(this,"onMouseOut"),true),on(this.node,"dragstart, selectstart",function(evt){evt.preventDefault();})];},destroy:function(){var h;while(h=this.events.pop()){h.remove();}this.node=this.parent=null;},onMouseOver:function(_c75){this.current=_c75;},onMouseOut:function(){this.current=null;},_changeState:function(type,_c76){var _c77="dojoDnd"+type;var _c78=type.toLowerCase()+"State";_c72.replace(this.node,_c77+_c76,_c77+this[_c78]);this[_c78]=_c76;},_addItemClass:function(node,type){_c72.add(node,"dojoDndItem"+type);},_removeItemClass:function(node,type){_c72.remove(node,"dojoDndItem"+type);},onOverEvent:function(){this._changeState("Container","Over");},onOutEvent:function(){this._changeState("Container","");}});});},"dijit/tree/dndSource":function(){define(["dojo/_base/array","dojo/_base/declare","dojo/dnd/common","dojo/dom-class","dojo/dom-geometry","dojo/_base/lang","dojo/mouse","dojo/on","dojo/touch","dojo/topic","dojo/dnd/Manager","./_dndSelector"],function(_c79,_c7a,_c7b,_c7c,_c7d,lang,_c7e,on,_c7f,_c80,_c81,_c82){var _c83=_c7a("dijit.tree.dndSource",_c82,{isSource:true,accept:["text","treeNode"],copyOnly:false,dragThreshold:5,betweenThreshold:0,generateText:true,constructor:function(tree,_c84){if(!_c84){_c84={};}lang.mixin(this,_c84);var type=_c84.accept instanceof Array?_c84.accept:["text","treeNode"];this.accept=null;if(type.length){this.accept={};for(var i=0;i<type.length;++i){this.accept[type[i]]=1;}}this.isDragging=false;this.mouseDown=false;this.targetAnchor=null;this.targetBox=null;this.dropPosition="";this._lastX=0;this._lastY=0;this.sourceState="";if(this.isSource){_c7c.add(this.node,"dojoDndSource");}this.targetState="";if(this.accept){_c7c.add(this.node,"dojoDndTarget");}this.topics=[_c80.subscribe("/dnd/source/over",lang.hitch(this,"onDndSourceOver")),_c80.subscribe("/dnd/start",lang.hitch(this,"onDndStart")),_c80.subscribe("/dnd/drop",lang.hitch(this,"onDndDrop")),_c80.subscribe("/dnd/cancel",lang.hitch(this,"onDndCancel"))];},checkAcceptance:function(){return true;},copyState:function(_c85){return this.copyOnly||_c85;},destroy:function(){this.inherited(arguments);var h;while(h=this.topics.pop()){h.remove();}this.targetAnchor=null;},_onDragMouse:function(e,_c86){var m=_c81.manager(),_c87=this.targetAnchor,_c88=this.current,_c89=this.dropPosition;var _c8a="Over";if(_c88&&this.betweenThreshold>0){if(!this.targetBox||_c87!=_c88){this.targetBox=_c7d.position(_c88.rowNode,true);}if((e.pageY-this.targetBox.y)<=this.betweenThreshold){_c8a="Before";}else{if((e.pageY-this.targetBox.y)>=(this.targetBox.h-this.betweenThreshold)){_c8a="After";}}}if(_c86||_c88!=_c87||_c8a!=_c89){if(_c87){this._removeItemClass(_c87.rowNode,_c89);}if(_c88){this._addItemClass(_c88.rowNode,_c8a);}if(!_c88){m.canDrop(false);}else{if(_c88==this.tree.rootNode&&_c8a!="Over"){m.canDrop(false);}else{var _c8b=false,_c8c=false;if(m.source==this){_c8c=(_c8a==="Over");for(var _c8d in this.selection){var _c8e=this.selection[_c8d];if(_c8e.item===_c88.item){_c8b=true;break;}if(_c8e.getParent().id!==_c88.id){_c8c=false;}}}m.canDrop(!_c8b&&!_c8c&&!this._isParentChildDrop(m.source,_c88.rowNode)&&this.checkItemAcceptance(_c88.rowNode,m.source,_c8a.toLowerCase()));}}this.targetAnchor=_c88;this.dropPosition=_c8a;}},onMouseMove:function(e){if(this.isDragging&&this.targetState=="Disabled"){return;}this.inherited(arguments);var m=_c81.manager();if(this.isDragging){this._onDragMouse(e);}else{if(this.mouseDown&&this.isSource&&(Math.abs(e.pageX-this._lastX)>=this.dragThreshold||Math.abs(e.pageY-this._lastY)>=this.dragThreshold)){var _c8f=this.getSelectedTreeNodes();if(_c8f.length){if(_c8f.length>1){var seen=this.selection,i=0,r=[],n,p;nextitem:while((n=_c8f[i++])){for(p=n.getParent();p&&p!==this.tree;p=p.getParent()){if(seen[p.id]){continue nextitem;}}r.push(n);}_c8f=r;}_c8f=_c79.map(_c8f,function(n){return n.domNode;});m.startDrag(this,_c8f,this.copyState(_c7b.getCopyKeyState(e)));this._onDragMouse(e,true);}}}},onMouseDown:function(e){if(e.type=="touchstart"||_c7e.isLeft(e)){this.mouseDown=true;this.mouseButton=e.button;this._lastX=e.pageX;this._lastY=e.pageY;}this.inherited(arguments);},onMouseUp:function(e){if(this.mouseDown){this.mouseDown=false;this.inherited(arguments);}},onMouseOut:function(){this.inherited(arguments);this._unmarkTargetAnchor();},checkItemAcceptance:function(){return true;},onDndSourceOver:function(_c90){if(this!=_c90){this.mouseDown=false;this._unmarkTargetAnchor();}else{if(this.isDragging){var m=_c81.manager();m.canDrop(false);}}},onDndStart:function(_c91,_c92,copy){if(this.isSource){this._changeState("Source",this==_c91?(copy?"Copied":"Moved"):"");}var _c93=this.checkAcceptance(_c91,_c92);this._changeState("Target",_c93?"":"Disabled");if(this==_c91){_c81.manager().overSource(this);}this.isDragging=true;},itemCreator:function(_c94){return _c79.map(_c94,function(node){return {"id":node.id,"name":node.textContent||node.innerText||""};});},onDndDrop:function(_c95,_c96,copy){if(this.containerState=="Over"){var tree=this.tree,_c97=tree.model,_c98=this.targetAnchor,_c99=false;this.isDragging=false;var _c9a;var _c9b;var _c9c;_c9a=(_c98&&_c98.item)||tree.item;if(this.dropPosition=="Before"||this.dropPosition=="After"){_c9a=(_c98.getParent()&&_c98.getParent().item)||tree.item;_c9b=_c98.getIndexInParent();if(this.dropPosition=="After"){_c9b=_c98.getIndexInParent()+1;_c9c=_c98.getNextSibling()&&_c98.getNextSibling().item;}else{_c9c=_c98.item;}}else{_c9a=(_c98&&_c98.item)||tree.item;_c99=true;}var _c9d;_c79.forEach(_c96,function(node,idx){var _c9e=_c95.getItem(node.id);if(_c79.indexOf(_c9e.type,"treeNode")!=-1){var _c9f=_c9e.data,_ca0=_c9f.item,_ca1=_c9f.getParent().item;}if(_c95==this){if(typeof _c9b=="number"){if(_c9a==_ca1&&_c9f.getIndexInParent()<_c9b){_c9b-=1;}}_c97.pasteItem(_ca0,_ca1,_c9a,copy,_c9b,_c9c);}else{if(_c97.isItem(_ca0)){_c97.pasteItem(_ca0,_ca1,_c9a,copy,_c9b,_c9c);}else{if(!_c9d){_c9d=this.itemCreator(_c96,_c98.rowNode,_c95);}_c97.newItem(_c9d[idx],_c9a,_c9b,_c9c);}}},this);if(_c99){this.tree._expandNode(_c98);}}this.onDndCancel();},onDndCancel:function(){this._unmarkTargetAnchor();this.isDragging=false;this.mouseDown=false;delete this.mouseButton;this._changeState("Source","");this._changeState("Target","");},onOverEvent:function(){this.inherited(arguments);_c81.manager().overSource(this);},onOutEvent:function(){this._unmarkTargetAnchor();var m=_c81.manager();if(this.isDragging){m.canDrop(false);}m.outSource(this);this.inherited(arguments);},_isParentChildDrop:function(_ca2,_ca3){if(!_ca2.tree||_ca2.tree!=this.tree){return false;}var root=_ca2.tree.domNode;var ids=_ca2.selection;var node=_ca3.parentNode;while(node!=root&&!ids[node.id]){node=node.parentNode;}return node.id&&ids[node.id];},_unmarkTargetAnchor:function(){if(!this.targetAnchor){return;}this._removeItemClass(this.targetAnchor.rowNode,this.dropPosition);this.targetAnchor=null;this.targetBox=null;this.dropPosition=null;},_markDndStatus:function(copy){this._changeState("Source",copy?"Copied":"Moved");}});return _c83;});},"dojo/dnd/Manager":function(){define(["../_base/array","../_base/declare","../_base/lang","../_base/window","../dom-class","../Evented","../has","../keys","../on","../topic","../touch","./common","./autoscroll","./Avatar"],function(_ca4,_ca5,lang,win,_ca6,_ca7,has,keys,on,_ca8,_ca9,dnd,_caa,_cab){var _cac=_ca5("dojo.dnd.Manager",[_ca7],{constructor:function(){this.avatar=null;this.source=null;this.nodes=[];this.copy=true;this.target=null;this.canDropFlag=false;this.events=[];},OFFSET_X:has("touch")?4:16,OFFSET_Y:has("touch")?4:16,overSource:function(_cad){if(this.avatar){this.target=(_cad&&_cad.targetState!="Disabled")?_cad:null;this.canDropFlag=Boolean(this.target);this.avatar.update();}_ca8.publish("/dnd/source/over",_cad);},outSource:function(_cae){if(this.avatar){if(this.target==_cae){this.target=null;this.canDropFlag=false;this.avatar.update();_ca8.publish("/dnd/source/over",null);}}else{_ca8.publish("/dnd/source/over",null);}},startDrag:function(_caf,_cb0,copy){_caa.autoScrollStart(win.doc);this.source=_caf;this.nodes=_cb0;this.copy=Boolean(copy);this.avatar=this.makeAvatar();win.body().appendChild(this.avatar.node);_ca8.publish("/dnd/start",_caf,_cb0,this.copy);function _cb1(e){e.preventDefault();e.stopPropagation();};this.events=[on(win.doc,_ca9.move,lang.hitch(this,"onMouseMove")),on(win.doc,_ca9.release,lang.hitch(this,"onMouseUp")),on(win.doc,"keydown",lang.hitch(this,"onKeyDown")),on(win.doc,"keyup",lang.hitch(this,"onKeyUp")),on(win.doc,"dragstart",_cb1),on(win.body(),"selectstart",_cb1)];var c="dojoDnd"+(copy?"Copy":"Move");_ca6.add(win.body(),c);},canDrop:function(flag){var _cb2=Boolean(this.target&&flag);if(this.canDropFlag!=_cb2){this.canDropFlag=_cb2;this.avatar.update();}},stopDrag:function(){_ca6.remove(win.body(),["dojoDndCopy","dojoDndMove"]);_ca4.forEach(this.events,function(_cb3){_cb3.remove();});this.events=[];this.avatar.destroy();this.avatar=null;this.source=this.target=null;this.nodes=[];},makeAvatar:function(){return new _cab(this);},updateAvatar:function(){this.avatar.update();},onMouseMove:function(e){var a=this.avatar;if(a){_caa.autoScrollNodes(e);var s=a.node.style;s.left=(e.pageX+this.OFFSET_X)+"px";s.top=(e.pageY+this.OFFSET_Y)+"px";var copy=Boolean(this.source.copyState(dnd.getCopyKeyState(e)));if(this.copy!=copy){this._setCopyStatus(copy);}}if(has("touch")){e.preventDefault();}},onMouseUp:function(e){if(this.avatar){if(this.target&&this.canDropFlag){var copy=Boolean(this.source.copyState(dnd.getCopyKeyState(e)));_ca8.publish("/dnd/drop/before",this.source,this.nodes,copy,this.target,e);_ca8.publish("/dnd/drop",this.source,this.nodes,copy,this.target,e);}else{_ca8.publish("/dnd/cancel");}this.stopDrag();}},onKeyDown:function(e){if(this.avatar){switch(e.keyCode){case keys.CTRL:var copy=Boolean(this.source.copyState(true));if(this.copy!=copy){this._setCopyStatus(copy);}break;case keys.ESCAPE:_ca8.publish("/dnd/cancel");this.stopDrag();break;}}},onKeyUp:function(e){if(this.avatar&&e.keyCode==keys.CTRL){var copy=Boolean(this.source.copyState(false));if(this.copy!=copy){this._setCopyStatus(copy);}}},_setCopyStatus:function(copy){this.copy=copy;this.source._markDndStatus(this.copy);this.updateAvatar();_ca6.replace(win.body(),"dojoDnd"+(this.copy?"Copy":"Move"),"dojoDnd"+(this.copy?"Move":"Copy"));}});dnd._manager=null;_cac.manager=dnd.manager=function(){if(!dnd._manager){dnd._manager=new _cac();}return dnd._manager;};return _cac;});},"dojo/dnd/Avatar":function(){define(["../_base/declare","../_base/window","../dom","../dom-attr","../dom-class","../dom-construct","../hccss","../query"],function(_cb4,win,dom,_cb5,_cb6,_cb7,has,_cb8){return _cb4("dojo.dnd.Avatar",null,{constructor:function(_cb9){this.manager=_cb9;this.construct();},construct:function(){var a=_cb7.create("table",{"class":"dojoDndAvatar",style:{position:"absolute",zIndex:"1999",margin:"0px"}}),_cba=this.manager.source,node,b=_cb7.create("tbody",null,a),tr=_cb7.create("tr",null,b),td=_cb7.create("td",null,tr),k=Math.min(5,this.manager.nodes.length),i=0;if(has("highcontrast")){_cb7.create("span",{id:"a11yIcon",innerHTML:this.manager.copy?"+":"<"},td);}_cb7.create("span",{innerHTML:_cba.generateText?this._generateText():""},td);_cb5.set(tr,{"class":"dojoDndAvatarHeader",style:{opacity:0.9}});for(;i<k;++i){if(_cba.creator){node=_cba._normalizedCreator(_cba.getItem(this.manager.nodes[i].id).data,"avatar").node;}else{node=this.manager.nodes[i].cloneNode(true);if(node.tagName.toLowerCase()=="tr"){var _cbb=_cb7.create("table"),_cbc=_cb7.create("tbody",null,_cbb);_cbc.appendChild(node);node=_cbb;}}node.id="";tr=_cb7.create("tr",null,b);td=_cb7.create("td",null,tr);td.appendChild(node);_cb5.set(tr,{"class":"dojoDndAvatarItem",style:{opacity:(9-i)/10}});}this.node=a;},destroy:function(){_cb7.destroy(this.node);this.node=false;},update:function(){_cb6.toggle(this.node,"dojoDndAvatarCanDrop",this.manager.canDropFlag);if(has("highcontrast")){var icon=dom.byId("a11yIcon");var text="+";if(this.manager.canDropFlag&&!this.manager.copy){text="< ";}else{if(!this.manager.canDropFlag&&!this.manager.copy){text="o";}else{if(!this.manager.canDropFlag){text="x";}}}icon.innerHTML=text;}_cb8(("tr.dojoDndAvatarHeader td span"+(has("highcontrast")?" span":"")),this.node).forEach(function(node){node.innerHTML=this.manager.source.generateText?this._generateText():"";},this);},_generateText:function(){return this.manager.nodes.length.toString();}});});},"url:dijit/templates/ColorPalette.html":"<div class=\"dijitInline dijitColorPalette\" role=\"grid\">\n\t<table data-dojo-attach-point=\"paletteTableNode\" class=\"dijitPaletteTable\" cellSpacing=\"0\" cellPadding=\"0\" role=\"presentation\">\n\t\t<tbody data-dojo-attach-point=\"gridNode\"></tbody>\n\t</table>\n</div>\n","url:dijit/templates/Dialog.html":"<div class=\"dijitDialog\" role=\"dialog\" aria-labelledby=\"${id}_title\">\n\t<div data-dojo-attach-point=\"titleBar\" class=\"dijitDialogTitleBar\">\n\t\t<span data-dojo-attach-point=\"titleNode\" class=\"dijitDialogTitle\" id=\"${id}_title\"\n\t\t\t\trole=\"heading\" level=\"1\"></span>\n\t\t<span data-dojo-attach-point=\"closeButtonNode\" class=\"dijitDialogCloseIcon\" data-dojo-attach-event=\"ondijitclick: onCancel\" title=\"${buttonCancel}\" role=\"button\" tabindex=\"-1\">\n\t\t\t<span data-dojo-attach-point=\"closeText\" class=\"closeText\" title=\"${buttonCancel}\">x</span>\n\t\t</span>\n\t</div>\n\t<div data-dojo-attach-point=\"containerNode\" class=\"dijitDialogPaneContent\"></div>\n\t${!actionBarTemplate}\n</div>\n\n","url:dijit/form/templates/Button.html":"<span class=\"dijit dijitReset dijitInline\" role=\"presentation\"\n\t><span class=\"dijitReset dijitInline dijitButtonNode\"\n\t\tdata-dojo-attach-event=\"ondijitclick:__onClick\" role=\"presentation\"\n\t\t><span class=\"dijitReset dijitStretch dijitButtonContents\"\n\t\t\tdata-dojo-attach-point=\"titleNode,focusNode\"\n\t\t\trole=\"button\" aria-labelledby=\"${id}_label\"\n\t\t\t><span class=\"dijitReset dijitInline dijitIcon\" data-dojo-attach-point=\"iconNode\"></span\n\t\t\t><span class=\"dijitReset dijitToggleButtonIconChar\">&#x25CF;</span\n\t\t\t><span class=\"dijitReset dijitInline dijitButtonText\"\n\t\t\t\tid=\"${id}_label\"\n\t\t\t\tdata-dojo-attach-point=\"containerNode\"\n\t\t\t></span\n\t\t></span\n\t></span\n\t><input ${!nameAttrSetting} type=\"${type}\" value=\"${value}\" class=\"dijitOffScreen\"\n\t\tdata-dojo-attach-event=\"onclick:_onClick\"\n\t\ttabIndex=\"-1\" aria-hidden=\"true\" data-dojo-attach-point=\"valueNode\"\n/></span>\n","url:dijit/form/templates/CheckBox.html":"<div class=\"dijit dijitReset dijitInline\" role=\"presentation\"\n\t><input\n\t \t${!nameAttrSetting} type=\"${type}\" role=\"${type}\" aria-checked=\"false\" ${checkedAttrSetting}\n\t\tclass=\"dijitReset dijitCheckBoxInput\"\n\t\tdata-dojo-attach-point=\"focusNode\"\n\t \tdata-dojo-attach-event=\"ondijitclick:_onClick\"\n/></div>\n","url:dijit/form/templates/DropDownButton.html":"<span class=\"dijit dijitReset dijitInline\"\n\t><span class='dijitReset dijitInline dijitButtonNode'\n\t\tdata-dojo-attach-event=\"ondijitclick:__onClick\" data-dojo-attach-point=\"_buttonNode\"\n\t\t><span class=\"dijitReset dijitStretch dijitButtonContents\"\n\t\t\tdata-dojo-attach-point=\"focusNode,titleNode,_arrowWrapperNode,_popupStateNode\"\n\t\t\trole=\"button\" aria-haspopup=\"true\" aria-labelledby=\"${id}_label\"\n\t\t\t><span class=\"dijitReset dijitInline dijitIcon\"\n\t\t\t\tdata-dojo-attach-point=\"iconNode\"\n\t\t\t></span\n\t\t\t><span class=\"dijitReset dijitInline dijitButtonText\"\n\t\t\t\tdata-dojo-attach-point=\"containerNode\"\n\t\t\t\tid=\"${id}_label\"\n\t\t\t></span\n\t\t\t><span class=\"dijitReset dijitInline dijitArrowButtonInner\"></span\n\t\t\t><span class=\"dijitReset dijitInline dijitArrowButtonChar\">&#9660;</span\n\t\t></span\n\t></span\n\t><input ${!nameAttrSetting} type=\"${type}\" value=\"${value}\" class=\"dijitOffScreen\" tabIndex=\"-1\"\n\t\tdata-dojo-attach-event=\"onclick:_onClick\" data-dojo-attach-point=\"valueNode\" aria-hidden=\"true\"\n/></span>\n","url:dijit/form/templates/ComboButton.html":"<table class=\"dijit dijitReset dijitInline dijitLeft\"\n\tcellspacing='0' cellpadding='0' role=\"presentation\"\n\t><tbody role=\"presentation\"><tr role=\"presentation\"\n\t\t><td class=\"dijitReset dijitStretch dijitButtonNode\" data-dojo-attach-point=\"buttonNode\" data-dojo-attach-event=\"ondijitclick:__onClick,onkeydown:_onButtonKeyDown\"\n\t\t><div id=\"${id}_button\" class=\"dijitReset dijitButtonContents\"\n\t\t\tdata-dojo-attach-point=\"titleNode\"\n\t\t\trole=\"button\" aria-labelledby=\"${id}_label\"\n\t\t\t><div class=\"dijitReset dijitInline dijitIcon\" data-dojo-attach-point=\"iconNode\" role=\"presentation\"></div\n\t\t\t><div class=\"dijitReset dijitInline dijitButtonText\" id=\"${id}_label\" data-dojo-attach-point=\"containerNode\" role=\"presentation\"></div\n\t\t></div\n\t\t></td\n\t\t><td id=\"${id}_arrow\" class='dijitReset dijitRight dijitButtonNode dijitArrowButton'\n\t\t\tdata-dojo-attach-point=\"_popupStateNode,focusNode,_buttonNode\"\n\t\t\tdata-dojo-attach-event=\"onkeydown:_onArrowKeyDown\"\n\t\t\ttitle=\"${optionsTitle}\"\n\t\t\trole=\"button\" aria-haspopup=\"true\"\n\t\t\t><div class=\"dijitReset dijitArrowButtonInner\" role=\"presentation\"></div\n\t\t\t><div class=\"dijitReset dijitArrowButtonChar\" role=\"presentation\">&#9660;</div\n\t\t></td\n\t\t><td style=\"display:none !important;\"\n\t\t\t><input ${!nameAttrSetting} type=\"${type}\" value=\"${value}\" data-dojo-attach-point=\"valueNode\"\n\t\t\t\tclass=\"dijitOffScreen\" aria-hidden=\"true\" data-dojo-attach-event=\"onclick:_onClick\"\n\t\t/></td></tr></tbody\n></table>\n","url:dijit/form/templates/TextBox.html":"<div class=\"dijit dijitReset dijitInline dijitLeft\" id=\"widget_${id}\" role=\"presentation\"\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class=\"dijitReset dijitInputInner\" data-dojo-attach-point='textbox,focusNode' autocomplete=\"off\"\n\t\t\t${!nameAttrSetting} type='${type}'\n\t/></div\n></div>\n","url:dijit/templates/Tooltip.html":"<div class=\"dijitTooltip dijitTooltipLeft\" id=\"dojoTooltip\" data-dojo-attach-event=\"mouseenter:onMouseEnter,mouseleave:onMouseLeave\"\n\t><div class=\"dijitTooltipConnector\" data-dojo-attach-point=\"connectorNode\"></div\n\t><div class=\"dijitTooltipContainer dijitTooltipContents\" data-dojo-attach-point=\"containerNode\" role='alert'></div\n></div>\n","url:dijit/form/templates/ValidationTextBox.html":"<div class=\"dijit dijitReset dijitInline dijitLeft\"\n\tid=\"widget_${id}\" role=\"presentation\"\n\t><div class='dijitReset dijitValidationContainer'\n\t\t><input class=\"dijitReset dijitInputField dijitValidationIcon dijitValidationInner\" value=\"&#935; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t/></div\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class=\"dijitReset dijitInputInner\" data-dojo-attach-point='textbox,focusNode' autocomplete=\"off\"\n\t\t\t${!nameAttrSetting} type='${type}'\n\t/></div\n></div>\n","url:dijit/form/templates/DropDownBox.html":"<div class=\"dijit dijitReset dijitInline dijitLeft\"\n\tid=\"widget_${id}\"\n\trole=\"combobox\"\n\taria-haspopup=\"true\"\n\tdata-dojo-attach-point=\"_popupStateNode\"\n\t><div class='dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer'\n\t\tdata-dojo-attach-point=\"_buttonNode\" role=\"presentation\"\n\t\t><input class=\"dijitReset dijitInputField dijitArrowButtonInner\" value=\"&#9660; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"button presentation\" aria-hidden=\"true\"\n\t\t\t${_buttonInputDisabled}\n\t/></div\n\t><div class='dijitReset dijitValidationContainer'\n\t\t><input class=\"dijitReset dijitInputField dijitValidationIcon dijitValidationInner\" value=\"&#935; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t/></div\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class='dijitReset dijitInputInner' ${!nameAttrSetting} type=\"${type}\" autocomplete=\"off\"\n\t\t\tdata-dojo-attach-point=\"textbox,focusNode\" role=\"textbox\"\n\t/></div\n></div>\n","url:dijit/templates/Menu.html":"<table class=\"dijit dijitMenu dijitMenuPassive dijitReset dijitMenuTable\" role=\"menu\" tabIndex=\"${tabIndex}\"\n\t   cellspacing=\"0\">\n\t<tbody class=\"dijitReset\" data-dojo-attach-point=\"containerNode\"></tbody>\n</table>\n","url:dijit/templates/MenuItem.html":"<tr class=\"dijitReset\" data-dojo-attach-point=\"focusNode\" role=\"menuitem\" tabIndex=\"-1\">\n\t<td class=\"dijitReset dijitMenuItemIconCell\" role=\"presentation\">\n\t\t<span role=\"presentation\" class=\"dijitInline dijitIcon dijitMenuItemIcon\" data-dojo-attach-point=\"iconNode\"></span>\n\t</td>\n\t<td class=\"dijitReset dijitMenuItemLabel\" colspan=\"2\" data-dojo-attach-point=\"containerNode,textDirNode\"\n\t\trole=\"presentation\"></td>\n\t<td class=\"dijitReset dijitMenuItemAccelKey\" style=\"display: none\" data-dojo-attach-point=\"accelKeyNode\"></td>\n\t<td class=\"dijitReset dijitMenuArrowCell\" role=\"presentation\">\n\t\t<span data-dojo-attach-point=\"arrowWrapper\" style=\"visibility: hidden\">\n\t\t\t<span class=\"dijitInline dijitIcon dijitMenuExpand\"></span>\n\t\t\t<span class=\"dijitMenuExpandA11y\">+</span>\n\t\t</span>\n\t</td>\n</tr>\n","url:dijit/templates/MenuSeparator.html":"<tr class=\"dijitMenuSeparator\" role=\"separator\">\n\t<td class=\"dijitMenuSeparatorIconCell\">\n\t\t<div class=\"dijitMenuSeparatorTop\"></div>\n\t\t<div class=\"dijitMenuSeparatorBottom\"></div>\n\t</td>\n\t<td colspan=\"3\" class=\"dijitMenuSeparatorLabelCell\">\n\t\t<div class=\"dijitMenuSeparatorTop dijitMenuSeparatorLabel\"></div>\n\t\t<div class=\"dijitMenuSeparatorBottom\"></div>\n\t</td>\n</tr>\n","url:dijit/form/templates/Select.html":"<table class=\"dijit dijitReset dijitInline dijitLeft\"\n\tdata-dojo-attach-point=\"_buttonNode,tableNode,focusNode,_popupStateNode\" cellspacing='0' cellpadding='0'\n\trole=\"listbox\" aria-haspopup=\"true\"\n\t><tbody role=\"presentation\"><tr role=\"presentation\"\n\t\t><td class=\"dijitReset dijitStretch dijitButtonContents\" role=\"presentation\"\n\t\t\t><div class=\"dijitReset dijitInputField dijitButtonText\"  data-dojo-attach-point=\"containerNode,textDirNode\" role=\"presentation\"></div\n\t\t\t><div class=\"dijitReset dijitValidationContainer\"\n\t\t\t\t><input class=\"dijitReset dijitInputField dijitValidationIcon dijitValidationInner\" value=\"&#935; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t\t\t/></div\n\t\t\t><input type=\"hidden\" ${!nameAttrSetting} data-dojo-attach-point=\"valueNode\" value=\"${value}\" aria-hidden=\"true\"\n\t\t/></td\n\t\t><td class=\"dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer\"\n\t\t\tdata-dojo-attach-point=\"titleNode\" role=\"presentation\"\n\t\t\t><input class=\"dijitReset dijitInputField dijitArrowButtonInner\" value=\"&#9660; \" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t\t\t\t${_buttonInputDisabled}\n\t\t/></td\n\t></tr></tbody\n></table>\n","url:dijit/templates/InlineEditBox.html":"<span data-dojo-attach-point=\"editNode\" role=\"presentation\" class=\"dijitReset dijitInline dijitOffScreen\"\n\t><span data-dojo-attach-point=\"editorPlaceholder\"></span\n\t><span data-dojo-attach-point=\"buttonContainer\"\n\t\t><button data-dojo-type=\"./form/Button\" data-dojo-props=\"label: '${buttonSave}', 'class': 'saveButton'\"\n\t\t\tdata-dojo-attach-point=\"saveButton\" data-dojo-attach-event=\"onClick:save\"></button\n\t\t><button data-dojo-type=\"./form/Button\"  data-dojo-props=\"label: '${buttonCancel}', 'class': 'cancelButton'\"\n\t\t\tdata-dojo-attach-point=\"cancelButton\" data-dojo-attach-event=\"onClick:cancel\"></button\n\t></span\n></span>\n","url:dijit/templates/CheckedMenuItem.html":"<tr class=\"dijitReset\" data-dojo-attach-point=\"focusNode\" role=\"${role}\" tabIndex=\"-1\" aria-checked=\"${checked}\">\n\t<td class=\"dijitReset dijitMenuItemIconCell\" role=\"presentation\">\n\t\t<span class=\"dijitInline dijitIcon dijitMenuItemIcon dijitCheckedMenuItemIcon\" data-dojo-attach-point=\"iconNode\"></span>\n\t\t<span class=\"dijitMenuItemIconChar dijitCheckedMenuItemIconChar\">${!checkedChar}</span>\n\t</td>\n\t<td class=\"dijitReset dijitMenuItemLabel\" colspan=\"2\" data-dojo-attach-point=\"containerNode,labelNode,textDirNode\"></td>\n\t<td class=\"dijitReset dijitMenuItemAccelKey\" style=\"display: none\" data-dojo-attach-point=\"accelKeyNode\"></td>\n\t<td class=\"dijitReset dijitMenuArrowCell\" role=\"presentation\">&#160;</td>\n</tr>\n","url:dijit/layout/templates/AccordionButton.html":"<div data-dojo-attach-event='ondijitclick:_onTitleClick' class='dijitAccordionTitle' role=\"presentation\">\n\t<div data-dojo-attach-point='titleNode,focusNode' data-dojo-attach-event='onkeydown:_onTitleKeyDown'\n\t\t\tclass='dijitAccordionTitleFocus' role=\"tab\" aria-expanded=\"false\"\n\t\t><span class='dijitInline dijitAccordionArrow' role=\"presentation\"></span\n\t\t><span class='arrowTextUp' role=\"presentation\">+</span\n\t\t><span class='arrowTextDown' role=\"presentation\">-</span\n\t\t><span role=\"presentation\" class=\"dijitInline dijitIcon\" data-dojo-attach-point=\"iconNode\"></span>\n\t\t<span role=\"presentation\" data-dojo-attach-point='titleTextNode, textDirNode' class='dijitAccordionText'></span>\n\t</div>\n</div>\n","url:dijit/layout/templates/TabContainer.html":"<div class=\"dijitTabContainer\">\n\t<div class=\"dijitTabListWrapper\" data-dojo-attach-point=\"tablistNode\"></div>\n\t<div data-dojo-attach-point=\"tablistSpacer\" class=\"dijitTabSpacer ${baseClass}-spacer\"></div>\n\t<div class=\"dijitTabPaneWrapper ${baseClass}-container\" data-dojo-attach-point=\"containerNode\"></div>\n</div>\n","url:dijit/layout/templates/_TabButton.html":"<div role=\"presentation\" data-dojo-attach-point=\"titleNode,innerDiv,tabContent\" class=\"dijitTabInner dijitTabContent\">\n\t<span role=\"presentation\" class=\"dijitInline dijitIcon dijitTabButtonIcon\" data-dojo-attach-point=\"iconNode\"></span>\n\t<span data-dojo-attach-point='containerNode,focusNode' class='tabLabel'></span>\n\t<span class=\"dijitInline dijitTabCloseButton dijitTabCloseIcon\" data-dojo-attach-point='closeNode'\n\t\t  role=\"presentation\">\n\t\t<span data-dojo-attach-point='closeText' class='dijitTabCloseText'>[x]</span\n\t\t\t\t></span>\n</div>\n","url:dijit/layout/templates/ScrollingTabController.html":"<div class=\"dijitTabListContainer-${tabPosition}\" style=\"visibility:hidden\">\n\t<div data-dojo-type=\"dijit.layout._ScrollingTabControllerMenuButton\"\n\t\t class=\"tabStripButton-${tabPosition}\"\n\t\t id=\"${id}_menuBtn\"\n\t\t data-dojo-props=\"containerId: '${containerId}', iconClass: 'dijitTabStripMenuIcon',\n\t\t\t\t\tdropDownPosition: ['below-alt', 'above-alt']\"\n\t\t data-dojo-attach-point=\"_menuBtn\" showLabel=\"false\" title=\"\">&#9660;</div>\n\t<div data-dojo-type=\"dijit.layout._ScrollingTabControllerButton\"\n\t\t class=\"tabStripButton-${tabPosition}\"\n\t\t id=\"${id}_leftBtn\"\n\t\t data-dojo-props=\"iconClass:'dijitTabStripSlideLeftIcon', showLabel:false, title:''\"\n\t\t data-dojo-attach-point=\"_leftBtn\" data-dojo-attach-event=\"onClick: doSlideLeft\">&#9664;</div>\n\t<div data-dojo-type=\"dijit.layout._ScrollingTabControllerButton\"\n\t\t class=\"tabStripButton-${tabPosition}\"\n\t\t id=\"${id}_rightBtn\"\n\t\t data-dojo-props=\"iconClass:'dijitTabStripSlideRightIcon', showLabel:false, title:''\"\n\t\t data-dojo-attach-point=\"_rightBtn\" data-dojo-attach-event=\"onClick: doSlideRight\">&#9654;</div>\n\t<div class='dijitTabListWrapper' data-dojo-attach-point='tablistWrapper'>\n\t\t<div role='tablist' data-dojo-attach-event='onkeydown:onkeydown'\n\t\t\t data-dojo-attach-point='containerNode' class='nowrapTabStrip'></div>\n\t</div>\n</div>","url:dijit/layout/templates/_ScrollingTabControllerButton.html":"<div data-dojo-attach-event=\"ondijitclick:_onClick\" class=\"dijitTabInnerDiv dijitTabContent dijitButtonContents\"  data-dojo-attach-point=\"focusNode\" role=\"button\">\n\t<span role=\"presentation\" class=\"dijitInline dijitTabStripIcon\" data-dojo-attach-point=\"iconNode\"></span>\n\t<span data-dojo-attach-point=\"containerNode,titleNode\" class=\"dijitButtonText\"></span>\n</div>","url:dijit/templates/ProgressBar.html":"<div class=\"dijitProgressBar dijitProgressBarEmpty\" role=\"progressbar\"\n\t><div  data-dojo-attach-point=\"internalProgress\" class=\"dijitProgressBarFull\"\n\t\t><div class=\"dijitProgressBarTile\" role=\"presentation\"></div\n\t\t><span style=\"visibility:hidden\">&#160;</span\n\t></div\n\t><div data-dojo-attach-point=\"labelNode\" class=\"dijitProgressBarLabel\" id=\"${id}_label\"></div\n\t><span data-dojo-attach-point=\"indeterminateHighContrastImage\"\n\t\t   class=\"dijitInline dijitProgressBarIndeterminateHighContrastImage\"></span\n></div>\n","url:dijit/templates/TooltipDialog.html":"<div role=\"alertdialog\" tabIndex=\"-1\">\n\t<div class=\"dijitTooltipContainer\" role=\"presentation\">\n\t\t<div data-dojo-attach-point=\"contentsNode\" class=\"dijitTooltipContents dijitTooltipFocusNode\">\n\t\t\t<div data-dojo-attach-point=\"containerNode\"></div>\n\t\t\t${!actionBarTemplate}\n\t\t</div>\n\t</div>\n\t<div class=\"dijitTooltipConnector\" role=\"presentation\" data-dojo-attach-point=\"connectorNode\"></div>\n</div>\n","url:dijit/templates/TreeNode.html":"<div class=\"dijitTreeNode\" role=\"presentation\"\n\t><div data-dojo-attach-point=\"rowNode\" class=\"dijitTreeRow\" role=\"presentation\"\n\t\t><span data-dojo-attach-point=\"expandoNode\" class=\"dijitInline dijitTreeExpando\" role=\"presentation\"></span\n\t\t><span data-dojo-attach-point=\"expandoNodeText\" class=\"dijitExpandoText\" role=\"presentation\"></span\n\t\t><span data-dojo-attach-point=\"contentNode\"\n\t\t\tclass=\"dijitTreeContent\" role=\"presentation\">\n\t\t\t<span role=\"presentation\" class=\"dijitInline dijitIcon dijitTreeIcon\" data-dojo-attach-point=\"iconNode\"></span\n\t\t\t><span data-dojo-attach-point=\"labelNode,focusNode\" class=\"dijitTreeLabel\" role=\"treeitem\"\n\t\t\t\t   tabindex=\"-1\" aria-selected=\"false\" id=\"${id}_label\"></span>\n\t\t</span\n\t></div>\n\t<div data-dojo-attach-point=\"containerNode\" class=\"dijitTreeNodeContainer\" role=\"presentation\"\n\t\t style=\"display: none;\" aria-labelledby=\"${id}_label\"></div>\n</div>\n","url:dijit/templates/Tree.html":"<div role=\"tree\">\n\t<div class=\"dijitInline dijitTreeIndent\" style=\"position: absolute; top: -9999px\" data-dojo-attach-point=\"indentDetector\"></div>\n\t<div class=\"dijitTreeExpando dijitTreeExpandoLoading\" data-dojo-attach-point=\"rootLoadingIndicator\"></div>\n\t<div data-dojo-attach-point=\"containerNode\" class=\"dijitTreeContainer\" role=\"presentation\">\n\t</div>\n</div>\n","*now":function(r){r(["dojo/i18n!*preload*dojo/nls/tt-rss-layer*[\"ar\",\"ca\",\"cs\",\"da\",\"de\",\"el\",\"en-gb\",\"en-us\",\"es-es\",\"fi-fi\",\"fr-fr\",\"he-il\",\"hu\",\"it-it\",\"ja-jp\",\"ko-kr\",\"nl-nl\",\"nb\",\"pl\",\"pt-br\",\"pt-pt\",\"ru\",\"sk\",\"sl\",\"sv\",\"th\",\"tr\",\"zh-tw\",\"zh-cn\",\"ROOT\"]"]);}}});define("dojo/tt-rss-layer",[],1);
//>>built
require({cache:{"url:dijit/templates/TreeNode.html":"<div class=\"dijitTreeNode\" role=\"presentation\"\n\t><div data-dojo-attach-point=\"rowNode\" class=\"dijitTreeRow\" role=\"presentation\"\n\t\t><span data-dojo-attach-point=\"expandoNode\" class=\"dijitInline dijitTreeExpando\" role=\"presentation\"></span\n\t\t><span data-dojo-attach-point=\"expandoNodeText\" class=\"dijitExpandoText\" role=\"presentation\"></span\n\t\t><span data-dojo-attach-point=\"contentNode\"\n\t\t\tclass=\"dijitTreeContent\" role=\"presentation\">\n\t\t\t<span role=\"presentation\" class=\"dijitInline dijitIcon dijitTreeIcon\" data-dojo-attach-point=\"iconNode\"></span\n\t\t\t><span data-dojo-attach-point=\"labelNode,focusNode\" class=\"dijitTreeLabel\" role=\"treeitem\"\n\t\t\t\t   tabindex=\"-1\" aria-selected=\"false\" id=\"${id}_label\"></span>\n\t\t</span\n\t></div>\n\t<div data-dojo-attach-point=\"containerNode\" class=\"dijitTreeNodeContainer\" role=\"presentation\"\n\t\t style=\"display: none;\" aria-labelledby=\"${id}_label\"></div>\n</div>\n","url:dijit/templates/Tree.html":"<div role=\"tree\">\n\t<div class=\"dijitInline dijitTreeIndent\" style=\"position: absolute; top: -9999px\" data-dojo-attach-point=\"indentDetector\"></div>\n\t<div class=\"dijitTreeExpando dijitTreeExpandoLoading\" data-dojo-attach-point=\"rootLoadingIndicator\"></div>\n\t<div data-dojo-attach-point=\"containerNode\" class=\"dijitTreeContainer\" role=\"presentation\">\n\t</div>\n</div>\n"}});define("dijit/Tree",["dojo/_base/array","dojo/aspect","dojo/cookie","dojo/_base/declare","dojo/Deferred","dojo/promise/all","dojo/dom","dojo/dom-class","dojo/dom-geometry","dojo/dom-style","dojo/errors/create","dojo/fx","dojo/has","dojo/_base/kernel","dojo/keys","dojo/_base/lang","dojo/on","dojo/topic","dojo/touch","dojo/when","./a11yclick","./focus","./registry","./_base/manager","./_Widget","./_TemplatedMixin","./_Container","./_Contained","./_CssStateMixin","./_KeyNavMixin","dojo/text!./templates/TreeNode.html","dojo/text!./templates/Tree.html","./tree/TreeStoreModel","./tree/ForestStoreModel","./tree/_dndSelector","dojo/query!css2"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,on,_11,_12,_13,_14,_15,_16,_17,_18,_19,_1a,_1b,_1c,_1d,_1e,_1f,_20,_21,_22){function _23(d){return _10.delegate(d.promise||d,{addCallback:function(_24){this.then(_24);},addErrback:function(_25){this.otherwise(_25);}});};var _26=_4("dijit._TreeNode",[_18,_19,_1a,_1b,_1c],{item:null,isTreeNode:true,label:"",_setLabelAttr:function(val){this.labelNode[this.labelType=="html"?"innerHTML":"innerText" in this.labelNode?"innerText":"textContent"]=val;this._set("label",val);if(_d("dojo-bidi")){this.applyTextDir(this.labelNode);}},labelType:"text",isExpandable:null,isExpanded:false,state:"NotLoaded",templateString:_1e,baseClass:"dijitTreeNode",cssStateNodes:{rowNode:"dijitTreeRow"},_setTooltipAttr:{node:"rowNode",type:"attribute",attribute:"title"},buildRendering:function(){this.inherited(arguments);this._setExpando();this._updateItemClasses(this.item);if(this.isExpandable){this.labelNode.setAttribute("aria-expanded",this.isExpanded);}this.setSelected(false);},_setIndentAttr:function(_27){var _28=(Math.max(_27,0)*this.tree._nodePixelIndent)+"px";_a.set(this.domNode,"backgroundPosition",_28+" 0px");_a.set(this.rowNode,this.isLeftToRight()?"paddingLeft":"paddingRight",_28);_1.forEach(this.getChildren(),function(_29){_29.set("indent",_27+1);});this._set("indent",_27);},markProcessing:function(){this.state="Loading";this._setExpando(true);},unmarkProcessing:function(){this._setExpando(false);},_updateItemClasses:function(_2a){var _2b=this.tree,_2c=_2b.model;if(_2b._v10Compat&&_2a===_2c.root){_2a=null;}this._applyClassAndStyle(_2a,"icon","Icon");this._applyClassAndStyle(_2a,"label","Label");this._applyClassAndStyle(_2a,"row","Row");this.tree._startPaint(true);},_applyClassAndStyle:function(_2d,_2e,_2f){var _30="_"+_2e+"Class";var _31=_2e+"Node";var _32=this[_30];this[_30]=this.tree["get"+_2f+"Class"](_2d,this.isExpanded);_8.replace(this[_31],this[_30]||"",_32||"");_a.set(this[_31],this.tree["get"+_2f+"Style"](_2d,this.isExpanded)||{});},_updateLayout:function(){var _33=this.getParent(),_34=!_33||!_33.rowNode||_33.rowNode.style.display=="none";_8.toggle(this.domNode,"dijitTreeIsRoot",_34);_8.toggle(this.domNode,"dijitTreeIsLast",!_34&&!this.getNextSibling());},_setExpando:function(_35){var _36=["dijitTreeExpandoLoading","dijitTreeExpandoOpened","dijitTreeExpandoClosed","dijitTreeExpandoLeaf"],_37=["*","-","+","*"],idx=_35?0:(this.isExpandable?(this.isExpanded?1:2):3);_8.replace(this.expandoNode,_36[idx],_36);this.expandoNodeText.innerHTML=_37[idx];},expand:function(){if(this._expandDeferred){return _23(this._expandDeferred);}if(this._collapseDeferred){this._collapseDeferred.cancel();delete this._collapseDeferred;}this.isExpanded=true;this.labelNode.setAttribute("aria-expanded","true");if(this.tree.showRoot||this!==this.tree.rootNode){this.containerNode.setAttribute("role","group");}_8.add(this.contentNode,"dijitTreeContentExpanded");this._setExpando();this._updateItemClasses(this.item);if(this==this.tree.rootNode&&this.tree.showRoot){this.tree.domNode.setAttribute("aria-expanded","true");}var _38=_c.wipeIn({node:this.containerNode,duration:_17.defaultDuration});var def=(this._expandDeferred=new _5(function(){_38.stop();}));_2.after(_38,"onEnd",function(){def.resolve(true);},true);_38.play();return _23(def);},collapse:function(){if(this._collapseDeferred){return _23(this._collapseDeferred);}if(this._expandDeferred){this._expandDeferred.cancel();delete this._expandDeferred;}this.isExpanded=false;this.labelNode.setAttribute("aria-expanded","false");if(this==this.tree.rootNode&&this.tree.showRoot){this.tree.domNode.setAttribute("aria-expanded","false");}_8.remove(this.contentNode,"dijitTreeContentExpanded");this._setExpando();this._updateItemClasses(this.item);var _39=_c.wipeOut({node:this.containerNode,duration:_17.defaultDuration});var def=(this._collapseDeferred=new _5(function(){_39.stop();}));_2.after(_39,"onEnd",function(){def.resolve(true);},true);_39.play();return _23(def);},indent:0,setChildItems:function(_3a){var _3b=this.tree,_3c=_3b.model,_3d=[];var _3e=_3b.focusedChild;var _3f=this.getChildren();_1.forEach(_3f,function(_40){_1a.prototype.removeChild.call(this,_40);},this);this.defer(function(){_1.forEach(_3f,function(_41){if(!_41._destroyed&&!_41.getParent()){_3b.dndController.removeTreeNode(_41);function _42(_43){var id=_3c.getIdentity(_43.item),ary=_3b._itemNodesMap[id];if(ary.length==1){delete _3b._itemNodesMap[id];}else{var _44=_1.indexOf(ary,_43);if(_44!=-1){ary.splice(_44,1);}}_1.forEach(_43.getChildren(),_42);};_42(_41);if(_3b.persist){var _45=_1.map(_41.getTreePath(),function(_46){return _3b.model.getIdentity(_46);}).join("/");for(var _47 in _3b._openedNodes){if(_47.substr(0,_45.length)==_45){delete _3b._openedNodes[_47];}}_3b._saveExpandedNodes();}if(_3b.lastFocusedChild&&!_7.isDescendant(_3b.lastFocusedChild.domNode,_3b.domNode)){delete _3b.lastFocusedChild;}if(_3e&&!_7.isDescendant(_3e.domNode,_3b.domNode)){_3b.focus();}_41.destroyRecursive();}});});this.state="Loaded";if(_3a&&_3a.length>0){this.isExpandable=true;_1.forEach(_3a,function(_48){var id=_3c.getIdentity(_48),_49=_3b._itemNodesMap[id],_4a;if(_49){for(var i=0;i<_49.length;i++){if(_49[i]&&!_49[i].getParent()){_4a=_49[i];_4a.set("indent",this.indent+1);break;}}}if(!_4a){_4a=this.tree._createTreeNode({item:_48,tree:_3b,isExpandable:_3c.mayHaveChildren(_48),label:_3b.getLabel(_48),labelType:(_3b.model&&_3b.model.labelType)||"text",tooltip:_3b.getTooltip(_48),ownerDocument:_3b.ownerDocument,dir:_3b.dir,lang:_3b.lang,textDir:_3b.textDir,indent:this.indent+1});if(_49){_49.push(_4a);}else{_3b._itemNodesMap[id]=[_4a];}}this.addChild(_4a);if(this.tree.autoExpand||this.tree._state(_4a)){_3d.push(_3b._expandNode(_4a));}},this);_1.forEach(this.getChildren(),function(_4b){_4b._updateLayout();});}else{this.isExpandable=false;}if(this._setExpando){this._setExpando(false);}this._updateItemClasses(this.item);var def=_6(_3d);this.tree._startPaint(def);return _23(def);},getTreePath:function(){var _4c=this;var _4d=[];while(_4c&&_4c!==this.tree.rootNode){_4d.unshift(_4c.item);_4c=_4c.getParent();}_4d.unshift(this.tree.rootNode.item);return _4d;},getIdentity:function(){return this.tree.model.getIdentity(this.item);},removeChild:function(_4e){this.inherited(arguments);var _4f=this.getChildren();if(_4f.length==0){this.isExpandable=false;this.collapse();}_1.forEach(_4f,function(_50){_50._updateLayout();});},makeExpandable:function(){this.isExpandable=true;this._setExpando(false);},setSelected:function(_51){this.labelNode.setAttribute("aria-selected",_51?"true":"false");_8.toggle(this.rowNode,"dijitTreeRowSelected",_51);},focus:function(){_15.focus(this.focusNode);}});if(_d("dojo-bidi")){_26.extend({_setTextDirAttr:function(_52){if(_52&&((this.textDir!=_52)||!this._created)){this._set("textDir",_52);this.applyTextDir(this.labelNode);_1.forEach(this.getChildren(),function(_53){_53.set("textDir",_52);},this);}}});}var _54=_4("dijit.Tree",[_18,_1d,_19,_1c],{baseClass:"dijitTree",store:null,model:null,query:null,label:"",showRoot:true,childrenAttr:["children"],paths:[],path:[],selectedItems:null,selectedItem:null,openOnClick:false,openOnDblClick:false,templateString:_1f,persist:false,autoExpand:false,dndController:_22,dndParams:["onDndDrop","itemCreator","onDndCancel","checkAcceptance","checkItemAcceptance","dragThreshold","betweenThreshold"],onDndDrop:null,itemCreator:null,onDndCancel:null,checkAcceptance:null,checkItemAcceptance:null,dragThreshold:5,betweenThreshold:0,_nodePixelIndent:19,_publish:function(_55,_56){_11.publish(this.id,_10.mixin({tree:this,event:_55},_56||{}));},postMixInProperties:function(){this.tree=this;if(this.autoExpand){this.persist=false;}this._itemNodesMap={};if(!this.cookieName&&this.id){this.cookieName=this.id+"SaveStateCookie";}this.expandChildrenDeferred=new _5();this.pendingCommandsPromise=this.expandChildrenDeferred.promise;this.inherited(arguments);},postCreate:function(){this._initState();var _57=this;this.own(on(this.containerNode,on.selector(".dijitTreeNode",_12.enter),function(evt){_57._onNodeMouseEnter(_16.byNode(this),evt);}),on(this.containerNode,on.selector(".dijitTreeNode",_12.leave),function(evt){_57._onNodeMouseLeave(_16.byNode(this),evt);}),on(this.containerNode,on.selector(".dijitTreeRow",_14.press),function(evt){_57._onNodePress(_16.getEnclosingWidget(this),evt);}),on(this.containerNode,on.selector(".dijitTreeRow",_14),function(evt){_57._onClick(_16.getEnclosingWidget(this),evt);}),on(this.containerNode,on.selector(".dijitTreeRow","dblclick"),function(evt){_57._onDblClick(_16.getEnclosingWidget(this),evt);}));if(!this.model){this._store2model();}this.own(_2.after(this.model,"onChange",_10.hitch(this,"_onItemChange"),true),_2.after(this.model,"onChildrenChange",_10.hitch(this,"_onItemChildrenChange"),true),_2.after(this.model,"onDelete",_10.hitch(this,"_onItemDelete"),true));this.inherited(arguments);if(this.dndController){if(_10.isString(this.dndController)){this.dndController=_10.getObject(this.dndController);}var _58={};for(var i=0;i<this.dndParams.length;i++){if(this[this.dndParams[i]]){_58[this.dndParams[i]]=this[this.dndParams[i]];}}this.dndController=new this.dndController(this,_58);}this._load();this.onLoadDeferred=_23(this.pendingCommandsPromise);this.onLoadDeferred.then(_10.hitch(this,"onLoad"));},_store2model:function(){this._v10Compat=true;_e.deprecated("Tree: from version 2.0, should specify a model object rather than a store/query");var _59={id:this.id+"_ForestStoreModel",store:this.store,query:this.query,childrenAttrs:this.childrenAttr};if(this.params.mayHaveChildren){_59.mayHaveChildren=_10.hitch(this,"mayHaveChildren");}if(this.params.getItemChildren){_59.getChildren=_10.hitch(this,function(_5a,_5b,_5c){this.getItemChildren((this._v10Compat&&_5a===this.model.root)?null:_5a,_5b,_5c);});}this.model=new _21(_59);this.showRoot=Boolean(this.label);},onLoad:function(){},_load:function(){this.model.getRoot(_10.hitch(this,function(_5d){var rn=(this.rootNode=this.tree._createTreeNode({item:_5d,tree:this,isExpandable:true,label:this.label||this.getLabel(_5d),labelType:this.model.labelType||"text",textDir:this.textDir,indent:this.showRoot?0:-1}));if(!this.showRoot){rn.rowNode.style.display="none";this.domNode.setAttribute("role","presentation");this.domNode.removeAttribute("aria-expanded");this.domNode.removeAttribute("aria-multiselectable");if(this["aria-label"]){rn.containerNode.setAttribute("aria-label",this["aria-label"]);this.domNode.removeAttribute("aria-label");}else{if(this["aria-labelledby"]){rn.containerNode.setAttribute("aria-labelledby",this["aria-labelledby"]);this.domNode.removeAttribute("aria-labelledby");}}rn.labelNode.setAttribute("role","presentation");rn.labelNode.removeAttribute("aria-selected");rn.containerNode.setAttribute("role","tree");rn.containerNode.setAttribute("aria-expanded","true");rn.containerNode.setAttribute("aria-multiselectable",!this.dndController.singular);}else{this.domNode.setAttribute("aria-multiselectable",!this.dndController.singular);this.rootLoadingIndicator.style.display="none";}this.containerNode.appendChild(rn.domNode);var _5e=this.model.getIdentity(_5d);if(this._itemNodesMap[_5e]){this._itemNodesMap[_5e].push(rn);}else{this._itemNodesMap[_5e]=[rn];}rn._updateLayout();this._expandNode(rn).then(_10.hitch(this,function(){if(!this._destroyed){this.rootLoadingIndicator.style.display="none";this.expandChildrenDeferred.resolve(true);}}));}),_10.hitch(this,function(err){console.error(this,": error loading root: ",err);}));},getNodesByItem:function(_5f){if(!_5f){return [];}var _60=_10.isString(_5f)?_5f:this.model.getIdentity(_5f);return [].concat(this._itemNodesMap[_60]);},_setSelectedItemAttr:function(_61){this.set("selectedItems",[_61]);},_setSelectedItemsAttr:function(_62){var _63=this;return this.pendingCommandsPromise=this.pendingCommandsPromise.always(_10.hitch(this,function(){var _64=_1.map(_62,function(_65){return (!_65||_10.isString(_65))?_65:_63.model.getIdentity(_65);});var _66=[];_1.forEach(_64,function(id){_66=_66.concat(_63._itemNodesMap[id]||[]);});this.set("selectedNodes",_66);}));},_setPathAttr:function(_67){if(_67.length){return _23(this.set("paths",[_67]).then(function(_68){return _68[0];}));}else{return _23(this.set("paths",[]).then(function(_69){return _69[0];}));}},_setPathsAttr:function(_6a){var _6b=this;function _6c(_6d,_6e){var _6f=_6d.shift();var _70=_1.filter(_6e,function(_71){return _71.getIdentity()==_6f;})[0];if(!!_70){if(_6d.length){return _6b._expandNode(_70).then(function(){return _6c(_6d,_70.getChildren());});}else{return _70;}}else{throw new _54.PathError("Could not expand path at "+_6f);}};return _23(this.pendingCommandsPromise=this.pendingCommandsPromise.always(function(){return _6(_1.map(_6a,function(_72){_72=_1.map(_72,function(_73){return _73&&_10.isObject(_73)?_6b.model.getIdentity(_73):_73;});if(_72.length){return _6c(_72,[_6b.rootNode]);}else{throw new _54.PathError("Empty path");}}));}).then(function setNodes(_74){_6b.set("selectedNodes",_74);return _6b.paths;}));},_setSelectedNodeAttr:function(_75){this.set("selectedNodes",[_75]);},_setSelectedNodesAttr:function(_76){this.dndController.setSelection(_76);},expandAll:function(){var _77=this;function _78(_79){return _77._expandNode(_79).then(function(){var _7a=_1.filter(_79.getChildren()||[],function(_7b){return _7b.isExpandable;});return _6(_1.map(_7a,_78));});};return _23(_78(this.rootNode));},collapseAll:function(){var _7c=this;function _7d(_7e){var _7f=_1.filter(_7e.getChildren()||[],function(_80){return _80.isExpandable;}),_81=_6(_1.map(_7f,_7d));if(!_7e.isExpanded||(_7e==_7c.rootNode&&!_7c.showRoot)){return _81;}else{return _81.then(function(){return _7c._collapseNode(_7e);});}};return _23(_7d(this.rootNode));},mayHaveChildren:function(){},getItemChildren:function(){},getLabel:function(_82){return this.model.getLabel(_82);},getIconClass:function(_83,_84){return (!_83||this.model.mayHaveChildren(_83))?(_84?"dijitFolderOpened":"dijitFolderClosed"):"dijitLeaf";},getLabelClass:function(){},getRowClass:function(){},getIconStyle:function(){},getLabelStyle:function(){},getRowStyle:function(){},getTooltip:function(){return "";},_onDownArrow:function(evt,_85){var _86=this._getNext(_85);if(_86&&_86.isTreeNode){this.focusNode(_86);}},_onUpArrow:function(evt,_87){var _88=_87.getPreviousSibling();if(_88){_87=_88;while(_87.isExpandable&&_87.isExpanded&&_87.hasChildren()){var _89=_87.getChildren();_87=_89[_89.length-1];}}else{var _8a=_87.getParent();if(!(!this.showRoot&&_8a===this.rootNode)){_87=_8a;}}if(_87&&_87.isTreeNode){this.focusNode(_87);}},_onRightArrow:function(evt,_8b){if(_8b.isExpandable&&!_8b.isExpanded){this._expandNode(_8b);}else{if(_8b.hasChildren()){_8b=_8b.getChildren()[0];if(_8b&&_8b.isTreeNode){this.focusNode(_8b);}}}},_onLeftArrow:function(evt,_8c){if(_8c.isExpandable&&_8c.isExpanded){this._collapseNode(_8c);}else{var _8d=_8c.getParent();if(_8d&&_8d.isTreeNode&&!(!this.showRoot&&_8d===this.rootNode)){this.focusNode(_8d);}}},focusLastChild:function(){var _8e=this._getLast();if(_8e&&_8e.isTreeNode){this.focusNode(_8e);}},_getFirst:function(){return this.showRoot?this.rootNode:this.rootNode.getChildren()[0];},_getLast:function(){var _8f=this.rootNode;while(_8f.isExpanded){var c=_8f.getChildren();if(!c.length){break;}_8f=c[c.length-1];}return _8f;},_getNext:function(_90){if(_90.isExpandable&&_90.isExpanded&&_90.hasChildren()){return _90.getChildren()[0];}else{while(_90&&_90.isTreeNode){var _91=_90.getNextSibling();if(_91){return _91;}_90=_90.getParent();}return null;}},childSelector:".dijitTreeRow",isExpandoNode:function(_92,_93){return _7.isDescendant(_92,_93.expandoNode)||_7.isDescendant(_92,_93.expandoNodeText);},_onNodePress:function(_94,e){this.focusNode(_94);},__click:function(_95,e,_96,_97){var _98=e.target,_99=this.isExpandoNode(_98,_95);if(_95.isExpandable&&(_96||_99)){this._onExpandoClick({node:_95});}else{this._publish("execute",{item:_95.item,node:_95,evt:e});this[_97](_95.item,_95,e);this.focusNode(_95);}e.stopPropagation();e.preventDefault();},_onClick:function(_9a,e){this.__click(_9a,e,this.openOnClick,"onClick");},_onDblClick:function(_9b,e){this.__click(_9b,e,this.openOnDblClick,"onDblClick");},_onExpandoClick:function(_9c){var _9d=_9c.node;this.focusNode(_9d);if(_9d.isExpanded){this._collapseNode(_9d);}else{this._expandNode(_9d);}},onClick:function(){},onDblClick:function(){},onOpen:function(){},onClose:function(){},_getNextNode:function(_9e){_e.deprecated(this.declaredClass+"::_getNextNode(node) is deprecated. Use _getNext(node) instead.","","2.0");return this._getNext(_9e);},_getRootOrFirstNode:function(){_e.deprecated(this.declaredClass+"::_getRootOrFirstNode() is deprecated. Use _getFirst() instead.","","2.0");return this._getFirst();},_collapseNode:function(_9f){if(_9f._expandNodeDeferred){delete _9f._expandNodeDeferred;}if(_9f.state=="Loading"){return;}if(_9f.isExpanded){var ret=_9f.collapse();this.onClose(_9f.item,_9f);this._state(_9f,false);this._startPaint(ret);return ret;}},_expandNode:function(_a0){if(_a0._expandNodeDeferred){return _a0._expandNodeDeferred;}var _a1=this.model,_a2=_a0.item,_a3=this;if(!_a0._loadDeferred){_a0.markProcessing();_a0._loadDeferred=new _5();_a1.getChildren(_a2,function(_a4){_a0.unmarkProcessing();_a0.setChildItems(_a4).then(function(){_a0._loadDeferred.resolve(_a4);});},function(err){console.error(_a3,": error loading "+_a0.label+" children: ",err);_a0._loadDeferred.reject(err);});}var def=_a0._loadDeferred.then(_10.hitch(this,function(){var _a5=_a0.expand();this.onOpen(_a0.item,_a0);this._state(_a0,true);return _a5;}));this._startPaint(def);return def;},focusNode:function(_a6){var tmp=[];for(var _a7=this.domNode;_a7&&_a7.tagName&&_a7.tagName.toUpperCase()!=="IFRAME";_a7=_a7.parentNode){tmp.push({domNode:_a7.contentWindow||_a7,scrollLeft:_a7.scrollLeft||0,scrollTop:_a7.scrollTop||0});}this.focusChild(_a6);this.defer(function(){for(var i=0,max=tmp.length;i<max;i++){tmp[i].domNode.scrollLeft=tmp[i].scrollLeft;tmp[i].domNode.scrollTop=tmp[i].scrollTop;}},0);},_onNodeMouseEnter:function(){},_onNodeMouseLeave:function(){},_onItemChange:function(_a8){var _a9=this.model,_aa=_a9.getIdentity(_a8),_ab=this._itemNodesMap[_aa];if(_ab){var _ac=this.getLabel(_a8),_ad=this.getTooltip(_a8);_1.forEach(_ab,function(_ae){_ae.set({item:_a8,label:_ac,tooltip:_ad});_ae._updateItemClasses(_a8);});}},_onItemChildrenChange:function(_af,_b0){var _b1=this.model,_b2=_b1.getIdentity(_af),_b3=this._itemNodesMap[_b2];if(_b3){_1.forEach(_b3,function(_b4){_b4.setChildItems(_b0);});}},_onItemDelete:function(_b5){var _b6=this.model,_b7=_b6.getIdentity(_b5),_b8=this._itemNodesMap[_b7];if(_b8){_1.forEach(_b8,function(_b9){this.dndController.removeTreeNode(_b9);var _ba=_b9.getParent();if(_ba){_ba.removeChild(_b9);}if(this.lastFocusedChild&&!_7.isDescendant(this.lastFocusedChild.domNode,this.domNode)){delete this.lastFocusedChild;}if(this.focusedChild&&!_7.isDescendant(this.focusedChild.domNode,this.domNode)){this.focus();}_b9.destroyRecursive();},this);delete this._itemNodesMap[_b7];}},_initState:function(){this._openedNodes={};if(this.persist&&this.cookieName){var _bb=_3(this.cookieName);if(_bb){_1.forEach(_bb.split(","),function(_bc){this._openedNodes[_bc]=true;},this);}}},_state:function(_bd,_be){if(!this.persist){return false;}var _bf=_1.map(_bd.getTreePath(),function(_c0){return this.model.getIdentity(_c0);},this).join("/");if(arguments.length===1){return this._openedNodes[_bf];}else{if(_be){this._openedNodes[_bf]=true;}else{delete this._openedNodes[_bf];}this._saveExpandedNodes();}},_saveExpandedNodes:function(){if(this.persist&&this.cookieName){var ary=[];for(var id in this._openedNodes){ary.push(id);}_3(this.cookieName,ary.join(","),{expires:365});}},destroy:function(){if(this._curSearch){this._curSearch.timer.remove();delete this._curSearch;}if(this.rootNode){this.rootNode.destroyRecursive();}if(this.dndController&&!_10.isString(this.dndController)){this.dndController.destroy();}this.rootNode=null;this.inherited(arguments);},destroyRecursive:function(){this.destroy();},resize:function(_c1){if(_c1){_9.setMarginBox(this.domNode,_c1);}this._nodePixelIndent=_9.position(this.tree.indentDetector).w||this._nodePixelIndent;this.expandChildrenDeferred.then(_10.hitch(this,function(){this.rootNode.set("indent",this.showRoot?0:-1);this._adjustWidths();}));},_outstandingPaintOperations:0,_startPaint:function(p){this._outstandingPaintOperations++;if(this._adjustWidthsTimer){this._adjustWidthsTimer.remove();delete this._adjustWidthsTimer;}var oc=_10.hitch(this,function(){this._outstandingPaintOperations--;if(this._outstandingPaintOperations<=0&&!this._adjustWidthsTimer&&this._started){this._adjustWidthsTimer=this.defer("_adjustWidths");}});_13(p,oc,oc);},_adjustWidths:function(){if(this._adjustWidthsTimer){this._adjustWidthsTimer.remove();delete this._adjustWidthsTimer;}this.containerNode.style.width="auto";this.containerNode.style.width=this.domNode.scrollWidth>this.domNode.offsetWidth?"auto":"100%";},_createTreeNode:function(_c2){return new _26(_c2);},focus:function(){if(this.lastFocusedChild){this.focusNode(this.lastFocusedChild);}else{this.focusFirstChild();}}});if(_d("dojo-bidi")){_54.extend({_setTextDirAttr:function(_c3){if(_c3&&this.textDir!=_c3){this._set("textDir",_c3);this.rootNode.set("textDir",_c3);}}});}_54.PathError=_b("TreePathError");_54._TreeNode=_26;return _54;});    How to keep colapsed category "Special"?