// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/AddData/search/templates/ItemCard.html":'\x3cdiv class\x3d"item-card"\x3e\r\n  \x3cdiv class\x3d"item-card-inner"\x3e\r\n    \x3cdiv class\x3d"thumbnail" data-dojo-attach-point\x3d"thumbnailNode"\x3e\x3c/div\x3e\r\n    \x3ch3 class\x3d"title" data-dojo-attach-point\x3d"titleNode"\x3e\x3c/h3\x3e\r\n    \x3cdiv class\x3d"info" data-dojo-attach-point\x3d"typeByOwnerNode"\x3e\x3c/div\x3e\r\n    \x3cdiv class\x3d"info" data-dojo-attach-point\x3d"dateNode"\x3e\x3c/div\x3e\r\n    \x3cdiv class\x3d"action-bar"\x3e\r\n      \x3cspan class\x3d"message" data-dojo-attach-point\x3d"messageNode"\x3e\x3c/span\x3e\r\n      \x3ca href\x3d"javascript:void(0)"\r\n        data-dojo-attach-point\x3d"addButton"\r\n        data-dojo-attach-event\x3d"onClick: addClicked"\r\n        \x3e${i18n.search.item.actions.add}\r\n      \x3c/a\x3e\r\n      \x3ca href\x3d"javascript:void(0)"\r\n        data-dojo-attach-point\x3d"detailsButton"\r\n        data-dojo-attach-event\x3d"onClick: detailsClicked"\r\n        \x3e${i18n.search.item.actions.details}\r\n      \x3c/a\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e\r\n'}});
define("dojo/_base/declare dojo/_base/array dojo/date/locale dojo/dom-class dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dojo/text!./templates/ItemCard.html dojo/i18n!../nls/strings ./util ./LayerLoader".split(" "),function(h,k,l,f,m,n,p,q,d,c,r){return h([m,n,p],{i18n:d,templateString:q,canRemove:!1,item:null,resultsPane:null,_dfd:null,postCreate:function(){this.inherited(arguments)},startup:function(){this._started||(this.inherited(arguments),this.render())},addClicked:function(){var a=
this,b=this.addButton;if(!f.contains(b,"disabled"))if(f.add(b,"disabled"),this.canRemove){var g=this.resultsPane.getMap();c.setNodeText(a.messageNode,d.search.item.messages.removing);var t=c.findLayersAdded(g,this.item.id).layers;k.forEach(t,function(e){g.removeLayer(e)});this.canRemove=!1;c.setNodeText(a.messageNode,"");c.setNodeText(this.addButton,d.search.item.actions.add);f.remove(b,"disabled")}else c.setNodeText(a.messageNode,d.search.item.messages.adding),(new r).addItem(this.item,this.resultsPane.getMap()).then(function(e){e?
(a.canRemove=!0,c.setNodeText(a.messageNode,""),c.setNodeText(a.addButton,d.search.item.actions.remove)):c.setNodeText(a.messageNode,d.search.item.messages.addFailed);f.remove(b,"disabled")}).otherwise(function(e){console.warn("Add layer failed.");console.warn(e);c.setNodeText(a.messageNode,d.search.item.messages.addFailed);f.remove(b,"disabled");e&&"string"===typeof e.message&&0<e.message.length&&console.log("")})},detailsClicked:function(){var a=this.item;a=c.checkMixedContent(a.portalUrl)+"/home/item.html?id\x3d"+
encodeURIComponent(a.id);window.open(a)},formatDate:function(a){"number"===typeof a&&(a=new Date(a));return l.format(a,{selector:"date",datePattern:d.search.item.dateFormat})},render:function(){c.setNodeText(this.titleNode,this.item.title);c.setNodeTitle(this.titleNode,this.item.title);this._renderThumbnail();this._renderTypeOwnerDate();this.canRemove&&c.setNodeText(this.addButton,d.search.item.actions.remove)},_renderThumbnail:function(){var a=this.thumbnailNode,b=this.item.thumbnailUrl;a.innerHTML=
"";b=c.checkMixedContent(b);var g=document.createElement("IMG");g.src=b||"widgets/AddData/images/placeholder_120x80.png";a.appendChild(g)},_renderTypeOwnerDate:function(){var a=this.item;var b=d.search.item.types[a.type];if("undefined"===typeof b||null===b)b=a.type;b=d.search.item.typeByOwnerPattern.replace("{type}",b);b=b.replace("{owner}",a.owner);c.setNodeText(this.typeByOwnerNode,b)}})});