// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/4.0beta2/esri/copyright.txt for details.
//>>built
define("./PortalComment ./PortalRating dojo/_base/array ../core/declare dojo/_base/lang require".split(" "),function(f,g,c,k,e,h){return k([],{declaredClass:"esri.arcgis.PortalItem",portal:null,constructor:function(a){e.mixin(this,a);this.folderId=this.ownerFolder||this.folderId;this.itemUrl=(this.portal&&this.portal.portalUrl)+"content/items/"+this.id;this.userItemUrl=this.hasOwnProperty("ownerFolder")?this.itemUrl.replace("content","content/users/"+this.owner+(this.folderId?"/"+this.folderId:"")):
null;this.itemDataUrl=this.portal.portalUtil.formatUrl(this.itemUrl+"/data");this.thumbnailUrl=this.portal.portalUtil.formatUrl(this.itemUrl+"/info/"+this.thumbnail);this.displayName=this._getDisplayName();this.iconUrl=this._getIconUrl();this.isPremiumContent=this._getIsPremiumContent();this.created=this.created?new Date(this.created):null;this.uploaded=this.uploaded?new Date(this.uploaded):null;this.modified=this.modified?new Date(this.modified):null},getTypeInfo:function(){var a=this.type;return{source:-1<
c.indexOf(this.typeKeywords||[],"ArcGIS Server")||"Feature Collection"===a?a:null,displayName:this.displayName,iconUrl:this.iconUrl,isPremiumContent:this.isPremiumContent,premiumIconUrl:this._getPremiumIconUrl()}},addComment:function(a){var b=e.isString(a)?{comment:a}:a;return this.portal.portalUtil.request(this.itemUrl+"/addComment",b,{usePost:!0}).then(e.hitch(this,function(a){return new f(e.mixin(b,{id:a.commentId,item:this}))}))},updateComment:function(a){if(a&&a.url&&a.comment)return this.portal.portalUtil.request(a.url+
"/update",{comment:a.comment},{usePost:!0}).then(function(b){a.id=b.commentId;return a});throw Error();},getComments:function(){return this.portal.portalUtil.requestToTypedArray(this.itemUrl+"/comments",null,null,f,{item:this})},deleteComment:function(a){if(a&&a.url)return this.portal.portalUtil.request(a.url+"/delete",null,{usePost:!0});throw Error();},addRating:function(a){var b=e.isObject(a)?a:{rating:parseFloat(a)};return this.portal.portalUtil.request(this.itemUrl+"/addRating",b,{usePost:!0}).then(e.hitch(this,
function(a){return new g(e.mixin(b,{id:a.ratingId,item:this}))}))},getRating:function(){return this.portal.portalUtil.request(this.itemUrl+"/rating").then(e.hitch(this,function(a){return new g(e.mixin(a,{item:this}))}))},deleteRating:function(){return this.portal.portalUtil.request(this.itemUrl+"/deleteRating",null,{usePost:!0})},_getDisplayName:function(){var a=this.type,b=this.typeKeywords||[],d=a;"Feature Service"===a||"Feature Collection"===a?d=-1<c.indexOf(b,"Table")?"Table":"Feature Layer":
"Image Service"===a?d=-1<c.indexOf(b,"Elevation 3D Layer")?"Elevation Layer":"Imagery Layer":"Scene Service"===a?d="Scene Layer":"Stream Service"===a?d="Feature Layer":"Microsoft Powerpoint"===a?d="Microsoft PowerPoint":"GeoJson"===a?this.type=d="GeoJSON":"Globe Service"===a?d="Globe Layer":"Map Service"===a&&(d=-1<c.indexOf(b,"Hosted Service")||-1<c.indexOf(b,"Tiled")?"Tile Layer":"Map Image Layer");return d},_getIconUrl:function(){var a=this.type&&this.type.toLowerCase()||"",b=this.typeKeywords||
[],d=!1,e=!1;0<a.indexOf("service")||"feature collection"===a||"kml"===a||"wms"===a||"wmts"===a?(d=-1<c.indexOf(b,"Hosted Service"),a="feature service"===a||"feature collection"===a||"kml"===a?(e=-1<c.indexOf(b,"Table"))?"table":d?"featureshosted":"features":"map service"===a||"wms"===a||"wmts"===a?d||-1<c.indexOf(b,"Tiled")?"maptiles":"mapimages":"scene service"===a?"sceneweblayer":"image service"===a?-1<c.indexOf(b,"Elevation 3D Layer")?"elevationlayer":"imagery":"stream service"===a?"streamlayer":
"layers"):"web map"===a||"cityengine web scene"===a?a="maps":"web scene"===a?(a="webscene",-1<c.indexOf(b,"ViewingMode-Local")||(a+="global")):a="web mapping application"===a||"mobile application"===a||"application"===a||"operation view"===a||"desktop application"===a?"apps":"map document"===a||"map package"===a||"published map"===a||"scene document"===a||"globe document"===a||"basemap package"===a||"mobile basemap package"===a||"mobile map package"===a||"project package"===a||"project template"===
a||"pro map"===a||"layout"===a||"layer"===a&&-1<c.indexOf(b,"ArcGIS Pro")||"explorer map"===a&&c.indexOf(b,"Explorer Document")?"mapsgray":"service definition"===a||"csv"===a||"shapefile"===a||"cad drawing"===a||"geojson"===a?"datafiles":"explorer add in"===a||"desktop add in"===a||"windows viewer add in"===a||"windows viewer configuration"===a?"appsgray":"rule package"===a||"file geodatabase"===a||"csv collection"===a||"kml collection"===a||"windows mobile package"===a||"map template"===a||"desktop application template"===
a||"arcpad package"===a||"code sample"===a||"document link"===a||"tile package"===a||"scene package"===a||"operations dashboard add in"===a||"rules package"===a||"image"===a||"workflow manager package"===a||"desktop style"===a||"explorer map"===a&&-1<c.indexOf(b,"Explorer Mapping Application")||-1<c.indexOf(b,"Document")?"datafilesgray":"geocoding service"===a||"network analysis service"===a||"geoprocessing service"===a||"geodata service"===a||"geometry service"===a||"geoprocessing package"===a||
"locator package"===a||"geoprocessing sample"===a||"workflow manager service"===a||"raster function template"===a?"toolsgray":"layer"===a||"layer package"===a||"explorer layer"===a?"layersgray":"task file"===a?"taskfile":"maps";return a?h.toUrl("../css/images/item_type_icons/"+a+"16.png"):null},_getIsPremiumContent:function(){var a=this.typeKeywords,b=!1;if(-1<c.indexOf(a,"Service")&&(-1<c.indexOf(a,"Requires Subscription")||-1<c.indexOf(this.typeKeywords,"Requires Credits")))b=!0;return b},_getPremiumIconUrl:function(){var a=
this.typeKeywords,b;this.isPremiumContent&&(b=-1<c.indexOf(a,"Requires Credits")?"premiumcredits":"premiumitem");return b?h.toUrl("../css/images/item_type_icons/"+b+"16.png"):null}})});