(function(){"use strict";var e="{{each phases}}{{widget($value)}}{{/each}}";u8.Base.Widgets.ProcessPhases=function(e,t){$.extend(true,this,u8.Base.Widgets.ProcessPhases.defaults,t);this.Widget(e,t);$assert(this.process,"Required field 'process' has not been set.");this._isCreated=false;this._load(this._create.bind(this))};u8.Base.Widgets.ProcessPhases.makeClass({name:"ProcessPhases",deriveFrom:u8.Base.Widgets.Widget,events:["Create"]});$.extend(u8.Base.Widgets.ProcessPhases.prototype,{dispose:function(){if(this._isDisposed){return}this.Widget_dispose()},update:function(){if(!this._model.phases){return}var e=this.process.getActivePhase();var t=this;this._model.phases.forEach(function(s,i){var a=s.phase===e&&t.process.step&&t.process.step.helpText;var n=t._getHelpText(s.phase,a);if(n.length>0){var h=t.children.get(t.id+"_phase"+i).element;h.title=n;h.setAttribute("data-helpcontenttype","text/x-markdown")}})},_load:function(e){return e()},_create:function(){this._createModel();this._createView();u8.tools.createdWhenReady(this)},_createModel:function(){var e=undefined;var t=this.process.phases;if(t){e=[];for(var s=0;s<t.length;s++){var i=t[s];var a=i.view&&i.view.type||"ProcessPhaseView";var n=i.view&&i.view.options||{};$.extend(n,{type:a,phase:i,id:this.id+"_phase"+s,context:i,onActiveChange:this._onPhaseActiveChange.bind(this)});if(s<t.length-1){n.nextId=this.id+"_phase"+(s+1)}e.push(n)}}this._model={percent:t&&t.length&&100/t.length,phases:e}},_createView:function(){this.empty();this.$(this.element).addClass("u8-processphases").utml({name:"processphases-template",template:e,data:this._model,itemOptions:{parent:this,context:this.process}})},_getHelpText:function(e,t){var s="";if(e.text){s="<strong>"+e.text+"</strong>"}if(e.helpText){if(s.length>0){s+="\n- - -\n"}s+=e.helpText}if(t){if(s.length>0){s+="\n- - -\n"}s+=t}return s},_onPhaseActiveChange:function(e,t){if(!t.active){return}u8.Base.Dom.scrollIntoCenter(e.element,"horizontal")}})})();