text: (function(){"use strict";BX.namespace("BX.Landing.UI.Card");var t=BX.Landing.Utils.getFileExtension;function e(t){return BX.util.add_url_param(t,{utm_source:"bitrix",utm_medium:"referral",utm_campaign:"api-credit"})}function i(t,i){return{image:t.urls.small,credit:{name:t.user.name,link:e(t.user.links.html)},onClick:i.onPictureChange.bind(i,t)}}function n(t,e){return t.map(function(t){return i(t,e)})}BX.Landing.UI.Card.Unsplash=function(t){BX.Landing.UI.Card.Library.apply(this,arguments);this.state="popular";this.page=1;this.query="";this.onSearchWithDebounce=BX.debounce(this.onSearchWithDebounce,1e3,this);this.showPopular()};BX.Landing.UI.Card.Unsplash.prototype={constructor:BX.Landing.UI.Card.Unsplash,__proto__:BX.Landing.UI.Card.Library.prototype,onLoadMore:function(){if(this.state==="popular"){this.appendPopular()}if(this.state==="search"){this.appendSearch()}},appendSearch:function(){this.state="search";this.page+=1;this.showBottomLoader();this.hideLoadMore();var t=BX.Landing.Client.Unsplash.getInstance();t.search(this.query,this.page).then(function(t){this.hideBottomLoader();this.showLoadMore();this.renderItems(n(t,this))}.bind(this))},appendPopular:function(){this.state="popular";this.page+=1;this.query="";var t=BX.Landing.Client.Unsplash.getInstance();var e=this;this.showBottomLoader();this.hideLoadMore();t.popular(this.page).then(function(t){e.hideBottomLoader();e.showLoadMore();e.renderItems(n(t,e))})},onSearchInput:function(t){var e=t.getValue();if(!!e&&e.length){this.state="search";this.query=e;this.page=1;this.showLoader();this.onSearchWithDebounce(e);this.hideEmptyResult();return}if(this.state!=="popular"){this.showPopular()}},onSearchWithDebounce:function(t){var e=BX.Landing.Client.Unsplash.getInstance();e.search(t).then(function(t){this.hideLoader();this.clearItems();if(t.length===0){this.hideLoadMore();this.showEmptyResult();return}this.renderItems(n(t,this))}.bind(this))},showPopular:function(){this.state="popular";this.page=1;this.query="";var t=BX.Landing.Client.Unsplash.getInstance();this.showLoader();this.hideEmptyResult();t.popular().then(function(t){this.hideLoader();this.clearItems();if(t.length===0){this.hideLoadMore();this.showEmptyResult();return}this.showLoadMore();this.renderItems(n(t,this))}.bind(this))},onPictureChange:function(e){BX.Landing.Client.Unsplash.getInstance().download(e).then(function(e){this.onChange({link:e,ext:t(e)})}.bind(this))}}})();