1import{aO as P,a as E,b as m,h as L,j as e,cS as b,cT as j,n as y,aN as S,b3 as k,t as B}from"./index-CmenFvy0.js";import{L as R}from"./LexicalArticleRenderer-By3fkpvj.js";import{NotFoundPage as D}from"./NotFoundPage-CFBvMq9v.js";import{a as I}from"./policy-queries-CYa64qP1.js";import{A as $}from"./arrow-left-CJS58dLz.js";import"./purify.es-CqxHTgmJ.js";import"./house-C_FPv-Eo.js";const U=/[\u0600-\u06ff\u0750-\u077f\u08a0-\u08ff]/;function F(s){if(!s)return"ltr";const r=`${s.title} ${s.summary??""} ${s.body??""}`;return U.test(r)?"rtl":"ltr"}function _(s,r){m.useEffect(()=>{if(!s)return;const l=document.title;document.title=s;let n=document.querySelector('meta[name="description"]');const i=(n==null?void 0:n.getAttribute("content"))??null;let x=!1;return n||(n=document.createElement("meta"),n.setAttribute("name","description"),document.head.appendChild(n),x=!0),r&&n.setAttribute("content",r),()=>{document.title=l,x&&n?n.remove():n&&i!==null&&n.setAttribute("content",i)}},[s,r])}const O=({badge:s,copy:r})=>s==="NONE"?null:s==="NEW"?e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-700",children:r("New")}):e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-amber-100 text-amber-700",children:r("Updated")});function Y(s,r){if(!s)return null;try{return k(s,r,{day:"numeric",month:"long",year:"numeric"})}catch{return null}}function H(s,r){const l=s.toLowerCase().trim().replaceAll(/[^a-z0-9]+/g,"-").split("-").filter(Boolean).join("-");return l?`${l}-${r}`:`heading-${r}`}const q=()=>e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-12",children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded mb-8 animate-pulse"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mb-3 animate-pulse"}),e.jsx("div",{className:"h-10 w-2/3 bg-muted rounded mb-4 animate-pulse"}),e.jsx("div",{className:"h-5 w-3/4 bg-muted rounded mb-12 animate-pulse"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 w-full bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 w-5/6 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 w-4/6 bg-muted rounded animate-pulse"})]})]}),X=()=>{const{slug:s}=P(),{locale:r}=E(),l=a=>B(a,r),n=m.useRef(null),[i,x]=m.useState([]),[w,N]=m.useState(""),{data:f,loading:T,error:A}=L(I,{variables:{slug:s??"",locale:r},skip:!s,fetchPolicy:"cache-and-network"}),t=(f==null?void 0:f.publicPolicyBySlug)??null;_(t?`${t.title} â PrintaRex`:null,(t==null?void 0:t.summary)??(t==null?void 0:t.title)??null),m.useEffect(()=>{if(!(t!=null&&t.body)){x([]);return}const a=setTimeout(()=>{if(!n.current)return;const c=n.current.querySelectorAll("h2"),o=[];c.forEach((d,p)=>{const g=(d.textContent??"").trim();if(!g)return;let h=d.id;h||(h=H(g,p),d.id=h),d.classList.add("scroll-mt-28"),o.push({id:h,text:g})}),x(o),o.length>0&&N(o[0].id)},80);return()=>clearTimeout(a)},[t==null?void 0:t.body,t==null?void 0:t.policyId]),m.useEffect(()=>{if(i.length===0)return;const a=()=>{const c=globalThis.scrollY+160;let o=i[0].id;for(const d of i){const p=document.getElementById(d.id);p&&p.offsetTop<=c&&(o=d.id)}N(o)};return globalThis.addEventListener("scroll",a,{passive:!0}),a(),()=>globalThis.removeEventListener("scroll",a)},[i]);const C=a=>{const c=document.getElementById(a);if(!c)return;const o=c.getBoundingClientRect().top+globalThis.scrollY-100;globalThis.scrollTo({top:o,behavior:"smooth"})},v=m.useMemo(()=>Y((t==null?void 0:t.lastUpdatedAt)??null,r),[r,t==null?void 0:t.lastUpdatedAt]),u=F(t);return T&&!f?e.jsxs(e.Fragment,{children:[e.jsx(b,{}),e.jsx("main",{className:"flex-1",children:e.jsx(q,{})}),e.jsx(j,{})]}):A||!t?e.jsxs(e.Fragment,{children:[e.jsx(b,{}),e.jsx("main",{className:"flex-1",children:e.jsx(D,{})}),e.jsx(j,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{}),e.jsx("main",{className:"flex-1",dir:u,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-12",children:[e.jsxs(y,{to:"/policies",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-primary transition mb-8 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded",children:[e.jsx($,{className:"w-4 h-4 rtl:rotate-180"}),l("Back to all policies")]}),e.jsxs("header",{className:"mb-12 max-w-4xl",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsx(O,{badge:t.statusBadge,copy:l}),v&&e.jsxs("span",{className:"inline-flex items-center",children:[l("Last updated")," ",v]})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold tracking-tight text-foreground leading-[1.1] mb-4",style:{fontFamily:'"DM Serif Display", Georgia, serif'},dir:u,children:t.title}),t.summary&&e.jsx("p",{className:"text-lg text-muted-foreground leading-relaxed",dir:u,children:t.summary})]}),e.jsxs("div",{className:"flex gap-12",children:[i.length>0&&e.jsx("aside",{className:"hidden lg:block w-64 shrink-0",children:e.jsxs("nav",{className:"sticky top-24","aria-label":"Table of contents",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4",children:l("On this page")}),e.jsx("ul",{className:"space-y-1 border-s border-border",children:i.map(a=>{const c=a.id===w;return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>C(a.id),className:`w-full text-start text-sm py-1.5 ps-4 -ms-px border-s-2 transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-sm ${c?"border-primary text-primary font-medium":"border-transparent text-muted-foreground hover:text-foreground"}`,dir:u,children:a.text})},a.id)})}),e.jsxs(y,{to:"/policies",className:"inline-flex items-center gap-1 mt-8 text-xs text-muted-foreground hover:text-primary transition",children:[l("All policies"),e.jsx(S,{className:"w-3 h-3 rtl:rotate-180"})]})]})}),e.jsx("article",{className:`${u==="rtl"?"policy-localized-content ":""}flex-1 min-w-0`,ref:n,dir:u,children:t.body?e.jsx(R,{content:t.body,className:"prose prose-lg max-w-none prose-headings:font-semibold prose-h2:text-2xl prose-h2:mt-12 prose-h2:mb-4 prose-p:leading-relaxed prose-a:text-primary"}):e.jsx("p",{className:"text-muted-foreground italic",children:l("This policy has no content yet.")})})]})]})}),e.jsx(j,{})]})};export{X as PolicyDetailPage,X 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.