import{o as Se,r as l,a as ie,u as Te,j as e,x as vs,y as ys,v as T,z as U,q as G,C as O,S as xe,X as $e,w as h,L as A,A as X,i as $,V as ws,D as ks,E as Ee,F as Ds,G as _s,H as Ie,W as As,e as Cs,J as Ss,d as Ts,K as $s,N as Es,O as Is,Q as Re,Y as Rs,Z as Ms,_ as Me,$ as Os,a0 as Ps,p as Vs,a1 as Ls,a2 as Fs,k as zs,a3 as Us,a4 as Gs,a5 as Js,T as we,b as Bs,M as oe,f as te,a6 as Hs,a7 as ae,B as Ks,a8 as ce}from"./index-oAPVDf-r.js";import{u as qs}from"./useMissionExamples-B0el-PHm.js";import{A as Ys,u as Xs}from"./useIdentityVerification-CD3mPBIt.js";import{C as Qs}from"./circle-check-D3hjqUcb.js";import{S as Ws}from"./SecureCamera-mAkOb0O2.js";import{A as ke}from"./award-By-NEFpe.js";import{T as Zs}from"./triangle-alert-B87swlNS.js";import{C as et}from"./check-CG8zylH4.js";import{A as De}from"./index-B-MEeiYV.js";import{S as st}from"./shield-BWGzcrms.js";import{G as tt}from"./gift-lxeNwCUB.js";import{T as at}from"./ticket-D1bxyCST.js";import{E as rt}from"./external-link-C86N9iPS.js";import{A as _e}from"./arrow-left-m6EiMbb-.js";import{C as Ae}from"./circle-alert-C1Hs9zwh.js";import{C as de}from"./clock-DRtqJZUo.js";import{I as it}from"./image-DuU1QaV8.js";import{T as Ce}from"./timer-C5oB41EC.js";import{R as nt}from"./refresh-cw-DEBvxUr1.js";/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lt=Se("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ot=Se("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);function ct(s,a,r){if(!s)return{title:r("missionDetail.verifyForMissions"),description:r("missionDetail.verifyDescription")};const n=["IAL1","IAL2","IAL3"],i=n.indexOf(s),c=n.indexOf(a??"IAL2");if(i{const{t:c}=ie(),o=Te(),{title:j,description:t}=ct(r,n,c),p=s||j,g=a||t,v=r!=null&&n!=null&&r!==n;return e.jsx(vs,{ref:i,className:"border-primary/30 bg-primary/5",children:e.jsxs(ys,{className:"p-6 text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/20 flex items-center justify-center mx-auto",children:v?e.jsx(ot,{className:"w-8 h-8 text-primary"}):e.jsx(Qs,{className:"w-8 h-8 text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g}),r&&n&&e.jsxs("p",{className:"text-xs text-muted-foreground/70",children:["Nuvarande nivå: ",r," · Krävs: ",n]})]}),e.jsxs(T,{onClick:()=>o("/verify-identity?returnTo="+encodeURIComponent(window.location.pathname)),className:"w-full",children:[v?"Uppgradera verifiering":c("missionDetail.verifyForMissions"),e.jsx(Ys,{className:"w-4 h-4 ml-2"})]})]})})});Oe.displayName="VerificationRequired";const dt=()=>{const[s,a]=l.useState(!1),[r,n]=l.useState(null),[i,c]=l.useState(null),o=l.useCallback(async t=>{a(!0),c(null),n(null);try{const p=t.replace(/^data:image\/\w+;base64,/,""),{data:g,error:v}=await U.functions.invoke("validate-aesthetic",{body:{imageBase64:p,missionType:"certified_global"}});if(v)throw new Error(v.message);if(!(g!=null&&g.success)||!(g!=null&&g.validation))throw new Error((g==null?void 0:g.error)||"Validation failed");return n(g.validation),g.validation}catch(p){const g=p instanceof Error?p.message:"Kunde inte validera bild";return c(g),console.error("Aesthetic validation error:",p),null}finally{a(!1)}},[]),j=l.useCallback(()=>{n(null),c(null)},[]);return{validateImage:o,isValidating:s,validationResult:r,error:i,reset:j}},me=({score:s,label:a,color:r})=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:a}),e.jsxs("span",{className:"font-medium",children:[s,"/100"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx(G.div,{initial:{width:0},animate:{width:`${s}%`},transition:{duration:.8,ease:"easeOut"},className:`h-full rounded-full ${r}`})})]}),re=({passed:s,label:a})=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s?e.jsx(et,{className:"w-4 h-4 text-green-500"}):e.jsx($e,{className:"w-4 h-4 text-red-500"}),e.jsx("span",{className:s?"text-foreground":"text-muted-foreground",children:a})]}),mt=({result:s,compact:a=!1})=>{const{t:r}=ie(),n=o=>o>=80?"bg-gradient-to-r from-green-500 to-emerald-400":o>=60?"bg-gradient-to-r from-yellow-500 to-amber-400":"bg-gradient-to-r from-red-500 to-orange-400",c=(o=>o>=90?{grade:"A+",text:r("aesthetic.gradeExceptional"),emoji:"🏆"}:o>=80?{grade:"A",text:r("aesthetic.gradeExcellent"),emoji:"⭐"}:o>=70?{grade:"B",text:r("aesthetic.gradeGood"),emoji:"👍"}:o>=60?{grade:"C",text:r("aesthetic.gradeAccepted"),emoji:"👌"}:{grade:"D",text:r("aesthetic.gradeNeedsImprovement"),emoji:"💪"})(s.overall_score);return a?e.jsx(G.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:`p-3 rounded-xl ${s.certified_global_eligible?"bg-gradient-to-r from-amber-500/20 to-yellow-500/20 border border-amber-500/30":"bg-muted/50 border border-border"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.certified_global_eligible?e.jsx(ke,{className:"w-5 h-5 text-amber-500"}):e.jsx(O,{className:"w-5 h-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-bold text-lg",children:s.overall_score}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"/100"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c.text})]})]}),s.certified_global_eligible&&e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-amber-500/20 rounded-full",children:[e.jsx(xe,{className:"w-3 h-3 text-amber-500"}),e.jsx("span",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:"Certified"})]})]})}):e.jsxs(G.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-4",children:[e.jsxs("div",{className:`p-4 rounded-2xl ${s.certified_global_eligible?"bg-gradient-to-br from-amber-500/20 via-yellow-500/10 to-orange-500/20 border border-amber-500/30":"bg-card border border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-14 h-14 rounded-xl flex items-center justify-center ${s.certified_global_eligible?"bg-gradient-to-br from-amber-500 to-yellow-500":n(s.overall_score)}`,children:e.jsx("span",{className:"text-2xl font-bold text-white",children:c.grade})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:s.overall_score}),e.jsx("span",{className:"text-muted-foreground",children:"/100"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx("span",{children:c.emoji}),e.jsx("span",{children:c.text})]})]})]}),s.certified_global_eligible&&e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(ke,{className:"w-8 h-8 text-amber-500"}),e.jsx("span",{className:"text-xs font-bold text-amber-600 dark:text-amber-400",children:"CERTIFIED"})]})]}),e.jsx("p",{className:"text-sm text-foreground bg-background/50 rounded-lg p-3",children:s.feedback})]}),e.jsxs("div",{className:"space-y-3 p-4 bg-card rounded-xl border border-border",children:[e.jsxs("h4",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4"}),r("aesthetic.detailedAnalysis")]}),e.jsx(me,{score:s.composition_score,label:r("aesthetic.composition"),color:n(s.composition_score)}),e.jsx(me,{score:s.lighting_score,label:r("aesthetic.lighting"),color:n(s.lighting_score)}),e.jsx(me,{score:s.technical_quality,label:r("aesthetic.technicalQuality"),color:n(s.technical_quality)})]}),e.jsxs("div",{className:"p-4 bg-card rounded-xl border border-border space-y-3",children:[e.jsxs("h4",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-amber-500"}),r("aesthetic.certifiedRequirements")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(re,{passed:s.is_schoolyard,label:r("aesthetic.schoolyard")}),e.jsx(re,{passed:s.golden_hour_detected,label:r("aesthetic.goldenHour")}),e.jsx(re,{passed:!s.has_people,label:r("aesthetic.noPeople")}),e.jsx(re,{passed:s.overall_score>=75,label:r("aesthetic.aestheticMin")})]}),!s.certified_global_eligible&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-amber-500/10 rounded-lg mt-2",children:[e.jsx(Zs,{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("aesthetic.requirementsNotMet")})]})]})]})},xt=({missionId:s,requiredPhotos:a,claimId:r,onComplete:n,isCertifiedGlobal:i=!1,isTestMode:c=!1})=>{const[o,j]=l.useState([]),[t,p]=l.useState(!1),[g,v]=l.useState(!1),[y,Q]=l.useState(null),{validateImage:W}=dt(),Z=l.useCallback(async d=>{const b={...d,isValidating:i};j(u=>[...u,b]);const x=o.length;if(o.length+1>=a&&p(!1),i)try{const u=await W(d.dataUrl);j(w=>w.map((D,R)=>R===x?{...D,validation:u||void 0,isValidating:!1}:D)),u&&(u.certified_global_eligible?h.success("🏆 Certified Global™ godkänd!",{description:`Estetisk poäng: ${u.overall_score}/100`}):h.info(`Estetisk poäng: ${u.overall_score}/100`,{description:u.feedback}))}catch(u){console.error("Validation error:",u),j(w=>w.map((D,R)=>R===x?{...D,isValidating:!1}:D))}},[o.length,a,i,W]),ee=l.useCallback(d=>{j(b=>b.filter((x,u)=>u!==d)),y===d&&Q(null)},[y]),ne=l.useCallback(async()=>{if(o.lengthb.validation&&!b.validation.certified_global_eligible).length>0&&h.warning("Vissa foton uppfyller inte Certified Global™-kraven",{description:"Du kan fortfarande skicka in, men dessa foton kanske inte godkänns."}),v(!0);try{const{data:{user:d}}=await U.auth.getUser();if(!d){h.error("Du måste vara inloggad");return}for(let u=0;u{var w;return(w=u.validation)==null?void 0:w.certified_global_eligible}).length;h.success("Foton inskickade!",{description:i&&x>0?`${x} av ${o.length} foton uppfyller Certified Global™-kraven.`:"Vi granskar dina foton och återkommer snart."}),n()}catch(d){console.error("Submit error:",d),h.error(d instanceof Error?d.message:"Kunde inte skicka in foton")}finally{v(!1)}},[o,a,i,c,n,r]),L=o.length>=a&&!o.some(d=>d.isValidating),I=y!==null?o[y]:null;return e.jsxs(e.Fragment,{children:[e.jsx(De,{children:t&&e.jsx(Ws,{onPhotoCapture:Z,onCancel:()=>p(!1),maxPhotos:a,currentPhotoCount:o.length})}),e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-gradient-to-r from-amber-500/10 to-yellow-500/10 border border-amber-500/30 rounded-xl",children:[e.jsx(xe,{className:"w-5 h-5 text-amber-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:"Certified Global™ Fotoutmaning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"AI bedömer estetik, komposition och golden hour-ljus"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 border border-green-500/30 rounded-xl",children:[e.jsx(st,{className:"w-5 h-5 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Säker fotouppladdning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Endast foton tagna i appen godkänns – för din och allas trygghet"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Foton (",o.length,"/",a,")"]}),o.lengthe.jsxs(G.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},className:`relative aspect-square rounded-xl overflow-hidden bg-muted cursor-pointer min-h-[120px] ${y===b?"ring-2 ring-primary":""}`,onClick:()=>Q(y===b?null:b),children:[e.jsx("img",{src:d.dataUrl,alt:`Foto ${b+1}`,className:"w-full h-full object-cover"}),d.isValidating&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(A,{className:"w-6 h-6 animate-spin text-white"}),e.jsx("span",{className:"text-xs text-white",children:"Analyserar..."})]})}),d.validation&&!d.isValidating&&e.jsx("div",{className:`absolute bottom-2 right-2 px-2 py-1 rounded-full text-xs font-bold ${d.validation.certified_global_eligible?"bg-amber-500 text-white":d.validation.overall_score>=60?"bg-green-500/80 text-white":"bg-red-500/80 text-white"}`,children:d.validation.overall_score}),e.jsx("button",{onClick:x=>{x.stopPropagation(),ee(b)},className:"absolute top-2 right-2 w-8 h-8 bg-black/60 rounded-full flex items-center justify-center active:bg-black/80",children:e.jsx($e,{className:"w-5 h-5 text-white"})}),e.jsx("div",{className:"absolute bottom-2 left-2 bg-black/60 px-3 py-1 rounded-full",children:e.jsx("span",{className:"text-sm text-white font-medium",children:b+1})})]},d.timestamp)),o.lengthp(!0),className:`rounded-xl border-2 border-dashed border-primary/50 bg-primary/5 flex flex-col items-center justify-center gap-3 hover:bg-primary/10 active:bg-primary/15 transition-colors ${o.length===0?"min-h-[200px] py-10":"aspect-square min-h-[120px]"}`,children:[e.jsx("div",{className:`rounded-full bg-primary/20 flex items-center justify-center ${o.length===0?"w-16 h-16":"w-12 h-12"}`,children:e.jsx(O,{className:`text-primary ${o.length===0?"w-8 h-8":"w-6 h-6"}`})}),e.jsx("span",{className:`text-primary font-medium ${o.length===0?"text-base":"text-sm"}`,children:"Ta foto"}),o.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Tryck för att öppna kameran"})]})]})]}),e.jsx(De,{children:(I==null?void 0:I.validation)&&e.jsx(G.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:e.jsx(mt,{result:I.validation})})}),e.jsx(T,{onClick:ne,disabled:!L||g,className:"w-full h-14 text-base font-semibold rounded-2xl",children:g?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-5 h-5 animate-spin mr-2"}),"Skickar in..."]}):o.some(d=>d.isValidating)?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-5 h-5 animate-spin mr-2"}),"Analyserar foton..."]}):L?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-5 h-5 mr-2"}),"Skicka in ",o.length," foton"]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-5 h-5 mr-2"}),"Ta ",a-o.length," fler foton"]})}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:["🔒 Alla foton verifieras automatiskt för äkthet",i&&" och estetisk kvalitet"]})]})]})},ut=({sponsor:s})=>{const a=s.colorPrimary||"#6366f1",r=s.rewardDescription||"Specialbelöning",n=s.redemptionInstructions||"Visa QR-koden efter slutfört uppdrag";return e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border-2 p-5",style:{borderColor:a,background:`linear-gradient(135deg, ${a}10 0%, ${a}05 100%)`},children:[e.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 opacity-10 -translate-y-8 translate-x-8",style:{background:`radial-gradient(circle, ${a} 0%, transparent 70%)`}}),e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-xl flex items-center justify-center flex-shrink-0 shadow-lg overflow-hidden",style:{background:"white",border:`2px solid ${a}40`},children:s.logoUrl?e.jsx("img",{src:s.logoUrl,alt:s.brandName,className:"w-full h-full object-contain p-2",onError:i=>{i.currentTarget.style.display="none";const c=i.currentTarget.parentElement;c&&(c.style.background=a,c.innerHTML=`${s.brandName.charAt(0)}`)}}):e.jsx("span",{className:"text-2xl font-bold",style:{color:a},children:s.brandName.charAt(0)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(tt,{className:"w-4 h-4",style:{color:a}}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:a},children:"Sponsorbelöning"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sponsrat av ",s.brandName]})]})]}),e.jsx("div",{className:"rounded-xl p-4 mb-4",style:{background:`${a}15`,border:`1px solid ${a}30`},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:a},children:e.jsx(at,{className:"w-5 h-5 text-white"})}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"font-bold text-foreground text-lg leading-tight",children:r})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Så här löser du in belöningen"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(rt,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-foreground leading-relaxed",children:n})]})]}),s.tagline&&e.jsxs("p",{className:"text-xs italic mt-4 pt-3 border-t",style:{color:`${a}99`,borderColor:`${a}20`},children:['"',s.tagline,'"']})]})};function pt(){const[s,a]=l.useState(!1),[r,n]=l.useState(!1),i=l.useRef(null),{t:c}=ie(),o=l.useCallback(async t=>{if(!(!t||t.trim().length===0)){i.current&&(i.current.pause(),i.current=null),a(!0);try{const p=await fetch("https://tmmrlsaixtghdicmmpmp.supabase.co/functions/v1/elevenlabs-tts",{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRtbXJsc2FpeHRnaGRpY21tcG1wIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc2Njk4ODQsImV4cCI6MjA4MzI0NTg4NH0.lKID0Mt0B-uyYWi57xldQJ56stbG7YopeOEy4ObKoMU",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRtbXJsc2FpeHRnaGRpY21tcG1wIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc2Njk4ODQsImV4cCI6MjA4MzI0NTg4NH0.lKID0Mt0B-uyYWi57xldQJ56stbG7YopeOEy4ObKoMU"},body:JSON.stringify({text:t})});if(!p.ok)throw new Error(`TTS request failed: ${p.status}`);const g=await p.blob(),v=URL.createObjectURL(g),y=new Audio(v);i.current=y,y.onplay=()=>n(!0),y.onended=()=>{n(!1),URL.revokeObjectURL(v),i.current=null},y.onerror=()=>{n(!1),URL.revokeObjectURL(v),i.current=null,h.error(c("tts.playbackError","Kunde inte spela upp ljud"))},await y.play()}catch(p){console.error("TTS error:",p),h.error(c("tts.error","Kunde inte generera tal"))}finally{a(!1)}}},[c]),j=l.useCallback(()=>{i.current&&(i.current.pause(),i.current=null,n(!1))},[]);return{speak:o,stop:j,isLoading:s,isPlaying:r}}function gt({text:s,className:a,variant:r="ghost",size:n="icon"}){const{speak:i,stop:c,isLoading:o,isPlaying:j}=pt(),t=()=>{j?c():i(s)};return e.jsx(T,{variant:r,size:n,onClick:t,disabled:o,className:$("transition-all",j&&"text-primary animate-pulse",a),title:j?"Stoppa uppläsning":"Läs upp",children:o?e.jsx(A,{className:"h-4 w-4 animate-spin"}):j?e.jsx(ws,{className:"h-4 w-4"}):e.jsx(ks,{className:"h-4 w-4"})})}var Pe="AlertDialog",[ft]=Cs(Pe,[Ee]),E=Ee(),Ve=s=>{const{__scopeAlertDialog:a,...r}=s,n=E(a);return e.jsx(Ds,{...n,...r,modal:!0})};Ve.displayName=Pe;var ht="AlertDialogTrigger",jt=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...n}=s,i=E(r);return e.jsx(Ms,{...i,...n,ref:a})});jt.displayName=ht;var bt="AlertDialogPortal",Le=s=>{const{__scopeAlertDialog:a,...r}=s,n=E(a);return e.jsx(_s,{...n,...r})};Le.displayName=bt;var Nt="AlertDialogOverlay",Fe=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...n}=s,i=E(r);return e.jsx(Rs,{...i,...n,ref:a})});Fe.displayName=Nt;var J="AlertDialogContent",[vt,yt]=ft(J),wt=$s("AlertDialogContent"),ze=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,children:n,...i}=s,c=E(r),o=l.useRef(null),j=Ie(a,o),t=l.useRef(null);return e.jsx(As,{contentName:J,titleName:Ue,docsSlug:"alert-dialog",children:e.jsx(vt,{scope:r,cancelRef:t,children:e.jsxs(Ss,{role:"alertdialog",...c,...i,ref:j,onOpenAutoFocus:Ts(i.onOpenAutoFocus,p=>{var g;p.preventDefault(),(g=t.current)==null||g.focus({preventScroll:!0})}),onPointerDownOutside:p=>p.preventDefault(),onInteractOutside:p=>p.preventDefault(),children:[e.jsx(wt,{children:n}),e.jsx(Dt,{contentRef:o})]})})})});ze.displayName=J;var Ue="AlertDialogTitle",Ge=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...n}=s,i=E(r);return e.jsx(Es,{...i,...n,ref:a})});Ge.displayName=Ue;var Je="AlertDialogDescription",Be=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...n}=s,i=E(r);return e.jsx(Is,{...i,...n,ref:a})});Be.displayName=Je;var kt="AlertDialogAction",He=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...n}=s,i=E(r);return e.jsx(Re,{...i,...n,ref:a})});He.displayName=kt;var Ke="AlertDialogCancel",qe=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...n}=s,{cancelRef:i}=yt(Ke,r),c=E(r),o=Ie(a,i);return e.jsx(Re,{...c,...n,ref:o})});qe.displayName=Ke;var Dt=({contentRef:s})=>{const a=`\`${J}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${J}\` by passing a \`${Je}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${J}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return l.useEffect(()=>{var n;document.getElementById((n=s.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(a)},[a,s]),null},_t=Ve,At=Le,Ye=Fe,Xe=ze,Qe=He,We=qe,Ze=Ge,es=Be;const Ct=_t,St=At,ss=l.forwardRef(({className:s,...a},r)=>e.jsx(Ye,{className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...a,ref:r}));ss.displayName=Ye.displayName;const ts=l.forwardRef(({className:s,...a},r)=>e.jsxs(St,{children:[e.jsx(ss,{}),e.jsx(Xe,{ref:r,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a})]}));ts.displayName=Xe.displayName;const as=({className:s,...a})=>e.jsx("div",{className:$("flex flex-col space-y-2 text-center sm:text-left",s),...a});as.displayName="AlertDialogHeader";const rs=({className:s,...a})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});rs.displayName="AlertDialogFooter";const is=l.forwardRef(({className:s,...a},r)=>e.jsx(Ze,{ref:r,className:$("text-lg font-semibold",s),...a}));is.displayName=Ze.displayName;const ns=l.forwardRef(({className:s,...a},r)=>e.jsx(es,{ref:r,className:$("text-sm text-muted-foreground",s),...a}));ns.displayName=es.displayName;const ls=l.forwardRef(({className:s,...a},r)=>e.jsx(Qe,{ref:r,className:$(Me(),s),...a}));ls.displayName=Qe.displayName;const os=l.forwardRef(({className:s,...a},r)=>e.jsx(We,{ref:r,className:$(Me({variant:"outline"}),"mt-2 sm:mt-0",s),...a}));os.displayName=We.displayName;const Yt=()=>{var be,Ne,ve;const{t:s}=ie(),{id:a}=Os(),r=Te(),n=Ps(),{user:i}=Vs();Ls();const{isVerified:c,achievedIAL:o,checkStatus:j}=Xs(i==null?void 0:i.id),{mission:t,loading:p,error:g}=Fs(a),{goodExamples:v,badExamples:y,hasExamples:Q,loading:W}=qs(a),{latitude:Z,longitude:ee,loading:ne}=zs(),[L,I]=l.useState(!1),[d,b]=l.useState(!1),[x,u]=l.useState(null),[w,D]=l.useState(!0),[R,F]=l.useState(null),[B,se]=l.useState(!1),[C,ue]=l.useState(!1),[H,pe]=l.useState(!1),[cs,K]=l.useState(null),[le,q]=l.useState(!1),[ds,ge]=l.useState(!1),[ms,xs]=l.useState(!1),P=Us({enabled:ms,autoNavigate:!1}),fe=l.useCallback(()=>{try{const m=new(window.AudioContext||window.webkitAudioContext),f=(_,z)=>{const k=m.createOscillator(),S=m.createGain();k.connect(S),S.connect(m.destination),k.frequency.value=z,k.type="sine",S.gain.setValueAtTime(.3,_),S.gain.exponentialRampToValueAtTime(.01,_+.15),k.start(_),k.stop(_+.15)},N=m.currentTime;f(N,800),f(N+.2,1e3),f(N+.4,1200)}catch(m){console.log("Could not play warning sound:",m)}},[]),he=l.useCallback(()=>{window.history.length>2?r(-1):r("/")},[r]),je=(be=t==null?void 0:t.title)==null?void 0:be.toLowerCase().includes("busskur");l.useEffect(()=>{(async()=>{if(!i||!a){D(!1);return}const f=ce.getToken();if(!f){D(!1);return}try{const N=await fetch(`https://api.quixzoom.com/api/qz/missions/claims/active?mission_id=${encodeURIComponent(a)}`,{headers:{Authorization:`Bearer ${f}`}});if(N.ok){const _=await N.json();_.claim&&u(_.claim)}}catch(N){console.error("[MissionDetail] fetchActiveClaim error:",N)}D(!1)})()},[i,a]),l.useEffect(()=>{i!=null&&i.id&&j()},[i==null?void 0:i.id,j]),l.useEffect(()=>{i!=null&&i.id&&j()},[n.key]),l.useEffect(()=>{if(!(x!=null&&x.expires_at)){F(null),se(!1);return}const m=()=>{const N=new Date,z=new Date(x.expires_at).getTime()-N.getTime();if(z<=0){F("Utgången"),ue(!1),h.error("Tiden har gått ut!",{description:"Uppdraget har släppts automatiskt."}),u(null);return}const k=Math.floor(z/6e4),S=Math.floor(z%6e4/1e3);F(`${k}:${S.toString().padStart(2,"0")}`);const V=k<3;ue(V),V&&!B&&(fe(),se(!0))};m();const f=setInterval(m,1e3);return()=>clearInterval(f)},[x==null?void 0:x.expires_at,B,fe]),l.useEffect(()=>{const m=(t==null?void 0:t.active_until)||(t==null?void 0:t.expires_at);if(!m){K(null),q(!1);return}const f=()=>{const _=new Date,k=new Date(m).getTime()-_.getTime();if(k<=0){K(s("missionDetail.expired")),q(!1);return}const S=Math.floor(k/(1e3*60*60*24)),V=Math.floor(k%(1e3*60*60*24)/(1e3*60*60)),ye=Math.floor(k%(1e3*60*60)/(1e3*60)),Ns=Math.floor(k%(1e3*60)/1e3);S>0?(K(`${S}d ${V}h`),q(!1)):V>0?(K(`${V}h ${ye}m`),q(V<2)):(K(`${ye}:${Ns.toString().padStart(2,"0")}`),q(!0))};f();const N=setInterval(f,1e3);return()=>clearInterval(N)},[t==null?void 0:t.active_until,t==null?void 0:t.expires_at]);const M=Z&&ee&&t?Gs(Z,ee,t.latitude,t.longitude):null,Y=je||M!==null&&t&&M<=t.radius_meters,us=async()=>{if(!i){r("/auth");return}if(!t||!je&&!Y)return;if(!c){r("/verify-identity?returnTo="+encodeURIComponent(window.location.pathname));return}I(!0);const m=ce.getToken();if(!m){h.error("Ingen giltig session — logga in igen"),I(!1);return}try{const f=await fetch("${import.meta.env.VITE_QZ_API_BASE}/missions/claims",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({mission_id:t.id})}),N=await f.json();f.ok?N.data&&(u({id:N.data.id,expires_at:N.data.expires_at}),N.reactivated?h.success(s("missionDetail.missionIsYoursAgain"),{description:s("missionDetail.youHave15Min")}):h.success(s("missionDetail.missionIsYours"),{description:s("missionDetail.youHave15Min")}),r(`/map?zoom-to=${t.latitude},${t.longitude}`)):h.error(s("missionDetail.couldNotClaim"),{description:N.error||`HTTP ${f.status}`})}catch{h.error(s("missionDetail.couldNotClaim"),{description:"Nätverksfel — försök igen"})}I(!1)},ps=async()=>{if(!x)return;b(!0);const m=ce.getToken();if(!m){h.error("Ingen giltig session"),b(!1);return}try{const f=await fetch(`https://api.quixzoom.com/api/qz/missions/claims/${x.id}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({status:"expired"})});if(f.ok)u(null),h.success(s("missionDetail.missionReleased"),{description:s("missionDetail.someoneElseCanTake")});else{const N=await f.json();h.error(s("missionDetail.couldNotRelease"),{description:N.error||`HTTP ${f.status}`})}}catch{h.error(s("missionDetail.couldNotRelease"),{description:"Nätverksfel"})}b(!1)},gs=()=>{t&&r(`/map?zoom-to=${t.latitude},${t.longitude}`)};if(p)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(A,{className:"w-8 h-8 animate-spin text-primary"})});if(g||!t)return e.jsxs("div",{className:"min-h-screen bg-background p-6",children:[e.jsxs("button",{onClick:he,className:"flex items-center gap-2 text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(_e,{className:"w-5 h-5"}),e.jsx("span",{children:s("missionDetail.back")})]}),e.jsxs("div",{className:"glass-card p-6 text-center",children:[e.jsx(Ae,{className:"w-12 h-12 mx-auto text-destructive mb-4"}),e.jsx("h2",{className:"text-lg font-semibold",children:s("missionDetail.notFound")})]})]});const fs=!!x,hs={missionTitle:t.title,distanceMeters:M??void 0,targetDescription:t.target_description||void 0,instructions:t.instructions||void 0,sponsorReward:((Ne=t.sponsor)==null?void 0:Ne.rewardDescription)||void 0,sponsorBrand:((ve=t.sponsor)==null?void 0:ve.brandName)||void 0},js=()=>M?M<=10?"photo":M<=50?"positioning":"navigation":"navigation",bs=()=>{P.isPlaying?P.stop():(xs(!0),P.triggerState(js(),hs))};return e.jsxs("div",{className:`min-h-screen bg-background safe-area-x ${fs?"pb-32":"pb-48"}`,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background/80 backdrop-blur-xl border-b border-border safe-area-top",children:e.jsxs("div",{className:"px-5 py-4 flex items-center justify-between",children:[e.jsxs("button",{onClick:he,className:"flex items-center gap-2 text-muted-foreground hover:text-foreground touch-target",children:[e.jsx(_e,{className:"w-5 h-5"}),e.jsx("span",{className:"text-base",children:s("missionDetail.back")})]}),e.jsx(Js,{isLoading:P.isLoading,isPlaying:P.isPlaying,currentState:P.currentState,onPlay:bs,onStop:P.stop,showLabel:!0})]})}),e.jsxs("div",{className:"px-5 py-6 space-y-5",children:[(t.organization||t.area_name)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.organization&&e.jsx("span",{className:"inline-block text-xs text-muted-foreground bg-secondary/50 px-3 py-1.5 rounded-lg",children:t.organization.name}),t.area_name&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground bg-secondary/50 px-3 py-1.5 rounded-lg",children:[e.jsx(we,{className:"w-3 h-3"}),t.area_name]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground leading-tight",children:t.title}),e.jsx(gt,{text:`${t.title}. ${t.target_description||""} ${t.description||""} ${t.instructions||""}`,className:"flex-shrink-0 mt-1"})]}),t.target_description&&e.jsx("p",{className:"text-sm text-primary/80 bg-primary/10 px-4 py-3 rounded-xl",children:t.target_description}),t.description&&e.jsx("p",{className:"text-muted-foreground text-base leading-relaxed",children:t.description})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"glass-card p-4 text-center rounded-2xl",children:[e.jsx(O,{className:"w-5 h-5 mx-auto text-primary mb-1.5"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:t.required_photos}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s("missionDetail.photos")})]}),e.jsxs("div",{className:"glass-card p-4 text-center rounded-2xl",children:[e.jsx(Bs,{className:"w-5 h-5 mx-auto text-warning mb-1.5"}),e.jsxs("p",{className:"text-2xl font-bold text-warning italic",children:[t.reward_credits," ",s("common.sek")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s("missionDetail.reward")})]}),e.jsxs("div",{className:`glass-card p-4 text-center rounded-2xl ${le?"bg-destructive/10 border border-destructive/30":""}`,children:[e.jsx(de,{className:`w-5 h-5 mx-auto mb-1.5 ${le?"text-destructive":"text-muted-foreground"}`}),e.jsx("p",{className:`text-2xl font-bold tabular-nums ${le?"text-destructive animate-pulse":"text-foreground"}`,children:cs||"∞"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s("missionDetail.timeLeft")})]})]}),t.sponsor&&e.jsx(ut,{sponsor:t.sponsor}),e.jsx("div",{className:"glass-card p-5 rounded-2xl space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center flex-shrink-0 ${Y?"bg-success/20":"bg-secondary"}`,children:e.jsx(oe,{className:`w-5 h-5 ${Y?"text-success":"text-muted-foreground"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:ne?"Hämtar...":M!==null?te(M):"Okänd"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:Y?"Du är tillräckligt nära!":`Inom ${te(t.radius_meters)}`})]}),e.jsxs(T,{variant:"ghost",size:"sm",onClick:gs,className:"flex-shrink-0 h-8 px-2.5 rounded-lg text-xs",children:[e.jsx(Hs,{className:"w-3.5 h-3.5 mr-1"}),"Karta"]})]})}),e.jsxs("div",{className:"glass-card p-5 rounded-2xl space-y-4 border-l-4 border-primary",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(we,{className:"w-4 h-4 text-primary"})}),e.jsx("h3",{className:"font-bold text-foreground text-lg",children:"Arbetsorder"})]}),e.jsx("div",{className:"space-y-2 pt-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-primary/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(O,{className:"w-3.5 h-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Vad ska fotograferas"}),e.jsx("p",{className:"text-sm text-foreground leading-relaxed",children:t.target_description||t.title})]})]})}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-success/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(X,{className:"w-3.5 h-3.5 text-success"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Antal foton som krävs"}),e.jsxs("p",{className:"text-sm text-foreground leading-relaxed",children:[t.required_photos," ",t.required_photos===1?"foto":"foton"]})]})]})}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-blue-500/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(it,{className:"w-3.5 h-3.5 text-blue-500"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",children:"Exempelbilder"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Så här ska fotot se ut ungefär:"}),W?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(A,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):Q?e.jsxs("div",{className:"space-y-3",children:[v.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-medium text-success uppercase tracking-wide",children:"Godkända exempel"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:v.map(m=>e.jsxs("div",{className:"relative aspect-[4/3] rounded-xl overflow-hidden border-2 border-success/40",children:[e.jsx("img",{src:m.image_url,alt:m.caption||"Godkänt exempel",loading:"lazy",referrerPolicy:"no-referrer",onError:f=>{f.currentTarget.src="/placeholder.svg"},className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-success/90 py-1 px-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3 text-white"}),e.jsx("span",{className:"text-[10px] text-white font-medium truncate",children:m.caption||"Godkänt"})]})})]},m.id))})]}),y.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-medium text-destructive uppercase tracking-wide",children:"Ej godkända exempel"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:y.map(m=>e.jsxs("div",{className:"relative aspect-[4/3] rounded-xl overflow-hidden border-2 border-destructive/40",children:[e.jsx("img",{src:m.image_url,alt:m.caption||"Ej godkänt exempel",loading:"lazy",referrerPolicy:"no-referrer",onError:f=>{f.currentTarget.src="/placeholder.svg"},className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-destructive/90 py-1 px-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ae,{className:"w-3 h-3 text-white"}),e.jsx("span",{className:"text-[10px] text-white font-medium truncate",children:m.caption||"Ej godkänt"})]})})]},m.id))})]})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"relative aspect-[4/3] rounded-xl overflow-hidden border-2 border-success/40 bg-secondary",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-2",children:[e.jsx(O,{className:"w-8 h-8 mx-auto text-muted-foreground/50 mb-1"}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"Exempel kommer snart"})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-success/90 py-1 px-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3 text-white"}),e.jsx("span",{className:"text-[10px] text-white font-medium",children:"Godkänt"})]})})]}),e.jsxs("div",{className:"relative aspect-[4/3] rounded-xl overflow-hidden border-2 border-destructive/40 bg-secondary",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-2",children:[e.jsx(O,{className:"w-8 h-8 mx-auto text-muted-foreground/50 mb-1"}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"Exempel kommer snart"})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-destructive/90 py-1 px-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ae,{className:"w-3 h-3 text-white"}),e.jsx("span",{className:"text-[10px] text-white font-medium",children:"Ej godkänt"})]})})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-2 italic",children:"Tips: Tydlig bild, rätt vinkel, bra ljus. Undvik suddig bild eller fel motiv."})]})]})}),t.instructions&&e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-warning/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ae,{className:"w-3.5 h-3.5 text-warning"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Så här gör du"}),e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:t.instructions})]})]})}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-secondary flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(oe,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Plats"}),e.jsxs("p",{className:"text-sm text-foreground leading-relaxed",children:[t.area_name||"Inom angiven radie"," • Max ",te(t.radius_meters)," från mittpunkten"]})]})]})}),(t.active_until||t.expires_at)&&e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-destructive/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ce,{className:"w-3.5 h-3.5 text-destructive"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Senast"}),e.jsx("p",{className:"text-sm text-foreground leading-relaxed",children:new Date(t.active_until||t.expires_at).toLocaleDateString("sv-SE",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})]})}),e.jsx("div",{className:"pt-3 mt-3 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Ersättning vid godkänt uppdrag"}),e.jsxs("span",{className:"text-lg font-bold text-warning italic",children:[t.reward_credits," kr"]})]})})]}),e.jsxs("div",{className:"glass-card p-5 rounded-2xl space-y-4",children:[e.jsx("h3",{className:"font-semibold text-foreground text-base",children:"Plats"}),e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Latitud"}),e.jsx("p",{className:"font-mono text-foreground text-sm",children:t.latitude.toFixed(6)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Longitud"}),e.jsx("p",{className:"font-mono text-foreground text-sm",children:t.longitude.toFixed(6)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Radie"}),e.jsx("p",{className:"font-mono text-foreground text-sm",children:te(t.radius_meters)})]})]}),t.frequency&&t.frequency!=="once"||t.active_until?e.jsxs("div",{className:"glass-card p-5 rounded-2xl space-y-4",children:[e.jsx("h3",{className:"font-semibold text-foreground text-base",children:"Frekvens & Varaktighet"}),e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[t.frequency&&t.frequency!=="once"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(nt,{className:"w-4 h-4 text-primary mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Frekvens"}),e.jsx("p",{className:"text-foreground font-medium text-sm",children:t.frequency==="daily"?"Dagligen":t.frequency==="weekly"?"Veckovis":t.frequency==="biweekly"?"Varannan vecka":t.frequency==="monthly"?"Månadsvis":t.frequency})]})]}),t.active_until&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Aktivt till"}),e.jsx("p",{className:"text-foreground font-medium text-sm",children:new Date(t.active_until).toLocaleDateString("sv-SE")})]})]})]})]}):null,!t.active_until&&t.expires_at&&e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground px-1",children:[e.jsx(de,{className:"w-4 h-4 flex-shrink-0"}),e.jsxs("span",{children:["Uppdrag löper ut ",new Date(t.expires_at).toLocaleDateString("sv-SE")]})]}),x&&R&&!w&&e.jsxs("div",{className:`p-4 rounded-2xl flex items-center justify-between ${C?"bg-destructive/10 border border-destructive/30":"bg-primary/10 border border-primary/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${C?"bg-destructive/20":"bg-primary/20"}`,children:e.jsx(Ce,{className:`w-5 h-5 ${C?"text-destructive":"text-primary"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:`font-semibold ${C?"text-destructive":"text-primary"}`,children:"Tid kvar"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C?"Skynda dig!":"Slutför innan tiden går ut"})]})]}),e.jsx("div",{className:`text-3xl font-mono font-bold tabular-nums ${C?"text-destructive animate-pulse":"text-primary"}`,children:R})]}),(x||H)&&!w&&e.jsxs("div",{className:"glass-card p-5 rounded-2xl",children:[H&&!x&&e.jsxs("div",{className:"mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-xl flex items-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:"Testläge - foton sparas inte"})]}),e.jsx(xt,{missionId:t.id,requiredPhotos:t.required_photos,claimId:(x==null?void 0:x.id)||"test-mode",isTestMode:H&&!x,onComplete:()=>{H&&!x?(h.success("Kameratest slutfört!",{description:"Foton sparades inte (testläge)."}),pe(!1)):(h.success("Uppdraget slutfört!"),r("/"))}})]})]}),e.jsx("div",{className:"fixed bottom-24 left-0 right-0 px-5 py-3 bg-background/90 backdrop-blur-xl border-t border-border safe-area-x",children:w?e.jsxs(T,{disabled:!0,className:"w-full h-12 text-base rounded-xl",children:[e.jsx(A,{className:"w-5 h-5 animate-spin mr-2"}),"Laddar..."]}):H?e.jsxs(T,{onClick:()=>pe(!1),variant:"outline",className:"w-full h-12 text-base rounded-xl border-amber-500/50 text-amber-600",children:[e.jsx(ae,{className:"w-5 h-5 mr-2"}),"Avsluta testläge"]}):x?e.jsxs(T,{onClick:ps,disabled:d,variant:"outline",className:"w-full h-12 text-base rounded-xl",children:[d?e.jsx(A,{className:"w-5 h-5 animate-spin mr-2"}):e.jsx(ae,{className:"w-5 h-5 mr-2"}),"Släpp uppdraget"]}):Y?e.jsxs("div",{className:"space-y-2",children:[!c&&e.jsx(Oe,{achievedIAL:o,requiredIAL:"IAL2"}),e.jsxs(T,{onClick:()=>ge(!0),disabled:L||!c,className:"w-full h-11 text-sm font-semibold bg-primary hover:bg-primary/90 rounded-xl",children:[L?e.jsx(A,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(X,{className:"w-4 h-4 mr-2"}),"Ta uppdraget"]})]}):e.jsx("div",{className:"space-y-2",children:e.jsxs(T,{disabled:!0,className:"w-full h-12 text-base opacity-60 rounded-xl",children:[e.jsx(oe,{className:"w-5 h-5 mr-2"}),"Gå närmare för att ta uppdraget"]})})}),e.jsx(Ct,{open:ds,onOpenChange:ge,children:e.jsxs(ts,{className:"max-w-[340px] rounded-2xl",children:[e.jsxs(as,{children:[e.jsx(is,{className:"text-lg",children:"Ta uppdraget?"}),e.jsxs(ns,{className:"text-sm",children:["Du har ",e.jsx("strong",{children:"15 minuter"})," på dig att ta bilden och ladda upp den. Är du redo?"]})]}),e.jsxs(rs,{className:"flex-row gap-2",children:[e.jsx(os,{className:"flex-1 mt-0",children:"Avbryt"}),e.jsxs(ls,{onClick:us,className:"flex-1 bg-primary hover:bg-primary/90",children:[L?e.jsx(A,{className:"w-4 h-4 animate-spin mr-2"}):null,"Ja, ta uppdraget"]})]})]})}),e.jsx(Ks,{})]})};export{Yt as default};