text: ﻿/*! Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved. Licensed under the Apache License, Version 2.0. See https://github.com/winjs/winjs/blob/master/License.txt for license information. */
  !function(a){!function(b){"function"==typeof define&&define.amd?define(["./base"],b):(a.msWriteProfilerMark&&msWriteProfilerMark("WinJS.3.0 3.0.0.winjs.2014.10.2 ui.js,StartTM"),b(a.WinJS),a.msWriteProfilerMark&&msWriteProfilerMark("WinJS.3.0 3.0.0.winjs.2014.10.2 ui.js,StopTM"))}(function(b){var c=b.Utilities._require,d=b.Utilities._define;d("WinJS/VirtualizedDataSource/_VirtualizedDataSourceImpl",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Promise","../Scheduler","../_Signal","../Utilities/_UI"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{VirtualizedDataSource:c.Namespace._lazy(function(){function a(a,c){function f(a){var b="WinJS.UI.VirtualizedDataSource:"+pe+":"+a+",StartTM";i(b),g.log&&g.log(b,"winjs vds","perf")}function u(a){var b="WinJS.UI.VirtualizedDataSource:"+pe+":"+a+",StopTM";i(b),g.log&&g.log(b,"winjs vds","perf")}function v(a){return"number"==typeof a&&a>=0}function w(a){return v(a)&&a===Math.floor(a)}function x(a){if(null===a)a=void 0;else if(void 0!==a&&!w(a))throw new e("WinJS.UI.ListDataSource.InvalidIndexReturned",s.invalidIndexReturned);return a}function y(a){if(null===a)a=void 0;else if(void 0!==a&&!w(a)&&a!==p.unknown)throw new e("WinJS.UI.ListDataSource.InvalidCountReturned",s.invalidCountReturned);return a}function z(){var a=(nd++).toString(),b={handle:a,item:null,itemNew:null,fetchListeners:null,cursorCount:0,bindingMap:null};return Nd[a]=b,b}function A(){return z()}function B(a,b){a.prev=b.prev,a.next=b,a.prev.next=a,b.prev=a}function C(a){a.lastInSequence&&(delete a.lastInSequence,a.prev.lastInSequence=!0),a.firstInSequence&&(delete a.firstInSequence,a.next.firstInSequence=!0),a.prev.next=a.next,a.next.prev=a.prev}function D(a){for(;!a.firstInSequence;)a=a.prev;return a}function E(a){for(;!a.lastInSequence;)a=a.next;return a}function F(a,b,c){return b.prev.next=c.next,c.next.prev=b.prev,b.prev=a.prev,c.next=a,b.prev.next=b,a.prev=c,!0}function G(a,b,c){return b.prev.next=c.next,c.next.prev=b.prev,b.prev=a,c.next=a.next,a.next=b,c.next.prev=c,!0}function H(a){delete a.lastInSequence,delete a.next.firstInSequence}function I(a){var b=a.next;a.lastInSequence=!0,b.firstInSequence=!0,b===Ld&&nb(Ld,void 0)}function J(a,b,c,d){B(a,b);var e=a.prev;e.lastInSequence&&(c?delete e.lastInSequence:a.firstInSequence=!0,d?delete b.firstInSequence:a.lastInSequence=!0)}function K(a,b){a.key=b,Od[a.key]=a}function L(a,b,c){+b===b&&(a.index=b,c[b]=a,Ad||(a.firstInSequence&&a.prev&&a.prev.index===b-1&&H(a.prev),a.lastInSequence&&a.next&&a.next.index===b+1&&H(a)))}function M(a,b){var c=b===Pd?A():z();return B(c,a),c}function N(a,b,c){var d=M(a,c);return d.firstInSequence=!0,d.lastInSequence=!0,L(d,b,c),d}function O(a,b){return N(a,b,Pd)}function P(a,b){var c=M(a,b);return delete a.firstInSequence,c.prev.index===c.index-1?delete c.prev.lastInSequence:c.firstInSequence=!0,L(c,a.index-1,b),c}function Q(a,b){var c=M(a.next,b);return delete a.lastInSequence,c.next.index===c.index+1?delete c.next.firstInSequence:c.lastInSequence=!0,L(c,a.index+1,b),c}function R(a,b,c,d){J(a,b,c,d),Od[a.key]=a,void 0!==a.index&&(Pd[a.index]=a)}function S(a){C(a),a.key&&delete Od[a.key],void 0!==a.index&&Pd[a.index]===a&&delete Pd[a.index];var b=a.bindingMap;for(var c in b){var d=b[c].handle;d&&Nd[d]===a&&delete Nd[d]}Nd[a.handle]===a&&delete Nd[a.handle]}function T(a){return!Nd[a.handle]}function U(a,b,c,d,e){var f=e?null:b[a-1];if(f&&(f.next!==d||d.firstInSequence))f=f.next;else if(f=b[a+1],!f){f=c.next;for(var g;;){if(f.firstInSequence&&(g=f),!(a>=f.index)||f===d)break;f=f.next}f!==d||d.firstInSequence||(f=g&&void 0===g.index?g:void 0)}return f}function V(a){return!a.item&&!a.itemNew&&a!==Ld}function W(a,b){Object.defineProperty(a,"handle",{value:b,writable:!1,enumerable:!1,configurable:!0})}function X(a,b,c){W(a,c),Object.defineProperty(a,"index",{get:function(){for(;b.slotMergedWith;)b=b.slotMergedWith;return b.index},enumerable:!1,configurable:!0})}function Y(a){if(void 0===a)return a;var b=JSON.stringify(a);if(void 0===b)throw new e("WinJS.UI.ListDataSource.ObjectIsNotValidJson",s.objectIsNotValidJson);return b}function Z(b){return a.itemSignature?a.itemSignature(b.data):Y(b.data)}function $(b){var c=b.itemNew;b.itemNew=null,c&&(c=Object.create(c),X(c,b,b.handle),a.compareByIdentity||(b.signature=Z(c))),b.item=c,delete b.indexRequested,delete b.keyRequested}function _(a){return a.bindingMap||a.cursorCount>0}function ab(a){return _(a)||a.fetchListeners||a.directFetchListeners}function bb(a){return ab(a)||!a.firstInSequence&&_(a.prev)||!a.lastInSequence&&_(a.next)||!ie&&(!a.firstInSequence&&a.prev!==Kd&&!(a.prev.item||a.prev.itemNew))|(!a.lastInSequence&&a.next!==Ld&&!(a.next.item||a.next.itemNew))}function cb(a){I(a),S(a)}function db(){if(!vd){(!Rd||T(Rd))&&(Rd=Ld.prev);for(var a=Rd.prev,b=Rd.next,c=0,d=function(a){a===Ld||bb(a)||(hd>=c?c++:cb(a))};a||b;){if(a){var e=a;a=e.prev,e!==Kd&&d(e)}if(b){var f=b;b=f.next,f!==Md&&d(f)}}Qd=0}}function eb(a){ab(a)||(Qd++,vd||Ud||(Rd=a,Qd>hd&&!Sd&&(Sd=!0,k.schedule(function(){Sd=!1,db()},k.Priority.idle,null,"WinJS.UI.VirtualizedDataSource.releaseSlotIfUnrequested"))))}function fb(a){for(var b in ld)a(ld[b])}function gb(a,b){for(var c in a.bindingMap)b(a.bindingMap[c].bindingRecord,c)}function hb(a){return a.notificationsSent||(a.notificationsSent=!0,a.notificationHandler.beginNotifications&&a.notificationHandler.beginNotifications()),a.notificationHandler}function ib(){sd||yd||fb(function(a){a.notificationsSent&&(a.notificationsSent=!1,a.notificationHandler.endNotifications&&a.notificationHandler.endNotifications())})}function jb(a,b){var c=a.bindingMap;if(c){var d=c[b];if(d){var e=d.handle;if(e)return e}}return a.handle}function kb(a,b){return a&&a.handle!==b&&(a=Object.create(a),W(a,b)),a}function lb(a){var b=Jd;Jd=a,fb(function(a){a.notificationHandler&&a.notificationHandler.countChanged&&hb(a).countChanged(Jd,b)})}function mb(a,b){gb(a,function(c,d){c.notificationHandler.indexChanged&&hb(c).indexChanged(jb(a,d),a.index,b)})}function nb(a,b){var c=a.index;if(void 0!==c&&Pd[c]===a&&delete Pd[c],+b===b)L(a,b,Pd);else{if(+c!==c)return;delete a.index}mb(a,c)}function ob(a,b,c,d,e){var f={};if(!(!d&&b.lastInSequence||!e&&c.firstInSequence))if(b===Kd)if(c===Ld)for(var g in ld)f[g]=ld[g];else for(var g in c.bindingMap)f[g]=ld[g];else if(c===Ld||c.bindingMap)for(var g in b.bindingMap)(c===Ld||c.bindingMap[g])&&(f[g]=ld[g]);for(var g in a.bindingMap)f[g]=ld[g];return f}function pb(a){var b,c=a.prev,d=a.next,e=ob(a,c,d);for(b in e){var f=e[b];f.notificationHandler&&hb(f).inserted(f.itemPromiseFromKnownSlot(a),c.lastInSequence||c===Kd?null:jb(c,b),d.firstInSequence||d===Ld?null:jb(d,b))}}function qb(a){var b=a.item;$(a),gb(a,function(c,d){var e=jb(a,d);hb(c).changed(kb(a.item,e),kb(b,e))})}function rb(a,b,c,d,e){var f,g=b.prev;if(b===a){if(!a.firstInSequence||!c)return;b=a.next}else if(g===a){if(!a.lastInSequence||!d)return;g=a.prev}if(!e){var h=ob(a,g,b,c,d);for(f in h){var i=h[f];hb(i).moved(i.itemPromiseFromKnownSlot(a),(g.lastInSequence||g===a.prev)&&!c||g===Kd?null:jb(g,f),(b.firstInSequence||b===a.next)&&!d||b===Ld?null:jb(b,f))}fb(function(b){b.adjustCurrentSlot(a)})}C(a),J(a,b,c,d)}function sb(a,b){Bb(a,!0),gb(a,function(c,d){hb(c).removed(jb(a,d),b)}),fb(function(b){b.adjustCurrentSlot(a)}),S(a)}function tb(a){for(;!a.firstInSequence;)a=a.prev;var b;do{b=a.lastInSequence;var c=a.next;sb(a,!0),a=c}while(!b)}function ub(a){var b;if(!a)return b;for(var c=0;!a.firstInSequence;)c++,a=a.prev;return"number"==typeof a.indexNew?a.indexNew+c:"number"==typeof a.index?a.index+c:b}function vb(a,b){for(a=a.next;a;a=a.next)if(a.firstInSequence){var c=void 0!==a.indexNew?a.indexNew:a.index;void 0!==c&&(a.indexNew=c+b)}zd+=b,Ad=!0,Ud?wc():Cd++}function wb(a,b){if(a.firstInSequence){var c;if(0>b)c=a.indexNew,void 0!==c?delete a.indexNew:c=a.index,a.lastInSequence||(a=a.next,void 0!==c&&(a.indexNew=c));else if(!a.lastInSequence){var d=a.next;c=d.indexNew,void 0!==c?delete d.indexNew:c=d.index,void 0!==c&&(a.indexNew=c)}}vb(a,b)}function xb(a,b){for(var c=Kd;c!==Ld;c=c.next){var d=c.indexNew;if(void 0!==d&&d>=a){vb(c,b);break}}}function yb(){var a,b,c;for(a=Kd;;a=a.next){if(a.firstInSequence){if(b=a,void 0!==a.indexNew){if(c=a.indexNew,delete a.indexNew,isNaN(c))break}else c=a.index;a!==Kd&&a.prev.index===c-1&&H(a.prev)}if(a.lastInSequence)for(var d=c,e=b;e!==a.next;e=e.next)d!==e.index&&nb(e,d),+d===d&&d++;if(a===Ld)break}for(;a!==Md;a=a.next)void 0!==a.index&&a!==Ld&&nb(a,void 0);Ad=!1,zd&&+Jd===Jd&&(pd?pd.reset():lb(Jd+zd),zd=0)}function zb(a,b,c,d,e){if(a.item)return new j(function(b){e?e(b,a.item):b(a.item)});var f={listBindingID:d,retained:!1};return a[b]||(a[b]={}),a[b][c]=f,f.promise=new j(function(a,b){f.complete=e?function(b){e(a,b)}:a,f.error=b},function(){for(;a.slotMergedWith;)a=a.slotMergedWith;var d=a[b];if(d){if(delete d[c],Object.keys(d).length>0)return;delete a[b]}eb(a)}),f.promise}function Ab(a,b){for(var c in b)b[c].complete(a)}function Bb(a,b){var c=a.fetchListeners,d=a.directFetchListeners;if(c||d){$(a);var e=a.item,f=function(a){b?Ab(e,a):Gd.push(function(){Ab(e,a)})};d&&(a.directFetchListeners=null,f(d)),c&&(a.fetchListeners=null,f(c)),eb(a)}}function Cb(){var a=Gd;Gd=[];for(var b=0,c=a.length;c>b;b++)a[b]()}function Db(a,b){var c=a.directFetchListeners;if(c){a.directFetchListeners=null;for(var d in c)c[d].error(b);eb(a)}}function Eb(a){return a.firstInSequence&&P(a,Pd),a.lastInSequence&&Q(a,Pd),a.itemNew&&$(a),ac(),a}function Fb(a){if(!a.firstInSequence){var b=a.prev;return b===Kd?null:Eb(b)}return Eb(P(a,Pd))}function Gb(a){if(!a.lastInSequence){var b=a.next;return b===Ld?null:Eb(b)}return Eb(Q(a,Pd))}function Hb(a){return a?zb(a,"directFetchListeners",(od++).toString()):j.wrap(null)}function Ib(a){if("string"!=typeof a||!a)throw new e("WinJS.UI.ListDataSource.KeyIsInvalid",s.keyIsInvalid)}function Jb(a){var b=O(Md);return K(b,a),b.keyRequested=!0,b}function Kb(a,b){Ib(a);var c=Od[a];return c||(c=Jb(a),c.hints=b),Eb(c)}function Lb(a){if("number"!=typeof a||0>a)throw new e("WinJS.UI.ListDataSource.IndexIsInvalid",s.indexIsInvalid);if(Ld.index<=a)return null;var b=Pd[a];if(!b){var c=U(a,Pd,Kd,Ld);if(!c)return null;c===Ld&&a>=Ld&&nb(Ld,void 0),b=c.prev.index===a-1?Q(c.prev,Pd):c.index===a+1?P(c,Pd):O(c,a)}return b.item||(b.indexRequested=!0),Eb(b)}function Mb(a){var b=O(Md);return b.description=a,Eb(b)}function Nb(a){if(jd=a,id!==jd){var c=function(){kd=!1,id!==jd&&(id=jd,qe.dispatchEvent(t,id))};jd===o.failure?c():kd||(kd=!0,b.setTimeout(c,40))}}function Ob(a){var b=a.fetchID;return b&&Fd[b]}function Pb(a,b){a.fetchID=b}function Qb(){var a=Ed;return Ed++,Fd[a]=!0,a}function Rb(a,b,c){var d=Qb();Pb(a,d);for(var e=a;!e.firstInSequence&&b>0;)e=e.prev,b--,Pb(e,d);for(var f=a;!f.lastInSequence&&c>0;)f=f.next,c--,Pb(f,d);return d}function Sb(a){var b=a.items,c=a.offset,d=a.totalCount,e=a.absoluteIndex,f=a.atStart,g=a.atEnd;if(v(e)){if(v(d)){var h=b.length;e-c+h===d&&(g=!0)}c===e&&(f=!0)}f&&(b.unshift(Hd),a.offset++),g&&b.push(Id)}function Tb(a,b,c){return delete Fd[c],b!==Cd||T(a)?(ac(),!1):!0}function Ub(a,b,c,d){var g=Cd;c.then(function(c){if(!c.items||!c.items.length)return j.wrapError(new e(q.doesNotExist));var h="itemsFetched id="+b+" count="+c.items.length;f(h),Tb(a,g,b)&&(+d===d&&(c.absoluteIndex=d),Sb(c),qc(a,c.items,c.offset,c.totalCount,c.absoluteIndex)),u(h)}).then(null,function(c){Tb(a,g,b)&&rc(a,c)})}function Vb(a,b,c,d){var g=Cd;d.then(function(d){if(!d.items||!d.items.length)return j.wrapError(new e(q.doesNotExist));var h="itemsFetched id="+c+" count="+d.items.length;f(h),Tb(b,g,c)&&(d.absoluteIndex=a,Sb(d),sc(a,b,d.items,d.offset,d.totalCount,d.absoluteIndex)),u(h)}).then(null,function(){Tb(b,g,c)&&tc(a,b,g)})}function Wb(a,b){var c=Rb(a,0,b-1);je?Ub(a,c,je(c,b),0):Ub(a,c,ie(c,0,0,b-1),0)}function Xb(a,b){var c=Rb(a,b-1,0);Ub(a,c,ke(c,b))}function Yb(a,b,c){var d=Rb(a,b,c);Ub(a,d,he(d,a.key,b,c,a.hints))}function Zb(a,b,c){var d=a.index;if(b>d&&(b=d),ie){var e=Rb(a,b,c);Ub(a,e,ie(e,d,b,c),d)}else if(a.key)Yb(a,b,c);else{var f,g,h=Kd,i=d+1;for(f=a.prev;f!==Kd;f=f.prev)if(void 0!==f.index&&f.key){g=d-f.index,i>g&&(i=g,h=f);break}for(f=a.next;f!==Ld;f=f.next)if(void 0!==f.index&&f.key){g=f.index-d,i>g&&(i=g,h=f);break}if(h===Kd){var e=Rb(a,0,d+1);Vb(0,a,e,je(e,d+1))}else{var j=Math.max(h.index-d,0),k=Math.max(d-h.index,0),e=Rb(h,j,k);Vb(h.index,a,e,he(e,h.key,j,k,a.hints))}}}function $b(a,b,c){var d=Rb(a,b,c);Ub(a,d,le(d,a.description,b,c))}function _b(){if(!Ud){for(var a,b,c,d,e,f,g,h,i=!1,j=!1,k=Kd.next;k!==Md;){var l=k.next;if(k!==Ld&&V(k)&&(j=!0,a?b++:(a=k,b=1),Ob(k)&&(i=!0),k.keyRequested&&!c&&(c=k,d=b-1),void 0===k.description||e||(e=k,f=b-1),k.indexRequested&&!g&&(g=k,h=b-1),k.lastInSequence||l===Md||!V(l))){if(i)i=!1;else{if(qd=!1,!a.firstInSequence&&a.prev.key&&he?Yb(a.prev,0,b):!k.lastInSequence&&l.key&&he?Yb(l,b,0):a.prev!==Kd||a.firstInSequence||!je&&!ie?l===Ld&&!k.lastInSequence&&ke?Xb(k,b):c?Yb(c,d,b-1-d):e?$b(e,f,b-1-f):g?Zb(g,h,b-1-h):"number"==typeof a.index?Zb(a,b-1,0):tb(a):Wb(a,b),qd)return void ac();if(Ud)return}a=g=c=null}k=l}Nb(j?o.waiting:o.ready)}}function ac(){Dd||(Dd=!0,k.schedule(function(){Dd=!1,_b(),ib()},k.Priority.max,null,"WinJS.UI.ListDataSource._fetch"))}function bc(b){var c=b.itemNew;if(!c)return!1;var d=b.item;for(var e in d)switch(e){case"data":break;default:if(d[e]!==c[e])return!0}return a.compareByIdentity?d.data!==c.data:b.signature!==Z(c)}function cc(a){ab(a)?bc(a)?qb(a):a.itemNew=null:a.item=null}function dc(a){a.item?cc(a):Bb(a)}function ec(a,b){a.key||K(a,b.key),a.itemNew=b,dc(a)}function fc(a,b,c){var d=b.bindingMap;if(d)for(var e in c)if(d[e]){var f=b.fetchListeners;for(var g in f){var h=f[g];h.listBindingID===e&&h.retained&&(delete f[g],h.complete(null))}var i=d[e].bindingRecord;hb(i).removed(jb(b,e),!0,jb(a,e)),b.bindingMap&&delete b.bindingMap[e]}}function gc(a,b){if(a.index!==b.index){var c=b.index;b.index=a.index,mb(b,c)}b.slotMergedWith=a;var d=b.bindingMap;for(var e in d){a.bindingMap||(a.bindingMap={});var f=d[e];f.handle||(f.handle=b.handle),Nd[f.handle]=a,a.bindingMap[e]=f}fb(function(c){c.adjustCurrentSlot(b,a)});var g=b.itemNew||b.item;if(g&&(g=Object.create(g),X(g,a,a.handle),ec(a,g)),a.item)b.directFetchListeners&&Gd.push(function(){Ab(a.item,b.directFetchListeners)}),b.fetchListeners&&Gd.push(function(){Ab(a.item,b.fetchListeners)});else{var h;for(h in b.directFetchListeners)a.directFetchListeners||(a.directFetchListeners={}),a.directFetchListeners[h]=b.directFetchListeners[h];for(h in b.fetchListeners)a.fetchListeners||(a.fetchListeners={}),a.fetchListeners[h]=b.fetchListeners[h]}a.itemNew&&Bb(a),b.handle=(nd++).toString(),I(b),S(b)}function hc(a,b,c){b&&b.key&&(c||(c=b.itemNew||b.item),delete b.key,delete Od[c.key],b.itemNew=null,b.item=null),c&&ec(a,c),b&&gc(a,b)}function ic(a){if("object"!=typeof a)throw new e("WinJS.UI.ListDataSource.InvalidItemReturned",s.invalidItemReturned);if(a===Hd)return Kd;if(a===Id)return Ld;if(a.key)return d.validation&&Ib(a.key),Od[a.key];throw new e("WinJS.UI.ListDataSource.InvalidKeyReturned",s.invalidKeyReturned)}function jc(a,b){var c=ic(b);c===a&&(c=null),c&&fc(a,c,a.bindingMap),hc(a,c,b)}function kc(a,b,c,d){if(b&&a.key&&a.key!==b.key)return wc(),!1;var e=Pd[c];if(e)if(e===a)e=null;else{if(e.key&&(a.key||b&&e.key!==b.key))return wc(),!1;if(!a.key&&e.bindingMap)return!1}var f;if(b)if(f=Od[b.key],f===a)f=null;else if(f&&f.bindingMap)return!1;return e?(fc(a,e,a.bindingMap),delete Pd[c],nb(a,c),a.prev.index===c-1&&H(a.prev),a.next.index===c+1&&H(a),d.slotNext=e.slotNext,b||(b=e.itemNew||e.item,b&&(f=Od[b.key]))):nb(a,c),f&&e!==f&&fc(a,f,a.bindingMap),hc(a,f,b),e&&e!==f&&gc(a,e),!0}function lc(a,b,c){if(b.key&&a.key&&b.key!==a.key)return wc(),!1;for(var d in a.bindingMap)c[d]=!0;return fc(a,b,c),hc(a,b),!0}function mc(a,b){for(var c={};a;){var d=a.firstInSequence?null:a.prev;if(b.firstInSequence||b.prev!==Kd){if(b=b.firstInSequence?P(b,Pd):b.prev,!lc(b,a,c))return}else sb(a,!0);a=d}}function nc(a,b){for(var c={};a;){var d=a.lastInSequence?null:a.next;if(b.lastInSequence||b.next!==Ld){if(b=b.lastInSequence?Q(b,Pd):b.next,!lc(b,a,c))return}else sb(a,!0);a=d}}function oc(a){for(var b=0;b<a.length;b++){var c=a[b];mc(c.slotBeforeSequence,c.slotFirstInSequence),nc(c.slotAfterSequence,c.slotLastInSequence)}}function pc(a,b){function c(b){for(var c=Ld.prev;!(c.index<a)&&c!==b;){var e=c.prev;void 0!==c.index&&sb(c,!0),c=e}d=0}for(var d=0,e=Ld.prev;!(e.index<a)||d>0;){var f=e.prev;if(e===Kd){c(Kd);break}if(e.key){if(e.index>=a)return wc(),!1;if(!(e.index>=b))return he?Yb(e,0,d):Zb(e,0,d),!1;c(e)}else e.indexRequested||e.firstInSequence?c(f):d++;e=f}return!0}function qc(a,b,c,d,e){var g="WinJS.UI.ListDataSource.processResults";return f(g),e=x(e),d=y(d),vd?void u(g):(Ad&&yb(),!v(d)&&d!==p.unknown||d===Jd||Ld.firstInSequence?(qd=!0,function(){var f,g,h,i,j=b.length;if("number"!=typeof e)for(f=0;j>f;f++)if(h=ic(b[f]),h&&void 0!==h.index){e=h.index+c-f;break}"number"==typeof e&&b[j-1]===Id?d=e-c+j-1:!v(d)||void 0!==e&&null!==e||(e=d-(j-1)+c),v(d)&&!pc(d,e-c)&&(d=void 0);var k=new Array(j);for(f=0;j>f;f++){var l=null;if(h=ic(b[f])){if(f>0&&!h.firstInSequence&&h.prev.key&&h.prev.key!==b[f-1].key||"number"==typeof e&&void 0!==h.index&&h.index!==e-c+f)return void wc();(h===Kd||h===Ld||h.bindingMap)&&(l=h)}if("number"==typeof e&&(h=Pd[e-c+f])){if(h.key&&h.key!==b[f].key)return void wc();!l&&h.bindingMap&&(l=h)}if(f===c){if(a.key&&a.key!==b[f].key||"number"==typeof a.index&&"number"==typeof e&&a.index!==e)return void wc();l||(l=a)}k[f]=l}for(f=0;j>f;f++)h=k[f],h&&void 0!==h.index&&h!==Kd&&h!==Ld&&jc(h,b[f]);var m,n,o=[],p=!0;for(f=0;j>f;f++)if(h=k[f],h&&h!==Ld){var q=f;if(void 0===h.index){var r={};kc(h,b[f],e-c+f,r);var s,t=h,u=h;for(g=f-1;!t.firstInSequence&&(s=b[g],s!==Hd);g--){var w=e-c+g;if(0>w)break;if(!kc(t.prev,s,w,r))break;t=t.prev,g>=0&&(k[g]=t)}for(g=f+1;!u.lastInSequence&&(s=b[g],s!==Id&&g!==d||u.next===Ld)&&(u.next===Ld||kc(u.next,s,e-c+g,r))&&(u=u.next,j>g&&(k[g]=u),q=g,u!==Ld);g++);if(m=t.firstInSequence?null:t.prev,n=u.lastInSequence?null:u.next,m&&I(m),n&&I(u),"number"==typeof e){if(u===Ld)m&&G(Ld,D(m),m);else{var x=r.slotNext;x||(x=U(u.index,Pd,Kd,Ld,!0)),F(x,t,u)}t.prev.index===t.index-1&&H(t.prev),u.next.index===u.index+1&&H(u)}else p||(i=k[f-1],i&&(t.prev!==i&&(u===Ld?(m&&G(Ld,D(m),m),F(t,D(i),i)):G(i,t,u)),H(i)));if(p=!1,Td)return;o.push({slotBeforeSequence:m,slotFirstInSequence:t,slotLastInSequence:u,slotAfterSequence:n})}f!==c||h===a||T(a)||(m=a.firstInSequence?null:a.prev,n=a.lastInSequence?null:a.next,fc(h,a,h.bindingMap),gc(h,a),o.push({slotBeforeSequence:m,slotFirstInSequence:h,slotLastInSequence:h,slotAfterSequence:n})),f=q}for(v(d)&&Ld.index!==d&&nb(Ld,d),oc(o),f=0;j>f;f++)if(h=k[f]){for(g=f-1;g>=0;g--){var y=k[g+1];jc(k[g]=y.firstInSequence?P(k[g+1],Pd):y.prev,b[g])}for(g=f+1;j>g;g++)i=k[g-1],h=k[g],h?h.firstInSequence&&(h.prev!==i&&G(i,h,E(h)),H(i)):jc(k[g]=i.lastInSequence?Q(i,Pd):i.next,b[g]);break}delete a.description}(),Td||(void 0!==d&&d!==Jd&&lb(d),ac()),ib(),Cb(),void u(g)):(wc(),void u(g)))}function rc(a,b){switch(b.name){case q.noResponse:Nb(o.failure),Db(a,b);break;case q.doesNotExist:a.indexRequested?pc(a.index):(a.keyRequested||a.description)&&tb(a),ib(),wc()}}function sc(a,b,c,d,f,g){g=x(g),f=y(f);var h=a-d,i=c.length;if(b.index>=h&&b.index<h+i)qc(b,c,b.index-h,f,b.index);else if(d===i-1&&a<b.index||v(f)&&f<=b.index)rc(b,new e(q.doesNotExist));else if(b.index<h){var j=Rb(b,0,h-b.index);Vb(h,b,j,he(j,c[0].key,h-b.index,0))}else{var k=h+i-1,j=Rb(b,b.index-k,0);Vb(k,b,j,he(j,c[i-1].key,0,b.index-k))}}function tc(a,b,c){switch(c.name){case q.doesNotExist:a===Kd.index?(pc(0),rc(b,c)):wc();break;default:rc(b,c)}}function uc(){for(var a=0;a<ne.length&&"beginRefresh"!==ne[a].kind;a++);for(var b=a;b<ne.length&&"beginRefresh"!==ne[b].kind;b++);if(b>a&&b+(b-a)<ne.length){for(var c=!0,d=b-a,e=0;d>e;e++)if(ne[a+e].kind!==ne[b+e].kind){c=!1;break}if(c&&g.log){g.log(s.refreshCycleIdentified,"winjs vds","error");for(var e=a;b>e;e++)g.log(""+(e-a)+": "+JSON.stringify(ne[e]),"winjs vds","error")}return c}}function vc(){return++me>h&&uc()?void Nb(o.failure):(ne[++oe%ne.length]={kind:"beginRefresh"},Zd={firstInSequence:!0,lastInSequence:!0,index:-1},$d={firstInSequence:!0,lastInSequence:!0},Zd.next=$d,$d.prev=Zd,Xd=!1,Yd=void 0,_d={},ae={},be={},be[-1]=Zd,void(ce={}))}function wc(){if(!Td){if(Td=!0,Nb(o.waiting),xd)return xd=!1,void Zc();if(!vd){var a=++Cd;Ud=!0,Wd=0,k.schedule(function(){if(Cd===a){Td=!1,vc();for(var b=Kd.next;b!==Md;){var c=b.next;bb(b)||b===Ld||cb(b),b=c}Ec()}},k.Priority.high,null,"WinJS.VirtualizedDataSource.beginRefresh")}}}function xc(){return Vd=Vd||new l,wc(),Vd.promise}function yc(a,b){return delete Fd[b],a!==Cd?!1:(Wd--,!0)}function zc(a,b,c,d,g){var h=Cd;Wd++,d.then(function(b){if(!b.items||!b.items.length)return j.wrapError(new e(q.doesNotExist));var d="itemsFetched id="+c+" count="+b.items.length;f(d),yc(h,c)&&(Sb(b),Kc(a,b.items,b.offset,b.totalCount,"number"==typeof g?g:b.absoluteIndex)),u(d)}).then(null,function(d){yc(h,c)&&Lc(a,b,d)})}function Ac(a,b,c,d){if(he)zc(a.key,!1,b,he(b,a.key,c,d,a.hints));else{var e=10,f=a.index;be[f]&&be[f].firstInSequence?zc(a.key,!1,b,ie(b,f-1,Math.min(c+e,f)-1,d+1+e),f-1):be[f]&&be[f].lastInSequence?zc(a.key,!1,b,ie(b,f+1,Math.min(c+e,f)+1,d-1+e),f+1):zc(a.key,!1,b,ie(b,f,Math.min(c+e,f),d+e),f)}}function Bc(a){je?zc(null,!0,a,je(a,1),0):ie&&zc(null,!0,a,ie(a,0,0,0),0)}function Cc(a){return Fd[_d[a]]}function Dc(a,b){for(var c,d,e,f=3,g=Cd,h=0,i=a;i!==Md;i=i.next){if(!c&&i.key&&!ce[i.key]&&!Cc(i.key)){var j=ae[i.key];(!j||j.firstInSequence||j.lastInSequence)&&(c=i,d=j,e=Qb())}if(c){var k=Cc(i.key);if(ce[i.key]||ae[i.key]||k||(i.key&&(_d[i.key]=e),h++),i.lastInSequence||i.next===Ld||k){if(Ac(c,e,!d||d.firstInSequence?f:0,h-1+f),!b)break;c=null,h=0}}else i.key&&V(i)&&!ce[i.key]&&(ae[i.key]||(e=Qb(),zc(i.key,!1,e,he(e,i.key,1,1,i.hints))))}0!==Wd||Xd||Cd!==g||Bc(Qb())}function Ec(){var a=Cd;do de=!1,ee=!0,Dc(Kd.next,!0),ee=!1;while(0===Wd&&de&&Cd===a&&Ud);0===Wd&&Cd===a&&Uc()}function Fc(a){var b=Cd;if(a){var c=Od[a];c||(c=Kd.next);do fe=!1,ge=!0,Dc(c,!1),ge=!1;while(fe&&Cd===b&&Ud)}ee?de=!0:0===Wd&&Cd===b&&Ec()}function Gc(a){if("object"==typeof a&&a){if(a===Hd)return Zd;if(a===Id)return $d;if(a.key)return ae[a.key];throw new e("WinJS.UI.ListDataSource.InvalidKeyReturned",s.invalidKeyReturned)}throw new e("WinJS.UI.ListDataSource.InvalidItemReturned",s.invalidItemReturned)}function Hc(a,b){for(;void 0===a.index;){if(L(a,b,be),a.firstInSequence)return!0;a=a.prev,b--}return a.index!==b?(wc(),!1):!0}function Ic(a,b){a.key=b.key,ae[a.key]=a,a.item=b}function Jc(){for(var a=$d;!a.firstInSequence;)if(a=a.prev,a===Zd)return null;return a}function Kc(a,b,c,d,e){e=x(e),d=y(d);var f=!1;Xd=!0;var g=e-c,h=b[0];h.key===a&&(f=!0);var i=Gc(h);if(i){if(+g===g&&!Hc(i,g))return}else{if(be[g])return void wc();var j;if(void 0!==e&&(j=be[g-1])){if(!j.lastInSequence)return void wc();i=Q(j,be)}else{var k=+g===g?U(g,be,Zd,$d):Jc(Zd,$d);if(!k)return void wc();i=N(k,g,be)}Ic(i,b[0])}for(var l=b.length,m=1;l>m;m++){h=b[m],h.key===a&&(f=!0);var n=Gc(h);if(n){if(void 0!==i.index&&!Hc(n,i.index+1))return;if(n!==i.next){if(!i.lastInSequence||!n.firstInSequence)return void wc();var o=E(n);if(o!==$d)G(i,n,o);else{var q=D(i);if(q===Zd)return void wc();F(n,q,i)}H(i)}else i.lastInSequence&&H(i)}else{if(!i.lastInSequence)return void wc();n=Q(i,be),Ic(n,h)}i=n}if(f||(ce[a]=!0),!v(d)&&!$d.firstInSequence){var r=$d.prev.index;void 0!==r&&(d=r+1)}if(v(d)||d===p.unknown){if(v(Yd)){if(d!==Yd)return void wc()}else Yd=d;v(Yd)&&!be[Yd]&&L($d,Yd,be)}ge?fe=!0:Fc(a)}function Lc(a,b,c){switch(c.name){case q.noResponse:Nb(o.failure);break;case q.doesNotExist:b?(L($d,0,be),Yd=0,Uc()):(ce[a]=!0,ge?fe=!0:Fc(a))}}function Mc(a){return a===Zd?Kd:a===$d?Ld:Od[a.key]}function Nc(a){return a===Kd?Zd:a===Ld?$d:ae[a.key]}function Oc(a){H(a),a.next.mergedForRefresh=!0}function Pc(a,b){K(b,a.key),b.itemNew=a.item}function Qc(a,b,c){var d=A();Pc(a,d),J(d,b,c,!c);var e=a.index;return+e!==e&&(e=c?d.prev.index+1:b.next.index-1),L(d,e,Pd),d}function Rc(a,b,c){a?(fc(a,b,a.bindingMap),hc(a,b,c.item)):(Pc(c,b),b.indexRequested&&dc(b))}function Sc(a,b,c){return b.key?!1:(a?(c.mergeWithPrev=!b.firstInSequence,c.mergeWithNext=!b.lastInSequence):c.stationary=!0,Rc(a,b,c),!0)}function Tc(a){var b;if(a.indexRequested)b=a.index;else{var c=Nc(a);c&&(b=c.index)}return b}function Uc(){me=0,ne=new Array(100),oe=-1,Ad=!0,_d={};var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=[],t=[];for(o=0,h=Zd;h;h=h.next)h.sequenceNumber=o,h.firstInSequence&&(j=h),h.lastInSequence&&(t[o]={first:j,last:h,matchingItems:0},o++);for(Rd=null,Qd=0,c=Kd.next;c!==Md;)h=ae[c.key],e=c.next,c!==Ld&&(bb(c)?c.key&&!h?sb(c,!1):0===Yd||c.indexRequested&&c.index>=Yd?sb(c,!0):c.item||c.keyRequested?c.itemNew=h.item:c.key&&(c.keyRequested||(delete Od[c.key],delete c.key),c.itemNew=null):cb(c)),c=e;for(c=Kd.next;c!==Ld;)e=c.next,c.indexRequested&&(h=be[c.index],h&&Rc(Mc(h),c,h)),c=e;var u,v,w,x,y,z=0,A=[];for(k=0,c=Kd;c!==Md;c=c.next){if(c.firstInSequence)for(j=c,w=null,a=0;o>a;a++)A[a]=0;if(c.indexRequested&&(w=c),h=Nc(c),h&&A[h.sequenceNumber]++,c.lastInSequence){for(v=0,a=z;o>a;a++)v<A[a]&&(v=A[a],u=a);l={first:j,last:c,sequenceNew:v>0?t[u]:void 0,matchingItems:v},w&&(l.indexRequested=!0,l.stationarySlot=w),s[k]=l,c===Ld&&(x=k,y=l),k++,void 0!==t[u].first.index&&(z=u)}}s[0].sequenceNew!==t[0]&&(I(Kd),s[0].first=Kd.next,s.unshift({first:Kd,last:Kd,sequenceNew:t[0],matchingItems:1}),x++,k++);var B=!Ld.firstInSequence;for(y.sequenceNew!==t[o-1]&&(I(Ld.prev),y.last=Ld.prev,x++,s.splice(x,0,{first:Ld,last:Ld,sequenceNew:t[o-1],matchingItems:1}),k++,y=s[x]),a=0;k>a;a++)p=s[a].sequenceNew,p&&p.matchingItems<s[a].matchingItems&&(p.matchingItems=s[a].matchingItems,p.sequenceOld=s[a]);for(t[o-1].sequenceOld=y,y.stationarySlot=Ld,t[0].sequenceOld=s[0],s[0].stationarySlot=Kd,a=0;x>=a;a++)l=s[a],l.sequenceNew&&(n=l.sequenceNew.sequenceOld)===m&&m.last!==Ld?(Oc(n.last),n.last=l.last,delete s[a]):m=l;for(m=null,a=x;a>=0;a--)l=s[a],l&&(l.sequenceNew&&(n=l.sequenceNew.sequenceOld)===m&&l.last!==Ld?(Oc(l.last),n.first=l.first,delete s[a]):m=l);B&&delete Ld.mergedForRefresh;var C=[];for(a=x+1;k>a;a++)if(l=s[a],l&&(!l.sequenceNew||l.sequenceNew.sequenceOld!==l)){var D=!0,E=null,J=null,K=0;for(h=Nc(l.first),h&&(E=J=h,K=1),c=l.first;c!==l.last;c=c.next){var L=Nc(c.next);if(h&&L&&(h.lastInSequence||h.next!==L)){D=!1;break}h&&!E&&(E=J=h),L&&E&&(J=L,K++),h=L}if(D&&E&&void 0!==E.index){var M;E.firstInSequence||(f=Mc(E.prev),f&&(M=f.index));var N;if(J.lastInSequence||(g=Mc(J.next),g&&(N=g.index)),(!g||g.lastInSequence||g.mergedForRefresh)&&(void 0===M||void 0===N||N-M-1>=K)){for(l.locationJustDetermined=!0,h=E;h.locationJustDetermined=!0,h!==J;h=h.next);var j=Mc(E),O=Mc(J);C.push({slotBeforeSequence:j.firstInSequence?null:j.prev,slotFirstInSequence:j,slotLastInSequence:O,slotAfterSequence:O.lastInSequence?null:O.next})}}}for(a=0;k>a;a++)if(l=s[a],!(!l||l.indexRequested||l.locationJustDetermined||l.sequenceNew&&l.sequenceNew.sequenceOld===l)){l.sequenceNew=null,c=l.first;var P;do{if(P=c===l.last,e=c.next,c!==Kd&&c!==Ld&&c!==Md&&!c.item&&!c.keyRequested)if(sb(c,!0),l.first===c){if(l.last===c){delete s[a];break}l.first=c.next}else l.last===c&&(l.last=c.prev);c=e}while(!P)}for(a=0;o>a;a++){for(p=t[a],h=p.first;!Mc(h)&&!h.lastInSequence;h=h.next);if(h.lastInSequence&&!Mc(h))p.firstInner=p.lastInner=null;else{for(p.firstInner=h,h=p.last;!Mc(h);h=h.prev);p.lastInner=h}}for(a=0;o>a;a++)if(p=t[a],p&&p.firstInner&&(l=p.sequenceOld)){var Q=0;for(c=l.first;!0&&(h=Nc(c),h&&h.sequenceNumber===p.firstInner.sequenceNumber&&(h.ordinal=Q),!c.lastInSequence);c=c.next,Q++);var R=[];for(h=p.firstInner;!0;h=h.next){if(Q=h.ordinal,void 0!==Q){for(var S=0,T=R.length-1;T>=S;){var U=Math.floor(.5*(S+T));R[U].ordinal<Q?S=U+1:T=U-1}R[S]=h,S>0&&(h.predecessor=R[S-1])}if(h===p.lastInner)break}var W=[],X=R.length;for(h=R[X-1],b=X;b--;)h.stationary=!0,W[b]=h,h=h.predecessor;l.stationarySlot=Mc(W[0]),h=W[0],c=Mc(h),d=c.prev;for(var Y=c.firstInSequence;!h.firstInSequence;)if(h=h.prev,i=Mc(h),!i||h.locationJustDetermined)for(;!Y&&d!==Kd&&(c=d,d=c.prev,Y=c.firstInSequence,!Sc(i,c,h)););for(b=0;X-1>b;b++){h=W[b],c=Mc(h);var i,Z=W[b+1],_=null,ab=Mc(Z);for(e=c.next,h=h.next;h!==Z&&!_&&c!==ab;h=h.next)if(i=Mc(h),!i||h.locationJustDetermined)for(;e!==ab;){if(e.mergedForRefresh){_=h.prev;break}if(c=e,e=c.next,Sc(i,c,h))break}if(_)for(d=ab.prev,h=Z.prev;h!==_&&ab!==c;h=h.prev)if(i=Mc(h),!i||h.locationJustDetermined)for(;d!==c&&(ab=d,d=ab.prev,!Sc(i,ab,h)););for(;e!==ab;)c=e,e=c.next,c!==Kd&&V(c)&&!c.keyRequested&&sb(c)}for(h=W[X-1],c=Mc(h),e=c.next,Y=c.lastInSequence;!h.lastInSequence;)if(h=h.next,i=Mc(h),!i||h.locationJustDetermined)for(;!Y&&e!==Ld&&(c=e,e=c.next,Y=c.lastInSequence,!Sc(i,c,h)););}for(a=0;o>a;a++)if(p=t[a],p.firstInner)for(d=null,h=p.firstInner;!0;h=h.next){if(c=Mc(h)){if(!h.stationary){var db,eb=!1,fb=!1;if(d)db=d.next,eb=!0;else{var gb;for(gb=p.firstInner;!gb.stationary&&gb!==p.lastInner;gb=gb.next);if(gb.stationary)db=Mc(gb),fb=!0;else if(q=h.index,0===q)db=Kd.next,eb=!0;else if(void 0===q)db=Md;else{db=Kd.next;for(var hb=null;;){if(db.firstInSequence&&(hb=db),q<db.index&&hb||db===Ld)break;db=db.next}!db.firstInSequence&&hb&&(db=hb)}}c.mergedForRefresh&&(delete c.mergedForRefresh,c.lastInSequence||(c.next.mergedForRefresh=!0)),eb=eb||h.mergeWithPrev,fb=fb||h.mergeWithNext;var jb=h.locationJustDetermined;rb(c,db,eb,fb,jb),jb&&fb&&(db.mergedForRefresh=!0)}d=c}if(h===p.lastInner)break}for(a=0;o>a;a++)if(p=t[a],p.firstInner)for(d=null,h=p.firstInner;!0;h=h.next){if(c=Mc(h),!c){var kb;if(d)kb=d.next;else{var mb;for(mb=p.firstInner;!Mc(mb);mb=mb.next);kb=Mc(mb)}c=Qc(h,kb,!!d);var L=Nc(kb);kb.mergedForRefresh||L&&L.locationJustDetermined||($(c),pb(c))}if(d=c,h===p.lastInner)break}Pd=[];var ob=-1;for(c=Kd,r=0;c!==Md;r++){var e=c.next;if(c.firstInSequence&&(j=c,r=0),void 0===ob){var qb=Tc(c);void 0!==qb&&(ob=qb-r)}if(void 0!==ob&&!c.lastInSequence){var tb=Tc(c.next);if(void 0!==tb&&tb!==ob+r+1){I(c);for(var ub=!0,vb=c.next,wb=!1;!wb&&vb!==Ld;){var xb=vb.next;wb=vb.lastInSequence,rb(vb,xb,!ub,!1),ub=!1,vb=xb}}}if(c.lastInSequence){q=ob;for(var yb=j;yb!==e;){var zb=yb.next;if(q>=Yd&&yb!==Ld)sb(yb,!0);else{var Ab=Pd[q];q!==yb.index?(delete Pd[q],nb(yb,q)):+q===q&&Pd[q]!==yb&&(Pd[q]=yb),yb.itemNew&&dc(yb),Ab&&(yb.key?(fc(yb,Ab,yb.bindingMap),gc(yb,Ab),+q===q&&(Pd[q]=yb)):(fc(Ab,yb,Ab.bindingMap),gc(Ab,yb),+q===q&&(Pd[q]=Ab))),+q===q&&q++}yb=zb}ob=void 0}c=e}var Bb,Db=-2;for(c=Kd,r=0;c!==Md;r++){var e=c.next;if(c.firstInSequence&&(j=c,r=0),delete c.mergedForRefresh,c.lastInSequence)if(void 0===j.index){f=j.prev;var Eb;f&&(Eb=Nc(f))&&!Eb.lastInSequence&&(h=Nc(c))&&h.prev===Eb?(G(f,j,c),H(f)):c===Ld||Bb||F(Md,j,c)}else{if(Db<c.index&&!Bb)Db=c.index;else{for(g=Kd.next;g.index<c.index;g=g.next);for(var vb=j;vb!==e;){var xb=vb.next;h=Nc(vb),rb(vb,g,g.prev.index===vb.index-1,g.index===vb.index+1,h&&h.locationJustDetermined),vb=xb}}f=j.prev,f&&f.index===j.index-1&&H(f)}c===Ld&&(Bb=!0),c=e}Ad=!1,oc(C),void 0!==Yd&&Yd!==Jd&&lb(Yd),ib();var Fb=[];for(a=0;o>a;a++){p=t[a];var Gb=[];c=null,r=0;var Hb;for(h=p.first;!0&&(h===Zd?Gb.push(Hd):h===$d?Gb.push(Id):(Gb.push(h.item),c||(c=Mc(h),Hb=r)),!h.lastInSequence);h=h.next,r++);c&&Fb.push({slot:c,results:Gb,offset:Hb})}for(vc(),Ud=!1,Cb(),a=0;a<Fb.length;a++){var Ib=Fb[a];qc(Ib.slot,Ib.results,Ib.offset,Jd,Ib.slot.index)}if(Vd){var Jb=Vd;Vd=null,Jb.complete()}ac()}function Vc(a,b,c,d,e,f,g){var h=ud.prev,i={prev:h,next:ud,applyEdit:a,editType:b,complete:c,error:d,keyUpdate:e};h.next=i,ud.prev=i,vd=!0,(Td||Ud)&&(Cd++,Ud=!1,Td=!0),ud.next===i&&Zc(),i.failed||(f(),i.undo=g),sd||$c()}function Wc(){td=!1;var a=ud.next.next;ud.next=a,a.prev=ud}function Xc(){for(;ud.prev!==ud;){var a=ud.prev;a.error&&a.error(new e(r.canceled)),a.undo&&!Td&&a.undo(),ud.prev=a.prev
  }ud.next=ud,sd=!1,$c()}function Yc(b){function c(){xd||(f?wd=!0:Zc())}function d(a){if(a){var d;if(g&&g.key!==a.key){var e=a.key;if(b.undo){if(d=g.slot){var h=d.key;h&&delete Od[h],K(d,e),d.itemNew=a,d.item?(qb(d),ib()):Bb(d)}}else g.key=e}else b.editType===re.change&&(d.itemNew=a,f||cc(d))}Wc(),b.complete&&b.complete(a),c()}function e(a){switch(a.Name){case r.noResponse:return Nb(o.failure),xd=!0,void(td=!1);case r.notPermitted:break;case r.noLongerMeaningful:wc()}b.failed=!0,Wc(),Xc(),b.error&&b.error(a),c()}if(!td){var f=!0,g=b.keyUpdate;a.beginEdits&&!rd&&(rd=!0,a.beginEdits()),td=!0,b.applyEdit().then(d,e),f=!1}}function Zc(){for(;ud.next!==ud;)if(wd=!1,Yc(ud.next),!wd)return;_c()}function $c(){yb(),ib(),Cb(),ud.next===ud&&_c()}function _c(){vd=!1,a.endEdits&&rd&&!sd&&(rd=!1,a.endEdits()),Td?(Td=!1,wc()):ac()}function ad(a){return Ib(a),Od[a]||Jb(a)}function bd(a,b,c,d,e){var f=A();return J(f,c,d,e),a&&K(f,a),f.itemNew=b,wb(f,1),sd||yd||(f.firstInSequence||"number"!=typeof f.prev.index?f.lastInSequence||"number"!=typeof f.next.index||L(f,f.next.index-1,Pd):L(f,f.prev.index+1,Pd)),$(f),pb(f),f}function cd(a,b,c,d,e){var f={key:a};return new j(function(a,g){Vc(e,re.insert,a,g,f,function(){if(c){var a={key:f.key,data:b};f.slot=bd(f.key,a,c,d,!d)}},function(){var a=f.slot;a&&(wb(a,-1),sb(a,!1))})})}function dd(a,b,c,d){return new j(function(e,f){var g,h,i,j;Vc(d,re.move,e,f,null,function(){h=a.next,i=a.firstInSequence,j=a.lastInSequence;var d=a.prev;g=!("number"==typeof a.index||!i&&d.item||!j&&h.item),wb(a,-1),rb(a,b,c,!c),wb(a,1),g&&(I(d),i||mc(d,a),j||nc(h,a))},function(){g?wc():(wb(a,-1),rb(a,h,!i,!j),wb(a,1))})})}function ed(){function a(){yd||(yb(),ib(),Cb())}this.invalidateAll=function(){return 0===Jd?(this.reload(),j.wrap()):xc()},this.reload=function(){pd&&pd.cancel(),Vd&&Vd.cancel();for(var a=Kd.next;a!==Md;a=a.next){var b=a.fetchListeners;for(var c in b)b[c].promise.cancel();var d=a.directFetchListeners;for(var c in d)d[c].promise.cancel()}fd(),fb(function(a){a.notificationHandler&&a.notificationHandler.reload()})},this.beginNotifications=function(){yd=!0},this.inserted=function(b,c,d,e){if(vd)wc();else{var f=b.key,g=Od[c],h=Od[d],i="string"==typeof c,j="string"==typeof d;if(i?h&&!h.firstInSequence&&(g=h.prev):j&&g&&!g.lastInSequence&&(h=g.next),(i||j)&&!g&&!h&&Kd.next===Ld)return void wc();if(Od[f])return void wc();if(g&&h&&(g.next!==h||g.lastInSequence||h.firstInSequence))return void wc();if(g&&(g.keyRequested||g.indexRequested)||h&&(h.keyRequested||h.indexRequested))return void wc();if(g||h)bd(f,b,h?h:g.next,!!g,!!h);else if(Kd.next===Ld)bd(f,b,Kd.next,!0,!0);else{if(void 0===e)return void wc();xb(e,1)}a()}},this.changed=function(b){if(vd)wc();else{var c=b.key,d=Od[c];d&&(d.keyRequested?wc():(d.itemNew=b,d.item&&(qb(d),a())))}},this.moved=function(b,c,d,e,f){if(vd)wc();else{var g=b.key,h=Od[g],i=Od[c],j=Od[d];h&&h.keyRequested||i&&i.keyRequested||j&&j.keyRequested?wc():h?i&&j&&(i.next!==j||i.lastInSequence||j.firstInSequence)?wc():i||j?(wb(h,-1),rb(h,j?j:i.next,!!i,!!j),wb(h,1),a()):(wb(h,-1),sb(h,!1),void 0!==e&&(f>e&&f--,xb(f,1)),a()):i||j?(void 0!==e&&(xb(e,-1),f>e&&f--),this.inserted(b,c,d,f)):void 0!==e&&(xb(e,-1),f>e&&f--,xb(f,1),a())}},this.removed=function(b,c){if(vd)wc();else{var d;d="string"==typeof b?Od[b]:Pd[c],d?d.keyRequested?wc():(wb(d,-1),sb(d,!1),a()):void 0!==c&&(xb(c,-1),a())}},this.endNotifications=function(){yd=!1,a()}}function fd(){Nb(o.ready),pd=null,rd=!1,sd=!1,td=!1,ud={},ud.next=ud,ud.prev=ud,vd=!1,xd=!1,zd=0,Ad=!1,Bd=0,Fd={},Gd=[],Jd=p.unknown,Kd={firstInSequence:!0,lastInSequence:!0,index:-1},Ld={firstInSequence:!0,lastInSequence:!0},Md={firstInSequence:!0,lastInSequence:!0},Kd.next=Ld,Ld.prev=Kd,Ld.next=Md,Md.prev=Ld,Nd={},Od={},Pd={},Pd[-1]=Kd,Qd=0,Rd=null,Sd=!1,Td=!1,Ud=!1,Vd=null}var gd,hd,id,jd,kd,ld,md,nd,od,pd,qd,rd,sd,td,ud,vd,wd,xd,yd,zd,Ad,Bd,Cd,Dd,Ed,Fd,Gd,Hd,Id,Jd,Kd,Ld,Md,Nd,Od,Pd,Qd,Rd,Sd,Td,Ud,Vd,Wd,Xd,Yd,Zd,$d,_d,ae,be,ce,de,ee,fe,ge,he,ie,je,ke,le,me=0,ne=new Array(100),oe=-1;a.itemsFromKey&&(he=function(b,c,d,e,g){var h="fetchItemsFromKey id="+b+" key="+c+" countBefore="+d+" countAfter="+e;f(h),ne[++oe%ne.length]={kind:"itemsFromKey",key:c,countBefore:d,countAfter:e};var i=a.itemsFromKey(c,d,e,g);return u(h),i}),a.itemsFromIndex&&(ie=function(b,c,d,e){var g="fetchItemsFromIndex id="+b+" index="+c+" countBefore="+d+" countAfter="+e;f(g),ne[++oe%ne.length]={kind:"itemsFromIndex",index:c,countBefore:d,countAfter:e};var h=a.itemsFromIndex(c,d,e);return u(g),h}),a.itemsFromStart&&(je=function(b,c){var d="fetchItemsFromStart id="+b+" count="+c;f(d),ne[++oe%ne.length]={kind:"itemsFromStart",count:c};var e=a.itemsFromStart(c);return u(d),e}),a.itemsFromEnd&&(ke=function(b,c){var d="fetchItemsFromEnd id="+b+" count="+c;f(d),ne[++oe%ne.length]={kind:"itemsFromEnd",count:c};var e=a.itemsFromEnd(c);return u(d),e}),a.itemsFromDescription&&(le=function(b,c,d,e){var g="fetchItemsFromDescription id="+b+" desc="+c+" countBefore="+d+" countAfter="+e;f(g),ne[++oe%ne.length]={kind:"itemsFromDescription",description:c,countBefore:d,countAfter:e};var h=a.itemsFromDescription(c,d,e);return u(g),h});var pe=++n,qe=this,re={insert:"insert",change:"change",move:"move",remove:"remove"};if(!a)throw new e("WinJS.UI.ListDataSource.ListDataAdapterIsInvalid",s.listDataAdapterIsInvalid);hd=a.compareByIdentity?0:200,c&&"number"==typeof c.cacheSize&&(hd=c.cacheSize),a.setNotificationHandler&&(gd=new ed,a.setNotificationHandler(gd)),id=o.ready,kd=!1,ld={},md=0,nd=1,od=0,Cd=0,Dd=!1,Ed=1,Hd={},Id={},fd(),this.createListBinding=function(a){function b(a){a&&a.cursorCount++}function c(a){a&&0===--a.cursorCount&&eb(a)}function d(a){b(a),c(m),m=a}function e(a,b){a===m&&(b||(b=!m||m.lastInSequence||m.next===Ld?null:m.next),d(b))}function f(a){var b=a.bindingMap,c=b[l].handle;delete a.bindingMap[l];var d=!0,e=!0;for(var f in b)if(d=!1,c&&b[f].handle===c){e=!1;break}c&&e&&delete Nd[c],d&&(a.bindingMap=null,eb(a))}function g(a,b){a.bindingMap||(a.bindingMap={});var c=a.bindingMap[l];if(c?c.count++:a.bindingMap[l]={bindingRecord:ld[l],count:1},a.fetchListeners){var d=a.fetchListeners[b];d&&(d.retained=!0)}}function h(a){var b=Nd[a];if(b){var c=b.bindingMap[l];if(0===--c.count){var d=b.fetchListeners;for(var e in d){var g=d[e];g.listBindingID===l&&(g.retained=!1)}f(b)}}}function i(b){var c=jb(b,l),d=(od++).toString(),e=zb(b,"fetchListeners",d,l,function(a,b){a(kb(b,c))});return X(e,b,c),a&&(e.retain=function(){return o._retainItem(b,d),e},e.release=function(){o._releaseItem(c)}),e}function k(b){var c;return!n&&b?c=i(b):(n?(c=new j(function(){}),c.cancel()):c=j.wrap(null),W(c,null),a&&(c.retain=function(){return c},c.release=function(){})),d(b),c}var l=(md++).toString(),m=null,n=!1;ld[l]={notificationHandler:a,notificationsSent:!1,adjustCurrentSlot:e,itemPromiseFromKnownSlot:i};var o={_retainItem:function(a,b){g(a,b)},_releaseItem:function(a){h(a)},jumpToItem:function(a){return k(a?Nd[a.handle]:null)},current:function(){return k(m)},previous:function(){return k(m?Fb(m):null)},next:function(){return k(m?Gb(m):null)},releaseItem:function(a){this._releaseItem(a.handle)},release:function(){n=!0,c(m),m=null;for(var a=Kd.next;a!==Md;){var b=a.next,d=a.fetchListeners;for(var e in d){var g=d[e];g.listBindingID===l&&(g.promise.cancel(),delete d[e])}a.bindingMap&&a.bindingMap[l]&&f(a),a=b}delete ld[l]}};return(je||ie)&&(o.first=function(){return k(Gb(Kd))}),ke&&(o.last=function(){return k(Fb(Ld))}),he&&(o.fromKey=function(a,b){return k(Kb(a,b))}),(ie||je&&he)&&(o.fromIndex=function(a){return k(Lb(a))}),le&&(o.fromDescription=function(a){return k(Mb(a))}),o},this.invalidateAll=function(){return xc()};var se=function(a,b){var c=new l;a.then(function(a){c.complete(a)},function(a){c.error(a)});var d=c.promise.then(null,function(c){return"WinJS.UI.VirtualizedDataSource.resetCount"===c.name?(pd=null,a=b.getCount()):j.wrapError(c)}),f=0,g={get:function(){return f++,new j(function(a,b){d.then(a,b)},function(){0===--f&&(c.promise.cancel(),a.cancel(),g===pd&&(pd=null))})},reset:function(){c.error(new e("WinJS.UI.VirtualizedDataSource.resetCount"))},cancel:function(){c.promise.cancel(),a.cancel(),g===pd&&(pd=null)}};return g};this.getCount=function(){if(a.getCount){var b=this;return j.wrap().then(function(){if(sd||vd)return Jd;var c;if(!pd){var d;c=a.getCount();var e;c.then(function(){pd===d&&(pd=null),e=!0},function(){pd===d&&(pd=null),e=!0}),zd=0,e||(d=pd=se(c,b))}return pd?pd.get():c}).then(function(a){if(!w(a)&&void 0!==a)throw new e("WinJS.UI.ListDataSource.InvalidRequestedCountReturned",s.invalidRequestedCountReturned);return a!==Jd&&(Jd===p.unknown?Jd=a:(lb(a),ib())),0===a&&(Kd.next!==Ld||Ld.next!==Md?wc():Kd.lastInSequence&&(H(Kd),Ld.index=0)),a}).then(null,function(a){return a.name===m.CountError.noResponse?(Nb(o.failure),Jd):j.wrapError(a)})}return j.wrap(Jd)},he&&(this.itemFromKey=function(a,b){return Hb(Kb(a,b))}),(ie||je&&he)&&(this.itemFromIndex=function(a){return Hb(Lb(a))}),le&&(this.itemFromDescription=function(a){return Hb(Mb(a))}),this.beginEdits=function(){sd=!0},a.insertAtStart&&(this.insertAtStart=function(b,c){return cd(b,c,Kd.lastInSequence?null:Kd.next,!0,function(){return a.insertAtStart(b,c)})}),a.insertBefore&&(this.insertBefore=function(b,c,d){var e=ad(d);return cd(b,c,e,!1,function(){return a.insertBefore(b,c,d,ub(e))})}),a.insertAfter&&(this.insertAfter=function(b,c,d){var e=ad(d);return cd(b,c,e?e.next:null,!0,function(){return a.insertAfter(b,c,d,ub(e))})}),a.insertAtEnd&&(this.insertAtEnd=function(b,c){return cd(b,c,Ld.firstInSequence?null:Ld,!1,function(){return a.insertAtEnd(b,c)})}),a.change&&(this.change=function(b,c){var d=ad(b);return new j(function(e,f){var g;Vc(function(){return a.change(b,c,ub(d))},re.change,e,f,null,function(){g=d.item,d.itemNew={key:b,data:c},g?qb(d):Bb(d)},function(){g?(d.itemNew=g,qb(d)):wc()})})}),a.moveToStart&&(this.moveToStart=function(b){var c=ad(b);return dd(c,Kd.next,!0,function(){return a.moveToStart(b,ub(c))})}),a.moveBefore&&(this.moveBefore=function(b,c){var d=ad(b),e=ad(c);return dd(d,e,!1,function(){return a.moveBefore(b,c,ub(d),ub(e))})}),a.moveAfter&&(this.moveAfter=function(b,c){var d=ad(b),e=ad(c);return dd(d,e.next,!0,function(){return a.moveAfter(b,c,ub(d),ub(e))})}),a.moveToEnd&&(this.moveToEnd=function(b){var c=ad(b);return dd(c,Ld,!1,function(){return a.moveToEnd(b,ub(c))})}),a.remove&&(this.remove=function(b){Ib(b);var c=Od[b];return new j(function(d,e){var f,g,h;Vc(function(){return a.remove(b,ub(c))},re.remove,d,e,null,function(){c&&(f=c.next,g=c.firstInSequence,h=c.lastInSequence,wb(c,-1),sb(c,!1))},function(){c&&(R(c,f,!g,!h),wb(c,1),pb(c))})})}),this.endEdits=function(){sd=!1,$c()}}var h=100,n=1,o=m.DataSourceStatus,p=m.CountResult,q=m.FetchError,r=m.EditError,s={get listDataAdapterIsInvalid(){return"Invalid argument: listDataAdapter must be an object or an array."},get indexIsInvalid(){return"Invalid argument: index must be a non-negative integer."},get keyIsInvalid(){return"Invalid argument: key must be a string."},get invalidItemReturned(){return"Error: data adapter returned item that is not an object."},get invalidKeyReturned(){return"Error: data adapter returned item with undefined or null key."},get invalidIndexReturned(){return"Error: data adapter should return undefined, null or a non-negative integer for the index."},get invalidCountReturned(){return"Error: data adapter should return undefined, null, CountResult.unknown, or a non-negative integer for the count."},get invalidRequestedCountReturned(){return"Error: data adapter should return CountResult.unknown, CountResult.failure, or a non-negative integer for the count."},get refreshCycleIdentified(){return"refresh cycle found, likely data inconsistency"}},t="statuschanged",u=c.Class.define(function(){},{_baseDataSourceConstructor:a,_isVirtualizedDataSource:!0},{supportedForProcessing:!1});return c.Class.mix(u,f.eventMixin),u})})}),d("WinJS/VirtualizedDataSource/_GroupDataSource",["exports","../Core/_Base","../Core/_ErrorFromName","../Promise","../Scheduler","../Utilities/_UI","./_VirtualizedDataSourceImpl"],function(a,b,c,d,e,f,g){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_GroupDataSource:b.Namespace._lazy(function(){function a(){return new c(f.FetchError.doesNotExist)}function h(a){return a&&a.firstReached&&a.lastReached}var i=101,j=b.Class.define(function(a){this._groupDataAdapter=a},{beginNotifications:function(){},inserted:function(a,b,c){this._groupDataAdapter._inserted(a,b,c)},changed:function(a,b){this._groupDataAdapter._changed(a,b)},moved:function(a,b,c){this._groupDataAdapter._moved(a,b,c)},removed:function(a,b){this._groupDataAdapter._removed(a,b)},countChanged:function(a,b){0===a&&0!==b&&this._groupDataAdapter.invalidateGroups()},indexChanged:function(a,b,c){this._groupDataAdapter._indexChanged(a,b,c)},endNotifications:function(){this._groupDataAdapter._endNotifications()},reload:function(){this._groupDataAdapter._reload()}},{supportedForProcessing:!1}),k=b.Class.define(function(a,b,c,d){this._listBinding=a.createListBinding(new j(this)),this._groupKey=b,this._groupData=c,this._initializeState(),this._batchSize=i,this._count=null,d&&("number"==typeof d.groupCountEstimate&&(this._count=d.groupCountEstimate<0?null:Math.max(d.groupCountEstimate,1)),"number"==typeof d.batchSize&&(this._batchSize=d.batchSize+1)),this._listBinding.last&&(this.itemsFromEnd=function(a){var b=this;return this._fetchItems(function(){return b._lastGroup},function(a){if(a)return!1;var c=b._count;return+c!==c?!0:c>0?!0:void 0},function(){b._fetchBatch(b._listBinding.last(),b._batchSize-1,0)},a-1,0)})},{setNotificationHandler:function(a){this._listDataNotificationHandler=a},compareByIdentity:!0,itemsFromKey:function(a,b,c,d){var e=this;return this._fetchItems(function(){return e._keyMap[a]},function(){var a=e._lastGroup;return a?+a.index!==a.index?!0:void 0:!0},function(){d=d||{};var a="string"==typeof d.groupMemberKey&&e._listBinding.fromKey?e._listBinding.fromKey(d.groupMemberKey):"number"==typeof d.groupMemberIndex&&e._listBinding.fromIndex?e._listBinding.fromIndex(d.groupMemberIndex):void 0!==d.groupMemberDescription&&e._listBinding.fromDescription?e._listBinding.fromDescription(d.groupMemberDescription):e._listBinding.first(),b=Math.floor(.5*(e._batchSize-1));e._fetchBatch(a,b,e._batchSize-1-b)},b,c)},itemsFromIndex:function(a,b,c){var d=this;return this._fetchItems(function(){return d._indexMap[a]},function(){var b=d._lastGroup;return b?+b.index!==b.index?!0:a<=b.index?!0:void 0:!0},function(){d._fetchNextIndex()},b,c)},getCount:function(){if(this._lastGroup&&"number"==typeof this._lastGroup.index)return d.wrap(this._count);var a=this,b=new d(function(b){var c={initialBatch:function(){a._fetchNextIndex()},getGroup:function(){return null},countBefore:0,countAfter:0,complete:function(c){c&&(a._count=0);var d=a._count;return"number"==typeof d?(b(d),!0):!1}};a._fetchQueue.push(c),a._itemBatch||a._continueFetch(c)});return"number"==typeof this._count?d.wrap(this._count):b},invalidateGroups:function(){this._beginRefresh(),this._initializeState()},_initializeState:function(){this._count=null,this._indexMax=null,this._keyMap={},this._indexMap={},this._lastGroup=null,this._handleMap={},this._fetchQueue=[],this._itemBatch=null,this._itemsToFetch=0,this._indicesChanged=!1},_releaseItem:function(a){delete this._handleMap[a.handle],this._listBinding.releaseItem(a)},_processBatch:function(){for(var a=null,b=null,c=null,d=0,f=!0,g=0;g<this._batchSize;g++){var h=this._itemBatch[g],i=h?this._groupKey(h):null;if(h&&(f=!1),b&&null!==i&&i===b.key)d++,b.lastItem===a?(b.lastItem.handle!==b.firstItem.handle&&this._releaseItem(b.lastItem),b.lastItem=h,this._handleMap[h.handle]=b,b.size++):b.firstItem===h&&(b.firstItem.handle!==b.lastItem.handle&&this._releaseItem(b.firstItem),b.firstItem=c,this._handleMap[c.handle]=b,b.size+=d);else{var j=null;if(b&&(b.lastReached=!0,"number"==typeof b.index&&(j=b.index+1)),h){var k=this._keyMap[i];if(k||(k={key:i,data:this._groupData(h),firstItem:h,lastItem:h,size:1},this._keyMap[k.key]=k,this._handleMap[h.handle]=k),g>0&&(k.firstReached=!0,b||(j=0)),"number"!=typeof k.index&&"number"==typeof j){for(var l=k;l;l=this._nextGroup(l))l.index=j,this._indexMap[j]=l,j++;this._indexMax=j,"number"==typeof this._count&&!this._lastGroup&&this._count<=this._indexMax&&(this._count=this._indexMax+1)}c=h,d=0,b=k}else b&&(this._lastGroup=b,"number"==typeof b.index&&(this._count=b.index+1),this._listDataNotificationHandler.invalidateAll(),b=null)}a=h}var m;for(m=this._fetchQueue[0];m&&m.complete(f);m=this._fetchQueue[0])this._fetchQueue.splice(0,1);if(m){var n=this;e.schedule(function(){n._continueFetch(m)},e.Priority.normal,null,"WinJS.UI._GroupDataSource._continueFetch")}else this._itemBatch=null},_processPromise:function(a,b){a.retain(),this._itemBatch[b]=a;var c=this;a.then(function(a){c._itemBatch[b]=a,0===--c._itemsToFetch&&c._processBatch()})},_fetchBatch:function(a,b){this._itemBatch=new Array(this._batchSize),this._itemsToFetch=this._batchSize,this._processPromise(a,b);var c;for(this._listBinding.jumpToItem(a),c=b-1;c>=0;c--)this._processPromise(this._listBinding.previous(),c);for(this._listBinding.jumpToItem(a),c=b+1;c<this._batchSize;c++)this._processPromise(this._listBinding.next(),c)},_fetchAdjacent:function(a,b){this._fetchBatch(this._listBinding.fromKey?this._listBinding.fromKey(a.key):this._listBinding.fromIndex(a.index),b?0:this._batchSize-1,b?this._batchSize-1:0)},_fetchNextIndex:function(){var a=this._indexMap[this._indexMax-1];a?this._fetchAdjacent(a.lastItem,!0):this._fetchBatch(this._listBinding.first(),1,this._batchSize-2)},_continueFetch:function(a){if(a.initialBatch)a.initialBatch(),a.initialBatch=null;else{var b=a.getGroup();if(b){var c,d;b.firstReached?b.lastReached?a.countBefore>0&&0!==b.index&&!h(c=this._previousGroup(b))?this._fetchAdjacent(c&&c.lastReached?c.firstItem:b.firstItem,!1):(d=this._nextGroup(b),this._fetchAdjacent(d&&d.firstReached?d.lastItem:b.lastItem,!0)):this._fetchAdjacent(b.lastItem,!0):this._fetchAdjacent(b.firstItem,!1)}else this._fetchNextIndex()}},_fetchComplete:function(a,b,c,d,e){if(h(a)){var g=this._previousGroup(a);if(d||h(g)||0===a.index||0===b){var i=this._nextGroup(a);if(d||h(i)||this._lastGroup===a||0===c){for(var j=0,k=a;b>j&&(g=this._previousGroup(k),h(g));)k=g,j++;for(var l=0,m=a;c>l&&(i=this._nextGroup(m),h(i));)m=i,l++;for(var n=j+1+l,o=new Array(n),p=0;n>p;p++){var q={key:k.key,data:k.data,firstItemKey:k.firstItem.key,groupSize:k.size},r=k.firstItem.index;"number"==typeof r&&(q.firstItemIndexHint=r),o[p]=q,k=this._nextGroup(k)}var s={items:o,offset:j};return s.totalCount="number"==typeof this._count?this._count:f.CountResult.unknown,"number"==typeof a.index&&(s.absoluteIndex=a.index),m===this._lastGroup&&(s.atEnd=!0),e(s),!0}}}return!1},_fetchItems:function(b,c,e,f,g){var h=this;return new d(function(d,i){function j(e){var j=b();return j?h._fetchComplete(j,f,g,l,d,i):l&&!c(e)?(i(a()),!0):m>2?(i(a()),!0):(e?m++:m=0,!1)}var k=b(),l=!k,m=0;if(!j()){var n={initialBatch:l?e:null,getGroup:b,countBefore:f,countAfter:g,complete:j};h._fetchQueue.push(n),h._itemBatch||h._continueFetch(n)}})},_previousGroup:function(a){return a&&a.firstReached?(this._listBinding.jumpToItem(a.firstItem),this._handleMap[this._listBinding.previous().handle]):null},_nextGroup:function(a){return a&&a.lastReached?(this._listBinding.jumpToItem(a.lastItem),this._handleMap[this._listBinding.next().handle]):null},_invalidateIndices:function(a){this._count=null,this._lastGroup=null,"number"==typeof a.index&&(this._indexMax=a.index>0?a.index:null);for(var b=a;b&&"number"==typeof b.index;b=this._nextGroup(b))delete this._indexMap[b.index],b.index=null},_releaseGroup:function(a){this._invalidateIndices(a),delete this._keyMap[a.key],this._lastGroup===a&&(this._lastGroup=null),a.firstItem!==a.lastItem&&this._releaseItem(a.firstItem),this._releaseItem(a.lastItem)},_beginRefresh:function(){if(this._fetchQueue=[],this._itemBatch){for(var a=0;a<this._batchSize;a++){var b=this._itemBatch[a];b&&(b.cancel&&b.cancel(),this._listBinding.releaseItem(b))}this._itemBatch=null}this._itemsToFetch=0,this._listDataNotificationHandler.invalidateAll()},_processInsertion:function(a,b,c){var d=this._handleMap[b],e=this._handleMap[c],f=null;d&&(d.lastReached&&b===d.lastItem.handle&&(f=this._groupKey(a))!==d.key?this._lastGroup===d&&(this._lastGroup=null,this._count=null):this._releaseGroup(d),this._beginRefresh()),e&&e!==d&&(this._invalidateIndices(e),e.firstReached&&c===e.firstItem.handle&&(null!==f?f:this._groupKey(a))!==e.key||this._releaseGroup(e),this._beginRefresh())},_processRemoval:function(a){var b=this._handleMap[a];if(!b||a!==b.firstItem.handle&&a!==b.lastItem.handle){if(this._itemBatch)for(var c=0;c<this._batchSize;c++){var d=this._itemBatch[c];if(d&&d.handle===a){this._beginRefresh();break}}}else this._releaseGroup(b),this._beginRefresh()},_inserted:function(a,b,c){var d=this;a.then(function(a){d._processInsertion(a,b,c)})},_changed:function(a,b){var c=this._handleMap[a.handle];if(c&&a.handle===c.firstItem.handle&&(this._releaseGroup(c),this._beginRefresh()),this._groupKey(a)!==this._groupKey(b)){this._listBinding.jumpToItem(a);var d=this._listBinding.previous().handle;this._listBinding.jumpToItem(a);var e=this._listBinding.next().handle;this._processRemoval(a.handle),this._processInsertion(a,d,e)}},_moved:function(a,b,c){this._processRemoval(a.handle);var d=this;a.then(function(a){d._processInsertion(a,b,c)})},_removed:function(a,b){b||this._processRemoval(a)},_indexChanged:function(a,b,c){"number"==typeof c&&(this._indicesChanged=!0)},_endNotifications:function(){if(this._indicesChanged){this._indicesChanged=!1;for(var a in this._keyMap){var b=this._keyMap[a];if(b.firstReached&&b.lastReached){var c=b.lastItem.index+1-b.firstItem.index;isNaN(c)||(b.size=c)}}this._beginRefresh()}},_reload:function(){this._initializeState(),this._listDataNotificationHandler.reload()}},{supportedForProcessing:!1});return b.Class.derive(g.VirtualizedDataSource,function(a,b,c,d){var e=new k(a,b,c,d);this._baseDataSourceConstructor(e),this.extensions={invalidateGroups:function(){e.invalidateGroups()}}},{},{supportedForProcessing:!1})})})}),d("WinJS/VirtualizedDataSource/_GroupedItemDataSource",["../Core/_Base","./_GroupDataSource"],function(a,b){"use strict";a.Namespace.define("WinJS.UI",{computeDataSourceGroups:function(a,c,d,e){function f(a){if(a){var b=Object.create(a);return b.groupKey=c(a),d&&(b.groupData=d(a)),b}return null}function g(a){var b=Object.create(a);return b.then=function(b,c,d){return a.then(function(a){return b(f(a))},c,d)},b}var h=Object.create(a);h.createListBinding=function(b){var c;b?(c=Object.create(b),c.inserted=function(a,c,d){return b.inserted(g(a),c,d)},c.changed=function(a,c){return b.changed(f(a),f(c))},c.moved=function(a,c,d){return b.moved(g(a),c,d)}):c=null;for(var d=a.createListBinding(c),e=Object.create(d),h=["first","last","fromDescription","jumpToItem","current"],i=0,j=h.length;j>i;i++)!function(a){d[a]&&(e[a]=function(){return g(d[a].apply(d,arguments))})}(h[i]);return d.fromKey&&(e.fromKey=function(a){return g(d.fromKey(a))}),d.fromIndex&&(e.fromIndex=function(a){return g(d.fromIndex(a))}),e.prev=function(){return g(d.prev())},e.next=function(){return g(d.next())},e};for(var i=["itemFromKey","itemFromIndex","itemFromDescription","insertAtStart","insertBefore","insertAfter","insertAtEnd","change","moveToStart","moveBefore","moveAfter","moveToEnd"],j=0,k=i.length;k>j;j++)!function(b){a[b]&&(h[b]=function(){return g(a[b].apply(a,arguments))})}(i[j]);["addEventListener","removeEventListener","dispatchEvent"].forEach(function(b){a[b]&&(h[b]=function(){return a[b].apply(a,arguments)})});var l=null;return Object.defineProperty(h,"groups",{get:function(){return l||(l=new b._GroupDataSource(a,c,d,e)),l},enumerable:!0,configurable:!0}),h}})}),d("WinJS/VirtualizedDataSource/_StorageDataSource",["exports","../Core/_WinRT","../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_WriteProfilerMark","../Animations","../Promise","../Utilities/_UI","./_VirtualizedDataSourceImpl"],function(a,b,c,d,e,f,g,h,i,j){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{StorageDataSource:d.Namespace._lazy(function(){var a=d.Class.define(function(a,c){f("WinJS.UI.StorageDataSource:constructor,StartTM");var d,e=b.Windows.Storage.FileProperties.ThumbnailMode.singleItem,g=256,h=b.Windows.Storage.FileProperties.ThumbnailOptions.useCurrentScale,i=!0;if("Pictures"===a?(e=b.Windows.Storage.FileProperties.ThumbnailMode.picturesView,d=b.Windows.Storage.KnownFolders.picturesLibrary,g=190):"Music"===a?(e=b.Windows.Storage.FileProperties.ThumbnailMode.musicView,d=b.Windows.Storage.KnownFolders.musicLibrary,g=256):"Documents"===a?(e=b.Windows.Storage.FileProperties.ThumbnailMode.documentsView,d=b.Windows.Storage.KnownFolders.documentsLibrary,g=40):"Videos"===a&&(e=b.Windows.Storage.FileProperties.ThumbnailMode.videosView,d=b.Windows.Storage.KnownFolders.videosLibrary,g=190),d){var j=new b.Windows.Storage.Search.QueryOptions;j.folderDepth=b.Windows.Storage.Search.FolderDepth.deep,j.indexerOption=b.Windows.Storage.Search.IndexerOption.useIndexerWhenAvailable,this._query=d.createFileQueryWithOptions(j)}else this._query=a;if(c){if("number"==typeof c.mode&&(e=c.mode),"number"==typeof c.requestedThumbnailSize)g=Math.max(1,Math.min(c.requestedThumbnailSize,1024));else switch(e){case b.Windows.Storage.FileProperties.ThumbnailMode.picturesView:case b.Windows.Storage.FileProperties.ThumbnailMode.videosView:g=190;break;case b.Windows.Storage.FileProperties.ThumbnailMode.documentsView:case b.Windows.Storage.FileProperties.ThumbnailMode.listView:g=40;break;case b.Windows.Storage.FileProperties.ThumbnailMode.musicView:case b.Windows.Storage.FileProperties.ThumbnailMode.singleItem:g=256}"number"==typeof c.thumbnailOptions&&(h=c.thumbnailOptions),"boolean"==typeof c.waitForFileLoad&&(i=!c.waitForFileLoad)}this._loader=new b.Windows.Storage.BulkAccess.FileInformationFactory(this._query,e,g,h,i),this.compareByIdentity=!1,this.firstDataRequest=!0,f("WinJS.UI.StorageDataSource:constructor,StopTM")},{setNotificationHandler:function(a){this._notificationHandler=a,this._query.addEventListener("contentschanged",function(){a.invalidateAll()}),this._query.addEventListener("optionschanged",function(){a.invalidateAll()})},itemsFromEnd:function(a){var b=this;return f("WinJS.UI.StorageDataSource:itemsFromEnd,info"),this.getCount().then(function(c){return 0===c?h.wrapError(new e(i.FetchError.doesNotExist)):b.itemsFromIndex(c-1,Math.min(c-1,a-1),1)})},itemsFromIndex:function(a,b,c){function d(a){k._notificationHandler.changed(k._item(a.target))}b+c>64&&(b=Math.min(b,32),c=64-(b+1));var g=a-b,j=b+1+c,k=this;k.firstDataRequest&&(k.firstDataRequest=!1,j=Math.max(j,32));var l="WinJS.UI.StorageDataSource:itemsFromIndex("+g+"-"+(g+j-1)+")";return f(l+",StartTM"),this._loader.getItemsAsync(g,j).then(function(c){var m=c.size;if(b>=m)return h.wrapError(new e(i.FetchError.doesNotExist));var n=new Array(m),o=new Array(m);c.getMany(0,o);for(var p=0;m>p;p++)n[p]=k._item(o[p]),o[p].addEventListener("propertiesupdated",d);var q={items:n,offset:b,absoluteIndex:a};return j>m&&(q.totalCount=g+m),f(l+",StopTM"),q})},itemsFromDescription:function(a,b,c){var d=this;return f("WinJS.UI.StorageDataSource:itemsFromDescription,info"),this._query.findStartIndexAsync(a).then(function(a){return d.itemsFromIndex(a,b,c)})},getCount:function(){return f("WinJS.UI.StorageDataSource:getCount,info"),this._query.getItemCountAsync()},itemSignature:function(a){return a.folderRelativeId},_item:function(a){return{key:a.path||a.folderRelativeId,data:a}}},{supportedForProcessing:!1});return d.Class.derive(j.VirtualizedDataSource,function(b,c){this._baseDataSourceConstructor(new a(b,c))},{},{loadThumbnail:function(a,d){var e,i,j=!1;return new h(function(k){var l=d?!0:!1,m=function(m){if(m){var n=c.URL.createObjectURL(m,{oneTimeOnly:!0});i=i?i.then(function(b){return a.loadImage(n,b)}):a.loadImage(n,d).then(function(b){return a.isOnScreen().then(function(a){var c;return a&&l?c=g.fadeIn(b).then(function(){return b}):(b.style.opacity=1,c=h.wrap(b)),c})}),m.type===b.Windows.Storage.FileProperties.ThumbnailType.icon||m.returnedSmallerCachedSize||(f("WinJS.UI.StorageDataSource:loadThumbnail complete,info"),a.data.removeEventListener("thumbnailupdated",e),j=!1,i=i.then(function(a){e=null,i=null,k(a)}))}};e=function(a){j&&m(a.target.thumbnail)},a.data.addEventListener("thumbnailupdated",e),j=!0,m(a.data.thumbnail)},function(){a.data.removeEventListener("thumbnailupdated",e),j=!1,e=null,i&&(i.cancel(),i=null)})},supportedForProcessing:!1})})})}),d("WinJS/VirtualizedDataSource",["./VirtualizedDataSource/_VirtualizedDataSourceImpl","./VirtualizedDataSource/_GroupDataSource","./VirtualizedDataSource/_GroupedItemDataSource","./VirtualizedDataSource/_StorageDataSource"],function(){}),d("require-style",{load:function(a){throw new Error("Dynamic load not allowed: "+a)}}),d("require-style!less/desktop/styles-intrinsic",[],function(){}),d("require-style!less/desktop/colors-intrinsic",[],function(){}),d("require-style!less/phone/styles-intrinsic",[],function(){}),d("require-style!less/phone/colors-intrinsic",[],function(){}),d("WinJS/Controls/IntrinsicControls",["../Utilities/_Hoverable","require-style!less/desktop/styles-intrinsic","require-style!less/desktop/colors-intrinsic","require-style!less/phone/styles-intrinsic","require-style!less/phone/colors-intrinsic"],function(){}),d("WinJS/Controls/ItemContainer/_Constants",["exports","../../Core/_Base"],function(a,b){"use strict";var c={};c._listViewClass="win-listview",c._listViewSupportsCrossSlideClass="win-listview-supports-cross-slide",c._viewportClass="win-viewport",c._rtlListViewClass="win-rtl",c._horizontalClass="win-horizontal",c._verticalClass="win-vertical",c._scrollableClass="win-surface",c._itemsContainerClass="win-itemscontainer",c._padderClass="win-itemscontainer-padder",c._proxyClass="_win-proxy",c._itemClass="win-item",c._itemBoxClass="win-itembox",c._itemsBlockClass="win-itemsblock",c._containerClass="win-container",c._backdropClass="win-backdrop",c._footprintClass="win-footprint",c._groupsClass="win-groups",c._selectedClass="win-selected",c._swipeableClass="win-swipeable",c._swipeClass="win-swipe",c._selectionBorderClass="win-selectionborder",c._selectionBackgroundClass="win-selectionbackground",c._selectionCheckmarkClass="win-selectioncheckmark",c._selectionCheckmarkBackgroundClass="win-selectioncheckmarkbackground",c._pressedClass="win-pressed",c._headerClass="win-groupheader",c._headerContainerClass="win-groupheadercontainer",c._groupLeaderClass="win-groupleader",c._progressClass="win-progress",c._selectionHintClass="win-selectionhint",c._revealedClass="win-revealed",c._itemFocusClass="win-focused",c._itemFocusOutlineClass="win-focusedoutline",c._zoomingXClass="win-zooming-x",c._zoomingYClass="win-zooming-y",c._listLayoutClass="win-listlayout",c._gridLayoutClass="win-gridlayout",c._headerPositionTopClass="win-headerpositiontop",c._headerPositionLeftClass="win-headerpositionleft",c._structuralNodesClass="win-structuralnodes",c._uniformGridLayoutClass="win-uniformgridlayout",c._uniformListLayoutClass="win-uniformlistlayout",c._cellSpanningGridLayoutClass="win-cellspanninggridlayout",c._laidOutClass="win-laidout",c._nonDraggableClass="win-nondraggable",c._nonSelectableClass="win-nonselectable",c._nonSwipeableClass="win-nonswipeable",c._dragOverClass="win-dragover",c._dragSourceClass="win-dragsource",c._clipClass="win-clip",c._selectionModeClass="win-selectionmode",c._noCSSGrid="win-nocssgrid",c._INVALID_INDEX=-1,c._UNINITIALIZED=-1,c._LEFT_MSPOINTER_BUTTON=0,c._RIGHT_MSPOINTER_BUTTON=2,c._TAP_END_THRESHOLD=10,c._DEFAULT_PAGES_TO_LOAD=5,c._DEFAULT_PAGE_LOAD_THRESHOLD=2,c._MIN_AUTOSCROLL_RATE=150,c._MAX_AUTOSCROLL_RATE=1500,c._AUTOSCROLL_THRESHOLD=100,c._AUTOSCROLL_DELAY=50,c._DEFERRED_ACTION=250,c._DEFERRED_SCROLL_END=250,c._VERTICAL_SWIPE_SELECTION_THRESHOLD=39,c._VERTICAL_SWIPE_SPEED_BUMP_START=0,c._VERTICAL_SWIPE_SPEED_BUMP_END=127,c._VERTICAL_SWIPE_SELF_REVEAL_GESTURE=15,c._HORIZONTAL_SWIPE_SELECTION_THRESHOLD=27,c._HORIZONTAL_SWIPE_SPEED_BUMP_START=0,c._HORIZONTAL_SWIPE_SPEED_BUMP_END=150,c._HORIZONTAL_SWIPE_SELF_REVEAL_GESTURE=23,c._SELECTION_CHECKMARK="",c._LISTVIEW_PROGRESS_DELAY=2e3;
  var d={uninitialized:0,low:1,medium:2,high:3},e={rebuild:0,remeasure:1,relayout:2,realize:3};c._ScrollToPriority=d,c._ViewChange=e,b.Namespace._moduleDefine(a,"WinJS.UI",c)}),d("WinJS/Controls/ItemContainer/_ItemEventsHandler",["exports","../../Core/_Global","../../Core/_WinRT","../../Core/_Base","../../Core/_BaseUtils","../../Core/_WriteProfilerMark","../../Animations","../../Animations/_TransitionAnimation","../../Promise","../../Utilities/_ElementUtilities","../../Utilities/_UI","./_Constants"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";function m(a){var b=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);return{x:a.x/b,y:a.y/b,z:a.z/b}}function n(a,b){var c=m(b),d=Math.cos(a),e=Math.sin(a),f=[d+c.x*c.x*(1-d),c.x*c.y*(1-d)-c.z*e,c.x*c.z*(1-d)+c.y*e,0,c.y*c.x*(1-d)+c.z*e,d+c.y*c.y*(1-d),c.y*c.z*(1-d)-c.x*e,0,c.z*c.x*(1-d)-c.y*e,c.z*c.y*(1-d)+c.x*e,d+c.z*c.z*(1-d),0,0,0,0,1];return f=f.map(function(a){return a.toFixed(8)}),"matrix3d("+f.join(",")+")"}function o(a,b,c){var d=j._clamp((a-c.left)/c.width,0,1),e=j._clamp((b-c.top)/c.height,0,1),f={x:e-.5,y:-(d-.5),z:1e-4},g=Math.abs(d-.5)+Math.abs(e-.5),h=g*q,i=1-(1-g)*r,k="perspective(800px) scale("+i+", "+i+") "+n(h,f);return k}var p=e._browserStyleEquivalents.transform,q=.15,r=.025,s=j._uniqueID,t=j._MSManipulationEvent;d.Namespace._moduleDefine(a,"WinJS.UI",{_rotationTransform3d:n,_tiltTransform:o,_ItemEventsHandler:d.Namespace._lazy(function(){function a(a,b){return a.querySelector("."+b)}function m(a,c){var d=b.document.createElement("div");return d.className=a,c||d.setAttribute("aria-hidden",!0),d}var n=j._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",q=d.Class.define(function(a){if(this._site=a,this._work=[],this._animations={},this._selectionHintTracker={},this._swipeClassTracker={},!e.isPhone&&this._selectionAllowed()){var c=this;b.setTimeout(function(){c._gestureRecognizer||a.isZombie()||(c._gestureRecognizer=c._createGestureRecognizer())},500)}},{dispose:function(){this._disposed||(this._disposed=!0,this._gestureRecognizer=null,j._removeEventListener(b,"pointerup",this._resetPointerDownStateBound),j._removeEventListener(b,"pointercancel",this._resetPointerDownStateBound))},onMSManipulationStateChanged:function(a){var b=a.currentState;if(b===t.MS_MANIPULATION_STATE_PRESELECT&&!this._site.pressedItemBox){var c=this._site.indexForItemElement(a.target);if(this._site.pressedEntity={type:k.ObjectType.item,index:c},this._site.pressedEntity.index!==l._INVALID_INDEX){this._site.pressedItemBox=this._site.itemBoxAtIndex(this._site.pressedEntity.index),this._site.pressedContainer=this._site.containerAtIndex(this._site.pressedEntity.index),this._site.animatedElement=e.isPhone?this._site.pressedItemBox:this._site.pressedContainer,this._site.pressedHeader=null;var d=this._site.verifySelectionAllowed(this._site.pressedEntity);this._canSelect=d.canSelect,this._canTapSelect=d.canTapSelect,this._swipeBehaviorSelectionChanged=!1,this._selectionHint=null,this._canSelect&&this._addSelectionHint()}}!this._canSelect||b!==t.MS_MANIPULATION_STATE_PRESELECT&&b!==t.MS_MANIPULATION_STATE_COMMITTED&&b!==t.MS_MANIPULATION_STATE_CANCELLED&&b!==t.MS_MANIPULATION_STATE_SELECTING&&b!==t.MS_MANIPULATION_STATE_DRAGGING||this._dispatchSwipeBehavior(b),(b===t.MS_MANIPULATION_STATE_COMMITTED||b===t.MS_MANIPULATION_STATE_CANCELLED||b===t.MS_MANIPULATION_STATE_STOPPED)&&this.resetPointerDownState()},onPointerDown:function(a){f("WinJS.UI._ItemEventsHandler:MSPointerDown,StartTM");var d,g,h=this._site,i=a.pointerType===n;if(h.pressedElement=a.target,c.Windows.UI.Input.PointerPoint){var m=this._getCurrentPoint(a),o=m.properties;i||o.isInverted||o.isEraser||o.isMiddleButtonPressed?d=g=!1:(g=o.isRightButtonPressed,d=!g&&o.isLeftButtonPressed)}else d=a.button===l._LEFT_MSPOINTER_BUTTON,g=a.button===l._RIGHT_MSPOINTER_BUTTON;this._DragStartBound=this._DragStartBound||this.onDragStart.bind(this),this._PointerEnterBound=this._PointerEnterBound||this.onPointerEnter.bind(this),this._PointerLeaveBound=this._PointerLeaveBound||this.onPointerLeave.bind(this),this._swipeBehaviorState=t.MS_MANIPULATION_STATE_STOPPED;var p=h.swipeBehavior===k.SwipeBehavior.select,q=this._isInteractive(a.target),r=h.indexForItemElement(a.target),s=h.indexForHeaderElement(a.target),u=!q&&r!==l._INVALID_INDEX;if((i||d||this._selectionAllowed()&&p&&g)&&this._site.pressedEntity.index===l._INVALID_INDEX&&!q&&(this._site.pressedEntity=s===l._INVALID_INDEX?{type:k.ObjectType.item,index:r}:{type:k.ObjectType.groupHeader,index:s},this._site.pressedEntity.index!==l._INVALID_INDEX)){this._site.pressedPosition=j._getCursorPos(a);var v=h.verifySelectionAllowed(this._site.pressedEntity);if(this._canSelect=v.canSelect,this._canTapSelect=v.canTapSelect,this._swipeBehaviorSelectionChanged=!1,this._selectionHint=null,this._site.pressedEntity.type!==k.ObjectType.groupHeader?(this._site.pressedItemBox=h.itemBoxAtIndex(this._site.pressedEntity.index),this._site.pressedContainer=h.containerAtIndex(this._site.pressedEntity.index),this._site.animatedElement=e.isPhone?this._site.pressedItemBox:this._site.pressedContainer,this._site.pressedHeader=null,this._togglePressed(!0,!1,a),this._site.pressedContainer.addEventListener("dragstart",this._DragStartBound),i||(j._addEventListener(this._site.pressedContainer,"pointerenter",this._PointerEnterBound,!1),j._addEventListener(this._site.pressedContainer,"pointerleave",this._PointerLeaveBound,!1))):(this._site.pressedHeader=this._site.headerFromElement(a.target),e.isPhone?(this._site.animatedElement=this._site.pressedHeader,this._togglePressed(!0,!1,a)):(this._site.pressedItemBox=null,this._site.pressedContainer=null,this._site.animatedElement=null)),this._resetPointerDownStateBound||(this._resetPointerDownStateBound=this._resetPointerDownStateForPointerId.bind(this)),i||(j._addEventListener(b,"pointerup",this._resetPointerDownStateBound,!1),j._addEventListener(b,"pointercancel",this._resetPointerDownStateBound,!1)),this._canSelect&&!e.isPhone&&(this._gestureRecognizer||(this._gestureRecognizer=this._createGestureRecognizer()),this._addSelectionHint()),this._pointerId=a.pointerId,this._pointerRightButton=g,this._pointerTriggeredSRG=!1,this._gestureRecognizer&&i)try{this._gestureRecognizer.addPointer(this._pointerId)}catch(w){this._gestureRecognizer.stop()}}if(u&&i)try{j._setPointerCapture(h.canvasProxy,a.pointerId)}catch(w){return void f("WinJS.UI._ItemEventsHandler:MSPointerDown,StopTM")}this._site.pressedEntity.type!==k.ObjectType.groupHeader&&this._selectionAllowed()&&this._multiSelection()&&this._site.pressedEntity.index!==l._INVALID_INDEX&&h.selection._getFocused().index!==l._INVALID_INDEX&&h.selection._pivot===l._INVALID_INDEX&&(h.selection._pivot=h.selection._getFocused().index),f("WinJS.UI._ItemEventsHandler:MSPointerDown,StopTM")},onPointerEnter:function(a){this._site.pressedContainer&&this._pointerId===a.pointerId&&this._togglePressed(!0,!1,a)},onPointerLeave:function(a){this._site.pressedContainer&&this._pointerId===a.pointerId&&this._togglePressed(!1,!0,a)},onDragStart:function(){this._resetPressedContainer()},_resetPressedContainer:function(){(this._site.pressedContainer||this._site.pressedHeader)&&this._site.animatedElement&&(this._togglePressed(!1),this._site.pressedContainer&&(this._site.pressedContainer.removeEventListener("dragstart",this._DragStartBound),j._removeEventListener(this._site.pressedContainer,"pointerenter",this._PointerEnterBound,!1),j._removeEventListener(this._site.pressedContainer,"pointerleave",this._PointerLeaveBound,!1)))},onClick:function(a){if(!this._skipClick){var b={type:k.ObjectType.item,index:this._site.indexForItemElement(a.target)};if(b.index===l._INVALID_INDEX&&(b.index=this._site.indexForHeaderElement(a.target),b.index!==l._INVALID_INDEX&&(b.type=k.ObjectType.groupHeader)),b.index!==l._INVALID_INDEX&&(j.hasClass(a.target,this._site.accessibleItemClass)||j.hasClass(a.target,l._headerClass))){var c=this._site.verifySelectionAllowed(b);c.canTapSelect&&this.handleTap(b),this._site.fireInvokeEvent(b,a.target)}}},onPointerUp:function(a){f("WinJS.UI._ItemEventsHandler:MSPointerUp,StartTM");var b=this._site;this._skipClick=!0;var c=this,d=this._site.swipeBehavior===k.SwipeBehavior.select;e._yieldForEvents(function(){c._skipClick=!1});try{j._releasePointerCapture(b.canvasProxy,a.pointerId)}catch(g){}var h=a.pointerType===n,i=this._releasedElement(a),m=b.indexForItemElement(i),o=b.indexForHeaderElement(i&&j.hasClass(i,l._headerContainerClass)?b.pressedHeader:i);if(this._pointerId===a.pointerId){var p;if(p=o===l._INVALID_INDEX?{type:k.ObjectType.item,index:m}:{type:k.ObjectType.groupHeader,index:o},this._resetPressedContainer(),this._site.pressedEntity.type!==k.ObjectType.groupHeader&&p.type!==k.ObjectType.groupHeader&&this._site.pressedContainer&&this._site.pressedEntity.index===p.index)if(a.shiftKey||(b.selection._pivot=l._INVALID_INDEX),a.shiftKey){if(this._selectionAllowed()&&this._multiSelection()&&b.selection._pivot!==l._INVALID_INDEX){var q=Math.min(this._site.pressedEntity.index,b.selection._pivot),r=Math.max(this._site.pressedEntity.index,b.selection._pivot),s=this._pointerRightButton||a.ctrlKey||b.tapBehavior===k.TapBehavior.toggleSelect;b.selectRange(q,r,s)}}else(a.ctrlKey||this._selectionAllowed()&&d&&this._pointerRightButton)&&this.handleSwipeBehavior(this._site.pressedEntity.index);if((this._site.pressedHeader||this._site.pressedContainer)&&this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_COMMITTED){var u=j._getCursorPos(a),v=Math.abs(u.left-this._site.pressedPosition.left)<=l._TAP_END_THRESHOLD&&Math.abs(u.top-this._site.pressedPosition.top)<=l._TAP_END_THRESHOLD;this._endSelfRevealGesture(),this._clearItem(this._site.pressedEntity,this._isSelected(this._site.pressedEntity.index)),this._pointerRightButton||this._pointerTriggeredSRG||a.ctrlKey||a.shiftKey||!(h&&v||!h&&this._site.pressedEntity.index===p.index&&this._site.pressedEntity.type===p.type)||(p.type===k.ObjectType.groupHeader?(this._site.pressedHeader=b.headerAtIndex(p.index),this._site.pressedItemBox=null,this._site.pressedContainer=null):(this._site.pressedItemBox=b.itemBoxAtIndex(p.index),this._site.pressedContainer=b.containerAtIndex(p.index),this._site.pressedHeader=null),this._canTapSelect&&this.handleTap(this._site.pressedEntity),this._site.fireInvokeEvent(this._site.pressedEntity,this._site.pressedItemBox||this._site.pressedHeader))}this._site.pressedEntity.index!==l._INVALID_INDEX&&b.changeFocus(this._site.pressedEntity,!0,!1,!0),this.resetPointerDownState()}f("WinJS.UI._ItemEventsHandler:MSPointerUp,StopTM")},onPointerCancel:function(a){this._pointerId===a.pointerId&&this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_PRESELECT&&(f("WinJS.UI._ItemEventsHandler:MSPointerCancel,info"),this.resetPointerDownState())},onLostPointerCapture:function(a){this._pointerId===a.pointerId&&this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_PRESELECT&&(f("WinJS.UI._ItemEventsHandler:MSLostPointerCapture,info"),this.resetPointerDownState())},onContextMenu:function(a){var b=this._site.containerFromElement(a.target);this._selectionAllowed()&&b&&!this._isInteractive(a.target)&&a.preventDefault()},onMSHoldVisual:function(a){this._isInteractive(a.target)||a.preventDefault()},onDataChanged:function(){this.resetPointerDownState()},handleSwipeBehavior:function(a){this._selectionAllowed(a)&&this._toggleItemSelection(a)},handleTap:function(a){if(a.type!==k.ObjectType.groupHeader){var b=this._site,c=b.selection;this._selectionAllowed(a.index)&&this._selectOnTap()&&(b.tapBehavior===k.TapBehavior.toggleSelect?this._toggleItemSelection(a.index):b.selectionMode!==k.SelectionMode.multi&&c._isIncluded(a.index)||c.set(a.index))}},_toggleItemSelection:function(a){var b=this._site,c=b.selection,d=c._isIncluded(a);b.selectionMode===k.SelectionMode.single?d?c.clear():c.set(a):d?c.remove(a):c.add(a)},_getCurrentPoint:function(a){return c.Windows.UI.Input.PointerPoint.getCurrentPoint(a.pointerId)},_containedInElementWithClass:function(a,b){if(a.parentNode)for(var c=a.parentNode.querySelectorAll("."+b+", ."+b+" *"),d=0,e=c.length;e>d;d++)if(c[d]===a)return!0;return!1},_isSelected:function(a){return!this._swipeBehaviorSelectionChanged&&this._site.selection._isIncluded(a)||this._swipeBehaviorSelectionChanged&&this.swipeBehaviorSelected},_isInteractive:function(a){return this._containedInElementWithClass(a,"win-interactive")},_togglePressed:function(a,b,c){function d(a){""===m._site.animatedElement.style[p.scriptName]?(m._site.animatedElement.style[p.scriptName]=a,m._site.animatedElementScaleTransform=m._site.animatedElement.style[p.scriptName]):m._site.animatedElementScaleTransform=""}function g(a,b){f("WinJS.UI._ItemEventsHandler:removePressedUI,info"),j.removeClass(a,l._pressedClass),e.isPhone?m._containsTransform(a,b)&&h.executeTransition(a,{property:p.cssName,delay:0,duration:500,timing:"cubic-bezier(0.7025,0,0.9225,-0.115)",to:a.style[p.scriptName].replace(b,"")}):m._removeTransform(a,b)}var m=this,n=this._site.pressedEntity.type===k.ObjectType.groupHeader;if(this._site.animatedDownPromise&&this._site.animatedDownPromise.cancel(),!(e.isPhone&&!n&&j.hasClass(this._site.pressedItemBox,l._nonSelectableClass)||this._staticMode(n)))if(a){if(!j.hasClass(this._site.animatedElement,l._pressedClass))if(f("WinJS.UI._ItemEventsHandler:applyPressedUI,info"),j.addClass(this._site.animatedElement,l._pressedClass),c&&e.isPhone){var q=n?m._site.pressedHeader:m._site.pressedContainer,r=o(c.clientX,c.clientY,q.getBoundingClientRect());this._site.animatedDownPromise=i.timeout(50).then(function(){d(r)})}else{var s=.975,t=7;this._site.getItemPosition(this._site.pressedEntity).then(function(a){a.contentWidth>0&&(s=Math.max(s,1-t/a.contentWidth)),a.contentHeight>0&&(s=Math.max(s,1-t/a.contentHeight))},function(){}),d("scale("+s+","+s+")")}}else if(j.hasClass(this._site.animatedElement,l._pressedClass)){var u=this._site.animatedElement,v=this._site.animatedElementScaleTransform;b?g(u,v):e._setImmediate(function(){j.hasClass(u,l._pressedClass)&&g(u,v)})}},_containsTransform:function(a,b){return b&&-1!==a.style[p.scriptName].indexOf(b)},_removeTransform:function(a,b){this._containsTransform(a,b)&&(a.style[p.scriptName]=a.style[p.scriptName].replace(b,""))},_endSwipeBehavior:function(){if((this._swipeBehaviorState===t.MS_MANIPULATION_STATE_PRESELECT||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_SELECTING||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_DRAGGING||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_COMMITTED||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_CANCELLED)&&this._site.pressedEntity.type!==k.ObjectType.groupHeader){this._flushUIBatches();var a=this._selectionHint;if(this._selectionHint=null,this._site.pressedItemBox){var b=this._site.pressedEntity.index,c=this._site.selection._isIncluded(b);if(c)for(var d=j._getElementsByClasses(this._site.pressedItemBox,[l._selectionCheckmarkClass,l._selectionCheckmarkBackgroundClass]),e=0;e<d.length;e++)d[e].style.opacity=1;this._clearItem(this._site.pressedEntity,c),a&&this._removeSelectionHint(a),delete this._animations[b]}}},_createGestureRecognizer:function(){var a=this._site.eventHandlerRoot,b=j._createGestureRecognizer();b.target=a;var c=this;return a.addEventListener("MSGestureHold",function(a){-1!==c._site.pressedEntity.index&&a.detail===j._MSGestureEvent.MSGESTURE_FLAG_BEGIN&&c._startSelfRevealGesture()}),b},_dispatchSwipeBehavior:function(a){if(this._site.pressedEntity.type!==k.ObjectType.groupHeader&&this._site.swipeBehavior===k.SwipeBehavior.select){if(this._site.selection._pivot=l._INVALID_INDEX,this._site.pressedItemBox){var b=this._site.pressedEntity.index;if(this._swipeBehaviorState!==a)if(a===t.MS_MANIPULATION_STATE_DRAGGING&&this._canSelect)this._animateSelectionChange(this._site.selection._isIncluded(b)),this._removeSelectionHint(this._selectionHint);else if(a===t.MS_MANIPULATION_STATE_PRESELECT){f("WinJS.UI._ItemEventsHandler:crossSlidingStarted,info");var c=this._site,d=c.itemAtIndex(b),e=c.selection._isIncluded(b);this._selfRevealGesture?(this._selfRevealGesture.finishAnimation(),this._selfRevealGesture=null):this._canSelect&&this._prepareItem(this._site.pressedEntity,d,e),this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_SELECTING?(this._site.animatedElement&&j.hasClass(this._site.animatedElement,l._pressedClass)&&(this._site.animatedDownPromise&&this._site.animatedDownPromise.cancel(),j.removeClass(this._site.animatedElement,l._pressedClass),this._removeTransform(this._site.animatedElement,this._site.animatedElementScaleTransform)),this._showSelectionHintCheckmark()):this._animateSelectionChange(this._site.selection._isIncluded(b))}else if(a===t.MS_MANIPULATION_STATE_COMMITTED){f("WinJS.UI._ItemEventsHandler:crossSlidingCompleted,info");var c=this._site,g=c.selection,h=this._swipeBehaviorSelectionChanged,i=this.swipeBehaviorSelected;this._swipeBehaviorState===t.MS_MANIPULATION_STATE_SELECTING&&h&&this._selectionAllowed()&&c.swipeBehavior===k.SwipeBehavior.select&&(c.selectionMode===k.SelectionMode.single?i?g.set(b):g._isIncluded(b)&&g.remove(b):i?g.add(b):g._isIncluded(b)&&g.remove(b)),this._endSwipeBehavior()}else a===t.MS_MANIPULATION_STATE_SELECTING&&this._canSelect?this._animateSelectionChange(!this._site.selection._isIncluded(b)):this._swipeBehaviorState===t.MS_MANIPULATION_STATE_SELECTING&&this._canSelect&&this._animateSelectionChange(this._site.selection._isIncluded(b),a===t.MS_MANIPULATION_STATE_CANCELLED)}this._swipeBehaviorState=a}},_resetPointerDownStateForPointerId:function(a){this._pointerId===a.pointerId&&this.resetPointerDownState()},resetPointerDownState:function(){this._gestureRecognizer&&(this._endSelfRevealGesture(),this._endSwipeBehavior()),this._site.pressedElement=null,j._removeEventListener(b,"pointerup",this._resetPointerDownStateBound),j._removeEventListener(b,"pointercancel",this._resetPointerDownStateBound),this._resetPressedContainer(),this._site.pressedContainer=null,this._site.animatedElement=null,this._site.pressedHeader=null,this._site.pressedItemBox=null,this._removeSelectionHint(this._selectionHint),this._selectionHint=null,this._site.pressedEntity={type:k.ObjectType.item,index:l._INVALID_INDEX},this._pointerId=null},_startSelfRevealGesture:function(){if(this._canSelect&&this._site.swipeBehavior===k.SwipeBehavior.select){f("WinJS.UI._ItemEventsHandler:playSelfRevealGesture,info");var a=this,b=this._site,c=this._site.pressedEntity.index,d=b.itemBoxAtIndex(c),e=b.selection._isIncluded(c),h=!1,j=function(){var a,c;return b.horizontal?(a=l._VERTICAL_SWIPE_SELF_REVEAL_GESTURE+"px",c="0px"):(a="0px",c=(b.rtl()?"":"-")+l._HORIZONTAL_SWIPE_SELF_REVEAL_GESTURE+"px"),g.swipeReveal(d,{top:a,left:c})},m=function(){return h?i.wrap():g.swipeReveal(d,{top:"0px",left:"0px"})},n=function(d){b.isZombie()||(d&&a._removeSelectionHint(d),a._clearItem(b.pressedEntity,b.selection._isIncluded(c)))},o=function(){a._selfRevealGesture._promise.cancel(),h=!0;var b=a._selectionHint;return a._selectionHint=null,m().then(function(){d.style[p.scriptName]="",n(b)})};this._prepareItem(this._site.pressedEntity,d,e),this._showSelectionHintCheckmark(),this._pointerTriggeredSRG=!0,this._selfRevealGesture={finishAnimation:o,_promise:j().then(m).then(function(){h||(a._hideSelectionHintCheckmark(),n(),a._selfRevealGesture=null)})}}},_endSelfRevealGesture:function(){this._selfRevealGesture&&(this._selfRevealGesture.finishAnimation(),this._selfRevealGesture=null)},_prepareItem:function(a,b,c){function d(a){e._swipeClassTracker[s(a)]?e._swipeClassTracker[s(a)]++:(j.addClass(a,l._swipeClass),e._swipeClassTracker[s(a)]=1)}if(a.type!==k.ObjectType.groupHeader){var e=this,f=this._site,g=a.index;if(c){var h=f.containerAtIndex(g);d(h)}else(this._animations[g]||i.wrap()).then(function(){if(!f.isZombie()&&a.type!==k.ObjectType.groupHeader&&-1!==f.pressedEntity.index){g=f.pressedEntity.index;var b=f.itemAtIndex(g),c=f.itemBoxAtIndex(g),e=f.containerAtIndex(g);if(d(e),!j._isSelectionRendered(c)){q.renderSelection(c,b,!0,e),j.removeClass(c,l._selectedClass),j.removeClass(e,l._selectedClass);for(var h=c.querySelectorAll(j._selectionPartsSelector),i=0,m=h.length;m>i;i++)h[i].style.opacity=0}}})}},_clearItem:function(a,b){function c(a){var b=--e._swipeClassTracker[s(a)];return b?!1:(delete e._swipeClassTracker[s(a)],j.removeClass(a,l._swipeClass),!0)}function d(a){var b=a.parentNode;b&&j.hasClass(b,l._itemsBlockClass)&&c(b)}if(a.type===k.ObjectType.item){var e=this,f=this._site,g=f.containerAtIndex(a.index),h=f.itemBoxAtIndex(a.index),i=f.itemAtIndex(a.index);if(g&&h&&i){var m=c(g);d(g),m&&q.renderSelection(h,i,b,!0,g)}}},_animateSelectionChange:function(b,c){function d(){var c=b?"addClass":"removeClass";if(j[c](h,l._selectedClass),j[c](g,l._selectedClass),e._selectionHint){var d=a(e._selectionHint,l._selectionHintClass);d&&j[c](d,l._revealedClass)}}var e=this,g=this._site.pressedContainer,h=this._site.pressedItemBox;this._swipeBehaviorSelectionChanged=!0,this.swipeBehaviorSelected=b;var i=j._getElementsByClasses(this._site.pressedItemBox,[l._selectionBorderClass,l._selectionBackgroundClass]);(!b||c)&&(i=i.concat(j._getElementsByClasses(this._site.pressedItemBox,[l._selectionCheckmarkBackgroundClass,l._selectionCheckmarkClass]))),f("WinJS.UI._ItemEventsHandler:"+(b?"hitSelectThreshold":"hitUnselectThreshold")+",info"),this._applyUIInBatches(function(){f("WinJS.UI._ItemEventsHandler:"+(b?"apply":"remove")+"SelectionVisual,info");for(var a=b?1:0,c=0;c<i.length;c++)i[c].style.opacity=a;d()})},_showSelectionHintCheckmark:function(){if(this._selectionHint){var b=a(this._selectionHint,l._selectionHintClass);b&&(b.style.display="block")}},_hideSelectionHintCheckmark:function(){if(this._selectionHint){var b=a(this._selectionHint,l._selectionHintClass);b&&(b.style.display="none")}},_addSelectionHint:function(){if(this._site.pressedEntity.type!==k.ObjectType.groupHeader){var a,c=this._site;if(c.customFootprintParent){a=this._selectionHint=b.document.createElement("div"),a.className=l._containerClass;var d=this;c.getItemPosition(this._site.pressedEntity).then(function(b){if(!c.isZombie()&&d._selectionHint&&d._selectionHint===a){var e=a.style,f=";position:absolute;"+(c.rtl()?"right:":"left:")+b.left+"px;top:"+b.top+"px;width:"+b.contentWidth+"px;height:"+b.contentHeight+"px";e.cssText+=f,c.customFootprintParent.insertBefore(d._selectionHint,d._site.pressedItemBox)}},function(){})}else a=this._selectionHint=this._site.pressedContainer;if(this._selectionHintTracker[s(a)])this._selectionHintTracker[s(a)]++;else{if(j.addClass(a,l._footprintClass),!c.selection._isIncluded(this._site.pressedEntity.index)){var e=b.document.createElement("div");e.className=l._selectionHintClass,e.textContent=l._SELECTION_CHECKMARK,e.style.display="none",this._selectionHint.insertBefore(e,this._selectionHint.firstElementChild)}this._selectionHintTracker[s(a)]=1}}},_removeSelectionHint:function(b){if(b){var c=--this._selectionHintTracker[s(b)];if(!c)if(delete this._selectionHintTracker[s(b)],this._site.customFootprintParent)b.parentNode&&b.parentNode.removeChild(b);else{j.removeClass(b,l._footprintClass);var d=a(b,l._selectionHintClass);d&&d.parentNode.removeChild(d)}}},_releasedElement:function(a){return b.document.elementFromPoint(a.clientX,a.clientY)},_applyUIInBatches:function(a){function b(){c._work.length>0?(c._flushUIBatches(),c._paintedThisFrame=e._requestAnimationFrame(b.bind(c))):c._paintedThisFrame=null}var c=this;this._work.push(a),this._paintedThisFrame||b()},_flushUIBatches:function(){if(this._work.length>0){var a=this._work;this._work=[];for(var b=0;b<a.length;b++)a[b]()}},_selectionAllowed:function(a){var b=void 0!==a?this._site.itemAtIndex(a):null,c=!(b&&j.hasClass(b,l._nonSelectableClass));return c&&this._site.selectionMode!==k.SelectionMode.none},_multiSelection:function(){return this._site.selectionMode===k.SelectionMode.multi},_selectOnTap:function(){return this._site.tapBehavior===k.TapBehavior.toggleSelect||this._site.tapBehavior===k.TapBehavior.directSelect},_staticMode:function(a){return a?this._site.headerTapBehavior===k.GroupHeaderTapBehavior.none:this._site.tapBehavior===k.TapBehavior.none&&this._site.selectionMode===k.SelectionMode.none}},{setAriaSelected:function(a,b){var c="true"===a.getAttribute("aria-selected");b!==c&&a.setAttribute("aria-selected",b)},renderSelection:function(a,b,c,d,e){if(!q._selectionTemplate){q._selectionTemplate=[],q._selectionTemplate.push(m(l._selectionBackgroundClass)),q._selectionTemplate.push(m(l._selectionBorderClass)),q._selectionTemplate.push(m(l._selectionCheckmarkBackgroundClass));var f=m(l._selectionCheckmarkClass);f.textContent=l._SELECTION_CHECKMARK,q._selectionTemplate.push(f)}if(c!==j._isSelectionRendered(a)){if(c){a.insertBefore(q._selectionTemplate[0].cloneNode(!0),a.firstElementChild);for(var g=1,h=q._selectionTemplate.length;h>g;g++)a.appendChild(q._selectionTemplate[g].cloneNode(!0))}else for(var i=a.querySelectorAll(j._selectionPartsSelector),g=0,h=i.length;h>g;g++)a.removeChild(i[g]);j[c?"addClass":"removeClass"](a,l._selectedClass),e&&j[c?"addClass":"removeClass"](e,l._selectedClass)}d&&q.setAriaSelected(b,c)}});return q})})}),d("WinJS/Controls/ListView/_SelectionManager",["exports","../../Core/_Global","../../Core/_Base","../../Promise","../../_Signal","../../Utilities/_UI","../ItemContainer/_Constants"],function(a,b,c,d,e,f,g){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{_ItemSet:c.Namespace._lazy(function(){var b=c.Class.define(function(a,b,c){this._listView=a,this._ranges=b,this._itemsCount=c});return b.prototype={getRanges:function(){for(var a=[],b=0,c=this._ranges.length;c>b;b++){var d=this._ranges[b];a.push({firstIndex:d.firstIndex,lastIndex:d.lastIndex,firstKey:d.firstKey,lastKey:d.lastKey})}return a},getItems:function(){return a.getItemsFromRanges(this._listView._itemsManager.dataSource,this._ranges)},isEverything:function(){return this.count()===this._itemsCount},count:function(){for(var a=0,b=0,c=this._ranges.length;c>b;b++){var d=this._ranges[b];a+=d.lastIndex-d.firstIndex+1}return a},getIndices:function(){for(var a=[],b=0,c=this._ranges.length;c>b;b++)for(var d=this._ranges[b],e=d.firstIndex;e<=d.lastIndex;e++)a.push(e);return a}},b}),getItemsFromRanges:function(a,b){function c(){for(var a=[],c=0,e=b.length;e>c;c++)for(var f=b[c],g=f.firstIndex;g<=f.lastIndex;g++)a.push(g);return d.wrap(a)}var e=a.createListBinding(),f=[];return c().then(function(a){for(var b=0;b<a.length;b++)f.push(e.fromIndex(a[b]));return d.join(f).then(function(a){return e.release(),a})})},_Selection:c.Namespace._lazy(function(){function b(a){return a&&0===a.firstIndex&&a.lastIndex===Number.MAX_VALUE}return c.Class.derive(a._ItemSet,function(a,b){this._listView=a,this._itemsCount=-1,this._ranges=[],b&&this.set(b)},{clear:function(){return this._releaseRanges(this._ranges),this._ranges=[],d.wrap()},set:function(a){if(b(a))return this.selectAll();this._releaseRanges(this._ranges),this._ranges=[];var c=this;return this._execute("_set",a).then(function(){return c._ranges.sort(function(a,b){return a.firstIndex-b.firstIndex}),c._ensureKeys()}).then(function(){return c._ensureCount()})},add:function(a){if(b(a))return this.selectAll();var c=this;return this._execute("_add",a).then(function(){return c._ensureKeys()}).then(function(){return c._ensureCount()})},remove:function(a){var b=this;return this._execute("_remove",a).then(function(){return b._ensureKeys()})},selectAll:function(){var a=this;return a._ensureCount().then(function(){if(a._itemsCount){var b={firstIndex:0,lastIndex:a._itemsCount-1};return a._retainRange(b),a._releaseRanges(a._ranges),a._ranges=[b],a._ensureKeys()}})},_execute:function(a,b){function c(a,b,c){var d={};return d["first"+a]=b,d["last"+a]=c,d}function e(b){var c=f._getListBinding(),e=d.join([c.fromKey(b.firstKey),c.fromKey(b.lastKey)]).then(function(c){return c[0]&&c[1]&&(b.firstIndex=c[0].index,b.lastIndex=c[1].index,f[a](b)),b});i.push(e)}for(var f=this,g=!!f._getListBinding().fromKey,h=Array.isArray(b)?b:[b],i=[d.wrap()],j=0,k=h.length;k>j;j++){var l=h[j];"number"==typeof l?this[a](c("Index",l,l)):l&&(g&&void 0!==l.key?e(c("Key",l.key,l.key)):g&&void 0!==l.firstKey&&void 0!==l.lastKey?e(c("Key",l.firstKey,l.lastKey)):void 0!==l.index&&"number"==typeof l.index?this[a](c("Index",l.index,l.index)):void 0!==l.firstIndex&&void 0!==l.lastIndex&&"number"==typeof l.firstIndex&&"number"==typeof l.lastIndex&&this[a](c("Index",l.firstIndex,l.lastIndex)))}return d.join(i)},_set:function(a){this._retainRange(a),this._ranges.push(a)},_add:function(a){for(var b,c,d,e=this,f=null,g=function(a,b){b.lastIndex>a.lastIndex&&(a.lastIndex=b.lastIndex,a.lastKey=b.lastKey,a.lastPromise&&a.lastPromise.release(),a.lastPromise=e._getListBinding().fromIndex(a.lastIndex).retain())},h=0,i=this._ranges.length;i>h;h++){if(b=this._ranges[h],a.firstIndex<b.firstIndex){d=f&&a.firstIndex<f.lastIndex+1,d?(c=h-1,g(f,a)):(this._insertRange(h,a),c=h);break}if(a.firstIndex===b.firstIndex){g(b,a),c=h;break}f=b}if(void 0===c){var j=this._ranges.length?this._ranges[this._ranges.length-1]:null,k=j&&a.firstIndex<j.lastIndex+1;k?g(j,a):(this._retainRange(a),this._ranges.push(a))}else{for(f=null,h=c+1,i=this._ranges.length;i>h;h++){if(b=this._ranges[h],a.lastIndex<b.firstIndex){d=f&&f.lastIndex>a.lastIndex,d&&g(this._ranges[c],f),this._removeRanges(c+1,h-c-1);break}if(a.lastIndex===b.firstIndex){g(this._ranges[c],b),this._removeRanges(c+1,h-c);break}f=b}h>=i&&(g(this._ranges[c],this._ranges[i-1]),this._removeRanges(c+1,i-c-1))}},_remove:function(a){function b(a){return c._getListBinding().fromIndex(a).retain()}for(var c=this,d=[],e=0,f=this._ranges.length;f>e;e++){var g=this._ranges[e];g.lastIndex<a.firstIndex||g.firstIndex>a.lastIndex?d.push(g):g.firstIndex<a.firstIndex&&g.lastIndex>=a.firstIndex&&g.lastIndex<=a.lastIndex?(d.push({firstIndex:g.firstIndex,firstKey:g.firstKey,firstPromise:g.firstPromise,lastIndex:a.firstIndex-1,lastPromise:b(a.firstIndex-1)}),g.lastPromise.release()):g.lastIndex>a.lastIndex&&g.firstIndex>=a.firstIndex&&g.firstIndex<=a.lastIndex?(d.push({firstIndex:a.lastIndex+1,firstPromise:b(a.lastIndex+1),lastIndex:g.lastIndex,lastKey:g.lastKey,lastPromise:g.lastPromise}),g.firstPromise.release()):g.firstIndex<a.firstIndex&&g.lastIndex>a.lastIndex?(d.push({firstIndex:g.firstIndex,firstKey:g.firstKey,firstPromise:g.firstPromise,lastIndex:a.firstIndex-1,lastPromise:b(a.firstIndex-1)}),d.push({firstIndex:a.lastIndex+1,firstPromise:b(a.lastIndex+1),lastIndex:g.lastIndex,lastKey:g.lastKey,lastPromise:g.lastPromise})):(g.firstPromise.release(),g.lastPromise.release())}this._ranges=d},_ensureKeys:function(){for(var a=[d.wrap()],b=this,c=function(a,b){var c=a+"Key";if(b[c])return d.wrap();var e=b[a+"Promise"];return e.then(function(a){a&&(b[c]=a.key)}),e},e=0,f=this._ranges.length;f>e;e++){var g=this._ranges[e];a.push(c("first",g)),a.push(c("last",g))}return d.join(a).then(function(){b._ranges=b._ranges.filter(function(a){return a.firstKey&&a.lastKey})}),d.join(a)},_mergeRanges:function(a,b){a.lastIndex=b.lastIndex,a.lastKey=b.lastKey},_isIncluded:function(a){if(this.isEverything())return!0;for(var b=0,c=this._ranges.length;c>b;b++){var d=this._ranges[b];if(d.firstIndex<=a&&a<=d.lastIndex)return!0}return!1},_ensureCount:function(){var a=this;return this._listView._itemsCount().then(function(b){a._itemsCount=b})},_insertRange:function(a,b){this._retainRange(b),this._ranges.splice(a,0,b)},_removeRanges:function(a,b){for(var c=0;b>c;c++)this._releaseRange(this._ranges[a+c]);this._ranges.splice(a,b)},_retainRange:function(a){a.firstPromise||(a.firstPromise=this._getListBinding().fromIndex(a.firstIndex).retain()),a.lastPromise||(a.lastPromise=this._getListBinding().fromIndex(a.lastIndex).retain())},_retainRanges:function(){for(var a=0,b=this._ranges.length;b>a;a++)this._retainRange(this._ranges[a])},_releaseRange:function(a){a.firstPromise.release(),a.lastPromise.release()},_releaseRanges:function(a){for(var b=0,c=a.length;c>b;++b)this._releaseRange(a[b])},_getListBinding:function(){return this._listView._itemsManager._listBinding}},{supportedForProcessing:!1})
  }),_SelectionManager:c.Namespace._lazy(function(){var c=function(b){this._listView=b,this._selected=new a._Selection(this._listView),this._pivot=g._INVALID_INDEX,this._focused={type:f.ObjectType.item,index:0},this._pendingChange=d.wrap()};return c.prototype={count:function(){return this._selected.count()},getIndices:function(){return this._selected.getIndices()},getItems:function(){return this._selected.getItems()},getRanges:function(){return this._selected.getRanges()},isEverything:function(){return this._selected.isEverything()},set:function(b){var c=this,f=new e;return this._synchronize(f).then(function(){var e=new a._Selection(c._listView);return e.set(b).then(function(){c._set(e),f.complete()},function(a){return e.clear(),f.complete(),d.wrapError(a)})})},clear:function(){var b=this,c=new e;return this._synchronize(c).then(function(){var e=new a._Selection(b._listView);return e.clear().then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},add:function(a){var b=this,c=new e;return this._synchronize(c).then(function(){var e=b._cloneSelection();return e.add(a).then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},remove:function(a){var b=this,c=new e;return this._synchronize(c).then(function(){var e=b._cloneSelection();return e.remove(a).then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},selectAll:function(){var b=this,c=new e;return this._synchronize(c).then(function(){var e=new a._Selection(b._listView);return e.selectAll().then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},_synchronize:function(a){var b=this;return this._listView._versionManager.unlocked.then(function(){var c=b._pendingChange;return b._pendingChange=d.join([c,a.promise]).then(function(){}),c})},_reset:function(){this._pivot=g._INVALID_INDEX,this._setFocused({type:f.ObjectType.item,index:0},this._keyboardFocused()),this._pendingChange.cancel(),this._pendingChange=d.wrap(),this._selected.clear(),this._selected=new a._Selection(this._listView)},_dispose:function(){this._selected.clear(),this._selected=null,this._listView=null},_set:function(a){var b=this;return this._fireSelectionChanging(a).then(function(c){return c?(b._selected.clear(),b._selected=a,b._listView._updateSelection(),b._fireSelectionChanged()):a.clear(),c})},_fireSelectionChanging:function(a){var c=b.document.createEvent("CustomEvent"),e=d.wrap();c.initCustomEvent("selectionchanging",!0,!0,{newSelection:a,preventTapBehavior:function(){},setPromise:function(a){e=a}});var f=this._listView._element.dispatchEvent(c);return e.then(function(){return f})},_fireSelectionChanged:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent("selectionchanged",!0,!1,null),this._listView._element.dispatchEvent(a)},_getFocused:function(){return{type:this._focused.type,index:this._focused.index}},_setFocused:function(a,b){this._focused={type:a.type,index:a.index},this._focusedByKeyboard=b},_keyboardFocused:function(){return this._focusedByKeyboard},_updateCount:function(a){this._selected._itemsCount=a},_isIncluded:function(a){return this._selected._isIncluded(a)},_cloneSelection:function(){var b=new a._Selection(this._listView);return b._ranges=this._selected.getRanges(),b._itemsCount=this._selected._itemsCount,b._retainRanges(),b}},c.supportedForProcessing=!1,c})})}),d("WinJS/Controls/ListView/_BrowseMode",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Animations","../../Promise","../../Utilities/_ElementUtilities","../../Utilities/_UI","../ItemContainer/_Constants","../ItemContainer/_ItemEventsHandler","./_SelectionManager"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";var l=d._browserStyleEquivalents.transform.scriptName;c.Namespace._moduleDefine(a,"WinJS.UI",{_SelectionMode:c.Namespace._lazy(function(){function a(a,b,c){return Math.max(a,Math.min(b,c))}function e(a,c,d){var e=b.document.createEvent("CustomEvent");return e.initCustomEvent("keyboardnavigating",!0,!0,{oldFocus:c.index,oldFocusType:c.type,newFocus:d.index,newFocusType:d.type}),a.dispatchEvent(e)}var m=c.Class.define(function(a){this.inboundFocusHandled=!1,this._pressedContainer=null,this._pressedItemBox=null,this._pressedHeader=null,this._pressedEntity={type:h.ObjectType.item,index:i._INVALID_INDEX},this._pressedPosition=null,this.initialize(a)},{_dispose:function(){this._itemEventsHandler&&this._itemEventsHandler.dispose(),this._setNewFocusItemOffsetPromise&&this._setNewFocusItemOffsetPromise.cancel()},initialize:function(a){function b(b,c){var d=function(c){return a._view.getAdjacent(c,b)};return d.clampToBounds=c,d}this.site=a,this._keyboardNavigationHandlers={},this._keyboardAcceleratorHandlers={};var c=this.site,d=this;this._itemEventsHandler=new j._ItemEventsHandler(Object.create({containerFromElement:function(a){return c._view.items.containerFrom(a)},indexForItemElement:function(a){return c._view.items.index(a)},indexForHeaderElement:function(a){return c._groups.index(a)},itemBoxAtIndex:function(a){return c._view.items.itemBoxAt(a)},itemAtIndex:function(a){return c._view.items.itemAt(a)},headerAtIndex:function(a){return c._groups.group(a).header},headerFromElement:function(a){return c._groups.headerFrom(a)},containerAtIndex:function(a){return c._view.items.containerAt(a)},isZombie:function(){return c._isZombie()},getItemPosition:function(a){return c._getItemPosition(a)},rtl:function(){return c._rtl()},fireInvokeEvent:function(a,b){return d._fireInvokeEvent(a,b)},verifySelectionAllowed:function(a){return d._verifySelectionAllowed(a)},changeFocus:function(a,b,d,e,f){return c._changeFocus(a,b,d,e,f)},selectRange:function(a,b,c){return d._selectRange(a,b,c)}},{pressedEntity:{enumerable:!0,get:function(){return d._pressedEntity},set:function(a){d._pressedEntity=a}},pressedContainerScaleTransform:{enumerable:!0,get:function(){return d._pressedContainerScaleTransform},set:function(a){d._pressedContainerScaleTransform=a}},pressedContainer:{enumerable:!0,get:function(){return d._pressedContainer},set:function(a){d._pressedContainer=a}},pressedItemBox:{enumerable:!0,get:function(){return d._pressedItemBox},set:function(a){d._pressedItemBox=a}},pressedHeader:{enumerable:!0,get:function(){return d._pressedHeader},set:function(a){return d._pressedHeader=a}},pressedPosition:{enumerable:!0,get:function(){return d._pressedPosition},set:function(a){d._pressedPosition=a}},pressedElement:{enumerable:!0,set:function(a){d._pressedElement=a}},swipeBehavior:{enumerable:!0,get:function(){return c._swipeBehavior}},eventHandlerRoot:{enumerable:!0,get:function(){return c._viewport}},selectionMode:{enumerable:!0,get:function(){return c._selectionMode}},accessibleItemClass:{enumerable:!0,get:function(){return i._itemClass}},canvasProxy:{enumerable:!0,get:function(){return c._canvasProxy}},tapBehavior:{enumerable:!0,get:function(){return c._tap}},headerTapBehavior:{enumerable:!0,get:function(){return c._groupHeaderTap}},draggable:{enumerable:!0,get:function(){return c.itemsDraggable||c.itemsReorderable}},selection:{enumerable:!0,get:function(){return c._selection}},horizontal:{enumerable:!0,get:function(){return c._horizontal()}},customFootprintParent:{enumerable:!0,get:function(){return null}}}));var e=g.Key;this._keyboardNavigationHandlers[e.upArrow]=b(e.upArrow),this._keyboardNavigationHandlers[e.downArrow]=b(e.downArrow),this._keyboardNavigationHandlers[e.leftArrow]=b(e.leftArrow),this._keyboardNavigationHandlers[e.rightArrow]=b(e.rightArrow),this._keyboardNavigationHandlers[e.pageUp]=b(e.pageUp,!0),this._keyboardNavigationHandlers[e.pageDown]=b(e.pageDown,!0),this._keyboardNavigationHandlers[e.home]=function(a){return f.wrap({type:a.type,index:0})},this._keyboardNavigationHandlers[e.end]=function(a){return a.type===h.ObjectType.groupHeader?f.wrap({type:a.type,index:c._groups.length()-1}):d.site._view.finalItem().then(function(b){return{type:a.type,index:b}},function(a){return f.wrapError(a)})},this._keyboardAcceleratorHandlers[e.a]=function(){d.site._multiSelection()&&d._selectAll()}},staticMode:function(){return this.site._tap===h.TapBehavior.none&&this.site._selectionMode===h.SelectionMode.none},itemUnrealized:function(a,b){if(this._pressedEntity.type!==h.ObjectType.groupHeader&&(this._pressedEntity.index===a&&this._resetPointerDownState(),this._itemBeingDragged(a)))for(var c=this._draggedItemBoxes.length-1;c>=0;c--)this._draggedItemBoxes[c]===b&&(g.removeClass(b,i._dragSourceClass),this._draggedItemBoxes.splice(c,1))},_fireInvokeEvent:function(a,c){function d(d,f){var g=d.createListBinding(),h=g.fromIndex(a.index),i=f?"groupheaderinvoked":"iteminvoked";h.done(function(){g.release()});var j=b.document.createEvent("CustomEvent");j.initCustomEvent(i,!0,!0,f?{groupHeaderPromise:h,groupHeaderIndex:a.index}:{itemPromise:h,itemIndex:a.index}),c.dispatchEvent(j)&&e.site._defaultInvoke(a)}if(c){var e=this;a.type===h.ObjectType.groupHeader?this.site._groupHeaderTap===h.GroupHeaderTapBehavior.invoke&&a.index!==i._INVALID_INDEX&&d(this.site.groupDataSource,!0):this.site._tap!==h.TapBehavior.none&&a.index!==i._INVALID_INDEX&&d(this.site.itemDataSource,!1)}},_verifySelectionAllowed:function(a){if(a.type===h.ObjectType.groupHeader)return{canSelect:!1,canTapSelect:!1};var c=a.index,d=this.site,e=this.site._view.items.itemAt(c);if(!d._selectionAllowed()||!d._selectOnTap()&&d._swipeBehavior!==h.SwipeBehavior.select||e&&g.hasClass(e,i._nonSelectableClass))return{canSelect:!1,canTapSelect:!1};var j=d._selection._isIncluded(c),k=!d._multiSelection(),l=d._selection._cloneSelection();j?k?l.clear():l.remove(c):k?l.set(c):l.add(c);var m,n=b.document.createEvent("CustomEvent"),o=f.wrap(),p=!1,q=!1;n.initCustomEvent("selectionchanging",!0,!0,{newSelection:l,preventTapBehavior:function(){q=!0},setPromise:function(a){o=a}});var r=d._element.dispatchEvent(n);o.then(function(){p=!0,m=l._isIncluded(c),l.clear()});var s=r&&p&&(j||m);return{canSelect:s,canTapSelect:s&&!q}},_containedInElementWithClass:function(a,b){if(a.parentNode)for(var c=a.parentNode.querySelectorAll("."+b+", ."+b+" *"),d=0,e=c.length;e>d;d++)if(c[d]===a)return!0;return!1},_isDraggable:function(a){return!this._containedInElementWithClass(a,i._nonDraggableClass)},_isInteractive:function(a){return this._containedInElementWithClass(a,"win-interactive")},_resetPointerDownState:function(){this._itemEventsHandler.resetPointerDownState()},onMSManipulationStateChanged:function(a){this._itemEventsHandler.onMSManipulationStateChanged(a)},onPointerDown:function(a){this._itemEventsHandler.onPointerDown(a)},onclick:function(a){this._itemEventsHandler.onClick(a)},onPointerUp:function(a){this._itemEventsHandler.onPointerUp(a)},onPointerCancel:function(a){this._itemEventsHandler.onPointerCancel(a)},onLostPointerCapture:function(a){this._itemEventsHandler.onLostPointerCapture(a)},onContextMenu:function(a){this._itemEventsHandler.onContextMenu(a)},onMSHoldVisual:function(a){this._itemEventsHandler.onMSHoldVisual(a)},onDataChanged:function(a){this._itemEventsHandler.onDataChanged(a)},_removeTransform:function(a,b){b&&-1!==a.style[l].indexOf(b)&&(a.style[l]=a.style[l].replace(b,""))},_selectAll:function(){var a=[];this.site._view.items.each(function(b,c){c&&g.hasClass(c,i._nonSelectableClass)&&a.push(b)}),this.site._selection.selectAll(),a.length>0&&this.site._selection.remove(a)},_selectRange:function(a,b,c){for(var d=[],e=-1,f=a;b>=f;f++){var h=this.site._view.items.itemAt(f);h&&g.hasClass(h,i._nonSelectableClass)?-1!==e&&(d.push({firstIndex:e,lastIndex:f-1}),e=-1):-1===e&&(e=f)}-1!==e&&d.push({firstIndex:e,lastIndex:b}),d.length>0&&this.site._selection[c?"add":"set"](d)},onDragStart:function(a){if(this._pressedEntity={type:h.ObjectType.item,index:this.site._view.items.index(a.target)},this.site._selection._pivot=i._INVALID_INDEX,this._pressedEntity.index===i._INVALID_INDEX||!this.site.itemsDraggable&&!this.site.itemsReorderable||this.site._view.animating||!this._isDraggable(a.target)||this._pressedElement&&this._isInteractive(this._pressedElement))a.preventDefault();else{this._dragging=!0,this._dragDataTransfer=a.dataTransfer,this._pressedPosition=g._getCursorPos(a),this._dragInfo=null,this._lastEnteredElement=a.target,this.site._selection._isIncluded(this._pressedEntity.index)?this._dragInfo=this.site.selection:(this._draggingUnselectedItem=!0,this._dragInfo=new k._Selection(this.site,[{firstIndex:this._pressedEntity.index,lastIndex:this._pressedEntity.index}]));var c=this.site.itemsReorderable,e=b.document.createEvent("CustomEvent");if(e.initCustomEvent("itemdragstart",!0,!1,{dataTransfer:a.dataTransfer,dragInfo:this._dragInfo}),a.dataTransfer.setData("text",""),a.dataTransfer.setDragImage){var f=this.site._view.items.itemDataAt(this._pressedEntity.index);if(f&&f.container){var j=f.container.getBoundingClientRect();a.dataTransfer.setDragImage(f.container,a.clientX-j.left,a.clientY-j.top)}}this.site.element.dispatchEvent(e),this.site.itemsDraggable&&!this.site.itemsReorderable&&(this._firedDragEnter||this._fireDragEnterEvent(a.dataTransfer)&&(c=!0,this._dragUnderstood=!0)),c&&(this._addedDragOverClass=!0,g.addClass(this.site._element,i._dragOverClass)),this._draggedItemBoxes=[];var l=this,m=a.target;m.addEventListener("dragend",function n(a){m.removeEventListener("dragend",n),l.onDragEnd(a)}),d._yieldForDomModification(function(){if(l._dragging)for(var a=l._dragInfo.getIndices(),b=0,c=a.length;c>b;b++){var d=l.site._view.items.itemDataAt(a[b]);d&&d.itemBox&&l._addDragSourceClass(d.itemBox)}})}},onDragEnter:function(a){var c=this._dragUnderstood;this._lastEnteredElement=a.target,this._exitEventTimer&&(b.clearTimeout(this._exitEventTimer),this._exitEventTimer=0),this._firedDragEnter||this._fireDragEnterEvent(a.dataTransfer)&&(c=!0),(c||this._dragging&&this.site.itemsReorderable)&&(a.preventDefault(),this._dragUnderstood=!0,this._addedDragOverClass||(this._addedDragOverClass=!0,g.addClass(this.site._element,i._dragOverClass))),this._pointerLeftRegion=!1},onDragLeave:function(a){a.target===this._lastEnteredElement&&(this._pointerLeftRegion=!0,this._handleExitEvent())},fireDragUpdateEvent:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent("itemdragchanged",!0,!1,{dataTransfer:this._dragDataTransfer,dragInfo:this._dragInfo}),this.site.element.dispatchEvent(a)},_fireDragEnterEvent:function(a){var c=b.document.createEvent("CustomEvent");c.initCustomEvent("itemdragenter",!0,!0,{dataTransfer:a});var d=!this.site.element.dispatchEvent(c);return this._firedDragEnter=!0,d},_fireDragBetweenEvent:function(a,c,d){var e=b.document.createEvent("CustomEvent");return e.initCustomEvent("itemdragbetween",!0,!0,{index:a,insertAfterIndex:c,dataTransfer:d}),this.site.element.dispatchEvent(e)},_fireDropEvent:function(a,c,d){var e=b.document.createEvent("CustomEvent");return e.initCustomEvent("itemdragdrop",!0,!0,{index:a,insertAfterIndex:c,dataTransfer:d}),this.site.element.dispatchEvent(e)},_handleExitEvent:function(){this._exitEventTimer&&(b.clearTimeout(this._exitEventTimer),this._exitEventTimer=0);var a=this;this._exitEventTimer=b.setTimeout(function(){if(!a.site._disposed&&a._pointerLeftRegion){if(a.site._layout.dragLeave&&a.site._layout.dragLeave(),a._pointerLeftRegion=!1,a._dragUnderstood=!1,a._lastEnteredElement=null,a._lastInsertPoint=null,a._dragBetweenDisabled=!1,a._firedDragEnter){var c=b.document.createEvent("CustomEvent");c.initCustomEvent("itemdragleave",!0,!1,{}),a.site.element.dispatchEvent(c),a._firedDragEnter=!1}a._addedDragOverClass&&(a._addedDragOverClass=!1,g.removeClass(a.site._element,i._dragOverClass)),a._exitEventTimer=0,a._stopAutoScroll()}},40)},_getEventPositionInElementSpace:function(a,c){var d={left:0,top:0};try{d=a.getBoundingClientRect()}catch(e){}var f=b.getComputedStyle(a,null),g=parseInt(f.paddingLeft),h=parseInt(f.paddingTop),i=parseInt(f.borderLeftWidth),j=parseInt(f.borderTopWidth),k=c.clientX,l=c.clientY,m={x:+k===k?k-d.left-g-i:0,y:+l===l?l-d.top-h-j:0};return this.site._rtl()&&(m.x=d.right-d.left-m.x),m},_getPositionInCanvasSpace:function(a){var b=this.site._horizontal()?this.site.scrollPosition:0,c=this.site._horizontal()?0:this.site.scrollPosition,d=this._getEventPositionInElementSpace(this.site.element,a);return{x:d.x+b,y:d.y+c}},_itemBeingDragged:function(a){return this._dragging?this._draggingUnselectedItem&&this._dragInfo._isIncluded(a)||!this._draggingUnselectedItem&&this.site._isSelected(a):!1},_addDragSourceClass:function(a){this._draggedItemBoxes.push(a),g.addClass(a,i._dragSourceClass),a.parentNode&&g.addClass(a.parentNode,i._footprintClass)},renderDragSourceOnRealizedItem:function(a,b){this._itemBeingDragged(a)&&this._addDragSourceClass(b)},onDragOver:function(b){if(this._dragUnderstood){this._pointerLeftRegion=!1,b.preventDefault();var c=this._getPositionInCanvasSpace(b),d=this._getEventPositionInElementSpace(this.site.element,b);if(this._checkAutoScroll(d.x,d.y),this.site._layout.hitTest)if(this._autoScrollFrame)this._lastInsertPoint&&(this.site._layout.dragLeave(),this._lastInsertPoint=null);else{var e=this.site._view.hitTest(c.x,c.y);e.insertAfterIndex=a(-1,this.site._cachedCount-1,e.insertAfterIndex),this._lastInsertPoint&&this._lastInsertPoint.insertAfterIndex===e.insertAfterIndex&&this._lastInsertPoint.index===e.index||(this._dragBetweenDisabled=!this._fireDragBetweenEvent(e.index,e.insertAfterIndex,b.dataTransfer),this._dragBetweenDisabled?this.site._layout.dragLeave():this.site._layout.dragOver(c.x,c.y,this._dragInfo)),this._lastInsertPoint=e}}},_clearDragProperties:function(){if(this._addedDragOverClass&&(this._addedDragOverClass=!1,g.removeClass(this.site._element,i._dragOverClass)),this._draggedItemBoxes){for(var a=0,b=this._draggedItemBoxes.length;b>a;a++)g.removeClass(this._draggedItemBoxes[a],i._dragSourceClass),this._draggedItemBoxes[a].parentNode&&g.removeClass(this._draggedItemBoxes[a].parentNode,i._footprintClass);this._draggedItemBoxes=[]}this.site._layout.dragLeave(),this._dragging=!1,this._dragInfo=null,this._draggingUnselectedItem=!1,this._dragDataTransfer=null,this._lastInsertPoint=null,this._resetPointerDownState(),this._lastEnteredElement=null,this._dragBetweenDisabled=!1,this._firedDragEnter=!1,this._dragUnderstood=!1,this._stopAutoScroll()},onDragEnd:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent("itemdragend",!0,!1,{}),this.site.element.dispatchEvent(a),this._clearDragProperties()},_findFirstAvailableInsertPoint:function(a,b,c){for(var d=a.getIndices(),e=-1,f=this.site._cachedCount,g=d.length,h=-1,i=b,j=0;g>j;j++)if(d[j]===i){e=j,h=j;break}for(;e>=0&&i>=0;)c?(i++,g>e&&d[e+1]===i&&f>i?e++:i>=f?(c=!1,i=b,e=h):e=-1):(i--,e>0&&d[e-1]===i?e--:e=-1);return i},_reorderItems:function(a,b,c,d,e){var f=this.site,g=function(a){c?f._selection.remove({key:a[0].key}):f._selection.set({firstKey:a[0].key,lastKey:a[a.length-1].key}),e&&f.ensureVisible(f._selection._getFocused())};b.getItems().then(function(b){var c=f.itemDataSource;if(-1===a){c.beginEdits();for(var e=b.length-1;e>=0;e--)c.moveToStart(b[e].key);c.endEdits(),g(b)}else{var h=c.createListBinding();h.fromIndex(a).then(function(a){if(h.release(),c.beginEdits(),d)for(var e=0,f=b.length;f>e;e++)c.moveBefore(b[e].key,a.key);else for(var e=b.length-1;e>=0;e--)c.moveAfter(b[e].key,a.key);c.endEdits(),g(b)})}})},onDrop:function(b){if(this._draggedItemBoxes)for(var c=0,d=this._draggedItemBoxes.length;d>c;c++)this._draggedItemBoxes[c].parentNode&&g.removeClass(this._draggedItemBoxes[c].parentNode,i._footprintClass);if(!this._dragBetweenDisabled){var e=this._getPositionInCanvasSpace(b),f=this.site._view.hitTest(e.x,e.y),h=a(-1,this.site._cachedCount-1,f.insertAfterIndex),j=!0;if(this._lastInsertPoint&&this._lastInsertPoint.insertAfterIndex===h&&this._lastInsertPoint.index===f.index||(j=this._fireDragBetweenEvent(f.index,h,b.dataTransfer)),j&&(this._lastInsertPoint=null,this.site._layout.dragLeave(),this._fireDropEvent(f.index,h,b.dataTransfer)&&this._dragging&&this.site.itemsReorderable)){if(this._dragInfo.isEverything()||this.site._groupsEnabled())return;h=this._findFirstAvailableInsertPoint(this._dragInfo,h,!1),this._reorderItems(h,this._dragInfo,this._draggingUnselectedItem)}}this._clearDragProperties(),b.preventDefault()},_checkAutoScroll:function(a,c){var e=this.site._getViewportLength(),f=this.site._horizontal(),h=f?a:c,j=this.site._viewport[f?"scrollWidth":"scrollHeight"],k=Math.floor(this.site.scrollPosition),l=0;if(h<i._AUTOSCROLL_THRESHOLD?l=h-i._AUTOSCROLL_THRESHOLD:h>e-i._AUTOSCROLL_THRESHOLD&&(l=h-(e-i._AUTOSCROLL_THRESHOLD)),l=Math.round(l/i._AUTOSCROLL_THRESHOLD*(i._MAX_AUTOSCROLL_RATE-i._MIN_AUTOSCROLL_RATE)),(0===k&&0>l||k>=j-e&&l>0)&&(l=0),0===l)this._autoScrollDelay&&(b.clearTimeout(this._autoScrollDelay),this._autoScrollDelay=0);else if(!this._autoScrollDelay&&!this._autoScrollFrame){var m=this;this._autoScrollDelay=b.setTimeout(function(){if(m._autoScrollRate){m._lastDragTimeout=d._now();var a=function(){if(!m._autoScrollRate&&m._autoScrollFrame||m.site._disposed)m._stopAutoScroll();else{var b=d._now(),c=m._autoScrollRate*((b-m._lastDragTimeout)/1e3);c=0>c?Math.min(-1,c):Math.max(1,c);var e={};e[m.site._scrollProperty]=m.site._viewportScrollPosition+c,g.setScrollPosition(m.site._viewport,e),m._lastDragTimeout=b,m._autoScrollFrame=d._requestAnimationFrame(a)}};m._autoScrollFrame=d._requestAnimationFrame(a)}},i._AUTOSCROLL_DELAY)}this._autoScrollRate=l},_stopAutoScroll:function(){this._autoScrollDelay&&(b.clearTimeout(this._autoScrollDelay),this._autoScrollDelay=0),this._autoScrollRate=0,this._autoScrollFrame=0},onKeyDown:function(a){function b(a,b,g){function j(j){var k=!0,l=!1;if(g?a.index=Math.max(0,Math.min(j,a.index)):(a.index<0||a.index>j)&&(l=!0),!l&&(m.index!==a.index||m.type!==a.type)){var n=e(d._element,m,a);n&&(k=!1,c._setNewFocusItemOffsetPromise&&c._setNewFocusItemOffsetPromise.cancel(),d._batchViewUpdates(i._ViewChange.realize,i._ScrollToPriority.high,function(){return c._setNewFocusItemOffsetPromise=d._getItemOffset(m,!0).then(function(e){e=d._convertFromCanvasCoordinates(e);var g=e.end<=d.scrollPosition||e.begin>=d.scrollPosition+d._getViewportLength()-1;return c._setNewFocusItemOffsetPromise=d._getItemOffset(a).then(function(e){c._setNewFocusItemOffsetPromise=null;var h={position:d.scrollPosition,direction:"right"};return g&&(d._selection._setFocused(a,!0),e=d._convertFromCanvasCoordinates(e),a.index>m.index?(h.direction="right",h.position=e.end-d._getViewportLength()):(h.direction="left",h.position=e.begin)),d._changeFocus(a,b,o,g,!0),g?h:f.cancel},function(c){return d._changeFocus(a,b,o,!0,!0),f.wrapError(c)}),c._setNewFocusItemOffsetPromise},function(c){return d._changeFocus(a,b,o,!0,!0),f.wrapError(c)}),c._setNewFocusItemOffsetPromise},!0))}return k&&(d._selection._setFocused(m,!0),d.ensureVisible(m)),l?{type:h.ObjectType.item,index:i._INVALID_INDEX}:a}return a.type!==h.ObjectType.groupHeader?l.finalItem().then(j):f.wrap(d._groups.length()-1).then(j)}var c=this,d=this.site,j=d._swipeBehavior===h.SwipeBehavior.select,l=d._view,m=d._selection._getFocused(),n=!0,o=a.ctrlKey,p=g.Key,q=a.keyCode,r=d._rtl();if(!this._isInteractive(a.target)){if(a.ctrlKey&&!a.altKey&&!a.shiftKey&&this._keyboardAcceleratorHandlers[q]&&this._keyboardAcceleratorHandlers[q](),d.itemsReorderable&&!a.ctrlKey&&a.altKey&&a.shiftKey&&m.type===h.ObjectType.item&&(q===p.leftArrow||q===p.rightArrow||q===p.upArrow||q===p.downArrow)){var s=d._selection,t=m.index,u=!1,v=!0;if(!s.isEverything()){if(!s._isIncluded(t)){var w=d._view.items.itemAt(t);w&&g.hasClass(w,i._nonDraggableClass)?v=!1:(u=!0,s=new k._Selection(this.site,[{firstIndex:t,lastIndex:t}]))}if(v){var x=t;q===p.rightArrow?x+=r?-1:1:q===p.leftArrow?x+=r?1:-1:q===p.upArrow?x--:x++;var y=x>t,z=y;y&&x>=this.site._cachedCount&&(z=!1,x=this.site._cachedCount-1),x=this._findFirstAvailableInsertPoint(s,x,z),x=Math.min(Math.max(-1,x),this.site._cachedCount-1);var A=x-(y||-1===x?0:1),B=x,C=this.site._groupsEnabled();if(C){var D=this.site._groups,E=x>-1?D.groupFromItem(x):0;y?D.group(E).startIndex===x&&A--:E<D.length()-1&&x===D.group(E+1).startIndex-1&&A++}if(this._fireDragBetweenEvent(B,A,null)&&this._fireDropEvent(B,A,null)){if(C)return;this._reorderItems(x,s,u,!y,!0)}}}}else if(a.altKey)n=!1;else if(this._keyboardNavigationHandlers[q])this._keyboardNavigationHandlers[q](m).then(function(e){var f=c._keyboardNavigationHandlers[q].clampToBounds;e.type!==h.ObjectType.groupHeader&&a.shiftKey&&d._selectionAllowed()&&d._multiSelection()?(d._selection._pivot===i._INVALID_INDEX&&(d._selection._pivot=m.index),b(e,!0,f).then(function(b){if(b.index!==i._INVALID_INDEX){var e=Math.min(b.index,d._selection._pivot),f=Math.max(b.index,d._selection._pivot),g=a.ctrlKey||d._tap===h.TapBehavior.toggleSelect;c._selectRange(e,f,g)}})):(d._selection._pivot=i._INVALID_INDEX,b(e,!1,f))});else if(a.ctrlKey||q!==p.enter)m.type!==h.ObjectType.groupHeader&&(a.ctrlKey&&q===p.enter||j&&a.shiftKey&&q===p.F10||j&&q===p.menu||q===p.space)?(this._itemEventsHandler.handleSwipeBehavior(m.index),d._changeFocus(m,!0,o,!1,!0)):q===p.escape&&d._selection.count()>0?(d._selection._pivot=i._INVALID_INDEX,d._selection.clear()):n=!1;else{var F=m.type===h.ObjectType.groupHeader?d._groups.group(m.index).header:d._view.items.itemBoxAt(m.index);if(F){m.type===h.ObjectType.groupHeader?(this._pressedHeader=F,this._pressedItemBox=null,this._pressedContainer=null):(this._pressedItemBox=F,this._pressedContainer=d._view.items.containerAt(m.index),this._pressedHeader=null);var G=this._verifySelectionAllowed(m);G.canTapSelect&&this._itemEventsHandler.handleTap(m),this._fireInvokeEvent(m,F)}}this._keyDownHandled=n,n&&(a.stopPropagation(),a.preventDefault())}q===p.tab&&(this.site._keyboardFocusInbound=!0)},onKeyUp:function(a){this._keyDownHandled&&(a.stopPropagation(),a.preventDefault())},onTabEntered:function(a){if(0!==this.site._groups.length()){var b=this.site,c=b._selection._getFocused(),d=a.detail,f=!b._hasKeyboardFocus||a.target===b._viewport;if(f)if(this.inboundFocusHandled=!0,c.index=c.index===i._INVALID_INDEX?0:c.index,d||!this.site._supportsGroupHeaderKeyboarding){var g={type:h.ObjectType.item};c.type===h.ObjectType.groupHeader?(g.index=b._groupFocusCache.getIndexForGroup(c.index),e(b._element,c,g)?b._changeFocus(g,!0,!1,!1,!0):b._changeFocus(c,!0,!1,!1,!0)):(g.index=c.index,b._changeFocus(g,!0,!1,!1,!0)),a.preventDefault()}else{var g={type:h.ObjectType.groupHeader};c.type!==h.ObjectType.groupHeader?(g.index=b._groups.groupFromItem(c.index),e(b._element,c,g)?b._changeFocus(g,!0,!1,!1,!0):b._changeFocus(c,!0,!1,!1,!0)):(g.index=c.index,b._changeFocus(g,!0,!1,!1,!0)),a.preventDefault()}}},onTabExiting:function(a){if(this.site._supportsGroupHeaderKeyboarding&&0!==this.site._groups.length()){var b=this.site,c=b._selection._getFocused(),d=a.detail;if(d&&c.type!==h.ObjectType.groupHeader){var f={type:h.ObjectType.groupHeader,index:b._groups.groupFromItem(c.index)};e(b._element,c,f)&&(b._changeFocus(f,!0,!1,!1,!0),a.preventDefault())}else if(!d&&c.type===h.ObjectType.groupHeader){var f={type:h.ObjectType.item,index:b._groupFocusCache.getIndexForGroup(c.index)};e(b._element,c,f)&&(b._changeFocus(f,!0,!1,!1,!0),a.preventDefault())}}}});return m})})}),d("WinJS/Controls/ListView/_ErrorMessages",["exports","../../Core/_Base","../../Core/_Resources"],function(a,b){"use strict";b.Namespace._moduleDefine(a,null,{modeIsInvalid:{get:function(){return"Invalid argument: mode must be one of following values: 'none', 'single' or 'multi'."}},loadingBehaviorIsDeprecated:{get:function(){return"Invalid configuration: loadingBehavior is deprecated. The control will default this property to 'randomAccess'. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},pagesToLoadIsDeprecated:{get:function(){return"Invalid configuration: pagesToLoad is deprecated. The control will not use this property. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},pagesToLoadThresholdIsDeprecated:{get:function(){return"Invalid configuration: pagesToLoadThreshold is deprecated.  The control will not use this property. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},automaticallyLoadPagesIsDeprecated:{get:function(){return"Invalid configuration: automaticallyLoadPages is deprecated. The control will default this property to false. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},invalidTemplate:{get:function(){return"Invalid template: Templates must be created before being passed to the ListView, and must contain a valid tree of elements."}},loadMorePagesIsDeprecated:{get:function(){return"loadMorePages is deprecated. Invoking this function will not have any effect. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},disableBackdropIsDeprecated:{get:function(){return"Invalid configuration: disableBackdrop is deprecated. Style: .win-listview .win-container.win-backdrop { background-color:transparent; } instead."}},backdropColorIsDeprecated:{get:function(){return"Invalid configuration: backdropColor is deprecated. Style: .win-listview .win-container.win-backdrop { rgba(155,155,155,0.23); } instead."}},itemInfoIsDeprecated:{get:function(){return"GridLayout.itemInfo may be altered or unavailable in future versions. Instead, use CellSpanningLayout."}},groupInfoIsDeprecated:{get:function(){return"GridLayout.groupInfo may be altered or unavailable in future versions. Instead, use CellSpanningLayout."}},resetItemIsDeprecated:{get:function(){return"resetItem may be altered or unavailable in future versions. Instead, mark the element as disposable using WinJS.Utilities.markDisposable."}},resetGroupHeaderIsDeprecated:{get:function(){return"resetGroupHeader may be altered or unavailable in future versions. Instead, mark the header element as disposable using WinJS.Utilities.markDisposable."}},maxRowsIsDeprecated:{get:function(){return"GridLayout.maxRows may be altered or unavailable in future versions. Instead, use the maximumRowsOrColumns property."}}})}),d("WinJS/Controls/ListView/_GroupFocusCache",["exports","../../Core/_Base"],function(a,b){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_GroupFocusCache:b.Namespace._lazy(function(){return b.Class.define(function(a){this._listView=a,this.clear()},{updateCache:function(a,b,c){c=""+c,this._itemToIndex[b]=c,this._groupToItem[a]=b},deleteItem:function(a){if(this._itemToIndex[a])for(var b=this,c=Object.keys(this._groupToItem),d=0,e=c.length;e>d;d++){var f=c[d];if(b._groupToItem[f]===a){b.deleteGroup(f);break}}},deleteGroup:function(a){var b=this._groupToItem[a];b&&delete this._itemToIndex[b],delete this._groupToItem[a]},updateItemIndex:function(a,b){this._itemToIndex[a]&&(this._itemToIndex[a]=""+b)},getIndexForGroup:function(a){var b=this._listView._groups.group(a).key,c=this._groupToItem[b];return c&&this._itemToIndex[c]?+this._itemToIndex[c]:this._listView._groups.fromKey(b).group.startIndex},clear:function(){this._groupToItem={},this._itemToIndex={}}})}),_UnsupportedGroupFocusCache:b.Namespace._lazy(function(){return b.Class.define(null,{updateCache:function(){},deleteItem:function(){},deleteGroup:function(){},updateItemIndex:function(){},getIndexForGroup:function(){return 0},clear:function(){}})})})}),d("WinJS/Controls/ListView/_GroupsContainer",["exports","../../Core/_Base","../../Promise","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_ItemsManager","../../Utilities/_UI","../ItemContainer/_Constants"],function(a,b,c,d,e,f,g,h){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_GroupsContainerBase:b.Namespace._lazy(function(){return b.Class.define(function(){},{index:function(a){var b=this.headerFrom(a);if(b)for(var c=0,d=this.groups.length;d>c;c++)if(b===this.groups[c].header)return c;
  return h._INVALID_INDEX},headerFrom:function(a){for(;a&&!e.hasClass(a,h._headerClass);)a=a.parentNode;return a},requestHeader:function(a){this._waitingHeaderRequests=this._waitingHeaderRequests||{},this._waitingHeaderRequests[a]||(this._waitingHeaderRequests[a]=[]);var b=this;return new c(function(c){var d=b.groups[a];d&&d.header?c(d.header):b._waitingHeaderRequests[a].push(c)})},notify:function(a,b){if(this._waitingHeaderRequests&&this._waitingHeaderRequests[a]){for(var c=this._waitingHeaderRequests[a],d=0,e=c.length;e>d;d++)c[d](b);this._waitingHeaderRequests[a]=[]}},groupFromImpl:function(a,b,c){if(a>b)return null;var d=a+Math.floor((b-a)/2),e=this.groups[d];return c(e,d)?this.groupFromImpl(a,d-1,c):b>d&&!c(this.groups[d+1],d+1)?this.groupFromImpl(d+1,b,c):d},groupFrom:function(a){if(this.groups.length>0){var b=this.groups.length-1,c=this.groups[b];return a(c,b)?this.groupFromImpl(0,this.groups.length-1,a):b}return null},groupFromItem:function(a){return this.groupFrom(function(b){return a<b.startIndex})},groupFromOffset:function(a){return this.groupFrom(function(b){return a<b.offset})},group:function(a){return this.groups[a]},length:function(){return this.groups.length},cleanUp:function(){if(this.listBinding){for(var a=0,b=this.groups.length;b>a;a++){var c=this.groups[a];c.userData&&this.listBinding.releaseItem(c.userData)}this.listBinding.release()}},_dispose:function(){this.cleanUp()},synchronizeGroups:function(){var a=this;return this.pendingChanges=[],this.ignoreChanges=!0,this.groupDataSource.invalidateAll().then(function(){return c.join(a.pendingChanges)}).then(function(){return a._listView._ifZombieDispose()?c.cancel:void 0}).then(function(){a.ignoreChanges=!1},function(b){return a.ignoreChanges=!1,c.wrapError(b)})},fromKey:function(a){for(var b=0,c=this.groups.length;c>b;b++){var d=this.groups[b];if(d.key===a)return{group:d,index:b}}return null},fromHandle:function(a){for(var b=0,c=this.groups.length;c>b;b++){var d=this.groups[b];if(d.handle===a)return{group:d,index:b}}return null}})}),_UnvirtualizedGroupsContainer:b.Namespace._lazy(function(){return b.Class.derive(a._GroupsContainerBase,function(a,b){this._listView=a,this.groupDataSource=b,this.groups=[],this.pendingChanges=[],this.dirty=!0;var c=this,f={beginNotifications:function(){c._listView._versionManager.beginNotifications()},endNotifications:function(){c._listView._versionManager.endNotifications(),c._listView._ifZombieDispose()||!c.ignoreChanges&&c._listView._groupsChanged&&c._listView._scheduleUpdate()},indexChanged:function(){c._listView._versionManager.receivedNotification(),c._listView._ifZombieDispose()||this.scheduleUpdate()},itemAvailable:function(){},countChanged:function(a){c._listView._versionManager.receivedNotification(),c._listView._writeProfilerMark("groupCountChanged("+a+"),info"),c._listView._ifZombieDispose()||this.scheduleUpdate()},changed:function(a){if(c._listView._versionManager.receivedNotification(),!c._listView._ifZombieDispose()){var b=c.fromKey(a.key);b&&(c._listView._writeProfilerMark("groupChanged("+b.index+"),info"),b.group.userData=a,b.group.startIndex=a.firstItemIndexHint,this.markToRemove(b.group)),this.scheduleUpdate()}},removed:function(a){if(c._listView._versionManager.receivedNotification(),c._listView._groupRemoved(a),!c._listView._ifZombieDispose()){var b=c.fromHandle(a);if(b){c._listView._writeProfilerMark("groupRemoved("+b.index+"),info"),c.groups.splice(b.index,1);var d=c.groups.indexOf(b.group,b.index);d>-1&&c.groups.splice(d,1),this.markToRemove(b.group)}this.scheduleUpdate()}},inserted:function(a,b,d){if(c._listView._versionManager.receivedNotification(),!c._listView._ifZombieDispose()){c._listView._writeProfilerMark("groupInserted,info");var e=this;a.retain().then(function(f){var g;if(g=b||d||c.groups.length?e.findIndex(b,d):0,-1!==g){var h={key:f.key,startIndex:f.firstItemIndexHint,userData:f,handle:a.handle};c.groups.splice(g,0,h)}e.scheduleUpdate()}),c.pendingChanges.push(a)}},moved:function(a,b,d){if(c._listView._versionManager.receivedNotification(),!c._listView._ifZombieDispose()){c._listView._writeProfilerMark("groupMoved,info");var e=this;a.then(function(f){var g=e.findIndex(b,d),h=c.fromKey(f.key);if(h)c.groups.splice(h.index,1),-1!==g&&(h.index<g&&g--,h.group.key=f.key,h.group.userData=f,h.group.startIndex=f.firstItemIndexHint,c.groups.splice(g,0,h.group));else if(-1!==g){var i={key:f.key,startIndex:f.firstItemIndexHint,userData:f,handle:a.handle};c.groups.splice(g,0,i),a.retain()}e.scheduleUpdate()}),c.pendingChanges.push(a)}},reload:function(){c._listView._versionManager.receivedNotification(),c._listView._ifZombieDispose()||c._listView._processReload()},markToRemove:function(a){if(a.header){var b=a.header;a.header=null,a.left=-1,a.width=-1,a.decorator=null,a.tabIndex=-1,b.tabIndex=-1,c._listView._groupsToRemove[e._uniqueID(b)]={group:a,header:b}}},scheduleUpdate:function(){c.dirty=!0,c.ignoreChanges||(c._listView._groupsChanged=!0)},findIndex:function(a,b){var d,e=-1;return a&&(d=c.fromHandle(a),d&&(e=d.index+1)),-1===e&&b&&(d=c.fromHandle(b),d&&(e=d.index)),e},removeElements:function(a){if(a.header){var b=a.header.parentNode;b&&(d.disposeSubTree(a.header),b.removeChild(a.header)),a.header=null,a.left=-1,a.width=-1}}};this.listBinding=this.groupDataSource.createListBinding(f)},{initialize:function(){this.initializePromise&&this.initializePromise.cancel(),this._listView._writeProfilerMark("GroupsContainer_initialize,StartTM");var a=this;return this.initializePromise=this.groupDataSource.getCount().then(function(b){for(var d=[],e=0;b>e;e++)d.push(a.listBinding.fromIndex(e).retain());return c.join(d)}).then(function(b){a.groups=[];for(var c=0,d=b.length;d>c;c++){var e=b[c];a.groups.push({key:e.key,startIndex:e.firstItemIndexHint,handle:e.handle,userData:e})}a._listView._writeProfilerMark("GroupsContainer_initialize groups("+b.length+"),info"),a._listView._writeProfilerMark("GroupsContainer_initialize,StopTM")},function(b){return a._listView._writeProfilerMark("GroupsContainer_initialize,StopTM"),c.wrapError(b)}),this.initializePromise},renderGroup:function(a){if(this._listView.groupHeaderTemplate){var b=this.groups[a];return c.wrap(this._listView._groupHeaderRenderer(c.wrap(b.userData))).then(f._normalizeRendererReturn)}return c.wrap(null)},setDomElement:function(a,b){this.groups[a].header=b,this.notify(a,b)},removeElements:function(){for(var a=this._listView._groupsToRemove||{},b=Object.keys(a),c=!1,e=this._listView._selection._getFocused(),f=0,h=b.length;h>f;f++){var i=a[b[f]],j=i.header,k=i.group;if(c||e.type!==g.ObjectType.groupHeader||k.userData.index!==e.index||(this._listView._unsetFocusOnItem(),c=!0),j){var l=j.parentNode;l&&(d._disposeElement(j),l.removeChild(j))}}c&&this._listView._setFocusOnItem(e),this._listView._groupsToRemove={}},resetGroups:function(){for(var a=this.groups.slice(0),b=0,c=a.length;c>b;b++){var d=a[b];this.listBinding&&d.userData&&this.listBinding.releaseItem(d.userData)}this.groups.length=0,this.dirty=!0}})}),_NoGroups:b.Namespace._lazy(function(){return b.Class.derive(a._GroupsContainerBase,function(a){this._listView=a,this.groups=[{startIndex:0}],this.dirty=!0},{synchronizeGroups:function(){return c.wrap()},addItem:function(){return c.wrap(this.groups[0])},resetGroups:function(){this.groups=[{startIndex:0}],delete this.pinnedItem,delete this.pinnedOffset,this.dirty=!0},renderGroup:function(){return c.wrap(null)},ensureFirstGroup:function(){return c.wrap(this.groups[0])},groupOf:function(){return c.wrap(this.groups[0])},removeElements:function(){}})})})}),d("WinJS/Controls/ListView/_Helpers",["exports","../../Core/_Base","../../Animations"],function(a,b,c){"use strict";function d(a){return Array.prototype.slice.call(a)}function e(a,b){return new Array(b+1).join(a)}b.Namespace._moduleDefine(a,"WinJS.UI",{_nodeListToArray:d,_repeat:e,_ListViewAnimationHelper:{fadeInElement:function(a){return c.fadeIn(a)},fadeOutElement:function(a){return c.fadeOut(a)},animateEntrance:function(a,b){return c.enterContent(a,[{left:b?"100px":"40px",top:"0px",rtlflip:!0}],{mechanism:"transition"})}}})}),d("WinJS/Controls/ListView/_ItemsContainer",["exports","../../Core/_Base","../../Promise","../../Utilities/_ElementUtilities","../ItemContainer/_Constants"],function(a,b,c,d,e){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_ItemsContainer:b.Namespace._lazy(function(){var a=function(a){this.site=a,this._itemData={},this.waitingItemRequests={}};return a.prototype={requestItem:function(a){this.waitingItemRequests[a]||(this.waitingItemRequests[a]=[]);var b=this,d=new c(function(c){var d=b._itemData[a];d&&!d.detached&&d.element?c(d.element):b.waitingItemRequests[a].push(c)});return d},removeItem:function(a){delete this._itemData[a]},removeItems:function(){this._itemData={},this.waitingItemRequests={}},setItemAt:function(a,b){this._itemData[a]=b,b.detached||this.notify(a,b)},notify:function(a,b){if(this.waitingItemRequests[a]){for(var c=this.waitingItemRequests[a],d=0;d<c.length;d++)c[d](b.element);this.waitingItemRequests[a]=[]}},elementAvailable:function(a){var b=this._itemData[a];b.detached=!1,this.notify(a,b)},itemAt:function(a){var b=this._itemData[a];return b?b.element:null},itemDataAt:function(a){return this._itemData[a]},containerAt:function(a){var b=this._itemData[a];return b?b.container:null},itemBoxAt:function(a){var b=this._itemData[a];return b?b.itemBox:null},itemBoxFrom:function(a){for(;a&&!d.hasClass(a,e._itemBoxClass);)a=a.parentNode;return a},containerFrom:function(a){for(;a&&!d.hasClass(a,e._containerClass);)a=a.parentNode;return a},index:function(a){var b=this.containerFrom(a);if(b)for(var c in this._itemData)if(this._itemData[c].container===b)return parseInt(c,10);return e._INVALID_INDEX},each:function(a){for(var b in this._itemData)if(this._itemData.hasOwnProperty(b)){var c=this._itemData[b];a(parseInt(b,10),c.element,c)}},eachIndex:function(a){for(var b in this._itemData)if(a(parseInt(b,10)))break},count:function(){return Object.keys(this._itemData).length}},a})})}),d("WinJS/Controls/ListView/_Layouts",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Resources","../../Core/_WriteProfilerMark","../../Animations/_TransitionAnimation","../../Promise","../../Scheduler","../../_Signal","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_SafeHtml","../../Utilities/_UI","../ItemContainer/_Constants","./_ErrorMessages"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){"use strict";function r(a){return"_win-dynamic-"+a+"-"+L++}function s(){var a,b,c,d=K.sheet.cssRules,e=M.length;for(a=0;e>a;a++)for(c="."+M[a]+" ",b=d.length-1;b>=0;b--)-1!==d[b].selectorText.indexOf(c)&&K.sheet.deleteRule(b);M=[]}function t(a,b,c,d){s();var e="."+p._listViewClass+" ."+a+" "+c+" { "+d+"}",f="_addDynamicCssRule:"+a+",info";b?b._writeProfilerMark(f):g("WinJS.UI.ListView:Layout"+f),K.sheet.insertRule(e,0)}function u(a){M.push(a)}function v(a,b,c){return Math.max(a,Math.min(b,c))}function w(a,c){return m.convertToPixels(a,b.getComputedStyle(a,null)[c])}function x(a,b){return w(b,"margin"+a)+w(b,"border"+a+"Width")+w(b,"padding"+a)}function y(a){return x("Top",a)+x("Bottom",a)}function z(a){return x("Left",a)+x("Right",a)}function A(a,b){if(a.items)for(var c=0,d=a.items.length;d>c;c++)b(a.items[c],c);else for(var e=0,f=0;e<a.itemsBlocks.length;e++)for(var g=a.itemsBlocks[e],c=0,d=g.items.length;d>c;c++)b(g.items[c],f++)}function B(a,b){if(0>b)return null;if(a.items)return b<a.items.length?a.items[b]:null;var c=a.itemsBlocks[0].items.length,d=Math.floor(b/c),e=b%c;return d<a.itemsBlocks.length&&e<a.itemsBlocks[d].items.length?a.itemsBlocks[d].items[e]:null}function C(a,b){for(var c,d=0,e=b.length;e>d;d++)if(b[d].itemsContainer.element===a){c=b[d].itemsContainer;break}return c}function D(a){var b,c;return a.itemsBlocks?(b=a.itemsBlocks.length,c=b>0?a.itemsBlocks[0].items.length*(b-1)+a.itemsBlocks[b-1].items.length:0):c=a.items.length,c}function E(a){if(!S){var c=b.document.createElement("div");c.style.width="500px",c.style.visibility="hidden";var d=b.document.createElement("div");d.style.cssText+="width: 500px; height: 200px; display: -webkit-flex; display: flex",n.setInnerHTMLUnsafe(d,"<div style='height: 100%; display: -webkit-flex; display: flex; flex-flow: column wrap; align-content: flex-start; -webkit-flex-flow: column wrap; -webkit-align-content: flex-start'><div style='width: 100px; height: 100px'></div><div style='width: 100px; height: 100px'></div><div style='width: 100px; height: 100px'></div></div>"),c.appendChild(d),a.viewport.insertBefore(c,a.viewport.firstChild);var e=c.offsetWidth>0,f=200;e&&(S={supportsCSSGrid:!!("-ms-grid-row"in b.document.documentElement.style),nestedFlexTooLarge:d.firstElementChild.offsetWidth>f,nestedFlexTooSmall:d.firstElementChild.offsetWidth<f}),a.viewport.removeChild(c)}return S}function F(a){return i.is(a)?{realizedRangeComplete:a,layoutComplete:a}:"object"==typeof a&&a&&a.layoutComplete?a:{realizedRangeComplete:i.wrap(),layoutComplete:i.wrap()}}function G(a){return{left:w(a,"marginLeft"),right:w(a,"marginRight"),top:w(a,"marginTop"),bottom:w(a,"marginBottom")}}var H=m.Key,I=m._uniqueID,J={get itemInfoIsInvalid(){return"Invalid argument: An itemInfo function must be provided which returns an object with numeric width and height properties."},get groupInfoResultIsInvalid(){return"Invalid result: groupInfo result for cell spanning groups must include the following numeric properties: cellWidth and cellHeight."}},K=b.document.createElement("style");b.document.head.appendChild(K);var L=0,M=[],N=d._browserStyleEquivalents,O=N.transform,P=d._browserStyleEquivalents.transition.scriptName,Q=O.cssName+" cubic-bezier(0.1, 0.9, 0.2, 1) 167ms",R=12,S=null;c.Namespace._moduleDefine(a,"WinJS.UI",{Layout:c.Class.define(function(){}),_LayoutCommon:c.Namespace._lazy(function(){return c.Class.derive(a.Layout,null,{groupHeaderPosition:{enumerable:!0,get:function(){return this._groupHeaderPosition},set:function(a){this._groupHeaderPosition=a,this._invalidateLayout()}},initialize:function(a,b){a._writeProfilerMark("Layout:initialize,info"),this._inListMode||m.addClass(a.surface,p._gridLayoutClass),this._backdropColorClassName&&m.addClass(a.surface,this._backdropColorClassName),this._disableBackdropClassName&&m.addClass(a.surface,this._disableBackdropClassName),this._groups=[],this._groupMap={},this._oldGroupHeaderPosition=null,this._usingStructuralNodes=!1,this._site=a,this._groupsEnabled=b,this._resetAnimationCaches(!0)},orientation:{enumerable:!0,get:function(){return this._orientation},set:function(a){this._orientation=a,this._horizontal="horizontal"===a,this._invalidateLayout()}},uninitialize:function(){function a(a){var b,c=a.length;for(b=0;c>b;b++)a[b].cleanUp(!0)}var b="Layout:uninitialize,info";this._elementsToMeasure={},this._site?(this._site._writeProfilerMark(b),m.removeClass(this._site.surface,p._gridLayoutClass),m.removeClass(this._site.surface,p._headerPositionTopClass),m.removeClass(this._site.surface,p._headerPositionLeftClass),m.removeClass(this._site.surface,p._structuralNodesClass),this._site.surface.style.cssText="",this._groups&&(a(this._groups),this._groups=null,this._groupMap=null),this._layoutPromise&&(this._layoutPromise.cancel(),this._layoutPromise=null),this._resetMeasurements(),this._oldGroupHeaderPosition=null,this._usingStructuralNodes=null,this._backdropColorClassName&&(m.removeClass(this._site.surface,this._backdropColorClassName),u(this._backdropColorClassName),this._backdropColorClassName=null),this._disableBackdropClassName&&(m.removeClass(this._site.surface,this._disableBackdropClassName),u(this._disableBackdropClassName),this._disableBackdropClassName=null),this._site=null,this._groupsEnabled=null,this._animationsRunning&&this._animationsRunning.cancel(),this._animatingItemsBlocks={}):g("WinJS.UI.ListView:"+b)},numberOfItemsPerItemsBlock:{get:function(){function b(){var a,b=c._site.groupCount;for(a=0;b>a;a++)if(c._isCellSpanning(a))return!1;return!0}var c=this;return c._measureItem(0).then(function(){return c._sizes.viewportContentSize!==c._getViewportCrossSize()&&c._viewportSizeChanged(c._getViewportCrossSize()),c._envInfo.nestedFlexTooLarge||c._envInfo.nestedFlexTooSmall||!b()?(c._usingStructuralNodes=!1,null):(c._usingStructuralNodes=a._LayoutCommon._barsPerItemsBlock>0,a._LayoutCommon._barsPerItemsBlock*c._itemsPerBar)})}},layout:function(a,b,c,d){function e(a){function b(a){if(l._usingStructuralNodes){var b=[];return a.itemsBlocks.forEach(function(a){b=b.concat(a.items.slice(0))}),b}return a.items.slice(0)}return{element:a.element,items:b(a)}}function f(){function c(a,b){var c=a.enableCellSpanning?T.CellSpanningGroup:T.UniformGroup;return new c(l,b)}var d,f=l._groups.length>0?l._getRealizationRange():null,g=[],h=[],j={},k={},m=0,n=a.length;for(d=0;n>d;d++){var o=null,p=l._getGroupInfo(d),q=l._site.groupFromIndex(d).key,r=l._groupMap[q],s=r instanceof T.CellSpanningGroup,t=p.enableCellSpanning;if(r)if(s!==t)j[q]=!0;else{var u=Math.max(0,b.firstIndex-r.startIndex),v=l._rangeForGroup(r,f);v&&u<=v.lastIndex&&(o={firstIndex:Math.max(u,v.firstIndex),lastIndex:v.lastIndex})}var w,x=c(p,a[d].itemsContainer.element);w=x.prepareLayoutWithCopyOfTree?x.prepareLayoutWithCopyOfTree(e(a[d].itemsContainer),o,r,{groupInfo:p,startIndex:m}):x.prepareLayout(D(a[d].itemsContainer),o,r,{groupInfo:p,startIndex:m}),h.push(w),m+=x.count,g.push(x),k[q]=x}return i.join(h).then(function(){for(var a=0,b=0,c=g.length;c>b;b++){var d=g[b];d.offset=a,a+=l._getGroupSize(d)}Object.keys(l._groupMap).forEach(function(a){var b=!j[a];l._groupMap[a].cleanUp(b)}),l._groups=g,l._groupMap=k})}function g(a,c,d){var e,f=l._groups[a],g=Math.max(0,b.firstIndex-f.startIndex),h=l._rangeForGroup(f,c);return d?void f.layoutRealizedRange(g,h):(h||(e=f.startIndex+f.count-1<c.firstIndex),f.layoutUnrealizedRange(g,h,e))}function h(){if(0!==l._groups.length){var c,d=l._getRealizationRange(),e=a.length,f=n.groupIndexFromItemIndex(b.firstIndex);for(c=f;e>c;c++)g(c,d,!0),l._layoutGroup(c)}}function j(){if(0===l._groups.length)return i.wrap();var a=l._getRealizationRange(),c=n.groupIndexFromItemIndex(a.firstIndex-1),d=n.groupIndexFromItemIndex(a.lastIndex+1),e=n.groupIndexFromItemIndex(b.firstIndex),f=[],h=l._groups.length,j=!1,k=c,m=Math.max(e,d);for(m=Math.max(k+1,m);!j;)j=!0,k>=e&&(f.push(g(k,a,!1)),j=!1,k--),h>m&&(f.push(g(m,a,!1)),j=!1,m++);return i.join(f)}var k,l=this,n=l._site,o="Layout.layout",q=o+":realizedRange";return l._site._writeProfilerMark(o+",StartTM"),l._site._writeProfilerMark(q+",StartTM"),k=l._measureItem(0).then(function(){return m[l._usingStructuralNodes?"addClass":"removeClass"](l._site.surface,p._structuralNodesClass),l._sizes.viewportContentSize!==l._getViewportCrossSize()&&l._viewportSizeChanged(l._getViewportCrossSize()),l._cacheRemovedElements(c,l._cachedItemRecords,l._cachedInsertedItemRecords,l._cachedRemovedItems,!1),l._cacheRemovedElements(d,l._cachedHeaderRecords,l._cachedInsertedHeaderRecords,l._cachedRemovedHeaders,!0),f()}).then(function(){l._syncDomWithGroupHeaderPosition(a);var b=0;if(l._groups.length>0){var e=l._groups[l._groups.length-1];b=e.offset+l._getGroupSize(e)}l._horizontal?(l._groupsEnabled&&l._groupHeaderPosition===U.left?n.surface.style.cssText+=";height:"+l._sizes.surfaceContentSize+"px;-ms-grid-columns: ("+l._sizes.headerContainerWidth+"px auto)["+a.length+"]":n.surface.style.height=l._sizes.surfaceContentSize+"px",(l._envInfo.nestedFlexTooLarge||l._envInfo.nestedFlexTooSmall)&&(n.surface.style.width=b+"px")):(l._groupsEnabled&&l._groupHeaderPosition===U.top?n.surface.style.cssText+=";width:"+l._sizes.surfaceContentSize+"px;-ms-grid-rows: ("+l._sizes.headerContainerHeight+"px auto)["+a.length+"]":n.surface.style.width=l._sizes.surfaceContentSize+"px",(l._envInfo.nestedFlexTooLarge||l._envInfo.nestedFlexTooSmall)&&(n.surface.style.height=b+"px")),h(),l._layoutAnimations(c,d),l._site._writeProfilerMark(q+":complete,info"),l._site._writeProfilerMark(q+",StopTM")},function(a){return l._site._writeProfilerMark(q+":canceled,info"),l._site._writeProfilerMark(q+",StopTM"),i.wrapError(a)}),l._layoutPromise=k.then(function(){return j().then(function(){l._site._writeProfilerMark(o+":complete,info"),l._site._writeProfilerMark(o+",StopTM")},function(a){return l._site._writeProfilerMark(o+":canceled,info"),l._site._writeProfilerMark(o+",StopTM"),i.wrapError(a)})}),{realizedRangeComplete:k,layoutComplete:l._layoutPromise}},itemsFromRange:function(a,b){return this._rangeContainsItems(a,b)?{firstIndex:this._firstItemFromRange(a),lastIndex:this._lastItemFromRange(b)}:{firstIndex:0,lastIndex:-1}},getAdjacent:function(b,c){function d(){var a={type:b.type,index:b.index-g.startIndex},c=g.getAdjacent(a,h);if("boundary"===c){var d=e._groups[f-1],i=e._groups[f+1],j=e._groups.length-1;if(h===H.leftArrow){if(0===f)return b;if(d instanceof T.UniformGroup&&g instanceof T.UniformGroup){var k=e._indexToCoordinate(a.index),l=e._horizontal?k.row:k.column,m=Math.floor((d.count-1)/e._itemsPerBar),n=m*e._itemsPerBar;return{type:o.ObjectType.item,index:d.startIndex+Math.min(d.count-1,n+l)}}return{type:o.ObjectType.item,index:g.startIndex-1}}if(h===H.rightArrow){if(f===j)return b;if(g instanceof T.UniformGroup&&i instanceof T.UniformGroup){var k=e._indexToCoordinate(a.index),l=e._horizontal?k.row:k.column;return{type:o.ObjectType.item,index:i.startIndex+Math.min(i.count-1,l)}}return{type:o.ObjectType.item,index:i.startIndex}}return b}return c.index+=g.startIndex,c}var e=this,f=e._site.groupIndexFromItemIndex(b.index),g=e._groups[f],h=e._adjustedKeyForOrientationAndBars(e._adjustedKeyForRTL(c),g instanceof T.CellSpanningGroup);if(b.type===o.ObjectType.groupHeader){if(c!==H.pageUp&&c!==H.pageDown){switch(h){case H.leftArrow:return{type:o.ObjectType.groupHeader,index:Math.max(0,b.index-1)};case H.rightArrow:return{type:o.ObjectType.groupHeader,index:Math.min(e._groups.length-1,b.index+1)}}return b}b={type:o.ObjectType.item,index:this._groups[b.index].startIndex}}switch(e._adjustedKeyForRTL(c)){case H.upArrow:case H.leftArrow:case H.downArrow:case H.rightArrow:return d();default:return a._LayoutCommon.prototype._getAdjacentForPageKeys.call(e,b,c)}},hitTest:function(a,b){var c,d=this._sizes;a-=d.layoutOriginX,b-=d.layoutOriginY;var e=this._groupFromOffset(this._horizontal?a:b),f=this._groups[e];return this._horizontal?a-=f.offset:b-=f.offset,this._groupsEnabled&&(this._groupHeaderPosition===U.left?a-=d.headerContainerWidth:b-=d.headerContainerHeight),c=f.hitTest(a,b),c.index+=f.startIndex,c.insertAfterIndex+=f.startIndex,c},setupAnimations:function(){if(0===this._groups.length)return void this._resetAnimationCaches();if(!Object.keys(this._cachedItemRecords).length){this._site._writeProfilerMark("Animation:setupAnimations,StartTM");for(var a=this._getRealizationRange(),b=this._site.tree,c=0,d="horizontal"===this.orientation,e=0,f=b.length;f>e;e++){var g=b[e],h=!1,i=this._groups[e],j=i instanceof T.CellSpanningGroup,k=i?i.offset:0;if(A(g.itemsContainer,function(b,d){if(a.firstIndex<=c&&a.lastIndex>=c&&(h=!0,!this._cachedItemRecords[c])){var f=this._getItemPositionForAnimations(c,e,d),g=f.row,i=f.column,k=f.left,l=f.top;this._cachedItemRecords[c]={oldRow:g,oldColumn:i,oldLeft:k,oldTop:l,width:f.width,height:f.height,element:b,inCellSpanningGroup:j}}c++}.bind(this)),h){var l=e;if(!this._cachedHeaderRecords[l]){var m=this._getHeaderPositionForAnimations(l);this._cachedHeaderRecords[l]={oldLeft:m.left,oldTop:m.top,width:m.width,height:m.height,element:g.header}}this._cachedGroupRecords[I(g.itemsContainer.element)]||(this._cachedGroupRecords[I(g.itemsContainer.element)]={oldLeft:d?k:0,left:d?k:0,oldTop:d?0:k,top:d?0:k,element:g.itemsContainer.element})}}this._site._writeProfilerMark("Animation:setupAnimations,StopTM")}},_layoutAnimations:function(a,b){if(Object.keys(this._cachedItemRecords).length||Object.keys(this._cachedGroupRecords).length||Object.keys(this._cachedHeaderRecords).length){this._site._writeProfilerMark("Animation:layoutAnimation,StartTM"),this._updateAnimationCache(a,b);for(var c=this._getRealizationRange(),d=this._site.tree,e=0,f="horizontal"===this.orientation,g=0,h=d.length;h>g;g++){var i=d[g],j=this._groups[g],k=j instanceof T.CellSpanningGroup,l=j?j.offset:0,n=0,o=0,q=this._cachedGroupRecords[I(i.itemsContainer.element)];q&&(f?n=q.oldLeft-l:o=q.oldTop-l),A(i.itemsContainer,function(a,b){if(c.firstIndex<=e&&c.lastIndex>=e){var d=this._cachedItemRecords[e];if(d){var f=this._getItemPositionForAnimations(e,g,b),h=f.row,i=f.column,j=f.left,l=f.top;if(d.inCellSpanningGroup=d.inCellSpanningGroup||k,d.oldRow!==h||d.oldColumn!==i||d.oldTop!==l||d.oldLeft!==j){d.row=h,d.column=i,d.left=j,d.top=l;var q=d.oldLeft-d.left-n,r=d.oldTop-d.top-o;if(q=(this._site.rtl?-1:1)*q,d.xOffset=q,d.yOffset=r,0!==q||0!==r){var s=d.element;d.needsToResetTransform=!0,s.style[P]="",s.style[O.scriptName]="translate("+q+"px,"+r+"px)"}var t=a.parentNode;m.hasClass(t,p._itemsBlockClass)&&(this._animatingItemsBlocks[I(t)]=t)}}else this._cachedInsertedItemRecords[e]=a,a.style[P]="",a.style.opacity=0}e++}.bind(this));var r=g,s=this._cachedHeaderRecords[r];if(s){var t=this._getHeaderPositionForAnimations(r);if(s.height=t.height,s.width=t.width,s.oldLeft!==t.left||s.oldTop!==t.top){s.left=t.left,s.top=t.top;var u=s.oldLeft-s.left,v=s.oldTop-s.top;if(u=(this._site.rtl?-1:1)*u,0!==u||0!==v){s.needsToResetTransform=!0;var w=s.element;w.style[P]="",w.style[O.scriptName]="translate("+u+"px,"+v+"px)"}}}if(q&&(f&&q.left!==l||!f&&q.top!==l)){var x=q.element;if(0===n&&0===o)q.needsToResetTransform&&(q.needsToResetTransform=!1,x.style[O.scriptName]="");else{var y=(this._site.rtl?-1:1)*n,z=o;q.needsToResetTransform=!0,x.style[P]="",x.style[O.scriptName]="translate("+y+"px, "+z+"px)"}}}if(this._inListMode||1===this._itemsPerBar)for(var B=Object.keys(this._animatingItemsBlocks),C=0,D=B.length;D>C;C++)this._animatingItemsBlocks[B[C]].style.overflow="visible";this._site._writeProfilerMark("Animation:layoutAnimation,StopTM")}},executeAnimations:function(){function b(){if(e(),H)f();else{if(bb._itemsPerBar>1)for(var a=bb._itemsPerBar*bb._sizes.containerCrossSize+bb._getHeaderSizeContentAdjustment()+bb._sizes.containerMargins[U?"top":v.rtl?"right":"left"]+(U?bb._sizes.layoutOriginY:bb._sizes.layoutOriginX),b=0,c=y.length;c>b;b++){var d=y[b];d[V]>d[W]?(N=Math.max(N,d[X]+d[U?"height":"width"]),R=Math.max(R,a-d[Y]),J=!0,T.push(d)):d[V]<d[W]&&(Q=Math.max(Q,a-d[X]),S=Math.max(S,d[Y]+d[U?"height":"width"]),T.push(d),J=!0)}v.rtl&&!U&&(N*=-1,R*=-1,Q*=-1,S*=-1),J?j(bb._itemsPerBar):q()}}function c(b){F=i.join(G),F.done(function(){G=[],t&&(a.Layout._debugAnimations?d._requestAnimationFrame(function(){b()}):b())})}function e(){if(x.length){v._writeProfilerMark("Animation:setupRemoveAnimation,StartTM"),B+=60,E+=60;var a=120;u&&(a*=10),G.push(h.executeTransition(x,[{property:"opacity",delay:A,duration:a,timing:"linear",to:0,skipStylesReset:!0}])),v._writeProfilerMark("Animation:setupRemoveAnimation,StopTM")}}function f(){v._writeProfilerMark("Animation:cellSpanningFadeOutMove,StartTM");for(var a=[],b=0,d=y.length;d>b;b++){var e=y[b],f=e.element;a.push(f)}for(var b=0,d=z.length;d>b;b++){var e=z[b],f=e.element;a.push(f)}var i=120;u&&(i*=10),G.push(h.executeTransition(a,{property:"opacity",delay:A,duration:i,timing:"linear",to:0})),c(g),v._writeProfilerMark("Animation:cellSpanningFadeOutMove,StopTM")}function g(){v._writeProfilerMark("Animation:cellSpanningFadeInMove,StartTM"),E=0;for(var a=[],b=0,c=y.length;c>b;b++){var d=y[b],e=d.element;e.style[O.scriptName]="",a.push(e)}for(var b=0,c=z.length;c>b;b++){var d=z[b],e=d.element;e.style[O.scriptName]="",a.push(e)}var f=120;u&&(f*=10),G.push(h.executeTransition(a,{property:"opacity",delay:E,duration:f,timing:"linear",to:1})),v._writeProfilerMark("Animation:cellSpanningFadeInMove,StopTM"),r()}function j(a){v._writeProfilerMark("Animation:setupReflowAnimation,StartTM");for(var b={},d=0,e=T.length;e>d;d++){var f=T[d],g=f.xOffset,i=f.yOffset;f[V]>f[W]?U?i-=N:g-=N:f[V]<f[W]&&(U?i+=Q:g+=Q);var j=f.element;K=Math.min(K,U?g:i),L=Math.max(L,U?g:i);var k=j.parentNode;m.hasClass(k,"win-itemscontainer")||(k=k.parentNode);var l=b[I(k)];if(!l){var n=D(C(k,v.tree));b[I(k)]=l=Math.ceil(n/a)-1}T[d][U?"column":"row"]===l&&(M[I(k)]=k);var q=80;u&&(q*=10),G.push(h.executeTransition(j,{property:O.cssName,delay:B,duration:q,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:"translate("+g+"px,"+i+"px)"}))}for(var r=Object.keys(M),d=0,e=r.length;e>d;d++){var s=M[r[d]];v.rtl&&U?(s.style.paddingLeft=-1*K+"px",s.style.marginLeft=K+"px"):(s.style[U?"paddingRight":"paddingBottom"]=L+"px",s.style[U?"marginRight":"marginBottom"]="-"+L+"px")}for(var t=Object.keys(Z),d=0,e=t.length;e>d;d++)Z[t[d]].classList.add(p._clipClass);c(o),v._writeProfilerMark("Animation:setupReflowAnimation,StopTM")}function n(){for(var a=Object.keys(M),b=0,c=a.length;c>b;b++){var d=M[a[b]];v.rtl&&U?(d.style.paddingLeft="",d.style.marginLeft=""):(d.style[U?"paddingRight":"paddingBottom"]="",d.style[U?"marginRight":"marginBottom"]="")}M={};for(var e=Object.keys(Z),b=0,c=e.length;c>b;b++){var f=Z[e[b]];f.style.overflow="",f.classList.remove(p._clipClass)}}function o(){v._writeProfilerMark("Animation:prepareReflowedItems,StartTM");for(var b=0,c=T.length;c>b;b++){var e=T[b],f=0,g=0;e[V]>e[W]?U?g=R:f=R:e[V]<e[W]&&(U?g=-1*S:f=-1*S),e.element.style[P]="",e.element.style[O.scriptName]="translate("+f+"px,"+g+"px)"}v._writeProfilerMark("Animation:prepareReflowedItems,StopTM"),a.Layout._debugAnimations?d._requestAnimationFrame(function(){q(!0)}):q(!0)}function q(a){var b=200;if(a&&(b=150,B=0,E=0),u&&(b*=10),y.length>0||z.length>0){v._writeProfilerMark("Animation:setupMoveAnimation,StartTM");for(var c=[],d=0,e=z.length;e>d;d++){var f=z[d].element;c.push(f)}for(var d=0,e=y.length;e>d;d++){var f=y[d].element;c.push(f)}G.push(h.executeTransition(c,{property:O.cssName,delay:B,duration:b,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""})),E+=80,v._writeProfilerMark("Animation:setupMoveAnimation,StopTM")}r()}function r(){if(w.length>0){v._writeProfilerMark("Animation:setupInsertAnimation,StartTM");var a=120;u&&(a*=10),G.push(h.executeTransition(w,[{property:"opacity",delay:E,duration:a,timing:"linear",to:1}])),v._writeProfilerMark("Animation:setupInsertAnimation,StopTM")}c(s)}function s(){v._writeProfilerMark("Animation:cleanupAnimations,StartTM"),n();for(var a=0,b=x.length;b>a;a++){var c=x[a];c.parentNode&&(l._disposeElement(c),c.parentNode.removeChild(c))}v._writeProfilerMark("Animation:cleanupAnimations,StopTM"),bb._animationsRunning=null,t.complete()}var t=new k;if(this._filterInsertedElements(),this._filterMovedElements(),this._filterRemovedElements(),0===this._insertedElements.length&&0===this._removedElements.length&&0===this._itemMoveRecords.length&&0===this._moveRecords.length)return this._resetAnimationCaches(!0),t.complete(),t.promise;this._animationsRunning=t.promise;for(var u=a.Layout._debugAnimations||a.Layout._slowAnimations,v=this._site,w=this._insertedElements,x=this._removedElements,y=this._itemMoveRecords,z=this._moveRecords,A=0,B=0,E=0,F=null,G=[],H=!1,J=!1,K=0,L=0,M={},N=0,Q=0,R=0,S=0,T=[],U="horizontal"===this.orientation,V=U?"oldColumn":"oldRow",W=U?"column":"row",X=U?"oldTop":"oldLeft",Y=U?"top":"left",Z=this._animatingItemsBlocks,$=0,_=y.length;_>$;$++){var ab=y[$];if(ab.inCellSpanningGroup){H=!0;break}}var bb=this;return a.Layout._debugAnimations?d._requestAnimationFrame(function(){b()}):b(),this._resetAnimationCaches(!0),t.promise.then(null,function(){n();for(var a=0,b=z.length;b>a;a++){var c=z[a].element;c.style[O.scriptName]="",c.style.opacity=1}for(var a=0,b=y.length;b>a;a++){var c=y[a].element;c.style[O.scriptName]="",c.style.opacity=1}for(var a=0,b=w.length;b>a;a++)w[a].style.opacity=1;for(var a=0,b=x.length;b>a;a++){var c=x[a];c.parentNode&&(l._disposeElement(c),c.parentNode.removeChild(c))}this._animationsRunning=null,t=null,F&&F.cancel()}.bind(this)),t.promise},dragOver:function(a,b,c){var d=this.hitTest(a,b),e=this._groups?this._site.groupIndexFromItemIndex(d.index):0,f=this._site.tree[e].itemsContainer,g=D(f),h=this._groups?this._groups[e].startIndex:0,i=this._getVisibleRange();
  d.index-=h,d.insertAfterIndex-=h,i.firstIndex=Math.max(i.firstIndex-h-1,0),i.lastIndex=Math.min(i.lastIndex-h+1,g);var j=Math.max(Math.min(g-1,d.insertAfterIndex),-1),k=Math.min(j+1,g);if(c){for(var l=j;l>=i.firstIndex;l--){if(!c._isIncluded(l+h)){j=l;break}l===i.firstIndex&&(j=-1)}for(var l=k;l<i.lastIndex;l++){if(!c._isIncluded(l+h)){k=l;break}l===i.lastIndex-1&&(k=g)}}var m=B(f,k),n=B(f,j);if(this._animatedDragItems)for(var l=0,o=this._animatedDragItems.length;o>l;l++){var p=this._animatedDragItems[l];p&&(p.style[P]=this._site.animationsDisabled?"":Q,p.style[O.scriptName]="")}this._animatedDragItems=[];var q="horizontal"===this.orientation,r=this._inListMode||1===this._itemsPerBar;this._groups&&this._groups[e]instanceof T.CellSpanningGroup&&(r=1===this._groups[e]._slotsPerColumn);var s=0,t=0;!q&&!r||q&&r?s=this._site.rtl?-R:R:t=R,m&&(m.style[P]=this._site.animationsDisabled?"":Q,m.style[O.scriptName]="translate("+s+"px, "+t+"px)",this._animatedDragItems.push(m)),n&&(n.style[P]=this._site.animationsDisabled?"":Q,n.style[O.scriptName]="translate("+-s+"px, -"+t+"px)",this._animatedDragItems.push(n))},dragLeave:function(){if(this._animatedDragItems)for(var a=0,b=this._animatedDragItems.length;b>a;a++)this._animatedDragItems[a].style[P]=this._site.animationsDisabled?"":Q,this._animatedDragItems[a].style[O.scriptName]="";this._animatedDragItems=[]},_setMaxRowsOrColumns:function(a){a===this._maxRowsOrColumns||this._inListMode||(this._sizes&&this._sizes.containerSizeLoaded&&(this._itemsPerBar=Math.floor(this._sizes.maxItemsContainerContentSize/this._sizes.containerCrossSize),a&&(this._itemsPerBar=Math.min(this._itemsPerBar,a)),this._itemsPerBar=Math.max(1,this._itemsPerBar)),this._maxRowsOrColumns=a,this._invalidateLayout())},_getItemPosition:function(a){if(this._groupsEnabled){var b=Math.min(this._groups.length-1,this._site.groupIndexFromItemIndex(a)),c=this._groups[b],d=a-c.startIndex;return this._getItemPositionForAnimations(a,b,d)}return this._getItemPositionForAnimations(a,0,a)},_getRealizationRange:function(){var a=this._site.realizedRange;return{firstIndex:this._firstItemFromRange(a.firstPixel),lastIndex:this._lastItemFromRange(a.lastPixel)}},_getVisibleRange:function(){var a=this._site.visibleRange;return{firstIndex:this._firstItemFromRange(a.firstPixel),lastIndex:this._lastItemFromRange(a.lastPixel)}},_resetAnimationCaches:function(a){if(!a){this._resetStylesForRecords(this._cachedGroupRecords),this._resetStylesForRecords(this._cachedItemRecords),this._resetStylesForRecords(this._cachedHeaderRecords),this._resetStylesForInsertedRecords(this._cachedInsertedItemRecords),this._resetStylesForInsertedRecords(this._cachedInsertedHeaderRecords),this._resetStylesForRemovedRecords(this._cachedRemovedItems),this._resetStylesForRemovedRecords(this._cachedRemovedHeaders);for(var b=Object.keys(this._animatingItemsBlocks),c=0,d=b.length;d>c;c++){var e=this._animatingItemsBlocks[b[c]];e.style.overflow="",e.classList.remove(p._clipClass)}}this._cachedGroupRecords={},this._cachedItemRecords={},this._cachedHeaderRecords={},this._cachedInsertedItemRecords={},this._cachedInsertedHeaderRecords={},this._cachedRemovedItems=[],this._cachedRemovedHeaders=[],this._animatingItemsBlocks={}},_cacheRemovedElements:function(a,b,c,d,e){var f="left";this._site.rtl&&(f="right");var g,h;e?(g=this._sizes.headerContainerOuterX,h=this._sizes.headerContainerOuterY):(g=this._sizes.containerMargins[f],h=this._sizes.containerMargins.top);for(var i=0,j=a.length;j>i;i++){var k=a[i];if(-1===k.newIndex){var l=k.element,m=b[k.oldIndex];m&&(m.element=l,delete b[k.oldIndex],l.style.position="absolute",l.style[P]="",l.style.top=m.oldTop-h+"px",l.style[f]=m.oldLeft-g+"px",l.style.width=m.width+"px",l.style.height=m.height+"px",l.style[O.scriptName]="",this._site.surface.appendChild(l),d.push(m)),c[k.oldIndex]&&delete c[k.oldIndex]}}},_cacheInsertedElements:function(a,b,c){for(var d={},e=0,f=a.length;f>e;e++){var g=a[e],h=b[g.oldIndex];if(h&&delete b[g.oldIndex],h||-1===g.oldIndex||g.moved){var i=c[g.newIndex];i&&delete c[g.newIndex];var j=g.element;d[g.newIndex]=j,j.style[P]="",j.style[O.scriptName]="",j.style.opacity=0}}for(var k=Object.keys(b),e=0,f=k.length;f>e;e++)d[k[e]]=b[k[e]];return d},_resetStylesForRecords:function(a){for(var b=Object.keys(a),c=0,d=b.length;d>c;c++){var e=a[b[c]];e.needsToResetTransform&&(e.element.style[O.scriptName]="",e.needsToResetTransform=!1)}},_resetStylesForInsertedRecords:function(a){for(var b=Object.keys(a),c=0,d=b.length;d>c;c++){var e=a[b[c]];e.style.opacity=1}},_resetStylesForRemovedRecords:function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b].element;d.parentNode&&(l._disposeElement(d),d.parentNode.removeChild(d))}},_updateAnimationCache:function(a,b){function c(a,b){for(var c={},e=0,f=a.length;f>e;e++){var g=a[e],h=b[g.oldIndex];h&&(c[g.newIndex]=h,h.element=g.element,delete b[g.oldIndex])}for(var i=Object.keys(b),e=0,f=i.length;f>e;e++){var j=i[e],k=b[j];(!k.element||d[I(k.element)])&&(c[j]=k)}return c}this._resetStylesForRecords(this._cachedItemRecords),this._resetStylesForRecords(this._cachedHeaderRecords),this._resetStylesForInsertedRecords(this._cachedInsertedItemRecords),this._resetStylesForInsertedRecords(this._cachedInsertedHeaderRecords);for(var d={},e=this._getRealizationRange(),f=this._site.tree,g=0,h=0,i=f.length;i>g;g++)A(f[g].itemsContainer,function(a){e.firstIndex<=h&&e.lastIndex>=h&&(d[I(a)]=!0),h++});this._cachedItemRecords=c(a,this._cachedItemRecords),this._cachedHeaderRecords=c(b,this._cachedHeaderRecords),this._cachedInsertedItemRecords=this._cacheInsertedElements(a,this._cachedInsertedItemRecords,this._cachedItemRecords),this._cachedInsertedHeaderRecords=this._cacheInsertedElements(b,this._cachedInsertedHeaderRecords,this._cachedHeaderRecords)},_filterRemovedElements:function(){function a(a,g){for(var h=0,i=a.length;i>h;h++){var j=a[h],k=j.element;j[c]+j[d]-1<e||j[c]>f||!b._site.viewport.contains(k)?k.parentNode&&(l._disposeElement(k),k.parentNode.removeChild(k)):g.push(k)}}if(this._removedElements=[],this._site.animationsDisabled)return this._resetStylesForRemovedRecords(this._cachedRemovedItems),void this._resetStylesForRemovedRecords(this._cachedRemovedHeaders);var b=this,c="horizontal"===this.orientation?"oldLeft":"oldTop",d="horizontal"===this.orientation?"width":"height",e=this._site.scrollbarPos,f=e+this._site.viewportSize[d]-1;a(this._cachedRemovedItems,this._removedElements),a(this._cachedRemovedHeaders,this._removedElements)},_filterInsertedElements:function(){function a(a,d){for(var e=Object.keys(a),f=0,g=e.length;g>f;f++){var h=e[f],i=a[h];h<c.firstIndex||h>c.lastIndex||b._site.viewport.contains(i.element)?i.style.opacity=1:d.push(i)}}if(this._insertedElements=[],this._site.animationsDisabled)return this._resetStylesForInsertedRecords(this._cachedInsertedItemRecords),void this._resetStylesForInsertedRecords(this._cachedInsertedHeaderRecords);var b=this,c=this._getVisibleRange();a(this._cachedInsertedItemRecords,this._insertedElements),a(this._cachedInsertedHeaderRecords,this._insertedElements)},_filterMovedElements:function(){var a=this,b="horizontal"===this.orientation?"oldLeft":"oldTop",c="horizontal"===this.orientation?"left":"top",d="horizontal"===this.orientation?"width":"height",e=this._getRealizationRange(),f=this._site.scrollbarPos,g=f+this._site.viewportSize[d]-1;if(this._itemMoveRecords=[],this._moveRecords=[],!this._site.animationsDisabled)for(var h=this._site.tree,i=0,j=0,k=h.length;k>j;j++){var l=h[j],m=!1;A(l.itemsContainer,function(){if(e.firstIndex<=i&&e.lastIndex>=i){var h=this._cachedItemRecords[i];if(h){var j=(h[b]+h[d]-1>=f&&h[b]<=g||h[c]+h[d]-1>=f&&h[c]<=g)&&a._site.viewport.contains(h.element);j&&(m=!0,h.needsToResetTransform&&(this._itemMoveRecords.push(h),delete this._cachedItemRecords[i]))}}i++}.bind(this));var n=j,o=this._cachedHeaderRecords[n];o&&m&&o.needsToResetTransform&&(this._moveRecords.push(o),delete this._cachedHeaderRecords[n]);var p=this._cachedGroupRecords[I(l.itemsContainer.element)];p&&m&&p.needsToResetTransform&&(this._moveRecords.push(p),delete this._cachedGroupRecords[I(l.itemsContainer.element)])}this._resetStylesForRecords(this._cachedGroupRecords),this._resetStylesForRecords(this._cachedItemRecords),this._resetStylesForRecords(this._cachedHeaderRecords)},_getItemPositionForAnimations:function(a,b,c){var d=this._groups[b],e=d.getItemPositionForAnimations(c),f=this._groups[b]?this._groups[b].offset:0,g=this._groupsEnabled&&this._groupHeaderPosition===U.left?this._sizes.headerContainerWidth:0,h=this._groupsEnabled&&this._groupHeaderPosition===U.top?this._sizes.headerContainerHeight:0;return e.left+=this._sizes.layoutOriginX+g+this._sizes.itemsContainerOuterX,e.top+=this._sizes.layoutOriginY+h+this._sizes.itemsContainerOuterY,e[this._horizontal?"left":"top"]+=f,e},_getHeaderPositionForAnimations:function(a){var b;if(this._groupsEnabled){var c=this._sizes.headerContainerWidth-this._sizes.headerContainerOuterWidth,d=this._sizes.headerContainerHeight-this._sizes.headerContainerOuterHeight;this._groupHeaderPosition!==U.left||this._horizontal?this._groupHeaderPosition===U.top&&this._horizontal&&(c=this._groups[a].getItemsContainerSize()-this._sizes.headerContainerOuterWidth):d=this._groups[a].getItemsContainerSize()-this._sizes.headerContainerOuterHeight;var e=this._horizontal?this._groups[a].offset:0,f=this._horizontal?0:this._groups[a].offset;b={top:this._sizes.layoutOriginY+f+this._sizes.headerContainerOuterY,left:this._sizes.layoutOriginX+e+this._sizes.headerContainerOuterX,height:d,width:c}}else b={top:0,left:0,height:0,width:0};return b},_rangeContainsItems:function(a,b){if(0===this._groups.length)return!1;var c=this._groups[this._groups.length-1],d=this._sizes.layoutOrigin+c.offset+this._getGroupSize(c)-1;return b>=0&&d>=a},_itemFromOffset:function(a,b){function c(a){if(!b.wholeItem){var c=e._horizontal?e._site.rtl?"right":"left":"top",d=e._horizontal?e._site.rtl?"left":"right":"bottom";return b.last?a-e._sizes.containerMargins[c]:a+e._sizes.containerMargins[d]}return a}function d(a){return b.last?a-e._getHeaderSizeGroupAdjustment()-e._sizes.itemsContainerOuterStart:a}var e=this;if(0===this._groups.length)return 0;b=b||{},a-=this._sizes.layoutOrigin,a=c(a);var f=this._groupFromOffset(d(a)),g=this._groups[f];return a-=g.offset,a-=this._getHeaderSizeGroupAdjustment(),g.startIndex+g.itemFromOffset(a,b)},_firstItemFromRange:function(a,b){return b=b||{},b.last=0,this._itemFromOffset(a,b)},_lastItemFromRange:function(a,b){return b=b||{},b.last=1,this._itemFromOffset(a,b)},_adjustedKeyForRTL:function(a){return this._site.rtl&&(a===H.leftArrow?a=H.rightArrow:a===H.rightArrow&&(a=H.leftArrow)),a},_adjustedKeyForOrientationAndBars:function(a,b){var c=a;if(b)return a;if(!this._horizontal)switch(c){case H.leftArrow:c=H.upArrow;break;case H.rightArrow:c=H.downArrow;break;case H.upArrow:c=H.leftArrow;break;case H.downArrow:c=H.rightArrow}return 1===this._itemsPerBar&&(c===H.upArrow?c=H.leftArrow:c===H.downArrow&&(c=H.rightArrow)),c},_getAdjacentForPageKeys:function(a,b){var c,d=this._sizes.containerMargins,e="horizontal"===this.orientation?d.left+d.right:d.top+d.bottom,f=this._site.viewportSize["horizontal"===this.orientation?"width":"height"],g=this._site.scrollbarPos,h=g+f-1-d["horizontal"===this.orientation?"right":"bottom"],i=this._firstItemFromRange(g,{wholeItem:!0}),j=this._lastItemFromRange(h,{wholeItem:!1}),k=this._getItemPosition(a.index),l=!1;if((a.index<i||a.index>j)&&(l=!0,g="horizontal"===this.orientation?k.left-e:k.top-e,h=g+f-1,i=this._firstItemFromRange(g,{wholeItem:!0}),j=this._lastItemFromRange(h,{wholeItem:!1})),b===H.pageUp){if(!l&&i!==a.index)return{type:o.ObjectType.item,index:i};var m;m="horizontal"===this.orientation?k.left+k.width+e+d.left:k.top+k.height+e+d.bottom;var n=this._firstItemFromRange(m-f,{wholeItem:!0});c=a.index===n?Math.max(0,a.index-this._itemsPerBar):n}else{if(!l&&j!==a.index)return{type:o.ObjectType.item,index:j};var p;p="horizontal"===this.orientation?k.left-e-d.right:k.top-e-d.bottom;var q=Math.max(0,this._lastItemFromRange(p+f-1,{wholeItem:!0}));c=a.index===q?a.index+this._itemsPerBar:q}return{type:o.ObjectType.item,index:c}},_isCellSpanning:function(a){var b=this._site.groupFromIndex(a),c=this._groupInfo;return c?!!("function"==typeof c?c(b):c).enableCellSpanning:!1},_getGroupInfo:function(a){var b=this._site.groupFromIndex(a),c=this._groupInfo,d=this._sizes.containerMargins,f={enableCellSpanning:!1};if(c="function"==typeof c?c(b):c){if(c.enableCellSpanning&&(+c.cellWidth!==c.cellWidth||+c.cellHeight!==c.cellHeight))throw new e("WinJS.UI.GridLayout.GroupInfoResultIsInvalid",J.groupInfoResultIsInvalid);f={enableCellSpanning:!!c.enableCellSpanning,cellWidth:c.cellWidth+d.left+d.right,cellHeight:c.cellHeight+d.top+d.bottom}}return f},_getItemInfo:function(a){var b;if(this._itemInfo&&"function"==typeof this._itemInfo)b=this._itemInfo(a);else{if(!this._useDefaultItemInfo)throw new e("WinJS.UI.GridLayout.ItemInfoIsInvalid",J.itemInfoIsInvalid);b=this._defaultItemInfo(a)}return i.as(b).then(function(a){if(!a||+a.width!==a.width||+a.height!==a.height)throw new e("WinJS.UI.GridLayout.ItemInfoIsInvalid",J.itemInfoIsInvalid);return a})},_defaultItemInfo:function(a){var b=this;return this._site.renderItem(this._site.itemFromIndex(a)).then(function(c){return b._elementsToMeasure[a]={element:c},b._measureElements()}).then(function(){var c=b._elementsToMeasure[a],d={width:c.width,height:c.height};return delete b._elementsToMeasure[a],d},function(c){return delete b._elementsToMeasure[a],i.wrapError(c)})},_getGroupSize:function(a){var b=0;return this._groupsEnabled&&(this._horizontal&&this._groupHeaderPosition===U.top?b=this._sizes.headerContainerMinWidth:this._horizontal||this._groupHeaderPosition!==U.left||(b=this._sizes.headerContainerMinHeight)),Math.max(b,a.getItemsContainerSize()+this._getHeaderSizeGroupAdjustment())},_groupFromOffset:function(a){return a<this._groups[0].offset?0:this._groupFrom(function(b){return a<b.offset})},_groupFromImpl:function(a,b,c){if(a>b)return null;var d=a+Math.floor((b-a)/2),e=this._groups[d];return c(e,d)?this._groupFromImpl(a,d-1,c):b>d&&!c(this._groups[d+1],d+1)?this._groupFromImpl(d+1,b,c):d},_groupFrom:function(a){if(this._groups.length>0){var b=this._groups.length-1,c=this._groups[b];return a(c,b)?this._groupFromImpl(0,this._groups.length-1,a):b}return null},_invalidateLayout:function(){this._site&&this._site.invalidateLayout()},_resetMeasurements:function(){this._measuringPromise&&(this._measuringPromise.cancel(),this._measuringPromise=null),this._containerSizeClassName&&(m.removeClass(this._site.surface,this._containerSizeClassName),u(this._containerSizeClassName),this._containerSizeClassName=null),this._sizes=null,this._resetAnimationCaches()},_measureElements:function(){if(!this._measuringElements){var a=this;a._measuringElements=j.schedulePromiseHigh(null,"WinJS.UI.GridLayout._measuringElements").then(function(){a._site._writeProfilerMark("_measureElements,StartTM");var c=a._createMeasuringSurface(),d=b.document.createElement("div"),e=a._site,f=a._measuringElements,g=a._elementsToMeasure,h=!1;d.className=p._itemsContainerClass+" "+p._laidOutClass,d.style.cssText+=";display: -ms-grid;-ms-grid-column: 1;-ms-grid-row: 1";var i,j,k=Object.keys(g);for(j=0,i=k.length;i>j;j++){var l=g[k[j]].element;l.style["-ms-grid-column"]=j+1,l.style["-ms-grid-row"]=j+1,d.appendChild(l)}for(c.appendChild(d),e.viewport.insertBefore(c,e.viewport.firstChild),f.then(null,function(){h=!0}),j=0,i=k.length;i>j&&!h;j++){var n=g[k[j]],o=n.element.querySelector("."+p._itemClass);n.width=m.getTotalWidth(o),n.height=m.getTotalHeight(o)}c.parentNode&&c.parentNode.removeChild(c),f===a._measuringElements&&(a._measuringElements=null),e._writeProfilerMark("_measureElements,StopTM")},function(b){return a._measuringElements=null,i.wrapError(b)})}return this._measuringElements},_ensureEnvInfo:function(){return this._envInfo||(this._envInfo=E(this._site),this._envInfo&&!this._envInfo.supportsCSSGrid&&m.addClass(this._site.surface,p._noCSSGrid)),!!this._envInfo},_createMeasuringSurface:function(){var a=b.document.createElement("div");return a.style.cssText="visibility: hidden;-ms-grid-columns: auto;-ms-grid-rows: auto;-ms-flex-align: start;-webkit-align-items: flex-start;align-items: flex-start",a.className=p._scrollableClass+" "+(this._inListMode?p._listLayoutClass:p._gridLayoutClass),this._envInfo.supportsCSSGrid||m.addClass(a,p._noCSSGrid),this._groupsEnabled&&(this._groupHeaderPosition===U.top?m.addClass(a,p._headerPositionTopClass):m.addClass(a,p._headerPositionLeftClass)),a},_measureItem:function(a){function c(a,e){var e,h=!!e,j={},k=f.rtl?"right":"left";return f.itemCount.then(function(b){return!b||d._groupsEnabled&&!f.groupCount?i.cancel:(e=e||f.itemFromIndex(a),j.container=f.renderItem(e),d._groupsEnabled&&(j.headerContainer=f.renderHeader(d._site.groupFromIndex(f.groupIndexFromItemIndex(a)))),i.join(j))}).then(function(j){function l(){var a=d._horizontal,b=d._groupsEnabled,c=!1;g.then(null,function(){c=!0});var e=G(C),h=f.rtl?f.viewport.offsetWidth-(C.offsetLeft+C.offsetWidth):C.offsetLeft,i=C.offsetTop,l={viewportContentSize:0,surfaceContentSize:0,maxItemsContainerContentSize:0,surfaceOuterHeight:y(o),surfaceOuterWidth:z(o),layoutOriginX:h-e[k],layoutOriginY:i-e.top,itemsContainerOuterHeight:y(q),itemsContainerOuterWidth:z(q),itemsContainerOuterX:x(f.rtl?"Right":"Left",q),itemsContainerOuterY:x("Top",q),itemsContainerMargins:G(q),itemBoxOuterHeight:y(s),itemBoxOuterWidth:z(s),containerOuterHeight:y(j.container),containerOuterWidth:z(j.container),emptyContainerContentHeight:m.getContentHeight(r),emptyContainerContentWidth:m.getContentWidth(r),containerMargins:G(j.container),containerWidth:0,containerHeight:0,containerSizeLoaded:!1};b&&(l.headerContainerOuterX=x(f.rtl?"Right":"Left",j.headerContainer),l.headerContainerOuterY=x("Top",j.headerContainer),l.headerContainerOuterWidth=z(j.headerContainer),l.headerContainerOuterHeight=y(j.headerContainer),l.headerContainerWidth=m.getTotalWidth(j.headerContainer),l.headerContainerHeight=m.getTotalHeight(j.headerContainer),l.headerContainerMinWidth=w(j.headerContainer,"minWidth")+l.headerContainerOuterWidth,l.headerContainerMinHeight=w(j.headerContainer,"minHeight")+l.headerContainerOuterHeight);var n={sizes:l,viewportContentWidth:m.getContentWidth(f.viewport),viewportContentHeight:m.getContentHeight(f.viewport),containerContentWidth:m.getContentWidth(j.container),containerContentHeight:m.getContentHeight(j.container),containerWidth:m.getTotalWidth(j.container),containerHeight:m.getTotalHeight(j.container)};return n.viewportCrossSize=n[a?"viewportContentHeight":"viewportContentWidth"],f.readyToMeasure(),c?null:n}function n(){o.parentNode&&o.parentNode.removeChild(o)}var o=d._createMeasuringSurface(),q=b.document.createElement("div"),r=b.document.createElement("div"),s=j.container.querySelector("."+p._itemBoxClass),t=f.groupIndexFromItemIndex(a);r.className=p._containerClass,q.className=p._itemsContainerClass+" "+p._laidOutClass;var u=1,v=1,A=2,B=2,C=q,D=!1;d._inListMode&&d._groupsEnabled&&(d._horizontal&&d._groupHeaderPosition===U.top?(u=2,B=1,A=1,C=j.headerContainer,D=!0):d._horizontal||d._groupHeaderPosition!==U.left||(v=2,B=1,A=1,C=j.headerContainer,D=!0)),q.style.cssText+=";display: "+(d._inListMode?(d._horizontal?"flex":"block")+"; overflow: hidden":"inline-block")+";vertical-align:top;-ms-grid-column: "+v+";-ms-grid-row: "+u,d._inListMode||(j.container.style.display="inline-block"),d._groupsEnabled&&(j.headerContainer.style.cssText+=";display: inline-block;-ms-grid-column: "+B+";-ms-grid-row: "+A,m.addClass(j.headerContainer,p._laidOutClass+" "+p._groupLeaderClass),(d._groupHeaderPosition===U.top&&d._horizontal||d._groupHeaderPosition===U.left&&!d._horizontal)&&m.addClass(q,p._groupLeaderClass)),D&&o.appendChild(j.headerContainer),q.appendChild(j.container),q.appendChild(r),o.appendChild(q),!D&&d._groupsEnabled&&o.appendChild(j.headerContainer),f.viewport.insertBefore(o,f.viewport.firstChild);var E=l();if(!E)return n(),i.cancel;if(d._horizontal&&0===E.viewportContentHeight||!d._horizontal&&0===E.viewportContentWidth)return n(),i.cancel;if(!(h||d._isCellSpanning(t)||0!==E.containerContentWidth&&0!==E.containerContentHeight))return n(),e.then(function(){return c(a,e)});var F=d._sizes=E.sizes;if(Object.defineProperties(F,{surfaceOuterCrossSize:{get:function(){return d._horizontal?F.surfaceOuterHeight:F.surfaceOuterWidth},enumerable:!0},layoutOrigin:{get:function(){return d._horizontal?F.layoutOriginX:F.layoutOriginY},enumerable:!0},itemsContainerOuterSize:{get:function(){return d._horizontal?F.itemsContainerOuterWidth:F.itemsContainerOuterHeight},enumerable:!0},itemsContainerOuterCrossSize:{get:function(){return d._horizontal?F.itemsContainerOuterHeight:F.itemsContainerOuterWidth},enumerable:!0},itemsContainerOuterStart:{get:function(){return d._horizontal?F.itemsContainerOuterX:F.itemsContainerOuterY},enumerable:!0},itemsContainerOuterCrossStart:{get:function(){return d._horizontal?F.itemsContainerOuterY:F.itemsContainerOuterX},enumerable:!0},containerCrossSize:{get:function(){return d._horizontal?F.containerHeight:F.containerWidth},enumerable:!0},containerSize:{get:function(){return d._horizontal?F.containerWidth:F.containerHeight},enumerable:!0}}),!d._isCellSpanning(t)){if(d._inListMode){var H=E.viewportCrossSize-F.surfaceOuterCrossSize-d._getHeaderSizeContentAdjustment()-F.itemsContainerOuterCrossSize;d._horizontal?(F.containerHeight=H,F.containerWidth=E.containerWidth):(F.containerHeight=E.containerHeight,F.containerWidth=H)}else F.containerWidth=E.containerWidth,F.containerHeight=E.containerHeight;F.containerSizeLoaded=!0}d._createContainerStyleRule(),d._viewportSizeChanged(E.viewportCrossSize),n()})}var d=this,e="Layout:measureItem",f=d._site,g=d._measuringPromise;if(!g){f._writeProfilerMark(e+",StartTM");var h=new k;d._measuringPromise=g=h.promise.then(function(){return d._ensureEnvInfo()?c(a):i.cancel}).then(function(){f._writeProfilerMark(e+":complete,info"),f._writeProfilerMark(e+",StopTM")},function(a){return d._measuringPromise=null,f._writeProfilerMark(e+":canceled,info"),f._writeProfilerMark(e+",StopTM"),i.wrapError(a)}),h.complete()}return g},_getHeaderSizeGroupAdjustment:function(){if(this._groupsEnabled){if(this._horizontal&&this._groupHeaderPosition===U.left)return this._sizes.headerContainerWidth;if(!this._horizontal&&this._groupHeaderPosition===U.top)return this._sizes.headerContainerHeight}return 0},_getHeaderSizeContentAdjustment:function(){if(this._groupsEnabled){if(this._horizontal&&this._groupHeaderPosition===U.top)return this._sizes.headerContainerHeight;if(!this._horizontal&&this._groupHeaderPosition===U.left)return this._sizes.headerContainerWidth}return 0},_getViewportCrossSize:function(){return this._site.viewportSize[this._horizontal?"height":"width"]},_viewportSizeChanged:function(a){var b=this._sizes;b.viewportContentSize=a,b.surfaceContentSize=a-b.surfaceOuterCrossSize,b.maxItemsContainerContentSize=b.surfaceContentSize-b.itemsContainerOuterCrossSize-this._getHeaderSizeContentAdjustment(),b.containerSizeLoaded&&!this._inListMode?(this._itemsPerBar=Math.floor(b.maxItemsContainerContentSize/b.containerCrossSize),this.maximumRowsOrColumns&&(this._itemsPerBar=Math.min(this._itemsPerBar,this.maximumRowsOrColumns)),this._itemsPerBar=Math.max(1,this._itemsPerBar)):(this._inListMode&&(b[this._horizontal?"containerHeight":"containerWidth"]=b.maxItemsContainerContentSize),this._itemsPerBar=1),this._resetAnimationCaches()},_createContainerStyleRule:function(){var a=this._sizes;if(!this._containerSizeClassName&&a.containerSizeLoaded&&(0===a.emptyContainerContentHeight||0===a.emptyContainerContentWidth)){var b=a.containerWidth-a.containerOuterWidth+"px",c=a.containerHeight-a.containerOuterHeight+"px";this._inListMode&&(this._horizontal?c="calc(100% - "+(a.containerMargins.top+a.containerMargins.bottom)+"px)":b="auto"),this._containerSizeClassName||(this._containerSizeClassName=r("containersize"),m.addClass(this._site.surface,this._containerSizeClassName));var d="."+p._containerClass,e="width:"+b+";height:"+c+";";t(this._containerSizeClassName,this._site,d,e)}},_ensureContainerSize:function(a){var b=this._sizes;if(b.containerSizeLoaded||this._ensuringContainerSize)return this._ensuringContainerSize?this._ensuringContainerSize:i.wrap();var c;if(this._itemInfo&&"function"==typeof this._itemInfo||!this._useDefaultItemInfo)c=this._getItemInfo();else{var d=b.containerMargins;c=i.wrap({width:a.groupInfo.cellWidth-d.left-d.right,height:a.groupInfo.cellHeight-d.top-d.bottom})}var e=this;return this._ensuringContainerSize=c.then(function(a){b.containerSizeLoaded=!0,b.containerWidth=a.width+b.itemBoxOuterWidth+b.containerOuterWidth,b.containerHeight=a.height+b.itemBoxOuterHeight+b.containerOuterHeight,e._inListMode?e._itemsPerBar=1:(e._itemsPerBar=Math.floor(b.maxItemsContainerContentSize/b.containerCrossSize),e.maximumRowsOrColumns&&(e._itemsPerBar=Math.min(e._itemsPerBar,e.maximumRowsOrColumns)),e._itemsPerBar=Math.max(1,e._itemsPerBar)),e._createContainerStyleRule()}),c.done(function(){e._ensuringContainerSize=null},function(){e._ensuringContainerSize=null}),c},_indexToCoordinate:function(a,b){b=b||this._itemsPerBar;var c=Math.floor(a/b);return this._horizontal?{column:c,row:a-c*b}:{row:c,column:a-c*b}},_rangeForGroup:function(a,b){var c=a.startIndex,d=c+a.count-1;return!b||b.firstIndex>d||b.lastIndex<c?null:{firstIndex:Math.max(0,b.firstIndex-c),lastIndex:Math.min(a.count-1,b.lastIndex-c)}},_syncDomWithGroupHeaderPosition:function(a){if(this._groupsEnabled&&this._oldGroupHeaderPosition!==this._groupHeaderPosition){var b,c=a.length;if(this._oldGroupHeaderPosition===U.top)if(m.removeClass(this._site.surface,p._headerPositionTopClass),this._horizontal)for(b=0;c>b;b++)a[b].header.style.maxWidth="",m.removeClass(a[b].itemsContainer.element,p._groupLeaderClass);else this._site.surface.style.msGridRows="";else if(this._oldGroupHeaderPosition===U.left){if(m.removeClass(this._site.surface,p._headerPositionLeftClass),!this._horizontal)for(b=0;c>b;b++)a[b].header.style.maxHeight="",m.removeClass(a[b].itemsContainer.element,p._groupLeaderClass);this._site.surface.style.msGridColumns=""}if(this._groupHeaderPosition===U.top){if(m.addClass(this._site.surface,p._headerPositionTopClass),this._horizontal)for(b=0;c>b;b++)m.addClass(a[b].itemsContainer.element,p._groupLeaderClass)}else if(m.addClass(this._site.surface,p._headerPositionLeftClass),!this._horizontal)for(b=0;c>b;b++)m.addClass(a[b].itemsContainer.element,p._groupLeaderClass);this._oldGroupHeaderPosition=this._groupHeaderPosition}},_layoutGroup:function(a){var b=this._groups[a],c=this._site.tree[a],d=c.header,e=c.itemsContainer.element,f=this._sizes,g=b.getItemsContainerCrossSize();if(this._groupsEnabled){if(this._horizontal)if(this._groupHeaderPosition===U.top){var h=f.headerContainerMinWidth-f.headerContainerOuterWidth,i=b.getItemsContainerSize()-f.headerContainerOuterWidth;d.style.maxWidth=Math.max(h,i)+"px",this._envInfo.supportsCSSGrid?(d.style.msGridColumn=a+1,e.style.msGridColumn=a+1):(d.style.height=f.headerContainerHeight-f.headerContainerOuterHeight+"px",e.style.height=g-f.itemsContainerOuterHeight+"px",e.style.marginBottom=f.itemsContainerMargins.bottom+(f.maxItemsContainerContentSize-g+f.itemsContainerOuterHeight)+"px"),m.addClass(e,p._groupLeaderClass)}else this._envInfo.supportsCSSGrid?(d.style.msGridColumn=2*a+1,e.style.msGridColumn=2*a+2):(d.style.width=f.headerContainerWidth-f.headerContainerOuterWidth+"px",d.style.height=g-f.headerContainerOuterHeight+"px",e.style.height=g-f.itemsContainerOuterHeight+"px");else if(this._groupHeaderPosition===U.left){var j=f.headerContainerMinHeight-f.headerContainerOuterHeight,k=b.getItemsContainerSize()-f.headerContainerOuterHeight;d.style.maxHeight=Math.max(j,k)+"px",this._envInfo.supportsCSSGrid?(d.style.msGridRow=a+1,e.style.msGridRow=a+1):(d.style.width=f.headerContainerWidth-f.headerContainerOuterWidth+"px",e.style.width=g-f.itemsContainerOuterWidth+"px",e.style["margin"+(this._site.rtl?"Left":"Right")]=f.itemsContainerMargins[this._site.rtl?"left":"right"]+(f.maxItemsContainerContentSize-g+f.itemsContainerOuterWidth)+"px"),m.addClass(e,p._groupLeaderClass)}else d.style.msGridRow=2*a+1,this._inListMode?d.style.height=f.headerContainerHeight-f.headerContainerOuterHeight+"px":this._envInfo.supportsCSSGrid?e.style.msGridRow=2*a+2:(d.style.height=f.headerContainerHeight-f.headerContainerOuterHeight+"px",d.style.width=g-f.headerContainerOuterWidth+"px",e.style.width=g-f.itemsContainerOuterWidth+"px");m.addClass(d,p._laidOutClass+" "+p._groupLeaderClass)}m.addClass(e,p._laidOutClass)}},{_barsPerItemsBlock:4})}),_LegacyLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LayoutCommon,null,{disableBackdrop:{get:function(){return this._backdropDisabled||!1},set:function(a){if(m._deprecated(q.disableBackdropIsDeprecated),a=!!a,this._backdropDisabled!==a&&(this._backdropDisabled=a,this._disableBackdropClassName&&(u(this._disableBackdropClassName),this._site&&m.removeClass(this._site.surface,this._disableBackdropClassName),this._disableBackdropClassName=null),this._disableBackdropClassName=r("disablebackdrop"),this._site&&m.addClass(this._site.surface,this._disableBackdropClassName),a)){var b=".win-container.win-backdrop",c="background-color:transparent;";t(this._disableBackdropClassName,this._site,b,c)}}},backdropColor:{get:function(){return this._backdropColor||"rgba(155,155,155,0.23)"},set:function(a){if(m._deprecated(q.backdropColorIsDeprecated),a&&this._backdropColor!==a){this._backdropColor=a,this._backdropColorClassName&&(u(this._backdropColorClassName),this._site&&m.removeClass(this._site.surface,this._backdropColorClassName),this._backdropColorClassName=null),this._backdropColorClassName=r("backdropcolor"),this._site&&m.addClass(this._site.surface,this._backdropColorClassName);var b=".win-container.win-backdrop",c="background-color:"+a+";";t(this._backdropColorClassName,this._site,b,c)}}}})}),GridLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LegacyLayout,function(a){a=a||{},this.itemInfo=a.itemInfo,this.groupInfo=a.groupInfo,this._maxRowsOrColumns=0,this._useDefaultItemInfo=!0,this._elementsToMeasure={},this._groupHeaderPosition=a.groupHeaderPosition||U.top,this.orientation=a.orientation||"horizontal",a.maxRows&&(this.maxRows=+a.maxRows),a.maximumRowsOrColumns&&(this.maximumRowsOrColumns=+a.maximumRowsOrColumns)},{maximumRowsOrColumns:{get:function(){return this._maxRowsOrColumns},set:function(a){this._setMaxRowsOrColumns(a)}},maxRows:{get:function(){return this.maximumRowsOrColumns},set:function(a){m._deprecated(q.maxRowsIsDeprecated),this.maximumRowsOrColumns=a}},itemInfo:{enumerable:!0,get:function(){return this._itemInfo},set:function(a){a&&m._deprecated(q.itemInfoIsDeprecated),this._itemInfo=a,this._invalidateLayout()}},groupInfo:{enumerable:!0,get:function(){return this._groupInfo},set:function(a){a&&m._deprecated(q.groupInfoIsDeprecated),this._groupInfo=a,this._invalidateLayout()}}})})});var T=c.Namespace.defineWithParent(null,null,{UniformGroupBase:c.Namespace._lazy(function(){return c.Class.define(null,{cleanUp:function(){},itemFromOffset:function(a,b){b=b||{};var c=this._layout._sizes;a-=c.itemsContainerOuterStart,b.wholeItem&&(a+=(b.last?-1:1)*(c.containerSize-1));var d=this.count-1,e=Math.floor(d/this._layout._itemsPerBar),f=v(0,e,Math.floor(a/c.containerSize)),g=(f+b.last)*this._layout._itemsPerBar-b.last;return v(0,this.count-1,g)},hitTest:function(a,b){var c=this._layout._horizontal,d=this._layout._itemsPerBar,e=this._layout._inListMode||1===d,f=c?a:b,g=c?b:a,h=this._layout._sizes;f-=h.itemsContainerOuterStart,g-=h.itemsContainerOuterCrossStart;var i,j=Math.floor(f/h.containerSize),k=v(0,d-1,Math.floor(g/h.containerCrossSize)),l=Math.max(-1,j*d+k);if(i=!c&&e||c&&!e?(b-h.containerHeight/2)/h.containerHeight:(a-h.containerWidth/2)/h.containerWidth,e)return i=Math.floor(i),{index:l,insertAfterIndex:i>=0&&l>=0?i:-1};
  i=v(-1,d-1,i);var m;return m=0>i?j*d-1:j*d+Math.floor(i),{index:v(-1,this.count-1,l),insertAfterIndex:v(-1,this.count-1,m)}},getAdjacent:function(a,b){var c,d=a.index,e=Math.floor(d/this._layout._itemsPerBar),f=d%this._layout._itemsPerBar;switch(b){case H.upArrow:c=0===f?"boundary":d-1;break;case H.downArrow:var g=d===this.count-1,h=this._layout._itemsPerBar>1&&f===this._layout._itemsPerBar-1;c=g||h?"boundary":d+1;break;case H.leftArrow:c=0===e&&this._layout._itemsPerBar>1?"boundary":d-this._layout._itemsPerBar;break;case H.rightArrow:var i=this.count-1,j=Math.floor(i/this._layout._itemsPerBar);c=e===j?"boundary":Math.min(d+this._layout._itemsPerBar,this.count-1)}return"boundary"===c?c:{type:o.ObjectType.item,index:c}},getItemsContainerSize:function(){var a=this._layout._sizes,b=Math.ceil(this.count/this._layout._itemsPerBar);return b*a.containerSize+a.itemsContainerOuterSize},getItemsContainerCrossSize:function(){var a=this._layout._sizes;return this._layout._itemsPerBar*a.containerCrossSize+a.itemsContainerOuterCrossSize},getItemPositionForAnimations:function(a){var b=this._layout._sizes,c=this._layout._site.rtl?"right":"left",d=this._layout._sizes.containerMargins,e=this._layout._indexToCoordinate(a),f={row:e.row,column:e.column,top:d.top+e.row*b.containerHeight,left:d[c]+e.column*b.containerWidth,height:b.containerHeight-b.containerMargins.top-b.containerMargins.bottom,width:b.containerWidth-b.containerMargins.left-b.containerMargins.right};return f}})}),UniformGroup:c.Namespace._lazy(function(){return c.Class.derive(T.UniformGroupBase,function(a,b){this._layout=a,this._itemsContainer=b,m.addClass(this._itemsContainer,a._inListMode?p._uniformListLayoutClass:p._uniformGridLayoutClass)},{cleanUp:function(a){a||(m.removeClass(this._itemsContainer,p._uniformGridLayoutClass),m.removeClass(this._itemsContainer,p._uniformListLayoutClass),this._itemsContainer.style.height=this._itemsContainer.style.width=""),this._itemsContainer=null,this._layout=null,this.groupInfo=null,this.startIndex=null,this.offset=null,this.count=null},prepareLayout:function(a,b,c,d){return this.groupInfo=d.groupInfo,this.startIndex=d.startIndex,this.count=a,this._layout._ensureContainerSize(this)},layoutRealizedRange:function(){var a=this._layout._sizes;this._itemsContainer.style[this._layout._horizontal?"width":"height"]=this.getItemsContainerSize()-a.itemsContainerOuterSize+"px",this._itemsContainer.style[this._layout._horizontal?"height":"width"]=this._layout._inListMode?a.maxItemsContainerContentSize+"px":this._layout._itemsPerBar*a.containerCrossSize+"px"},layoutUnrealizedRange:function(){return i.wrap()}})}),UniformFlowGroup:c.Namespace._lazy(function(){return c.Class.derive(T.UniformGroupBase,function(a,b){this._layout=a,this._itemsContainer=b.element,m.addClass(this._itemsContainer,a._inListMode?p._uniformListLayoutClass:p._uniformGridLayoutClass)},{cleanUp:function(a){a||(m.removeClass(this._itemsContainer,p._uniformListLayoutClass),m.removeClass(this._itemsContainer,p._uniformGridLayoutClass),this._itemsContainer.style.height="")},layout:function(){this._layout._site._writeProfilerMark("Layout:_UniformFlowGroup:setItemsContainerHeight,info"),this._itemsContainer.style.height=this.count*this._layout._sizes.containerHeight+"px"}})}),CellSpanningGroup:c.Namespace._lazy(function(){return c.Class.define(function(a,b){this._layout=a,this._itemsContainer=b,m.addClass(this._itemsContainer,p._cellSpanningGridLayoutClass),this.resetMap()},{cleanUp:function(a){a||(this._cleanContainers(),m.removeClass(this._itemsContainer,p._cellSpanningGridLayoutClass),this._itemsContainer.style.cssText=""),this._itemsContainer=null,this._layoutPromise&&(this._layoutPromise.cancel(),this._layoutPromise=null),this.resetMap(),this._slotsPerColumn=null,this._offScreenSlotsPerColumn=null,this._items=null,this._layout=null,this._containersToHide=null,this.groupInfo=null,this.startIndex=null,this.offset=null,this.count=null},prepareLayoutWithCopyOfTree:function(a,b,c,d){var e,f=this;if(this._containersToHide={},b)for(e=b.firstIndex;e<=b.lastIndex;e++)this._containersToHide[I(c._items[e])]=c._items[e];this.groupInfo=d.groupInfo,this.startIndex=d.startIndex,this.count=a.items.length,this._items=a.items,this._slotsPerColumn=Math.floor(this._layout._sizes.maxItemsContainerContentSize/this.groupInfo.cellHeight),this._layout.maximumRowsOrColumns&&(this._slotsPerColumn=Math.min(this._slotsPerColumn,this._layout.maximumRowsOrColumns)),this._slotsPerColumn=Math.max(this._slotsPerColumn,1),this.resetMap();var g=new Array(this.count);for(e=0;e<this.count;e++)g[e]=this._layout._getItemInfo(this.startIndex+e);return i.join(g).then(function(a){a.forEach(function(a,b){f.addItemToMap(b,a)})})},layoutRealizedRange:function(a,b){if(b){var c,d=Math.max(a,b.firstIndex);for(c=d;c<=b.lastIndex;c++)this._layoutItem(c),delete this._containersToHide[I(this._items[c])]}Object.keys(this._containersToHide).forEach(function(a){m.removeClass(this._containersToHide[a],p._laidOutClass)}.bind(this)),this._containersToHide={},this._itemsContainer.style.cssText+=";width:"+(this.getItemsContainerSize()-this._layout._sizes.itemsContainerOuterSize)+"px;height:"+this._layout._sizes.maxItemsContainerContentSize+"px;-ms-grid-columns: ("+this.groupInfo.cellWidth+"px)["+this.getColumnCount()+"];-ms-grid-rows: ("+this.groupInfo.cellHeight+"px)["+(this._slotsPerColumn+this._offScreenSlotsPerColumn)+"]"},layoutUnrealizedRange:function(a,b,c){var d,e=this;return e._layoutPromise=new i(function(f){function g(){d=null,f()}function h(a){return j.schedule(a,j.Priority.normal,null,"WinJS.UI.GridLayout.CellSpanningGroup.LayoutUnrealizedRange")}if(b){var i=!1,k=b.firstIndex-1,l=Math.max(a,b.lastIndex+1);l=Math.max(k+1,l),d=h(function n(b){for(;!i;){if(b.shouldYield)return void b.setWork(n);i=!0,k>=a&&(e._layoutItem(k),k--,i=!1),l<e.count&&(e._layoutItem(l),l++,i=!1)}g()})}else if(c){var m=e.count-1;d=h(function o(b){for(;m>=a;m--){if(b.shouldYield)return void b.setWork(o);e._layoutItem(m)}g()})}else{var m=a;d=h(function p(a){for(;m<e.count;m++){if(a.shouldYield)return void a.setWork(p);e._layoutItem(m)}g()})}},function(){d&&d.cancel(),d=null}),e._layoutPromise},itemFromOffset:function(a,b){b=b||{};var c=this._layout._sizes,d=c.containerMargins;a-=c.itemsContainerOuterX,a-=(b.last?1:-1)*d[b.last?"left":"right"];var e=this.indexFromOffset(a,b.wholeItem,b.last).item;return v(0,this.count-1,e)},getAdjacent:function(a,b){var c,d;c=d=a.index;var e,f,g;g=this.lastAdjacent===c?this.lastInMapIndex:this.findItem(c);do{var h=Math.floor(g/this._slotsPerColumn),i=g-h*this._slotsPerColumn,j=Math.floor((this.occupancyMap.length-1)/this._slotsPerColumn);switch(b){case H.upArrow:if(!(i>0))return{type:o.ObjectType.item,index:d};g--;break;case H.downArrow:if(!(i+1<this._slotsPerColumn))return{type:o.ObjectType.item,index:d};g++;break;case H.leftArrow:g=h>0?g-this._slotsPerColumn:-1;break;case H.rightArrow:g=j>h?g+this._slotsPerColumn:this.occupancyMap.length}f=g>=0&&g<this.occupancyMap.length,f&&(e=this.occupancyMap[g]?this.occupancyMap[g].index:void 0)}while(f&&(c===e||void 0===e));return this.lastAdjacent=e,this.lastInMapIndex=g,f?{type:o.ObjectType.item,index:e}:"boundary"},hitTest:function(a,b){var c=this._layout._sizes,d=0;if(a-=c.itemsContainerOuterX,b-=c.itemsContainerOuterY,this.occupancyMap.length>0){for(var e=this.indexFromOffset(a,!1,0),f=Math.min(this._slotsPerColumn-1,Math.floor(b/this.groupInfo.cellHeight)),g=e.index,h=g;f-->0;)g++,this.occupancyMap[g]&&(h=g);this.occupancyMap[h]||h--,d=this.occupancyMap[h].index}var i=this.getItemSize(d),j=i.column*this.groupInfo.cellWidth,k=i.row*this.groupInfo.cellHeight,l=1===this._slotsPerColumn,m=d;return(l&&a<j+i.contentWidth/2||!l&&b<k+i.contentHeight/2)&&m--,{type:o.ObjectType.item,index:v(0,this.count-1,d),insertAfterIndex:v(-1,this.count-1,m)}},getItemsContainerSize:function(){var a=this._layout._sizes;return this.getColumnCount()*this.groupInfo.cellWidth+a.itemsContainerOuterSize},getItemsContainerCrossSize:function(){var a=this._layout._sizes;return a.maxItemsContainerContentSize+a.itemsContainerOuterCrossSize},getItemPositionForAnimations:function(a){var b=this._layout._site.rtl?"right":"left",c=this._layout._sizes.containerMargins,d=this.getItemSize(a),e=this.groupInfo,f={row:d.row,column:d.column,top:c.top+d.row*e.cellHeight,left:c[b]+d.column*e.cellWidth,height:d.contentHeight,width:d.contentWidth};return f},_layoutItem:function(a){var b=this.getItemSize(a);return this._items[a].style.cssText+=";-ms-grid-row:"+(b.row+1)+";-ms-grid-column:"+(b.column+1)+";-ms-grid-row-span:"+b.rows+";-ms-grid-column-span:"+b.columns+";height:"+b.contentHeight+"px;width:"+b.contentWidth+"px",m.addClass(this._items[a],p._laidOutClass),this._items[a]},_cleanContainers:function(){var a,b=this._items,c=b.length;for(a=0;c>a;a++)b[a].style.cssText="",m.removeClass(b[a],p._laidOutClass)},getColumnCount:function(){return Math.ceil(this.occupancyMap.length/this._slotsPerColumn)},getOccupancyMapItemCount:function(){var a=-1;return this.occupancyMap.forEach(function(b){b.index>a&&(a=b.index)}),a+1},coordinateToIndex:function(a,b){return a*this._slotsPerColumn+b},markSlotAsFull:function(a,b){for(var c=this._layout._indexToCoordinate(a,this._slotsPerColumn),d=c.row+b.rows,e=c.row;d>e&&e<this._slotsPerColumn;e++)for(var f=c.column,g=c.column+b.columns;g>f;f++)this.occupancyMap[this.coordinateToIndex(f,e)]=b;this._offScreenSlotsPerColumn=Math.max(this._offScreenSlotsPerColumn,d-this._slotsPerColumn)},isSlotEmpty:function(a,b,c){for(var d=b,e=b+a.rows;e>d;d++)for(var f=c,g=c+a.columns;g>f;f++)if(d>=this._slotsPerColumn||void 0!==this.occupancyMap[this.coordinateToIndex(f,d)])return!1;return!0},findEmptySlot:function(a,b,c){var d=this._layout._indexToCoordinate(a,this._slotsPerColumn),e=d.row,f=Math.floor((this.occupancyMap.length-1)/this._slotsPerColumn);if(c){for(var g=d.column+1;f>=g;g++)if(this.isSlotEmpty(b,0,g))return this.coordinateToIndex(g,0)}else for(var g=d.column;f>=g;g++){for(var h=e;h<this._slotsPerColumn;h++)if(this.isSlotEmpty(b,h,g))return this.coordinateToIndex(g,h);e=0}return(f+1)*this._slotsPerColumn},findItem:function(a){for(var b=a,c=this.occupancyMap.length;c>b;b++){var d=this.occupancyMap[b];if(d&&d.index===a)return b}return b},getItemSize:function(a){var b=this.findItem(a),c=this.occupancyMap[b],d=this._layout._indexToCoordinate(b,this._slotsPerColumn);return a===c.index?{row:d.row,column:d.column,contentWidth:c.contentWidth,contentHeight:c.contentHeight,columns:c.columns,rows:c.rows}:null},resetMap:function(){this.occupancyMap=[],this.lastAdded=0,this._offScreenSlotsPerColumn=0},addItemToMap:function(a,b){function c(a,b){var c=d.findEmptySlot(d.lastAdded,a,b);d.lastAdded=c,d.markSlotAsFull(c,a)}var d=this,e=d.groupInfo,f=d._layout._sizes.containerMargins,g={index:a,contentWidth:b.width,contentHeight:b.height,columns:Math.max(1,Math.ceil((b.width+f.left+f.right)/e.cellWidth)),rows:Math.max(1,Math.ceil((b.height+f.top+f.bottom)/e.cellHeight))};c(g,b.newColumn)},indexFromOffset:function(a,b,c){var d=0,e=0,f=this.groupInfo,g=0;if(this.occupancyMap.length>0){if(e=this.getOccupancyMapItemCount()-1,d=Math.ceil((this.occupancyMap.length-1)/this._slotsPerColumn)*f.cellWidth,d>a){for(var h=this._slotsPerColumn,g=(Math.max(0,Math.floor(a/f.cellWidth))+c)*this._slotsPerColumn-c;!this.occupancyMap[g]&&h-->0;)g+=c>0?-1:1;return{index:g,item:this.occupancyMap[g].index}}g=this.occupancyMap.length-1}return{index:g,item:e+(Math.max(0,Math.floor((a-d)/f.cellWidth))+c)*this._slotsPerColumn-c}}})})});c.Namespace._moduleDefine(a,"WinJS.UI",{ListLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LegacyLayout,function(a){a=a||{},this._itemInfo={},this._groupInfo={},this._groupHeaderPosition=a.groupHeaderPosition||U.top,this._inListMode=!0,this.orientation=a.orientation||"vertical"},{initialize:function(b,c){m.addClass(b.surface,p._listLayoutClass),a._LegacyLayout.prototype.initialize.call(this,b,c)},uninitialize:function(){this._site&&m.removeClass(this._site.surface,p._listLayoutClass),a._LegacyLayout.prototype.uninitialize.call(this)},layout:function(b,c,d,e){return this._groupsEnabled||this._horizontal?a._LegacyLayout.prototype.layout.call(this,b,c,d,e):this._layoutNonGroupedVerticalList(b,c,d,e)},_layoutNonGroupedVerticalList:function(a,b,c,d){var e=this,f="Layout:_layoutNonGroupedVerticalList";return e._site._writeProfilerMark(f+",StartTM"),this._layoutPromise=e._measureItem(0).then(function(){m[e._usingStructuralNodes?"addClass":"removeClass"](e._site.surface,p._structuralNodesClass),e._sizes.viewportContentSize!==e._getViewportCrossSize()&&e._viewportSizeChanged(e._getViewportCrossSize()),e._cacheRemovedElements(c,e._cachedItemRecords,e._cachedInsertedItemRecords,e._cachedRemovedItems,!1),e._cacheRemovedElements(d,e._cachedHeaderRecords,e._cachedInsertedHeaderRecords,e._cachedRemovedHeaders,!0);var b=a[0].itemsContainer,g=new T.UniformFlowGroup(e,b);e._groups=[g],g.groupInfo={enableCellSpanning:!1},g.startIndex=0,g.count=D(b),g.offset=0,g.layout(),e._site._writeProfilerMark(f+":setSurfaceWidth,info"),e._site.surface.style.width=e._sizes.surfaceContentSize+"px",e._layoutAnimations(c,d),e._site._writeProfilerMark(f+":complete,info"),e._site._writeProfilerMark(f+",StopTM")},function(a){return e._site._writeProfilerMark(f+":canceled,info"),e._site._writeProfilerMark(f+",StopTM"),i.wrapError(a)}),{realizedRangeComplete:this._layoutPromise,layoutComplete:this._layoutPromise}},numberOfItemsPerItemsBlock:{get:function(){var b=this;return this._measureItem(0).then(function(){return b._usingStructuralNodes=b._envInfo.nestedFlexTooLarge||b._envInfo.nestedFlexTooSmall?!1:a.ListLayout._numberOfItemsPerItemsBlock>0,b._usingStructuralNodes?a.ListLayout._numberOfItemsPerItemsBlock:null})}}},{_numberOfItemsPerItemsBlock:10})}),CellSpanningLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LayoutCommon,function(a){a=a||{},this._itemInfo=a.itemInfo,this._groupInfo=a.groupInfo,this._groupHeaderPosition=a.groupHeaderPosition||U.top,this._horizontal=!0,this._cellSpanning=!0},{maximumRowsOrColumns:{get:function(){return this._maxRowsOrColumns},set:function(a){this._setMaxRowsOrColumns(a)}},itemInfo:{enumerable:!0,get:function(){return this._itemInfo},set:function(a){this._itemInfo=a,this._invalidateLayout()}},groupInfo:{enumerable:!0,get:function(){return this._groupInfo},set:function(a){this._groupInfo=a,this._invalidateLayout()}},orientation:{enumerable:!0,get:function(){return"horizontal"}}})}),_LayoutWrapper:c.Namespace._lazy(function(){return c.Class.define(function(a){this.defaultAnimations=!0,this.initialize=function(b,c){a.initialize(b,c)},this.hitTest=function(b,c){return a.hitTest(b,c)},a.uninitialize&&(this.uninitialize=function(){a.uninitialize()}),"numberOfItemsPerItemsBlock"in a&&Object.defineProperty(this,"numberOfItemsPerItemsBlock",{get:function(){return a.numberOfItemsPerItemsBlock}}),a._getItemPosition&&(this._getItemPosition=function(b){return a._getItemPosition(b)}),a.itemsFromRange&&(this.itemsFromRange=function(b,c){return a.itemsFromRange(b,c)}),a.getAdjacent&&(this.getAdjacent=function(b,c){return a.getAdjacent(b,c)}),a.dragOver&&(this.dragOver=function(b,c,d){return a.dragOver(b,c,d)}),a.dragLeave&&(this.dragLeave=function(){return a.dragLeave()});var b={enumerable:!0,get:function(){return"vertical"}};if(void 0!==a.orientation&&(b.get=function(){return a.orientation},b.set=function(b){a.orientation=b}),Object.defineProperty(this,"orientation",b),(a.setupAnimations||a.executeAnimations)&&(this.defaultAnimations=!1,this.setupAnimations=function(){return a.setupAnimations()},this.executeAnimations=function(){return a.executeAnimations()}),a.layout)if(this.defaultAnimations){var c=this;this.layout=function(b,d,e,f){var g,h=F(a.layout(b,d,[],[]));return h.realizedRangeComplete.then(function(){g=!0}),g&&c._layoutAnimations(e,f),h}}else this.layout=function(b,c,d,e){return F(a.layout(b,c,d,e))}},{uninitialize:function(){},numberOfItemsPerItemsBlock:{get:function(){}},layout:function(a,b,c,d){return this.defaultAnimations&&this._layoutAnimations(c,d),F()},itemsFromRange:function(){return{firstIndex:0,lastIndex:Number.MAX_VALUE}},getAdjacent:function(a,b){switch(b){case H.pageUp:case H.upArrow:case H.leftArrow:return{type:a.type,index:a.index-1};case H.downArrow:case H.rightArrow:case H.pageDown:return{type:a.type,index:a.index+1}}},dragOver:function(){},dragLeave:function(){},setupAnimations:function(){},executeAnimations:function(){},_getItemPosition:function(){},_layoutAnimations:function(){}})})});var U={left:"left",top:"top"};c.Namespace._moduleDefine(a,"WinJS.UI",{HeaderPosition:U,_getMargins:G})}),d("WinJS/Controls/ListView/_VirtualizeContentsView",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Promise","../../_Signal","../../Scheduler","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_SafeHtml","../../Utilities/_UI","../ItemContainer/_Constants","../ItemContainer/_ItemEventsHandler","./_Helpers","./_ItemsContainer"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";function p(a,b){i._setAttribute(a,"aria-flowto",b.id),i._setAttribute(b,"x-ms-aria-flowfrom",a.id)}c.Namespace._moduleDefine(a,"WinJS.UI",{_VirtualizeContentsView:c.Namespace._lazy(function(){function a(b){for(var c,d=b.job._workItems;d.length&&!b.shouldYield;)(c=d.shift())();b.setWork(a),d.length||b.job.pause()}function q(b,c){var d=g.schedule(a,b,null,c);return d._workItems=[],d.addWork=function(a,b){b?this._workItems.unshift(a):this._workItems.push(a),this.resume()},d.clearWork=function(){this._workItems.length=0},d.dispose=function(){this.cancel(),this._workItems.length=0},d}function r(a){return a._zooming||a._pinching}function s(a,b){return a._isZombie()?e.wrap():r(a)?(+b!==b&&(b=v._waitForSeZoTimeoutDuration),e.timeout(v._waitForSeZoIntervalDuration).then(function(){return b-=v._waitForSeZoIntervalDuration,0>=b?!0:s(a,b)})):e.wrap()}function t(a){if("number"==typeof a){var b=a;a=function(){return{position:b,direction:"right"}}}return a}function u(){}var v=c.Class.define(function(a){this._listView=a,this._forceRelayout=!1,this.items=new o._ItemsContainer(a),this.firstIndexDisplayed=-1,this.lastIndexDisplayed=-1,this.begin=0,this.end=0,this._realizePass=1,this._firstLayoutPass=!0,this._runningAnimations=null,this._renderCompletePromise=e.wrap(),this._state=new w(this),this._createLayoutSignal(),this._createTreeBuildingSignal(),this._layoutWork=null,this._onscreenJob=q(g.Priority.aboveNormal,"on-screen items"),this._frontOffscreenJob=q(g.Priority.normal,"front off-screen items"),this._backOffscreenJob=q(g.Priority.belowNormal,"back off-screen items"),this._scrollbarPos=0,this._direction="right",this._scrollToFunctor=t(0)},{_dispose:function(){this.cleanUp(),this.items=null,this._renderCompletePromise&&this._renderCompletePromise.cancel(),this._renderCompletePromise=null,this._onscreenJob.dispose(),this._frontOffscreenJob.dispose(),this._backOffscreenJob.dispose()},_createItem:function(a,b,c,d){this._listView._writeProfilerMark("createItem("+a+") "+this._getBoundingRectString(a)+",info");var f=this;f._listView._itemsManager._itemFromItemPromiseThrottled(b).done(function(b){b?c(a,b,f._listView._itemsManager._recordFromElement(b)):d(a)},function(b){return d(a),e.wrapError(b)})},_addItem:function(a,b,c,d){if(this._realizePass===d){var e=this._listView._itemsManager._recordFromElement(c);delete this._pendingItemPromises[e.itemPromise.handle],this.items.setItemAt(b,{itemBox:null,container:null,element:c,detached:!0,itemsManagerRecord:e})}},finalItem:function(){return this.containers?e.wrap(this.containers.length-1):e.cancel},_setSkipRealizationForChange:function(a){a?this._realizationLevel!==v._realizationLevel.realize&&(this._realizationLevel=v._realizationLevel.skip):this._realizationLevel=v._realizationLevel.realize},_realizeItems:function(a,b,c,d,h,j,n,o,p,q){function r(a,b){D.push(e._cancelBlocker(b.renderComplete)),v(a)}function s(a,b){function c(a,b){!a.updatedSwipeableAttribute&&(H._listView.itemsDraggable||H._listView.itemsReorderable||H._listView._swipeable)&&a.itemsManagerRecord.renderComplete.done(function(){if(H._realizePass===h){var c=i.hasClass(b,l._nonDraggableClass),d=i.hasClass(b,l._nonSelectableClass),e=H._listView.itemsDraggable||H._listView.itemsReorderable,f=H._listView._selectionAllowed()&&H._listView._swipeBehavior===k.SwipeBehavior.select;e&&!c&&(a.itemBox.draggable=!0),H._listView._swipeable&&(e&&!f&&c||f&&!e&&d||c&&d)&&i.addClass(a.itemBox,l._nonSwipeableClass),a.updatedSwipeableAttribute=!0}})}if(H._listView._writeProfilerMark("_realizeItems_appendedItemsToDom,StartTM"),!H._listView._isZombie()){var d,e=0,f=-1,g=-1;for(d=a;b>=d;d++){var j=H.items.itemDataAt(d);if(j){var o=j.element,p=j.itemBox;p||(p=H._listView._itemBoxTemplate.cloneNode(!0),j.itemBox=p,p.appendChild(o),i.addClass(o,l._itemClass),H._listView._setupAriaSelectionObserver(o),H._listView._isSelected(d)&&m._ItemEventsHandler.renderSelection(p,o,!0,!0),H._listView._currentMode().renderDragSourceOnRealizedItem(d,p)),c(j,o,p);var q=H.getContainer(d);p.parentNode!==q&&(H._appendAndRestoreFocus(q,p),e++,0>f&&(f=d),g=d,j.container=q,H._listView._isSelected(d)&&i.addClass(q,l._selectedClass),i.removeClass(q,l._backdropClass),H.items.elementAvailable(d))}}H._listView._writeProfilerMark("_realizeItems_appendedItemsToDom,StopTM"),e>0&&(H._listView._writeProfilerMark("_realizeItems_appendedItemsToDom:"+e+" ("+f+"-"+g+"),info"),H._reportElementsLevel(n))}}function t(a,b,c,d){function e(a,b){var c=H.items.itemDataAt(a);if(c){var d=c.itemBox;return d&&d.parentNode?b?(i.addClass(d.parentNode,l._backdropClass),d.parentNode.removeChild(d),!0):!1:!0}return!0}if(!q){for(var f=!1;a>=c;)f=e(a,f),a--;for(f=!1;d>=b;)f=e(b,f),b++}}function u(a,b,c,d,f){function g(a){var b=H.items.itemDataAt(a);if(b){var d=b.itemsManagerRecord;d.readyComplete||H._realizePass!==h||c.addWork(function(){H._listView._isZombie()||d.pendingReady&&H._realizePass===h&&(H._listView._writeProfilerMark("pendingReady("+a+"),info"),d.pendingReady())},f)}}for(var i=[],j=a;b>=j;j++){var k=H.items.itemDataAt(j);k&&i.push(k.itemsManagerRecord.itemPromise)}e.join(i).then(function(){if("right"===d)for(var c=a;b>=c;c++)g(c);else for(var c=b;c>=a;c--)g(c)})}function v(a){if(H._realizePass===h){if(a>=o&&p>=a){if(0===--A){if(s(o,p),t(o,p,b,c),H._firstLayoutPass){u(o,p,H._frontOffscreenJob,"right"===n?"left":"right",!0);var d=g.schedulePromiseHigh(null,"WinJS.UI.ListView.entranceAnimation").then(function(){if(!H._listView._isZombie()){H._listView._writeProfilerMark("entranceAnimation,StartTM");var a=H._listView._animateListEntrance(!H._firstEntranceAnimated);return H._firstEntranceAnimated=!0,a}});H._runningAnimations=e.join([H._runningAnimations,d]),H._runningAnimations.done(function(){H._listView._writeProfilerMark("entranceAnimation,StopTM"),H._realizePass===h&&(H._runningAnimations=null,E.complete())}),H._firstLayoutPass=!1,H._listView._isCurrentZoomView&&g.requestDrain(H._onscreenJob.priority)}else u(o,p,H._frontOffscreenJob,n),E.complete();H._updateHeaders(H._listView._canvas,o,p+1).done(function(){F.complete()})}}else o>a?(--C,C%z===0&&s(b,o-1),C||(H._updateHeaders(H._listView._canvas,b,o).done(function(){"right"!==n&&G.complete()}),u(b,o-1,"right"!==n?H._frontOffscreenJob:H._backOffscreenJob,"left"))):a>p&&(--B,B%z===0&&s(p+1,c-1),B||(H._updateHeaders(H._listView._canvas,p+1,c).then(function(){"right"===n&&G.complete()}),u(p+1,c-1,"right"===n?H._frontOffscreenJob:H._backOffscreenJob,"right")));y--,0===y&&(H._renderCompletePromise=e.join(D).then(null,function(a){var b=Array.isArray(a)&&a.some(function(a){return a&&!(a instanceof Error&&"Canceled"===a.name)});return b?e.wrapError(a):void 0}),(H._headerRenderPromises||e.wrap()).done(function(){g.schedule(function(){H._listView._isZombie()?M.cancel():M.complete()},Math.min(H._onscreenJob.priority,H._backOffscreenJob.priority),null,"WinJS.UI.ListView._allItemsRealized")}))}}function w(b,c,d){if(H._realizePass===h){var c=d.element;H._addItem(a,b,c,h),r(b,d)}}var x="_realizeItems("+b+"-"+(c-1)+") visible("+o+"-"+p+")";this._listView._writeProfilerMark(x+",StartTM"),n=n||"right";var y=c-b,z=p-o+1,A=z,B=c-p-1,C=o-b,D=[],E=new f,F=new f,G=new f,H=this;if(y>0){var I=0,J=0,K=0;H.firstIndexDisplayed=o,H.lastIndexDisplayed=p;var L=H._listView._isCurrentZoomView;H._highPriorityRealize&&(H._firstLayoutPass||H._hasAnimationInViewportPending)?(H._highPriorityRealize=!1,H._onscreenJob.priority=g.Priority.high,H._frontOffscreenJob.priority=g.Priority.normal,H._backOffscreenJob.priority=g.Priority.belowNormal):H._highPriorityRealize?(H._highPriorityRealize=!1,H._onscreenJob.priority=g.Priority.high,H._frontOffscreenJob.priority=g.Priority.high-1,H._backOffscreenJob.priority=g.Priority.high-1):L?(H._onscreenJob.priority=g.Priority.aboveNormal,H._frontOffscreenJob.priority=g.Priority.normal,H._backOffscreenJob.priority=g.Priority.belowNormal):(H._onscreenJob.priority=g.Priority.belowNormal,H._frontOffscreenJob.priority=g.Priority.idle,H._backOffscreenJob.priority=g.Priority.idle);var M=new f,N=H._listView._versionManager.cancelOnNotification(M.promise),O=function(a,b){b.startStage1&&b.stage0.then(function(){H._realizePass===h&&b.startStage1&&a.addWork(b.startStage1)})},P=function(a,b){var c=H.items.itemDataAt(b);if(!c){var d=H._listView._itemsManager._itemPromiseAtIndex(b);H._pendingItemPromises[d.handle]=d,delete H._previousRealizationPendingItemPromises[d.handle],a.addWork(function(){if(!H._listView._isZombie()&&(I++,H._createItem(b,d,w,v),!H._listView._isZombie()&&H._realizePass===h&&d.handle)){var c=H._listView._itemsManager._recordFromHandle(d.handle);O(a,c)}})}},Q=function(a,b,c){for(var d=b;c>=d;d++)P(a,d)},R=function(a,b,c){for(var d=c;d>=b;d--)P(a,d)},S=function(a,b,c){for(var d=b;c>=d;d++){var e=H.items.itemDataAt(d);if(e){var f=e.itemsManagerRecord;r(d,f),J++,O(a,f)}}};this._previousRealizationPendingItemPromises=this._pendingItemPromises||{},this._pendingItemPromises={};var T;"left"===n?(R(H._onscreenJob,o,p),R(H._frontOffscreenJob,b,o-1),T=b>o-1):(Q(H._onscreenJob,o,p),Q(H._frontOffscreenJob,p+1,c-1),T=p+1>c-1);for(var U=0,V=Object.keys(this._previousRealizationPendingItemPromises),W=V.length;W>U;U++){var X=V[U];H._listView._itemsManager.releaseItemPromise(this._previousRealizationPendingItemPromises[X])}this._previousRealizationPendingItemPromises={},S(H._onscreenJob,o,p),"left"===n?S(H._frontOffscreenJob,b,o-1):S(H._frontOffscreenJob,p+1,c-1);var Y=A===p-o+1;return H._firstLayoutPass?H._listView._canvas.style.opacity=0:Y?H._listView._showProgressBar(H._listView._element,"50%","50%"):H._listView._hideProgressBar(),H._frontOffscreenJob.pause(),H._backOffscreenJob.pause(),F.promise.done(function(){H._frontOffscreenJob.resume(),T&&G.complete()},function(){M.cancel()}),G.promise.done(function(){H._listView._writeProfilerMark("frontItemsRealized,info"),"left"===n?(Q(H._backOffscreenJob,p+1,c-1),S(H._backOffscreenJob,p+1,c-1)):(R(H._backOffscreenJob,b,o-1),S(H._backOffscreenJob,b,o-1)),H._backOffscreenJob.resume()}),M.promise.done(function(){H._listView._versionManager.clearCancelOnNotification(N),H._listView._writeProfilerMark(x+" complete(created:"+I+" updated:"+J+"),info")},function(a){return H._listView._versionManager.clearCancelOnNotification(N),H._onscreenJob.clearWork(),H._frontOffscreenJob.clearWork(),H._backOffscreenJob.clearWork(),E.cancel(),F.cancel(),H._listView._writeProfilerMark(x+" canceled(created:"+I+" updated:"+J+" clean:"+K+"),info"),e.wrapError(a)}),H._listView._writeProfilerMark(x+",StopTM"),{viewportItemsRealized:F.promise,allItemsRealized:M.promise,loadingCompleted:e.join([M.promise,E.promise]).then(function(){for(var a=[],d=b;c>d;d++){var f=H.items.itemDataAt(d);f&&a.push(f.itemsManagerRecord.itemReadyPromise)}return e._cancelBlocker(e.join(a))})}}return H._listView._writeProfilerMark(x+",StopTM"),{viewportItemsRealized:e.wrap(),allItemsRealized:e.wrap(),loadingCompleted:e.wrap()}},_setAnimationInViewportState:function(a){if(this._hasAnimationInViewportPending=!1,a&&a.length>0)for(var b=this._listView._getViewportLength(),c=this._listView._layout.itemsFromRange(this._scrollbarPos,this._scrollbarPos+b-1),d=0,e=a.length;e>d;d++){var f=a[d];if(f.newIndex>=c.firstIndex&&f.newIndex<=c.lastIndex&&f.newIndex!==f.oldIndex){this._hasAnimationInViewportPending=!0;break}}},_addHeader:function(a,b){var c=this;return this._listView._groups.renderGroup(b).then(function(a){if(a){a.element.tabIndex=0;var d=c._getHeaderContainer(b);a.element.parentNode!==d&&(d.appendChild(a.element),i.addClass(a.element,l._headerClass)),c._listView._groups.setDomElement(b,a.element)}})},_updateHeaders:function(a,b,c){function d(b){var c=g._listView._groups.group(b);if(c&&!c.header){var d=c.headerPromise;return d||(d=c.headerPromise=g._addHeader(a,b),d.done(function(){c.headerPromise=null},function(){c.headerPromise=null})),d}return e.wrap()}function f(){g._headerRenderPromises=null}var g=this;this._listView._groups.removeElements();var h=this._listView._groups.groupFromItem(b),i=h,j=this._listView._groups.groupFromItem(c-1),k=[];if(null!==i)for(;j>=i;i++)k.push(d(i));return this._headerRenderPromises=e.join(k,this._headerRenderPromises).then(f,f),this._headerRenderPromises||e.wrap()},_unrealizeItem:function(a){var b,c=this._listView;this._listView._writeProfilerMark("_unrealizeItem("+a+"),info");var d=c._selection._getFocused();d.type!==k.ObjectType.groupHeader&&d.index===a&&(c._unsetFocusOnItem(),b=!0);var e=this.items.itemDataAt(a),f=e.element,g=e.itemBox;g&&g.parentNode&&(i.removeClass(g.parentNode,l._selectedClass),i.removeClass(g.parentNode,l._footprintClass),i.addClass(g.parentNode,l._backdropClass),g.parentNode.removeChild(g)),e.container=null,c._currentMode().itemUnrealized&&c._currentMode().itemUnrealized(a,g),this.items.removeItem(a),e.removed||c._itemsManager.releaseItem(f),h._disposeElement(f),b&&c._setFocusOnItem(c._selection._getFocused())},_unrealizeGroup:function(a){var b,c=a.header,d=this._listView._selection._getFocused();d.type===k.ObjectType.groupHeader&&this._listView._groups.group(d.index)===a&&(this._listView._unsetFocusOnItem(),b=!0),c.parentNode&&c.parentNode.removeChild(c),h._disposeElement(c),a.header=null,a.left=-1,a.top=-1,b&&this._listView._setFocusOnItem(this._listView._selection._getFocused())},_unrealizeItems:function(a){var b=this,c=0;this.items.eachIndex(function(d){return d<b.begin||d>=b.end?(b._unrealizeItem(d),a&&++c>=a):void 0});var d=this._listView._groups,e=d.groupFromItem(this.begin);if(null!==e)for(var f=d.groupFromItem(this.end-1),g=0,h=d.length();h>g;g++){var i=d.group(g);(e>g||g>f)&&i.header&&this._unrealizeGroup(i)}},_unrealizeExcessiveItems:function(){var a=this.items.count(),b=this.end-this.begin,c=b+this._listView._maxDeferredItemCleanup;this._listView._writeProfilerMark("_unrealizeExcessiveItems realized("+a+") approved("+c+"),info"),a>c&&this._unrealizeItems(a-c)},_lazilyUnrealizeItems:function(){this._listView._writeProfilerMark("_lazilyUnrealizeItems,StartTM");var a=this;return s(this._listView).then(function(){function b(){a._listView._writeProfilerMark("_lazilyUnrealizeItems,StopTM")}if(a._listView._isZombie())return void b();var c=[];a.items.eachIndex(function(b){(b<a.begin||b>=a.end)&&c.push(b)}),a._listView._writeProfilerMark("_lazilyUnrealizeItems itemsToUnrealize("+c.length+"),info");var d=[],f=a._listView._groups,h=f.groupFromItem(a.begin);if(null!==h)for(var i=f.groupFromItem(a.end-1),j=0,k=f.length();k>j;j++){var l=f.group(j);(h>j||j>i)&&l.header&&d.push(l)}if(c.length||d.length){var m,n=new e(function(b){function e(f){if(!a._listView._isZombie()){for(var g=-1,h=-1,i=0,j=r(a._listView);c.length&&!j&&!f.shouldYield;){var k=c.shift();a._unrealizeItem(k),i++,0>g&&(g=k),h=k}for(a._listView._writeProfilerMark("unrealizeWorker removeItems:"+i+" ("+g+"-"+h+"),info");d.length&&!j&&!f.shouldYield;)a._unrealizeGroup(d.shift());c.length||d.length?j?f.setPromise(s(a._listView).then(function(){return e})):f.setWork(e):b()
  }}m=g.schedule(e,g.Priority.belowNormal,null,"WinJS.UI.ListView._lazilyUnrealizeItems")});return n.then(b,function(b){return m.cancel(),a._listView._writeProfilerMark("_lazilyUnrealizeItems canceled,info"),a._listView._writeProfilerMark("_lazilyUnrealizeItems,StopTM"),e.wrapError(b)})}return b(),e.wrap()})},_getBoundingRectString:function(a){var b;if(a>=0&&a<this.containers.length){var c=this._listView._layout._getItemPosition(a);c&&(b="["+c.left+"; "+c.top+"; "+c.width+"; "+c.height+" ]")}return b||""},_clearDeferTimeout:function(){this.deferTimeout&&(this.deferTimeout.cancel(),this.deferTimeout=null),-1!==this.deferredActionCancelToken&&(this._listView._versionManager.clearCancelOnNotification(this.deferredActionCancelToken),this.deferredActionCancelToken=-1)},_setupAria:function(a){function b(){d._listView._writeProfilerMark("aria work,StopTM")}function c(a){var b=d._listView._groups,c=b.group(a+1);return c?Math.min(c.startIndex-1,d.end-1):d.end-1}if(!this._listView._isZombie()){var d=this;return this._listView._createAriaMarkers(),this._listView._itemsCount().then(function(f){if(!(f>0&&-1!==d.firstIndexDisplayed&&-1!==d.lastIndexDisplayed))return e.wrap();d._listView._writeProfilerMark("aria work,StartTM");var h,j,k,l,m,n,o=d._listView._ariaStartMarker,q=d._listView._ariaEndMarker,t=d.begin,u=d.items.itemAt(d.begin);return u?(i._ensureId(u),d._listView._groupsEnabled()?(j=d._listView._groups,k=l=j.groupFromItem(d.begin),m=j.group(l),n=c(l),i._ensureId(m.header),i._setAttribute(m.header,"role",d._listView._headerRole),i._setAttribute(m.header,"x-ms-aria-flowfrom",o.id),p(m.header,u),i._setAttribute(m.header,"tabindex",d._listView._tabIndex)):i._setAttribute(u,"x-ms-aria-flowfrom",o.id),new e(function(e){var o=a;h=g.schedule(function v(a){if(d._listView._isZombie())return void b();for(;t<d.end;t++){if(!o&&r(d._listView))return void a.setPromise(s(d._listView).then(function(a){return o=a,v}));if(a.shouldYield)return void a.setWork(v);u=d.items.itemAt(t);var g=d.items.itemAt(t+1);if(g&&i._ensureId(g),i._setAttribute(u,"role",d._listView._itemRole),i._setAttribute(u,"aria-setsize",f),i._setAttribute(u,"aria-posinset",t+1),i._setAttribute(u,"tabindex",d._listView._tabIndex),d._listView._groupsEnabled())if(t!==n&&g)p(u,g);else{var h=j.group(l+1);h&&h.header&&g?(i._setAttribute(h.header,"tabindex",d._listView._tabIndex),i._setAttribute(h.header,"role",d._listView._headerRole),i._ensureId(h.header),p(u,h.header),p(h.header,g)):i._setAttribute(u,"aria-flowto",q.id),l++,m=h,n=c(l)}else g?p(u,g):i._setAttribute(u,"aria-flowto",q.id);if(!g)break}d._listView._fireAccessibilityAnnotationCompleteEvent(d.begin,t,k,l-1),b(),e()},g.Priority.belowNormal,null,"WinJS.UI.ListView._setupAria")},function(){h.cancel(),b()})):void b()})}},_setupDeferredActions:function(){function a(){b._listView._isZombie()||(b.deferTimeout=null,b._listView._versionManager.clearCancelOnNotification(b.deferredActionCancelToken),b.deferredActionCancelToken=-1)}this._listView._writeProfilerMark("_setupDeferredActions,StartTM");var b=this;this._clearDeferTimeout(),this.deferTimeout=this._lazilyRemoveRedundantItemsBlocks().then(function(){return e.timeout(l._DEFERRED_ACTION)}).then(function(){return s(b._listView)}).then(function(a){return b._setupAria(a)}).then(a,function(b){return a(),e.wrapError(b)}),this.deferredActionCancelToken=this._listView._versionManager.cancelOnNotification(this.deferTimeout),this._listView._writeProfilerMark("_setupDeferredActions,StopTM")},_updateAriaMarkers:function(a,b,c){function d(){return f.items.itemAt(b)}function e(){for(var a=c;a>=b;a--)if(f.items.itemAt(a))return f.items.itemAt(a);return null}var f=this;if(!this._listView._isZombie()){this._listView._createAriaMarkers();var g,h,j=this._listView._ariaStartMarker,k=this._listView._ariaEndMarker;if(-1!==b&&-1!==c&&c>=b&&(g=d(),h=e()),!a&&g&&h){if(i._ensureId(g),i._ensureId(h),this._listView._groupsEnabled()){var l=this._listView._groups,m=l.group(l.groupFromItem(b));m.header&&(i._ensureId(m.header),b===m.startIndex?i._setAttribute(j,"aria-flowto",m.header.id):i._setAttribute(j,"aria-flowto",g.id))}else i._setAttribute(j,"aria-flowto",g.id);i._setAttribute(k,"x-ms-aria-flowfrom",h.id)}else p(j,k),this._listView._fireAccessibilityAnnotationCompleteEvent(-1,-1)}},updateAriaForAnnouncement:function(a,b){var c=-1,d=k.ObjectType.item;i.hasClass(a,l._headerClass)?(c=this._listView._groups.index(a),d=k.ObjectType.groupHeader,i._setAttribute(a,"role",this._listView._headerRole),i._setAttribute(a,"tabindex",this._listView._tabIndex)):(c=this.items.index(a),i._setAttribute(a,"aria-setsize",b),i._setAttribute(a,"aria-posinset",c+1),i._setAttribute(a,"role",this._listView._itemRole),i._setAttribute(a,"tabindex",this._listView._tabIndex)),d===k.ObjectType.groupHeader?this._listView._fireAccessibilityAnnotationCompleteEvent(-1,-1,c,c):this._listView._fireAccessibilityAnnotationCompleteEvent(c,c,-1,-1)},_reportElementsLevel:function(a){function b(a,b){for(var c=0,e=a;b>=e;e++){var f=d.itemDataAt(e);f&&f.container&&c++}return c}var c,d=this.items;c=Math.floor("right"===a?100*b(this.firstIndexDisplayed,this.end-1)/(this.end-this.firstIndexDisplayed):100*b(this.begin,this.lastIndexDisplayed)/(this.lastIndexDisplayed-this.begin+1)),this._listView._writeProfilerMark("elementsLevel level("+c+"),info")},_createHeaderContainer:function(a){return this._createSurfaceChild(l._headerContainerClass,a)},_createItemsContainer:function(a){var c=this._createSurfaceChild(l._itemsContainerClass,a),d=b.document.createElement("div");return d.className=l._padderClass,c.appendChild(d),c},_ensureContainerInDOM:function(a){var b=this.containers[a];return b&&!this._listView._canvas.contains(b)?(this._forceItemsBlocksInDOM(a,a+1),!0):!1},_ensureItemsBlocksInDOM:function(a,b){if(this._expandedRange){var c=this._expandedRange.first.index,d=this._expandedRange.last.index+1;c>=a&&b>c?b=Math.max(b,d):d>a&&b>=d&&(a=Math.min(a,c))}this._forceItemsBlocksInDOM(a,b)},_removeRedundantItemsBlocks:function(){-1!==this.begin&&-1!==this.end&&this._forceItemsBlocksInDOM(this.begin,this.end)},_lazilyRemoveRedundantItemsBlocks:function(){this._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks,StartTM");var a=this;return s(this._listView).then(function(){function b(){a._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks,StopTM")}if(a._listView._isZombie())return void b();if(a._expandedRange&&-1!==a.begin&&-1!==a.end&&(a._expandedRange.first.index<a.begin||a._expandedRange.last.index+1>a.end)){var c,d=new e(function(b){function d(c){if(!a._listView._isZombie()){for(var e=r(a._listView);a._expandedRange.first.index<a.begin&&!e&&!c.shouldYield;){var f=Math.min(a.begin,a._expandedRange.first.index+a._blockSize*v._blocksToRelease);a._forceItemsBlocksInDOM(f,a.end)}for(;a._expandedRange.last.index+1>a.end&&!e&&!c.shouldYield;){var g=Math.max(a.end,a._expandedRange.last.index-a._blockSize*v._blocksToRelease);a._forceItemsBlocksInDOM(a.begin,g)}a._expandedRange.first.index<a.begin||a._expandedRange.last.index+1>a.end?e?c.setPromise(s(a._listView).then(function(){return d})):c.setWork(d):b()}}c=g.schedule(d,g.Priority.belowNormal,null,"WinJS.UI.ListView._lazilyRemoveRedundantItemsBlocks")});return d.then(b,function(b){return c.cancel(),a._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks canceled,info"),a._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks,StopTM"),e.wrapError(b)})}return b(),e.wrap()})},_forceItemsBlocksInDOM:function(a,b){function c(a,b){var c=a.element.firstElementChild;c.style[q]=b}function d(a){for(var b=0;b<n.tree.length;b++)for(var c=n.tree[b].itemsContainer,d=0,e=c.itemsBlocks.length;e>d;d++)if(a(c,c.itemsBlocks[d]))return}function e(a){n._listView._writeProfilerMark("_itemsBlockExtent,StartTM"),n._listView._itemsBlockExtent=i[n._listView._horizontal()?"getTotalWidth":"getTotalHeight"](a.element),n._listView._writeProfilerMark("_itemsBlockExtent("+n._listView._itemsBlockExtent+"),info"),n._listView._writeProfilerMark("_itemsBlockExtent,StopTM")}function f(){return-1===n._listView._itemsBlockExtent&&d(function(a,b){return b.items.length===n._blockSize&&b.element.parentNode===a.element?(e(b),!0):!1}),-1===n._listView._itemsBlockExtent&&d(function(a,b){return b.items.length===n._blockSize?(a.element.appendChild(b.element),e(b),a.element.removeChild(b.element),!0):!1}),n._listView._itemsBlockExtent}function g(a,b,c){function d(b){var c=a.itemsBlocks[b];c&&c.element.parentNode===a.element&&(a.element.removeChild(c.element),p++)}if(Array.isArray(b))b.forEach(d);else for(var e=b;c>e;e++)d(e)}function h(a,b,c){for(var d=a.element.firstElementChild,e=d,f=b;c>f;f++){var g=a.itemsBlocks[f];g&&(g.element.parentNode!==a.element&&(a.element.insertBefore(g.element,e.nextElementSibling),o++),e=g.element)}}function j(a){if(a<n.tree.length){n._listView._writeProfilerMark("collapseGroup("+a+"),info");var b=n.tree[a].itemsContainer;g(b,0,b.itemsBlocks.length),c(b,"")}}function k(a){if(a<n.tree.length){n._listView._writeProfilerMark("expandGroup("+a+"),info");var b=n.tree[a].itemsContainer;h(b,0,b.itemsBlocks.length),c(b,"")}}function l(a,b){function c(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c}var d=b[0],e=b[1],f=a[0],g=a[1];return f>e||d>g?c(f,g):d>f&&g>e?c(f,d-1).concat(c(e+1,g)):d>f?c(f,d-1):g>e?c(e+1,g):null}if(this._blockSize){var m="_forceItemsBlocksInDOM begin("+a+") end("+b+"),";this._listView._writeProfilerMark(m+"StartTM");var n=this,o=0,p=0,q="padding"+(this._listView._horizontal()?"Left":"Top"),r=this._listView._groups.groupFromItem(a),s=this._listView._groups.groupFromItem(b-1),t=this._listView._groups.group(r),u=n.tree[r].itemsContainer,v=Math.floor((a-t.startIndex)/this._blockSize),w=this._listView._groups.group(s),x=n.tree[s].itemsContainer,y=Math.floor((b-1-w.startIndex)/this._blockSize);v&&-1===n._listView._itemsBlockExtent&&d(function(a,b){return b.items.length===n._blockSize&&b.element.parentNode===a.element?(e(b),!0):!1});var z=this._expandedRange?l([this._expandedRange.first.groupIndex,this._expandedRange.last.groupIndex],[r,s]):null;if(z&&z.forEach(j),this._expandedRange&&this._expandedRange.first.groupKey===t.key){var A=l([this._expandedRange.first.block,Number.MAX_VALUE],[v,Number.MAX_VALUE]);A&&g(u,A)}else this._expandedRange&&r>=this._expandedRange.first.groupIndex&&r<=this._expandedRange.last.groupIndex&&g(u,0,v);if(r!==s?(h(u,v,u.itemsBlocks.length),h(x,0,y+1)):h(u,v,y+1),this._expandedRange&&this._expandedRange.last.groupKey===w.key){var A=l([0,this._expandedRange.last.block],[0,y]);A&&g(x,A)}else this._expandedRange&&s>=this._expandedRange.first.groupIndex&&s<=this._expandedRange.last.groupIndex&&g(x,y+1,x.itemsBlocks.length);c(u,v?v*f()+"px":""),r!==s&&c(x,"");for(var B=r+1;s>B;B++)k(B);this._expandedRange={first:{index:a,groupIndex:r,groupKey:t.key,block:v},last:{index:b-1,groupIndex:s,groupKey:w.key,block:y}},this._listView._writeProfilerMark("_forceItemsBlocksInDOM groups("+r+"-"+s+") blocks("+v+"-"+y+") added("+o+") removed("+p+"),info"),this._listView._writeProfilerMark(m+"StopTM")}},_realizePageImpl:function(){var a=this,b="realizePage(scrollPosition:"+this._scrollbarPos+" forceLayout:"+this._forceRelayout+")";return this._listView._writeProfilerMark(b+",StartTM"),this._listView._versionManager.locked?(this._listView._versionManager.unlocked.done(function(){a._listView._isZombie()||a._listView._batchViewUpdates(l._ViewChange.realize,l._ScrollToPriority.low,a._listView.scrollPosition)}),this._listView._writeProfilerMark(b+",StopTM"),e.cancel):new e(function(c){function g(){c(),l.complete()}function h(){a._listView._hideProgressBar(),a._state.setLoadingState(a._listView._LoadingState.viewPortLoaded),a._executeAnimations&&a._setState(F,l.promise)}function j(b){a._updateAriaMarkers(0===b,a.firstIndexDisplayed,a.lastIndexDisplayed),a._state.setLoadingState&&a._state.setLoadingState(a._listView._LoadingState.itemsLoaded)}function k(b){a._listView._clearInsertedItems(),a._listView._groups.removeElements(),h(),j(b),g()}var l=new f;a._state.setLoadingState(a._listView._LoadingState.itemsLoading),a._firstLayoutPass&&a._listView._showProgressBar(a._listView._element,"50%","50%");var m=a.containers.length;if(m){var n=v._pagesToPrefetch,o=v._customPagesToPrefetchMax,p=v._customPagesToPrefetchMin;a._listView._zooming&&(n=0,o=0,p=0);var q,r,s=a._listView._getViewportLength();if(d._isiOS&&!v._disableCustomPagesPrefetch){q="left"===a._direction?o:p;var t=Math.max(0,q-a._scrollbarPos/s);r=Math.min(o,t+("right"===a._direction?o:p))}else q=n,r=n;var u=Math.max(0,a._scrollbarPos-q*s),w=a._scrollbarPos+(1+r)*s,x=a._listView._layout.itemsFromRange(u,w-1);if((x.firstIndex<0||x.firstIndex>=m)&&(x.lastIndex<0||x.lastIndex>=m))a.begin=-1,a.end=-1,a.firstIndexDisplayed=-1,a.lastIndexDisplayed=-1,k(m);else{var y=i._clamp(x.firstIndex,0,m-1),z=i._clamp(x.lastIndex+1,0,m),A=a._listView._layout.itemsFromRange(a._scrollbarPos,a._scrollbarPos+s-1),B=i._clamp(A.firstIndex,0,m-1),C=i._clamp(A.lastIndex,0,m-1);if(a._realizationLevel!==v._realizationLevel.skip||a.lastRealizePass||B!==a.firstIndexDisplayed||C!==a.lastIndexDisplayed)if((a._forceRelayout||y!==a.begin||z!==a.end||B!==a.firstIndexDisplayed||C!==a.lastIndexDisplayed)&&z>y&&w>u){a._listView._writeProfilerMark("realizePage currentInView("+B+"-"+C+") previousInView("+a.firstIndexDisplayed+"-"+a.lastIndexDisplayed+") change("+(B-a.firstIndexDisplayed)+"),info"),a._cancelRealize();var D=a._realizePass;a.begin=y,a.end=z,a.firstIndexDisplayed=B,a.lastIndexDisplayed=C,a.deletesWithoutRealize=0,a._ensureItemsBlocksInDOM(a.begin,a.end);var E=a._realizeItems(a._listView._itemCanvas,a.begin,a.end,m,D,a._scrollbarPos,a._direction,B,C,a._forceRelayout);a._forceRelayout=!1;var G=E.viewportItemsRealized.then(function(){return h(),E.allItemsRealized}).then(function(){return a._realizePass===D?a._updateHeaders(a._listView._canvas,a.begin,a.end).then(function(){j(m)}):void 0}).then(function(){return E.loadingCompleted}).then(function(){a._unrealizeExcessiveItems(),a.lastRealizePass=null,g()},function(b){return a._realizePass===D&&(a.lastRealizePass=null,a.begin=-1,a.end=-1),e.wrapError(b)});a.lastRealizePass=e.join([E.viewportItemsRealized,E.allItemsRealized,E.loadingCompleted,G]),a._unrealizeExcessiveItems()}else a.lastRealizePass?a.lastRealizePass.then(g):k(m);else a.begin=y,a.end=y+Object.keys(a.items._itemData).length,a._updateHeaders(a._listView._canvas,a.begin,a.end).done(function(){a.lastRealizePass=null,k(m)})}}else a.begin=-1,a.end=-1,a.firstIndexDisplayed=-1,a.lastIndexDisplayed=-1,k(m);a._reportElementsLevel(a._direction),a._listView._writeProfilerMark(b+",StopTM")})},realizePage:function(a,b,c,d){this._scrollToFunctor=t(a),this._forceRelayout=this._forceRelayout||b,this._scrollEndPromise=c,this._listView._writeProfilerMark(this._state.name+"_realizePage,info"),this._state.realizePage(d||A)},onScroll:function(a,b){this.realizePage(a,!1,b,C)},reload:function(a,b){this._listView._isZombie()||(this._scrollToFunctor=t(a),this._forceRelayout=!0,this._highPriorityRealize=!!b,this.stopWork(!0),this._listView._writeProfilerMark(this._state.name+"_rebuildTree,info"),this._state.rebuildTree())},refresh:function(a){this._listView._isZombie()||(this._scrollToFunctor=t(a),this._forceRelayout=!0,this._highPriorityRealize=!0,this.stopWork(),this._listView._writeProfilerMark(this._state.name+"_relayout,info"),this._state.relayout())},waitForValidScrollPosition:function(a){var b=this,c=this._listView._viewport[this._listView._scrollLength]-this._listView._getViewportLength();return a>c?b._listView._itemsCount().then(function(c){return b.containers.length<c?e._cancelBlocker(b._creatingContainersWork&&b._creatingContainersWork.promise).then(function(){return b._getLayoutCompleted()}).then(function(){return a}):a}):e.wrap(a)},waitForEntityPosition:function(a){var b=this;return this._listView._writeProfilerMark(this._state.name+"_waitForEntityPosition("+a.type+": "+a.index+"),info"),e._cancelBlocker(this._state.waitForEntityPosition(a).then(function(){return a.type!==k.ObjectType.groupHeader&&a.index>=b.containers.length||a.type===k.ObjectType.groupHeader&&b._listView._groups.group(a.index).startIndex>=b.containers.length?b._creatingContainersWork&&b._creatingContainersWork.promise:void 0}).then(function(){return b._getLayoutCompleted()}))},stopWork:function(a){this._listView._writeProfilerMark(this._state.name+"_stop,info"),this._state.stop(a),this._layoutWork&&this._layoutWork.cancel(),a&&this._creatingContainersWork&&this._creatingContainersWork.cancel(),a&&(this._state=new w(this))},_cancelRealize:function(){this._listView._writeProfilerMark("_cancelRealize,StartTM"),(this.lastRealizePass||this.deferTimeout)&&(this._forceRelayout=!0),this._clearDeferTimeout(),this._realizePass++,this._headerRenderPromises&&(this._headerRenderPromises.cancel(),this._headerRenderPromises=null);var a=this.lastRealizePass;a&&(this.lastRealizePass=null,this.begin=-1,this.end=-1,a.cancel()),this._listView._writeProfilerMark("_cancelRealize,StopTM")},resetItems:function(a){if(!this._listView._isZombie()){this.firstIndexDisplayed=-1,this.lastIndexDisplayed=-1,this._runningAnimations=null,this._executeAnimations=!1;var b=this._listView;this._firstLayoutPass=!0,b._unsetFocusOnItem(),b._currentMode().onDataChanged&&b._currentMode().onDataChanged(),this.items.each(function(c,d){a&&d.parentNode&&d.parentNode.parentNode&&d.parentNode.parentNode.removeChild(d.parentNode),b._itemsManager.releaseItem(d),h._disposeElement(d)}),this.items.removeItems(),this._deferredReparenting=[],a&&b._groups.removeElements(),b._clearInsertedItems()}},reset:function(){if(this.stopWork(!0),this._state=new w(this),this.resetItems(),!this._listView._isZombie()){var a=this._listView;a._groups.resetGroups(),a._resetCanvas(),this.tree=null,this.keyToGroupIndex=null,this.containers=null,this._expandedRange=null}},cleanUp:function(){this.stopWork(!0),this._runningAnimations&&this._runningAnimations.cancel();var a=this._listView._itemsManager;this.items.each(function(b,c){a.releaseItem(c),h._disposeElement(c)}),this._listView._unsetFocusOnItem(),this.items.removeItems(),this._deferredReparenting=[],this._listView._groups.resetGroups(),this._listView._resetCanvas(),this.tree=null,this.keyToGroupIndex=null,this.containers=null,this._expandedRange=null,this.destroyed=!0},getContainer:function(a){return this.containers[a]},_getHeaderContainer:function(a){return this.tree[a].header},_getGroups:function(a){if(this._listView._groupDataSource){var b=this._listView._groups.groups,c=[];if(a)for(var d=0,e=b.length;e>d;d++){var f=b[d],g=e>d+1?b[d+1].startIndex:a;c.push({key:f.key,size:g-f.startIndex})}return c}return[{key:"-1",size:a}]},_createChunk:function(a,b,c){function d(a,b){var d=a.element.children,e=d.length,g=Math.min(b-a.items.length,c);j.insertAdjacentHTMLUnsafe(a.element,"beforeend",n._repeat("<div class='win-container win-backdrop'></div>",g));for(var h=0;g>h;h++){var i=d[e+h];a.items.push(i),f.containers.push(i)}}function e(a){var b={header:f._listView._groupDataSource?f._createHeaderContainer():null,itemsContainer:{element:f._createItemsContainer(),items:[]}};f.tree.push(b),f.keyToGroupIndex[a.key]=f.tree.length-1,d(b.itemsContainer,a.size)}var f=this;if(this._listView._writeProfilerMark("createChunk,StartTM"),this.tree.length&&this.tree.length<=a.length){var g=this.tree[this.tree.length-1],h=a[this.tree.length-1].size;if(g.itemsContainer.items.length<h)return d(g.itemsContainer,h),void this._listView._writeProfilerMark("createChunk,StopTM")}this.tree.length<a.length&&e(a[this.tree.length]),this._listView._writeProfilerMark("createChunk,StopTM")},_createChunkWithBlocks:function(a,c,d,e){function f(a,c){var f=a.itemsBlocks.length?a.itemsBlocks[a.itemsBlocks.length-1]:null;if(f&&f.items.length<d){var g=Math.min(c,d-f.items.length);j.insertAdjacentHTMLUnsafe(f.element,"beforeend",n._repeat("<div class='win-container win-backdrop'></div>",g));var i=f.items.length;s=f.element.children;for(var k=0;g>k;k++){var l=s[i+k];f.items.push(l),h.containers.push(l)}c-=g}c>e&&(c=Math.min(c,Math.max(1,Math.floor(e/d))*d));var m=Math.floor(c/d),o=c%d,p="<div class='win-itemsblock'>"+n._repeat("<div class='win-container win-backdrop'></div>",d)+"</div>",q=n._repeat(p,m);o&&(q+="<div class='win-itemsblock'>"+n._repeat("<div class='win-container win-backdrop'></div>",o)+"</div>",m++);var r=b.document.createElement("div");j.setInnerHTMLUnsafe(r,q);for(var s=r.children,t=0;m>t;t++){var u=s[t],v={element:u,items:n._nodeListToArray(u.children)};a.itemsBlocks.push(v);for(var w=0;w<v.items.length;w++)h.containers.push(v.items[w])}}function g(a){var b={header:h._listView._groupDataSource?h._createHeaderContainer():null,itemsContainer:{element:h._createItemsContainer(),itemsBlocks:[]}};h.tree.push(b),h.keyToGroupIndex[a.key]=h.tree.length-1,f(b.itemsContainer,a.size)}var h=this;if(this._listView._writeProfilerMark("createChunk,StartTM"),this.tree.length&&this.tree.length<=a.length){var i=this.tree[this.tree.length-1].itemsContainer,k=a[this.tree.length-1].size,l=0;if(i.itemsBlocks.length&&(l=(i.itemsBlocks.length-1)*d+i.itemsBlocks[i.itemsBlocks.length-1].items.length),k>l)return f(i,k-l),void this._listView._writeProfilerMark("createChunk,StopTM")}this.tree.length<a.length&&g(a[this.tree.length]),this._listView._writeProfilerMark("createChunk,StopTM")},_generateCreateContainersWorker:function(){var a=this,b=0,c=!1;return function e(f){a._listView._versionManager.locked?f.setPromise(a._listView._versionManager.unlocked.then(function(){return e})):a._listView._itemsCount().then(function(g){var h=!c&&r(a._listView);if(h)f.setPromise(s(a._listView).then(function(a){return c=a,e}));else{if(a._listView._isZombie())return;c=!1;var i=d._now()+v._createContainersJobTimeslice,j=a._getGroups(g),k=a.containers.length,l=a.end===a.containers.length,m=v._chunkSize;do a._blockSize?a._createChunkWithBlocks(j,g,a._blockSize,m):a._createChunk(j,g,m),b++;while(a.containers.length<g&&d._now()<i);a._listView._writeProfilerMark("createContainers yields containers("+a.containers.length+"),info"),a._listView._affectedRange.add({start:k,end:a.containers.length},g),l?(a.stopWork(),a._listView._writeProfilerMark(a._state.name+"_relayout,info"),a._state.relayout()):(a._listView._writeProfilerMark(a._state.name+"_layoutNewContainers,info"),a._state.layoutNewContainers()),a.containers.length<g?f.setWork(e):(a._listView._writeProfilerMark("createContainers completed steps("+b+"),info"),a._creatingContainersWork.complete())}})}},_scheduleLazyTreeCreation:function(){return g.schedule(this._generateCreateContainersWorker(),g.Priority.idle,this,"WinJS.UI.ListView.LazyTreeCreation")},_createContainers:function(){this.tree=null,this.keyToGroupIndex=null,this.containers=null,this._expandedRange=null;var a,b=this;return this._listView._itemsCount().then(function(c){return 0===c&&b._listView._hideProgressBar(),a=c,b._listView._writeProfilerMark("createContainers("+a+"),StartTM"),b._listView._groupDataSource?b._listView._groups.initialize():void 0}).then(function(){return b._listView._writeProfilerMark("numberOfItemsPerItemsBlock,StartTM"),a&&b._listView._groups.length()?b._listView._layout.numberOfItemsPerItemsBlock:null}).then(function(c){b._listView._writeProfilerMark("numberOfItemsPerItemsBlock("+c+"),info"),b._listView._writeProfilerMark("numberOfItemsPerItemsBlock,StopTM"),b._listView._resetCanvas(),b.tree=[],b.keyToGroupIndex={},b.containers=[],b._blockSize=c;var e,f=b._getGroups(a),g=d._now()+v._maxTimePerCreateContainers,h=Math.min(v._startupChunkSize,v._chunkSize);do e=c?b._createChunkWithBlocks(f,a,c,h):b._createChunk(f,a,h);while(d._now()<g&&b.containers.length<a&&!e);if(b._listView._writeProfilerMark("createContainers created("+b.containers.length+"),info"),b._listView._affectedRange.add({start:0,end:b.containers.length},a),b.containers.length<a){var i=b._scheduleLazyTreeCreation();b._creatingContainersWork.promise.done(null,function(){i.cancel()})}else b._listView._writeProfilerMark("createContainers completed synchronously,info"),b._creatingContainersWork.complete();b._listView._writeProfilerMark("createContainers("+a+"),StopTM")})},_updateItemsBlocks:function(a){function c(){var a=b.document.createElement("div");return a.className=l._itemsBlockClass,a}function d(b,d){function g(){b.itemsBlocks=null,b.items=[];for(var a=0;k>a;a++){var c=e.containers[d+a];b.element.appendChild(c),b.items.push(c)}}function h(){b.itemsBlocks=[{element:j.length?j.shift():c(),items:[]}];for(var f=b.itemsBlocks[0],g=0;k>g;g++){if(f.items.length===a){var h=j.length?j.shift():c();b.itemsBlocks.push({element:h,items:[]}),f=b.itemsBlocks[b.itemsBlocks.length-1]}var i=e.containers[d+g];f.element.appendChild(i),f.items.push(i)}b.items=null}var i,j=[],k=0,l=b.itemsBlocks;if(l)for(i=0;i<l.length;i++)k+=l[i].items.length,j.push(l[i].element);else k=b.items.length;for(f?h():g(),i=0;i<j.length;i++){var m=j[i];m.parentNode===b.element&&b.element.removeChild(m)}return k}for(var e=this,f=!!a,g=0,h=0;g<this.tree.length;g++)h+=d(this.tree[g].itemsContainer,h);e._blockSize=a},_layoutItems:function(){var a=this;return this._listView._itemsCount().then(function(){return e.as(a._listView._layout.numberOfItemsPerItemsBlock).then(function(b){a._listView._writeProfilerMark("numberOfItemsPerItemsBlock("+b+"),info"),b!==a._blockSize&&(a._updateItemsBlocks(b),a._listView._itemsBlockExtent=-1);var c,d=a._listView._affectedRange.get();return d&&(c={firstIndex:Math.max(d.start-1,0),lastIndex:Math.min(a.containers.length-1,d.end)},c.firstIndex<a.containers.length||0===a.containers.length)?a._listView._layout.layout(a.tree,c,a._modifiedElements||[],a._modifiedGroups||[]):(a._listView._affectedRange.clear(),{realizedRangeComplete:e.wrap(),layoutComplete:e.wrap()})})})},updateTree:function(a,b,c){return this._listView._writeProfilerMark(this._state.name+"_updateTree,info"),this._state.updateTree(a,b,c)},_updateTreeImpl:function(a,c,d,e){function f(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];d.parentNode.removeChild(d)}}if(this._executeAnimations=!0,this._modifiedElements=d,!d.handled){d.handled=!0,this._listView._writeProfilerMark("_updateTreeImpl,StartTM");var g,h=this;e||this._unrealizeItems();for(var g=0,j=d.length;j>g;g++)d[g]._itemBox&&d[g]._itemBox.parentNode&&i.removeClass(d[g]._itemBox.parentNode,l._selectedClass);this.items.each(function(a,b,c){c.container&&i.removeClass(c.container,l._selectedClass),c.container&&i.addClass(c.container,l._backdropClass)});var k=this._listView._updateContainers(this._getGroups(a),a,c,d);f(k.removedHeaders),f(k.removedItemsContainers);for(var g=0,j=d.length;j>g;g++){var n=d[g];if(-1!==n.newIndex){if(n.element=this.getContainer(n.newIndex),!n.element)throw"Container missing after updateContainers."}else i.removeClass(n.element,l._backdropClass)}var o=b.document.activeElement;this._listView._canvas.contains(o)&&(this._requireFocusRestore=o),this._deferredReparenting=[],this.items.each(function(a,b,c){var d=h.getContainer(a),e=c.itemBox;e&&d&&(e.parentNode!==d&&(a>=h.firstIndexDisplayed&&a<=h.lastIndexDisplayed?h._appendAndRestoreFocus(d,e):h._deferredReparenting.push({itemBox:e,container:d})),i.removeClass(d,l._backdropClass),c.container=d,i[h._listView.selection._isIncluded(a)?"addClass":"removeClass"](d,l._selectedClass),!h._listView.selection._isIncluded(a)&&i.hasClass(e,l._selectedClass)&&m._ItemEventsHandler.renderSelection(e,c.element,!1,!0))}),this._listView._writeProfilerMark("_updateTreeImpl,StopTM")}},_completeUpdateTree:function(){if(this._deferredReparenting){var a=this._deferredReparenting.length;if(a>0){var b="_completeReparenting("+a+")";this._listView._writeProfilerMark(b+",StartTM");for(var c,d=0;a>d;d++)c=this._deferredReparenting[d],this._appendAndRestoreFocus(c.container,c.itemBox);this._deferredReparenting=[],this._listView._writeProfilerMark(b+",StopTM")}}this._requireFocusRestore=null},_appendAndRestoreFocus:function(a,c){if(c.parentNode!==a){var d;if(this._requireFocusRestore&&(d=b.document.activeElement),this._requireFocusRestore&&this._requireFocusRestore===d&&(a.contains(d)||c.contains(d))&&(this._listView._unsetFocusOnItem(),d=b.document.activeElement),i.empty(a),a.appendChild(c),this._requireFocusRestore&&d===this._listView._keyboardEventsHelper){var e=this._listView._selection._getFocused();e.type===k.ObjectType.item&&this.items.itemBoxAt(e.index)===c&&(i._setActive(this._requireFocusRestore),this._requireFocusRestore=null)}}},_startAnimations:function(){this._listView._writeProfilerMark("startAnimations,StartTM");var a=this;this._hasAnimationInViewportPending=!1;var b=e.as(this._listView._layout.executeAnimations()).then(function(){a._listView._writeProfilerMark("startAnimations,StopTM")});return b},_setState:function(a,b){if(!this._listView._isZombie()){var c=this._state.name;this._state=new a(this,b),this._listView._writeProfilerMark(this._state.name+"_enter from("+c+"),info"),this._state.enter()}},getAdjacent:function(a,b){var c=this;return this.waitForEntityPosition(a).then(function(){return c._listView._layout.getAdjacent(a,b)})},hitTest:function(a,b){if(this._realizedRangeLaidOut)return{index:-1,insertAfterIndex:-1};var c=this._listView._layout.hitTest(a,b);return c.index=i._clamp(c.index,-1,this._listView._cachedCount-1,0),c.insertAfterIndex=i._clamp(c.insertAfterIndex,-1,this._listView._cachedCount-1,0),c},_createTreeBuildingSignal:function(){if(!this._creatingContainersWork){this._creatingContainersWork=new f;var a=this;this._creatingContainersWork.promise.done(function(){a._creatingContainersWork=null},function(){a._creatingContainersWork=null})}},_createLayoutSignal:function(){var a=this;this._layoutCompleted||(this._layoutCompleted=new f,this._layoutCompleted.promise.done(function(){a._layoutCompleted=null},function(){a._layoutCompleted=null})),this._realizedRangeLaidOut||(this._realizedRangeLaidOut=new f,this._realizedRangeLaidOut.promise.done(function(){a._realizedRangeLaidOut=null},function(){a._realizedRangeLaidOut=null}))},_getLayoutCompleted:function(){return this._layoutCompleted?e._cancelBlocker(this._layoutCompleted.promise):e.wrap()},_createSurfaceChild:function(a,c){var d=b.document.createElement("div");return d.className=a,this._listView._canvas.insertBefore(d,c?c.nextElementSibling:null),d},_executeScrollToFunctor:function(){var a=this;return e.as(this._scrollToFunctor?this._scrollToFunctor():null).then(function(b){a._scrollToFunctor=null,b=b||{},+b.position===b.position&&(a._scrollbarPos=b.position),a._direction=b.direction||"right"})}},{_pagesToPrefetch:2,_customPagesToPrefetchMax:6,_customPagesToPrefetchMin:2,_disableCustomPagesPrefetch:!1,_waitForSeZoIntervalDuration:100,_waitForSeZoTimeoutDuration:500,_chunkSize:500,_startupChunkSize:100,_maxTimePerCreateContainers:5,_createContainersJobTimeslice:15,_blocksToRelease:10,_realizationLevel:{skip:"skip",realize:"realize",normal:"normal"}}),w=c.Class.define(function(a){this.view=a,this.view._createTreeBuildingSignal(),this.view._createLayoutSignal()},{name:"CreatedState",enter:function(){this.view._createTreeBuildingSignal(),this.view._createLayoutSignal()},stop:u,realizePage:u,rebuildTree:function(){this.view._setState(x)},relayout:function(){this.view._setState(x)},layoutNewContainers:u,waitForEntityPosition:function(){return this.view._setState(x),this.view._getLayoutCompleted()},updateTree:u}),x=c.Class.define(function(a){this.view=a},{name:"BuildingState",enter:function(){this.canceling=!1,this.view._createTreeBuildingSignal(),this.view._createLayoutSignal();var a=this,b=new f;this.promise=b.promise.then(function(){return a.view._createContainers()}).then(function(){a.view._setState(y)},function(b){return a.canceling||(a.view._setState(w),a.view._listView._raiseViewComplete()),e.wrapError(b)}),b.complete()},stop:function(){this.canceling=!0,this.promise.cancel(),this.view._setState(w)},realizePage:u,rebuildTree:function(){this.canceling=!0,this.promise.cancel(),this.enter()},relayout:u,layoutNewContainers:u,waitForEntityPosition:function(){return this.view._getLayoutCompleted()
  },updateTree:u}),y=c.Class.define(function(a,b){this.view=a,this.nextStateType=b||A},{name:"LayingoutState",enter:function(){var a=this;this.canceling=!1,this.view._createLayoutSignal(),this.view._listView._writeProfilerMark(this.name+"_enter_layoutItems,StartTM");var b=new f;this.promise=b.promise.then(function(){return a.view._layoutItems()}).then(function(b){return a.view._layoutWork=b.layoutComplete,b.realizedRangeComplete}).then(function(){a.view._listView._writeProfilerMark(a.name+"_enter_layoutItems,StopTM"),a.view._listView._clearInsertedItems(),a.view._setAnimationInViewportState(a.view._modifiedElements),a.view._modifiedElements=[],a.view._modifiedGroups=[],a.view._realizedRangeLaidOut.complete(),a.view._layoutWork.then(function(){a.view._listView._writeProfilerMark(a.name+"_enter_layoutCompleted,info"),a.view._listView._affectedRange.clear(),a.view._layoutCompleted.complete()}),a.canceling||a.view._setState(a.nextStateType)},function(b){return a.view._listView._writeProfilerMark(a.name+"_enter_layoutCanceled,info"),a.canceling||(a.view.firstIndexDisplayed=a.view.lastIndexDisplayed=-1,a.view._updateAriaMarkers(!0,a.view.firstIndexDisplayed,a.view.lastIndexDisplayed),a.view._setState(G)),e.wrapError(b)}),b.complete(),this.canceling&&this.promise.cancel()},cancelLayout:function(a){this.view._listView._writeProfilerMark(this.name+"_cancelLayout,info"),this.canceling=!0,this.promise&&this.promise.cancel(),a&&this.view._setState(z)},stop:function(){this.cancelLayout(!0)},realizePage:u,rebuildTree:function(){this.cancelLayout(!1),this.view._setState(x)},relayout:function(){this.cancelLayout(!1),this.enter()},layoutNewContainers:function(){this.relayout()},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),z=c.Class.define(function(a){this.view=a},{name:"LayoutCanceledState",enter:u,stop:u,realizePage:function(){this.relayout()},rebuildTree:function(){this.view._setState(x)},relayout:function(){this.view._setState(y)},layoutNewContainers:function(){this.relayout()},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),A=c.Class.define(function(a){this.view=a,this.nextState=E,this.relayoutNewContainers=!0},{name:"RealizingState",enter:function(){var a=this,b=new f;this.promise=b.promise.then(function(){return a.view._executeScrollToFunctor()}).then(function(){return a.relayoutNewContainers=!1,e._cancelBlocker(a.view._realizePageImpl())}).then(function(){a.view._state===a&&(a.view._completeUpdateTree(),a.view._listView._writeProfilerMark("RealizingState_to_UnrealizingState"),a.view._setState(a.nextState))},function(b){return a.view._state!==a||a.canceling||(a.view._listView._writeProfilerMark("RealizingState_to_CanceledState"),a.view._setState(B)),e.wrapError(b)}),b.complete()},stop:function(){this.canceling=!0,this.promise.cancel(),this.view._cancelRealize(),this.view._setState(B)},realizePage:function(){this.canceling=!0,this.promise.cancel(),this.enter()},rebuildTree:function(){this.stop(),this.view._setState(x)},relayout:function(){this.stop(),this.view._setState(y)},layoutNewContainers:function(){this.relayoutNewContainers?this.relayout():(this.view._createLayoutSignal(),this.view._relayoutInComplete=!0)},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)},setLoadingState:function(a){this.view._listView._setViewState(a)}}),B=c.Class.define(function(a){this.view=a},{name:"CanceledState",enter:u,stop:function(){this.view._cancelRealize()},realizePage:function(a){this.stop(),this.view._setState(a)},rebuildTree:function(){this.stop(),this.view._setState(x)},relayout:function(a){this.stop(),this.view._setState(y,a)},layoutNewContainers:function(){this.relayout(B)},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),C=c.Class.derive(A,function(a){this.view=a,this.nextState=D,this.relayoutNewContainers=!0},{name:"ScrollingState",setLoadingState:function(){}}),D=c.Class.derive(B,function(a){this.view=a},{name:"ScrollingPausedState",enter:function(){var a=this;this.promise=e._cancelBlocker(this.view._scrollEndPromise).then(function(){a.view._setState(E)})},stop:function(){this.promise.cancel(),this.view._cancelRealize()}}),E=c.Class.define(function(a){this.view=a},{name:"UnrealizingState",enter:function(){var a=this;this.promise=this.view._lazilyUnrealizeItems().then(function(){return a.view._listView._writeProfilerMark("_renderCompletePromise wait starts,info"),a.view._renderCompletePromise}).then(function(){a.view._setState(G)})},stop:function(){this.view._cancelRealize(),this.promise.cancel(),this.view._setState(B)},realizePage:function(a){this.promise.cancel(),this.view._setState(a)},rebuildTree:function(){this.view._setState(x)},relayout:function(){this.view._setState(y)},layoutNewContainers:function(){this.view._createLayoutSignal(),this.view._relayoutInComplete=!0},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),F=c.Class.define(function(a,b){this.view=a,this.realizePromise=b,this.realizeId=1},{name:"RealizingAnimatingState",enter:function(){var a=this;this.animating=!0,this.animatePromise=this.view._startAnimations(),this.animateSignal=new f,this.view._executeAnimations=!1,this.animatePromise.done(function(){a.animating=!1,a.modifiedElements?(a.view._updateTreeImpl(a.count,a.delta,a.modifiedElements),a.modifiedElements=null,a.view._setState(B)):a.animateSignal.complete()},function(b){return a.animating=!1,e.wrapError(b)}),this._waitForRealize()},_waitForRealize:function(){var a=this;this.realizing=!0,this.realizePromise.done(function(){a.realizing=!1});var b=++this.realizeId;e.join([this.realizePromise,this.animateSignal.promise]).done(function(){b===a.realizeId&&(a.view._completeUpdateTree(),a.view._listView._writeProfilerMark("RealizingAnimatingState_to_UnrealizingState"),a.view._setState(E))})},stop:function(a){this.realizePromise.cancel(),this.view._cancelRealize(),a&&(this.animatePromise.cancel(),this.view._setState(B))},realizePage:function(){if(!this.modifiedElements){var a=this;this.realizePromise=this.view._executeScrollToFunctor().then(function(){return e._cancelBlocker(a.view._realizePageImpl())}),this._waitForRealize()}},rebuildTree:function(){this.stop(!0),this.view._setState(x)},relayout:function(){this.stop(!0),this.modifiedElements&&(this.view._updateTreeImpl(this.count,this.delta,this.modifiedElements),this.modifiedElements=null),this.view._setState(y)},layoutNewContainers:function(){this.view._createLayoutSignal(),this.view._relayoutInComplete=!0},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){if(this.animating){var d=this.modifiedElements;return this.count=a,this.delta=b,this.modifiedElements=c,d?e.cancel:this.animatePromise}return this.view._updateTreeImpl(a,b,c)},setLoadingState:function(a){this.view._listView._setViewState(a)}}),G=c.Class.derive(B,function(a){this.view=a},{name:"CompletedState",enter:function(){this._stopped=!1,this.view._setupDeferredActions(),this.view._realizationLevel=v._realizationLevel.normal,this.view._listView._raiseViewComplete(),this.view._state===this&&this.view._relayoutInComplete&&!this._stopped&&this.view._setState(H)},stop:function(){this._stopped=!0,B.prototype.stop.call(this)},layoutNewContainers:function(){this.view._createLayoutSignal(),this.view._setState(H)},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c,!0)}}),H=c.Class.derive(B,function(a){this.view=a},{name:"LayingoutNewContainersState",enter:function(){var a=this;this.promise=e.join([this.view.deferTimeout,this.view._layoutWork]),this.promise.then(function(){a.view._relayoutInComplete=!1,a.relayout(B)})},stop:function(){this.promise.cancel(),this.view._cancelRealize()},realizePage:function(a){this.stop(),this.view._setState(y,a)},layoutNewContainers:function(){this.view._createLayoutSignal()}});return v})})}),d("require-style!less/desktop/controls",[],function(){}),d("require-style!less/phone/controls",[],function(){}),d("WinJS/Controls/ListView",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Animations/_TransitionAnimation","../BindingList","../Promise","../Scheduler","../_Signal","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_ItemsManager","../Utilities/_SafeHtml","../Utilities/_TabContainer","../Utilities/_UI","../Utilities/_VersionManager","./ItemContainer/_Constants","./ItemContainer/_ItemEventsHandler","./ListView/_BrowseMode","./ListView/_ErrorMessages","./ListView/_GroupFocusCache","./ListView/_GroupsContainer","./ListView/_Helpers","./ListView/_ItemsContainer","./ListView/_Layouts","./ListView/_SelectionManager","./ListView/_VirtualizeContentsView","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G){"use strict";function H(){var a=N;N=[],a=a.filter(function(a){return a._isZombie()?(a._dispose(),!1):!0}),N=N.concat(a)}function I(a){N.push(a),K&&K.cancel(),K=k.timeout(M).then(H)}function J(a){return a.offsetParent?a.offsetParent.offsetWidth-a.offsetLeft-a.offsetWidth:0}var K,L=c._browserStyleEquivalents.transform,M=1e3,N=[],O=p._uniqueID,P=C._ListViewAnimationHelper,Q={get notCompatibleWithSemanticZoom(){return"ListView can only be used with SemanticZoom if randomAccess loading behavior is specified."},get listViewInvalidItem(){return"Item must provide index, key or description of corresponding item."},get listViewViewportAriaLabel(){return g._getWinJSString("ui/listViewViewportAriaLabel").value}},R=c.requireSupportedForProcessing,S={entrance:"entrance",contentTransition:"contentTransition"};b.Namespace.define("WinJS.UI",{ListViewAnimationType:S,ListView:b.Namespace._lazy(function(){var g=b.Class.define(function(){this.clear()},{add:function(a,b){if(a._lastKnownSizeOfData=b,this._range){this._range.start=Math.min(this._range.start,a.start);var c=this._range._lastKnownSizeOfData-this._range.end,d=a._lastKnownSizeOfData-a.end,e=Math.min(c,d);this._range._lastKnownSizeOfData=a._lastKnownSizeOfData,this._range.end=this._range._lastKnownSizeOfData-e}else this._range=a},addAll:function(){this.add({start:0,end:Number.MAX_VALUE},Number.MAX_VALUE)},clear:function(){this._range=null},get:function(){return this._range}}),q=b.Class.define(function(a){this._listView=a},{getPanAxis:function(){return this._listView._getPanAxis()},configureForZoom:function(a,b,c,d){this._listView._configureForZoom(a,b,c,d)},setCurrentItem:function(a,b){this._listView._setCurrentItem(a,b)},getCurrentItem:function(){return this._listView._getCurrentItem()},beginZoom:function(){return this._listView._beginZoom()},positionItem:function(a,b){return this._listView._positionItem(a,b)},endZoom:function(a){this._listView._endZoom(a)},pinching:{get:function(){return this._listView._pinching},set:function(a){this._listView._pinching=a}}}),D=b.Class.define(function(b,c){if(b=b||a.document.createElement("div"),p._supportsTouchActionCrossSlide&&b.classList.add(w._listViewSupportsCrossSlideClass),this._id=b.id||"",this._writeProfilerMark("constructor,StartTM"),c=c||{},b.winControl=this,p.addClass(b,"win-disposable"),this._affectedRange=new g,this._mutationObserver=new p._MutationObserver(this._itemPropertyChange.bind(this)),this._versionManager=null,this._insertedItems={},this._element=b,this._startProperty=null,this._scrollProperty=null,this._scrollLength=null,this._scrolling=!1,this._zooming=!1,this._pinching=!1,this._itemsManager=null,this._canvas=null,this._cachedCount=w._UNINITIALIZED,this._loadingState=this._LoadingState.complete,this._firstTimeDisplayed=!0,this._currentScrollPosition=0,this._lastScrollPosition=0,this._notificationHandlers=[],this._itemsBlockExtent=-1,this._viewportWidth=w._UNINITIALIZED,this._viewportHeight=w._UNINITIALIZED,this._manipulationState=p._MSManipulationEvent.MS_MANIPULATION_STATE_STOPPED,this._maxDeferredItemCleanup=Number.MAX_VALUE,this._groupsToRemove={},this._setupInternalTree(),this._isCurrentZoomView=!0,this._dragSource=!1,this._reorderable=!1,this._groupFocusCache=new A._UnsupportedGroupFocusCache,this._viewChange=w._ViewChange.rebuild,this._scrollToFunctor=null,this._setScrollbarPosition=!1,this._view=new G._VirtualizeContentsView(this),this._selection=new F._SelectionManager(this),this._createTemplates(),this._groupHeaderRenderer=r._trivialHtmlRenderer,this._itemRenderer=r._trivialHtmlRenderer,this._groupHeaderRelease=null,this._itemRelease=null,c.itemDataSource)this._dataSource=c.itemDataSource;else{var d=new j.List;this._dataSource=d.dataSource}this._selectionMode=u.SelectionMode.multi,this._tap=u.TapBehavior.invokeOnly,this._groupHeaderTap=u.GroupHeaderTapBehavior.invoke,this._swipeBehavior=u.SwipeBehavior.select,this._mode=new y._SelectionMode(this),this._setSwipeClass(),this._groups=new B._NoGroups(this),this._updateItemsAriaRoles(),this._updateGroupHeadersAriaRoles(),this._element.setAttribute("aria-multiselectable",this._multiSelection()),this._element.tabIndex=-1,this._tabManager.tabIndex=this._tabIndex,"absolute"!==this._element.style.position&&"relative"!==this._element.style.position&&(this._element.style.position="relative"),this._updateItemsManager(),c.layout||this._updateLayout(new E.GridLayout),this._attachEvents(),this._runningInit=!0,n.setOptions(this,c),this._runningInit=!1,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},layout:{get:function(){return this._layoutImpl},set:function(a){this._updateLayout(a),this._runningInit||(this._view.reset(),this._updateItemsManager(),this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},pagesToLoad:{get:function(){return 2*G._VirtualizeContentsView._pagesToPrefetch+1},set:function(){p._deprecated(z.pagesToLoadIsDeprecated)}},pagesToLoadThreshold:{get:function(){return 0},set:function(){p._deprecated(z.pagesToLoadThresholdIsDeprecated)}},groupDataSource:{get:function(){return this._groupDataSource},set:function(a){function b(a){a.detail===u.DataSourceStatus.failure&&(c.itemDataSource=null,c.groupDataSource=null)}this._writeProfilerMark("set_groupDataSource,info");var c=this;this._groupDataSource&&this._groupDataSource.removeEventListener&&this._groupDataSource.removeEventListener("statuschanged",b,!1),this._groupDataSource=a,this._groupFocusCache=a&&this._supportsGroupHeaderKeyboarding?new A._GroupFocusCache(this):new A._UnsupportedGroupFocusCache,this._groupDataSource&&this._groupDataSource.addEventListener&&this._groupDataSource.addEventListener("statuschanged",b,!1),this._createGroupsContainer(),this._runningInit?(this._updateGroupWork(),this._resetLayout()):(this._view.reset(),this._pendingLayoutReset=!0,this._pendingGroupWork=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},_updateGroupWork:function(){this._pendingGroupWork=!1,this._groupDataSource?p.addClass(this._element,w._groupsClass):p.removeClass(this._element,w._groupsClass),this._resetLayout()},automaticallyLoadPages:{get:function(){return!1},set:function(){p._deprecated(z.automaticallyLoadPagesIsDeprecated)}},loadingBehavior:{get:function(){return"randomAccess"},set:function(){p._deprecated(z.loadingBehaviorIsDeprecated)}},selectionMode:{get:function(){return this._selectionMode},set:function(a){if("string"==typeof a&&a.match(/^(none|single|multi)$/)){if(c.isPhone&&a===u.SelectionMode.single)return;return this._selectionMode=a,this._element.setAttribute("aria-multiselectable",this._multiSelection()),this._updateItemsAriaRoles(),this._setSwipeClass(),void this._configureSelectionMode()}throw new d("WinJS.UI.ListView.ModeIsInvalid",z.modeIsInvalid)}},tapBehavior:{get:function(){return this._tap},set:function(a){c.isPhone&&a===u.TapBehavior.directSelect||(this._tap=a,this._updateItemsAriaRoles(),this._configureSelectionMode())}},groupHeaderTapBehavior:{get:function(){return this._groupHeaderTap},set:function(a){this._groupHeaderTap=a,this._updateGroupHeadersAriaRoles()}},swipeBehavior:{get:function(){return this._swipeBehavior},set:function(a){this._swipeBehavior=a,this._setSwipeClass()}},itemDataSource:{get:function(){return this._itemsManager.dataSource},set:function(a){this._writeProfilerMark("set_itemDataSource,info"),this._dataSource=a||(new j.List).dataSource,this._groupFocusCache.clear(),this._runningInit||(this._selection._reset(),this._cancelAsyncViewWork(!0),this._updateItemsManager(),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},itemTemplate:{get:function(){return this._itemRenderer},set:function(a){this._setRenderer(a,!1),this._runningInit||(this._cancelAsyncViewWork(!0),this._updateItemsManager(),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},resetItem:{get:function(){return this._itemRelease},set:function(a){p._deprecated(z.resetItemIsDeprecated),this._itemRelease=a}},groupHeaderTemplate:{get:function(){return this._groupHeaderRenderer},set:function(a){this._setRenderer(a,!0),this._runningInit||(this._cancelAsyncViewWork(!0),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},resetGroupHeader:{get:function(){return this._groupHeaderRelease},set:function(a){p._deprecated(z.resetGroupHeaderIsDeprecated),this._groupHeaderRelease=a}},loadingState:{get:function(){return this._loadingState}},selection:{get:function(){return this._selection}},indexOfFirstVisible:{get:function(){return this._view.firstIndexDisplayed},set:function(a){if(!(0>a)){this._writeProfilerMark("set_indexOfFirstVisible("+a+"),info"),this._raiseViewLoading(!0);var b=this;this._batchViewUpdates(w._ViewChange.realize,w._ScrollToPriority.high,function(){var c;return b._entityInRange({type:u.ObjectType.item,index:a}).then(function(a){return a.inRange?b._getItemOffset({type:u.ObjectType.item,index:a.index}).then(function(a){return c=a,b._ensureFirstColumnRange(u.ObjectType.item)}).then(function(){return c=b._correctRangeInFirstColumn(c,u.ObjectType.item),c=b._convertFromCanvasCoordinates(c),b._view.waitForValidScrollPosition(c.begin)}).then(function(a){var c=a<b._lastScrollPosition?"left":"right",d=b._viewport[b._scrollLength]-b._getViewportLength();return a=p._clamp(a,0,d),{position:a,direction:c}}):{position:0,direction:"left"}})},!0)}}},indexOfLastVisible:{get:function(){return this._view.lastIndexDisplayed}},currentItem:{get:function(){var a=this._selection._getFocused(),b={index:a.index,type:a.type,key:null,hasFocus:!!this._hasKeyboardFocus,showFocus:!1};if(a.type===u.ObjectType.groupHeader){var c=this._groups.group(a.index);c&&(b.key=c.key,b.showFocus=!(!c.header||!p.hasClass(c.header,w._itemFocusClass)))}else{var d=this._view.items.itemAt(a.index);if(d){var e=this._itemsManager._recordFromElement(d);b.key=e.item&&e.item.key,b.showFocus=!!d.parentNode.querySelector("."+w._itemFocusOutlineClass)}}return b},set:function(a){function b(b,d,e){var f=!!a.showFocus&&c._hasKeyboardFocus;c._unsetFocusOnItem(d),c._selection._setFocused(e,f),c._hasKeyboardFocus?(c._keyboardFocusInbound=f,c._setFocusOnItem(e)):c._tabManager.childFocus=d?b:null,e.type!==u.ObjectType.groupHeader&&(c._updateFocusCache(e.index),c._updater&&(c._updater.newSelectionPivot=e.index,c._updater.oldSelectionPivot=-1),c._selection._pivot=e.index)}this._hasKeyboardFocus=a.hasFocus||this._hasKeyboardFocus;var c=this;if(a.key&&(a.type!==u.ObjectType.groupHeader&&this._dataSource.itemFromKey||a.type===u.ObjectType.groupHeader&&this._groupDataSource&&this._groupDataSource.itemFromKey)){this.oldCurrentItemKeyFetch&&this.oldCurrentItemKeyFetch.cancel();var d=a.type===u.ObjectType.groupHeader?this._groupDataSource:this._dataSource;this.oldCurrentItemKeyFetch=d.itemFromKey(a.key).then(function(d){if(c.oldCurrentItemKeyFetch=null,d){var e=a.type===u.ObjectType.groupHeader?c._groups.group(d.index).header:c._view.items.itemAt(d.index);b(e,!!e,{type:a.type||u.ObjectType.item,index:d.index})}})}else if(void 0!==a.index){var e;if(a.type===u.ObjectType.groupHeader){var f=c._groups.group(a.index);e=f&&f.header}else e=c._view.items.itemAt(a.index);b(e,!!e,{type:a.type||u.ObjectType.item,index:a.index})}}},zoomableView:{get:function(){return this._zoomableView||(this._zoomableView=new q(this)),this._zoomableView}},itemsDraggable:{get:function(){return this._dragSource},set:function(a){c.isPhone||this._dragSource!==a&&(this._dragSource=a,this._setSwipeClass())}},itemsReorderable:{get:function(){return this._reorderable},set:function(a){c.isPhone||this._reorderable!==a&&(this._reorderable=a,this._setSwipeClass())}},maxDeferredItemCleanup:{get:function(){return this._maxDeferredItemCleanup},set:function(a){this._maxDeferredItemCleanup=Math.max(0,+a||0)}},dispose:function(){this._dispose()},elementFromIndex:function(a){return this._view.items.itemAt(a)},indexOfElement:function(a){return this._view.items.index(a)},ensureVisible:function(a){var b=u.ObjectType.item,c=a;if(+a!==a&&(b=a.type,c=a.index),this._writeProfilerMark("ensureVisible("+b+": "+c+"),info"),!(0>c)){this._raiseViewLoading(!0);var d=this;this._batchViewUpdates(w._ViewChange.realize,w._ScrollToPriority.high,function(){var a;return d._entityInRange({type:b,index:c}).then(function(c){return c.inRange?d._getItemOffset({type:b,index:c.index}).then(function(c){return a=c,d._ensureFirstColumnRange(b)}).then(function(){a=d._correctRangeInFirstColumn(a,b);var e=d._getViewportLength(),f=d._viewportScrollPosition,g=f+e,h=d._viewportScrollPosition,i=a.end-a.begin;a=d._convertFromCanvasCoordinates(a);var j=!1;if(b===u.ObjectType.groupHeader&&f<=a.begin){var k=d._groups.group(c.index).header;if(k){var l,m=E._getMargins(k);if(d._horizontalLayout){var n=d._rtl(),o=n?J(k)-m.right:k.offsetLeft-m.left;l=o+k.offsetWidth+(n?m.left:m.right)}else l=k.offsetTop+k.offsetHeight+m.top;j=g>=l}}j||(i>=g-f?h=a.begin:a.begin<f?h=a.begin:a.end>g&&(h=a.end-e));var q=h<d._lastScrollPosition?"left":"right",r=d._viewport[d._scrollLength]-e;return h=p._clamp(h,0,r),{position:h,direction:q}}):{position:0,direction:"left"}})},!0)}},loadMorePages:function(){p._deprecated(z.loadMorePagesIsDeprecated)},recalculateItemPosition:function(){this._writeProfilerMark("recalculateItemPosition,info"),this._forceLayoutImpl(w._ViewChange.relayout)},forceLayout:function(){this._writeProfilerMark("forceLayout,info"),this._forceLayoutImpl(w._ViewChange.remeasure)},_entityInRange:function(a){if(a.type===u.ObjectType.item)return this._itemsCount().then(function(b){var c=p._clamp(a.index,0,b-1);return{inRange:c>=0&&b>c,index:c}});var b=p._clamp(a.index,0,this._groups.length()-1);return k.wrap({inRange:b>=0&&b<this._groups.length(),index:b})},_forceLayoutImpl:function(a){var b=this;this._versionManager.unlocked.then(function(){b._writeProfilerMark("_forceLayoutImpl viewChange("+a+"),info"),b._cancelAsyncViewWork(),b._pendingLayoutReset=!0,b._resizeViewport(),b._batchViewUpdates(a,w._ScrollToPriority.low,function(){return{position:b._lastScrollPosition,direction:"right"}},!0,!0)})},_configureSelectionMode:function(){c.isPhone&&(this.tapBehavior===u.TapBehavior.toggleSelect&&this.selectionMode===u.SelectionMode.multi?p.addClass(this._canvas,w._selectionModeClass):p.removeClass(this._canvas,w._selectionModeClass))},_lastScrollPosition:{get:function(){return this._lastScrollPositionValue},set:function(a){if(0===a)this._lastDirection="right",this._direction="right",this._lastScrollPositionValue=0;else{var b=a<this._lastScrollPositionValue?"left":"right";this._direction=this._scrollDirection(a),this._lastDirection=b,this._lastScrollPositionValue=a}}},_supportsGroupHeaderKeyboarding:{get:function(){return this._groupDataSource}},_viewportScrollPosition:{get:function(){return this._currentScrollPosition=p.getScrollPosition(this._viewport)[this._scrollProperty],this._currentScrollPosition},set:function(a){var b={};b[this._scrollProperty]=a,p.setScrollPosition(this._viewport,b),this._currentScrollPosition=a}},_canvasStart:{get:function(){return this._canvasStartValue||0},set:function(a){var b=this._horizontal()?this._rtl()?-a:a:0,c=this._horizontal()?0:a;this._canvas.style[L.scriptName]=0!==a?"translate( "+b+"px, "+c+"px)":"",this._canvasStartValue=a}},scrollPosition:{get:function(){return this._viewportScrollPosition},set:function(a){var b=this;this._batchViewUpdates(w._ViewChange.realize,w._ScrollToPriority.high,function(){return b._view.waitForValidScrollPosition(a).then(function(){var c=b._viewport[b._scrollLength]-b._getViewportLength();a=p._clamp(a,0,c);var d=a<b._lastScrollPosition?"left":"right";return{position:a,direction:d}})},!0)}},_setRenderer:function(a,b){var e;if(a){if("function"==typeof a)e=a;else if("object"==typeof a){if(c.validation&&!a.renderItem)throw new d("WinJS.UI.ListView.invalidTemplate",z.invalidTemplate);e=a.renderItem}}else{if(c.validation)throw new d("WinJS.UI.ListView.invalidTemplate",z.invalidTemplate);e=r.trivialHtmlRenderer}e&&(b?this._groupHeaderRenderer=e:this._itemRenderer=e)},_renderWithoutReuse:function(a,b){b&&o._disposeElement(b);var c=this._itemRenderer(a);if(c.then)return c.then(function(a){return a.tabIndex=0,a});var d=c.element||c;return d.tabIndex=0,c},_isInsertedItem:function(a){return!!this._insertedItems[a.handle]},_clearInsertedItems:function(){for(var a=Object.keys(this._insertedItems),b=0,c=a.length;c>b;b++)this._insertedItems[a[b]].release();this._insertedItems={},this._modifiedElements=[],this._countDifference=0},_cancelAsyncViewWork:function(a){this._view.stopWork(a)},_updateView:function(){function a(){c._itemsBlockExtent=-1,c._firstItemRange=null,c._firstHeaderRange=null,c._itemMargins=null,c._headerMargins=null,c._canvasMargins=null,c._cachedRTL=null,c._rtl()}function b(){c._scrollToPriority=w._ScrollToPriority.uninitialized;var a=c._setScrollbarPosition;c._setScrollbarPosition=!1;var b="number"==typeof c._scrollToFunctor?{position:c._scrollToFunctor}:c._scrollToFunctor();return k.as(b).then(function(b){return b=b||{},a&&+b.position===b.position&&(c._lastScrollPosition=b.position,c._viewportScrollPosition=b.position),b},function(b){return c._setScrollbarPosition|=a,k.wrapError(b)})}if(!this._isZombie()){var c=this,d=this._viewChange;this._viewChange=w._ViewChange.realize,d===w._ViewChange.rebuild?(this._pendingGroupWork&&this._updateGroupWork(),this._pendingLayoutReset&&this._resetLayout(),a(),this._firstTimeDisplayed||this._view.reset(),this._view.reload(b,!0),this._setFocusOnItem(this._selection._getFocused())):d===w._ViewChange.remeasure?(this._view.resetItems(!0),this._resetLayout(),a(),this._view.refresh(b),this._setFocusOnItem(this._selection._getFocused())):d===w._ViewChange.relayout?(this._pendingLayoutReset&&(this._resetLayout(),a()),this._view.refresh(b)):this._view.onScroll(b)}},_batchViewUpdates:function(a,b,c,d,e){if(this._viewChange=Math.min(this._viewChange,a),(null===this._scrollToFunctor||b>=this._scrollToPriority)&&(this._scrollToPriority=b,this._scrollToFunctor=c),this._setScrollbarPosition|=!!d,!this._batchingViewUpdates){this._raiseViewLoading();var f=this;this._batchingViewUpdatesSignal=new m,this._batchingViewUpdates=k.any([this._batchingViewUpdatesSignal.promise,l.schedulePromiseHigh(null,"WinJS.UI.ListView._updateView")]).then(function(){return f._isZombie()?void 0:f._viewChange!==w._ViewChange.rebuild||f._firstTimeDisplayed||0===Object.keys(f._view.items._itemData).length||e?void 0:f._fadeOutViewport()}).then(function(){f._batchingViewUpdates=null,f._batchingViewUpdatesSignal=null,f._updateView(),f._firstTimeDisplayed=!1},function(){f._batchingViewUpdates=null,f._batchingViewUpdatesSignal=null})}return this._batchingViewUpdatesSignal},_resetCanvas:function(){if(!this._disposed){var b=a.document.createElement("div");b.className=this._canvas.className,this._viewport.replaceChild(b,this._canvas),this._canvas=b,this._groupsToRemove={},this._canvas.appendChild(this._canvasProxy)}},_setupInternalTree:function(){p.addClass(this._element,w._listViewClass),p[this._rtl()?"addClass":"removeClass"](this._element,w._rtlListViewClass),this._element.innerHTML='<div tabIndex="-1" role="group" class="'+w._viewportClass+" "+w._horizontalClass+'"><div class="'+w._scrollableClass+'"><div class="'+w._proxyClass+'"></div></div><div></div></div><div aria-hidden="true" style="position:absolute;left:50%;top:50%;width:0px;height:0px;" tabindex="-1"></div>',this._viewport=this._element.firstElementChild,this._canvas=this._viewport.firstElementChild,this._canvasProxy=this._canvas.firstElementChild,this._deleteWrapper=this._canvas.nextElementSibling,this._keyboardEventsHelper=this._viewport.nextElementSibling,this._tabIndex=p.getTabIndex(this._element),this._tabIndex<0&&(this._tabIndex=0),this._tabManager=new t.TabContainer(this._viewport),this._tabManager.tabIndex=this._tabIndex,this._progressBar=a.document.createElement("progress"),p.addClass(this._progressBar,w._progressClass),this._progressBar.style.position="absolute",this._progressBar.max=100},_unsetFocusOnItem:function(b){this._tabManager.childFocus&&this._clearFocusRectangle(this._tabManager.childFocus),this._isZombie()||(b||(this._tabManager.childFocus&&(this._tabManager.childFocus=null),this._keyboardEventsHelper._shouldHaveFocus=!1,a.document.activeElement!==this._viewport&&this._hasKeyboardFocus&&(this._keyboardEventsHelper._shouldHaveFocus=!0,p._setActive(this._keyboardEventsHelper))),this._itemFocused=!1)},_setFocusOnItem:function(a){if(this._writeProfilerMark("_setFocusOnItem,info"),this._focusRequest&&this._focusRequest.cancel(),!this._isZombie()){var b=this,c=function(c){b._isZombie()||(b._tabManager.childFocus!==c&&(b._tabManager.childFocus=c),b._focusRequest=null,b._hasKeyboardFocus&&!b._itemFocused&&(b._selection._keyboardFocused()&&b._drawFocusRectangle(c),b._view.updateAriaForAnnouncement(c,a.type===u.ObjectType.groupHeader?b._groups.length():b._cachedCount),b._itemFocused=!0,p._setActive(c)))};this._focusRequest=a.type!==u.ObjectType.groupHeader?this._view.items.requestItem(a.index):this._groups.requestHeader(a.index),this._focusRequest.then(c)}},_attachEvents:function(){function a(a,b,c){return{name:b?a:a.toLowerCase(),handler:function(b){d["_on"+a](b)},capture:c}}function b(a,b,c){return{capture:c,name:b?a:a.toLowerCase(),handler:function(b){var c=d._mode,e="on"+a;!d._disposed&&c[e]&&c[e](b)}}}function c(a,b){return{handler:function(b){d["_on"+a](b)},filter:b}}var d=this,e=[c("PropertyChange",["dir","style","tabindex"])];this._cachedStyleDir=this._element.style.direction,e.forEach(function(a){new p._MutationObserver(a.handler).observe(d._element,{attributes:!0,attributeFilter:a.filter})});var f=[b("PointerDown"),b("click",!1),b("PointerUp"),b("LostPointerCapture"),b("MSHoldVisual",!0),b("PointerCancel",!0),b("DragStart"),b("DragOver"),b("DragEnter"),b("DragLeave"),b("Drop"),b("ContextMenu"),b("MSManipulationStateChanged",!0,!0)];f.forEach(function(a){p._addEventListener(d._viewport,a.name,a.handler,!!a.capture)});var g=[a("FocusIn",!1,!1),a("FocusOut",!1,!1),b("KeyDown"),b("KeyUp"),a("MSElementResize",!1,!1)];g.forEach(function(a){p._addEventListener(d._element,a.name,a.handler,!!a.capture)}),this._onMSElementResizeBound=this._onMSElementResize.bind(this),p._resizeNotifier.subscribe(this._element,this._onMSElementResizeBound);var h=[a("MSManipulationStateChanged",!0),a("Scroll")];h.forEach(function(a){d._viewport.addEventListener(a.name,a.handler,!1)}),this._viewport.addEventListener("onTabEnter",this._onTabEnter.bind(this)),this._viewport.addEventListener("onTabExit",this._onTabExit.bind(this)),this._viewport.addEventListener("onTabEntered",function(a){d._mode.onTabEntered(a)
  }),this._viewport.addEventListener("onTabExiting",function(a){d._mode.onTabExiting(a)})},_updateItemsManager:function(){function a(a){a.detail===u.DataSourceStatus.failure&&(b.itemDataSource=null,b.groupDataSource=null)}var b=this,c={beginNotifications:function(){},changed:function(a,c){if(!b._ifZombieDispose()){b._createUpdater();var d=b._updater.elements[O(c)];if(d){var e=b.selection._isIncluded(d.index);if(e&&(b._updater.updateDrag=!0),c!==a){if((b._tabManager.childFocus===c||b._updater.newFocusedItem===c)&&(b._updater.newFocusedItem=a,b._tabManager.childFocus=null),d.itemBox){p.addClass(a,w._itemClass),b._setupAriaSelectionObserver(a);var f=c.nextElementSibling;d.itemBox.removeChild(c),d.itemBox.insertBefore(a,f)}b._setAriaSelected(a,e),b._view.items.setItemAt(d.newIndex,{element:a,itemBox:d.itemBox,container:d.container,itemsManagerRecord:d.itemsManagerRecord}),delete b._updater.elements[O(c)],o._disposeElement(c),b._updater.elements[O(a)]={item:a,container:d.container,itemBox:d.itemBox,index:d.index,newIndex:d.newIndex,itemsManagerRecord:d.itemsManagerRecord}}else d.itemBox&&d.container&&(x._ItemEventsHandler.renderSelection(d.itemBox,a,e,!0),p[e?"addClass":"removeClass"](d.container,w._selectedClass));b._updater.changed=!0}for(var g=0,h=b._notificationHandlers.length;h>g;g++)b._notificationHandlers[g].changed(a,c);b._writeProfilerMark("changed,info")}},removed:function(a,c,d){function e(a){b._updater.updateDrag=!0,b._currentMode()._dragging&&b._currentMode()._draggingUnselectedItem&&b._currentMode()._dragInfo._isIncluded(a)&&(b._updater.newDragInfo=new F._Selection(b,[]));var c=b._updater.selectionFirst[a],d=b._updater.selectionLast[a],e=c||d;e&&(delete b._updater.selectionFirst[e.oldFirstIndex],delete b._updater.selectionLast[e.oldLastIndex],b._updater.selectionChanged=!0)}if(!b._ifZombieDispose()){b._createUpdater();var f=b._insertedItems[d];f&&delete b._insertedItems[d];var g;if(a){var h=b._updater.elements[O(a)],i=b._itemsManager.itemObject(a);if(i&&b._groupFocusCache.deleteItem(i.key),h){g=h.index,h.itemBox&&b._updater.removed.push({index:g,itemBox:h.itemBox}),b._updater.deletesCount++;var j=b._view.items.itemDataAt(g);j.removed=!0,delete b._updater.elements[O(a)]}else g=i&&i.index;b._updater.oldFocus.type!==u.ObjectType.groupHeader&&b._updater.oldFocus.index===g&&(b._updater.newFocus.index=g,b._updater.focusedItemRemoved=!0),e(g)}else g=b._updater.selectionHandles[d],g===+g&&e(g);b._writeProfilerMark("removed("+g+"),info"),b._updater.changed=!0}},updateAffectedRange:function(a){b._itemsCount().then(function(c){var d=b._view.containers?b._view.containers.length:0;a.start=Math.min(a.start,d),b._affectedRange.add(a,c)}),b._createUpdater(),b._updater.changed=!0},indexChanged:function(a,c,d){if(!b._ifZombieDispose()){if(b._createUpdater(),a){var e=b._itemsManager.itemObject(a);e&&b._groupFocusCache.updateItemIndex(e.key,c);var f=b._updater.elements[O(a)];f&&(f.newIndex=c,b._updater.changed=!0),b._updater.itemsMoved=!0}b._currentMode()._dragging&&b._currentMode()._draggingUnselectedItem&&b._currentMode()._dragInfo._isIncluded(d)&&(b._updater.newDragInfo=new F._Selection(b,[{firstIndex:c,lastIndex:c}]),b._updater.updateDrag=!0),b._updater.oldFocus.type!==u.ObjectType.groupHeader&&b._updater.oldFocus.index===d&&(b._updater.newFocus.index=c,b._updater.changed=!0),b._updater.oldSelectionPivot===d&&(b._updater.newSelectionPivot=c,b._updater.changed=!0);var g=b._updater.selectionFirst[d];g&&(g.newFirstIndex=c,b._updater.changed=!0,b._updater.updateDrag=!0),g=b._updater.selectionLast[d],g&&(g.newLastIndex=c,b._updater.changed=!0,b._updater.updateDrag=!0)}},endNotifications:function(){b._update()},inserted:function(a){b._ifZombieDispose()||(b._writeProfilerMark("inserted,info"),b._createUpdater(),b._updater.changed=!0,a.retain(),b._updater.insertsCount++,b._insertedItems[a.handle]=a)},moved:function(a,c,d,e){if(!b._ifZombieDispose()){if(b._createUpdater(),b._updater.movesCount++,a){b._updater.itemsMoved=!0;var f=b._updater.elements[O(a)];f&&(f.moved=!0)}var g=b._updater.selectionHandles[e.handle];if(g===+g){b._updater.updateDrag=!0;var h=b._updater.selectionFirst[g],i=b._updater.selectionLast[g],j=h||i;j&&j.oldFirstIndex!==j.oldLastIndex&&(delete b._updater.selectionFirst[j.oldFirstIndex],delete b._updater.selectionLast[j.oldLastIndex],b._updater.selectionChanged=!0,b._updater.changed=!0)}b._writeProfilerMark("moved("+g+"),info")}},countChanged:function(a,c){b._ifZombieDispose()||(b._writeProfilerMark("countChanged("+a+"),info"),b._cachedCount=a,b._createUpdater(),b._view.lastIndexDisplayed+1===c&&(b._updater.changed=!0),b._updater.countDifference+=a-c)},reload:function(){b._ifZombieDispose()||(b._writeProfilerMark("reload,info"),b._processReload())}};this._versionManager&&this._versionManager._dispose(),this._versionManager=new v._VersionManager,this._updater=null;var d=this._selection.getRanges();this._selection._selected.clear(),this._itemsManager&&(this._itemsManager.dataSource&&this._itemsManager.dataSource.removeEventListener&&this._itemsManager.dataSource.removeEventListener("statuschanged",a,!1),this._clearInsertedItems(),this._itemsManager.release()),this._itemsCountPromise&&(this._itemsCountPromise.cancel(),this._itemsCountPromise=null),this._cachedCount=w._UNINITIALIZED,this._itemsManager=r._createItemsManager(this._dataSource,this._renderWithoutReuse.bind(this),c,{ownerElement:this._element,versionManager:this._versionManager,indexInView:function(a){return a>=b.indexOfFirstVisible&&a<=b.indexOfLastVisible},viewCallsReady:!0,profilerId:this._id}),this._dataSource.addEventListener&&this._dataSource.addEventListener("statuschanged",a,!1),this._selection._selected.set(d)},_processReload:function(){this._affectedRange.addAll(),this._cancelAsyncViewWork(!0),this._currentMode()._dragging&&this._currentMode()._clearDragProperties(),this._groupFocusCache.clear(),this._selection._reset(),this._updateItemsManager(),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.low,this.scrollPosition)},_createUpdater:function(){if(!this._updater){this.itemDataSource._isVirtualizedDataSource&&this._affectedRange.addAll(),this._versionManager.beginUpdating(),this._cancelAsyncViewWork();var a={changed:!1,elements:{},selectionFirst:{},selectionLast:{},selectionHandles:{},oldSelectionPivot:{type:u.ObjectType.item,index:w._INVALID_INDEX},newSelectionPivot:{type:u.ObjectType.item,index:w._INVALID_INDEX},removed:[],selectionChanged:!1,oldFocus:{type:u.ObjectType.item,index:w._INVALID_INDEX},newFocus:{type:u.ObjectType.item,index:w._INVALID_INDEX},hadKeyboardFocus:this._hasKeyboardFocus,itemsMoved:!1,lastVisible:this.indexOfLastVisible,updateDrag:!1,movesCount:0,insertsCount:0,deletesCount:0,countDifference:0};this._view.items.each(function(b,c,d){a.elements[O(c)]={item:c,container:d.container,itemBox:d.itemBox,index:b,newIndex:b,itemsManagerRecord:d.itemsManagerRecord,detached:d.detached}});for(var b=this._selection._selected._ranges,c=0,d=b.length;d>c;c++){var e=b[c],f={newFirstIndex:b[c].firstIndex,oldFirstIndex:b[c].firstIndex,newLastIndex:b[c].lastIndex,oldLastIndex:b[c].lastIndex};a.selectionFirst[f.oldFirstIndex]=f,a.selectionLast[f.oldLastIndex]=f,a.selectionHandles[e.firstPromise.handle]=f.oldFirstIndex,a.selectionHandles[e.lastPromise.handle]=f.oldLastIndex}a.oldSelectionPivot=this._selection._pivot,a.newSelectionPivot=a.oldSelectionPivot,a.oldFocus=this._selection._getFocused(),a.newFocus=this._selection._getFocused(),this._updater=a}},_synchronize:function(){var a=this._updater;if(this._updater=null,this._groupsChanged=!1,this._countDifference=this._countDifference||0,a&&a.changed){a.itemsMoved&&this._layout.itemsMoved&&this._layout.itemsMoved(),a.removed.length&&this._layout.itemsRemoved&&this._layout.itemsRemoved(a.removed.map(function(a){return a.itemBox})),(a.itemsMoved||a.removed.length||Object.keys(this._insertedItems).length)&&this._layout.setupAnimations&&this._layout.setupAnimations(),this._currentMode().onDataChanged&&this._currentMode().onDataChanged();var b=[];for(var c in a.selectionFirst)if(a.selectionFirst.hasOwnProperty(c)){var d=a.selectionFirst[c];a.selectionChanged=a.selectionChanged||d.newLastIndex-d.newFirstIndex!==d.oldLastIndex-d.oldFirstIndex,d.newFirstIndex<=d.newLastIndex&&b.push({firstIndex:d.newFirstIndex,lastIndex:d.newLastIndex})}if(a.selectionChanged){var e=new F._Selection(this,b);this._selection._fireSelectionChanging(e),this._selection._selected.set(b),this._selection._fireSelectionChanged(),e.clear()}else this._selection._selected.set(b);this._selection._updateCount(this._cachedCount),a.newSelectionPivot=Math.min(this._cachedCount-1,a.newSelectionPivot),this._selection._pivot=a.newSelectionPivot>=0?a.newSelectionPivot:w._INVALID_INDEX,a.newFocus.type!==u.ObjectType.groupHeader&&(a.newFocus.index=Math.max(0,Math.min(this._cachedCount-1,a.newFocus.index))),this._selection._setFocused(a.newFocus,this._selection._keyboardFocused());var f=this._modifiedElements||[],g={};for(this._modifiedElements=[],this._countDifference+=a.countDifference,c=0;c<f.length;c++){var h=f[c];-1===h.newIndex?this._modifiedElements.push(h):g[h.newIndex]=h}for(c=0;c<a.removed.length;c++){var i=a.removed[c],h=g[i.index];h?delete g[i.index]:h={oldIndex:i.index},h.newIndex=-1,h._removalHandled||(h._itemBox=i.itemBox),this._modifiedElements.push(h)}var j=Object.keys(this._insertedItems);for(c=0;c<j.length;c++)this._modifiedElements.push({oldIndex:-1,newIndex:this._insertedItems[j[c]].index});this._writeProfilerMark("_synchronize:update_modifiedElements,StartTM");var k={};for(c in a.elements)if(a.elements.hasOwnProperty(c)){var l=a.elements[c];k[l.newIndex]={element:l.item,container:l.container,itemBox:l.itemBox,itemsManagerRecord:l.itemsManagerRecord,detached:l.detached};var h=g[l.index];h?(delete g[l.index],h.newIndex=l.newIndex):h={oldIndex:l.index,newIndex:l.newIndex},h.moved=l.moved,this._modifiedElements.push(h)}this._writeProfilerMark("_synchronize:update_modifiedElements,StopTM");var m=Object.keys(g);for(c=0;c<m.length;c++){var n=m[c],h=g[n];-1!==h.oldIndex&&this._modifiedElements.push(h)}this._view.items._itemData=k,a.updateDrag&&this._currentMode()._dragging&&(this._currentMode()._draggingUnselectedItem?a.newDragInfo&&(this._currentMode()._dragInfo=a.newDragInfo):this._currentMode()._dragInfo=this._selection,this._currentMode().fireDragUpdateEvent()),a.focusedItemRemoved||this._focusRequest&&a.oldFocus.index!==a.newFocus.index||a.oldFocus.type!==a.newFocus.type?(this._itemFocused=!1,this._setFocusOnItem(this._selection._getFocused())):a.newFocusedItem&&(this._hasKeyboardFocus=a.hadKeyboardFocus,this._itemFocused=!1,this._setFocusOnItem(this._selection._getFocused()));var o=this;return this._groups.synchronizeGroups().then(function(){return a.newFocus.type===u.ObjectType.groupHeader&&(a.newFocus.index=Math.min(o._groups.length()-1,a.newFocus.index),a.newFocus.index<0&&(a.newFocus={type:u.ObjectType.item,index:0}),o._selection._setFocused(a.newFocus,o._selection._keyboardFocused())),o._versionManager.endUpdating(),a.deletesCount>0&&o._updateDeleteWrapperSize(),o._view.updateTree(o._cachedCount,o._countDifference,o._modifiedElements)}).then(function(){return o._lastScrollPosition})}this._countDifference+=a?a.countDifference:0;var o=this;return this._groups.synchronizeGroups().then(function(){return a&&o._versionManager.endUpdating(),o._view.updateTree(o._cachedCount,o._countDifference,o._modifiedElements)}).then(function(){return o.scrollPosition})},_updateDeleteWrapperSize:function(a){var b=this._horizontal()?"width":"height";this._deleteWrapper.style["min-"+b]=(a?0:this.scrollPosition+this._getViewportSize()[b])+"px"},_verifyRealizationNeededForChange:function(){var a=!1,b=(this._view.lastIndexDisplayed||0)-(this._view.firstIndexDisplayed||0),c=this._updater&&0===this._updater.movesCount&&0===this._updater.insertsCount&&this._updater.deletesCount>0&&this._updater.deletesCount===Math.abs(this._updater.countDifference);if(c&&this._updater.elements)for(var d=Object.keys(this._updater.elements),e=0,f=d.length;f>e;e++){var g=this._updater.elements[d[e]],h=g.index-g.newIndex;if(0>h||h>this._updater.deletesCount){c=!1;break}}this._view.deletesWithoutRealize=this._view.deletesWithoutRealize||0,c&&this._view.lastIndexDisplayed<this._view.end-b&&this._updater.deletesCount+this._view.deletesWithoutRealize<b?(a=!0,this._view.deletesWithoutRealize+=Math.abs(this._updater.countDifference),this._writeProfilerMark("skipping realization on delete,info")):this._view.deletesWithoutRealize=0,this._view._setSkipRealizationForChange(a)},_update:function(){if(this._writeProfilerMark("update,StartTM"),!this._ifZombieDispose()){this._updateJob=null;var a=this;this._versionManager.noOutstandingNotifications&&(this._updater||this._groupsChanged?(this._cancelAsyncViewWork(),this._verifyRealizationNeededForChange(),this._synchronize().then(function(b){a._writeProfilerMark("update,StopTM"),a._batchViewUpdates(w._ViewChange.relayout,w._ScrollToPriority.low,b).complete()})):this._batchViewUpdates(w._ViewChange.relayout,w._ScrollToPriority.low,this._lastScrollPosition).complete())}},_scheduleUpdate:function(){if(!this._updateJob){var a=this;this._updateJob=l.schedulePromiseHigh(null,"WinJS.UI.ListView._update").then(function(){a._updateJob&&a._update()}),this._raiseViewLoading()}},_createGroupsContainer:function(){this._groups&&this._groups.cleanUp(),this._groups=this._groupDataSource?new B._UnvirtualizedGroupsContainer(this,this._groupDataSource):new B._NoGroups(this)},_createLayoutSite:function(){var b=this;return Object.create({invalidateLayout:function(){b._pendingLayoutReset=!0;var a="horizontal"===b._layout.orientation!==b._horizontalLayout;b._affectedRange.addAll(),b._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.low,a?0:b.scrollPosition,!1,!0)},itemFromIndex:function(a){return b._itemsManager._itemPromiseAtIndex(a)},groupFromIndex:function(a){return b._groupsEnabled()?a<b._groups.length()?b._groups.group(a).userData:null:{key:"-1"}},groupIndexFromItemIndex:function(a){return a=Math.max(0,a),b._groups.groupFromItem(a)},renderItem:function(c){return k._cancelBlocker(b._itemsManager._itemFromItemPromise(c)).then(function(c){if(c){var d=b._itemsManager._recordFromElement(c);d.pendingReady&&d.pendingReady(),c=c.cloneNode(!0),p.addClass(c,w._itemClass);var e=a.document.createElement("div");p.addClass(e,w._itemBoxClass),e.appendChild(c);var f=a.document.createElement("div");return p.addClass(f,w._containerClass),f.appendChild(e),f}return k.cancel})},renderHeader:function(c){var d=r._normalizeRendererReturn(b.groupHeaderTemplate(k.wrap(c)));return d.then(function(b){p.addClass(b.element,w._headerClass);var c=a.document.createElement("div");return p.addClass(c,w._headerContainerClass),c.appendChild(b.element),c})},readyToMeasure:function(){b._getViewportLength(),b._getCanvasMargins()},_isZombie:function(){return b._isZombie()},_writeProfilerMark:function(a){b._writeProfilerMark(a)}},{_itemsManager:{enumerable:!0,get:function(){return b._itemsManager}},rtl:{enumerable:!0,get:function(){return b._rtl()}},surface:{enumerable:!0,get:function(){return b._canvas}},viewport:{enumerable:!0,get:function(){return b._viewport}},scrollbarPos:{enumerable:!0,get:function(){return b.scrollPosition}},viewportSize:{enumerable:!0,get:function(){return b._getViewportSize()}},loadingBehavior:{enumerable:!0,get:function(){return b.loadingBehavior}},animationsDisabled:{enumerable:!0,get:function(){return b._animationsDisabled()}},tree:{enumerable:!0,get:function(){return b._view.tree}},realizedRange:{enumerable:!0,get:function(){return{firstPixel:Math.max(0,b.scrollPosition-2*b._getViewportLength()),lastPixel:b.scrollPosition+3*b._getViewportLength()-1}}},visibleRange:{enumerable:!0,get:function(){return{firstPixel:b.scrollPosition,lastPixel:b.scrollPosition+b._getViewportLength()-1}}},itemCount:{enumerable:!0,get:function(){return b._itemsCount()}},groupCount:{enumerable:!0,get:function(){return b._groups.length()}}})},_initializeLayout:function(){this._affectedRange.addAll();var a=this._createLayoutSite();return this._layout.initialize(a,this._groupsEnabled()),"horizontal"===this._layout.orientation},_resetLayoutOrientation:function(a){this._horizontalLayout?(this._startProperty="left",this._scrollProperty="scrollLeft",this._scrollLength="scrollWidth",this._deleteWrapper.style.minHeight="",p.addClass(this._viewport,w._horizontalClass),p.removeClass(this._viewport,w._verticalClass),a&&(this._viewport.scrollTop=0)):(this._startProperty="top",this._scrollProperty="scrollTop",this._scrollLength="scrollHeight",this._deleteWrapper.style.minWidth="",p.addClass(this._viewport,w._verticalClass),p.removeClass(this._viewport,w._horizontalClass),a&&p.setScrollPosition(this._viewport,{scrollLeft:0}))},_resetLayout:function(){this._pendingLayoutReset=!1,this._affectedRange.addAll(),this._layout&&(this._layout.uninitialize(),this._horizontalLayout=this._initializeLayout(),this._resetLayoutOrientation())},_updateLayout:function(a){var b=!1;this._layout&&(this._cancelAsyncViewWork(!0),this._layout.uninitialize(),b=!0);var c;if(a&&"function"==typeof a.type){var d=R(a.type);c=new d(a)}else c=a&&a.initialize?a:new E.GridLayout(a);b&&this._resetCanvas(),this._layoutImpl=c,this._layout=new E._LayoutWrapper(c),b&&this._unsetFocusOnItem(),this._setFocusOnItem({type:u.ObjectType.item,index:0}),this._selection._setFocused({type:u.ObjectType.item,index:0}),this._horizontalLayout=this._initializeLayout(),this._resetLayoutOrientation(b),b&&(this._canvas.style.width=this._canvas.style.height="")},_currentMode:function(){return this._mode},_setSwipeClass:function(){!c.isPhone&&(this._currentMode()instanceof y._SelectionMode&&this._selectionAllowed()&&this._swipeBehavior===u.SwipeBehavior.select||this._dragSource||this._reorderable)?(this._swipeable=!0,p.addClass(this._element,w._swipeableClass)):(this._swipeable=!1,p.removeClass(this._element,w._swipeableClass));var a=this.itemsDraggable||this.itemsReorderable,b=this._selectionAllowed()&&this._swipeBehavior===u.SwipeBehavior.select,d=this._swipeable;this._view.items.each(function(e,f,g){if(g.itemBox){var h=p.hasClass(f,w._nonDraggableClass),i=p.hasClass(f,w._nonSelectableClass),j=p.hasClass(g.itemBox,w._nonSwipeableClass);if(g.itemBox.draggable=a&&!h,!d&&j)p.removeClass(g.itemBox,w._nonSwipeableClass);else if(d){var k=a&&!b&&h||b&&!a&&i||h&&i;k&&!j?p.addClass(g.itemBox,w._nonSwipeableClass):!k&&j&&p.removeClass(g.itemBox,w._nonSwipeableClass)}var l=c.isPhone&&i;p[l?"addClass":"removeClass"](g.itemBox,w._nonSelectableClass)}})},_resizeViewport:function(){this._viewportWidth=w._UNINITIALIZED,this._viewportHeight=w._UNINITIALIZED},_onMSElementResize:function(){this._writeProfilerMark("_onMSElementResize,info"),l.schedule(function(){if(!this._isZombie()&&this._viewportWidth!==w._UNINITIALIZED&&this._viewportHeight!==w._UNINITIALIZED){var a=this._element.offsetWidth,b=this._element.offsetHeight;if(this._previousWidth!==a||this._previousHeight!==b){this._writeProfilerMark("resize ("+this._previousWidth+"x"+this._previousHeight+") => ("+a+"x"+b+"),info"),this._previousWidth=a,this._previousHeight=b,this._resizeViewport();var c=this;this._affectedRange.addAll(),this._batchViewUpdates(w._ViewChange.relayout,w._ScrollToPriority.low,function(){return{position:c.scrollPosition,direction:"right"}})}}},l.Priority.max,this,"WinJS.UI.ListView._onMSElementResize")},_onFocusIn:function(a){function b(a){c._changeFocus(c._selection._getFocused(),!0,!1,!1,a)}this._hasKeyboardFocus=!0;var c=this;if(a.target===this._keyboardEventsHelper)!this._keyboardEventsHelper._shouldHaveFocus&&this._keyboardFocusInbound?b(!0):this._keyboardEventsHelper._shouldHaveFocus=!1;else if(a.target===this._element)b();else{if(this._mode.inboundFocusHandled)return void(this._mode.inboundFocusHandled=!1);var d=this._view.items,e={},f=this._groups.headerFrom(a.target),g=null;if(f?(e.type=u.ObjectType.groupHeader,e.index=this._groups.index(f)):(e.index=d.index(a.target),e.type=u.ObjectType.item,f=d.itemBoxAt(e.index),g=d.itemAt(e.index)),e.index!==w._INVALID_INDEX&&((this._keyboardFocusInbound||this._selection._keyboardFocused())&&(e.type===u.ObjectType.groupHeader&&a.target===f||e.type===u.ObjectType.item&&a.target.parentNode===f)&&this._drawFocusRectangle(f),this._tabManager.childFocus!==f&&this._tabManager.childFocus!==g&&(this._selection._setFocused(e,this._keyboardFocusInbound||this._selection._keyboardFocused()),this._keyboardFocusInbound=!1,f=e.type===u.ObjectType.groupHeader?f:d.itemAt(e.index),this._tabManager.childFocus=f,c._updater))){var h=c._updater.elements[O(f)],i=e.index;h&&h.newIndex&&(i=h.newIndex),c._updater.oldFocus={type:e.type,index:i},c._updater.newFocus={type:e.type,index:i}}}},_onFocusOut:function(a){if(!this._disposed){this._hasKeyboardFocus=!1,this._itemFocused=!1;var b=this._view.items.itemBoxFrom(a.target)||this._groups.headerFrom(a.target);b&&this._clearFocusRectangle(b)}},_onMSManipulationStateChanged:function(a){function b(){c._manipulationEndSignal=null}var c=this;this._manipulationState=a.currentState,c._writeProfilerMark("_onMSManipulationStateChanged state("+a.currentState+"),info"),this._manipulationState===p._MSManipulationEvent.MS_MANIPULATION_STATE_STOPPED||this._manipulationEndSignal||(this._manipulationEndSignal=new m,this._manipulationEndSignal.promise.done(b,b)),this._manipulationState===p._MSManipulationEvent.MS_MANIPULATION_STATE_STOPPED&&this._manipulationEndSignal.complete()},_pendingScroll:!1,_onScroll:function(){this._zooming||this._pendingScroll||this._checkScroller()},_checkScroller:function(){if(!this._isZombie()){var a=this._viewportScrollPosition;if(a!==this._lastScrollPosition){this._pendingScroll=c._requestAnimationFrame(this._checkScroller.bind(this)),a=Math.max(0,a);var b=this._scrollDirection(a);this._lastScrollPosition=a,this._raiseViewLoading(!0);var d=this;this._view.onScroll(function(){return{position:d._lastScrollPosition,direction:b}},this._manipulationEndSignal?this._manipulationEndSignal.promise:k.timeout(w._DEFERRED_SCROLL_END))}else this._pendingScroll=null}},_scrollDirection:function(a){var b=a<this._lastScrollPosition?"left":"right";return b===this._lastDirection?b:this._direction},_onTabEnter:function(){this._keyboardFocusInbound=!0},_onTabExit:function(){this._keyboardFocusInbound=!1},_onPropertyChange:function(a){var b=this;a.forEach(function(a){var c=!1;if("dir"===a.attributeName?c=!0:"style"===a.attributeName&&(c=b._cachedStyleDir!==a.target.style.direction),c&&(b._cachedStyleDir=a.target.style.direction,b._cachedRTL=null,p[b._rtl()?"addClass":"removeClass"](b._element,w._rtlListViewClass),b._lastScrollPosition=0,b._viewportScrollPosition=0,b.forceLayout()),"tabIndex"===a.attributeName){var d=b._element.tabIndex;d>=0&&(b._view.items.each(function(a,b){b.tabIndex=d}),b._tabIndex=d,b._tabManager.tabIndex=d,b._element.tabIndex=-1)}})},_getCanvasMargins:function(){return this._canvasMargins||(this._canvasMargins=E._getMargins(this._canvas)),this._canvasMargins},_convertCoordinatesByCanvasMargins:function(a,b){function c(c,d){void 0!==a[c]&&(a[c]=b(a[c],d))}var d;return this._horizontal()?(d=this._getCanvasMargins()[this._rtl()?"right":"left"],c("left",d)):(d=this._getCanvasMargins().top,c("top",d)),c("begin",d),c("end",d),a},_convertFromCanvasCoordinates:function(a){return this._convertCoordinatesByCanvasMargins(a,function(a,b){return a+b})},_convertToCanvasCoordinates:function(a){return this._convertCoordinatesByCanvasMargins(a,function(a,b){return a-b})},_getViewportSize:function(){return(this._viewportWidth===w._UNINITIALIZED||this._viewportHeight===w._UNINITIALIZED)&&(this._viewportWidth=Math.max(0,p.getContentWidth(this._element)),this._viewportHeight=Math.max(0,p.getContentHeight(this._element)),this._writeProfilerMark("viewportSizeDetected width:"+this._viewportWidth+" height:"+this._viewportHeight),this._previousWidth=this._element.offsetWidth,this._previousHeight=this._element.offsetHeight),{width:this._viewportWidth,height:this._viewportHeight}},_itemsCount:function(){function a(){b._itemsCountPromise=null}var b=this;if(this._cachedCount!==w._UNINITIALIZED)return k.wrap(this._cachedCount);var c;return this._itemsCountPromise?c=this._itemsCountPromise:(c=this._itemsCountPromise=this._itemsManager.dataSource.getCount().then(function(a){return a===u.CountResult.unknown&&(a=0),b._cachedCount=a,b._selection._updateCount(b._cachedCount),a},function(){return k.cancel}),this._itemsCountPromise.then(a,a)),c},_isSelected:function(a){return this._selection._isIncluded(a)},_LoadingState:{itemsLoading:"itemsLoading",viewPortLoaded:"viewPortLoaded",itemsLoaded:"itemsLoaded",complete:"complete"},_raiseViewLoading:function(a){this._loadingState!==this._LoadingState.itemsLoading&&(this._scrolling=!!a),this._setViewState(this._LoadingState.itemsLoading)},_raiseViewComplete:function(){this._disposed||this._view.animating||this._setViewState(this._LoadingState.complete)},_setViewState:function(b){if(b!==this._loadingState){var c=null;switch(b){case this._LoadingState.viewPortLoaded:this._scheduledForDispose||(I(this),this._scheduledForDispose=!0),this._setViewState(this._LoadingState.itemsLoading);break;case this._LoadingState.itemsLoaded:c={scrolling:this._scrolling},this._setViewState(this._LoadingState.viewPortLoaded);break;case this._LoadingState.complete:this._setViewState(this._LoadingState.itemsLoaded),this._updateDeleteWrapperSize(!0)}this._writeProfilerMark("loadingStateChanged:"+b+",info"),this._loadingState=b;var d=a.document.createEvent("CustomEvent");d.initCustomEvent("loadingstatechanged",!0,!1,c),this._element.dispatchEvent(d)}},_createTemplates:function(){function b(b,c){var d=a.document.createElement("div");return d.className=b,c||d.setAttribute("aria-hidden",!0),d}this._itemBoxTemplate=b(w._itemBoxClass,!0)},_updateSelection:function(){var a=this._selection.getIndices(),b=this._selection.isEverything(),c={};if(!b)for(var d=0,e=a.length;e>d;d++){var f=a[d];c[f]=!0}this._view.items.each(function(a,d,e){if(e.itemBox&&!p.hasClass(e.itemBox,w._swipeClass)){var f=b||!!c[a];x._ItemEventsHandler.renderSelection(e.itemBox,d,f,!0),e.container&&p[f?"addClass":"removeClass"](e.container,w._selectedClass)}})},_getViewportLength:function(){return this._getViewportSize()[this._horizontal()?"width":"height"]},_horizontal:function(){return this._horizontalLayout},_rtl:function(){return"boolean"!=typeof this._cachedRTL&&(this._cachedRTL="rtl"===a.getComputedStyle(this._element,null).direction),this._cachedRTL},_showProgressBar:function(a,b,c){var d=this._progressBar,e=d.style;if(!d.parentNode){this._fadingProgressBar=!1,this._progressIndicatorDelayTimer&&this._progressIndicatorDelayTimer.cancel();var f=this;this._progressIndicatorDelayTimer=k.timeout(w._LISTVIEW_PROGRESS_DELAY).then(function(){f._isZombie()||(a.appendChild(d),P.fadeInElement(d),f._progressIndicatorDelayTimer=null)})}e[this._rtl()?"right":"left"]=b,e.top=c},_hideProgressBar:function(){this._progressIndicatorDelayTimer&&(this._progressIndicatorDelayTimer.cancel(),this._progressIndicatorDelayTimer=null);var a=this._progressBar;if(a.parentNode&&!this._fadingProgressBar){this._fadingProgressBar=!0;var b=this;P.fadeOutElement(a).then(function(){a.parentNode&&a.parentNode.removeChild(a),b._fadingProgressBar=!1})}},_getPanAxis:function(){return this._horizontal()?"horizontal":"vertical"},_configureForZoom:function(a,b,e){if(c.validation&&(!this._view.realizePage||"number"!=typeof this._view.begin))throw new d("WinJS.UI.ListView.NotCompatibleWithSemanticZoom",Q.notCompatibleWithSemanticZoom);this._isZoomedOut=a,this._disableEntranceAnimation=!b,this._isCurrentZoomView=b,this._triggerZoom=e},_setCurrentItem:function(a,b){this._rtl()&&(a=this._viewportWidth-a),this._horizontal()?a+=this.scrollPosition:b+=this.scrollPosition;var c=this._view.hitTest(a,b),d={type:c.type?c.type:u.ObjectType.item,index:c.index};d.index>=0&&(this._hasKeyboardFocus?this._changeFocus(d,!0,!1,!0):this._changeFocusPassively(d))},_getCurrentItem:function(){var a=this._selection._getFocused();a.type===u.ObjectType.groupHeader&&(a={type:u.ObjectType.item,index:this._groups.group(a.index).startIndex}),"number"!=typeof a.index&&(this._setCurrentItem(.5*this._viewportWidth,.5*this._viewportHeight),a=this._selection._getFocused());var b=this,c=this._getItemOffsetPosition(a.index).then(function(a){var c=b._canvasStart;return a[b._startProperty]+=c,a});return k.join({item:this._dataSource.itemFromIndex(a.index),position:c})},_animateItemsForPhoneZoom:function(){function a(a,b,c){return function(d){return(b[d]-a)*c}}function b(){for(var a=0,b=c.length;b>a;a++)c[a].style[L.scriptName]=""}for(var c=[],d=[],e=[],f=Number.MAX_VALUE,g=this,h=this._view.firstIndexDisplayed,j=Math.min(this._cachedCount,this._view.lastIndexDisplayed+1);j>h;h++)e.push(this._view.waitForEntityPosition({type:u.ObjectType.item,index:h}).then(function(){c.push(g._view.items.containerAt(h));var a=0;if(g.layout._getItemPosition){var b=g.layout._getItemPosition(h);b.row&&(a=b.row)}d.push(a),f=Math.min(a,f)}));return k.join(e).then(function(){return(0===c.length?k.wrap():i.executeTransition(c,{property:L.cssName,delay:a(f,d,30),duration:100,timing:"ease-in-out",from:g._isCurrentZoomView?"rotateX(0deg)":"rotateX(-90deg)",to:g._isCurrentZoomView?"rotateX(90deg)":"rotateX(0deg)"})).then(b,b)}).then(b,b)},_beginZoom:function(){this._zooming=!0;var a=null;if(c.isPhone){if(this._isZoomedOut)if(this._zoomAnimationPromise&&this._zoomAnimationPromise.cancel(),this._isCurrentZoomView){var b=this,d=function(){b._zoomAnimationPromise=null};this._zoomAnimationPromise=a=this._animateItemsForPhoneZoom().then(d,d)}else this._zoomAnimationPromise=new m,a=this._zoomAnimationPromise.promise}else{var e=this._horizontal(),f=-this.scrollPosition;p.addClass(this._viewport,e?w._zoomingXClass:w._zoomingYClass),this._canvasStart=f,p.addClass(this._viewport,e?w._zoomingYClass:w._zoomingXClass)}return a},_positionItem:function(a,b){function e(a){return f._getItemOffsetPosition(a).then(function(d){var e,g=f._horizontal(),h=f._viewport[g?"scrollWidth":"scrollHeight"],i=g?f._viewportWidth:f._viewportHeight,j=g?"headerContainerWidth":"headerContainerHeight",k=f.layout._sizes,l=0;k&&k[j]&&(l=k[j]);var m=c.isPhone?l:b[f._startProperty],n=i-(g?d.width:d.height);m=Math.max(0,Math.min(n,m)),e=d[f._startProperty]-m;var o=Math.max(0,Math.min(h-i,e)),p=o-e;e=o;var q={type:u.ObjectType.item,index:a};if(f._hasKeyboardFocus?f._changeFocus(q,!0):f._changeFocusPassively(q),f._raiseViewLoading(!0),c.isPhone)f._viewportScrollPosition=e;else{var r=-e;f._canvasStart=r}if(f._view.realizePage(e,!0),c.isPhone&&f._isZoomedOut){var s=function(){f._zoomAnimationPromise&&f._zoomAnimationPromise.complete&&f._zoomAnimationPromise.complete(),f._zoomAnimationPromise=null};f._animateItemsForPhoneZoom().then(s,s)}return g?{x:p,y:0}:{x:0,y:p}})}var f=this,g=0;if(a&&(g=this._isZoomedOut?a.groupIndexHint:a.firstItemIndexHint),"number"==typeof g)return e(g);var h,i=this._isZoomedOut?a.groupKey:a.firstItemKey;if("string"==typeof i&&this._dataSource.itemFromKey)h=this._dataSource.itemFromKey(i,this._isZoomedOut?{groupMemberKey:a.key,groupMemberIndex:a.index}:null);else{var j=this._isZoomedOut?a.groupDescription:a.firstItemDescription;if(c.validation&&void 0===j)throw new d("WinJS.UI.ListView.InvalidItem",Q.listViewInvalidItem);h=this._dataSource.itemFromDescription(j)}return h.then(function(a){return e(a.index)})},_endZoom:function(a){if(!this._isZombie()){if(!c.isPhone){var b=this._canvasStart;p.removeClass(this._viewport,w._zoomingYClass),p.removeClass(this._viewport,w._zoomingXClass),this._canvasStart=0,this._viewportScrollPosition=-b}this._disableEntranceAnimation=!a,this._isCurrentZoomView=a,this._zooming=!1,this._view.realizePage(this.scrollPosition,!1)}},_getItemOffsetPosition:function(a){var b=this;return this._getItemOffset({type:u.ObjectType.item,index:a}).then(function(a){return b._ensureFirstColumnRange(u.ObjectType.item).then(function(){return a=b._correctRangeInFirstColumn(a,u.ObjectType.item),a=b._convertFromCanvasCoordinates(a),b._horizontal()?(a.left=a.begin,a.width=a.end-a.begin,a.height=a.totalHeight):(a.top=a.begin,a.height=a.end-a.begin,a.width=a.totalWidth),a
  })})},_groupRemoved:function(a){this._groupFocusCache.deleteGroup(a)},_updateFocusCache:function(a){this._updateFocusCacheItemRequest&&this._updateFocusCacheItemRequest.cancel();var b=this;this._updateFocusCacheItemRequest=this._view.items.requestItem(a).then(function(){b._updateFocusCacheItemRequest=null;var c=b._view.items.itemDataAt(a),d=b._groups.groupFromItem(a),e=b._groups.group(d).key;c.itemsManagerRecord.item&&b._groupFocusCache.updateCache(e,c.itemsManagerRecord.item.key,a)})},_changeFocus:function(a,b,c,d,e){if(!this._isZombie()){var f;if(a.type!==u.ObjectType.groupHeader)f=this._view.items.itemAt(a.index),!b&&f&&p.hasClass(f,w._nonSelectableClass)&&(b=!0),this._updateFocusCache(a.index);else{var g=this._groups.group(a.index);f=g&&g.header}this._unsetFocusOnItem(!!f),this._hasKeyboardFocus=!0,this._selection._setFocused(a,e),d||this.ensureVisible(a),!b&&this._selectFocused(c)&&this._selection.set(a.index),this._setFocusOnItem(a)}},_changeFocusPassively:function(a){var b;if(a.type!==u.ObjectType.groupHeader)b=this._view.items.itemAt(a.index),this._updateFocusCache(a.index);else{var c=this._groups.group(a.index);b=c&&c.header}this._unsetFocusOnItem(!!b),this._selection._setFocused(a),this._setFocusOnItem(a)},_drawFocusRectangle:function(b){if(p.hasClass(b,w._headerClass))p.addClass(b,w._itemFocusClass);else{var c=this._view.items.itemBoxFrom(b);if(c.querySelector("."+w._itemFocusOutlineClass))return;p.addClass(c,w._itemFocusClass);var d=a.document.createElement("div");d.className=w._itemFocusOutlineClass,c.appendChild(d)}},_clearFocusRectangle:function(a){if(a&&!this._isZombie()){var b=this._view.items.itemBoxFrom(a);if(b){p.removeClass(b,w._itemFocusClass);var c=b.querySelector("."+w._itemFocusOutlineClass);c&&c.parentNode.removeChild(c)}else{var d=this._groups.headerFrom(a);d&&p.removeClass(d,w._itemFocusClass)}}},_defaultInvoke:function(a){(this._isZoomedOut||c.isPhone&&this._triggerZoom&&a.type===u.ObjectType.groupHeader)&&(this._changeFocusPassively(a),this._triggerZoom())},_selectionAllowed:function(a){var b=void 0!==a?this.elementFromIndex(a):null,c=!(b&&p.hasClass(b,w._nonSelectableClass));return c&&this._selectionMode!==u.SelectionMode.none},_multiSelection:function(){return this._selectionMode===u.SelectionMode.multi},_selectOnTap:function(){return this._tap===u.TapBehavior.toggleSelect||this._tap===u.TapBehavior.directSelect},_selectFocused:function(a){return this._tap===u.TapBehavior.directSelect&&this._selectionMode===u.SelectionMode.multi&&!a},_dispose:function(){if(!this._disposed){this._disposed=!0;var a=function(a){a&&(a.textContent="")};p._resizeNotifier.unsubscribe(this._element,this._onMSElementResizeBound),this._batchingViewUpdates&&this._batchingViewUpdates.cancel(),this._view&&this._view._dispose&&this._view._dispose(),this._mode&&this._mode._dispose&&this._mode._dispose(),this._groups&&this._groups._dispose&&this._groups._dispose(),this._selection&&this._selection._dispose&&this._selection._dispose(),this._layout&&this._layout.uninitialize&&this._layout.uninitialize(),this._itemsCountPromise&&this._itemsCountPromise.cancel(),this._versionManager&&this._versionManager._dispose(),this._clearInsertedItems(),this._itemsManager&&this._itemsManager.release(),this._zoomAnimationPromise&&this._zoomAnimationPromise.cancel(),a(this._viewport),a(this._canvas),a(this._canvasProxy),this._versionManager=null,this._view=null,this._mode=null,this._element=null,this._viewport=null,this._itemsManager=null,this._canvas=null,this._canvasProxy=null,this._itemsCountPromise=null,this._scrollToFunctor=null;var b=N.indexOf(this);b>=0&&N.splice(b,1)}},_isZombie:function(){return this._disposed||!(this.element.firstElementChild&&a.document.body.contains(this.element))},_ifZombieDispose:function(){var a=this._isZombie();return a&&!this._disposed&&I(this),a},_animationsDisabled:function(){return 0===this._viewportWidth||0===this._viewportHeight?!0:!i.isAnimationEnabled()},_fadeOutViewport:function(){var a=this;return new k(function(b){if(a._animationsDisabled())return void b();if(!a._fadingViewportOut){a._waitingEntranceAnimationPromise&&(a._waitingEntranceAnimationPromise.cancel(),a._waitingEntranceAnimationPromise=null);var d=a._fireAnimationEvent(S.contentTransition);a._firedAnimationEvent=!0;var e=c._browserStyleEquivalents["overflow-style"],f=e?a._viewport:a._canvas;d.prevented?(a._disableEntranceAnimation=!0,f.style.opacity=1,b()):(a._fadingViewportOut=!0,e&&(f.style[e.scriptName]="none"),P.fadeOutElement(f).then(function(){a._isZombie()||(a._fadingViewportOut=!1,f.style.opacity=1,b())}))}})},_animateListEntrance:function(a){function b(){e._canvas.style.opacity=1,f&&(g.style[f.scriptName]="")}var d={prevented:!1,animationPromise:k.wrap()},e=this,f=c._browserStyleEquivalents["overflow-style"],g=f?this._viewport:this._canvas;return this._disableEntranceAnimation||this._animationsDisabled()?(b(),this._waitingEntranceAnimationPromise&&(this._waitingEntranceAnimationPromise.cancel(),this._waitingEntranceAnimationPromise=null),k.wrap()):(this._firedAnimationEvent?this._firedAnimationEvent=!1:d=this._fireAnimationEvent(S.entrance),d.prevented||c.isPhone?(b(),k.wrap()):(this._waitingEntranceAnimationPromise&&this._waitingEntranceAnimationPromise.cancel(),this._canvas.style.opacity=0,f&&(g.style[f.scriptName]="none"),this._waitingEntranceAnimationPromise=d.animationPromise.then(function(){return e._isZombie()?void 0:(e._canvas.style.opacity=1,P.animateEntrance(g,a).then(function(){e._isZombie()||(f&&(g.style[f.scriptName]=""),e._waitingEntranceAnimationPromise=null)}))}),this._waitingEntranceAnimationPromise))},_fireAnimationEvent:function(b){var c=a.document.createEvent("CustomEvent"),d=k.wrap();c.initCustomEvent("contentanimating",!0,!0,{type:b}),b===S.entrance&&(c.detail.setPromise=function(a){d=a});var e=!this._element.dispatchEvent(c);return{prevented:e,animationPromise:d}},_createAriaMarkers:function(){this._viewport.getAttribute("aria-label")||this._viewport.setAttribute("aria-label",Q.listViewViewportAriaLabel),this._ariaStartMarker||(this._ariaStartMarker=a.document.createElement("div"),this._ariaStartMarker.id=O(this._ariaStartMarker),this._viewport.insertBefore(this._ariaStartMarker,this._viewport.firstElementChild)),this._ariaEndMarker||(this._ariaEndMarker=a.document.createElement("div"),this._ariaEndMarker.id=O(this._ariaEndMarker),this._viewport.appendChild(this._ariaEndMarker))},_updateItemsAriaRoles:function(){var a,b,c=this,d=this._element.getAttribute("role");this._currentMode().staticMode()?(a="list",b="listitem"):(a="listbox",b="option"),(d!==a||this._itemRole!==b)&&(this._element.setAttribute("role",a),this._itemRole=b,this._view.items.each(function(a,b){b.setAttribute("role",c._itemRole)}))},_updateGroupHeadersAriaRoles:function(){var a=this.groupHeaderTapBehavior===u.GroupHeaderTapBehavior.none?"separator":"link";if(this._headerRole!==a){this._headerRole=a;for(var b=0,c=this._groups.length();c>b;b++){var d=this._groups.group(b).header;d&&d.setAttribute("role",this._headerRole)}}},_setAriaSelected:function(a,b){var c="true"===a.getAttribute("aria-selected");b!==c&&a.setAttribute("aria-selected",b)},_setupAriaSelectionObserver:function(a){a._mutationObserver||(this._mutationObserver.observe(a,{attributes:!0,attributeFilter:["aria-selected"]}),a._mutationObserver=!0)},_itemPropertyChange:function(a){function b(a){a.forEach(function(a){a.item.setAttribute("aria-selected",!a.selected)})}if(!this._isZombie()){for(var c=this,d=c._selectionMode===u.SelectionMode.single,e=[],f=[],g=0,h=a.length;h>g;g++){var i=a[g].target,j=c._view.items.itemBoxFrom(i),k="true"===i.getAttribute("aria-selected");if(j&&k!==p._isSelectionRendered(j)){var l=c._view.items.index(j),n={index:l,item:i,selected:k};(c._selectionAllowed(l)?e:f).push(n)}}if(e.length>0){var o=new m;c.selection._synchronize(o).then(function(){var a=c.selection._cloneSelection();return e.forEach(function(b){b.selected?a[d?"set":"add"](b.index):a.remove(b.index)}),c.selection._set(a)}).then(function(a){c._isZombie()||a||b(e),o.complete()})}b(f)}},_groupsEnabled:function(){return!!this._groups.groupDataSource},_getItemPosition:function(a,b){var c=this;return this._view.waitForEntityPosition(a).then(function(){var d=a.type===u.ObjectType.groupHeader?c._view._getHeaderContainer(a.index):c._view.getContainer(a.index);if(d){c._writeProfilerMark("WinJS.UI.ListView:getItemPosition,info");var e,f;c._view._expandedRange?(e=c._view._expandedRange.first.index,f=c._view._expandedRange.last.index):b=!1,a.type===u.ObjectType.item?(b=!!b,b&=c._view._ensureContainerInDOM(a.index)):b=!1;var g=c._getItemMargins(a.type),h={left:c._rtl()?J(d)-g.right:d.offsetLeft-g.left,top:d.offsetTop-g.top,totalWidth:p.getTotalWidth(d),totalHeight:p.getTotalHeight(d),contentWidth:p.getContentWidth(d),contentHeight:p.getContentHeight(d)};return b&&c._view._forceItemsBlocksInDOM(e,f+1),c._zooming&&0!==c._canvasStart?h:c._convertToCanvasCoordinates(h)}return k.cancel})},_getItemOffset:function(a,b){var c=this;return this._getItemPosition(a,b).then(function(b){var d=c._getItemMargins(a.type);if(c._horizontal()){var e=c._rtl();b.begin=b.left-d[e?"left":"right"],b.end=b.left+b.totalWidth+d[e?"right":"left"]}else b.begin=b.top-d.bottom,b.end=b.top+b.totalHeight+d.top;return b})},_getItemMargins:function(b){b=b||u.ObjectType.item;var c=this,d=function(b){var d,e=c._canvas.querySelector("."+b);e||(e=a.document.createElement("div"),p.addClass(e,b),c._viewport.appendChild(e),d=!0);var f=E._getMargins(e);return d&&c._viewport.removeChild(e),f};return b!==u.ObjectType.groupHeader?this._itemMargins?this._itemMargins:this._itemMargins=d(w._containerClass):this._headerMargins?this._headerMargins:this._headerMargins=d(w._headerContainerClass)},_fireAccessibilityAnnotationCompleteEvent:function(b,c,d,e){var f={firstIndex:b,lastIndex:c,firstHeaderIndex:+d||-1,lastHeaderIndex:+e||-1},g=a.document.createEvent("CustomEvent");g.initCustomEvent("accessibilityannotationcomplete",!0,!1,f),this._element.dispatchEvent(g)},_ensureFirstColumnRange:function(a){var b=a===u.ObjectType.item?"_firstItemRange":"_firstHeaderRange";if(this[b])return k.wrap();var c=this;return this._getItemOffset({type:a,index:0},!0).then(function(a){c[b]=a})},_correctRangeInFirstColumn:function(a,b){var c=b===u.ObjectType.groupHeader?this._firstHeaderRange:this._firstItemRange;return c.begin===a.begin&&(a.begin=this._horizontal()?-this._getCanvasMargins()[this._rtl()?"right":"left"]:-this._getCanvasMargins().top),a},_updateContainers:function(b,c,d,e){function f(){var b=a.document.createElement("div");return b.className=w._containerClass,b}function g(b,c,d){c+d>n&&(d=n-c);var e,f,g=b.itemsContainer,h=g.itemsBlocks,i=h.length?h[h.length-1]:null,j=h.length?(h.length-1)*m._view._blockSize+i.items.length:0,k=d-j;if(k>0){if(i&&i.items.length<m._view._blockSize){var l=Math.min(k,m._view._blockSize-i.items.length);s.insertAdjacentHTMLUnsafe(i.element,"beforeend",C._repeat("<div class='win-container win-backdrop'></div>",l)),e=i.items.length,f=i.element.children;for(var o=0;l>o;o++)i.items.push(f[e+o]);k-=l}var p=Math.floor(k/m._view._blockSize),q=k%m._view._blockSize,u="<div class='win-itemsblock'>"+C._repeat("<div class='win-container win-backdrop'></div>",m._view._blockSize)+"</div>",v=C._repeat(u,p);q&&(v+="<div class='win-itemsblock'>"+C._repeat("<div class='win-container win-backdrop'></div>",q)+"</div>",p++);var w=a.document.createElement("div");s.setInnerHTMLUnsafe(w,v);for(var f=w.children,o=0;p>o;o++){var x=f[o],y={element:x,items:C._nodeListToArray(x.children)};g.itemsBlocks.push(y)}}else if(0>k)for(var z=k;0>z;z++){var A=i.items.pop();!m._view._requireFocusRestore&&A.contains(a.document.activeElement)&&(m._view._requireFocusRestore=a.document.activeElement,m._unsetFocusOnItem()),i.element.removeChild(A),t.push(A),i.items.length||(g.element===i.element.parentNode&&g.element.removeChild(i.element),h.pop(),i=h[h.length-1])}for(var o=0,B=h.length;B>o;o++)for(var x=h[o],z=0;z<x.items.length;z++)r.push(x.items[z])}function h(a,b,c){for(var d=e.filter(function(a){return-1===a.oldIndex&&a.newIndex>=b&&a.newIndex<b+c}).sort(function(a,b){return a.newIndex-b.newIndex}),g=a.itemsContainer,h=0,i=d.length;i>h;h++){var j=d[h],k=j.newIndex-b,l=f(),m=k<g.items.length?g.items[k]:null;g.items.splice(k,0,l),g.element.insertBefore(l,m)}}function i(a,b,c){b+c>n&&(c=n-b);var d=a.itemsContainer,e=c-d.items.length;if(e>0){var f=d.element.children,g=f.length;s.insertAdjacentHTMLUnsafe(d.element,"beforeend",C._repeat("<div class='win-container win-backdrop'></div>",e));for(var h=0;e>h;h++){var i=f[g+h];d.items.push(i)}}for(var h=e;0>h;h++){var i=d.items.pop();d.element.removeChild(i),t.push(i)}for(var h=0,j=d.items.length;j>h;h++)r.push(d.items[h])}function j(a,b){var c=m._view._createHeaderContainer(G),d={header:c,itemsContainer:{element:m._view._createItemsContainer(c)}};return d.itemsContainer[m._view._blockSize?"itemsBlocks":"items"]=[],m._view._blockSize?g(d,b,a.size):i(d,b,a.size),d}function k(a,b,d,f){for(var g,h,i=d+f-1,j=0,k=e.length;k>j;j++){var l=e[j];l.newIndex>=d&&l.newIndex<=i&&-1!==l.oldIndex&&(g!==+g||l.newIndex<g)&&(g=l.newIndex,h=l.newIndex-l.oldIndex)}if(g===+g){var n=0;for(j=0,k=e.length;k>j;j++){var l=e[j];l.newIndex>=d&&l.newIndex<g&&-1===l.oldIndex&&n++}var o=0,p=g-h;for(j=0,k=e.length;k>j;j++){var l=e[j];l.oldIndex>=b&&l.oldIndex<p&&-1===l.newIndex&&o++}h+=o,h-=n,h-=d-b;var q=a.itemsContainer;if(h>0){var r=q.element.children;s.insertAdjacentHTMLUnsafe(q.element,"afterBegin",C._repeat("<div class='win-container win-backdrop'></div>",h));for(var t=0;h>t;t++){var u=r[t];q.items.splice(t,0,u)}}for(var t=h;0>t;t++){var u=q.items.shift();q.element.removeChild(u)}h&&m._affectedRange.add({start:d,end:d+f},c)}}function l(a){for(var b=0,c=0,d=m._view.tree.length;d>c;c++){var e=m._view.tree[c],f=e.itemsContainer.items.length,g=b+f-1;if(a>=b&&g>=a)return{group:c,item:a-b};b+=f}}var m=this,n=this._view.containers.length+(d>0?d:0),o=[],q={},r=[],t=[],u=[],v=0;if(!m._view._blockSize)for(var x=0,y=this._view.tree.length;y>x;x++)u.push(v),v+=this._view.tree[x].itemsContainer.items.length;if(!m._view._blockSize)for(var z=e.filter(function(a){return-1===a.newIndex&&!a._removalHandled}).sort(function(a,b){return b.oldIndex-a.oldIndex}),x=0,y=z.length;y>x;x++){var A=z[x];A._removalHandled=!0;var B=A._itemBox;A._itemBox=null;var D=l(A.oldIndex),E=this._view.tree[D.group],F=E.itemsContainer.items[D.item];F.parentNode.removeChild(F),p.hasClass(B,w._selectedClass)&&p.addClass(F,w._selectedClass),E.itemsContainer.items.splice(D.item,1),A.element=F}this._view._modifiedGroups=[];var G=this._canvasProxy;v=0;for(var x=0,y=b.length;y>x&&(!this._groupsEnabled()||n>v);x++){var H=b[x],I=this._view.keyToGroupIndex[H.key],J=this._view.tree[I];if(J)m._view._blockSize?g(J,v,H.size):(k(J,u[I],v,H.size),h(J,v,H.size),i(J,v,H.size)),o.push(J),q[H.key]=o.length-1,delete this._view.keyToGroupIndex[H.key],G=J.itemsContainer.element,this._view._modifiedGroups.push({oldIndex:I,newIndex:o.length-1,element:J.header});else{var K=j(H,v);o.push(K),q[H.key]=o.length-1,this._view._modifiedGroups.push({oldIndex:-1,newIndex:o.length-1,element:K.header}),G=K.itemsContainer.element}v+=H.size}for(var L=[],M=[],N=this._view.keyToGroupIndex?Object.keys(this._view.keyToGroupIndex):[],x=0,y=N.length;y>x;x++){var D=this._view.keyToGroupIndex[N[x]],O=this._view.tree[D];if(M.push(O.header),L.push(O.itemsContainer.element),this._view._blockSize)for(var P=0;P<O.itemsContainer.itemsBlocks.length;P++)for(var Q=O.itemsContainer.itemsBlocks[P],R=0;R<Q.items.length;R++)t.push(Q.items[R]);else for(var R=0;R<O.itemsContainer.items.length;R++)t.push(O.itemsContainer.items[R]);this._view._modifiedGroups.push({oldIndex:D,newIndex:-1,element:O.header})}for(var x=0,y=e.length;y>x;x++)if(-1===e[x].newIndex&&!e[x]._removalHandled){e[x]._removalHandled=!0;var B=e[x]._itemBox;e[x]._itemBox=null;var F;t.length?(F=t.pop(),p.empty(F)):F=f(),p.hasClass(B,w._selectedClass)&&p.addClass(F,w._selectedClass),F.appendChild(B),e[x].element=F}return this._view.tree=o,this._view.keyToGroupIndex=q,this._view.containers=r,{removedHeaders:M,removedItemsContainers:L}},_writeProfilerMark:function(a){var b="WinJS.UI.ListView:"+this._id+":"+a;h(b),f.log&&f.log(b,null,"listviewprofiler")}},{triggerDispose:function(){H()}});return b.Class.mix(D,e.createEventProperties("iteminvoked","groupheaderinvoked","selectionchanging","selectionchanged","loadingstatechanged","keyboardnavigating","contentanimating","itemdragstart","itemdragenter","itemdragend","itemdragbetween","itemdragleave","itemdragchanged","itemdragdrop","accessibilityannotationcomplete")),b.Class.mix(D,n.DOMEventMixin),D})})}),d("WinJS/Controls/FlipView/_Constants",[],function(){"use strict";var a={};return a.datasourceCountChangedEvent="datasourcecountchanged",a.pageVisibilityChangedEvent="pagevisibilitychanged",a.pageSelectedEvent="pageselected",a.pageCompletedEvent="pagecompleted",a}),d("WinJS/Controls/FlipView/_PageManager",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Log","../../Core/_Resources","../../Core/_WriteProfilerMark","../../Animations","../../Promise","../../_Signal","../../Scheduler","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_TabContainer","./_Constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{_FlipPageManager:c.Namespace._lazy(function(){function a(a){var b=a.winControl;return b&&b._isFlipView?!0:!1}function g(a){a.forEach(function(a){var c=a.target;c.winControl&&c.tabIndex>=0&&(c.winControl._pageManager._updateTabIndex(c.tabIndex),c.tabIndex=-1);var d=c.winControl;if(d&&d._isFlipView){var e=!1;"dir"===a.attributeName?e=!0:"style"===a.attributeName&&(e=d._cachedStyleDir!==c.style.direction),e&&(d._cachedStyleDir=c.style.direction,d._pageManager._rtl="rtl"===b.getComputedStyle(d._pageManager._flipperDiv,null).direction,d._pageManager.resized())}})}var q=n._uniqueID,r=d._browserStyleEquivalents,s=50,t=250,u={get badCurrentPage(){return"Invalid argument: currentPage must be a number greater than or equal to zero and be within the bounds of the datasource"}},v=c.Class.define(function(a,c,e,f,h,i,j){this._visibleElements=[],this._flipperDiv=a,this._panningDiv=c,this._panningDivContainer=e,this._buttonVisibilityHandler=j,this._currentPage=null,this._rtl="rtl"===b.getComputedStyle(this._flipperDiv,null).direction,this._itemsManager=f,this._itemSpacing=h,this._tabIndex=n.getTabIndex(a),this._tabIndex<0&&(this._tabIndex=0),c.tabIndex=-1,a.tabIndex=-1,this._tabManager=new o.TabContainer(this._panningDivContainer),this._tabManager.tabIndex=this._tabIndex,this._lastSelectedPage=null,this._lastSelectedElement=null,this._bufferSize=v.flipPageBufferCount,this._cachedSize=-1,this._environmentSupportsTouch=i;var k=this;this._panningDiv.addEventListener("keydown",function(a){k._blockTabs&&a.keyCode===n.Key.tab&&(a.stopImmediatePropagation(),a.preventDefault())},!0),n._addEventListener(this._flipperDiv,"focusin",function(a){a.target===k._flipperDiv&&k._currentPage.element&&n._setActive(k._currentPage.element)},!1),new n._MutationObserver(g).observe(this._flipperDiv,{attributes:!0,attributeFilter:["dir","style","tabindex"]}),this._cachedStyleDir=this._flipperDiv.style.direction,this._handleManipulationStateChangedBound=this._handleManipulationStateChanged.bind(this),this._environmentSupportsTouch&&this._panningDivContainer.addEventListener(d._browserEventEquivalents.manipulationStateChanged,this._handleManipulationStateChangedBound,!0)},{initialize:function(a,c){var d=null;if(this._panningDivContainerOffsetWidth=this._panningDivContainer.offsetWidth,this._panningDivContainerOffsetHeight=this._panningDivContainer.offsetHeight,this._isHorizontal=c,!this._currentPage){this._bufferAriaStartMarker=b.document.createElement("div"),this._bufferAriaStartMarker.id=q(this._bufferAriaStartMarker),this._panningDiv.appendChild(this._bufferAriaStartMarker),this._currentPage=this._createFlipPage(null,this),d=this._currentPage,this._panningDiv.appendChild(d.pageRoot);for(var e=2*this._bufferSize,f=0;e>f;f++)d=this._createFlipPage(d,this),this._panningDiv.appendChild(d.pageRoot);this._bufferAriaEndMarker=b.document.createElement("div"),this._bufferAriaEndMarker.id=q(this._bufferAriaEndMarker),this._panningDiv.appendChild(this._bufferAriaEndMarker)}this._prevMarker=this._currentPage.prev.prev,this._itemsManager&&this.setNewItemsManager(this._itemsManager,a)},dispose:function(){var a=this._currentPage,b=a;do m._disposeElement(b.element),b=b.next;while(b!==a)},setOrientation:function(a){if(this._notificationsEndedSignal){var b=this;return void this._notificationsEndedSignal.promise.done(function(){b._notificationsEndedSignal=null,b.setOrientation(a)})}if(a!==this._isHorizontal){this._isOrientationChanging=!0,this._isHorizontal?n.setScrollPosition(this._panningDivContainer,{scrollLeft:this._getItemStart(this._currentPage),scrollTop:0}):n.setScrollPosition(this._panningDivContainer,{scrollLeft:0,scrollTop:this._getItemStart(this._currentPage)}),this._isHorizontal=a;var c=this._panningDivContainer.style;c.overflowX="hidden",c.overflowY="hidden";var b=this;d._requestAnimationFrame(function(){b._isOrientationChanging=!1,b._forEachPage(function(a){var b=a.pageRoot.style;b.left="0px",b.top="0px"}),c.overflowX=b._isHorizontal&&b._environmentSupportsTouch?"scroll":"hidden",c.overflowY=b._isHorizontal||!b._environmentSupportsTouch?"hidden":"scroll",b._ensureCentered()})}},resetState:function(a){if(this._writeProfilerMark("WinJS.UI.FlipView:resetState,info"),0!==a){var b=this.jumpToIndex(a,!0);if(!b&&d.validation)throw new e("WinJS.UI.FlipView.BadCurrentPage",u.badCurrentPage);return b}m.disposeSubTree(this._flipperDiv),this._resetBuffer(null,!0);var c=this,f=j.wrap(!0);return this._itemsManager&&(f=c._itemsManager._firstItem().then(function(a){return c._currentPage.setElement(a),c._fetchPreviousItems(!0).then(function(){return c._fetchNextItems()}).then(function(){c._setButtonStates()})})),f.then(function(){c._tabManager.childFocus=c._currentPage.element,c._ensureCentered(),c._itemSettledOn()})},setNewItemsManager:function(a,b){this._itemsManager=a;var c=this;return this.resetState(b).then(function(){0!==b&&(c._tabManager.childFocus=c._currentPage.element,c._ensureCentered(),c._itemSettledOn())})},currentIndex:function(){if(!this._itemsManager)return 0;var a=0,b=this._navigationAnimationRecord?this._navigationAnimationRecord.newCurrentElement:this._currentPage.element;return b&&(a=this._getElementIndex(b)),a},resetScrollPos:function(){this._ensureCentered()},scrollPosChanged:function(){if(this._hasFocus&&(this._hadFocus=!0),this._itemsManager&&this._currentPage.element&&!this._isOrientationChanging){var a=this._getViewportStart(),b=this._lastScrollPos>a?this._getTailOfBuffer():this._getHeadOfBuffer();if(a!==this._lastScrollPos){for(;this._currentPage.element&&this._getItemStart(this._currentPage)>a&&this._currentPage.prev.element;)this._currentPage=this._currentPage.prev,this._fetchOnePrevious(b.prev),b=b.prev;for(;this._currentPage.element&&this._itemEnd(this._currentPage)<=a&&this._currentPage.next.element;)this._currentPage=this._currentPage.next,this._fetchOneNext(b.next),b=b.next;this._setButtonStates(),this._checkElementVisibility(!1),this._blockTabs=!0,this._lastScrollPos=a,this._currentPage.element&&(this._tabManager.childFocus=this._currentPage.element),this._setListEnds(),!this._manipulationState&&this._viewportOnItemStart()&&(this._currentPage.element.setAttribute("aria-setsize",this._cachedSize),this._currentPage.element.setAttribute("aria-posinset",this.currentIndex()+1),this._timeoutPageSelection())}}},itemRetrieved:function(a,b){var c=this;if(this._forEachPage(function(d){return d.element===b?(d===c._currentPage||d===c._currentPage.next?c._changeFlipPage(d,b,a):d.setElement(a,!0),!0):void 0}),this._navigationAnimationRecord&&this._navigationAnimationRecord.elementContainers)for(var d=this._navigationAnimationRecord.elementContainers,e=0,f=d.length;f>e;e++)d[e].element===b&&(c._changeFlipPage(d[e],b,a),d[e].element=a);this._checkElementVisibility(!1)},resized:function(){this._panningDivContainerOffsetWidth=this._panningDivContainer.offsetWidth,this._panningDivContainerOffsetHeight=this._panningDivContainer.offsetHeight;var a=this;this._forEachPage(function(b){b.pageRoot.style.width=a._panningDivContainerOffsetWidth+"px",b.pageRoot.style.height=a._panningDivContainerOffsetHeight+"px"}),this._ensureCentered(),this._writeProfilerMark("WinJS.UI.FlipView:resize,StopTM")},jumpToIndex:function(a,b){if(!b){if(!this._itemsManager||!this._currentPage.element||0>a)return j.wrap(!1);var c=this._getElementIndex(this._currentPage.element),d=Math.abs(a-c);if(0===d)return j.wrap(!1)}var e=j.wrap(!0),f=this;return e=e.then(function(){var c=f._itemsManager._itemPromiseAtIndex(a);return j.join({element:f._itemsManager._itemFromItemPromise(c),item:c}).then(function(a){var c=a.element;return f._resetBuffer(c,b),c?(f._currentPage.setElement(c),f._fetchNextItems().then(function(){return f._fetchPreviousItems(!0)}).then(function(){return!0})):!1})}),e=e.then(function(a){return f._setButtonStates(),a})},startAnimatedNavigation:function(a,b,c){if(this._writeProfilerMark("WinJS.UI.FlipView:startAnimatedNavigation,info"),this._currentPage.element){var d=this._currentPage,e=a?this._currentPage.next:this._currentPage.prev;if(e.element){this._hasFocus&&n._setActive(this._panningDiv),this._navigationAnimationRecord={},this._navigationAnimationRecord.goForward=a,this._navigationAnimationRecord.cancelAnimationCallback=b,this._navigationAnimationRecord.completionCallback=c,this._navigationAnimationRecord.oldCurrentPage=d,this._navigationAnimationRecord.newCurrentPage=e;var f=d.element,g=e.element;this._navigationAnimationRecord.newCurrentElement=g,d.setElement(null,!0),d.elementUniqueID=q(f),e.setElement(null,!0),e.elementUniqueID=q(g);var h=this._createDiscardablePage(f),i=this._createDiscardablePage(g);return h.pageRoot.itemIndex=this._getElementIndex(f),i.pageRoot.itemIndex=h.pageRoot.itemIndex+(a?1:-1),h.pageRoot.style.position="absolute",i.pageRoot.style.position="absolute",h.pageRoot.style.zIndex=1,i.pageRoot.style.zIndex=2,this._setItemStart(h,0),this._setItemStart(i,0),this._blockTabs=!0,this._visibleElements.push(g),this._announceElementVisible(g),this._navigationAnimationRecord.elementContainers=[h,i],{outgoing:h,incoming:i}}}return null},endAnimatedNavigation:function(a,b,c){if(this._writeProfilerMark("WinJS.UI.FlipView:endAnimatedNavigation,info"),this._navigationAnimationRecord&&this._navigationAnimationRecord.oldCurrentPage&&this._navigationAnimationRecord.newCurrentPage){var d=this._restoreAnimatedElement(this._navigationAnimationRecord.oldCurrentPage,b);this._restoreAnimatedElement(this._navigationAnimationRecord.newCurrentPage,c),d||this._setViewportStart(this._getItemStart(a?this._currentPage.next:this._currentPage.prev)),this._navigationAnimationRecord=null,this._itemSettledOn()}},startAnimatedJump:function(a,b,c){if(this._writeProfilerMark("WinJS.UI.FlipView:startAnimatedJump,info"),this._hasFocus&&(this._hadFocus=!0),this._currentPage.element){var d=this._currentPage.element,e=this._getElementIndex(d),f=this;return f.jumpToIndex(a).then(function(g){if(!g)return null;if(f._navigationAnimationRecord={},f._navigationAnimationRecord.cancelAnimationCallback=b,f._navigationAnimationRecord.completionCallback=c,f._navigationAnimationRecord.oldCurrentPage=null,f._forEachPage(function(a){return a.element===d?(f._navigationAnimationRecord.oldCurrentPage=a,!0):void 0}),f._navigationAnimationRecord.newCurrentPage=f._currentPage,f._navigationAnimationRecord.newCurrentPage===f._navigationAnimationRecord.oldCurrentPage)return null;var h=f._currentPage.element;f._navigationAnimationRecord.newCurrentElement=h,f._currentPage.setElement(null,!0),f._currentPage.elementUniqueID=q(h),f._navigationAnimationRecord.oldCurrentPage&&f._navigationAnimationRecord.oldCurrentPage.setElement(null,!0);var i=f._createDiscardablePage(d),j=f._createDiscardablePage(h);return i.pageRoot.itemIndex=e,j.pageRoot.itemIndex=a,i.pageRoot.style.position="absolute",j.pageRoot.style.position="absolute",i.pageRoot.style.zIndex=1,j.pageRoot.style.zIndex=2,f._setItemStart(i,0),f._setItemStart(j,f._itemSize(f._currentPage)),f._visibleElements.push(h),f._announceElementVisible(h),f._navigationAnimationRecord.elementContainers=[i,j],f._blockTabs=!0,{oldPage:i,newPage:j}})}return j.wrap(null)},simulateMouseWheelScroll:function(a){if(!this._environmentSupportsTouch&&!this._waitingForMouseScroll){var c;c="number"==typeof a.deltaY?(a.deltaX||a.deltaY)>0:a.wheelDelta<0;var d=c?this._currentPage.next:this._currentPage.prev;if(d.element){var e={contentX:0,contentY:0,viewportX:0,viewportY:0};e[this._isHorizontal?"contentX":"contentY"]=this._getItemStart(d),n._zoomTo(this._panningDivContainer,e),this._waitingForMouseScroll=!0,b.setTimeout(function(){this._waitingForMouseScroll=!1}.bind(this),n._zoomToDuration+100)}}},endAnimatedJump:function(a,b){this._writeProfilerMark("WinJS.UI.FlipView:endAnimatedJump,info"),this._navigationAnimationRecord.oldCurrentPage?this._navigationAnimationRecord.oldCurrentPage.setElement(a.element,!0):a.element.parentNode&&a.element.parentNode.removeChild(a.element),this._navigationAnimationRecord.newCurrentPage.setElement(b.element,!0),this._navigationAnimationRecord=null,this._ensureCentered(),this._itemSettledOn()},inserted:function(a,b,c,d){this._writeProfilerMark("WinJS.UI.FlipView:inserted,info");var e=this._prevMarker,f=!1,g=!1;if(d&&(this._createAnimationRecord(q(a),null),this._getAnimationRecord(a).inserted=!0),b){do{if(e===this._currentPage&&(f=!0),e.elementUniqueID===q(b)){g=!0;var h,i=e,j=a,k=q(a);if(f)for(;i.next!==this._prevMarker;)h=i.next.element,k=i.next.elementUniqueID,i.next.setElement(j,!0),!j&&k&&(i.next.elementUniqueID=k),j=h,i=i.next;else for(e.elementUniqueID===e.next.elementUniqueID&&e.elementUniqueID&&(i=e.next);i.next!==this._prevMarker;)h=i.element,k=i.elementUniqueID,i.setElement(j,!0),!j&&k&&(i.elementUniqueID=k),j=h,i=i.prev;if(j){var l=!1;this._forEachPage(function(a){return q(j)===a.elementUniqueID?(l=!0,!0):void 0}),l||this._releaseElementIfNotAnimated(j)}break}e=e.next}while(e!==this._prevMarker)}else if(c){for(;e.next!==this._prevMarker&&e.elementUniqueID!==q(c);)e===this._currentPage&&(f=!0),e=e.next;e.elementUniqueID===q(c)&&e!==this._prevMarker?(e.prev.setElement(a),g=!0):this._releaseElementIfNotAnimated(a)}else this._currentPage.setElement(a);this._getAnimationRecord(a).successfullyMoved=g,this._setButtonStates()},changed:function(a,b){this._writeProfilerMark("WinJS.UI.FlipView:changed,info");var c=this;if(this._forEachPage(function(d){if(d.elementUniqueID===q(b)){var e=c._animationRecords[d.elementUniqueID];return e.changed=!0,e.oldElement=b,e.newElement=a,d.element=a,d.elementUniqueID=q(a),c._animationRecords[q(a)]=e,!0}}),this._navigationAnimationRecord&&this._navigationAnimationRecord.elementContainers){for(var d=0,e=this._navigationAnimationRecord.elementContainers.length;e>d;d++){var f=this._navigationAnimationRecord.elementContainers[d];f&&f.elementUniqueID===q(b)&&(f.element=a,f.elementUniqueID=q(a))}var g=this._navigationAnimationRecord.newCurrentElement;g&&q(g)===q(b)&&(this._navigationAnimationRecord.newCurrentElement=a)}},moved:function(a,b,c){this._writeProfilerMark("WinJS.UI.FlipView:moved,info");var d=this._getAnimationRecord(a);d||(d=this._createAnimationRecord(q(a))),d.moved=!0,this.removed(a,!1,!1),b||c?this.inserted(a,b,c,!1):d.successfullyMoved=!1},removed:function(a,b,c){this._writeProfilerMark("WinJS.UI.FlipView:removed,info");var d=this,e=this._prevMarker,f=j.wrap();if(b){var g=!1;return this._forEachPage(function(b){(b.elementUniqueID===q(a)||g)&&(b.setElement(null,!0),g=!0)}),void this._setButtonStates()}if(c){var h=this._getAnimationRecord(a);h&&(h.removed=!0)}if(this._currentPage.elementUniqueID===q(a))this._currentPage.next.elementUniqueID?(this._shiftLeft(this._currentPage),this._ensureCentered()):this._currentPage.prev.elementUniqueID?this._shiftRight(this._currentPage):this._currentPage.setElement(null,!0);
  else if(e.elementUniqueID===q(a))e.next.element?f=this._itemsManager._previousItem(e.next.element).then(function(b){return b===a&&(b=d._itemsManager._previousItem(b)),b}).then(function(a){e.setElement(a,!0)}):e.setElement(null,!0);else if(e.prev.elementUniqueID===q(a))e.prev.prev&&e.prev.prev.element?f=this._itemsManager._nextItem(e.prev.prev.element).then(function(b){return b===a&&(b=d._itemsManager._nextItem(b)),b}).then(function(a){e.prev.setElement(a,!0)}):e.prev.setElement(null,!0);else{for(var i=this._currentPage.prev,k=!1;i!==e&&!k;)i.elementUniqueID===q(a)&&(this._shiftRight(i),k=!0),i=i.prev;for(i=this._currentPage.next;i!==e&&!k;)i.elementUniqueID===q(a)&&(this._shiftLeft(i),k=!0),i=i.next}return f.then(function(){d._setButtonStates()})},reload:function(){this._writeProfilerMark("WinJS.UI.FlipView:reload,info"),this.resetState(0)},getItemSpacing:function(){return this._itemSpacing},setItemSpacing:function(a){this._itemSpacing=a,this._ensureCentered()},notificationsStarted:function(){this._writeProfilerMark("WinJS.UI.FlipView:changeNotifications,StartTM"),this._logBuffer(),this._notificationsStarted=this._notificationsStarted||0,this._notificationsStarted++,this._notificationsEndedSignal=new k,this._temporaryKeys=[],this._animationRecords={};var a=this;this._forEachPage(function(b){a._createAnimationRecord(b.elementUniqueID,b)}),this._animationRecords.currentPage=this._currentPage.element,this._animationRecords.nextPage=this._currentPage.next.element},notificationsEnded:function(){var a=this;this._endNotificationsWork&&this._endNotificationsWork.cancel(),this._endNotificationsWork=this._ensureBufferConsistency().then(function(){function b(b){var c=null;return a._forEachPage(function(a){return a.element===b?(c=a,!0):void 0}),c}function c(b,c){a._writeProfilerMark("WinJS.UI.FlipView:_animateOldViewportItemRemoved,info");var d=a._createDiscardablePage(c);a._setItemStart(d,b.originalLocation),f.push(a._deleteFlipPage(d))}function d(c,d){a._writeProfilerMark("WinJS.UI.FlipView:_animateOldViewportItemMoved,info");var e,g=c.originalLocation;if(c.successfullyMoved)e=b(d),g=c.newLocation;else{e=a._createDiscardablePage(d);var h=a._getElementIndex(d),i=a._currentPage.element?a._getElementIndex(a._currentPage.element):0;g+=i>h?-100*a._bufferSize:100*a._bufferSize}e&&(a._setItemStart(e,c.originalLocation),f.push(a._moveFlipPage(e,function(){a._setItemStart(e,g)})))}function e(){return 0===f.length&&f.push(j.wrap()),j.join(f)}var f=[];a._forEachPage(function(b){var c=a._getAnimationRecord(b.element);c&&(c.changed&&(c.oldElement.removedFromChange=!0,f.push(a._changeFlipPage(b,c.oldElement,c.newElement))),c.newLocation=b.location,a._setItemStart(b,c.originalLocation),c.inserted&&(b.elementRoot.style.opacity=0))});var g=a._animationRecords.currentPage,h=a._getAnimationRecord(g),i=a._animationRecords.nextPage,k=a._getAnimationRecord(i);h&&h.changed&&(g=h.newElement),k&&k.changed&&(i=k.newElement),(g!==a._currentPage.element||i!==a._currentPage.next.element)&&(h&&h.removed&&c(h,g),k&&k.removed&&c(k,i)),a._blockTabs=!0,e().then(function(){f=[],h&&h.moved&&d(h,g),k&&k.moved&&d(k,i);var b=a._getAnimationRecord(a._currentPage.element),c=a._getAnimationRecord(a._currentPage.next.element);a._forEachPage(function(d){var e=a._getAnimationRecord(d.element);e&&(e.inserted?e!==b&&e!==c&&(d.elementRoot.style.opacity=1):e.originalLocation!==e.newLocation&&(e!==h&&e!==k||e===h&&!h.moved||e===k&&!k.moved)&&f.push(a._moveFlipPage(d,function(){a._setItemStart(d,e.newLocation)})))}),e().then(function(){f=[],b&&b.inserted&&f.push(a._insertFlipPage(a._currentPage)),c&&c.inserted&&f.push(a._insertFlipPage(a._currentPage.next)),e().then(function(){a._checkElementVisibility(!1),a._itemSettledOn(),a._setListEnds(),a._notificationsStarted--,0===a._notificationsStarted&&a._notificationsEndedSignal.complete(),a._writeProfilerMark("WinJS.UI.FlipView:changeNotifications,StopTM"),a._logBuffer(),a._endNotificationsWork=null})})})})},disableTouchFeatures:function(){this._environmentSupportsTouch=!1;var a=this._panningDivContainer.style;this._panningDivContainer.removeEventListener(d._browserEventEquivalents.manipulationStateChanged,this._handleManipulationStateChangedBound,!0),a.overflowX="hidden",a.overflowY="hidden";var b=["scroll-snap-type","scroll-snap-points-x","scroll-snap-points-y","scroll-limit-x-min","scroll-limit-x-max","scroll-limit-y-min","scroll-limit-y-max"];b.forEach(function(b){var c=r[b];c&&(a[c.scriptName]="")})},_hasFocus:{get:function(){return this._flipperDiv.contains(b.document.activeElement)}},_timeoutPageSelection:function(){var a=this;this._lastTimeoutRequest&&this._lastTimeoutRequest.cancel(),this._lastTimeoutRequest=j.timeout(t).then(function(){a._itemSettledOn()})},_updateTabIndex:function(a){this._forEachPage(function(b){b.element&&(b.element.tabIndex=a)}),this._tabIndex=a,this._tabManager.tabIndex=a},_releaseElementIfNotAnimated:function(a){var b=this._getAnimationRecord(a);b&&(b.changed||b.inserted||b.moved||b.removed)||this._itemsManager.releaseItem(a)},_getAnimationRecord:function(a){return a?this._animationRecords[q(a)]:null},_createAnimationRecord:function(a,b){if(a){var c=this._animationRecords[a]={removed:!1,changed:!1,inserted:!1};return b&&(c.originalLocation=b.location),c}},_writeProfilerMark:function(a){h(a),this._flipperDiv.winControl.constructor._enabledDebug&&f.log&&f.log(a,null,"flipviewdebug")},_getElementIndex:function(a){var b=0;try{b=this._itemsManager.itemObject(a).index}catch(c){}return b},_resetBuffer:function(a,b){this._writeProfilerMark("WinJS.UI.FlipView:_resetBuffer,info");var c=this._currentPage,d=c;do d.element&&d.element===a||b?d.setElement(null,!0):d.setElement(null),d=d.next;while(d!==c)},_getHeadOfBuffer:function(){return this._prevMarker.prev},_getTailOfBuffer:function(){return this._prevMarker},_insertNewFlipPage:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_insertNewFlipPage,info");var b=this._createFlipPage(a,this);return this._panningDiv.appendChild(b.pageRoot),b},_fetchNextItems:function(){this._writeProfilerMark("WinJS.UI.FlipView:_fetchNextItems,info");for(var a=j.wrap(this._currentPage),b=this,c=0;c<this._bufferSize;c++)a=a.then(function(a){return a.next===b._prevMarker&&b._insertNewFlipPage(a),a.element?b._itemsManager._nextItem(a.element).then(function(b){return a.next.setElement(b),a.next}):(a.next.setElement(null),a.next)});return a},_fetchOneNext:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_fetchOneNext,info");var b=a.prev.element;if(this._prevMarker===a&&(this._prevMarker=this._prevMarker.next),!b)return void a.setElement(null);var c=this;return this._itemsManager._nextItem(b).then(function(b){a.setElement(b),c._movePageAhead(a.prev,a)})},_fetchPreviousItems:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_fetchPreviousItems,info");for(var b=this,c=j.wrap(this._currentPage),d=0;d<this._bufferSize;d++)c=c.then(function(a){return a.element?b._itemsManager._previousItem(a.element).then(function(b){return a.prev.setElement(b),a.prev}):(a.prev.setElement(null),a.prev)});return c.then(function(c){a&&(b._prevMarker=c)})},_fetchOnePrevious:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_fetchOnePrevious,info");var b=a.next.element;if(this._prevMarker===a.next&&(this._prevMarker=this._prevMarker.prev),!b)return a.setElement(null),j.wrap();var c=this;return this._itemsManager._previousItem(b).then(function(b){a.setElement(b),c._movePageBehind(a.next,a)})},_setButtonStates:function(){this._currentPage.prev.element?this._buttonVisibilityHandler.showPreviousButton():this._buttonVisibilityHandler.hidePreviousButton(),this._currentPage.next.element?this._buttonVisibilityHandler.showNextButton():this._buttonVisibilityHandler.hideNextButton()},_ensureCentered:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_ensureCentered,info"),this._setItemStart(this._currentPage,s*this._viewportSize());for(var b=this._currentPage;b!==this._prevMarker;)this._movePageBehind(b,b.prev),b=b.prev;for(b=this._currentPage;b.next!==this._prevMarker;)this._movePageAhead(b,b.next),b=b.next;var c=!1;this._lastScrollPos&&!a&&(this._setListEnds(),c=!0),this._lastScrollPos=this._getItemStart(this._currentPage),this._setViewportStart(this._lastScrollPos),this._checkElementVisibility(!0),this._setupSnapPoints(),c||this._setListEnds()},_ensureBufferConsistency:function(){var a=this,b=this._currentPage.element;if(!b)return j.wrap();var c=!1,d={},e={};this._forEachPage(function(a){if(a&&a.elementUniqueID){if(d[a.elementUniqueID])return c=!0,!0;if(d[a.elementUniqueID]=!0,a.location>0){if(e[a.location])return c=!0,!0;e[a.location]=!0}}});var f=Object.keys(this._animationRecords);return f.forEach(function(b){var d=a._animationRecords[b];d&&(d.changed||d.inserted||d.moved||d.removed)&&(c=!0)}),c?(this._resetBuffer(null,!0),this._currentPage.setElement(b),this._fetchNextItems().then(function(){return a._fetchPreviousItems(!0)}).then(function(){a._ensureCentered()})):j.wrap()},_shiftLeft:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_shiftLeft,info");for(var b=a,c=null;b!==this._prevMarker&&b.next!==this._prevMarker;)c=b.next.element,!c&&b.next.elementUniqueID&&(b.elementUniqueID=b.next.elementUniqueID),b.next.setElement(null,!0),b.setElement(c,!0),b=b.next;if(b!==this._prevMarker&&b.prev.element){var d=this;return this._itemsManager._nextItem(b.prev.element).then(function(a){b.setElement(a),d._createAnimationRecord(b.elementUniqueID,b)})}},_logBuffer:function(){if(this._flipperDiv.winControl.constructor._enabledDebug){f.log&&f.log(this._currentPage.next.next.next.elementUniqueID+"	@:"+this._currentPage.next.next.next.location+(this._currentPage.next.next.next.element?"	"+this._currentPage.next.next.next.element.textContent:""),null,"flipviewdebug"),f.log&&f.log(this._currentPage.next.next.next.next.elementUniqueID+"	@:"+this._currentPage.next.next.next.next.location+(this._currentPage.next.next.next.next.element?"	"+this._currentPage.next.next.next.next.element.textContent:""),null,"flipviewdebug"),f.log&&f.log("> "+this._currentPage.elementUniqueID+"	@:"+this._currentPage.location+(this._currentPage.element?"	"+this._currentPage.element.textContent:""),null,"flipviewdebug"),f.log&&f.log(this._currentPage.next.elementUniqueID+"	@:"+this._currentPage.next.location+(this._currentPage.next.element?"	"+this._currentPage.next.element.textContent:""),null,"flipviewdebug"),f.log&&f.log(this._currentPage.next.next.elementUniqueID+"	@:"+this._currentPage.next.next.location+(this._currentPage.next.next.element?"	"+this._currentPage.next.next.element.textContent:""),null,"flipviewdebug");var a=Object.keys(this._itemsManager._elementMap),b=[];this._forEachPage(function(a){a&&a.elementUniqueID&&b.push(a.elementUniqueID)}),f.log&&f.log("itemsmanager  = ["+a.join(" ")+"] flipview ["+b.join(" ")+"]",null,"flipviewdebug")}},_shiftRight:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_shiftRight,info");for(var b=a,c=null;b!==this._prevMarker;)c=b.prev.element,!c&&b.prev.elementUniqueID&&(b.elementUniqueID=b.prev.elementUniqueID),b.prev.setElement(null,!0),b.setElement(c,!0),b=b.prev;if(b.next.element){var d=this;return this._itemsManager._previousItem(b.next.element).then(function(a){b.setElement(a),d._createAnimationRecord(b.elementUniqueID,b)})}},_checkElementVisibility:function(a){var b,c;if(a){var d=this._currentPage.element;for(b=0,c=this._visibleElements.length;c>b;b++)this._visibleElements[b]!==d&&this._announceElementInvisible(this._visibleElements[b]);this._visibleElements=[],d&&(this._visibleElements.push(d),this._announceElementVisible(d))}else{for(b=0,c=this._visibleElements.length;c>b;b++)(!this._visibleElements[b].parentNode||this._visibleElements[b].removedFromChange)&&this._announceElementInvisible(this._visibleElements[b]);this._visibleElements=[];var e=this;this._forEachPage(function(a){var b=a.element;b&&(e._itemInView(a)?(e._visibleElements.push(b),e._announceElementVisible(b)):e._announceElementInvisible(b))})}},_announceElementVisible:function(a){if(a&&!a.visible){a.visible=!0;var c=b.document.createEvent("CustomEvent");this._writeProfilerMark("WinJS.UI.FlipView:pageVisibilityChangedEvent(visible:true),info"),c.initCustomEvent(p.pageVisibilityChangedEvent,!0,!1,{source:this._flipperDiv,visible:!0}),a.dispatchEvent(c)}},_announceElementInvisible:function(a){if(a&&a.visible){a.visible=!1;var c=!1;a.parentNode||(c=!0,this._panningDivContainer.appendChild(a));var d=b.document.createEvent("CustomEvent");this._writeProfilerMark("WinJS.UI.FlipView:pageVisibilityChangedEvent(visible:false),info"),d.initCustomEvent(p.pageVisibilityChangedEvent,!0,!1,{source:this._flipperDiv,visible:!1}),a.dispatchEvent(d),c&&this._panningDivContainer.removeChild(a)}},_createDiscardablePage:function(a){var b=this._createPageContainer(),c={pageRoot:b.root,elementRoot:b.elementContainer,discardable:!0,element:a,elementUniqueID:q(a),discard:function(){c.pageRoot.parentNode&&c.pageRoot.parentNode.removeChild(c.pageRoot),c.element.parentNode&&c.element.parentNode.removeChild(c.element)}};return c.pageRoot.style.top="0px",c.elementRoot.appendChild(a),this._panningDiv.appendChild(c.pageRoot),c},_createPageContainer:function(){var a=this._panningDivContainerOffsetWidth,c=this._panningDivContainerOffsetHeight,d=b.document.createElement("div"),e=d.style,f=b.document.createElement("div");return f.className="win-item",e.position="absolute",e.overflow="hidden",e.width=a+"px",e.height=c+"px",d.appendChild(f),{root:d,elementContainer:f}},_createFlipPage:function(b,c){var d={};d.element=null,d.elementUniqueID=null,b?(d.prev=b,d.next=b.next,d.next.prev=d,b.next=d):(d.next=d,d.prev=d);var e=this._createPageContainer();return d.elementRoot=e.elementContainer,d.elementRoot.style.msOverflowStyle="auto",d.pageRoot=e.root,d.setElement=function(b,e){if(void 0===b&&(b=null),b===d.element)return void(b||(d.elementUniqueID=null));if(d.element&&(e||(c._itemsManager.releaseItem(d.element),m._disposeElement(d.element))),d.element=b,d.elementUniqueID=b?q(b):null,n.empty(d.elementRoot),d.element){if(d===c._currentPage&&(c._tabManager.childFocus=b),!a(d.element)){d.element.tabIndex=c._tabIndex,d.element.setAttribute("role","option"),d.element.setAttribute("aria-selected",!1),d.element.id||(d.element.id=q(d.element));var f=function(a,b,c){a.setAttribute(c,b.id)},g=!d.next.element||d===c._prevMarker.prev;g&&(f(d.element,c._bufferAriaEndMarker,"aria-flowto"),f(c._bufferAriaEndMarker,d.element,"x-ms-aria-flowfrom")),d!==c._prevMarker&&d.prev.element&&(f(d.prev.element,d.element,"aria-flowto"),f(d.element,d.prev.element,"x-ms-aria-flowfrom")),d.next!==c._prevMarker&&d.next.element&&(f(d.element,d.next.element,"aria-flowto"),f(d.next.element,d.element,"x-ms-aria-flowfrom")),d.prev.element||f(d.element,c._bufferAriaStartMarker,"x-ms-aria-flowfrom")}d.elementRoot.appendChild(d.element)}},d},_itemInView:function(a){return this._itemEnd(a)>this._getViewportStart()&&this._getItemStart(a)<this._viewportEnd()},_getViewportStart:function(){return this._panningDivContainer.parentNode?this._isHorizontal?n.getScrollPosition(this._panningDivContainer).scrollLeft:n.getScrollPosition(this._panningDivContainer).scrollTop:void 0},_setViewportStart:function(a){this._panningDivContainer.parentNode&&(this._isHorizontal?n.setScrollPosition(this._panningDivContainer,{scrollLeft:a}):n.setScrollPosition(this._panningDivContainer,{scrollTop:a}))},_viewportEnd:function(){var a=this._panningDivContainer;return this._isHorizontal?this._rtl?this._getViewportStart()+this._panningDivContainerOffsetWidth:n.getScrollPosition(a).scrollLeft+this._panningDivContainerOffsetWidth:a.scrollTop+this._panningDivContainerOffsetHeight},_viewportSize:function(){return this._isHorizontal?this._panningDivContainerOffsetWidth:this._panningDivContainerOffsetHeight},_getItemStart:function(a){return a.location},_setItemStart:function(a,b){this._isHorizontal?a.pageRoot.style.left=(this._rtl?-b:b)+"px":a.pageRoot.style.top=b+"px",a.location=b},_itemEnd:function(a){return(this._isHorizontal?a.location+this._panningDivContainerOffsetWidth:a.location+this._panningDivContainerOffsetHeight)+this._itemSpacing},_itemSize:function(){return this._isHorizontal?this._panningDivContainerOffsetWidth:this._panningDivContainerOffsetHeight},_movePageAhead:function(a,b){var c=this._itemSize(a)+this._itemSpacing;this._setItemStart(b,this._getItemStart(a)+c)},_movePageBehind:function(a,b){var c=this._itemSize(a)+this._itemSpacing;this._setItemStart(b,this._getItemStart(a)-c)},_setupSnapPoints:function(){if(this._environmentSupportsTouch){var a=this._panningDivContainer.style;a[r["scroll-snap-type"].scriptName]="mandatory";var b=this._viewportSize(),c=b+this._itemSpacing,d="scroll-snap-points",e=0,f=this._getItemStart(this._currentPage);e=f%(b+this._itemSpacing),a[r[this._isHorizontal?d+"-x":d+"-y"].scriptName]="snapInterval("+e+"px, "+c+"px)"}},_setListEnds:function(){if(this._environmentSupportsTouch&&this._currentPage.element){for(var a=this._panningDivContainer.style,b=0,c=0,d=this._getTailOfBuffer(),e=this._getHeadOfBuffer(),f=r["scroll-limit-"+(this._isHorizontal?"x-min":"y-min")].scriptName,g=r["scroll-limit-"+(this._isHorizontal?"x-max":"y-max")].scriptName;!e.element&&(e=e.prev,e!==this._prevMarker.prev););for(;!d.element&&(d=d.next,d!==this._prevMarker););c=this._getItemStart(e),b=this._getItemStart(d),a[f]=b+"px",a[g]=c+"px"}},_viewportOnItemStart:function(){return this._getItemStart(this._currentPage)===this._getViewportStart()},_restoreAnimatedElement:function(a,b){var c=!0;return a.elementUniqueID!==q(b.element)||a.element?this._forEachPage(function(a){a.elementUniqueID!==b.elementUniqueID||a.element||(a.setElement(b.element,!0),c=!1)}):(a.setElement(b.element,!0),c=!1),c},_itemSettledOn:function(){this._lastTimeoutRequest&&(this._lastTimeoutRequest.cancel(),this._lastTimeoutRequest=null);var c=this;d._setImmediate(function(){c._viewportOnItemStart()&&(c._blockTabs=!1,c._currentPage.element&&c._lastSelectedElement!==c._currentPage.element&&(c._lastSelectedPage&&c._lastSelectedPage.element&&!a(c._lastSelectedPage.element)&&c._lastSelectedPage.element.setAttribute("aria-selected",!1),c._lastSelectedPage=c._currentPage,c._lastSelectedElement=c._currentPage.element,a(c._currentPage.element)||c._currentPage.element.setAttribute("aria-selected",!0),l.schedule(function(){if(c._currentPage.element){(c._hasFocus||c._hadFocus)&&(c._hadFocus=!1,n._setActive(c._currentPage.element),c._tabManager.childFocus=c._currentPage.element);var a=b.document.createEvent("CustomEvent");a.initCustomEvent(p.pageSelectedEvent,!0,!1,{source:c._flipperDiv}),c._writeProfilerMark("WinJS.UI.FlipView:pageSelectedEvent,info"),c._currentPage.element.dispatchEvent(a);var d=c._currentPage.element;if(d){var e=c._itemsManager._recordFromElement(d,!0);e&&e.renderComplete.then(function(){d===c._currentPage.element&&(c._currentPage.element.setAttribute("aria-setsize",c._cachedSize),c._currentPage.element.setAttribute("aria-posinset",c.currentIndex()+1),c._bufferAriaStartMarker.setAttribute("aria-flowto",c._currentPage.element.id),a=b.document.createEvent("CustomEvent"),a.initCustomEvent(p.pageCompletedEvent,!0,!1,{source:c._flipperDiv}),c._writeProfilerMark("WinJS.UI.FlipView:pageCompletedEvent,info"),c._currentPage.element.dispatchEvent(a))})}}},l.Priority.normal,null,"WinJS.UI.FlipView._dispatchPageSelectedEvent")))})},_forEachPage:function(a){var b=this._prevMarker;do{if(a(b))break;b=b.next}while(b!==this._prevMarker)},_changeFlipPage:function(a,b,c){this._writeProfilerMark("WinJS.UI.FlipView:_changeFlipPage,info"),a.element=null,a.setElement?a.setElement(c,!0):(b.parentNode.removeChild(b),a.elementRoot.appendChild(c));var d=b.style;return d.position="absolute",d.left="0px",d.top="0px",d.opacity=1,a.pageRoot.appendChild(b),b.style.left=Math.max(0,(a.pageRoot.offsetWidth-b.offsetWidth)/2)+"px",b.style.top=Math.max(0,(a.pageRoot.offsetHeight-b.offsetHeight)/2)+"px",i.fadeOut(b).then(function(){b.parentNode&&b.parentNode.removeChild(b)})},_deleteFlipPage:function(a){h("WinJS.UI.FlipView:_deleteFlipPage,info"),a.elementRoot.style.opacity=0;var b=i.createDeleteFromListAnimation([a.elementRoot]),c=this;return b.execute().then(function(){a.discardable&&(a.discard(),c._itemsManager.releaseItem(a.element))})},_insertFlipPage:function(a){h("WinJS.UI.FlipView:_insertFlipPage,info"),a.elementRoot.style.opacity=1;var b=i.createAddToListAnimation([a.elementRoot]);return b.execute().then(function(){a.discardable&&a.discard()})},_moveFlipPage:function(a,b){h("WinJS.UI.FlipView:_moveFlipPage,info");var c=i.createRepositionAnimation(a.pageRoot);b();var d=this;return c.execute().then(function(){if(a.discardable){a.discard();var b=d._getAnimationRecord(a.element);b&&!b.successfullyMoved&&d._itemsManager.releaseItem(a.element)}})},_handleManipulationStateChanged:function(a){this._manipulationState=a.currentState,0===a.currentState&&a.target===this._panningDivContainer&&(this._itemSettledOn(),this._ensureCentered())}},{supportedForProcessing:!1});return v.flipPageBufferCount=2,v})})}),d("WinJS/Controls/FlipView",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Animations/_TransitionAnimation","../BindingList","../Promise","../Scheduler","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_ItemsManager","../Utilities/_UI","./FlipView/_Constants","./FlipView/_PageManager","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){"use strict";b.Namespace.define("WinJS.UI",{FlipView:b.Namespace._lazy(function(){function p(b){var c=b[0].target.winControl;c&&c instanceof L&&b.some(function(a){return"dir"===a.attributeName?!0:"style"===a.attributeName?c._cachedStyleDir!==a.target.style.direction:!1})&&(c._cachedStyleDir=c._flipviewDiv.style.direction,c._rtl="rtl"===a.getComputedStyle(c._flipviewDiv,null).direction,c._setupOrientation())}function u(a){var b=a.target&&a.target.winControl;b&&b instanceof L&&(g("WinJS.UI.FlipView:resize,StartTM"),b._resize())}var v="win-navbutton",w="win-flipview",x="win-navleft",y="win-navright",z="win-navtop",A="win-navbottom",B="Previous",C="Next",D=3e3,E=500,F="&#57570;",G="&#57571;",H="&#57572;",I="&#57573;",J=40,K={get badAxis(){return"Invalid argument: orientation must be a string, either 'horizontal' or 'vertical'"},get badCurrentPage(){return"Invalid argument: currentPage must be a number greater than or equal to zero and be within the bounds of the datasource"},get noitemsManagerForCount(){return"Invalid operation: can't get count if no dataSource has been set"},get badItemSpacingAmount(){return"Invalid argument: itemSpacing must be a number greater than or equal to zero"},get navigationDuringStateChange(){return"Error: After changing itemDataSource or itemTemplate, any navigation in the FlipView control should be delayed until the pageselected event is fired."},get panningContainerAriaLabel(){return f._getWinJSString("ui/flipViewPanningContainerAriaLabel").value}},L=b.Class.define(function(b,c){g("WinJS.UI.FlipView:constructor,StartTM"),this._disposed=!1,b=b||a.document.createElement("div");var d=!0,e=null,f=q._trivialHtmlRenderer,h=0,i=0;if(c){if(c.orientation&&"string"==typeof c.orientation)switch(c.orientation.toLowerCase()){case"horizontal":d=!0;break;case"vertical":d=!1}c.currentPage&&(h=c.currentPage>>0,h=0>h?0:h),c.itemDataSource&&(e=c.itemDataSource),c.itemTemplate&&(f=this._getItemRenderer(c.itemTemplate)),c.itemSpacing&&(i=c.itemSpacing>>0,i=0>i?0:i)}if(!e){var k=new j.List;e=k.dataSource}o.empty(b),this._flipviewDiv=b,b.winControl=this,m._setOptions(this,c,!0),this._initializeFlipView(b,d,e,f,h,i),o.addClass(b,"win-disposable"),this._avoidTrappingTime=0,this._windowWheelHandlerBound=this._windowWheelHandler.bind(this),o._globalListener.addEventListener(b,"wheel",this._windowWheelHandlerBound),o._globalListener.addEventListener(b,"mousewheel",this._windowWheelHandlerBound),g("WinJS.UI.FlipView:constructor,StopTM")},{dispose:function(){g("WinJS.UI.FlipView:dispose,StopTM"),this._disposed||(o._globalListener.removeEventListener(this._flipviewDiv,"wheel",this._windowWheelHandlerBound),o._globalListener.removeEventListener(this._flipviewDiv,"mousewheel",this._windowWheelHandlerBound),o._resizeNotifier.unsubscribe(this._flipviewDiv,u),this._disposed=!0,this._pageManager.dispose(),this._itemsManager.release(),this.itemDataSource=null)},next:function(){g("WinJS.UI.FlipView:next,info");var a=this._nextAnimation?null:this._cancelDefaultAnimation;return this._navigate(!0,a)},previous:function(){g("WinJS.UI.FlipView:prev,info");var a=this._prevAnimation?null:this._cancelDefaultAnimation;return this._navigate(!1,a)},element:{get:function(){return this._flipviewDiv}},currentPage:{get:function(){return this._getCurrentIndex()},set:function(a){if(g("WinJS.UI.FlipView:set_currentPage,info"),this._pageManager._notificationsEndedSignal){var b=this;return void this._pageManager._notificationsEndedSignal.promise.done(function(){b._pageManager._notificationsEndedSignal=null,b.currentPage=a})}if(!this._animating||this._cancelAnimation())if(a>>=0,a=0>a?0:a,this._refreshTimer)this._indexAfterRefresh=a;else{this._pageManager._cachedSize>0?a=Math.min(this._pageManager._cachedSize-1,a):0===this._pageManager._cachedSize&&(a=0);var b=this;if(this._jumpingToIndex===a)return;var c=function(){b._jumpingToIndex=null};this._jumpingToIndex=a;var d=this._jumpAnimation?this._jumpAnimation:this._defaultAnimation.bind(this),e=this._jumpAnimation?null:this._cancelDefaultAnimation,f=function(){b._completeJump()};this._pageManager.startAnimatedJump(a,e,f).then(function(a){if(a){b._animationsStarted();var e=a.oldPage.pageRoot,h=a.newPage.pageRoot;b._contentDiv.appendChild(e),b._contentDiv.appendChild(h),b._completeJumpPending=!0,d(e,h).then(function(){b._completeJumpPending&&(f(),g("WinJS.UI.FlipView:set_currentPage.animationComplete,info"))}).done(c,c)}else c()},c)}}},orientation:{get:function(){return this._axisAsString()},set:function(a){g("WinJS.UI.FlipView:set_orientation,info");var b="horizontal"===a;b!==this._isHorizontal&&(this._isHorizontal=b,this._setupOrientation(),this._pageManager.setOrientation(this._isHorizontal))}},itemDataSource:{get:function(){return this._dataSource},set:function(a){g("WinJS.UI.FlipView:set_itemDataSource,info"),this._dataSourceAfterRefresh=a||(new j.List).dataSource,this._refresh()}},itemTemplate:{get:function(){return this._itemRenderer},set:function(a){g("WinJS.UI.FlipView:set_itemTemplate,info"),this._itemRendererAfterRefresh=this._getItemRenderer(a),this._refresh()}},itemSpacing:{get:function(){return this._pageManager.getItemSpacing()},set:function(a){g("WinJS.UI.FlipView:set_itemSpacing,info"),a>>=0,a=0>a?0:a,this._pageManager.setItemSpacing(a)}},count:function(){g("WinJS.UI.FlipView:count,info");var a=this;return new k(function(b,c){a._itemsManager?a._pageManager._cachedSize===r.CountResult.unknown||a._pageManager._cachedSize>=0?b(a._pageManager._cachedSize):a._dataSource.getCount().then(function(c){a._pageManager._cachedSize=c,b(c)}):c(L.noitemsManagerForCount)})},setCustomAnimations:function(a){g("WinJS.UI.FlipView:setCustomAnimations,info"),void 0!==a.next&&(this._nextAnimation=a.next),void 0!==a.previous&&(this._prevAnimation=a.previous),void 0!==a.jump&&(this._jumpAnimation=a.jump)},forceLayout:function(){g("WinJS.UI.FlipView:forceLayout,info"),this._pageManager.resized()},_initializeFlipView:function(b,d,e,f,g,h){function i(a){a.setAttribute("aria-hidden",!0),a.style.visibility="hidden",a.style.opacity=0,a.tabIndex=-1,a.style.zIndex=1e3}function j(a){if(a.pointerType!==D){if(m._touchInteraction=!1,a.screenX===m._lastMouseX&&a.screenY===m._lastMouseY)return;m._lastMouseX=a.screenX,m._lastMouseY=a.screenY,m._mouseInViewport=!0,m._fadeInButton("prev"),m._fadeInButton("next"),m._fadeOutButtons()}}function k(a){a.pointerType===D?(m._mouseInViewport=!1,m._touchInteraction=!0,m._fadeOutButtons(!0)):(m._touchInteraction=!1,m._isInteractive(a.target)||0!==(4&a.buttons)&&(a.stopPropagation(),a.preventDefault()))}function l(a){a.pointerType!==D&&(m._touchInteraction=!1)}var m=this,n=!1;this._flipviewDiv=b,o.addClass(this._flipviewDiv,w),this._contentDiv=a.document.createElement("div"),this._panningDivContainer=a.document.createElement("div"),this._panningDivContainer.className="win-surface",this._panningDiv=a.document.createElement("div"),this._prevButton=a.document.createElement("button"),this._nextButton=a.document.createElement("button"),this._isHorizontal=d,this._dataSource=e,this._itemRenderer=f,this._itemsManager=null,this._pageManager=null;for(var s=["scroll-limit-x-max","scroll-limit-x-min","scroll-limit-y-max","scroll-limit-y-min","scroll-snap-type","scroll-snap-x","scroll-snap-y","overflow-style"],v=!0,x=c._browserStyleEquivalents,y=0,z=s.length;z>y;y++)v=v&&!!x[s[y]];v=v&&!!c._browserEventEquivalents.manipulationStateChanged,v=v&&o._supportsSnapPoints,this._environmentSupportsTouch=v;var A=this._flipviewDiv.getAttribute("aria-label");A||this._flipviewDiv.setAttribute("aria-label",""),this._flipviewDiv.setAttribute("role","listbox"),this._flipviewDiv.style.overflow||(this._flipviewDiv.style.overflow="hidden"),this._contentDiv.style.position="relative",this._contentDiv.style.zIndex=0,this._contentDiv.style.width="100%",this._contentDiv.style.height="100%",this._panningDiv.style.position="relative",this._panningDivContainer.style.position="relative",this._panningDivContainer.style.width="100%",this._panningDivContainer.style.height="100%",this._panningDivContainer.setAttribute("role","group"),this._panningDivContainer.setAttribute("aria-label",K.panningContainerAriaLabel),this._contentDiv.appendChild(this._panningDivContainer),this._flipviewDiv.appendChild(this._contentDiv),this._panningDiv.style.width="100%",this._panningDiv.style.height="100%",this._setupOrientation(),i(this._prevButton),i(this._nextButton),this._prevButton.setAttribute("aria-label",B),this._nextButton.setAttribute("aria-label",C),this._prevButton.setAttribute("type","button"),this._nextButton.setAttribute("type","button"),this._panningDivContainer.appendChild(this._panningDiv),this._contentDiv.appendChild(this._prevButton),this._contentDiv.appendChild(this._nextButton),this._itemsManagerCallback={inserted:function(a,b,c){m._itemsManager._itemFromPromise(a).then(function(a){var d=m._itemsManager._elementFromHandle(b),e=m._itemsManager._elementFromHandle(c);m._pageManager.inserted(a,d,e,!0)})},countChanged:function(a,b){m._pageManager._cachedSize=a,b!==r.CountResult.unknown&&m._fireDatasourceCountChangedEvent()},changed:function(a,b){m._pageManager.changed(a,b)},moved:function(a,b,c,d){var e=function(a){m._pageManager.moved(a,b,c)};a?e(a):m._itemsManager._itemFromPromise(d).then(e)},removed:function(a,b){a&&m._pageManager.removed(a,b,!0)},knownUpdatesComplete:function(){},beginNotifications:function(){m._cancelAnimation(),m._pageManager.notificationsStarted()},endNotifications:function(){m._pageManager.notificationsEnded()},itemAvailable:function(a,b){m._pageManager.itemRetrieved(a,b)},reload:function(){m._pageManager.reload()}},this._dataSource&&(this._itemsManager=q._createItemsManager(this._dataSource,this._itemRenderer,this._itemsManagerCallback,{ownerElement:this._flipviewDiv})),this._pageManager=new t._FlipPageManager(this._flipviewDiv,this._panningDiv,this._panningDivContainer,this._itemsManager,h,this._environmentSupportsTouch,{hidePreviousButton:function(){m._hasPrevContent=!1,m._fadeOutButton("prev"),m._prevButton.setAttribute("aria-hidden",!0)},showPreviousButton:function(){m._hasPrevContent=!0,m._fadeInButton("prev"),m._prevButton.setAttribute("aria-hidden",!1)},hideNextButton:function(){m._hasNextContent=!1,m._fadeOutButton("next"),m._nextButton.setAttribute("aria-hidden",!0)},showNextButton:function(){m._hasNextContent=!0,m._fadeInButton("next"),m._nextButton.setAttribute("aria-hidden",!1)
  }}),this._pageManager.initialize(g,this._isHorizontal),this._dataSource.getCount().then(function(a){m._pageManager._cachedSize=a}),this._prevButton.addEventListener("click",function(){m.previous()},!1),this._nextButton.addEventListener("click",function(){m.next()},!1),new o._MutationObserver(p).observe(this._flipviewDiv,{attributes:!0,attributeFilter:["dir","style"]}),this._cachedStyleDir=this._flipviewDiv.style.direction,this._flipviewDiv.addEventListener("mselementresize",u),o._resizeNotifier.subscribe(this._flipviewDiv,u),this._contentDiv.addEventListener("mouseleave",function(){m._mouseInViewport=!1},!1);var D=o._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch";this._environmentSupportsTouch&&(o._addEventListener(this._contentDiv,"pointerdown",k,!1),o._addEventListener(this._contentDiv,"pointermove",j,!1),o._addEventListener(this._contentDiv,"pointerup",l,!1)),this._panningDivContainer.addEventListener("scroll",function(){m._scrollPosChanged()},!1),this._panningDiv.addEventListener("blur",function(){m._touchInteraction||m._fadeOutButtons()},!0);var E=a.document.body.contains(this._flipviewDiv);o._addInsertedNotifier(this._flipviewDiv),this._flipviewDiv.addEventListener("WinJSNodeInserted",function(){return E?void(E=!1):void m._pageManager.resized()},!1),this._flipviewDiv.addEventListener("keydown",function(a){var b=!0;if(!m._isInteractive(a.target)){var c=o.Key,d=!1;if(m._isHorizontal)switch(a.keyCode){case c.leftArrow:m._rtl?m.next():m.previous(),d=!0;break;case c.pageUp:m.previous(),d=!0;break;case c.rightArrow:m._rtl?m.previous():m.next(),d=!0;break;case c.pageDown:m.next(),d=!0;break;case c.upArrow:case c.downArrow:d=!0,b=!1}else switch(a.keyCode){case c.upArrow:case c.pageUp:m.previous(),d=!0;break;case c.downArrow:case c.pageDown:m.next(),d=!0;break;case c.space:d=!0}switch(a.keyCode){case c.home:m.currentPage=0,d=!0;break;case c.end:m._pageManager._cachedSize>0&&(m.currentPage=m._pageManager._cachedSize-1),d=!0}if(d)return a.preventDefault(),b&&a.stopPropagation(),!0}},!1),n=!0},_windowWheelHandler:function(a){a=a.detail.originalEvent;var b=a.target&&(this._flipviewDiv.contains(a.target)||this._flipviewDiv===a.target),d=this,e=c._now(),f=this._avoidTrappingTime>e;(!b||f)&&(this._avoidTrappingTime=e+E),b&&f?(this._panningDivContainer.style.overflowX="hidden",this._panningDivContainer.style.overflowY="hidden",c._yieldForDomModification(function(){d._pageManager._ensureCentered(),d._isHorizontal?(d._panningDivContainer.style.overflowX=d._environmentSupportsTouch?"scroll":"hidden",d._panningDivContainer.style.overflowY="hidden"):(d._panningDivContainer.style.overflowY=d._environmentSupportsTouch?"scroll":"hidden",d._panningDivContainer.style.overflowX="hidden")})):b&&this._pageManager.simulateMouseWheelScroll(a)},_isInteractive:function(a){if(a.parentNode)for(var b=a.parentNode.querySelectorAll(".win-interactive, .win-interactive *"),c=0,d=b.length;d>c;c++)if(b[c]===a)return!0;return!1},_refreshHandler:function(){var a=this._dataSourceAfterRefresh||this._dataSource,b=this._itemRendererAfterRefresh||this._itemRenderer,c=this._indexAfterRefresh||0;this._setDatasource(a,b,c),this._dataSourceAfterRefresh=null,this._itemRendererAfterRefresh=null,this._indexAfterRefresh=0,this._refreshTimer=!1},_refresh:function(){if(!this._refreshTimer){var a=this;this._refreshTimer=!0,l.schedule(function(){a._refreshTimer&&!a._disposed&&a._refreshHandler()},l.Priority.high,null,"WinJS.UI.FlipView._refreshHandler")}},_getItemRenderer:function(b){var c=null;if("function"==typeof b){var d=new k(function(){}),e=b(d);c=e.element?"object"==typeof e.element&&"function"==typeof e.element.then?function(c){var d=a.document.createElement("div");return d.className="win-template",n.markDisposable(d),{element:d,renderComplete:b(c).element.then(function(a){d.appendChild(a)})}}:b:function(c){var d=a.document.createElement("div");return d.className="win-template",n.markDisposable(d),{element:d,renderComplete:c.then(function(){return k.as(b(c)).then(function(a){d.appendChild(a)})})}}}else"object"==typeof b&&(c=b.renderItem);return c},_navigate:function(a,b){if(c.validation&&this._refreshTimer)throw new d("WinJS.UI.FlipView.NavigationDuringStateChange",K.navigationDuringStateChange);if(this._animating||(this._animatingForward=a),this._goForward=a,this._animating&&!this._cancelAnimation())return!1;var e=this,f=a?this._nextAnimation:this._prevAnimation,g=f?f:this._defaultAnimation.bind(this),h=function(a){e._completeNavigation(a)},i=this._pageManager.startAnimatedNavigation(a,b,h);if(i){this._animationsStarted();var j=i.outgoing.pageRoot,k=i.incoming.pageRoot;return this._contentDiv.appendChild(j),this._contentDiv.appendChild(k),this._completeNavigationPending=!0,g(j,k).then(function(){e._completeNavigationPending&&h(e._goForward)}).done(),!0}return!1},_cancelDefaultAnimation:function(a,b){a.style.opacity=0,b.style.animationName="",b.style.opacity=1},_cancelAnimation:function(){if(this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.completionCallback){var a=this._pageManager._navigationAnimationRecord.cancelAnimationCallback;if(a&&(a=a.bind(this)),this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.elementContainers){var b=this._pageManager._navigationAnimationRecord.elementContainers[0],c=this._pageManager._navigationAnimationRecord.elementContainers[1],d=b.pageRoot,e=c.pageRoot;return a&&a(d,e),this._pageManager._navigationAnimationRecord.completionCallback(this._animatingForward),!0}}return!1},_completeNavigation:function(a){if(!this._disposed){if(this._pageManager._resizing=!1,this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.elementContainers){var b=this._pageManager._navigationAnimationRecord.elementContainers[0],c=this._pageManager._navigationAnimationRecord.elementContainers[1],d=b.pageRoot,e=c.pageRoot;d.parentNode&&d.parentNode.removeChild(d),e.parentNode&&e.parentNode.removeChild(e),this._pageManager.endAnimatedNavigation(a,b,c),this._fadeOutButtons(),this._scrollPosChanged(),this._pageManager._ensureCentered(!0),this._animationsFinished()}this._completeNavigationPending=!1}},_completeJump:function(){if(!this._disposed){if(this._pageManager._resizing=!1,this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.elementContainers){var a=this._pageManager._navigationAnimationRecord.elementContainers[0],b=this._pageManager._navigationAnimationRecord.elementContainers[1],c=a.pageRoot,d=b.pageRoot;c.parentNode&&c.parentNode.removeChild(c),d.parentNode&&d.parentNode.removeChild(d),this._pageManager.endAnimatedJump(a,b),this._animationsFinished()}this._completeJumpPending=!1}},_resize:function(){this._pageManager.resized()},_setCurrentIndex:function(a){return this._pageManager.jumpToIndex(a)},_getCurrentIndex:function(){return this._pageManager.currentIndex()},_setDatasource:function(a,b,c){this._animating&&this._cancelAnimation();var d=0;void 0!==c&&(d=c),this._dataSource=a,this._itemRenderer=b;var e=this._itemsManager;this._itemsManager=q._createItemsManager(this._dataSource,this._itemRenderer,this._itemsManagerCallback,{ownerElement:this._flipviewDiv}),this._dataSource=this._itemsManager.dataSource;var f=this;this._dataSource.getCount().then(function(a){f._pageManager._cachedSize=a}),this._pageManager.setNewItemsManager(this._itemsManager,d),e&&e.release()},_fireDatasourceCountChangedEvent:function(){var b=this;l.schedule(function(){var c=a.document.createEvent("Event");c.initEvent(L.datasourceCountChangedEvent,!0,!0),g("WinJS.UI.FlipView:dataSourceCountChangedEvent,info"),b._flipviewDiv.dispatchEvent(c)},l.Priority.normal,null,"WinJS.UI.FlipView._dispatchDataSourceCountChangedEvent")},_scrollPosChanged:function(){this._pageManager.scrollPosChanged()},_axisAsString:function(){return this._isHorizontal?"horizontal":"vertical"},_setupOrientation:function(){if(this._isHorizontal){this._panningDivContainer.style.overflowX=this._environmentSupportsTouch?"scroll":"hidden",this._panningDivContainer.style.overflowY="hidden";var b="rtl"===a.getComputedStyle(this._flipviewDiv,null).direction;this._rtl=b,b?(this._prevButton.className=v+" "+y,this._nextButton.className=v+" "+x):(this._prevButton.className=v+" "+x,this._nextButton.className=v+" "+y),this._prevButton.innerHTML=b?G:F,this._nextButton.innerHTML=b?F:G}else this._panningDivContainer.style.overflowY=this._environmentSupportsTouch?"scroll":"hidden",this._panningDivContainer.style.overflowX="hidden",this._prevButton.className=v+" "+z,this._nextButton.className=v+" "+A,this._prevButton.innerHTML=H,this._nextButton.innerHTML=I;this._panningDivContainer.style.msOverflowStyle="none"},_fadeInButton:function(a,b){(this._mouseInViewport||b||!this._environmentSupportsTouch)&&("next"===a&&this._hasNextContent?(this._nextButtonAnimation&&(this._nextButtonAnimation.cancel(),this._nextButtonAnimation=null),this._nextButton.style.visibility="visible",this._nextButtonAnimation=this._fadeInFromCurrentValue(this._nextButton)):"prev"===a&&this._hasPrevContent&&(this._prevButtonAnimation&&(this._prevButtonAnimation.cancel(),this._prevButtonAnimation=null),this._prevButton.style.visibility="visible",this._prevButtonAnimation=this._fadeInFromCurrentValue(this._prevButton)))},_fadeOutButton:function(a){var b=this;return"next"===a?(this._nextButtonAnimation&&(this._nextButtonAnimation.cancel(),this._nextButtonAnimation=null),this._nextButtonAnimation=h.fadeOut(this._nextButton).then(function(){b._nextButton.style.visibility="hidden"}),this._nextButtonAnimation):(this._prevButtonAnimation&&(this._prevButtonAnimation.cancel(),this._prevButtonAnimation=null),this._prevButtonAnimation=h.fadeOut(this._prevButton).then(function(){b._prevButton.style.visibility="hidden"}),this._prevButtonAnimation)},_fadeOutButtons:function(a){if(this._environmentSupportsTouch){this._buttonFadePromise&&(this._buttonFadePromise.cancel(),this._buttonFadePromise=null);var b=this;this._buttonFadePromise=(a?k.wrap():k.timeout(i._animationTimeAdjustment(D))).then(function(){b._fadeOutButton("prev"),b._fadeOutButton("next"),b._buttonFadePromise=null})}},_animationsStarted:function(){this._animating=!0},_animationsFinished:function(){this._animating=!1},_defaultAnimation:function(a,b){var c={};b.style.left="0px",b.style.top="0px",b.style.opacity=0;var d=a.itemIndex>b.itemIndex?-J:J;c.left=(this._isHorizontal?this._rtl?-d:d:0)+"px",c.top=(this._isHorizontal?0:d)+"px";var e=h.fadeOut(a),f=h.enterContent(b,[c],{mechanism:"transition"});return k.join([e,f])},_fadeInFromCurrentValue:function(a){return i.executeTransition(a,{property:"opacity",delay:0,duration:167,timing:"linear",to:1})}},s);return b.Class.mix(L,e.createEventProperties(L.datasourceCountChangedEvent,L.pageVisibilityChangedEvent,L.pageSelectedEvent,L.pageCompletedEvent)),b.Class.mix(L,m.DOMEventMixin),L})})}),d("WinJS/Controls/ItemContainer",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Promise","../Scheduler","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_KeyboardBehavior","../Utilities/_UI","./ItemContainer/_Constants","./ItemContainer/_ItemEventsHandler"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){"use strict";var t=f._createEventProperty,u={invoked:"invoked",selectionchanging:"selectionchanging",selectionchanged:"selectionchanged"};c.Namespace._moduleDefine(a,"WinJS.UI",{ItemContainer:c.Namespace._lazy(function(){var f={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"}},h=c.Class.define(function(c,d){function g(a,b,c){return{name:b?a:a.toLowerCase(),handler:function(b){i["_on"+a](b)},capture:c}}if(c=c||b.document.createElement("DIV"),this._id=c.id||n._uniqueID(c),this._writeProfilerMark("constructor,StartTM"),d=d||{},c.winControl)throw new e("WinJS.UI.ItemContainer.DuplicateConstruction",f.duplicateConstruction);c.winControl=this,this._element=c,n.addClass(c,"win-disposable"),this._selectionMode=q.SelectionMode.single,this._draggable=!1,this._pressedEntity={type:q.ObjectType.item,index:r._INVALID_INDEX},this.tapBehavior=q.TapBehavior.invokeOnly,this.swipeOrientation=q.Orientation.vertical,this.swipeBehavior=q.SwipeBehavior.select,n.addClass(this.element,h._ClassName.itemContainer+" "+r._containerClass),this._setupInternalTree(),this._selection=new a._SingleItemSelectionManager(c,this._itemBox),this._setTabIndex(),l.setOptions(this,d),this._mutationObserver=new n._MutationObserver(this._itemPropertyChange.bind(this)),this._mutationObserver.observe(c,{attributes:!0,attributeFilter:["aria-selected"]}),this._setAriaRole();var i=this;this.selectionDisabled||k.schedule(function(){i._setDirectionClass()},k.Priority.normal,null,"WinJS.UI.ItemContainer_async_initialize"),this._itemEventsHandler=new s._ItemEventsHandler(Object.create({containerFromElement:function(){return i.element},indexForItemElement:function(){return 1},indexForHeaderElement:function(){return r._INVALID_INDEX},itemBoxAtIndex:function(){return i._itemBox},itemAtIndex:function(){return i.element},headerAtIndex:function(){return null},containerAtIndex:function(){return i.element},isZombie:function(){return this._disposed},getItemPosition:function(){return i._getItemPosition()},rtl:function(){return i._rtl()},fireInvokeEvent:function(){i._fireInvokeEvent()},verifySelectionAllowed:function(){return i._verifySelectionAllowed()},changeFocus:function(){},selectRange:function(a,b){return i._selection.set({firstIndex:a,lastIndex:b})}},{pressedEntity:{get:function(){return i._pressedEntity},set:function(a){i._pressedEntity=a}},pressedElement:{enumerable:!0,set:function(a){i._pressedElement=a}},eventHandlerRoot:{enumerable:!0,get:function(){return i.element}},swipeBehavior:{enumerable:!0,get:function(){return i._swipeBehavior}},selectionMode:{enumerable:!0,get:function(){return i._selectionMode}},accessibleItemClass:{enumerable:!0,get:function(){return r._containerClass}},canvasProxy:{enumerable:!0,get:function(){return i._captureProxy}},tapBehavior:{enumerable:!0,get:function(){return i._tapBehavior}},draggable:{enumerable:!0,get:function(){return i._draggable}},selection:{enumerable:!0,get:function(){return i._selection}},horizontal:{enumerable:!0,get:function(){return i._swipeOrientation===q.Orientation.vertical}},customFootprintParent:{enumerable:!0,get:function(){return null}},skipPreventDefaultOnPointerDown:{enumerable:!0,get:function(){return!0}}}));var j=[g("MSManipulationStateChanged",!0,!0),g("PointerDown"),g("Click"),g("PointerUp"),g("PointerCancel"),g("LostPointerCapture"),g("ContextMenu"),g("MSHoldVisual",!0),g("FocusIn"),g("FocusOut"),g("DragStart"),g("DragEnd"),g("KeyDown")];j.forEach(function(a){n._addEventListener(i.element,a.name,a.handler,!!a.capture)}),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},draggable:{get:function(){return this._draggable},set:function(a){d.isPhone||this._draggable!==a&&(this._draggable=a,this._updateDraggableAttribute())}},selected:{get:function(){return this._selection.selected},set:function(a){this._selection.selected!==a&&(this._selection.selected=a)}},swipeOrientation:{get:function(){return this._swipeOrientation},set:function(a){a===q.Orientation.vertical?(n.removeClass(this.element,h._ClassName.horizontal),n.addClass(this.element,h._ClassName.vertical)):(a=q.Orientation.horizontal,n.removeClass(this.element,h._ClassName.vertical),n.addClass(this.element,h._ClassName.horizontal)),this._swipeOrientation=a}},tapBehavior:{get:function(){return this._tapBehavior},set:function(a){d.isPhone&&a===q.TapBehavior.directSelect||(this._tapBehavior=a,this._setAriaRole())}},swipeBehavior:{get:function(){return this._swipeBehavior},set:function(a){this._swipeBehavior=a,this._setSwipeClass()}},selectionDisabled:{get:function(){return this._selectionMode===q.SelectionMode.none},set:function(a){a?this._selectionMode=q.SelectionMode.none:(this._setDirectionClass(),this._selectionMode=q.SelectionMode.single),this._setSwipeClass(),this._setAriaRole()}},oninvoked:t(u.invoked),onselectionchanging:t(u.selectionchanging),onselectionchanged:t(u.selectionchanged),forceLayout:function(){this._forceLayout()},dispose:function(){this._disposed||(this._disposed=!0,this._itemEventsHandler.dispose(),m.disposeSubTree(this.element))},_onMSManipulationStateChanged:function(a){this._itemEventsHandler.onMSManipulationStateChanged(a)},_onPointerDown:function(a){this._itemEventsHandler.onPointerDown(a)},_onClick:function(a){this._itemEventsHandler.onClick(a)},_onPointerUp:function(a){n.hasClass(this._itemBox,r._itemFocusClass)&&this._onFocusOut(a),this._itemEventsHandler.onPointerUp(a)},_onPointerCancel:function(a){this._itemEventsHandler.onPointerCancel(a)},_onLostPointerCapture:function(a){this._itemEventsHandler.onLostPointerCapture(a)},_onContextMenu:function(a){this._itemEventsHandler.onContextMenu(a)},_onMSHoldVisual:function(a){this._itemEventsHandler.onMSHoldVisual(a)},_onFocusIn:function(){if(!this._itemBox.querySelector("."+r._itemFocusOutlineClass)&&p._keyboardSeenLast){n.addClass(this._itemBox,r._itemFocusClass);var a=b.document.createElement("div");a.className=r._itemFocusOutlineClass,this._itemBox.appendChild(a)}},_onFocusOut:function(){n.removeClass(this._itemBox,r._itemFocusClass);var a=this._itemBox.querySelector("."+r._itemFocusOutlineClass);a&&a.parentNode.removeChild(a)},_onDragStart:function(a){if(this._pressedElement&&this._itemEventsHandler._isInteractive(this._pressedElement))a.preventDefault();else{this._dragging=!0;var b=this;if(a.dataTransfer.setData("text",""),a.dataTransfer.setDragImage){var c=this.element.getBoundingClientRect();a.dataTransfer.setDragImage(this.element,a.clientX-c.left,a.clientY-c.top)}d._yieldForDomModification(function(){b._dragging&&n.addClass(b._itemBox,r._dragSourceClass)})}},_onDragEnd:function(){this._dragging=!1,n.removeClass(this._itemBox,r._dragSourceClass),this._itemEventsHandler.resetPointerDownState()},_onKeyDown:function(a){if(!this._itemEventsHandler._isInteractive(a.target)){var b=n.Key,c=a.keyCode,d=this._swipeBehavior===q.SwipeBehavior.select,e=!1;if(a.ctrlKey||c!==b.enter)a.ctrlKey&&c===b.enter||d&&a.shiftKey&&c===b.F10||d&&c===b.menu||c===b.space?this.selectionDisabled||(this.selected=!this.selected,e=n._setActive(this.element)):c===b.escape&&this.selected&&(this.selected=!1,e=!0);else{var f=this._verifySelectionAllowed();f.canTapSelect&&(this.selected=!this.selected),this._fireInvokeEvent(),e=!0}e&&(a.stopPropagation(),a.preventDefault())}},_setTabIndex:function(){var a=this.element.getAttribute("tabindex");a||this.element.setAttribute("tabindex","0")},_rtl:function(){return"boolean"!=typeof this._cachedRTL&&(this._cachedRTL="rtl"===b.getComputedStyle(this.element,null).direction),this._cachedRTL},_setDirectionClass:function(){n[this._rtl()?"addClass":"removeClass"](this.element,r._rtlListViewClass)},_forceLayout:function(){this._cachedRTL="rtl"===b.getComputedStyle(this.element,null).direction,this._setDirectionClass()},_getItemPosition:function(){var a=this.element;return a?j.wrap({left:this._rtl()?a.offsetParent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft,top:a.offsetTop,totalWidth:n.getTotalWidth(a),totalHeight:n.getTotalHeight(a),contentWidth:n.getContentWidth(a),contentHeight:n.getContentHeight(a)}):j.cancel},_itemPropertyChange:function(a){if(!this._disposed){var b=a[0].target,c="true"===b.getAttribute("aria-selected");c!==n._isSelectionRendered(this._itemBox)&&(this.selectionDisabled?n._setAttribute(b,"aria-selected",!c):(this.selected=c,c!==this.selected&&n._setAttribute(b,"aria-selected",!c)))}},_setSwipeClass:function(){d.isPhone||(this._swipeBehavior===q.SwipeBehavior.select&&this._selectionMode!==q.SelectionMode.none||this._draggable?n.addClass(this._element,r._swipeableClass):n.removeClass(this._element,r._swipeableClass))},_updateDraggableAttribute:function(){this._setSwipeClass(),this._itemBox.setAttribute("draggable",this._draggable)},_verifySelectionAllowed:function(){if(this._selectionMode===q.SelectionMode.none||this._tapBehavior!==q.TapBehavior.toggleSelect&&this._swipeBehavior!==q.SwipeBehavior.select)return{canSelect:!1,canTapSelect:!1};var a=this._selection.fireSelectionChanging();return{canSelect:a,canTapSelect:a&&this._tapBehavior===q.TapBehavior.toggleSelect}},_setupInternalTree:function(){var a=b.document.createElement("div");a.className=r._itemClass,this._captureProxy=b.document.createElement("div"),this._itemBox=b.document.createElement("div"),this._itemBox.className=r._itemBoxClass;for(var c=this.element.firstChild;c;){var d=c.nextSibling;a.appendChild(c),c=d}this.element.appendChild(this._itemBox),this._itemBox.appendChild(a),this.element.appendChild(this._captureProxy)},_fireInvokeEvent:function(){if(this.tapBehavior!==q.TapBehavior.none){var a=b.document.createEvent("CustomEvent");a.initCustomEvent(u.invoked,!0,!1,{}),this.element.dispatchEvent(a)}},_setAriaRole:function(){if(!this.element.getAttribute("role")||this._usingDefaultItemRole){this._usingDefaultItemRole=!0;var a;a=this.tapBehavior===q.TapBehavior.none&&this.selectionDisabled?"listitem":"option",n._setAttribute(this.element,"role",a)}},_writeProfilerMark:function(a){var b="WinJS.UI.ItemContainer:"+this._id+":"+a;i(b),g.log&&g.log(b,null,"itemcontainerprofiler")}},{_ClassName:{itemContainer:"win-itemcontainer",vertical:"win-vertical",horizontal:"win-horizontal"}});return c.Class.mix(h,l.DOMEventMixin),h}),_SingleItemSelectionManager:c.Namespace._lazy(function(){return c.Class.define(function(a,b){this._selected=!1,this._element=a,this._itemBox=b},{selected:{get:function(){return this._selected},set:function(a){a=!!a,this._selected!==a&&this.fireSelectionChanging()&&(this._selected=a,s._ItemEventsHandler.renderSelection(this._itemBox,this._element,a,!0,this._element),this.fireSelectionChanged())}},count:function(){return this._selected?1:0},getIndices:function(){},getItems:function(){},getRanges:function(){},isEverything:function(){return!1},set:function(){this.selected=!0},clear:function(){this.selected=!1},add:function(){this.selected=!0},remove:function(){this.selected=!1},selectAll:function(){},fireSelectionChanging:function(){var a=b.document.createEvent("CustomEvent");return a.initCustomEvent(u.selectionchanging,!0,!0,{}),this._element.dispatchEvent(a)},fireSelectionChanged:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent(u.selectionchanged,!0,!1,{}),this._element.dispatchEvent(a)},_isIncluded:function(){return this._selected},_getFocused:function(){return{type:q.ObjectType.item,index:r._INVALID_INDEX}}})})})}),d("WinJS/Controls/Repeater",["exports","../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Core/_WriteProfilerMark","../BindingList","../BindingTemplate","../Promise","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{Repeater:c.Namespace._lazy(function(){function a(a){var c=b.document.createElement("div");return c.textContent=JSON.stringify(a),c}var f="itemsloaded",n="itemchanging",o="itemchanged",p="iteminserting",q="iteminserted",r="itemmoving",s="itemmoved",t="itemremoving",u="itemremoved",v="itemsreloading",w="itemsreloaded",x=e._createEventProperty,y={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get asynchronousRender(){return"Top level items must render synchronously"},get repeaterReentrancy(){return"Cannot modify Repeater data until Repeater has commited previous modification."}},z=c.Class.define(function(a,c){if(a&&a.winControl)throw new d("WinJS.UI.Repeater.DuplicateConstruction",y.duplicateConstruction);this._element=a||b.document.createElement("div"),this._id=this._element.id||m._uniqueID(this._element),this._writeProfilerMark("constructor,StartTM"),c=c||{},m.addClass(this._element,"win-repeater win-disposable"),this._render=null,this._modifying=!1,this._disposed=!1,this._element.winControl=this,this._dataListeners={itemchanged:this._dataItemChangedHandler.bind(this),iteminserted:this._dataItemInsertedHandler.bind(this),itemmoved:this._dataItemMovedHandler.bind(this),itemremoved:this._dataItemRemovedHandler.bind(this),reload:this._dataReloadHandler.bind(this)};var e=this._extractInlineTemplate();this._initializing=!0,this.template=c.template||e,this.data=c.data,this._initializing=!1,k._setOptions(this,c,!0),this._repeatedDOM=[],this._renderAllItems(),this.dispatchEvent(f,{}),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},data:{get:function(){return this._data},set:function(a){this._writeProfilerMark("data.set,StartTM"),this._data&&this._removeDataListeners(),this._data=a||new h.List,this._addDataListeners(),this._initializing||(this._reloadRepeater(!0),this.dispatchEvent(f,{})),this._writeProfilerMark("data.set,StopTM")}},template:{get:function(){return this._template},set:function(b){this._writeProfilerMark("template.set,StartTM"),this._template=b||a,this._render=m._syncRenderer(this._template,this.element.tagName),this._initializing||(this._reloadRepeater(!0),this.dispatchEvent(f,{})),this._writeProfilerMark("template.set,StopTM")}},length:{get:function(){return this._repeatedDOM.length}},elementFromIndex:function(a){return this._repeatedDOM[a]},dispose:function(){if(!this._disposed){this._disposed=!0,this._removeDataListeners(),this._data=null,this._template=null;for(var a=0,b=this._repeatedDOM.length;b>a;a++)l._disposeElement(this._repeatedDOM[a])}},onitemsloaded:x(f),onitemchanging:x(n),onitemchanged:x(o),oniteminserting:x(p),oniteminserted:x(q),onitemmoving:x(r),onitemmoved:x(s),onitemremoving:x(t),onitemremoved:x(u),onitemsreloading:x(v),onitemsreloaded:x(w),_extractInlineTemplate:function(){if(this._element.firstElementChild){for(var a=b.document.createElement(this._element.tagName);this._element.firstElementChild;)a.appendChild(this._element.firstElementChild);return new i.Template(a,{extractChild:!0})}},_renderAllItems:function(){for(var a=b.document.createDocumentFragment(),c=0,e=this._data.length;e>c;c++){var f=this._render(this._data.getAt(c));if(!f)throw new d("WinJS.UI.Repeater.AsynchronousRender",y.asynchronousRender);a.appendChild(f),this._repeatedDOM.push(f)}this._element.appendChild(a)},_reloadRepeater:function(a){this._unloadRepeatedDOM(a),this._repeatedDOM=[],this._renderAllItems()},_unloadRepeatedDOM:function(a){for(var b=0,c=this._repeatedDOM.length;c>b;b++){var d=this._repeatedDOM[b];a&&l._disposeElement(d),d.parentElement===this._element&&this._element.removeChild(d)}},_addDataListeners:function(){Object.keys(this._dataListeners).forEach(function(a){this._data.addEventListener(a,this._dataListeners[a],!1)}.bind(this))},_beginModification:function(){if(this._modifying)throw new d("WinJS.UI.Repeater.RepeaterModificationReentrancy",y.repeaterReentrancy);this._modifying=!0},_endModification:function(){this._modifying=!1},_removeDataListeners:function(){Object.keys(this._dataListeners).forEach(function(a){this._data.removeEventListener(a,this._dataListeners[a],!1)}.bind(this))},_dataItemChangedHandler:function(a){this._beginModification();var b,c=this._element,e=a.detail.index,f=this._render(a.detail.newValue);if(!f)throw new d("WinJS.UI.Repeater.AsynchronousRender",y.asynchronousRender);this._repeatedDOM[e]&&(a.detail.oldElement=this._repeatedDOM[e]),a.detail.newElement=f,a.detail.setPromise=function(a){b=a},this._writeProfilerMark(n+",info"),this.dispatchEvent(n,a.detail);var g=null;e<this._repeatedDOM.length?(g=this._repeatedDOM[e],c.replaceChild(f,g),this._repeatedDOM[e]=f):(c.appendChild(f),this._repeatedDOM.push(f)),this._endModification(),this._writeProfilerMark(o+",info"),this.dispatchEvent(o,a.detail),g&&j.as(b).done(function(){l._disposeElement(g)}.bind(this))},_dataItemInsertedHandler:function(a){this._beginModification();var b=a.detail.index,c=this._render(a.detail.value);if(!c)throw new d("WinJS.UI.Repeater.AsynchronousRender",y.asynchronousRender);var e=this._element;if(a.detail.affectedElement=c,this._writeProfilerMark(p+",info"),this.dispatchEvent(p,a.detail),b<this._repeatedDOM.length){var f=this._repeatedDOM[b];e.insertBefore(c,f)}else e.appendChild(c);this._repeatedDOM.splice(b,0,c),this._endModification(),this._writeProfilerMark(q+",info"),this.dispatchEvent(q,a.detail)},_dataItemMovedHandler:function(a){this._beginModification();var b=this._repeatedDOM[a.detail.oldIndex];if(a.detail.affectedElement=b,this._writeProfilerMark(r+",info"),this.dispatchEvent(r,a.detail),this._repeatedDOM.splice(a.detail.oldIndex,1)[0],b.parentNode.removeChild(b),a.detail.newIndex<this._data.length-1){var c=this._repeatedDOM[a.detail.newIndex];this._element.insertBefore(b,c),this._repeatedDOM.splice(a.detail.newIndex,0,b)}else this._repeatedDOM.push(b),this._element.appendChild(b);this._endModification(),this._writeProfilerMark(s+",info"),this.dispatchEvent(s,a.detail)},_dataItemRemovedHandler:function(a){this._beginModification();var b,c=this._repeatedDOM[a.detail.index],d={affectedElement:c,index:a.detail.index,item:a.detail.item};d.setPromise=function(a){b=a},this._writeProfilerMark(t+",info"),this.dispatchEvent(t,d),c.parentNode.removeChild(c),this._repeatedDOM.splice(a.detail.index,1),this._endModification(),this._writeProfilerMark(u+",info"),this.dispatchEvent(u,d),j.as(b).done(function(){l._disposeElement(c)}.bind(this))},_dataReloadHandler:function(){this._beginModification();var a,b=this._repeatedDOM.slice(0),c={affectedElements:b};c.setPromise=function(b){a=b},this._writeProfilerMark(v+",info"),this.dispatchEvent(v,c),this._reloadRepeater(!1);var d=this._repeatedDOM.slice(0);this._endModification(),this._writeProfilerMark(w+",info"),this.dispatchEvent(w,{affectedElements:d}),j.as(a).done(function(){for(var a=0,c=b.length;c>a;a++)l._disposeElement(b[a])}.bind(this))},_writeProfilerMark:function(a){g("WinJS.UI.Repeater:"+this._id+":"+a)}},{isDeclarativeControlContainer:!0});return c.Class.mix(z,k.DOMEventMixin),z})})}),d("WinJS/Controls/DatePicker",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_Select","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j){"use strict";c.Namespace.define("WinJS.UI",{DatePicker:c.Namespace._lazy(function(){function d(a,c,d){var e=b.Windows.Globalization.DateTimeFormatting;a=a?a:d;var f=new e.DateTimeFormatter(a);return c?new e.DateTimeFormatter(a,f.languages,f.geographicRegion,c,f.clock):f}function i(a,b,c){var e=t[a];e||(e=t[a]={});var f=e[b];f||(f=e[b]={});var g=f[c];return g||(g=f[c]={},g.formatter=d(a,b,c),g.years={}),g}function k(a,b,c,d,e,f){var g=i(a,b,c),h=g.years[f.year+"-"+f.era];return h||(h=g.formatter.format(f.getDateTime()),g.years[f.year+"-"+f.era]=h),h}function l(a,b,c,d){var e=i(a,b,c);return e.formatter.format(d.getDateTime())}function m(a,b,c,d){var e=i(a,b,c);return e.formatter.format(d.getDateTime())}function n(a){var c=b.Windows.Globalization,d=new c.Calendar;return a?new c.Calendar(d.languages,a,d.getClock()):d}function o(a,b){var c=0;if(a.era===b.era)c=b.year-a.year;else for(;a.era!==b.era||a.year!==b.year;)c++,a.addYears(1);return c}var p="day",q="{month.full}",r="year.full",s={get ariaLabel(){return f._getWinJSString("ui/datePicker").value},get selectDay(){return f._getWinJSString("ui/selectDay").value},get selectMonth(){return f._getWinJSString("ui/selectMonth").value},get selectYear(){return f._getWinJSString("ui/selectYear").value}},t={},u=c.Class.define(function(b,c){this._currentDate=new Date,this._minYear=this._currentDate.getFullYear()-100,this._maxYear=this._currentDate.getFullYear()+100,this._datePatterns={date:null,month:null,year:null},b=b||a.document.createElement("div"),h.addClass(b,"win-disposable"),b.winControl=this;
  var d=b.getAttribute("aria-label");d||b.setAttribute("aria-label",s.ariaLabel),this._init(b),g.setOptions(this,c)},{_information:null,_currentDate:null,_calendar:null,_disabled:!1,_dateElement:null,_dateControl:null,_monthElement:null,_monthControl:null,_minYear:null,_maxYear:null,_yearElement:null,_yearControl:null,_datePatterns:{date:null,month:null,year:null},_addAccessibilityAttributes:function(){this._domElement.setAttribute("role","group"),this._dateElement.setAttribute("aria-label",s.selectDay),this._monthElement.setAttribute("aria-label",s.selectMonth),this._yearElement.setAttribute("aria-label",s.selectYear)},_addControlsInOrder:function(){var a=this._domElement,b=this,c=0;b._information.order.forEach(function(d){switch(d){case"month":a.appendChild(b._monthElement),h.addClass(b._monthElement,"win-order"+c++);break;case"date":a.appendChild(b._dateElement),h.addClass(b._dateElement,"win-order"+c++);break;case"year":a.appendChild(b._yearElement),h.addClass(b._yearElement,"win-order"+c++)}})},_createControlElements:function(){this._monthElement=a.document.createElement("select"),this._monthElement.className="win-datepicker-month",this._dateElement=a.document.createElement("select"),this._dateElement.className="win-datepicker-date",this._yearElement=a.document.createElement("select"),this._yearElement.className="win-datepicker-year"},_createControls:function(){var a=this._information,b=a.getIndex(this.current);a.forceLanguage&&(this._domElement.setAttribute("lang",a.forceLanguage),this._domElement.setAttribute("dir",a.isRTL?"rtl":"ltr")),this._yearControl=new j._Select(this._yearElement,{dataSource:this._information.years,disabled:this.disabled,index:b.year}),this._monthControl=new j._Select(this._monthElement,{dataSource:this._information.months(b.year),disabled:this.disabled,index:b.month}),this._dateControl=new j._Select(this._dateElement,{dataSource:this._information.dates(b.year,b.month),disabled:this.disabled,index:b.date}),this._wireupEvents()},dispose:function(){},calendar:{get:function(){return this._calendar},set:function(a){this._calendar=a,this._setElement(this._domElement)}},current:{get:function(){var a=this._currentDate,b=a.getFullYear();return new Date(Math.max(Math.min(this.maxYear,b),this.minYear),a.getMonth(),a.getDate(),12,0,0,0)},set:function(a){var b;"string"==typeof a?(b=new Date(Date.parse(a)),b.setHours(12,0,0,0)):b=a;var c=this._currentDate;c!==b&&(this._currentDate=b,this._updateDisplay())}},disabled:{get:function(){return this._disabled},set:function(a){this._disabled!==a&&(this._disabled=a,this._yearControl&&(this._monthControl.setDisabled(a),this._dateControl.setDisabled(a),this._yearControl.setDisabled(a)))}},datePattern:{get:function(){return this._datePatterns.date},set:function(a){this._datePatterns.date!==a&&(this._datePatterns.date=a,this._init())}},element:{get:function(){return this._domElement}},_setElement:function(a){this._domElement=this._domElement||a,this._domElement&&(h.empty(this._domElement),h.addClass(this._domElement,"win-datepicker"),this._updateInformation(),this._createControlElements(),this._addControlsInOrder(),this._createControls(),this._addAccessibilityAttributes())},minYear:{get:function(){return this._information.getDate({year:0,month:0,date:0}).getFullYear()},set:function(a){this._minYear!==a&&(this._minYear=a,a>this._maxYear&&(this._maxYear=a),this._updateInformation(),this._yearControl&&(this._yearControl.dataSource=this._information.years),this._updateDisplay())}},maxYear:{get:function(){var a={year:this._information.years.getLength()-1};return a.month=this._information.months(a.year).getLength()-1,a.date=this._information.dates(a.year,a.month).getLength()-1,this._information.getDate(a).getFullYear()},set:function(a){this._maxYear!==a&&(this._maxYear=a,a<this._minYear&&(this._minYear=a),this._updateInformation(),this._yearControl&&(this._yearControl.dataSource=this._information.years),this._updateDisplay())}},monthPattern:{get:function(){return this._datePatterns.month},set:function(a){this._datePatterns.month!==a&&(this._datePatterns.month=a,this._init())}},_updateInformation:function(){var a=new Date(this._minYear,0,1,12,0,0),b=new Date(this._maxYear,11,31,12,0,0);a.setFullYear(this._minYear),b.setFullYear(this._maxYear),this._information=u.getInformation(a,b,this._calendar,this._datePatterns)},_init:function(a){this._setElement(a)},_updateDisplay:function(){if(this._domElement&&this._yearControl){var a=this._information.getIndex(this.current);this._yearControl.index=a.year,this._monthControl.dataSource=this._information.months(a.year),this._monthControl.index=a.month,this._dateControl.dataSource=this._information.dates(a.year,a.month),this._dateControl.index=a.date}},_wireupEvents:function(){function a(){b._currentDate=b._information.getDate({year:b._yearControl.index,month:b._monthControl.index,date:b._dateControl.index},b._currentDate);var a=b._information.getIndex(b._currentDate);b._monthControl.dataSource=b._information.months(a.year),b._monthControl.index=a.month,b._dateControl.dataSource=b._information.dates(a.year,a.month),b._dateControl.index=a.date}var b=this;this._dateElement.addEventListener("change",a,!1),this._monthElement.addEventListener("change",a,!1),this._yearElement.addEventListener("change",a,!1)},yearPattern:{get:function(){return this._datePatterns.year},set:function(a){this._datePatterns.year!==a&&(this._datePatterns.year=a,this._init())}}},{_getInformationWinRT:function(a,b,c,d){function e(a){return new Date(Math.min(new Date(Math.max(j,a)),s))}d=d||{date:p,month:q,year:r};var f=n(c),g=n(c),h=n(c);f.setToMin();var j=f.getDateTime();f.setToMax();var s=f.getDateTime();f.hour=12,a=e(a),b=e(b),f.setDateTime(b);var t={year:f.year,era:f.era};f.setDateTime(a);var u=0;u=o(f,t)+1;var v=i("day month.full year",c).formatter,w=v.patterns[0],x=8207===w.charCodeAt(0),y=["date","month","year"],z={month:w.indexOf("{month"),date:w.indexOf("{day"),year:w.indexOf("{year")};y.sort(function(a,b){return z[a]<z[b]?-1:z[a]>z[b]?1:0});var A=function(){return{getLength:function(){return u},getValue:function(b){return f.setDateTime(a),f.addYears(b),k(d.year,c,r,d,y,f)}}}(),B=function(b){return g.setDateTime(a),g.addYears(b),{getLength:function(){return g.numberOfMonthsInThisYear},getValue:function(a){return g.month=g.firstMonthInThisYear,g.addMonths(a),l(d.month,c,q,g)}}},C=function(b,e){return h.setDateTime(a),h.addYears(b),h.month=h.firstMonthInThisYear,h.addMonths(e),h.day=h.firstDayInThisMonth,{getLength:function(){return h.numberOfDaysInThisMonth},getValue:function(a){return h.day=h.firstDayInThisMonth,h.addDays(a),m(d.date,c,p,h)}}};return{isRTL:x,forceLanguage:v.resolvedLanguage,order:y,getDate:function(b,c){var d;c&&(f.setDateTime(c),d={year:f.year,month:f.month,day:f.day});var e=f;e.setDateTime(a),e.addYears(b.year);var g;e.firstMonthInThisYear>e.lastMonthInThisYear?(g=b.month+e.firstMonthInThisYear>e.numberOfMonthsInThisYear?b.month+e.firstMonthInThisYear-e.numberOfMonthsInThisYear:b.month+e.firstMonthInThisYear,d&&d.year!==e.year&&(g=Math.max(Math.min(d.month,e.numberOfMonthsInThisYear),1))):g=d&&d.year!==e.year?Math.max(Math.min(d.month,e.firstMonthInThisYear+e.numberOfMonthsInThisYear-1),e.firstMonthInThisYear):Math.max(Math.min(b.month+e.firstMonthInThisYear,e.firstMonthInThisYear+e.numberOfMonthsInThisYear-1),e.firstMonthInThisYear),e.month=g;var h=Math.max(Math.min(b.date+e.firstDayInThisMonth,e.firstDayInThisMonth+e.numberOfDaysInThisMonth-1),e.firstDayInThisMonth);return!d||d.year===e.year&&d.month===e.month||(h=Math.max(Math.min(d.day,e.firstDayInThisMonth+e.numberOfDaysInThisMonth-1),e.firstDayInThisMonth)),e.day=e.firstDayInThisMonth,e.addDays(h-e.firstDayInThisMonth),e.getDateTime()},getIndex:function(b){var c=e(b);f.setDateTime(c);var d={year:f.year,era:f.era},g=0;f.setDateTime(a),f.month=1,g=o(f,d),f.setDateTime(c);var h=f.month-f.firstMonthInThisYear;0>h&&(h=f.month-f.firstMonthInThisYear+f.numberOfMonthsInThisYear);var i=f.day-f.firstDayInThisMonth,j={year:g,month:h,date:i};return j},years:A,months:B,dates:C}},_getInformationJS:function(a,b){var c=a.getFullYear(),d=b.getFullYear(),e={getLength:function(){return Math.max(0,d-c+1)},getValue:function(a){return c+a}},f=["January","February","March","April","May","June","July","August","September","October","November","December"],g=function(){return{getLength:function(){return f.length},getValue:function(a){return f[a]},getMonthNumber:function(a){return Math.min(a,f.length-1)}}},h=function(a,b){var c=new Date,d=e.getValue(a),f=b+1;c.setFullYear(d,f,0);var g=c.getDate();return{getLength:function(){return g},getValue:function(a){return""+(a+1)},getDateNumber:function(a){return Math.min(a+1,g)}}};return{order:["month","date","year"],getDate:function(a){return new Date(e.getValue(a.year),g(a.year).getMonthNumber(a.month),h(a.year,a.month).getDateNumber(a.date),12,0)},getIndex:function(a){var b=0,d=a.getFullYear();b=c>d?0:d>this.maxYear?e.getLength()-1:a.getFullYear()-c;var f=Math.min(a.getMonth(),g(b).getLength()),i=Math.min(a.getDate()-1,h(b,f).getLength());return{year:b,month:f,date:i}},years:e,months:g,dates:h}}});return u.getInformation=b.Windows.Globalization.Calendar&&b.Windows.Globalization.DateTimeFormatting?u._getInformationWinRT:u._getInformationJS,c.Class.mix(u,e.createEventProperties("change")),c.Class.mix(u,g.DOMEventMixin),u})})}),d("WinJS/Controls/TimePicker",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_Select","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j){"use strict";c.Namespace.define("WinJS.UI",{TimePicker:c.Namespace._lazy(function(){var d="{minute.integer(2)}",i="{hour.integer(1)}",k="{period.abbreviated(2)}",l={get ariaLabel(){return f._getWinJSString("ui/timePicker").value},get selectHour(){return f._getWinJSString("ui/selectHour").value},get selectMinute(){return f._getWinJSString("ui/selectMinute").value},get selectAMPM(){return f._getWinJSString("ui/selectAMPM").value}},m=function(a,b){return a.getHours()===b.getHours()&&a.getMinutes()===b.getMinutes()},n=c.Class.define(function(b,c){this._currentTime=n._sentinelDate(),b=b||a.document.createElement("div"),h.addClass(b,"win-disposable"),b.winControl=this;var d=b.getAttribute("aria-label");d||b.setAttribute("aria-label",l.ariaLabel),this._timePatterns={minute:null,hour:null,period:null},this._init(b),g.setOptions(this,c)},{_currentTime:null,_clock:null,_disabled:!1,_hourElement:null,_hourControl:null,_minuteElement:null,_minuteControl:null,_ampmElement:null,_ampmControl:null,_minuteIncrement:1,_timePatterns:{minute:null,hour:null,period:null},_information:null,_addAccessibilityAttributes:function(){this._domElement.setAttribute("role","group"),this._hourElement.setAttribute("aria-label",l.selectHour),this._minuteElement.setAttribute("aria-label",l.selectMinute),this._ampmElement&&this._ampmElement.setAttribute("aria-label",l.selectAMPM)},_addControlsInOrder:function(a){var b=this;a.order.forEach(function(a,c){switch(a){case"hour":b._domElement.appendChild(b._hourElement),h.addClass(b._hourElement,"win-order"+c);break;case"minute":b._domElement.appendChild(b._minuteElement),h.addClass(b._minuteElement,"win-order"+c);break;case"period":b._ampmElement&&(b._domElement.appendChild(b._ampmElement),h.addClass(b._ampmElement,"win-order"+c))}})},dispose:function(){},clock:{get:function(){return this._clock},set:function(a){this._clock!==a&&(this._clock=a,this._init())}},current:{get:function(){var a=this._currentTime;if(a){var b=n._sentinelDate();return b.setHours(a.getHours()),b.setMinutes(this._getMinutesIndex(a)*this.minuteIncrement),b.setSeconds(0),b.setMilliseconds(0),b}return a},set:function(a){var b;"string"==typeof a?(b=n._sentinelDate(),b.setTime(Date.parse(b.toDateString()+" "+a))):(b=n._sentinelDate(),b.setHours(a.getHours()),b.setMinutes(a.getMinutes()));var c=this._currentTime;m(c,b)||(this._currentTime=b,this._updateDisplay())}},disabled:{get:function(){return this._disabled},set:function(a){this._disabled!==a&&(this._disabled=a,this._hourControl&&(this._hourControl.setDisabled(a),this._minuteControl.setDisabled(a)),this._ampmControl&&this._ampmControl.setDisabled(a))}},element:{get:function(){return this._domElement}},_init:function(a){this._setElement(a),this._updateDisplay()},hourPattern:{get:function(){return this._timePatterns.hour.pattern},set:function(a){this._timePatterns.hour!==a&&(this._timePatterns.hour=a,this._init())}},_getHoursAmpm:function(a){var b=a.getHours();return this._ampmElement?0===b?{hours:12,ampm:0}:12>b?{hours:b,ampm:0}:{hours:b-12,ampm:1}:{hours:b}},_getHoursIndex:function(a){return this._ampmElement&&12===a?0:a},_getMinutesIndex:function(a){return parseInt(a.getMinutes()/this.minuteIncrement)},minuteIncrement:{get:function(){return Math.max(1,Math.abs(0|this._minuteIncrement)%60)},set:function(a){this._minuteIncrement!==a&&(this._minuteIncrement=a,this._init())}},minutePattern:{get:function(){return this._timePatterns.minute.pattern},set:function(a){this._timePatterns.minute!==a&&(this._timePatterns.minute=a,this._init())}},periodPattern:{get:function(){return this._timePatterns.period.pattern},set:function(a){this._timePatterns.period!==a&&(this._timePatterns.period=a,this._init())}},_setElement:function(b){if(this._domElement=this._domElement||b,this._domElement){var c=n.getInformation(this.clock,this.minuteIncrement,this._timePatterns);this._information=c,c.forceLanguage&&(this._domElement.setAttribute("lang",c.forceLanguage),this._domElement.setAttribute("dir",c.isRTL?"rtl":"ltr")),h.empty(this._domElement),h.addClass(this._domElement,"win-timepicker"),this._hourElement=a.document.createElement("select"),h.addClass(this._hourElement,"win-timepicker-hour"),this._minuteElement=a.document.createElement("select"),h.addClass(this._minuteElement,"win-timepicker-minute"),this._ampmElement=null,"12HourClock"===c.clock&&(this._ampmElement=a.document.createElement("select"),h.addClass(this._ampmElement,"win-timepicker-period")),this._addControlsInOrder(c);var d=this._getHoursAmpm(this.current);this._hourControl=new j._Select(this._hourElement,{dataSource:this._getInfoHours(),disabled:this.disabled,index:this._getHoursIndex(d.hours)}),this._minuteControl=new j._Select(this._minuteElement,{dataSource:c.minutes,disabled:this.disabled,index:this._getMinutesIndex(this.current)}),this._ampmControl=null,this._ampmElement&&(this._ampmControl=new j._Select(this._ampmElement,{dataSource:c.periods,disabled:this.disabled,index:d.ampm})),this._wireupEvents(),this._updateValues(),this._addAccessibilityAttributes()}},_getInfoHours:function(){return this._information.hours},_updateLayout:function(){this._domElement&&this._updateValues()},_updateValues:function(){if(this._hourControl){var a=this._getHoursAmpm(this.current);this._ampmControl&&(this._ampmControl.index=a.ampm),this._hourControl.index=this._getHoursIndex(a.hours),this._minuteControl.index=this._getMinutesIndex(this.current)}},_updateDisplay:function(){var a=this._getHoursAmpm(this.current);this._ampmControl&&(this._ampmControl.index=a.ampm),this._hourControl&&(this._hourControl.index=this._getHoursIndex(a.hours),this._minuteControl.index=this._getMinutesIndex(this.current))},_wireupEvents:function(){var a=this,b=function(){var b=a._hourControl.index;return a._ampmElement&&1===a._ampmControl.index&&12!==b&&(b+=12),b},c=function(){var c=b();a._currentTime.setHours(c),a._currentTime.setMinutes(a._minuteControl.index*a.minuteIncrement)};this._hourElement.addEventListener("change",c,!1),this._minuteElement.addEventListener("change",c,!1),this._ampmElement&&this._ampmElement.addEventListener("change",c,!1)}},{_sentinelDate:function(){var a=new Date;return new Date(2011,6,15,a.getHours(),a.getMinutes())},_getInformationWinRT:function(a,c,e){var f=function(c,d){var e=b.Windows.Globalization.DateTimeFormatting;c=c?c:d;var f=new e.DateTimeFormatter(c);return a&&(f=e.DateTimeFormatter(c,f.languages,f.geographicRegion,f.calendar,a)),f},g=b.Windows.Globalization,h=new g.Calendar;a&&(h=new g.Calendar(h.languages,h.getCalendarSystem(),a)),h.setDateTime(n._sentinelDate());var j=h.getClock(),l=24;l=h.numberOfHoursInThisPeriod;var m=function(){var a=f(e.period,k);return{getLength:function(){return 2},getValue:function(b){var c=n._sentinelDate();if(0===b){c.setHours(1);var d=a.format(c);return d}if(1===b){c.setHours(13);var e=a.format(c);return e}return null}}}(),o=function(){var a=f(e.minute,d),b=n._sentinelDate();return{getLength:function(){return 60/c},getValue:function(d){var e=d*c;return b.setMinutes(e),a.format(b)}}}(),p=function(){var a=f(e.hour,i),b=n._sentinelDate();return{getLength:function(){return l},getValue:function(c){return b.setHours(c),a.format(b)}}}(),q=f("hour minute"),r=q.patterns[0],s=["hour","minute"],t={period:r.indexOf("{period"),hour:r.indexOf("{hour"),minute:r.indexOf("{minute")};t.period>-1&&s.push("period");var u=b.Windows.Globalization.DateTimeFormatting.DateTimeFormatter,v=new u("month.full",b.Windows.Globalization.ApplicationLanguages.languages,"ZZ","GregorianCalendar","24HourClock"),w=v.patterns[0],x=8207===w.charCodeAt(0);if(x){var y=t.hour;t.hour=t.minute,t.minute=y}return s.sort(function(a,b){return t[a]<t[b]?-1:t[a]>t[b]?1:0}),{minutes:o,hours:p,clock:j,periods:m,order:s,forceLanguage:q.resolvedLanguage,isRTL:x}},_getInformationJS:function(a,b){var c=[12,1,2,3,4,5,6,7,8,9,10,11],d={};d.getLength=function(){return 60/b},d.getValue=function(a){var c=a*b;return 10>c?"0"+c.toString():c.toString()};var e=["hour","minute","period"];return"24HourClock"===a&&(c=["00","01","02","03","04","05","06","07","08","09",10,11,12,13,14,15,16,17,18,19,20,21,22,23],e=["hour","minute"]),{minutes:d,hours:c,clock:a||"12HourClock",periods:["AM","PM"],order:e}}});return n.getInformation=b.Windows.Globalization.DateTimeFormatting&&b.Windows.Globalization.Calendar&&b.Windows.Globalization.ApplicationLanguages?n._getInformationWinRT:n._getInformationJS,c.Class.mix(n,e.createEventProperties("change")),c.Class.mix(n,g.DOMEventMixin),n})})}),d("WinJS/Controls/BackButton",["../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Resources","../Navigation","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g){"use strict";var h=g.Key,i="win-navigation-backbutton",j="win-back",k=3,l=function(){function b(){a.addEventListener("keyup",d,!1),g._addEventListener(a,"pointerup",f,!1)}function c(){a.removeEventListener("keyup",d,!1),g._removeEventListener(a,"pointerup",f,!1)}function d(a){(a.keyCode===h.leftArrow&&a.altKey&&!a.shiftKey&&!a.ctrlKey||a.keyCode===h.browserBack)&&e.back()}function f(a){a.button===k&&e.back()}var i=0;return{addRef:function(){0===i&&b(),i++},release:function(){i>0&&(i--,0===i&&c())},getCount:function(){return i}}}();b.Namespace.define("WinJS.UI",{BackButton:b.Namespace._lazy(function(){var h={get ariaLabel(){return d._getWinJSString("ui/backbuttonarialabel").value},get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get badButtonElement(){return"Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"}},k=b.Class.define(function(b,d){if(b&&b.winControl)throw new c("WinJS.UI.BackButton.DuplicateConstruction",h.duplicateConstruction);this._element=b||a.document.createElement("button"),d=d||{},this._initializeButton(),this._disposed=!1,this._element.winControl=this,f.setOptions(this,d),this._buttonClickHandler=this._handleBackButtonClick.bind(this),this._element.addEventListener("click",this._buttonClickHandler,!1),this._navigatedHandler=this._handleNavigatedEvent.bind(this),e.addEventListener("navigated",this._navigatedHandler,!1),l.addRef()},{element:{get:function(){return this._element}},dispose:function(){this._disposed||(this._disposed=!0,e.removeEventListener("navigated",this._navigatedHandler,!1),l.release())},refresh:function(){this._element.disabled=e.canGoBack?!1:!0},_initializeButton:function(){if("BUTTON"!==this._element.tagName)throw new c("WinJS.UI.BackButton.BadButtonElement",h.badButtonElement);g.addClass(this._element,i),g.addClass(this._element,"win-disposable"),this._element.innerHTML='<span class="'+j+'"></span>',this.refresh(),this._element.setAttribute("aria-label",h.ariaLabel),this._element.setAttribute("title",h.ariaLabel),this._element.setAttribute("type","button")},_handleNavigatedEvent:function(){this.refresh()},_handleBackButtonClick:function(){e.back()}});return k._getReferenceCount=function(){return l.getCount()},b.Class.mix(k,f.DOMEventMixin),k})})}),d("WinJS/Controls/Tooltip",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Animations","../Animations/_TransitionAnimation","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{Tooltip:d.Namespace._lazy(function(){function a(a,b){return"pointerdown"===a?b===G:a in H}function l(a,b){return"pointerdown"===a?b!==G:a in J}var m=0,n=k.Key,o="top",p=h._animationTimeAdjustment(400),q=h._animationTimeAdjustment(1200),r=h._animationTimeAdjustment(400),s=h._animationTimeAdjustment(5e3),t=h._animationTimeAdjustment(0),u=h._animationTimeAdjustment(600),v=h._animationTimeAdjustment(400),w=h._animationTimeAdjustment(600),x=h._animationTimeAdjustment(200),y=h._animationTimeAdjustment(3e5),z=12,A=20,B=45,C=20,D=12,E=1,F=k._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",G=k._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",H={keyup:"",pointerover:"",pointerdown:""},I={pointermove:""},J={pointerdown:"",keydown:"",focusout:"",pointerout:"",pointercancel:"",pointerup:""},K={pointerover:"",pointerout:""},L="win-tooltip",M="win-tooltip-phantom",N=r,O=2*N,P=2.5*N,Q=s,R=!1,S=!1,T=f._createEventProperty;return d.Class.define(function(a,d){a=a||b.document.createElement("div");var e=k.data(a).tooltip;if(e)return e;if(!S&&c.Windows.UI.ViewManagement.UISettings){var f=new c.Windows.UI.ViewManagement.UISettings;N=h._animationTimeAdjustment(f.mouseHoverTime),O=2*N,P=2.5*N,Q=h._animationTimeAdjustment(1e3*f.messageDuration);var g=f.handPreference;R=g===c.Windows.UI.ViewManagement.HandPreference.leftHanded}S=!0,this._disposed=!1,this._placement=o,this._infotip=!1,this._innerHTML=null,this._contentElement=null,this._extraClass=null,this._lastContentType="html",this._anchorElement=a,this._domElement=null,this._phantomDiv=null,this._triggerByOpen=!1,this._eventListenerRemoveStack=[],this._lastKeyOrBlurEvent=null,this._currentKeyOrBlurEvent=null,a.winControl=this,k.addClass(a,"win-disposable"),a.title&&(this._innerHTML=this._anchorElement.title,this._anchorElement.removeAttribute("title")),i.setOptions(this,d),this._events(),k.data(a).tooltip=this},{innerHTML:{get:function(){return this._innerHTML},set:function(a){if(this._innerHTML=a,this._domElement){if(!this._innerHTML||""===this._innerHTML)return void this._onDismiss();this._domElement.innerHTML=a,this._position()}this._lastContentType="html"}},element:{get:function(){return this._anchorElement}},contentElement:{get:function(){return this._contentElement},set:function(a){if(this._contentElement=a,this._domElement){if(!this._contentElement)return void this._onDismiss();this._domElement.innerHTML="",this._domElement.appendChild(this._contentElement),this._position()}this._lastContentType="element"}},placement:{get:function(){return this._placement},set:function(a){"top"!==a&&"bottom"!==a&&"left"!==a&&"right"!==a&&(a=o),this._placement=a,this._domElement&&this._position()}},infotip:{get:function(){return this._infotip},set:function(a){this._infotip=!!a}},extraClass:{get:function(){return this._extraClass},set:function(a){this._extraClass=a}},onbeforeopen:T("beforeopen"),onopened:T("opened"),onbeforeclose:T("beforeclose"),onclosed:T("closed"),dispose:function(){if(!this._disposed){this._disposed=!0,j.disposeSubTree(this.element);for(var a=0,b=this._eventListenerRemoveStack.length;b>a;a++)this._eventListenerRemoveStack[a]();this._onDismiss();var c=k.data(this._anchorElement);c&&delete c.tooltip}},addEventListener:function(a,b,c){if(this._anchorElement){this._anchorElement.addEventListener(a,b,c);var d=this;this._eventListenerRemoveStack.push(function(){d._anchorElement.removeEventListener(a,b,c)})}},removeEventListener:function(a,b,c){this._anchorElement&&this._anchorElement.removeEventListener(a,b,c)},open:function(a){switch(this._triggerByOpen=!0,"touch"!==a&&"mouseover"!==a&&"mousedown"!==a&&"keyboard"!==a&&(a="default"),a){case"touch":this._onInvoke("touch","never");break;case"mouseover":this._onInvoke("mouse","auto");break;case"keyboard":this._onInvoke("keyboard","auto");break;case"mousedown":case"default":this._onInvoke("nodelay","never")}},close:function(){this._onDismiss()},_cleanUpDOM:function(){this._domElement&&(j.disposeSubTree(this._domElement),b.document.body.removeChild(this._domElement),this._domElement=null,b.document.body.removeChild(this._phantomDiv),this._phantomDiv=null)},_createTooltipDOM:function(){this._cleanUpDOM(),this._domElement=b.document.createElement("div");var a=k._uniqueID(this._domElement);this._domElement.setAttribute("id",a);var c=b.document.defaultView.getComputedStyle(this._anchorElement,null),d=this._domElement.style;d.direction=c.direction,d.writingMode=c["writing-mode"],this._domElement.setAttribute("tabindex",-1),this._domElement.setAttribute("role","tooltip"),this._anchorElement.setAttribute("aria-describedby",a),"element"===this._lastContentType?this._domElement.appendChild(this._contentElement):this._domElement.innerHTML=this._innerHTML,b.document.body.appendChild(this._domElement),k.addClass(this._domElement,L),this._extraClass&&k.addClass(this._domElement,this._extraClass),this._phantomDiv=b.document.createElement("div"),this._phantomDiv.setAttribute("tabindex",-1),b.document.body.appendChild(this._phantomDiv),k.addClass(this._phantomDiv,M);var e=b.document.defaultView.getComputedStyle(this._domElement,null).zIndex+1;this._phantomDiv.style.zIndex=e},_raiseEvent:function(a,c){if(this._anchorElement){var d=b.document.createEvent("CustomEvent");d.initCustomEvent(a,!1,!1,c),this._anchorElement.dispatchEvent(d)}},_captureLastKeyBlurOrPointerOverEvent:function(a){switch(this._lastKeyOrBlurEvent=this._currentKeyOrBlurEvent,a.type){case"keyup":this._currentKeyOrBlurEvent=a.keyCode===n.shift?null:"keyboard";break;case"focusout":this._currentKeyOrBlurEvent=null}},_registerEventToListener:function(a,b){var c=this,d=function(a){c._captureLastKeyBlurOrPointerOverEvent(a),c._handleEvent(a)};k._addEventListener(a,b,d,!1),this._eventListenerRemoveStack.push(function(){k._removeEventListener(a,b,d,!1)})},_events:function(){for(var a in H)this._registerEventToListener(this._anchorElement,a);for(var a in I)this._registerEventToListener(this._anchorElement,a);for(a in J)this._registerEventToListener(this._anchorElement,a);this._registerEventToListener(this._anchorElement,"contextmenu"),this._registerEventToListener(this._anchorElement,"MSHoldVisual")},_handleEvent:function(b){var c=b._normalizedType||b.type;if(!this._triggerByOpen){if(c in K&&k.eventWithinElement(this._anchorElement,b))return;if(a(c,b.pointerType))if(b.pointerType===G)this._isShown||(this._showTrigger="touch"),this._onInvoke("touch","never",b);else{if(this._skipMouseOver&&b.pointerType===F&&"pointerover"===c)return void(this._skipMouseOver=!1);var d="key"===c.substring(0,3)?"keyboard":"mouse";this._isShown||(this._showTrigger=d),this._onInvoke(d,"auto",b)}else if(c in I)this._contactPoint={x:b.clientX,y:b.clientY};else if(l(c,b.pointerType)){var f;if(b.pointerType===G){if("pointerup"===c){this._skipMouseOver=!0;var g=this;e._yieldForEvents(function(){g._skipMouseOver=!1})}f="touch"}else f="key"===c.substring(0,3)?"keyboard":"mouse";if("focusout"!==c&&f!==this._showTrigger)return;this._onDismiss()}else("contextmenu"===c||"MSHoldVisual"===c)&&b.preventDefault()}},_onShowAnimationEnd:function(){if(!this._shouldDismiss&&!this._disposed&&(this._raiseEvent("opened"),this._domElement&&"never"!==this._hideDelay)){var a=this,b=this._infotip?Math.min(3*Q,y):Q;this._hideDelayTimer=this._setTimeout(function(){a._onDismiss()},b)}},_onHideAnimationEnd:function(){b.document.body.removeEventListener("DOMNodeRemoved",this._removeTooltip,!1),this._cleanUpDOM(),this._anchorElement&&this._anchorElement.removeAttribute("aria-describedby"),m=(new Date).getTime(),this._triggerByOpen=!1,this._disposed||this._raiseEvent("closed")},_decideOnDelay:function(a){var b;if(this._useAnimation=!0,"nodelay"===a)b=0,this._useAnimation=!1;else{var c=(new Date).getTime();x>=c-m?(b="touch"===a?this._infotip?v:t:this._infotip?w:u,this._useAnimation=!1):b="touch"===a?this._infotip?q:p:this._infotip?P:O}return b},_getAnchorPositionFromElementWindowCoord:function(){var a=this._anchorElement.getBoundingClientRect();return{x:a.left,y:a.top,width:a.width,height:a.height}},_getAnchorPositionFromPointerWindowCoord:function(a){return{x:a.x,y:a.y,width:1,height:1}},_canPositionOnSide:function(a,b,c,d){var e=0,f=0;switch(a){case"top":e=d.width+this._offset,f=c.y;break;case"bottom":e=d.width+this._offset,f=b.height-c.y-c.height;break;case"left":e=c.x,f=d.height+this._offset;break;case"right":e=b.width-c.x-c.width,f=d.height+this._offset}return e>=d.width+this._offset&&f>=d.height+this._offset},_positionOnSide:function(a,b,c,d){var e=0,f=0;switch(a){case"top":case"bottom":e=c.x+c.width/2-d.width/2,e=Math.min(Math.max(e,0),b.width-d.width-E),f="top"===a?c.y-d.height-this._offset:c.y+c.height+this._offset;break;case"left":case"right":f=c.y+c.height/2-d.height/2,f=Math.min(Math.max(f,0),b.height-d.height-E),e="left"===a?c.x-d.width-this._offset:c.x+c.width+this._offset}this._domElement.style.left=e+"px",this._domElement.style.top=f+"px",this._phantomDiv.style.left=e+"px",this._phantomDiv.style.top=f+"px",this._phantomDiv.style.width=d.width+"px",this._phantomDiv.style.height=d.height+"px"},_position:function(a){var c={width:0,height:0},d={x:0,y:0,width:0,height:0},e={width:0,height:0};c.width=b.document.documentElement.clientWidth,c.height=b.document.documentElement.clientHeight,"tb-rl"===b.document.defaultView.getComputedStyle(b.document.body,null)["writing-mode"]&&(c.width=b.document.documentElement.clientHeight,c.height=b.document.documentElement.clientWidth),d=!this._contactPoint||"touch"!==a&&"mouse"!==a?this._getAnchorPositionFromElementWindowCoord():this._getAnchorPositionFromPointerWindowCoord(this._contactPoint),e.width=this._domElement.offsetWidth,e.height=this._domElement.offsetHeight;var f={top:["top","bottom","left","right"],bottom:["bottom","top","left","right"],left:["left","right","top","bottom"],right:["right","left","top","bottom"]};R&&(f.top[2]="right",f.top[3]="left",f.bottom[2]="right",f.bottom[3]="left");for(var g=f[this._placement],h=g.length,i=0;h>i;i++)if(i===h-1||this._canPositionOnSide(g[i],c,d,e)){this._positionOnSide(g[i],c,d,e);break}return g[i]},_showTooltip:function(a){if(!this._shouldDismiss&&(this._isShown=!0,this._raiseEvent("beforeopen"),b.document.body.contains(this._anchorElement)&&!this._shouldDismiss)){if("element"===this._lastContentType){if(!this._contentElement)return void(this._isShown=!1)}else if(!this._innerHTML||""===this._innerHTML)return void(this._isShown=!1);var c=this;this._removeTooltip=function(a){for(var d=c._anchorElement;d;){if(a.target===d){b.document.body.removeEventListener("DOMNodeRemoved",c._removeTooltip,!1),c._cleanUpDOM();break}d=d.parentNode}},b.document.body.addEventListener("DOMNodeRemoved",this._removeTooltip,!1),this._createTooltipDOM(),this._position(a),this._useAnimation?g.fadeIn(this._domElement).then(this._onShowAnimationEnd.bind(this)):this._onShowAnimationEnd()
  }},_onInvoke:function(a,b,c){if(this._shouldDismiss=!1,!this._isShown&&(!c||"keyup"!==c.type||"keyboard"!==this._lastKeyOrBlurEvent&&(this._lastKeyOrBlurEvent||c.keyCode===n.tab))){this._hideDelay=b,this._contactPoint=null,c?(this._contactPoint={x:c.clientX,y:c.clientY},this._offset="touch"===a?B:"keyboard"===a?z:A):this._offset="touch"===a?C:D,this._clearTimeout(this._delayTimer),this._clearTimeout(this._hideDelayTimer);var d=this._decideOnDelay(a);if(d>0){var e=this;this._delayTimer=this._setTimeout(function(){e._showTooltip(a)},d)}else this._showTooltip(a)}},_onDismiss:function(){this._shouldDismiss=!0,this._isShown&&(this._isShown=!1,this._showTrigger="mouse",this._domElement?(this._raiseEvent("beforeclose"),this._useAnimation?g.fadeOut(this._domElement).then(this._onHideAnimationEnd.bind(this)):this._onHideAnimationEnd()):(this._raiseEvent("beforeclose"),this._raiseEvent("closed")))},_setTimeout:function(a,c){return b.setTimeout(a,c)},_clearTimeout:function(a){b.clearTimeout(a)}},{_DELAY_INITIAL_TOUCH_SHORT:{get:function(){return p}},_DELAY_INITIAL_TOUCH_LONG:{get:function(){return q}},_DEFAULT_MOUSE_HOVER_TIME:{get:function(){return r}},_DEFAULT_MESSAGE_DURATION:{get:function(){return s}},_DELAY_RESHOW_NONINFOTIP_TOUCH:{get:function(){return t}},_DELAY_RESHOW_NONINFOTIP_NONTOUCH:{get:function(){return u}},_DELAY_RESHOW_INFOTIP_TOUCH:{get:function(){return v}},_DELAY_RESHOW_INFOTIP_NONTOUCH:{get:function(){return w}},_RESHOW_THRESHOLD:{get:function(){return x}},_HIDE_DELAY_MAX:{get:function(){return y}}})})})}),d("WinJS/Controls/Rating",["../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_SafeHtml","./Tooltip","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j){"use strict";b.Namespace.define("WinJS.UI",{Rating:b.Namespace._lazy(function(){var h=d._createEventProperty,k={get averageRating(){return e._getWinJSString("ui/averageRating").value},get clearYourRating(){return e._getWinJSString("ui/clearYourRating").value},get tentativeRating(){return e._getWinJSString("ui/tentativeRating").value},get tooltipStringsIsInvalid(){return"Invalid argument: tooltipStrings must be null or an array of strings."},get unrated(){return e._getWinJSString("ui/unrated").value},get userRating(){return e._getWinJSString("ui/userRating").value}},l=5,m=!1,n="cancel",o="change",p="previewchange",q=0,r=g._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",s=g._MSPointerEvent.MSPOINTER_TYPE_PEN||"pen",t=g._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",u="padding-left: 0px; padding-right: 0px; border-left: 0px; border-right: 0px; -ms-flex: none; -webkit-flex: none; flex: none; display: none",v="win-rating",w="win-star win-empty",x="win-star win-average win-empty",y="win-star win-average win-full",z="win-star win-user win-empty",A="win-star win-user win-full",B="win-star win-tentative win-empty",C="win-star win-tentative win-full",D="win-disabled",E="win-average",F="win-user";return b.Class.define(function(b,c){this._disposed=!1,b=b||a.document.createElement("div"),c=c||{},this._element=b,g.addClass(this._element,"win-disposable"),this._userRating=0,this._averageRating=0,this._disabled=m,this._enableClear=!0,this._tooltipStrings=[],this._controlUpdateNeeded=!1,this._setControlSize(c.maxRating),c.tooltipStrings||this._updateTooltips(null),f.setOptions(this,c),this._controlUpdateNeeded=!0,this._forceLayout(),g._addInsertedNotifier(this._element),b.winControl=this,this._events()},{maxRating:{get:function(){return this._maxRating},set:function(a){this._setControlSize(a),this._forceLayout()}},userRating:{get:function(){return this._userRating},set:function(a){this._userRating=Math.max(0,Math.min(Number(a)>>0,this._maxRating)),this._updateControl()}},averageRating:{get:function(){return this._averageRating},set:function(a){this._averageRating=Number(a)<1?0:Math.min(Number(a)||0,this._maxRating),this._averageRatingElement&&this._ensureAverageMSStarRating(),this._updateControl()}},disabled:{get:function(){return this._disabled},set:function(a){this._disabled=!!a,this._disabled&&this._clearTooltips(),this._updateTabIndex(),this._updateControl()}},enableClear:{get:function(){return this._enableClear},set:function(a){this._enableClear=!!a,this._setAriaValueMin(),this._updateControl()}},tooltipStrings:{get:function(){return this._tooltipStrings},set:function(a){if("object"!=typeof a)throw new c("WinJS.UI.Rating.TooltipStringsIsInvalid",k.tooltipStringsIsInvalid);this._updateTooltips(a),this._updateAccessibilityRestState()}},element:{get:function(){return this._element}},oncancel:h(n),onchange:h(o),onpreviewchange:h(p),dispose:function(){if(!this._disposed){this._disposed=!0;for(var a=0;a<this._toolTips.length;a++)this._toolTips[a].dispose();this._toolTips=null}},addEventListener:function(a,b,c){this._element.addEventListener(a,b,c)},removeEventListener:function(a,b,c){return this._element.removeEventListener(a,b,c)},_forceLayout:function(){if(this._controlUpdateNeeded){var a=!1;this._updateControl=function(){a=!0},this.userRating=this._userRating,this.averageRating=this._averageRating,this._lastEventWasChange=!1,this._lastEventWasCancel=!1,this._tentativeRating=-1,this._captured=!1,this._pointerDownFocus=!1,this._elements=[],this._toolTips=[],this._clearElement=null,this._averageRatingElement=null,this._elementWidth=null,this._elementPadding=null,this._elementBorder=null,this._floatingValue=0,this._createControl(),this._setAccessibilityProperties(),delete this._updateControl,a&&this._updateControl()}},_hideAverageRating:function(){this._averageRatingHidden||(this._averageRatingHidden=!0,this._averageRatingElement.style.cssText=u)},_createControl:function(){g.addClass(this._element,v);var a="";this._averageRatingHidden=!0;for(var b=0;b<=this._maxRating;b++)a=b===this._maxRating?a+"<div class='"+y+"' style='"+u+"'></div>":a+"<div class='"+z+"'></div>";i.setInnerHTMLUnsafe(this._element,a);for(var c=this._element.firstElementChild,b=0;c;)this._elements[b]=c,b<this._maxRating&&(g.data(c).msStarRating=b+1),c=c.nextElementSibling,b++;this._averageRatingElement=this._elements[this._maxRating],this._ensureAverageMSStarRating(),this._updateTabIndex()},_setAriaValueMin:function(){this._element.setAttribute("aria-valuemin",this._enableClear?0:1)},_setAccessibilityProperties:function(){this._element.setAttribute("role","slider"),this._element.setAttribute("aria-valuemax",this._maxRating),this._setAriaValueMin(),this._updateAccessibilityRestState()},_getText:function(b){var c=this._tooltipStrings[b];if(c){var d=a.document.createElement("div");return d.innerHTML=c,d.textContent}return b===this._maxRating?k.clearYourRating:b+1},_updateAccessibilityRestState:function(){var a=this._element;this._ariaValueNowMutationObserver&&this._ariaValueNowMutationObserver.disconnect(),a.setAttribute("aria-readOnly",this._disabled),0!==this._userRating?(a.setAttribute("aria-valuenow",this._userRating),a.setAttribute("aria-label",k.userRating),a.setAttribute("aria-valuetext",this._getText(this._userRating-1))):0!==this._averageRating?(a.setAttribute("aria-valuenow",this._averageRating),a.setAttribute("aria-label",k.averageRating),a.setAttribute("aria-valuetext",this._averageRating)):(a.setAttribute("aria-valuenow",k.unrated),a.setAttribute("aria-label",k.userRating),a.setAttribute("aria-valuetext",k.unrated)),this._ariaValueNowMutationObserver&&this._ariaValueNowMutationObserver.observe(this._element,{attributes:!0,attributeFilter:["aria-valuenow"]})},_updateAccessibilityHoverState:function(){var a=this._element;this._ariaValueNowMutationObserver&&this._ariaValueNowMutationObserver.disconnect(),a.setAttribute("aria-readOnly",this._disabled),this._tentativeRating>0?(a.setAttribute("aria-label",k.tentativeRating),a.setAttribute("aria-valuenow",this._tentativeRating),a.setAttribute("aria-valuetext",this._getText(this._tentativeRating-1))):0===this._tentativeRating?(a.setAttribute("aria-valuenow",k.unrated),a.setAttribute("aria-label",k.tentativeRating),a.setAttribute("aria-valuetext",this._getText(this._maxRating))):(a.setAttribute("aria-valuenow",k.unrated),a.setAttribute("aria-label",k.tentativeRating),a.setAttribute("aria-valuetext",k.unrated)),this._ariaValueNowMutationObserver&&this._ariaValueNowMutationObserver.observe(this._element,{attributes:!0,attributeFilter:["aria-valuenow"]})},_ensureTooltips:function(){if(!this.disabled&&0===this._toolTips.length)for(var a=0;a<this._maxRating;a++)this._toolTips[a]=new j.Tooltip(this._elements[a])},_decrementRating:function(){this._closeTooltip();var a=!0;0===this._tentativeRating||-1===this._tentativeRating&&0===this._userRating?a=!1:(this._tentativeRating>0?this._tentativeRating--:-1===this._tentativeRating&&(this._tentativeRating=0!==this._userRating&&this._userRating>0?this._userRating-1:0),0!==this._tentativeRating||this._enableClear||(this._tentativeRating=1,a=!1)),this._showTentativeRating(a,"keyboard")},_events:function(){function a(a){return{name:a,lowerCaseName:a.toLowerCase(),handler:function(b){var d=c["_on"+a];d&&d.apply(c,[b])}}}var b,c=this,d=[a("KeyDown"),a("FocusOut"),a("FocusIn"),a("PointerCancel"),a("PointerDown"),a("PointerMove"),a("PointerOver"),a("PointerUp"),a("PointerOut")],e=[a("WinJSNodeInserted")];for(b=0;b<d.length;++b)g._addEventListener(this._element,d[b].lowerCaseName,d[b].handler,!1);for(b=0;b<e.length;++b)this._element.addEventListener(e[b].name,e[b].handler,!1);this._ariaValueNowMutationObserver=new g._MutationObserver(this._ariaValueNowChanged.bind(this)),this._ariaValueNowMutationObserver.observe(this._element,{attributes:!0,attributeFilter:["aria-valuenow"]})},_onWinJSNodeInserted:function(){this._recalculateStarProperties(),this._updateControl()},_recalculateStarProperties:function(){var b=0;1===this._averageRating&&(b=1);var c=a.getComputedStyle(this._elements[b]);this._elementWidth=c.width,"rtl"===a.getComputedStyle(this._element).direction?(this._elementPadding=c.paddingRight,this._elementBorder=c.borderRight):(this._elementPadding=c.paddingLeft,this._elementBorder=c.borderLeft)},_hideAverageStar:function(){0!==this._averageRating&&this._resetAverageStar(!1)},_incrementRating:function(){this._closeTooltip();var a=!0;(this._tentativeRating===this._maxRating||-1===this._tentativeRating&&this._userRating===this._maxRating)&&(a=!1),-1!==this._tentativeRating?this._tentativeRating<this._maxRating&&this._tentativeRating++:this._tentativeRating=0!==this._userRating?this._userRating<this._maxRating?this._userRating+1:this._maxRating:1,this._showTentativeRating(a,"keyboard")},_ariaValueNowChanged:function(){if(!this._disabled){var a=this._element.getAttributeNode("aria-valuenow");if(null!==a){var b=Number(a.nodeValue);this.userRating!==b&&(this.userRating=b,this._tentativeRating=this._userRating,this._raiseEvent(o,this._userRating))}}},_onPointerCancel:function(){this._showCurrentRating(),this._lastEventWasChange||this._raiseEvent(n,null),this._captured=!1},_onPointerDown:function(a){(a.pointerType!==t||a.button===q)&&(this._captured||(this._pointerDownAt={x:a.clientX,y:a.clientY},this._pointerDownFocus=!0,this._disabled||(g._setPointerCapture(this._element,a.pointerId),this._captured=!0,a.pointerType===r?(this._tentativeRating=g.data(a.target).msStarRating||0,this._setStarClasses(C,this._tentativeRating,B),this._hideAverageStar(),this._updateAccessibilityHoverState(),this._openTooltip("touch"),this._raiseEvent(p,this._tentativeRating)):this._openTooltip("mousedown"))))},_onCapturedPointerMove:function(b,c){var d,e=this._pointerDownAt||{x:b.clientX,y:b.clientY},f=g._elementsFromPoint(b.clientX,e.y);if(f)for(var h=0,i=f.length;i>h;h++){var j=f[h];if("tooltip"===j.getAttribute("role"))return;if(g.hasClass(j,"win-star")){d=j;break}}var k;if(d&&d.parentElement===this._element)k=g.data(d).msStarRating||0;else{var l=0,m=this.maxRating;"rtl"===a.getComputedStyle(this._element).direction&&(l=m,m=0),k=b.clientX<e.x?l:m}var n=!1,o=Math.min(Math.ceil(k),this._maxRating);0!==o||this._enableClear||(o=1),o!==this._tentativeRating&&(this._closeTooltip(),n=!0),this._tentativeRating=o,this._showTentativeRating(n,c),b.preventDefault()},_onPointerMove:function(a){this._captured&&(a.pointerType===r?this._onCapturedPointerMove(a,"touch"):this._onCapturedPointerMove(a,"mousedown"))},_onPointerOver:function(a){this._disabled||a.pointerType!==s&&a.pointerType!==t||this._onCapturedPointerMove(a,"mouseover")},_onPointerUp:function(a){this._captured&&(g._releasePointerCapture(this._element,a.pointerId),this._captured=!1,this._onUserRatingChanged()),this._pointerDownAt=null},_onFocusOut:function(){this._captured||(this._onUserRatingChanged(),this._lastEventWasChange||this._lastEventWasCancel||this._raiseEvent(n,null))},_onFocusIn:function(){if(!this._pointerDownFocus){if(!this._disabled){if(0===this._userRating)for(var a=0;a<this._maxRating;a++)this._elements[a].className=B;this._hideAverageStar()}0!==this._userRating?this._raiseEvent(p,this._userRating):this._raiseEvent(p,0),this._tentativeRating=this._userRating}this._pointerDownFocus=!1},_onKeyDown:function(b){var c=g.Key,d=b.keyCode,e=a.getComputedStyle(this._element).direction,f=!0;switch(d){case c.enter:this._onUserRatingChanged();break;case c.tab:this._onUserRatingChanged(),f=!1;break;case c.escape:this._showCurrentRating(),this._lastEventWasChange||this._raiseEvent(n,null);break;case c.leftArrow:"rtl"===e?this._incrementRating():this._decrementRating();break;case c.upArrow:this._incrementRating();break;case c.rightArrow:"rtl"===e?this._decrementRating():this._incrementRating();break;case c.downArrow:this._decrementRating();break;default:var h=0;if(d>=c.num0&&d<=c.num9?h=c.num0:d>=c.numPad0&&d<=c.numPad9&&(h=c.numPad0),h>0){var i=!1,j=Math.min(d-h,this._maxRating);0!==j||this._enableClear||(j=1),j!==this._tentativeRating&&(this._closeTooltip(),i=!0),this._tentativeRating=j,this._showTentativeRating(i,"keyboard")}else f=!1}f&&(b.stopPropagation(),b.preventDefault())},_onPointerOut:function(a){this._captured||g.eventWithinElement(this._element,a)||(this._showCurrentRating(),this._lastEventWasChange||this._raiseEvent(n,null))},_onUserRatingChanged:function(){this._disabled||(this._closeTooltip(),this._userRating===this._tentativeRating||this._lastEventWasCancel||this._lastEventWasChange?this._updateControl():(this.userRating=this._tentativeRating,this._raiseEvent(o,this._userRating)))},_raiseEvent:function(b,c){if(!this._disabled&&(this._lastEventWasChange=b===o,this._lastEventWasCancel=b===n,a.document.createEvent)){var d=a.document.createEvent("CustomEvent");d.initCustomEvent(b,!1,!1,{tentativeRating:c}),this._element.dispatchEvent(d)}},_resetNextElement:function(b){if(null!==this._averageRatingElement.nextSibling){g._setFlexStyle(this._averageRatingElement.nextSibling,{grow:1,shrink:1});var c=this._averageRatingElement.nextSibling.style,d=a.getComputedStyle(this._element).direction;b&&(d="rtl"===d?"ltr":"rtl"),"rtl"===d?(c.paddingRight=this._elementPadding,c.borderRight=this._elementBorder,c.direction="rtl"):(c.paddingLeft=this._elementPadding,c.borderLeft=this._elementBorder,c.direction="ltr"),c.backgroundPosition="left",c.backgroundSize="100% 100%",c.width=this._resizeStringValue(this._elementWidth,1,c.width)}},_resetAverageStar:function(a){this._resetNextElement(a),this._hideAverageRating()},_resizeStringValue:function(a,b,c){var d=parseFloat(a);if(isNaN(d))return null!==c?c:a;var e=a.substring(d.toString(10).length);return d*=b,d+e},_setControlSize:function(a){var b=(Number(a)||l)>>0;this._maxRating=b>0?b:l},_updateTooltips:function(a){var b,c=0;if(null!==a)for(c=a.length<=this._maxRating+1?a.length:this._maxRating+1,b=0;c>b;b++)this._tooltipStrings[b]=a[b];else{for(b=0;b<this._maxRating;b++)this._tooltipStrings[b]=b+1;this._tooltipStrings[this._maxRating]=k.clearYourRating}},_updateTabIndex:function(){this._element.tabIndex=this._disabled?"-1":"0"},_setStarClasses:function(a,b,c){for(var d=0;d<this._maxRating;d++)this._elements[d].className=b>d?a:c},_updateAverageStar:function(){var b=this._averageRatingElement.style,c=this._averageRatingElement.nextSibling.style;"rtl"===a.getComputedStyle(this._element).direction?(b.backgroundPosition="right",b.paddingRight=this._elementPadding,b.borderRight=this._elementBorder,c.paddingRight="0px",c.borderRight="0px",c.direction="ltr"):(b.backgroundPosition="left",c.backgroundPosition="right",b.paddingLeft=this._elementPadding,b.borderLeft=this._elementBorder,c.paddingLeft="0px",c.borderLeft="0px",c.direction="rtl"),g._setFlexStyle(this._averageRatingElement,{grow:this._floatingValue,shrink:this._floatingValue}),b.width=this._resizeStringValue(this._elementWidth,this._floatingValue,b.width),b.backgroundSize=100/this._floatingValue+"% 100%",b.display=a.getComputedStyle(this._averageRatingElement.nextSibling).display,this._averageRatingHidden=!1,g._setFlexStyle(this._averageRatingElement.nextSibling,{grow:1-this._floatingValue,shrink:1-this._floatingValue}),c.width=this._resizeStringValue(this._elementWidth,1-this._floatingValue,c.width),c.backgroundSize=100/(1-this._floatingValue)+"% 100%"},_showCurrentRating:function(){this._closeTooltip(),this._tentativeRating=-1,this._disabled||this._updateControl(),this._updateAccessibilityRestState()},_showTentativeRating:function(a,b){!this._disabled&&this._tentativeRating>=0&&(this._setStarClasses(C,this._tentativeRating,B),this._hideAverageStar()),this._updateAccessibilityHoverState(),a&&(this._openTooltip(b),this._raiseEvent(p,this._tentativeRating))},_openTooltip:function(b){if(!this.disabled)if(this._ensureTooltips(),this._tentativeRating>0)this._toolTips[this._tentativeRating-1].innerHTML=this._tooltipStrings[this._tentativeRating-1],this._toolTips[this._tentativeRating-1].open(b);else if(0===this._tentativeRating){this._clearElement=a.document.createElement("div");var c=this._elements[0].offsetWidth+parseInt(this._elementPadding,10);"ltr"===a.getComputedStyle(this._element).direction&&(c*=-1),this._clearElement.style.cssText="visiblity:hidden; position:absolute; width:0px; height:100%; left:"+c+"px; top:0px;",this._elements[0].appendChild(this._clearElement),this._toolTips[this._maxRating]=new j.Tooltip(this._clearElement),this._toolTips[this._maxRating].innerHTML=this._tooltipStrings[this._maxRating],this._toolTips[this._maxRating].open(b)}},_closeTooltip:function(){0!==this._toolTips.length&&(this._tentativeRating>0?this._toolTips[this._tentativeRating-1].close():0===this._tentativeRating&&null!==this._clearElement&&(this._toolTips[this._maxRating].close(),this._elements[0].removeChild(this._clearElement),this._clearElement=null))},_clearTooltips:function(){if(this._toolTips&&0!==this._toolTips.length)for(var a=0;a<this._maxRating;a++)this._toolTips[a].innerHTML=null},_appendClass:function(a){for(var b=0;b<=this._maxRating;b++)g.addClass(this._elements[b],a)},_setClasses:function(a,b,c){for(var d=0;d<this._maxRating;d++)this._elements[d].className=b>d?a:c},_ensureAverageMSStarRating:function(){g.data(this._averageRatingElement).msStarRating=Math.ceil(this._averageRating)},_updateControl:function(){if(this._controlUpdateNeeded){if(0!==this._averageRating&&0===this._userRating&&this._averageRating>=1&&this._averageRating<=this._maxRating){this._setClasses(y,this._averageRating-1,x),this._averageRatingElement.className=y;for(var b=0;b<this._maxRating;b++)if(b<this._averageRating&&b+1>=this._averageRating){this._resetNextElement(!1),this._element.insertBefore(this._averageRatingElement,this._elements[b]),this._floatingValue=this._averageRating-b;var c=a.getComputedStyle(this._elements[b]);this._elementWidth=c.width,"rtl"===a.getComputedStyle(this._element).direction?(this._elementPadding=c.paddingRight,this._elementBorder=c.borderRight):(this._elementPadding=c.paddingLeft,this._elementBorder=c.borderLeft),this._updateAverageStar()}}0!==this._userRating&&this._userRating>=1&&this._userRating<=this._maxRating&&(this._setClasses(A,this._userRating,z),this._resetAverageStar(!1)),0===this._userRating&&0===this._averageRating&&(this._setClasses(w,this._maxRating),this._resetAverageStar(!1)),this.disabled&&this._appendClass(D),this._appendClass(0!==this._averageRating&&0===this._userRating?E:F),this._updateAccessibilityRestState()}}})})})}),d("WinJS/Controls/ToggleSwitch",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g){"use strict";b.Namespace.define("WinJS.UI",{ToggleSwitch:b.Namespace._lazy(function(){var c="win-toggleswitch",h="win-toggleswitch-header",i="win-toggleswitch-clickregion",j="win-toggleswitch-track",k="win-toggleswitch-fill",l="win-toggleswitch-fill-lower",m="win-toggleswitch-fill-upper",n="win-toggleswitch-thumb",o="win-toggleswitch-values",p="win-toggleswitch-value",q="win-toggleswitch-value-on",r="win-toggleswitch-value-off",s="win-toggleswitch-description",t="win-toggleswitch-on",u="win-toggleswitch-off",v="win-toggleswitch-disabled",w="win-toggleswitch-enabled",x="win-toggleswitch-dragging",y="win-toggleswitch-pressed",z={get on(){return e._getWinJSString("ui/on").value},get off(){return e._getWinJSString("ui/off").value}},A=b.Class.define(function(b,d){b=b||a.document.createElement("div"),this._domElement=b,g.addClass(this._domElement,c),this._domElement.innerHTML=['<div class="'+h+'"></div>','<div class="'+o+'">','   <div class="'+p+" "+q+'"></div>','   <div class="'+p+" "+r+'"></div>',"</div>",'<div class="'+i+'">','   <div class="'+j+'">','       <div class="'+k+" "+l+'"></div>','       <div class="'+n+'"></div>','       <div class="'+k+" "+m+'"></div>',"   </div>","</div>",'<div class="'+s+'"></div>'].join("\n"),this._headerElement=this._domElement.firstElementChild,this._labelsElement=this._headerElement.nextElementSibling,this._labelOnElement=this._labelsElement.firstElementChild,this._labelOffElement=this._labelOnElement.nextElementSibling,this._clickElement=this._labelsElement.nextElementSibling,this._trackElement=this._clickElement.firstElementChild,this._fillLowerElement=this._trackElement.firstElementChild,this._thumbElement=this._fillLowerElement.nextElementSibling,this._fillUpperElement=this._thumbElement.nextElementSibling,this._descriptionElement=this._clickElement.nextElementSibling,this._headerElement.setAttribute("aria-hidden",!0),this._labelsElement.setAttribute("aria-hidden",!0),this._headerElement.setAttribute("id",g._uniqueID(this._headerElement)),this._domElement.setAttribute("aria-labelledby",this._headerElement.id),this._domElement.setAttribute("role","checkbox"),this._domElement.winControl=this,g.addClass(this._domElement,"win-disposable"),this._domElement.addEventListener("keydown",this._keyDownHandler.bind(this)),g._addEventListener(this._clickElement,"pointerdown",this._pointerDownHandler.bind(this)),g._globalListener.addEventListener(this._domElement,"pointermove",this._pointerMoveHandler.bind(this)),g._globalListener.addEventListener(this._domElement,"pointerup",this._pointerUpHandler.bind(this)),this._mutationObserver=new g._MutationObserver(this._ariaChangedHandler.bind(this)),this._mutationObserver.observe(this._domElement,{attributes:!0,attributeFilter:["aria-checked"]}),this._dragX=0,this._dragging=!1,this.checked=!1,this.disabled=!1,this.labelOn=z.on,this.labelOff=z.off,f.setOptions(this,d)},{element:{get:function(){return this._domElement}},checked:{get:function(){return this._checked},set:function(a){a=!!a,a!==this.checked&&(this._checked=a,this._domElement.setAttribute("aria-checked",a),a?(g.addClass(this._domElement,t),g.removeClass(this._domElement,u)):(g.addClass(this._domElement,u),g.removeClass(this._domElement,t)),this.dispatchEvent("change"))}},disabled:{get:function(){return this._disabled},set:function(a){a=!!a,a!==this._disabled&&(a?(g.addClass(this._domElement,v),g.removeClass(this._domElement,w)):(g.removeClass(this._domElement,v),g.addClass(this._domElement,w)),this._disabled=a,this._domElement.setAttribute("aria-disabled",a),this._domElement.setAttribute("tabIndex",a?-1:0))}},labelOn:{get:function(){return this._labelOnElement.innerHTML},set:function(a){this._labelOnElement.innerHTML=a}},labelOff:{get:function(){return this._labelOffElement.innerHTML},set:function(a){this._labelOffElement.innerHTML=a}},title:{get:function(){return this._headerElement.innerHTML},set:function(a){this._headerElement.innerHTML=a}},onchange:d._createEventProperty("change"),dispose:function(){this._disposed||(this._disposed=!0)},_ariaChangedHandler:function(){var a=this._domElement.getAttribute("aria-checked");a="true"===a?!0:!1,this.checked=a},_keyDownHandler:function(a){this.disabled||(a.keyCode===g.Key.space&&(this.checked=!this.checked),(a.keyCode===g.Key.rightArrow||a.keyCode===g.Key.upArrow)&&(this.checked=!0),(a.keyCode===g.Key.leftArrow||a.keyCode===g.Key.downArrow)&&(this.checked=!1))},_pointerDownHandler:function(a){this.disabled||(a.preventDefault(),this._mousedown=!0,this._dragXStart=a.pageX-this._trackElement.offsetLeft-this._thumbElement.offsetWidth/2,this._dragX=this._dragXStart,this._dragging=!1,g.addClass(this._domElement,y))},_pointerUpHandler:function(b){if(!this.disabled&&this._mousedown){b=b.detail.originalEvent,b.preventDefault();var c="rtl"===a.getComputedStyle(this._domElement).direction;if(this._dragging){var d=this._trackElement.offsetWidth-this._thumbElement.offsetWidth;this.checked=c?this._dragX<d/2:this._dragX>=d/2,this._dragging=!1,g.removeClass(this._domElement,x)}else this.checked=!this.checked;this._mousedown=!1,this._thumbElement.style.left="",this._fillLowerElement.style.width="",this._fillUpperElement.style.width="",g.removeClass(this._domElement,y)}},_pointerMoveHandler:function(a){if(!this.disabled&&this._mousedown){a=a.detail.originalEvent,a.preventDefault();var b=a.pageX-this._trackElement.offsetLeft-this._thumbElement.offsetWidth/2,c=this._trackElement.offsetWidth-this._thumbElement.offsetWidth,d=this._fillLowerElement.offsetLeft+this._trackElement.clientLeft;this._dragX=Math.min(c,b),this._dragX=Math.max(0,this._dragX),!this._dragging&&Math.abs(this._dragX-this._dragXStart)>3&&(this._dragging=!0,g.addClass(this._domElement,x)),this._thumbElement.style.left=this._dragX+"px",this._fillLowerElement.style.width=this._dragX-d+"px",this._fillUpperElement.style.width=c-this._dragX-d+"px"}}});return b.Class.mix(A,f.DOMEventMixin),A})})}),d("WinJS/Controls/SemanticZoom",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Animations/_TransitionAnimation","../ControlProcessor","../Promise","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_ElementListUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";b.Namespace.define("WinJS.UI",{SemanticZoom:b.Namespace._lazy(function(){function f(a){return a}function q(a,b,c){return a+" "+i._animationTimeAdjustment(b)+"s "+c+" "+i._libraryDelay+"ms"}function r(){return q(X.cssName,Q,"ease-in-out")+", "+q("opacity",O,"ease-in-out")}function s(){return q(X.cssName,R,"ease-in-out")+", "+q("opacity",P,"ease-in-out")}function t(){return q(X.cssName,U,W)}function u(){return q(X.cssName,V,W)}function v(a,b){return n.convertToPixels(a,b)}function w(a,b){i.isAnimationEnabled()&&(a.style[X.scriptName]="scale("+b+")")}function x(a){var b=a.target&&a.target.winControl;b&&!b._resizing&&b._onResize()}function y(a){var b=a[0].target&&a[0].target.winControl;b&&b instanceof hb&&b._onPropertyChanged()}var z=c._browserStyleEquivalents,A={get invalidZoomFactor(){return"Invalid zoomFactor"}},B="win-semanticzoom-button",C="win-semanticzoom-button-location",D=3e3,E=8,F="win-semanticzoom",G="win-semanticzoom-zoomedinview",H="win-semanticzoom-zoomedoutview",I="zoomchanged",J=1.05,K=.65,L=.8,M=.2,N=4096,O=.333,P=.333,Q=.333,R=.333,S=1e3*O,T=50,U=.333,V=.333,W="cubic-bezier(0.1,0.9,0.2,1)",X=z.transform,Y=z.transition.scriptName,Z=2,$=.2,_=.45,ab=1e3,bb=50,cb={none:0,zoomedIn:1,zoomedOut:2},db=n._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",eb=n._MSPointerEvent.MSPOINTER_TYPE_PEN||"pen",fb=n._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",gb={x:0,y:0},hb=b.Class.define(function(b,e){this._disposed=!1;var f=this,g=c.isPhone;this._element=b,this._element.winControl=this,n.addClass(this._element,"win-disposable"),n.addClass(this._element,F),this._element.setAttribute("role","ms-semanticzoomcontainer");var h=this._element.getAttribute("aria-label");if(h||this._element.setAttribute("aria-label",""),e=e||{},this._zoomedOut=!!e.zoomedOut||!!e.initiallyZoomedOut||!1,this._enableButton=!g,g||void 0===e.enableButton||(this._enableButton=!!e.enableButton),this._element.setAttribute("aria-checked",this._zoomedOut.toString()),this._zoomFactor=n._clamp(e.zoomFactor,M,L,K),this.zoomedInItem=e.zoomedInItem,this.zoomedOutItem=e.zoomedOutItem,c.validation&&e._zoomFactor&&e._zoomFactor!==this._zoomFactor)throw new d("WinJS.UI.SemanticZoom.InvalidZoomFactor",A.invalidZoomFactor);this._locked=!!e.locked,this._zoomInProgress=!1,this._isBouncingIn=!1,this._isBouncing=!1,this._zooming=!1,this._aligning=!1,this._gesturing=!1,this._gestureEnding=!1,this._buttonShown=!1,this._shouldFakeTouchCancel="TouchEvent"in a,this._initialize(),this._configure(),this._element.addEventListener("mselementresize",x),n._resizeNotifier.subscribe(this._element,x),new n._MutationObserver(y).observe(this._element,{attributes:!0,attributeFilter:["aria-checked"]}),g||(this._element.addEventListener("wheel",this._onWheel.bind(this),!0),this._element.addEventListener("mousewheel",this._onMouseWheel.bind(this),!0),this._element.addEventListener("keydown",this._onKeyDown.bind(this),!0),n._addEventListener(this._element,"pointerdown",this._onPointerDown.bind(this),!0),n._addEventListener(this._element,"pointermove",this._onPointerMove.bind(this),!0),n._addEventListener(this._element,"pointerout",this._onPointerOut.bind(this),!0),n._addEventListener(this._element,"pointercancel",this._onPointerCancel.bind(this),!0),n._addEventListener(this._element,"pointerup",this._onPointerUp.bind(this),!1),this._hiddenElement.addEventListener("gotpointercapture",this._onGotPointerCapture.bind(this),!1),this._hiddenElement.addEventListener("lostpointercapture",this._onLostPointerCapture.bind(this),!1),this._element.addEventListener("click",this._onClick.bind(this),!0),this._canvasIn.addEventListener(c._browserEventEquivalents.transitionEnd,this._onCanvasTransitionEnd.bind(this),!1),this._canvasOut.addEventListener(c._browserEventEquivalents.transitionEnd,this._onCanvasTransitionEnd.bind(this),!1),this._element.addEventListener("MSContentZoom",this._onMSContentZoom.bind(this),!0),this._resetPointerRecords()),this._onResizeImpl(),l._setOptions(this,e,!0),f._setVisibility()},{element:{get:function(){return this._element}},enableButton:{get:function(){return this._enableButton},set:function(a){var b=!!a;this._enableButton===b||c.isPhone||(this._enableButton=b,b?this._createSemanticZoomButton():this._removeSemanticZoomButton())}},zoomedOut:{get:function(){return this._zoomedOut},set:function(a){this._zoom(!!a,{x:.5*this._sezoClientWidth,y:.5*this._sezoClientHeight},!1,!1,this._zoomedOut&&c.isPhone)}},zoomFactor:{get:function(){return this._zoomFactor},set:function(a){var b=this._zoomFactor,c=n._clamp(a,M,L,K);b!==c&&(this._zoomFactor=c,this._onResize())}},locked:{get:function(){return this._locked},set:function(a){this._locked=!!a,a?this._hideSemanticZoomButton():this._displayButton()}},zoomedInItem:{get:function(){return this._zoomedInItem},set:function(a){this._zoomedInItem=a||f}},zoomedOutItem:{get:function(){return this._zoomedOutItem},set:function(a){this._zoomedOutItem=a||f}},dispose:function(){this._disposed||(this._disposed=!0,n._resizeNotifier.unsubscribe(this._element,x),m._disposeElement(this._elementIn),m._disposeElement(this._elementOut),this._clearTimeout(this._completeZoomTimer),this._clearTimeout(this._TTFFTimer))
  },forceLayout:function(){this._onResizeImpl()},_initialize:function(){var b=o.children(this._element);this._elementIn=b[0],this._elementOut=b[1],this._elementIn.style.height=this._elementOut.style.height=this._element.offsetHeight+"px",j.processAll(this._elementIn),j.processAll(this._elementOut),this._viewIn=this._elementIn.winControl.zoomableView,this._viewOut=this._elementOut.winControl.zoomableView,this._element.removeChild(this._elementOut),this._element.removeChild(this._elementIn),this._element.innerHTML="",this._cropViewport=a.document.createElement("div"),this._element.appendChild(this._cropViewport),this._viewportIn=a.document.createElement("div"),this._opticalViewportIn=a.document.createElement("div"),this._viewportOut=a.document.createElement("div"),this._opticalViewportOut=a.document.createElement("div"),this._opticalViewportIn.appendChild(this._viewportIn),this._opticalViewportOut.appendChild(this._viewportOut),this._cropViewport.appendChild(this._opticalViewportIn),this._cropViewport.appendChild(this._opticalViewportOut),this._canvasIn=a.document.createElement("div"),this._canvasOut=a.document.createElement("div"),this._viewportIn.appendChild(this._canvasIn),this._viewportOut.appendChild(this._canvasOut),this._canvasIn.appendChild(this._elementIn),this._canvasOut.appendChild(this._elementOut),this._enableButton&&this._createSemanticZoomButton(),this._hiddenElement=a.document.createElement("div"),this._hiddenElement.tabIndex=-1,this._hiddenElement.visibility="hidden",this._hiddenElement.setAttribute("aria-hidden","true"),this._element.appendChild(this._hiddenElement),n.addClass(this._elementIn,G),n.addClass(this._elementOut,H),this._setLayout(this._element,"relative","hidden"),this._setLayout(this._cropViewport,"absolute","hidden"),this._setLayout(this._opticalViewportIn,"absolute","auto"),this._setLayout(this._opticalViewportOut,"absolute","auto"),this._setLayout(this._viewportIn,"absolute","hidden"),this._setLayout(this._viewportOut,"absolute","hidden"),this._setLayout(this._canvasIn,"absolute","hidden"),this._setLayout(this._canvasOut,"absolute","hidden"),this._setupOpticalViewport(this._opticalViewportIn),this._setupOpticalViewport(this._opticalViewportOut),this._viewportIn.style["-ms-overflow-style"]="-ms-autohiding-scrollbar",this._viewportOut.style["-ms-overflow-style"]="-ms-autohiding-scrollbar",this._elementIn.style.position="absolute",this._elementOut.style.position="absolute"},_createSemanticZoomButton:function(){this._sezoButton=a.document.createElement("button"),this._sezoButton.className=B+" "+C,this._sezoButton.tabIndex=-1,this._sezoButton.style.visibility="hidden",this._sezoButton.setAttribute("aria-hidden",!0),this._element.appendChild(this._sezoButton),this._sezoButton.addEventListener("click",this._onSeZoButtonZoomOutClick.bind(this),!1),this._element.addEventListener("scroll",this._onSeZoChildrenScroll.bind(this),!0),n._addEventListener(this._element,"pointermove",this._onPenHover.bind(this),!1)},_removeSemanticZoomButton:function(){this._sezoButton&&(this._element.removeChild(this._sezoButton),this._sezoButton=null)},_configure:function(){var a=this._viewIn.getPanAxis(),b=this._viewOut.getPanAxis(),d=c.isPhone;if(this._pansHorizontallyIn="horizontal"===a||"both"===a,this._pansVerticallyIn="vertical"===a||"both"===a,this._pansHorizontallyOut="horizontal"===b||"both"===b,this._pansVerticallyOut="vertical"===b||"both"===b,!this._zoomInProgress){var e=1/this._zoomFactor-1,f=J-1;this._setLayout(this._elementIn,"absolute","visible"),this._setLayout(this._elementOut,"absolute","visible"),this._viewIn.configureForZoom(!1,!this._zoomedOut,this._zoomFromCurrent.bind(this,!0),e),this._viewOut.configureForZoom(!0,this._zoomedOut,this._zoomFromCurrent.bind(this,!1),f),this._pinching=!1,this._pinchGesture=0,this._canvasLeftIn=0,this._canvasTopIn=0,this._canvasLeftOut=0,this._canvasTopOut=0,d||(this._zoomedOut?w(this._canvasIn,this._zoomFactor):w(this._canvasOut,1/this._zoomFactor));var g=this._opticalViewportIn.style,h=this._opticalViewportOut.style,j=this._canvasIn.style,k=this._canvasOut.style;j.opacity=this._zoomedOut&&!d?0:1,k.opacity=this._zoomedOut?1:0,d&&(j.zIndex=1,k.zIndex=2),i.isAnimationEnabled()&&!d&&(g[z["transition-property"].scriptName]=X.cssName,g[z["transition-duration"].scriptName]="0s",g[z["transition-timing-function"].scriptName]="linear",h[z["transition-property"].scriptName]=X.cssName,h[z["transition-duration"].scriptName]="0s",h[z["transition-timing-function"].scriptName]="linear")}},_onPropertyChanged:function(){var a=this._element.getAttribute("aria-checked"),b="true"===a;this._zoomedOut!==b&&(this.zoomedOut=b)},_onResizeImpl:function(){this._resizing=this._resizing||0,this._resizing++;try{var b=function(a,b,c,d,e){var f=a.style;f.left=b+"px",f.top=c+"px",f.width=d+"px",f.height=e+"px"},c=a.getComputedStyle(this._element,null),d=parseFloat(c.width),e=parseFloat(c.height),f=v(this._element,c.paddingLeft),g=v(this._element,c.paddingRight),h=v(this._element,c.paddingTop),i=v(this._element,c.paddingBottom),j=d-f-g,k=e-h-i,l=1/this._zoomFactor;if(this._viewportWidth===j&&this._viewportHeight===k)return;this._sezoClientHeight=e,this._sezoClientWidth=d,this._viewportWidth=j,this._viewportHeight=k,this._configure();var m=2*l-1,n=Math.min(N,(this._pansHorizontallyIn?m:1)*j),o=Math.min(N,(this._pansVerticallyIn?m:1)*k);this._canvasLeftIn=.5*(n-j),this._canvasTopIn=.5*(o-k),b(this._cropViewport,f,h,j,k),b(this._viewportIn,0,0,j,k),b(this._opticalViewportIn,0,0,j,k),b(this._canvasIn,-this._canvasLeftIn,-this._canvasTopIn,n,o),b(this._elementIn,this._canvasLeftIn,this._canvasTopIn,j,k);var p=2*J-1,q=(this._pansHorizontallyOut?p:1)*j,r=(this._pansVerticallyOut?p:1)*k;this._canvasLeftOut=.5*(q-j),this._canvasTopOut=.5*(r-k),b(this._viewportOut,0,0,j,k),b(this._opticalViewportOut,0,0,j,k),b(this._canvasOut,-this._canvasLeftOut,-this._canvasTopOut,q,r),b(this._elementOut,this._canvasLeftOut,this._canvasTopOut,j,k)}finally{this._resizing--}},_onResize:function(){this._onResizeImpl()},_onMouseMove:function(a){return this._zooming||!this._lastMouseX&&!this._lastMouseY||a.screenX===this._lastMouseX&&a.screenY===this._lastMouseY?(this._lastMouseX=a.screenX,void(this._lastMouseY=a.screenY)):void(Math.abs(a.screenX-this._lastMouseX)<=E&&Math.abs(a.screenY-this._lastMouseY)<=E||(this._lastMouseX=a.screenX,this._lastMouseY=a.screenY,this._displayButton()))},_displayButton:function(){if(p.isHoverable){a.clearTimeout(this._dismissButtonTimer),this._showSemanticZoomButton();var b=this;this._dismissButtonTimer=a.setTimeout(function(){b._hideSemanticZoomButton()},i._animationTimeAdjustment(D))}},_showSemanticZoomButton:function(){this._disposed||this._buttonShown||!this._sezoButton||this._zoomedOut||this._locked||(h.fadeIn(this._sezoButton),this._sezoButton.style.visibility="visible",this._buttonShown=!0)},_hideSemanticZoomButton:function(a){if(!this._disposed&&this._buttonShown&&this._sezoButton){if(a)this._sezoButton.style.visibility="hidden";else{var b=this;h.fadeOut(this._sezoButton).then(function(){b._sezoButton.style.visibility="hidden"})}this._buttonShown=!1}},_onSeZoChildrenScroll:function(a){a.target!==this.element&&this._hideSemanticZoomButton(!0)},_onWheel:function(a){a.ctrlKey&&(this._zoom(a.deltaY>0,this._getPointerLocation(a)),a.stopPropagation(),a.preventDefault())},_onMouseWheel:function(a){a.ctrlKey&&(this._zoom(a.wheelDelta<0,this._getPointerLocation(a)),a.stopPropagation(),a.preventDefault())},_onPenHover:function(a){a.pointerType===eb&&0===a.buttons&&this._displayButton()},_onSeZoButtonZoomOutClick:function(){this._hideSemanticZoomButton(),this._zoom(!0,{x:.5*this._sezoClientWidth,y:.5*this._sezoClientHeight},!1)},_onKeyDown:function(a){var b=!1;if(a.ctrlKey){var c=n.Key;switch(a.keyCode){case c.add:case c.equal:case 61:this._zoom(!1),b=!0;break;case c.subtract:case c.dash:case 173:this._zoom(!0),b=!0}}b&&(a.stopPropagation(),a.preventDefault())},_createPointerRecord:function(a,b){var c=this._getPointerLocation(a),d={};return d.startX=d.currentX=c.x,d.startY=d.currentY=c.y,d.fireCancelOnPinch=b,this._pointerRecords[a.pointerId]=d,this._pointerCount=Object.keys(this._pointerRecords).length,d},_deletePointerRecord:function(a){var b=this._pointerRecords[a];return delete this._pointerRecords[a],this._pointerCount=Object.keys(this._pointerRecords).length,2!==this._pointerCount&&(this._pinching=!1),b},_fakeCancelOnPointer:function(b){var c=a.document.createEvent("UIEvent");c.initUIEvent("touchcancel",!0,!0,a,0),c.touches=b.touches,c.targetTouches=b.targetTouches,c.changedTouches=[b._currentTouch],c._fakedBySemanticZoom=!0,b.target.dispatchEvent(c)},_handlePointerDown:function(a){this._createPointerRecord(a,!1);for(var b=Object.keys(this._pointerRecords),c=0,d=b.length;d>c;c++)try{n._setPointerCapture(this._hiddenElement,b[c]||0)}catch(e){return void this._resetPointerRecords()}a.stopImmediatePropagation(),a.preventDefault()},_handleFirstPointerDown:function(a){this._resetPointerRecords(),this._createPointerRecord(a,this._shouldFakeTouchCancel),this._startedZoomedOut=this._zoomedOut},_onClick:function(a){a.target!==this._element&&this._isBouncing&&a.stopImmediatePropagation()},_onPointerDown:function(a){a.pointerType===db&&(0===this._pointerCount?this._handleFirstPointerDown(a):this._handlePointerDown(a))},_onPointerMove:function(a){function b(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))}function c(a,b){return{x:.5*(a.currentX+b.currentX)|0,y:.5*(a.currentY+b.currentY)|0}}if(a.pointerType===fb||a.pointerType===eb)return void this._onMouseMove(a);if(a.pointerType===db){var d=this._pointerRecords[a.pointerId],e=this._getPointerLocation(a);if(d){if(d.currentX=e.x,d.currentY=e.y,2===this._pointerCount){this._pinching=!0;var f=Object.keys(this._pointerRecords),h=this._pointerRecords[f[0]],i=this._pointerRecords[f[1]];this._currentMidPoint=c(h,i);var j=b(h.currentX,h.currentY,i.currentX,i.currentY),k=this,l=function(a){var b=a?cb.zoomedOut:cb.zoomedIn,d=a?k._pinchedDirection===cb.zoomedIn&&!k._zoomingOut:k._pinchedDirection===cb.zoomedOut&&k._zoomingOut,e=a?!k._zoomedOut:k._zoomedOut;if(k._pinchedDirection===cb.none)e?(k._isBouncingIn=!1,k._zoom(a,c(h,i),!0),k._pinchedDirection=b):k._isBouncingIn||k._playBounce(!0,c(h,i));else if(d){var f=k._lastPinchDistance/k._lastPinchStartDistance,g=k._lastLastPinchDistance/k._lastPinchDistance;(a&&f>$||!a&&g>_)&&(k._zoom(a,c(h,i),!0),k._pinchedDirection=b)}};this._updatePinchDistanceRecords(j),this._pinchDistanceCount>=Z&&(this._zooming||this._isBouncing||(g("WinJS.UI.SemanticZoom:EndPinchDetection,info"),l(this._lastPinchDirection===cb.zoomedOut)))}else this._pointerCount>2&&this._resetPinchDistanceRecords();this._pointerCount>=2&&(d.fireCancelOnPinch&&(this._fakeCancelOnPointer(a,d),d.fireCancelOnPinch=!1),a.stopImmediatePropagation(),a.preventDefault()),2!==this._pointerCount&&this._isBouncingIn&&this._playBounce(!1)}}},_onPointerOut:function(a){a.pointerType===db&&a.target===this._element&&this._completePointerUp(a,!1)},_onPointerUp:function(a){this._releasePointerCapture(a),this._completePointerUp(a,!0),this._completeZoomingIfTimeout()},_onPointerCancel:function(a){a._fakedBySemanticZoom||(this._releasePointerCapture(a),this._completePointerUp(a,!1),this._completeZoomingIfTimeout())},_onGotPointerCapture:function(a){var b=this._pointerRecords[a.pointerId];b&&(b.dirty=!1)},_onLostPointerCapture:function(a){var b=this._pointerRecords[a.pointerId];if(b){b.dirty=!0;var c=this;k.timeout(bb).then(function(){b.dirty&&c._completePointerUp(a,!1)})}},_onMSContentZoom:function(a){var b=a.target;if(b===this._opticalViewportIn||b===this._opticalViewportOut){var c=b.msContentZoomFactor<.995,d=b.msContentZoomFactor>1.005;!c||this._zoomedOut||this._zoomingOut?d&&(this._zoomedOut||this._zoomingOut)&&(this.zoomedOut=!1):this.zoomedOut=!0}},_updatePinchDistanceRecords:function(a){function b(b){c._lastPinchDirection===b?c._pinchDistanceCount++:(c._pinchGesture++,c._pinchDistanceCount=0,c._lastPinchStartDistance=a),c._lastPinchDirection=b,c._lastPinchDistance=a,c._lastLastPinchDistance=c._lastPinchDistance}var c=this;-1===this._lastPinchDistance?(g("WinJS.UI.SemanticZoom:StartPinchDetection,info"),this._lastPinchDistance=a):this._lastPinchDistance!==a&&b(this._lastPinchDistance>a?cb.zoomedOut:cb.zoomedIn)},_zoomFromCurrent:function(a){this._zoom(a,null,!1,!0)},_zoom:function(a,b,d,e,f){if(g("WinJS.UI.SemanticZoom:StartZoom(zoomOut="+a+"),info"),this._clearTimeout(this._completeZoomTimer),this._clearTimeout(this._TTFFTimer),this._hideSemanticZoomButton(),this._resetPinchDistanceRecords(),!this._locked&&!this._gestureEnding)if(this._zoomInProgress){if(this._gesturing===!d)return;a!==this._zoomingOut&&this._startAnimations(a)}else if(a!==this._zoomedOut){this._zooming=!0,this._aligning=!0,this._gesturing=!!d,b&&(a?this._viewIn:this._viewOut).setCurrentItem(b.x,b.y),this._zoomInProgress=!0,(a?this._opticalViewportOut:this._opticalViewportIn).style.visibility="visible",a&&c.isPhone&&(this._canvasOut.style.opacity=1);var h=this._viewIn.beginZoom(),i=this._viewOut.beginZoom(),j=null;if((h||i)&&c.isPhone&&(j=k.join([h,i])),e&&!f){var l=this;(a?this._viewIn:this._viewOut).getCurrentItem().then(function(b){var c=b.position;l._prepareForZoom(a,{x:l._rtl()?l._sezoClientWidth-c.left-.5*c.width:c.left+.5*c.width,y:c.top+.5*c.height},k.wrap(b),j)})}else this._prepareForZoom(a,b||{},null,j,f)}},_prepareForZoom:function(b,c,d,e,f){function h(a,b){i._canvasIn.style[z["transform-origin"].scriptName]=i._canvasLeftIn+j-a.x+"px "+(i._canvasTopIn+k-a.y)+"px",i._canvasOut.style[z["transform-origin"].scriptName]=i._canvasLeftOut+j-b.x+"px "+(i._canvasTopOut+k-b.y)+"px"}g("WinJS.UI.SemanticZoom:prepareForZoom,StartTM");var i=this,j=c.x,k=c.y;"number"==typeof j&&this._pansHorizontallyIn&&this._pansHorizontallyOut||(j=.5*this._sezoClientWidth),"number"==typeof k&&this._pansVerticallyIn&&this._pansVerticallyOut||(k=.5*this._sezoClientHeight),h(gb,gb),f?this._aligning=!1:this._alignViewsPromise=this._alignViews(b,j,k,d).then(function(){i._aligning=!1,i._gestureEnding=!1,i._alignViewsPromise=null,i._zooming||i._gesturing||i._completeZoom()}),this._zoomingOut=b,a.getComputedStyle(this._canvasIn).opacity,a.getComputedStyle(this._canvasOut).opacity,g("WinJS.UI.SemanticZoom:prepareForZoom,StopTM"),this._startAnimations(b,e)},_alignViews:function(a,b,c,d){var e=1-this._zoomFactor,f=this._rtl(),g=e*(f?this._viewportWidth-b:b),h=e*c,i=this;if(a){var j=d||this._viewIn.getCurrentItem();if(j)return j.then(function(a){var b=a.position,c={left:b.left*i._zoomFactor+g,top:b.top*i._zoomFactor+h,width:b.width*i._zoomFactor,height:b.height*i._zoomFactor};return i._viewOut.positionItem(i._zoomedOutItem(a.item),c)})}else{var l=d||this._viewOut.getCurrentItem();if(l)return l.then(function(a){var b=a.position,c={left:(b.left-g)/i._zoomFactor,top:(b.top-h)/i._zoomFactor,width:b.width/i._zoomFactor,height:b.height/i._zoomFactor};return i._viewIn.positionItem(i._zoomedInItem(a.item),c)})}return new k(function(a){a({x:0,y:0})})},_startAnimations:function(a,b){this._zoomingOut=a;var d=c.isPhone;if(i.isAnimationEnabled()&&!d&&(g("WinJS.UI.SemanticZoom:ZoomAnimation,StartTM"),this._canvasIn.style[Y]=a?r():s(),this._canvasOut.style[Y]=a?s():r()),d||(w(this._canvasIn,a?this._zoomFactor:1),w(this._canvasOut,a?1:1/this._zoomFactor)),this._canvasIn.style.opacity=a&&!d?0:1,(!d||a)&&(this._canvasOut.style.opacity=a?1:0),i.isAnimationEnabled())if(b){var e=this,f=function(){e._canvasIn.style[X.scriptName]="",e._canvasOut.style[X.scriptName]="",e._onZoomAnimationComplete()};b.then(f,f)}else this.setTimeoutAfterTTFF(this._onZoomAnimationComplete.bind(this),i._animationTimeAdjustment(S));else this._zooming=!1,this._canvasIn.style[X.scriptName]="",this._canvasOut.style[X.scriptName]="",this._completeZoom()},_onBounceAnimationComplete:function(){this._isBouncingIn||this._disposed||this._completeZoom()},_onZoomAnimationComplete:function(){g("WinJS.UI.SemanticZoom:ZoomAnimation,StopTM"),this._disposed||(this._zooming=!1,this._aligning||this._gesturing||this._gestureEnding||this._completeZoom())},_onCanvasTransitionEnd:function(a){return this._disposed?void 0:a.target!==this._canvasOut&&a.target!==this._canvasIn||!this._isBouncing?void(a.target===this._canvasIn&&a.propertyName===X.cssName&&this._onZoomAnimationComplete()):void this._onBounceAnimationComplete()},_clearTimeout:function(b){b&&a.clearTimeout(b)},_completePointerUp:function(a,b){if(!this._disposed){var c=a.pointerId,d=this._pointerRecords[c];if(d&&(this._deletePointerRecord(c),this._isBouncingIn&&this._playBounce(!1),b&&this._pinchedDirection!==cb.none&&a.stopImmediatePropagation(),0===this._pointerCount)){if(1===this._pinchGesture&&!this._zooming&&this._lastPinchDirection!==cb.none&&this._pinchDistanceCount<Z)return this._zoom(this._lastPinchDirection===cb.zoomedOut,this._currentMidPoint,!1),this._pinchGesture=0,void this._attemptRecordReset();this._pinchedDirection!==cb.none&&(this._gesturing=!1,this._aligning||this._zooming||this._completeZoom()),this._pinchGesture=0,this._attemptRecordReset()}}},setTimeoutAfterTTFF:function(b,c){var d=this;d._TTFFTimer=a.setTimeout(function(){this._disposed||(d._TTFFTimer=a.setTimeout(b,c))},T)},_completeZoomingIfTimeout:function(){if(0===this._pointerCount){var b=this;(this._zoomInProgress||this._isBouncing)&&(b._completeZoomTimer=a.setTimeout(function(){b._completeZoom()},i._animationTimeAdjustment(ab)))}},_completeZoom:function(){if(!this._disposed){if(this._isBouncing)return this._zoomedOut?this._viewOut.endZoom(!0):this._viewIn.endZoom(!0),void(this._isBouncing=!1);if(this._zoomInProgress){g("WinJS.UI.SemanticZoom:CompleteZoom,info"),this._aligning=!1,this._alignViewsPromise&&this._alignViewsPromise.cancel(),this._clearTimeout(this._completeZoomTimer),this._clearTimeout(this._TTFFTimer),this._gestureEnding=!1,this[this._zoomingOut?"_opticalViewportOut":"_opticalViewportIn"].msContentZoomFactor=1,this._viewIn.endZoom(!this._zoomingOut),this._viewOut.endZoom(this._zoomingOut),this._canvasIn.style.opacity=this._zoomingOut&&!c.isPhone?0:1,this._canvasOut.style.opacity=this._zoomingOut?1:0,this._zoomInProgress=!1;var b=!1;if(this._zoomingOut!==this._zoomedOut&&(this._zoomedOut=!!this._zoomingOut,this._element.setAttribute("aria-checked",this._zoomedOut.toString()),b=!0),this._setVisibility(),b){var d=a.document.createEvent("CustomEvent");d.initCustomEvent(I,!0,!0,this._zoomedOut),this._element.dispatchEvent(d),this._isActive&&n._setActive(this._zoomedOut?this._elementOut:this._elementIn)}g("WinJS.UI.SemanticZoom:CompleteZoom_Custom,info")}}},_isActive:function(){var b=a.document.activeElement;return this._element===b||this._element.contains(b)},_setLayout:function(a,b,c){var d=a.style;d.position=b,d.overflow=c},_setupOpticalViewport:function(a){a.style["-ms-overflow-style"]="none",c.isPhone||(a.style["-ms-content-zooming"]="zoom",a.style["-ms-content-zoom-limit-min"]="99%",a.style["-ms-content-zoom-limit-max"]="101%",a.style["-ms-content-zoom-snap-points"]="snapList(100%)",a.style["-ms-content-zoom-snap-type"]="mandatory")},_setVisibility:function(){function a(a,b){a.style.visibility=b?"visible":"hidden",a.style.zIndex=b?"1":"0"}a(this._opticalViewportIn,!this._zoomedOut||c.isPhone),a(this._opticalViewportOut,this._zoomedOut),this._opticalViewportIn.setAttribute("aria-hidden",!!this._zoomedOut),this._opticalViewportOut.setAttribute("aria-hidden",!this._zoomedOut)},_resetPointerRecords:function(){this._pinchedDirection=cb.none,this._pointerCount=0,this._pointerRecords={},this._resetPinchDistanceRecords()},_releasePointerCapture:function(a){var b=a.pointerId;try{n._releasePointerCapture(this._hiddenElement,b)}catch(c){}},_attemptRecordReset:function(){this._recordResetPromise&&this._recordResetPromise.cancel();var a=this;this._recordResetPromise=k.timeout(bb).then(function(){0===a._pointerCount&&(a._resetPointerRecords(),a._recordResetPromise=null)})},_resetPinchDistanceRecords:function(){this._lastPinchDirection=cb.none,this._lastPinchDistance=-1,this._lastLastPinchDistance=-1,this._pinchDistanceCount=0,this._currentMidPoint=null},_getPointerLocation:function(b){var c={left:0,top:0};try{c=this._element.getBoundingClientRect()}catch(d){}var e=a.getComputedStyle(this._element,null),f=v(this._element,e.paddingLeft),g=v(this._element,e.paddingTop),h=v(this._element,e.borderLeftWidth);return{x:+b.clientX===b.clientX?b.clientX-c.left-f-h:0,y:+b.clientY===b.clientY?b.clientY-c.top-g-g:0}},_playBounce:function(a,b){if(i.isAnimationEnabled()&&this._isBouncingIn!==a){this._clearTimeout(this._completeZoomTimer),this._clearTimeout(this._TTFFTimer),this._isBouncing=!0,this._isBouncingIn=a,a?this._bounceCenter=b:this._aligned=!0;var c=this._zoomedOut?this._canvasOut:this._canvasIn,d=this._zoomedOut?this._canvasLeftOut:this._canvasLeftIn,e=this._zoomedOut?this._canvasTopOut:this._canvasTopIn;c.style[z["transform-origin"].scriptName]=d+this._bounceCenter.x+"px "+(e+this._bounceCenter.y)+"px",c.style[Y]=a?t():u(),this._zoomedOut?this._viewOut.beginZoom():this._viewIn.beginZoom();var f=a?this._zoomedOut?2-J:J:1;w(c,f),this.setTimeoutAfterTTFF(this._onBounceAnimationComplete.bind(this),i._animationTimeAdjustment(S))}},_rtl:function(){return"rtl"===a.getComputedStyle(this._element,null).direction},_pinching:{set:function(a){this._viewIn.pinching=a,this._viewOut.pinching=a}}});return b.Class.mix(hb,e.createEventProperties("zoomchanged")),b.Class.mix(hb,l.DOMEventMixin),hb})})}),d("WinJS/Controls/Pivot/_Constants",[],function(){"use strict";var a={_ClassName:{pivot:"win-pivot",pivotLocked:"win-pivot-locked",pivotTitle:"win-pivot-title",pivotHeaders:"win-pivot-headers",pivotHeader:"win-pivot-header",pivotHeaderSelected:"win-pivot-header-selected",pivotViewport:"win-pivot-viewport",pivotSurface:"win-pivot-surface",pivotNoSnap:"win-pivot-nosnap",pivotNavButton:"win-pivot-navbutton",pivotNavButtonPrev:"win-pivot-navbutton-prev",pivotNavButtonNext:"win-pivot-navbutton-next",pivotShowNavButtons:"win-pivot-shownavbuttons",pivotInputTypeMouse:"win-pivot-mouse",pivotInputTypeTouch:"win-pivot-touch"}};return a}),d("WinJS/Controls/Pivot/_Item",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Resources","../../ControlProcessor","../../Promise","../../Scheduler","../../Utilities/_Control","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","./_Constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{PivotItem:c.Namespace._lazy(function(){var a={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"}},f=c.Class.define(function(c,d){if(c=c||b.document.createElement("DIV"),d=d||{},c.winControl)throw new e("WinJS.UI.PivotItem.DuplicateConstruction",a.duplicateConstruction);c.winControl=this,this._element=c,l.addClass(this.element,f._ClassName.pivotItem),l.addClass(this.element,"win-disposable"),this._element.setAttribute("role","tabpanel"),this._contentElement=b.document.createElement("DIV"),this._contentElement.className=f._ClassName.pivotItemContent,c.appendChild(this._contentElement);for(var h=this.element.firstChild;h!==this._contentElement;){var i=h.nextSibling;this._contentElement.appendChild(h),h=i}this._processors=[g.processAll],j.setOptions(this,d)},{element:{get:function(){return this._element}},contentElement:{get:function(){return this._contentElement}},header:{get:function(){return this._header},set:function(a){this._header=a,this._parentPivot&&this._parentPivot._renderHeaders()}},_parentPivot:{get:function(){for(var a=this._element;a&&!l.hasClass(a,m._ClassName.pivot);)a=a.parentNode;return a&&a.winControl}},_process:function(){var a=this;return this._processors&&this._processors.push(function(){return i.schedulePromiseAboveNormal()}),this._processed=(this._processors||[]).reduce(function(b,c){return b.then(function(){return c(a.contentElement)})},this._processed||h.as()),this._processors=null,this._processed},dispose:function(){this._disposed||(this._disposed=!0,this._processors=null,k.disposeSubTree(this.contentElement))}},{_ClassName:{pivotItem:"win-pivot-item",pivotItemContent:"win-pivot-item-content"},isDeclarativeControlContainer:d.markSupportedForProcessing(function(a,b){b!==g.processAll&&(a._processors=a._processors||[],a._processors.push(b),a._processed&&a._process())})});return f})})}),d("WinJS/Controls/Pivot",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Animations/_TransitionAnimation","../BindingList","../ControlProcessor","../Promise","../Scheduler","../_Signal","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_TabContainer","../Utilities/_KeyboardBehavior","./Pivot/_Constants","./Pivot/_Item","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){"use strict";b.Namespace.define("WinJS.UI",{Pivot:b.Namespace._lazy(function(){function s(b){var c=a.document.createTextNode("object"==typeof b.header?JSON.stringify(b.header):""+b.header);return c}var w=r._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",x=r._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",y=r.Key,z=e._createEventProperty,A={selectionChanged:"selectionchanged",itemAnimationStart:"itemanimationstart",itemAnimationEnd:"itemanimationend"},B=r._MSManipulationEvent,C=!(!r._supportsSnapPoints||!a.HTMLElement.prototype.msZoomTo),D=b.Class.define(function(b,e){if(b=b||a.document.createElement("DIV"),e=e||{},b.winControl)throw new d("WinJS.UI.Pivot.DuplicateConstruction",E.duplicateConstruction);this._handleItemChangedBound=this._handleItemChanged.bind(this),this._handleItemInsertedBound=this._handleItemInserted.bind(this),this._handleItemMovedBound=this._handleItemMoved.bind(this),this._handleItemRemovedBound=this._handleItemRemoved.bind(this),this._handleItemReloadBound=this._handleItemReload.bind(this),this._id=b.id||r._uniqueID(b),this._writeProfilerMark("constructor,StartTM"),b.winControl=this,this._element=b,this._element.setAttribute("role","tablist"),this._element.getAttribute("aria-label")||this._element.setAttribute("aria-label",E.pivotAriaLabel),C||r.addClass(this.element,D._ClassName.pivotNoSnap),r.addClass(this.element,D._ClassName.pivot),r.addClass(this.element,"win-disposable"),r._addEventListener(this.element,"pointerenter",this._updatePointerType.bind(this)),r._addEventListener(this.element,"pointerout",this._updatePointerType.bind(this)),this._pointerType=w,this._titleElement=a.document.createElement("DIV"),this._titleElement.style.display="none",r.addClass(this._titleElement,D._ClassName.pivotTitle),this._element.appendChild(this._titleElement),this._headersContainerElement=a.document.createElement("DIV"),r.addClass(this._headersContainerElement,D._ClassName.pivotHeaders),this._headersContainerElement.addEventListener("keydown",this._headersKeyDown.bind(this)),this._element.appendChild(this._headersContainerElement),this._element.addEventListener("click",this._elementClickedHandler.bind(this)),r._addEventListener(this._headersContainerElement,"pointerenter",this._showNavButtons.bind(this)),r._addEventListener(this._headersContainerElement,"pointerout",this._hideNavButtons.bind(this)),r._addEventListener(this._headersContainerElement,"pointerdown",this._headersPointerDownHandler.bind(this)),r._addEventListener(this._headersContainerElement,"pointerup",this._headersPointerUpHandler.bind(this)),this._winKeyboard=new u._WinKeyboard(this._headersContainerElement),this._tabContainer=new t.TabContainer(this._headersContainerElement),this._viewportElement=a.document.createElement("DIV"),this._viewportElement.className=D._ClassName.pivotViewport,this._element.appendChild(this._viewportElement),this._viewportElement.setAttribute("role","group"),this._viewportElement.setAttribute("aria-label",E.pivotViewportAriaLabel),this._resizeHandlerBound=this._resizeHandler.bind(this),this.element.addEventListener("mselementresize",this._resizeHandlerBound),r._resizeNotifier.subscribe(this.element,this._resizeHandlerBound),this._viewportWidth=null,this._viewportElement.addEventListener("scroll",this._scrollHandler.bind(this)),this._viewportElement.addEventListener("MSManipulationStateChanged",this._MSManipulationStateChangedHandler.bind(this)),r._addEventListener(this._viewportElement,"pointerdown",this._pointerDownHandler.bind(this)),this._surfaceElement=a.document.createElement("DIV"),this._surfaceElement.className=D._ClassName.pivotSurface,this._viewportElement.appendChild(this._surfaceElement),this._offsetFromCenter=0,this._currentIndexOnScreen=0,this._loadId=0,this._navMode=D._NavigationModes.none,this._currentManipulationState=B.MS_MANIPULATION_STATE_STOPPED,this._parse(),e=c._shallowCopy(e),e.items&&(this.items=e.items,delete e.items),p.setOptions(this,e),this._refresh(),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},locked:{get:function(){return r.hasClass(this.element,D._ClassName.pivotLocked)},set:function(a){r[a?"addClass":"removeClass"](this.element,D._ClassName.pivotLocked),a&&this._hideNavButtons()}},items:{get:function(){return this._pendingItems?this._pendingItems:this._items},set:function(a){var b=!this._pendingItems;this._pendingItems=a,this._refresh(),b&&(this._pendingIndexOnScreen=0)}},title:{get:function(){return this._titleElement.textContent},set:function(a){a?(this._titleElement.style.display="block",this._titleElement.textContent=a):(this._titleElement.style.display="none",this._titleElement.textContent="")}},selectedIndex:{get:function(){return 0===this.items.length?-1:+this._pendingIndexOnScreen===this._pendingIndexOnScreen?this._pendingIndexOnScreen:this._currentIndexOnScreen},set:function(a){a>=0&&a<this.items.length&&(this._pendingRefresh?this._pendingIndexOnScreen=a:(this._navMode=this._navMode||D._NavigationModes.api,this._loadItem(a)))}},selectedItem:{get:function(){return this.items.getAt(this.selectedIndex)},set:function(a){var b=this.items.indexOf(a);-1!==b&&(this.selectedIndex=b)}},dispose:function(){if(!this._disposed){this._disposed=!0,this._updateEvents(this._items),r._resizeNotifier.unsubscribe(this.element,this._resizeHandlerBound),q._disposeElement(this._headersContainerElement);for(var a=0,b=this.items.length;b>a;a++)this.items.getAt(a).dispose()}},onselectionchanged:z(A.selectionChanged),onitemanimationstart:z(A.itemAnimationStart),onitemanimationend:z(A.itemAnimationEnd),_currentScrollTargetLocation:{get:function(){return this._viewportWidth===D._invalidViewportWidth?0:(50+this._offsetFromCenter)*Math.ceil(this._viewportWidth)}},_pointerType:{get:function(){return this._pointerTypeValue},set:function(a){this._pointerTypeValue!==a&&(this._pointerTypeValue=a,a===x?(r.removeClass(this.element,D._ClassName.pivotInputTypeMouse),r.addClass(this.element,D._ClassName.pivotInputTypeTouch),this._hideNavButtons()):(r.removeClass(this.element,D._ClassName.pivotInputTypeTouch),r.addClass(this.element,D._ClassName.pivotInputTypeMouse)))}},_rtl:{get:function(){return this._cachedRTL}},_viewportWidth:{get:function(){return this._viewportElWidth||(this._viewportElWidth=parseFloat(a.getComputedStyle(this._viewportElement).width),C&&(this._viewportElement.style[c._browserStyleEquivalents["scroll-snap-points-x"].scriptName]="snapInterval(0%, "+Math.ceil(this._viewportElWidth)+"px)")),this._viewportElWidth||D._invalidViewportWidth},set:function(a){this._viewportElWidth=a}},_applyProperties:function(){if(!this._disposed){if(this._pendingItems){for(this._updateEvents(this._items,this._pendingItems),this._items=this._pendingItems,this._pendingItems=null;this.element.firstElementChild!==this._titleElement;){var a=this.element.firstElementChild;a.parentNode.removeChild(a)}r.empty(this._surfaceElement)}this._attachItems();var b=this._pendingIndexOnScreen;
  this._pendingIndexOnScreen=null,this._currentIndexOnScreen=0,this._skipHeaderSlide=!0,this._pendingRefresh=!1,this.selectedIndex=Math.min(b,this.items.length-1),this._skipHeaderSlide=!1,this._recenterUI()}},_attachItems:function(){this._measured=!1;for(var a=0,b=this.items.length;b>a;a++){var c=this._items.getAt(a);if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Pivot.DuplicateItem",E.duplicateItem);c.element.style.visibility="hidden",c.element.style.opacity=0,this._surfaceElement.appendChild(c.element)}},_parse:function(){for(var a=[],b=this.element.firstElementChild;b!==this._titleElement;){l.processAll(b);var c=b.winControl;if(!c)throw new d("WinJS.UI.Pivot.InvalidContent",E.invalidContent);a.push(c);var e=b.nextElementSibling;b=e}this.items=new k.List(a)},_refresh:function(){this._pendingRefresh||(this._pendingRefresh=!0,n.schedule(this._applyProperties.bind(this),n.Priority.high))},_renderHeaders:function(b){function d(b){function c(){l._disposed||l._headersContainerElement.contains(e)&&b!==l.selectedIndex&&"true"===e.getAttribute("aria-selected")&&(l.selectedIndex=b)}var d=l._items.getAt(b),e=a.document.createElement("BUTTON");e.style.maxWidth=.8*k+"px",b===l.selectedIndex?(r.addClass(e,D._ClassName.pivotHeaderSelected),e.setAttribute("aria-selected",!0)):e.setAttribute("aria-selected",!1),r.addClass(e,D._ClassName.pivotHeader),e._item=d,f(d,e),e.setAttribute("role","tab"),l._headersContainerElement.appendChild(e),new r._MutationObserver(c).observe(e,{attributes:!0,attributeFilter:["aria-selected"]})}if(!this._pendingRefresh&&this._items){var e=this._headersContainerElement.contains(a.document.activeElement),f=r._syncRenderer(s);q._disposeElement(this._headersContainerElement),r.empty(this._headersContainerElement);var g=a.getComputedStyle(this._headersContainerElement),h=parseFloat(g.marginLeft);h=h>0?0:h;var i=parseFloat(g.marginRight);i=i>0?0:i;var k=parseFloat(g.width)+h+i,l=this;if(1===this._items.length)d(0),this._viewportElement.style.overflow="hidden",this._headersContainerElement.style.marginLeft="0px",this._headersContainerElement.style.marginRight="0px";else if(this._items.length>1){var m=this._items.length+(b?2:1),n=this.selectedIndex-1;this._viewportElement.style.overflow&&(this._viewportElement.style.overflow="");for(var o=0;m>o;o++)-1===n?n=this._items.length-1:n===this._items.length&&(n=0),d(n),n++;if(!this._skipHeaderSlide){var p,t;b?(p="",t="0"):(p="0",t="");var u=this._headersContainerElement.children[m-1];u.style.opacity=p;var v=.167;u.style[c._browserStyleEquivalents.transition.scriptName]="opacity "+j._animationTimeAdjustment(v)+"s",a.getComputedStyle(u).opacity,u.style.opacity=t}this._headersContainerElement.children[0].setAttribute("aria-hidden","true"),this._headersContainerElement.style.marginLeft="0px",this._headersContainerElement.style.marginRight="0px";var w=this._rtl?"marginRight":"marginLeft",x=this._rtl?"paddingLeft":"paddingRight",y=this._headersContainerElement.children[0],z=y.offsetWidth+parseFloat(a.getComputedStyle(y)[w])-parseFloat(a.getComputedStyle(y)[x]);if(y!==this._headersContainerElement.children[0])return;this._headersContainerElement.style[w]=-1*z+"px",this._prevButton=a.document.createElement("button"),r.addClass(this._prevButton,D._ClassName.pivotNavButton),r.addClass(this._prevButton,D._ClassName.pivotNavButtonPrev),this._prevButton.addEventListener("click",function(){l.locked||(l._rtl?l._goNext():l._goPrevious())}),this._headersContainerElement.appendChild(this._prevButton),this._prevButton.style.left=this._rtl?"0px":z+"px",this._nextButton=a.document.createElement("button"),r.addClass(this._nextButton,D._ClassName.pivotNavButton),r.addClass(this._nextButton,D._ClassName.pivotNavButtonNext),this._nextButton.addEventListener("click",function(){l.locked||(l._rtl?l._goPrevious():l._goNext())}),this._headersContainerElement.appendChild(this._nextButton),this._nextButton.style.right=this._rtl?z+"px":"0px"}var A=this._headersContainerElement.children.length>1?1:0;this._tabContainer.childFocus=this._headersContainerElement.children[A],e&&this._headersContainerElement.children[A].focus()}},_resizeHandler:function(){if(!this._disposed){var a=this._viewportWidth;this._viewportWidth=null,a!==this._viewportWidth?(f.log&&f.log("_resizeHandler from:"+a+" to: "+this._viewportWidth),this._hidePivotItemAnimation&&this._hidePivotItemAnimation.cancel(),this._showPivotItemAnimation&&this._showPivotItemAnimation.cancel(),this._slideHeadersAnimation&&this._slideHeadersAnimation.cancel(),this._recenterUI(),this._renderHeaders()):f.log&&f.log("_resizeHandler worthless resize")}},_activateHeader:function(a){if(!this.locked){var b=this._items.indexOf(a._item);if(b!==this.selectedIndex){if(!a.previousSibling)return;this.selectedIndex=b}else r._setActiveFirstFocusableElement(this.selectedItem.element)}},_goNext:function(){this.selectedIndex<this._items.length-1?this.selectedIndex++:this.selectedIndex=0},_goPrevious:function(){this._animateToPrevious=!0,this.selectedIndex>0?this.selectedIndex--:this.selectedIndex=this._items.length-1,this._animateToPrevious=!1},_loadItem:function(b){var c=this._animateToPrevious;this._cachedRTL="rtl"===a.getComputedStyle(this._element,null).direction,this._loadId++;var d=this._loadId;this._hidePivotItemAnimation&&this._hidePivotItemAnimation.cancel(),this._showPivotItemAnimation&&this._showPivotItemAnimation.cancel(),this._slideHeadersAnimation&&this._slideHeadersAnimation.cancel(),this._currentItem&&this._hidePivotItem(this._currentItem.element,c);var e=this._currentIndexOnScreen;if(this._currentIndexOnScreen=b,this._slideHeaders(c,b,e),!(0>b)){var g=this._items.getAt(b);this._currentItem=g,c?this._offsetFromCenter--:b!==e&&this._offsetFromCenter++;var h=!1;C&&this._currentManipulationState!==B.MS_MANIPULATION_STATE_INERTIA&&(this._skipHeaderSlide?(f.log&&f.log("_skipHeaderSlide index:"+this.selectedIndex+" offset: "+this._offsetFromCenter+" scrollLeft: "+this._currentScrollTargetLocation,"winjs pivot","log"),r.setScrollPosition(this._viewportElement,{scrollLeft:this._currentScrollTargetLocation})):(f.log&&f.log("zoomTo index:"+this.selectedIndex+" offset: "+this._offsetFromCenter+" scrollLeft: "+this._currentScrollTargetLocation,"winjs pivot","log"),this._viewportElement.msZoomTo({contentX:this._currentScrollTargetLocation,contentY:0,viewportX:0,viewportY:0}),h=0!==this._offsetFromCenter&&this.items.length>1));var i=this,j={index:b,direction:c?"backwards":"forward",item:g};this._writeProfilerMark("selectionChanged,info"),this._fireEvent(D._EventName.selectionChanged,!0,!1,j),g._process().then(function(){if(!i._disposed&&d===i._loadId){C?(g.element.style[i._getDirectionAccessor()]=i._currentScrollTargetLocation+"px",i._showPivotItem(g.element,c)):i._hidePivotItemAnimation?i._showPivotItemAnimation=i._hidePivotItemAnimation.then(function(){return i._disposed||d!==i._loadId?void 0:i._showPivotItem(g.element,c)}):i._showPivotItem(g.element,c);var a;h?(i._stoppedAndRecenteredSignal||(i._stoppedAndRecenteredSignal=new o),a=i._stoppedAndRecenteredSignal.promise):a=m.wrap(),m.join([i._slideHeadersAnimation,i._showPivotItemAnimation,i._hidePivotItemAnimation]).then(function(){a.then(function(){m.timeout(50).then(function(){i._disposed||d!==i._loadId||(i._navMode=D._NavigationModes.none,i._writeProfilerMark("itemAnimationStop,info"),i._fireEvent(D._EventName.itemAnimationEnd,!0))})})})}})}},_MSManipulationStateChangedHandler:function(a){if(this._currentManipulationState=a.currentState,C&&a.target===this._viewportElement)if(this._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED?f.log&&f.log("MSManipulation: Stopped","winjs pivot","log"):this._currentManipulationState===B.MS_MANIPULATION_STATE_INERTIA?f.log&&f.log("MSManipulation: Inertia","winjs pivot","log"):f.log&&f.log("MSManipulation: Active","winjs pivot","log"),this._stoppedAndRecenteredSignal||(this._stoppedAndRecenteredSignal=new o),this._manipulationRecenterPromise&&this._manipulationRecenterPromise.cancel(),this._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED){this._navMode===D._NavigationModes.scroll&&this._scrollHandler(),this._navMode=D._NavigationModes.none;var b=this;this._manipulationRecenterPromise=m._cancelBlocker(m.join([n.schedulePromiseNormal(null,"WinJS.UI.Pivot._MSManipulationStateChangedHandler_animationPlaceholder"),this._hidePivotItemAnimation,this._showPivotItemAnimation,this._slideHeadersAnimation])).then(function(){b._disposed||(b._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED?(f.log&&f.log("Still in Stopped state: calling _recenterUI","winjs pivot","log"),b._recenterUI()):(this._stoppedAndRecenteredSignal.complete(),this._stoppedAndRecenteredSignal=null))})}else if(this._currentManipulationState===B.MS_MANIPULATION_STATE_INERTIA){var c=a.inertiaDestinationX;if(+c===c){f.log&&f.log("MSManipulation: inertiaDestinationX: "+c);var d=c-this._currentScrollTargetLocation;d>0?(f.log&&f.log("MSManipulation: Inertia diff > 1","winjs pivot","log"),this._navMode=D._NavigationModes.inertia,this._goNext()):0>d&&(f.log&&f.log("MSManipulation: Stopped diff < -1","winjs pivot","log"),this._navMode=D._NavigationModes.inertia,this._goPrevious())}}},_scrollHandler:function(){if(C&&!this._disposed){if(this._recentering&&this._stoppedAndRecenteredSignal)return this._stoppedAndRecenteredSignal.complete(),this._stoppedAndRecenteredSignal=null,void(this._recentering=!1);if((this._navMode===D._NavigationModes.none||this._navMode===D._NavigationModes.scroll)&&(this._navMode=D._NavigationModes.scroll,this._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED)){f.log&&f.log("_scrollHandler ScrollPosition: "+r.getScrollPosition(this._viewportElement).scrollLeft,"winjs pivot","log");var b=r.getScrollPosition(this._viewportElement).scrollLeft-this._currentScrollTargetLocation;this._cachedRTL="rtl"===a.getComputedStyle(this._element,null).direction,b>0?(f.log&&f.log("_scrollHandler diff > 1: "+b,"winjs pivot","log"),this._goNext()):0>b&&(f.log&&f.log("_scrollHandler diff < -1: "+b,"winjs pivot","log"),this._goPrevious())}}},_recenterUI:function(){C&&(this._offsetFromCenter=0,r.getScrollPosition(this._viewportElement).scrollLeft!==this._currentScrollTargetLocation?(this._recentering=!0,this._stoppedAndRecenteredSignal=this._stoppedAndRecenteredSignal||new o):this._stoppedAndRecenteredSignal&&(this._stoppedAndRecenteredSignal.complete(),this._stoppedAndRecenteredSignal=null),this.selectedItem&&(this.selectedItem.element.style[this._getDirectionAccessor()]=this._currentScrollTargetLocation+"px"),f.log&&f.log("_recenterUI index:"+this.selectedIndex+" offset: "+this._offsetFromCenter+" scrollLeft: "+this._currentScrollTargetLocation),r.setScrollPosition(this._viewportElement,{scrollLeft:this._currentScrollTargetLocation}))},_hidePivotItem:function(a,b){function c(){d._disposed||(d._hidePivotItemAnimation=null,a.style.visibility="hidden",a.style.opacity=0)}var d=this,e=this._rtl&&!b||b&&!this._rtl;this._hidePivotItemAnimation=j.isAnimationEnabled()?i[e?"slideRightOut":"slideLeftOut"](a):n.schedulePromiseNormal(null,"WinJS.UI.Pivot._hidePivotItem_animationPlaceholder"),this._hidePivotItemAnimation.then(c,c)},_showPivotItem:function(a,b){function c(a){var b=a.getBoundingClientRect();return b.top<h.bottom&&b.bottom>h.top}function d(){l._disposed||(l._showPivotItemAnimation=null)}if(this._writeProfilerMark("itemAnimationStart,info"),this._fireEvent(D._EventName.itemAnimationStart,!0),!j.isAnimationEnabled())return a.style.visibility="",a.style.opacity="",void(this._showPivotItemAnimation=null);var e=a.querySelectorAll(".win-pivot-slide1"),f=a.querySelectorAll(".win-pivot-slide2"),g=a.querySelectorAll(".win-pivot-slide3"),h=this._viewportElement.getBoundingClientRect();e=Array.prototype.filter.call(e,c),f=Array.prototype.filter.call(f,c),g=Array.prototype.filter.call(g,c);var k=this._rtl&&!b||b&&!this._rtl;a.style.visibility="",this._showPivotItemAnimation=i[k?"slideRightIn":"slideLeftIn"](a,e,f,g);var l=this;return this._showPivotItemAnimation.then(d,d),this._showPivotItemAnimation},_slideHeaders:function(a,b,d){function e(a){return h?a.offsetParent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft}function f(){l._disposed||(l._renderHeaders(a),l._slideHeadersAnimation=null)}if(0>b||this._skipHeaderSlide)return void this._renderHeaders(a);var g;if(a?g=this._headersContainerElement.children[0]:(d>b&&(b+=this._items.length),g=this._headersContainerElement.children[1+b-d]),!g)return void this._renderHeaders(a);r.removeClass(this._headersContainerElement.children[1],D._ClassName.pivotHeaderSelected),r.addClass(g,D._ClassName.pivotHeaderSelected);var h=this._rtl,i=e(this._headersContainerElement.children[1])-e(g);h&&(i*=-1);var k,l=this;k=j.isAnimationEnabled()?j.executeTransition(this._headersContainerElement.querySelectorAll("."+D._ClassName.pivotHeader),{property:c._browserStyleEquivalents.transform.cssName,delay:0,duration:D._headerSlideAnimationDuration,timing:"ease-out",to:"translateX("+i+"px)"}):m.wrap(),this._slideHeadersAnimation=k.then(f,f)},_elementClickedHandler:function(a){if(this.locked||this._navigationHandled)return void(this._navigationHandled=!1);var b,c=a.target;if(r.hasClass(c,D._ClassName.pivotHeader))b=c;else{var d=!1,e=r._elementsFromPoint(a.clientX,a.clientY);if(e&&e[0]===this._viewportElement)for(var f=0,g=e.length;g>f;f++)e[f]===c&&(d=!0),r.hasClass(e[f],D._ClassName.pivotHeader)&&(b=e[f]);d||(b=null)}b&&this._activateHeader(b)},_headersKeyDown:function(a){this.locked||(a.keyCode===y.leftArrow||a.keyCode===y.pageUp?this._rtl?this._goNext():this._goPrevious():(a.keyCode===y.rightArrow||a.keyCode===y.pageDown)&&(this._rtl?this._goPrevious():this._goNext()))},_headersPointerDownHandler:function(a){a.preventDefault(),this._headersPointerDownPoint={x:a.clientX,y:a.clientY,type:a.pointerType||"mouse"}},_headersPointerUpHandler:function(a){if(!this._headersPointerDownPoint||this.locked)return void(this._headersPointerDownPoint=null);var b=a.clientX-this._headersPointerDownPoint.x;if(b=this._rtl?-b:b,this._navigationHandled=!1,(!r._supportsTouchDetection||this._headersPointerDownPoint.type===a.pointerType&&a.pointerType===x)&&(b<-D._headerSwipeTriggerDistance?(this._goNext(),this._navigationHandled=!0):b>D._headerSwipeTriggerDistance&&(this._goPrevious(),this._navigationHandled=!0)),!this._navigationHandled){for(var c=a.target;null!==c&&!r.hasClass(c,D._ClassName.pivotHeader);)c=c.parentElement;null!==c&&(this._activateHeader(c),this._navigationHandled=!0)}this._headersPointerDownPoint=null},_hideNavButtons:function(a){a&&this._headersContainerElement.contains(a.relatedTarget)||r.removeClass(this._headersContainerElement,D._ClassName.pivotShowNavButtons)},_pointerDownHandler:function(){f.log&&f.log("_pointerDown","winjs pivot","log"),this._manipulationRecenterPromise&&this._manipulationRecenterPromise.cancel(),this._slideHeadersAnimation&&this._slideHeadersAnimation.cancel(),this._hidePivotItemAnimation&&this._hidePivotItemAnimation.cancel()},_showNavButtons:function(a){this.locked||a&&a.pointerType===x||r.addClass(this._headersContainerElement,D._ClassName.pivotShowNavButtons)},_handleItemChanged:function(a){if(!this._pendingItems){var b=a.detail.index,c=a.detail.newValue,e=a.detail.oldValue;if(c.element!==e.element){if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Pivot.DuplicateItem",E.duplicateItem);c.element.style.visibility="hidden",c.element.style.opacity=0,this._surfaceElement.insertBefore(c.element,e.element),this._surfaceElement.removeChild(e.element),b===this._currentIndexOnScreen&&(this.selectedIndex=this._currentIndexOnScreen)}this._renderHeaders()}},_handleItemInserted:function(a){if(!this._pendingItems){var b=a.detail.index,c=a.detail.value;if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Pivot.DuplicateItem",E.duplicateItem);c.element.style.visibility="hidden",c.element.style.opacity=0,b<this.items.length-1?this._surfaceElement.insertBefore(c.element,this.items.getAt(b+1).element):this._surfaceElement.appendChild(c.element),b<=this._currentIndexOnScreen&&this._currentIndexOnScreen++,1===this._items.length&&(this.selectedIndex=0),this._renderHeaders()}},_handleItemMoved:function(a){if(!this._pendingItems){var b=a.detail.oldIndex,c=a.detail.newIndex,d=a.detail.value;c<this.items.length-1?this._surfaceElement.insertBefore(d.element,this.items.getAt(c+1).element):this._surfaceElement.appendChild(d.element),b<this._currentIndexOnScreen&&c>=this._currentIndexOnScreen?this._currentIndexOnScreen--:c>this._currentIndexOnScreen&&b<=this._currentIndexOnScreen?this._currentIndexOnScreen++:b===this._currentIndexOnScreen&&(this.selectedIndex=c),this._renderHeaders()}},_handleItemReload:function(){this.items=this.items},_handleItemRemoved:function(a){if(!this._pendingItems){var b=a.detail.value,c=a.detail.index;this._surfaceElement.removeChild(b.element),c<this._currentIndexOnScreen?this._currentIndexOnScreen--:c===this._currentIndexOnScreen&&(this.selectedIndex=Math.min(this.items.length-1,this._currentIndexOnScreen)),this._renderHeaders()}},_fireEvent:function(b,c,d,e){var f=a.document.createEvent("CustomEvent");return f.initCustomEvent(b,!!c,!!d,e),this.element.dispatchEvent(f)},_getDirectionAccessor:function(){return this._rtl?"right":"left"},_updateEvents:function(a,b){a&&(a.removeEventListener("itemchanged",this._handleItemChangedBound),a.removeEventListener("iteminserted",this._handleItemInsertedBound),a.removeEventListener("itemmoved",this._handleItemMovedBound),a.removeEventListener("itemremoved",this._handleItemRemovedBound),a.removeEventListener("reload",this._handleItemReloadBound)),b&&(b.addEventListener("itemchanged",this._handleItemChangedBound),b.addEventListener("iteminserted",this._handleItemInsertedBound),b.addEventListener("itemmoved",this._handleItemMovedBound),b.addEventListener("itemremoved",this._handleItemRemovedBound),b.addEventListener("reload",this._handleItemReloadBound))},_updatePointerType:function(a){this._pointerType=a.pointerType||w},_writeProfilerMark:function(a){var b="WinJS.UI.Pivot:"+this._id+":"+a;h(b),f.log&&f.log(b,null,"pivotprofiler")}},{_invalidViewportWidth:-1,_headerSlideAnimationDuration:250,_headerSwipeTriggerDistance:50,_ClassName:v._ClassName,_EventName:{selectionChanged:A.selectionChanged,itemAnimationStart:A.itemAnimationStart,itemAnimationEnd:A.itemAnimationEnd},_NavigationModes:{api:"api",inertia:"inertia",none:"",scroll:"scroll"}});b.Class.mix(D,p.DOMEventMixin);var E={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get duplicateItem(){return g._getWinJSString("ui/duplicateItem").value},get invalidContent(){return"Invalid content: Pivot content must be made up of PivotItems."},get pivotAriaLabel(){return g._getWinJSString("ui/pivotAriaLabel").value},get pivotViewportAriaLabel(){return g._getWinJSString("ui/pivotViewportAriaLabel").value}};return D})})}),d("WinJS/Controls/Hub/_Section",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Resources","../../ControlProcessor","../../Promise","../../Utilities/_Control","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_KeyboardBehavior"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{HubSection:c.Namespace._lazy(function(){var a={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"}},f=c.Class.define(function(c,d){if(c=c||b.document.createElement("DIV"),d=d||{},c.winControl)throw new e("WinJS.UI.HubSection.DuplicateConstruction",a.duplicateConstruction);c.winControl=this,this._element=c,k.addClass(this.element,f._ClassName.hubSection),k.addClass(this.element,"win-disposable"),this._headerElement=b.document.createElement("DIV"),this._headerElement.className=f._ClassName.hubSectionHeader,this._headerElement.innerHTML='<button type="button" role="link" class="'+f._ClassName.hubSectionInteractive+" "+f._ClassName.hubSectionHeaderTabStop+'"><div class="'+f._ClassName.hubSectionHeaderWrapper+'" tabindex="-1"><h2 class="'+f._ClassName.hubSectionHeaderContent+" "+f._Constants.ellipsisTypeClassName+" "+f._Constants.xLargeTypeClassName+'"></h2><span class="'+f._ClassName.hubSectionHeaderChevron+" "+f._Constants.ellipsisTypeClassName+" "+f._Constants.xLargeTypeClassName+'"></span></div></button>',this._headerTabStopElement=this._headerElement.firstElementChild,this._headerWrapperElement=this._headerTabStopElement.firstElementChild,this._headerContentElement=this._headerWrapperElement.firstElementChild,this._headerChevronElement=this._headerWrapperElement.lastElementChild,c.appendChild(this._headerElement),this._winKeyboard=new l._WinKeyboard(this._headerElement),this._contentElement=b.document.createElement("DIV"),this._contentElement.className=f._ClassName.hubSectionContent,this._contentElement.style.visibility="hidden",c.appendChild(this._contentElement);for(var h=this.element.firstChild;h!==this._headerElement;){var j=h.nextSibling;this._contentElement.appendChild(h),h=j}this._processors=[g.processAll],i.setOptions(this,d)},{element:{get:function(){return this._element}},isHeaderStatic:{get:function(){return this._isHeaderStatic},set:function(a){this._isHeaderStatic=a,this._isHeaderStatic?(this._headerTabStopElement.setAttribute("role","heading"),k.removeClass(this._headerTabStopElement,f._ClassName.hubSectionInteractive)):(this._headerTabStopElement.setAttribute("role","link"),k.addClass(this._headerTabStopElement,f._ClassName.hubSectionInteractive))}},contentElement:{get:function(){return this._contentElement}},header:{get:function(){return this._header},set:function(a){this._header=a,this._renderHeader()}},_setHeaderTemplate:function(a){this._template=k._syncRenderer(a),this._renderHeader()},_renderHeader:function(){this._template&&(j._disposeElement(this._headerContentElement),k.empty(this._headerContentElement),this._template(this,this._headerContentElement))},_process:function(){var a=this;return this._processed=(this._processors||[]).reduce(function(b,c){return b.then(function(){return c(a.contentElement)})},this._processed||h.as()),this._processors=null,this._processed},dispose:function(){this._disposed||(this._disposed=!0,this._processors=null,j._disposeElement(this._headerContentElement),j.disposeSubTree(this.contentElement))}},{_ClassName:{hubSection:"win-hub-section",hubSectionHeader:"win-hub-section-header",hubSectionHeaderTabStop:"win-hub-section-header-tabstop",hubSectionHeaderWrapper:"win-hub-section-header-wrapper",hubSectionInteractive:"win-hub-section-header-interactive",hubSectionHeaderContent:"win-hub-section-header-content",hubSectionHeaderChevron:"win-hub-section-header-chevron",hubSectionContent:"win-hub-section-content"},_Constants:{ellipsisTypeClassName:"win-type-ellipsis",xLargeTypeClassName:"win-type-x-large"},isDeclarativeControlContainer:d.markSupportedForProcessing(function(a,b){b!==g.processAll&&(a._processors=a._processors||[],a._processors.push(b),a._processed&&a._process())})});return f})})}),d("WinJS/Controls/Hub",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Animations/_TransitionAnimation","../BindingList","../ControlProcessor","../Promise","../_Signal","../Scheduler","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_UI","./Hub/_Section","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){"use strict";b.Namespace.define("WinJS.UI",{Hub:b.Namespace._lazy(function(){function r(b){var c=a.document.createTextNode("object"==typeof b.header?JSON.stringify(b.header):""+b.header);return c}var u=q.Key,v=e._createEventProperty,w={contentAnimating:"contentanimating",headerInvoked:"headerinvoked",loadingStateChanged:"loadingstatechanged"},x=500,y={scrollPos:"scrollTop",scrollSize:"scrollHeight",offsetPos:"offsetTop",offsetSize:"offsetHeight",oppositeOffsetSize:"offsetWidth",marginStart:"marginTop",marginEnd:"marginBottom",borderStart:"borderTopWidth",borderEnd:"borderBottomWidth",paddingStart:"paddingTop",paddingEnd:"paddingBottom"},z={scrollPos:"scrollLeft",scrollSize:"scrollWidth",offsetPos:"offsetLeft",offsetSize:"offsetWidth",oppositeOffsetSize:"offsetHeight",marginStart:"marginRight",marginEnd:"marginLeft",borderStart:"borderRightWidth",borderEnd:"borderLeftWidth",paddingStart:"paddingRight",paddingEnd:"paddingLeft"},A={scrollPos:"scrollLeft",scrollSize:"scrollWidth",offsetPos:"offsetLeft",offsetSize:"offsetWidth",oppositeOffsetSize:"offsetHeight",marginStart:"marginLeft",marginEnd:"marginRight",borderStart:"borderLeftWidth",borderEnd:"borderRightWidth",paddingStart:"paddingLeft",paddingEnd:"paddingRight"},B=b.Class.define(function(b,c){if(b=b||a.document.createElement("DIV"),c=c||{},b.winControl)throw new d("WinJS.UI.Hub.DuplicateConstruction",D.duplicateConstruction);this._id=b.id||q._uniqueID(b),this._writeProfilerMark("constructor,StartTM"),this._windowKeyDownHandlerBound=this._windowKeyDownHandler.bind(this),a.addEventListener("keydown",this._windowKeyDownHandlerBound),b.winControl=this,this._element=b,q.addClass(this.element,B._ClassName.hub),q.addClass(this.element,"win-disposable"),this._viewportElement=a.document.createElement("DIV"),this._viewportElement.className=B._ClassName.hubViewport,this._element.appendChild(this._viewportElement),this._viewportElement.setAttribute("role","group"),this._viewportElement.setAttribute("aria-label",D.hubViewportAriaLabel),this._surfaceElement=a.document.createElement("DIV"),this._surfaceElement.className=B._ClassName.hubSurface,this._viewportElement.appendChild(this._surfaceElement),this._visible=!1,this._viewportElement.style.opacity=0,c.orientation||(this._orientation=s.Orientation.horizontal,q.addClass(this.element,B._ClassName.hubHorizontal)),this._fireEntrance=!0,this._animateEntrance=!0,this._loadId=0,this.runningAnimations=new m.wrap,this._currentIndexForSezo=0,this._parse(),p.setOptions(this,c),q._addEventListener(this.element,"focusin",this._focusin.bind(this),!1),this.element.addEventListener("keydown",this._keyDownHandler.bind(this)),this.element.addEventListener("click",this._clickHandler.bind(this)),this._resizeHandlerBound=this._resizeHandler.bind(this),this.element.addEventListener("mselementresize",this._resizeHandlerBound),q._resizeNotifier.subscribe(this.element,this._resizeHandlerBound),this._viewportElement.addEventListener("scroll",this._scrollHandler.bind(this)),this._surfaceElement.addEventListener("mselementresize",this._contentResizeHandler.bind(this)),this._handleSectionChangedBind=this._handleSectionChanged.bind(this),this._handleSectionInsertedBind=this._handleSectionInserted.bind(this),this._handleSectionMovedBind=this._handleSectionMoved.bind(this),this._handleSectionRemovedBind=this._handleSectionRemoved.bind(this),this._handleSectionReloadBind=this._handleSectionReload.bind(this),this._refresh(),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},orientation:{get:function(){return this._orientation},set:function(a){if(a!==this._orientation){if(this._measured=!1,this._names){var b={};b[this._names.scrollPos]=0,q.setScrollPosition(this._viewportElement,b)}a===s.Orientation.vertical?(q.removeClass(this.element,B._ClassName.hubHorizontal),q.addClass(this.element,B._ClassName.hubVertical)):(a=s.Orientation.horizontal,q.removeClass(this.element,B._ClassName.hubVertical),q.addClass(this.element,B._ClassName.hubHorizontal)),this._orientation=a,o.schedule(this._updateSnapList.bind(this),o.Priority.idle)}}},sections:{get:function(){return this._pendingSections?this._pendingSections:this._sections},set:function(a){var b=!this._pendingSections;this._pendingSections=a,this._refresh(),b&&(this.scrollPosition=0)}},headerTemplate:{get:function(){return this._pendingHeaderTemplate?this._pendingHeaderTemplate:(this._headerTemplate||(this._headerTemplate=r),this._headerTemplate)},set:function(a){this._pendingHeaderTemplate=a||r,this._refresh()}},scrollPosition:{get:function(){return+this._pendingScrollLocation===this._pendingScrollLocation?this._pendingScrollLocation:(this._measure(),this._scrollPosition)},set:function(a){if(a=Math.max(0,a),this._pendingRefresh)this._pendingScrollLocation=a,this._pendingSectionOnScreen=null;else{this._measure();var b=Math.max(0,Math.min(this._scrollLength-this._viewportSize,a));this._scrollPosition=b;var c={};c[this._names.scrollPos]=b,q.setScrollPosition(this._viewportElement,c)}}},sectionOnScreen:{get:function(){if(+this._pendingSectionOnScreen===this._pendingSectionOnScreen)return this._pendingSectionOnScreen;this._measure();for(var a=0;a<this._sectionSizes.length;a++){var b=this._sectionSizes[a];if(b.offset+b.size-b.borderEnd-b.paddingEnd>this._scrollPosition+this._startSpacer+b.borderStart+b.paddingStart)return a}return-1},set:function(a){a=Math.max(0,a),this._pendingRefresh?(this._pendingSectionOnScreen=a,this._pendingScrollLocation=null):(this._measure(),a>=0&&a<this._sectionSizes.length&&this._scrollToSection(a))}},indexOfFirstVisible:{get:function(){this._measure();for(var a=0;a<this._sectionSizes.length;a++){var b=this._sectionSizes[a];if(b.offset+b.size-b.borderEnd-b.paddingEnd>this._scrollPosition)return a}return-1}},indexOfLastVisible:{get:function(){this._measure();for(var a=this._sectionSizes.length-1;a>=0;a--){var b=this._sectionSizes[a];if(b.offset+b.paddingStart+b.borderStart<this._scrollPosition+this._viewportSize)return a}return-1}},onheaderinvoked:v(w.headerInvoked),onloadingstatechanged:v(w.loadingStateChanged),oncontentanimating:v(w.contentAnimating),_refresh:function(){this._pendingRefresh||(this._loadId++,this._setState(B.LoadingState.loading),this._pendingRefresh=!0,o.schedule(this._refreshImpl.bind(this),o.Priority.high))},_refreshImpl:function(){if(!this._disposed){var a=m.wrap();if(this._pendingSections&&(this._animateEntrance=!0,this._fireEntrance=!this._visible,!this._fireEntrance&&(this._visible=!1,this._viewportElement.style.opacity=0,j.isAnimationEnabled()))){var b=this._fireEvent(B._EventName.contentAnimating,{type:B.AnimationType.contentTransition});b&&(this._viewportElement.style["-ms-overflow-style"]="none",a=i.fadeOut(this._viewportElement).then(function(){this._viewportElement.style["-ms-overflow-style"]=""}.bind(this))),this._animateEntrance=b}a.done(this._applyProperties.bind(this))}},_applyProperties:function(){if(!this._disposed){this._pendingRefresh=!1;var a=!1;if(this._pendingSections){for(a=!0,this._updateEvents(this._sections,this._pendingSections),this._sections=this._pendingSections,this._pendingSections=null;this.element.firstElementChild!==this._viewportElement;){var b=this.element.firstElementChild;b.parentNode.removeChild(b)}q.empty(this._surfaceElement)}this._pendingHeaderTemplate&&(this._headerTemplate=this._pendingHeaderTemplate,this._pendingHeaderTemplate=null),this._assignHeaderTemplate(),a&&this._attachSections(),+this._pendingSectionOnScreen===this._pendingSectionOnScreen?this.sectionOnScreen=this._pendingSectionOnScreen:this.scrollPosition=+this._pendingScrollLocation===this._pendingScrollLocation?this._pendingScrollLocation:0,this._pendingSectionOnScreen=null,this._pendingScrollLocation=null,this._setState(B.LoadingState.loading),this._loadSections()}},_handleSectionChanged:function(a){if(!this._pendingSections){var b=a.detail.newValue,c=a.detail.oldValue;if(b._setHeaderTemplate(this.headerTemplate),b.element!==c.element){if(b.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Hub.DuplicateSection",D.duplicateSection);this._surfaceElement.insertBefore(b.element,c.element),this._surfaceElement.removeChild(c.element),this._measured=!1,this._setState(B.LoadingState.loading),this._loadSections()}}},_handleSectionInserted:function(a){if(!this._pendingSections){var b=a.detail.index,c=a.detail.value;
  c._animation&&c._animation.cancel();var e,f=this._fireEvent(B._EventName.contentAnimating,{type:B.AnimationType.insert,index:b,section:c});if(f){for(var g=[],h=b+1;h<this.sections.length;h++)g.push(this.sections.getAt(h).element);e=new i._createUpdateListAnimation([c.element],[],g)}if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Hub.DuplicateSection",D.duplicateSection);if(c._setHeaderTemplate(this.headerTemplate),b<this.sections.length-1?this._surfaceElement.insertBefore(c.element,this.sections.getAt(b+1).element):this._surfaceElement.appendChild(c.element),this._measured=!1,e){var j=e.execute();this.runningAnimations=m.join([this.runningAnimations,j])}this._setState(B.LoadingState.loading),this._loadSections()}},_handleSectionMoved:function(a){if(!this._pendingSections){var b=a.detail.newIndex,c=a.detail.value;b<this.sections.length-1?this._surfaceElement.insertBefore(c.element,this.sections.getAt(b+1).element):this._surfaceElement.appendChild(c.element),this._measured=!1,this._setState(B.LoadingState.loading),this._loadSections()}},_handleSectionRemoved:function(a){if(!this._pendingSections){var b=a.detail.value,c=a.detail.index,d=m.wrap(),e=this._fireEvent(B._EventName.contentAnimating,{type:B.AnimationType.remove,index:c,section:b});if(e){for(var f=[],g=c;g<this.sections.length;g++)f.push(this.sections.getAt(g).element);var h=new i._createUpdateListAnimation([],[b.element],f);this._measure();var j=b.element.offsetTop,k=b.element.offsetLeft;b.element.style.position="absolute",b.element.style.top=j,b.element.style.left=k,b.element.style.opacity=0,this._measured=!1,d=h.execute().then(function(){b.element.style.position="",b.element.style.top="",b.element.style.left="",b.element.style.opacity=1}.bind(this))}d.done(function(){this._disposed||(this._surfaceElement.removeChild(b.element),this._measured=!1)}.bind(this)),b._animation=d,this.runningAnimations=m.join([this.runningAnimations,d]),this._setState(B.LoadingState.loading),this._loadSections()}},_handleSectionReload:function(){this.sections=this.sections},_updateEvents:function(a,b){a&&(a.removeEventListener("itemchanged",this._handleSectionChangedBind),a.removeEventListener("iteminserted",this._handleSectionInsertedBind),a.removeEventListener("itemmoved",this._handleSectionMovedBind),a.removeEventListener("itemremoved",this._handleSectionRemovedBind),a.removeEventListener("reload",this._handleSectionReloadBind)),b&&(b.addEventListener("itemchanged",this._handleSectionChangedBind),b.addEventListener("iteminserted",this._handleSectionInsertedBind),b.addEventListener("itemmoved",this._handleSectionMovedBind),b.addEventListener("itemremoved",this._handleSectionRemovedBind),b.addEventListener("reload",this._handleSectionReloadBind))},_attachSections:function(){this._measured=!1;for(var a=0;a<this.sections.length;a++){var b=this._sections.getAt(a);if(b._animation&&b._animation.cancel(),b.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Hub.DuplicateSection",D.duplicateSection);this._surfaceElement.appendChild(b.element)}},_assignHeaderTemplate:function(){this._measured=!1;for(var a=0;a<this.sections.length;a++){var b=this._sections.getAt(a);b._setHeaderTemplate(this.headerTemplate)}},_loadSection:function(a){var b=this._sections.getAt(a);return b._process().then(function(){var a=b.contentElement.style;""!==a.visibility&&(a.visibility="")})},_loadSections:function(){function b(a){a.then(function(){o.schedule(c,o.Priority.idle)})}function c(){if(d===e._loadId&&!e._disposed)if(g.length){var a=g.shift(),c=e._loadSection(a);b(c)}else k.complete()}this._loadId++;var d=this._loadId,e=this,f=m.wrap(),g=[],h=m.wrap();if(this._showProgressPromise||(this._showProgressPromise=m.timeout(x).then(function(){this._disposed||(this._progressBar||(this._progressBar=a.document.createElement("progress"),q.addClass(this._progressBar,B._ClassName.hubProgress),this._progressBar.max=100),this._progressBar.parentNode||this.element.insertBefore(this._progressBar,this._viewportElement),this._showProgressPromise=null)}.bind(this),function(){this._showProgressPromise=null}.bind(this))),this.sections.length){var k=new n;h=k.promise;for(var l=[],p=Math.max(0,this.indexOfFirstVisible),r=Math.max(0,this.indexOfLastVisible),s=p;r>=s;s++)l.push(this._loadSection(s));for(p--,r++;p>=0||r<this.sections.length;)r<this.sections.length&&(g.push(r),r++),p>=0&&(g.push(p),p--);var t=m.join(l);t.done(function(){d!==this._loadId||e._disposed||(this._showProgressPromise&&this._showProgressPromise.cancel(),this._progressBar&&this._progressBar.parentNode&&this._progressBar.parentNode.removeChild(this._progressBar),o.schedule(function(){if(d===this._loadId&&!e._disposed&&!this._visible){if(this._visible=!0,this._viewportElement.style.opacity=1,this._animateEntrance&&j.isAnimationEnabled()){var b={type:B.AnimationType.entrance};(!this._fireEntrance||this._fireEvent(B._EventName.contentAnimating,b))&&(this._viewportElement.style["-ms-overflow-style"]="none",f=i.enterContent(this._viewportElement,[{left:this._fireEntrance?"100px":"40px",top:"0px",rtlflip:!0}],{mechanism:"transition"}).then(function(){this._viewportElement.style["-ms-overflow-style"]=""}.bind(this)))}this._element===a.document.activeElement&&this._moveFocusIn(this.sectionOnScreen)}},o.Priority.high,this,"WinJS.UI.Hub.entranceAnimation"))}.bind(this)),b(t)}else this._showProgressPromise&&this._showProgressPromise.cancel(),this._progressBar&&this._progressBar.parentNode&&this._progressBar.parentNode.removeChild(this._progressBar);m.join([this.runningAnimations,f,h]).done(function(){d!==this._loadId||e._disposed||(this.runningAnimations=m.wrap(),this._setState(B.LoadingState.complete),o.schedule(this._updateSnapList.bind(this),o.Priority.idle))}.bind(this))},loadingState:{get:function(){return this._loadingState}},_setState:function(b){if(b!==this._loadingState){this._writeProfilerMark("loadingStateChanged:"+b+",info"),this._loadingState=b;var c=a.document.createEvent("CustomEvent");c.initCustomEvent(B._EventName.loadingStateChanged,!0,!1,{loadingState:b}),this._element.dispatchEvent(c)}},_parse:function(){for(var a=[],b=this.element.firstElementChild;b!==this._viewportElement;){l.processAll(b);var c=b.winControl;if(!c)throw new d("WinJS.UI.Hub.InvalidContent",D.invalidContent);a.push(c);var e=b.nextElementSibling;b=e}this.sections=new k.List(a)},_fireEvent:function(b,c){var d=a.document.createEvent("CustomEvent");return d.initCustomEvent(b,!0,!0,c),this.element.dispatchEvent(d)},_findHeaderTabStop:function(a){if(a.parentNode&&q._matchesSelector(a,".win-hub-section-header-tabstop, .win-hub-section-header-tabstop *")){for(;!q.hasClass(a,"win-hub-section-header-tabstop");)a=a.parentElement;return a}return null},_isHeaderInteractive:function(a){return a.parentNode?q._matchesSelector(a,".win-interactive, .win-interactive *"):!1},_clickHandler:function(a){var b=this._findHeaderTabStop(a.target);if(b&&!this._isHeaderInteractive(a.target)){var c=b.parentElement.parentElement.winControl;if(!c.isHeaderStatic){var d=this.sections.indexOf(c);this._fireEvent(B._EventName.headerInvoked,{index:d,section:c})}}},_resizeHandler:function(){this._measured=!1,o.schedule(this._updateSnapList.bind(this),o.Priority.idle)},_contentResizeHandler:function(){this._measured=!1,o.schedule(this._updateSnapList.bind(this),o.Priority.idle)},_scrollHandler:function(){this._measured=!1,this._pendingSections||(this._pendingScrollLocation=null,this._pendingSectionOnScreen=null,this._pendingScrollHandler||(this._pendingScrollHandler=c._requestAnimationFrame(function(){this._pendingScrollHandler=null,this._pendingSections||this.loadingState!==B.LoadingState.complete&&this._loadSections()}.bind(this))))},_measure:function(){if(!this._measured||0===this._scrollLength){this._writeProfilerMark("measure,StartTM"),this._measured=!0,this._rtl="rtl"===a.getComputedStyle(this._element,null).direction,this._names=this.orientation===s.Orientation.vertical?y:this._rtl?z:A,this._viewportSize=this._viewportElement[this._names.offsetSize],this._viewportOppositeSize=this._viewportElement[this._names.oppositeOffsetSize],this._scrollPosition=q.getScrollPosition(this._viewportElement)[this._names.scrollPos],this._scrollLength=this._viewportElement[this._names.scrollSize];var b=a.getComputedStyle(this._surfaceElement);this._startSpacer=parseFloat(b[this._names.marginStart])+parseFloat(b[this._names.borderStart])+parseFloat(b[this._names.paddingStart]),this._endSpacer=parseFloat(b[this._names.marginEnd])+parseFloat(b[this._names.borderEnd])+parseFloat(b[this._names.paddingEnd]),this._sectionSizes=[];for(var c=0;c<this.sections.length;c++){var d=this.sections.getAt(c),e=a.getComputedStyle(d.element);this._sectionSizes[c]={offset:d.element[this._names.offsetPos],size:d.element[this._names.offsetSize],marginStart:parseFloat(e[this._names.marginStart]),marginEnd:parseFloat(e[this._names.marginEnd]),borderStart:parseFloat(e[this._names.borderStart]),borderEnd:parseFloat(e[this._names.borderEnd]),paddingStart:parseFloat(e[this._names.paddingStart]),paddingEnd:parseFloat(e[this._names.paddingEnd])},this._rtl&&this.orientation===s.Orientation.horizontal&&(this._sectionSizes[c].offset=this._viewportSize-(this._sectionSizes[c].offset+this._sectionSizes[c].size))}this._writeProfilerMark("measure,StopTM")}},_updateSnapList:function(){this._writeProfilerMark("updateSnapList,StartTM"),this._measure();for(var a="snapList(",b=0;b<this._sectionSizes.length;b++){b>0&&(a+=",");var c=this._sectionSizes[b];a+=c.offset-c.marginStart-this._startSpacer+"px"}a+=")";var d="",e="";this.orientation===s.Orientation.vertical?d=a:e=a,this._lastSnapPointY!==d&&(this._lastSnapPointY=d,this._viewportElement.style["-ms-scroll-snap-points-y"]=d),this._lastSnapPointX!==e&&(this._lastSnapPointX=e,this._viewportElement.style["-ms-scroll-snap-points-x"]=e),this._writeProfilerMark("updateSnapList,StopTM")},_scrollToSection:function(a,b){this._measure();var c=this._sectionSizes[a],d=Math.min(this._scrollLength-this._viewportSize,c.offset-c.marginStart-this._startSpacer);this._scrollTo(d,b)},_ensureVisible:function(a,b){this._measure();var c=this._ensureVisibleMath(a,this._scrollPosition);this._scrollTo(c,b)},_ensureVisibleMath:function(a,b){this._measure();var c=this._sectionSizes[a],d=Math.min(this._scrollLength-this._viewportSize,c.offset-c.marginStart-this._startSpacer),e=Math.max(0,c.offset+c.size+c.marginEnd+this._endSpacer-this._viewportSize+1);return b>d?b=d:e>b&&(b=Math.min(d,e)),b},_scrollTo:function(a,b){if(this._scrollPosition=a,b)this.orientation===s.Orientation.vertical?q._zoomTo(this._viewportElement,{contentX:0,contentY:this._scrollPosition,viewportX:0,viewportY:0}):q._zoomTo(this._viewportElement,{contentX:this._scrollPosition,contentY:0,viewportX:0,viewportY:0});else{var c={};c[this._names.scrollPos]=this._scrollPosition,q.setScrollPosition(this._viewportElement,c)}},_windowKeyDownHandler:function(a){if(a.keyCode===u.tab){this._tabSeenLast=!0;var b=this;c._yieldForEvents(function(){b._tabSeenLast=!1})}},_focusin:function(a){if(this._tabSeenLast){var b=this._findHeaderTabStop(a.target);if(b&&!this._isHeaderInteractive(a.target)){var c=this.sections.indexOf(b.parentElement.parentElement.winControl);c>-1&&this._ensureVisible(c,!0)}}for(var d=a.target;d&&!q.hasClass(d,t.HubSection._ClassName.hubSection);)d=d.parentElement;if(d){var c=this.sections.indexOf(d.winControl);c>-1&&(this._currentIndexForSezo=c)}if(a.target===this.element){var e;+this._sectionToFocus===this._sectionToFocus&&this._sectionToFocus>=0&&this._sectionToFocus<this.sections.length?(e=this._sectionToFocus,this._sectionToFocus=null):e=this.sectionOnScreen,this._moveFocusIn(e)}},_moveFocusIn:function(a){if(a>=0){for(var b=a;b<this.sections.length;b++){var c=this.sections.getAt(b),d=q._trySetActive(c._headerTabStopElement,this._viewportElement);if(d)return;if(q._setActiveFirstFocusableElement(c.contentElement,this._viewportElement))return}for(var b=a-1;b>=0;b--){var c=this.sections.getAt(b);if(q._setActiveFirstFocusableElement(c.contentElement,this._viewportElement))return;var d=q._trySetActive(c._headerTabStopElement,this._viewportElement);if(d)return}}},_keyDownHandler:function(a){var b=this._rtl?u.rightArrow:u.leftArrow,c=this._rtl?u.leftArrow:u.rightArrow;if(a.keyCode===u.upArrow||a.keyCode===u.downArrow||a.keyCode===u.leftArrow||a.keyCode===u.rightArrow||a.keyCode===u.pageUp||a.keyCode===u.pageDown){var d=this._findHeaderTabStop(a.target);if(d&&!this._isHeaderInteractive(a.target)){var e,f=this.sections.indexOf(d.parentElement.parentElement.winControl),g=!1;if(a.keyCode===u.pageDown||this.orientation===s.Orientation.horizontal&&a.keyCode===c||this.orientation===s.Orientation.vertical&&a.keyCode===u.downArrow){for(var h=f+1;h<this.sections.length;h++)if(this._tryFocus(h)){e=h;break}}else if(a.keyCode===u.pageUp||this.orientation===s.Orientation.horizontal&&a.keyCode===b||this.orientation===s.Orientation.vertical&&a.keyCode===u.upArrow)for(var h=f-1;h>=0;h--)if(this._tryFocus(h)){e=h;break}(a.keyCode===u.upArrow||a.keyCode===u.downArrow||a.keyCode===u.leftArrow||a.keyCode===u.rightArrow)&&(g=!0),+e===e&&(g?this._ensureVisible(e,!0):this._scrollToSection(e,!0)),a.preventDefault()}}else if(a.keyCode===u.home||a.keyCode===u.end){this._measure();var i=Math.max(0,this._scrollLength-this._viewportSize);this._scrollTo(a.keyCode===u.home?0:i,!0),a.preventDefault()}},_tryFocus:function(b){var c=this.sections.getAt(b);return q._setActive(c._headerTabStopElement,this._viewportElement),a.document.activeElement===c._headerTabStopElement},zoomableView:{get:function(){return this._zoomableView||(this._zoomableView=new C(this)),this._zoomableView}},_getPanAxis:function(){return this.orientation===s.Orientation.horizontal?"horizontal":"vertical"},_configureForZoom:function(){},_setCurrentItem:function(a,b){var c;c=this.orientation===s.Orientation.horizontal?a:b,this._measure(),c+=this._scrollPosition,this._currentIndexForSezo=this._sectionSizes.length-1;for(var d=1;d<this._sectionSizes.length;d++){var e=this._sectionSizes[d];if(e.offset-e.marginStart>c){this._currentIndexForSezo=d-1;break}}},_getCurrentItem:function(){var a;if(this._sectionSizes.length>0){this._measure();var b=Math.max(0,Math.min(this._currentIndexForSezo,this._sectionSizes.length)),c=this._sectionSizes[b];a=this.orientation===s.Orientation.horizontal?{left:Math.max(0,c.offset-c.marginStart-this._scrollPosition),top:0,width:c.size,height:this._viewportOppositeSize}:{left:0,top:Math.max(0,c.offset-c.marginStart-this._scrollPosition),width:this._viewportOppositeSize,height:c.size};var d=this.sections.getAt(b);return m.wrap({item:{data:d,index:b,groupIndexHint:b},position:a})}},_beginZoom:function(){this._viewportElement.style["-ms-overflow-style"]="none"},_positionItem:function(a,b){if(a.index>=0&&a.index<this._sectionSizes.length){this._measure();var c,d=this._sectionSizes[a.index];c=this.orientation===s.Orientation.horizontal?b.left:b.top,this._sectionToFocus=a.index;var e=d.offset-c,e=this._ensureVisibleMath(a.index,e);this._scrollPosition=e;var f={};f[this._names.scrollPos]=this._scrollPosition,q.setScrollPosition(this._viewportElement,f)}},_endZoom:function(){this._viewportElement.style["-ms-overflow-style"]=""},_writeProfilerMark:function(a){var b="WinJS.UI.Hub:"+this._id+":"+a;h(b),f.log&&f.log(b,null,"hubprofiler")},dispose:function(){if(!this._disposed){this._disposed=!0,a.removeEventListener("keydown",this._windowKeyDownHandlerBound),q._resizeNotifier.unsubscribe(this.element,this._resizeHandlerBound),this._updateEvents(this._sections);for(var b=0;b<this.sections.length;b++)this.sections.getAt(b).dispose()}}},{AnimationType:{entrance:"entrance",contentTransition:"contentTransition",insert:"insert",remove:"remove"},LoadingState:{loading:"loading",complete:"complete"},_ClassName:{hub:"win-hub",hubSurface:"win-hub-surface",hubProgress:"win-hub-progress",hubViewport:"win-hub-viewport",hubVertical:"win-hub-vertical",hubHorizontal:"win-hub-horizontal"},_EventName:{contentAnimating:w.contentAnimating,headerInvoked:w.headerInvoked,loadingStateChanged:w.loadingStateChanged}});b.Class.mix(B,p.DOMEventMixin);var C=b.Class.define(function(a){this._hub=a},{getPanAxis:function(){return this._hub._getPanAxis()},configureForZoom:function(a,b,c,d){this._hub._configureForZoom(a,b,c,d)},setCurrentItem:function(a,b){this._hub._setCurrentItem(a,b)},getCurrentItem:function(){return this._hub._getCurrentItem()},beginZoom:function(){this._hub._beginZoom()},positionItem:function(a,b){return this._hub._positionItem(a,b)},endZoom:function(a){this._hub._endZoom(a)}}),D={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get duplicateSection(){return"Hub duplicate sections: Each HubSection must be unique"},get invalidContent(){return"Invalid content: Hub content must be made up of HubSections."},get hubViewportAriaLabel(){return g._getWinJSString("ui/hubViewportAriaLabel").value}};return B})})}),d("WinJS/Controls/AppBar/_Constants",["exports","../../Core/_Base"],function(a,b){"use strict";b.Namespace._moduleDefine(a,null,{appBarClass:"win-appbar",firstDivClass:"win-firstdiv",finalDivClass:"win-finaldiv",invokeButtonClass:"win-appbar-invokebutton",ellipsisClass:"win-appbar-ellipsis",primaryCommandsClass:"win-primarygroup",secondaryCommandsClass:"win-secondarygroup",reducedClass:"win-reduced",commandLayoutClass:"win-commandlayout",topClass:"win-top",bottomClass:"win-bottom",showingClass:"win-appbar-showing",shownClass:"win-appbar-shown",hidingClass:"win-appbar-hiding",hiddenClass:"win-appbar-hidden",minimalClass:"win-appbar-minimal",appBarPlacementTop:"top",appBarPlacementBottom:"bottom",appBarLayoutCustom:"custom",appBarLayoutCommands:"commands",appBarInvokeButtonWidth:60,typeSeparator:"separator",typeContent:"content",typeButton:"button",typeToggle:"toggle",typeFlyout:"flyout",menuCommandClass:"win-command",appBarCommandClass:"win-command",appBarCommandGlobalClass:"win-global",appBarCommandSelectionClass:"win-selection",sectionSelection:"selection",sectionGlobal:"global",hideFocusClass:"win-hidefocus",overlayClass:"win-overlay",flyoutClass:"win-flyout",flyoutLightClass:"win-ui-light",menuClass:"win-menu",menuToggleClass:"win-menu-toggle",settingsFlyoutClass:"win-settingsflyout",scrollsClass:"win-scrolls",separatorWidth:60,buttonWidth:100,narrowClass:"win-narrow",wideClass:"win-wide",_clickEatingAppBarClass:"win-appbarclickeater",_clickEatingFlyoutClass:"win-flyoutmenuclickeater",_visualViewportClass:"win-visualviewport-space"})}),d("WinJS/Controls/Flyout/_Overlay",["exports","../../Core/_Global","../../Core/_WinRT","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Events","../../Core/_Resources","../../Core/_WriteProfilerMark","../../Animations","../../ControlProcessor","../../Promise","../../Scheduler","../../Utilities/_Control","../../Utilities/_ElementUtilities","../AppBar/_Constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{_Overlay:d.Namespace._lazy(function(){function a(a){if(!a)return[];"string"!=typeof a&&a&&a.length||(a=[a]);var c,d=[];for(c=0;c<a.length;c++)if(a[c])if("string"==typeof a[c]){var e=b.document.getElementById(a[c]);e&&d.push(e)}else d.push(a[c].element?a[c].element:a[c]);return d}function q(a,c){var d=b.document.querySelectorAll("."+p.overlayClass);if(d)for(var e=d.length,f=0;e>f;f++){var g=d[f],h=g.winControl;h._disposed||h&&h[c](a)}}function r(){y._rightMouseMightEdgy||y._hideAllFlyouts()}var s=g._createEventProperty,t="beforeshow",u="aftershow",v="beforehide",w="afterhide",x={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get mustContainCommands(){return"Invalid HTML: AppBars/Menus must contain only AppBarCommands/MenuCommands"},get closeOverlay(){return h._getWinJSString("ui/closeOverlay").value}},y=d.Class.define(function(a,b){this._baseOverlayConstructor(a,b)},{_baseOverlayConstructor:function(a,c){this._disposed=!1,a||(a=b.document.createElement("div"));var d=a.winControl;if(d)throw new f("WinJS.UI._Overlay.DuplicateConstruction",x.duplicateConstruction);this._element||(this._element=a),this._sticky=!1,this._doNext="",this._element.style.visibility="hidden",this._element.style.opacity=0,a.winControl=this,o.addClass(this._element,p.overlayClass),o.addClass(this._element,"win-disposable");var e=this._element.getAttribute("unselectable");(null===e||void 0===e)&&this._element.setAttribute("unselectable","on"),this._currentAnimateIn=this._baseAnimateIn,this._currentAnimateOut=this._baseAnimateOut,this._animationPromise=l.as(),this._queuedToShow=[],this._queuedToHide=[],this._queuedCommandAnimation=!1,c&&n.setOptions(this,c)},element:{get:function(){return this._element}},disabled:{get:function(){return!!this._element.disabled},set:function(a){a=!!a;var b=!!this._element.disabled;b!==a&&(this._element.disabled=a,!this.hidden&&this._element.disabled&&this._hideOrDismiss())}},onbeforeshow:s(t),onaftershow:s(u),onbeforehide:s(v),onafterhide:s(w),dispose:function(){this._disposed||(this._disposed=!0,this._dispose())},_dispose:function(){},show:function(){this._show()},_show:function(){this._baseShow()},hide:function(){this._hide()},_hide:function(){this._baseHide()},hidden:{get:function(){return"hidden"===this._element.style.visibility||"hiding"===this._element.winAnimating||"hide"===this._doNext}},addEventListener:function(a,b,c){return this._element.addEventListener(a,b,c)},removeEventListener:function(a,b,c){return this._element.removeEventListener(a,b,c)},_baseShow:function(){if(this._animating||this._needToHandleShowingKeyboard||this._needToHandleHidingKeyboard)return this._doNext="show",!1;if(this._cachedDocumentSize=this._cachedDocumentSize||y._sizeOfDocument(),"visible"!==this._element.style.visibility){this._element.winAnimating="showing",this._element.style.display="",this._element.style.visibility="hidden",this._queuedCommandAnimation&&(this._showAndHideFast(this._queuedToShow,this._queuedToHide),this._queuedToShow=[],this._queuedToHide=[]),this._sendEvent(y.beforeShow),this._findPosition();var a=this;return this._animationPromise=this._currentAnimateIn().then(function(){a._baseEndShow()},function(){a._baseEndShow()}),!0}return!1},_findPosition:function(){},_baseEndShow:function(){this._disposed||(this._element.setAttribute("aria-hidden","false"),this._element.winAnimating="",this._endShow(),"show"===this._doNext&&(this._doNext=""),this._sendEvent(y.afterShow),this._writeProfilerMark("show,StopTM"),m.schedule(this._checkDoNext,m.Priority.normal,this,"WinJS.UI._Overlay._checkDoNext"))},_endShow:function(){},_baseHide:function(){if(this._animating||this._needToHandleShowingKeyboard)return this._doNext="hide",!1;if(this._needToHandleHidingKeyboard&&(this._element.style.visibility=""),"hidden"!==this._element.style.visibility){if(this._element.winAnimating="hiding",this._element.setAttribute("aria-hidden","true"),this._sendEvent(y.beforeHide),""===this._element.style.visibility)this._element.style.opacity=0,this._baseEndHide();else{var a=this;this._animationPromise=this._currentAnimateOut().then(function(){a._baseEndHide()},function(){a._baseEndHide()})}return!0}return!1},_baseEndHide:function(){this._disposed||(this._element.style.visibility="hidden",this._element.style.display="none",this._element.winAnimating="",this._queuedCommandAnimation&&(this._showAndHideFast(this._queuedToShow,this._queuedToHide),this._queuedToShow=[],this._queuedToHide=[]),"hide"===this._doNext&&(this._doNext=""),this._sendEvent(y.afterHide),this._writeProfilerMark("hide,StopTM"),m.schedule(this._checkDoNext,m.Priority.normal,this,"WinJS.UI._Overlay._checkDoNext"))},_checkDoNext:function(){this._animating||this._needToHandleShowingKeyboard||this._needToHandleHidingKeyboard||this._disposed||("hide"===this._doNext?(this._hide(),this._doNext=""):this._queuedCommandAnimation?this._showAndHideQueue():"show"===this._doNext&&(this._show(),this._doNext=""))},_baseAnimateIn:function(){return this._element.style.opacity=0,this._element.style.visibility="visible",b.getComputedStyle(this._element,null).opacity,j.fadeIn(this._element)},_baseAnimateOut:function(){return this._element.style.opacity=1,b.getComputedStyle(this._element,null).opacity,j.fadeOut(this._element)},_animating:{get:function(){return!!this._element.winAnimating}},_sendEvent:function(a,c){if(!this._disposed){var d=b.document.createEvent("CustomEvent");d.initEvent(a,!0,!0,c||{}),this._element.dispatchEvent(d)}},_showCommands:function(a,b){var c=this._resolveCommands(a);this._showAndHideCommands(c.commands,[],b)},_hideCommands:function(a,b){var c=this._resolveCommands(a);this._showAndHideCommands([],c.commands,b)},_showOnlyCommands:function(a,b){var c=this._resolveCommands(a);this._showAndHideCommands(c.commands,c.others,b)},_showAndHideCommands:function(a,b,c){c||this.hidden&&!this._animating?(this._showAndHideFast(a,b),this._removeFromQueue(a,this._queuedToShow),this._removeFromQueue(b,this._queuedToHide)):(this._updateAnimateQueue(a,this._queuedToShow,this._queuedToHide),this._updateAnimateQueue(b,this._queuedToHide,this._queuedToShow))},_removeFromQueue:function(a,b){var c;for(c=0;c<a.length;c++){var d;for(d=0;d<b.length;d++)if(b[d]===a[c]){b.splice(d,1);break}}},_updateAnimateQueue:function(a,b,c){if(!this._disposed){var d;for(d=0;d<a.length;d++){var e;for(e=0;e<b.length&&b[e]!==a[d];e++);for(e===b.length&&(b[e]=a[d]),e=0;e<c.length;e++)if(c[e]===a[d]){c.splice(e,1);break}}this._queuedCommandAnimation||(this._animating||m.schedule(this._checkDoNext,m.Priority.normal,this,"WinJS.UI._Overlay._checkDoNext"),this._queuedCommandAnimation=!0)}},_showAndHideFast:function(a,b){var c,d;for(c=0;c<a.length;c++)d=a[c],d&&d.style&&(d.style.visibility="",d.style.display="");for(c=0;c<b.length;c++)d=b[c],d&&d.style&&(d.style.visibility="hidden",d.style.display="none");this._commandsUpdated()},_showAndHideQueue:function(){if(this._queuedCommandAnimation=!1,this.hidden)this._showAndHideFast(this._queuedToShow,this._queuedToHide),m.schedule(this._checkDoNext,m.Priority.normal,this,"WinJS.UI._Overlay._checkDoNext");else{var a,c=this._queuedToShow,d=this._queuedToHide,e=this._findSiblings(c.concat(d));for(a=0;a<c.length;a++)c[a]&&c[a].style&&b.document.body.contains(c[a])?"hidden"!==c[a].style.visibility&&"0"!==c[a].style.opacity&&(e.push(c[a]),c.splice(a,1),a--):(c.splice(a,1),a--);for(a=0;a<d.length;a++)d[a]&&d[a].style&&b.document.body.contains(d[a])&&"hidden"!==d[a].style.visibility&&"0"!==d[a].style.opacity||(d.splice(a,1),a--);var f=this._baseBeginAnimateCommands(c,d,e),g=this;f?f.done(function(){g._baseEndAnimateCommands(d)},function(){g._baseEndAnimateCommands(d)}):m.schedule(function(){g._baseEndAnimateCommands([])},m.Priority.normal,null,"WinJS.UI._Overlay._endAnimateCommandsWithoutAnimation")}this._queuedToShow=[],this._queuedToHide=[]},_baseBeginAnimateCommands:function(a,c,d){this._beginAnimateCommands(a,c,this._getVisibleCommands(d));var e=null,f=null;c.length>0&&(f=j.createDeleteFromListAnimation(c,0===a.length?d:void 0)),a.length>0&&(e=j.createAddToListAnimation(a,d));for(var g=0,h=c.length;h>g;g++){var i=c[g].getBoundingClientRect(),k=b.getComputedStyle(c[g]);c[g].style.top=i.top-parseFloat(k.marginTop)+"px",c[g].style.left=i.left-parseFloat(k.marginLeft)+"px",c[g].style.opacity=0,c[g].style.position="fixed"}this._element.winAnimating="rearranging";var m=null;for(f&&(m=f.execute()),g=0;g<a.length;g++)a[g].style.visibility="",a[g].style.display="",a[g].style.opacity=1;if(e){var n=e.execute();m=m?l.join([m,n]):n}return m},_beginAnimateCommands:function(){},_getVisibleCommands:function(a){var b,c=a,d=[];c||(c=this.element.querySelectorAll(".win-command"));for(var e=0,f=c.length;f>e;e++)b=c[e].winControl||c[e],b.hidden||d.push(b);return d},_baseEndAnimateCommands:function(a){if(!this._disposed){var b;for(b=0;b<a.length;b++)a[b].style.position="",a[b].getBoundingClientRect(),a[b].style.visibility="hidden",a[b].style.display="none",a[b].style.opacity=1;this._element.winAnimating="",this._endAnimateCommands(),this._checkDoNext()}},_endAnimateCommands:function(){},_resolveCommands:function(b){b=a(b);var c={};c.commands=[],c.others=[];var d,e,f=this.element.querySelectorAll(".win-command");for(d=0;d<f.length;d++){var g=!1;for(e=0;e<b.length;e++)if(b[e]===f[d]){c.commands.push(f[d]),b.splice(e,1),g=!0;break}g||c.others.push(f[d])}return c},_findSiblings:function(a){var b,c,d=[],e=this.element.querySelectorAll(".win-command");for(b=0;b<e.length;b++){var f=!1;for(c=0;c<a.length;c++)if(a[c]===e[b]){a.splice(c,1),f=!0;break}f||d.push(e[b])}return d},_baseResize:function(a){if(this._cachedDocumentSize)if(this.hidden)this._cachedDocumentSize=null;else{var b=y._sizeOfDocument();(this._cachedDocumentSize.width!==b.width||this._cachedDocumentSize.height!==b.height)&&(this._cachedDocumentSize=b,this._sticky||this._hideOrDismiss())}this._resize(a)},_hideOrDismiss:function(){var a=this._element;a&&o.hasClass(a,p.settingsFlyoutClass)?this._dismiss():this.hide()},_resize:function(){},_commandsUpdated:function(){},_checkScrollPosition:function(){},_showingKeyboard:function(){},_hidingKeyboard:function(){},_verifyCommandsOnly:function(a,b){for(var c=a.children,d=new Array(c.length),e=0;e<c.length;e++){if(!o.hasClass(c[e],"win-command")&&c[e].getAttribute("data-win-control")!==b)throw new f("WinJS.UI._Overlay.MustContainCommands",x.mustContainCommands);k.processAll(c[e]),d[e]=c[e].winControl}return d},_focusOnLastFocusableElementOrThis:function(){this._focusOnLastFocusableElement()||y._trySetActive(this._element)},_focusOnLastFocusableElement:function(){if(this._element.firstElementChild){var a=this._element.firstElementChild.tabIndex,c=this._element.lastElementChild.tabIndex;this._element.firstElementChild.tabIndex=-1,this._element.lastElementChild.tabIndex=-1;var d=o._focusLastFocusableElement(this._element);return d&&y._trySelect(b.document.activeElement),this._element.firstElementChild.tabIndex=a,this._element.lastElementChild.tabIndex=c,d}return!1},_focusOnFirstFocusableElementOrThis:function(){this._focusOnFirstFocusableElement()||y._trySetActive(this._element)},_focusOnFirstFocusableElement:function(){if(this._element.firstElementChild){var a=this._element.firstElementChild.tabIndex,c=this._element.lastElementChild.tabIndex;this._element.firstElementChild.tabIndex=-1,this._element.lastElementChild.tabIndex=-1;var d=o._focusFirstFocusableElement(this._element);return d&&y._trySelect(b.document.activeElement),this._element.firstElementChild.tabIndex=a,this._element.lastElementChild.tabIndex=c,d}return!1},_addOverlayEventHandlers:function(a){if(!y._flyoutEdgeLightDismissEvent){b.addEventListener("blur",y._checkBlur,!1);var d=this;if(c.Windows.UI.Input.EdgeGesture){var e=c.Windows.UI.Input.EdgeGesture.getForCurrentView();e.addEventListener("starting",y._hideAllFlyouts),e.addEventListener("completed",r)}if(c.Windows.UI.ViewManagement.InputPane){var f=c.Windows.UI.ViewManagement.InputPane.getForCurrentView();f.addEventListener("showing",function(a){d._writeProfilerMark("_showingKeyboard,StartTM"),q(a,"_showingKeyboard"),d._writeProfilerMark("_showingKeyboard,StopTM")}),f.addEventListener("hiding",function(a){d._writeProfilerMark("_hidingKeyboard,StartTM"),q(a,"_hidingKeyboard"),d._writeProfilerMark("_hidingKeyboard,StopTM")}),b.document.addEventListener("scroll",function(a){d._writeProfilerMark("_checkScrollPosition,StartTM"),q(a,"_checkScrollPosition"),d._writeProfilerMark("_checkScrollPosition,StopTM")})}b.addEventListener("resize",function(a){d._writeProfilerMark("_baseResize,StartTM"),q(a,"_baseResize"),d._writeProfilerMark("_baseResize,StopTM")}),y._flyoutEdgeLightDismissEvent=!0}a&&this._handleEventsForFlyoutOrSettingsFlyout()},_handleEventsForFlyoutOrSettingsFlyout:function(){var a=this;o._addEventListener(this._element,"focusout",function(b){y._hideIfLostFocus(a,b)},!1),o._addEventListener(this._element,"pointerdown",y._checkRightClickDown,!0),o._addEventListener(this._element,"pointerup",y._checkRightClickUp,!0)
  },_writeProfilerMark:function(a){i("WinJS.UI._Overlay:"+this._id+":"+a)}},{_clickEatingAppBarDiv:!1,_clickEatingFlyoutDiv:!1,_flyoutEdgeLightDismissEvent:!1,_hideFlyouts:function(a,b){for(var c=a.querySelectorAll("."+p.flyoutClass),d=c.length,e=0;d>e;e++){var f=c[e];if("hidden"!==f.style.visibility){var g=f.winControl;!g||b&&g._sticky||g._hideOrDismiss()}}},_hideSettingsFlyouts:function(a,b){for(var c=a.querySelectorAll("."+p.settingsFlyoutClass),d=c.length,e=0;d>e;e++){var f=c[e];if("hidden"!==f.style.visibility){var g=f.winControl;!g||b&&g._sticky||g._hideOrDismiss()}}},_hideAllFlyouts:function(){y._hideFlyouts(b.document,!0),y._hideSettingsFlyouts(b.document,!0)},_createClickEatingDivTemplate:function(a,c){var d=b.document.createElement("section");return d._winHideClickEater=c,o.addClass(d,a),o._addEventListener(d,"pointerup",function(a){y._checkSameClickEatingPointerUp(a,!0)},!0),o._addEventListener(d,"pointerdown",function(a){y._checkClickEatingPointerDown(a,!0)},!0),d.addEventListener("click",function(a){d._winHideClickEater(a)},!0),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",x.closeOverlay),d.setAttribute("unselectable","on"),b.document.body.appendChild(d),d},_createClickEatingDivAppBar:function(){y._clickEatingAppBarDiv||(y._clickEatingAppBarDiv=y._createClickEatingDivTemplate(p._clickEatingAppBarClass,y._handleAppBarClickEatingClick))},_createClickEatingDivFlyout:function(){y._clickEatingFlyoutDiv||(y._clickEatingFlyoutDiv=y._createClickEatingDivTemplate(p._clickEatingFlyoutClass,y._handleFlyoutClickEatingClick))},_checkClickEatingPointerDown:function(a,b){var c=a.currentTarget;if(c)try{c._winPointerId=a.pointerId,c._winRightMouse=2===a.button}catch(d){}b&&!c._winRightMouse&&(a.stopPropagation(),a.preventDefault())},_checkSameClickEatingPointerUp:function(a,b){var c=!1,d=!1,e=a.currentTarget;try{e&&e._winPointerId===a.pointerId&&(c=!0,d=e._winRightMouse,d&&b&&(c=!1))}catch(f){}return b&&!d&&(a.stopPropagation(),a.preventDefault(),e._winHideClickEater(a)),c},_handleAppBarClickEatingClick:function(a){a.stopPropagation(),a.preventDefault(),y._hideLightDismissAppBars(null,!1),y._hideClickEatingDivAppBar(),y._hideAllFlyouts()},_handleFlyoutClickEatingClick:function(a){a.stopPropagation(),a.preventDefault(),y._hideClickEatingDivFlyout(),y._hideFlyouts(b.document,!0)},_checkRightClickDown:function(a){y._checkClickEatingPointerDown(a,!1)},_checkRightClickUp:function(a){y._checkSameClickEatingPointerUp(a,!1)&&(y._rightMouseMightEdgy=!0,e._yieldForEvents(function(){y._rightMouseMightEdgy=!1}))},_showClickEatingDivAppBar:function(){m.schedule(function(){y._clickEatingAppBarDiv&&(y._clickEatingAppBarDiv.style.display="block")},m.Priority.high,null,"WinJS.UI._Overlay._showClickEatingDivAppBar")},_hideClickEatingDivAppBar:function(){m.schedule(function(){y._clickEatingAppBarDiv&&(y._clickEatingAppBarDiv.style.display="none")},m.Priority.high,null,"WinJS.UI._Overlay._hideClickEatingDivAppBar")},_showClickEatingDivFlyout:function(){m.schedule(function(){y._clickEatingFlyoutDiv&&(y._clickEatingFlyoutDiv.style.display="block")},m.Priority.high,null,"WinJS.UI._Overlay._showClickEatingDivFlyout")},_hideClickEatingDivFlyout:function(){m.schedule(function(){y._clickEatingFlyoutDiv&&(y._clickEatingFlyoutDiv.style.display="none")},m.Priority.high,null,"WinJS.UI._Overlay._hideClickEatingDivFlyout")},_isFlyoutVisible:function(){return y._clickEatingFlyoutDiv?"block"===y._clickEatingFlyoutDiv.style.display:!1},_hideIfLostFocus:function(a){if(!a.hidden&&"showing"!==a.element.winAnimating&&!a._sticky){var c=b.document.activeElement;if(!a._element||!a._element.contains(c)){if(o.hasClass(a._element,p.settingsFlyoutClass)){var d=a,e=y._getParentControlUsingClassName(c,"win-flyout");if(e&&e._previousFocus&&d.element.contains(e._previousFocus))return void o._addEventListener(e.element,"focusout",function f(a){y._hideIfLostFocus(d,a),o._removeEventListener(e.element,"focusout",f,!1)},!1)}c&&(o.hasClass(c,p._clickEatingFlyoutClass)||o.hasClass(c,p._clickEatingAppBarClass))||a._hideOrDismiss()}}},_checkBlur:function(){if(b.document.hasFocus()){if(y._clickEatingFlyoutDiv&&"block"===y._clickEatingFlyoutDiv.style.display||y._clickEatingAppBarDiv&&"block"===y._clickEatingAppBarDiv.style.display){var a=b.document.activeElement;a&&"IFRAME"===a.tagName&&!a.msLightDismissBlur&&(a.addEventListener("blur",y._checkBlur,!1),a.msLightDismissBlur=!0)}}else y._hideAllFlyouts(),y._hideLightDismissAppBars(null,!1)},_trySetActive:function(a){return a&&b.document.body&&b.document.body.contains(a)&&o._setActive(a)?a===b.document.activeElement:!1},_trySelect:function(a){try{a&&a.select&&a.select()}catch(b){}},_addHideFocusClass:function(a){a&&(o.addClass(a,p.hideFocusClass),o._addEventListener(a,"focusout",y._removeHideFocusClass,!1))},_removeHideFocusClass:function(a){var c=a.target;c&&c!==b.document.activeElement&&(o.removeClass(c,p.hideFocusClass),o._removeEventListener(a.target,"focusout",y._removeHideFocusClass,!1))},_sizeOfDocument:function(){return{width:b.document.documentElement.offsetWidth,height:b.document.documentElement.offsetHeight}},_getParentControlUsingClassName:function(a,c){for(;a&&a!==b.document.body;){if(o.hasClass(a,c))return a.winControl;a=a.parentNode}return null},_hideIfAllAppBarsLostFocus:function(){y._isAppBarOrChild(b.document.activeElement)||(y._hideLightDismissAppBars(null,!1),y._ElementWithFocusPreviousToAppBar=null)},_hideLightDismissAppBars:function(a,c){for(var d=b.document.querySelectorAll("."+p.appBarClass),e=d.length,f=[],g=0;e>g;g++){var h=d[g].winControl;!h||h.sticky||h.hidden||f.push(h)}y._hideAllBars(f,c)},_hideAllBars:function(a,b){var c=a.map(function(a){return a._keyboardInvoked=b,a.hide(),a._animationPromise});return l.join(c)},_showAllBars:function(a,b){var c=a.map(function(a){return a._keyboardInvoked=b,a._doNotFocus=!1,a._show(),a._animationPromise});return l.join(c)},_isAppBarOrChild:function(a){if(!a)return null;if(o.hasClass(a,p._clickEatingAppBarClass)||o.hasClass(a,p._clickEatingFlyoutClass)||o.hasClass(a,p.firstDivClass)||o.hasClass(a,p.finalDivClass)||o.hasClass(a,p.invokeButtonClass))return a;for(;a&&a!==b.document;){if(o.hasClass(a,p.appBarClass))return a;if(o.hasClass(a,"win-flyout")&&a!==a.winControl._previousFocus){var c=a.winControl,d=y._isAppBarOrChild(c._previousFocus);return d&&o._addEventListener(c.element,"focusout",function e(){y._hideIfAllAppBarsLostFocus(),o._removeEventListener(c.element,"focusout",e,!1)},!1),d}a=a.parentNode}return null},_keyboardInfo:{get _visible(){try{return c.Windows.UI.ViewManagement.InputPane&&c.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height>0}catch(a){return!1}},get _extraOccluded(){var a;if(c.Windows.UI.ViewManagement.InputPane)try{a=c.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height}catch(b){}return a&&!y._keyboardInfo._isResized?a:0},get _isResized(){var a=b.document.documentElement.clientHeight/b.innerHeight,c=b.document.documentElement.clientWidth/b.innerWidth;return.99>c/a},get _visibleDocBottom(){return y._keyboardInfo._visibleDocTop+y._keyboardInfo._visibleDocHeight},get _visibleDocHeight(){return y._keyboardInfo._visualViewportHeight-y._keyboardInfo._extraOccluded},get _animationShowLength(){if(c.Windows.UI.Core.AnimationMetrics){for(var a=c.Windows.UI.Core.AnimationMetrics,b=new a.AnimationDescription(a.AnimationEffect.showPanel,a.AnimationEffectTarget.primary),d=b.animations,e=0,f=0;f<d.size;f++){var g=d[f];e=Math.max(e,g.delay+g.duration)}return e}return 0}},_ElementWithFocusPreviousToAppBar:null,_clickEatingAppBarClass:p._clickEatingAppBarClass,_clickEatingFlyoutClass:p._clickEatingFlyoutClass,_scrollTimeout:150,beforeShow:t,beforeHide:v,afterShow:u,afterHide:w,commonstrings:{get cannotChangeCommandsWhenVisible(){return"Invalid argument: You must call hide() before changing {0} commands"},get cannotChangeHiddenProperty(){return"Unable to set hidden property while parent {0} is visible."}}}),z={_visibleDocTop:function(){return 0},_visibleDocBottomOffset:function(){return y._keyboardInfo._isResized?0:y._keyboardInfo._extraOccluded},_visualViewportHeight:function(){var a=y._keyboardInfo._visualViewportSpace;return a.bottom-a.top},_visualViewportWidth:function(){var a=y._keyboardInfo._visualViewportSpace;return a.right-a.left},_visualViewportSpace:function(){var a=b.document.body.querySelector("."+p._visualViewportClass);return a||(a=b.document.createElement("DIV"),a.className=p._visualViewportClass,b.document.body.appendChild(a)),a.getBoundingClientRect()}},A={_visibleDocTop:function(){return b.window.pageYOffset-b.document.documentElement.scrollTop},_visibleDocBottomOffset:function(){return b.document.documentElement.clientHeight-y._keyboardInfo._visibleDocBottom},_visualViewportHeight:function(){return b.window.innerHeight},_visualViewportWidth:function(){return b.window.innerWidth}};d.Class.mix(y,n.DOMEventMixin);var B=b.document.createElement("DIV");B.className=p._visualViewportClass,b.document.body.appendChild(B);var C,D="-ms-device-fixed"===b.getComputedStyle(B).position;!D&&c.Windows.UI.ViewManagement.InputPane?(C=A,b.document.body.removeChild(B)):C=z;for(var E in C)Object.defineProperty(y._keyboardInfo,E,{get:C[E]});return y})})}),d("WinJS/Controls/Flyout",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","./AppBar/_Constants","./Flyout/_Overlay","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{Flyout:c.Namespace._lazy(function(){function a(a,c){return parseFloat(a,b.getComputedStyle(a,null)[c])}var k=j.Key,n={get ariaLabel(){return f._getWinJSString("ui/flyoutAriaLabel").value},get noAnchor(){return"Invalid argument: Showing flyout requires a DOM element as its parameter."},get badPlacement(){return"Invalid argument: Flyout placement should be 'top' (default), 'bottom', 'left', 'right', or 'auto'."},get badAlignment(){return"Invalid argument: Flyout alignment should be 'center' (default), 'left', or 'right'."}},o=c.Class.derive(m._Overlay,function(a,c){c=c||{},this._element=a||b.document.createElement("div"),this._id=this._element.id||j._uniqueID(this._element),this._writeProfilerMark("constructor,StartTM"),this._baseFlyoutConstructor(this._element,c);var d=this._element.getElementsByTagName("*"),e=this._addFirstDiv();e.tabIndex=j._getLowestTabIndexInList(d);var f=this._addFinalDiv();return f.tabIndex=j._getHighestTabIndexInList(d),this._element.addEventListener("keydown",this._handleKeyDown,!0),this._writeProfilerMark("constructor,StopTM"),this},{_lastMaxHeight:null,_baseFlyoutConstructor:function(a,b){this._placement="auto",this._alignment="center",this._baseOverlayConstructor(a,b),m._Overlay._createClickEatingDivFlyout(),this._element.style.visibilty="hidden",this._element.style.display="none",j.addClass(this._element,l.flyoutClass),j.addClass(this._element,l.flyoutLightClass);var c=this._element.getAttribute("role");(null===c||""===c||void 0===c)&&(j.hasClass(this._element,l.menuClass)?this._element.setAttribute("role","menu"):this._element.setAttribute("role","dialog"));var d=this._element.getAttribute("aria-label");(null===d||""===d||void 0===d)&&this._element.setAttribute("aria-label",n.ariaLabel),this._currentAnimateIn=this._flyoutAnimateIn,this._currentAnimateOut=this._flyoutAnimateOut,this._addOverlayEventHandlers(!0)},anchor:{get:function(){return this._anchor},set:function(a){this._anchor=a}},placement:{get:function(){return this._placement},set:function(a){if("top"!==a&&"bottom"!==a&&"left"!==a&&"right"!==a&&"auto"!==a)throw new e("WinJS.UI.Flyout.BadPlacement",n.badPlacement);this._placement=a}},alignment:{get:function(){return this._alignment},set:function(a){if("right"!==a&&"left"!==a&&"center"!==a)throw new e("WinJS.UI.Flyout.BadAlignment",n.badAlignment);this._alignment=a}},_dispose:function(){i.disposeSubTree(this.element),this._hide(),this.anchor=null},show:function(a,b,c){this._writeProfilerMark("show,StartTM"),this._show(a,b,c)},_show:function(a,b,c){this._baseFlyoutShow(a,b,c)},hide:function(){this._writeProfilerMark("hide,StartTM"),this._keyboardInvoked=!1,this._hide()},_hide:function(){if(this._baseHide()){var a=b.document.activeElement;if(this._previousFocus&&a&&(this._element.contains(a)||j.hasClass(a,m._Overlay._clickEatingFlyoutClass))&&void 0!==this._previousFocus.focus){var c=m._Overlay._isAppBarOrChild(this._previousFocus);if(!c||c.winControl&&!c.winControl.hidden&&!c.winAnimating){var e=this._previousFocus.getAttribute("role"),f=m._Overlay._keyboardInfo._visible&&!this._keyboardWasUp;if(f&&this._previousFocus.setAttribute("role",""),this._keyboardInvoked?this._previousFocus.focus():m._Overlay._trySetActive(this._previousFocus),a=b.document.activeElement,f){var g=this._previousFocus;g&&d._yieldForDomModification(function(){g.setAttribute("role",e)})}}!this._keyboardInvoked&&this._previousFocus===a&&c&&a&&m._Overlay._addHideFocusClass(a)}this._previousFocus=null,this._isThereVisibleFlyout()||m._Overlay._hideClickEatingDivFlyout()}},_baseFlyoutShow:function(a,c,d){if(!this.disabled){if(a||(a=this._anchor),c||(c=this._placement),d||(d=this._alignment),"string"==typeof a?a=b.document.getElementById(a):a&&a.element&&(a=a.element),a)this._currentAnchor=a,this._currentPlacement=c,this._currentAlignment=d;else{if(!this._retryLast)throw new e("WinJS.UI.Flyout.NoAnchor",n.noAnchor);this._retryLast=null}if(this._sticky||m._Overlay._showClickEatingDivFlyout(),this._element.winAnimating)return this._doNext="show",void(this._retryLast=!0);if(this._baseShow()){if(!j.hasClass(this.element,"win-menu")){var f=this._element.getElementsByTagName("*"),g=this.element.querySelectorAll(".win-first");this.element.children.length&&!j.hasClass(this.element.children[0],l.firstDivClass)&&(g&&g.length>0&&g.item(0).parentNode.removeChild(g.item(0)),g=this._addFirstDiv()),g.tabIndex=j._getLowestTabIndexInList(f);var h=this.element.querySelectorAll(".win-final");j.hasClass(this.element.children[this.element.children.length-1],l.finalDivClass)||(h&&h.length>0&&h.item(0).parentNode.removeChild(h.item(0)),h=this._addFinalDiv()),h.tabIndex=j._getHighestTabIndexInList(f)}this._hideAllOtherFlyouts(this),this._previousFocus=b.document.activeElement}}},_endShow:function(){this._keyboardWasUp=m._Overlay._keyboardInfo._visible,j.hasClass(this.element,l.menuClass)?m._Overlay._trySetActive(this._element):(this._focusOnFirstFocusableElementOrThis(),m._Overlay._addHideFocusClass(b.document.activeElement))},_findPosition:function(){this._nextHeight=null,this._keyboardMovedUs=!1,this._hasScrolls=!1,this._keyboardSquishedUs=0,this._checkToggle&&this._checkToggle(),this._updateAdjustments(this._currentAlignment),this._getTopLeft(),this._scrollTop=this._nextTop-m._Overlay._keyboardInfo._visibleDocTop,this._nextTop<0?(this._element.style.bottom="0px",this._element.style.top="auto"):(this._element.style.top=this._nextTop+"px",this._element.style.bottom="auto"),this._nextLeft<0?(this._element.style.right="0px",this._element.style.left="auto"):(this._element.style.left=this._nextLeft+"px",this._element.style.right="auto"),null!==this._nextHeight&&(j.addClass(this._element,l.scrollsClass),this._lastMaxHeight=this._element.style.maxHeight,this._element.style.maxHeight=this._nextHeight+"px",this._nextBottom=this._nextTop+this._nextHeight,this._hasScrolls=!0),m._Overlay._keyboardInfo._visible&&(this._checkKeyboardFit(),this._keyboardMovedUs&&this._adjustForKeyboard())},_getTopLeft:function(){var b=this._currentAnchor.getBoundingClientRect(),c={},d={};switch(d.top=b.top,d.bottom=b.bottom,d.left=b.left,d.right=b.right,d.height=d.bottom-d.top,d.width=d.right-d.left,c.marginTop=a(this._element,"marginTop"),c.marginBottom=a(this._element,"marginBottom"),c.marginLeft=a(this._element,"marginLeft"),c.marginRight=a(this._element,"marginRight"),c.width=j.getTotalWidth(this._element),c.height=j.getTotalHeight(this._element),c.innerWidth=j.getContentWidth(this._element),c.innerHeight=j.getContentHeight(this._element),this._nextMarginPadding=c.height-c.innerHeight,this._currentPlacement){case"top":this._fitTop(d,c)||(this._nextTop=m._Overlay._keyboardInfo._visibleDocTop,this._nextHeight=d.top-m._Overlay._keyboardInfo._visibleDocTop-this._nextMarginPadding),this._centerHorizontally(d,c,this._currentAlignment);break;case"bottom":this._fitBottom(d,c)||(this._nextTop=-1,this._nextHeight=m._Overlay._keyboardInfo._visibleDocHeight-(d.bottom-m._Overlay._keyboardInfo._visibleDocTop)-this._nextMarginPadding),this._centerHorizontally(d,c,this._currentAlignment);break;case"left":this._fitLeft(d,c)||(this._nextLeft=0),this._centerVertically(d,c);break;case"right":this._fitRight(d,c)||(this._nextLeft=-1),this._centerVertically(d,c);break;case"auto":this._sometimesFitsAbove(d,c)?(this._fitTop(d,c)||this._fitBottom(d,c),this._centerHorizontally(d,c,this._currentAlignment)):this._fitLeft(d,c)||this._fitRight(d,c)?this._centerVertically(d,c):(this._topHasMoreRoom(d)?(this._nextTop=m._Overlay._keyboardInfo._visibleDocTop,this._nextHeight=d.top-m._Overlay._keyboardInfo._visibleDocTop-this._nextMarginPadding):(this._nextTop=-1,this._nextHeight=m._Overlay._keyboardInfo._visibleDocHeight-(d.bottom-m._Overlay._keyboardInfo._visibleDocTop)-this._nextMarginPadding),this._centerHorizontally(d,c,this._currentAlignment));break;default:throw new e("WinJS.UI.Flyout.BadPlacement",n.badPlacement)}this._nextBottom=this._nextTop+c.height},_sometimesFitsAbove:function(a,b){return(m._Overlay._keyboardInfo._visibleDocHeight-a.height)/2>=b.height},_topHasMoreRoom:function(a){return a.top>m._Overlay._keyboardInfo._visibleDocHeight-a.bottom},_fitTop:function(a,b){return this._nextTop=a.top-b.height,this._nextAnimOffset={top:"50px",left:"0px",keyframe:"WinJS-showFlyoutTop"},this._nextTop>=m._Overlay._keyboardInfo._visibleDocTop&&this._nextTop+b.height<=m._Overlay._keyboardInfo._visibleDocBottom},_fitBottom:function(a,b){return this._nextTop=a.bottom,this._nextAnimOffset={top:"-50px",left:"0px",keyframe:"WinJS-showFlyoutBottom"},this._nextTop>=m._Overlay._keyboardInfo._visibleDocTop&&this._nextTop+b.height<=m._Overlay._keyboardInfo._visibleDocBottom},_fitLeft:function(a,b){return this._nextLeft=a.left-b.width,this._nextAnimOffset={top:"0px",left:"50px",keyframe:"WinJS-showFlyoutLeft"},this._nextLeft>=0&&this._nextLeft+b.width<=m._Overlay._keyboardInfo._visualViewportWidth},_fitRight:function(a,b){return this._nextLeft=a.right,this._nextAnimOffset={top:"0px",left:"-50px",keyframe:"WinJS-showFlyoutRight"},this._nextLeft>=0&&this._nextLeft+b.width<=m._Overlay._keyboardInfo._visualViewportWidth},_centerVertically:function(a,b){this._nextTop=a.top+a.height/2-b.height/2,this._nextTop<m._Overlay._keyboardInfo._visibleDocTop?this._nextTop=m._Overlay._keyboardInfo._visibleDocTop:this._nextTop+b.height>=m._Overlay._keyboardInfo._visibleDocBottom&&(this._nextTop=-1)},_centerHorizontally:function(a,c,d){if("center"===d)this._nextLeft=a.left+a.width/2-c.width/2;else if("left"===d)this._nextLeft=a.left;else{if("right"!==d)throw new e("WinJS.UI.Flyout.BadAlignment",n.badAlignment);this._nextLeft=a.right-c.width}this._nextLeft<0?this._nextLeft=0:this._nextLeft+c.width>=b.document.documentElement.clientWidth&&(this._nextLeft=-1)},_updateAdjustments:function(a){this._element.style.top="0px",this._element.style.bottom="auto",this._element.style.left="0px",this._element.style.right="auto",j.removeClass(this._element,l.scrollsClass),null!==this._lastMaxHeight&&(this._element.style.maxHeight=this._lastMaxHeight,this._lastMaxHeight=null),"center"===a?(j.removeClass(this._element,"win-leftalign"),j.removeClass(this._element,"win-rightalign")):"left"===a?(j.addClass(this._element,"win-leftalign"),j.removeClass(this._element,"win-rightalign")):"right"===a&&(j.addClass(this._element,"win-rightalign"),j.removeClass(this._element,"win-leftalign"))},_showingKeyboard:function(a){if(!this.hidden&&(a.ensuredFocusedElementInView=!0,this._checkKeyboardFit(),this._keyboardMovedUs)){this._element.style.opacity=0;var c=this;b.setTimeout(function(){c._adjustForKeyboard(),c._baseAnimateIn()},m._Overlay._keyboardInfo._animationShowLength)}},_resize:function(){if((!this.hidden||this._animating)&&this._needToHandleHidingKeyboard){var a=this;d._setImmediate(function(){a._findPosition()}),this._needToHandleHidingKeyboard=!1}},_checkKeyboardFit:function(){var a=j.getTotalHeight(this._element),b=m._Overlay._keyboardInfo._visibleDocHeight-this._nextMarginPadding;a>b?(this._keyboardMovedUs=!0,this._scrollTop=0,this._keyboardSquishedUs=b):-1===this._nextTop?this._keyboardMovedUs=!0:this._nextTop<m._Overlay._keyboardInfo._visibleDocTop?(this._scrollTop=0,this._keyboardMovedUs=!0):this._nextBottom>m._Overlay._keyboardInfo._visibleDocBottom&&(this._scrollTop=-1,this._keyboardMovedUs=!0)},_adjustForKeyboard:function(){this._keyboardSquishedUs&&(this._hasScrolls||(j.addClass(this._element,l.scrollsClass),this._lastMaxHeight=this._element.style.maxHeight),this._element.style.maxHeight=this._keyboardSquishedUs+"px"),this._checkScrollPosition(!0)},_hidingKeyboard:function(){if(!this.hidden||this._animating)if(m._Overlay._keyboardInfo._isResized)this._needToHandleHidingKeyboard=!0;else{var a=this;d._setImmediate(function(){a._findPosition()})}},_checkScrollPosition:function(a){(!this.hidden||a)&&(this._scrollTop<0?(this._element.style.bottom=m._Overlay._keyboardInfo._visibleDocBottomOffset+"px",this._element.style.top="auto"):(this._element.style.top=m._Overlay._keyboardInfo._visibleDocTop+"px",this._element.style.bottom="auto"))},_flyoutAnimateIn:function(){return this._keyboardMovedUs?this._baseAnimateIn():(this._element.style.opacity=1,this._element.style.visibility="visible",h.showPopup(this._element,this._nextAnimOffset))},_flyoutAnimateOut:function(){return this._keyboardMovedUs?this._baseAnimateOut():(this._element.style.opacity=0,h.hidePopup(this._element,this._nextAnimOffset))},_hideAllOtherFlyouts:function(a){for(var c=b.document.querySelectorAll("."+l.flyoutClass),d=0;d<c.length;d++){var e=c[d].winControl;e&&!e.hidden&&e!==a&&e.hide()}},_isThereVisibleFlyout:function(){for(var a=b.document.querySelectorAll("."+l.flyoutClass),c=0;c<a.length;c++){var d=a[c].winControl;if(d&&!d.hidden)return!0}return!1},_handleKeyDown:function(a){a.keyCode===k.escape&&a.keyCode!==k.IME?(a.preventDefault(),a.stopPropagation(),this.winControl._keyboardInvoked=!0,this.winControl._hide()):a.keyCode!==k.space&&a.keyCode!==k.enter||this!==b.document.activeElement?!a.shiftKey||a.keyCode!==k.tab||this!==b.document.activeElement||a.altKey||a.ctrlKey||a.metaKey||(a.preventDefault(),a.stopPropagation(),this.winControl._focusOnLastFocusableElementOrThis()):(a.preventDefault(),a.stopPropagation(),this.winControl.hide())},_addFirstDiv:function(){var a=b.document.createElement("div");a.className=l.firstDivClass,a.style.display="inline",a.setAttribute("role","menuitem"),a.setAttribute("aria-hidden","true"),this._element.children[0]?this._element.insertBefore(a,this._element.children[0]):this._element.appendChild(a);var c=this;return j._addEventListener(a,"focusin",function(){c._focusOnLastFocusableElementOrThis()},!1),a},_addFinalDiv:function(){var a=b.document.createElement("div");a.className=l.finalDivClass,a.style.display="inline",a.setAttribute("role","menuitem"),a.setAttribute("aria-hidden","true"),this._element.appendChild(a);var c=this;return j._addEventListener(a,"focusin",function(){c._focusOnFirstFocusableElementOrThis()},!1),a},_writeProfilerMark:function(a){g("WinJS.UI.Flyout:"+this._id+":"+a)}});return o})})}),d("WinJS/Controls/AppBar/_Icon",["exports","../../Core/_Base","../../Core/_Resources"],function(a,b,c){"use strict";var d=["previous","next","play","pause","edit","save","clear","delete","remove","add","cancel","accept","more","redo","undo","home","up","forward","right","back","left","favorite","camera","settings","video","sync","download","mail","find","help","upload","emoji","twopage","leavechat","mailforward","clock","send","crop","rotatecamera","people","closepane","openpane","world","flag","previewlink","globe","trim","attachcamera","zoomin","bookmarks","document","protecteddocument","page","bullets","comment","mail2","contactinfo","hangup","viewall","mappin","phone","videochat","switch","contact","rename","pin","musicinfo","go","keyboard","dockleft","dockright","dockbottom","remote","refresh","rotate","shuffle","list","shop","selectall","orientation","import","importall","browsephotos","webcam","pictures","savelocal","caption","stop","showresults","volume","repair","message","page2","calendarday","calendarweek","calendar","characters","mailreplyall","read","link","accounts","showbcc","hidebcc","cut","attach","paste","filter","copy","emoji2","important","mailreply","slideshow","sort","manage","allapps","disconnectdrive","mapdrive","newwindow","openwith","contactpresence","priority","uploadskydrive","gototoday","font","fontcolor","contact2","folder","audio","placeholder","view","setlockscreen","settile","cc","stopslideshow","permissions","highlight","disableupdates","unfavorite","unpin","openlocal","mute","italic","underline","bold","movetofolder","likedislike","dislike","like","alignright","aligncenter","alignleft","zoom","zoomout","openfile","otheruser","admin","street","map","clearselection","fontdecrease","fontincrease","fontsize","cellphone","reshare","tag","repeatone","repeatall","outlinestar","solidstar","calculator","directions","target","library","phonebook","memo","microphone","postupdate","backtowindow","fullscreen","newfolder","calendarreply","unsyncfolder","reporthacked","syncfolder","blockcontact","switchapps","addfriend","touchpointer","gotostart","zerobars","onebar","twobars","threebars","fourbars","scan","preview"],e=d.reduce(function(a,b){return a[b]={get:function(){return c._getWinJSString("ui/appBarIcons/"+b).value}},a},{});b.Namespace._moduleDefine(a,"WinJS.UI.AppBarIcon",e)}),d("WinJS/Controls/AppBar/_Command",["exports","../../Core/_Global","../../Core/_WinRT","../../Core/_Base","../../Core/_ErrorFromName","../../Core/_Resources","../../Utilities/_Control","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../Flyout/_Overlay","../Tooltip","./_Constants","./_Icon"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{AppBarCommand:d.Namespace._lazy(function(){function a(a){var c=this.winControl;if(c){if(c._type===l.typeToggle)c.selected=!c.selected;else if(c._type===l.typeFlyout&&c._flyout){var d=j._Overlay._getParentControlUsingClassName(this,l.appBarClass),e="top";d&&"top"===d.placement&&(e="bottom");var f=c._flyout;"string"==typeof f&&(f=b.document.getElementById(f)),f.show||(f=f.winControl),f&&f.show&&f.show(this,e)}c.onclick&&c.onclick(a)}}var n={get ariaLabel(){return f._getWinJSString("ui/appBarCommandAriaLabel").value},get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get badClick(){return"Invalid argument: The onclick property for an {0} must be a function"},get badDivElement(){return"Invalid argument: For a content command, the element must be null or a div element"},get badHrElement(){return"Invalid argument: For a separator, the element must be null or an hr element"},get badButtonElement(){return"Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"}};return d.Class.define(function(b,c){if(b&&b.winControl)throw new e("WinJS.UI.AppBarCommand.DuplicateConstruction",n.duplicateConstruction);if(this._disposed=!1,c||(c={}),c.type||(this._type=l.typeButton),c.section=c.section||l.sectionGlobal,this._element=b,c.type===l.typeContent?this._createContent():c.type===l.typeSeparator?this._createSeparator():this._createButton(),i.addClass(this._element,"win-disposable"),this._element.winControl=this,i.addClass(this._element,l.appBarCommandClass),c.onclick&&(this.onclick=c.onclick),c.onclick=a,g.setOptions(this,c),this._type!==l.typeToggle||c.selected||(this.selected=!1),this._type!==l.typeSeparator){var d=this;i._addEventListener(this._element,"pointerdown",function(){j._Overlay._addHideFocusClass(d._element)},!1);var f=this._element.getAttribute("role");(null===f||""===f||void 0===f)&&(f=this._type===l.typeToggle?"menuitemcheckbox":this._type===l.typeContent?"group":"menuitem",this._element.setAttribute("role",f),this._type===l.typeFlyout&&this._element.setAttribute("aria-haspopup",!0));var h=this._element.getAttribute("aria-label");(null===h||""===h||void 0===h)&&this._element.setAttribute("aria-label",n.ariaLabel)}},{id:{get:function(){return this._element.id},set:function(a){a&&!this._element.id&&(this._element.id=a)}},type:{get:function(){return this._type},set:function(a){this._type||(this._type=a!==l.typeContent&&a!==l.typeFlyout&&a!==l.typeToggle&&a!==l.typeSeparator?l.typeButton:a)}},label:{get:function(){return this._label},set:function(a){this._label=a,this._labelSpan&&(this._labelSpan.textContent=this.label),!this.tooltip&&this._tooltipControl&&(this._tooltip=this.label,this._tooltipControl.innerHTML=this.label),this._element.setAttribute("aria-label",this.label),this._testIdenticalTooltip()}},icon:{get:function(){return this._icon},set:function(a){this._icon=m[a]||a,this._imageSpan&&(this._icon&&1===this._icon.length?(this._imageSpan.textContent=this._icon,this._imageSpan.style.backgroundImage="",this._imageSpan.style.msHighContrastAdjust=""):(this._imageSpan.textContent="",this._imageSpan.style.backgroundImage=this._icon,this._imageSpan.style.msHighContrastAdjust="none"))}},onclick:{get:function(){return this._onclick},set:function(a){if(a&&"function"!=typeof a)throw new e("WinJS.UI.AppBarCommand.BadClick",f._formatString(n.badClick,"AppBarCommand"));this._onclick=a}},flyout:{get:function(){var a=this._flyout;return"string"==typeof a&&(a=b.document.getElementById(a)),a&&!a.element&&(a=a.winControl),a},set:function(a){var b=a;b&&"string"!=typeof b&&(b.element&&(b=b.element),b&&(b.id?b=b.id:(b.id=i._uniqueID(b),b=b.id))),"string"==typeof b&&this._element.setAttribute("aria-owns",b),this._flyout=a}},section:{get:function(){return this._section},set:function(a){(!this._section||c.Windows.ApplicationModel.DesignMode.designModeEnabled)&&this._setSection(a)}},tooltip:{get:function(){return this._tooltip},set:function(a){this._tooltip=a,this._tooltipControl&&(this._tooltipControl.innerHTML=this._tooltip),this._testIdenticalTooltip()}},selected:{get:function(){return"true"===this._element.getAttribute("aria-checked")},set:function(a){this._element.setAttribute("aria-checked",a)}},element:{get:function(){return this._element}},disabled:{get:function(){return!!this._element.disabled},set:function(a){this._element.disabled=a}},hidden:{get:function(){return"hidden"===this._element.style.visibility},set:function(a){var b=j._Overlay._getParentControlUsingClassName(this._element,l.appBarClass);if(b&&!b.hidden)throw new e("WinJS.UI.AppBarCommand.CannotChangeHiddenProperty",f._formatString(j._Overlay.commonstrings.cannotChangeHiddenProperty,"AppBar"));if(a!==this.hidden){var c=this._element.style;a?(c.visibility="hidden",c.display="none"):(c.visibility="",c.display="inline-block"),b&&b._commandsUpdated()}}},firstElementFocus:{get:function(){return this._firstElementFocus||this._lastElementFocus||this._element},set:function(a){this._firstElementFocus=a===this.element?null:a,this._updateTabStop()}},lastElementFocus:{get:function(){return this._lastElementFocus||this._firstElementFocus||this._element},set:function(a){this._lastElementFocus=a===this.element?null:a,this._updateTabStop()}},dispose:function(){this._disposed||(this._disposed=!0,this._tooltipControl&&this._tooltipControl.dispose(),this._type===l.typeContent&&h.disposeSubTree(this.element))},addEventListener:function(a,b,c){return this._element.addEventListener(a,b,c)
  },removeEventListener:function(a,b,c){return this._element.removeEventListener(a,b,c)},extraClass:{get:function(){return this._extraClass},set:function(a){this._extraClass&&i.removeClass(this._element,this._extraClass),this._extraClass=a,i.addClass(this._element,this._extraClass)}},_testIdenticalTooltip:function(){this._hideIfFullSize=this._label===this._tooltip},_createContent:function(){if(this._element){if("DIV"!==this._element.tagName)throw new e("WinJS.UI.AppBarCommand.BadDivElement",n.badDivElement)}else this._element=b.document.createElement("div");parseInt(this._element.getAttribute("tabIndex"),10)!==this._element.tabIndex&&(this._element.tabIndex=0)},_createSeparator:function(){if(this._element){if("HR"!==this._element.tagName)throw new e("WinJS.UI.AppBarCommand.BadHrElement",n.badHrElement)}else this._element=b.document.createElement("hr")},_createButton:function(){if(this._element){if("BUTTON"!==this._element.tagName)throw new e("WinJS.UI.AppBarCommand.BadButtonElement",n.badButtonElement);var a=this._element.getAttribute("type");(null===a||""===a||void 0===a)&&this._element.setAttribute("type","button"),this._element.innerHTML=""}else this._element=b.document.createElement("button");this._element.type="button",this._iconSpan=b.document.createElement("span"),this._iconSpan.setAttribute("aria-hidden","true"),this._iconSpan.className="win-commandicon win-commandring",this._iconSpan.tabIndex=-1,this._element.appendChild(this._iconSpan),this._imageSpan=b.document.createElement("span"),this._imageSpan.setAttribute("aria-hidden","true"),this._imageSpan.className="win-commandimage",this._imageSpan.tabIndex=-1,this._iconSpan.appendChild(this._imageSpan),this._labelSpan=b.document.createElement("span"),this._labelSpan.setAttribute("aria-hidden","true"),this._labelSpan.className="win-label",this._labelSpan.tabIndex=-1,this._element.appendChild(this._labelSpan),this._tooltipControl=new k.Tooltip(this._element);var c=this;this._tooltipControl.addEventListener("beforeopen",function(){c._hideIfFullSize&&!j._Overlay._getParentControlUsingClassName(c._element.parentElement,l.reducedClass)&&c._tooltipControl.close()},!1)},_setSection:function(a){a||(a=l.sectionGlobal),this._section&&(this._section===l.sectionGlobal?i.removeClass(this._element,l.appBarCommandGlobalClass):this.section===l.sectionSelection&&i.removeClass(this._element,l.appBarCommandSelectionClass)),this._section=a,a===l.sectionGlobal?i.addClass(this._element,l.appBarCommandGlobalClass):a===l.sectionSelection&&i.addClass(this._element,l.appBarCommandSelectionClass)},_updateTabStop:function(){this.element.tabIndex=this._firstElementFocus||this._lastElementFocus?-1:0},_isFocusable:function(){return!this.hidden&&this._type!==l.typeSeparator&&!this.element.disabled&&(this.firstElementFocus.tabIndex>=0||this.lastElementFocus.tabIndex>=0)}})})})}),d("WinJS/Controls/AppBar/_Layouts",["exports","../../Core/_Global","../../Core/_Base","../../Core/_ErrorFromName","../../Core/_Resources","../../Scheduler","../../Utilities/_Control","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","./_Command","./_Constants"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{_AppBarBaseLayout:c.Namespace._lazy(function(){var a=k.appBarLayoutCustom,b={get nullCommand(){return"Invalid argument: command must not be null"}},e=c.Class.define(function(a,b){this._disposed=!1,b=b||{},g.setOptions(this,b),a&&this.connect(a)},{className:{get:function(){return this._className}},type:{get:function(){return this._type||a}},commandsInOrder:{get:function(){var a=this.appBarEl.querySelectorAll("."+k.appBarCommandClass);return Array.prototype.slice.call(a)}},connect:function(a){this.className&&i.addClass(a,this.className),this.appBarEl=a},disconnect:function(){this.className&&i.removeClass(this.appBarEl,this.className),this.appBarEl=null,this.dispose()},layout:function(a){for(var b=a.length,c=0;b>c;c++){var d=this.sanitizeCommand(a[c]);this.appBarEl.appendChild(d._element)}},sanitizeCommand:function(a){if(!a)throw new d("WinJS.UI.AppBar.NullCommand",b.nullCommand);return a=a.winControl||a,a._element||(a=new j.AppBarCommand(null,a)),a._element.parentElement&&a._element.parentElement.removeChild(a._element),a},dispose:function(){this._disposed=!0},disposeChildren:function(){var a=this.appBarEl.querySelectorAll("."+k.firstDivClass);a=a.length>=1?a[0]:null;var b=this.appBarEl.querySelectorAll("."+k.finalDivClass);b=b.length>=1?b[0]:null;for(var c=this.appBarEl.children,d=c.length,e=0;d>e;e++){var f=c[e];f!==a&&f!==b&&h.disposeSubTree(f)}},handleKeyDown:function(){},commandsUpdated:function(){},beginAnimateCommands:function(){},endAnimateCommands:function(){},scale:function(){},resize:function(){}});return e})}),c.Namespace._moduleDefine(a,"WinJS.UI",{_AppBarCommandsLayout:c.Namespace._lazy(function(){var d=k.commandLayoutClass,e=k.appBarLayoutCommands,f=c.Class.derive(a._AppBarBaseLayout,function(b){a._AppBarBaseLayout.call(this,b,{_className:d,_type:e}),this._commandLayoutsInit(b)},{_getWidthOfFullSizeCommands:function(a){this._needToMeasureNewCommands&&this._measureContentCommands();var b=0,c=0,d=0;if(!a)return this._fullSizeWidthOfLastKnownVisibleCommands;for(var e,f=0,g=a.length;g>f;f++)e=a[f].winControl||a[f],e._type===k.typeSeparator?c++:e._type!==k.typeContent?d++:b+=e._fullSizeWidth;return b+=c*k.separatorWidth+d*k.buttonWidth},_getFocusableCommandsInLogicalOrder:function(){var a=this._secondaryCommands.children,c=this._primaryCommands.children,d=-1,e=function(a){for(var c=[],e=0,f=a.length;f>e;e++){var g=a[e];if(i.hasClass(g,k.appBarCommandClass)&&g.winControl){var h=g.contains(b.document.activeElement);(g.winControl._isFocusable()||h)&&(c.push(g),h&&(d=c.length-1))}}return c},f=Array.prototype.slice.call(a).concat(Array.prototype.slice.call(c)),g=e(f);return g.focusedIndex=d,g}});return c.Class.mix(f,l),f})});var l={layout:function(a){i.empty(this._primaryCommands),i.empty(this._secondaryCommands),this._commandsInOriginalOrder=[];for(var b=0,c=a.length;c>b;b++){var d=this.sanitizeCommand(a[b]);this._commandsInOriginalOrder.push(d.element),"global"===d.section?this._primaryCommands.appendChild(d._element):this._secondaryCommands.appendChild(d._element)}this.appBarEl.appendChild(this._secondaryCommands),this.appBarEl.appendChild(this._primaryCommands),this._needToMeasureNewCommands=!0,f.schedule(function(){this._needToMeasureNewCommands&&!this._disposed&&this.scale()}.bind(this),f.Priority.idle,this,"WinJS._commandLayoutsMixin._scaleNewCommands")},commandsInOrder:{get:function(){return this._commandsInOriginalOrder.filter(function(a){return this.appBarEl.contains(a)},this)}},disposeChildren:function(){h.disposeSubTree(this._primaryCommands),h.disposeSubTree(this._secondaryCommands)},handleKeyDown:function(a){var c=i.Key;if(!i._matchesSelector(a.target,".win-interactive, .win-interactive *")){var d="rtl"===b.getComputedStyle(this.appBarEl).direction,e=d?c.rightArrow:c.leftArrow,f=d?c.leftArrow:c.rightArrow;if(a.keyCode===e||a.keyCode===f||a.keyCode===c.home||a.keyCode===c.end){var g,h=this._primaryCommands.contains(b.document.activeElement),j=this._getFocusableCommandsInLogicalOrder(h);if(j.length)switch(a.keyCode){case e:var k=Math.max(-1,j.focusedIndex-1)+j.length;g=j[k%j.length].winControl.lastElementFocus;break;case f:var k=j.focusedIndex+1+j.length;g=j[k%j.length].winControl.firstElementFocus;break;case c.home:var k=0;g=j[k].winControl.firstElementFocus;break;case c.end:var k=j.length-1;g=j[k].winControl.lastElementFocus}g&&(g.focus(),a.preventDefault())}}},commandsUpdated:function(a){var b=a?a:this.commandsInOrder.filter(function(a){return!a.winControl.hidden});this._fullSizeWidthOfLastKnownVisibleCommands=this._getWidthOfFullSizeCommands(b)},beginAnimateCommands:function(a,b,c){this._scaleAfterAnimations=!1;var d=this._getWidthOfFullSizeCommands(a)-this._getWidthOfFullSizeCommands(b);if(d>0){var e=c.concat(a);this.commandsUpdated(e),this.scale()}else 0>d&&(this._scaleAfterAnimations=!0)},endAnimateCommands:function(){this._scaleAfterAnimations&&(this.commandsUpdated(),this.scale())},scale:function(){var a=this._getWidthOfFullSizeCommands();this._appBarTotalKnownWidth!==+this._appBarTotalKnownWidth&&(this._appBarTotalKnownWidth=this._scaleHelper()),a<=this._appBarTotalKnownWidth?i.removeClass(this.appBarEl,k.reducedClass):i.addClass(this.appBarEl,k.reducedClass)},resize:function(){this._disposed||(this._appBarTotalKnownWidth=null,this.appBarEl.winControl.hidden||this.scale())},disconnect:function(){i.removeClass(this.appBarEl,k.reducedClass),a._AppBarBaseLayout.prototype.disconnect.call(this)},_commandLayoutsInit:function(){this._primaryCommands=b.document.createElement("DIV"),this._secondaryCommands=b.document.createElement("DIV"),i.addClass(this._primaryCommands,k.primaryCommandsClass),i.addClass(this._secondaryCommands,k.secondaryCommandsClass)},_scaleHelper:function(){var a="minimal"===this.appBarEl.winControl.closedDisplayMode?k.appBarInvokeButtonWidth:0;return b.document.documentElement.clientWidth-a},_measureContentCommands:function(){if(b.document.body.contains(this.appBarEl)){this._needToMeasureNewCommands=!1;var a=i.hasClass(this.appBarEl,k.reducedClass);i.removeClass(this.appBarEl,k.reducedClass);var c=i.hasClass(this.appBarEl,k.hiddenClass);i.removeClass(this.appBarEl,k.hiddenClass);var d=this.appBarEl.style.display;this.appBarEl.style.display="";for(var e,f,g=this.appBarEl.querySelectorAll("div."+k.appBarCommandClass),h=0,j=g.length;j>h;h++)f=g[h],f.winControl&&f.winControl._type===k.typeContent&&(e=f.style.display,f.style.display="",f.winControl._fullSizeWidth=i.getTotalWidth(f)||0,f.style.display=e);this.appBarEl.style.display=d,a&&i.addClass(this.appBarEl,k.reducedClass),c&&i.addClass(this.appBarEl,k.hiddenClass),this.commandsUpdated()}}}}),d("WinJS/Controls/AppBar",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Promise","../Scheduler","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_KeyboardBehavior","./AppBar/_Constants","./AppBar/_Layouts","./AppBar/_Command","./AppBar/_Icon","./Flyout/_Overlay","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{AppBar:d.Namespace._lazy(function(){function a(a){if(!u._Overlay._rightMouseMightEdgy||a.kind!==c.Windows.UI.Input.EdgeGestureKind.mouse)if(M)M=null;else{var b=a.kind===c.Windows.UI.Input.EdgeGestureKind.keyboard;O._toggleAllAppBarsState(b)}}function o(){M||(M=O._toggleAllAppBarsState(!1))}function s(){var a=v();"showing"===M?u._Overlay._hideAllBars(a,!1):"hiding"===M&&u._Overlay._showAllBars(a,!1),M=null}function t(a){var c=b.document.querySelectorAll("."+q.appBarClass);if(c)for(var d=c.length,e=0;d>e;e++){var f=c[e],g=f.winControl;g&&!f.disabled&&g._manipulationChanged(a)}}function v(){var a=b.document.querySelectorAll("."+q.appBarClass),c=a.length,d=[];d._shown=!1,d._hidden=!1;for(var e=0;c>e;e++){var f=a[e];if(!f.disabled){var g=f.winControl;g&&(d.push(g),n.hasClass(g._element,q.hiddenClass)||n.hasClass(g._element,q.hidingClass)?d._hidden=!0:d._shown=!0)}}return d}function w(a,b,c){for(var d,e=a;e>=0;e--)if(d=c[e].winControl,d&&d.placement===b&&!d.hidden&&d._focusOnLastFocusableElement&&d._focusOnLastFocusableElement())return!0;return!1}function x(){var a=b.document.querySelectorAll("."+q.appBarClass);if(a.length){for(var c=0,d=0;d<a.length;d++)if(a[d]===this.parentElement){c=d;break}var e=this.parentElement.winControl;if(e.placement===q.appBarPlacementBottom){if(c&&w(c-1,q.appBarPlacementBottom,a))return;if(w(a.length-1,q.appBarPlacementTop,a))return;if(w(a.length-1,q.appBarPlacementBottom,a))return}else if(e.placement===q.appBarPlacementTop){if(c&&w(c-1,q.appBarPlacementTop,a))return;if(w(a.length-1,q.appBarPlacementBottom,a))return;if(w(a.length-1,q.appBarPlacementTop,a))return}}}function y(a,b,c){for(var d,e=a;e<c.length;e++)if(d=c[e].winControl,d&&d.placement===b&&!d.hidden&&d._focusOnFirstFocusableElement&&d._focusOnFirstFocusableElement())return!0;return!1}function z(){for(var a=b.document.querySelectorAll("."+q.appBarClass),c=0,d=0;d<a.length;d++)if(a[d]===this.parentElement){c=d;break}if(this.parentElement.winControl.placement===q.appBarPlacementBottom){if(y(c+1,q.appBarPlacementBottom,a))return;if(y(0,q.appBarPlacementTop,a))return;if(y(0,q.appBarPlacementBottom,a))return}else if(this.parentElement.winControl.placement===q.appBarPlacementTop){if(y(c+1,q.appBarPlacementTop,a))return;if(y(0,q.appBarPlacementBottom,a))return;if(y(0,q.appBarPlacementTop,a))return}}function A(){for(var a,c=b.document.querySelectorAll("."+q.appBarClass),d=0;d<c.length;d++)a=c[d].winControl,a&&!a.hidden&&a._updateFirstAndFinalDiv&&a._updateFirstAndFinalDiv()}function B(){for(var a=b.document.querySelectorAll("."+q.appBarClass),c=0;c<a.length;c++){var d=a[c].winControl;if(d&&!d.sticky&&(!d.hidden||d._element.winAnimating===H.shown))return!0}return!1}function C(a){a.relatedTarget&&a.relatedTarget.focus&&!u._Overlay._isAppBarOrChild(a.relatedTarget)&&D(a.relatedTarget)}function D(a){a&&(u._Overlay._ElementWithFocusPreviousToAppBar=a)}function E(){u._Overlay._trySetActive(u._Overlay._ElementWithFocusPreviousToAppBar)}var F=n.Key,G={disabled:0,none:0,hidden:0,minimal:25},H={disabled:"hidden",none:"hidden",hidden:"hidden",minimal:"minimal",shown:"shown"},I={none:"none",minimal:"minimal"},J="shown",K="hidden",L=!1,M=null,N={get ariaLabel(){return g._getWinJSString("ui/appBarAriaLabel").value},get requiresCommands(){return"Invalid argument: commands must not be empty"},get cannotChangePlacementWhenVisible(){return"Invalid argument: The placement property cannot be set when the AppBar is visible, call hide() first"},get badLayout(){return"Invalid argument: The layout property must be 'custom' or 'commands'"},get cannotChangeLayoutWhenVisible(){return"Invalid argument: The layout property cannot be set when the AppBar is visible, call hide() first"}},O=d.Class.derive(u._Overlay,function(d,f){this._initializing=!0,f=f||{},this._element=d||b.document.createElement("div"),this._id=this._element.id||n._uniqueID(this._element),this._writeProfilerMark("constructor,StartTM"),this._element.hasAttribute("tabIndex")||(this._element.tabIndex=-1),n.addClass(this._element,q.appBarClass);var g=this._element.getAttribute("role");g||this._element.setAttribute("role","menubar");var h=this._element.getAttribute("aria-label");h||this._element.setAttribute("aria-label",N.ariaLabel),this._baseOverlayConstructor(this._element),this._lastPositionVisited=H.none,n.addClass(this._element,q.hiddenClass),f.layout!==q.appBarLayoutCustom&&!f.commands&&this._element&&(f=e._shallowCopy(f),f.commands=this._verifyCommandsOnly(this._element,"WinJS.UI.AppBarCommand")),this._invokeButton=b.document.createElement("button"),this._invokeButton.tabIndex=0,this._invokeButton.innerHTML="<span class='"+q.ellipsisClass+"'></span>",n.addClass(this._invokeButton,q.invokeButtonClass),this._element.appendChild(this._invokeButton);var i=this;if(n._addEventListener(this._invokeButton,"pointerdown",function(){u._Overlay._addHideFocusClass(i._invokeButton)},!1),this._invokeButton.addEventListener("click",function(){O._toggleAllAppBarsState(p._keyboardSeenLast,i)},!1),this.layout=f.layout||q.appBarLayoutCommands,delete f.layout,this.placement=f.placement||q.appBarPlacementBottom,this.closedDisplayMode=f.closedDisplayMode||I.minimal,l.setOptions(this,f),this._initializing=!1,u._Overlay._createClickEatingDivAppBar(),this._element.addEventListener("keydown",this._handleKeyDown.bind(this),!1),!L){if(c.Windows.UI.Input.EdgeGesture){var j=c.Windows.UI.Input.EdgeGesture.getForCurrentView();j.addEventListener("starting",o),j.addEventListener("completed",a),j.addEventListener("canceled",s)}b.document.addEventListener("MSManipulationStateChanged",t,!1),L=!0}return this._addOverlayEventHandlers(!1),n._addEventListener(this._element,"focusin",function(a){C(a)},!1),n._addEventListener(this._element,"focusout",function(){u._Overlay._hideIfAllAppBarsLostFocus()},!1),this.closedDisplayMode===I.none&&this.layout===q.appBarLayoutCommands&&(this._element.style.display="none"),this._writeProfilerMark("constructor,StopTM"),this},{placement:{get:function(){return this._placement},set:function(a){var b=!1;if(c.Windows.ApplicationModel.DesignMode.designModeEnabled&&(this._hide(),b=!0),!this.hidden)throw new f("WinJS.UI.AppBar.CannotChangePlacementWhenVisible",N.cannotChangePlacementWhenVisible);this._placement=a===q.appBarPlacementTop?q.appBarPlacementTop:q.appBarPlacementBottom,this._placement===q.appBarPlacementTop?(n.addClass(this._element,q.topClass),n.removeClass(this._element,q.bottomClass)):this._placement===q.appBarPlacementBottom&&(n.removeClass(this._element,q.topClass),n.addClass(this._element,q.bottomClass)),b&&this._show()}},layout:{get:function(){return this._layout.type},set:function(a){if(a!==q.appBarLayoutCommands&&a!==q.appBarLayoutCustom)throw new f("WinJS.UI.AppBar.BadLayout",N.badLayout);var b=!1;if(c.Windows.ApplicationModel.DesignMode.designModeEnabled&&(this._hide(),b=!0),!this.hidden)throw new f("WinJS.UI.AppBar.CannotChangeLayoutWhenVisible",N.cannotChangeLayoutWhenVisible);var d;this._initializing||(d=this._layout.commandsInOrder,this._layout.disconnect()),this._layout=a===q.appBarLayoutCommands?new r._AppBarCommandsLayout:new r._AppBarBaseLayout,this._layout.connect(this._element),d&&d.length&&this._layoutCommands(d),this._layout.connect(this._element),d&&d.length&&this._layoutCommands(d),b&&this._show()},configurable:!0},sticky:{get:function(){return this._sticky},set:function(a){this._sticky!==!!a&&(this._sticky=!!a,this.hidden||"visible"!==this._element.style.visibility||(A(),this._sticky?B()||u._Overlay._hideClickEatingDivAppBar():(u._Overlay._showClickEatingDivAppBar(),this._shouldStealFocus()&&(D(b.document.activeElement),this._setFocusToAppBar()))))}},commands:{set:function(a){if(!this.hidden)throw new f("WinJS.UI.AppBar.CannotChangeCommandsWhenVisible",g._formatString(u._Overlay.commonstrings.cannotChangeCommandsWhenVisible,"AppBar"));this._initializing||this._disposeChildren(),this._layoutCommands(a)}},_layoutCommands:function(a){n.empty(this._element),this._element.appendChild(this._invokeButton),Array.isArray(a)||(a=[a]),this._layout.layout(a)},closedDisplayMode:{get:function(){return this._closedDisplayMode},set:function(a){var b=this._closedDisplayMode;b!==a&&(a===I.none?(this._closedDisplayMode=I.none,n.removeClass(this._element,q.minimalClass)):(this._closedDisplayMode=I.minimal,n.addClass(this._element,q.minimalClass)),this._layout.resize(),(n.hasClass(this._element,q.hiddenClass)||n.hasClass(this._element,q.hidingClass))&&this._changeVisiblePosition(H[this._closedDisplayMode]))}},disabled:{get:function(){return!!this._element.disabled},set:function(a){var a=!!a;if(this.disabled!==a){this._element.disabled=a;var b;b=a?H.disabled:H[this.closedDisplayMode],this._hide(b)}}},hidden:{get:function(){return n.hasClass(this._element,q.hiddenClass)||n.hasClass(this._element,q.hidingClass)||this._doNext===H.minimal||this._doNext===H.none}},getCommandById:function(a){for(var b=this.element.querySelectorAll("#"+a),c=[],d=0,e=b.length;e>d;d++)b[d].winControl&&c.push(b[d].winControl);return 1===c.length?c[0]:0===c.length?null:c},showCommands:function(a){if(!a)throw new f("WinJS.UI.AppBar.RequiresCommands",N.requiresCommands);this._showCommands(a)},hideCommands:function(a){if(!a)throw new f("WinJS.UI.AppBar.RequiresCommands",N.requiresCommands);this._hideCommands(a)},showOnlyCommands:function(a){if(!a)throw new f("WinJS.UI.AppBar.RequiresCommands",N.requiresCommands);this._showOnlyCommands(a)},show:function(){this._writeProfilerMark("show,StartTM"),this._keyboardInvoked=!1,this._doNotFocus=!!this.sticky,this._show()},_show:function(){var a=H.shown,c=null;this.disabled||!n.hasClass(this._element,q.hiddenClass)&&!n.hasClass(this._element,q.hidingClass)||(c=J),this._changeVisiblePosition(a,c),c&&(this.sticky||u._Overlay._showClickEatingDivAppBar(),!this.sticky&&B()?A():this._updateFirstAndFinalDiv(),!this._doNotFocus&&this._shouldStealFocus()&&(u._Overlay._ElementWithFocusPreviousToAppBar||D(b.document.activeElement),this._setFocusToAppBar()))},hide:function(){this._writeProfilerMark("hide,StartTM"),this._hide()},_hide:function(a){var a=a||H[this.closedDisplayMode],c=null;if(n.hasClass(this._element,q.hiddenClass)||n.hasClass(this._element,q.hidingClass)||(c=K),this._changeVisiblePosition(a,c),c){var d,e=b.document.querySelectorAll("."+q.appBarClass),f=!1,g=!1;for(d=0;d<e.length;d++){var h=e[d].winControl;if(h&&!h.hidden&&h!==this&&(f=!0,!h.sticky)){g=!0;break}}var i=b.document.querySelectorAll("."+q.settingsFlyoutClass),j=!1;for(d=0;d<i.length;d++){var k=i[d].winControl;if(k&&!k.hidden){j=!0;break}}g||j||u._Overlay._hideClickEatingDivAppBar();var l=this;if(f){if(O._isWithinAppBarOrChild(b.document.activeElement,l.element)){var m=!1;for(d=0;d<=e.length;d++){d===e.length&&(d=0);var o=e[d];if(o===this.element)m=!0;else if(m&&!o.winControl.hidden){o.winControl._keyboardInvoked=!!this._keyboardInvoked,o.winControl._setFocusToAppBar();break}}}}else!u._Overlay._ElementWithFocusPreviousToAppBar||b.document.activeElement&&!u._Overlay._isAppBarOrChild(b.document.activeElement)||E(),u._Overlay._ElementWithFocusPreviousToAppBar=null;this.sticky||B()||A(),this._keyboardInvoked=!1,this._doNotFocus=!1}},_dispose:function(){m.disposeSubTree(this.element),this._layout.dispose(),this.disabled=!0},_disposeChildren:function(){this._layout.disposeChildren()},_handleKeyDown:function(a){a.keyCode===F.escape&&a.keyCode!==F.IME&&(a.preventDefault(),a.stopPropagation(),u._Overlay._hideAllFlyouts(),u._Overlay._hideLightDismissAppBars(null,!0)),this._invokeButton.contains(b.document.activeElement)||this._layout.handleKeyDown(a)},_visiblePixels:{get:function(){return{hidden:G.hidden,minimal:G.minimal,shown:this._element.offsetHeight}}},_visiblePosition:{get:function(){return this._animating&&H[this._element.winAnimating]?this._element.winAnimating:this._lastPositionVisited}},_visible:{get:function(){return this._visiblePosition!==H.none}},_changeVisiblePosition:function(a,b){if(this._visiblePosition===a&&!this._keyboardObscured||this.disabled&&a!==H.disabled)this._afterPositionChange(null);else if(this._animating||this._needToHandleShowingKeyboard||this._needToHandleHidingKeyboard)this._doNext=a,this._afterPositionChange(null);else{this._element.winAnimating=a;var c=this._initializing?!1:!0,d=this._lastPositionVisited;this._element.style.display="";var e=a===H.hidden;this._keyboardObscured&&(e?c=!1:d=H.hidden,this._keyboardObscured=!1),b===J?this._beforeShow():b===K&&this._beforeHide(),this._ensurePosition(),this._element.style.opacity=1,this._element.style.visibility="visible",this._animationPromise=c?this._animatePositionChange(d,a):j.wrap(),this._animationPromise.then(function(){this._afterPositionChange(a,b)}.bind(this),function(){this._afterPositionChange(a,b)}.bind(this))}},_afterPositionChange:function(a,b){if(!this._disposed){if(a){this._element.winAnimating="",this._lastPositionVisited=a,this._doNext===this._lastPositionVisited&&(this._doNext=""),a===H.hidden&&(this._element.style.visibility="hidden",this._element.style.display="none");var c=e._browserStyleEquivalents.transform.scriptName;this._element.style[c]="",b===J?this._afterShow():b===K&&this._afterHide(),k.schedule(this._checkDoNext,k.Priority.normal,this,"WinJS.UI.AppBar._checkDoNext")}this._afterPositionChangeCallBack()}},_afterPositionChangeCallBack:function(){},_beforeShow:function(){this._cachedDocumentSize=this._cachedDocumentSize||u._Overlay._sizeOfDocument(),this._queuedCommandAnimation&&(this._showAndHideFast(this._queuedToShow,this._queuedToHide),this._queuedToShow=[],this._queuedToHide=[]),this._layout.scale(),n.removeClass(this._element,q.hiddenClass),n.addClass(this._element,q.showingClass),this._sendEvent(u._Overlay.beforeShow)},_afterShow:function(){n.removeClass(this._element,q.showingClass),n.addClass(this._element,q.shownClass),this._sendEvent(u._Overlay.afterShow),this._writeProfilerMark("show,StopTM")},_beforeHide:function(){n.removeClass(this._element,q.shownClass),n.addClass(this._element,q.hidingClass),this._sendEvent(u._Overlay.beforeHide)},_afterHide:function(){this._queuedCommandAnimation&&(this._showAndHideFast(this._queuedToShow,this._queuedToHide),this._queuedToShow=[],this._queuedToHide=[]),n.removeClass(this._element,q.hidingClass),n.addClass(this._element,q.hiddenClass),this._sendEvent(u._Overlay.afterHide),this._writeProfilerMark("hide,StopTM")},_animatePositionChange:function(a,b){var c=this._visiblePixels[a],d=this._visiblePixels[b],e=Math.abs(d-c),f=this._placement===q.appBarPlacementTop?-e:e;if(d>c){var g={top:f+"px",left:"0px"};return i.showEdgeUI(this._element,g,{mechanism:"transition"})}var h={top:f+"px",left:"0px"};return i.hideEdgeUI(this._element,h,{mechanism:"transition"})},_checkDoNext:function(){this._animating||this._needToHandleShowingKeyboard||this._needToHandleHidingKeyboard||this._disposed||(this._doNext===H.disabled||this._doNext===H.hidden||this._doNext===H.minimal?(this._hide(this._doNext),this._doNext=""):this._queuedCommandAnimation?this._showAndHideQueue():this._doNext===H.shown&&(this._show(),this._doNext=""))},_isABottomAppBarInTheProcessOfShowing:function(){for(var a=b.document.querySelectorAll("."+q.appBarClass+"."+q.bottomClass),c=0;c<a.length;c++)if(a[c].winAnimating===H.shown)return!0;return!1},_shouldStealFocus:function(){var a=u._Overlay._isAppBarOrChild(b.document.activeElement);if(this._element===a)return!1;if(this._placement===q.appBarPlacementBottom)return!0;var c=this._isABottomAppBarInTheProcessOfShowing();return a?a.winControl&&(a.winControl._placement===q.appBarPlacementBottom||a.winControl._placement===q.appBarPlacementTop||c)?!1:!0:!c},_setFocusToAppBar:function(){this._focusOnFirstFocusableElement()?this._keyboardInvoked||u._Overlay._addHideFocusClass(b.document.activeElement):u._Overlay._trySetActive(this._element)},_commandsUpdated:function(){this._initializing||(this._layout.commandsUpdated(),this._layout.scale())},_beginAnimateCommands:function(a,b,c){this._layout.beginAnimateCommands(a,b,c)},_endAnimateCommands:function(){this._layout.endAnimateCommands(),this._endAnimateCommandsCallBack()},_endAnimateCommandsCallBack:function(){},_getTopOfVisualViewport:function(){return u._Overlay._keyboardInfo._visibleDocTop},_getAdjustedBottom:function(){return u._Overlay._keyboardInfo._visibleDocBottomOffset},_showingKeyboard:function(a){if(this._keyboardObscured=!1,this._needToHandleHidingKeyboard=!1,!u._Overlay._keyboardInfo._visible||!this._alreadyInPlace()){this._needToHandleShowingKeyboard=!0,!this.hidden&&this._element.contains(b.document.activeElement)&&(a.ensuredFocusedElementInView=!0),this._visible&&this._placement!==q.appBarPlacementTop&&u._Overlay._isFlyoutVisible()?this._keyboardObscured=!0:this._scrollHappened=!1;var c=this;b.setTimeout(function(a){c._checkKeyboardTimer(a)},u._Overlay._keyboardInfo._animationShowLength+u._Overlay._scrollTimeout)}},_hidingKeyboard:function(){this._keyboardObscured=!1,this._needToHandleShowingKeyboard=!1,this._needToHandleHidingKeyboard=!0,u._Overlay._keyboardInfo._isResized||((this._visible||this._animating)&&(this._checkScrollPosition(),this._element.style.display=""),this._needToHandleHidingKeyboard=!1)},_resize:function(a){this._needToHandleShowingKeyboard?this._visible&&(this._placement===q.appBarPlacementTop||this._keyboardObscured||(this._element.style.display="none")):this._needToHandleHidingKeyboard&&(this._needToHandleHidingKeyboard=!1,(this._visible||this._animating)&&(this._checkScrollPosition(),this._element.style.display="")),this._initializing||this._layout.resize(a)},_checkKeyboardTimer:function(){this._scrollHappened||this._mayEdgeBackIn()},_manipulationChanged:function(a){0===a.currentState&&this._scrollHappened&&this._mayEdgeBackIn()},_mayEdgeBackIn:function(){if(this._needToHandleShowingKeyboard)if(this._needToHandleShowingKeyboard=!1,this._keyboardObscured||this._placement===q.appBarPlacementTop&&0===u._Overlay._keyboardInfo._visibleDocTop)this._checkDoNext();else{var a=this._visiblePosition;this._lastPositionVisited=H.hidden,this._changeVisiblePosition(a,!1)}this._scrollHappened=!1},_ensurePosition:function(){var a=this._computePositionOffset();this._element.style.bottom=a.bottom,this._element.style.top=a.top},_computePositionOffset:function(){var a={};return this._placement===q.appBarPlacementBottom?(a.bottom=this._getAdjustedBottom()+"px",a.top=""):this._placement===q.appBarPlacementTop&&(a.bottom="",a.top=this._getTopOfVisualViewport()+"px"),a},_checkScrollPosition:function(){return this._needToHandleShowingKeyboard?void(this._scrollHappened=!0):void((this._visible||this._animating)&&(this._ensurePosition(),this._checkDoNext()))},_alreadyInPlace:function(){var a=this._computePositionOffset();return a.top===this._element.style.top&&a.bottom===this._element.style.bottom},_updateFirstAndFinalDiv:function(){var a=this._element.querySelectorAll("."+q.firstDivClass);a=a.length>=1?a[0]:null;var c=this._element.querySelectorAll("."+q.finalDivClass);c=c.length>=1?c[0]:null,a&&this._element.children[0]!==a&&(a.parentNode.removeChild(a),a=null),c&&this._element.children[this._element.children.length-1]!==c&&(c.parentNode.removeChild(c),c=null),a||(a=b.document.createElement("div"),a.style.display="inline",a.className=q.firstDivClass,a.tabIndex=-1,a.setAttribute("aria-hidden","true"),n._addEventListener(a,"focusin",x,!1),this._element.children[0]?this._element.insertBefore(a,this._element.children[0]):this._element.appendChild(a)),c||(c=b.document.createElement("div"),c.style.display="inline",c.className=q.finalDivClass,c.tabIndex=-1,c.setAttribute("aria-hidden","true"),n._addEventListener(c,"focusin",z,!1),this._element.appendChild(c)),this._element.children[this._element.children.length-2]!==this._invokeButton&&this._element.insertBefore(this._invokeButton,c);var d=this._element.getElementsByTagName("*"),e=n._getHighestTabIndexInList(d);this._invokeButton.tabIndex=e,B()?(a&&(a.tabIndex=n._getLowestTabIndexInList(d)),c&&(c.tabIndex=e)):(a&&(a.tabIndex=-1),c&&(c.tabIndex=-1))},_writeProfilerMark:function(a){h("WinJS.UI.AppBar:"+this._id+":"+a)}},{_appBarsSynchronizationPromise:j.as(),_isWithinAppBarOrChild:function(a,b){if(!a||!b)return!1;if(b.contains(a))return!0;var c=u._Overlay._getParentControlUsingClassName(a,q.flyoutClass);return c&&b.contains(c._previousFocus)},_toggleAllAppBarsState:function(a,b){var c,d=v();return c=b?n.hasClass(b._element,q.showingClass)||n.hasClass(b._element,q.shownClass):d._shown&&!d._hidden,c?(O._appBarsSynchronizationPromise=O._appBarsSynchronizationPromise.then(function(){return u._Overlay._hideAllBars(d,a)}),"hiding"):(O._appBarsSynchronizationPromise=O._appBarsSynchronizationPromise.then(function(){return u._Overlay._showAllBars(d,a)}),"showing")}});return O})})}),d("WinJS/Controls/Menu/_Command",["exports","../../Core/_Global","../../Core/_Base","../../Core/_ErrorFromName","../../Core/_Resources","../../Utilities/_Control","../../Utilities/_ElementUtilities","../AppBar/_Constants","../Flyout/_Overlay"],function(a,b,c,d,e,f,g,h,i){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{MenuCommand:c.Namespace._lazy(function(){function a(a){var c=this.winControl;if(c){var d=!0;if(c._type===h.typeToggle)c.selected=!c.selected;else if(c._type===h.typeFlyout&&c._flyout){var e=c._flyout;"string"==typeof e&&(e=b.document.getElementById(e)),e.show||(e=e.winControl),e&&e.show&&(c._parentFlyout?(d=!1,e.show(c._parentFlyout._currentAnchor,c._parentFlyout._currentPlacement,c._parentFlyout._currentAlignment)):e.show(this))}c.onclick&&c.onclick(a),d&&c._parentFlyout&&c._parentFlyout.hide()}}function j(){this&&this.focus&&(this.focus(),this.addEventListener("mousemove",k,!1))
  }function k(){this&&this.focus&&this!==b.document.activeElement&&this.focus()}function l(){var a=this,c=m(a);c&&this===b.document.activeElement&&g.hasClass(c,h.menuClass)&&c.focus?c.focus():c&&this===b.document.activeElement&&c.children&&c.children.length>0&&c.children[0]&&g.hasClass(c.children[0],h.firstDivClass)&&c.children[0].focus&&c.children[0].focus(),this.removeEventListener("mousemove",k,!1)}function m(a){for(;a&&!g.hasClass(a,h.flyoutClass);)a=a.parentElement;return a}var n={get ariaLabel(){return e._getWinJSString("ui/menuCommandAriaLabel").value},get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get badClick(){return"Invalid argument: The onclick property for an {0} must be a function"},get badHrElement(){return"Invalid argument: For a separator, the element must be null or an hr element"},get badButtonElement(){return"Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"}};return c.Class.define(function(b,c){if(b&&b.winControl)throw new d("WinJS.UI.MenuCommand.DuplicateConstruction",n.duplicateConstruction);if(this._disposed=!1,c||(c={}),c.type||(this._type=h.typeButton),this._element=b,c.type===h.typeSeparator?this._createSeparator():this._createButton(),g.addClass(this._element,"win-disposable"),this._element.winControl=this,g.addClass(this._element,h.menuCommandClass),c.selected||c.type!==h.typeToggle||(this.selected=!1),c.onclick&&(this.onclick=c.onclick),c.onclick=a,f.setOptions(this,c),this._type!==h.typeSeparator){var e=this._element.getAttribute("role");(null===e||""===e||void 0===e)&&(e="menuitem",this._type===h.typeToggle&&(e="menuitemcheckbox"),this._element.setAttribute("role",e),this._type===h.typeFlyout&&this._element.setAttribute("aria-haspopup",!0));var i=this._element.getAttribute("aria-label");(null===i||""===i||void 0===i)&&this._element.setAttribute("aria-label",n.ariaLabel)}this._element.addEventListener("mouseover",j,!1),this._element.addEventListener("mouseout",l,!1)},{id:{get:function(){return this._element.id},set:function(a){this._element.id||(this._element.id=a)}},type:{get:function(){return this._type},set:function(a){this._type||(this._type=a!==h.typeButton&&a!==h.typeFlyout&&a!==h.typeToggle&&a!==h.typeSeparator?h.typeButton:a)}},label:{get:function(){return this._label},set:function(a){this._label=a,this._element.textContent=this.label,this._element.setAttribute("aria-label",this.label)}},onclick:{get:function(){return this._onclick},set:function(a){if(a&&"function"!=typeof a)throw new d("WinJS.UI.MenuCommand.BadClick",e._formatString(n.badClick,"MenuCommand"));this._onclick=a}},flyout:{get:function(){var a=this._flyout;return"string"==typeof a&&(a=b.document.getElementById(a)),a&&!a.element&&(a=a.winControl),a},set:function(a){var b=a;b&&"string"!=typeof b&&(b.element&&(b=b.element),b&&(b.id?b=b.id:(b.id=g._uniqueID(b),b=b.id))),"string"==typeof b&&this._element.setAttribute("aria-owns",b),this._flyout=a}},selected:{get:function(){return"true"===this._element.getAttribute("aria-checked")},set:function(a){this._element.setAttribute("aria-checked",!!a)}},element:{get:function(){return this._element}},disabled:{get:function(){return!!this._element.disabled},set:function(a){this._element.disabled=!!a}},hidden:{get:function(){return"hidden"===this._element.style.visibility},set:function(a){var b=i._Overlay._getParentControlUsingClassName(this._element,h.menuClass);if(b&&!b.hidden)throw new d("WinJS.UI.MenuCommand.CannotChangeHiddenProperty",e._formatString(i._Overlay.commonstrings.cannotChangeHiddenProperty,"Menu"));var c=this._element.style;a?(c.visibility="hidden",c.display="none"):(c.visibility="",c.display="block")}},extraClass:{get:function(){return this._extraClass},set:function(a){this._extraClass&&g.removeClass(this._element,this._extraClass),this._extraClass=a,g.addClass(this._element,this._extraClass)}},dispose:function(){this._disposed||(this._disposed=!0,this._flyout&&this._flyout.dispose())},addEventListener:function(a,b,c){return this._element.addEventListener(a,b,c)},removeEventListener:function(a,b,c){return this._element.removeEventListener(a,b,c)},_createSeparator:function(){if(this._element){if("HR"!==this._element.tagName)throw new d("WinJS.UI.MenuCommand.BadHrElement",n.badHrElement)}else this._element=b.document.createElement("hr")},_createButton:function(){if(this._element){if("BUTTON"!==this._element.tagName)throw new d("WinJS.UI.MenuCommand.BadButtonElement",n.badButtonElement);this._element.innerHTML=""}else this._element=b.document.createElement("button");this._element.type="button"}})})})}),d("WinJS/Controls/Menu",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","../Core/_WriteProfilerMark","../Utilities/_ElementUtilities","../Utilities/_Hoverable","./AppBar/_Constants","./Flyout","./Flyout/_Overlay","./Menu/_Command","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";b.Namespace.define("WinJS.UI",{Menu:b.Namespace._lazy(function(){var h=g.Key,m={get ariaLabel(){return e._getWinJSString("ui/menuAriaLabel").value},get requiresCommands(){return"Invalid argument: commands must not be empty"},get nullCommand(){return"Invalid argument: command must not be null"}},n=b.Class.derive(j.Flyout,function(b,d){d=d||{},this._element=b||a.document.createElement("div"),this._id=this._element.id||g._uniqueID(this._element),this._writeProfilerMark("constructor,StartTM"),!d.commands&&this._element&&(d=c._shallowCopy(d),d.commands=this._verifyCommandsOnly(this._element,"WinJS.UI.MenuCommand"));var e=this._element?this._element.getAttribute("role"):null,f=this._element?this._element.getAttribute("aria-label"):null;this._baseFlyoutConstructor(this._element,d),(null===e||""===e||void 0===e)&&this._element.setAttribute("role","menu"),(null===f||""===f||void 0===f)&&this._element.setAttribute("aria-label",m.ariaLabel),this._element.addEventListener("keydown",this._handleKeyDown,!0),g.addClass(this._element,i.menuClass),this.hide(),this._writeProfilerMark("constructor,StopTM")},{commands:{set:function(a){if(!this.hidden)throw new d("WinJS.UI.Menu.CannotChangeCommandsWhenVisible",e._formatString(k._Overlay.commonstrings.cannotChangeCommandsWhenVisible,"Menu"));g.empty(this._element),Array.isArray(a)||(a=[a]);for(var b=a.length,c=0;b>c;c++)this._addCommand(a[c])}},getCommandById:function(a){for(var b=this.element.querySelectorAll("#"+a),c=[],d=0,e=b.length;e>d;d++)b[d].winControl&&c.push(b[d].winControl);return 1===c.length?c[0]:0===c.length?null:c},showCommands:function(a){if(!a)throw new d("WinJS.UI.Menu.RequiresCommands",m.requiresCommands);this._showCommands(a,!0)},hideCommands:function(a){if(!a)throw new d("WinJS.UI.Menu.RequiresCommands",m.requiresCommands);this._hideCommands(a,!0)},showOnlyCommands:function(a){if(!a)throw new d("WinJS.UI.Menu.RequiresCommands",m.requiresCommands);this._showOnlyCommands(a,!0)},show:function(a,b,c){this._writeProfilerMark("show,StartTM"),this._show(a,b,c)},_show:function(a,b,c){this._checkForFlyoutCommands(),this._baseFlyoutShow(a,b,c)},_addCommand:function(a){if(!a)throw new d("WinJS.UI.Menu.NullCommand",m.nullCommand);a._element||(a=new l.MenuCommand(null,a)),a._element.parentElement&&a._element.parentElement.removeChild(a._element),this._element.appendChild(a._element)},_checkToggle:function(){var a=this._element.querySelectorAll(".win-command[aria-checked]"),b=!1;if(a)for(var c=0;c<a.length;c++)if(a[c]&&a[c].winControl&&!a[c].winControl.hidden){b=!0;break}b?g.addClass(this._element,i.menuToggleClass):g.removeClass(this._element,i.menuToggleClass)},_checkForFlyoutCommands:function(){for(var a=this._element.querySelectorAll(".win-command"),b=0;b<a.length;b++)a[b].winControl&&(a[b].winControl._parentFlyout=this)},_handleKeyDown:function(b){var c=this;b.keyCode===h.escape?(this.winControl._keyboardInvoked=!0,this.winControl._hide()):b.keyCode!==h.space&&b.keyCode!==h.enter||this!==a.document.activeElement?b.keyCode===h.upArrow?(n._focusOnPreviousElement(c),b.preventDefault()):b.keyCode===h.downArrow?(n._focusOnNextElement(c),b.preventDefault()):b.keyCode===h.tab&&b.preventDefault():(b.preventDefault(),this.winControl.hide())},_writeProfilerMark:function(a){f("WinJS.UI.Menu:"+this._id+":"+a)}});return n._focusOnNextElement=function(b){var c=a.document.activeElement;do c=c===b?c.firstElementChild:c.nextElementSibling,c?c.focus():c=b;while(c!==a.document.activeElement)},n._focusOnPreviousElement=function(b){var c=a.document.activeElement;do c=c===b?c.lastElementChild:c.previousElementSibling,c?c.focus():c=b;while(c!==a.document.activeElement)},n})})}),d("WinJS/Controls/SearchBox/_SearchSuggestionManagerShim",["exports","../../_Signal","../../Core/_Base","../../Core/_BaseUtils","../../Core/_Events","../../BindingList"],function(a,b,c,d,e){"use strict";var f={reset:0,itemInserted:1,itemRemoved:2,itemChanged:3},g={Query:0,Result:1,Separator:2},h=c.Class.derive(Array,function(){},{reset:function(){this.length=0,this.dispatchEvent("vectorchanged",{collectionChange:f.reset,index:0})},insert:function(a,b){this.splice(a,0,b),this.dispatchEvent("vectorchanged",{collectionChange:f.itemInserted,index:a})},remove:function(a){this.splice(a,1),this.dispatchEvent("vectorchanged",{collectionChange:f.itemRemoved,index:a})}});c.Class.mix(h,e.eventMixin);var i=c.Class.define(function(){this._data=[]},{size:{get:function(){return this._data.length}},appendQuerySuggestion:function(a){this._data.push({kind:g.Query,text:a})},appendQuerySuggestions:function(a){a.forEach(this.appendQuerySuggestion.bind(this))},appendResultSuggestion:function(a,b,c,d,e){this._data.push({kind:g.Result,text:a,detailText:b,tag:c,imageUrl:d,imageAlternateText:e,image:null})},appendSearchSeparator:function(a){this._data.push({kind:g.Separator,text:a})}}),j=c.Class.define(function(a,b,c){this._queryText=a,this._language=b,this._linguisticDetails=c,this._searchSuggestionCollection=new i},{language:{get:function(){return this._language}},linguisticDetails:{get:function(){return this._linguisticDetails}},queryText:{get:function(){return this._queryText}},searchSuggestionCollection:{get:function(){return this._searchSuggestionCollection}},getDeferral:function(){return this._deferralSignal||(this._deferralSignal=new b)},_deferralSignal:null}),k=c.Class.define(function(){this._updateVector=this._updateVector.bind(this),this._suggestionVector=new h,this._query="",this._history={"":[]},this._dataSource=[],this.searchHistoryContext="",this.searchHistoryEnabled=!0},{addToHistory:function(a){if(a&&a.trim()){for(var b=this._history[this.searchHistoryContext],c=-1,d=0,e=b.length;e>d;d++){var f=b[d];if(f.text.toLowerCase()===a.toLowerCase()){c=d;break}}c>=0&&b.splice(c,1),b.splice(0,0,{text:a,kind:g.Query}),this._updateVector()}},clearHistory:function(){this._history[this.searchHistoryContext]=[],this._updateVector()},setLocalContentSuggestionSettings:function(){},setQuery:function(a){function b(a){c._dataSource=a,c._updateVector()}var c=this;this._query=a;var d=new j(a);this.dispatchEvent("suggestionsrequested",{request:d}),d._deferralSignal?d._deferralSignal.promise.then(b.bind(this,d.searchSuggestionCollection._data)):b(d.searchSuggestionCollection._data)},searchHistoryContext:{get:function(){return""+this._searchHistoryContext},set:function(a){a=""+a,this._history[a]||(this._history[a]=[]),this._searchHistoryContext=a}},searchHistoryEnabled:{get:function(){return this._searchHistoryEnabled},set:function(a){this._searchHistoryEnabled=a}},suggestions:{get:function(){return this._suggestionVector}},_updateVector:function(){for(this.suggestions.insert(this.suggestions.length,{text:"",kind:g.Query});this.suggestions.length>1;)this.suggestions.remove(0);var a=0,b={};if(this.searchHistoryEnabled){var c=this._query.toLowerCase();this._history[this.searchHistoryContext].forEach(function(d){var e=d.text.toLowerCase();0===e.indexOf(c)&&(this.suggestions.insert(a,d),b[e]=!0,a++)},this)}this._dataSource.forEach(function(c){c.kind===g.Query?b[c.text.toLowerCase()]||(this.suggestions.insert(a,c),a++):(this.suggestions.insert(a,c),a++)},this),this.suggestions.remove(this.suggestions.length-1)}});c.Class.mix(k,e.eventMixin),c.Namespace._moduleDefine(a,null,{_CollectionChange:f,_SearchSuggestionKind:g,_SearchSuggestionManagerShim:k})}),d("WinJS/Controls/SearchBox",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Animations","../BindingList","../Controls/Repeater","../Utilities/_Control","../Utilities/_ElementListUtilities","../Utilities/_ElementUtilities","../Utilities/_Hoverable","./SearchBox/_SearchSuggestionManagerShim","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";c.Namespace.define("WinJS.UI",{SearchBox:c.Namespace._lazy(function(){var m=e._createEventProperty,o=l.Key,p={searchBox:"win-searchbox",searchBoxInput:"win-searchbox-input",searchBoxButton:"win-searchbox-button",searchBoxFlyout:"win-searchbox-flyout",searchBoxSuggestionResult:"win-searchbox-suggestion-result",searchBoxSuggestionQuery:"win-searchbox-suggestion-query",searchBoxSuggestionSeparator:"win-searchbox-suggestion-separator",searchBoxSuggestionSelected:"win-searchbox-suggestion-selected",searchBoxFlyoutHighlightText:"win-searchbox-flyout-highlighttext",searchBoxButtonInputFocus:"win-searchbox-button-input-focus",searchBoxInputFocus:"win-searchbox-input-focus",searchBoxSuggestionResultText:"win-searchbox-suggestion-result-text",searchBoxSuggestionResultDetailedText:"win-searchbox-suggestion-result-detailed-text",searchboxDisabled:"win-searchbox-disabled",searchboxHitHighlightSpan:"win-searchbox-hithighlight-span"},q={querychanged:"querychanged",querysubmitted:"querysubmitted",resultsuggestionchosen:"resultsuggestionchosen",suggestionsrequested:"suggestionsrequested",receivingfocusonkeyboardinput:"receivingfocusonkeyboardinput"},r={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get invalidSearchBoxSuggestionKind(){return"Error: Invalid search suggestion kind."},get ariaLabel(){return f._getWinJSString("ui/searchBoxAriaLabel").value},get ariaLabelInputNoPlaceHolder(){return f._getWinJSString("ui/searchBoxAriaLabelInputNoPlaceHolder").value},get ariaLabelInputPlaceHolder(){return f._getWinJSString("ui/searchBoxAriaLabelInputPlaceHolder").value},get ariaLabelButton(){return f._getWinJSString("ui/searchBoxAriaLabelButton").value},get ariaLabelQuery(){return f._getWinJSString("ui/searchBoxAriaLabelQuery").value},get ariaLabelSeparator(){return f._getWinJSString("ui/searchBoxAriaLabelSeparator").value},get ariaLabelResult(){return f._getWinJSString("ui/searchBoxAriaLabelResult").value}},s=c.Class.define(function(c,e){if(c=c||a.document.createElement("div"),c.winControl)throw new d("WinJS.UI.SearchBox.DuplicateConstruction",r.duplicateConstruction);c.winControl=this,this._domElement=null,this._inputElement=null,this._buttonElement=null,this._flyout=null,this._flyoutDivElement=null,this._repeaterDivElement=null,this._repeater=null,this._disposed=!1,this._focusOnKeyboardInput=!1,this._chooseSuggestionOnEnter=!1,this._lastKeyPressLanguage="",this._prevQueryText="",this._prevLinguisticDetails=this._createSearchQueryLinguisticDetails([],0,0,"",""),this._prevCompositionStart=0,this._prevCompositionLength=0,this._isProcessingDownKey=!1,this._isProcessingUpKey=!1,this._isProcessingTabKey=!1,this._isProcessingEnterKey=!1,this._isFlyoutPointerDown=!1,this._reflowImeOnPointerRelease=!1,this._currentFocusedIndex=-1,this._currentSelectedIndex=-1,this._suggestionRendererBind=this._suggestionRenderer.bind(this),this._requestingFocusOnKeyboardInputHandlerBind=this._requestingFocusOnKeyboardInputHandler.bind(this),this._suggestionsRequestedHandlerBind=this._suggestionsRequestedHandler.bind(this),this._suggestionsChangedHandlerBind=this._suggestionsChangedHandler.bind(this),this._keydownCaptureHandlerBind=this._keydownCaptureHandler.bind(this),this._frameLoadCaptureHandlerBind=this._frameLoadCaptureHandler.bind(this),this._searchSuggestionManager=null,this._searchSuggestions=null,this._searchSuggestionManager=b.Windows.ApplicationModel.Search.Core.SearchSuggestionManager?new b.Windows.ApplicationModel.Search.Core.SearchSuggestionManager:new n._SearchSuggestionManagerShim,this._searchSuggestions=this._searchSuggestionManager.suggestions,this._hitFinder=null,this._setElement(c),j.setOptions(this,e),this._setAccessibilityProperties(),l.addClass(c,"win-disposable")},{element:{get:function(){return this._domElement}},placeholderText:{get:function(){return this._inputElement.placeholder},set:function(a){this._inputElement.placeholder=a,this._updateInputElementAriaLabel()}},queryText:{get:function(){return this._inputElement.value},set:function(a){this._inputElement.value=a}},searchHistoryDisabled:{get:function(){return this._searchSuggestionManager?!this._searchSuggestionManager.searchHistoryEnabled:!0},set:function(a){this._searchSuggestionManager&&(this._searchSuggestionManager.searchHistoryEnabled=!a)}},searchHistoryContext:{get:function(){return this._searchSuggestionManager?this._searchSuggestionManager.searchHistoryContext:""},set:function(a){this._searchSuggestionManager&&(this._searchSuggestionManager.searchHistoryContext=a)}},focusOnKeyboardInput:{get:function(){return this._focusOnKeyboardInput},set:function(b){this._focusOnKeyboardInput&&!b?this._searchSuggestionManager instanceof n._SearchSuggestionManagerShim?this._updateKeydownCaptureListeners(a.top,!1):this._searchSuggestionManager.removeEventListener("requestingfocusonkeyboardinput",this._requestingFocusOnKeyboardInputHandlerBind):!this._focusOnKeyboardInput&&b&&(this._searchSuggestionManager instanceof n._SearchSuggestionManagerShim?this._updateKeydownCaptureListeners(a.top,!0):this._searchSuggestionManager.addEventListener("requestingfocusonkeyboardinput",this._requestingFocusOnKeyboardInputHandlerBind)),this._focusOnKeyboardInput=!!b}},chooseSuggestionOnEnter:{get:function(){return this._chooseSuggestionOnEnter},set:function(a){this._chooseSuggestionOnEnter=!!a,this._updateSearchButtonClass()}},disabled:{get:function(){return this._inputElement.disabled},set:function(b){this._inputElement.disabled!==!!b&&(b?(this._isFlyoutShown&&this._hideFlyout(),l.addClass(this.element,p.searchboxDisabled),this._inputElement.disabled=!0,this._buttonElement.disabled=!0,this._domElement.disabled=!0):(this._inputElement.disabled=!1,this._buttonElement.disabled=!1,this._domElement.disabled=!1,l.removeClass(this.element,p.searchboxDisabled),a.document.activeElement===this.element&&l._setActive(this._inputElement)))}},setLocalContentSuggestionSettings:function(a){this._searchSuggestionManager&&this._searchSuggestionManager.setLocalContentSuggestionSettings(a)},dispose:function(){this._disposed||(this._flyoutOpenPromise&&this._flyoutOpenPromise.cancel(),this._focusOnKeyboardInput&&(this._searchSuggestionManager instanceof n._SearchSuggestionManagerShim?this._updateKeydownCaptureListeners(a.top,!1):this._searchSuggestionManager.removeEventListener("requestingfocusonkeyboardinput",this._requestingFocusOnKeyboardInputHandlerBind)),this._searchSuggestions.removeEventListener("vectorchanged",this._suggestionsChangedHandlerBind),this._searchSuggestionManager.removeEventListener("suggestionsrequested",this._suggestionsRequestedHandlerBind),this._searchSuggestionManager=null,this._searchSuggestions=null,this._hitFinder=null,this._disposed=!0)},onquerychanged:m(q.querychanged),onquerysubmitted:m(q.querysubmitted),onresultsuggestionchosen:m(q.resultsuggestionchosen),onsuggestionsrequested:m(q.suggestionsrequested),_isFlyoutShown:function(){return"none"!==this._flyoutDivElement.style.display},_isFlyoutBelow:function(){return this._flyoutDivElement.getBoundingClientRect().top>this._inputElement.getBoundingClientRect().top?!0:!1},_getFlyoutTop:function(){if(this._isFlyoutBelow())return this._inputElement.getBoundingClientRect().bottom;var a=this._flyoutDivElement.getBoundingClientRect().bottom-this._flyoutDivElement.getBoundingClientRect().top;return this._inputElement.getBoundingClientRect().top-a},_getFlyoutBottom:function(){if(this._isFlyoutBelow()){var a=this._flyoutDivElement.getBoundingClientRect().bottom-this._flyoutDivElement.getBoundingClientRect().top;return this._inputElement.getBoundingClientRect().bottom+a}return this._inputElement.getBoundingClientRect().top},_updateFlyoutTopAndTouchAction:function(){var a=this._flyoutDivElement.getBoundingClientRect().bottom-this._flyoutDivElement.getBoundingClientRect().top;this._isFlyoutBelow()||(this._flyoutDivElement.style.top="-"+a+"px"),this._flyoutDivElement.style.touchAction=this._flyoutDivElement.scrollHeight>a?"pan-y":"none"},_showFlyout:function(){if(!this._isFlyoutShown()&&0!==this._suggestionsData.length){this._flyoutDivElement.style.display="block";var b=this._flyoutDivElement.clientHeight;b<s._Constants.MIN_POPUP_HEIGHT&&(b=s._Constants.MIN_POPUP_HEIGHT);var c=this._flyoutDivElement.getBoundingClientRect(),d=this.element.getBoundingClientRect(),e=c.bottom-c.top,f=c.right-c.left,h=d.right-d.left,i=a.document.documentElement.clientHeight,j=a.document.documentElement.clientWidth,k=this.element.clientHeight,l=this.element.clientLeft,m=!0;d.bottom+b<=i?this._flyoutDivElement.style.top=k+"px":d.top-b>=0?(this._flyoutDivElement.style.top="-"+e+"px",m=!1):this._flyoutDivElement.style.top=k+"px";var n;n="rtl"===a.getComputedStyle(this._flyoutDivElement).direction?d.right-f>=0||d.left+f>j:d.left+f>j&&d.right-f>=0,this._flyoutDivElement.style.left=n?h-f-l+"px":"-"+l+"px",this._flyoutDivElement.style.touchAction=this._flyoutDivElement.scrollHeight>e?"pan-y":"none",this._addFlyoutIMEPaddingIfRequired(),this._flyoutOpenPromise&&(this._flyoutOpenPromise.cancel(),this._flyoutOpenPromise=null);var o=m?"WinJS-flyoutBelowSearchBox-showPopup":"WinJS-flyoutAboveSearchBox-showPopup";this._flyoutOpenPromise=g.showPopup(this._flyoutDivElement,{top:"0px",left:"0px",keyframe:o})}},_hideFlyout:function(){this._isFlyoutShown()&&(this._flyoutDivElement.style.display="none",this._updateSearchButtonClass())},_addNewSpan:function(b,c,d){var e=a.document.createElement("span");return e.textContent=c,e.setAttribute("aria-hidden","true"),l.addClass(e,p.searchboxHitHighlightSpan),b.insertBefore(e,d),e},_addHitHighlightedText:function(a,b,c){if(c){k.query("."+p.searchboxHitHighlightSpan,a).forEach(function(a){a.parentNode.removeChild(a)});var d=a.firstChild,e=b.hits;e||null===this._hitFinder||b.kind===n._SearchSuggestionKind.Separator||(e=this._hitFinder.find(c));for(var f=s._sortAndMergeHits(e),g=0,h=0;h<f.length;h++){var i=f[h];this._addNewSpan(a,c.substring(g,i.startPosition),d),g=i.startPosition+i.length;var j=this._addNewSpan(a,c.substring(i.startPosition,g),d);l.addClass(j,p.searchBoxFlyoutHighlightText)}g<c.length&&this._addNewSpan(a,c.substring(g),d)}},_findSuggestionElementIndex:function(a){if(a)for(var b=0;b<this._suggestionsData.length;b++)if(this._repeater.elementFromIndex(b)===a)return b;return-1},_isSuggestionSelectable:function(a){return a.kind===n._SearchSuggestionKind.Query||a.kind===n._SearchSuggestionKind.Result},_findNextSuggestionElementIndex:function(a){var b=a+1;0>b&&(b=0);for(var c=b;c<this._suggestionsData.length;c++)if(this._repeater.elementFromIndex(c)&&this._isSuggestionSelectable(this._suggestionsData.getAt(c)))return c;return-1},_findPreviousSuggestionElementIndex:function(a){var b=a-1;b>=this._suggestionsData.length&&(b=this._suggestionsData.length-1);for(var c=b;c>=0;c--)if(this._repeater.elementFromIndex(c)&&this._isSuggestionSelectable(this._suggestionsData.getAt(c)))return c;return-1},_trySetFocusOnSuggestionIndex:function(a){try{this._repeater.elementFromIndex(a).focus()}catch(b){}},_updateFakeFocus:function(){var a;a=this._isFlyoutShown()&&this._chooseSuggestionOnEnter?this._findNextSuggestionElementIndex(-1):-1,this._selectSuggestionAtIndex(a)},_updateSearchButtonClass:function(){-1!==this._currentSelectedIndex||a.document.activeElement!==this._inputElement?l.removeClass(this._buttonElement,p.searchBoxButtonInputFocus):a.document.activeElement===this._inputElement&&l.addClass(this._buttonElement,p.searchBoxButtonInputFocus)},_selectSuggestionAtIndex:function(a){for(var b=null,c=0;c<this._suggestionsData.length;c++)b=this._repeater.elementFromIndex(c),c!==a?(l.removeClass(b,p.searchBoxSuggestionSelected),b.setAttribute("aria-selected","false")):(l.addClass(b,p.searchBoxSuggestionSelected),this._scrollToView(b),b.setAttribute("aria-selected","true"));this._updateSearchButtonClass(),this._currentSelectedIndex=a,b?this._inputElement.setAttribute("aria-activedescendant",this._repeaterDivElement.id+a):this._inputElement.hasAttribute("aria-activedescendant")&&this._inputElement.removeAttribute("aria-activedescendant")},_scrollToView:function(a){var b=this._flyoutDivElement.getBoundingClientRect().bottom-this._flyoutDivElement.getBoundingClientRect().top;if(a.offsetTop+a.offsetHeight>this._flyoutDivElement.scrollTop+b){var c=a.offsetTop+a.offsetHeight-(this._flyoutDivElement.scrollTop+b);l._zoomTo(this._flyoutDivElement,{contentX:0,contentY:this._flyoutDivElement.scrollTop+c,viewportX:0,viewportY:0})}else a.offsetTop<this._flyoutDivElement.scrollTop&&l._zoomTo(this._flyoutDivElement,{contentX:0,contentY:a.offsetTop,viewportX:0,viewportY:0})},_querySuggestionRenderer:function(b){var c=a.document.createElement("div");this._addHitHighlightedText(c,b,b.text),c.title=b.text,l.addClass(c,p.searchBoxSuggestionQuery);var d=this;l._addEventListener(c,"pointerup",function(a){d._inputElement.focus(),d._processSuggestionChosen(b,a)}),c.setAttribute("role","option");var e=f._formatString(r.ariaLabelQuery,b.text);return c.setAttribute("aria-label",e),c},_separatorSuggestionRenderer:function(b){var c=a.document.createElement("div");if(b.text.length>0){var d=a.document.createElement("div");d.textContent=b.text,d.title=b.text,d.setAttribute("aria-hidden","true"),c.appendChild(d)}c.insertAdjacentHTML("beforeend","<hr/>"),l.addClass(c,p.searchBoxSuggestionSeparator),c.setAttribute("role","separator");var e=f._formatString(r.ariaLabelSeparator,b.text);return c.setAttribute("aria-label",e),c},_resultSuggestionRenderer:function(b){var c=a.document.createElement("div"),d=new a.Image;d.style.opacity=0;var e=function(a){function b(){d.removeEventListener("load",b,!1),g.fadeIn(d)}d.addEventListener("load",b,!1),d.src=a};null!==b.image?b.image.openReadAsync().then(function(b){null!==b&&e(a.URL.createObjectURL(b,{oneTimeOnly:!0}))}):null!==b.imageUrl&&e(b.imageUrl),d.setAttribute("aria-hidden","true"),c.appendChild(d);var h=a.document.createElement("div");l.addClass(h,p.searchBoxSuggestionResultText),this._addHitHighlightedText(h,b,b.text),h.title=b.text,h.setAttribute("aria-hidden","true"),c.appendChild(h);var i=a.document.createElement("br");h.appendChild(i);var j=a.document.createElement("span");l.addClass(j,p.searchBoxSuggestionResultDetailedText),this._addHitHighlightedText(j,b,b.detailText),j.title=b.detailText,j.setAttribute("aria-hidden","true"),h.appendChild(j),l.addClass(c,p.searchBoxSuggestionResult);var k=this;l._addEventListener(c,"pointerup",function(a){k._inputElement.focus(),k._processSuggestionChosen(b,a)}),c.setAttribute("role","option");var m=f._formatString(r.ariaLabelResult,b.text,b.detailText);return c.setAttribute("aria-label",m),c},_suggestionRenderer:function(a){var b=null;if(!a)return b;if(a.kind===n._SearchSuggestionKind.Query)b=this._querySuggestionRenderer(a);else if(a.kind===n._SearchSuggestionKind.Separator)b=this._separatorSuggestionRenderer(a);else{if(a.kind!==n._SearchSuggestionKind.Result)throw new d("WinJS.UI.SearchBox.invalidSearchBoxSuggestionKind",r.invalidSearchBoxSuggestionKind);b=this._resultSuggestionRenderer(a)}return b},_setElement:function(b){this._domElement=b,l.addClass(this._domElement,p.searchBox),this._inputElement=a.document.createElement("input"),this._inputElement.type="search",l.addClass(this._inputElement,p.searchBoxInput),this._buttonElement=a.document.createElement("div"),this._buttonElement.tabIndex=-1,l.addClass(this._buttonElement,p.searchBoxButton),this._flyoutDivElement=a.document.createElement("div"),l.addClass(this._flyoutDivElement,p.searchBoxFlyout),this._repeaterDivElement=a.document.createElement("div"),this._suggestionsData=new h.List,this._repeater=new i.Repeater(this._repeaterDivElement,{data:this._suggestionsData,template:this._suggestionRendererBind}),this._domElement.appendChild(this._inputElement),this._domElement.appendChild(this._buttonElement),this._domElement.appendChild(this._flyoutDivElement),this._flyoutDivElement.appendChild(this._repeaterDivElement),this._hideFlyout(),this._wireupUserEvents(),this._wireupWinRTEvents(),this._wireupRepeaterEvents()},_setAccessibilityProperties:function(){var a=this._domElement.getAttribute("aria-label");a||this._domElement.setAttribute("aria-label",r.ariaLabel),this._domElement.setAttribute("role","group"),this._updateInputElementAriaLabel(),this._inputElement.setAttribute("role","textbox"),this._buttonElement.setAttribute("role","button"),this._buttonElement.setAttribute("aria-label",r.ariaLabelButton),this._repeaterDivElement.setAttribute("role","listbox"),l._ensureId(this._repeaterDivElement),this._inputElement.setAttribute("aria-controls",this._repeaterDivElement.id),this._repeaterDivElement.setAttribute("aria-live","polite")},_updateInputElementAriaLabel:function(){var a=r.ariaLabelInputNoPlaceHolder;this._inputElement.placeholder&&this._inputElement.placeholder&&(a=f._formatString(r.ariaLabelInputPlaceHolder,this._inputElement.placeholder)),this._inputElement.setAttribute("aria-label",a)},_submitQuery:function(a,c,d){this._disposed||(b.Windows.Globalization.Language&&(this._lastKeyPressLanguage=b.Windows.Globalization.Language.currentInputMethodLanguageTag),this._fireEvent(s._EventName.querysubmitted,{language:this._lastKeyPressLanguage,linguisticDetails:this._getLinguisticDetails(!0,c),queryText:a,keyModifiers:s._getKeyModifiers(d)}),this._searchSuggestionManager&&this._searchSuggestionManager.addToHistory(this._inputElement.value,this._lastKeyPressLanguage))},_processSuggestionChosen:function(a,b){this.queryText=a.text,a.kind===n._SearchSuggestionKind.Query?this._submitQuery(a.text,!1,b):a.kind===n._SearchSuggestionKind.Result&&this._fireEvent(s._EventName.resultsuggestionchosen,{tag:a.tag,keyModifiers:s._getKeyModifiers(b),storageFile:null}),this._hideFlyout()},_buttonClickHandler:function(a){this._inputElement.focus(),this._submitQuery(this._inputElement.value,!0,a),this._hideFlyout()},_inputOrImeChangeHandler:function(){var a=l._matchesSelector(this._buttonElement,":active");if(!this._isProcessingImeFocusLossKey()&&!a&&!this._isFlyoutPointerDown){var c=this._getLinguisticDetails(!1,!0),d=this._hasLinguisticDetailsChanged(c);if((this._inputElement.value!==this._prevQueryText||0===this._prevCompositionLength||c.queryTextCompositionLength>0)&&(this._prevCompositionStart=c.queryTextCompositionStart,this._prevCompositionLength=c.queryTextCompositionLength),this._prevQueryText===this._inputElement.value&&!d)return;this._prevQueryText=this._inputElement.value,b.Windows.Globalization.Language&&(this._lastKeyPressLanguage=b.Windows.Globalization.Language.currentInputMethodLanguageTag),b.Windows.Data.Text.SemanticTextQuery&&(this._hitFinder=""!==this._inputElement.value?new b.Windows.Data.Text.SemanticTextQuery(this._inputElement.value,this._lastKeyPressLanguage):null),this._fireEvent(s._EventName.querychanged,{language:this._lastKeyPressLanguage,queryText:this._inputElement.value,linguisticDetails:c}),this._searchSuggestionManager&&this._searchSuggestionManager.setQuery(this._inputElement.value,this._lastKeyPressLanguage,c)}},_createSearchQueryLinguisticDetails:function(a,c,d,e,f){for(var g=null,h=[],i=0;i<a.length;i++)h[i]=e+a[i]+f;
  return g=b.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails?new b.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails(h,c,d):{queryTextAlternatives:h,queryTextCompositionStart:c,queryTextCompositionLength:d}},_getLinguisticDetails:function(a,b){var c=null;if(this._inputElement.value===this._prevQueryText&&a&&this._prevLinguisticDetails&&b)c=this._prevLinguisticDetails;else{var d=[],e=0,f=0,g="",h="";if(b&&this._inputElement.msGetInputContext&&this._inputElement.msGetInputContext().getCompositionAlternatives){var i=this._inputElement.msGetInputContext();d=i.getCompositionAlternatives(),e=i.compositionStartOffset,f=i.compositionEndOffset-i.compositionStartOffset,this._inputElement.value!==this._prevQueryText||0===this._prevCompositionLength||f>0?(g=this._inputElement.value.substring(0,e),h=this._inputElement.value.substring(e+f)):(g=this._inputElement.value.substring(0,this._prevCompositionStart),h=this._inputElement.value.substring(this._prevCompositionStart+this._prevCompositionLength))}c=this._createSearchQueryLinguisticDetails(d,e,f,g,h)}return c},_handleTabKeyDown:function(a){var b=!0;a.shiftKey?-1!==this._currentFocusedIndex&&(this._currentFocusedIndex=-1,this._selectSuggestionAtIndex(this._currentFocusedIndex),this._updateSearchButtonClass(),a.preventDefault(),a.stopPropagation(),b=!1):-1===this._currentFocusedIndex&&(this._currentFocusedIndex=this._isFlyoutBelow()?this._findNextSuggestionElementIndex(this._currentFocusedIndex):this._findPreviousSuggestionElementIndex(this._suggestionsData.length),-1!==this._currentFocusedIndex&&(this._selectSuggestionAtIndex(this._currentFocusedIndex),this._updateQueryTextWithSuggestionText(this._currentFocusedIndex),this._updateSearchButtonClass(),a.preventDefault(),a.stopPropagation(),b=!1)),b&&this._hideFlyout()},_keyDownHandler:function(a){if(this._lastKeyPressLanguage=a.locale,a.keyCode===o.tab?this._isProcessingTabKey=!0:a.keyCode===o.upArrow?this._isProcessingUpKey=!0:a.keyCode===o.downArrow?this._isProcessingDownKey=!0:a.keyCode===o.enter&&"ko"===a.locale&&(this._isProcessingEnterKey=!0),a.keyCode!==o.IME)if(a.keyCode===o.tab)this._handleTabKeyDown(a);else if(a.keyCode===o.escape)-1!==this._currentFocusedIndex?(this.queryText=this._prevQueryText,this._currentFocusedIndex=-1,this._selectSuggestionAtIndex(this._currentFocusedIndex),this._updateSearchButtonClass(),a.preventDefault(),a.stopPropagation()):""!==this.queryText&&(this.queryText="",this._inputOrImeChangeHandler(null),this._updateSearchButtonClass(),a.preventDefault(),a.stopPropagation());else if(a.keyCode===o.upArrow){var b;-1!==this._currentSelectedIndex?(b=this._findPreviousSuggestionElementIndex(this._currentSelectedIndex),-1===b&&(this.queryText=this._prevQueryText)):b=this._findPreviousSuggestionElementIndex(this._suggestionsData.length),this._currentFocusedIndex=b,this._selectSuggestionAtIndex(b),this._updateQueryTextWithSuggestionText(this._currentFocusedIndex),this._updateSearchButtonClass(),a.preventDefault(),a.stopPropagation()}else if(a.keyCode===o.downArrow){var c=this._findNextSuggestionElementIndex(this._currentSelectedIndex);-1!==this._currentSelectedIndex&&-1===c&&(this.queryText=this._prevQueryText),this._currentFocusedIndex=c,this._selectSuggestionAtIndex(c),this._updateQueryTextWithSuggestionText(this._currentFocusedIndex),this._updateSearchButtonClass(),a.preventDefault(),a.stopPropagation()}else a.keyCode===o.enter?(-1===this._currentSelectedIndex?this._submitQuery(this._inputElement.value,!0,a):this._processSuggestionChosen(this._suggestionsData.getAt(this._currentSelectedIndex),a),this._hideFlyout()):s._isTypeToSearchKey(a)&&-1!==this._currentFocusedIndex&&(this._currentFocusedIndex=-1,this._selectSuggestionAtIndex(-1),this._updateFakeFocus())},_keyPressHandler:function(a){this._lastKeyPressLanguage=a.locale},_keyUpHandler:function(a){a.keyCode===o.tab?this._isProcessingTabKey=!1:a.keyCode===o.upArrow?this._isProcessingUpKey=!1:a.keyCode===o.downArrow?this._isProcessingDownKey=!1:a.keyCode===o.enter&&(this._isProcessingEnterKey=!1)},_inputFocusHandler:function(a){this._inputElement.value!==this._prevQueryText&&b.Windows.Data.Text.SemanticTextQuery&&(this._hitFinder=""!==this._inputElement.value?new b.Windows.Data.Text.SemanticTextQuery(this._inputElement.value,this._inputElement.lang):null),a.target!==this._inputElement||this._internalFocusMove||(this._showFlyout(),-1!==this._currentFocusedIndex?this._selectSuggestionAtIndex(this._currentFocusedIndex):this._updateFakeFocus(),this._searchSuggestionManager&&this._searchSuggestionManager.setQuery(this._inputElement.value,this._lastKeyPressLanguage,this._getLinguisticDetails(!0,!0))),this._internalFocusMove=!1,l.addClass(this.element,p.searchBoxInputFocus),this._updateSearchButtonClass()},_flyoutBlurHandler:function(){this._isElementInSearchControl(a.document.activeElement)?this._internalFocusMove=!0:(this._hideFlyout(),l.removeClass(this.element,p.searchBoxInputFocus))},_inputBlurHandler:function(){this._isElementInSearchControl(a.document.activeElement)||(this._hideFlyout(),l.removeClass(this.element,p.searchBoxInputFocus)),this._updateSearchButtonClass(),this._isProcessingDownKey=!1,this._isProcessingUpKey=!1,this._isProcessingTabKey=!1,this._isProcessingEnterKey=!1},_isIMEOccludingFlyout:function(a){var b=this._getFlyoutTop(),c=this._getFlyoutBottom();return a.top>=b&&a.top<=c||a.bottom>=b&&a.bottom<=c?!0:!1},_addFlyoutIMEPaddingIfRequired:function(){if(this._isFlyoutShown()&&this._isFlyoutBelow()&&this._inputElement.msGetInputContext&&this._inputElement.msGetInputContext()){var a=this._inputElement.msGetInputContext(),b=a.getCandidateWindowClientRect();if(this._isIMEOccludingFlyout(b)){var c=g.createRepositionAnimation(this._flyoutDivElement.children);this._flyoutDivElement.style.paddingTop=b.bottom-b.top+"px",c.execute()}}},_msCandidateWindowShowHandler:function(){this._addFlyoutIMEPaddingIfRequired(),this._reflowImeOnPointerRelease=!1},_msCandidateWindowHideHandler:function(){if(this._isFlyoutPointerDown)this._reflowImeOnPointerRelease=!0;else{var a=g.createRepositionAnimation(this._flyoutDivElement.children);this._flyoutDivElement.style.paddingTop="",a.execute()}},_wireupUserEvents:function(){var a=this._inputOrImeChangeHandler.bind(this);if(this._buttonElement.addEventListener("click",this._buttonClickHandler.bind(this)),this._inputElement.addEventListener("input",a),this._inputElement.addEventListener("keydown",this._keyDownHandler.bind(this)),this._inputElement.addEventListener("keypress",this._keyPressHandler.bind(this)),this._inputElement.addEventListener("keyup",this._keyUpHandler.bind(this)),this._inputElement.addEventListener("focus",this._inputFocusHandler.bind(this)),this._inputElement.addEventListener("blur",this._inputBlurHandler.bind(this)),l._addEventListener(this._inputElement,"pointerdown",this._inputPointerDownHandler.bind(this)),this._flyoutDivElement.addEventListener("blur",this._flyoutBlurHandler.bind(this)),l._addEventListener(this._flyoutDivElement,"pointerdown",this._flyoutPointerDownHandler.bind(this)),l._addEventListener(this._flyoutDivElement,"pointerup",this._flyoutPointerReleasedHandler.bind(this)),l._addEventListener(this._flyoutDivElement,"pointercancel",this._flyoutPointerReleasedHandler.bind(this)),l._addEventListener(this._flyoutDivElement,"pointerout",this._flyoutPointerReleasedHandler.bind(this)),this._inputElement.addEventListener("compositionstart",a),this._inputElement.addEventListener("compositionupdate",a),this._inputElement.addEventListener("compositionend",a),this._inputElement.msGetInputContext&&this._inputElement.msGetInputContext()){var b=this._inputElement.msGetInputContext();b.addEventListener("MSCandidateWindowShow",this._msCandidateWindowShowHandler.bind(this)),b.addEventListener("MSCandidateWindowHide",this._msCandidateWindowHideHandler.bind(this))}},_repeaterChangedHandler:function(){this._updateFlyoutTopAndTouchAction(),this._isFlyoutShown()&&(this._repeaterDivElement.style.display="none",this._repeaterDivElement.style.display="block")},_wireupRepeaterEvents:function(){var a=this._repeaterChangedHandler.bind(this);this._repeater.addEventListener("itemchanged",a),this._repeater.addEventListener("iteminserted",a),this._repeater.addEventListener("itemremoved",a),this._repeater.addEventListener("itemsreloaded",a)},_inputPointerDownHandler:function(){a.document.activeElement===this._inputElement&&-1!==this._currentSelectedIndex&&(this._currentFocusedIndex=-1,this._selectSuggestionAtIndex(this._currentFocusedIndex))},_flyoutPointerDownHandler:function(a){this._isFlyoutPointerDown=!0;for(var b=a.target;b&&b.parentNode!==this._repeaterDivElement;)b=b.parentNode;var c=this._findSuggestionElementIndex(b);c>=0&&c<this._suggestionsData.length&&this._currentFocusedIndex!==c&&this._isSuggestionSelectable(this._suggestionsData.getAt(c))&&(this._currentFocusedIndex=c,this._selectSuggestionAtIndex(c),this._updateQueryTextWithSuggestionText(this._currentFocusedIndex)),a.preventDefault()},_flyoutPointerReleasedHandler:function(){if(this._isFlyoutPointerDown=!1,this._reflowImeOnPointerRelease){this._reflowImeOnPointerRelease=!1;var a=g.createRepositionAnimation(this._flyoutDivElement.children);this._flyoutDivElement.style.paddingTop="",a.execute()}},_isElementInSearchControl:function(a){return this.element.contains(a)||this.element===a},_hideFlyoutIfLeavingSearchControl:function(a){this._isFlyoutShown()&&(this._isElementInSearchControl(a)||this._hideFlyout())},_wireupWinRTEvents:function(){this._searchSuggestions.addEventListener("vectorchanged",this._suggestionsChangedHandlerBind),this._searchSuggestionManager.addEventListener("suggestionsrequested",this._suggestionsRequestedHandlerBind)},_suggestionsChangedHandler:function(b){var c=b.collectionChange||b.detail.collectionChange,d=+b.index===b.index?b.index:b.detail.index,e=n._CollectionChange;if(c===e.reset)this._isFlyoutShown()&&this._hideFlyout(),this._suggestionsData.splice(0,this._suggestionsData.length);else if(c===e.itemInserted){var f=this._searchSuggestions[d];this._suggestionsData.splice(d,0,f),this._showFlyout()}else if(c===e.itemRemoved)1===this._suggestionsData.length&&(l._setActive(this._inputElement),this._hideFlyout()),this._suggestionsData.splice(d,1);else if(c===e.itemChanged){var f=this._searchSuggestions[d];if(f!==this._suggestionsData.getAt(d))this._suggestionsData.setAt(d,f);else{var g=this._repeater.elementFromIndex(d);if(l.hasClass(g,p.searchBoxSuggestionQuery))this._addHitHighlightedText(g,f,f.text);else{var h=g.querySelector("."+p.searchBoxSuggestionResultText);if(h){this._addHitHighlightedText(h,f,f.text);var i=g.querySelector("."+p.searchBoxSuggestionResultDetailedText);i&&this._addHitHighlightedText(i,f,f.detailText)}}}}a.document.activeElement===this._inputElement&&this._updateFakeFocus()},_suggestionsRequestedHandler:function(a){b.Windows.Globalization.Language&&(this._lastKeyPressLanguage=b.Windows.Globalization.Language.currentInputMethodLanguageTag);var c,d=a.request||a.detail.request;this._fireEvent(s._EventName.suggestionsrequested,{setPromise:function(a){c=d.getDeferral(),a.then(function(){c.complete()})},searchSuggestionCollection:d.searchSuggestionCollection,language:this._lastKeyPressLanguage,linguisticDetails:this._getLinguisticDetails(!0,!0),queryText:this._inputElement.value})},_fireEvent:function(b,c){var d=a.document.createEvent("CustomEvent");return d.initCustomEvent(b,!0,!0,c),this.element.dispatchEvent(d)},_requestingFocusOnKeyboardInputHandler:function(){if(this._fireEvent(s._EventName.receivingfocusonkeyboardinput,null),a.document.activeElement!==this._inputElement)try{this._inputElement.focus()}catch(b){}},_keydownCaptureHandler:function(a){this._focusOnKeyboardInput&&this._shouldKeyTriggerTypeToSearch(a)&&this._requestingFocusOnKeyboardInputHandler(a)},_frameLoadCaptureHandler:function(a){this._focusOnKeyboardInput&&this._updateKeydownCaptureListeners(a.target.contentWindow,!0)},_updateKeydownCaptureListeners:function(a,b){try{b?a.document.addEventListener("keydown",this._keydownCaptureHandlerBind,!0):a.document.removeEventListener("keydown",this._keydownCaptureHandlerBind,!0)}catch(c){}if(a.frames)for(var d=0,e=a.frames.length;e>d;d++){var f=a.frames[d];this._updateKeydownCaptureListeners(f,b);try{b?f.frameElement&&f.frameElement.addEventListener("load",this._frameLoadCaptureHandlerBind,!0):f.frameElement&&f.frameElement.removeEventListener("load",this._frameLoadCaptureHandlerBind,!0)}catch(c){}}},_shouldKeyTriggerTypeToSearch:function(a){var b=!1;if(!a.metaKey&&(!a.ctrlKey&&!a.altKey||a.getModifierState&&a.getModifierState("AltGraph")))switch(a.keyCode){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 186:case 187:case 188:case 189:case 190:case 191:case 192:case 219:case 220:case 221:case 222:case 223:case 226:case 229:case 231:b=!0}return b},_hasLinguisticDetailsChanged:function(a){var b=!1;return(this._prevLinguisticDetails.queryTextCompositionStart!==a.queryTextCompositionStart||this._prevLinguisticDetails.queryTextCompositionLength!==a.queryTextCompositionLength||this._prevLinguisticDetails.queryTextAlternatives.length!==a.queryTextAlternatives.length)&&(b=!0),this._prevLinguisticDetails=a,b},_isProcessingImeFocusLossKey:function(){return this._isProcessingDownKey||this._isProcessingUpKey||this._isProcessingTabKey||this._isProcessingEnterKey},_updateQueryTextWithSuggestionText:function(a){a>=0&&a<this._suggestionsData.length&&(this.queryText=this._suggestionsData.getAt(a).text)}},{_EventName:{querychanged:q.querychanged,querysubmitted:q.querysubmitted,resultsuggestionchosen:q.resultsuggestionchosen,suggestionsrequested:q.suggestionsrequested,receivingfocusonkeyboardinput:q.receivingfocusonkeyboardinput},_Constants:{MIN_POPUP_HEIGHT:152},createResultSuggestionImage:function(a){return b.Windows.Foundation.Uri&&b.Windows.Storage.Streams.RandomAccessStreamReference?b.Windows.Storage.Streams.RandomAccessStreamReference.createFromUri(new b.Windows.Foundation.Uri(a)):a},_getKeyModifiers:function(a){var b={ctrlKey:1,altKey:2,shiftKey:4},c=0;return a.ctrlKey&&(c|=b.ctrlKey),a.altKey&&(c|=b.altKey),a.shiftKey&&(c|=b.shiftKey),c},_sortAndMergeHits:function(a){var b=[];if(a){for(var c=new Array(a.length),d=0;d<a.length;d++)c.push({startPosition:a[d].startPosition,length:a[d].length});c.sort(s._hitStartPositionAscendingSorter),c.reduce(s._hitIntersectionReducer,b)}return b},_hitStartPositionAscendingSorter:function(a,b){var c=0;return a.startPosition<b.startPosition?c=-1:a.startPosition>b.startPosition&&(c=1),c},_hitIntersectionReducer:function(a,b,c){if(0===c)a.push(b);else{var d=a[a.length-1],e=d.startPosition+d.length;if(b.startPosition<=e){var f=b.startPosition+b.length;f>e&&(d.length=f-d.startPosition)}else a.push(b)}return a},_isTypeToSearchKey:function(a){return a.shiftKey||a.ctrlKey||a.altKey?!1:!0}});return c.Class.mix(s,j.DOMEventMixin),s})})}),d("WinJS/Controls/SettingsFlyout",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Pages","../Promise","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_ElementListUtilities","../Utilities/_Hoverable","./AppBar/_Constants","./Flyout/_Overlay","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";c.Namespace.define("WinJS.UI",{SettingsFlyout:c.Namespace._lazy(function(){function d(){if(b.Windows.UI.ApplicationSettings.SettingsEdgeLocation){var a=b.Windows.UI.ApplicationSettings;return a.SettingsPane.edge===a.SettingsEdgeLocation.left}return!1}function n(a,b){for(var c,d,e=a.querySelectorAll("."+o.settingsFlyoutClass),f=0;f<e.length;f++)if(d=e[f].winControl){if(d.settingsCommandId===b){c=d;break}e[f].id===b&&(c=c||d)}return c}var q,r=l.Key,s="narrow",t="wide",u=c.Class.derive(p._Overlay,function(b,c){this._element=b||a.document.createElement("div"),this._id=this._element.id||l._uniqueID(this._element),this._writeProfilerMark("constructor,StartTM"),this._baseOverlayConstructor(this._element,c),this._addFirstDiv(),this._addFinalDiv(),this._element.addEventListener("keydown",this._handleKeyDown,!0),p._Overlay._createClickEatingDivAppBar(),this._element.style.visibilty="hidden",this._element.style.display="none",l.addClass(this._element,o.settingsFlyoutClass),m.query("div.win-content",this._element).forEach(function(a){l._matchesSelector(a,".win-ui-dark, .win-ui-dark *")||l.addClass(a,o.flyoutLightClass)});var d=this._element.getAttribute("role");(null===d||""===d||void 0===d)&&this._element.setAttribute("role","dialog");var e=this._element.getAttribute("aria-label");(null===e||""===e||void 0===e)&&this._element.setAttribute("aria-label",w.ariaLabel),this._addOverlayEventHandlers(!0),this._currentAnimateIn=this._animateSlideIn,this._currentAnimateOut=this._animateSlideOut,this._writeProfilerMark("constructor,StopTM")},{width:{get:function(){return this._width},set:function(a){l._deprecated(w.widthDeprecationMessage),a!==this._width&&(this._width===s?l.removeClass(this._element,o.narrowClass):this._width===t&&l.removeClass(this._element,o.wideClass),this._width=a,this._width===s?l.addClass(this._element,o.narrowClass):this._width===t&&l.addClass(this._element,o.wideClass))}},settingsCommandId:{get:function(){return this._settingsCommandId},set:function(a){this._settingsCommandId=a}},show:function(){this.disabled||(this._writeProfilerMark("show,StartTM"),this._show())},_dispose:function(){k.disposeSubTree(this.element),this._dismiss()},_show:function(){this._baseShow(),p._Overlay._showClickEatingDivAppBar()},_endShow:function(){this._initAfterAnimation()},_initAfterAnimation:function(){if(q=0,!l.hasClass(this.element.children[0],o.firstDivClass)){var a=this.element.querySelectorAll(".win-first");a&&a.length>0&&a.item(0).parentNode.removeChild(a.item(0)),this._addFirstDiv()}if(this.element.children[0]&&(l._addEventListener(this.element.children[0],"focusout",function(){q=1},!1),this.element.children[0].focus()),!l.hasClass(this.element.children[this.element.children.length-1],o.finalDivClass)){var b=this.element.querySelectorAll(".win-final");b&&b.length>0&&b.item(0).parentNode.removeChild(b.item(0)),this._addFinalDiv()}this._setBackButtonsAriaLabel()},_setBackButtonsAriaLabel:function(){for(var a,b=this.element.querySelectorAll(".win-backbutton"),c=0;c<b.length;c++)a=b[c].getAttribute("aria-label"),(null===a||""===a||void 0===a)&&b[c].setAttribute("aria-label",w.backbuttonAriaLabel)},hide:function(){this._writeProfilerMark("hide,StartTM"),this._hide()},_hide:function(){this._baseHide()&&p._Overlay._hideClickEatingDivAppBar()},_animateSlideIn:function(){var a=d(),b=a?"-100px":"100px";m.query("div.win-content",this._element).forEach(function(a){h.enterPage(a,{left:b})});var c,e=this._element.offsetWidth;return a?(c={top:"0px",left:"-"+e+"px"},this._element.style.right="auto",this._element.style.left="0px"):(c={top:"0px",left:e+"px"},this._element.style.right="0px",this._element.style.left="auto"),this._element.style.opacity=1,this._element.style.visibility="visible",h.showPanel(this._element,c)},_animateSlideOut:function(){var a,b=this._element.offsetWidth;return d()?(a={top:"0px",left:b+"px"},this._element.style.right="auto",this._element.style.left="-"+b+"px"):(a={top:"0px",left:"-"+b+"px"},this._element.style.right="-"+b+"px",this._element.style.left="auto"),h.showPanel(this._element,a)},_fragmentDiv:{get:function(){return this._fragDiv},set:function(a){this._fragDiv=a}},_unloadPage:function(b){var c=b.currentTarget.winControl;c.removeEventListener(p._Overlay.afterHide,this._unloadPage,!1),j.as().then(function(){c._fragmentDiv&&(a.document.body.removeChild(c._fragmentDiv),c._fragmentDiv=null)})},_dismiss:function(){this.addEventListener(p._Overlay.afterHide,this._unloadPage,!1),this._hide()},_handleKeyDown:function(b){if(b.keyCode===r.escape)b.preventDefault(),b.stopPropagation(),this.winControl._dismiss();else if(b.keyCode!==r.space&&b.keyCode!==r.enter||this.children[0]!==a.document.activeElement){if(b.shiftKey&&b.keyCode===r.tab&&this.children[0]===a.document.activeElement){b.preventDefault(),b.stopPropagation();for(var c=this.getElementsByTagName("*"),d=c.length-2;d>=0&&(c[d].focus(),c[d]!==a.document.activeElement);d--);}}else b.preventDefault(),b.stopPropagation(),this.winControl._dismiss()},_focusOnLastFocusableElementFromParent:function(){var b=a.document.activeElement;if(q&&b&&l.hasClass(b,o.firstDivClass)){var c=this.parentElement.getElementsByTagName("*");if(!(c.length<=2)){var d,e=c[c.length-1].tabIndex;if(e){for(d=c.length-2;d>0;d--)if(c[d].tabIndex===e){c[d].focus();break}}else for(d=c.length-2;d>0&&("DIV"===c[d].tagName&&null===c[d].getAttribute("tabIndex")||(c[d].focus(),c[d]!==a.document.activeElement));d--);}}},_focusOnFirstFocusableElementFromParent:function(){var b=a.document.activeElement;if(b&&l.hasClass(b,o.finalDivClass)){var c=this.parentElement.getElementsByTagName("*");if(!(c.length<=2)){var d,e=c[0].tabIndex;if(e){for(d=1;d<c.length-1;d++)if(c[d].tabIndex===e){c[d].focus();break}}else for(d=1;d<c.length-1&&("DIV"===c[d].tagName&&null===c[d].getAttribute("tabIndex")||(c[d].focus(),c[d]!==a.document.activeElement));d++);}}},_addFirstDiv:function(){for(var b=this._element.getElementsByTagName("*"),c=0,d=0;d<b.length;d++)0<b[d].tabIndex&&(0===c||b[d].tabIndex<c)&&(c=b[d].tabIndex);var e=a.document.createElement("div");e.className=o.firstDivClass,e.style.display="inline",e.setAttribute("role","menuitem"),e.setAttribute("aria-hidden","true"),e.tabIndex=c,l._addEventListener(e,"focusin",this._focusOnLastFocusableElementFromParent,!1),this._element.children[0]?this._element.insertBefore(e,this._element.children[0]):this._element.appendChild(e)},_addFinalDiv:function(){for(var b=this._element.getElementsByTagName("*"),c=0,d=0;d<b.length;d++)b[d].tabIndex>c&&(c=b[d].tabIndex);var e=a.document.createElement("div");e.className=o.finalDivClass,e.style.display="inline",e.setAttribute("role","menuitem"),e.setAttribute("aria-hidden","true"),e.tabIndex=c,l._addEventListener(e,"focusin",this._focusOnFirstFocusableElementFromParent,!1),this._element.appendChild(e)},_writeProfilerMark:function(a){g("WinJS.UI.SettingsFlyout:"+this._id+":"+a)}});u.show=function(){b.Windows.UI.ApplicationSettings.SettingsPane&&b.Windows.UI.ApplicationSettings.SettingsPane.show();for(var c=a.document.querySelectorAll('div[data-win-control="WinJS.UI.SettingsFlyout"]'),d=c.length,e=0;d>e;e++){var f=c[e].winControl;f&&f._dismiss()}};var v={event:void 0};u.populateSettings=function(a){if(v.event=a.detail,v.event.applicationcommands){var c=b.Windows.UI.ApplicationSettings;Object.keys(v.event.applicationcommands).forEach(function(a){var b=v.event.applicationcommands[a];b.title||(b.title=a);var d=new c.SettingsCommand(a,b.title,u._onSettingsCommand);v.event.e.request.applicationCommands.append(d)})}},u._onSettingsCommand=function(a){var b=a.id;v.event.applicationcommands&&v.event.applicationcommands[b]&&u.showSettings(b,v.event.applicationcommands[b].href)},u.showSettings=function(b,c){var d=n(a.document,b);if(d)d.show();else{if(!c)throw new e("WinJS.UI.SettingsFlyout.BadReference",w.badReference);var f=a.document.createElement("div");f=a.document.body.appendChild(f),i.render(c,f).then(function(){d=n(f,b),d?(d._fragmentDiv=f,d.show()):a.document.body.removeChild(f)})}};var w={get ariaLabel(){return f._getWinJSString("ui/settingsFlyoutAriaLabel").value},get badReference(){return"Invalid argument: Invalid href to settings flyout fragment"},get backbuttonAriaLabel(){return f._getWinJSString("ui/backbuttonarialabel").value},get widthDeprecationMessage(){return"SettingsFlyout.width may be altered or unavailable in future versions. Instead, style the CSS width property on elements with the .win-settingsflyout class."}};return u})})}),d("WinJS/Controls/NavBar/_Command",["exports","../../Core/_Global","../../Core/_Base","../../Core/_ErrorFromName","../../Core/_Resources","../../ControlProcessor","../../Navigation","../../Utilities/_Control","../../Utilities/_ElementUtilities","../AppBar/_Icon"],function(a,b,c,d,e,f,g,h,i,j){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{_WinPressed:c.Namespace._lazy(function(){var a=c.Class.define(function(a){this._element=a,i._addEventListener(this._element,"pointerdown",this._MSPointerDownButtonHandler.bind(this))},{_MSPointerDownButtonHandler:function(c){this._pointerUpBound||(this._pointerUpBound=this._MSPointerUpHandler.bind(this),this._pointerCancelBound=this._MSPointerCancelHandler.bind(this),this._pointerOverBound=this._MSPointerOverHandler.bind(this),this._pointerOutBound=this._MSPointerOutHandler.bind(this)),c.isPrimary&&(this._pointerId&&this._resetPointer(),i._matchesSelector(c.target,".win-interactive, .win-interactive *")||(this._pointerId=c.pointerId,i._addEventListener(b,"pointerup",this._pointerUpBound,!0),i._addEventListener(b,"pointercancel",this._pointerCancelBound),!0,i._addEventListener(this._element,"pointerover",this._pointerOverBound,!0),i._addEventListener(this._element,"pointerout",this._pointerOutBound,!0),i.addClass(this._element,a.winPressed)))},_MSPointerOverHandler:function(b){this._pointerId===b.pointerId&&i.addClass(this._element,a.winPressed)},_MSPointerOutHandler:function(b){this._pointerId===b.pointerId&&i.removeClass(this._element,a.winPressed)},_MSPointerCancelHandler:function(a){this._pointerId===a.pointerId&&this._resetPointer()},_MSPointerUpHandler:function(a){this._pointerId===a.pointerId&&this._resetPointer()},_resetPointer:function(){this._pointerId=null,i._removeEventListener(b,"pointerup",this._pointerUpBound,!0),i._removeEventListener(b,"pointercancel",this._pointerCancelBound,!0),i._removeEventListener(this._element,"pointerover",this._pointerOverBound,!0),i._removeEventListener(this._element,"pointerout",this._pointerOutBound,!0),i.removeClass(this._element,a.winPressed)},dispose:function(){this._disposed||(this._disposed=!0,this._resetPointer())}},{winPressed:"win-pressed"});return a}),NavBarCommand:c.Namespace._lazy(function(){var e=i.Key,k={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"}},l=c.Class.define(function(a,c){if(a=a||b.document.createElement("DIV"),c=c||{},a.winControl)throw new d("WinJS.UI.NavBarCommand.DuplicateConstruction",k.duplicateConstruction);a.winControl=this,this._element=a,i.addClass(this.element,l._ClassName.navbarcommand),i.addClass(this.element,"win-disposable"),this._tooltip=null,this._splitOpened=!1,this._buildDom(),a.addEventListener("keydown",this._keydownHandler.bind(this)),h.setOptions(this,c)},{element:{get:function(){return this._element}},label:{get:function(){return this._label},set:function(a){this._label=a,this._labelEl.textContent=a}},tooltip:{get:function(){return this._tooltip},set:function(a){this._tooltip=a,this._tooltip||""===this._tooltip?this._element.setAttribute("title",this._tooltip):this._element.removeAttribute("title")}},icon:{get:function(){return this._icon},set:function(a){this._icon=j[a]||a,this._icon&&1===this._icon.length?(this._imageSpan.textContent=this._icon,this._imageSpan.style.backgroundImage="",this._imageSpan.style.msHighContrastAdjust="",this._imageSpan.style.display=""):this._icon&&this._icon.length>1?(this._imageSpan.textContent="",this._imageSpan.style.backgroundImage=this._icon,this._imageSpan.style.msHighContrastAdjust="none",this._imageSpan.style.display=""):(this._imageSpan.textContent="",this._imageSpan.style.backgroundImage="",this._imageSpan.style.msHighContrastAdjust="",this._imageSpan.style.display="none")}},location:{get:function(){return this._location},set:function(a){this._location=a}},state:{get:function(){return this._state},set:function(a){this._state=a}},splitButton:{get:function(){return this._split},set:function(a){this._split=a,this._splitButtonEl.style.display=this._split?"":"none"}},splitOpened:{get:function(){return this._splitOpened},set:function(a){this._splitOpened!==!!a&&this._toggleSplit()}},_toggleSplit:function(){this._splitOpened=!this._splitOpened,this._splitOpened?(i.addClass(this._splitButtonEl,l._ClassName.navbarcommandsplitbuttonopened),this._splitButtonEl.setAttribute("aria-expanded","true")):(i.removeClass(this._splitButtonEl,l._ClassName.navbarcommandsplitbuttonopened),this._splitButtonEl.setAttribute("aria-expanded","false")),this._fireEvent(l._EventName._splitToggle)},_rtl:{get:function(){return"rtl"===b.getComputedStyle(this.element).direction}},_keydownHandler:function(a){if(!i._matchesSelector(a.target,".win-interactive, .win-interactive *")){var b=this._rtl?e.rightArrow:e.leftArrow,c=this._rtl?e.leftArrow:e.rightArrow;a.altKey||a.keyCode!==b&&a.keyCode!==e.home&&a.keyCode!==e.end||a.target!==this._splitButtonEl?a.altKey||a.keyCode!==c||!this.splitButton||a.target!==this._buttonEl&&!this._buttonEl.contains(a.target)?a.keyCode!==e.space&&a.keyCode!==e.enter||a.target!==this._buttonEl&&!this._buttonEl.contains(a.target)?a.keyCode!==e.space&&a.keyCode!==e.enter||a.target!==this._splitButtonEl||this._toggleSplit():(this.location&&g.navigate(this.location,this.state),this._fireEvent(l._EventName._invoked)):(i._setActive(this._splitButtonEl),a.keyCode===c&&a.stopPropagation(),a.preventDefault()):(i._setActive(this._buttonEl),a.keyCode===b&&a.stopPropagation(),a.preventDefault())}},_getFocusInto:function(a){var b=this._rtl?e.rightArrow:e.leftArrow;return a===b&&this.splitButton?this._splitButtonEl:this._buttonEl},_buildDom:function(){var b='<div tabindex="0" role="button" class="'+l._ClassName.navbarcommandbutton+'"><div class="'+l._ClassName.navbarcommandbuttoncontent+'"><div class="'+l._ClassName.navbarcommandicon+'"></div><div class="'+l._ClassName.navbarcommandlabel+'"></div></div></div><div tabindex="-1" aria-expanded="false" class="'+l._ClassName.navbarcommandsplitbutton+'"></div>';this.element.insertAdjacentHTML("afterBegin",b),this._buttonEl=this.element.firstElementChild,this._buttonPressedBehavior=new a._WinPressed(this._buttonEl),this._contentEl=this._buttonEl.firstElementChild,this._imageSpan=this._contentEl.firstElementChild,this._imageSpan.style.display="none",this._labelEl=this._imageSpan.nextElementSibling,this._splitButtonEl=this._buttonEl.nextElementSibling,this._splitButtonPressedBehavior=new a._WinPressed(this._splitButtonEl),this._splitButtonEl.style.display="none",i._ensureId(this._buttonEl),this._splitButtonEl.setAttribute("aria-labelledby",this._buttonEl.id),this._buttonEl.addEventListener("click",this._handleButtonClick.bind(this));var c=new i._MutationObserver(this._splitButtonAriaExpandedPropertyChangeHandler.bind(this));c.observe(this._splitButtonEl,{attributes:!0,attributeFilter:["aria-expanded"]}),this._splitButtonEl.addEventListener("click",this._handleSplitButtonClick.bind(this));for(var d=this._splitButtonEl.nextSibling;d;)this._buttonEl.insertBefore(d,this._contentEl),"#text"!==d.nodeName&&f.processAll(d),d=this._splitButtonEl.nextSibling},_handleButtonClick:function(a){var b=a.target;i._matchesSelector(b,".win-interactive, .win-interactive *")||(this.location&&g.navigate(this.location,this.state),this._fireEvent(l._EventName._invoked))},_splitButtonAriaExpandedPropertyChangeHandler:function(){"true"===this._splitButtonEl.getAttribute("aria-expanded")!==this._splitOpened&&this._toggleSplit()},_handleSplitButtonClick:function(){this._toggleSplit()},_fireEvent:function(a,c){var d=b.document.createEvent("CustomEvent");d.initCustomEvent(a,!0,!1,c),this.element.dispatchEvent(d)},dispose:function(){this._disposed||(this._disposed=!0,this._buttonPressedBehavior.dispose(),this._splitButtonPressedBehavior.dispose())
  }},{_ClassName:{navbarcommand:"win-navbarcommand",navbarcommandbutton:"win-navbarcommand-button",navbarcommandbuttoncontent:"win-navbarcommand-button-content",navbarcommandsplitbutton:"win-navbarcommand-splitbutton",navbarcommandsplitbuttonopened:"win-navbarcommand-splitbutton-opened",navbarcommandicon:"win-navbarcommand-icon",navbarcommandlabel:"win-navbarcommand-label"},_EventName:{_invoked:"_invoked",_splitToggle:"_splittoggle"}});return c.Class.mix(l,h.DOMEventMixin),l})})}),d("WinJS/Controls/NavBar/_Container",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Events","../../Core/_Log","../../Core/_Resources","../../Core/_WriteProfilerMark","../../Animations","../../Animations/_TransitionAnimation","../../BindingList","../../ControlProcessor","../../Navigation","../../Promise","../../Scheduler","../../Utilities/_Control","../../Utilities/_ElementUtilities","../../Utilities/_KeyboardBehavior","../../Utilities/_UI","../AppBar/_Constants","../Repeater","./_Command"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){"use strict";function x(){return null===b.document.activeElement||b.document.activeElement===b.document.body}c.Namespace._moduleDefine(a,"WinJS.UI",{NavBarContainer:c.Namespace._lazy(function(){var a=r.Key,y=3e3,z=r._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",A=0,B=f._createEventProperty,C={invoked:"invoked",splittoggle:"splittoggle"},D={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get navBarContainerViewportAriaLabel(){return h._getWinJSString("ui/navBarContainerViewportAriaLabel").value}},E=c.Class.define(function(a,c){if(a=a||b.document.createElement("DIV"),this._id=a.id||r._uniqueID(a),this._writeProfilerMark("constructor,StartTM"),c=c||{},a.winControl)throw new e("WinJS.UI.NavBarContainer.DuplicateConstruction",D.duplicateConstruction);a.winControl=this,this._element=a,r.addClass(this.element,E._ClassName.navbarcontainer),r.addClass(this.element,"win-disposable"),a.getAttribute("tabIndex")||(a.tabIndex=-1),this._focusCurrentItemPassivelyBound=this._focusCurrentItemPassively.bind(this),this._closeSplitAndResetBound=this._closeSplitAndReset.bind(this),this._currentManipulationState=A,this._panningDisabled=!r._supportsSnapPoints,this._fixedSize=!1,this._maxRows=1,this._sizes={},this._setupTree(),this._duringConstructor=!0,this._dataChangingBound=this._dataChanging.bind(this),this._dataChangedBound=this._dataChanged.bind(this),n.addEventListener("navigated",this._closeSplitAndResetBound),this.layout=c.layout||t.Orientation.horizontal,c.maxRows&&(this.maxRows=c.maxRows),c.template&&(this.template=c.template),c.data&&(this.data=c.data),c.fixedSize&&(this.fixedSize=c.fixedSize),q._setOptions(this,c,!0),this._duringConstructor=!1,c.currentIndex&&(this.currentIndex=c.currentIndex),this._updatePageUI(),p.schedule(function(){this._updateAppBarReference()},p.Priority.normal,this,"WinJS.UI.NavBarContainer_async_initialize"),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},template:{get:function(){return this._template},set:function(a){if(this._template=a,this._repeater){var c=this.element.contains(b.document.activeElement);this._duringConstructor||this._closeSplitIfOpen(),this._repeater.template=this._repeater.template,this._duringConstructor||(this._measured=!1,this._sizes.itemMeasured=!1,this._reset(),c&&this._keyboardBehavior._focus(0))}}},_render:function(a){var c=b.document.createElement("div"),d=this._template;d&&(d.render?d.render(a,c):d.winControl&&d.winControl.render?d.winControl.render(a,c):c.appendChild(d(a)));var e=new w.NavBarCommand(c,a);return e._element},data:{get:function(){return this._repeater&&this._repeater.data},set:function(a){a||(a=new l.List),this._duringConstructor||this._closeSplitIfOpen(),this._removeDataChangingEvents(),this._removeDataChangedEvents();var c=this.element.contains(b.document.activeElement);this._repeater||(this._surfaceEl.innerHTML="",this._repeater=new v.Repeater(this._surfaceEl,{template:this._render.bind(this)})),this._addDataChangingEvents(a),this._repeater.data=a,this._addDataChangedEvents(a),this._duringConstructor||(this._measured=!1,this._sizes.itemMeasured=!1,this._reset(),c&&this._keyboardBehavior._focus(0))}},maxRows:{get:function(){return this._maxRows},set:function(a){a=+a===a?a:1,this._maxRows=Math.max(1,a),this._duringConstructor||(this._closeSplitIfOpen(),this._measured=!1,this._reset())}},layout:{get:function(){return this._layout},set:function(a){a===t.Orientation.vertical?(this._layout=t.Orientation.vertical,r.removeClass(this.element,E._ClassName.horizontal),r.addClass(this.element,E._ClassName.vertical)):(this._layout=t.Orientation.horizontal,r.removeClass(this.element,E._ClassName.vertical),r.addClass(this.element,E._ClassName.horizontal)),this._viewportEl.style.msScrollSnapType="",this._zooming=!1,this._duringConstructor||(this._measured=!1,this._sizes.itemMeasured=!1,this._ensureVisible(this._keyboardBehavior.currentIndex,!0),this._updatePageUI(),this._closeSplitIfOpen())}},currentIndex:{get:function(){return this._keyboardBehavior.currentIndex},set:function(a){if(a===+a){var c=this.element.contains(b.document.activeElement);this._keyboardBehavior.currentIndex=a,this._ensureVisible(this._keyboardBehavior.currentIndex,!0),c&&this._keyboardBehavior._focus()}}},fixedSize:{get:function(){return this._fixedSize},set:function(a){this._fixedSize=!!a,this._duringConstructor||(this._closeSplitIfOpen(),this._measured?this._surfaceEl.children.length>0&&this._updateGridStyles():this._measure())}},oninvoked:B(C.invoked),onsplittoggle:B(C.splittoggle),forceLayout:function(){this._resizeHandler(),this._measured&&(this._scrollPosition=r.getScrollPosition(this._viewportEl)[this.layout===t.Orientation.horizontal?"scrollLeft":"scrollTop"]),this._duringForceLayout=!0,this._ensureVisible(this._keyboardBehavior.currentIndex,!0),this._updatePageUI(),this._duringForceLayout=!1},_updateAppBarReference:function(){if(!this._appBarEl||!this._appBarEl.contains(this.element)){this._appBarEl&&(this._appBarEl.removeEventListener("beforeshow",this._closeSplitAndResetBound),this._appBarEl.removeEventListener("beforeshow",this._resizeImplBound),this._appBarEl.removeEventListener("aftershow",this._focusCurrentItemPassivelyBound));for(var a=this.element.parentNode;a&&!r.hasClass(a,u.appBarClass);)a=a.parentNode;this._appBarEl=a,this._appBarEl&&(this._appBarEl.addEventListener("beforeshow",this._closeSplitAndResetBound),this._appBarEl.addEventListener("aftershow",this._focusCurrentItemPassivelyBound))}},_closeSplitAndReset:function(){this._closeSplitIfOpen(),this._reset()},_dataChanging:function(a){this._elementHadFocus=b.document.activeElement,this._currentSplitNavItem&&this._currentSplitNavItem.splitOpened&&("itemremoved"===a.type?this._surfaceEl.children[a.detail.index].winControl===this._currentSplitNavItem&&this._closeSplitIfOpen():"itemchanged"===a.type?this._surfaceEl.children[a.detail.index].winControl===this._currentSplitNavItem&&this._closeSplitIfOpen():"itemmoved"===a.type?this._surfaceEl.children[a.detail.oldIndex].winControl===this._currentSplitNavItem&&this._closeSplitIfOpen():"reload"===a.type&&this._closeSplitIfOpen())},_dataChanged:function(a){this._measured=!1,"itemremoved"===a.type?a.detail.index<this._keyboardBehavior.currentIndex?this._keyboardBehavior.currentIndex--:a.detail.index===this._keyboardBehavior.currentIndex&&(this._keyboardBehavior.currentIndex=this._keyboardBehavior.currentIndex,x()&&this._elementHadFocus&&this._keyboardBehavior._focus()):"itemchanged"===a.type?a.detail.index===this._keyboardBehavior.currentIndex&&x()&&this._elementHadFocus&&this._keyboardBehavior._focus():"iteminserted"===a.type?a.detail.index<=this._keyboardBehavior.currentIndex&&this._keyboardBehavior.currentIndex++:"itemmoved"===a.type?a.detail.oldIndex===this._keyboardBehavior.currentIndex&&(this._keyboardBehavior.currentIndex=a.detail.newIndex,x()&&this._elementHadFocus&&this._keyboardBehavior._focus()):"reload"===a.type&&(this._keyboardBehavior.currentIndex=0,x()&&this._elementHadFocus&&this._keyboardBehavior._focus()),this._ensureVisible(this._keyboardBehavior.currentIndex,!0),this._updatePageUI()},_focusCurrentItemPassively:function(){this.element.contains(b.document.activeElement)&&this._keyboardBehavior._focus()},_reset:function(){this._keyboardBehavior.currentIndex=0,this.element.contains(b.document.activeElement)&&this._keyboardBehavior._focus(0),this._viewportEl.style.msScrollSnapType="",this._zooming=!1,this._ensureVisible(0,!0),this._updatePageUI()},_removeDataChangedEvents:function(){this._repeater&&(this._repeater.data.removeEventListener("itemchanged",this._dataChangedBound),this._repeater.data.removeEventListener("iteminserted",this._dataChangedBound),this._repeater.data.removeEventListener("itemmoved",this._dataChangedBound),this._repeater.data.removeEventListener("itemremoved",this._dataChangedBound),this._repeater.data.removeEventListener("reload",this._dataChangedBound))},_addDataChangedEvents:function(){this._repeater&&(this._repeater.data.addEventListener("itemchanged",this._dataChangedBound),this._repeater.data.addEventListener("iteminserted",this._dataChangedBound),this._repeater.data.addEventListener("itemmoved",this._dataChangedBound),this._repeater.data.addEventListener("itemremoved",this._dataChangedBound),this._repeater.data.addEventListener("reload",this._dataChangedBound))},_removeDataChangingEvents:function(){this._repeater&&(this._repeater.data.removeEventListener("itemchanged",this._dataChangingBound),this._repeater.data.removeEventListener("iteminserted",this._dataChangingBound),this._repeater.data.removeEventListener("itemmoved",this._dataChangingBound),this._repeater.data.removeEventListener("itemremoved",this._dataChangingBound),this._repeater.data.removeEventListener("reload",this._dataChangingBound))},_addDataChangingEvents:function(a){a.addEventListener("itemchanged",this._dataChangingBound),a.addEventListener("iteminserted",this._dataChangingBound),a.addEventListener("itemmoved",this._dataChangingBound),a.addEventListener("itemremoved",this._dataChangingBound),a.addEventListener("reload",this._dataChangingBound)},_mouseleave:function(){this._mouseInViewport&&(this._mouseInViewport=!1,this._updateArrows())},_MSPointerDown:function(a){a.pointerType===z&&this._mouseInViewport&&(this._mouseInViewport=!1,this._updateArrows())},_MSPointerMove:function(a){a.pointerType!==z&&(this._mouseInViewport||(this._mouseInViewport=!0,this._updateArrows()))},_setupTree:function(){this._animateNextPreviousButtons=o.wrap(),this._element.addEventListener("mouseleave",this._mouseleave.bind(this)),r._addEventListener(this._element,"pointerdown",this._MSPointerDown.bind(this)),r._addEventListener(this._element,"pointermove",this._MSPointerMove.bind(this)),r._addEventListener(this._element,"focusin",this._focusHandler.bind(this),!1),this._pageindicatorsEl=b.document.createElement("div"),r.addClass(this._pageindicatorsEl,E._ClassName.pageindicators),this._element.appendChild(this._pageindicatorsEl),this._ariaStartMarker=b.document.createElement("div"),this._element.appendChild(this._ariaStartMarker),this._viewportEl=b.document.createElement("div"),r.addClass(this._viewportEl,E._ClassName.viewport),this._element.appendChild(this._viewportEl),this._viewportEl.setAttribute("role","group"),this._viewportEl.setAttribute("aria-label",D.navBarContainerViewportAriaLabel),this._boundResizeHandler=this._resizeHandler.bind(this),r._resizeNotifier.subscribe(this._element,this._boundResizeHandler),this._viewportEl.addEventListener("mselementresize",this._resizeHandler.bind(this)),this._viewportEl.addEventListener("scroll",this._scrollHandler.bind(this)),this._viewportEl.addEventListener("MSManipulationStateChanged",this._MSManipulationStateChangedHandler.bind(this)),this._ariaEndMarker=b.document.createElement("div"),this._element.appendChild(this._ariaEndMarker),this._surfaceEl=b.document.createElement("div"),r.addClass(this._surfaceEl,E._ClassName.surface),this._viewportEl.appendChild(this._surfaceEl),this._surfaceEl.addEventListener("_invoked",this._navbarCommandInvokedHandler.bind(this)),this._surfaceEl.addEventListener("_splittoggle",this._navbarCommandSplitToggleHandler.bind(this)),r._addEventListener(this._surfaceEl,"focusin",this._itemsFocusHandler.bind(this),!1),this._surfaceEl.addEventListener("keydown",this._keyDownHandler.bind(this));for(var a=this.element.firstElementChild;a!==this._pageindicatorsEl;)this._surfaceEl.appendChild(a),m.process(a),a=this.element.firstElementChild;this._leftArrowEl=b.document.createElement("div"),r.addClass(this._leftArrowEl,E._ClassName.navleftarrow),r.addClass(this._leftArrowEl,E._ClassName.navarrow),this._element.appendChild(this._leftArrowEl),this._leftArrowEl.addEventListener("click",this._goLeft.bind(this)),this._leftArrowEl.style.opacity=0,this._leftArrowEl.style.visibility="hidden",this._leftArrowFadeOut=o.wrap(),this._rightArrowEl=b.document.createElement("div"),r.addClass(this._rightArrowEl,E._ClassName.navrightarrow),r.addClass(this._rightArrowEl,E._ClassName.navarrow),this._element.appendChild(this._rightArrowEl),this._rightArrowEl.addEventListener("click",this._goRight.bind(this)),this._rightArrowEl.style.opacity=0,this._rightArrowEl.style.visibility="hidden",this._rightArrowFadeOut=o.wrap(),this._keyboardBehavior=new s._KeyboardBehavior(this._surfaceEl,{scroller:this._viewportEl}),this._winKeyboard=new s._WinKeyboard(this._surfaceEl)},_goRight:function(){this._sizes.rtl?this._goPrev():this._goNext()},_goLeft:function(){this._sizes.rtl?this._goNext():this._goPrev()},_goNext:function(){this._measure();var a=this._sizes.rowsPerPage*this._sizes.columnsPerPage,b=Math.min(Math.floor(this._keyboardBehavior.currentIndex/a)+1,this._sizes.pages-1);this._keyboardBehavior.currentIndex=Math.min(a*b,this._surfaceEl.children.length),this._keyboardBehavior._focus()},_goPrev:function(){this._measure();var a=this._sizes.rowsPerPage*this._sizes.columnsPerPage,b=Math.max(0,Math.floor(this._keyboardBehavior.currentIndex/a)-1);this._keyboardBehavior.currentIndex=Math.max(a*b,0),this._keyboardBehavior._focus()},_currentPage:{get:function(){return this.layout===t.Orientation.horizontal&&(this._measure(),this._sizes.viewportOffsetWidth>0)?Math.min(this._sizes.pages-1,Math.round(this._scrollPosition/this._sizes.viewportOffsetWidth)):0}},_resizeHandler:function(){if(!this._disposed&&this._measured){var a=this.layout===t.Orientation.horizontal?this._sizes.viewportOffsetWidth!==parseFloat(b.getComputedStyle(this._viewportEl).width):this._sizes.viewportOffsetHeight!==parseFloat(b.getComputedStyle(this._viewportEl).height);a&&(this._measured=!1,this._pendingResize||(this._pendingResize=!0,this._resizeImplBound=this._resizeImplBound||this._resizeImpl.bind(this),this._updateAppBarReference(),this._appBarEl&&this._appBarEl.winControl&&this._appBarEl.winControl.hidden?(p.schedule(this._resizeImplBound,p.Priority.idle,null,"WinJS.UI.NavBarContainer._resizeImpl"),this._appBarEl.addEventListener("beforeshow",this._resizeImplBound)):this._resizeImpl()))}},_resizeImpl:function(){!this._disposed&&this._pendingResize&&(this._pendingResize=!1,this._appBarEl&&this._appBarEl.removeEventListener("beforeshow",this._resizeImplBound),this._keyboardBehavior.currentIndex=0,this.element.contains(b.document.activeElement)&&this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex),this._closeSplitIfOpen(),this._ensureVisible(this._keyboardBehavior.currentIndex,!0),this._updatePageUI())},_keyDownHandler:function(c){var d=c.keyCode;if(!c.altKey&&(d===a.pageUp||d===a.pageDown)){var e=c.target;if(r._matchesSelector(e,".win-interactive, .win-interactive *"))return;var f=this._keyboardBehavior.currentIndex;this._measure();var g=this._sizes,h=Math.floor(f/(g.columnsPerPage*g.rowsPerPage)),i=null;if(d===a.pageUp){if(this.layout===t.Orientation.horizontal){var j=h*g.columnsPerPage*g.rowsPerPage;f===j&&this._surfaceEl.children[f].winControl._buttonEl===b.document.activeElement?f-=g.columnsPerPage*g.rowsPerPage:f=j}else{var k=this._surfaceEl.children[f],l=k.offsetTop,m=l+k.offsetHeight,n=this._zooming?this._zoomPosition:this._scrollPosition;if(l>=n&&m<n+g.viewportOffsetHeight)for(;f>0&&this._surfaceEl.children[f-1].offsetTop>n;)f--;if(this._keyboardBehavior.currentIndex===f){var o=m-g.viewportOffsetHeight;for(f=Math.max(0,f-1);f>0&&this._surfaceEl.children[f-1].offsetTop>o;)f--;i=f>0?this._surfaceEl.children[f].offsetTop-this._sizes.itemMarginTop:0}}f=Math.max(f,0),this._keyboardBehavior.currentIndex=f;var p=this._surfaceEl.children[f].winControl._buttonEl;null!==i&&this._scrollTo(i),r._setActive(p,this._viewportEl)}else{if(this.layout===t.Orientation.horizontal){var q=(h+1)*g.columnsPerPage*g.rowsPerPage-1;f===q?f+=g.columnsPerPage*g.rowsPerPage:f=q}else{var k=this._surfaceEl.children[this._keyboardBehavior.currentIndex],l=k.offsetTop,m=l+k.offsetHeight,n=this._zooming?this._zoomPosition:this._scrollPosition;if(l>=n&&m<n+g.viewportOffsetHeight)for(;f<this._surfaceEl.children.length-1&&this._surfaceEl.children[f+1].offsetTop+this._surfaceEl.children[f+1].offsetHeight<n+g.viewportOffsetHeight;)f++;if(f===this._keyboardBehavior.currentIndex){var s=l+g.viewportOffsetHeight;for(f=Math.min(this._surfaceEl.children.length-1,f+1);f<this._surfaceEl.children.length-1&&this._surfaceEl.children[f+1].offsetTop+this._surfaceEl.children[f+1].offsetHeight<s;)f++;i=f<this._surfaceEl.children.length-1?this._surfaceEl.children[f+1].offsetTop-this._sizes.viewportOffsetHeight:this._scrollLength-this._sizes.viewportOffsetHeight}}f=Math.min(f,this._surfaceEl.children.length-1),this._keyboardBehavior.currentIndex=f;var p=this._surfaceEl.children[f].winControl._buttonEl;null!==i&&this._scrollTo(i);try{r._setActive(p,this._viewportEl)}catch(u){}}}},_focusHandler:function(a){var b=a.target;this._surfaceEl.contains(b)||(this._skipEnsureVisible=!0,this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex))},_itemsFocusHandler:function(a){var b=a.target;if(b!==this._surfaceEl){for(;b.parentNode!==this._surfaceEl;)b=b.parentNode;for(var c=-1;b;)c++,b=b.previousSibling;this._skipEnsureVisible?this._skipEnsureVisible=!1:this._ensureVisible(c)}},_ensureVisible:function(a,b){if(this._measure(),this.layout===t.Orientation.horizontal){var c=Math.floor(a/(this._sizes.rowsPerPage*this._sizes.columnsPerPage));this._scrollTo(c*this._sizes.viewportOffsetWidth,b)}else{var d,e=this._surfaceEl.children[a];d=a>0?e.offsetTop-this._sizes.itemMarginTop:0;var f;f=a<this._surfaceEl.children.length-1?this._surfaceEl.children[a+1].offsetTop-this._sizes.viewportOffsetHeight:this._scrollLength-this._sizes.viewportOffsetHeight;var g=this._zooming?this._zoomPosition:this._scrollPosition;g=Math.max(g,f),g=Math.min(g,d),this._scrollTo(g,b)}},_scrollTo:function(a,b){if(this._measure(),a=this.layout===t.Orientation.horizontal?Math.max(0,Math.min(this._scrollLength-this._sizes.viewportOffsetWidth,a)):Math.max(0,Math.min(this._scrollLength-this._sizes.viewportOffsetHeight,a)),b){if(Math.abs(this._scrollPosition-a)>1){this._zooming=!1,this._scrollPosition=a,this._updatePageUI(),this._duringForceLayout||this._closeSplitIfOpen();var c={};c[this.layout===t.Orientation.horizontal?"scrollLeft":"scrollTop"]=a,r.setScrollPosition(this._viewportEl,c)}}else(!this._zooming&&Math.abs(this._scrollPosition-a)>1||this._zooming&&Math.abs(this._zoomPosition-a)>1)&&(this._zoomPosition=a,this._zooming=!0,this.layout===t.Orientation.horizontal?(this._viewportEl.style.msScrollSnapType="none",r._zoomTo(this._viewportEl,{contentX:a,contentY:0,viewportX:0,viewportY:0})):r._zoomTo(this._viewportEl,{contentX:0,contentY:a,viewportX:0,viewportY:0}),this._closeSplitIfOpen())},_MSManipulationStateChangedHandler:function(a){this._currentManipulationState=a.currentState,a.currentState===a.MS_MANIPULATION_STATE_ACTIVE&&(this._viewportEl.style.msScrollSnapType="",this._zooming=!1),b.clearTimeout(this._manipulationStateTimeoutId),a.currentState===a.MS_MANIPULATION_STATE_STOPPED&&(this._manipulationStateTimeoutId=b.setTimeout(function(){this._viewportEl.style.msScrollSnapType="",this._zooming=!1,this._updateCurrentIndexIfPageChanged()}.bind(this),100))},_scrollHandler:function(){if(!this._disposed&&(this._measured=!1,!this._checkingScroll)){var a=this;this._checkingScroll=d._requestAnimationFrame(function(){if(!a._disposed){a._checkingScroll=null;var b=r.getScrollPosition(a._viewportEl)[a.layout===t.Orientation.horizontal?"scrollLeft":"scrollTop"];b!==a._scrollPosition&&(a._scrollPosition=b,a._closeSplitIfOpen()),a._updatePageUI(),a._zooming||a._currentManipulationState!==A||a._updateCurrentIndexIfPageChanged()}})}},_updateCurrentIndexIfPageChanged:function(){if(this.layout===t.Orientation.horizontal){this._measure();var a=this._currentPage,c=a*this._sizes.rowsPerPage*this._sizes.columnsPerPage,d=(a+1)*this._sizes.rowsPerPage*this._sizes.columnsPerPage-1;(this._keyboardBehavior.currentIndex<c||this._keyboardBehavior.currentIndex>d)&&(this._keyboardBehavior.currentIndex=c,this.element.contains(b.document.activeElement)&&this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex))}},_measure:function(){if(!this._measured){this._resizeImpl(),this._writeProfilerMark("measure,StartTM");var a=this._sizes;a.rtl="rtl"===b.getComputedStyle(this._element).direction;var c=this._surfaceEl.children.length;if(c>0){if(!this._sizes.itemMeasured){this._writeProfilerMark("measureItem,StartTM");var d=this._surfaceEl.firstElementChild;d.style.margin="",d.style.width="";var e=b.getComputedStyle(d);a.itemOffsetWidth=parseFloat(b.getComputedStyle(d).width),0===d.offsetWidth&&(a.itemOffsetWidth=0),a.itemMarginLeft=parseFloat(e.marginLeft),a.itemMarginRight=parseFloat(e.marginRight),a.itemWidth=a.itemOffsetWidth+a.itemMarginLeft+a.itemMarginRight,a.itemOffsetHeight=parseFloat(b.getComputedStyle(d).height),0===d.offsetHeight&&(a.itemOffsetHeight=0),a.itemMarginTop=parseFloat(e.marginTop),a.itemMarginBottom=parseFloat(e.marginBottom),a.itemHeight=a.itemOffsetHeight+a.itemMarginTop+a.itemMarginBottom,a.itemOffsetWidth>0&&a.itemOffsetHeight>0&&(a.itemMeasured=!0),this._writeProfilerMark("measureItem,StopTM")}if(a.viewportOffsetWidth=parseFloat(b.getComputedStyle(this._viewportEl).width),0===this._viewportEl.offsetWidth&&(a.viewportOffsetWidth=0),a.viewportOffsetHeight=parseFloat(b.getComputedStyle(this._viewportEl).height),0===this._viewportEl.offsetHeight&&(a.viewportOffsetHeight=0),this._measured=0===a.viewportOffsetWidth||0===a.itemOffsetHeight?!1:!0,this.layout===t.Orientation.horizontal){this._scrollPosition=r.getScrollPosition(this._viewportEl).scrollLeft,a.leadingEdge=this._leftArrowEl.offsetWidth+parseInt(b.getComputedStyle(this._leftArrowEl).marginLeft)+parseInt(b.getComputedStyle(this._leftArrowEl).marginRight);var f=a.viewportOffsetWidth-2*a.leadingEdge;a.maxColumns=a.itemWidth?Math.max(1,Math.floor(f/a.itemWidth)):1,a.rowsPerPage=Math.min(this.maxRows,Math.ceil(c/a.maxColumns)),a.columnsPerPage=Math.min(a.maxColumns,c),a.pages=Math.ceil(c/(a.columnsPerPage*a.rowsPerPage)),a.trailingEdge=a.leadingEdge,a.extraSpace=f-a.columnsPerPage*a.itemWidth,this._scrollLength=a.viewportOffsetWidth*a.pages,this._keyboardBehavior.fixedSize=a.rowsPerPage,this._keyboardBehavior.fixedDirection=s._KeyboardBehavior.FixedDirection.height,this._surfaceEl.style.height=a.itemHeight*a.rowsPerPage+"px",this._surfaceEl.style.width=this._scrollLength+"px"}else this._scrollPosition=this._viewportEl.scrollTop,a.leadingEdge=0,a.rowsPerPage=c,a.columnsPerPage=1,a.pages=1,a.trailingEdge=0,this._scrollLength=this._viewportEl.scrollHeight,this._keyboardBehavior.fixedSize=a.columnsPerPage,this._keyboardBehavior.fixedDirection=s._KeyboardBehavior.FixedDirection.width,this._surfaceEl.style.height="",this._surfaceEl.style.width="";this._updateGridStyles()}else a.pages=1,this._hasPreviousContent=!1,this._hasNextContent=!1,this._surfaceEl.style.height="",this._surfaceEl.style.width="";this._writeProfilerMark("measure,StopTM")}},_updateGridStyles:function(){for(var a=this._sizes,b=this._surfaceEl.children.length,c=0;b>c;c++){var d,e,f=this._surfaceEl.children[c],g="";if(this.layout===t.Orientation.horizontal){var h=Math.floor(c/a.rowsPerPage),i=h%a.columnsPerPage===0,j=h%a.columnsPerPage===a.columnsPerPage-1,k=a.trailingEdge;if(this.fixedSize)k+=a.extraSpace;else{var l=a.extraSpace-(a.maxColumns-a.columnsPerPage)*a.itemWidth;g=a.itemOffsetWidth+l/a.maxColumns+"px"}var m,n;a.rtl?(m=i?a.leadingEdge:0,n=j?k:0):(m=j?k:0,n=i?a.leadingEdge:0),d=m+a.itemMarginRight+"px",e=n+a.itemMarginLeft+"px"}else d="",e="";f.style.marginRight!==d&&(f.style.marginRight=d),f.style.marginLeft!==e&&(f.style.marginLeft=e),f.style.width!==g&&(f.style.width=g)}},_updatePageUI:function(){this._measure();var a=this._currentPage;this._hasPreviousContent=0!==a,this._hasNextContent=a<this._sizes.pages-1,this._updateArrows(),this._indicatorCount!==this._sizes.pages&&(this._indicatorCount=this._sizes.pages,this._pageindicatorsEl.innerHTML=new Array(this._sizes.pages+1).join('<span class="'+E._ClassName.indicator+'"></span>'));for(var b=0;b<this._pageindicatorsEl.children.length;b++)b===a?r.addClass(this._pageindicatorsEl.children[b],E._ClassName.currentindicator):r.removeClass(this._pageindicatorsEl.children[b],E._ClassName.currentindicator);if(this._sizes.pages>1?(this._viewportEl.style.overflowX=this._panningDisabled?"hidden":"",this._pageindicatorsEl.style.visibility=""):(this._viewportEl.style.overflowX="hidden",this._pageindicatorsEl.style.visibility="hidden"),this._sizes.pages<=1||this._layout!==t.Orientation.horizontal)this._ariaStartMarker.removeAttribute("aria-flowto"),this._ariaEndMarker.removeAttribute("x-ms-aria-flowfrom");else{var c=a*this._sizes.rowsPerPage*this._sizes.columnsPerPage,d=this._surfaceEl.children[c].winControl._buttonEl;r._ensureId(d),this._ariaStartMarker.setAttribute("aria-flowto",d.id);var e=Math.min(this._surfaceEl.children.length-1,(a+1)*this._sizes.rowsPerPage*this._sizes.columnsPerPage-1),f=this._surfaceEl.children[e].winControl._buttonEl;r._ensureId(f),this._ariaEndMarker.setAttribute("x-ms-aria-flowfrom",f.id)}},_closeSplitIfOpen:function(){this._currentSplitNavItem&&(this._currentSplitNavItem.splitOpened&&this._currentSplitNavItem._toggleSplit(),this._currentSplitNavItem=null)},_updateArrows:function(){var a=this._sizes.rtl?this._hasNextContent:this._hasPreviousContent,b=this._sizes.rtl?this._hasPreviousContent:this._hasNextContent,c=this;(this._mouseInViewport||this._panningDisabled)&&a?(this._leftArrowWaitingToFadeOut&&this._leftArrowWaitingToFadeOut.cancel(),this._leftArrowWaitingToFadeOut=null,this._leftArrowFadeOut&&this._leftArrowFadeOut.cancel(),this._leftArrowFadeOut=null,this._leftArrowEl.style.visibility="",this._leftArrowFadeIn=this._leftArrowFadeIn||j.fadeIn(this._leftArrowEl)):(a?this._leftArrowWaitingToFadeOut=this._leftArrowWaitingToFadeOut||o.timeout(k._animationTimeAdjustment(y)):(this._leftArrowWaitingToFadeOut&&this._leftArrowWaitingToFadeOut.cancel(),this._leftArrowWaitingToFadeOut=o.wrap()),this._leftArrowWaitingToFadeOut.then(function(){this._leftArrowFadeIn&&this._leftArrowFadeIn.cancel(),this._leftArrowFadeIn=null,this._leftArrowFadeOut=this._leftArrowFadeOut||j.fadeOut(this._leftArrowEl).then(function(){c._leftArrowEl.style.visibility="hidden"})}.bind(this))),(this._mouseInViewport||this._panningDisabled)&&b?(this._rightArrowWaitingToFadeOut&&this._rightArrowWaitingToFadeOut.cancel(),this._rightArrowWaitingToFadeOut=null,this._rightArrowFadeOut&&this._rightArrowFadeOut.cancel(),this._rightArrowFadeOut=null,this._rightArrowEl.style.visibility="",this._rightArrowFadeIn=this._rightArrowFadeIn||j.fadeIn(this._rightArrowEl)):(b?this._rightArrowWaitingToFadeOut=this._rightArrowWaitingToFadeOut||o.timeout(k._animationTimeAdjustment(y)):(this._rightArrowWaitingToFadeOut&&this._rightArrowWaitingToFadeOut.cancel(),this._rightArrowWaitingToFadeOut=o.wrap()),this._rightArrowWaitingToFadeOut.then(function(){this._rightArrowFadeIn&&this._rightArrowFadeIn.cancel(),this._rightArrowFadeIn=null,this._rightArrowFadeOut=this._rightArrowFadeOut||j.fadeOut(this._rightArrowEl).then(function(){c._rightArrowEl.style.visibility="hidden"})}.bind(this)))},_navbarCommandInvokedHandler:function(a){for(var b=a.target,c=-1;b;)c++,b=b.previousSibling;this._fireEvent(E._EventName.invoked,{index:c,navbarCommand:a.target.winControl,data:this._repeater?this._repeater.data.getAt(c):null})},_navbarCommandSplitToggleHandler:function(a){for(var b=a.target,c=-1;b;)c++,b=b.previousSibling;var d=a.target.winControl;this._closeSplitIfOpen(),d.splitOpened&&(this._currentSplitNavItem=d),this._fireEvent(E._EventName.splitToggle,{opened:d.splitOpened,index:c,navbarCommand:d,data:this._repeater?this._repeater.data.getAt(c):null})},_fireEvent:function(a,c){var d=b.document.createEvent("CustomEvent");d.initCustomEvent(a,!0,!1,c),this.element.dispatchEvent(d)},_writeProfilerMark:function(a){var b="WinJS.UI.NavBarContainer:"+this._id+":"+a;i(b),g.log&&g.log(b,null,"navbarcontainerprofiler")},dispose:function(){this._disposed||(this._disposed=!0,this._appBarEl&&(this._appBarEl.removeEventListener("beforeshow",this._closeSplitAndResetBound),this._appBarEl.removeEventListener("beforeshow",this._resizeImplBound)),n.removeEventListener("navigated",this._closeSplitAndResetBound),this._leftArrowWaitingToFadeOut&&this._leftArrowWaitingToFadeOut.cancel(),this._leftArrowFadeOut&&this._leftArrowFadeOut.cancel(),this._leftArrowFadeIn&&this._leftArrowFadeIn.cancel(),this._rightArrowWaitingToFadeOut&&this._rightArrowWaitingToFadeOut.cancel(),this._rightArrowFadeOut&&this._rightArrowFadeOut.cancel(),this._rightArrowFadeIn&&this._rightArrowFadeIn.cancel(),r._resizeNotifier.unsubscribe(this._element,this._boundResizeHandler),this._removeDataChangingEvents(),this._removeDataChangedEvents())}},{_ClassName:{navbarcontainer:"win-navbarcontainer",pageindicators:"win-navbarcontainer-pageindicator-box",indicator:"win-navbarcontainer-pageindicator",currentindicator:"win-navbarcontainer-pageindicator-current",vertical:"win-navbarcontainer-vertical",horizontal:"win-navbarcontainer-horizontal",viewport:"win-navbarcontainer-viewport",surface:"win-navbarcontainer-surface",navarrow:"win-navbarcontainer-navarrow",navleftarrow:"win-navbarcontainer-navleft",navrightarrow:"win-navbarcontainer-navright"},_EventName:{invoked:C.invoked,splitToggle:C.splittoggle}});return c.Class.mix(E,q.DOMEventMixin),E})})}),d("WinJS/Controls/NavBar",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_WriteProfilerMark","../Promise","../Scheduler","../Utilities/_ElementUtilities","../Utilities/_Hoverable","./AppBar","./NavBar/_Command","./NavBar/_Container","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";var l="custom";c.Namespace.define("WinJS.UI",{NavBar:c.Namespace._lazy(function(){var j="childrenprocessed",m=e._createEventProperty,n=c.Class.derive(k.AppBar,function(a,c){c=c||{},c=d._shallowCopy(c),c.placement=c.placement||"top",c.layout=l,k.AppBar.call(this,a,c),this._element.addEventListener("beforeshow",this._handleBeforeShow.bind(this)),i.addClass(this.element,n._ClassName.navbar),b.Windows.ApplicationModel.DesignMode.designModeEnabled?this._processChildren():h.schedule(this._processChildren.bind(this),h.Priority.idle,null,"WinJS.UI.NavBar.processChildren")},{layout:{get:function(){return l},set:function(){Object.getOwnPropertyDescriptor(k.AppBar.prototype,"layout").set.call(this,l)}},onchildrenprocessed:m(j),_processChildren:function(){if(!this._processed){this._processed=!0,this._writeProfilerMark("processChildren,StartTM");var a=this,b=g.as();return this._processors&&this._processors.forEach(function(c){for(var d=0,e=a.element.children.length;e>d;d++)!function(a){b=b.then(function(){c(a)})}(a.element.children[d])}),b.then(function(){a._writeProfilerMark("processChildren,StopTM"),a._fireEvent(n._EventName.childrenProcessed)
  },function(){a._writeProfilerMark("processChildren,StopTM"),a._fireEvent(n._EventName.childrenProcessed)})}return g.wrap()},_show:function(){if(!this.disabled){var a=this;this._processChildren().then(function(){k.AppBar.prototype._show.call(a)})}},_handleBeforeShow:function(){if(!this._disposed)for(var a=this.element.querySelectorAll(".win-navbarcontainer"),b=0;b<a.length;b++)a[b].winControl.forceLayout()},_fireEvent:function(b,c){var d=a.document.createEvent("CustomEvent");d.initCustomEvent(b,!0,!1,c||{}),this.element.dispatchEvent(d)},_writeProfilerMark:function(a){f("WinJS.UI.NavBar:"+this._id+":"+a)}},{_ClassName:{navbar:"win-navbar"},_EventName:{childrenProcessed:j},isDeclarativeControlContainer:d.markSupportedForProcessing(function(a,b){if(a._processed)for(var c=0,d=a.element.children.length;d>c;c++)b(a.element.children[c]);else a._processors=a._processors||[],a._processors.push(b)})});return n})})}),d("WinJS/Controls/ViewBox",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","../Scheduler","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i){"use strict";b.Namespace.define("WinJS.UI",{ViewBox:b.Namespace._lazy(function(){function e(a){if(a&&!a._resizing){a._resizing=a._resizing||0,a._resizing++;try{a._updateLayout()}finally{a._resizing--}}}function j(a){a.target&&e(a.target.winControl)}function k(a){a.target&&e(a.target.parentElement.winControl)}var l={get invalidViewBoxChildren(){return"ViewBox expects to only have one child element"}},m=b.Class.define(function(b){this._disposed=!1,this._element=b||a.document.createElement("div");var c=this.element;c.winControl=this,i.addClass(c,"win-disposable"),i.addClass(c,"win-viewbox"),this.forceLayout()},{_sizer:null,_element:null,element:{get:function(){return this._element}},_rtl:{get:function(){return"rtl"===a.getComputedStyle(this.element).direction}},_initialize:function(){var a=this.element;if(a.firstElementChild!==this._sizer){if(c.validation&&1!==a.childElementCount)throw new d("WinJS.UI.ViewBox.InvalidChildren",l.invalidViewBoxChildren);this._sizer&&(this._sizer.onresize=null);var b=a.firstElementChild;if(this._sizer=b,b&&(i._resizeNotifier.subscribe(a,j),a.addEventListener("mselementresize",j),i._resizeNotifier.subscribe(b,k),b.addEventListener("mselementresize",k)),0===a.clientWidth&&0===a.clientHeight){var e=this;f.schedule(function(){e._updateLayout()},f.Priority.normal,null,"WinJS.UI.ViewBox._updateLayout")}}},_updateLayout:function(){var a=this._sizer;if(a){var b=this.element,d=a.clientWidth,e=a.clientHeight,f=b.clientWidth,g=b.clientHeight,h=f/d,i=g/e,j=Math.min(h,i),k=Math.abs(f-d*j)/2,l=Math.abs(g-e*j)/2,m=this._rtl;this._sizer.style[c._browserStyleEquivalents.transform.scriptName]="translate("+(m?"-":"")+k+"px,"+l+"px) scale("+j+")",this._sizer.style[c._browserStyleEquivalents["transform-origin"].scriptName]=m?"top right":"top left"}},dispose:function(){this._disposed||(this.element&&i._resizeNotifier.unsubscribe(this.element,j),this._sizer&&i._resizeNotifier.unsubscribe(this._sizer,k),this._disposed=!0,h.disposeSubTree(this._element))},forceLayout:function(){this._initialize(),this._updateLayout()}});return b.Class.mix(m,g.DOMEventMixin),m})})}),d("ui",["WinJS/Core/_WinJS","WinJS/VirtualizedDataSource","WinJS/Controls/IntrinsicControls","WinJS/Controls/ListView","WinJS/Controls/FlipView","WinJS/Controls/ItemContainer","WinJS/Controls/Repeater","WinJS/Controls/DatePicker","WinJS/Controls/TimePicker","WinJS/Controls/BackButton","WinJS/Controls/Rating","WinJS/Controls/ToggleSwitch","WinJS/Controls/SemanticZoom","WinJS/Controls/Pivot","WinJS/Controls/Hub","WinJS/Controls/Flyout","WinJS/Controls/AppBar","WinJS/Controls/Menu","WinJS/Controls/SearchBox","WinJS/Controls/SettingsFlyout","WinJS/Controls/NavBar","WinJS/Controls/Tooltip","WinJS/Controls/ViewBox"],function(a){"use strict";return a}),c(["WinJS/Core/_WinJS","ui"],function(b){return a.WinJS=b,b})})}(this);
  //# sourceMappingURL=ui.min.js.map