1import{Ec as h,O as r,S as p,X as d,a as u,ic as n,na as s}from"./chunk-TRZM4QZA.js";var l="benchmap.token",i="benchmap.user";function w(o){return o.display_name&&o.display_name.trim()||o.username}var b=class o{http=d(h);user=s(this.loadUser());isAdmin=n(()=>this.user()?.role_name==="admin");contributablePoiTypes=n(()=>this.user()?.poi_types??[]);canContributePois=n(()=>this.isAdmin()||this.contributablePoiTypes().length>0);showPoiFab=n(()=>this.user()?.show_poi_fab===!0&&this.user()?.capture_fab_enabled!==!1);showNrtTrailFab=n(()=>this.user()?.show_nrt_trail_fab===!0&&this.user()?.capture_fab_enabled!==!1);hasCaptureFabAccess=n(()=>this.user()?.show_poi_fab===!0||this.user()?.nrt_capture_fab_access===!0);showNrtReports=n(()=>this.user()?.nrt_capture_fab_access===!0&&this.user()?.capture_fab_enabled!==!1);isNrtMember=n(()=>this.user()?.organizations?.some(e=>e.slug==="naturpark-rhein-taunus")??!1);canManageOsmTrailNodeImages=n(()=>this.isAdmin()||this.isNrtMember());loginModal=s(!1);registerModal=s(!1);forgotPasswordModal=s(!1);uploadModal=s(null);poiUploadModal=s(null);editModal=s(null);trailReportModal=s(null);trailNodeImageModal=s(null);get token(){return localStorage.getItem(l)}setToken(e){localStorage.setItem(l,e)}isAuthenticated(){return this.token!==null}menuFlags(){return this.http.get("/api/auth/menu").pipe(r(e=>{this.stewardedGroupIds.set(e.stewarded_group_ids??[]),this.hasStewardedReports.set(!!e.stewarded_reports)}))}stewardedGroupIds=s([]);hasStewardedReports=s(!1);isStewardOfGroup(e){return e==null?!1:this.stewardedGroupIds().includes(e)}changePassword(e,t){return this.http.post("/api/auth/password",{current_password:e,new_password:t}).pipe(r(a=>{a?.token&&this.setToken(a.token)}))}login(e,t){return this.http.post("/api/auth/login",{username:e,password:t}).pipe(r(a=>this.storeIfFinal(a)))}register(e){return this.http.post("/api/auth/register",e)}verifyEmail(e){return this.http.post("/api/auth/verify-email",{token:e})}resendVerification(e){return this.http.post("/api/auth/resend-verification",{email:e})}forgotPassword(e){return this.http.post("/api/auth/forgot-password",{email:e})}resetPassword(e,t){return this.http.post("/api/auth/reset-password",{token:e,new_password:t})}setEmail(e){return this.http.post("/api/auth/email",{email:e}).pipe(r(t=>this.patchUser({email:t.email,email_verified:t.email_verified})))}setDisplayName(e){return this.http.post("/api/auth/display-name",{display_name:e}).pipe(r(t=>this.patchUser({display_name:t.display_name,contributor_name:t.contributor_name})))}verifyTwoFactor(e,t){return this.http.post("/api/auth/verify-2fa",{temp_token:e,code:t}).pipe(r(a=>this.storeIfFinal(a)))}logoutEverywhere(){return this.http.post("/api/auth/logout-all",{}).pipe(r(e=>{e?.token&&this.setToken(e.token)}))}mcpTokens(){return this.http.get("/api/auth/mcp-tokens")}createMcpToken(e){return this.http.post("/api/auth/mcp-tokens",{name:e})}deleteMcpToken(e){return this.http.delete(`/api/auth/mcp-tokens/${e}`)}me(){return this.http.get("/api/auth/me")}levelCheck(){return this.http.post("/api/auth/level-check",{})}achievements(){return this.http.get("/api/auth/achievements")}refreshUser(e){localStorage.setItem(i,JSON.stringify(e)),this.user.set(e)}syncUser(){this.isAuthenticated()&&this.me().subscribe({next:e=>this.refreshUser(e)})}uploadAvatar(e,t){let a=new FormData;return a.set("avatar",e,t),this.http.post("/api/auth/avatar",a).pipe(r(g=>this.patchUser({avatar:g.avatar})))}removeAvatar(){return this.http.delete("/api/auth/avatar").pipe(r(()=>this.patchUser({avatar:null})))}setDefaultGemarkung(e){return this.http.post("/api/auth/default-gemarkung",{gemarkung_id:e}).pipe(r(()=>this.patchUser({default_gemarkung_id:e})))}setRelocateMode(e){return this.http.post("/api/auth/relocate-mode",{mode:e}).pipe(r(()=>this.patchUser({relocate_mode:e})))}setMapStartMode(e){return this.http.post("/api/auth/map-start-mode",{mode:e}).pipe(r(()=>this.patchUser({map_start_mode:e})))}setBenchesPublishFrom(e){return this.http.post("/api/auth/benches-publish-from",{date:e}).pipe(r(()=>this.patchUser({benches_publish_from:e})))}setCompassEnabled(e){return this.http.post("/api/auth/compass-enabled",{enabled:e}).pipe(r(()=>this.patchUser({compass_enabled:e})))}setScaleEnabled(e){return this.http.post("/api/auth/scale-enabled",{enabled:e}).pipe(r(()=>this.patchUser({scale_enabled:e})))}setEditModeEnabled(e){return this.http.post("/api/auth/edit-mode-enabled",{enabled:e}).pipe(r(()=>this.patchUser({edit_mode_enabled:e})))}setCaptureFabEnabled(e){return this.http.post("/api/auth/capture-fab-enabled",{enabled:e}).pipe(r(()=>this.patchUser({capture_fab_enabled:e})))}setUpdatesLastSeen(e){return this.http.post("/api/auth/updates-last-seen",{id:e}).pipe(r(()=>this.patchUser({updates_last_seen_id:e})))}patchUser(e){let t=this.user();if(!t)return;let a=u(u({},t),e);localStorage.setItem(i,JSON.stringify(a)),this.user.set(a)}twoFactorSetup(e){return this.http.post("/api/auth/2fa/setup",{password:e})}twoFactorEnable(e,t,a){return this.http.post("/api/auth/2fa/enable",{secret:e,code:t,password:a})}twoFactorDisable(e){return this.http.post("/api/auth/2fa/disable",{code:e})}logout(){localStorage.removeItem(l),localStorage.removeItem(i),this.user.set(null),this.stewardedGroupIds.set([])}storeIfFinal(e){"token"in e&&(localStorage.setItem(l,e.token),localStorage.setItem(i,JSON.stringify(e.user)),this.user.set(e.user))}loadUser(){let e=localStorage.getItem(i);if(!e)return null;try{return JSON.parse(e)}catch(t){return null}}static \u0275fac=function(t){return new(t||o)};static \u0275prov=p({token:o,factory:o.\u0275fac,providedIn:"root"})};export{w as a,b};
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.