=e[0].scrollHeight-20},_queryHistoriesVersions:function(){var t=[];return this.objectInfo&&(t.push(l.getHistories(this.objectInfo,"output")),t.push(l.getVersions(this.objectInfo,"creationTime"))),Promise.all(t).then(function(t){return{historiesInfo:t[0],versionsInfo:t[1]}})},_handleGetOutputsSuccess:function(t){var e=t.data,n=t.index,o=[];return e&&e.forEach(function(t){if(d[t.format]){var e={id:l.getObjectId(t),format:l.getFormat(t),content:l.getOutputContentLink(t),modificationTime:l.getModificationTime(t,!0,"short")};if(e.format&&e.content){var n=l.getBurstKey(t),i=l.getLocale(t);n?(o[n]||(o[n]=[]),o[n][i]||(o[n][i]=[]),o[n][i].push(e)):(o[this.noBurstKey]||(o[this.noBurstKey]=[]),o[this.noBurstKey][i]||(o[this.noBurstKey][i]=[]),o[this.noBurstKey][i].push(e))}}}.bind(this)),{outputsInfo:o,index:n}},_mergeVersionAndHistory:function(e,o){return e=e||[],o=o||[],s.each(o,function(t,n){var i=!1;s.each(e,function(t,e){if(e.output&&e.output.id===n.id)return!(i=!0)}),i||(n[l.REQUESTED_TIME]=l.getCreationDate(n),delete n[l.CREATION_TIME],n[l.STATUS]="succeeded",e.push(n))}),s.each(e,function(t,e){if(e.output&&e.output.id){var n=e.output.id,i=!1;s.each(o,function(t,e){if(e.id===n)return!(i=!0)}),i||(e.output=null)}}),e},_getItems:function(t){this.mergedInfo=t;var r=[];return this.mergedInfo.forEach(function(t,e){var n=l.getRequestedTime(t,!0,"medium"),i="succeeded"===l.getStatus(t),o=null!==l.getDetailsLink(this.mergedInfo[e]),s=null!==this._getOutputsLinkFromIndex(e);r.push({type:"SingleLineLinks",name:e+"_versions",role:"group",items:[{align:"left",items:[{type:"icon",class:i?"versionReport":"versionStatusFailed",svgIcon:i?s?"common-savedoutput_report":"common-savedoutput_reporthistory":"common-failed",value:i?a.get("successful"):a.get("failed"),iconTooltip:a.get("report")},{type:"text",value:n,class:"versionText"+(s?"":" hasNoOutput"),clickCallback:s?this._toggleOutputsSection.bind(this,e):null}]},{align:"right",items:[{type:"icon",class:"versionDetailsLinks"+(o?"":" disabled"),svgIcon:"common-info-moreinfo",clickCallback:o?this._openDetails.bind(this,e):null,iconTooltip:a.get("showDetails"),showRightArrow:!0}]}]}),r.push({type:"CollapsibleSection",name:e+"_outputs",label:n,styleAsSimpleRow:!0,hideSectionTitle:!0,indent:3.3,items:[],onOpenChange:this._openOutputsSection.bind(this,e)}),r.push({type:"Separator"})}.bind(this)),r},_toggleOutputsSection:function(t,e){this._getOutputSection(t).toggleCollapsibleSection()},_showAllHistoryRefresh:function(){var t=this._oPropertyUIControl.getProperty("showAllHistory").isChecked();this._showAllHistoryChange(null,t)},_showItem:function(t,e){s(e).removeClass("hidden")},_selectItem:function(t){var e=s(t).closest(".propertyRow").nextUntil(".separator").addBack();return e=e.add(e.last().next())},_hideItem:function(t,e){this._selectItem(e).addClass("hidden")},_removeItem:function(t){this._selectItem(t).remove()},_showAllHistoryChange:function(t,e){e?s(".itemContainerUIControl > div",this.$el).each(this._showItem.bind(this)):s(".itemContainerUIControl .hasNoOutput",this.$el).each(this._hideItem.bind(this))},_getOutputFromIndex:function(t){var e=this.mergedInfo[t],n={};return h.isObject(e.output)?n[l.OUTPUT]=[e.output]:n[l.OUTPUT]=[e],n},_getOutputsLinkFromIndex:function(t){var e=this._getOutputFromIndex(t);return l.getOutputsLink(e)},_getVersionLinkFromIndex:function(t){var e=this._getOutputFromIndex(t);return l.getVersionLink(e)},_openOutputsSection:function(n,t,e){if(e){var i=this._getOutputsLinkFromIndex(n);this._getOutputs(i,n).then(this._handleGetOutputsSuccess.bind(this)).then(this._getOutputsSectionPayload.bind(this)).done(function(t){var e=this._getItemsSpec(t.outputsInfo,n,t.items);this._getOutputSection(n).refreshProperties(e)}.bind(this))}},_getVersionSection:function(t){var e=t+"_versions";return this._oPropertyUIControl.getProperty(e)},_getOutputSection:function(t){var e=t+"_outputs";return this._oPropertyUIControl.getProperty(e)},_openDetails:function(i){this._getDetails(i).then(function(t){var e=s("");this.parentEl.append(e);var n=new o({glassContext:this.glassContext,position:this.slideout.position,el:e,width:"400",content:{module:"bi/content_apps/VersionsDetailsView",parentView:this,objectInfo:this.objectInfo,historyInfo:this.mergedInfo[i],detailsInfo:t,glassContext:this.glassContext}});n.render().then(n.show())}.bind(this))},_getOutputsSectionPayload:function(t){var i=t.outputsInfo,e=t.index,o=[];return this._canDelete()&&o.push({type:"SingleLineLinks",items:[{align:"left",items:[{type:"text",value:a.get("deleteReportVersion"),class:"versionText",clickCallback:function(){this._onClickDelete(e)}.bind(this)}]}]}),u.getContentLocales(this.glassContext).then(function(t){var e;if(i&&0")),e._container().addClass("contentDeleteConfirmDialog")},_handleDeleteVersionSuccess:function(t){var e=this._getVersionSection(t).getPropertyNode(),n=this._getOutputSection(t);s(".versionText",e).removeClass("clickable").addClass("hasNoOutput"),this._showAllHistoryRefresh(),s(".versionDetailsLinks",e).hasClass("disabled")&&this._removeItem(e),s(".versionReport .svgIcon use",e).attr("xlink:href","#common-savedoutput_reporthistory"),n.getPropertyNode().remove();var i=a.get("toastDoneDeletingSingular",{nameOfItem:p.enforceTextDirection(a.get("reportOutputVersion"))});this.glassContext.appController.showToast(i)},_deleteVersion:function(t){var e=this._getVersionLinkFromIndex(t);if(e){var n={dataType:"json",type:"DELETE",url:e+"?force=true&recursive=true"};return this.glassContext.getCoreSvc(".Ajax").ajax(n).then(this._handleDeleteVersionSuccess.bind(this,t)).catch(function(t){u.showAjaxServiceError(this.glassContext,t)}.bind(this))}return Promise.resolve()},_initOutputHandlers:function(){return this._outputHandlers?Promise.resolve():this.glassContext.appController.findCollection("com.ibm.bi.contentApps.authoring.outputHandlers").then(function(t){this._outputHandlers=[];var e=[];return h.each(t,function(t){e.push(new Promise(function(e){n([t.outputHandler],function(t){this._outputHandlers.push(new t),e()}.bind(this))}.bind(this)))}.bind(this)),Promise.all(e)}.bind(this))},_handleOutput:function(o){return this._initOutputHandlers().then(function(){if("interactive"===this._getOutputDefaultAction(o.output.format)&&o.download)return Promise.resolve(!1);var n,i=-1;return h.each(this._outputHandlers||[],function(t){var e=t.getPriority();i",{class:"propertyUIControl versionsView"}),this.$el.append(this._containerElement),this._getAdditionalInfo().then(function(){return this._oPropertyUIControl=this._getPropertyUIControl({el:this.$el,glassContext:this.glassContext,slideout:this.slideout,animatedSpinner:!0,items:[{name:"versions",value:e.get("versions"),type:"Banner"},{type:"TabControl",items:[{name:e.get("versions"),module:o,objectInfo:this.objectInformation,glassContext:this.glassContext,slideout:this.slideout,parentEl:this.$el},{name:e.get("archives"),module:s,objectInfo:this.objectInformation,glassContext:this.glassContext,slideout:this.slideout}]}]}),this._oPropertyUIControl.render()}.bind(this))},_getPropertyUIControl:function(t){return new i(t)},_getAdditionalInfo:function(){return this.glassContext.getCoreSvc(".Ajax").ajax({dataType:"json",type:"GET",url:n.getSelfLink(this.objectInformation),data:{fields:"permissions,"+n.RUN_IN_ADVANCED_VIEWER}}).then(function(t){var e=t.data&&t.data.data;if(!e)return Promise.reject(new Error("No additional information"));r.extend(this.objectInformation,e[0])}.bind(this))}});return a}),define("bi/content_apps/VersionsDetailsView",["q","jquery","bi/glass/app/ContentView","bi/content_apps/nls/StringResource","bacontentnav/utils/ContentStoreObject","bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl","bacontentnav/utils/GlassContextHelper","bi/content_apps/utils/C10Utils","underscore"],function(e,i,t,a,l,n,s,o,r){"use strict";var u=t.extend({init:function(t){u.inherited("init",this,arguments),r.extend(this,t)},render:function(){var t=e.defer();return this._getItems().then(function(t){return this.$el.addClass("versionsDetails"),this._oPropertyUIControl=new n({el:this.$el,glassContext:this.glassContext,slideout:this.slideout,items:t}),this._oPropertyUIControl.render()}.bind(this)).done(t.resolve),t.promise},_getItems:function(){var n=e.defer(),t="succeeded"===l.getStatus(this.historyInfo),i=[{type:"Banner",name:"detailsBanner",value:l.getRequestedTime(this.historyInfo,!0,"medium"),centerLabel:!0,backButton:!0,editable:!1,readOnly:!0,onClose:function(){this.slideout.hide()}.bind(this)},{type:"Separator"},{type:"SingleLineLinks",name:"actionbar",items:[{align:"left",items:[{type:"icon",class:t?"versionStatusSuccessful":"versionStatusFailed",svgIcon:t?"common-successful":"common-failed",value:t?a.get("successful"):a.get("failed"),iconTooltip:t?a.get("successful"):a.get("failed")},{type:"text",class:"versionStatusText",role:"status",value:t?a.get("successful"):a.get("failed")}]}]},{type:"SingleLineLinks",name:"historydetails",items:[{align:"right",items:[{type:"text",value:a.get("runHistoryDetails"),class:"historydetailsText",clickCallback:this._viewRunHistory.bind(this),showRightArrow:!0}]}]}];return l.getMessages(this.detailsInfo)&&i.push({type:"CollapsibleSection",name:"errorMessages",open:!0,label:a.get("errorMessages"),items:this._getMessageItems()}),this._getOptionsItems().then(function(t){i=i.concat([{type:"CollapsibleSection",name:"runTime",open:!0,label:a.get("runTime"),items:[{type:"SingleLineValue",name:"requestTime",label:a.get("requestTime"),value:l.getRequestedTime(this.historyInfo,!0,"medium")},{type:"Separator"},{type:"SingleLineValue",name:"startTime",label:a.get("startTime"),value:l.getExecutionTime(this.historyInfo,!0,"medium")},{type:"Separator"},{type:"SingleLineValue",name:"endTime",label:a.get("endTime"),value:l.getCompletionTime(this.historyInfo,!0,"medium")}]}]),"jupyterNotebook"!==this.objectInfo.type&&i.push({type:"CollapsibleSection",name:"options",open:!0,label:"jobDefinition"===this.objectInfo.type?a.get("job"):a.get("report"),items:t});var e=l.getDetailsReportVersionParameters(this.detailsInfo);e&&(i=i.concat([{type:"CollapsibleSection",name:"promptValues",label:a.get("promptValues"),items:this._getPromptValuesItems(e)}])),n.resolve(i)}.bind(this)),n.promise},_getMessageItems:function(){var o=[],s="versionMessageIcon ",r="";return l.getMessages(this.detailsInfo).forEach(function(t,e){var n=l.getMessageSeverity(t),i="";switch(n){case"error":case"fatal":i=s+"versionErrorIcon",r="common-close-cancel-error";break;case"warn":i=s+"versionWarningIcon",r="common-warning-hollow";break;case"debug":i=s+"versionDebugIcon",r="common-debug";break;case"info":i=s+"versionInfoIcon",r="common-information"}o.push({type:"SingleLineLinks",name:"messages_"+e,items:[{align:"left",items:[{type:"icon",class:i,svgIcon:r,value:a.get(n),iconTooltip:a.get(n)},{type:"text",class:"wraptext textSelectable",value:l.getMessageDetail(t)}]}]})}),o},_getOptionsItems:function(){var i=l.getDetailsReportVersionOptions(this.detailsInfo),o=e.defer();return i?this._getReportLanguages(i).then(function(t){var e=[];"jobDefinition"!==this.objectInfo.type&&e.push({type:"TextArea",name:"formats",label:a.get("formats"),value:this._getReportFormats(i),editable:!1,multiline:!1},{type:"Separator"}),e.push({type:"TextArea",name:"languages",label:a.get("languages"),value:t,editable:!1,multiline:!1});var n=l.getLocation(this.objectInfo);n&&(e=e.concat([{type:"Separator"},{type:"SingleLineValue",name:"location",label:a.get("location"),value:n}])),o.resolve(e)}.bind(this)):o.resolve([{type:"SingleLineLinks",items:[{align:"left",items:[{type:"text",class:"wraptext",value:a.get("noReportOptionsAvailable")}]}]}]),o.promise},_getReportFormats:function(t){var e=this._getReportVersionOption(t,"outputFormat"),n=[];return e?(r.isArray(e)?e.forEach(function(t){n.push(a.get(t))}):n.push(a.get(e)),this._getDelimitedStringFromArray(n)):a.get("unavailable")},_getReportLanguages:function(t){var i=this._getReportVersionOption(t,"outputLocale"),o=e.defer();return i?s.getContentLocales(this.glassContext).then(function(e){var n=[];e=e||{},i.forEach(function(t){n.push(e[t])}),o.resolve(this._getDelimitedStringFromArray(n))}.bind(this)):o.resolve(a.get("unavailable")),o.promise},_getDelimitedStringFromArray:function(t){return t?t.join(", "):null},_getReportVersionOption:function(t,e){var n=i.grep(t,function(t){return t.name===e});return 1===n.length&&n[0].value?n[0].value:null},_getPromptValuesItems:function(t){var e=[];return l.getPromptsDisplayValues(t,!0).forEach(function(t){e.push({type:"SingleLineLinks",items:[{align:"left",items:[{type:"text",class:"promptNameText textSelectable",value:r.escape(t.name+":")}]}]},{type:"SingleLineLinks",items:[{align:"left",items:[{type:"text",class:"wraptext textSelectable",value:r.escape(t.display)}]}]},{type:"Separator"})}),e},_viewRunHistory:function(){var t=[{m_name:this.objectInfo.defaultName}];o.openC10Morphlet(o.morphletMap.viewHistory,this.objectInfo.type,this.historyInfo.id,t)}});return u}),define("js/content_apps/versionBundle",function(){});