var __awaiter=this&&this.__awaiter||function(t,e,i,r){return new(i||(i=Promise))(function(n,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r["throw"](t))}catch(t){s(t)}}function a(t){t.done?n(t.value):new i(function(e){e(t.value)}).then(o,u)}a((r=r.apply(t,e||[])).next())})};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,n,s,o;return o={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(t){return function(e){return a([t,e])}}function a(o){if(r)throw new TypeError("Generator is already executing.");while(i)try{if(r=1,n&&(s=o[0]&2?n["return"]:o[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;if(n=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:i.label++;return{value:o[1],done:false};case 5:i.label++;n=o[1];o=[0];continue;case 7:o=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){i=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(o[0]===6&&i.label<s[1]){i.label=s[1];s=o;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(o);break}if(s[2])i.ops.pop();i.trys.pop();continue}o=e.call(t,i)}catch(t){o=[6,t];n=0}finally{r=s=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};System.register(["./p-b236363f.system.js"],function(t){"use strict";var e,i,r,n,s;return{setters:[function(t){e=t.r;i=t.e;r=t.c;n=t.h;s=t.d}],execute:function(){var o=function(){function t(t){e(this,t);this.count=0;this.liked=false;this.attribute="_likes";this.disabled=false;this.iconNo="star-outline";this.iconYes="star";this.method="POST";this.glLike=i(this,"glLike",7);this.likeCtrl=r(this,"gl-like-controller");this.restCtrl=r(this,"gl-rest-controller")}t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.setState()];case 1:t.sent();return[2]}})})};t.prototype.setState=function(){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:if(!this.feature)return[3,2];this.count=this.feature.properties[this.attribute];t=this;return[4,this.likeCtrl.create(this.feature)];case 1:t.proxy=e.sent();this.liked=this.proxy.isLiked();e.label=2;case 2:return[2]}})})};t.prototype.toggle=function(){return __awaiter(this,void 0,void 0,function(){var t,e,i;return __generator(this,function(r){switch(r.label){case 0:this.liked=!this.liked;this.count+=this.liked?1:-1;if(this.feature&&this.feature.properties)this.feature.properties[this.attribute]=this.count;this.liked?this.proxy.like():this.proxy.unlike();t=false;e=this.proxy.getClientId();r.label=1;case 1:r.trys.push([1,3,,4]);return[4,this.restCtrl.create({type:"Feature",properties:{action:this.liked?"like":"unlike",feature_id:this.feature.id,client_id:e}},{url:this.url,token:this.token,method:this.method,mode:this.requestMode})];case 2:r.sent();t=true;return[3,4];case 3:i=r.sent();return[3,4];case 4:this.glLike.emit({success:t,feature:this.feature,action:this.liked?"like":"unlike",client_id:e});return[2]}})})};t.prototype.render=function(){var t=this;return n("ion-button",{fill:"clear",onClick:function(){if(!t.disabled)t.toggle()},disabled:this.disabled},n("ion-icon",{slot:"start",name:this.liked?this.iconYes:this.iconNo}),n("span",{class:"gl-like-button-count"},this.count))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:true,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{feature:["setState"]}},enumerable:true,configurable:true});return t}();t("gl_like_button",o)}}});