PageSourceSearch

https://elzewhere.com/assets/Record-V50GGVno.js

js elzewhere.com collected 2026-10-09 05:15:45 UTC 68,107 bytes, 7 lines download raw bytes

1import{r,j as e}from"./radix-BKGOUGPy.js";import{c as H,u as ee,f as te,t as n,p as g,X as je,d as z,m as Lt,a as qt,L as _t,q as be}from"./index-CQ3mh-re.js";import{a as Kt,o as Ut}from"./ShareButton-Dzi-aoeR.js";import{u as _}from"./useQuery-DT7BwPXL.js";import{u as T,L as _e}from"./Layout-ClRIc5KF.js";import{P as Bt}from"./PageState-Tb6Ikd4T.js";import{C as Ht,a as Qt}from"./CorrectDetailDialog-3mN0Lvva.js";import{B as o}from"./button-DVXdkXF8.js";import{T as He}from"./textarea-B2fCvs3Z.js";import{S as xt,a as gt,b as bt,c as jt,d as K,E as Yt,A as Vt}from"./select-CNlsli4_.js";import{a as U,A as Gt,D as Wt}from"./schema-CQW2MjS5.js";import{u as Jt}from"./useSEO-DFpC2sg1.js";import{D as se,a as ae,d as re,b as ie,c as ne,f as Ye}from"./dialog-C04An0tB.js";import{I as Ke}from"./input-1MsrCV3N.js";import{L as Ue}from"./label-B1wxkk0b.js";import{L as Xt}from"./LocationPicker-BuYP6PjZ.js";import{C as ye}from"./camera-DCuiu_ly.js";import{U as Zt}from"./upload-B7Gp7dFB.js";import{M as Ct}from"./message-square-BQZwJ9v1.js";import{M as Qe}from"./map-pin-CO2c6oL5.js";import{f as O}from"./format-Cwb9Zj0H.js";import{C as Be}from"./check-CyzPzt_C.js";import{T as es}from"./trash-2-BduVB9Em.js";import{T as ts,C as yt}from"./tag-BzuoE29e.js";import{E as ft}from"./eye-BCh0BLUG.js";import{C as vt}from"./chevron-right-DNk19cPm.js";import{C as ss}from"./sun-B6ctUv83.js";import{S as as}from"./sparkles-78jTBfkM.js";import{S as Nt}from"./share-2-q8RhTvDF.js";import{F as wt}from"./flag-C-eVEWGO.js";import{T as rs}from"./triangle-alert-BOBIqv1b.js";import{R as B}from"./refresh-cw-DOEVmfI7.js";import{E as is}from"./external-link-CH16l20p.js";import{C as kt}from"./chevron-left-DEL0G3sJ.js";import{C as ns}from"./chevron-up-C2P4PJt3.js";import{C as os}from"./chevron-down-XIFEHD3n.js";import"./mapbox-DYU4mihP.js";import"./circle-CqI9K94X.js";import"./link-2-JquDTt0Q.js";import"./user-B0xt_bjv.js";import"./types-DqHNHyJ7.js";import"./geolocation-89ElFUOl.js";/* empty css                  */import"./en-US-DaTnBiBt.js";const ds=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ls=H("code-xml",ds);const cs=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],fe=H("file-text",cs);const ms=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],zt=H("hash",ms);const hs=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],us=H("history",hs);const ps=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],xs=H("qr-code",ps);const gs=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],bs=H("star",gs);function js({isOpen:i,onClose:h,recordId:u,publicId:l}){const{session:F}=ee(),D=te(),C=r.useRef(null),[c,I]=r.useState([]),[b,E]=r.useState([]),[j,v]=r.useState(!1),y=T({mutationFn:async s=>{const x=new FormData;
1s.forEach(k=>x.append("images",k));const w=await g(`/api/records/${u}/add-photos`,{method:"POST",headers:{Authorization:`Bearer ${F?.access_token}`},body:x});if(!w.ok){const k=await w.json();throw new Error(k.error||"Failed to upload photos")}return w.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["/api/records",l]}),n.success("Photos added successfully"),Y()},onError:s=>{n.error(s.message)}}),p=s=>{const x=s.filter(P=>P.type.startsWith("image/"));if(x.length===0)return;const w=[...c,...x].slice(0,5);I(w);const k=w.map(P=>URL.createObjectURL(P));b.forEach(P=>URL.revokeObjectURL(P)),E(k)},M=s=>{const x=Array.from(s.target.files||[]);p(x)},R=s=>{s.preventDefault(),s.stopPropagation(),v(!0)},oe=s=>{s.preventDefault(),s.stopPropagation(),v(!1)},ve=s=>{s.preventDefault(),s.stopPropagation(),v(!1);const x=Array.from(s.dataTransfer.files);p(x)},Q=s=>{if(!i)return;const x=s.clipboardData?.items;if(!x)return;const w=[];for(let k=0;k<x.length;k++)if(x[k].type.startsWith("image/")){const P=x[k].getAsFile();if(P){const de=new File([P],`pasted-image-${Date.now()}.png`,{type:P.type});w.push(de)}}w.length>0&&(s.preventDefault(),p(w),n.success(`Pasted ${w.length} image${w.length>1?"s":""}`))};r.useEffect(()=>{if(i)return document.addEventListener("paste",Q),()=>document.removeEventListener("paste",Q)},[i,c]);const Ne=s=>{const x=c.filter((w,k)=>k!==s);I(x),URL.revokeObjectURL(b[s]),E(b.filter((w,k)=>k!==s))},Y=()=>{I([]),b.forEach(s=>URL.revokeObjectURL(s)),E([]),h()},N=()=>{c.length!==0&&y.mutate(c)};return e.jsx(se,{open:i,onOpenChange:Y,children:e.jsxs(ae,{className:"bg-elz-ink border-elz max-w-md",children:[e.jsxs(re,{children:[e.jsxs(ie,{className:"flex items-center gap-2 text-elz-primary",children:[e.jsx(ye,{className:"w-5 h-5 text-amber-600"}),"Add Photos"]}),e.jsx(ne,{className:"text-elz-muted",children:"Add up to 5 additional photos to this record."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:C,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:M,"data-testid":"input-photo-file"}),b.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:b.map((s,x)=>e.jsxs("div",{className:"relative aspect-square","data-testid":`preview-photo-${x}`,children:[e.jsx("img",{src:s,alt:`Preview ${x+1}`,className:"w-full h-full object-cover rounded-lg"}),e.jsx("button",{onClick:()=>Ne(x),className:"absolute top-1 right-1 p-1 bg-black/60 rounded-full","data-testid":`btn-remove-photo-${x}`,children:e.jsx(je,{className:"w-3 h-3 text-elz-primary"})})]},x))}),c.length<5&&e.jsxs("div",{onDragOver:R,onDragLeave:oe,onDrop:ve,onClick:()=>C.current?.click(),className:`
2                w-full p-6 border-2 border-dashed rounded-lg cursor-pointer
3                transition-colors duration-200 flex flex-col items-center justify-center gap-2
4                ${j?"border-amber-500 bg-amber-600/10":"border-elz hover:border-slate-600 bg-elz-surface"}
5              `,"data-testid":"dropzone-photos",children:[e.jsx(Zt,{className:`w-8 h-8 ${j?"text-amber-600":"text-elz-muted"}`}),e.jsx("p",{className:"text-sm text-elz-muted text-center",children:j?"Drop photos here":c.length===0?"Drag, paste, or tap to add photos":"Drag, paste, or tap to add more"}),e.jsxs("p",{className:"text-xs text-elz-muted",children:[5-c.length," photo",5-c.length!==1?"s":""," remaining • Ctrl+V to paste"]})]})]}),e.jsxs(Ye,{children:[e.jsx(o,{variant:"ghost",onClick:Y,"data-testid":"btn-cancel-photo",children:"Cancel"}),e.jsxs(o,{onClick:N,disabled:c.length===0||y.isPending,"data-testid":"btn-submit-photo",children:[y.isPending?e.jsx(z,{className:"w-4 h-4 animate-spin mr-2"}):null,"Upload ",c.length>0?`(${c.length})`:""]})]})]})})}function ys({isOpen:i,onClose:h,recordId:u,publicId:l,currentValue:F}){const{session:D}=ee(),C=te(),[c,I]=r.useState(F||""),b=c.length,E=b>0&&b<20;r.useEffect(()=>{i&&I(F||"")},[i,F]);const j=T({mutationFn:async y=>{if(y.length<20)throw new Error("Notes must be at least 20 characters for AI enrichment.");const p=await g(`/api/records/${u}/notes`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${D?.access_token}`},body:JSON.stringify({notes:y})});if(!p.ok){const M=await p.json();throw new Error(M.error||"Failed to update notes")}return p.json()},onSuccess:()=>{C.invalidateQueries({queryKey:["/api/records",l]}),C.invalidateQueries({queryKey:["/api/records/stories",l]}),n.success("Notes added successfully"),h()},onError:y=>{n.error(y.message)}}),v=()=>{j.mutate(c)};return e.jsx(se,{open:i,onOpenChange:h,children:e.jsxs(ae,{className:"bg-elz-ink border-elz max-w-md",children:[e.jsxs(re,{children:[e.jsxs(ie,{className:"flex items-center gap-2 text-elz-primary",children:[e.jsx(Ct,{className:"w-5 h-5 text-emerald-500"}),"Add Note"]}),e.jsxs(ne,{className:"text-elz-muted",children:["Add personal notes or additional context about this observation.",e.jsx("span",{className:"block mt-1 font-medium text-elz-accent-deep italic",children:"Minimum 20 characters required for AI enrichment."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(He,{value:c,onChange:y=>I(y.target.value),placeholder:"Add any notes, context, or details...",className:`min-h-[120px] bg-elz-border border-elz text-elz-primary ${E?"border-red-500 focus-visible:ring-red-500":""}`,"data-testid":"input-notes"}),e.jsxs("div",{className:"flex justify-between items-center px-1",children:[e.jsxs("span",{className:`text-xs font-mono ${E?"text-red-500":"text-elz-muted"}`,children:[b," / 20 characters minimum"]}),E&&e.jsx("span",{className:"text-[10px] text-red-500 font-medium uppercase tracking-tighter",children:"Too short for AI enrichment"})]})]}),e.jsxs(Ye,{children:[e.jsx(o,{variant:"ghost",onClick:h,"data-testid":"btn-cancel-note",children:"Cancel"}),e.jsxs(o,{onClick:v,disabled:j.isPending||c.length<20,"data-testid":"btn-submit-note",className:c.length<20?"opacity-50 cursor-not-allowed":"",children:[j.isPending?e.jsx(z,{className:"w-4 h-4 animate-spin mr-2"}):null,"Save Note"]})]})]})})}function fs({isOpen:i,onClose:h,recordId:u,publicId:l,currentLatitude:F,currentLongitude:D,currentLocalArea:C}){const{session:c}=ee(),I=te(),b=T({mutationFn:async j=>{const v=await g(`/api/records/${u}/location`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c?.access_token}`},body:JSON.stringify(j)});if(!v.ok){const y=await v.json();throw new Error(y.error||"Failed to update location")}return v.json()},onSuccess:()=>{I.invalidateQueries({queryKey:["/api/records"]}),I.invalidateQueries({queryKey:["/api/records/unattached/map"]}),I.invalidateQueries({queryKey:["/api/subjects/map"]}),n.success("Location updated successfully"),h()},onError:j=>{n.error(j.message)}}),E=(j,v)=>{b.isPending||b.mutate({latitude:j,longitude:v})};return e.jsx(se,{open:i,onOpenChange:h,children:e.jsxs(ae,{className:"bg-elz-ink border-elz max-w-md p-4",children:[e.jsxs(re,{children:[e.jsxs(ie,{className:"flex items-center gap-2 text-elz-primary",children:[e.jsx(Qe,{className:"w-5 h-5 text-cyan-500"}),"Fix Location"]}),e.jsx(ne,{className:"text-elz-muted",children:"Tap the map to place a pin where this was taken."})]}),i&&e.jsx(Xt,{onConfirm:E,onCancel:h,initialLatitude:F??void 0,initialLongitude:D??void 0,height:"280px"}),b.isPending&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-amber-400 text-sm py-2",children:[e.jsx(z,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Updating location…"})]})]})})}function vs({isOpen:i,onClose:h,recordId:u,publicId:l}){const{session:F}=ee(),D=te(),[C,c]=r.useState(""),[I,b]=r.useState(""),[E,j]=r.useState("");r.useEffect(()=>
5{i&&(c(""),b(""),j(""))},[i]);const v=T({mutationFn:async p=>{const M=await g(`/api/records/${u}/details`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F?.access_token}`},body:JSON.stringify(p)});if(!M.ok){const R=await M.json();throw new Error(R.error||"Failed to update details")}return M.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["/api/records",l]}),n.success("Details updated successfully"),h()},onError:p=>{n.error(p.message)}}),y=()=>{const p={};if(C.trim()&&(p.identityPrimary=C.trim()),I.trim()&&(p.identitySecondary=I.trim()),E.trim()&&(p.title=E.trim()),Object.keys(p).length===0){n.error("Please provide at least one detail to update");return}v.mutate(p)};return e.jsx(se,{open:i,onOpenChange:h,children:e.jsxs(ae,{className:"bg-elz-ink border-elz max-w-md",children:[e.jsxs(re,{children:[e.jsxs(ie,{className:"flex items-center gap-2 text-elz-primary",children:[e.jsx(fe,{className:"w-5 h-5 text-amber-500"}),"Add Details"]}),e.jsx(ne,{className:"text-elz-muted",children:"Add or update identification details for this record."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(Ue,{className:"text-elz-muted",children:"Primary Identity"}),e.jsx(Ke,{value:C,onChange:p=>c(p.target.value),placeholder:"e.g., BNSF 7890, RISK tag, Water Tower #42",className:"mt-1 bg-elz-border border-elz text-elz-primary","data-testid":"input-identity-primary"}),e.jsx("p",{className:"text-xs text-elz-muted mt-1",children:"The main identifying feature"})]}),e.jsxs("div",{children:[e.jsx(Ue,{className:"text-elz-muted",children:"Secondary Identity"}),e.jsx(Ke,{value:I,onChange:p=>b(p.target.value),placeholder:"e.g., ES44DC, Freight graffiti, 1920s construction",className:"mt-1 bg-elz-border border-elz text-elz-primary","data-testid":"input-identity-secondary"}),e.jsx("p",{className:"text-xs text-elz-muted mt-1",children:"Additional classification or type"})]}),e.jsxs("div",{children:[e.jsx(Ue,{className:"text-elz-muted",children:"Title / Display Name"}),e.jsx(Ke,{value:E,onChange:p=>j(p.target.value),placeholder:"e.g., BNSF Locomotive at Chicago Yard",className:"mt-1 bg-elz-border border-elz text-elz-primary","data-testid":"input-title"})]})]}),e.jsxs(Ye,{children:[e.jsx(o,{variant:"ghost",onClick:h,"data-testid":"btn-cancel-details",children:"Cancel"}),e.jsxs(o,{onClick:y,disabled:v.isPending,"data-testid":"btn-submit-details",children:[v.isPending?e.jsx(z,{className:"w-4 h-4 animate-spin mr-2"}):null,"Save Details"]})]})]})})}function $({title:i,icon:h,children:u,defaultOpen:l=!0,testId:F,titleClassName:D}){const[C,c]=r.useState(l);return e.jsxs("div",{className:"border-b border-elz","data-testid":`section-${F}`,children:[e.jsxs("button",{onClick:()=>c(!C),className:"w-full flex items-center justify-between py-3 px-4 text-left hover:bg-elz-surface transition-colors","data-testid":`btn-toggle-${F}`,children:[e.jsxs("div",{className:`flex items-center gap-2 ${D||"text-elz-muted"}`,children:[h,e.jsx("span",{className:"text-xs font-bold uppercase tracking-wide",children:i})]}),C?e.jsx(ns,{className:"w-4 h-4 text-elz-muted"}):e.jsx(os,{className:"w-4 h-4 text-elz-muted"})]}),C&&e.jsx("div",{className:"px-4 pb-4",children:u})]})}function ha(){const{publicId:i}=Lt(),[,h]=qt(),{user:u,session:l}=ee(),[F,D]=r.useState(!1),[C,c]=r.useState(!1),[I,b]=r.useState(!1),[E,j]=r.useState(!1),[v,y]=r.useState(!1);r.useEffect(()=>{const t=new URLSearchParams(window.location.search);if(u&&t.get("correct")==="1"){y(!0),t.delete("correct");const a=t.toString();window.history.replaceState(window.history.state,"",window.location.pathname+(a?`?${a}`:""))}},[u,i]);const[p,M]=r.useState(!1),[R,oe]=r.useState(!1),[ve,Q]=r.useState(!1),[Ne,Y]=r.useState(0),N=te(),{data:s,isLoading:x,error:w,refetch:k,isFetching:P}=_({queryKey:["/api/records",i],queryFn:async()=>{if(!i)throw new Error("No publicId provided");const t=await g(`/api/records/${i}`,{credentials:"include"});if(!t.ok)throw new Error("Record not found");return t.json()},enabled:!!i,retry:!1,refetchInterval:t=>t.state.data?.status==="DRAFT"&&!t.state.error&&!R?2e3:!1});r.useEffect(()=>{if(oe(!1),Q(!1),s?.status!=="DRAFT")return;const t=window.setTimeout(()=>Q(!0),3e4),a=window.setTimeout(()=>
5oe(!0),9e4);return()=>{window.clearTimeout(t),window.clearTimeout(a)}},[i,s?.status,Ne]);const de=async()=>{(await k()).isError||Y(a=>a+1)},It=s?.title||s?.identityPrimary||"Record",St=s?.aiEnrichment?.narrativeSummary??(s?.localArea?`Observed in ${s.localArea}`:"An observation on Elzewhere");Jt({title:It,description:St,canonical:i?`/record/${i}`:void 0});const{data:le}=_({queryKey:["/api/records/suggestions",s?.id],queryFn:async()=>{if(!s?.id)return[];const t=await g(`/api/records/${s.id}/suggestions`);return t.ok?t.json():[]},enabled:!!s?.id&&s?.status==="MYSTERY"}),{data:A}=_({queryKey:["/api/subjects",s?.subjectId],queryFn:async()=>{if(!s?.subjectId)throw new Error("No subject");const t=await g(`/api/subjects/${s.subjectId}`);if(!t.ok)throw new Error("Subject not found");return t.json()},enabled:!!s?.subjectId}),{data:we}=_({queryKey:["/api/venues"],queryFn:async()=>{const t=await g("/api/venues",{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch venues");return t.json()},enabled:!!s?.venueId||!!A?.subject?.venueId,staleTime:6e4});r.useMemo(()=>{const t=s?.venueId??A?.subject?.venueId;return!t||!we?null:we.find(a=>a.id===t)??null},[s?.venueId,A?.subject?.venueId,we]);const[ce,V]=r.useState(!1);r.useEffect(()=>{V(!1)},[i]);const[ke,Ve]=r.useState(""),[ze,Ge]=r.useState(""),[We,Je]=r.useState(""),[Xe,Ze]=r.useState(""),Ce=T({mutationFn:async()=>{if(!s?.id)throw new Error("No record");if(!l?.access_token)throw new Error("Please log in to submit suggestions");const t=await g(`/api/records/${s.id}/suggestions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({proposedDpt:ke,proposedIdentityPrimary:ze||null,proposedIdentitySecondary:We||null,reasoning:Xe||null})});if(!t.ok){const a=await t.json();throw new Error(a.error||"Failed to submit suggestion")}return t.json()},onSuccess:()=>{n.success("Suggestion submitted!"),V(!1),Ve(""),Ge(""),Je(""),Ze(""),N.invalidateQueries({queryKey:["/api/records/suggestions",s?.id]})},onError:t=>{n.error(t.message)}}),me=T({mutationFn:async({suggestionId:t,voteType:a})=>{if(!l?.access_token)throw new Error("Please log in to vote");const d=await g(`/api/records/suggestions/${t}/vote`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({voteType:a})});if(!d.ok){const qe=await d.json();throw new Error(qe.error||"Failed to vote")}return d.json()},onSuccess:()=>{n.success("Vote recorded!"),N.invalidateQueries({queryKey:["/api/records/suggestions",s?.id]})},onError:t=>{n.error(t.message)}}),et=T({mutationFn:async t=>{if(!l?.access_token)throw new Error("Please log in to accept suggestions");const a=await g(`/api/records/suggestions/${t}/accept`,{method:"POST",headers:{Authorization:`Bearer ${l.access_token}`}});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to accept")}return a.json()},onSuccess:()=>{n.success("Mystery solved! +6 NP awarded to solver"),N.invalidateQueries({queryKey:["/api/records",i]}),N.invalidateQueries({queryKey:["/api/records/suggestions",s?.id]}),N.invalidateQueries({queryKey:["/api/auth/me"]}),N.invalidateQueries({queryKey:["/api/users/me"]}),N.invalidateQueries({queryKey:["/api/leaderboard"]})},onError:t=>{n.error(t.message)}}),Et=r.useCallback(()=>{window.history.length>1?window.history.back():h("/compass")},[h]),Ie=e.jsx(o,{variant:"ghost",size:"icon",className:"text-elz-muted hover:text-elz-primary -ml-2",onClick:Et,"data-testid":"btn-back",children:e.jsx(kt,{className:"w-5 h-5"})}),f=T({mutationFn:async({deepThink:t=!1,modelId:a}={})=>{if(!s)throw new Error("No record");if(!l?.access_token)throw new Error("Not authenticated");const d=await g(`/api/admin/records/${s.publicId}/rescan`,{method:"POST",headers:{Authorization:`Bearer ${l.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({deepThink:t,modelId:a})});if(!d.ok){const qe=await d.json();throw new Error(qe.error||"Failed to rescan")}return d.json()},onSuccess:t=>{n.success(`Rescan complete! Analyzed ${t.stats.photosAnalyzed} photos, found ${t.stats.observationsFound} observations`),N.invalidateQueries({queryKey:["/api/records"]}),N.invalidateQueries({queryKey:["/api/records/feed"]}),N.invalidateQueries({queryKey:["/api/admin/records"]})},onError:t=>{n.error(t.message)}}),Se=T({mutationFn:async t=>{if(!s)throw new Error("No record");if(!l?.access_token)throw new Error("Not authenticated");const a=await g(`/api/admin/records/${s.publicId}/swap-primary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({newPrimaryUrl:t})});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to swap primary photo")}return a.json()},onSuccess:()=>{n.success("Primary photo updated!"),N.invalidateQueries({queryKey:["/api/records",i]})},onError:t=>{n.error(t.message)}}),Ee=T({mutationFn:async t=>{if(!s)throw new Error("No record");if(!l?.access_token)throw new Error("Not authenticated");const a=await g(`/api/admin/records/${s.publicId}/unlist`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({isUnlisted:t})});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to update visibility")}return a.json()},onSuccess:t=>{n.success(t.isUnlisted?"Record unlisted":"Record is now visible"),N.invalidateQueries({queryKey:["/api/records",i]})},onError:t=>{n.error(t.message)}}),Pe=T({mutationFn:async()=>
5{if(!s)throw new Error("No record");if(!l?.access_token)throw new Error("Not authenticated");const t=await g(`/api/admin/records/${s.publicId}/convert-to-venue`,{method:"POST",headers:{Authorization:`Bearer ${l.access_token}`}});if(!t.ok){const a=await t.json();throw new Error(a.error||"Conversion failed")}return t.json()},onSuccess:t=>{n.success("Finding converted to venue"),h(`/venue/${t.venue.publicId}`)},onError:t=>{n.error(t.message)}}),he=T({mutationFn:async t=>{if(!s)throw new Error("No record");if(!l?.access_token)throw new Error("Not authenticated");const a=await g(`/api/admin/records/${s.publicId}/photo`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({photoUrl:t})});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to delete photo")}return a.json()},onSuccess:()=>{n.success("Photo deleted"),N.invalidateQueries({queryKey:["/api/records",i]})},onError:t=>{n.error(t.message)}}),[Pt,tt]=r.useState(!1),[Tt,st]=r.useState(!1),[at,G]=r.useState(null),[W,Te]=r.useState(0),[Ft,ue]=r.useState(!1),[Fe,rt]=r.useState(""),[it,nt]=r.useState(""),[pe,ot]=r.useState(""),{data:Ae=[]}=_({queryKey:["/api/records/stories",i],queryFn:async()=>{if(!i)return[];const t=await g(`/api/records/${i}/stories`);return t.ok?t.json():[]},enabled:!!i}),De=T({mutationFn:async t=>{if(!l?.access_token)throw new Error("Please sign in to add your story");const a=await g(`/api/records/${i}/stories`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({body:t})});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to add story")}return a.json()},onSuccess:t=>{ot(""),t.np?.awarded?n.success(`Story added! +${t.np.awarded} NP`):n.success("Story added!"),N.invalidateQueries({queryKey:["/api/records/stories",i]})},onError:t=>{n.error(t.message)}}),{data:$e=[]}=_({queryKey:["/api/records/nearby",s?.latitude,s?.longitude],queryFn:async()=>{if(!s?.latitude||!s?.longitude)return[];const t=await g(`/api/records?nearby=${s.latitude},${s.longitude}&limit=6`);return t.ok?(await t.json()).filter(d=>d.publicId!==s.publicId).slice(0,5):[]},enabled:!!s?.latitude&&!!s?.longitude}),{data:dt=[]}=_({queryKey:["/api/records/similar",s?.dptKey,s?.publicId],queryFn:async()=>{if(!s?.dptKey||s.dptKey==="unknown")return[];const t=await g(`/api/records?dpt=${s.dptKey}`);return t.ok?(await t.json()).filter(d=>d.publicId!==s.publicId).slice(0,5):[]},enabled:!!s?.dptKey&&s.dptKey!=="unknown"}),S=r.useMemo(()=>s?[s.primaryImageUrl,...s.additionalImageUrls||[]]:[],[s]),lt=r.useCallback(t=>{const a=S.indexOf(t);Te(a>=0?a:0),G(t)},[S]),J=r.useCallback(t=>{const a=t==="next"?(W+1)%S.length:(W-1+S.length)%S.length;Te(a),G(S[a])},[W,S]),ct=r.useRef(0),Me=r.useRef(0),At=r.useCallback(t=>{ct.current=t.touches[0].clientX,Me.current=t.touches[0].clientX},[]),Dt=r.useCallback(t=>{Me.current=t.touches[0].clientX},[]),$t=r.useCallback(()=>{const t=ct.current-Me.current;Math.abs(t)>50&&S.length>1&&(t>0?J("next"):J("prev"))},[S.length,J]),Oe=T({mutationFn:async t=>{const a=await g(`/api/records/${s?.publicId}/report`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to report")}return a.json()},onSuccess:()=>{n.success("Report submitted. This record is now under review."),ue(!1),rt(""),nt(""),N.invalidateQueries({queryKey:["/api/records",i]})},onError:t=>{n.error(t.message)}}),Re=T({mutationFn:async()=>{if(!s)throw new Error("No record");if(!l?.access_token)throw new Error("Not authenticated");const t=await g(`/api/records/${s.publicId}`,{method:"DELETE",headers:{Authorization:`Bearer ${l.access_token}`}});if(!t.ok){const a=await t.json();throw new Error(a.error||"Failed to delete record")}return t.json()},onSuccess:()=>{n.success("Record deleted"),h("/compass")},onError:t=>{n.error(t.message)}});if(x)return e.jsx(_e,{headerLeft:Ie,children:e.jsxs("div",{className:"pb-20 animate-pulse","data-testid":"loading-state",children:[e.jsx("div",{className:"w-full aspect-[4/3] bg-elz-border"}),e.jsxs("div",{className:"px-4 py-5 border-b border-elz",children:[e.jsx("div",{className:"h-7 bg-elz-border rounded w-3/4 mb-3"}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("div",{className:"h-5 bg-elz-border rounded w-24"}),e.jsx("div",{className:"h-5 bg-elz-border rounded w-16"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-1 bg-amber-600/20 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-elz-border rounded w-full"}),e.jsx("div",{className:"h-4 bg-elz-border rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-elz-border rounded w-2/3"})]})]})]}),e.jsxs("div",{className:"px-4 py-4 border-b border-elz",children:[e.jsx("div",{className:"h-4 bg-elz-border rounded w-28 mb-3"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-elz-border mt-1.5"}),e.jsx("div",{className:"h-4 bg-elz-border rounded w-3/4"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-elz-border mt-1.5"}),e.jsx("div",{className:"h-4 bg-elz-border rounded w-1/2"})]})]})]}),e.jsx("div",{className:"px-4 py-3 border-b border-elz",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"h-6 bg-elz-border rounded w-20"}),e.jsx("div",{className:"h-6 bg-elz-border rounded w-24"}),e.jsx("div",{className:"h-6 bg-elz-border rounded w-16"})]})}),e.jsx("div",{className:"px-4 py-4",children:e.jsx("div",{className:"h-40 bg-elz-border rounded-lg"})})]})});if(!s)return e.jsx(_e,{headerLeft:Ie,children:e.jsx(Bt,{title:"We couldn’t load this find",description:"Try again to check the connection. The photo may also have been removed or its link changed.",onRetry:()=>k(),retrying:P,children:e.jsx(o,{variant:"outline",onClick:()=>
5h("/feed"),children:"Explore other finds"})})});const m=s.aiEnrichment,xe=m?.placeNarrative||A?.subject?.canonicalNarrative,X=m?.narrativeSummary,Mt=Array.isArray(s.keyFacts)?s.keyFacts:Array.isArray(m?.factualSummary)?m.factualSummary:[],Ot=!!m?.userCorrection,Rt=["location","locationContext","environment","local_area","localArea","region","city","state","country","coordinates","gps","latitude","longitude","area","place","address","neighborhood","district","county","province"],mt=(m?.confirmChips||[]).filter(t=>!Rt.includes(t.field?.toLowerCase())),Le=m?.textFound||[],ht=m?.observations||[],ut=m?.suggestedTags||[];m?.primaryObservations;const ge=U(s.childDptKey||s.dptKey||s.parentDptKey||"unknown"),L=s.identityPrimary||m?.identityPrimary||m?.titleSuggestion||s.title||ge,Z=u?.id===s.userId,pt=!!u,q=u?.email===Gt||u?.role==="admin";return e.jsxs(_e,{headerLeft:Ie,children:[e.jsxs("div",{className:"pb-20 elz-editorial","data-testid":"record-page",children:[w&&e.jsxs("section",{className:"m-4 rounded-xl border border-elz bg-elz-elevated p-4",role:"alert","data-testid":"identification-connection-error",children:[e.jsx("p",{className:"font-semibold text-elz-primary",children:"We couldn’t check for an update"}),e.jsx("p",{className:"mt-2 text-sm text-elz-secondary",children:"Your saved photo is still here. Check your connection and try again."}),e.jsx(o,{variant:"outline",className:"mt-3",disabled:P,onClick:de,children:P?"Checking…":"Check for an update"})]}),(s.status==="DRAFT"||s.status==="PENDING_LOCATION")&&e.jsxs("section",{className:"m-4 rounded-xl border border-elz bg-elz-elevated p-4",role:"status","aria-live":"polite","data-testid":"identification-progress",children:[e.jsx("p",{className:"font-semibold text-elz-primary",children:s.status==="PENDING_LOCATION"?"Your photo is saved for location review":R?"Your photo is saved. Identification is taking longer.":ve?"Still looking at your photo…":"Finding out what’s in your photo…"}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-elz-secondary",children:s.status==="PENDING_LOCATION"?"We’ll check the pin before identifying and listing your photo.":R?"Automatic checking has paused. Check for an update to resume, or return to this page later. You don’t need to upload again.":"The result will appear here when it’s ready. Your photo is saved, so you can leave and come back to this page."}),!w&&(s.status==="PENDING_LOCATION"||R)&&e.jsx(o,{variant:"outline",className:"mt-3","data-testid":"btn-check-identification",disabled:P,onClick:de,children:P?"Checking…":"Check for an update"})]}),e.jsxs("div",{className:"ed-meta-strip",children:[e.jsxs("div",{children:[e.jsxs("div",{children:["PHOTOGRAPHED: ",O(new Date(s.capturedAt),"MMM d, yyyy")]}),e.jsxs("div",{children:["PHOTO: ",s.publicId.split("-")[0].toUpperCase()]})]}),e.jsxs("div",{className:"text-right",children:[s.user?.username&&e.jsxs("div",{children:["BY: @",s.user.username]}),s.status==="IDENTIFIED"||s.status==="ENRICHED"||s.status==="VERIFIED"?e.jsxs("div",{className:"ed-seal","data-testid":"seal-identified",children:[e.jsx(Be,{className:"w-2.5 h-2.5",strokeWidth:3})," Identified"]}):s.isFirstObservation?e.jsxs("div",{className:"ed-seal","data-testid":"seal-discovery",children:[e.jsx(bs,{className:"w-2.5 h-2.5 fill-current"})," Discovery"]}):null]})]}),e.jsxs("figure",{className:"ed-plate-frame",children:[e.jsxs("div",{className:"ed-plate-inner",children:[e.jsx("button",{type:"button",onClick:()=>lt(s.primaryImageUrl),"aria-label":"Open photo in lightbox","data-testid":"btn-open-lightbox",style:{display:"block",padding:0,border:0,background:"transparent",width:"100%",cursor:"zoom-in"},children:e.jsx("img",{src:s.primaryImageUrl,alt:L,className:"ed-plate-img","data-testid":"img-primary",draggable:!1})}),e.jsx("div",{className:"ed-plate-ring"}),S.length>1&&e.jsxs("div",{className:"ed-photo-count","data-testid":"badge-photo-count",children:[e.jsx(ye,{className:"w-3 h-3 inline mr-1"}),"1/",S.length]}),q&&s.additionalImageUrls&&s.additionalImageUrls.length>0&&e.jsx("button",{className:"ed-photo-delete",onClick:t=>{t.stopPropagation(),confirm("Delete this primary photo? The first additional photo will become the new primary.")&&he.mutate(s.primaryImageUrl)},disabled:he.isPending,"data-testid":"btn-delete-primary",children:e.jsx(es,{className:"w-4 h-4"})}),s.status==="MYSTERY"&&e.jsx("div",{className:"absolute z-10",style:{bottom:"-10px",right:"16px",transform:"rotate(-3deg)"},"aria-label":"Help identify this find",children:e.jsxs("div",{className:"ed-stamp",children:[e.jsx("div",{className:"stamp-line-1",children:"Still a mystery"}),e.jsx("div",{className:"stamp-line-2",children:"Can you identify it?"})]})})]}),e.jsxs("figcaption",{className:"ed-caption",children:[e.jsx("span",{className:"ed-caption-fig",children:ge}),e.jsxs("span",{className:"ed-caption-meta",children:["Photographed ",O(new Date(s.capturedAt),"MMMM d, yyyy"),s.localArea?` · ${s.localArea}`:""]})]})]}),s.additionalImageUrls&&s.additionalImageUrls.length>0&&e.jsx("div",{className:"ed-thumbs","data-testid":"strip-additional-photos",children:s.additionalImageUrls.map((t,a)=>e.jsxs("div",{className:"ed-thumb",onClick:()=>lt(t),"data-testid":`img-additional-${a}`,children:[e.jsx("img",{src:t,alt:`Additional ${a+1}`}),q&&e.jsx("button",{onClick:d=>{d.stopPropagation(),confirm("Delete this photo?")&&he.mutate(t)},disabled:he.isPending,className:"absolute -top-1 -right-1 p-1 bg-red-600/90 rounded-full text-white","data-testid":`btn-delete-additional-${a}`,style:{fontSize:10},children:e.jsx(je,{className:"w-3 h-3"})})]},a))}),e.jsxs("article",{className:"ed-article",children:[e.jsx("p",{className:"mb-3 text-center text-sm text-elz-secondary",children:s.status==="DRAFT"||s.status==="PENDING_LOCATION"?"Your photo":s.status==="MYSTERY"?"Help identify this find":s.status==="VERIFIED"?"Identification":"Here’s what we think it is"}),e.jsx("h1",{className:"ed-article-title","data-testid":"text-record-title",children:L}),X&&e.jsx("p",{className:"mb-6 text-center text-base leading-relaxed text-elz-secondary","data-testid":"text-observation-caption",children:X}),e.jsx("div",{className:"ed-article-body","data-testid":"text-place-narrative",children:e.jsx("p",{children:xe&&xe!==X?xe:X?null:s.status==="DRAFT"||s.status==="PENDING_LOCATION"?"Your photo is saved. Its description will appear after identification.":"There’s more to learn about this find. Add a note or a visible detail to help tell its story."})}),e.jsxs("p",{className:"mt-4 flex flex-wrap justify-center gap-x-4 gap-y-1 text-sm text-elz-secondary","data-testid":"exhibit-provenance",children:[s.user?.username&&e.jsxs(_t,{href:`/profile/${s.user.id}`,children:["Contributed by @",s.user.username]}),s.localArea&&e.jsx("span",{children:s.localArea}),s.status!=="DRAFT"&&s.status!=="PENDING_LOCATION"&&e.jsx("span",{children:s.status==="VERIFIED"?"Reviewed identification":Ot?"Includes contributor corrections":"AI-suggested identification"})]}),e.jsx(Ht,{note:s.notes,contributor:s.user,anonymous:!s.userId}),s.keyFacts&&s.keyFacts.length>0&&e.jsxs("section",{className:"mt-6 rounded-xl border border-elz bg-elz-elevated p-5","aria-labelledby":"result-facts-heading",children:[e.jsx("h2",{id:"result-facts-heading",className:"mb-3 text-xl font-serif text-elz-primary",children:"A few things to know"}),e.jsx("ul",{className:"list-disc space-y-2 pl-5 text-sm leading-relaxed text-elz-secondary",children:s.keyFacts.slice(0,4).map((t,a)=>e.jsx("li",{children:t},a))})]}),s.status!=="VERIFIED"&&s.status!=="DRAFT"&&s.status!=="PENDING_LOCATION"&&e.jsx("p",{className:"mt-5 text-center text-sm text-elz-secondary",children:"AI suggestions can be wrong. Compare the details, or add a correction below."}),e.jsxs("div",{className:"my-5 flex flex-wrap justify-center gap-3","data-testid":"result-actions",children:[e.jsx(Kt,{title:L,text:`Take a look at ${L} on Elzewhere`,url:be(`/record/${i}`),variant:"outline"}),e.jsx(o,{variant:"outline",onClick:()=>h(u?"/observe":"/identify"),children:"Identify another photo"}),s.status!=="DRAFT"&&s.status!=="PENDING_LOCATION"&&e.jsx(o,{variant:"outline","data-testid":"btn-correct-detail",onClick:()=>u?y(!0):h(`/login?next=${encodeURIComponent(`/record/${i}?correct=1`)}`),children:"Correct a detail"})]}),s.status==="MYSTERY"&&e.jsxs("div",{className:"ed-editors-note","data-testid":"editors-note",children:[e.jsx("div",{className:"ed-editors-note-tag",children:"Editor's Note"}),e.jsx("p",{children:"We haven’t confirmed what this is yet. Recognize a detail? Share what you know to help identify it."}),u&&!ce&&e.jsx("button",{className:"ed-btn-outline-gold",onClick:()=>V(!0),"data-testid":"btn-propose-identity",children:"Suggest an identification"}),!u&&e.jsx("button",{className:"ed-btn-outline-gold",onClick:()=>h(`/login?next=/record/${i}`),"data-testid":"btn-signin-to-propose",children:"Sign in to help identify it"})]})]}),pt&&e.jsxs("div",{className:"ed-section","data-testid":"section-contribute",style:{paddingTop:"1.5rem",paddingBottom:"1.5rem"},children:[e.jsx("h2",{className:"ed-section-eyebrow",children:"Add to this find"}),e.jsxs("div",{className:"ed-tools",children:[e.jsxs("button",{className:"ed-tool-btn",onClick:()=>D(!0),"data-testid":"btn-add-photo",children:[e.jsx(ye,{className:"w-4 h-4"})," Add Photo"]}),(Z||q)&&e.jsxs("button",{className:"ed-tool-btn",onClick:()=>j(!0),"data-testid":"btn-add-details",children:[e.jsx(fe,{className:"w-4 h-4"})," Add Details"]}
5),(Z||q)&&e.jsxs("button",{className:"ed-tool-btn",onClick:()=>b(!0),"data-testid":"btn-fix-location",children:[e.jsx(Qe,{className:"w-4 h-4"})," Fix Location"]}),e.jsxs("button",{className:"ed-tool-btn",onClick:()=>c(!0),"data-testid":"btn-add-note",children:[e.jsx(Ct,{className:"w-4 h-4"})," Add Note"]})]})]}),A?.observations&&A.observations.length>0&&e.jsxs("div",{className:"ed-section","data-testid":"section-timeline",style:{paddingTop:"1.5rem",paddingBottom:"1.5rem"},children:[e.jsx("h2",{className:"ed-section-eyebrow",children:"Observed Here"}),e.jsxs("div",{style:{marginTop:"0.5rem"},children:[e.jsxs("div",{className:"ed-timeline-item","data-testid":"timeline-current",children:[e.jsx("div",{className:"ed-timeline-dot"}),e.jsxs("div",{children:[s.user?.username&&e.jsxs("span",{className:"ed-timeline-attr",children:["@",s.user.username]}),e.jsxs("span",{children:[" · ",O(new Date(s.capturedAt),"MMM d, yyyy")]}),m?.narrativeSummary&&e.jsxs("span",{children:[" — ",m.narrativeSummary]}),!m?.narrativeSummary&&s.isFirstObservation&&e.jsx("span",{children:" — first recorded on Elzewhere"})]})]}),A.observations.filter(t=>t.publicId!==s.publicId).slice(0,3).map((t,a)=>e.jsxs("div",{className:"ed-timeline-item","data-testid":`timeline-${a}`,children:[e.jsx("div",{className:"ed-timeline-dot dim"}),e.jsxs("div",{children:[t.user?.username&&e.jsxs("span",{style:{fontWeight:600},children:["@",t.user.username]}),e.jsxs("span",{children:[" · ",O(new Date(t.capturedAt),"MMM d, yyyy")]}),t.aiEnrichment?.narrativeSummary&&e.jsxs("span",{children:[" — ",t.aiEnrichment.narrativeSummary]})]})]},t.publicId)),A.observations.length>4&&e.jsxs("button",{onClick:()=>h(`/subject/${A.subject.publicId}`),className:"ed-btn-outline-gold",style:{marginTop:"0.75rem"},"data-testid":"link-all-observations",children:["View all ",A.observations.length," observations →"]})]})]}),s.latitude&&s.longitude&&e.jsxs("div",{className:"ed-section","data-testid":"section-mini-map",style:{paddingTop:"1.5rem",paddingBottom:"1.5rem"},children:[e.jsx("h2",{className:"ed-section-eyebrow",children:"Coordinates"}),e.jsxs("p",{style:{textAlign:"center",fontFamily:"Fraunces, Georgia, serif",color:"var(--ed-secondary)",margin:"0 0 0.5rem",fontSize:"0.9rem"},children:[s.localArea?`${s.localArea} — `:"",s.latitude.toFixed(4),"°, ",s.longitude.toFixed(4),"°"]}),e.jsx("div",{className:"ed-map",children:e.jsx("iframe",{title:"Record location",loading:"lazy",src:`https://www.openstreetmap.org/export/embed.html?bbox=${s.longitude-.005},${s.latitude-.003},${s.longitude+.005},${s.latitude+.003}&layer=mapnik&marker=${s.latitude},${s.longitude}`})})]}),e.jsxs("section",{className:"ed-section","data-testid":"section-community",children:[e.jsx("h2",{className:"ed-section-eyebrow",children:"From the Community"}),e.jsx("p",{className:"ed-section-tagline",children:"Identifications, corrections, and field notes from other readers."}),s.status==="MYSTERY"&&ce&&e.jsxs("div",{className:"ed-form","data-testid":"form-propose-identity",children:[e.jsx("div",{style:{fontFamily:"Fraunces, Georgia, serif",fontSize:"0.95rem",color:"var(--ed-ink)",marginBottom:"0.75rem"},children:"What do you think this is?"}),e.jsx("label",{children:"Type *"}),e.jsxs(xt,{value:ke,onValueChange:Ve,children:[e.jsx(gt,{className:"bg-white border","data-testid":"select-dpt",style:{marginBottom:"0.75rem"},children:e.jsx(bt,{placeholder:"Select type..."})}),e.jsx(jt,{children:Wt.filter(t=>t!=="unknown").map(t=>e.jsx(K,{value:t,children:U(t)},t))})]}),e.jsx("label",{children:"Specific name / ID *"}),e.jsx("input",{value:ze,onChange:t=>Ge(t.target.value),placeholder:"What specifically is this?","data-testid":"input-identity-primary"}),e.jsx("label",{children:"Additional details"}),e.jsx("input",{value:We,onChange:t=>Je(t.target.value),placeholder:"Model, manufacturer, features…","data-testid":"input-identity-secondary"}),e.jsx("label",{children:"Reasoning"}),e.jsx("textarea",{value:Xe,onChange:t=>Ze(t.target.value),placeholder:"How did you identify this? What clues helped?","data-testid":"textarea-reasoning"}),e.jsxs("div",{className:"ed-form-actions",children:[e.jsx("button",{className:"ed-btn-solid",onClick:()=>Ce.mutate(),disabled:!ke||!ze.trim()||Ce.isPending,"data-testid":"btn-submit-suggestion",children:Ce.isPending?e.jsx(z,{className:"w-4 h-4 animate-spin"}):"Submit"}),e.jsx("button",{className:"ed-btn-outline-gold",onClick:()=>V(!1),"data-testid":"btn-cancel-suggestion",children:"Cancel"})]})]}),le&&le.length>0&&e.jsxs("div",{style:{marginBottom:"2rem",marginTop:ce?"1.5rem":0},children:[e.jsxs("h3",{className:"ed-section-h3",children:["Proposed Identifications · ",le.length]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:le.map(t=>e.jsxs("li",{className:"ed-proposal-card","data-testid":`suggestion-${t.id}`,children:[e.jsxs("div",{className:"ed-proposal-row",children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{className:"ed-proposal-dpt",children:U(t.proposedDpt)}),t.proposedIdentityPrimary&&e.jsx("p",{className:"ed-proposal-primary",children:t.proposedIdentityPrimary}),t.proposedIdentitySecondary&&e.jsx("p",{className:"ed-proposal-secondary",children:t.proposedIdentitySecondary}),t.reasoning&&e.jsxs("p",{className:"ed-proposal-reason",children:['"',t.reasoning,'"']}),e.jsxs("p",{className:"ed-proposal-attr",children:["by @",t.user?.username||"unknown"," · ",O(new Date(t.createdAt),"MMM d, yyyy")]})]}),t.status==="accepted"?e.jsxs("div",{className:"ed-accepted-badge",children:[e.jsx("div",{className:"ed-accepted-dot",children:e.jsx(Be,{className:"w-3 h-3",strokeWidth:3})}),e.jsx("span",{className:"ed-accepted-label",children:"Accepted"})]}):e.jsxs("div",{className:"ed-vote-col",children:[e.jsx("button",{className:"ed-vote-btn",onClick:()=>me.mutate({suggestionId:t.id,voteType:"up"}),disabled:!u||me.isPending,"aria-label":"Upvote","data-testid":`btn-upvote-${t.id}`,children:"▲"}),e.jsx("span",{className:"ed-vote-score","data-testid":`score-${t.id}`,children:t.upvotes-t.downvotes}),e.jsx("button",{className:"ed-vote-btn",onClick:()=>me.mutate({suggestionId:t.id,voteType:"down"}),disabled:!u||me.isPending,"aria-label":"Downvote","data-testid":`btn-downvote-${t.id}`,children:"▼"})]})]}),Z&&t.status==="pending"&&e.jsx("div",{className:"ed-accept-btn",children:e.jsxs("button",{className:"ed-btn-outline-gold",onClick:()=>et.mutate(t.id),disabled:et.isPending,"data-testid":`btn-accept-${t.id}`,style:{width:"100%"},children:[e.jsx(Be,{className:"w-4 h-4 mr-1"})," Accept this Identification"]})})]},t.id))}),u&&s.status==="MYSTERY"&&!ce&&e.jsx("button",{className:"ed-btn-outline-gold",style:{width:"100%",marginTop:"0.5rem"},onClick:()=>V(!0),"data-testid":"btn-propose-identity-bottom",children:"+ Propose an Identity"})]}),Ae.length>0&&e.jsxs("div",{style:{marginBottom:"1.5rem"},children:[e.jsxs("h3",{className:"ed-section-h3",children:["Field Notes · ",Ae.length]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:Ae.map(t=>e.jsxs("li",{className:"ed-fieldnote","data-testid":`story-entry-${t.id}`,children:[e.jsxs("p",{className:"body",children:['"',t.body,'"']}),e.jsxs("p",{className:"attr",children:["— @",t.user?.username||"anonymous"," · ",O(new Date(t.createdAt),"MMM d, yyyy")]})]},t.id))})]}),pt?e.jsxs("div",{className:"ed-add-cta","data-testid":"cta-add-field-note",children:[e.jsx("p",{className:"eyebrow",children:"Add to the Record"}),e.jsx("p",{className:"tagline",children:"Saw it later? Know more? Add a field note."}),e.jsx(He,{placeholder:"What caught your eye about this place?",value:pe,onCh
5ange:t=>ot(t.target.value),className:"bg-white border resize-none",style:{minHeight:70,fontFamily:"Fraunces, Georgia, serif",fontSize:"0.95rem",color:"var(--ed-ink)",marginBottom:"0.5rem"},maxLength:2e3,"data-testid":"input-story-body"}),e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:e.jsxs("span",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:10,color:"var(--ed-muted)"},children:[pe.length,"/2000"]})}),e.jsx("button",{className:"ed-btn-solid",disabled:!pe.trim()||De.isPending,onClick:()=>De.mutate(pe),"data-testid":"btn-submit-story",children:De.isPending?e.jsx(z,{className:"w-3 h-3 animate-spin"}):"+ Add Field Note"})]}):e.jsx("div",{className:"ed-add-cta",children:e.jsxs("p",{className:"tagline",children:[e.jsx("a",{href:"/auth",style:{color:"var(--ed-accent)",textDecoration:"underline"},children:"Sign in"})," to add a field note."]})})]}),(m?.environment||m?.timeOfDay||m?.usageContext||s.parentDptKey&&s.parentDptKey!=="unknown")&&e.jsx($,{title:"Context",icon:e.jsx(Qe,{className:"w-4 h-4"}),defaultOpen:!0,testId:"context",children:e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2",children:[m?.environment&&e.jsxs("span",{className:"text-elz-muted text-sm","data-testid":"context-environment",children:["• ",m.environment]}),m?.usageContext&&e.jsxs("span",{className:"text-elz-muted text-sm","data-testid":"context-usage",children:["• ",m.usageContext]}),m?.timeOfDay&&e.jsxs("span",{className:"text-elz-muted text-sm","data-testid":"context-time",children:["• ",m.timeOfDay]}),s.parentDptKey&&s.parentDptKey!=="unknown"&&e.jsxs("span",{className:"text-elz-muted text-sm","data-testid":"context-dpt",children:["• ",ge]})]})}),mt.length>0&&e.jsx($,{title:"Key Facts",icon:e.jsx(ts,{className:"w-4 h-4"}),defaultOpen:!1,testId:"key-facts",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:mt.map((t,a)=>e.jsx("div",{className:"px-3 py-1.5 bg-elz-border border border-elz rounded-lg text-sm text-elz-muted","data-testid":`chip-fact-${a}`,children:t.value||t.label},a))})}),Le.length>0&&e.jsx($,{title:"Text Found",icon:e.jsx(fe,{className:"w-4 h-4"}),defaultOpen:!1,testId:"ocr",children:e.jsx("div",{className:"space-y-2",children:Le.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3 px-3 py-2.5 bg-cyan-500/5 border border-cyan-500/20 rounded-lg","data-testid":`chip-ocr-${a}`,children:[e.jsx(fe,{className:"w-4 h-4 text-cyan-500/60 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-elz-muted text-xs uppercase tracking-wide mb-0.5",children:"Sign reads"}),e.jsxs("p",{className:"text-cyan-400 font-mono text-sm",children:['"',t,'"']})]})]},a))})}),ht.length>0&&e.jsx($,{title:"Observations",icon:e.jsx(ft,{className:"w-4 h-4"}),defaultOpen:!1,testId:"observations",children:e.jsx("ul",{className:"space-y-1.5",children:ht.map((t,a)=>e.jsxs("li",{className:"text-sm text-elz-muted flex items-start gap-2","data-testid":`item-observation-${a}`,children:[e.jsx("span",{className:"text-elz-muted mt-1",children:"•"}),e.jsx("span",{children:t})]},a))})}),ut.length>0&&e.jsx($,{title:"Tags",icon:e.jsx(zt,{className:"w-4 h-4"}),defaultOpen:!0,testId:"tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ut.map((t,a)=>e.jsxs("button",{onClick:()=>h(`/search?q=${encodeURIComponent("#"+t)}`),className:"flex items-center text-[10px] font-mono font-bold text-emerald-900 dark:text-emerald-400 bg-elz-surface dark:bg-emerald-600/10 px-2 py-1 rounded border border-emerald-600 dark:border-emerald-500/30 hover:bg-emerald-50 dark:hover:bg-emerald-600/20 transition-colors cursor-pointer shadow-sm","data-testid":`chip-tag-${a}`,children:[e.jsx(zt,{size:10,className:"mr-1 text-emerald-700 dark:text-emerald-500"}),t]},a))})}),e.jsx($,{title:"Change History",icon:e.jsx(us,{className:"w-4 h-4"}),defaultOpen:!1,testId:"history",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"history-item-created",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-500 mt-2"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-elz-muted text-sm",children:"Photo added"}),e.jsx("p",{className:"text-elz-muted text-xs",children:O(new Date(s.createdAt),"MMM d, yyyy 'at' h:mm a")})]})]}),s.confirmedAt&&e.jsxs("div",{className:"flex items-start gap-3","data-testid":"history-item-confirmed",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 mt-2"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-elz-muted text-sm",children:["Confirmed as ",s.status==="MYSTERY"?"Mystery":"Identified"]}),e.jsx("p",{className:"text-elz-muted text-xs",children:O(new Date(s.confirmedAt),"MMM d, yyyy 'at' h:mm a")})]})]})]})}),A&&A.observations.length>1&&(()=>{const t=A.observations.filter(a=>a.publicId!==s.publicId);return t.length===0?null:e.jsx($,{title:`Browse Photos (${t.length})`,icon:e.jsx(ye,{className:"w-4 h-4"}),defaultOpen:!1,testId:"browse-observations",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-elz-muted text-sm mb-3",children:"View other photos of this place"}),t.slice(0,5).map((a,d)=>e.jsxs("a",{href:`/record/${a.publicId}`,className:"flex items-start gap-3 p-2 rounded-lg bg-elz-surface hover:bg-elz-surface transition-colors","data-testid":`timeline-observation-${d}`,children:[e.jsx("img",{src:a.primaryImageUrl,alt:"",className:"w-12 h-12 rounded object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-elz-muted text-sm font-medium truncate",children:a.title||a.identityPrimary||U(a.childDptKey||a.dptKey||"unknown")}),e.jsx("p",{className:"text-elz-muted text-xs",children:O(new Date(a.capturedAt||a.createdAt),"MMM d, yyyy")})]})]},a.publicId)),t.length>20&&e.jsxs("p",{className:"text-elz-muted text-xs text-center",children:["+ ",t.length-20," more observations"]})]})})})(),$e.length>0&&e.jsxs($,{title:`Nearby (${$e.length})`,icon:e.jsx(ss,{className:"w-4 h-4"}),defaultOpen:!1,testId:"nearby",children:[e.jsx("p",{className:"text-elz-muted text-sm mb-3",children:"Other things noticed near here"}),e.jsx("div",{className:"space-y-2",children:$e.map(t=>e.jsxs("a",{href:`/record/${t.publicId}`,className:"flex items-center gap-3 p-2 rounded-lg bg-elz-border/30 hover:bg-elz-surface/60 transition-colors","data-testid":`nearby-record-${t.publicId}`,children:[e.jsx("img",{src:t.primaryImageUrl,alt:"",className:"w-12 h-12 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-elz-primary text-sm font-medium truncate",children:t.identityPrimary||t.title||U(t.childDptKey||t.dptKey||"unknown")}),e.jsx("p",{className:"text-elz-muted text-xs truncate",children:t.localArea||U(t.childDptKey||t.dptKey||"unknown")})]}),e.jsx(vt,{className:"w-4 h-4 text-elz-muted flex-shrink-0"})]},t.publicId))})]}),dt.length>0&&e.jsxs($,{title:"You might also like",icon:e.jsx(as,{className:"w-4 h-4"}),defaultOpen:!1,testId:"similar",children:[e.jsxs("p",{className:"text-elz-muted text-sm mb-3",children:["Other ",ge.toLowerCase()," records"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:dt.map(t=>e.jsxs("a",{href:`/record/${t.publicId}`,className:"block rounded-lg overflow-hidden bg-elz-border/30 hover:bg-elz-surface/60 transition-colors","data-testid":`similar-record-${t.publicId}`,children:[e.jsx("img",{src:t.primaryImageUrl,alt:"",className:"w-full aspect-square object-cover"}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"text-elz-primary text-xs font-medium truncate",children:t.identityPrimary||t.title||U(t.childDptKey||t.dptKey||"unknown")}),t.localArea&&e.jsx("p",{className:"text-elz-muted text-xs truncate",children:t.localArea})]})]},t.publicId))})]}),(s.status==="IDENTIFIED"||s.status==="ENRICHED"||s.status==="VERIFIED")&&e.jsx($,{title:"Share",icon:e.jsx(Nt,{className:"w-4 h-4"}),defaultOpen:!0,testId:"share",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-elz-muted text-sm",children:"This record is public. Share it to help document the world."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",className:"border-elz text-elz-muted flex-1 hover:bg-elz-surface",onClick:async()=>{const t=be(`/record/${s.publicId}`);navigator.clipboard.writeText(t),n.success("Link copied to clipboard");try{await g(`/api/records/${s.publicId}/share`,{method:"POST"})}catch{}},"data-testid":"btn-copy-link",children:[e.jsx(yt,{className:"w-4 h-4 mr-2"}),"Copy Link"]}),typeof navigator.share=="function"&&e.jsxs(o,{variant:"outline",className:"border-elz text-elz-muted flex-1 hover:bg-elz-surface",onClick:async()=>{try{const t=m?.narrativeSummary?.split(/[.!?]/)[0]?.trim(),a=t?`${t}. — Elzewhere`:`${L} - seen on Elzewhere`;await navigator.share({title:L,text:a,url:be(`/record/${s.publicId}`)}),await g(`/api/records/${s.publicId}/share`,{method:"POST"})}catch(t){t.name!=="AbortError"&&n.error("Sharing failed")}},"data-testid":"btn-share-native",children:[e.jsx(Nt,{className:"w-4 h-4 mr-2"}),"Share"]})]}),e.jsxs(o,{variant:"outline",className:"w-full border-elz text-elz-muted hover:bg-elz-surface",onClick:()=>M(!0),"data-testid":"btn-embed-record",children:[e.jsx(ls,{className:"w-4 h-4 mr-2"}),"Embed on your site"]}),e.jsxs("div",{className:"bg-elz-surface rounded-lg p-3 flex items-center gap-3",children:[e.jsx(xs,{className:"w-5 h-5 text-elz-muted"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-elz-muted text-sm font-mono truncate","data-testid":"text-share-url",children:["elzewhere.com/record/",s.publicId.slice(0,8),"..."]}),e.jsx("p",{className:"text-elz-muted text-xs",children:"Permanent, canonical link"})]})]})]})}),u&&s.userId!==u.id&&e.jsxs("div",{className:"border border-elz rounded-lg p-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-elz-muted mb-3",children:[e.jsx(wt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Report"})]}),e.jsx("p",{className:"text-elz-muted text-sm mb-3",children:"See something wrong with this record? Let us know."}),e.jsxs(o,{variant:"outline",className:"border-elz text-elz-muted hover:bg-elz-surface hover:text-red-400 hover:border-red-700",onClick:()=>ue(!0),"data-testid":"btn-report-record",children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),"Report this record"]})]}),Ft&&e.jsx("div",{className:"fixed inset-0 bg-black/80 z-50 flex items-center justify-center p-4",onClick:()=>ue(!1),children:e.jsxs("div",{className:"bg-elz-ink rounded-lg max-w-md w-full p-6 border border-elz",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-400 mb-4",children:[e.jsx(rs,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-medium",children:"Report Record"})]}),e.jsx("p",{className:"text-elz-muted text-sm mb-4",children:"This record will be temporarily hidden until reviewed by our team."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-elz-muted text-sm block mb-2",children:"Reason *"}),e.jsxs(xt,{value:Fe,onValueChange:rt,children:[e.jsx(gt,{className:"bg-elz-border border-elz text-elz-muted",children:e.jsx(bt,{placeholder:"Select a reason"})}),e.jsxs(jt,{className:"bg-elz-border border-elz",children:[e.jsx(K,{value:"inappropriate",children:"Inappropriate content"}),e.jsx(K,{value:"spam",children:"Spam or misleading"}),e.jsx(K,{value:"wrong_location",children:"Wrong location"}),e.jsx(K,{value:"privacy",children:"Privacy concern"}),e.jsx(K,{value:"duplicate",children:"Duplicate record"}),e.jsx(K,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-elz-muted text-sm block mb-2",children:"Additional details (optional)"}),e.jsx(He,{value:it,onChange:t=>nt(t.target.value),placeholder:"Provide any additional context...",className:"bg-elz-border border-elz text-elz-muted min-h-[80px]","data-testid":"input-report-details"})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(o,{variant:"outline",className:"flex-1 border-elz text-elz-muted",onClick:()=>ue(!1),"data-testid":"btn-cancel-report",children:"Cancel"}),e.jsx(o,{className:"flex-1 bg-red-600 hover:bg-red-700",disabled:!Fe||Oe.isPending,onClick:()=>Oe.mutate({reason:Fe,details:it}),"data-testid":"btn-submit-report",children:Oe.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Report"})]})]})]})}),q&&e.jsx($,{title:"Admin Tools",icon:e.jsx(B,{className:"w-4 h-4"}),defaultOpen:!1,testId:"section-admin",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-elz-muted text-sm mb-2",children:["Force rescan will re-analyze all ",1+(s.additionalImageUrls?.length||0)," photos and rebuild the AI enrichment from scratch. (Limit: 20 ph
5otos)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{onClick:()=>f.mutate({deepThink:!1}),disabled:f.isPending,className:"flex-1 bg-amber-700 hover:bg-amber-600","data-testid":"btn-force-rescan",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Rescanning..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Rescan"]})}),e.jsx(o,{onClick:()=>f.mutate({deepThink:!0}),disabled:f.isPending,className:"flex-1 bg-purple-600 hover:bg-purple-700","data-testid":"btn-deep-think-rescan",title:"Uses more powerful AI model with detailed instructions for difficult images",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Thinking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Deep Think"]})})]}),m?.rescanHistory?.length>0&&e.jsxs("div",{className:"text-elz-muted text-xs mt-2",children:["Last rescan: ",O(new Date(m.rescanHistory.slice(-1)[0].rescannedAt),"MMM d, yyyy HH:mm"),m.rescanHistory.slice(-1)[0].deepThink&&" (Deep Think)"]})]}),e.jsxs("div",{className:"border-t border-elz pt-4",children:[e.jsx("p",{className:"text-elz-muted text-sm mb-2",children:"Additional Enrichment Models"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(o,{onClick:()=>f.mutate({modelId:"xai/grok-4"}),disabled:f.isPending,className:"flex-1 bg-elz-border hover:bg-elz-border","data-testid":"btn-enrich-grok",title:"Re-analyze with xAI Grok 4",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Grok 4"]})}),e.jsx(o,{onClick:()=>f.mutate({modelId:"google/gemini-3-pro"}),disabled:f.isPending,className:"flex-1 bg-blue-700 hover:bg-blue-600","data-testid":"btn-enrich-gemini",title:"Re-analyze with Google Gemini 3 Pro",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Gemini 3 Pro"]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{onClick:()=>f.mutate({modelId:"nvidia/nemotron-3-super-120b-a12b:free"}),disabled:f.isPending,className:"flex-1 bg-green-800 hover:bg-green-700","data-testid":"btn-enrich-nemotron",title:"Re-analyze with NVIDIA Nemotron Super 120B (free)",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Nemotron 120B"]})}),e.jsx(o,{onClick:()=>f.mutate({modelId:"minimax/minimax-m2.7"}),disabled:f.isPending,className:"flex-1 bg-teal-700 hover:bg-teal-600","data-testid":"btn-enrich-minimax",title:"Re-analyze with MiniMax M2.7",children:f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"MiniMax M2.7"]})})]})]}),s.additionalImageUrls&&s.additionalImageUrls.length>0&&e.jsxs("div",{className:"border-t border-elz pt-4",children:[e.jsx("p",{className:"text-elz-muted text-sm mb-2",children:"Change Primary Photo"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:s.additionalImageUrls.map((t,a)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t,alt:`Photo ${a+1}`,className:"w-full aspect-square object-cover rounded-lg"}),e.jsx(o,{size:"sm",onClick:()=>Se.mutate(t),disabled:Se.isPending,className:"absolute inset-0 opacity-0 group-hover:opacity-100 bg-black/70 hover:bg-black/80 text-elz-primary text-xs transition-opacity","data-testid":`btn-swap-primary-${a}`,children:Se.isPending?e.jsx(z,{className:"w-3 h-3 animate-spin"}):"Make Primary"})]},a))})]}),e.jsxs("div",{className:"border-t border-elz pt-4",children:[e.jsx("p",{className:"text-elz-muted text-sm mb-2",children:"Visibility"}),e.jsx(o,{onClick:()=>Ee.mutate(!s.isUnlisted),disabled:Ee.isPending,className:`w-full ${s.isUnlisted?"bg-emerald-600 hover:bg-emerald-700":"bg-elz-border hover:bg-elz-border"}`,"data-testid":"btn-unlist-record",children:Ee.isPending?e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}):s.isUnlisted?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4 mr-2"}),"Make Visible"]}):e.jsxs(e.Fragment,{children:[e.jsx(Yt,{className:"w-4 h-4 mr-2"}),"Unlist"]})}),s.isUnlisted&&e.jsx("p",{className:"text-amber-400 text-xs mt-2",children:"This record is hidden from public view"})]}),e.jsxs("div",{className:"border-t border-elz pt-4",children:[e.jsx("p",{className:"text-elz-muted text-sm mb-2",children:"Convert to Venue"}),e.jsx("p",{className:"text-elz-muted text-xs mb-3",children:"Creates a new venue page from this finding's image and location, then deletes this record. Cannot be undone."}),Tt?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-orange-400 text-sm text-center",children:"Confirm? This will delete the finding and create a venue."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{variant:"outline",className:"flex-1 border-elz",onClick:()=>st(!1),"data-testid":"btn-cancel-convert-to-venue",children:"Cancel"}),e.jsx(o,{className:"flex-1 bg-orange-600 hover:bg-orange-700",disabled:Pe.isPending,onClick:()=>Pe.mutate(),"data-testid":"btn-confirm-convert-to-venue",children:Pe.isPending?e.jsx(z,{className:"w-4 h-4 animate-spin"}):"Convert"})]})]}):e.jsxs(o,{variant:"outline",className:"w-full border-orange-500/50 text-orange-400 hover:bg-orange-500/10",onClick:()=>st(!0),"data-testid":"btn-convert-record-to-venue",children:[e.jsx(Vt,{className:"w-4 h-4 mr-2"}),"Convert to Venue"]})]})]})}),(Z||q)&&e.jsx("div",{className:"px-4 py-4 border-t border-elz",children:Pt?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-red-400 text-sm text-center",children:"Are you sure? This cannot be undone."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{variant:"outline",className:"flex-1 border-elz",onClick:()=>tt(!1),"data-testid":"btn-cancel-delete",children:"Cancel"}),e.jsx(o,{className:"flex-1 bg-red-600 hover:bg-red-700",onClick:()=>Re.mutate(),disabled:Re.isPending,"data-testid":"btn-confirm-delete",children:Re.isPending?e.jsx(z,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]}):e.jsxs(o,{variant:"outline",className:"w-full border-red-600/50 text-red-400 hover:bg-red-600/20",onClick:()=>tt(!0),"data-testid":"btn-delete-record",children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),"Delete Record"]})})]}),e.jsx(Qt,{open:v,onClose:()=>y(!1),recordId:s.id,publicId:s.publicId,canEdit:Z||q,initial:{name:L,caption:X||"",label:xe||"",facts:Mt.join(`
6`),signText:Le.join(`
7`)}}),e.jsx(js,{isOpen:F,onClose:()=>D(!1),recordId:s.id,publicId:s.publicId}),e.jsx(ys,{isOpen:C,onClose:()=>c(!1),recordId:s.id,publicId:s.publicId,currentValue:s.notes||void 0}),e.jsx(fs,{isOpen:I,onClose:()=>b(!1),recordId:s.id,publicId:s.publicId,currentLatitude:s.latitude,currentLongitude:s.longitude,currentLocalArea:s.localArea}),e.jsx(vs,{isOpen:E,onClose:()=>j(!1),recordId:s.id,publicId:s.publicId}),e.jsx(se,{open:p,onOpenChange:M,children:e.jsxs(ae,{className:"bg-elz-ink border-elz max-w-lg","data-testid":"dialog-embed",children:[e.jsxs(re,{children:[e.jsx(ie,{className:"text-elz-primary",children:"Embed this observation"}
7),e.jsx(ne,{className:"text-elz-muted",children:"Drop this snippet into any blog post or web page. The card links back to the full observation on Elzewhere."})]}),(()=>{const t=be(`/embed/record/${s.publicId}`),a=`<iframe src="${t}" width="100%" height="420" style="border:0;max-width:720px;" loading="lazy" title="${(L||"Observation").replace(/"/g,"&quot;")} on Elzewhere"></iframe>`;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg overflow-hidden border border-elz bg-[#f3ecdd]",children:e.jsx("iframe",{src:t,title:"Embed preview",className:"w-full",style:{height:360,border:0,display:"block"},"data-testid":"iframe-embed-preview"})}),e.jsx("textarea",{readOnly:!0,value:a,className:"w-full h-24 text-xs font-mono p-2 rounded-md bg-elz-surface border border-elz text-elz-muted resize-none",onFocus:d=>d.currentTarget.select(),"data-testid":"textarea-embed-snippet"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",className:"flex-1 border-elz text-elz-muted hover:bg-elz-surface",onClick:()=>{navigator.clipboard.writeText(a),n.success("Embed code copied")},"data-testid":"btn-copy-embed",children:[e.jsx(yt,{className:"w-4 h-4 mr-2"}),"Copy embed code"]}),e.jsxs(o,{variant:"outline",className:"border-elz text-elz-muted hover:bg-elz-surface",onClick:()=>{Ut(t)},"data-testid":"btn-open-embed",children:[e.jsx(is,{className:"w-4 h-4 mr-2"}),"Preview"]})]})]})})()]})}),at&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>G(null),onTouchStart:At,onTouchMove:Dt,onTouchEnd:$t,"data-testid":"lightbox-modal",children:[e.jsx(o,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 text-elz-primary hover:bg-elz-elevated/20 z-10",onClick:()=>G(null),"data-testid":"btn-close-lightbox",children:e.jsx(je,{className:"w-6 h-6"})}),S.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"absolute left-2 top-1/2 -translate-y-1/2 p-2 rounded-full bg-black/60 text-white/80 hover:text-white hover:bg-black/80 transition-colors z-10 hidden md:block",onClick:t=>{t.stopPropagation(),J("prev")},"data-testid":"btn-lightbox-prev",children:e.jsx(kt,{className:"w-6 h-6"})}),e.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 rounded-full bg-black/60 text-white/80 hover:text-white hover:bg-black/80 transition-colors z-10 hidden md:block",onClick:t=>{t.stopPropagation(),J("next")},"data-testid":"btn-lightbox-next",children:e.jsx(vt,{className:"w-6 h-6"})})]}),e.jsx("img",{src:at,alt:"Full size",className:"max-w-full max-h-full object-contain p-4 select-none",onClick:t=>t.stopPropagation(),draggable:!1,"data-testid":"img-lightbox"}),S.length>1&&e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-2 z-10","data-testid":"lightbox-dots",children:[S.map((t,a)=>e.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${a===W?"bg-elz-elevated":"bg-elz-elevated/30 hover:bg-elz-elevated/50"}`,onClick:d=>{d.stopPropagation(),Te(a),G(S[a])},"data-testid":`lightbox-dot-${a}`},a)),e.jsxs("span",{className:"text-white/50 text-xs ml-2",children:[W+1,"/",S.length]})]})]})]})}export{ha as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.