PageSourceSearch

https://loveacrossborders.com/assets/harm-reduction-DeRdxa3O.js

js loveacrossborders.com collected 2026-10-08 14:16:24 UTC 9,888 bytes, 3 lines download raw bytes

1import{h as T,r as i,j as e,L as P,M as f,t as _}from"./index-hs4a0mYW.js";import{D as R,u as D,C as H,a as L,b as U,S as F,d as O,P as Y,e as q,f as B,g as z,M as j,c as b,h as G}from"./mermaid-GHXKKRXX-BW650IWT.js";import{l as K,u as X,S as Z,c as $}from"./use-persisted-chat-eOePmI3y.js";import{S as N}from"./shield-check-B0Y8X4cW.js";import{T as J}from"./trash-2-Bg71gBw1.js";import{T as Q}from"./triangle-alert-Y3Bwbf1c.js";import"./button-Cc6vISkn.js";import"./check-rFTGGwOD.js";import"./input-XaHB6AeD.js";import"./textarea-DM5dDCD0.js";import"./loader-circle-CKo3nrvz.js";import"./index.browser-BY9c7rfI.js";const V=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],W=T("phone",V),ee=[{label:"Emergency",value:"911 (US) / 112 (EU)"},{label:"Suicide & Crisis Lifeline (US)",value:"988 (call or text)"},{label:"SAMHSA Helpline (US)",value:"1-800-662-HELP (4357)"},{label:"Never Use Alone (US)",value:"1-800-484-3731"},{label:"Never Use Alone (Canada)",value:"1-877-696-1996"}],v="hr_consent_v1";function pe(){const[t,a]=i.useState(""),[r,n]=i.useState(!1),[l,o]=i.useState(!1),[h,y]=i.useState(!1),[u,w]=i.useState(!1);i.useEffect(()=>{try{localStorage.getItem(v)==="1"?n(!0):o(!0)}catch{o(!0)}},[]);const S=()=>{try{localStorage.setItem(v,"1")}catch{}n(!0),o(!1)},p=i.useRef(null),m="hr_chat_messages_v1",k=i.useMemo(()=>K(m),[]),C=new R({api:"/api/public/harm-reduction-chat",prepareSendMessagesRequest:async({messages:s})=>({body:{messages:s}})}),{messages:c,sendMessage:I,status:x,error:g,setMessages:M}=D({transport:C,messages:k,onError:s=>_.error(s.message||"Something went wrong")});X(m,c);const A=()=>{M([]),$(m)},d=x==="submitted"||x==="streaming",E=()=>{if(!r){o(!0);return}const s=t.trim();!s||d||(a(""),I({text:s}),setTimeout(()=>p.current?.focus(),0))};return e.jsxs("div",{className:"min-h-screen bg-slate-50 text-slate-900",children:[l&&e.jsx("div",{className:"fixed inset-0 z-50 bg-slate-900/70 backdrop-blur-sm grid place-items-center px-4",children:e.jsxs("div",{className:"max-w-md w-full rounded-xl bg-white shadow-2xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(N,{className:"h-5 w-5 text-sky-700","aria-hidden":!0}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900",children:"Before you continue"})]}),e.jsx("p",{className:"text-sm text-slate-600 mb-4",children:"This is a free, nonjudgmental harm-reduction information assistant. It is not medical care. Please confirm before continuing."}),e.jsxs("label",{className:"flex items-start gap-3 text-sm text-slate-800 mb-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:s=>y(s.target.checked),className:"mt-1"}),e.jsxs("span",{children:["I am ",e.jsx("strong",{children:"18 years of age or older"}),"."]})]}),e.jsxs("label",{className:"flex items-start gap-3 text-sm text-slate-800 mb-5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:s=>w(s.target.checked),className:"mt-1"}),e.jsxs("span",{children:["I understand this is ",e.jsx("strong",{children:"harm-reduction information, not medical, legal, or clinical advice"}),". For emergencies I will contact local emergency services."]})]}),e.jsx("button",{type:"button",onClick:S,disabled:!h||!u,className:"w-full inline-flex items-center justify-center px-5 py-2.5 rounded-md bg-sky-700 text-white text-sm font-medium hover:bg-sky-800 disabled:opacity-50 disabled:cursor-not-allowed",children:"I understand · continue"}),e.jsx("p",{className:"mt-3 text-[11px] text-slate-500 text-center",children:"Your choice is remembered in this browser only."})]})}),e.jsx("header",{className:"border-b border-slate-200 bg-white",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-5 w-5 text-sky-700","aria-hidden":!0}),e.jsx("span",{className:"font-semibold tracking-tight text-slate-900",children:"Harm Reduction Information"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c.length>0&&e.jsxs("button",{type:"button",onClick:A,className:"inline-flex items-center gap-1 text-xs text-slate-600 hover:text-slate-900 px-2 py-1",title:"Clear conversation",children:[e.jsx(J,{className:"h-3.5 w-3.5","aria-hidden":!0})," Clear"]}),e.jsxs(P,{to:"/harm-reduction/admin",className:"hidden sm:inline-flex items-center gap-1 text-xs text-slate-600 hover:text-slate-900 px-2 py-1",children:[e.jsx(Z,{className:"h-3.5 w-3.5","aria-hidden":!0})," Admin"]}),e.jsxs("a",{href:"tel:988",className:"inline-flex items-center gap-1.5 rounded-md bg-rose-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-rose-700",children:[e.jsx(W,{className:"h-4 w-4","aria-hidden":!0}),"Crisis line: 988"]})]})]})}),e.jsx("div",{className:"border-b border-rose-200 bg-rose-50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-2 text-sm text-rose-900 flex items-start gap-2",children:[e.jsx(Q,{className:"h-4 w-4 mt-0.5 flex-none","aria-hidden":!0}),e.jsxs("p",{children:["If someone may be overdosing or in immediate danger, call local emergency services now. In the US: ",e.jsx("strong",{children:"911"}),". Suicide and Crisis Lifeline: ",e.jsx("strong",{children:"988"}),"."]})]})}),e.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-6 grid gap-6 lg:grid-cols-[1fr,18rem]",children:[e.jsxs("section",{className:"flex flex-col rounded-lg border border-slate-200 bg-white shadow-sm overflow-hidden h-[calc(100vh-12rem)]",children:[e.jsxs("div",{className:"border-b border-slate-200 bg-slate-50 px-4 py-3",children:[e.jsx("h1",{className:"text-base font-semibold text-slate-900",children:"Ask a harm-reduction question"}),e.jsx("p",{className:"text-xs text-slate-600 mt-0.5",children:"Information and triage, not medical advice. For emergencie
1s, contact a professional. You will not be asked to identify yourself or stop using."})]}),e.jsxs(H,{className:"flex-1",children:[e.jsxs(L,{className:"max-w-3xl mx-auto w-full",children:[c.length===0?e.jsx(U,{title:"How can I help?",description:"Ask about overdose response, drug-checking, finding services, or what to do in a difficult moment. I will not provide dosing or how to combine substances.",icon:e.jsx(f,{className:"h-8 w-8"})}):c.map(s=>e.jsx(se,{message:s},s.id)),d&&e.jsx("div",{className:"px-1",children:e.jsx(F,{children:"Thinking..."})}),g&&e.jsx("p",{className:"text-sm text-rose-700 px-1",children:g.message})]}),e.jsx(O,{})]}),e.jsx("div",{className:"border-t border-slate-200 bg-white p-4",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(Y,{onSubmit:E,children:[e.jsx(q,{ref:p,value:t,onChange:s=>a(s.target.value),placeholder:"e.g. How do I recognize an opioid overdose?",disabled:d}),e.jsx(B,{className:"justify-end",children:e.jsx(z,{status:x,disabled:!t.trim()||d})})]}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-500 text-center",children:"This assistant is grounded in vetted harm-reduction sources (DanceSafe, NEXT Distro, Harm Reduction Coalition, Zendo Project, NORML, SAMHSA, NIDA, CDC, Bluelight). It will decline dosing, combination, and sourcing questions."})]})})]}),e.jsxs("aside",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-4",children:[e.jsxs("h2",{className:"text-sm font-semibold text-slate-900 flex items-center gap-1.5",children:[e.jsx(f,{className:"h-4 w-4 text-sky-700","aria-hidden":!0}),"Crisis & helplines"]}),e.jsx("ul",{className:"mt-3 space-y-2 text-sm",children:ee.map(s=>e.jsxs("li",{className:"text-slate-700",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-500",children:s.label}),e.jsx("div",{className:"font-medium text-slate-900",children:s.value})]},s.label))})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-4 text-sm text-slate-700",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Find services"}),e.jsxs("ul",{className:"mt-3 space-y-2",children:[e.jsx("li",{children:e.jsx("a",{className:"text-sky-700 hover:underline",href:"https://nasen.org",target:"_blank",rel:"noreferrer",children:"Syringe service programs (NASEN)"})}),e.jsx("li",{children:e.jsx("a",{className:"text-sky-700 hover:underline",href:"https://nextdistro.org",target:"_blank",rel:"noreferrer",children:"Free naloxone by mail (NEXT Distro)"})}),e.jsx("li",{children:e.jsx("a",{className:"text-sky-700 hover:underline",href:"https://dancesafe.org",target:"_blank",rel:"noreferrer",children:"Drug-checking & test kits (DanceSafe)"})}),e.jsx("li",{children:e.jsx("a",{className:"text-sky-700 hover:underline",href:"https://findtreatment.gov",target:"_blank",rel:"noreferrer",children:"Find treatment (SAMHSA)"})})]})]}),e.jsx("p",{className:"text-xs text-slate-500 px-1",children:"This is a public, free resource. No account required. Your messages are not associated with an identity."})]})]})]})}function se({message:t}){const a=t.parts.map(l=>l.type==="text"?l.text:"").join("");if(t.role!=="assistant")return e.jsx(j,{from:t.role,children:e.jsx(b,{children:e.jsx("p",{className:"whitespace-pre-wrap",children:a})})});const{body:r,citation:n}=te(a);return e.jsx(j,{from:"assistant",children:e.jsxs(b,{children:[e.jsx(G,{children:r}),n&&e.jsxs("p",{className:"mt-3 text-xs text-slate-600 border-t border-slate-200 pt-2",children:[e.jsx("span",{className:"font-medium text-slate-900",children:"From:"})," ",n]})]})})}function te(t){const a=t.split(`
2`);for(let r=a.length-1;r>=0;r--){const n=a[r].trim();if(!n)continue;const l=n.match(/^From:\s*(.+)$/i);if(l)return{body:a.slice(0,r).join(`
3`).trim(),citation:l[1].trim()};break}return{body:t,citation:null}}export{pe 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.