1import{r as a,h as e,a as i}from"./p-BfiO-GnF.js";import{A as o,a as t,i as s,O as n,y as d,H as l}from"./p-DQw3aa6Y.js";import{U as c}from"./p-DJsGqBIS.js";import"./p-vpVk1EJj.js";import"./p-AuPLCHfl.js";import"./p-E-ZsRS8r.js";var b;!function(a){a.SEARCH="search",a.GET="filterByTeam"}(b||(b={}));const r=class{constructor(e){a(this,e),this.playerAdded=!1,this.selectedTab=b.SEARCH,this.user=o.currentUser,this.minAge=0,this.showPlaySiteText=!0}async cancel(){await this.el.closest("ion-modal").dismiss()}async submit(a){await this.el.closest("ion-modal").dismiss({newPlayer:a})}async openPurchaseModal(a){await c.openPurchaseModal({},a,"FAVORITE_PERSON")}async addPlayerToAccount(a){var e,i,c,b,r;if(null===(e=this.playerList)||void 0===e?void 0:e.some((e=>e.personId===a.id)))return await t.presentErrorToast({message:s("FAVORITE_PERSON_PAGE.PLAYER_ALREADY_FOLLOWED")});{const e="BACKOFFICE"===(null===(i=o.siteConfig)||void 0===i?void 0:i.siteId)?o.backofficeContext.currentSite:o.siteConfig.siteId,f={type:d.PERSON,image:(null===(c=null==a?void 0:a.group)||void 0===c?void 0:c.logo)||(null==a?void 0:a.image),siteId:e,userId:this.user.id,personId:a.id,firstName:a.firstName,lastName:a.lastName,num:(null===(b=null==a?void 0:a.lineupAttributes)||void 0===b?void 0:b[0].num)||(null==a?void 0:a.num),playerLevelName:(null===(r=a.lineupAttributes)||void 0===r?void 0:r[0].playerLevelName)||null,groupId:a.group.id||null};try{const a=await n.createUserFavorite(f);if("PRODUCT_REQUIRED"===(null==a?void 0:a.errorCode)){let i=[];a.productIds.length>0&&(i=await l.getProducts({siteId:e,id:a.productIds})),await this.openPurchaseModal(i)}else await this.submit(a),await t.presentSuccessToast({message:s("FAVORITE_PERSON_PAGE.PLAYER_ADDED")}),this.playerAdded=!0}catch(a){return await t.presentErrorToast({message:s("ERROR_PAGE.GENERIC_ERROR")})}}}handleTabChange(a){this.selectedTab=a.detail.value}render(){return[e("ion-header",{key:"885bf41842aa7c23a82d31794cb686077c01d236"},e("ion-toolbar",{key:"185ecf383f0c96a035e9641037a16d532fa0a8d3",color:"primary"},e("ion-icon",{key:"e196f3809e404d5177322b2cafb8798d750fb1c3",class:"ion-margin-start",size:"large",slot:"start",icon:"people-circle-outline"}),e("ion-title",{key:"9105da4724c222b852611a7fa87e779b3793b7a8",style:{fontWeight:"bolder"}},s("FAVORITE_PERSON_PAGE.FOLLOW_PLAYER")),e("ion-buttons",{key:"27a3ad20a0a1d2279b2ba025d480b86913614b66",slot:"end"},e("ion-button",{key:"d6d6ed1e451127d7e62e171c5b2e3cee7d043b45",onClick:()=>this.cancel()},e("ion-icon",{key:"12e4a6a05b01c8a067d34cf8a43d9c1ae60b18fd",slot:"icon-only",name:"close"}))))),e("ion-content",{key:"00a2db3d3a2a1007e83436bd2a49848fe0c102ab"},e("ion-item",{key:"8753cf960cc4951bd9da231b4e6c16593a9ab1e8",class:"ion-padding-bottom-xs"},e("ion-icon",{key:"fbe0fece87ecb9f2279aabba691e60922c6a8db6",slot:"start",name:"information-circle-outline"}),e("ion-label",{key:"11d5631c8b9d14460e18b7592d07fb3aaaebb0bf"},s("FAVORITE_PERSON_PAGE.SEARCH_NAME_OR_FILTER"))),e("ion-segment",{key:"c262e5e8bb6beda33f1d9cd3643fc79ce9e9dd1f",value:this.selectedTab,onIonChange:a=>this.handleTabChange(a)},e("ion-segment-button",{key:"a67306f6499b4c126f7f218daab6d88abd7ed9e2",value:b.SEARCH},e("ion-label",{key:"0941231b6fe28f18143a8f8260809029c53cf0a4"},s("FAVORITE_PERSON_PAGE.SEARCH_FOR_PLAYER"))),e("ion-segment-button",{key:"d8f4b7e6edcb4aa2a47de45159ed0932eac2425c",value:b.GET},e("ion-label",{key:"a83d1de7fd30af254a922e56f408dee6d5f7abf6"},s("FAVORITE_PERSON_PAGE.FILTER_BY_TEAM")))),this.selectedTab===b.SEARCH&&e("app-search-player",{key:"8ed9513afc19d52f430ec940180568216ddfb950",minAge:this.minAge,onPlayerFormComplete:a=>this.addPlayerToAccount(a.detail),autoFocus:!0}),this.selectedTab===b.GET&&e("app-get-player",{key:"1d2a1e5b6e55af882087baf40ca9fb4837c1b266",minAge:this.minAge,autoFocus:!0,onPlayerFormComplete:a=>this.addPlayerToAccount(a.detail)})),e("app-modal-footer",{key:"40c2a97d90053bf59ff0a530a2018d36ec02e9a4",showCancel:!1,showSave:!1,disableSaveBtn:!this.playerAdded})]}get el(){return i(this)}};export{r as app_follow_player_modal}
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.