PageSourceSearch

https://holylandphotos.org/_next/static/chunks/app/(frontend)/ai-search/page-c9b59f167ea90fc1.js

js holylandphotos.org collected 2026-10-02 05:01:06 UTC 5,794 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1266],{4427:(e,t,r)=>{"use strict";r.d(t,{G:()=>o});var n=r(95155);function s(e){let t,r=[],o=/\[([^\]]+)\]\(([^)]+)\)|\*\*([^*]+?)\*\*|\n/g,i=0,l=0;for(;null!==(t=o.exec(e));){if(t.index>i&&r.push(e.slice(i,t.index)),t[1]&&t[2]){let e=t[2],s=!!e.startsWith("http")&&!e.startsWith(window.location.origin);r.push((0,n.jsx)("a",{href:e,style:{color:"var(--link)"},...s?{target:"_blank",rel:"noopener"}:{},children:t[1]},l++))}else t[3]?r.push((0,n.jsx)("strong",{children:s(t[3])},l++)):"\n"===t[0]&&r.push((0,n.jsx)("br",{},l++));i=t.index+t[0].length}return i<e.length&&r.push(e.slice(i)),r}function o(e){return e.split(/\n\n+/).map((e,t)=>{let r=/^###\s+(.+)$/.exec(e);if(r)return(0,n.jsx)("h3",{style:{fontSize:"1rem",fontWeight:600,margin:"0.75rem 0 0.4rem 0"},children:s(r[1])},t);let o=/^##\s+(.+)$/.exec(e);if(o)return(0,n.jsx)("h2",{style:{fontSize:"1.1rem",fontWeight:600,margin:"1rem 0 0.5rem 0"},children:s(o[1])},t);let i=/^#\s+(.+)$/.exec(e);return i?(0,n.jsx)("h2",{style:{fontSize:"1.2rem",fontWeight:700,margin:"1rem 0 0.5rem 0"},children:s(i[1])},t):(0,n.jsx)("p",{style:{margin:"0 0 0.75rem 0"},children:s(e)},t)})}r(12115)},7617:(e,t,r)=>{"use strict";r.d(t,{default:()=>a});var n=r(95155),s=r(12115),o=r(70523),i=r(4427);let l="hlp_ai_searches";
1function a(){let[e,t]=(0,s.useState)([]),[r,a]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),[u,f]=(0,s.useState)(""),[h,p]=(0,s.useState)(0),[m,x]=(0,s.useState)(null),g=(0,s.useRef)(null),b=(0,s.useRef)(null),y=(0,s.useRef)(null),v=(0,s.useRef)(0);async function j(n){n.preventDefault();let s=r.trim();if(!s||c)return;let o=[...e,{role:"user",content:s}];t(o),a(""),d(!0),f("");try{let e=Date.now(),r=await fetch("/api/ai-search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:o})}),n=await r.json(),s=Date.now()-e;if(r.ok){t([...o,{role:"assistant",content:n.reply,durationMs:s}]);let e=h+1,r=new Date(Date.now()+2592e6).toUTCString();document.cookie="".concat(l,"=").concat(e,"; expires=").concat(r,"; path=/; SameSite=Lax"),p(e)}else f(n.error||"Request failed")}catch(e){f(e instanceof Error?e.message:"Network error")}finally{d(!1)}}(0,s.useEffect)(()=>{var e,t;p(function(){let e=document.cookie.match(new RegExp("(?:^|; )".concat(l,"=(\\d+)")));return e?parseInt(e[1]):0}());let r=null==(e=new URLSearchParams(window.location.search).get("q"))?void 0:e.trim();r&&a(r.slice(0,200)),null==(t=b.current)||t.focus()},[]),(0,s.useEffect)(()=>{var t;let r=e.filter(e=>"assistant"===e.role).length,n=r>v.current;if(v.current=r,n){x(e.length-1);let t=setTimeout(()=>{var e;null==(e=y.current)||e.scrollIntoView({behavior:"smooth",block:"start"})},50),r=setTimeout(()=>x(null),4e3);return()=>{clearTimeout(t),clearTimeout(r)}}null==(t=g.current)||t.scrollIntoView({behavior:"smooth"})},[e,c]);let w=e.length>0||c||u,S=-1;for(let t=e.length-1;t>=0;t--)if("assistant"===e[t].role){S=t;break}return(0,n.jsxs)("div",{style:{maxWidth:800},children:[w&&e.length>0&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:(0,n.jsx)("button",{type:"button",onClick:function(){var e;t([]),f(""),a(""),x(null),null==(e=b.current)||e.focus()},disabled:c,style:{fontSize:12,fontFamily:"var(--sans)",padding:"4px 10px",background:"transparent",border:"1px solid #ccc",borderRadius:3,cursor:c?"not-allowed":"pointer",color:"#555"},children:"New conversation"})}),w&&(0,n.jsxs)("div",{style:{border:"1px solid #ccc",borderRadius:4,padding:16,maxHeight:500,overflowY:"auto",marginBottom:16,background:"#fafafa"},children:[e.map((e,t)=>(0,n.jsxs)("div",{ref:t===S?y:null,style:{marginBottom:"1rem",padding:"0.75rem 1rem",borderRadius:4,background:"user"===e.role?"#e6f0ff":"#fff",border:"1px solid #e0e0e0",borderLeft:"3px solid",borderLeftColor:t===m?"var(--accent, #B85C2C)":"transparent",transition:"border-left-color 1.5s ease-out"},children:[(0,n.jsxs)("div",{style:{fontSize:11,color:"#888",textTransform:"uppercase",marginBottom:4,display:"flex",justifyContent:"space-between"},children:[(0,n.jsx)("span",{children:"user"===e.role?"You":"Assistant"}),null!=e.durationMs&&(0,n.jsxs)("span",{children:[(e.durationMs/1e3).toFixed(1),"s"]})]}),"assistant"===e.role?(0,i.G)(e.content):(0,n.jsx)("p",{style:{margin:0},children:e.content})]},t)),c&&(0,n.jsx)("div",{style:{color:"#888",fontStyle:"italic",padding:"0.5rem 0"},children:"Searching…"}),u&&(0,n.jsxs)("div",{style:{color:"#c00",padding:"0.5rem 0"},children:["Error: ",u]}),(0,n.jsx)("div",{ref:g})]}),(0,n.jsxs)("form",{onSubmit:j,style:{display:"flex",gap:8},children:[(0,n.jsx)("input",{ref:b,type:"text",value:r,onChange:e=>a(e.target.value),placeholder:"Ask about a site or photo…",disabled:c,style:{flex:1,padding:"10px 14px",fontSize:16,border:"1px solid #ccc",borderRadius:4}}),(0,n.jsx)("button",{type:"submit",disabled:c||!r.trim(),style:{padding:"10px 20px",fontSize:16,cursor:c||!r.trim()?"not-allowed":"pointer",borderRadius:4,border:"1px solid #ccc",background:c?"#eee":"#fff"},children:c?"…":"Send"})]}),h>=100&&(0,n.jsxs)("div",{style:{marginTop:16,padding:"12px 16px",background:"#fef9e7",border:"1px solid #f0e4b8",borderRadius:4,fontSize:14,color:"#555"},children:["You've used ",h," ",o.lu," this month. If you find this feature valuable, please consider supporting Holy Land Photos to help keep it running."]})]})}},32873:(e,t,r)=>{Promise.resolve().then(r.bind(r,7617))},70523:(e,t,r)=>{"use strict";r.d(t,{JO:()=>n,OK:()=>i,Z1:()=>l,hT:()=>o,lu:()=>s,qo:()=>a});let n="Ask the Archive",s="questions",o="Open the full ".concat(n," page →"),i="Asking the Archive…",l="Holy Land Photos \xb7 AI",a="Powered by Claude AI; verify with primary sources."}},e=>{var t=t=>e(e.s=t);e.O(0,[8441,1684,7358],()=>t(32873)),_N_E=e.O()}]);

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.