var __extends=this&&this.__extends||function(m,c){function k(){this.constructor=m}for(var l in c)c.hasOwnProperty(l)&&(m[l]=c[l]);m.prototype=null===c?Object.create(c):(k.prototype=c.prototype,new k)};
define("DateHelper",["require","exports"],function(m,c){function k(d){return d.getUTCFullYear()+"-"+l(d.getUTCMonth()+1)+"-"+l(d.getUTCDate())+"T"+l(d.getUTCHours())+":"+l(d.getUTCMinutes())+":"+l(d.getUTCSeconds())+"-0000"}function l(d){return 10>d?"0"+d:d}c.ISODateString=k;c.displayDueDate=function(d){var g=(new Date).getTimezoneOffset();d=new Date(d);d.setMinutes(d.getMinutes()-g);return d.getUTCFullYear()+"-"+l(d.getUTCMonth()+1)+"-"+l(d.getUTCDate())};c.convertTimeStamp=function(d){return(new Date(d)).toLocaleString()};
c.compareDateStrings=function(d,g){var h=new Date(g);return(new Date(d)).getTime()-h.getTime()};c.fixDueDate=function(d){d=new Date(d);var g=(new Date).getTimezoneOffset();d.setDate(d.getDate()+1);d.setMinutes(g);return k(d)}});
define("l10n",["require","exports"],function(m,c){function k(){if(!l){var d;a:{d=window.location.search.substr(1).split("&");for(var g=0;g<d.length;g++){var h=d[g].split("=");if("hl"===h[0]&&1<h.length){d=decodeURIComponent(h[1]);break a}}d=void 0}if(!d)a:{d=document.cookie.split(/\s*;\s*/);for(g=0;h=d[g];g++){if(0===h.lastIndexOf("hl=",0)){d=h.substr(3);break a}if("hl"===h){d="";break a}}d="en"}l=d||"en"}l&&"en-us"===l.toLowerCase()&&(l="en");return l=l.toLowerCase()}var l;c.strings=void 0;c.getLanguageFilePath=
function(d){var g=k();if("en"!==g)return d+g+".js"};c.getCurrentLanguage=k;c.forceEnglish=function(d){l="en"};c.isEnglish=function(d){return"en"===d};c.$t=function(d){if(!c.strings)return d;var g=k(),g=c.strings[g];return g?(g=g[d])?g:d:d}});
define("FileUtils",["require","exports"],function(m,c){c.StripExtension=function(c){var l=goog.string.path.extension(c);0<l.length&&(c=c.slice(0,c.length-l.length-1));return c};c.ArrayBufferToBase64=function(c){var l="";c=new Uint8Array(c);for(var d=c.byteLength,g=0;g<d;++g)l+=String.fromCharCode(c[g]);return window.btoa(l)};c.getValidSKPName=function(c){goog.string.endsWith(c,".skp")||(c+=".skp");return c}});
define("TC-Object",["require","exports","FileUtils","DateHelper","l10n"],function(m,c,k,l,d){c.Type={view:"VIEW",file:"FILE",folder:"FOLDER",user:"USER",group:"GROUP",clash:"CLASH",release:"RELEASE",todo:"TODO"};(function(a){a[a.CRITICAL=0]="CRITICAL";a[a.HIGH=1]="HIGH";a[a.NORMAL=2]="NORMAL";a[a.LOW=3]="LOW"})(c.TaskPriority||(c.TaskPriority={}));(function(a){a[a.NEW=0]="NEW";a[a.IN_PROGRESS=1]="IN_PROGRESS";a[a.RESOLVED=2]="RESOLVED";a[a.BLOCKED=3]="BLOCKED";a[a.CLOSED=4]="CLOSED"})(c.TaskStatus||
(c.TaskStatus={}));c.UserStatus={ACTIVE:"ACTIVE",PENDING:"PENDING",REMOVED:"REMOVED"};var g=function(){function a(a){this.hasDetails_=!1;this.id_=a.id;this.type_=a.type}Object.defineProperty(a.prototype,"id",{get:function(){return this.id_},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"type",{get:function(){return this.type_},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"hasDetails",{get:function(){return this.hasDetails_},set:function(a){this.hasDetails_=
a},enumerable:!0,configurable:!0});a.prototype.isNull=function(){return!1};a.prototype.getThumbnailUrl=function(){return""};a.prototype.setThumbnailData=function(a){this.thumbnailData_=k.ArrayBufferToBase64(a)};a.newNull=function(){return new b};a.newMulti=function(){return new e};return a}();c.Assignee=g;var h=function(a){function f(f){a.call(this,f);this.firstName_=f.firstName;this.lastName_=f.lastName;this.thumbnail_=f.thumbnail;this.email_=f.email}__extends(f,a);Object.defineProperty(f.prototype,
"id",{get:function(){return this.id_},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"type",{get:function(){return this.type_},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"email",{get:function(){return this.email_},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"thumbnailData",{get:function(){return this.thumbnailData_},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"firstName",{get:function(){return this.firstName_},enumerable:!0,
configurable:!0});Object.defineProperty(f.prototype,"lastName",{get:function(){return this.lastName_},enumerable:!0,configurable:!0});f.prototype.defaultThumbnail=function(){return"images/dlg_user.svg"};f.prototype.getInitials=function(){var a="";goog.isDefAndNotNull(this.firstName_)&&(a+=this.firstName_[0]);goog.isDefAndNotNull(this.lastName_)&&(a+=this.lastName_[0]);goog.string.isEmpty(a)&&(a=this.email_.slice(0,1));return a.toUpperCase()};f.prototype.displayName=function(){var a="",f=!1,n=!1;goog.isDefAndNotNull(this.firstName_)&&
!goog.string.isEmpty(this.firstName_)&&(a+=this.firstName_,f=!0);goog.isDefAndNotNull(this.lastName_)&&!goog.string.isEmpty(this.lastName_)&&(f&&(a+=" "),a+=this.lastName_,n=!0);f||n||goog.isDefAndNotNull(this.email_)&&(goog.string.isEmpty(this.email_)||(a=goog.string.splitLimit(this.email_,"@",1)[0]));return a};f.prototype.hasThumbnail=function(){return goog.isDefAndNotNull(this.thumbnail_)&&!goog.string.isEmpty(this.thumbnail_)?!0:!1};f.prototype.hasThumbnailData=function(){return goog.isDefAndNotNull(this.thumbnailData_)&&
!goog.string.isEmpty(this.thumbnailData_)?!0:!1};f.prototype.getThumbnail=function(){return this.hasThumbnail()&&this.hasThumbnailData()?"data:image/bmp;base64, "+this.thumbnailData_:null};f.prototype.getThumbnailUrl=function(){return this.thumbnail_};return f}(g);c.User=h;var b=function(a){function f(){a.call(this,{})}__extends(f,a);f.prototype.getInitials=function(){return"?"};f.prototype.defaultThumbnail=function(){return"images/dlg_assign_user.svg"};f.prototype.getThumbnail=function(){return this.defaultThumbnail()};
f.prototype.hasThumbnailData=function(){return!1};f.prototype.isNull=function(){return!0};f.prototype.displayName=function(){return d.$t("None")};f.prototype.hasThumbnail=function(){return!1};Object.defineProperty(f.prototype,"hasDetails",{get:function(){return!0},enumerable:!0,configurable:!0});return f}(g);c.NullAssignee=b;var e=function(a){function f(){a.call(this,{id:null,type:null})}__extends(f,a);f.prototype.isNull=function(){return!1};f.prototype.getInitials=function(){return".."};f.prototype.defaultThumbnail=
function(){return"images/dlg_user_group.svg"};f.prototype.getThumbnail=function(){return this.defaultThumbnail()};f.prototype.hasThumbnail=function(){return!1};f.prototype.hasThumbnailData=function(){return!1};f.prototype.displayName=function(){return d.$t("Multiple")};Object.defineProperty(f.prototype,"hasDetails",{get:function(){return!0},enumerable:!0,configurable:!0});return f}(g);c.MultiUser=e;var q=function(a){function f(f){a.call(this,f);this.name_=f.name;this.projectId_=f.projectId}__extends(f,
a);Object.defineProperty(f.prototype,"name",{get:function(){return this.name_},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"projectId",{get:function(){return this.projectId_},enumerable:!0,configurable:!0});f.prototype.defaultThumbnail=function(){return"images/dlg_user_group.svg"};f.prototype.getInitials=function(){var a="";goog.isDefAndNotNull(this.name_[0])&&(a+=this.name_[0]);goog.isDefAndNotNull(this.name_[1])&&(a+=this.name_[1]);return a.toUpperCase()};f.prototype.displayName=
function(){return goog.isDefAndNotNull(this.name_)&&!goog.string.isEmpty(this.name_)?this.name_:""};f.prototype.hasThumbnail=function(){return!1};f.prototype.hasThumbnailData=function(){return!1};f.prototype.getThumbnail=function(){return this.defaultThumbnail()};Object.defineProperty(f.prototype,"hasDetails",{get:function(){return!0},enumerable:!0,configurable:!0});return f}(g);c.Group=q;m=function(){function a(a){this.id=a.id;this.label=a.label;this.description=a.description;this.dueDate=a.dueDate;
this.status=a.status;this.priority=a.priority;this.projectId=a.projectId;this.attachments=a.attachments;this.createdOn=a.createdOn;goog.isDefAndNotNull(this.attachments)||(this.attachments=[]);this.assignees=a.assignees;goog.isDefAndNotNull(this.assignees)?this.assigneesCSV=this.getAssigneeListCSV(a.assignees):(this.assignees=[],this.assigneesCSV="");goog.isDefAndNotNull(this.dueDate)?this.displayDueDate=l.displayDueDate(this.dueDate):this.displayDueDate=null;this.view=null}a.defaultTask=function(f){return new a({id:"",
label:"",description:"",dueDate:null,status:a.statusOptions[0],priority:a.priorityOptions[1],projectId:f,assignees:[]})};a.prototype.getDisplayedAssignee=function(){var a=this.assignees;if(1<a.length)return g.newMulti();if(1==a.length){a=a[0];if(a.type==c.Type.user)return new h(a);if(a.type==c.Type.group)return new q(a)}return g.newNull()};a.prototype.addAttachment=function(a,e){var b={id:a,type:e,embedded:e==c.Type.view?!0:!1};Array.isArray(this.attachments)||(this.attachments=[]);this.attachments.push(b)};
a.prototype.removeAttachment=function(a){var e,b=!1;this.attachments.forEach(function(n,t){n.id===a&&(e=t)});e&&(this.attachments.splice(e),b=!0);return b};a.prototype.removeAllAttachments=function(){this.attachments=[]};a.prototype.includesModel=function(a){var e=!1;this.attachments.forEach(function(b){b.id==a&&(e=!0)});goog.isDefAndNotNull(this.view)&&Array.isArray(this.view.files)&&this.view.files.forEach(function(b){b===a&&(e=!0)});return e};a.prototype.getDifference=function(a){var e={};this.description.trim()!=
a.description.trim()&&(e.description=a.description);this.status!=a.status&&(e.status=a.status);this.priority!=a.priority&&(e.priority=a.priority);this.hasDifferentAssignees(a)&&(e.assignees=a.assignees);this.hasDifferentDueDate(a)&&(e.dueDate=a.dueDate);return e};a.prototype.getViewAttachment=function(){for(var a=this.attachments,e=0;e<a.length;++e)if(a[e].type==c.Type.view&&a[e].embedded)return a[e];return null};a.prototype.hasDifferentAssignees=function(a){if(this.assignees.length!=a.assignees.length)return!0;
this.assignees.forEach(function(e,b,n){if(n[b].id!=a.assignees[b].id)return!0});return!1};a.prototype.hasDifferentDueDate=function(a){var e=Date.parse(this.dueDate);a=Date.parse(a.dueDate);return e==a||isNaN(e)&&isNaN(a)?!1:!0};a.prototype.getThumbnailURL=function(){var a;if(goog.isDefAndNotNull(this.attachments))for(var e=0,b=this.attachments;e<b.length;e++)if(a=b[e],"VIEW"==a.type&&(a=a.thumbnailUrl,goog.isDefAndNotNull))return a;return null};a.prototype.getAssigneeListCSV=function(a){for(var e=
[],b=0;b<a.length;++b)if(a[b].type==c.Type.user){var n=new h(a[b]);e.push(n.displayName())}else a[b].type==c.Type.group&&(n=new q(a[b]),e.push(n.displayName()));return e.join(", ")};a.statusOptions=["NEW","IN_PROGRESS","RESOLVED","BLOCKED","CLOSED"];a.priorityOptions=["LOW","NORMAL","HIGH","CRITICAL"];return a}();c.Task=m});
define("TrimbleConnect","require exports ModelStorageProvider XhrUtils TC-Object ErrorHandler".split(" "),function(m,c,k,l,d,g){var h;(function(b){b[b.FULL_ACCESS=0]="FULL_ACCESS";b[b.NO_ACCESS=1]="NO_ACCESS";b[b.READ=2]="READ"})(h||(h={}));m=function(){function b(e){this.connectClientIdentifier_=e;this.errorHandler_=new g.ErrorHandler}Object.defineProperty(b.prototype,"token",{get:function(){return this.token_},enumerable:!0,configurable:!0});b.prototype.baseURL=function(e){return this.getRegionURLFromLocation(e)+
this.CONNECT_API_ENDPOINT};Object.defineProperty(b.prototype,"name",{get:function(){return"Trimble Connect"},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,"iconURL",{get:function(){return"images/tb_connect_icon.svg"},enumerable:!0,configurable:!0});b.prototype.initialize=function(e){this.TOKEN_URL=e.tokenUrl;this.CONNECT_BASE_URL=e.connectBaseUrl;this.CONNECT_API_ENDPOINT=e.connectAPIEndPoint;this.USER_AGENT=e.userAgent;goog.isDefAndNotNull(e.connectClientIdentifier)&&(this.connectClientIdentifier_=
e.connectClientIdentifier);return this.refreshToken()};b.prototype.refreshToken=function(){var e=this,b=this.doTokenRequest().then(function(a){if(a.error)throw Error("Problem fetching connect token: "+a.error);e.token_=a.token}),b=b.then(function(){return e.getLicenses()});return b=b.then(function(){return e.getRegions()})};b.prototype.doTokenRequest=function(){var e=l.crossDomainRequest(this.TOKEN_URL+"?client="+this.connectClientIdentifier_);return e=e.then(function(e){return JSON.parse(e)})};b.prototype.getLicenses=
function(){var e=this,b=this.doRequest(this.CONNECT_BASE_URL,"/users/licenses").promise;return b=b.then(function(a){e.licenses_=JSON.parse(a)})};b.prototype.getProjectsOrCreateDefault=function(){var e=this;this.projectIdRegionIndexMap_={};for(var b=[],a=0;a<this.regions_.length;++a){var f=this.doRequest(this.regions_[a].origin,"/projects");b.push(f)}var d=[];b.forEach(function(a,n){var b=e.regions_[n],f={promise:a.promise.then(function(a){return e.parseProjectsArrayOrCreateDefault(a,b).then(function(a){return e.convertProjects(a,
n)})}),cancel:function(){a.cancel()}};d.push(f)});return d};b.prototype.parseProjectsArrayOrCreateDefault=function(e,b){var a=JSON.parse(e),a=a.filter(function(a){return a.access===h[h.FULL_ACCESS]}),f=goog.Promise.resolve(a);b.isMaster&&0==a.length&&(f=this.createDefaultProject(),f=f.then(function(e){e=JSON.parse(e);a.push(e);return a},void 0,this));return f};b.prototype.convertProjects=function(e,b){for(var a=[],f=this.regions_[b],d=0;d<e.length;d++){var p=e[d],p={region:f.location,id:p.id,name:p.name,
thumbnailURL:p.thumbnail,rootFolderId:p.rootId,hasChildren:!0};(new goog.Uri(p.thumbnailURL,!0)).hasDomain()||(p.thumbnailURL=this.CONNECT_BASE_URL+p.thumbnailURL);a.push(p);this.projectIdRegionIndexMap_[p.id]=b}return a};b.prototype.getProjectsSynchronous=function(){var e=this.getProjectsOrCreateDefault().map(function(e){return e.promise});return goog.Promise.all(e)};b.prototype.getRegionForProject=function(e){var b=this,a=goog.Promise.resolve();this.projectIdRegionIndexMap_&&void 0!==this.projectIdRegionIndexMap_[e]||
(a=this.getProjectsSynchronous());return a=a.then(function(){var a=b.projectIdRegionIndexMap_[e];return void 0!==a?b.regions_[a].location:goog.Promise.reject()},void 0,this)};b.prototype.getLatestVersionId=function(e,b){var a=this.getRegionURLFromLocation(e),a=this.doRequest(a,"/files/"+b+"/versions","GET").promise;return a=a.then(function(a){a=JSON.parse(a);return 0<a.length?a[0].versionId:goog.Promise.reject()})};b.prototype.createDefaultProject=function(){var e=this.regions_[this.masterRegionIndex_].origin,
b={name:"SketchUp"};goog.isDefAndNotNull(this.licenses_)&&0<this.licenses_.length&&(b.licenseId=this.licenses_[0].id);return this.doRequest(e,"/projects","POST",JSON.stringify(b),!0).promise};b.prototype.defaultAlignment=function(e){return{fileId:e,axisX:0,axisY:0,axisZ:1,locationX:0,locationY:0,locationZ:0,refDirectionX:1,refDirectionY:0,refDirectionZ:0}};b.prototype.getRegions=function(){var e=this;if(goog.isDefAndNotNull(this.regions_)&&0<this.regions_.length)return goog.Promise.resolve();this.regions_=
[];this.masterRegionIndex_=-1;var b=this.doRequest(this.CONNECT_BASE_URL,"/regions").promise;return b=b.then(function(a){a=JSON.parse(a);for(var b=0;b<a.length;++b){var d=a[b],p=d.origin;goog.string.startsWith(p,"//")&&(p="https:"+p);d.origin=p;d.isMaster&&(e.masterRegionIndex_=b);e.regions_.push(d)}},void 0,this)};b.prototype.getRegionURLFromLocation=function(e){for(var b=0;b<this.regions_.length;++b)if(this.regions_[b].location==e)return this.regions_[b].origin;throw Error("Could not find the region for location "+
e);};b.prototype.getContents=function(b,d){var a=this,f=this.getRegionURLFromLocation(b),f=this.doRequest(f,"/folders/"+d+"/items").promise;return f=f.then(function(f){var d=[];f=JSON.parse(f);for(var n=0;n<f.length;n++){var t=a.convertResponseToFolderItem(f[n],b);d.push(t)}return d},void 0,this)};b.prototype.convertResponseToFolderItem=function(b,d){var a={id:b.id,createdOn:b.createdOn,modifiedOn:b.modifiedOn,region:d,parentFolderId:b.parentId,projectId:b.projectId,versionId:b.versionId,name:b.name,
type:"FOLDER"===b.type?k.FolderItemType.Folder:k.FolderItemType.File,size:b.size,thumbnailURL:b.thumbnailUrl?b.thumbnailUrl[0]:void 0,hasChildren:"FOLDER"===b.type?!0:!1};b.createdBy&&(a.createdByEmail=b.createdBy.email,a.createdByFirstName=b.createdBy.firstName,a.createdByLastName=b.createdBy.lastName);b.modifiedBy&&(a.modifiedByEmail=b.modifiedBy.email,a.modifiedByFirstName=b.modifiedBy.firstName,a.modifiedByLastName=b.modifiedBy.lastName);return a};b.prototype.downloadFile=function(b,d,a,f){b=
this.getRegionURLFromLocation(b);return this.doRequest(b,"/files/"+d+"/content?versionId="+a,"GET",null,!1,!0,f)};b.prototype.uploadFile=function(b,d,a,f,g){b=this.getRegionURLFromLocation(b);var p=new FormData;p.append(d,f,d);var n=this.doRequest(b,"/files?parentId="+a,"POST",p,!1,!1,g);return{promise:n.promise.then(function(a){a=JSON.parse(a)[0];return{projectId:a.projectId,parentFolderId:a.parentId,fileId:a.id,versionId:a.versionId}}),cancel:function(){n.cancel()}}};b.prototype.downloadThumbnail=
function(b){return this.doRequest(b,"","GET",null,!1,!0).promise};b.prototype.createFolder=function(b,d,a){var f=this,g=this.getRegionURLFromLocation(b);return this.doRequest(g,"/folders","POST",JSON.stringify({name:d,parentId:a}),!0).promise.then(function(a){a=JSON.parse(a);return f.convertResponseToFolderItem(a,b)})};b.prototype.deleteFile=function(b,d){var a=this.getRegionURLFromLocation(b);return this.doRequest(a,"/files/"+d,"DELETE").promise.then(function(){return!0})};b.prototype.deleteFolder=
function(b,d){var a=this.getRegionURLFromLocation(b);return this.doRequest(a,"/folders/"+d,"DELETE").promise.then(function(){return!0})};b.prototype.getErrorTypeFromErrorString=function(b){return"INVALID_OPERATION_DELETED"===b?k.ErrorType.ItemWasDeleted:"ALIGNMENT_NOT_FOUND"===b?k.ErrorType.ModelNotAligned:k.ErrorType.UnknownError};b.prototype.getFolderDetails=function(b,d){var a=this,f=this.getRegionURLFromLocation(b);return this.doRequest(f,"/folders/"+d).promise.then(function(f){f=JSON.parse(f);
return a.convertResponseToFolderItem(f,b)})};b.prototype.getFileDetails=function(b,d){var a=this.getRegionURLFromLocation(b);return this.doRequest(a,"/files/"+d).promise.then(function(a){return JSON.parse(a)})};b.prototype.doRequest=function(b,d,a,f,g,p,n){void 0===a&&(a="GET");0<d.length&&(b+=this.CONNECT_API_ENDPOINT+d);return l.doRequest(b,a,f,{Authorization:"Bearer "+this.token_,"X-TrimbleConnect-Client":this.connectClientIdentifier_},g,p,n)};b.prototype.getTasks=function(b,q){var a=this.getRegionURLFromLocation(b),
a=this.doRequest(a,"/todos?projectId="+q).promise;return a=a.then(function(a){var b=[];a=JSON.parse(a);for(var e=0;e<a.length;e++){var n=new d.Task(a[e]);b.push(n)}return b},void 0,this)};b.prototype.getTaskDetails=function(b,q,a){b=this.getRegionURLFromLocation(b);a=this.doRequest(b,"/todos/"+a).promise;return a=a.then(function(a){a=JSON.parse(a);return new d.Task(a)},void 0,this)};b.prototype.publishTask=function(b,q,a){b=this.getRegionURLFromLocation(b);return this.doRequest(b,"/todos","POST",
JSON.stringify(a),!0).promise.then(function(a){a=JSON.parse(a);return new d.Task(a)})};b.prototype.updateTask=function(b,q,a){b=this.getRegionURLFromLocation(b);return this.doRequest(b,"/todos/"+q,"PATCH",JSON.stringify(a),!0).promise.then(function(a){console.log("Update Task Response");console.log(JSON.parse(a));a=JSON.parse(a);return new d.Task(a)})};b.prototype.deleteTask=function(b,d){var a=this.getRegionURLFromLocation(b);return this.doRequest(a,"/todos/"+d,"DELETE").promise.then(function(){return!0})};
b.prototype.getAlignment=function(b,d){var a=this,f=this.getRegionURLFromLocation(b),f=this.doRequest(f,"/files/"+d+"/alignment").promise;return f=f.then(function(a){return JSON.parse(a)},function(b){return a.defaultAlignment(d)})};b.prototype.publishAlignment=function(b,d,a){console.log("Alignment data being published:");console.log(a);b=this.getRegionURLFromLocation(b);return this.doRequest(b,"/files/"+d+"/alignment","PUT",JSON.stringify(a),!0).promise.then(function(a){return JSON.parse(a)})};b.prototype.publishView=
function(b,d,a){b=this.getRegionURLFromLocation(b);return this.doRequest(b,"/views","POST",JSON.stringify(a),!0).promise.then(function(a){return JSON.parse(a)})};b.prototype.updateView=function(b,d,a){b=this.getRegionURLFromLocation(b);d=this.doRequest(b,"/views/"+d,"PATCH",JSON.stringify(a),!0).promise;return d=d.then(function(a){return JSON.parse(a)})};b.prototype.deleteView=function(b,d){var a=this.getRegionURLFromLocation(b);return this.doRequest(a,"/views/"+d,"DELETE").promise.then(function(){return!0})};
b.prototype.getViewDetails=function(b,d){var a=this,f=this.getRegionURLFromLocation(b),f=this.doRequest(f,"/views/"+d).promise;return f=f.then(function(a){return JSON.parse(a)}).thenCatch(function(b){return a.errorHandler_.getCode(b)==g.code.VIEW_NOT_FOUND?goog.Promise.resolve(null):goog.Promise.reject(b)})};b.prototype.publishTaskAttachments=function(b,d,a,f){b=this.getRegionURLFromLocation(b);return this.doRequest(b,"/todos/"+a.id+"/attachments","POST",JSON.stringify(f),!0).promise.then(function(a){return JSON.parse(a)})};
b.prototype.getTaskAttachments=function(b,d,a){b=this.getRegionURLFromLocation(b);a=this.doRequest(b,"/todos/"+a+"/attachments").promise;return a=a.then(function(a){return JSON.parse(a)},void 0,this)};b.prototype.removeAttachments=function(b,d,a){b=this.getRegionURLFromLocation(b);return this.doRequest(b,"/todos/"+d+"/attachments","DELETE",JSON.stringify(a),!0).promise.then(function(){return!0})};b.prototype.getUsers=function(b,d){var a=this.getRegionURLFromLocation(b),a=this.doRequest(a,"/projects/"+
d+"/users").promise;return a=a.then(function(a){return JSON.parse(a)},void 0,this)};b.prototype.getUserDetails=function(b,d){var a=this.getRegionURLFromLocation(b),a=this.doRequest(a,"/users/"+d).promise;return a=a.then(function(a){return JSON.parse(a)},void 0,this)};b.prototype.getUserGroups=function(b,d){var a=this.getRegionURLFromLocation(b),a=this.doRequest(a,"/groups?projectId="+d).promise;return a=a.then(function(a){return JSON.parse(a)},void 0,this)};b.prototype.getComments=function(b,d,a){b=
this.getRegionURLFromLocation(b);d=this.doRequest(b,"/comments?objectId="+d+"&objectType="+a).promise;return d=d.then(function(a){return JSON.parse(a)},void 0,this)};b.prototype.publishComment=function(b,d){var a=this.getRegionURLFromLocation(b);return this.doRequest(a,"/comments","POST",JSON.stringify(d),!0).promise.then(function(a){return JSON.parse(a)})};return b}();c.TrimbleConnect=m});
define("ModelStorageProviderFactory",["require","exports","TrimbleConnect"],function(m,c,k){(function(d){d[d.Trimble_Connect=0]="Trimble_Connect"})(c.ProviderKey||(c.ProviderKey={}));var l=c.ProviderKey;c.Init=function(d){void 0===d&&(d="");c.Providers={};c.Providers[l.Trimble_Connect]=new k.TrimbleConnect(d)}});
define("DialogPrompts",["require","exports","l10n","XhrUtils"],function(m,c,k,l){function d(b,a){var d=b.getButtonSet(),e=b.getElementByClass("goog-buttonset-default");a?(d.setButtonEnabled(d.getDefault(),!0),e.classList.remove("modal-dialog-button-disabled")):(d.setButtonEnabled(d.getDefault(),!1),e.classList.add("modal-dialog-button-disabled"))}function g(){return(new goog.ui.Dialog.ButtonSet).addButton(goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL,!1,!0).addButton(goog.ui.Dialog.ButtonSet.DefaultButtons.OK,
!0)}function h(){return(new goog.ui.Dialog.ButtonSet).addButton(goog.ui.Dialog.ButtonSet.DefaultButtons.NO,!1,!0).addButton(goog.ui.Dialog.ButtonSet.DefaultButtons.YES,!0)}function b(){return(new goog.ui.Dialog.ButtonSet).addButton(goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL,!0,!0)}c.ShowInfoDialog=function(b,a,d){var e=!0;goog.isDefAndNotNull(d)||(d=goog.ui.Dialog.ButtonSet.DefaultButtons.OK.caption,e=!1);return new goog.Promise(function(p,n){var t=new goog.ui.Dialog(null);t.setTitle(b);t.setContent(a);
var g=new goog.ui.Dialog.ButtonSet;g.addButton({key:goog.ui.Dialog.ButtonSet.DefaultButtons.OK.key,caption:d},!0,!0);t.setButtonSet(g);e&&(g=t.getButtonElement().getElementsByTagName("button")[0],goog.style.setWidth(g,300));goog.events.listen(t,goog.ui.Dialog.EventType.SELECT,function(a){p()});t.setVisible(!0)})};c.ShowQuestionDialog=function(b){return new goog.Promise(function(a,d){var e=new goog.ui.Dialog(null);e.setTitle(k.$t("Please confirm"));e.setContent(b);e.setButtonSet(h());goog.events.listen(e,
goog.ui.Dialog.EventType.SELECT,function(b){b.key==goog.ui.Dialog.DefaultButtonKeys.YES?a(!0):a(!1)});e.setVisible(!0)})};var e=!1;c.ShowErrorDialog=function(){return new goog.Promise(function(b,a){if(e)return goog.Promise.resolve();e=!0;var d=new goog.ui.Dialog(null);d.setTitle(k.$t("Whoops! SketchUp has crashed!"));d.setContent(SketchUpTemplates.errorDialog());var h=d.getContentElement().querySelector(".error-input-text");d.setButtonSet(g());goog.events.listen(d,goog.ui.Dialog.EventType.SELECT,
function(a){b(h.value)});d.setVisible(!0)})};c.GetModelNameFromUser=function(b){void 0===b&&(b="");return new goog.Promise(function(a,e){var h=new goog.ui.Dialog(null);h.setTitle(k.$t("Please enter a model name"));h.setContent(SketchUpTemplates.modelTitleInput());h.setButtonSet(g());h.setVisible(!0);d(h,!1);var p=h.getElementByClass("model-title-input");p.value=b;p.addEventListener("input",function(a){d(h,0<a.target.value.length)});p.focus();goog.events.listen(h,goog.ui.Dialog.EventType.SELECT,function(n,
b){b.key==goog.ui.Dialog.DefaultButtonKeys.OK?a(n.value):e()}.bind(this,p))}.bind(this))};c.ShowProgressDialog=function(d,a){var e=new goog.ui.Dialog(null);e.setTitle(d);e.setContent(SketchUpTemplates.progressDialog());e.setVisible(!0);var g=e.getElementByClass("progress-dialog-progress-bar");e.setButtonSet(b());return{dialog:e,onProgress:function(b){g.value=l.ComputeProgressPercentage(b,a)},close:function(){e.setVisible(!1)},setCancelCallback:function(a){goog.events.listenOnce(e,goog.ui.Dialog.EventType.SELECT,
function(n){n.key==goog.ui.Dialog.DefaultButtonKeys.CANCEL&&a()})}}};c.SetDefaultButtonEnabled=d;c.CreateOkCancel=g;c.CreateYesNo=h;c.CreateCancel=b});
define("ErrorHandler",["require","exports","ModelStorageProviderFactory","DialogPrompts","l10n"],function(m,c,k,l,d){c.code={UNAUTHORIZED:"UNAUTHORIZED",PROJECT_NOT_DEFINED:"PROJECT_NOT_DEFINED",ACTION_ABORTED_BY_USER:"ACTION_ABORTED_BY_USER",MISSING_TODO_DESCRIPTION:"MISSING_TODO_DESCRIPTION",INVALID_ASSIGNEE:"INVALID_ASSIGNEE",INVALID_HEADER:"INVALID_HEADER",MISSING_REQUIRED_PARAMS:"MISSING_REQUIRED_PARAMS",INVALID_PARAM:"INVALID_PARAM",USER_NOT_IN_PROJECT:"USER_NOT_IN_PROJECT",PROJECT_NOT_FOUND:"PROJECT_NOT_FOUND",
PROJECT_DELETED:"PROJECT_DELETED",PERMISSION_DENIED:"PERMISSION_DENIED",NAME_TOO_LONG:"NAME_TOO_LONG",INVALID_OPERATION_OLD_REVISION:"INVALID_OPERATION_OLD_REVISION",DUPLICATE_NAME:"DUPLICATE_NAME",OBJECT_NOT_FOUND:"OBJECT_NOT_FOUND",INVALID_OPERATION_DELETED:"INVALID_OPERATION_DELETED",UPLOAD_FAILED:"UPLOAD_FAILED",FILE_NOT_READY:"FILE_NOT_READY",DOWNLOAD_FAILED:"DOWNLOAD_FAILED",DOWNLOAD_FAILED_SIZE_LIMIT:"DOWNLOAD_FAILED_SIZE_LIMIT",INVALID_OPERATION_FILE_DELETED:"INVALID_OPERATION_FILE_DELETED",
INVALID_OPERATION_FOLDER_DELETED:"INVALID_OPERATION_FOLDER_DELETED",EMPTY_FOLDER_CANNOT_CHECKOUT:"EMPTY_FOLDER_CANNOT_CHECKOUT",EMPTY_FOLDER_CANNOT_CHECKIN:"EMPTY_FOLDER_CANNOT_CHECKIN",FILE_ALREADY_CHECKED_OUT:"FILE_ALREADY_CHECKED_OUT",FILE_CHECKED_OUT_BY_ANOTHER_USER:"FILE_CHECKED_OUT_BY_ANOTHER_USER",FILE_NOT_CHECKED_OUT:"FILE_NOT_CHECKED_OUT",SAME_SOURCE_DEST_PARENT:"SAME_SOURCE_DEST_PARENT",OBJECT_NOT_IN_PROJECT:"OBJECT_NOT_IN_PROJECT",NOT_MODIFIED:"NOT_MODIFIED",UNSUPPORTED_FILETYPE:"UNSUPPORTED_FILETYPE",
ALIGNMENT_NOT_FOUND:"ALIGNMENT_NOT_FOUND",BAD_REQUEST:"BAD_REQUEST",JWT_TOKEN_INVALID:"JWT_TOKEN_INVALID",JWT_TOKEN_EXPIRED:"JWT_TOKEN_EXPIRED",API_KEY_REVOKED:"API_KEY_REVOKED",ECOM_ENTITLEMENT_DATA_FAILED:"ECOM_ENTITLEMENT_DATA_FAILED",API_KEY_GENERATION_ERROR:"API_KEY_GENERATION_ERROR",API_KEY_INVALID:"API_KEY_INVALID",INVALID_SESSION:"INVALID_SESSION",UNAUTHORIZED_LICENSE:"UNAUTHORIZED_LICENSE",INVALID_OPERATION_VIEW_DELETED:"INVALID_OPERATION_VIEW_DELETED",INVALID_OPERATION_CLASH_DELETED:"INVALID_OPERATION_CLASH_DELETED",
INVALID_OPERATION_COMMENT_DELETED:"INVALID_OPERATION_COMMENT_DELETED",INVALID_OPERATION_RELEASE_DELETED:"INVALID_OPERATION_RELEASE_DELETED",INVALID_OPERATION_TODO_DELETED:"INVALID_OPERATION_TODO_DELETED",TODO_ALREADY_DELETED:"TODO_ALREADY_DELETED",TODO_NOT_FOUND:"TODO_NOT_FOUND",RELEASE_NOT_FOUND:"RELEASE_NOT_FOUND",VIEW_NOT_FOUND:"VIEW_NOT_FOUND",VIEWGROUP_NOT_FOUND:"VIEWGROUP_NOT_FOUND",CLASH_NOT_FOUND:"CLASH_NOT_FOUND"};m=function(){function g(){}g.prototype.getCode=function(d){try{this.code_=
JSON.parse(d.message).errorcode}catch(b){this.code_=d.message}return this.code_};g.prototype.rescue=function(g){var b=this;console.log("ErrorHandler caught:");console.log(g);this.getCode(g);var e=k.Providers[k.ProviderKey.Trimble_Connect];switch(this.code_){case c.code.UNAUTHORIZED:window.sketchup.sign_in();break;case c.code.PROJECT_NOT_DEFINED:this.notify(d.$t("This model is not yet associated with a Trimble Connect project. First, publish this model to Trimble Connect or open a model from Trimble Connect.")).then(function(){return b.close()});
break;case c.code.USER_NOT_IN_PROJECT:this.notify(d.$t("User does not have access to this project.")).then(function(){return b.close()});break;case c.code.PROJECT_NOT_FOUND:this.notify(d.$t("The project for this model could not be found.")).then(function(){return b.close()});break;case c.code.PROJECT_DELETED:this.notify(d.$t("The project for this model has been deleted. Please publish this model to another project.")).then(function(){return b.close()});break;case c.code.PERMISSION_DENIED:this.notify(d.$t("You do not have permission to perform this action. Please request permission from the project administrator."));
break;case c.code.NAME_TOO_LONG:this.notify(d.$t("The specified name is too long. Max length is 255 characters."));break;case c.code.DUPLICATE_NAME:this.notify(d.$t("Name already exists."));break;case c.code.INVALID_OPERATION_DELETED:this.notify(d.$t("The specified folder has been deleted."));break;case c.code.UPLOAD_FAILED:this.notify(d.$t("File upload failed due to server error."));break;case c.code.FILE_NOT_READY:this.notify(d.$t("File is currently being processed and is not yet available."));
break;case c.code.DOWNLOAD_FAILED:this.notify(d.$t("File download failed."));break;case c.code.DOWNLOAD_FAILED_SIZE_LIMIT:this.notify(d.$t("Download failed. Download size limit has been exceeded."));break;case c.code.INVALID_OPERATION_FILE_DELETED:this.notify(d.$t("File is already deleted."));break;case c.code.INVALID_OPERATION_FOLDER_DELETED:this.notify(d.$t("Folder is already deleted."));break;case c.code.EMPTY_FOLDER_CANNOT_CHECKOUT:this.notify(d.$t("Unable to check out an empty folder."));break;
case c.code.EMPTY_FOLDER_CANNOT_CHECKIN:this.notify(d.$t("Unable to check in an empty folder."));break;case c.code.FILE_ALREADY_CHECKED_OUT:this.notify(d.$t("You have already checked out this file."));break;case c.code.FILE_CHECKED_OUT_BY_ANOTHER_USER:this.notify(d.$t("Another user has checked out this file."));break;case c.code.FILE_NOT_CHECKED_OUT:this.notify(d.$t("This file is not checked out."));break;case c.code.OBJECT_NOT_IN_PROJECT:this.notify(d.$t("You cannot move a file to another project."));
break;case c.code.ALIGNMENT_NOT_FOUND:break;case c.code.ECOM_ENTITLEMENT_DATA_FAILED:this.notify(d.$t("Failed to retrieve license entitlement. Please try again."));break;case c.code.API_KEY_REVOKED:e.refreshToken().then(function(){b.notify(d.$t("API key has been revoked. Please try again."))});break;case c.code.API_KEY_GENERATION_ERROR:e.refreshToken().then(function(){b.notify(d.$t("Unable to generate access token. Please try again."))});break;case c.code.API_KEY_INVALID:e.refreshToken().then(function(){b.notify(d.$t("Your Trimble Connect session is not valid. Please try again."))});
break;case c.code.INVALID_SESSION:e.refreshToken().then(function(){b.notify(d.$t("Your Trimble Connect session is not valid. Please try again."))});break;case c.code.UNAUTHORIZED_LICENSE:this.notify(d.$t("Your Trimble Connect license does not permit the requested operation."));break;case c.code.INVALID_OPERATION_VIEW_DELETED:this.notify(d.$t("The specified View has been deleted."));break;case c.code.INVALID_OPERATION_COMMENT_DELETED:this.notify(d.$t("The specified comment has been deleted."));break;
case c.code.INVALID_OPERATION_TODO_DELETED:this.notify(d.$t("The specified ToDo has been deleted."));break;case c.code.TODO_NOT_FOUND:this.notify(d.$t("The specified ToDo is not found."));break;case c.code.TODO_ALREADY_DELETED:this.notify(d.$t("The specified ToDo has been deleted."));case c.code.VIEW_NOT_FOUND:this.notify(d.$t("The specified View is not found."));break;case c.code.MISSING_TODO_DESCRIPTION:this.notify(d.$t("You must enter a description."));break;case c.code.INVALID_ASSIGNEE:this.notify(d.$t("One or more assignees for this ToDo could not be found."));
break;case c.code.ACTION_ABORTED_BY_USER:break;default:window.sketchup.debug(g.message)}return this.code_};g.prototype.notify=function(g){var b=d.$t("Oops...");return l.ShowInfoDialog(b,g)};g.prototype.close=function(){window.sketchup.close_window()};return g}();c.ErrorHandler=m});
define("XhrUtils",["require","exports","ErrorHandler"],function(m,c,k){c.doRequest=function(c,d,g,h,b,e,q){void 0===d&&(d="GET");var a=new XMLHttpRequest;return{promise:new goog.Promise(function(f,k){a.open(d,c,!0);if(h)for(var p in h)a.setRequestHeader(p,h[p]);b&&a.setRequestHeader("Content-Type","application/json");e&&(a.responseType="arraybuffer");"POST"==d&&a.upload?a.upload.onprogress=q:a.onprogress=q;a.onerror=function(a){k(Error("XHR error."))};a.onabort=function(a){k(Error("XHR aborted."))};
a.onload=function(n){200<=a.status&&300>a.status?f(a.response):""==a.responseType||"text"==a.responseType?k(Error(a.responseText)):k(Error())};g?a.send(g):a.send()}),cancel:function(){a.abort()}}};c.fetchBinary=function(c,d,g,h){var b=h||function(b){console.error("Problem during xmlhttprequest "+b)},e=g||function(){};g=new XMLHttpRequest;g.open("GET",c,!0);g.responseType="arraybuffer";g.onprogress=function(b){e(b)};g.onload=function(e){200==this.status?d(this.response):b(e)};g.send()};c.crossDomainRequest=
function(c){return new goog.Promise(function(d,g){var h=new XMLHttpRequest;h.open("GET",c,!0);h.withCredentials=!0;h.onload=function(b){200==this.status?d(this.response):401==this.status?g(Error(k.code.UNAUTHORIZED)):""==h.responseType||"text"==h.responseType?g(Error(h.responseText)):g(Error())};h.onerror=function(b){g(b)};h.send()}.bind(this))};c.ComputeProgressPercentage=function(c,d){var g=c.loaded,h=c.total;0===h&&(h=d||0);return 0<h?Math.round(g/h*100):0}});
define("ModelStorageProvider",["require","exports"],function(m,c){(function(c){c[c.File=0]="File";c[c.Folder=1]="Folder"})(c.FolderItemType||(c.FolderItemType={}));(function(c){c[c.UpToDate=0]="UpToDate";c[c.ModifiedAtRemoteStorage=1]="ModifiedAtRemoteStorage";c[c.ModifiedLocally=2]="ModifiedLocally";c[c.HasConflict=3]="HasConflict";c[c.DeleteAtRemoteStorage=4]="DeleteAtRemoteStorage"})(c.FileVersionState||(c.FileVersionState={}));(function(c){c[c.UnknownError=0]="UnknownError";c[c.ItemWasDeleted=
1]="ItemWasDeleted";c[c.ModelNotAligned=2]="ModelNotAligned"})(c.ErrorType||(c.ErrorType={}))});
define("FileDetailsPage",["require","exports","l10n"],function(m,c,k){m=function(){function d(d,c,b){this.folderItemView_=d;this.container_=c;this.openCallback_=b;this.container_.appendChild(this.getContent());this.setupOpenButton()}d.prototype.getContent=function(){var d={fileEntry:this.folderItemView_,buttonName:k.$t("Open")};return goog.soy.renderAsFragment(SketchUpTemplates.fileDetailsPage,d)};d.prototype.setupOpenButton=function(){var d=this;this.container_.querySelector(".bottom-button").addEventListener("click",
function(c){d.openCallback_(d.folderItemView_)})};d.prototype.close=function(){};return d}();c.FileDetailsPage=m;var l=function(d){function c(g,b,e){d.call(this,g,b,e)}__extends(c,d);return c}(m);c.OpenFileDetailsPage=l;m=function(d){function c(g,b,e){d.call(this,g,b,e)}__extends(c,d);c.prototype.getContent=function(){var d={fileEntry:this.folderItemView_,buttonName:k.$t("Import Reference")};return goog.soy.renderAsFragment(SketchUpTemplates.fileDetailsPage,d)};return c}(m);c.ImportRefDetailsPage=
m});
define("ImportFromLocalView",["require","exports"],function(m,c){var k=function(){function c(d,g){this.container_=d;this.importCallback_=g}c.prototype.close=function(){};c.prototype.render=function(){var d=this,c=goog.soy.renderAsFragment(SketchUpTemplates.importLocal,{});this.container_.appendChild(c);this.textArea_=c.querySelector(".import-text");this.thumbnailContainer_=c.querySelector(".preview-thumbnail");c.querySelector(".upload-button").addEventListener("click",this.handleBrowseClick.bind(this));this.fileInput_=
document.getElementById("system-file-browser");this.fileInput_.addEventListener("change",function(c){d.fileSelected(d.fileInput_.files[0])})};c.prototype.handleBrowseClick=function(d){this.fileInput_.value="";this.fileInput_.click()};c.prototype.fileSelected=function(d){this.textArea_.textContent=d.name;this.importCallback_(d)};return c}();Object.defineProperty(c,"__esModule",{value:!0});c["default"]=k});
define("ImportDetailsPage",["require","exports","ImportFromLocalView"],function(m,c,k){m=function(){function c(d,g){this.container_=d;this.importCallback_=g;var h=goog.soy.renderAsFragment(SketchUpTemplates.importPage,{});this.container_.appendChild(h);this.content_=this.container_.querySelector(".left-details-content");this.importView_=new k["default"](this.content_,this.importCallback_);this.importView_.render()}c.prototype.close=function(){this.importView_&&this.importView_.close()};return c}();
Object.defineProperty(c,"__esModule",{value:!0});c["default"]=m});define("SketchUpEvent",["require","exports"],function(m,c){var k=function(){function c(){this.handlers=[]}c.prototype.listen=function(d){this.handlers.push(d)};c.prototype.remove=function(d){goog.array.remove(this.handlers,d)};c.prototype.trigger=function(d){this.handlers.forEach(function(c){return c(d)})};return c}();(function(c){c.Create=function(){return new k}})(c.SketchUpEvents||(c.SketchUpEvents={}))});
define("DetailsView",["require","exports","FileDetailsPage","ImportDetailsPage"],function(m,c,k,l){m=function(){function d(c,b,e,g){this.relativeContainer_=c;this.importCallback_=b;this.openCallback_=e;c=goog.soy.renderAsFragment(SketchUpTemplates.detailsView,{});document.body.appendChild(c);this.content_=c;window.addEventListener("resize",this.handleResize.bind(this));this.position();this.close();g&&g.listen(this.close.bind(this))}d.prototype.clear=function(){this.closePages();this.content_.innerHTML=
""};d.prototype.activateFileDetails=function(d){this.clear();this.makeVisible();this.fileDetailsPage_=new k.FileDetailsPage(d,this.content_,this.openCallback_)};d.prototype.activateImportPage=function(){this.clear();this.importPage_=new l["default"](this.content_,this.importCallback_)};d.prototype.handleResize=function(){this.position()};d.prototype.position=function(){var d=this.relativeContainer_;this.content_.style.left=d.offsetWidth+d.offsetLeft+"px"};d.prototype.closePages=function(){this.importPage_&&
this.importPage_.close();this.fileDetailsPage_&&this.fileDetailsPage_.close()};d.prototype.close=function(){this.content_.style.display="none";this.closePages();this.relativeContainer_.classList.remove("compressed")};d.prototype.makeVisible=function(){this.relativeContainer_.classList.add("compressed");this.content_.style.display="";this.position()};return d}();c.DetailsView=m;var d=function(d){function c(){d.apply(this,arguments)}__extends(c,d);c.prototype.activateFileDetails=function(b){d.prototype.clear.call(this);
d.prototype.makeVisible.call(this);this.fileDetailsPage_=new k.OpenFileDetailsPage(b,this.content_,this.openCallback_)};return c}(m);c.OpenDetailsView=d;m=function(d){function c(){d.apply(this,arguments)}__extends(c,d);c.prototype.activateFileDetails=function(b){d.prototype.clear.call(this);d.prototype.makeVisible.call(this);this.fileDetailsPage_=new k.ImportRefDetailsPage(b,this.content_,this.openCallback_)};return c}(m);c.ImportRefView=m});
define("EnvironmentSettings",["require","exports"],function(m,c){function k(d){return l(d)||goog.string.contains(d,"dev-my.sketchup.com")}function l(d){return goog.string.contains(d,"localhost")||goog.string.contains(d,"127.0.0.1")||goog.string.startsWith(d,"file:")||goog.string.contains(d,"localdev-my.sketchup.com")}function d(){return{connectBaseUrl:"https://app.connect.trimble.com",connectPortalEndPoint:"/tc/app#/",connectAPIEndPoint:"/tc/api/2.0",loginUsersEndPoint:"/api/v1.0/users",loginConnectTokenEndPoint:"/api/v1.0/users/connectToken",
loginServer:"https://login.sketchup.com",loginEndPoint:"/login/trimbleid",logoutEndPoint:"/logout",ADD_LOCATION_SERVICES:"/addlocation/services"}}c.IsLocal=function(){return l(window.location.href)};c.IsLocalOrDev=function(){return k(window.location.href)};c.CheckOrigin=function(d){return k(d)||goog.string.contains(d,"stg-my.sketchup.com")||goog.string.contains(d,"my.sketchup.com")};c.Get=function(){return d()};c.GetTest=function(){return{connectBaseUrl:"https://app.stage.connect.trimble.com",connectPortalEndPoint:"/tc/app#/",
connectAPIEndPoint:"/tc/api/2.0",loginConnectTokenEndPoint:"/api/v1.0/users/connectToken",loginUsersEndPoint:"/api/v1.0/users",loginServer:"https://stg-login.sketchup.com",loginEndPoint:"/login/trimbleid",logoutEndPoint:"/logout",ADD_LOCATION_SERVICES:"/addlocation/services"}};c.GetProd=d});
define("FolderMetadata",["require","exports","ModelStorageProviderFactory"],function(m,c,k){m=function(){return function(d,c,h,b,e,q,a){this.fileId=d;this.projectId=c;this.parentFolderId=h;this.versionId=b;this.providerKey=e;this.region=q;this.isModified=a}}();c.RemoteModelMetadata=m;var l=function(){return function(d,c,h,b){void 0===d&&(d="");void 0===c&&(c=k.ProviderKey.Trimble_Connect);void 0===h&&(h="");void 0===b&&(b={});this.folderId=d;this.providerKey=c;this.region=h;this.filesMap=b}}();m=
function(){function d(d){this.folderPath_=d;this.serializable_=new l}d.prototype.initFromJson=function(d){this.serializable_=JSON.parse(d);goog.isDefAndNotNull(this.serializable_.folderId)||(this.serializable_.folderId="");goog.isDefAndNotNull(this.serializable_.providerKey)||(this.serializable_.providerKey=k.ProviderKey.Trimble_Connect);goog.isDefAndNotNull(this.serializable_.region)||(d=Object.getOwnPropertyNames(this.serializable_.filesMap),this.serializable_.region=0<d.length?this.serializable_.filesMap[d[0]].region:
"");goog.isDefAndNotNull(this.serializable_.filesMap)||(this.serializable_.filesMap={})};d.prototype.addFile=function(d,c){this.serializable_.filesMap[d]=c};d.prototype.removeFile=function(d){delete this.serializable_.filesMap[d]};d.prototype.lookupFile=function(d){return this.serializable_.filesMap[d]};Object.defineProperty(d.prototype,"folderId",{get:function(){return this.serializable_.folderId},set:function(d){this.serializable_.folderId=d},enumerable:!0,configurable:!0});Object.defineProperty(d.prototype,
"providerKey",{get:function(){return this.serializable_.providerKey},set:function(d){this.serializable_.providerKey=d},enumerable:!0,configurable:!0});Object.defineProperty(d.prototype,"region",{get:function(){return this.serializable_.region},set:function(d){this.serializable_.region=d},enumerable:!0,configurable:!0});d.prototype.write=function(){};d.hasMetadata=function(d){return!1};d.read=function(c){goog.string.path.join(c,d.METADATA_FILENAME);return new d(c)};d.lookupRemoteModelMetadata=function(c){var h=
goog.string.path.dirname(c);c=goog.string.path.baseName(c);return d.read(h).lookupFile(c)};d.METADATA_FILENAME=".metadata";return d}();c.FolderMetadata=m});
define("FileManager","require exports FolderMetadata ModelStorageProvider ModelStorageProviderFactory DateHelper".split(" "),function(m,c,k,l,d,g){m=function(){function c(){c.AUTOSAVE_PREFIX="autosave-";this.remoteFileMap_={};this.remoteProjectMap_={};this.folderPathFolderIdMap_={};this.trimbleConnect_=d.Providers[d.ProviderKey.Trimble_Connect]}c.prototype.addRemoteFiles=function(b){for(var d=0;d<b.length;++d){var c=b[d];this.remoteFileMap_[c.id]=c}};c.prototype.addRemoteProjects=function(b){for(var d=
0;d<b.length;d++){var c=b[d];this.remoteProjectMap_[c.rootFolderId]=c}};c.prototype.getFolderAncestorList=function(b){var d=[];do{var c=this.remoteFileMap_[b];if(!c)break;d.unshift({name:c.name,id:c.id,localPath:void 0});b=c.parentFolderId}while(b);c=this.remoteProjectMap_[b];goog.isDefAndNotNull(c)&&d.unshift({name:c.name,id:b,localPath:void 0});return d};c.prototype.getFolderAncestorListFromPath=function(b){if(goog.string.startsWith(b,c.OFFLINE_DIR)){for(var d=[];b!==c.OFFLINE_DIR;){var q=goog.string.path.baseName(b);
goog.string.isEmpty(q)||d.unshift({name:q,id:this.folderPathFolderIdMap_[b]||"",localPath:b});b=goog.string.path.dirname(b)}if(2<=d.length)d.shift(),d.shift();else throw"Not enough ancestors";return d}throw"Path must be in OFFLINE_DIR: "+b;};c.prototype.makeFolderPathFromAncestorList=function(b){for(var d="",c=0;c<b.length;++c)d=goog.string.path.join(d,b[c].name);return d};c.prototype.makeFolderIdPathFromAncestorList=function(b){for(var d="",c=0;c<b.length;++c)d=goog.string.path.join(d,b[c].id);return d};
c.prototype.createRemoteFolder=function(b,c,g,a){var f=this;return d.Providers[b].createFolder(c,g,a).then(function(a){f.addRemoteFiles([a]);return f.convertFolderItemToFileItemView(a)})};c.prototype.convertFolderItemToFileItemView=function(b){b={name:b.name,isFolder:b.type===l.FolderItemType.Folder,thumbnailURL:b.thumbnailURL,isLocal:!1,versionState:l.FileVersionState.UpToDate,isActionInProgress:!1,remoteId:b.id,remoteVersionId:b.versionId,sizeInKB:b.size/1024,createdOn:g.convertTimeStamp(b.createdOn),
modifiedOn:g.convertTimeStamp(b.modifiedOn),createdByEmail:b.createdByEmail,createdByFirstName:b.createdByFirstName,createdByLastName:b.createdByLastName,modifiedByEmail:b.modifiedByEmail,modifiedByFirstName:b.modifiedByFirstName,modifiedByLastName:b.modifiedByLastName};b.isFolder&&!goog.isDef(b.thumbnailURL)&&(b.thumbnailURL=this.getDefaultFolderURL());return b};c.prototype.getFileViewsForFolder=function(b,d,c){var a=this,f=[];d=this.trimbleConnect_.getContents(d,c).then(function(d){a.addRemoteFiles(d);
a.folderPathFolderIdMap_[b]=c;for(var n=0;n<d.length;++n){var t=a.convertFolderItemToFileItemView(d[n]);f.push(t)}return f});d=d.thenCatch(function(){});var g=this.readLocalFilesInFolder(b);return goog.Promise.all([d,g]).then(function(a){var n=a[0]||[],d=a[1],c=k.FolderMetadata.read(b);a=n.filter(function(a){var n=goog.array.findIndex(d,function(n){return n.name===a.name});if(-1!==n){var n=d[n],b=n.isFolder?null:c.lookupFile(n.name);n.remoteId=a.remoteId;n.remoteVersionId=a.remoteVersionId;goog.isDefAndNotNull(b)?
(n.localVersionId=b.versionId,n.localVersionId!==n.remoteVersionId?(n.versionState=l.FileVersionState.ModifiedAtRemoteStorage,b.isModified&&(n.versionState=l.FileVersionState.HasConflict)):b.isModified&&(n.versionState=l.FileVersionState.ModifiedLocally)):(n.localVersionId="",n.versionState=l.FileVersionState.UpToDate);n.createdByFirstName=a.createdByFirstName;n.createdByLastName=a.createdByLastName;n.createdByEmail=a.createdByEmail;n.modifiedByFirstName=a.modifiedByFirstName;n.modifiedByLastName=
a.modifiedByLastName;n.modifiedByEmail=a.modifiedByEmail;n.createdOn=a.createdOn;n.modifiedOn=a.modifiedOn;return!1}return!0});d.forEach(function(a){goog.string.isEmptySafe(a.remoteId)&&(a.versionState=l.FileVersionState.ModifiedLocally)});a=a.concat(d);a.sort(function(a,n){return a.isFolder===n.isFolder?a.name.localeCompare(n.name):a.isFolder?-1:1});return a})};c.prototype.readLocalFilesInFolder=function(b){return new goog.Promise(function(b,d){b([])})};c.prototype.makeFileViewForLocalDirectory=
function(b){return{name:goog.string.path.basename(b),isFolder:!0,thumbnailURL:this.getDefaultFolderURL(),isLocal:!0,versionState:l.FileVersionState.UpToDate,isActionInProgress:!1,localPath:b,remoteId:"",sizeInKB:0,createdOn:"",modifiedOn:""}};c.prototype.getDefaultFolderURL=function(){return"images/tb_FolderOpen.svg"};c.getInstance=function(){c.staticInstance_||(c.staticInstance_=new c);return c.staticInstance_};c.prototype.deleteFileOrFolder=function(b,c,g){var a=goog.Promise.resolve(!0);goog.string.isEmptySafe(b.remoteId)||
(c=d.Providers[c],a=b.isFolder?c.deleteFolder(g,b.remoteId):c.deleteFile(g,b.remoteId));return a};c.SAVE_DIR="/autosave-indexeddb";c.OFFLINE_DIR=goog.string.path.join(c.SAVE_DIR,"offline");c.AUTOSAVE_SUBDIR=".autosave";c.DEFAULT_AUTOSAVE_DIR=goog.string.path.join(c.SAVE_DIR,c.AUTOSAVE_SUBDIR);return c}();c.FileManager=m});
define("Init",["require","exports","l10n"],function(m,c,k){function l(d,c){function h(b,d){if(0<b.length){var q=b.shift();Array.isArray(q)||(q=[q]);m(q,function(){d.push.apply(d,arguments);h(b,d)})}else c.apply(null,d)}h(d,[])}c.withModule=function(d){var c=[],h=k.getLanguageFilePath("js/l10n/");if(h){var b=k.getCurrentLanguage();c.push([h,"js/templates-"+b+".js"]);c.push("module-"+b)}else c.push("js/templates-en.js");c.push(d);l(c,function(){})}});
define("LoadingGif",["require","exports"],function(m,c){function k(c){if(!goog.isDefAndNotNull(d)){var h=goog.soy.renderAsFragment(SketchUpTemplates.loadingGif,{});c.appendChild(h);d=h}}function l(c){goog.isDefAndNotNull(d)&&d.parentElement===c&&d.parentElement.removeChild(d);d=null}var d=null;c.Show=k;c.Hide=l;c.Toggle=function(c){goog.isDefAndNotNull(d)?l(c):k(c)}});
define("TextInput",["require","exports","SketchUpEvent"],function(m,c,k){c.EditField=function(c,d){void 0===d&&(d=!1);return new goog.Promise(function(g,h){var b=goog.dom.createDom("INPUT",{type:"text",value:c.textContent,"class":"scene-name-editable"});goog.dom.replaceNode(b,c);b.focus();d&&b.select();var e=!1,q=function(){e||(e=!0,c.textContent=b.value,goog.dom.replaceNode(c,b),g(b.value))};b.addEventListener("keydown",function(a){var d=a.keyCode||a.which;d==goog.events.KeyCodes.ENTER?(a.stopPropagation(),
q()):d==goog.events.KeyCodes.ESC&&(a.stopPropagation(),e=!0,goog.dom.replaceNode(c,b),h(null))});b.addEventListener("blur",function(a){q()})})};m=function(){function c(d,g){var h=this;this.changeEvent_=k.SketchUpEvents.Create();this.label_=d;this.initialValue_=g;var b=goog.soy.renderAsFragment(SketchUpTemplates.inputText,{title:d,initialValue:g});this.content_=b;var e=b.querySelector("input");e.addEventListener("keypress",function(b){(b.keyCode||b.which)==goog.events.KeyCodes.ENTER&&h.fireTextChange(e.value)});
e.addEventListener("blur",function(b){h.fireTextChange(e.value)})}c.prototype.addToContainer=function(d){d.appendChild(this.content_)};c.prototype.fireTextChange=function(d){this.changeEvent_.trigger(d)};Object.defineProperty(c.prototype,"onChange",{get:function(){return this.changeEvent_},enumerable:!0,configurable:!0});return c}();c.LabeledTextInput=m});
define("OpenDialogWidget","require exports DetailsView DialogPrompts FileManager FileUtils l10n LoadingGif ModelStorageProvider ModelStorageProviderFactory TextInput ErrorHandler".split(" "),function(m,c,k,l,d,g,h,b,e,q,a,f){(function(a){a[a.ModelOpen=0]="ModelOpen";a[a.ModelSave=1]="ModelSave";a[a.ImportReference=2]="ImportReference"})(c.LaunchMode||(c.LaunchMode={}));var r=c.LaunchMode;m=function(){function c(a,b){this.parent_=a;this.feedback_=b;this.onSaveInputKeyDownHandler_=null;this.launchMode_=
r.ModelOpen;this.trimbleConnect_=q.Providers[q.ProviderKey.Trimble_Connect];this.errorHandler_=new f.ErrorHandler;this.render()}c.prototype.render=function(){var a=goog.soy.renderAsFragment(SketchUpTemplates.leftSidebarConnectTab,{});this.parent_.appendChild(a);this.container_=a;b.Show(this.container_);this.content_=a.querySelector(".trimble-connect-content");this.saveNewModelInputContainer_=a.querySelector(".save-new-model-container");this.saveNewModelInput_=this.saveNewModelInputContainer_.querySelector(".save-new-model-input");
this.saveNewModelButton_=this.saveNewModelInputContainer_.querySelector(".save-here-button");this.saveNewModelButton_.addEventListener("click",this.handleSave.bind(this))};Object.defineProperty(c.prototype,"currentRegionLocation",{get:function(){return goog.isDefAndNotNull(this.currentRegion_)?this.currentRegion_:null},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"currentFolderId",{get:function(){return goog.isDefAndNotNull(this.currentFolderId_)?this.currentFolderId_:null},enumerable:!0,
configurable:!0});Object.defineProperty(c.prototype,"currentProjectId",{get:function(){return goog.isDefAndNotNull(this.currentProjectId_)?this.currentProjectId_:null},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"currentModelId",{get:function(){return goog.isDefAndNotNull(this.currentModelId_)?this.currentModelId_:null},enumerable:!0,configurable:!0});c.prototype.disableOpenButton=function(){this.disableButton(this.getOpenButton())};c.prototype.enableOpenButton=function(){this.enableButton(this.getOpenButton())};
c.prototype.disablePublishButton=function(){this.disableButton(this.getPublishButton())};c.prototype.enablePublishButton=function(){this.enableButton(this.getPublishButton())};c.prototype.open=function(a){var b=this,d=a.mode,c=a.projectId,f=a.folderId,e=a.location,p=a.fileName;goog.isDefAndNotNull(a.fileId)&&(this.currentModelId_=a.fileId);this.launchMode_=d;switch(this.launchMode_){case r.ModelSave:this.saveNewModelInputContainer_.classList.remove("invisible");this.setModelTitleInputFieldContents(p);
break;case r.ModelOpen:this.saveNewModelInputContainer_.classList.add("invisible");this.detailsView_=new k.OpenDetailsView(this.container_,this.importFile.bind(this),this.openFolderOrFile.bind(this),null);break;case r.ImportReference:this.saveNewModelInputContainer_.classList.add("invisible");this.detailsView_=new k.ImportRefView(this.container_,this.importFile.bind(this),this.openFolderOrFile.bind(this),null);break;default:console.log("Invalid Launch Mode passed to File Dialog")}this.adjustStyleForScrollableContent();
this.makeVisible();a=this.trimbleConnect_.initialize(a);console.log("Initializing Trimble Connect");a=a.then(function(){goog.isDefAndNotNull(c)&&goog.isDefAndNotNull(f)?(b.currentFolderId_=f,b.currentProjectId_=c,b.getRegion(e).then(function(a){b.currentRegion_=a;b.renderFolderView(a,f)}).thenCatch(function(a){console.log("Caught error fetching region");b.errorHandler_.rescue(a)})):b.renderProjectsView()});a.thenCatch(function(a){console.log("Failed to initialize Trimble Connect.");b.errorHandler_.rescue(a);
b.renderProjectsView()});return new goog.Promise(function(a,n){},this)};c.prototype.updateProgressDialog=function(a){if(goog.isDefAndNotNull(this.progressDialog_))this.progressDialog_.onProgress(a)};c.prototype.processFileTransferError=function(a){a=Error(a);console.log("File Transfer Failed.");this.errorHandler_.rescue(a);this.progressDialog_.close()};c.prototype.setupDownloadProgressDialog=function(){this.setupProgressDialog(h.$t("Downloading..."))};c.prototype.setupUploadProgressDialog=function(){this.setupProgressDialog(h.$t("Uploading..."))};
c.prototype.setupImportProgressDialog=function(){this.setupProgressDialog(h.$t("Importing..."))};c.prototype.getRegion=function(a){return goog.isDefAndNotNull(a)?goog.Promise.resolve(a):this.trimbleConnect_.getRegionForProject(this.currentProjectId_)};c.prototype.makeVisible=function(){this.container_.classList.remove("left-sidebar-hidden")};c.prototype.renderProjectsView=function(){var a=this;this.currentProjectId_=this.currentFolderId_=this.currentRegion_=null;goog.dom.removeChildren(this.content_);
this.closeDetailsView();this.fileNameElementMap_={};this.enableSaveModelButtonIfVisible(!1);var d=goog.soy.renderAsFragment(SketchUpTemplates.projectsView,{});this.content_.appendChild(d);this.adjustStyleForScrollableContent();this.registerProjectsLinkClickHandler(d);b.Show(this.container_);this.projectsList_=d.querySelector(".projects-section ul");for(var d=this.trimbleConnect_.getProjectsOrCreateDefault(),c=0;c<d.length;++c){var f=d[c].promise,f=f.then(this.handleProjectResponse.bind(this));f.thenCatch(function(b){console.log("Failed to load projects");
a.errorHandler_.rescue(b)})}};c.prototype.handleProjectResponse=function(a){if(a.length){d.FileManager.getInstance().addRemoteProjects(a);for(var b=0;b<a.length;++b){var c=a[b];if("svg"==goog.string.path.extension(c.thumbnailURL))this.renderSingleProject(c);else var f=this.trimbleConnect_.downloadThumbnail(c.thumbnailURL),f=f.then(this.projectThumbnailDownloadDone.bind(this,c)),f=f.thenCatch(function(){})}}};c.prototype.reRenderCurrentFolderView=function(){goog.isDefAndNotNull(this.currentRegion_)&&
goog.isDefAndNotNull(this.currentFolderId_)&&this.renderFolderView(this.currentRegion_,this.currentFolderId_,this.currentFolderPath_)};c.prototype.adjustStyleForScrollableContent=function(){var a=this.content_.querySelector(".connect-scrollable-content");a&&(this.launchMode_===r.ModelSave?a.classList.add("connect-scrollable-content-short"):a.classList.remove("connect-scrollable-content-short"))};c.prototype.registerProjectsLinkClickHandler=function(a){a.querySelector(".projects-link").addEventListener("click",
this.renderProjectsView.bind(this))};c.prototype.closeDetailsView=function(){this.detailsView_&&this.detailsView_.close()};c.prototype.renderSingleProject=function(a){a=goog.soy.renderAsFragment(SketchUpTemplates.projectInstance,{project:a});a.addEventListener("click",this.handleProjectClick.bind(this,a));b.Hide(this.container_);this.projectsList_.appendChild(a)};c.prototype.projectThumbnailDownloadDone=function(a,b){a.thumbnailData=g.ArrayBufferToBase64(b);this.renderSingleProject(a)};c.prototype.handleProjectClick=
function(a,b){var d=a.dataset.projectregion,c=a.dataset.projectfolder,f=a.dataset.projectid;this.currentRegion_=d;this.currentProjectId_=f;this.renderFolderView(d,c)};c.prototype.renderFolderView=function(a,c,f){var e=this;goog.dom.removeChildren(this.content_);this.closeDetailsView();this.fileNameElementMap_={};this.currentFolderFileItemViews_=null;this.enableSaveModelButtonIfVisible(!1);var p=d.FileManager.getInstance(),h={ancestorList:void 0},g,q;if(goog.string.isEmptyString(c)){if(goog.string.isEmptySafe(f))throw"No folder id or local folder path";
h.ancestorList=p.getFolderAncestorListFromPath(f);g=f}else q=this.getFolderAncestorListNoCache(c,this.currentRegion_),q.then(function(d){h.ancestorList=d;g=p.makeFolderPathFromAncestorList(h.ancestorList);e.currentFolderId_=c;e.currentFolderPath_=g;d=goog.soy.renderAsFragment(SketchUpTemplates.projectFileView,h);e.registerProjectsLinkClickHandler(d);e.setupBreadcrumbs(d,h);e.fileContainer_=d.querySelector(".file-tree ul");e.setupActionsBar(d);e.content_.appendChild(d);e.adjustStyleForScrollableContent();
d=e.getCurrentFolderFullPath();b.Show(e.container_);return p.getFileViewsForFolder(d,a,c)}).then(function(a){e.currentFolderFileItemViews_=a;e.enableSaveModelButtonIfVisible(!0);b.Hide(e.container_);e.renderFileTree(a)});return q};c.prototype.setupBreadcrumbs=function(a,b){var d=a.querySelectorAll(".folder-link");if(d.length!==b.ancestorList.length)throw"Mismatching breadcrumb sizes";for(var c=0;c<d.length;++c){var f=d[c],e=b.ancestorList[c];f.addEventListener("click",function(a){this.renderFolderView(this.currentRegion_,
a,e.localPath)}.bind(this,f.dataset.folderid))}};c.prototype.setupActionsBar=function(a){var b=a.querySelector(".add-file-button"),d=a.querySelector(".add-folder-button");a=a.querySelector(".sync-button");d.addEventListener("click",this.onAddFolder.bind(this));this.launchMode_===r.ModelSave?(b.classList.add("disabled-button"),a.classList.add("disabled-button")):(b.classList.remove("disabled-button"),a.classList.remove("disabled-button"),b.addEventListener("click",this.onAddFile.bind(this)))};c.prototype.renderFileTree=
function(a){for(var b=0;b<a.length;++b)this.renderSingleFileOrFolder(a[b]);0==a.length&&this.notifyEmptyFolder()};c.prototype.renderSingleFileOrFolder=function(a,b,d){var c=this;void 0===b&&(b=!0);void 0===d&&(d=!1);var f=a.versionState===e.FileVersionState.HasConflict,p=goog.soy.renderAsFragment(SketchUpTemplates.fileEntry,{fileEntry:a,hasConflict:f,isFolder:a.isFolder});p.addEventListener("click",this.selectFile.bind(this,a,p));p.addEventListener("dblclick",this.openFolderOrFile.bind(this,a));a.isFolder&&
goog.dom.getElementByClass("connect-foldername",p).addEventListener("click",function(b){b.stopPropagation();c.openFolderOrFile(a)});if(this.launchMode_!==r.ModelSave&&a.versionState!==e.FileVersionState.UpToDate){var h=goog.dom.getElementByClass("file-sync-actions-div",p);h.classList.remove("invisible");var g=a.versionState===e.FileVersionState.ModifiedAtRemoteStorage||a.versionState===e.FileVersionState.HasConflict;this.showDownloadUploadButton(a,h,"download-cloud",!0,g,f);g=a.versionState===e.FileVersionState.ModifiedLocally||
a.versionState===e.FileVersionState.HasConflict;this.showDownloadUploadButton(a,h,"upload-cloud",!1,g,f)}goog.dom.getElementByClass("close-button",p).addEventListener("click",this.onClickDeleteButton.bind(this,a));b?this.fileContainer_.appendChild(p):this.fileContainer_.insertBefore(p,this.fileContainer_.firstChild);d||(this.fileNameElementMap_[a.name]=p);return p};c.prototype.getCurrentFolderFullPath=function(){return"/"};c.prototype.onAddFolder=function(b){var c=this,f=d.FileManager.getInstance();
b=this.createUniqueFilename(h.$t("New Folder"));this.removeEmptyFolderMessage();b=f.makeFileViewForLocalDirectory(b);b.isActionInProgress=!0;var e=this.renderSingleFileOrFolder(b,!1,!0);b=goog.dom.getElementByClass("connect-foldername",e);b=a.EditField(b,!0).then(function(a){if(c.isFileNameAvailable(a))return f.createRemoteFolder(q.ProviderKey.Trimble_Connect,c.currentRegion_,a,c.currentFolderId_);window.setTimeout(function(){l.ShowInfoDialog(h.$t("Error"),h.$t("A file or folder with same name already exists."))},
0);return goog.Promise.reject(null)});b=b.then(function(a){var b=c.renderSingleFileOrFolder(a,!1);c.fileContainer_.replaceChild(b,e);c.selectFile(a,b)});b=b.thenCatch(function(a){c.fileContainer_.removeChild(e);goog.isDefAndNotNull(a)&&l.ShowInfoDialog(h.$t("Error"),h.$t("Sorry, this folder could not be created.")).then(function(){c.errorHandler_.rescue(a)})})};c.prototype.onAddFile=function(a){this.deselectSelected();this.detailsView_.makeVisible();this.detailsView_.activateImportPage()};c.prototype.deselectSelected=
function(){this.selectedFile_&&this.selectedFile_.classList.remove("selected-file");this.selectedFile_=null};c.prototype.selectFile=function(a,b){a.isActionInProgress||(this.deselectSelected(),this.selectedFile_=b,this.selectedFile_.classList.add("selected-file"),this.launchMode_===r.ModelSave?a.isFolder||this.setModelTitleInputFieldContents(a.name):this.detailsView_.activateFileDetails(a))};c.prototype.createUniqueFilename=function(a){for(var b=a,d=0;!this.isFileNameAvailable(b);)b=a+(++d).toString();
return b};c.prototype.isFileNameAvailable=function(a){for(var b in this.fileNameElementMap_)if(0===goog.string.caseInsensitiveCompare(b,a))return!1;return!0};c.prototype.showDownloadUploadButton=function(a,b,d,c,f,e){b=goog.dom.getElementByClass(d,b);f?c?b.addEventListener("click",this.onClickDownloadButton.bind(this,a,e)):b.addEventListener("click",this.onClickUploadButton.bind(this,a)):b.classList.add("invisible")};c.prototype.onClickDeleteButton=function(a,b){b.stopPropagation();a.isActionInProgress=
!0;this.feedback_.deleteFile(a)};c.prototype.doDeleteFileItem=function(a){var b=this,c=d.FileManager.getInstance().deleteFileOrFolder(a,q.ProviderKey.Trimble_Connect,this.currentRegion_),c=c.then(function(d){d&&b.reRenderCurrentFolderView();a.isActionInProgress=!1;return d});c.thenCatch(function(a){console.log("Failed to delete the File Item.");b.errorHandler_.rescue(a)})};c.prototype.onClickDownloadButton=function(a,b,d){};c.prototype.onClickUploadButton=function(a,b){};c.prototype.importFile=function(a){};
c.prototype.importReferenceFile=function(a){a.isActionInProgress||(a.isFolder?this.renderFolderView(this.currentRegion_,a.remoteId,a.localPath):this.launchMode_!==r.ModelSave&&this.feedback_.importReferenceFile(a))};c.prototype.openFolderOrFile=function(a){a.isActionInProgress||(a.isFolder?this.renderFolderView(this.currentRegion_,a.remoteId,a.localPath):this.launchMode_===r.ModelOpen?this.feedback_.openFile(a):this.launchMode_===r.ImportReference&&this.feedback_.importReferenceFile(a))};c.prototype.setupProgressDialog=
function(a){this.progressDialog_=l.ShowProgressDialog(a);this.progressDialog_.setCancelCallback(this.feedback_.cancelFileTransfer)};c.prototype.getFolderAncestorListNoCache=function(a,b){var d=this;return new goog.Promise(function(c,f){d.getFolderAncestorListRecursive(a,b,[],c)})};c.prototype.getFolderAncestorListRecursive=function(a,b,d,c){var f=this;a=this.trimbleConnect_.getFolderDetails(b,a);a.then(function(a){d.unshift({name:a.name,id:a.id,localPath:void 0});a.parentFolderId?f.getFolderAncestorListRecursive(a.parentFolderId,
b,d,c):c(d)});a.thenCatch(function(a){f.handleInvalidSavedState(a)})};c.prototype.setModelTitleInputFieldContents=function(a){this.saveNewModelInput_.value=a;this.saveNewModelInput_.focus();this.saveNewModelInput_.select()};c.prototype.enableSaveModelButtonIfVisible=function(a){var b=this;this.launchMode_===r.ModelSave&&(a?(this.saveNewModelButton_.classList.remove("disabled-button"),goog.isNull(this.onSaveInputKeyDownHandler_)&&(this.onSaveInputKeyDownHandler_=function(a){(a.keyCode||a.which)===
goog.events.KeyCodes.ENTER&&(a.stopPropagation(),a.preventDefault(),b.handleSave())},this.saveNewModelInput_.addEventListener("keydown",this.onSaveInputKeyDownHandler_))):(this.saveNewModelButton_.classList.add("disabled-button"),goog.isNull(this.onSaveInputKeyDownHandler_)||(this.saveNewModelInput_.removeEventListener("keydown",this.onSaveInputKeyDownHandler_),this.onSaveInputKeyDownHandler_=null)))};c.prototype.handleSave=function(){var a=this;if(goog.isDefAndNotNull(this.currentFolderId_)&&goog.isDefAndNotNull(this.currentFolderFileItemViews_)){var b=
this.saveNewModelInput_.value;if(0!==b.length){for(var d,c=g.StripExtension(b),f=0,e=this.currentFolderFileItemViews_;f<e.length;f++){var p=e[f],q=g.StripExtension(p.name);if(0==goog.string.caseInsensitiveCompare(c,q)){d=p;break}}c=goog.Promise.resolve(!0);goog.isDefAndNotNull(d)&&(c=l.ShowQuestionDialog(h.$t("A model with the same name already exists.")+"<br/>"+h.$t("Overwrite it?")));c=c.then(function(d){d&&a.feedback_.publishFile(a.currentFolderId_,b);return!0});c.thenCatch(function(b){console.log("Failed to initiate the file publish operation.");
a.errorHandler_.rescue(b)})}}};c.prototype.handleInvalidSavedState=function(a){var b=this;console.log("Failed to Load Saved Dialog State.");this.currentProjectId_=this.currentFolderId_=this.currentRegion_=null;console.log(a.message);this.trimbleConnect_.refreshToken().then(function(){b.renderProjectsView()})};c.prototype.notifyEmptyFolder=function(){var a=h.$t("This folder is empty"),a=goog.soy.renderAsFragment(SketchUpTemplates.emptyList,{message:a});document.querySelector(".file-tree ul").appendChild(a)};
c.prototype.removeEmptyFolderMessage=function(){var a=document.querySelector(".empty-list-message"),b=document.querySelector(".file-tree ul");goog.isDefAndNotNull(a)&&b.removeChild(a)};c.prototype.getOpenButton=function(){return goog.dom.getElementByClass("bottom-button")};c.prototype.getPublishButton=function(){return goog.dom.getElementByClass("save-here-button")};c.prototype.disableButton=function(a){a.classList.add("disabled-button")};c.prototype.enableButton=function(a){a.classList.remove("disabled-button")};
return c}();c.OpenDialogWidget=m});define("SketchUpFileRequest",["require","exports"],function(m,c){});
define("ProgressDialog","require exports ModelStorageProviderFactory DialogPrompts l10n ErrorHandler".split(" "),function(m,c,k,l,d,g){m=function(){function c(b){this.parent_=b;this.trimbleConnect_=k.Providers[k.ProviderKey.Trimble_Connect];this.errorHandler_=new g.ErrorHandler;this.render()}c.prototype.render=function(){var b=d.$t("Uploading...");this.progressDialog_=l.ShowProgressDialog(b);this.progressDialog_.setCancelCallback(this.cancelFileTransfer);b=goog.dom.getElementByClass("modal-dialog");
b.style.width="100%";b.style.height="100%";b.style.left="0px";b.style.top="0px";b.style.boxSizing="border-box";goog.dom.getElementByClass("progress-dialog-div").style.width="100%"};c.prototype.open=function(b){var d=this;this.trimbleConnect_.initialize(b).then(function(){d.sendUploadRequest(b)})};c.prototype.sendUploadRequest=function(b){var d=this,c=b.fileId;this.currentProjectId_=b.projectId;var a=b.location,f=null,g=null,p;this.getRegion(a).then(function(b){a=b;return p=goog.isDefAndNotNull(c)?
d.trimbleConnect_.getFileDetails(a,c):goog.Promise.resolve(null)}).then(function(a){a&&(f=a.versionId,g=a.name)}).then(function(){var n={token:d.trimbleConnect_.token,baseURL:d.trimbleConnect_.baseURL(a),fileName:b.fileName,projectId:b.projectId,parentId:b.folderId,location:a,remoteIdPath:b.remoteIdPath,versionId:f,fileId:c,remoteFileName:g};window.sketchup.publish_file(JSON.stringify(n))}).thenCatch(function(a){d.errorHandler_.rescue(a)})};c.prototype.updateProgress=function(b){if(goog.isDefAndNotNull(this.progressDialog_))this.progressDialog_.onProgress(b)};
c.prototype.processFileTransferError=function(b){this.errorHandler_.rescue(Error(b))};c.prototype.cancelFileTransfer=function(){window.sketchup.cancel_file_transfer()};c.prototype.getRegion=function(b){return goog.isDefAndNotNull(b)?goog.Promise.resolve(b):this.trimbleConnect_.getRegionForProject(this.currentProjectId_)};return c}();c.UploadProgressDialog=m});
define("main-progress",["require","exports","ModelStorageProviderFactory","ProgressDialog"],function(m,c,k,l){k.Init();window.ProgressDlg={show:function(d){this.dialog=new l.UploadProgressDialog(document.body);this.dialog.open(d)},updateProgress:function(d){this.dialog.updateProgress(d)},error:function(d){this.dialog.processFileTransferError(d)}};window.sketchup.ready()});
define("ReferenceListView","require exports TC-Object l10n ModelStorageProvider DialogPrompts DateHelper XhrUtils TaskDialogWidget".split(" "),function(m,c,k,l,d,g,h,b,e){m=function(){function c(a,b,d){this.parent_=a;this.localReferences_=b;this.feedback_=d;this.versionStateMap_={};this.remoteReferences_=[];this.progressElements_=[]}c.prototype.render=function(){var a=goog.soy.renderAsFragment(SketchUpTemplates.referenceList,{});this.parent_.appendChild(a);this.content_=a;this.renderActionBar();this.renderCommitCancel();
this.renderList()};c.prototype.addRemoteReference=function(a){this.remoteReferences_.push(a)};c.prototype.updateLocalReference=function(a){var b=this.getReferenceById(a.id,this.localReferences_),b=this.localReferences_.indexOf(b);this.localReferences_[b]=a};c.prototype.syncAlignment=function(a,b){var c=this.getReferenceById(a,this.remoteReferences_),c=this.remoteReferences_.indexOf(c),d=this.getReferenceById(a,this.localReferences_),d=this.localReferences_.indexOf(d);this.remoteReferences_[c].alignment=
b;this.localReferences_[d].alignment=b;this.displayAlignmentStateSatus();this.displayVersionStateStatus(a)};c.prototype.refreshFileStatus=function(a){this.deleteProgressBar(a);this.compareLocalAndRemote(a);this.displayAlignmentStateSatus();this.displayVersionStateStatus(a)};c.prototype.renderActionBar=function(){var a=goog.soy.renderAsFragment(SketchUpTemplates.refActionsBar,{});this.parent_.appendChild(a);this.actionBar_=a;this.handleActionBarEvents()};c.prototype.renderCommitCancel=function(){var a=
{cancelText:l.$t("Revert"),cancelTooltip:l.$t("Revert to the latest published model alignment"),commitText:l.$t("Upload"),commitTooltip:l.$t("Publish the alignment changes to Trimble Connect")},a=goog.soy.renderAsFragment(SketchUpTemplates.commitOrCancel,a);e.TaskDlg.handleCommitOrCancelClick(a,this.updateAlignment.bind(this),this.revertAlignment.bind(this));this.content_.appendChild(a)};c.prototype.updateAlignment=function(){this.disableButton(this.getCommitButton());this.feedback_.publishAlignment(this.selectedReference_.id)};
c.prototype.revertAlignment=function(){var a=this;this.disableButton(this.getCancelButton());this.feedback_.revertAlignment(this.selectedReference_.id).then(function(){a.enableButton(a.getCancelButton())})};c.prototype.handleActionBarEvents=function(){this.actionBar_.querySelector(".ref-add-button").addEventListener("click",this.addReference.bind(this));this.actionBar_.querySelector(".ref-delete-button").addEventListener("click",this.deleteReference.bind(this));this.getUpdateAllButton().addEventListener("click",
this.updateAllReferences.bind(this))};c.prototype.addReference=function(){this.feedback_.addReference()};c.prototype.deleteReference=function(){var a=this;goog.isDefAndNotNull(this.selectedReference_)&&goog.isDefAndNotNull(this.selectedReference_.id)&&g.ShowQuestionDialog(l.$t("Remove selected reference model?")).then(function(b){b&&a.feedback_.deleteReference(a.selectedReference_.id)})};c.prototype.updateAllReferences=function(){var a=this;g.ShowQuestionDialog(l.$t("Update all References?")).then(function(b){b&&
(a.deselectAllReferences(),a.localReferences_.forEach(function(b,c,n){a.versionStateMap_[b.id]==d.FileVersionState.ModifiedAtRemoteStorage&&a.doUpdateReference(b)}))})};c.prototype.updateReference=function(a){var b=this;g.ShowQuestionDialog(l.$t("Update model from Trimble Connect?")).then(function(c){c&&(b.deselectAllReferences(),b.doUpdateReference(a))})};c.prototype.doUpdateReference=function(a){var b=this.getReferenceById(a.id,this.remoteReferences_);null==b?g.ShowInfoDialog(l.$t("Error"),l.$t("Unable to locate the remote Trimble Connect model for the reference: ")+
a.name):(this.disableSyncButton(a.id),this.addProgressBar(this.setupProgressBar(a)),this.feedback_.updateReference(b))};c.prototype.disableSyncButton=function(a){a=document.getElementById(a);this.displaySyncedStatus(a)};c.prototype.addProgressBar=function(a){this.progressElements_.push(a)};c.prototype.deleteProgressBar=function(a){a=this.getProgressBarById(a);goog.isDefAndNotNull(a)&&(a=this.progressElements_.indexOf(a),goog.dom.removeNode(this.progressElements_[a].progressElement),this.progressElements_.splice(a,
1))};c.prototype.getProgressBarById=function(a){for(var b=0;b<this.progressElements_.length;++b){var c=this.progressElements_[b];if(c.id==a)return c}return null};c.prototype.setupProgressBar=function(a){var c=document.getElementById(a.id),d=goog.soy.renderAsFragment(SketchUpTemplates.listItemProgress);c.appendChild(d);var e=goog.dom.getElementByClass("progress-bar",d);return{id:a.id,progressElement:e,onProgress:function(a){e.value=b.ComputeProgressPercentage(a)}}};c.prototype.updateProgress=function(a,
b){for(var c=0;c<this.progressElements_.length;++c){var d=this.progressElements_[c];if(d.id==b)d.onProgress(a)}};c.prototype.renderList=function(){this.refList_=this.content_.querySelector(".ref-list-container ul");for(var a=0;a<this.localReferences_.length;++a)this.renderSingleReference(this.localReferences_[a]);0==this.localReferences_.length&&this.notifyEmptyList();this.deselectAllReferences()};c.prototype.renderSingleReference=function(a){var b=goog.soy.renderAsFragment(SketchUpTemplates.referenceEntry,
{reference:a,thumbnail:null,hasConflict:null}),c=goog.dom.getElementByClass("ref-list-item",b);c.addEventListener("click",this.selectReference.bind(this,b,a));c.addEventListener("dblclick",this.editAlignment.bind(this,b,a));goog.dom.getElementByClass("ref-update-button",b).addEventListener("click",this.updateReference.bind(this,a));c=goog.dom.getElementByClass("accordian-chevron",b);c.addEventListener("click",this.toggleEditAlignment.bind(this,b,a,c));this.refList_.appendChild(b)};c.prototype.toggleEditAlignment=
function(a,b){this.alignmentEditor_?this.selectReference(a,b):this.editAlignment(a,b)};c.prototype.notifyEmptyList=function(){var a=l.$t("This model has no reference models.");this.refList_.appendChild(goog.soy.renderAsFragment(SketchUpTemplates.emptyList,{message:a}))};c.prototype.selectReference=function(a,b){this.deselectAllReferences();a.classList.add("selected");this.selectedEntry_=a;this.enableButton(this.getDeleteButton());this.enableButton(this.getUpdateButton());this.selectedReference_=b;
this.feedback_.selectReference(b.id)};c.prototype.editAlignment=function(a,b){this.feedback_.editAlignment(b.id)};c.prototype.loadAlignmentView=function(a,b,c){this.getReferenceById(this.selectedReference_.id,this.localReferences_).alignment=a;goog.isDefAndNotNull(this.alignmentEditor_)?this.populateAlignmentFields(c):(this.rotateChevron(this.selectedEntry_),this.renderAlignmentEditor(b,c),this.loadCreator(),this.loadModifier(),this.handleAlignmentViewEvents());this.displayAlignmentStateSatus()};
c.prototype.rotateChevron=function(a){goog.dom.getElementByClass("accordian-chevron",a).classList.add("expanded")};c.prototype.unrotateChevron=function(a){goog.dom.getElementByClass("accordian-chevron",a).classList.remove("expanded")};c.prototype.renderAlignmentEditor=function(a,b){var c={position:{x:b.positionX,y:b.positionY,z:b.positionZ},rotation:{x:b.rotationX,y:b.rotationY,z:b.rotationZ},lengthUnit:b.lengthUnit,angleUnit:String.fromCharCode(176)};this.alignmentEditor_=goog.soy.renderAsFragment(SketchUpTemplates.editAlignment,
c);this.selectedEntry_.appendChild(this.alignmentEditor_);this.enableButton(this.getCommitButton());this.enableButton(this.getCancelButton())};c.prototype.populateAlignmentFields=function(a){var b=goog.dom.getElementByClass("pos-x-input"),c=goog.dom.getElementByClass("pos-y-input"),d=goog.dom.getElementByClass("pos-z-input"),n=goog.dom.getElementByClass("rot-x-input"),e=goog.dom.getElementByClass("rot-y-input"),u=goog.dom.getElementByClass("rot-z-input");b.value=a.positionX;c.value=a.positionY;d.value=
a.positionZ;n.value=a.rotationX;e.value=a.rotationY;u.value=a.rotationZ};c.prototype.loadCreator=function(){var a=this.getReferenceById(this.selectedReference_.id,this.remoteReferences_);if(goog.isDefAndNotNull(a)){var b=new k.User(a.createdBy),a={data:{label:l.$t("Created By:"),thumbnail:null,initials:b.getInitials(),name:b.displayName(),timestamp:h.convertTimeStamp(a.createdOn)}},a=goog.soy.renderAsFragment(SketchUpTemplates.authorDetails,a);this.alignmentEditor_.appendChild(a)}};c.prototype.loadModifier=
function(){var a=this.getReferenceById(this.selectedReference_.id,this.remoteReferences_);if(goog.isDefAndNotNull(a)){var b=new k.User(a.modifiedBy),a={data:{label:l.$t("Last Edited By:"),thumbnail:null,initials:b.getInitials(),name:b.displayName(),timestamp:h.convertTimeStamp(a.modifiedOn)}},a=goog.soy.renderAsFragment(SketchUpTemplates.authorDetails,a);this.alignmentEditor_.appendChild(a)}};c.prototype.handleAlignmentViewEvents=function(){goog.dom.getElementByClass("align-button-container",this.selectedEntry_).addEventListener("click",
this.launchAlignmentTool.bind(this));for(var a=document.querySelectorAll(".alignment-input"),b=0;b<a.length;++b)a[b].addEventListener("keyup",this.positionReference.bind(this,a))};c.prototype.launchAlignmentTool=function(){this.feedback_.launchAlignmentTool(this.selectedReference_.id)};c.prototype.positionReference=function(a){var b={};a.forEach(function(a,c,d){b[a.classList.item(1)]=a.value});this.showUpdateAlignmentButton();this.feedback_.positionReference(this.selectedReference_.id,b)};c.prototype.showUpdateAlignmentButton=
function(){this.content_.querySelector(".commit-cancel-container").classList.add("visible");this.content_.classList.add("compressed")};c.prototype.hideUpdateAlignmentButton=function(){this.content_.querySelector(".commit-cancel-container").classList.remove("visible");this.content_.classList.remove("compressed")};c.prototype.deselectAllReferences=function(){for(var a=this.refList_.getElementsByTagName("li"),b=0;b<a.length;++b)a[b].classList.remove("selected");this.disableButton(this.getDeleteButton());
goog.isDefAndNotNull(this.alignmentEditor_)&&(goog.dom.removeNode(this.alignmentEditor_),this.unrotateChevron(this.selectedEntry_));this.hideUpdateAlignmentButton();this.selectedReference_=this.alignmentEditor_=null};c.prototype.enableButton=function(a){a.classList.remove("disabled-button")};c.prototype.disableButton=function(a){a.classList.add("disabled-button")};c.prototype.getDeleteButton=function(){return goog.dom.getElementByClass("ref-delete-button",this.actionBar_)};c.prototype.getUpdateAllButton=
function(){return goog.dom.getElementByClass("ref-update-button",this.actionBar_)};c.prototype.getCommitButton=function(){return goog.dom.getElementByClass("commit-button",this.content_)};c.prototype.getCancelButton=function(){return goog.dom.getElementByClass("cancel-button",this.content_)};c.prototype.getUpdateButton=function(){return goog.dom.getElementByClass("ref-update-button",this.actionBar_)};c.prototype.compareLocalAndRemote=function(a){var b=this.getReferenceById(a,this.localReferences_),
c=this.getReferenceById(a,this.remoteReferences_);goog.isDefAndNotNull(b)&&goog.isDefAndNotNull(c)?c.versionId==b.versionId?this.versionStateMap_[a]=d.FileVersionState.UpToDate:this.getNewest(b,c)==c?this.versionStateMap_[a]=d.FileVersionState.ModifiedAtRemoteStorage:this.versionStateMap_[a]=d.FileVersionState.ModifiedLocally:(goog.isDefAndNotNull(b),this.versionStateMap_[a]=d.FileVersionState.DeleteAtRemoteStorage)};c.prototype.displayVersionStateStatus=function(a){var b=document.getElementById(a);
switch(this.versionStateMap_[a]){case d.FileVersionState.ModifiedAtRemoteStorage:this.displayRemoteModifiedStatus(b);break;case d.FileVersionState.DeleteAtRemoteStorage:this.displayDeletedStatus(b);break;default:this.displaySyncedStatus(b)}};c.prototype.displayAlignmentStateSatus=function(){if(goog.isDefAndNotNull(this.selectedReference_)&&goog.isDefAndNotNull(this.alignmentEditor_)){var a=this.getReferenceById(this.selectedReference_.id,this.remoteReferences_),b=this.getReferenceById(this.selectedReference_.id,
this.localReferences_);goog.isDefAndNotNull(a)&&!this.hasSameAlignment(b.alignment,a.alignment)?this.showUpdateAlignmentButton():this.hideUpdateAlignmentButton()}};c.prototype.displayRemoteModifiedStatus=function(a){goog.dom.getElementByClass("ref-update-button",a).classList.remove("invisible");this.shrinkRefName(a)};c.prototype.displayDeletedStatus=function(a){var b=l.$t("The model has been deleted from Trimble Connect");a.title=b;a.classList.add("reference-not-found")};c.prototype.shrinkRefName=
function(a){goog.dom.getElementByClass("ref-list-item-name",a).classList.add("shrink")};c.prototype.unshrinkRefName=function(a){goog.dom.getElementByClass("ref-list-item-name",a).classList.remove("shrink")};c.prototype.displaySyncedStatus=function(a){goog.dom.getElementByClass("ref-update-button",a).classList.add("invisible");this.unshrinkRefName(a)};c.prototype.getNewest=function(a,b){return new Date(a.modifiedOn)<new Date(b.modifiedOn)?b:a};c.prototype.getReferenceById=function(a,b){for(var c=0;c<
b.length;++c){var d=b[c];if(d.id==a)return d}return null};c.prototype.hasSameAlignment=function(a,b){var c=!1;goog.math.nearlyEquals(a.axisX,b.axisX)&&goog.math.nearlyEquals(a.axisY,b.axisY)&&goog.math.nearlyEquals(a.axisZ,b.axisZ)&&goog.math.nearlyEquals(a.locationX,b.locationX)&&goog.math.nearlyEquals(a.locationY,b.locationY)&&goog.math.nearlyEquals(a.locationZ,b.locationZ)&&goog.math.nearlyEquals(a.refDirectionX,b.refDirectionX)&&goog.math.nearlyEquals(a.refDirectionY,b.refDirectionY)&&goog.math.nearlyEquals(a.refDirectionZ,
b.refDirectionZ)&&(c=!0);return c};return c}();c.ReferenceListView=m});
define("TaskDialogWidget","require exports DialogPrompts ModelStorageProviderFactory LoadingGif DateHelper FileUtils l10n TC-Object ReferenceListView ErrorHandler".split(" "),function(m,c,k,l,d,g,h,b,e,q,a){(function(a){a[a.TaskList=0]="TaskList";a[a.TaskConsume=1]="TaskConsume";a[a.Comment=2]="Comment";a[a.Reference=3]="Reference"})(c.TabView||(c.TabView={}));var f=c.TabView;m=function(){function c(b,d){this.parent_=b;this.feedback_=d;this.initialized_=!1;this.MAX_ASSIGNEES=10;this.trimbleConnect_=
l.Providers[l.ProviderKey.Trimble_Connect];this.setupDialog();this.currentRegion_=null;this.errorHandler_=new a.ErrorHandler}Object.defineProperty(c.prototype,"currentRegionLocation",{get:function(){return this.currentRegion_},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"currentModelId",{get:function(){return goog.isDefAndNotNull(this.currentModelId_)?this.currentModelId_:null},enumerable:!0,configurable:!0});c.prototype.setupDialog=function(){this.container_=goog.soy.renderAsFragment(SketchUpTemplates.taskTab,
{});this.parent_.appendChild(this.container_);console.log("Setting up Dialog");d.Show(this.container_)};c.prototype.render=function(){var a=goog.soy.renderAsFragment(SketchUpTemplates.topActionsBar,{});this.handleActionBarEvents(a);var b=goog.soy.renderAsFragment(SketchUpTemplates.taskContent,{});this.container_.appendChild(a);this.container_.appendChild(b);this.content_=this.container_.querySelector(".tasks-content-wrapper")};c.prototype.handleActionBarEvents=function(a){var b=this,c=a.querySelector(".task-button");
c.addEventListener("click",this.openTab.bind(this,f.TaskList));a.querySelector(".connect-button").addEventListener("click",this.openConnect.bind(this));var d=a.querySelector(".comments-button");d.addEventListener("click",this.openTab.bind(this,f.Comment));a=a.querySelector(".references-button");a.addEventListener("click",this.openTab.bind(this,f.Reference));[c,d,a].forEach(function(a,c,d){a.addEventListener("click",b.displayAsSelected.bind(b,d,a))})};c.prototype.displayAsSelected=function(a,b){a.forEach(function(a,
b,c){a.classList.remove("selected")});b.classList.add("selected")};c.prototype.open=function(a){var b=this,c=a.mode,e=a.projectId,f=a.location,g=a.fileId;this.currentUserEmail_=a.email;a=this.trimbleConnect_.initialize(a);console.log("Initializing Trimble Connect");a=a.then(function(){if(goog.isDefAndNotNull(e)&&goog.isDefAndNotNull(g))b.currentProjectId_=e,b.currentModelId_=g,b.getRegion(f).then(function(a){b.currentRegion_=a;d.Hide(b.container_);b.render();b.openTab(c)}).thenCatch(function(a){console.log("Caught error fetching region");
b.errorHandler_.rescue(a)});else throw Error("PROJECT_NOT_DEFINED");});a.thenCatch(function(a){console.log("Caught Error in Open");b.errorHandler_.rescue(a)});return new goog.Promise(function(a,b){},this)};c.prototype.getRegion=function(a){return goog.isDefAndNotNull(a)?goog.Promise.resolve(a):this.trimbleConnect_.getRegionForProject(this.currentProjectId_)};c.prototype.getUsers=function(){var a=this;if(goog.isDefAndNotNull(this.currentUsers_))return goog.Promise.resolve();var b=this.trimbleConnect_.getUsers(this.currentRegion_,
this.currentProjectId_);return b=b.then(function(b){var c=[];b.forEach(function(a,b,d){a.status==e.UserStatus.ACTIVE&&c.push(new e.User(a))});return a.currentUsers_=c})};c.prototype.getGroups=function(){var a=this;if(goog.isDefAndNotNull(this.currentGroups_))return goog.Promise.resolve();var b=this.trimbleConnect_.getUserGroups(this.currentRegion_,this.currentProjectId_);return b=b.then(function(b){return a.currentGroups_=b})};c.prototype.openTab=function(a){if(this.currentTabView_!=a)switch(this.currentTabView_=
a,d.Hide(this.commentList_),d.Hide(this.taskList_),a){case f.TaskList:this.renderTaskListView();break;case f.Comment:this.renderCommentsView();break;case f.Reference:this.renderReferencesView();break;default:this.renderTaskListView()}};c.prototype.renderTaskListView=function(){var b=this;this.clearContent();var c=goog.soy.renderAsFragment(SketchUpTemplates.tasksList,{});this.content_.appendChild(c);var e=goog.soy.renderAsFragment(SketchUpTemplates.list,{}),g=goog.dom.getElementByClass("task-list-container");
this.renderFilterView(g);c.appendChild(e);this.taskList_=e;this.renderTaskListActionBar();d.Hide(this.taskList_);d.Show(this.taskList_);this.getUsers().then(function(){return b.getGroups()}).then(function(){return b.trimbleConnect_.getTasks(b.currentRegion_,b.currentProjectId_)}).then(function(c){if(b.currentTabView_==f.TaskList)return b.getAttachments(c);d.Hide(b.taskList_);return goog.Promise.reject(Error(a.code.ACTION_ABORTED_BY_USER))}).then(function(a){return b.getTaskViews(a)}).then(function(a){b.currentModelTasks_=
b.getModelTasks(a);b.renderTaskList(b.currentModelTasks_)}).thenCatch(function(a){console.log("Caught error in renderTaskListView");b.errorHandler_.rescue(a);d.Hide(b.taskList_);d.Hide(b.commentList_)})};c.prototype.renderFilterView=function(a){var b=goog.soy.renderAsFragment(SketchUpTemplates.taskFilterView,{users:[],selectedUser:"",priority:e.Task.priorityOptions[0],status:e.Task.statusOptions[0]});a.appendChild(b)};c.prototype.getAttachments=function(a){var b=this,c=[];a.forEach(function(a,d,n){c.push(b.trimbleConnect_.getTaskAttachments(b.currentRegion_,
b.currentProjectId_,a.id))});var d=goog.Promise.all(c);return d=d.then(function(b){b.forEach(function(b,c,d){a[c].attachments=b});return a})};c.prototype.getTaskViews=function(a){var b=this,c=[];a.forEach(function(a){(a=a.getViewAttachment())?c.push(b.trimbleConnect_.getViewDetails(b.currentRegion_,a.id)):c.push(goog.Promise.resolve(null))});var d=goog.Promise.all(c);return d=d.then(function(b){b.forEach(function(b,c){a[c].view=b});return a})};c.prototype.renderTaskListActionBar=function(){var a=
goog.soy.renderAsFragment(SketchUpTemplates.taskActionsBar,{});this.content_.appendChild(a);a.querySelector(".create-task-button").addEventListener("click",this.renderCreateTaskView.bind(this));a.querySelector(".task-delete-button").addEventListener("click",this.deleteTask.bind(this))};c.prototype.getModelTasks=function(a){var b=this,c=[];a.forEach(function(a){a.includesModel(b.currentModelId_)&&c.push(a)});return c};c.prototype.renderTaskList=function(a){a=this.sortTaskList(a);d.Hide(this.taskList_);
if(this.currentTabView_==f.TaskList){goog.dom.removeChildren(this.taskList_);for(var b=0;b<a.length;++b)this.renderSingleTask(a[b]);0==a.length&&this.notifyEmptyTaskList();this.deselectAllTasks()}};c.prototype.sortTaskList=function(a){var b=a.filter(function(a){return a.status==e.TaskStatus[e.TaskStatus.CLOSED]}),c=a.filter(function(a){return a.status==e.TaskStatus[e.TaskStatus.RESOLVED]}),d=a.filter(function(a){return a.status!=e.TaskStatus[e.TaskStatus.CLOSED]&&a.status!=e.TaskStatus[e.TaskStatus.RESOLVED]});
a=d.filter(function(a){return!goog.isString(a.dueDate)});d=d.filter(function(a){return goog.isString(a.dueDate)});b.sort(function(a,b){return g.compareDateStrings(b.createdOn,a.createdOn)});c.sort(function(a,b){return g.compareDateStrings(b.createdOn,a.createdOn)});a.sort(function(a,b){return e.TaskPriority[a.priority]-e.TaskPriority[b.priority]});d.sort(function(a,b){return g.compareDateStrings(a.dueDate,b.dueDate)});return d.concat(a,c,b)};c.prototype.renderSingleTask=function(a){var b=a.getDisplayedAssignee(),
b={task:a,thumbnail:b.getThumbnail(),initials:b.getInitials()},b=goog.soy.renderAsFragment(SketchUpTemplates.taskEntry,b);b.addEventListener("dblclick",this.openTask.bind(this,b));b.addEventListener("click",this.selectTask.bind(this,a,b));this.taskList_.appendChild(b)};c.prototype.notifyEmptyTaskList=function(){var a=b.$t("There are no ToDos related to this model.");this.taskList_.appendChild(goog.soy.renderAsFragment(SketchUpTemplates.emptyList,{message:a}))};c.prototype.getAssigneeDetailsAndThumbnail=
function(a){var b=this,c;c=a.getDisplayedAssignee();c.hasDetails?a=goog.Promise.resolve(c):(a=this.trimbleConnect_.getUserDetails(this.currentRegion_,c.id),a=a.then(function(a){c=new e.User(a);c.hasThumbnail()&&(a=c.getThumbnailUrl(),a=b.trimbleConnect_.downloadThumbnail(a),a=a.then(function(a){c.setThumbnailData(a);return a}));return c}));return a};c.prototype.renderCreateTaskView=function(){this.currentView_=null;this.clearContent();var a={mode:"CREATE",task:e.Task.defaultTask(this.currentProjectId_)};
this.renderTaskDetailView(a);this.renderCaptureViewButton();a={cancelText:b.$t("Cancel"),cancelTooltip:b.$t("Cancel the ToDo creation"),commitText:b.$t("Create"),commitTooltip:b.$t("Publish this ToDo")};a=goog.soy.renderAsFragment(SketchUpTemplates.commitOrCancel,a);r.handleCommitOrCancelClick(a,this.publishTask.bind(this),this.openTab.bind(this,f.TaskList));this.content_.appendChild(a);this.showUpdateTaskButton()};c.prototype.renderCaptureViewButton=function(){var a=goog.soy.renderAsFragment(SketchUpTemplates.captureView,
{});a.addEventListener("click",this.getSUView.bind(this));document.querySelector(".task-view-image-container").appendChild(a)};c.prototype.renderEditTaskView=function(a){var c=this.renderTaskDetailView({mode:"EDIT",task:a});this.renderTaskCommentView(c);this.setRemoteTaskImage(a);c={cancelText:b.$t("Cancel"),cancelTooltip:b.$t("Cancel changes to this ToDo"),commitText:b.$t("Update"),commitTooltip:b.$t("Publish changes to this ToDo")};c=goog.soy.renderAsFragment(SketchUpTemplates.commitOrCancel,c);
r.handleCommitOrCancelClick(c,this.updateTask.bind(this,a),this.openTab.bind(this,f.TaskList));this.content_.appendChild(c);this.handleTaskEditEvents()};c.prototype.handleTaskEditEvents=function(){for(var a=this.content_.querySelectorAll(".task-input"),b=this.content_.querySelector(".capture-view-button"),c=0;c<a.length;++c)a[c].addEventListener("change",this.showUpdateTaskButton.bind(this));for(c=0;c<a.length;++c)a[c].addEventListener("keyup",this.showUpdateTaskButton.bind(this));goog.isDefAndNotNull(b)&&
b.addEventListener("click",this.showUpdateTaskButton.bind(this))};c.prototype.getRefreshViewButton=function(){return this.content_.querySelector(".task-view-image-refresh-button")};c.prototype.showUpdateTaskButton=function(){this.content_.querySelector(".commit-cancel-container").classList.add("visible");this.content_.querySelector(".task-details").classList.add("compressed")};c.prototype.openConnect=function(){this.feedback_.openTrimbleConnect()};c.prototype.renderCommentsView=function(){var a=this;
this.clearContent();var c=goog.soy.renderAsFragment(SketchUpTemplates.commentList,{}),f=b.$t("Comment on this model..."),f=goog.soy.renderAsFragment(SketchUpTemplates.commentInputBar,{placeholder:f});this.commentList_=c.querySelector(".comment-list-container ul");this.content_.appendChild(c);this.content_.appendChild(f);d.Hide(this.commentList_);d.Show(this.commentList_);this.getUsers().then(function(){return a.trimbleConnect_.getComments(a.currentRegion_,a.currentModelId_,e.Type.file)}).then(function(b){a.comments_=
b;d.Hide(a.commentList_);a.renderComments(a.comments_.reverse())}).thenCatch(function(b){console.log("Caught error in render Comments View");a.errorHandler_.rescue(b);d.Hide(a.taskList_);d.Hide(a.commentList_)});this.handlePublishCommentClick(this.publishComment)};c.prototype.renderComments=function(a){if(this.currentTabView_==f.Comment){for(var b=0;b<a.length;++b)this.renderSingleComment(a[b]);0==a.length&&this.notifyEmptyCommentList()}};c.prototype.renderSingleComment=function(a){var b=this.getUserFromEmail(this.currentUserEmail_),
c=new e.User(a.createdBy);a=a.createdBy.email==b.email?this.makeCommentHTMLElement(a,b,SketchUpTemplates.activeUserComment):this.makeCommentHTMLElement(a,c,SketchUpTemplates.userComment);this.commentList_.appendChild(a)};c.prototype.notifyEmptyCommentList=function(){var a=b.$t("There are no comments for this model.");this.commentList_.appendChild(goog.soy.renderAsFragment(SketchUpTemplates.emptyList,{message:a}))};c.prototype.handlePublishCommentClick=function(a){goog.dom.getElementByClass("publish-comment").addEventListener("click",
a.bind(this))};c.prototype.getUserFromEmail=function(a){for(var b=0;b<this.currentUsers_.length;++b)if(this.currentUsers_[b].email==a)return new e.User(this.currentUsers_[b]);return null};c.prototype.makeCommentHTMLElement=function(a,b,c){a={comment:a,user:b,thumbnail:b.getThumbnail(),initials:b.getInitials(),date:g.convertTimeStamp(a.modifiedOn)};return goog.soy.renderAsFragment(c,a)};c.prototype.publishComment=function(){var a=this,b={},c=goog.dom.getElementByClass("comment-input-field"),d=c.value;
if(!goog.string.isEmpty(d))return b.objectId=this.currentModelId_,b.objectType=e.Type.file,b.description=d,b=this.trimbleConnect_.publishComment(this.currentRegion_,b),b.then(function(b){c.value="";a.comments_.unshift(b);1==a.comments_.length?a.renderCommentsView():a.renderSingleComment(b)}),b.thenCatch(function(b){a.errorHandler_.rescue(b)}),b};c.prototype.renderReferencesView=function(){this.feedback_.renderReferencesView()};c.prototype.renderReferencesViewCallback=function(b){var c=this;this.referencesView_=
new q.ReferenceListView(this.content_,b,this.feedback_);for(var d=function(){var d=b[g].id;e.trimbleConnect_.getFileDetails(e.currentRegion_,d).then(function(a){var b=c.getAlignment(a.id);b.then(function(b){c.currentTabView_==f.Reference&&(a.alignment=b,c.referencesView_.addRemoteReference(a),c.setReferenceModelImage(a),c.referencesView_.refreshFileStatus(d))});b.thenCatch(function(a){c.errorHandler_.rescue(a)})}).thenCatch(function(b){c.errorHandler_.getCode(b)==a.code.INVALID_OPERATION_FILE_DELETED&&
c.currentTabView_==f.Reference?c.referencesView_.refreshFileStatus(d):c.errorHandler_.rescue(b)})},e=this,g=0;g<b.length;++g)d();this.clearContent();this.referencesView_.render()};c.prototype.updateReferenceStatus=function(a){goog.isDefAndNotNull(this.referencesView_)&&this.currentTabView_==f.Reference&&(this.referencesView_.updateLocalReference(a),this.referencesView_.refreshFileStatus(a.id))};c.prototype.publishAlignment=function(a,c){var d=this;goog.isDefAndNotNull(this.referencesView_)&&this.trimbleConnect_.publishAlignment(this.currentRegion_,
a,c).then(function(b){d.referencesView_.syncAlignment(a,b)}).then(function(){d.enableButton(d.getCommitButton());var a=b.$t("Alignment successfully published to Trimble Connect");k.ShowInfoDialog(b.$t("Info"),a)}).thenCatch(function(a){d.errorHandler_.rescue(a);d.enableButton(d.getCommitButton())})};c.prototype.updateProgress=function(a,b){goog.isDefAndNotNull(this.referencesView_)&&this.referencesView_.updateProgress(a,b)};c.prototype.setReferenceModelImage=function(a){var b=this,c=a.thumbnailUrl;
goog.isDefAndNotNull(c)&&(c=this.trimbleConnect_.downloadThumbnail(c[0]),c=c.then(this.referenceModelThumbnailDownloadDone.bind(this,a)),c=c.thenCatch(function(a){b.errorHandler_.rescue(a)}))};c.prototype.loadAlignment=function(a,b,c){this.referencesView_.loadAlignmentView(a,b,c)};c.prototype.renderTaskDetailView=function(a){this.currentTabView_=f.TaskConsume;a=goog.soy.renderAsFragment(SketchUpTemplates.taskDetails,a);this.taskViewModified_=!1;this.content_.appendChild(a);this.setupAssignField();
this.handleRefreshViewButtonEvents();return a};c.prototype.renderTaskCommentView=function(a){var c=b.$t("Add comment..."),c=goog.soy.renderAsFragment(SketchUpTemplates.taskCommentList,{placeholder:c});goog.dom.getElementByClass("task-details",a).appendChild(c);return c};c.prototype.setupAssignField=function(){var a=goog.dom.getElementByClass("assign-task-input",this.content_),b=this.getUserFullNameIdMap(),c=this.getGroupNameIdMap(),d=[],e;for(e in b)d.push(b[e]);for(e in c)d.push(c[e]);goog.ui.ac.createSimpleAutoComplete(d,
a,!0)};c.prototype.handleRefreshViewButtonEvents=function(){this.getRefreshViewButton().addEventListener("click",this.getSUView.bind(this));this.getRefreshViewButton().addEventListener("click",this.showUpdateTaskButton.bind(this))};c.prototype.getUserFullNameIdMap=function(){for(var a={},b=0;b<this.currentUsers_.length;b++){var c=this.currentUsers_[b].displayName();a[this.currentUsers_[b].id]=c}return a};c.prototype.getGroupNameIdMap=function(){for(var a={},b=0;b<this.currentGroups_.length;b++)a[this.currentGroups_[b].id]=
this.currentGroups_[b].name;return a};c.prototype.getSUView=function(){var a=this;this.getAlignment(this.currentModelId).then(function(b){a.taskViewModified_=!0;a.feedback_.captureView(b)}).thenCatch(function(b){a.errorHandler_.rescue(b)})};c.prototype.getAlignment=function(a){return this.trimbleConnect_.getAlignment(this.currentRegion_,a)};c.prototype.setRemoteTaskImage=function(a){var b=this,c=a.getThumbnailURL();if(goog.isDefAndNotNull(c)){var e=this.content_.querySelector(".task-view-image-container");
d.Show(e);c=this.trimbleConnect_.downloadThumbnail(c);c=c.then(this.taskThumbnailDownloadDone.bind(this,a,e));c=c.thenCatch(function(a){b.errorHandler_.rescue(a)})}else this.renderCaptureViewButton()};c.prototype.taskThumbnailDownloadDone=function(a,b,c){a=h.ArrayBufferToBase64(c);c=goog.dom.getElementByClass("task-view-image");d.Hide(b);c.src="data:image/png;base64, "+a;this.showTaskImage()};c.prototype.showViewRefreshButton=function(){goog.dom.getElementByClass("task-view-image-refresh-button").classList.remove("invisible")};
c.prototype.referenceModelThumbnailDownloadDone=function(a,b){var c=h.ArrayBufferToBase64(b),d=document.getElementById(a.id),d=goog.dom.getElementByClass("ref-icon",d);goog.isDefAndNotNull(d)&&(d.src="data:image/png;base64, "+c)};c.prototype.setLocalTaskImage=function(a){goog.dom.getElementByClass("task-view-image").src=a;this.showTaskImage()};c.prototype.hideTaskImage=function(){goog.dom.getElementByClass("task-view-image").classList.add("invisible");this.showCaptureViewButton()};c.prototype.showTaskImage=
function(){var a=goog.dom.getElementByClass("task-view-image");a.classList.remove("invisible");a.addEventListener("click",this.setClientView.bind(this));this.hideCaptureViewButton();this.showViewRefreshButton()};c.prototype.setClientView=function(){var a=this;this.getAlignment(this.currentModelId).then(function(b){a.feedback_.setView(a.currentView_,b)})};c.prototype.hideCaptureViewButton=function(){var a=goog.dom.getElementByClass("capture-view-button-container");goog.isDefAndNotNull(a)&&a.classList.add("invisible")};
c.prototype.showCaptureViewButton=function(){goog.dom.getElementByClass("capture-view-button-container").classList.remove("invisible")};c.prototype.getViewDetails=function(a){var b=this;this.currentView_=null;return goog.isDefAndNotNull(a)?(a=this.trimbleConnect_.getViewDetails(this.currentRegion_,a.id),a.then(function(a){b.currentView_=a}),a.thenCatch(function(a){b.errorHandler_.rescue(a)}),a):goog.Promise.resolve()};c.prototype.setTaskView=function(a){a.projectId=this.currentProjectId_;this.currentView_=
a};c.prototype.selectTask=function(a,b){this.deselectAllTasks();b.classList.add("selected");this.selectedTask_=b;this.enableButton(this.getDeleteButton())};c.prototype.deselectAllTasks=function(){for(var a=this.taskList_.getElementsByTagName("li"),b=0;b<a.length;++b)a[b].classList.remove("selected");this.disableButton(this.getDeleteButton())};c.prototype.enableButton=function(a){a.classList.remove("disabled-button")};c.prototype.disableButton=function(a){a.classList.add("disabled-button")};c.prototype.getDeleteButton=
function(){return goog.dom.getElementByClass("task-delete-button",this.content_)};c.prototype.getCommitButton=function(){return goog.dom.getElementByClass("commit-button",this.content_)};c.prototype.deleteTask=function(a){var c=this;a.stopPropagation();if(goog.isDefAndNotNull(this.selectedTask_)){var d=this.selectedTask_.dataset.id;a=k.ShowQuestionDialog(b.$t("Are you sure you want to delete the selected ToDo? You cannot undo this."));a.then(function(a){if(a){var b=c.trimbleConnect_.deleteTask(c.currentRegion_,
d);b.then(function(){c.renderTaskListView()});b.thenCatch(function(a){c.errorHandler_.rescue(a)})}return a});a.thenCatch(function(a){c.errorHandler_.rescue(a)})}};c.prototype.updateTask=function(a){var c=this;try{var d=this.createTaskFromFormInput(),e=a.getDifference(d);e.assignees=d.assignees;e.dueDate=d.dueDate;e.priority=d.priority;this.disableButton(this.getCommitButton());d=void 0;d=this.trimbleConnect_.updateTask(this.currentRegion_,a.id,e);d=d.then(function(){return c.taskViewModified_?c.updateTaskView(a,
c.currentView_):goog.Promise.resolve()});d.then(function(){k.ShowInfoDialog(b.$t("Info"),b.$t("ToDo Successfully Updated")).then(function(){c.openTab(f.TaskList)})});d.thenCatch(function(a){c.errorHandler_.rescue(a);c.enableButton(c.getCommitButton())});return d}catch(g){return this.errorHandler_.rescue(g),this.enableButton(this.getCommitButton()),goog.Promise.reject(g)}};c.prototype.updateTaskView=function(a,b){var c=this,d=a.getViewAttachment();return(goog.isDefAndNotNull(d)?this.trimbleConnect_.removeAttachments(this.currentRegion_,
a.id,a.attachments).then(function(){a.removeAllAttachments();return c.trimbleConnect_.deleteView(c.currentRegion_,d.id)}):goog.Promise.resolve()).then(function(){return c.publishTaskView(a)})};c.prototype.openTask=function(a,b){var c=this;b.stopPropagation();var e=a.dataset.id;this.currentTaskId_=e;this.clearContent();d.Show(this.content_);var f;this.currentModelTasks_.forEach(function(a){a.id==e&&(f=a)});var g=f.getViewAttachment();this.getViewDetails(g).then(function(){d.Hide(c.content_);c.renderEditTaskView(f)}).thenCatch(function(a){c.errorHandler_.rescue(a);
c.renderTaskListView()})};c.prototype.publishTask=function(){var a=this,c;try{this.disableButton(this.getCommitButton());c=this.createTaskFromFormInput();var d=this.trimbleConnect_.publishTask(this.currentRegion_,this.currentProjectId_,c),e;d.then(function(b){e=b;return a.attachModel(e)}).then(function(b){return a.publishTaskView(e)}).then(function(){return k.ShowInfoDialog(b.$t("Info"),b.$t("ToDo Successfully Published"))}).then(function(){a.openTab(f.TaskList)});d.thenCatch(function(b){a.errorHandler_.rescue(b);
a.enableButton(a.getCommitButton())});return d}catch(g){return this.errorHandler_.rescue(g),this.enableButton(this.getCommitButton()),goog.Promise.reject(g)}};c.prototype.attachModel=function(a){goog.isDefAndNotNull(this.currentView_)?a=goog.Promise.resolve():(a.addAttachment(this.currentModelId_,e.Type.file),a=this.trimbleConnect_.publishTaskAttachments(this.currentRegion_,this.currentProjectId_,a,a.attachments));return a};c.prototype.setViewPropertiesFromTask=function(a){a=b.$t("ToDo View: ")+a.label;
this.currentView_.name=a;this.currentView_.description=a};c.prototype.publishTaskView=function(a){var b=this,c;goog.isDefAndNotNull(this.currentView_)?(this.setViewPropertiesFromTask(a),c=this.trimbleConnect_.publishView(this.currentRegion_,this.currentProjectId_,this.currentView_),c.then(function(c){a.addAttachment(c.id,e.Type.view);return b.trimbleConnect_.publishTaskAttachments(b.currentRegion_,b.currentProjectId_,a,a.attachments)})):c=goog.Promise.resolve();return c};c.prototype.createTaskFromFormInput=
function(){var a=goog.dom.getElementByClass("task-name-input"),b=goog.dom.getElementByClass("task-description-input"),c=goog.dom.getElementByClass("due-date-input"),d=goog.dom.getElementByClass("priority-input"),f=goog.dom.getElementByClass("status-input"),g=goog.dom.getElementByClass("assign-task-input"),a={description:goog.string.trim(b.value),projectId:this.currentProjectId_,label:goog.string.trim(a.value),status:f.value,priority:d.value,dueDate:c.value,assignees:this.getAssigneesFromInputField(g)},
a=this.validateTaskInput(a);return new e.Task(a)};c.prototype.getAssigneesFromInputField=function(a){a=goog.string.splitLimit(a.value,",",this.MAX_ASSIGNEES);a.forEach(function(a,b,c){c[b]=goog.string.trim(a)});goog.array.removeAllIf(a,function(a,b,c){return goog.string.isEmpty(a)});var b=[],c=this.getUserFullNameIdMap(),d=this.getGroupNameIdMap();a.forEach(function(a){for(var f in c)c[f]==a&&b.push({id:f,type:e.Type.user});for(f in d)d[f]==a&&b.push({id:f,type:e.Type.group})});if(a.length!=b.length)throw Error("INVALID_ASSIGNEE");
return b};c.prototype.validateTaskInput=function(a){if(Date.parse(a.dueDate)){var b=g.ISODateString(new Date(a.dueDate)),b=g.fixDueDate(b);a.dueDate=b}else delete a.dueDate;if(goog.string.isEmpty(a.description))throw Error("MISSING_TODO_DESCRIPTION");return a};c.prototype.hideElement=function(a){a.classList.add("invisible")};c.prototype.showElement=function(a){a.classList.remove("invisible")};c.prototype.clearContent=function(){goog.dom.removeChildren(this.content_)};return c}();c.TaskDialogWidget=
m;var r;(function(a){a.handleCommitOrCancelClick=function(a,b,c){a.querySelector(".commit-button").addEventListener("click",b.bind(this));a.querySelector(".cancel-button").addEventListener("click",c.bind(this))}})(r=c.TaskDlg||(c.TaskDlg={}))});
define("main-task",["require","exports","TaskDialogWidget","ModelStorageProviderFactory","LoadingGif"],function(m,c,k,l,d){d.Show(document.body);l.Init();window.TaskDialog={dialog:null,trimbleConnect:l.Providers[l.ProviderKey.Trimble_Connect],show:function(c){d.Hide(document.body);this.dialog=new k.TaskDialogWidget(document.body,new g);this.dialog.open(c)},setTaskImage:function(c){this.dialog.setLocalTaskImage(c)},setTaskView:function(c){this.dialog.setTaskView(c)},renderReferencesView:function(c){this.dialog.renderReferencesViewCallback(c)},
renderAlignmentView:function(c,b,d){this.dialog.loadAlignment(c,b,d)},updateProgress:function(c,b){this.dialog.updateProgress(c,b)},updateReferenceStatus:function(c){this.dialog.updateReferenceStatus(c)},publishAlignment:function(c,b){this.dialog.publishAlignment(c,b)}};var g=function(){function c(){}c.prototype.openTrimbleConnect=function(){window.sketchup.open_trimble_connect()};c.prototype.renderReferencesView=function(){this.getBaseAlignment().then(function(b){window.sketchup.render_references_view(JSON.stringify(b))})};
c.prototype.addReference=function(){this.getBaseAlignment().then(function(b){window.sketchup.add_reference(JSON.stringify(b))})};c.prototype.deleteReference=function(b){this.getBaseAlignment().then(function(c){window.sketchup.delete_reference(b,JSON.stringify(c))})};c.prototype.selectReference=function(b){window.sketchup.select_reference(b)};c.prototype.updateReference=function(b){var c=window.TaskDialog.dialog.currentRegionLocation,d={token:window.TaskDialog.trimbleConnect.token,baseURL:window.TaskDialog.trimbleConnect.baseURL(c),
fileId:b.id,versionId:b.versionId,fileName:b.name,thumbnailURL:b.thumbnailUrl[0],createdOn:b.createdOn,modifiedOn:b.modifiedOn,size:b.size,projectId:b.projectId,parentId:b.parentId,location:c,remoteIdPath:null,alignment:b.alignment};this.getBaseAlignment().then(function(a){window.sketchup.update_reference(JSON.stringify(d),JSON.stringify(a))})};c.prototype.editAlignment=function(b){this.getBaseAlignment().then(function(c){window.sketchup.edit_alignment(b,JSON.stringify(c))})};c.prototype.launchAlignmentTool=
function(b){this.getAlignment(b).then(function(c){window.sketchup.launch_alignment_tool(b,JSON.stringify(c))})};c.prototype.positionReference=function(b,c){window.sketchup.position_reference(b,JSON.stringify(c))};c.prototype.revertAlignment=function(b){var c,d;b=this.getAlignment(b);var a=this.getBaseAlignment();return goog.Promise.all([b,a]).then(function(a){c=a[0];d=a[1];window.sketchup.revert_alignment(JSON.stringify(c),JSON.stringify(d))})};c.prototype.publishAlignment=function(b){this.getBaseAlignment().then(function(c){window.sketchup.publish_alignment(b,
JSON.stringify(c))})};c.prototype.captureView=function(b){window.sketchup.capture_view(JSON.stringify(b))};c.prototype.setView=function(b,c){var d=JSON.stringify(b),a=JSON.stringify(c);window.sketchup.set_view(d,a)};c.prototype.getBaseAlignment=function(){return this.getAlignment(window.TaskDialog.dialog.currentModelId)};c.prototype.getAlignment=function(b){return window.TaskDialog.trimbleConnect.getAlignment(window.TaskDialog.dialog.currentRegionLocation,b)};return c}();window.sketchup.ready()});
define("ViewerWidget",["require","exports","ModelStorageProviderFactory"],function(m,c,k){m=function(){function c(d){this.parent_=d;this.trimbleConnect_=k.Providers[k.ProviderKey.Trimble_Connect]}c.prototype.open=function(c){var g=this,h=this.trimbleConnect_.initialize(c),b=this.trimbleConnect_.baseURL("northAmerica");h.then(function(){var e=goog.dom.getElementByClass("trimble-connect-viewer");c.domNode=e;c.gteamOrigin=encodeURIComponent(b);c.accessToken=g.trimbleConnect_.token;new EmbeddedViewer(c)})};
return c}();c.ViewerWidget=m});define("main-viewer",["require","exports","ViewerWidget","ModelStorageProviderFactory"],function(m,c,k,l){l.Init();window.ViewerDialog={dialog:null,trimbleConnect:l.Providers[l.ProviderKey.Trimble_Connect],show:function(c){console.log(c);this.viewDialog=new k.ViewerWidget(document.body);this.viewDialog.open(c)}};window.sketchup.ready()});
define("main","require exports OpenDialogWidget FileManager ModelStorageProviderFactory FileUtils".split(" "),function(m,c,k,l,d,g){var h=function(){function b(){}b.prototype.openFile=function(b){window.TCE.fileDialog.disableOpenButton();this.setupDownloadRequest(b).then(function(b){window.TCE.fileDialog.setupDownloadProgressDialog();window.sketchup.download_file(JSON.stringify(b))}).thenAlways(function(){window.TCE.fileDialog.enableOpenButton()})};b.prototype.deleteFile=function(b){window.TCE.fileDialog.getFolderAncestorListNoCache(window.TCE.fileDialog.currentFolderId,
window.TCE.fileDialog.currentRegionLocation).then(function(c){c=l.FileManager.getInstance().makeFolderIdPathFromAncestorList(c);c=goog.string.path.join(c,b.remoteId);window.sketchup.delete_file(c,JSON.stringify(b))})};b.prototype.importReferenceFile=function(b){window.TCE.fileDialog.disableOpenButton();this.setupDownloadRequest(b).then(function(b){window.TCE.fileDialog.setupImportProgressDialog();window.sketchup.import_file(JSON.stringify(b))}).thenAlways(function(){window.TCE.fileDialog.enableOpenButton()})};
b.prototype.publishFile=function(b,c){window.TCE.fileDialog.disablePublishButton();c=g.getValidSKPName(c);var a=window.TCE.fileDialog.currentRegionLocation,d=window.TCE.fileDialog.currentProjectId,h=window.TCE.fileDialog.currentModelId,k=null,n=null,m;m=goog.isDefAndNotNull(h)?window.TCE.trimbleConnect.getFileDetails(a,h):goog.Promise.resolve(null);var u;u=window.TCE.fileDialog.getFolderAncestorListNoCache(b,a);m.then(function(a){a&&(k=a.versionId,n=a.name);return u}).thenCatch(function(a){return u}).then(function(g){g=
l.FileManager.getInstance().makeFolderIdPathFromAncestorList(g);g={token:window.TCE.trimbleConnect.token,baseURL:window.TCE.trimbleConnect.baseURL(a),fileName:c,projectId:d,parentId:b,location:a,remoteIdPath:g,versionId:k,fileId:h,remoteFileName:n};window.sketchup.publish_file(JSON.stringify(g))}).thenAlways(function(){window.TCE.fileDialog.enablePublishButton()})};b.prototype.setupDownloadRequest=function(b){var c=window.TCE.fileDialog.currentRegionLocation,a=window.TCE.fileDialog.currentProjectId,
d=window.TCE.fileDialog.currentFolderId,g=(new Date(b.createdOn)).toUTCString(),h=(new Date(b.modifiedOn)).toUTCString(),k;k=window.TCE.fileDialog.getFolderAncestorListNoCache(d,c);var m,u;m=window.TCE.trimbleConnect.getAlignment(c,b.remoteId);u=window.TCE.fileDialog.currentModelId;u=goog.isDefAndNotNull(u)?window.TCE.trimbleConnect.getAlignment(c,u):goog.Promise.resolve(null);var v,w,x;return goog.Promise.all([m,u,k]).then(function(k){v=k[0];w=k[1];console.log(v);console.log(w);x=k[2];k=l.FileManager.getInstance().makeFolderIdPathFromAncestorList(x);
return{token:window.TCE.trimbleConnect.token,baseURL:window.TCE.trimbleConnect.baseURL(c),fileId:b.remoteId,versionId:b.remoteVersionId,fileName:b.name,thumbnailURL:b.thumbnailURL,createdOn:g,modifiedOn:h,size:1024*b.sizeInKB,projectId:a,parentId:d,location:c,remoteIdPath:k,alignment:v,baseAlignment:w}})};b.prototype.cancelFileTransfer=function(){window.sketchup.cancel_file_transfer()};return b}();d.Init();window.TCE={fileDialog:null,trimbleConnect:d.Providers[d.ProviderKey.Trimble_Connect],showFileDialog:function(b){this.fileDialog=
new k.OpenDialogWidget(document.body,new h);this.fileDialog.open(b)},deleteItem:function(b){b=JSON.parse(b);this.fileDialog.doDeleteFileItem(b)},updateProgressDialog:function(b){this.fileDialog.updateProgressDialog(b)},error:function(b){this.fileDialog.processFileTransferError(b)}};window.sketchup.ready()});
