1import{A as o}from"./ArmadaIcon-htdeOLJg.js";import{b as n,c as i,d as l}from"./emits-DS_YPhAT.js";import{i as r}from"./app-BWJCW4UM.js";import{s as a}from"./spotify-BdCSwpxb.js";import{n as f}from"./_plugin-vue2_normalizer-ChkZV5ho.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"armada_541"}}catch(e){}})();try{(function(){var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="1b8d235a-77b3-42cf-a014-cb6c841ca788",t._sentryDebugIdIdentifier="sentry-dbid-1b8d235a-77b3-42cf-a014-cb6c841ca788")})()}catch(t){}const u={name:"SpotifyButton",components:{ArmadaIcon:o},props:{label:{type:String,default:""},url:{type:String,default:""}},data:function(){return{isFollowSuccess:!1,isRequesting:!1,spotifyService:a(this.$store)}},computed:{iconName:function(){return this.isFollowSuccess?"checkmark":"spotify"},shouldOpenInNewTab:function(){return this.url?r(this.url):!1}},methods:{click:function(t){if(this.isFollowUrl(this.url)){if(t.preventDefault(),!this.spotifyService.isLoggedIn()){this.loginToSpotify();return}this.makeFollowRequest()}},getIdFromSpotifyUrl:function(t){const e=t.includes("?")?t.substr(0,t.lastIndexOf("?")):t;return e.substr(e.lastIndexOf("/")+1)},isSpotifyUrl:function(t){return t.includes("//open.spotify.com")},isFollowArtistUrl:function(t){return!!(this.isSpotifyUrl(t)&&t.includes("/artist/"))},isFollowPlaylistUrl:function(t){return!!(this.isSpotifyUrl(t)&&t.includes("/playlist/"))},isFollowUserUrl:function(t){return!!(this.isSpotifyUrl(t)&&t.includes("/user/"))},isFollowUrl:function(t){return!!(this.isFollowArtistUrl(t)||this.isFollowPlaylistUrl(t)||this.isFollowUserUrl(t))},loginToSpotify:function(){this.$root.eventBus.$emit(n),this.$root.eventBus.$on(i,this.makeFollowRequest),this.$root.eventBus.$on(l,()=>{this.$root.eventBus.$off(i,this.makeFollowRequest)})},makeFollowRequest:async function(){this.isRequesting=!0;const t=this.getCorrespondingSpotifyRequestFunction();t||(this.isRequesting=!1);try{const e=this.getIdFromSpotifyUrl(this.url);await t(e),this.isRequesting=!1,this.isFollowSuccess=!0}catch(e){this.isRequesting=!1}},getCorrespondingSpotifyRequestFunction:function(){if(this.isFollowArtistUrl(this.url)||this.isFollowUserUrl())return this.spotifyService.followArtist;if(this.isFollowPlaylistUrl(this.url))return this.spotifyService.followPlaylist}}};var c=function(){var e=this,s=e._self._c;return s("a",{class:"btn btn--spotify btn--wide-sm ".concat(e.isRequesting?"btn--disabled":""),attrs:{href:e.url,rel:e.shouldOpenInNewTab?"noreferrer":null,target:e.shouldOpenInNewTab?"_blank":null},on:{click:e.click}},[e._v(" "+e._s(e.label)+" "),s("armada-icon",{attrs:{name:e.iconName,size:24}})],1)},d=[],p=f(u,c,d,!1,null,null);const b=p.exports;export{b as default}; 2//# sourceMappingURL=SpotifyButton-CUuQp-QW.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.