UNPKG

platypusui

Version:

A front-end set of UI controls for PlatypusTS written in TypeScript

1 lines 107 kB
"use strict";var platui,__extends=this&&this.__extends||function(){var s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};return function(t,e){function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}();!function(t){var s="$Promise",n="$Compat",o="$Window",r="$Document",a="$Animator",i="$DomEventInstance",l="$TemplateControlFactory",e="plat",v=e+"-",h=v+"button",u=v+"checkbox",d=v+"drawer",p=d+"-controller",_=v+"modal",c=v+"progress",f=v+"ring",m=v+"radio",g=v+"toggle",y=v+"slider",b=v+"range",C=v+"select",x=v+"input",T=v+"file",w=v+"carousel",E=v+"listview",P=v+"navbar",N=v+"image",S=v+"hide",A=v+"hidden",I=v+"context",L=v+"foreach",k=v+"html",O=e+"Checked",V=e+"Bind",z=e+"Src",F="index",R="even",B="odd",M="first",j="last",K="group",D=v+"transition",q=v+"enter",U=v+"leave",G="$tap",W="$touchstart",H="$touchend",Y="$touchcancel",X="$swipe",Q="$track",$="$trackend",J="__plat-button-",Z="__plat-radio-",tt="__platDrawerControllerFetch",et="__platDrawerFound",it="-reversed",st={right:"left",left:"right",up:"down",down:"up"},nt=function(t){return t.preventDefault(),!1},ot=function(){};"undefined"!=typeof window&&(void 0===window.platui&&(window.platui=t),void 0===window.module&&(window.module={}));var rt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.replaceWith="button",t._isSelected=!1,t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,h+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.loaded=function(){var t=this.element,e=((this.options||{}).value||{}).group,i=this.utils.isString;i(e)?(this._group=e,this.dom.hasClass(t,v+"selected")&&this._onTap(),this._addEventListeners()):i(e=this.attributes[V])&&(this._group=e,this.dom.hasClass(t,v+"selected")&&this._onTap(),this._addEventListeners())},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty)},t.prototype._setBoundProperty=function(t,e,i,s){this.utils.isString(t)&&t===this.element.textContent&&this._onTap()},t.prototype._addEventListeners=function(){var t=this;this.addEventListener(this.element,G,this._onTap,!1),this.on(J+this._group,function(){t._isSelected&&(t.dom.removeClass(t.element,v+"selected"),t._isSelected=!1)})},t.prototype._onTap=function(){if(!this._isSelected){var t=this.element;this.dom.addClass(t,v+"selected"),this.dispatchEvent(J+this._group,plat.events.EventManager.DIRECT),this._isSelected=!0,this.inputChanged(t.hasAttribute("value")?t.getAttribute("value").trim():t.textContent.trim())}},t._inject={_document:r},t}(plat.ui.BindControl);t.Button=rt,plat.register.control(h,rt);var at=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.templateString='<div class="plat-toggle-container">\n <div class="plat-knob"></div>\n</div>\n',t.isActive=!1,t._targetType="slide",t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,g+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.setTemplate=function(){var t=this.utils.isNull,e=this.innerTemplate;if(!t(e)){var i=this._document.createElement("span");this.dom.appendChildren(e.childNodes,i),this.element.insertBefore(i,null)}},t.prototype.loaded=function(){var t=this.element;this._targetElement=t.firstElementChild,this.addEventListener(t,G,this._onTap),this._convertChecked()},t.prototype.toggle=function(){this._toggle(!0)},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty)},t.prototype._setBoundProperty=function(t,e,i,s){t!==e&&(!0===s&&this.utils.isNull(t)?this.inputChanged(this.isActive):!!t!==this.isActive&&this._toggle(s))},t.prototype._convertChecked=function(){var t=this.element;this.utils.isNull(this.attributes[O])?t.hasAttribute("checked")&&this._convertAttribute(!0):(this._convertAttribute(this.attributes[O]),this.attributes.observe(this._convertAttribute,O))},t.prototype._convertAttribute=function(t,e){var i=this.utils;if(i.isBoolean(t))return this._setBoundProperty(t,e,null,!0);i.isString(t)&&this._setBoundProperty("true"===t,"true"===e,null,!0)},t.prototype._onTap=function(t){this.element.hasAttribute("disabled")||(this._toggle(!0),this._trigger("change"))},t.prototype._trigger=function(t){var e=plat.acquire(i);e.initialize(this.element,t),e.trigger()},t.prototype._toggle=function(t){var e=this.isActive,i=!e,s=this.element;this._activate(this._targetElement||(this._targetElement=s.firstElementChild)),this.isActive=s.checked=i,i?s.setAttribute("checked","checked"):s.removeAttribute("checked"),!0===t&&this.inputChanged(i,e)},t.prototype._activate=function(t){this.dom.toggleClass(t,v+this._targetType)},t._inject={_document:r},t}(plat.ui.BindControl);t.Toggle=at,plat.register.control(g,at);var lt=function(s){function t(){var t=null!==s&&s.apply(this,arguments)||this;return t.templateString='<div class="plat-checkbox-container">\n <span class="plat-mark"></span>\n</div>\n',t._targetTypeSet=!1,t}return __extends(t,s),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,u+" "+(t||""))},t.prototype.loaded=function(){s.prototype.loaded.call(this);var t=(this.options||{}).value||{},e=this._targetType;switch((this._targetType=t.mark||"check").toLowerCase()){case"check":case"x":break;default:this._log.debug("Invalid mark option specified for "+this.type+". Defaulting to checkmark."),this._targetType="check"}if(this._targetTypeSet){var i=this._targetElement;this.dom.removeClass(i,e),this._activate(i)}this._targetTypeSet=!0},t.prototype._activate=function(t){this._targetTypeSet?this.dom.toggleClass(t,v+this._targetType):this._targetTypeSet=!0},t}(at);t.Checkbox=lt,plat.register.control(u,lt);var ht=function(n){function t(){var t=null!==n&&n.apply(this,arguments)||this;return t.templateString='<div class="plat-radio-container">\n <div class="plat-mark"></div>\n</div>\n',t.groupName="",t._targetType="bullet",t._targetTypeSet=!0,t}return __extends(t,n),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,m+" "+(t||""))},t.prototype.loaded=function(){var t=this.element;this._targetElement=t.firstElementChild,this.addEventListener(t,G,this._onTap),t.hasAttribute("name")?this.groupName=t.getAttribute("name"):this.utils.isNull(this.attributes[V])||(this.groupName=this.attributes[V]),this._convertChecked()},t.prototype.inputChanged=function(t,e){this.isActive&&n.prototype.inputChanged.call(this,this._getValue())},t.prototype._setBoundProperty=function(t,e,i,s){var n=this.utils;if(t!==e)if(!0===s&&n.isNull(t))this.inputChanged();else{var o=this._getValue(),r=t===o,a=this.isActive;if(r){if(a)return}else if(n.isNull(t)){if(!a)return}else{var l=n.isFunction(t.toString)?t.toString():Object.prototype.toString.call(t);if(a){if(l===o)return}else if(l!==o)return}this._toggle(s)}},t.prototype._onTap=function(t){this.isActive||n.prototype._onTap.call(this,t)},t.prototype._toggle=function(t){var e=this;if(n.prototype._toggle.call(this,t),this.utils.isFunction(this._removeListener)&&(this._removeListener(),this._removeListener=null),this.isActive){var i=this.groupName;this.dispatchEvent(Z+i,plat.events.EventManager.DIRECT);var s=this._removeListener=this.on(Z+i,function(){e._toggle(),s()})}},t.prototype._convertAttribute=function(t,e){var i=this.utils;i.isBoolean(t)?t&&this._setBoundProperty(this._getValue(),null,null,!0):i.isString(t)&&"true"===t&&this._setBoundProperty(this._getValue(),null,null,!0)},t.prototype._getValue=function(){var t=this.element;return t.hasAttribute("value")?t.getAttribute("value").trim():t.textContent.trim()},t}(lt);t.Radio=ht,plat.register.control(m,ht);var ut=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.templateString='<div class="plat-animated-ring"></div>',t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,f+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.loaded=function(){var t=this.options,e=this.utils,i=e.isObject,s=0;i(t)&&i(t.value)&&(s=t.value.style,e.isNumber(s)||(s=0)),this.dom.addClass(this.element,f+"-"+s),0!==s&&this._addAnimatedElements(s)},t.prototype._addAnimatedElements=function(t){for(var e,i=plat.acquire(r),s=i.createDocumentFragment(),n=2===t?12:4,o=0;o<n;++o)(e=i.createElement("div")).className="plat-animated-child plat-animated-child-"+o,s.insertBefore(e,null);this.element.firstElementChild.insertBefore(s,null)},t}(plat.ui.TemplateControl);t.ProgressRing=ut,plat.register.control(f,ut);var pt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.templateString='<div class="plat-progress-container">\n <div class="plat-animated-bar"></div>\n</div>\n',t._removeVisibilityListener=ot,t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,c+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.loaded=function(){var t=this;this._barElement=this.element.firstElementChild.firstElementChild,this.addEventListener(this._window,"resize",function(){t.setProgress(t.context)}),this.setProgress(this.context)},t.prototype.dispose=function(){this._removeVisibilityListener()},t.prototype.contextChanged=function(){this.setProgress(this.context)},t.prototype.setProgress=function(o){var r=this;return new this._Promise(function(t,e){if(!r.utils.isNumber(o)||1<o||o<0){var i='The value of a "'+r.type+'" control must be a number between 0 and 1.';return r._log.debug(i),void e(i)}var s=r._barElement,n=s.parentElement.clientWidth;if(!n)return r._removeVisibilityListener(),void(r._removeVisibilityListener=r.dom.whenVisible(function(){r.setProgress(o).then(t)},r.element));r._animator.animate(s,D,{properties:{width:Math.ceil(n*o)+"px"}}).then(function(){t()})})},t._inject={_window:o,_Promise:s,_animator:a},t}(plat.ui.TemplateControl);t.ProgressBar=pt,plat.register.control(c,pt);var _t=function(e){function t(){var t=e.call(this)||this;return t._controllers=[],t._isInitialized=!1,t._preInitializedValue=!1,t.__state=!1,t.__nextState=!1,t.ready=t._Promise.resolve(),t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,d+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.setTemplate=function(){this.innerTemplate=this.dom.appendChildren(this.element.childNodes)},t.prototype.loaded=function(){var e=this,t=this.element,i=this.utils,s=(this.options||{}).value||{},n=this._currentPosition=s.position||"left",o=s.id||"",r=s.templateUrl,a=!0===s.elastic;t.setAttribute(S,""),this.dom.addClass(t,v+n),i.isString(r)?plat.ui.TemplateControl.determineTemplate(this,r).then(function(t){e.innerTemplate=t,e._initializeEvents(o,n,a)}):this._initializeEvents(o,n,a)},t.prototype.open=function(){var t=this._controllers[0];return this.utils.isNull(t)?(this._log.debug("No controller, such as a "+p+", found for the "+this.type+" attempting to open."),this._Promise.resolve()):t.open()},t.prototype.close=function(){var t=this._controllers[0];return this.utils.isNull(t)?(this._log.debug("No controller, such as a "+p+", found for the "+this.type+" attempting to close."),this._Promise.resolve()):t.close()},t.prototype.toggle=function(){var t=this._controllers[0];return this.utils.isNull(t)?(this._log.debug("No controller, such as a "+p+", found for the "+this.type+" attempting to toggle."),this._Promise.resolve()):t.toggle()},t.prototype.isOpen=function(){var t=this._controllers[0];return this.utils.isNull(t)?(this._log.debug("No controller, such as a "+p+", found for the "+this.type+" attempting to check if open."),!1):t.isOpen()},t.prototype.bindTemplate=function(t,e){var i=this,s=this.bindableTemplates;return s.add(t,e),s.bind(t).then(function(t){var e=i.element;i.dom.clearNode(e),e.appendChild(t)}).catch(function(t){i._log.debug("Error binding template for "+i.type+": "+t)})},t.prototype.controllerCount=function(){return this._controllers.length},t.prototype.spliceController=function(t){var e=this._controllers,i=e.indexOf(t);-1!==i&&(this.__state=this.__nextState=e[i].isOpen(),e.splice(i,1))},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty)},t.prototype._setBoundProperty=function(t,e,i,s){var n=this.utils,o=this._controllers[0];if(!0===s&&n.isNull(t))this.inputChanged(!n.isNull(o)&&o.isOpen());else{var r=!!t;if(r!==t&&this.inputChanged(r),this._isInitialized)if(n.isNull(o))this.__nextState=r;else if(r){if(o.isOpen())return;o.open()}else o.isOpen()&&o.close();else this._preInitializedValue=r}},t.prototype._changeDirection=function(t){if(!this.utils.isNull(t)&&t!==this._currentPosition){var e=this.dom,i=this.element;e.removeClass(i,v+this._currentPosition),e.addClass(i,v+t),this._currentPosition=t}},t.prototype._initializeEvents=function(s,n,o){var r=this,a=this.utils,l=this.innerTemplate;this.on(tt+"_"+s,function(t,e){var i=e.control;a.isNull(i)||(a.isString(e.position)&&(n=e.position,r._changeDirection(n)),r._controllers.unshift(i),e.received||r.ready.then(function(){r.dispatchEvent(et+"_"+s,plat.events.EventManager.DIRECT,{control:r,received:!0,position:n,template:a.isNode(l)?l.cloneNode(!0):null,elastic:o,state:r.__state,nextState:r.__nextState})}),r._isInitialized=!0,e.useContext?r._checkPreInit():r.bindTemplate("drawer",l.cloneNode(!0)).then(function(){r._checkPreInit()}))}),this.dispatchEvent(et+"_"+s,plat.events.EventManager.DIRECT,{control:this,received:!1,position:n,template:a.isNode(l)?l.cloneNode(!0):null,elastic:o,state:this.__state,nextState:this.__nextState})},t.prototype._checkPreInit=function(){var e=this;if(this._preInitializedValue){var i=this.utils;i.postpone(function(){var t=e._controllers[0];i.isNull(t)||t.open()})}},t._inject={_Promise:s},t}(plat.ui.BindControl);t.Drawer=_t,plat.register.control(d,_t);var dt=function(i){function t(){var t=null!==i&&i.apply(this,arguments)||this;return t._hasSwiped=!1,t._hasTapped=!1,t._isOpen=!1,t._touchState=0,t._isVertical=!1,t._removeClickEaterListener=ot,t._toggleDelay=ot,t._isInitialized=!1,t}return __extends(t,i),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,p+" "+(t||""))},t.prototype.initialize=function(){this.dom.addClass(this.element,p)},t.prototype.loaded=function(){var t=(this.options||{}).value||{},e=t.position,i=t.id||"";this._type=t.type||"tap track",this._isElastic=t.elastic,this._useContext=!0===t.useContext,this._templateUrl=t.templateUrl,this._initializeEvents(i,e)},t.prototype.dispose=function(){var t=this;i.prototype.dispose.call(this);var e=this._drawer;this.utils.isNull(e)||(1<e.controllerCount()?e.spliceController(this):this._isOpen?e.ready=this.close().then(function(){e.spliceController(t),0<e.controllerCount()||t._cleanRootElement()}):e.ready.then(function(){e.spliceController(t),0<e.controllerCount()||t._cleanRootElement()}))},t.prototype.open=function(){var e=this,t=!this._isOpen,i=this.utils;this._toggleDelay();var s=new this._Promise(function(t){e._toggleDelay=i.requestAnimationFrame(function(){e._open().then(t)})});if(t){var n=this._drawer;this.inputChanged(!0),i.isNull(n)||n.inputChanged(!0)}return s},t.prototype.close=function(){var e=this,t=this._isOpen,i=this.utils;this._toggleDelay();var s=new this._Promise(function(t){e._toggleDelay=i.requestAnimationFrame(function(){e._close().then(t)})});if(t){var n=this._drawer;this.inputChanged(!1),i.isNull(n)||(n.ready=s,n.inputChanged(!1))}return s},t.prototype.toggle=function(){return this._isOpen?this.close():this.open()},t.prototype.isOpen=function(){return this._isOpen},t.prototype.bindTemplate=function(t,e){var i=this,s=this.bindableTemplates;return s.add(t,e),s.bind(t).then(function(t){var e=i._drawerElement;i.dom.clearNode(e),e.appendChild(t)}).catch(function(t){i._log.debug("Error binding template for "+i.type+": "+t)})},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty)},t.prototype._setBoundProperty=function(t,e,i,s){var n=this,o=this.utils;if(!0===s&&o.isNull(t))this.inputChanged(this._isOpen);else{var r=!!t;if(r!==t&&this.inputChanged(r),this._isInitialized){if(r){if(this._isOpen)return;this._toggleDelay(),this._toggleDelay=o.requestAnimationFrame(function(){n._open()})}else if(this._isOpen){this._toggleDelay();var a=new this._Promise(function(t){n._toggleDelay=o.requestAnimationFrame(function(){t(n._close())})}),l=this._drawer;o.isNull(l)||(l.ready=a)}}else this._preInitializedValue=r}},t.prototype._open=function(t){var e,i=this,s=this._rootElement,n=this.utils.isNode,o=this._isOpen,r=this._getOffset();if(o&&!t||!(r&&n(s)&&n(this._drawerElement)))return this._Promise.resolve();switch(this._position){case"left":e="translate3d("+r+"px,0,0)";break;case"right":e="translate3d("+-r+"px,0,0)";break;case"top":e="translate3d(0,"+r+"px,0)";break;case"bottom":e="translate3d(0,"+-r+"px,0)";break;default:return this._Promise.resolve()}this._isOpen=!0,this.dom.addClass(s,this._directionalTransitionPrep),o||this._addClickEater();var a={};return a[this._transform]=e,this._animationThenable=this._animator.animate(s,D,{properties:a}).then(function(){i._animationThenable=null,i._drawerElement.removeEventListener("selectstart",nt,!1)})},t.prototype._close=function(t){var e=this,i=this._rootElement,s=this.utils.isNode;if(!this._isOpen&&!t||!s(i)||!s(this._drawerElement))return this._Promise.resolve();this._isOpen=!1;var n={};return n[this._transform]=this._preTransform,this._animationThenable=this._animator.animate(i,D,{properties:n}).then(function(){e._animationThenable=null,e._drawerElement.removeEventListener("selectstart",nt,!1),e._isOpen||e._touchState<2&&e._removeClickEater()})},t.prototype._reset=function(){if(this._isOpen)return this._open(!0);var t=this._close(!0),e=this._drawer;return this.utils.isNull(e)||(e.ready=t),t},t.prototype._addClickEater=function(){var t=this,e=this._clickEater,i=e.style,s=this._rootElement;if(!s.contains(e)){i.top=s.scrollTop+"px",i.left=s.scrollLeft+"px",s.insertBefore(e,null),this.dom.addClass(this._rootElement,this._directionalTransitionPrep);var n,o=ot,r=!0;n=this.addEventListener(s,"scroll",function(){r&&(r=!1,o=t.utils.requestAnimationFrame(function(){var t=e.style;r=!0,t.top=s.scrollTop+"px",t.left=s.scrollLeft+"px"}))}),this._removeClickEaterListener=function(){o(),n()}}},t.prototype._removeClickEater=function(){var t=this._rootElement,e=this._clickEater;this._removeClickEaterListener(),t.contains(e)&&t.removeChild(e),this.dom.removeClass(t,this._directionalTransitionPrep)},t.prototype._addSwipeToggle=function(){var t=this,e=this.element,i=this.addEventListener(e,X+st[this._position],function(){t._hasSwiped=!0,t.open()},!1),s=this.addEventListener(e,X+this._position,function(){t._hasSwiped=!0,t.close()},!1);this._removeSwipeToggle=function(){i(),s()}},t.prototype._addSwipeClose=function(){var t=this;this._openSwipeRemover=this.addEventListener(this._clickEater,X+this._position,function(){t._hasSwiped=!0,t.close()},!1)},t.prototype._addTapToggle=function(){var t=this;this._removeTap=this.addEventListener(this.element,G,function(){t._hasTapped=!0,t.toggle()},!1)},t.prototype._addTapClose=function(){var t=this;this._openTapRemover=this.addEventListener(this._clickEater,G,function(){t._hasTapped=!0,t.close()},!1)},t.prototype._addEventListeners=function(){var t=this.element,e=this.utils.isNull,i=this._type.split(" "),s=this._position;if((this._isTap=-1!==i.indexOf("tap"))&&(this._addTapToggle(),this._addTapClose()),(this._isSwipe=-1!==i.indexOf("swipe"))&&(this._addSwipeToggle(),this._addSwipeClose()),this._isTrack=-1!==i.indexOf("track")){var n=this._track,o=void 0,r=this._clickEater;switch(s){case"left":case"right":o=s;break;case"top":o="up";break;case"bottom":o="down";break;default:return}var a=Q+st[o],l=Q+o,h=this.addEventListener(t,a,n,!1),u=this.addEventListener(t,l,n,!1),p=this.addEventListener(r,a,n,!1),_=this.addEventListener(r,l,n,!1);if(this._removeTrack=function(){h(),u()},this._openTrackRemover=function(){p(),_()},e(this._lastTouch)){var d=this._touchStart,c=this._touchEnd;this._lastTouch={x:0,y:0},this.addEventListener(t,W,d,!1),this.addEventListener(t,H,c,!1),this.addEventListener(t,$,c,!1),this.addEventListener(r,W,d,!1),this.addEventListener(r,$,c,!1),this.addEventListener(r,H,c,!1)}}this.addEventListener(this._window,"resize",this._handleResize,!1)},t.prototype._handleResize=function(){if(this._isOpen){var t=this.utils.isNull,e=this._rootElement,i=this._drawer;this._isOpen=!1,this.inputChanged(!1),t(e)||(e.style[this._transform]=this._preTransform),t(i)||(i.inputChanged(!1),this._drawerElement.removeEventListener("selectstart",nt,!1)),this._touchState<2&&this._removeClickEater()}},t.prototype._removeEventListeners=function(){var t=this.utils.isFunction;this._isTap&&(t(this._removeTap)&&(this._removeTap(),this._removeTap=null),t(this._openTapRemover)&&(this._openTapRemover(),this._openTapRemover=null)),this._isTrack&&(t(this._removeTrack)&&(this._removeTrack(),this._removeTrack=null),t(this._openTrackRemover)&&(this._openTrackRemover(),this._openTrackRemover=null)),this._isSwipe&&(t(this._removeSwipeToggle)&&(this._removeSwipeToggle(),this._removeSwipeToggle=null),t(this._openSwipeRemover)&&(this._openSwipeRemover(),this._openSwipeRemover=null))},t.prototype._touchStart=function(t){1!==this._touchState&&(this._touchState=1,this._lastTouch={x:t.clientX,y:t.clientY})},t.prototype._touchEnd=function(t){var e=0===this._touchState,i=this._hasSwiped,s=this._hasTapped;if(this._hasSwiped=this._hasTapped=!1,this._touchState=0,!(s||e||i)){var n=this._isVertical?t.clientY-this._lastTouch.y:t.clientX-this._lastTouch.x;if(this._isRightDirection(n)){var o=this._getOffset();if(!o)return;if(Math.abs(n)>Math.ceil(o/2))return void this.toggle();this._reset()}else this._isElastic?0<Math.abs(n)&&this._reset():this._isOpen||this._removeClickEater()}},t.prototype._track=function(t){var e=this,i=this._touchState;0!==i&&(1===i&&(this.utils.isNull(this._animationThenable)?(this._addClickEater(),this.utils.isNode(this._drawerElement)&&this._drawerElement.addEventListener("selectstart",nt,!1)):this._animationThenable.cancel().then(function(){e._addClickEater(),e.utils.isNode(e._drawerElement)&&e._drawerElement.addEventListener("selectstart",nt,!1)}),this._touchState=2),this.utils.requestAnimationFrame(function(){e._rootElement.style[e._transform]=e._calculateTranslation(t)}))},t.prototype._isRightDirection=function(t){switch(this._position){case"left":case"top":return this._isOpen?t<0:0<t;case"right":case"bottom":return this._isOpen?0<t:t<0;default:return!1}},t.prototype._calculateTranslation=function(t){var e,i=this._getOffset();if(!i)return this._preTransform;switch(this._position){case"left":return 0===(e=this._checkElasticity(i,t.clientX-this._lastTouch.x))?this._preTransform:"translate3d("+e+"px,0,0)";case"right":return 0===(e=this._checkElasticity(i,this._lastTouch.x-t.clientX))?this._preTransform:"translate3d("+-e+"px,0,0)";case"top":return 0===(e=this._checkElasticity(i,t.clientY-this._lastTouch.y))?this._preTransform:"translate3d(0,"+e+"px,0)";case"bottom":return 0===(e=this._checkElasticity(i,this._lastTouch.y-t.clientY))?this._preTransform:"translate3d(0,"+-e+"px,0)";default:return this._preTransform}},t.prototype._checkElasticity=function(t,e){var i=this._isOpen?t+e:e;return this._isElastic||(i<0?i=0:t<i&&(i=t)),i},t.prototype._initializeEvents=function(l,h){var u=this,p=this._useContext,_=this.on(et+"_"+l,function(t,e){_();var i=u.utils,s=i.isString,n=i.isUndefined,o=(u._drawer=e.control)||{},r=u._drawerElement=o.element;if(!s(h)){if(!s(e.position))return void u._log.debug('"position" is incorrectly defined for a control such as "'+d+'" or "'+u.type+'." Please ensure it is a string.');h=e.position}if(r.removeAttribute(S),u._controllerIsValid(h.toLowerCase())){u._setTransform(),u._addEventListeners(),n(u._isElastic)&&(u._isElastic=!0===e.elastic),e.received||u.dispatchEvent(tt+"_"+l,plat.events.EventManager.DIRECT,{control:u,received:!0,position:h,useContext:p}),e.state?(u._isOpen=!0,u.inputChanged(!0),!e.nextState&&i.isNull(u._preInitializedValue)&&(u._preInitializedValue=!1)):e.nextState&&i.isNull(u._preInitializedValue)&&(u._preInitializedValue=!0);var a=function(){u._isInitialized=!0,u._checkPreInit()};p?u._determineTemplate(e.template).then(a):a()}});this.dispatchEvent(tt+"_"+l,plat.events.EventManager.DIRECT,{control:this,received:!1,position:h,useContext:p})},t.prototype._checkPreInit=function(){var e=this,t=this._preInitializedValue,i=this.utils,s=i.isNull;if(!s(t)){var n=this._isOpen;if(!(n&&t||!n&&!t))if(this._toggleDelay(),t)this._toggleDelay=i.requestAnimationFrame(this._open.bind(this));else{var o=new this._Promise(function(t){e._toggleDelay=i.requestAnimationFrame(function(){t(e._close())})}),r=this._drawer;s(r)||(r.ready=o)}}},t.prototype._determineTemplate=function(t){var e=this,i=this.utils;return i.isString(this._templateUrl)?plat.ui.TemplateControl.determineTemplate(this,this._templateUrl).then(function(t){return e.bindTemplate("drawer",t)}):i.isNode(t)?this.bindTemplate("drawer",t):this._Promise.resolve()},t.prototype._setTransform=function(){var t=this._rootElement.style,e=this.utils.isUndefined,i=this._compat.vendorPrefix;e(this._preTransform=t[i.lowerCase+"Transform"])?e(this._preTransform=t[i.upperCase+"Transform"])?this._transform="transform":this._transform=i.upperCase+"Transform":this._transform=i.lowerCase+"Transform"},t.prototype._controllerIsValid=function(t){var e=this.utils.isNull;if(e(this._drawerElement))return this._log.debug('Could not find a corresponding control such as "'+d+'" for this "'+this.type+'."'),!1;switch(t){case"top":case"bottom":this._isVertical=!0;case"left":case"right":this._position=t;break;default:return this._log.debug('Incorrect position: "'+t+'" defined for the a control such as a "'+d+'", or "'+this.type+'."'),!1}var i=this._rootElement=this._getRootElement();if(e(i))return this._log.debug('Cannot have a "'+this.type+'" in a hierarchy above the corresponding control such as "'+d+'."'),!1;var s=this.dom;return s.addClass(i,d+"-root"),s.addClass(this.element,this._isVertical?v+"vertical":v+"horizontal"),this._directionalTransitionPrep=d+"-transition-"+t,this._clickEater=this._document.createElement("div"),this._clickEater.className=v+"clickeater",this._styleRootElement(),!0},t.prototype._getRootElement=function(){var t=this._drawer,e=this.utils;if(!e.isNull(t.storedProperties))return t.storedProperties.rootElement;for(var i,s=e.isNode,n=this.root,o=e.isObject(n)&&s(n.element)?n.element:this.element,r=this._drawerElement;s(i=o.parentElement)&&!i.contains(r);)o=i;return o},t.prototype._styleRootElement=function(){var t=this._window,e=this.utils,i=this._drawer,s=this._rootElement,n=s.parentElement,o=t.getComputedStyle(s),r=s.style,a=o.position,l=Number(o.zIndex),h={rootElement:s};if("static"===a&&(h.position=r.position,r.position="relative"),(!e.isNumber(l)||l<1)&&(h.zIndex=r.zIndex,r.zIndex="1"),e.isNode(n)){var u=t.getComputedStyle(n);if("hidden"!==u.overflow){var p=void 0;if("hidden"!==(this._isVertical?(p="overflowY",u.overflowY):(p="overflowX",u.overflowX))){var _=n.style;h.parentOverflow={key:p,value:_[p]},_[p]="hidden"}}}i.storedProperties=h},t.prototype._cleanRootElement=function(){var t=this.utils,e=t.isObject,i=t.isNode,s=this._rootElement,n=this._drawer;if(i(s)&&(this.dom.removeClass(s,d+"-root "+this._directionalTransitionPrep),!t.isNull(n))){var o=n.storedProperties;if(e(o)){var r=s.style,a=s.parentElement,l=o.parentOverflow;r.position=o.position,r.zIndex=o.zIndex,e(l)&&i(a)&&(a.style[l.key]=l.value),delete n.storedProperties,this._drawerElement.setAttribute(S,"")}}},t.prototype._getOffset=function(){return this._isVertical?this._drawerElement.offsetHeight:this._drawerElement.offsetWidth},t._inject={_document:r,_window:o,_compat:n,_animator:a,_Promise:s},t}(plat.ui.BindControl);t.DrawerController=dt,plat.register.control(p,dt);var ct=function(e){function t(){var i=e.call(this)||this;i._isVisible=!1,i._scrollRemover=ot,i._presenceRemover=ot,i._scrollTop=0,i._transitionHash={up:!0,down:!0,left:!0,right:!0,fade:!0},i.__templateString='<div class="plat-modal-container"></div>\n',i.templateString=i.__templateString;var t=i._Promise;return i._showingPromise=t.resolve(),i._hidingPromise=t.resolve(),i.modalLoaded=new t(function(t,e){i.__resolveFn=t,i.__rejectFn=e}).catch(ot),i}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,_+" "+S+" "+(t||""))},t.prototype.initialize=function(){var t=this.options||(this.options={}),e=t.value||(t.value={});this.templateUrl=e.templateUrl||this.templateUrl,this.setClasses()},t.prototype.setTemplate=function(){if(this.templateString!==this.__templateString||this.utils.isString(this.templateUrl)){var t=this.dom,e=t.serializeHtml(this.__templateString),i=this.element;this._container=e.firstChild;this.innerTemplate=t.appendChildren(i.childNodes),i.appendChild(e)}},t.prototype.loaded=function(){var t=this.options.value.transition,e=this.element;if(this._container=this._container||e.firstElementChild,this._presenceRemover=this.dom.whenPresent(this._injectElement.bind(this),e),this.utils.isString(t)&&"none"!==t){this._transitionHash[t]||this._log.debug('Custom transition: "'+t+'" defined for "'+this.type+'." Please ensure the transition is defined to avoid errors.');var i=this._compat.animationEvents;if(this.utils.isNull(i))return this._log.debug("This browser does not support CSS3 animations."),void this.dom.addClass(this._container,v+"no-transition");this._transitionEnd=i.$transitionEnd,this.dom.addClass(this._container,v+t+" "+v+"modal-transition")}else this.dom.addClass(this._container,v+"no-transition")},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._scrollRemover(),this._presenceRemover(),this.utils.isFunction(this.__rejectFn)&&(this.__rejectFn(),this.__rejectFn=this.__resolveFn=null),this._hidingPromise=this._showingPromise=null},t.prototype.show=function(){var t=!this._isVisible,e=this._show();return t&&this.inputChanged(!0),e},t.prototype.hide=function(){var t=this.isVisible,e=this._hide();return t&&this.inputChanged(!1),e},t.prototype.toggle=function(){return this._isVisible?this.hide():this.show()},t.prototype.isVisible=function(){return this._isVisible},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty)},t.prototype._setBoundProperty=function(t,e,i,s){var n=this.utils;if(!0===s&&n.isNull(t))this.inputChanged(this._isVisible);else if(n.isBoolean(t)){if(t){if(this._isVisible)return;return void this._show()}this._isVisible&&this._hide()}else this._log.debug("Attempting to show or hide a "+this.type+" with a bound value that is something other than a boolean.")},t.prototype._show=function(){var e=this,i=this.dom,s=this.utils;return s.isNull(this.innerTemplate)?this._isVisible?this._showingPromise:(this._isVisible=!0,this._showingPromise=new this._Promise(function(t){s.requestAnimationFrame(function(){e._alignModal(),i.removeClass(e.element,S),s.defer(function(){s.requestAnimationFrame(function(){i.addClass(e._container,v+"activate"),t()})},20)})})):this._bindInnerTemplate()},t.prototype._alignModal=function(t){var e=this,i=this.utils,s=i.isNull,n=this._document,o=n.documentElement,r=(s(o)||!o.scrollTop?n.body:o).scrollTop;this._scrollTop!==r&&(s(t)?(this.element.style.top=r+"px",this._scrollRemover=this.addEventListener(this._window,"scroll",this._alignModal,!1)):i.requestAnimationFrame(function(){e.element.style.top=r+"px"}),this._scrollTop=r)},t.prototype._hide=function(){var t,e=this,i=this.dom,s=this.utils;return this._isVisible?(this._scrollRemover(),this._scrollRemover=ot,this._isVisible=!1,s.isString(this._transitionEnd)?(t=this._addHideOnTransitionEnd(),s.requestAnimationFrame(function(){i.removeClass(e._container,v+"activate")})):t=new this._Promise(function(t){s.requestAnimationFrame(function(){i.addClass(e.element,S),i.removeClass(e._container,v+"activate"),t()})}),this._hidingPromise=t):this._hidingPromise},t.prototype._bindInnerTemplate=function(){var e=this,t=this.innerTemplate;return this.innerTemplate=null,this.bindableTemplates.once(t).then(function(t){return e._container.insertBefore(t,null),e.utils.isFunction(e.__resolveFn)&&(e.__resolveFn(),e.__resolveFn=e.__rejectFn=null),e._show()})},t.prototype._injectElement=function(){var t=this.element,e=t.parentElement,i=this._document.body;this.utils.isNode(e)&&e!==i&&i.insertBefore(t,null)},t.prototype._addHideOnTransitionEnd=function(){var s=this;return new this._Promise(function(t){var e=s.element,i=s.addEventListener(e,s._transitionEnd,function(){i(),s.dom.addClass(e,S),t()},!1)})},t._inject={_window:o,_document:r,_compat:n,_Promise:s},t}(plat.ui.BindControl);t.Modal=ct,plat.register.control(_,ct);var ft=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.templateString='<div class="plat-slider-container">\n <div class="plat-slider-track">\n <div class="plat-knob"></div>\n </div>\n</div>\n',t._isVertical=!1,t._knobOffset=0,t._touchState=0,t._removeVisibilityListener=ot,t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,y+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.loaded=function(){var t=this.element,e=this._slider=t.firstElementChild.firstElementChild,i=this.utils.isNumber,s=(this.options||{}).value||{},n=Number(s.value),o=s.min,r=s.max,a=s.step,l=this._reversed=!0===s.reverse,h=this.min=i(o)?Math.floor(o):0,u=this.max=i(r)?Math.ceil(r):100,p=i(n)?Math.round(n):h,_=v+this._validateOrientation(s.orientation);this._knob=e.firstElementChild,l&&(_+=it),this.dom.addClass(t,_),this.value=h,this._step=i(a)&&0<a?Math.round(a):1,u<=h&&(this._log.debug('"'+this.type+"'s\" min is greater than or equal to its max. Setting max to min + 1."),this.max=h+1),this._setLength(),this._initializeEvents(),this.setValue(p)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._removeVisibilityListener(),this._sliderVisible=null},t.prototype.setValue=function(t){this._setValue(t,!0)},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty)},t.prototype._setBoundProperty=function(t,e,i,s){this._setValue(t,!1)},t.prototype._setValue=function(t,e){var i=this.utils;if(1!==this._touchState){if(i.isNull(t)&&(t=this.min,e=!0),!i.isNumber(t)){var s=Number(t);if(!i.isNumber(s))return void this._log.warn(this.type+" has its value bound to a property that cannot be interpreted as a Number.");t=s,e=!0}this._setValueProperty(t,!0,e)}else this._log.debug("Cannot set the value of "+this.type+" while the user is manipulating it.")},t.prototype._initializeEvents=function(){var t,e,i=this,s=this.element,n=this._track,o=this._touchEnd;e=this._isVertical?(t=Q+"down",Q+"up"):(t=Q+"right",Q+"left"),this.addEventListener(s,W,this._touchStart,!1),this.addEventListener(s,t,n,!1),this.addEventListener(s,e,n,!1),this.addEventListener(s,H,o,!1),this.addEventListener(s,$,o,!1),this.addEventListener(this._window,"resize",function(){i.utils.isNull(i._sliderVisible)&&(i._setLength(),i._setKnob())},!1)},t.prototype._touchStart=function(t){var e=this;if(1!==this._touchState){this._touchState=1,this._lastTouch={x:t.clientX,y:t.clientY,value:this.value};var i,s=t.target;if(s!==this._knob)i=this._isVertical?s===this.element?this._reversed?t.offsetY-this._sliderOffset:this._maxOffset-(t.offsetY-this._sliderOffset):s===this._slider?this._reversed?t.offsetY:this._knobOffset-t.offsetY:this._reversed?t.offsetY:this._maxOffset-t.offsetY:s===this.element?this._reversed?this._maxOffset-(t.offsetX-this._sliderOffset):t.offsetX-this._sliderOffset:s===this._slider?this._reversed?this._knobOffset-t.offsetX:t.offsetX:this._reversed?this._maxOffset-t.offsetX:t.offsetX,this.utils.requestAnimationFrame(function(){e._knobOffset=e._setSliderProperties(i)})}},t.prototype._touchEnd=function(t){var e=this;if(1===this._touchState){this._touchState=2;var i=this._calculateOffset(t),s=this._maxOffset;this.utils.requestAnimationFrame(function(){e._touchState=0,e._lastTouch.value!==e.value&&e._trigger("change"),e._knobOffset=i<0?0:s<i?s:i})}else this._touchState=0},t.prototype._track=function(t){var e=this;0!==this._touchState&&this.utils.requestAnimationFrame(function(){e._setSliderProperties(e._calculateOffset(t))})},t.prototype._setSliderProperties=function(t){var e,i=this._maxOffset;if(t<=0){if((t=0)<=(e=this.min)-this.value)return t}else if(i<=t){if(t=i,(e=this.max)-this.value<=0)return t}else e=this._calculateValue(t);return this._setValueProperty(e,!1,!0),this._slider.style[this._lengthProperty]=t+"px",t},t.prototype._calculateValue=function(t){var e=this._step;return this.min+Math.round(t/this._increment/e)*e},t.prototype._calculateKnobPosition=function(t){return(t-this.min)*this._increment},t.prototype._calculateOffset=function(t){return this._isVertical?this._reversed?this._knobOffset+t.clientY-this._lastTouch.y:this._knobOffset+this._lastTouch.y-t.clientY:this._reversed?this._knobOffset+this._lastTouch.x-t.clientX:this._knobOffset+t.clientX-this._lastTouch.x},t.prototype._setLength=function(){var e=this,i=this._slider.parentElement;this._isVertical?(this._lengthProperty="height",this._maxOffset=i.clientHeight,this._sliderOffset=i.offsetTop):(this._lengthProperty="width",this._maxOffset=i.clientWidth,this._sliderOffset=i.offsetLeft),this._maxOffset?this._setIncrement():this._sliderVisible=new this._Promise(function(t){e._removeVisibilityListener=e.dom.whenVisible(function(){e._sliderVisible=null,e._setLength(),t()},i)})},t.prototype._setIncrement=function(){return this._increment=this._maxOffset/(this.max-this.min)},t.prototype._setValueProperty=function(t,e,i){var s=this.value;if(t!==s){if(t>=this.max)t=this.max;else if(t<=this.min)t=this.min;else if(Math.abs(t-s)<this._step)return;this.value=this.element.value=t,e&&this._setKnob(),i&&this.inputChanged(t,s),this._trigger("input")}},t.prototype._setKnob=function(i){var s=this;this._Promise.resolve(this._sliderVisible).then(function(){var t={},e=s._calculateKnobPosition(i||s.value);e!==s._knobOffset&&(t[s._lengthProperty]=e+"px",s._animator.animate(s._slider,D,{properties:t}),s._knobOffset=e)})},t.prototype._trigger=function(t){var e=plat.acquire(i);e.initialize(this.element,t),e.trigger()},t.prototype._validateOrientation=function(t){return this.utils.isUndefined(t)?"horizontal":("horizontal"===t?e=t:"vertical"===t?(e=t,this._isVertical=!0):(this._log.debug('Invalid orientation "'+t+'" for '+this.type+'. Defaulting to "horizontal."'),e="horizontal"),e);var e},t._inject={_document:r,_window:o,_Promise:s,_animator:a},t}(plat.ui.BindControl);t.Slider=ft,plat.register.control(y,ft);var mt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.templateString='<div class="plat-range-container">\n <div class="plat-range-track">\n <div class="plat-lower-knob"></div>\n <div class="plat-upper-knob"></div>\n </div>\n</div>\n',t._isVertical=!1,t._touchState=0,t._removeVisibilityListener=ot,t._forceFirstTime=!1,t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,b+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.loaded=function(){var t=this.element,e=this._slider=t.firstElementChild.firstElementChild,i=this.utils.isNumber,s=(this.options||{}).value||{},n=Number(s.lower),o=Number(s.upper),r=s.identifiers||{},a=s.min,l=s.max,h=s.step,u=this._reversed=!0===s.reverse,p=this.min=i(a)?Math.floor(a):0,_=this.max=i(l)?Math.ceil(l):100,d=i(n)?Math.round(n):p,c=i(o)?Math.round(o):_,f=v+this._validateOrientation(s.orientation);if(this._lowerKnob=e.firstElementChild,this._upperKnob=e.lastElementChild,this._lowerIdentifier=r.lower||"lower",this._upperIdentifier=r.upper||"upper",u){var m=this._lowerKnob;this._lowerKnob=this._upperKnob,this._upperKnob=m,f+=it}this.dom.addClass(t,f),this.lower=p,this.upper=_,this._step=i(h)&&0<h?Math.round(h):1,_<=p&&(this._log.debug('"'+this.type+"'s\" min is greater than or equal to its max. Setting max to min + 1."),this.max=p+1),this._setPositionAndLength(),this._setLowerKnobPosition(p),this._initializeEvents(),this.setLower(d),this.setUpper(c)},t.prototype.setLower=function(t){this._setLower(t,!0)},t.prototype.setUpper=function(t){this._setUpper(t,!0)},t.prototype.observeProperties=function(t){t.observeProperty(this._setLowerBoundProperty,this._lowerIdentifier),t.observeProperty(this._setUpperBoundProperty,this._upperIdentifier)},t.prototype._setLowerBoundProperty=function(t,e,i,s){this._setLower(t,!1,s)},t.prototype._setUpperBoundProperty=function(t,e,i,s){this._setUpper(t,!1,s)},t.prototype._setLower=function(t,e,i){var s=this.utils;if(2!==this._touchState){if(s.isNull(t)&&(t=this.min,!0===i?this._forceFirstTime=!0:e=!0),!s.isNumber(t)){var n=Number(t);if(!s.isNumber(n))return void this._log.warn(this.type+" has its lower value bound to a property that cannot be interpreted as a Number.");t=n,!0===i?this._forceFirstTime=!0:e=!0}this._setLowerValue(t,!0,e,!0)}else this._log.debug("Cannot set the value of the "+this.type+"'s lower knob while the user is manipulating it.")},t.prototype._setUpper=function(t,e,i){var s=this.utils;if(3!==this._touchState){if(s.isNull(t)&&(t=this.max,e=!0),!s.isNumber(t)){var n=Number(t);if(!s.isNumber(n))return void this._log.warn(this.type+" has its upper value bound to a property that cannot be interpreted as a Number.");t=n,e=!0}this._setUpperValue(t,!0,e||!0===i&&this._forceFirstTime,!0)}else this._log.debug("Cannot set the value of the "+this.type+"'s upper knob while the user is manipulating it.")},t.prototype._initializeEvents=function(){var t,e,i=this,s=this._lowerKnob,n=this._upperKnob,o=this._touchStart,r=this._touchEnd,a=this._trackLower,l=this._trackUpper;e=this._isVertical?(t=Q+"down",Q+"up"):(t=Q+"right",Q+"left"),this.addEventListener(s,W,o,!1),this.addEventListener(n,W,o,!1),this.addEventListener(s,t,a,!1),this.addEventListener(s,e,a,!1),this.addEventListener(n,t,l,!1),this.addEventListener(n,e,l,!1),this.addEventListener(s,H,r,!1),this.addEventListener(n,H,r,!1),this.addEventListener(s,$,r,!1),this.addEventListener(n,$,r,!1),this.addEventListener(this._window,"resize",function(){i.utils.isNull(i._rangeVisible)&&(i._setPositionAndLength(),i._setLowerKnobPosition(),i._setUpperKnobPosition())},!1)},t.prototype._touchStart=function(t){var e=this._touchState;if(1!==e&&2!==e&&3!==e){this._touchState=1;var i=t.currentTarget,s=this._lastTouch;if(this.utils.isNull(s))this.dom.addClass(i,v+"top");else if(s.target!==i){var n=this.dom;n.addClass(i,v+"top"),n.removeClass(s.target,v+"top")}this._lastTouch={x:t.clientX,y:t.clientY,value:i===this._lowerKnob?this.lower:this.upper,target:i}}},t.prototype._touchEnd=function(i){var s=this,t=this._touchState;if(0!==t&&4!==t){this._touchState=4;var n=this._lastTouch,o=i.currentTarget;this.utils.isNull(n)||n.target!==o||this.utils.requestAnimationFrame(function(){s._touchState=0;var t=o===s._lowerKnob,e=s._calculateOffset(i,t);t?n.value!==s.lower&&s._trigger("change"):n.value!==s.upper&&s._trigger("change"),s._setOffset(e,t)})}else this._touchState=0},t.prototype._setOffset=function(t,e){var i=this._maxOffset;return t<0?e?this._lowerKnobOffset=0:this._upperKnobOffset=0:i<t?e?this._lowerKnobOffset=i:this._upperKnobOffset=i:e?this._lowerKnobOffset=t:this._upperKnobOffset=t},t.prototype._trackLower=function(t){var e=this._touchState;if(2!==e)if(1===e)this._touchState=2;else if(0===e||3===e)return;var i,s=this._maxOffset,n=this._calculateOffset(t,!0);if(n<=0?(0<=(i=this.min)-this.lower&&(i=null),n=0):s<=n?((i=this.max)-this.lower<=0&&(i=null),n=s):(i=this._calculateValue(n))-this.lower==0&&(i=null),n>this._upperKnobOffset)return this._positionTogether(n,i),void this._setOffset(n,!1);this._positionLower(n,i)},t.prototype._trackUpper=function(t){var e=this._touchState;if(3!==e)if(1===e)this._touchState=3;else if(0===e||2===e)return;var i,s=this._maxOffset,n=this._calculateOffset(t,!1);if(n<=0?(0<=(i=this.min)-this.upper&&(i=null),n=0):s<=n?((i=this.max)-this.upper<=0&&(i=null),n=s):(i=this._calculateValue(n))-this.upper==0&&(i=null),n<this._lowerKnobOffset)return this._positionTogether(n,i),void this._setOffset(n,!0);this._positionUpper(n,i)},t.prototype._positionLower=function(e,i){var s=this;this.utils.requestAnimationFrame(function(){var t=s._slider.style;t[s._positionProperty]=e+"px",t[s._lengthProperty]=s._upperKnobOffset-e+"px",null!==i&&s._setLowerValue(i,!1,!0,!0)})},t.prototype._positionUpper=function(t,e){var i=this;this.utils.requestAnimationFrame(function(){i._slider.style[i._lengthProperty]=t-i._lowerKnobOffset+"px",null!==e&&i._setUpperValue(e,!1,!0,!0)})},t.prototype._positionTogether=function(e,i){var s=this;this.utils.requestAnimationFrame(function(){var t=s._slider.style;t[s._positionProperty]=e+"px",t[s._lengthProperty]="0px",null!==i&&(s._setLowerValue(i,!1,!1,!1),s._setUpperValue(i,!1,!0,!0))})},t.prototype._calculateValue=function(t){var e=this._step;return this.min+Math.round(t/this._increment/e)*e},t.prototype._calculateOffset=function(t,e){return(e?this._lowerKnobOffset:this._upperKnobOffset)+(this._isVertical?this._reversed?t.clientY-this._lastTouch.y:this._lastTouch.y-t.clientY:this._reversed?this._lastTouch.x-t.clientX:t.clientX-this._lastTouch.x)},t.prototype._calculateKnobPosition=function(t){return(t-this.min)*this._increment},t.prototype._setLowerValue=function(t,e,i,s){var n=this.lower;if(t!==n){if(t>=this.max)t=this.max;else if(t<=this.min)t=this.min;else if(Math.abs(t-n)<this._step)return;this.lower=t,e&&this._setLowerKnobPosition(),i&&this._fireChange(),s&&this._trigger("input")}},t.prototype._setUpperValue=function(t,e,i,s){var n=this.upper;if(t!==n){if(t>=this.max)t=this.max;else if(t<=this.min)t=this.min;else if(Math.abs(t-n)<this._step)return;this.upper=t,e&&this._setUpperKnobPosition(),i&&this._fireChange(),s&&this._trigger("input")}},t.prototype._setIncrement=function(){return this._increment=this._maxOffset/(this.max-this.min)},t.prototype._setPositionAndLength=function(){var e=this,i=this._slider.parentElement;this._isVertical?(this._lengthProperty="height",this._positionProperty=this._reversed?"top":"bottom",this._maxOffset=i.clientHeight):(this._lengthProperty="width",this._positionProperty=this._reversed?"right":"left",this._maxOffset=i.clientWidth),this._maxOffset?this._setIncrement():this._rangeVisible=new this._Promise(function(t){e._removeVisibilityListener=e.dom.whenVisible(function(){e._rangeVisible=null,e._setPositionAndLength(),t()},i)})},t.prototype._setLowerKnobPosition=function(n){var o=this;this._Promise.resolve(this._rangeVisible).then(function(){var t={},e=o._upperKnobOffset,i=o.utils.isNumber(e)?e:o._setOffset(o._calculateKnobPosition(o.upper),!1),s=o._calculateKnobPosition(n||o.lower);s!==o._lowerKnobOffset&&(t[o._positionProperty]=s+"px",t[o._lengthProperty]=i-s+"px",o._animator.animate(o._slider,D,{properties:t}),o._lowerKnobOffset=s)})},t.prototype._setUpperKnobPosition=function(i){var s=this;this._Promise.resolve(this._rangeVisible).then(function(){var t={},e=s._calculateKnobPosition(i||s.upper);e!==s._upperKnobOffset&&(t[s._lengthProperty]=e-s._lowerKnobOffset+"px",s._animator.animate(s._slider,D,{properties:t}),s._upperKnobOffset=e)})},t.prototype._fireChange=function(){var t={};t[this._lowerIdentifier]=this.lower,t[this._upperIdentifier]=this.upper,this.inputChanged(t)},t.prototype._trigger=function(t){var e=plat.acquire(i);e.initialize(this.element,t),e.trigger()},t.prototype._validateOrientation=function(t){return this.utils.isUndefined(t)?"horizontal":("horizontal"===t?e=t:"vertical"===t?(e=t,this._isVertical=!0):(this._log.debug('Invalid orientation "'+t+'" for '+this.type+'. Defaulting to "horizontal."'),e="horizontal"),e);var e},t._inject={_document:r,_window:o,_Promise:s,_animator:a},t}(plat.ui.BindControl);t.Range=mt,plat.register.control(b,mt);var vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,C+" "+(t||""))},e.prototype.initialize=function(){t.prototype.initialize.call(this),this.setClasses()},e}(plat.ui.controls.Select);t.Select=vt,plat.register.control(C,vt);var gt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.replaceWith="input",t.value="",t}return __extends(t,e),t.prototype.setClasses=function(t,e){this.dom.addClass(e||this.element,x+" "+(t||""))},t.prototype.initialize=function(){this.setClasses()},t.prototype.setTemplate=function(){this.dom.clearNode(this.element)},t.prototype.loaded=function(){var t=(this.options||{}).value||{},e=t.pattern,i=t.validation,s=this.utils.isString;this._type=this.attributes.type||t.type||"text",s(e)&&""!==e&&("/"===e[0]&&"/"===e[e.length-1]&&(e=e.slice(1,-1)),this._pattern=new RegExp(e)),s(i)&&""!==i&&("/"===i[0]&&"/"===i[i.length-1]&&(i=i.slice(1,-1)),this._validation=new RegExp(i)),this._initializeType()},t.prototype.validate=function(){return this._validation.test(this.element.value)},t.prototype.clear=function(){var t=this.element,e=t.value;""!==e&&(t.value=this.value="",this.inputChanged(this.value,e))},t.prototype.focus=function(){this.element.focus()},t.prototype.blur=function(){this.element.blur()},t.prototype.observeProperties=function(t){t.observeProperty(this._setBoundProperty,null,!0)},t.prototype._setBoundProperty=function(t,e,i,s){var n=this.element.value;if(this.utils.isNull(t)){if(!(t="")===s)return void(this.utils.isNull(n)&&this._onInputChanged(t))}else if(t===n)return;this._onInputChanged(t)},t.prototype._initializeType=function(){var t=this._type;switch(t){case"text":this._pattern=this._pattern||/[\S\s]*/,this._validation=this._validation||this._pattern;break;case"email":this._pattern=this._pattern||/[\S\s]*/,this._validation=this._validation||this._regex.validateEmail;break;case"password":this.