(function(){"use strict";var e="tree";var r;page.using={types:["RecordTreeView","GoogleAnalyticsProvider"]};page.onLoad=function(){var t=this.url;var d=t.getUid();var n=t.getLinkUid("");var s="Tree";if(d&&d.infoAreaId){var u=d.infoAreaId;u8.services.googleAnalyticsProvider.sendCRMDataToGA(u,s)}var c=t.get("relationName");var g=t.getOptions("expandOptions");if(!g&&t.has("initialExpandParams")){g=u8.services.migration.convertInitialExpandParams(t.getOptions("initialExpandParams"))}var p=t.get("walkUpToRootRecord")=="1"||t.getBoolean("walkUpToRootRecord")!==false;var l=this.getHistory();if(l.exists&&n){var v=u8.services.history.getHistoryRecordUid({infoAreaId:n.infoAreaId});if(u8.isValidRecordUid(v)){n=$.extend(n,v)}}l=this.getHistory(e);if(l&&u8.isValidRecordUid(l.uid)){d=l.uid;c=null}var f={uid:d,link:n,isDefault:true,recordTree:{model:{treeViewName:t.get("treeViewName"),linkName:c,walkUpToRootRecord:p}},headerGroupName:t.get("headerGroupName"),viewMode:t.get("viewMode"),expandView:g||{},parent:this,usePageHeader:!page.process&&(n||d),onCreate:function(e,r){if(r.error){$("#tree").errorMessage(r.error);r.error.handled=true}$("#tree").css("visibility","inherit")}};var m=page.url.get("proceed","off");if(page.url.get("onSave")||/on.*Save/.test(m)){f.onSave=i.bind(this)}if(page.url.get("onDelete")||/on.*Delete/.test(m)){f.onDelete=a.bind(this)}r=u8.widget("RecordTreeView",$el("tree"),f);var h=page.id+"_tree";u8.services.publisher.subscribe("record",o,h);page.bind("Unload",function(){u8.services.publisher.unsubscribe("record",h)})};function i(e,r){t("Save",r,{savedUid:u8.recordUidToString(r.uid),SavedInfoArea:r.uid.infoAreaId,SavedRecID:r.uid.recordId})}function a(e,r){t("Delete",r)}function t(e,r,i){$command(page,e,{parameters:i,stopPropagationAt:"Page"},function(i,a){if(a.stopPropagation){return}if(page.process){a.cancel=true}page.proceed({uid:r.uid,command:e})})}function o(e,i){if(e!=r){return}d(i.data&&i.data.uid)}function d(r){if(!u8.isValidRecordUid(r)){return}var i=page.getHistory(e);if(i){i.uid=r}var a=page.url;if(a.has("uid")){a.set("uid",u8.recordUidToString(r));page.setUrl(a)}}})();