1import{r as e}from"./supabase-EaUugxh7.js";import{t}from"./logger-CLdAxy8E.js";import{i as n,r,s as i}from"./customerAuthService-CEEw0fcb.js";import{t as a}from"./programRegistrationService-D-w_GPWX.js";import{t as o}from"./adminApiFetch-DarlCD_G.js";async function s(e,t={}){let n=i();if(!n)throw Error(`Sichere Sitzung abgelaufen. Bitte melde dich erneut an.`);let r=await fetch(`/api/member-product-test${e}`,{...t,headers:{...t.body?{"Content-Type":`application/json`}:{},...t.headers,Authorization:`Bearer ${n}`}}),a=await r.json().catch(()=>({}));if(!r.ok||!a?.success)throw Error(a?.error||`Produkttest-Anfrage fehlgeschlagen.`);return a.data}async function c(e,t={}){let n=await o(`/api/member-product-test/admin${e}`,{...t,headers:{...t.body?{"Content-Type":`application/json`}:{},...t.headers||{}}}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.success)throw Error(r?.error||`Produkttest-Admin-Anfrage fehlgeschlagen.`);return r.data}function l(e,t){return JSON.stringify({confirmation:{action:e,target:String(t)}})}var u={async verifyMemberPassword(e,r){try{let t=await n(e,r);return{valid:t.success===!0&&!!t.memberPortalToken,member:t.memberData||null,error:t.success?null:t.error||`Falsches Passwort`,needsPasswordReset:t.needsPasswordReset===!0}}catch{return t.error(`[ProductTestService] member_password_verification_failed`),{valid:!1,member:null,error:`Verifizierung fehlgeschlagen`,needsPasswordReset:!1}}},async verifyGoogleMemberSession(e){try{let t=String(e||``).trim().toLowerCase();if(!t)return{valid:!1,member:null,error:`Google-Sitzung fehlt.`};let n=await r(t);return{valid:n.success===!0&&!!n.memberPortalToken,member:n.memberData||null,error:n.success?null:`Bitte melde dich mit dem passenden Google-Konto an.`}}catch{return t.warn(`[ProductTestService] google_member_session_verification_failed`),{valid:!1,member:null,error:`Google-Verifizierung fehlgeschlagen.`}}},async startGoogleMemberLogin(n){let r=String(n||``).trim().toLowerCase();if(!r)return{success:!1,error:`E-Mail-Adresse fehlt.`};try{sessionStorage.setItem(`product_test_google_email`,r);let t=`${window.location.origin}${window.location.pathname}${window.location.search}`,{error:n}=await e.auth.signInWithOAuth({provider:`google`,options:{redirectTo:t,queryParams:{login_hint:r}}});if(n)throw n;return{success:!0}}catch{return t.warn(`[ProductTestService] google_login_start_failed`),{success:!1,error:`Google-Anmeldung konnte nicht gestartet werden.`}}},async submitApplicationForExistingMember(e){try{return{data:await s(`/application`,{method:`POST`,body:JSON.stringify({gender:e?.gender,preferred_group:e?.preferred_group,sponsor_ref_code:e?.sponsor_ref_code})}),error:null}}catch(e){return{data:null,error:e}}},async registerNewMemberAndApply(e){let{email:n,password:r,username:i,firstName:o,lastName:s,gender:c,preferred_group:l,sponsor_ref_code:u,preferredLanguage:d}=e;try{let e=await a.registerNewMember({email:n,password:r,username:i,firstName:o,lastName:s,referrer:u||`info`,program:`choco`,herkunft:`gewinner-landing`,preferredLanguage:d,productTestApplication:{gender:c,preferredGroup:l}});return e.success?e.existingMemberAuthenticated===!0&&e.productTestApplicationSubmitted!==!0?{success:!1,error:`Produkttest-Bewerbung konnte nicht sicher gespeichert werden.`}:{success:!0,member_id:e.data.member_id,application_status:e.data?.product_test_application_status||null,pending_confirmation:e.pendingConfirmation===!0,message:e.message||`Registrierung erfolgreich! Bitte bestätige deine Email-Adresse.`}:{success:!1,error:e.error}}catch{return t.error(`[ProductTestService] member_registration_failed`),{success:!1,error:`Registrierung fehlgeschlagen.`}}},async checkUsernameAvailable(e){return await a.checkUsernameExists(e)},async validateRefCode(e){return await a.validateRefCode(e)},async checkExistingApplication(e){return s(`/application`)},async submitApplication(e){try{return{data:await s(`/application`,{method:`POST`,body:JSON.stringify(e||{})}),error:null}}catch(e){return{data:null,error:e}}},async submitScreeningAnswers(e,t){return s(`/screening`,{method:`POST`,body:JSON.stringify(t||{})})},async checkGewinnerUserStatus(e){try{return await s(`/status`)}catch{return t.error(`[ProductTestService] gewinner_status_lookup_failed`),{isGewinnerUser:!1,hasStudyApplication:!1,applicationStatus:null}}},async getParticipantStatus(e){return s(`/participant`)},async getResponses(e){return s(`/responses`)},async saveResponse(e,t,n){return s(`/response`,{method:`PUT`,body:JSON.stringify({phase:t,data:n})})},async getStats(){return c(`/stats`)},async getChocoTeamStats(e){try{return await s(`/choco-team-stats`)}catch{return t.error(`[ProductTestService] choco_team_stats_lookup_failed`),{personalReferrals:0,teamReferrals:0,totalBonus:0}}},async createParticipant(e,t,n){try{return{data:await c(`/participants`,{method:`POST`,body:JSON.stringify({memberId:e,gender:t,group:n})}),error:null}}catch(e){return{data:null,error:e}}},async startOwnParticipant(e,t,n){return s(`/participant/start`,{method:`POST`})},async quickApplyForProductTest(e){try{return t.debug(`[ProductTestService] quick_apply_started`),await s(`/quick-apply`,{method:`POST`})}catch{return t.error(`[ProductTestService] quick_apply_failed`),{success:!1,error:`Produkttest-Anmeldung fehlgeschlagen.`}}},async getStudyStatusForPortal(e){try{return await s(`/study-status`)}catch{return t.error(`[ProductTestService] study_status_lookup_failed`),{hasApplication:!1,status:null,participant:null,needsWeeklyEntry:!1,currentWeek:null}}},async getTotalChocoCommunityCount(){try{return await s(`/community-count`)}catch{return t.error(`[ProductTestService] community_count_lookup_failed`),0}},acceptApplication(e){return c(`/applications/${encodeURIComponent(e)}/accept`,{method:`POST`})},rejectApplication(e){return c(`/applications/${encodeURIComponent(e)}/reject`,{method:`POST`})},resetParticipant(e){return c(`/participants/${encodeURIComponent(e)}/reset`,{method:`POST`,body:l(`reset_product_test_participant`,e)})},revertApplication(e){return c(`/applications/${encodeURIComponent(e)}/revert`,{method:`POST`,body:l(`revert_product_test_application`,e)})},deleteAllStudyData(){return c(`/data`,{method:`DELETE`,body:l(`delete_all_product_test_data`,`all_product_test_data`)})},deleteApplication(e){return c(`/applications/${encodeURIComponent(e)}`,{method:`DELETE`,body:l(`delete_product_test_application`,e)})}};export{u as t};
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.