PageSourceSearch

https://www.vithajsafari.se/assets/hajarter.index-DRkPVpLb.js

js vithajsafari.se collected 2026-09-25 11:30:10 UTC 5,349 bytes, 1 lines download raw bytes

1import{a8 as $,r as E,j as e,L as j}from"./index-CPtAmAsA.js";import{S as B}from"./SiteShell-yObs9XYd.js";import{C as R}from"./ContentPage-BbY1mpmC.js";import{S as q}from"./search-BJQ3p6g1.js";import{X as A}from"./x-CGGUdM8O.js";import"./createLucideIcon-DzegPNAp.js";import"./footer-settings.functions-DNRRB3pN.js";import"./input-DjSO5Vm8.js";import"./mail-B-GT16Tf.js";import"./instagram-D6ut8EG9.js";import"./arrow-left-DGAvrGRg.js";const b=["Hexanchiformes","Squaliformes","Pristiophoriformes","Squatiniformes","Heterodontiformes","Lamniformes","Orectolobiformes","Carcharhiniformes"];function U(){const{species:g,labels:x}=$.useLoaderData(),[c,h]=E.useState(""),u=c.trim().toLowerCase(),v=n=>{const o=x.find(l=>l.rank==="order"&&l.latin_name===n)?.swedish_name;return o?`${n} — ${o}`:n},k=n=>{const o=x.find(l=>l.rank==="family"&&l.latin_name===n)?.swedish_name;return o?`${n} — ${o}`:n};return e.jsx(B,{children:e.jsx(R,{eyebrow:"Artfakta",title:"Hajarter",lead:"Artfakta om hajar — taxonomi, mått och biologi. Klicka på en art för att läsa mer.",children:g.length===0?e.jsx("p",{className:"text-muted-foreground",children:"Inga arter publicerade ännu."}):(()=>{const n=g,o=u?n.filter(r=>[r.svenskt_namn,r.engelskt_namn,r.artnamn,r.familj,r.ordning].filter(Boolean).some(i=>i.toLowerCase().includes(u))):[],l=e.jsx("div",{className:"not-prose mb-8",children:e.jsxs("div",{className:"relative max-w-xl",children:[e.jsx(q,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"search",value:c,onChange:r=>h(r.target.value),placeholder:"Sök på svenskt, engelskt eller latinskt namn, familj eller ordning…",className:"w-full rounded-sm border border-border bg-background py-2.5 pl-9 pr-9 text-sm outline-none focus:border-deep-3","aria-label":"Sök bland arter"}),c&&e.jsx("button",{type:"button",onClick:()=>h(""),className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-1 text-muted-foreground hover:bg-muted","aria-label":"Rensa sökning",children:e.jsx(A,{size:14})})]})});if(u)return e.jsxs("div",{className:"not-prose",children:[l,o.length===0?e.jsxs("p",{className:"text-muted-foreground",children:["Inga arter matchar ”",c,"”."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-3 text-sm text-muted-foreground",children:[o.length," träff",o.length===1?"":"ar"]}),e.jsx("ul",{className:"divide-y divide-border rounded-sm border border-border bg-card",children:o.map(r=>e.jsx("li",{children:e.jsxs(j,{to:"/hajarter/$slug",params:{slug:r.slug},className:"flex items-center gap-4 p-3 transition-colors hover:bg-muted",children:[r.image?e.jsx("img",{src:r.image,alt:r.svenskt_namn||r.artnamn,className:"h-14 w-20 flex-shrink-0 rounded-sm object-contain mix-blend-multiply"}):e.jsx("div",{className:"h-14 w-20 flex-shrink-0 rounded-sm bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-serif text-lg leading-tight",children:r.svenskt_namn||r.artnamn}),e.jsxs("div",{className:"text-sm italic text-muted-foreground",children:[r.artnamn,r.engelskt_namn?` · ${r.engelskt_namn}`:""]}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[r.familj,r.ordning].filter(Boolean).join(" · ")})]})]})},r.slug))})]})]});const m=new Map;for(const r of n){const i=(r.ordning||"").trim()||"Övrigt";m.has(i)||m.set(i,[]),m.get(i).push(r)}const N=b.filter(r=>m.has(r)).map(r=>[r,m.get(r)]),y=[...m.entries()].filter(([r])=>!b.includes(r)).sort(([r],[i])=>r.localeCompare(i,"sv")),w=[...N,...y];return e.jsxs("div",{className:"not-prose space-y-12",children:[l,w.map(([r,i])=>{const d=new Map;for(const a of i){const s=(a.familj||"").trim()||"Övrigt";d.has(s)||d.set(s,[]),d.get(s).push(a)}const _=[...d.entries()].sort(([a],[s])=>a.localeCompare(s,"sv")),p=a=>{const s=(a.artnamn||"").trim().split(/\s+/);return[(s[0]||"").toLowerCase(),(s[1]||"").toLowerCase()]},C=(a,s)=>{const[t,S]=p(a),[f,L]=p(s);return t!==f?t.localeCompare(f,"sv"):S.localeCompare(L,"sv")};return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-6 font-serif text-2xl tracking-tight",children:v(r)}),e.jsx("div",{className:"space-y-8",children:_.map(([a,s])=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 font-serif text-lg tracking-tight text-muted-foreground",children:k(a)}),e.jsx("ul",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3",children:[...s].sort(C).map(t=>e.jsx("li",{children:e.jsxs(j,{to:"/hajarter/$slug",params:{slug:t.slug},className:"group block overflow-hidden rounded-sm border border-border bg-card transition-colors hover:border-deep-3/60",children:[t.image?e.jsx("div",{className:"flex aspect-[4/3] w-full items-center justify-center bg-muted",children:e.jsx("img",{src:t.image,alt:t.svenskt_namn||t.artnamn,className:"h-full w-full object-contain mix-blend-multiply transition-transform group-hover:scale-[1.02]"})}):e.jsx("div",{className:"aspect-[4/3] w-full bg-muted"}),e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"font-serif text-xl leading-tight",children:t.svenskt_namn||t.artnamn}),e.jsx("div",{className:"mt-1 text-sm italic text-muted-foreground",children:t.artnamn}),t.engelskt_namn&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t.engelskt_namn})]})]})},t.slug))})]},a))})]},r)})]})})()})})}export{U as component};

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.