1import{c as se,j as e,d as L,L as U,e as A,X as re,r as x,h as ae,n as ne,o as ie,p as F,q as oe,S as z,N as O,F as $,a as B,b as le}from"./index-bomMc6QM.js";import{S as j}from"./skeleton-B01d9WUS.js";import{s as M,S as W,a as ce,b as Q,f as de,g as me,c as q,d as ue,e as he}from"./articleReads-U_HKGA3x.js";import{u as V}from"./useQuery-CncuzZ0t.js";const xe=se("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);function ge({heroArticle:t,isLoading:s}){return e.jsx(L,{fullWidth:!0,className:"articles-hero",children:e.jsx("div",{className:"content-container w-full relative z-10",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"articles-hero__header",children:[e.jsx("span",{className:"articles-hero__eyebrow",children:"Blogg"}),e.jsx("h1",{className:"articles-hero__title",children:"Innsikt & Oppdateringer"}),e.jsx("p",{className:"articles-hero__subtitle-text",children:"Teknologi, trender og tanker fra teamet vårt"})]}),e.jsx("div",{className:"articles-hero__featured-wrapper",children:s?e.jsx("div",{className:"h-[min(50svh,28rem)] w-full rounded-[28px] border border-border/40 bg-card/20 p-4 md:p-6",children:e.jsx(j,{className:"h-full w-full rounded-[22px]"})}):t?e.jsx(U,{to:`/blogg/${t.slug.current}`,"aria-label":t.title,className:"group/card block no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-[24px]",style:{textDecoration:"none",textDecorationLine:"none",textUnderlineOffset:"0",textDecorationThickness:"0"},children:e.jsxs("article",{className:"articles-hero__card flex min-h-[420px] w-full flex-col overflow-hidden md:min-h-[460px] md:grid md:grid-cols-2",children:[e.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none rounded-[24px]",style:{background:"linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 8%, transparent 25%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.15), inset 1px 0 0 rgba(255,255,255,0.08), inset -1px 0 0 rgba(255,255,255,0.05), inset 0 -1px 0 rgba(0,0,0,0.2)"},"aria-hidden":"true"}),e.jsxs("div",{className:"relative flex h-full flex-col justify-between px-8 pt-12 pb-8 md:px-12 md:pt-16 md:pb-12",children:[t.categories?.[0]?.title&&e.jsx("div",{className:"absolute top-6 left-8 md:top-8 md:left-12",children:e.jsx(X,{title:t.categories[0].title})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-start pt-8 md:pt-10",children:[e.jsx("h2",{className:"text-[clamp(1.75rem,2.5vw,2.25rem)] font-semibold leading-[1.15] tracking-[-0.02em] text-foreground/95 max-w-[22ch] text-balance transition-colors group-hover/card:text-primary/90 mb-5 [display:-webkit-box] [-webkit-line-clamp:3] [-webkit-box-orient:vertical] overflow-hidden",children:t.title}),t.author&&e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.author.image?.asset?.url?e.jsx("img",{src:M(t.author.image.asset.url,{width:80,crop:t.author.image.crop,hotspot:t.author.image.hotspot}),alt:t.author.name||"Forfatter",width:40,height:40,className:"w-10 h-10 rounded-full object-cover border border-foreground
1/20 flex-shrink-0",decoding:"async"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-foreground/10 border border-foreground/20 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-[12px] font-medium text-foreground/60",children:(t.author.name||"C")[0].toUpperCase()})}),e.jsx("div",{children:e.jsx("div",{className:"text-[14px] font-medium text-foreground/95 leading-tight",children:t.author.name||"CAP10"})})]}),t.excerpt&&e.jsx("p",{className:"text-[clamp(1rem,1.15vw,1.125rem)] leading-[1.5] text-foreground/85 content-max-text mb-6",children:t.excerpt.length>200?`${t.excerpt.slice(0,200)}...`:t.excerpt})]}),e.jsx("div",{className:"mt-auto",children:e.jsxs("span",{"aria-hidden":"true",className:"inline-flex items-center gap-1.5 text-[15px] font-medium",style:{color:"hsl(var(--apple-blue))"},children:["Les mer",e.jsx("span",{className:"inline-block transition-transform duration-200 group-hover/card:translate-x-1",style:{opacity:.7},children:"â"})]})})]}),e.jsxs("div",{className:"relative h-[280px] overflow-hidden md:h-full",children:[e.jsx("div",{className:"absolute inset-0",style:{opacity:.92},children:e.jsx(G,{imageUrl:t.mainImage?.asset?.url,lqip:t.mainImage?.asset?.metadata?.lqip,alt:t.mainImage?.alt||t.title,logoClassName:"h-20 w-auto opacity-40",sizes:"(min-width: 768px) 544px, 100vw",widths:W.hero,priority:!0,crop:t.mainImage?.crop,hotspot:t.mainImage?.hotspot,originalDimensions:t.mainImage?.asset?.metadata?.dimensions})}),e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%, rgba(0,0,0,0.05) 100%)",boxShadow:"inset 0 0 60px rgba(0,0,0,0.3), inset 0 0 20px rgba(0,0,0,0.15)"},"aria-hidden":"true"}),e.jsx("div",{className:"absolute inset-y-0 left-0 w-20 pointer-events-none hidden md:block",style:{background:"linear-gradient(to right, hsl(var(--card) / 0.4) 0%, transparent 100%)"},"aria-hidden":"true"})]})]})}):e.jsxs("div",{className:"w-full rounded-[28px] border border-border/40 bg-card/20 p-6",children:[e.jsx("h2",{className:"text-title-2 font-semibold",children:"Ingen artikler funnet"}),e.jsx("p",{className:"text-body text-muted-foreground mt-2",children:"Prøv et annet søk eller fjern et filter."})]})})]})})})}function pe({id:t,selectedCategory:s,categories:i,searchQuery:o,totalCount:r,onSelectCategory:l,onSearchQueryChange:m}){const g=o.trim();return e.jsxs("div",{id:t,className:"space-y-6 scroll-mt-24",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("div",{className:"h-[3px] w-8 rounded-full bg-gradient-to-r from-blue-500/60 to-purple-500/40"}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.15em] text-muted-foreground/70",children:"Utforsk"})]}),e.jsx("h2",{className:"text-title-1 font-normal tracking-[-0.02em]",children:"Alle artikler"}),e.jsxs("p",{className:"text-subheadline text-muted-foreground mt-1",children:[s?`Viser artikler i «${s}».`:g?`Viser treff for «${g}».`:"Oppdateringer, guider og perspektiver fra CAP10."," ",e.jsx("span",{className:"tabular-nums",children:r})," ",r===1?"artikkel":"artikler","."]})]}),e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(null),className:A("rounded-full border px-4 py-2 text-[13px] font-medium transition-smooth",s===null?"border-primary bg-primary text-primary-foreground":"border-border/50 bg-card/20 text-muted-foreground hover:text-foreground hover:border-border"),children:"Alle"}),i.map(c=>e.jsx("button",{type:"button",onClick:()=>l(c),className:A("rounded-full border px-4 py-2 text-[13px] font-medium transition-smooth",s===c?"border-primary bg-primary text-primary-foreground":"border-border/50 bg-card/20 text-muted-foreground hover:text-foreground hover:border-border"),children:c},c))]}),e.jsxs("div",{className:"relative w-full lg:w-auto lg:min-w-[280px]",children:[e.jsx(xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),e.jsx("input",{type:"text",placeholder:"Søk i artiklerâ¦",value:o,onChange:c=>m(c.target.value),onKeyDown:c=>c.key==="Escape"&&m(""),className:"w-full rounded-full border border-border/50 bg-card/20 py-2 pl-10 pr-10 text-[14px] text-foreground placeholder:text-muted-foreground transition-all focus:outline-none focus:ring-2 focus:ring-blue-600/40 focu
1s:border-blue-600/50 [&::-webkit-search-cancel-button]:hidden"}),o&&e.jsx("button",{type:"button",onClick:()=>m(""),className:"absolute right-3 top-1/2 -translate-y-1/2 flex h-[18px] w-[18px] items-center justify-center rounded-full bg-muted text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","aria-label":"Tøm søk",children:e.jsx(re,{className:"h-3 w-3",strokeWidth:2.5})})]})]})]})}var fe="AspectRatio",H=x.forwardRef((t,s)=>{const{ratio:i=1/1,style:o,...r}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/i}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(ae.div,{...r,ref:s,style:{...o,position:"absolute",top:0,right:0,bottom:0,left:0}})})});H.displayName=fe;var be=H;const je=be;function G({imageUrl:t,alt:s,lqip:i,logoClassName:o="h-12 w-auto opacity-40",sizes:r,priority:l=!1,widths:m,crop:g,hotspot:c,originalDimensions:v}){const u={crop:g,hotspot:c,originalDimensions:v},f=t?ce(t,[...m??W.card],80,u):void 0,k=t?M(t,{width:640,...u}):void 0;return e.jsxs("div",{className:"relative h-full w-full overflow-hidden bg-muted/20",children:[i&&e.jsx("img",{src:i,alt:"","aria-hidden":"true",className:"absolute inset-0 h-full w-full object-cover blur-2xl scale-110 opacity-60",loading:"lazy"}),t?e.jsx("img",{src:k,srcSet:f||void 0,sizes:r,alt:s,className:"absolute inset-0 h-full w-full object-cover",loading:l?"eager":"lazy",fetchpriority:l?"high":void 0,decoding:"async"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("img",{src:ne,alt:"CAP10",width:59,height:40,className:A(o,"logo-crisp"),style:{aspectRatio:"59/40"},loading:"lazy",decoding:"async"})})]})}function X({title:t}){return e.jsx("span",{className:"block text-[11px] font-medium uppercase tracking-[0.08em]",style:{color:"hsl(var(--apple-blue))"},children:t})}function K(t,s,i=60){if(!t||!s)return null;const o=t.toLowerCase(),r=s.toLowerCase(),l=o.indexOf(r);if(l===-1)return null;const m=Math.max(0,l-i),g=Math.min(t.length,l+s.length+i),c=(m>0?"...":"")+t.slice(m,l),v=t.slice(l,l+s.length),u=t.slice(l+s.length,g)+(g<t.length?"...":"");return{before:c,match:v,after:u}}function ve({article:t,priority:s=!1,searchQuery:i}){const o=Q(t.publishedAt),r=x.useMemo(()=>{if(!i?.trim())return null;const l=i.trim().toLowerCase();if(t.title?.toLowerCase().includes(l))return null;const g=K(t.excerpt,i.trim());if(g)return g;const c=K(t.bodyText,i.trim());return c||null},[i,t.title,t.excerpt,t.bodyText]);return e.jsx(U,{to:`/blogg/${t.slug.current}`,className:"group block h-full no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-2xl",children:e.jsxs("article",{className:"article-card-enhanced flex h-full flex-col overflow-hidden rounded-2xl bg-card/45 border border-border/45 transition-all duration-300 hover:bg-card/65 hover:border-border/70 hover:shadow-elev-2",children:[e.jsxs("div",{className:"relative overflow-hidden bg-background/20",children:[e.jsx(je,{ratio:16/10,children:e.jsx(G,{imageUrl:t.mainImage?.asset?.url,lqip:t.mainImage?.asset?.metadata?.lqip,alt:t.mainImage?.alt||t.title||"Artikkel",logoClassName:"h-12 w-auto opacity-30",sizes:"(min-width: 1024px) 340px, (min-width: 640px) 50vw, 100vw",priority:s,crop:t.mainImage?.crop,hotspot:t.mainImage?.hotspot,originalDimensions:t.mainImage?.asset?.metadata?.dimensions})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-transparent"})]}),e.jsxs("div",{className:"flex flex-1 flex-col p-5 gap-3",children:[t.categories?.[0]?.title&&e.jsx("div",{children:e.jsx(X,{title:t.categories[0].title})}),e.jsx("h3",{className:"text-[clamp(1rem,1.125vw,1.125rem)] font-semibold leading-[1.3] tracking-[-0.01em] text-foreground transition-colors group-hover:text-primary line-clamp-3 text-balance",children:t.title}),r&&e.jsxs("p",{className:"text-[13px] leading-[1.5] text-muted-foreground line-clamp-2",children:[e.jsx("span",{children:r.before}),e.jsx("mark",{className:"bg-primary/10 text-foreground px-0.5 rounded",children:r.match}),e.jsx("span",{children:r.after})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-3 mt-auto pt-3 border-t border-border/40",children:[t.author?.image?.asset?.url?e.jsx("img",{src:M(t.author.image.asset.url,{width:64,crop:t.author.image.crop,hotspot:t.author.image.hotspot}),alt:t.author.name||"Forfatter",width:32,height:32,className:"w-8 h-8 rounded-full object-cover border border-border/60 flex-shrink-0",loading:s?"eager":"lazy",decoding:"async"}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted border border-border/60 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:(t.author?.name||"C")[0].toUpperCase()})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground
1/90 leading-tight truncate",children:t.author?.name||"CAP10"}),o&&e.jsx("time",{dateTime:t.publishedAt,className:"text-[12px] text-muted-foreground leading-tight",children:de(o)})]})]})]})]})})}const Ne=6;function we({articles:t,isLoading:s,searchQuery:i}){return s?e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:Array.from({length:Ne}).map((o,r)=>e.jsx(ye,{},r))}):t.length===0?e.jsxs("div",{className:"rounded-2xl border border-border/30 bg-card/10 p-8 text-center",children:[e.jsx("h3",{className:"text-title-3 font-semibold",children:"Ingen artikler funnet"}),e.jsx("p",{className:"text-body text-muted-foreground mt-2",children:"Prøv et annet søk eller fjern et filter."})]}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:t.map((o,r)=>e.jsx(ve,{article:o,priority:r<3,searchQuery:i},o._id))})}function ye(){return e.jsxs("div",{className:"flex flex-col overflow-hidden rounded-2xl bg-card/45 border border-border/45",children:[e.jsx(j,{className:"aspect-[16/10] w-full rounded-none"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx(j,{className:"h-3 w-16"}),e.jsx(j,{className:"h-5 w-full"}),e.jsx(j,{className:"h-5 w-4/5"}),e.jsxs("div",{className:"flex items-center gap-3 pt-3 border-t border-border/40",children:[e.jsx(j,{className:"h-8 w-8 rounded-full"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{className:"h-3 w-20"}),e.jsx(j,{className:"h-2.5 w-16"})]})]})]})]})}function ke(t,s){const[i,o]=x.useState(t);return x.useEffect(()=>{const r=setTimeout(()=>o(t),s);return()=>clearTimeout(r)},[t,s]),i}function Se(){const[t,s]=ie(),i=t.get("kategori"),o=t.get("sok")??"",[r,l]=x.useState(i),[m,g]=x.useState(o),c=a=>{l(a);const n={};a&&(n.kategori=a),m.trim()&&(n.sok=m.trim()),s(n,{replace:!0})},v=a=>{g(a);const n={};r&&(n.kategori=r),a.trim()&&(n.sok=a.trim()),s(n,{replace:!0})},u=ke(m.trim(),300),{data:f,isLoading:k,error:S}=V({queryKey:["articles"],queryFn:async()=>{try{return await q(ue)}catch(a){throw F.error("Failed to fetch articles from Sanity",a),a}},staleTime:300*1e3,gcTime:600*1e3}),{data:w,isLoading:I,error:_}=V({queryKey:["articles-search",u],queryFn:async()=>{try{const a=`*${u}*`;return await q(he,{searchTerm:a})}catch(a){throw F.error("Failed to search articles in Sanity",a),a}},enabled:u.length>=2,staleTime:30*1e3,gcTime:60*1e3}),y=k||u.length>=2&&I,J=S||_,P=a=>{if(!a)return[];const n=new Map;for(const h of a){const p=h._id;if(!p||p.startsWith("drafts."))continue;const d=h.slug?.current?.trim();if(!d)continue;const b=d.toLowerCase();n.has(b)||n.set(b,h)}return Array.from(n.values())},C=x.useMemo(()=>P(f),[f]),E=x.useMemo(()=>P(w),[w]),R=x.useMemo(()=>{const a=new Map;
1return C.forEach(n=>{n.categories?.forEach(h=>{h?.title&&a.set(h.title,(a.get(h.title)??0)+1)})}),Array.from(a.entries()).map(([n,h])=>({title:n,count:h})).sort((n,h)=>h.count-n.count||n.title.localeCompare(h.title))},[C]),Y=x.useMemo(()=>R.map(a=>a.title),[R]),N=x.useMemo(()=>(u.length>=2?E:C).filter(n=>!r||n.categories?.some(p=>p.title===r)),[C,E,u,r]),Z=C[0],D=N.slice(1,3),ee=N.slice(1+D.length),T=x.useMemo(()=>N.slice(0,10),[N]),te=x.useMemo(()=>{const a=me(),n=N.map(d=>({article:d,reads:a[d.slug.current]??0,ts:Q(d.publishedAt)?.getTime()??0,title:d.title??""}));n.sort((d,b)=>b.reads-d.reads||b.ts-d.ts||d.title.localeCompare(b.title,"nb-NO"));const h=new Set(T.map(d=>d._id)),p=[];for(const d of n){if(p.length>=6)break;h.has(d.article._id)||p.push(d.article)}if(p.length<6)for(const d of n){if(p.length>=6)break;p.some(b=>b._id===d.article._id)||p.push(d.article)}return p},[N,T]);return{isLoading:y,error:J,searchQuery:m,setSearchQuery:v,selectedCategory:r,setSelectedCategory:c,categories:Y,filteredArticles:N,heroArticle:Z,secondaryFeatured:D,listArticles:ee,latestRailArticles:T,mostReadArticles:te}}function Le(){const t=oe(),s="Oppdateringer, guider og perspektiver fra CAP10.";x.useEffect(()=>{if(t.hash){const S=t.hash.slice(1);setTimeout(()=>{document.getElementById(S)?.scrollIntoView({behavior:"smooth",block:"start"})},100)}},[t.hash]);const i={"@context":"https://schema.org","@type":"CollectionPage",name:"Blogg",url:`${B}/blogg`,description:s,publisher:{"@type":"Organization",name:le,url:B}},{isLoading:o,error:r,searchQuery:l,setSearchQuery:m,selectedCategory:g,setSelectedCategory:c,categories:v,filteredArticles:u,heroArticle:f}=Se(),k=x.useMemo(()=>{if(!u.length)return[];const S=f?._id,w=new Set,I=[];for(const _ of u){const y=_._id;y&&y!==S&&(w.has(y)||(w.add(y),I.push(_)))}return I},[u,f?._id]);return r?e.jsxs("main",{className:"min-h-screen bg-background",children:[e.jsx(z,{title:"Blogg",description:s,canonicalPath:"/blogg"}),e.jsx(O,{}),e.jsx(L,{className:"pad-page",children:e.jsxs("div",{className:"stack-xs",children:[e.jsx("h1",{className:"text-title-1 font-normal",children:"Blogg"}),e.jsx("p",{className:"text-body text-destructive",children:"Feil ved lasting av artikler. Vennligst oppdater siden."})]})}),e.jsx($,{})]}):e.jsxs("main",{className:"articles-page min-h-screen",children:[e.jsx("div",{className:"articles-page__background","aria-hidden":"true"}),e.jsx(z,{title:"Blogg",description:s,canonicalPath:"/blogg",jsonLd:i}),e.jsx(O,{}),e.jsx(ge,{heroArticle:f,isLoading:o}),e.jsx(L,{fullWidth:!0,className:"pad-page",children:e.jsx("div",{className:"content-container pad-page",children:e.jsxs("div",{className:"stack-xl",children:[e.jsx(pe,{id:"artikler",selectedCategory:g,categories:v,searchQuery:l,totalCount:u.length,onSelectCategory:c,onSearchQueryChange:m}),e.jsx(we,{articles:k,isLoading:o,searchQuery:l})]})})}),e.jsx($,{})]})}export{Le 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.