48ea61cdcc
- Product documentation in docs/products/ - Updated MEMORY.md with product info - quiXzoom Auth Core as AAMOS Identity product
13 lines
46 KiB
JavaScript
13 lines
46 KiB
JavaScript
import{x as Ae,r as l,a as se,u as Ce,j as e,y as Ns,z as vs,v as S,A as Se,p as U,C as R,S as oe,X as Te,o as $e,w as f,D as ys,E as ws,L as D,F as J,V as ks,H as _s,i as T,J as Ds,K as Ee,N as As,O as Re,Q as Cs,d as Ss,R as Ts,W as $s,Y as Me,Z as Es,g as Rs,_ as Ms,$ as Pe,a0 as Ps,a1 as Is,a2 as Vs,a3 as Os,k as Ls,a4 as Fs,a5 as zs,a6 as Us,T as ve,b as Bs,M as re,f as X,a7 as Gs,a8 as Z,B as Hs,a9 as ie}from"./index-CZD3_4lD.js";import{u as qs}from"./useMissionExamples-k-4yLF0Z.js";import{A as Ks,u as Js}from"./useIdentityVerification-Cb6XYb0B.js";import{C as Ws}from"./circle-check-60AjePHB.js";import{S as Qs}from"./SecureCamera-0VtB9UCG.js";import{A as ye}from"./award-7DMfX1ZX.js";import{T as Ys}from"./triangle-alert-I_PJ38kC.js";import{C as Xs}from"./check-CCL32zXH.js";import{A as we}from"./index-DXB3_sFe.js";import{S as Zs}from"./shield-DIM7u0gp.js";import{G as et}from"./gift-C8Ri1JSk.js";import{T as st}from"./ticket-DTjwndeG.js";import{E as tt}from"./external-link-DZgJPdR9.js";import{A as ke}from"./arrow-left-DyClWdEf.js";import{C as _e}from"./circle-alert-DFiBooaQ.js";import{C as le}from"./clock-CHYQgZWG.js";import{I as at}from"./image-CUEcTqim.js";import{T as De}from"./timer-DiqX45Mc.js";import{R as rt}from"./refresh-cw-CCL0Gd2i.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 it=Ae("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 lt=Ae("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 nt(s,a,r){if(!s)return{title:r("missionDetail.verifyForMissions"),description:r("missionDetail.verifyDescription")};const o=["IAL1","IAL2","IAL3"],i=o.indexOf(s),d=o.indexOf(a??"IAL2");if(i<d){if(s==="IAL1"&&(a==="IAL2"||a==="IAL3"))return{title:"Förhöjd verifiering krävs",description:"Detta uppdrag kräver förhöjd verifiering (ID-handling). Verifiera din identitet för att ta uppdraget."};if(s==="IAL2"&&a==="IAL3")return{title:"Fullständig verifiering krävs",description:"Detta uppdrag kräver fullständig identitetsverifiering (IAL3). Kontakta support för att uppgradera."}}return{title:r("missionDetail.verifyForMissions"),description:r("missionDetail.verifyDescription")}}const Ie=l.forwardRef(({title:s,description:a,achievedIAL:r,requiredIAL:o},i)=>{const{t:d}=se(),n=Ce(),{title:h,description:t}=nt(r,o,d),u=s||h,p=a||t,k=r!=null&&o!=null&&r!==o;return e.jsx(Ns,{ref:i,className:"border-primary/30 bg-primary/5",children:e.jsxs(vs,{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:k?e.jsx(lt,{className:"w-8 h-8 text-primary"}):e.jsx(Ws,{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:u}),e.jsx("p",{className:"text-sm text-muted-foreground",children:p}),r&&o&&e.jsxs("p",{className:"text-xs text-muted-foreground/70",children:["Nuvarande nivå: ",r," · Krävs: ",o]})]}),e.jsxs(S,{onClick:()=>n("/verify-identity?returnTo="+encodeURIComponent(window.location.pathname)),className:"w-full",children:[k?"Uppgradera verifiering":d("missionDetail.verifyForMissions"),e.jsx(Ks,{className:"w-4 h-4 ml-2"})]})]})})});Ie.displayName="VerificationRequired";const ot=()=>{const[s,a]=l.useState(!1),[r,o]=l.useState(null),[i,d]=l.useState(null),n=l.useCallback(async t=>{a(!0),d(null),o(null);try{const u=t.replace(/^data:image\/\w+;base64,/,""),p=await Se("/validate-aesthetic",{imageBase64:u,missionType:"certified_global"});if(!(p!=null&&p.success)||!(p!=null&&p.validation))throw new Error((p==null?void 0:p.error)||"Validation failed");return o(p.validation),p.validation}catch(u){const p=u instanceof Error?u.message:"Kunde inte validera bild";return d(p),console.error("Aesthetic validation error:",u),null}finally{a(!1)}},[]),h=l.useCallback(()=>{o(null),d(null)},[]);return{validateImage:n,isValidating:s,validationResult:r,error:i,reset:h}},ne=({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(U.div,{initial:{width:0},animate:{width:`${s}%`},transition:{duration:.8,ease:"easeOut"},className:`h-full rounded-full ${r}`})})]}),ee=({passed:s,label:a})=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s?e.jsx(Xs,{className:"w-4 h-4 text-green-500"}):e.jsx(Te,{className:"w-4 h-4 text-red-500"}),e.jsx("span",{className:s?"text-foreground":"text-muted-foreground",children:a})]}),ct=({result:s,compact:a=!1})=>{const{t:r}=se(),o=n=>n>=80?"bg-gradient-to-r from-green-500 to-emerald-400":n>=60?"bg-gradient-to-r from-yellow-500 to-amber-400":"bg-gradient-to-r from-red-500 to-orange-400",d=(n=>n>=90?{grade:"A+",text:r("aesthetic.gradeExceptional"),emoji:"🏆"}:n>=80?{grade:"A",text:r("aesthetic.gradeExcellent"),emoji:"⭐"}:n>=70?{grade:"B",text:r("aesthetic.gradeGood"),emoji:"👍"}:n>=60?{grade:"C",text:r("aesthetic.gradeAccepted"),emoji:"👌"}:{grade:"D",text:r("aesthetic.gradeNeedsImprovement"),emoji:"💪"})(s.overall_score);return a?e.jsx(U.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(ye,{className:"w-5 h-5 text-amber-500"}):e.jsx(R,{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:d.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(oe,{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(U.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":o(s.overall_score)}`,children:e.jsx("span",{className:"text-2xl font-bold text-white",children:d.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:d.emoji}),e.jsx("span",{children:d.text})]})]})]}),s.certified_global_eligible&&e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(ye,{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(R,{className:"w-4 h-4"}),r("aesthetic.detailedAnalysis")]}),e.jsx(ne,{score:s.composition_score,label:r("aesthetic.composition"),color:o(s.composition_score)}),e.jsx(ne,{score:s.lighting_score,label:r("aesthetic.lighting"),color:o(s.lighting_score)}),e.jsx(ne,{score:s.technical_quality,label:r("aesthetic.technicalQuality"),color:o(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(oe,{className:"w-4 h-4 text-amber-500"}),r("aesthetic.certifiedRequirements")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ee,{passed:s.is_schoolyard,label:r("aesthetic.schoolyard")}),e.jsx(ee,{passed:s.golden_hour_detected,label:r("aesthetic.goldenHour")}),e.jsx(ee,{passed:!s.has_people,label:r("aesthetic.noPeople")}),e.jsx(ee,{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(Ys,{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")})]})]})]})},dt=({missionId:s,requiredPhotos:a,claimId:r,onComplete:o,isCertifiedGlobal:i=!1,isTestMode:d=!1})=>{const[n,h]=l.useState([]),[t,u]=l.useState(!1),[p,k]=l.useState(!1),[v,W]=l.useState(null),{validateImage:Q}=ot(),{user:O}=$e(),Y=l.useCallback(async m=>{const c={...m,isValidating:i};h(N=>[...N,c]);const b=n.length;if(n.length+1>=a&&u(!1),i)try{const N=await Q(m.dataUrl);h(A=>A.map((w,P)=>P===b?{...w,validation:N||void 0,isValidating:!1}:w)),N&&(N.certified_global_eligible?f.success("🏆 Certified Global™ godkänd!",{description:`Estetisk poäng: ${N.overall_score}/100`}):f.info(`Estetisk poäng: ${N.overall_score}/100`,{description:N.feedback}))}catch(N){console.error("Validation error:",N),h(A=>A.map((w,P)=>P===b?{...w,isValidating:!1}:w))}},[n.length,a,i,Q]),te=l.useCallback(m=>{h(c=>c.filter((b,N)=>N!==m)),v===m&&W(null)},[v]),B=l.useCallback(async()=>{if(n.length<a){f.error(`Du behöver ${a} foton`);return}if(d){f.success("Kameratest slutfört!",{description:"Foton sparades inte (testläge)."}),o();return}i&&n.filter(c=>c.validation&&!c.validation.certified_global_eligible).length>0&&f.warning("Vissa foton uppfyller inte Certified Global™-kraven",{description:"Du kan fortfarande skicka in, men dessa foton kanske inte godkänns."}),k(!0);try{if(!O){f.error("Du måste vara inloggad");return}for(let c=0;c<n.length;c++){const b=n[c],A=await(await fetch(b.dataUrl)).blob(),w=await ys(new File([A],`photo_${c}.jpg`,{type:"image/jpeg"}),`submissions/${O.id}/${r}`);if(!(w!=null&&w.url))throw new Error(`Kunde inte ladda upp foto ${c+1}`);await Se("/submissions",{claim_id:r,photo_url:w.url,ai_validated:!!b.validation,ai_validation_result:b.validation?JSON.parse(JSON.stringify(b.validation)):null})}try{await ws(`/claims/${r}`,{status:"approved",completed_at:new Date().toISOString()})}catch(c){console.error("Claim update error:",c)}const m=n.filter(c=>{var b;return(b=c.validation)==null?void 0:b.certified_global_eligible}).length;f.success("Foton inskickade!",{description:i&&m>0?`${m} av ${n.length} foton uppfyller Certified Global™-kraven.`:"Vi granskar dina foton och återkommer snart."}),o()}catch(m){console.error("Submit error:",m),f.error(m instanceof Error?m.message:"Kunde inte skicka in foton")}finally{k(!1)}},[n,a,i,d,o,r,O]),L=n.length>=a&&!n.some(m=>m.isValidating),M=v!==null?n[v]:null;return e.jsxs(e.Fragment,{children:[e.jsx(we,{children:t&&e.jsx(Qs,{onPhotoCapture:Y,onCancel:()=>u(!1),maxPhotos:a,currentPhotoCount:n.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(oe,{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(Zs,{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 (",n.length,"/",a,")"]}),n.length<a&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a-n.length," kvar"]})]}),e.jsxs("div",{className:`grid gap-3 ${n.length===0?"grid-cols-1":"grid-cols-2 sm:grid-cols-3"}`,children:[n.map((m,c)=>e.jsxs(U.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] ${v===c?"ring-2 ring-primary":""}`,onClick:()=>W(v===c?null:c),children:[e.jsx("img",{src:m.dataUrl,alt:`Foto ${c+1}`,className:"w-full h-full object-cover"}),m.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(D,{className:"w-6 h-6 animate-spin text-white"}),e.jsx("span",{className:"text-xs text-white",children:"Analyserar..."})]})}),m.validation&&!m.isValidating&&e.jsx("div",{className:`absolute bottom-2 right-2 px-2 py-1 rounded-full text-xs font-bold ${m.validation.certified_global_eligible?"bg-amber-500 text-white":m.validation.overall_score>=60?"bg-green-500/80 text-white":"bg-red-500/80 text-white"}`,children:m.validation.overall_score}),e.jsx("button",{onClick:b=>{b.stopPropagation(),te(c)},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(Te,{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:c+1})})]},m.timestamp)),n.length<a&&e.jsxs(U.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>u(!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 ${n.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 ${n.length===0?"w-16 h-16":"w-12 h-12"}`,children:e.jsx(R,{className:`text-primary ${n.length===0?"w-8 h-8":"w-6 h-6"}`})}),e.jsx("span",{className:`text-primary font-medium ${n.length===0?"text-base":"text-sm"}`,children:"Ta foto"}),n.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Tryck för att öppna kameran"})]})]})]}),e.jsx(we,{children:(M==null?void 0:M.validation)&&e.jsx(U.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},children:e.jsx(ct,{result:M.validation})})}),e.jsx(S,{onClick:B,disabled:!L||p,className:"w-full h-14 text-base font-semibold rounded-2xl",children:p?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-5 h-5 animate-spin mr-2"}),"Skickar in..."]}):n.some(m=>m.isValidating)?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-5 h-5 animate-spin mr-2"}),"Analyserar foton..."]}):L?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-5 h-5 mr-2"}),"Skicka in ",n.length," foton"]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-5 h-5 mr-2"}),"Ta ",a-n.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"]})]})]})},mt=({sponsor:s})=>{const a=s.colorPrimary||"#6366f1",r=s.rewardDescription||"Specialbelöning",o=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 d=i.currentTarget.parentElement;d&&(d.style.background=a,d.innerHTML=`<span style="font-size:24px;font-weight:bold;color:white;">${s.brandName.charAt(0)}</span>`)}}):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(et,{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(st,{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(tt,{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:o})]})]}),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 xt(){const[s,a]=l.useState(!1),[r,o]=l.useState(!1),i=l.useRef(null),{t:d}=se(),n=l.useCallback(async t=>{if(!(!t||t.trim().length===0)){i.current&&(i.current.pause(),i.current=null),a(!0);try{const u=await fetch("undefined/functions/v1/elevenlabs-tts",{method:"POST",headers:{"Content-Type":"application/json",apikey:void 0,Authorization:"Bearer undefined"},body:JSON.stringify({text:t})});if(!u.ok)throw new Error(`TTS request failed: ${u.status}`);const p=await u.blob(),k=URL.createObjectURL(p),v=new Audio(k);i.current=v,v.onplay=()=>o(!0),v.onended=()=>{o(!1),URL.revokeObjectURL(k),i.current=null},v.onerror=()=>{o(!1),URL.revokeObjectURL(k),i.current=null,f.error(d("tts.playbackError","Kunde inte spela upp ljud"))},await v.play()}catch(u){console.error("TTS error:",u),f.error(d("tts.error","Kunde inte generera tal"))}finally{a(!1)}}},[d]),h=l.useCallback(()=>{i.current&&(i.current.pause(),i.current=null,o(!1))},[]);return{speak:n,stop:h,isLoading:s,isPlaying:r}}function ut({text:s,className:a,variant:r="ghost",size:o="icon"}){const{speak:i,stop:d,isLoading:n,isPlaying:h}=xt(),t=()=>{h?d():i(s)};return e.jsx(S,{variant:r,size:o,onClick:t,disabled:n,className:T("transition-all",h&&"text-primary animate-pulse",a),title:h?"Stoppa uppläsning":"Läs upp",children:n?e.jsx(D,{className:"h-4 w-4 animate-spin"}):h?e.jsx(ks,{className:"h-4 w-4"}):e.jsx(_s,{className:"h-4 w-4"})})}var Ve="AlertDialog",[pt]=Rs(Ve,[Ee]),$=Ee(),Oe=s=>{const{__scopeAlertDialog:a,...r}=s,o=$(a);return e.jsx(Ds,{...o,...r,modal:!0})};Oe.displayName=Ve;var gt="AlertDialogTrigger",ft=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...o}=s,i=$(r);return e.jsx(Ms,{...i,...o,ref:a})});ft.displayName=gt;var ht="AlertDialogPortal",Le=s=>{const{__scopeAlertDialog:a,...r}=s,o=$(a);return e.jsx(As,{...o,...r})};Le.displayName=ht;var jt="AlertDialogOverlay",Fe=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...o}=s,i=$(r);return e.jsx(Es,{...i,...o,ref:a})});Fe.displayName=jt;var ze="AlertDialogContent",[bt,Nt]=pt(ze),Ue=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,children:o,...i}=s,d=$(r),n=l.useRef(null),h=Re(a,n),t=l.useRef(null);return e.jsx(bt,{scope:r,cancelRef:t,children:e.jsx(Cs,{role:"alertdialog",...d,...i,ref:h,onOpenAutoFocus:Ss(i.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=t.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:o})})});Ue.displayName=ze;var vt="AlertDialogTitle",Be=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...o}=s,i=$(r);return e.jsx(Ts,{...i,...o,ref:a})});Be.displayName=vt;var yt="AlertDialogDescription",Ge=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...o}=s,i=$(r);return e.jsx($s,{...i,...o,ref:a})});Ge.displayName=yt;var wt="AlertDialogAction",He=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...o}=s,i=$(r);return e.jsx(Me,{...i,...o,ref:a})});He.displayName=wt;var qe="AlertDialogCancel",Ke=l.forwardRef((s,a)=>{const{__scopeAlertDialog:r,...o}=s,{cancelRef:i}=Nt(qe,r),d=$(r),n=Re(a,i);return e.jsx(Me,{...d,...o,ref:n})});Ke.displayName=qe;var kt=Oe,_t=Le,Je=Fe,We=Ue,Qe=He,Ye=Ke,Xe=Be,Ze=Ge;const Dt=kt,At=_t,es=l.forwardRef(({className:s,...a},r)=>e.jsx(Je,{className:T("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}));es.displayName=Je.displayName;const ss=l.forwardRef(({className:s,...a},r)=>e.jsxs(At,{children:[e.jsx(es,{}),e.jsx(We,{ref:r,className:T("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})]}));ss.displayName=We.displayName;const ts=({className:s,...a})=>e.jsx("div",{className:T("flex flex-col space-y-2 text-center sm:text-left",s),...a});ts.displayName="AlertDialogHeader";const as=({className:s,...a})=>e.jsx("div",{className:T("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});as.displayName="AlertDialogFooter";const rs=l.forwardRef(({className:s,...a},r)=>e.jsx(Xe,{ref:r,className:T("text-lg font-semibold",s),...a}));rs.displayName=Xe.displayName;const is=l.forwardRef(({className:s,...a},r)=>e.jsx(Ze,{ref:r,className:T("text-sm text-muted-foreground",s),...a}));is.displayName=Ze.displayName;const ls=l.forwardRef(({className:s,...a},r)=>e.jsx(Qe,{ref:r,className:T(Pe(),s),...a}));ls.displayName=Qe.displayName;const ns=l.forwardRef(({className:s,...a},r)=>e.jsx(Ye,{ref:r,className:T(Pe({variant:"outline"}),"mt-2 sm:mt-0",s),...a}));ns.displayName=Ye.displayName;const Kt=()=>{var he,je,be;const{t:s}=se(),{id:a}=Ps(),r=Ce(),o=Is(),{user:i}=$e();Vs();const{isVerified:d,achievedIAL:n,checkStatus:h}=Js(i==null?void 0:i.id),{mission:t,loading:u,error:p}=Os(a),{goodExamples:k,badExamples:v,hasExamples:W,loading:Q}=qs(a),{latitude:O,longitude:Y,loading:te}=Ls(),[B,L]=l.useState(!1),[M,m]=l.useState(!1),[c,b]=l.useState(null),[N,A]=l.useState(!0),[w,P]=l.useState(null),[ce,de]=l.useState(!1),[F,me]=l.useState(!1),[G,xe]=l.useState(!1),[os,H]=l.useState(null),[ae,q]=l.useState(!1),[cs,ue]=l.useState(!1),[ds,ms]=l.useState(!1),I=Fs({enabled:ds,autoNavigate:!1}),pe=l.useCallback(()=>{try{const x=new(window.AudioContext||window.webkitAudioContext),g=(_,z)=>{const y=x.createOscillator(),C=x.createGain();y.connect(C),C.connect(x.destination),y.frequency.value=z,y.type="sine",C.gain.setValueAtTime(.3,_),C.gain.exponentialRampToValueAtTime(.01,_+.15),y.start(_),y.stop(_+.15)},j=x.currentTime;g(j,800),g(j+.2,1e3),g(j+.4,1200)}catch(x){console.log("Could not play warning sound:",x)}},[]),ge=l.useCallback(()=>{window.history.length>2?r(-1):r("/")},[r]),fe=(he=t==null?void 0:t.title)==null?void 0:he.toLowerCase().includes("busskur");l.useEffect(()=>{(async()=>{if(!i||!a){A(!1);return}const g=ie.getToken();if(!g){A(!1);return}try{const j=await fetch(`https://api.quixzoom.com/api/qz/missions/claims/active?mission_id=${encodeURIComponent(a)}`,{headers:{Authorization:`Bearer ${g}`}});if(j.ok){const _=await j.json();_.claim&&b(_.claim)}}catch(j){console.error("[MissionDetail] fetchActiveClaim error:",j)}A(!1)})()},[i,a]),l.useEffect(()=>{i!=null&&i.id&&h()},[i==null?void 0:i.id,h]),l.useEffect(()=>{i!=null&&i.id&&h()},[o.key]),l.useEffect(()=>{if(!(c!=null&&c.expires_at)){P(null),de(!1);return}const x=()=>{const j=new Date,z=new Date(c.expires_at).getTime()-j.getTime();if(z<=0){P("Utgången"),me(!1),f.error("Tiden har gått ut!",{description:"Uppdraget har släppts automatiskt."}),b(null);return}const y=Math.floor(z/6e4),C=Math.floor(z%6e4/1e3);P(`${y}:${C.toString().padStart(2,"0")}`);const V=y<3;me(V),V&&!ce&&(pe(),de(!0))};x();const g=setInterval(x,1e3);return()=>clearInterval(g)},[c==null?void 0:c.expires_at,ce,pe]),l.useEffect(()=>{const x=(t==null?void 0:t.active_until)||(t==null?void 0:t.expires_at);if(!x){H(null),q(!1);return}const g=()=>{const _=new Date,y=new Date(x).getTime()-_.getTime();if(y<=0){H(s("missionDetail.expired")),q(!1);return}const C=Math.floor(y/(1e3*60*60*24)),V=Math.floor(y%(1e3*60*60*24)/(1e3*60*60)),Ne=Math.floor(y%(1e3*60*60)/(1e3*60)),bs=Math.floor(y%(1e3*60)/1e3);C>0?(H(`${C}d ${V}h`),q(!1)):V>0?(H(`${V}h ${Ne}m`),q(V<2)):(H(`${Ne}:${bs.toString().padStart(2,"0")}`),q(!0))};g();const j=setInterval(g,1e3);return()=>clearInterval(j)},[t==null?void 0:t.active_until,t==null?void 0:t.expires_at]);const E=O&&Y&&t?zs(O,Y,t.latitude,t.longitude):null,K=fe||E!==null&&t&&E<=t.radius_meters,xs=async()=>{if(!i){r("/auth");return}if(!t||!fe&&!K)return;if(!d){r("/verify-identity?returnTo="+encodeURIComponent(window.location.pathname));return}L(!0);const x=ie.getToken();if(!x){f.error("Ingen giltig session — logga in igen"),L(!1);return}try{const g=await fetch("${import.meta.env.VITE_QZ_API_BASE}/missions/claims",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({mission_id:t.id})}),j=await g.json();g.ok?j.data&&(b({id:j.data.id,expires_at:j.data.expires_at}),j.reactivated?f.success(s("missionDetail.missionIsYoursAgain"),{description:s("missionDetail.youHave15Min")}):f.success(s("missionDetail.missionIsYours"),{description:s("missionDetail.youHave15Min")}),r(`/map?zoom-to=${t.latitude},${t.longitude}`)):f.error(s("missionDetail.couldNotClaim"),{description:j.error||`HTTP ${g.status}`})}catch{f.error(s("missionDetail.couldNotClaim"),{description:"Nätverksfel — försök igen"})}L(!1)},us=async()=>{if(!c)return;m(!0);const x=ie.getToken();if(!x){f.error("Ingen giltig session"),m(!1);return}try{const g=await fetch(`https://api.quixzoom.com/api/qz/missions/claims/${c.id}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({status:"expired"})});if(g.ok)b(null),f.success(s("missionDetail.missionReleased"),{description:s("missionDetail.someoneElseCanTake")});else{const j=await g.json();f.error(s("missionDetail.couldNotRelease"),{description:j.error||`HTTP ${g.status}`})}}catch{f.error(s("missionDetail.couldNotRelease"),{description:"Nätverksfel"})}m(!1)},ps=()=>{t&&r(`/map?zoom-to=${t.latitude},${t.longitude}`)};if(u)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(D,{className:"w-8 h-8 animate-spin text-primary"})});if(p||!t)return e.jsxs("div",{className:"min-h-screen bg-background p-6",children:[e.jsxs("button",{onClick:ge,className:"flex items-center gap-2 text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(ke,{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(_e,{className:"w-12 h-12 mx-auto text-destructive mb-4"}),e.jsx("h2",{className:"text-lg font-semibold",children:s("missionDetail.notFound")})]})]});const gs=!!c,fs={missionTitle:t.title,distanceMeters:E??void 0,targetDescription:t.target_description||void 0,instructions:t.instructions||void 0,sponsorReward:((je=t.sponsor)==null?void 0:je.rewardDescription)||void 0,sponsorBrand:((be=t.sponsor)==null?void 0:be.brandName)||void 0},hs=()=>E?E<=10?"photo":E<=50?"positioning":"navigation":"navigation",js=()=>{I.isPlaying?I.stop():(ms(!0),I.triggerState(hs(),fs))};return e.jsxs("div",{className:`min-h-screen bg-background safe-area-x ${gs?"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:ge,className:"flex items-center gap-2 text-muted-foreground hover:text-foreground touch-target",children:[e.jsx(ke,{className:"w-5 h-5"}),e.jsx("span",{className:"text-base",children:s("missionDetail.back")})]}),e.jsx(Us,{isLoading:I.isLoading,isPlaying:I.isPlaying,currentState:I.currentState,onPlay:js,onStop:I.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(ve,{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(ut,{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(R,{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 ${ae?"bg-destructive/10 border border-destructive/30":""}`,children:[e.jsx(le,{className:`w-5 h-5 mx-auto mb-1.5 ${ae?"text-destructive":"text-muted-foreground"}`}),e.jsx("p",{className:`text-2xl font-bold tabular-nums ${ae?"text-destructive animate-pulse":"text-foreground"}`,children:os||"∞"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s("missionDetail.timeLeft")})]})]}),t.sponsor&&e.jsx(mt,{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 ${K?"bg-success/20":"bg-secondary"}`,children:e.jsx(re,{className:`w-5 h-5 ${K?"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:te?"Hämtar...":E!==null?X(E):"Okänd"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:K?"Du är tillräckligt nära!":`Inom ${X(t.radius_meters)}`})]}),e.jsxs(S,{variant:"ghost",size:"sm",onClick:ps,className:"flex-shrink-0 h-8 px-2.5 rounded-lg text-xs",children:[e.jsx(Gs,{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(ve,{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(R,{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(J,{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(at,{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:"}),Q?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):W?e.jsxs("div",{className:"space-y-3",children:[k.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:k.map(x=>e.jsxs("div",{className:"relative aspect-[4/3] rounded-xl overflow-hidden border-2 border-success/40",children:[e.jsx("img",{src:x.image_url,alt:x.caption||"Godkänt exempel",loading:"lazy",referrerPolicy:"no-referrer",onError:g=>{g.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(J,{className:"w-3 h-3 text-white"}),e.jsx("span",{className:"text-[10px] text-white font-medium truncate",children:x.caption||"Godkänt"})]})})]},x.id))})]}),v.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:v.map(x=>e.jsxs("div",{className:"relative aspect-[4/3] rounded-xl overflow-hidden border-2 border-destructive/40",children:[e.jsx("img",{src:x.image_url,alt:x.caption||"Ej godkänt exempel",loading:"lazy",referrerPolicy:"no-referrer",onError:g=>{g.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(Z,{className:"w-3 h-3 text-white"}),e.jsx("span",{className:"text-[10px] text-white font-medium truncate",children:x.caption||"Ej godkänt"})]})})]},x.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(R,{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(J,{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(R,{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(Z,{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(_e,{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(re,{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 ",X(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(De,{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," krediter"]})]})})]}),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:X(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(rt,{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(le,{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(le,{className:"w-4 h-4 flex-shrink-0"}),e.jsxs("span",{children:["Uppdrag löper ut ",new Date(t.expires_at).toLocaleDateString("sv-SE")]})]}),c&&w&&!N&&e.jsxs("div",{className:`p-4 rounded-2xl flex items-center justify-between ${F?"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 ${F?"bg-destructive/20":"bg-primary/20"}`,children:e.jsx(De,{className:`w-5 h-5 ${F?"text-destructive":"text-primary"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:`font-semibold ${F?"text-destructive":"text-primary"}`,children:"Tid kvar"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:F?"Skynda dig!":"Slutför innan tiden går ut"})]})]}),e.jsx("div",{className:`text-3xl font-mono font-bold tabular-nums ${F?"text-destructive animate-pulse":"text-primary"}`,children:w})]}),(c||G)&&!N&&e.jsxs("div",{className:"glass-card p-5 rounded-2xl",children:[G&&!c&&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(it,{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(dt,{missionId:t.id,requiredPhotos:t.required_photos,claimId:(c==null?void 0:c.id)||"test-mode",isTestMode:G&&!c,onComplete:()=>{G&&!c?(f.success("Kameratest slutfört!",{description:"Foton sparades inte (testläge)."}),xe(!1)):(f.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:N?e.jsxs(S,{disabled:!0,className:"w-full h-12 text-base rounded-xl",children:[e.jsx(D,{className:"w-5 h-5 animate-spin mr-2"}),"Laddar..."]}):G?e.jsxs(S,{onClick:()=>xe(!1),variant:"outline",className:"w-full h-12 text-base rounded-xl border-amber-500/50 text-amber-600",children:[e.jsx(Z,{className:"w-5 h-5 mr-2"}),"Avsluta testläge"]}):c?e.jsxs(S,{onClick:us,disabled:M,variant:"outline",className:"w-full h-12 text-base rounded-xl",children:[M?e.jsx(D,{className:"w-5 h-5 animate-spin mr-2"}):e.jsx(Z,{className:"w-5 h-5 mr-2"}),"Släpp uppdraget"]}):K?e.jsxs("div",{className:"space-y-2",children:[!d&&e.jsx(Ie,{achievedIAL:n,requiredIAL:"IAL2"}),e.jsxs(S,{onClick:()=>ue(!0),disabled:B||!d,className:"w-full h-11 text-sm font-semibold bg-primary hover:bg-primary/90 rounded-xl",children:[B?e.jsx(D,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),"Ta uppdraget"]})]}):e.jsx("div",{className:"space-y-2",children:e.jsxs(S,{disabled:!0,className:"w-full h-12 text-base opacity-60 rounded-xl",children:[e.jsx(re,{className:"w-5 h-5 mr-2"}),"Gå närmare för att ta uppdraget"]})})}),e.jsx(Dt,{open:cs,onOpenChange:ue,children:e.jsxs(ss,{className:"max-w-[340px] rounded-2xl",children:[e.jsxs(ts,{children:[e.jsx(rs,{className:"text-lg",children:"Ta uppdraget?"}),e.jsxs(is,{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(as,{className:"flex-row gap-2",children:[e.jsx(ns,{className:"flex-1 mt-0",children:"Avbryt"}),e.jsxs(ls,{onClick:xs,className:"flex-1 bg-primary hover:bg-primary/90",children:[B?e.jsx(D,{className:"w-4 h-4 animate-spin mr-2"}):null,"Ja, ta uppdraget"]})]})]})}),e.jsx(Hs,{})]})};export{Kt as default};
|
||
//# sourceMappingURL=MissionDetail-Bkj3Z1-2.js.map
|