1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bibleApi-COTrrsw1.js","assets/index-DwOsqt_4.js","assets/index-BqHR-vAv.css"])))=>i.map(i=>d[i]); 2import{c as In,j as e,R as Cn,r as u,l as Tn,X as dt,C as is,m as Mt,n as nr,f as Bt,g as pr,o as gt,p as Pt,Z as ds,q as Ir,s as Ze,t as tt,v as Cr,w as Tr,x as us,_ as fs,y as ms,z as hs,u as ps,A as nn,D as gs,E as sn,F as bs,G as ir,J as xs,K as Wt,M as Nr,N as an,O as on}from"./index-DwOsqt_4.js";import{f as Dr,b as sr,c as Ht,a as ln}from"./formatDailyVerse-tt8MGf-V.js";import{r as vs,f as $n,a as Or,b as ys,c as js}from"./bibleApi-COTrrsw1.js";import{D as xt,a as vt,b as yt,c as Oe,S as wt,n as tr}from"./nativeShare-Bdd46ISN.js";import{B as cn,C as dn}from"./ChapterSelector-BPha2_iR.js";import{S as bt}from"./square-check-big-BBkMg0Tf.js";import{A as jt,a as ws,C as Ss}from"./columns-2-CLx5sJ6h.js";import{P as hr,n as un}from"./exportVerses-CHG4NYwA.js";import{B as fn}from"./book-marked-Ci3uIxJ0.js";import{F as Ns}from"./filter-CnyphT0d.js";import{i as Ar,g as ks,F as Es,a as Is,c as Cs,r as Rn,s as $r}from"./savedVerses-i9SRR9f5.js";import{f as lt,p as Kt,i as mn,r as Tt}from"./printHelpers-DeIXVbT9.js";import{C as zt}from"./chevron-right-P-TuxYpG.js";import{M as hn}from"./minus-CIbjoxkk.js";import{P as pn}from"./plus-BFaUv1Jo.js";import{T as Ts}from"./type-D0rq44Ep.js";import{S as dr}from"./square-D8qfWSYD.js";import{g as $s}from"./gospelVerses-CwTXxT39.js";import"./jspdf.es.min-CFcvHOBu.js";import"./publicOrigin-DLiAwV89.js";import"./Combination-BzYupgMc.js";import"./tslib.es6-CwyXKlH1.js";import"./arrow-left-D11w9CMl.js";import"./arrow-right-ChcTNfqN.js";import"./nativeDownload-ruPHFkyf.js";/** 3 * @license lucide-react v0.475.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const Rs=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]],Ps=In("BookmarkCheck",Rs);/** 8 * @license lucide-react v0.475.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */const Ls=[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]],rr=In("Highlighter",Ls);function Ds(r){if(!r||typeof r!="string")return"";let n=r.replace(/\u2019/g,"'").replace(/\u2018/g,"'").replace(/\u201C/g,'"').replace(/\u201D/g,'"').replace(/^[\u00B6\uFFFD]\s*/,"");n=n.replace(/([A-Za-z])[\u00B6\uFFFD](?=[A-Za-z])/g,"$1'").replace(/([A-Za-z])[\u00B6\uFFFD](?=[^A-Za-z]|$)/g,"$1'"),n=n.replace(/\](['\u2019-])\[/g,"$1");let a;do a=n,n=n.replace(/\]( +)\[/g,"$1");while(n!==a);return n}function gn({text:r,searchTerm:n}){if(!n||!n.trim())return r;const a=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`(${a})`,"gi");return r.split(l).map((t,m)=>m%2===1?e.jsx("mark",{style:{backgroundColor:"rgba(250, 204, 21, 0.55)",borderRadius:"3px",padding:"0 2px"},children:t},m):e.jsx(Cn.Fragment,{children:t},m))}function kr({text:r,searchTerm:n}){const l=Ds(r).split(/\[([^\]]+)\]/g);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pilcrow",children:"¶"})," ",l.map((o,t)=>t%2===1?e.jsx("em",{children:e.jsx(gn,{text:o,searchTerm:n})},t):e.jsx(gn,{text:o,searchTerm:n},t))]})}function bn({verseCount:r,currentVerse:n,currentSection:a,hasSubscript:l,hasColophon:o,onSelect:t,bare:m}){const h=y=>n!=null&&n===y&&!a,b=y=>a===y,x=y=>`h-9 w-full rounded text-sm font-sans font-medium border transition-colors ${y?"bg-accent text-accent-foreground font-bold border-accent":"bg-secondary hover:bg-accent/20 text-foreground border-border"}`,c=[];l&&c.push({key:"sub",label:"Subscript",active:b("subscript")}),o&&c.push({key:"col",label:"Colophon",active:b("colophon")});const i=6,N=r%i,j=N===0?i:i-N,C=Math.floor(j/Math.max(c.length,1)),I=j-C*Math.max(c.length,1),T=c.map((y,g)=>Math.max(1,g<I?C+1:C)),v=m?"flex flex-col":"bg-card rounded-2xl overflow-hidden w-[90vw] max-w-sm max-h-[70vh] flex flex-col relative";return e.jsx("div",{className:v,children:e.jsxs("div",{className:m?"space-y-3"
12:"overflow-y-auto flex-1 p-3 space-y-3",children:[e.jsx("button",{"data-vaul-no-drag":!0,onPointerDown:y=>y.stopPropagation(),onClick:()=>t(""),className:x(!n&&!a),children:"Whole chapter"}),e.jsxs("div",{className:"grid grid-cols-6 gap-2",children:[Array.from({length:r},(y,g)=>g+1).map(y=>e.jsx("button",{"data-vaul-no-drag":!0,onPointerDown:g=>g.stopPropagation(),onClick:()=>t(y),className:x(h(y)),children:y},y)),c.map((y,g)=>e.jsx("button",{"data-vaul-no-drag":!0,onPointerDown:k=>k.stopPropagation(),onClick:()=>t(y.key),className:x(y.active),style:{gridColumn:`span ${T[g]}`},children:y.label},y.key))]})]})})}function Zt({open:r,onClose:n,title:a,children:l}){return u.useEffect(()=>{if(!r)return;const o=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=o}},[r]),r?Tn.createPortal(e.jsxs("div",{className:"kjb-selector-sheet fixed inset-0 z-[200] flex flex-col justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onPointerDown:o=>{o.target===o.currentTarget&&n()}}),e.jsxs("div",{className:"relative flex flex-col rounded-t-2xl bg-card border-t border-border max-h-[80vh] shadow-2xl animate-in slide-in-from-bottom duration-200",children:[e.jsx("div",{className:"mx-auto mt-3 mb-2 w-10 h-1.5 rounded-full bg-border flex-shrink-0"}),e.jsxs("div",{className:"flex items-center justify-center relative pb-3 flex-shrink-0 px-4",children:[a&&e.jsx("p",{className:"font-sans text-sm font-semibold text-foreground text-center",children:a}),e.jsx("button",{onClick:n,className:"absolute right-4 p-1 rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground transition-colors",children:e.jsx(dt,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"overflow-y-auto flex-1 px-4 pb-6",children:l})]})]}),document.body):null}function Er(r){if(!r||r.length===0)return"";if(r.length===1)return String(r[0]);const n=[...r].sort((t,m)=>t-m),a=[];let l=n[0],o=n[0];for(let t=1;t<n.length;t++)n[t]===o+1||(a.push(l===o?String(l):`${l}-${o}`),l=n[t]),o=n[t];return a.push(l===o?String(l):`${l}-${o}`),a.join(",")}function Os({highlightVerse:r,filterMode:n,selectedVerses:a,lastReadingPos:l,book:o,pos:t,highlightSection:m,onClear:h,searchTerm:b,onPrevResult:x,onNextResult:c,currentResultIndex:i,totalResults:N,gospelMode:j,gospelLabel:C,occurrenceLabel:I}){const T=n&&a.size>0,v=typeof window<"u"?new URLSearchParams(window.location.search):null,y=(v==null?void 0:v.get("from"))==="search";let g=b;if(!g&&!j&&v&&y){const F=localStorage.getItem("kjb-search-term"),J=F&&!/\d+\s*:\s*\d+/.test(F);g=v.get("q")||(J?F:null)||null}const k=t.verse,L=m==="colophon"?" (Colophon)":m==="subscript"?" (Superscription)":"";let D="",A="",R=null,V="Clear";if(j){D=C||"Gospel";const F=a&&a.size>1?`:${Er([...a])}`:k?`:${k}`:"";A=`${o.shortName} ${t.chapter}${F}`,V="Clear"}else if(g){D=/\d+\s*:\s*\d+/.test(g)&&!(N>1)?"Reading":`Searched: "${g}"`;const W=o.abbr==="PSA"&&t.chapter===119&&a&&a.size>1?" (Stanza)":a&&a.size>1?`:${Er([...a])}`:k?`:${k}${I||""}`:"";A=`${o.shortName} ${t.chapter}${W}${L}`,V=a&&a.size>0||n?"Show Full Chapter":"Clear search"}else T?(D="Reading",A=`${o.shortName} ${t.chapter}:${Er([...a])}`,V="Show Full Chapter"):k?A=`${o.shortName} ${t.chapter}:${k}`:A=`${o.shortName} ${t.chapter}`;if(!A)return null;const ae=(g||j)&&N>1&&x&&c;return e.jsxs("div",{className:"flex items-stretch gap-2 px-3 py-2 rounded-lg bg-accent text-accent-foreground font-sans text-xs font-medium min-w-0 flex-shrink-0",children:[e.jsx("div",{className:"flex flex-col leading-snug gap-0.5 min-w-0 justify-center",children:D?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[10px] uppercase tracking-wide opacity-75 break-words",children:D}),R,e.jsx("span",{className:"font-bold text-sm break-words",children:A})]}):e.jsx("span",{className:"font-bold text-sm break-words",children:A})}),(ae||h)&&e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 border-l border-accent-foreground/20 pl-2",children:[ae&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[10px] font-semibold opacity-70",children:[i+1,"/",N]}),e.jsx("button",{onClick:F=>{F.preventDefault(),F.stopPropagation(),x()},onTouchEnd:F=>{F.preventDefault(),F.stopPropagation(),x()},title:"Previous result (wraps to last)",className:"p-1 rounded hover:bg-accent-foreground
12/20 transition-all duration-200 hover:scale-110 active:scale-95 flex-shrink-0",children:e.jsx(is,{className:"w-4 h-4"})}),e.jsx("button",{onClick:F=>{F.preventDefault(),F.stopPropagation(),c()},onTouchEnd:F=>{F.preventDefault(),F.stopPropagation(),c()},title:"Next result (wraps to first)",className:"p-1 rounded hover:bg-accent-foreground/20 transition-all duration-200 hover:scale-110 active:scale-95 flex-shrink-0",children:e.jsx(Mt,{className:"w-4 h-4"})})]}),h&&e.jsx("button",{id:"kjb-currently-reading-clear-btn",onClick:F=>{F.preventDefault(),F.stopPropagation(),h()},title:V,className:"p-1 rounded hover:bg-accent-foreground/20 transition-all duration-200 hover:scale-110 active:scale-95 flex-shrink-0",children:e.jsx(dt,{className:"w-4 h-4"})})]})]})}const Fr=[{name:"yellow",bg:"bg-yellow-300/40 dark:bg-yellow-500/30",label:"Yellow",color:"#facc15"},{name:"green",bg:"bg-green-300/40 dark:bg-green-500/30",label:"Green",color:"#4ade80"},{name:"blue",bg:"bg-blue-300/40 dark:bg-blue-500/30",label:"Blue",color:"#60a5fa"},{name:"pink",bg:"bg-pink-300/40 dark:bg-pink-500/30",label:"Pink",color:"#f472b6"},{name:"purple",bg:"bg-purple-300/40 dark:bg-purple-500/30",label:"Purple",color:"#c084fc"}];function As({selectedCount:r,totalVerses:n,copyFeedback:a,shareFeedback:l,shareLinkFeedback:o,saveFeedback:t,onSelectAll:m,onCancel:h,onCopy:b,onCopyPerVerse:x,onShareText:c,onShareTextPerVerse:i,onShareLink:N,onReadSelected:j,onShowFull:C,onPrintPage:I,onPrintContents:T,onSave:v,onHighlight:y}){return e.jsxs("div",{className:"mt-2 pt-2 border-t border-border flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[e.jsxs("span",{className:"font-sans text-xs text-muted-foreground font-medium whitespace-nowrap",children:[r===0?"0":r,r===0?"":`/${n}`," selected"]}),e.jsx("div",{className:"w-px h-4 bg-border"}),e.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(bt,{className:"w-3.5 h-3.5"})," All"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(dt,{className:"w-3.5 h-3.5"})," Cancel"]}),r>0&&e.jsxs(e.Fragment,{children:[e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(nr,{className:"w-3.5 h-3.5"})," ",a?"Copied!":"Copy"]})}),e.jsxs(yt,{align:"end",className:"w-52",onCloseAutoFocus:g=>g.preventDefault(),children:[e.jsxs(Oe,{onClick:b,className:"cursor-pointer",children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),"Copy (Passage)"]}),e.jsxs(Oe,{onClick:x,className:"cursor-pointer",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Copy (Per Verse)"]})]})]}),e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(wt,{className:"w-3.5 h-3.5"})," ",l||o?"Copied!":"Share"]})}),e.jsxs(yt,{align:"end",className:"w-52",onCloseAutoFocus:g=>g.preventDefault(),children:[e.jsxs(Oe,{onClick:c,className:"cursor-pointer",children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),"Share Text (Passage)"]}),e.jsxs(Oe,{onClick:i,className:"cursor-pointer",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Share Text (Per Verse)"]}),e.jsxs(Oe,{onClick:N,className:"cursor-pointer",children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),"Share Link Only"]})]})]}),e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(hr,{className:"w-3.5 h-3.5"})," Print"]})}),e.jsxs(yt,{align:"end",className:"w-48",onCloseAutoFocus:g=>g.preventDefault(),children:[e.jsxs(Oe,{onClick:I,className:"cursor-pointer",children:[e.jsx(hr,{className:"w-4 h-4 mr-2"}),"Print Full Page"]}),e.jsxs(Oe,{onClick:T,className:"cursor-pointer",children:[e.jsx(fn,{className:"w-4 h-4 mr-2"}),"Print Selected Verses"]})]})]}),e.jsxs("button",{onClick:v,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(pr,{className:"w-3.5 h-3.5"})," ",t?"Saved!":"Save"]}),e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(rr,{className:"w-3.5 h-3.5"})," Highlight"]})}),e.jsx(yt,{align:"end",className:"min-w-[140px]",onCloseAutoFocus:g=>g.preventDefault(),children:Fr.map(g=>e.jsxs(Oe,{onSelect:k=>k.preventDefault(),onClick:()=>y(g.name),className:"cursor-pointer gap-2.5",children:[e.jsx("span",{className:"w-5 h-5 rounded-full border-2 border-border shadow-sm",style:{backgroundColor:g.color}}),e.jsx("span",{className:"font-sans text-sm text-foreground",children:g.label})]},g.name))})]}),e.jsxs("button",{onClick:j,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-primary text-primary-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(fn,{className:"w-3.5 h-3.5"})," Read Selected"]}),e.jsxs("button",{onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-accent/10 text-accent hover:bg-accent/20 font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(jt,{className:"w-3.5 h-3.5"})," Show Full Chapter"]})]})]})}function Fs({label:r,filterMode:n,copyFeedback:a,shareFeedback:l,shareLinkFeedback:o,saveFeedback:t,onCopy:m,onCopyPerVerse:h,onShareText:b,onShareTextPerVerse:x,onShareLink:c,onSave:i,onToggleView:N,onClear:j,onPrintPage:C,onPrintContents:I}){const T=u.useRef(r);return u.useEffect(()=>{const v=T.current;if(v&&r){const y=v.split(":")[0],g=r.split(":")[0];if(y!==g){const L=new URLSearchParams(window.location.search).get("from");L!=="search"&&L!=="gospel"&&j()}}T.current=r},[r,j]),e.jsxs("div",{className:"mt-2 pt-2 border-t border-border flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[e.jsx("span",{className:"font-sans text-xs text-muted-foreground font-medium whitespace-nowrap",children:r}),e.jsx("div",{className:"w-px h-4 bg-border"}),h?e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(nr,{className:"w-3.5 h-3.5"})," ",a?"Copied!":"Copy"]})}),e.jsxs(yt,{align:"end",className:"w-52",onCloseAutoFocus:v=>v.preventDefault(),children:[e.jsxs(Oe,{onClick:m,className:"cursor-pointer",children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),"Copy (Passage)"]}),e.jsxs(Oe,{onClick:h,className:"cursor-pointer",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Copy (Per Verse)"]})]})]}):e.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(nr,{className:"w-3.5 h-3.5"})," ",a?"Copied!":"Copy"]}),i&&e.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(pr,{className:"w-3.5 h-3.5"})," ",t?"Saved!":"Save"]}),e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(wt,{className:"w-3.5 h-3.5"})," ",l||o?"Copied!":"Share"]})}),e.jsxs(yt,{align:"end",className:"w-52",onCloseAutoFocus:v=>v.preventDefault(),children:[e.jsxs(Oe,{onClick:b,className:"cursor-pointer",children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),"Share Text (Passage)"]}),x&&e.jsxs(Oe,{onClick:x,className:"cursor-pointer",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Share Text (Per Verse)"]}),e.jsxs(Oe,{onClick:c,className:"cursor-pointer",children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),"Share Link Only"]})]})]}),e.jsxs("button",{onClick:I,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(hr,{className:"w-3.5 h-3.5"})," Print"]}),e.jsx("button",{onClick:N,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-accent/10 text-accent hover:bg-accent/20 font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:n?e.jsxs(e.Fragment,{children:[e.jsx(jt,{className:"w-3.5 h-3.5"})," Full Chapter"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ns,{className:"w-3.5 h-3.5"})," Verses Only"]})}),e.jsx("button",{id:"kjb-reading-range-clear-btn",onClick:v=>{v.preventDefault(),v.stopPropagation(),j(v)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:"Clear"})]})}function zs({label:r,isHighlighted:n,isSaved:a,copyFeedback:l,shareFeedback:o,saveFeedback:t,onToggleHighlight:m,onCopy:h,onShare:b,onSave:x,onClose:c}){return e.jsxs("div",{className:"mt-2 pt-2 border-t border-border flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[e.jsx("span",{className:"font-sans text-xs text-muted-foreground font-medium whitespace-nowrap",children:r}),e.jsx("div",{className:"w-px h-4 bg-border"}),e.jsxs(xt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap ${n?"bg-accent/20 text-accent":"bg-secondary hover:bg-accent/20 text-foreground"}`,children:[e.jsx(rr,{className:"w-3.5 h-3.5"})," ",n?"Highlighted":"Highlight"," ",e.jsx(Mt,{className:"w-3 h-3 opacity-60"})]})}),e.jsxs(yt,{align:"start",className:"min-w-[140px]",onCloseAutoFocus:i=>i.preventDefault(),children:[n&&e.jsx(Oe,{onSelect:i=>i.preventDefault(),onClick:()=>m(null),className:"cursor-pointer text-destructive",children:"Remove Highlight"}),Fr.map(i=>e.jsxs(Oe,{onSelect:N=>N.preventDefault(),onClick:()=>m(i.name),className:"cursor-pointer gap-2.5",children:[e.jsx("span",{className:"w-5 h-5 rounded-full border-2 border-border shadow-sm",style:{backgroundColor:i.color}}),e.jsx("span",{className:"font-sans text-sm text-foreground",children:i.label})]},i.name))]})]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(nr,{className:"w-3.5 h-3.5"})," ",l?"Copied!":"Copy"]}),e.jsxs("button",{onClick:b,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(wt,{className:"w-3.5 h-3.5"})," ",o?"Copied!":"Share"]}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(pr,{className:"w-3.5 h-3.5"})," ",t?"Saved!":a?"Saved":"Save"]}),e.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-all duration-200 hover:scale-[1.02] active:scale-[0.98] whitespace-nowrap",children:[e.jsx(dt,{className:"w-3.5 h-3.5"})," Close"]})]})}function Hs(r){const{results:n}=gt(),a=n[r];if(!a||!a.verse||a.section||n.filter(t=>t.abbr===a.abbr&&t.chapter===a.chapter&&t.verse===a.verse&&!t.section).length<2)return"";const o=a.occurrence||0;return String.fromCharCode(97+Math.min(o,25))}function Pn(r,n){r.forEach((a,l)=>{l===n?(a.style.backgroundColor="rgba(250, 204, 21, 0.95)",a.style.outline="2px s
12olid rgba(202, 138, 4, 0.9)"):(a.style.backgroundColor="rgba(250, 204, 21, 0.22)",a.style.outline="none")})}function Ms(r,n,a){requestAnimationFrame(()=>{const l=document.getElementById(`v${r}`);if(!l)return;Pn(l.querySelectorAll("mark[data-occ]"),n);const o=document.getElementById("kjb-scroll"),t=(a!=null&&a.current?a.current.getBoundingClientRect().height:0)+12,m=l.querySelector("sup, .kjb-dropcap-num")||l,h=m.getClientRects(),b=h.length>0?h[0].top:m.getBoundingClientRect().top;o?o.scrollTo({top:Math.max(0,b-o.getBoundingClientRect().top+o.scrollTop-t),behavior:"smooth"}):window.scrollTo({top:Math.max(0,b+window.scrollY-t),behavior:"smooth"})})}const Ln="kjb-verse-highlights";function zr(){try{return JSON.parse(localStorage.getItem(Ln)||"{}")}catch{return{}}}function Hr(r,n){return`${r}-${n}`}function Dn(r){try{localStorage.setItem(Ln,JSON.stringify(r))}catch{}window.dispatchEvent(new Event("kjb-highlights-changed"))}function Bs(r,n){return zr()[Hr(r,n)]||{}}function Rr(r,n,a){return Bs(r,n)[String(a)]||null}function $t(r,n,a,l){const o=zr(),t=Hr(r,n);o[t]={...o[t]||{},[String(a)]:l},Dn(o)}function mr(r,n,a){const l=zr(),o=Hr(r,n);if(l[o]){const{[String(a)]:t,...m}=l[o];Object.keys(m).length===0?delete l[o]:l[o]=m}Dn(l)}function Rt(r){return r==="cursive"?"'Dancing Script', cursive":r==="serif"?"'Merriweather', 'Cormorant Garamond', Georgia, serif":r==="sans-serif"?"'Inter', system-ui, -apple-system, sans-serif":r==="monospace"?"'Courier New', monospace":r==="comic-sans"?"'Comic Sans MS', 'Comic Sans', 'Chalkboard SE', 'Comic Neue', system-ui, sans-serif":r==="times"?"'Times New Roman', Times, serif":r==="dyslexic"?"'OpenDyslexic', 'Comic Sans MS', sans-serif":r==="hyperlegible"?"'Atkinson Hyperlegible', system-ui, sans-serif":r}const et=()=>{try{if(window.matchMedia&&window.matchMedia("(pointer: coarse)").matches)return!0}catch{}return/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent||"")||window.innerWidth<640},ot="kjb-position";function On(){try{const r=JSON.parse(localStorage.getItem(ot));if(r!=null&&r.abbr&&Pt.find(n=>n.abbr===r.abbr))return r}catch{}return{abbr:"GEN",chapter:1,verse:null}}function Xt(r,n,a=null,l=null){try{localStorage.setItem(ot,JSON.stringify({abbr:r,chapter:n,verse:a,verseEnd:l||null})),window.dispatchEvent(new Event("storage"))}catch{}}async function ur(r){if(navigator.clipboard&&window.isSecureContext)try{await navigator.clipboard.writeText(r);return}catch{}const n=document.createElement("textarea");n.value=r,n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy")}catch{}document.body.removeChild(n)}function Js({topRef:r,hideHeader:n,setHideHeader:a,anyMenuOpen:l,closeAllMenus:o,pos:t,book:m,isViewingTitlePage:h,showBookPicker:b,setShowBookPicker:x,showChapterPicker:c,setShowChapterPicker:i,showVersePicker:N,setShowVersePicker:j,showZoomPopover:C,setShowZoomPopover:I,showFontPopover:T,setShowFontPopover:v,pendingBook:y,setPendingBook:g,navigate:k,handleVersePick:L,verseCount:D,chapterSubscript:A,colophon:R,highlightVerse:V,highlightSection:ae,selectMode:F,selectedVerses:J,filterMode:W,setSelectMode:Ne,setFilterMode:P,setSelectedVerses:ve,setHighlightedVerses:de,setShowFilterOverlay:ke,setHighlightVerse:M,setHighlightSection:X,setTappedVerses:Q,zoomLevel:Ee,adjustZoom:q,handleZoomChange:Ie,resetZoom:he,fontFamily:K,a11yActive:Re,a11yFont:Be,handleFontChange:ut,flowMode:St,toggleFlow:G,columnOn:se,toggleColumn:Fe,toggleSelectMode:rt,paragraphMode:pe,columnMode:ee,verses:le,searchTerm:Le,gospelMode:ye,lastReadingActive:nt,lastReadingPos:Xe,gospelResultIndex:ne,gospelTotalResults:ue,searchResultIndex:ft,searchTotalResults:Se,setGospelResultIndex:Nt,setSearchResultIndex:Ce,stepToResult:fe,clearSearchContext:Me,setGospelMode:We,setLastReadingPos:st,returnToChapter:kt,scrollToVerseEl:d,rangeHighlightRef:B,resultViewRef:ge,goPrev:oe,goNext:Ye,isFirstChapterFirstBook:Te,isLastChapterLastBook:Et,copyFeedback:_e,saveFeedback:Lt,shareFeedback:Dt,shareLinkFeedback:ct,selectAllVerses:gr,handleCopySelected:Jt,handleCopyPerVerse:It,handleSaveSelected:mt,handleHighlightSelected:br,handleReadSelected:xr,handleShareChapter:Gt,handleSharePerVerse:Ot,handleShareLink:Yt,tappedVerseNums:ht,handleTapHighlightToggle:vr,handleTapCopy:ar,handleTapShare:Mr,handleTapSave:Ct,tapCopyFeedback:it,tapShareFeedback:Je,tapSaveFeedback:Br}){var _t;
12return e.jsxs("div",{ref:r,"data-kjb-reader-toolbar-wrap":!0,className:"print:hidden sticky top-0 z-[100] border-b border-border pb-4 pt-3 mb-8 relative shadow-sm -mx-5 sm:-mx-8 lg:-mx-12 px-5 sm:px-8 lg:px-12 bg-background before:content-[''] before:absolute before:bottom-full before:left-[calc(-1*env(safe-area-inset-left,0px))] before:right-[calc(-1*env(safe-area-inset-right,0px))] before:h-12 before:bg-background",children:[e.jsxs("div",{onClickCapture:S=>{l&&!S.target.closest('button, [role="menu"], .kjb-popover-panel')&&o()},className:"kjb-reader-toolbar flex flex-wrap items-stretch justify-stretch gap-3 w-full max-w-[120rem] mx-auto [&>button:not(.kjb-fixed-btn)]:flex-grow [&>button:not(.kjb-fixed-btn)]:basis-auto [&>div.relative]:flex-grow [&>div.relative>button]:w-full",children:[e.jsxs("div",{className:"relative flex",children:[e.jsxs("button",{onClick:()=>{x(S=>!S),i(!1),j(!1),I(!1),v(!1)},className:"flex items-center justify-center gap-1.5 px-3 rounded-lg bg-primary text-primary-foreground font-sans text-sm font-medium hover:opacity-90 transition-all duration-200 touch-manipulation h-10 w-full",children:[e.jsx("span",{className:"notranslate truncate text-center",children:h?"Title Page":m.shortName}),e.jsx(zt,{className:`w-3 h-3 opacity-70 transition-transform duration-200 flex-shrink-0 ${b?"rotate-90":""}`})]}),b&&!et()&&e.jsx("div",{className:"kjb-popover-panel absolute top-full left-0 mt-1 z-[100]",children:e.jsx(cn,{currentAbbr:t.abbr,onSelect:(S,te,me)=>{te?(k(S.abbr,0),x(!1)):me&&(g(S),x(!1),i(!0))},onClose:()=>x(!1)})}),e.jsx(Zt,{open:b&&et(),onClose:()=>x(!1),title:"Select Book",children:e.jsx(cn,{currentAbbr:t.abbr,onSelect:(S,te,me)=>{te?(k(S.abbr,0),x(!1)):me&&(g(S),x(!1),i(!0))},onClose:()=>x(!1)})})]}),!h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex",children:[e.jsxs("button",{onClick:()=>{x(!1),I(!1),v(!1),m.chapters<=1?(j(S=>!S),i(!1)):(i(S=>!S),j(!1))},className:"flex items-center justify-center gap-1.5 px-3 rounded-lg bg-secondary border border-border text-secondary-foreground font-sans text-sm font-medium hover:bg-accent/20 transition-all duration-200 touch-manipulation h-10 w-full",children:[e.jsxs("span",{className:"notranslate",children:["Ch.",t.chapter]}),e.jsx(zt,{className:`w-3 h-3 opacity-70 transition-transform duration-200 flex-shrink-0 ${c?"rotate-90":""}`})]}),c&&!et()&&e.jsx("div",{className:"kjb-popover-panel absolute top-full left-0 mt-1 z-[100]",children:e.jsx(dn,{totalChapters:y?y.chapters:m.chapters,currentChapter:y?null:t.chapter,onSelect:(S,te)=>{k(y?y.abbr:t.abbr,S),g(null),i(!1),te&&j(!0)},onClose:()=>{g(null),i(!1)},onWholeBook:()=>{y&&k(y.abbr,1),g(null),i(!1)},bookName:y?y.name:m.name})}),e.jsx(Zt,{open:c&&et(),onClose:()=>i(!1),title:"Select Chapter",children:e.jsx(dn,{totalChapters:y?y.chapters:m.chapters,currentChapter:y?null:t.chapter,onSelect:(S,te)=>{k(y?y.abbr:t.abbr,S),g(null),i(!1),te&&j(!0)},onClose:()=>{g(null),i(!1)},onWholeBook:()=>{y&&k(y.abbr,1),g(null),i(!1)},bookName:y?y.name:m.name,bare:!0})})]}),e.jsxs("div",{className:"relative flex",children:[e.jsxs("button",{onClick:()=>{j(S=>!S),x(!1),i(!1),I(!1),v(!1)},className:`flex items-center justify-center gap-1.5 px-3 rounded-lg border border-border font-sans text-sm font-medium transition-all duration-200 touch-manipulation h-10 w-full ${F?"bg-primary text-primary-foreground":W&&J.size>0||V?"bg-accent/20 text-accent":"bg-secondary text-secondary-foreground hover:bg-accent/20"}`,disabled:D===0,children:[e.jsx("span",{className:"truncate min-w-[3.5rem] text-center",children:F?`${J.size>0?J.size:"0"} selected`:W&&J.size>0?`vv.${lt([...J])}`:ae==="colophon"?"Colophon":ae==="subscript"?"Subscript":V?`v.${V}`:"Verse"}),F?e.jsx(bt,{className:"w-3.5 h-3.5 opacity-70 flex-shrink-0 transition-transform duration-200"}):e.jsx(zt,{className:`w-3 h-3 opacity-70 transition-transform duration-200 flex-shrink-0 ${N?"rotate-90":""}`})]}),N&&D>0&&!et()&&e.jsx("div",{className:"kjb-popover-panel absolute top-full left-0 mt-1 z-[100]",children:e.jsx(bn,{verseCount:D,currentVerse:V,currentSection:ae,hasSubscript:!!A,hasColophon:!!R,onSelect:L})}),e.jsx(Zt,{open:N&&D>0&&et(),onClose:()=>j(!1),title:"Select Verse",children:e.jsx(bn,{verseCount:D,currentVerse:V,currentSection:ae,hasSubscript:!!A,hasColophon:!!R,onSelect:L,bare:!0})})]}),e.jsxs("div",{className:"relative flex",children:[e.jsxs("button",{onClick:()=>{I(S=>!S),x(!1),i(!1),j(!1),v(!1)},title:`Zoom: ${Ee}%`,className:"flex items-center justify-center gap-1 px-3 rounded-lg bg-secondary border border-border text-secondary-foreground font-sans text-xs font-medium hover:bg-accent/20 transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:[e.jsx(ds,{className:"w-3.5 h-3.5 transition-transform duration-200 flex-shrink-0"}),e.jsxs("span",{className:"truncate",children:[Ee,"%"]})]}),C&&!et()&&e.jsx("div",{className:"kjb-popover-panel absolute top-full right-0 mt-1 z-[100]",onClick:S=>S.stopPropagation(),children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-xl p-4 w-64 relative overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 pr-6",children:[e.jsx("span",{className:"font-sans text-xs font-medium text-foreground",children:"Text Size"}),e.jsxs("span",{className:"font-sans text-xs font-semibold text-primary",children:[Ee,"%"]})]}),e.jsx("button",{onClick:()=>I(!1),className:"absolute top-3 right-3 p-1 rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground transition-colors",children:e.jsx(dt,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>q(-5),className:"p-1.5 rounded-lg bg-secondary hover:bg-accent/20 transition-colors",children:e.jsx(hn,{className:"w-3.5 h-3.5"})}),e.jsx("input",{type:"range",min:"75",max:"250",step:"5",value:Ee,onChange:Ie,className:"flex-1 h-2 bg-muted-foreground
12/30 rounded-lg appearance-none cursor-pointer accent-primary"}),e.jsx("button",{onClick:()=>q(5),className:"p-1.5 rounded-lg bg-secondary hover:bg-accent/20 transition-colors",children:e.jsx(pn,{className:"w-3.5 h-3.5"})})]}),Ee!==100&&e.jsx("button",{onClick:he,className:"w-full mt-2 px-2 py-1.5 rounded-lg bg-primary/10 text-primary font-sans text-xs font-medium hover:bg-primary/20 transition-colors",children:"Reset to 100%"})]})}),e.jsx(Zt,{open:C&&et(),onClose:()=>I(!1),title:"Text Size",children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-sans text-sm font-medium text-foreground",children:"Zoom Level"}),e.jsxs("span",{className:"font-sans text-sm font-semibold text-primary",children:[Ee,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>q(-5),className:"p-2 rounded-lg bg-secondary hover:bg-accent/20 transition-colors",children:e.jsx(hn,{className:"w-4 h-4"})}),e.jsx("input",{type:"range",min:"75",max:"250",step:"5",value:Ee,onChange:Ie,className:"flex-1 h-3 bg-muted-foreground/30 rounded-lg appearance-none cursor-pointer accent-primary"}),e.jsx("button",{onClick:()=>q(5),className:"p-2 rounded-lg bg-secondary hover:bg-accent/20 transition-colors",children:e.jsx(pn,{className:"w-4 h-4"})})]}),Ee!==100&&e.jsx("button",{onClick:he,className:"w-full px-4 py-3 rounded-lg bg-primary/10 text-primary font-sans text-sm font-medium hover:bg-primary/20 transition-colors",children:"Reset to 100%"})]})})]}),e.jsxs("div",{className:"relative flex",children:[e.jsxs("button",{onClick:()=>{v(S=>!S),x(!1),i(!1),j(!1),I(!1)},title:"Font family",className:"flex items-center justify-center gap-1 px-3 rounded-lg bg-secondary border border-border text-secondary-foreground font-sans text-xs font-medium hover:bg-accent/20 transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:[e.jsx(Ts,{className:"w-3.5 h-3.5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:(()=>{const S=Re?Be:K;return S==="serif"?"Serif":S==="sans-serif"?"Sans":S==="monospace"?"Mono":S==="comic-sans"?"Comic":S==="times"?"Times":S==="dyslexic"?"Dyslexic":S==="hyperlegible"?"Legible":"Cursive"})()})]}),T&&!et()&&e.jsx("div",{className:"kjb-popover-panel absolute top-full left-0 mt-1 z-[100]",onClick:S=>S.stopPropagation(),children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-xl p-4 w-64 relative overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between mb-3 pr-6",children:e.jsx("span",{className:"font-sans text-xs font-medium text-foreground",children:"Font Family"})}),e.jsx("button",{onClick:()=>v(!1),className:"absolute top-3 right-3 p-1 rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground transition-colors",children:e.jsx(dt,{className:"w-4 h-4"})}),Re&&e.jsx("p",{className:"font-sans text-[11px] text-muted-foreground mb-2 leading-snug",children:"An accessibility font is active app-wide and overrides reading fonts."}),e.jsx("p",{className:"font-sans text-[11px] text-muted-foreground",children:"Standard"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[{value:"serif",label:"Serif"},{value:"sans-serif",label:"Sans"},{value:"monospace",label:"Mono"},{value:"cursive",label:"Cursive"},{value:"comic-sans",label:"Comic"},{value:"times",label:"Times"}].map(S=>{const te=Re?!1:K===S.value,me=Re;return e.jsx("button",{disabled:me,onClick:()=>{ut(S.value),v(!1)},className:`px-3 py-2 rounded-lg border font-sans text-xs font-medium transition-all ${te?"bg-primary text-primary-foreground border-primary":"bg-secondary text-secondary-foreground border-border hover:bg-accent/20"} ${me?"opacity-40 pointer-events-none":""}`,style:{fontFamily:Rt(S.value)},children:S.label},S.value)})}),e.jsx("p",{className:"font-sans text-[11px] text-muted-foreground",children:"Accessibility"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"dyslexic",label:"Dyslexic"},{value:"hyperlegible",label:"Legible"}].map(S=>{const te=Re&&Be===S.value;return e.jsx("button",{onClick:()=>{ut(S.value),v(!1)},className:`px-3 py-2 rounded-lg border font-sans text-xs font-medium transition-all ${te?"bg-primary text-primary-foreground border-primary":"bg-secondary text-secondary-foreground border-border hover:bg-accent/20"}`,style:{fontFamily:Rt(S.value)},children:S.label},S.value)})})]})}),e.jsx(Zt,{open:T&&et(),onClose:()=>v(!1),title:"Font Family",children:e.jsxs("div",{className:"space-y-2 p-2",children:[Re&&e.jsx("p",{className:"font-sans text-xs text-muted-foreground leading-snug mb-1",children:"An accessibility font is active app-wide and overrides reading fonts."}),e.jsx("p",{className:"font-sans text-xs text-muted-foreground",children:"Standard"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[{value:"serif",label:"Serif"},{value:"sans-serif",label:"Sans"},{value:"monospace",label:"Mono"},{value:"cursive",label:"Cursive"},{value:"comic-sans",label:"Comic"},{value:"times",label:"Times"}].map(S=>{const te=Re?!1:K===S.value,me=Re;return e.jsx("button",{disabled:me,onClick:()=>{ut(S.value),v(!1)},className:`w-full px-4 py-3 rounded-lg border font-sans text-sm font-medium transition-all ${te?"bg-primary text-primary-foreground border-primary":"bg-secondary text-secondary-foreground border-border hover:bg-accent/20"} ${me?"opacity-40 pointer-events-none":""}`,style:{fontFamily:Rt(S.value)},children:S.label},S.value)})}),e.jsx("p",{className:"font-sans text-xs text-muted-foreground",children:"Accessibility"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"dyslexic",label:"Dyslexic"},{value:"hyperlegible",label:"Legible"}].map(S=>{const te=Re&&Be===S.value;return e.jsx("button",{onClick:()=>{ut(S.value),v(!1)},className:`w-full px-4 py-3 rounded-lg border font-sans text-sm font-medium transition-all ${te?"bg-primary text-primary-foreground border-primary":"bg-secondary text-secondary-foreground border-border hover:bg-accent/20"}`,style:{fontFamily:Rt(S.value)},children:S.label},S.value)})})]})})]}),e.jsxs("button",{onClick:G,title:St==="line"?"Switch to paragraph":"Switch to line-by-line",className:`flex items-center justify-center gap-1.5 px-3 rounded-lg border border-border font-sans text-xs font-medium transition-all duration-200 touch-manipulation h-10 whitespace-nowrap ${pe?"bg-accent/20 text-accent":"bg-secondary text-secondary-foreground hover:bg-accent/20"}`,children:[St==="line"?e.jsx(Bt,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}):e.jsx(ws,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:St==="line"?"Lines":"Para"})]}),e.jsxs("button",{onClick:Fe,title:se?"Switch to single column":"Switch to two-column",className:`flex items-center justify-center gap-1.5 px-3 rounded-lg border border-border font-sans text-xs font-medium transition-all duration-200 touch-manipulation h-10 whitespace-nowrap ${se?"bg-accent/20 text-accent":"bg-secondary text-secondary-foreground hover:bg-accent/20"}`,children:[se?e.jsx(Ss,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}):e.jsx(jt,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:se?"2-Col":"1-Col"})]}),e.jsxs("button",{onClick:rt,title:"Select verses",className:`kjb-fixed-btn flex-none flex items-center justify-center gap-1.5 px-3 rounded-lg border border-border font-sans text-xs font-medium transition-all duration-200 touch-manipulation h-10 whitespace-nowrap ${F?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-accent/20"}`,children:[e.jsx(bt,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:"Select"})]}),e.jsxs(xt,{onOpenChange:S=>{S&&o()},children:[e.jsx(vt,{asChild:!0,children:e.jsxs("button",{title:Dt||ct?"Copied!":"Share",className:"kjb-fixed-btn flex-none flex items-center justify-center gap-1.5 px-3 rounded-lg bg-secondary border border-border text-secondary-foreground hover:bg-accent/20 transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:[e.jsx(wt,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:Dt||ct?"Copied!":"Share"})]})}),e.jsxs(yt,{align:"center",className:"w-52",onCloseAutoFocus:S=>
12S.preventDefault(),children:[e.jsxs(Oe,{onClick:Gt,className:"cursor-pointer",children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),"Share Text (Passage)"]}),e.jsxs(Oe,{onClick:Ot,className:"cursor-pointer",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),"Share Text (Per Verse)"]}),e.jsxs(Oe,{onClick:Yt,className:"cursor-pointer",children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),"Share Link Only"]})]})]}),e.jsxs("button",{onClick:()=>Kt(le,m,t,W,J,R,ee,pe),title:"Print",className:"kjb-fixed-btn flex items-center justify-center gap-1.5 px-3 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:[e.jsx(hr,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:"Print"})]}),e.jsxs("button",{onClick:oe,disabled:Te,"data-testid":"prev-chapter-btn",className:"kjb-fixed-btn flex-shrink-0 flex items-center justify-center gap-1.5 px-3 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground disabled:opacity-30 transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:[e.jsx(Ir,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:"Prev"})]}),e.jsxs("button",{onClick:()=>Ye(),disabled:Et,"data-testid":"next-chapter-btn",className:"kjb-fixed-btn flex-shrink-0 flex items-center justify-center gap-1.5 px-3 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground disabled:opacity-30 transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:[e.jsx("span",{className:"hidden lg:inline",children:"Next"}),e.jsx(zt,{className:"w-5 h-5 transition-transform duration-200 flex-shrink-0"})]}),e.jsx("button",{onClick:S=>{S.stopPropagation(),a(!n)},title:n?"Show header":"Hide header",className:"kjb-fixed-btn flex-shrink-0 flex items-center justify-center px-2.5 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground transition-all duration-200 touch-manipulation h-10 whitespace-nowrap",children:e.jsx(Mt,{className:`w-5 h-5 transition-transform duration-200 flex-shrink-0 ${n?"":"rotate-180"}`})}),(W&&J.size>0||nt||Le||ye||V)&&e.jsx(Os,{highlightVerse:V,filterMode:W,selectedVerses:J,lastReadingPos:nt?Xe:null,book:m,pos:t,highlightSection:ae,searchTerm:Le,gospelMode:ye,gospelLabel:ye?((_t=tt().results[ne])==null?void 0:_t.label)||"Gospel":null,currentResultIndex:ye?ne:ft,totalResults:ye?ue:Se,occurrenceLabel:!ye&&Le?Hs(ft):"",onPrevResult:()=>{if(ye){const{results:be,index:Ut}=tt();if(be.length===0)return;const De=(Ut-1+be.length)%be.length,pt=be[De];pt&&(Cr(De),Nt(De),fe(pt));return}const{results:S,index:te}=gt();if(S.length===0)return;const me=(te-1+S.length)%S.length,Ue=S[me];Ue&&(Tr(me),Ce(me),fe(Ue))},onNextResult:()=>{if(ye){const{results:be,index:Ut}=tt();if(be.length===0)return;const De=(Ut+1)%be.length,pt=be[De];pt&&(Cr(De),Nt(De),fe(pt));return}const{results:S,index:te}=gt();if(S.length===0)return;const me=(te+1)%S.length,Ue=S[me];Ue&&(Tr(me),Ce(me),fe(Ue))},onClear:()=>{let S,te,me;try{const Ue=localStorage.getItem("kjb-prev-reading-session");if(Ue){const be=JSON.parse(Ue);be&&be.abbr&&be.chapter&&(S=be.abbr,te=be.chapter,me=be.scrollY)}}catch{}if(!S||!te)try{const Ue=localStorage.getItem("kjb-last-reading");if(Ue){const be=JSON.parse(Ue);be&&be.prevAbbr&&be.prevChapter&&(S=be.prevAbbr,te=be.prevChapter,me=typeof be.prevScrollY=="number"?be.prevScrollY:be.scrollY)}}catch{}Le&&Me(),ye&&(Ze(),We(!1)),st(null),P(!1),Ne(!1),ve(new Set),de(new Set),M(null),X(null),ke(!1);try{localStorage.removeItem("kjb-last-reading")}catch{}try{localStorage.removeItem("kjb-reader-toolbar-state")}catch{}S&&te?kt(S,te,me):k(t.abbr,t.chapter,null,!1,!1,!0)}})]}),h&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:oe,disabled:Te,title:"Previous","data-testid":"prev-chapter-btn",className:"flex flex-1 items-center justify-center gap-1.5 px-2.5 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground disabled:opacity-30 transition-all duration-200 touch-manipulation h-10 ",children:[e.jsx(Ir,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{className:"hidden lg:inline",children:"Prev"})]}),e.jsxs("button",{onClick:()=>Ye(),title:"Next","data-testid":"next-chapter-btn",className:"flex flex-1 items-center justify-center gap-1.5 px-2.5 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground transition-all duration-200 touch-manipulation h-10 ",children:[e.jsx("span",{className:"hidden lg:inline",children:"Next"}),e.jsx(zt,{className:"w-5 h-5 flex-shrink-0"})]}),e.jsx("button",{onClick:S=>{S.stopPropagation(),a(!n)},title:n?"Show header":"Hide header",className:"flex items-center justify-center px-2.5 rounded-lg bg-secondary border border-border hover:bg-accent/20 text-foreground transition-all duration-200 touch-manipulation h-10 flex-shrink-0",children:e.jsx(Mt,{className:`w-5 h-5 flex-shrink-0 ${n?"":"rotate-180"}`})})]})]}),F&&e.jsx(As,{selectedCount:J.size,totalVerses:le.length,copyFeedback:_e,shareFeedback:Dt,shareLinkFeedback:ct,saveFeedback:Lt,onSelectAll:gr,onCancel:()=>{if(Le){Me();return}if(ye){Ze(),We(!1),M(null),st(null);try{localStorage.removeItem("kjb-last-reading")}catch{}return}Ne(!1),W&&J.size>0?M(Math.min(...J)):(P(!1),ve(new Set),M(null))},onCopy:Jt,onCopyPerVerse:It,onShareText:Gt,onShareTextPerVerse:Ot,onShareLink:Yt,onReadSelected:xr,onShowFull:()=>{P(!1),Ne(!1),ve(new Set),ke(!1)},onPrintPage:()=>{if(!un()){if(ee&&mn()){Kt(le,m,t,W,J,R,ee,pe);return}window.print()}},onPrintContents:()=>Kt(le,m,t,W,J,R,ee,pe),onSave:mt,onHighlight:br}),!F&&J.size>0&&ht.length===0&&e.jsx(Fs,{label:Le?/\d+:\d+/.test(Le)?`Currently Reading: ${m.shortName} ${t.chapter}:${lt([...J])}`:`Search: "${Le}"`:ye?"Gospel":nt?Xe!=null&&Xe.fromRandom?"Random Chapter":"Daily Verse":`Reading ${m.shortName} ${t.chapter}:${lt([...J])}`,filterMode:W,copyFeedback:_e,shareFeedback:Dt,shareLinkFeedback:ct,saveFeedback:Lt,onCopy:Jt,onCopyPerVerse:It,onShareText:Gt,onShareTextPerVerse:Ot,onShareLink:Yt,onSave:mt,onPrintPage:()=>{if(!un()){if(ee&&mn()){Kt(le,m,t,W,J,R,ee,pe);return}window.print()}},onPrintContents:()=>Kt(le,m,t,W,J,R,ee,pe),onToggleView:()=>{P(S=>{const te=!S;if(B.current=te,ge.current=te?"filter":"full",!te&&J.size>0){const me=Math.min(...J);M(me),setTimeout(()=>d(me),80),setTimeout(()=>d(me),350)}return te})},onClear:()=>{if(Le){Me();return}if(ye){Ze(),We(!1),M(null),st(null);try{localStorage.removeItem("kjb-last-reading"),localStorage.removeItem("kjb-reader-toolbar-state")}catch{}return}if(nt){st(null);try{localStorage.removeItem("kjb-last-reading"),localStorage.removeItem("kjb-reader-toolbar-state")}catch{}return}B.current=!1,Ne(!1),ke(!1);try{localStorage.removeItem("kjb-reader-toolbar-state")}catch{}k(t.abbr,t.chapter,null,!1,!1,!0)}}),!F&&ht.length>0&&e.jsx(zs,{label:`${m.shortName} ${t.chapter}:${lt(ht)}`,isHighlighted:ht.some(S=>!!Rr(t.abbr,t.chapter,S)),isSaved:ht.every(S=>Ar(t.abbr,t.chapter,S)),copyFeedback:it,shareFeedback:Je,saveFeedback:Br,onToggleHighlight:vr,onCopy:ar,onShare:Mr,onSave:Ct,onClose:()=>Q(new Set)})]})}const Pr="Â";let fr=null,An=null;function Gs(){return fr||(fr=fetch("/hyphenation.json").then(r=>r.ok?r.json():{}).then(r=>(An=r,r)).catch(()=>(fr=null,{}))),fr}function xn(){return An}function Ys(r,n){if(!n)return r;let a="",l=0;const o=r.length;for(;l<o;){const t=r.indexOf("<",l);if(t===-1){a+=vn(r.slice(l),n);break}t>
12l&&(a+=vn(r.slice(l,t),n));const m=r.indexOf(">",t);if(m===-1){a+=r.slice(t);break}a+=r.slice(t,m+1),l=m+1}return a}function vn(r,n){return r.replace(/[A-Za-z]{5,}/g,a=>{const l=n[a.toLowerCase()];if(!l)return a;let o="",t=0;for(let m=0;m<a.length;m++)o+=a[m],t<l.length&&l[t]===m+1&&(o+=Pr,t++);return o})}let yn=!1;function _s(){yn||typeof document>"u"||(yn=!0,document.addEventListener("copy",r=>{try{const n=window.getSelection?String(window.getSelection()):"";if(!n||n.indexOf(Pr)===-1)return;const a=n.split(Pr).join(""),l=a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>");r.clipboardData.setData("text/plain",a),r.clipboardData.setData("text/html",`<span>${l}</span>`),r.preventDefault()}catch{}},!0))}function Us({children:r,point:n}){const a=u.useRef(null),[l,o]=u.useState({position:"fixed",top:0,left:0,opacity:0});return u.useLayoutEffect(()=>{const t=a.current;if(!t)return;const m=()=>{const h=t.getBoundingClientRect(),b=window.innerWidth,x=window.innerHeight,c=8,i=document.querySelector("[data-kjb-reader-toolbar-wrap]"),N=i?i.getBoundingClientRect().bottom:96,j=96,C=N+c,I=x-j-c,T=(n==null?void 0:n.x)??b/2,v=(n==null?void 0:n.y)??x/2,y=I-C,g=Math.max(120,y),k=Math.min(h.height,g);let A=I-v<k+c?v-k-c:v+c;A=Math.max(C,Math.min(A,I-k));const R=b-c*2,V=Math.min(h.width,R);let ae=T-V/2;ae=Math.max(c,Math.min(ae,b-c-V)),o({position:"fixed",top:A,left:ae,maxWidth:R,maxHeight:g,opacity:1})};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[n]),e.jsx("div",{ref:a,style:l,className:"z-[120] w-max max-w-[calc(100vw-1rem)] inline-flex flex-wrap items-center justify-start gap-1.5 bg-card border border-border rounded-xl shadow-xl px-2.5 py-2 overflow-y-auto",children:r})}function Vs({onSelect:r,onCancel:n}){const[a,l]=u.useState(ks()),[o,t]=u.useState(!1),[m,h]=u.useState(""),b=u.useRef(null);u.useEffect(()=>{o&&b.current&&b.current.focus()},[o]);const x=()=>{const c=m.trim();c&&(Cs(c),r(c))};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-50",onClick:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),n()},onTouchEnd:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),n()}}),e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-[60] flex flex-col gap-1 bg-card border border-border rounded-xl p-3 shadow-xl min-w-[180px] max-w-[240px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"font-sans text-xs font-medium text-muted-foreground",children:"Save to folder"}),e.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),n()},onTouchEnd:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),n()},className:"p-1 rounded hover:bg-secondary text-muted-foreground transition-colors",children:e.jsx(dt,{className:"w-3 h-3"})})]}),o?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("input",{ref:b,type:"text",value:m,onChange:c=>h(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"&&(c.preventDefault(),x()),c.key==="Escape"&&(c.preventDefault(),t(!1),h(""))},placeholder:"Folder name",className:"w-full px-2.5 py-1.5 rounded-lg bg-background border border-border font-sans text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",onClick:c=>{c.stopPropagation()},onTouchEnd:c=>{c.stopPropagation()}}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),t(!1),h("")},onTouchEnd:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),t(!1),h("")},className:"flex-1 px-2 py-1.5 rounded-lg bg-secondary text-secondary-foreground font-sans text-xs font-medium hover:bg-accent/20 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),x()},onTouchEnd:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),x()},disabled:!m.trim(),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-lg bg-primary text-primary-foreground font-sans text-xs font-medium hover:opacity-90 disabled:opacity-50 transition-colors",children:[e.jsx(us,{className:"w-3 h-3"}),"Create"]})]})]}):e.jsxs(e.Fragment,{children:[a.map(c=>e.jsxs("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),i.nativeEvent.stopImmediatePropagation(),r(c)},onTouchEnd:i=>{i.preventDefault(),i.stopPropagation(),i.nativeEvent.stopImmediatePropagation(),r(c)},className:"flex items-center gap-2 w-full p-1.5 rounded-lg hover:bg-secondary transition-colors text-left",children:[e.jsx(Es,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-sans text-sm text-foreground truncate",children:c})]},c)),e.jsxs("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),t(!0)},onTouchEnd:c=>{c.preventDefault(),c.stopPropagation(),c.nativeEvent.stopImmediatePropagation(),t(!0)},className:"flex items-center gap-2 w-full p-1.5 rounded-lg hover:bg-secondary transition-colors text-left border-t border-border mt-1 pt-2",children:[e.jsx(Is,{className:"w-3.5 h-3.5 text-primary shrink-0"}),e.jsx("span",{className:"font-sans text-sm text-primary font-medium",children:"New Folder"})]})]})]})]})}const qs=1.625,Ws=2,Ks="'Merriweather', 'Cormorant Garamond', Georgia, serif",Zs="'Cormorant Garamond', 'Merriweather', Georgia, serif",jn={dyslexic:"'OpenDyslexic', 'Comic Sans MS', sans-serif",hyperlegible:"'Atkinson Hyperlegible', system-ui, sans-serif",system:"system-ui, -apple-system, sans-serif"};function Xs(){const r=document.documentElement,n=r.getAttribute("data-a11y-font");if(n&&jn[n]){const l=jn[n];return{text:l,cap:l}}const a=r.getAttribute("data-reader-font");if(a&&a!=="cursive"){const l=Rt(a);return{text:l,cap:l}}return{text:Ks,cap:Zs}}let Qt=null;function wn(r,n){try{if(Qt||(Qt=document.createElement("canvas").getContext("2d")),!Qt)return null;Qt.font=`${r} 100px ${n}`;const a=Qt.measureText("Mg"),{fontBoundingBoxAscent:l,fontBoundingBoxDescent:o}=a;return typeof l!="number"||typeof o!="number"||l<=0||o<0?null:{A:l/100,D:o/100}}catch{return null}}async function Qs(r,n){var a;try{(a=document.fonts)!=null&&a.load&&await Promise.all([document.fonts.load(`700 100px ${n.cap}`),document.fonts.load(`400 100px ${n.text}
12`)]).catch(()=>{});const l=wn(400,n.text),o=wn(700,n.cap);if(!l||!o)return"";const t=(r-(l.A+l.D))/2,m=r+t+l.A,h=(o.A-o.D)/2;if(h<=0)return"";const b=(m-r)/h,x=2*r/b;return!Number.isFinite(b)||!Number.isFinite(x)||b<=.5||b>12||x<=0||x>4?"":`--kjb-dc-f:${b.toFixed(3)}em;--kjb-dc-lh:${x.toFixed(3)};`}catch{return""}}let er={key:null,style:""};const Lr=new Set;function ea(r){return Lr.add(r),()=>Lr.delete(r)}function ta(r){const n=r?Ws:qs,a=Xs(),l=`${n}|${a.text}|${a.cap}`;return er.key===l||(er={key:l,style:""},Qs(n,a).then(o=>{er.style=o,Lr.forEach(t=>t())}).catch(()=>{})),er.style}function ra(r){const[,n]=u.useState(0);return u.useEffect(()=>ea(()=>n(a=>a+1)),[]),ta(r)}function na({verse:r,highlight:n=!1,id:a,bookName:l,abbr:o,chapter:t,isFirstVerse:m=!1,paragraphMode:h=!1,selectMode:b=!1,highlightMode:x=!1,activeHighlightColor:c=null,isSelected:i=!1,onSelect:N,onActivateSelect:j,totalVerses:C=0,colophon:I=null,subscript:T=null,isCursive:v=!1,fontFamilyValue:y=null,zoomLevel:g=100,hasSubscript:k=!1,searchTerm:L=null,dropCap:D=!1,columnMode:A=!1,onVerseTap:R=null,isDirectJump:V=!1}){var st,kt;const ae=Pt.find(d=>d.abbr===o),F=ae?ae.shortName:l,[J,W]=u.useState(!1),[,Ne]=u.useState(0);u.useEffect(()=>{const d=()=>Ne(B=>B+1);return window.addEventListener("kjb-highlights-changed",d),()=>window.removeEventListener("kjb-highlights-changed",d)},[]);const P=Rr(o,t,r.verse),ve=!!P,[de,ke]=u.useState(()=>Rr(o,t,r.verse)||"yellow"),[M,X]=u.useState(!1),[Q,Ee]=u.useState(()=>Ar(o,t,r.verse)),[q,Ie]=u.useState(r.text),[he,K]=u.useState(!1),[Re,Be]=u.useState(null),[,ut]=u.useState(0),St=ra(h);u.useEffect(()=>{Ie(r.text)},[r.text]),u.useEffect(()=>{if(_s(),!A||xn())return;let d=!0;return Gs().then(()=>{d&&ut(B=>B+1)}),()=>{d=!1}},[A]),u.useEffect(()=>{const d=async()=>{try{const{fetchChapter:B}=await fs(async()=>{const{fetchChapter:Te}=await import("./bibleApi-COTrrsw1.js").then(Et=>Et.o);return{fetchChapter:Te}},__vite__mapDeps([0,1,2])),ge=Pt.find(Te=>Te.abbr===o);if(!ge)return;const Ye=(await B(ge.apiName,t)).verses.find(Te=>Te.verse===r.verse);Ye&&Ye.text!==q&&Ie(Ye.text)}catch(B){console.error("Failed to update verse silently:",B)}};return window.addEventListener("kjb-cache-updated",d),()=>window.removeEventListener("kjb-cache-updated",d)},[o,t,r.verse,q]);const G=Fr;let se=q.replace(/^<<[^>]*>>\s*/,""),Fe=vs(se,L);if(A){const d=xn();d&&(Fe=Ys(Fe,d))}const rt=d=>{if(b){N==null||N(r.verse);return}if(x){if(ve)mr(o,t,r.verse);else{const B=c||de;ke(B),$t(o,t,r.verse,B)}return}if(R){R(r.verse);return}Be({x:d.clientX,y:d.clientY}),W(B=>!B)};if(D){const d=/^(?:<[^>]+>|\s)*<mark\b/.test(Fe),ge=ve||n&&(V||!L||d)?(st=G.find(Lt=>Lt.name===(P||de)))==null?void 0:st.color:null,oe=ge?ge.startsWith("#")?`${ge}99`:"hsl(var(--accent) / 0.6)":null,Ye=oe&&!b?` style="background-color:${oe};border-radius:0.1em;"`:"",Te=oe&&!b?"background-color:hsl(var(--background));":"",Et=Te||D&&!v&&St?` style="${D&&!v?St:""}${Te}"`:"",_e=h?`<span class="kjb-dropcap-num">${r.verse}</span><span class="kjb-dropcap-letter"${Ye}>$2</span>`:`<span class="kjb-dropcap-letter"${Ye}>$2</span>`;Fe=Fe.replace(/^((?:<[^>]+>|\s)*)([A-Za-z])/,`$1<span class="kjb-dropcap-group${h?" kjb-dropcap-group-para":""}"${Et}>${_e}</span>`)}const pe=r.heading?r.heading.toUpperCase():null,ee=()=>{if(!pe)return null;if(!L||!L.trim())return pe;const d=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),B=new RegExp(`(${d})`,"gi");return B.test(pe)?pe.split(B).map((oe,Ye)=>B.test(oe)?e.jsx("mark",{style:{backgroundColor:"rgba(250, 204, 21, 0.55)",borderRadius:"3px",padding:"0"},children:oe},Ye):oe):pe},le=r.heading?!A&&!h?e.jsxs("span",{className:"flex items-start mt-6 mb-4 px-[0.4em] gap-[0.6em] w-full",children:[e.jsx("span",{className:"text-[0.6em] shrink-0 invisible mr-[0.3em]",children:r.verse}),e.jsx("span",{className:`notranslate flex-1 text-center font-bold text-foreground select-none not-italic tracking-wide ${v?"cursive-em-style":"font-serif"}`,style:{fontSize:`${g/100*1.2}rem`},children:ee()})]}):e.jsx("span",{className:`notranslate block text-center font-bold text-foreground select-none mt-6 mb-4 not-italic tracking-wide ${v?"cursive-em-style":"font-serif"}`,style:{fontSize:`${g/100*1.2}rem`},children:ee()}):null,Le=`${F} ${t}:${r.verse}`,ye=Dr({text:q,subscript:T,heading:r.heading||null,colophon:I,ref:Le,url:sr({abbr:o,chapter:t,verse:r.verse,from:L?"search":void 0})}),nt=P||de,Xe=(kt=G.find(d=>d.name===nt))==null?void 0:kt.bg,ne=A?"px-[0.12em]":"px-[0.3em]",ue=ve||n,ft=async d=>{d.stopPropagation(),console.log("[VerseText] handleCopy called for",Le),console.log("[VerseText] Text to copy:",ye.substring(0,100)+"...");try{const B=document.createElement("textarea");B.value=ye,B.style.position="fixed",B.style.opacity="0",B.style.left="-9999px",document.body.appendChild(B),B.select(),document.execCommand("copy"),document.body.removeChild(B),c
12onsole.log("[VerseText] â
Copy via execCommand (no toast)")}catch{await navigator.clipboard.writeText(ye),console.log("[VerseText] â
Clipboard write successful (fallback)")}W(!1)},Se=d=>{d.stopPropagation(),q.replace(/\[([^\]]+)\]/g,"$1").replace(/¶\s*/g,"").replace(/^<<[^>]*>>\s*/,""),Q?(Rn(o,t,r.verse),Ee(!1),W(!1)):K(!0)},Nt=d=>{const B=q.replace(/\[([^\]]+)\]/g,"$1").replace(/¶\s*/g,"").replace(/^<<[^>]*>>\s*/,"");$r({abbr:o,chapter:t,verse:r.verse,ref:Le,text:B,folder:d}),Ee(!0),K(!1),W(!1)},Ce=d=>{if(d.stopPropagation(),console.log("[VerseText] handleShare called for",Le),tr({text:ye})){W(!1);return}navigator.share?(console.log("[VerseText] Using native share"),navigator.share({text:ye})):(console.log("[VerseText] Using clipboard fallback"),navigator.clipboard.writeText(ye),console.log("[VerseText] â
Clipboard write successful")),W(!1)},fe={fontSize:"inherit",fontScale:String(g/100),...y?{fontFamily:y}:{}},Me=J&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),W(!1)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),W(!1)}}),e.jsxs(Us,{point:Re,children:[e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),X(!M)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),X(!M)},className:"flex items-center gap-1 px-2 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-colors",title:"Highlight colour",children:[e.jsx(rr,{className:"w-3.5 h-3.5"}),e.jsx(Mt,{className:"w-2.5 h-2.5"})]}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),X(!1)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),X(!1)}}),e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 flex flex-col gap-1.5 bg-card border border-border rounded-xl p-3 shadow-xl min-w-[140px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsx("p",{className:"font-sans text-xs font-medium text-muted-foreground",children:"Choose colour"}),e.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),X(!1)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),X(!1)},className:"p-1 rounded hover:bg-secondary text-muted-foreground transition-colors",children:e.jsx(dt,{className:"w-3 h-3"})})]}),G.map(d=>e.jsxs("button",{onClick:B=>{B.preventDefault(),B.stopPropagation(),B.nativeEvent.stopImmediatePropagation(),ke(d.name),X(!1),$t(o,t,r.verse,d.name)},onTouchEnd:B=>{B.preventDefault(),B.stopPropagation(),B.nativeEvent.stopImmediatePropagation(),ke(d.name),X(!1),$t(o,t,r.verse,d.name)},className:"flex items-center gap-2.5 w-full p-1.5 rounded-lg hover:bg-secondary transition-colors",children:[e.jsx("span",{className:"w-5 h-5 rounded-full border-2 border-border shadow-sm",style:{backgroundColor:d.color}}),e.jsx("span",{className:`font-sans text-sm ${(P||de)===d.name?"font-semibold text-foreground":"text-muted-foreground"}`,children:d.label}),(P||de)===d.name&&ve&&e.jsx("span",{className:"ml-auto text-xs text-primary font-medium",children:"Active"})]},d.name))]})]})]}),ve?e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),mr(o,t,r.verse)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),mr(o,t,r.verse)},className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-accent/20 text-accent hover:bg-accent/30 font-sans text-xs font-medium transition-colors",title:"Remove highlight",children:[e.jsx(rr,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Unhighlight"})]}):e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),$t(o,t,r.verse,de)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),$t(o,t,r.verse,de)},className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-colors",title:"Ap
12ply highlight",children:[e.jsx(rr,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Highlight"})]}),e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),ft(d)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),ft(d)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-colors",title:"Copy",children:[e.jsx(nr,{className:"w-3 h-3"})," ",e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]}),e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),Ce(d)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),Ce(d)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-primary text-primary-foreground hover:opacity-90 font-sans text-xs font-medium transition-colors",title:"Share",children:[e.jsx(wt,{className:"w-3 h-3"})," ",e.jsx("span",{className:"hidden sm:inline",children:"Share"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),Se(d)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),Se(d)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-colors",title:Q?"Saved":"Save",children:[Q?e.jsx(Ps,{className:"w-3 h-3 text-accent"}):e.jsx(pr,{className:"w-3 h-3"}),e.jsx("span",{className:"hidden sm:inline",children:Q?"Saved":"Save"})]}),he&&e.jsx(Vs,{onSelect:Nt,onCancel:()=>{K(!1)}})]}),j&&e.jsxs("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),W(!1),j(r.verse)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),W(!1),j(r.verse)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-secondary hover:bg-accent/20 text-foreground font-sans text-xs font-medium transition-colors",title:"Select verses",children:[e.jsx(bt,{className:"w-3 h-3"})," ",e.jsx("span",{className:"hidden sm:inline",children:"Select"})]}),e.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),W(!1)},onTouchEnd:d=>{d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),W(!1)},className:"p-1 rounded-lg hover:bg-secondary text-muted-foreground transition-colors",children:e.jsx(dt,{className:"w-3 h-3"})})]})]}),We=/(^|[\s.,;:!?'")\]])[\u00B6\uFFFD\u000F]/.test(q);return h?We&&!m?e.jsxs("span",{id:a,"data-pilcrow":"true",className:"block relative mt-12 scroll-mt-24",children:[le,e.jsxs("span",{onClick:rt,className:"inline leading-relaxed rounded cursor-pointer px-[0.3em] py-[0.2em]",children:[e.jsx("sup",{className:"text-accent font-sans font-bold text-[0.65em] mr-2 select-none",children:r.verse}),e.jsxs("span",{className:b&&i?"bg-primary/10 border border-primary/30 rounded-[0.4em] box-decoration-clone px-[0.2em] py-[0.1em]":"",children:[b&&e.jsx("span",{className:"inline-flex items-center mr-1 text-primary align-middle",children:i?e.jsx(bt,{className:"w-[1em] h-[1em]"}):e.jsx(dr,{className:"w-[1em] h-[1em] text-muted-foreground"})}),e.jsx("span",{className:`kjb-verse-text notranslate leading-relaxed [&_em]:italic [&_em]:text-foreground/75 ${A?"":"break-words"} text-left inline transition-colors duration-200 rounded box-decoration-clone py-[0.1em] ${ue?ne:"pr-[0.3em]"} ${v?"cursive-em-style":""} ${ue?Xe:b?"":"hover:bg-secondary/60"}`,style:v?{fontSize:`${g/100*1.125}rem`}:fe,dangerouslySetInnerHTML:{__html:Fe}})]})]}),!b&&Me]}):e.jsxs("span",{id:a,className:"inline relative scroll-mt-24",children:[le,e.jsxs("span",{onClick:rt,className:"inline leading-loose rounded cursor-pointer px-[0.3em] py-[0.2em]",children:[!D&&e.jsx("sup",{className:"text-accent font-sans font-bold text-[0.65em] mr-2 select-none",children:r.verse}),e.jsxs("span",{className:b&&D?i?"inline-block kjb-select-dropcap-box":"inline-block":b&&i?"bg-primary/10 box-decoration-clone rounded px-[0.2em] py-[0.1em]":"",children:[b&&e.jsx("span",{className:D?"float-left items-center mr-1 mt-[0.2em] text-primary":"inline-flex items-center mr-1 text-primary align-middle",children:i?e.jsx(bt,{className:"w-[1em] h-[1em]"}):e.jsx(dr,{className:"w-[1em] h-[1em] text-muted-foreground"})}),e.jsx("span",{className:`kjb-verse-text notranslate leading-loose [&_em]:italic [&_em]:text-foreground
12/75 ${A?"":"break-words"} text-left transition-colors duration-200 rounded box-decoration-clone py-[0.1em] ${ue?ne:"pr-[0.3em]"} ${v?"cursive-em-style":""} ${ue?Xe:b?"":"hover:bg-secondary/60"}`,style:v?{fontSize:`${g/100*1.125}rem`}:fe,dangerouslySetInnerHTML:{__html:Fe}})]})," "]}),!b&&Me]}):D?e.jsxs("span",{id:a,className:"block relative mt-2 scroll-mt-24",style:{display:"flow-root"},children:[le,e.jsxs("span",{onClick:rt,className:"flex items-start leading-relaxed rounded cursor-pointer px-[0.4em] py-[0.15em] gap-[0.6em] w-full",children:[e.jsx("sup",{className:"text-accent font-sans font-bold text-[0.6em] shrink-0 select-none mt-[0.2em] mr-[0.3em] inline-block text-right w-[1.6em]",children:r.verse}),e.jsxs("span",{className:`flex-1 min-w-0 flex items-start gap-[0.6em] ${b&&i?"kjb-select-dropcap-box":""}`,children:[b&&e.jsx("span",{className:"shrink-0 mt-[0.2em] text-primary",children:i?e.jsx(bt,{className:"w-[1.1em] h-[1.1em]"}):e.jsx(dr,{className:"w-[1.1em] h-[1.1em] text-muted-foreground"})}),e.jsx("span",{className:"kjb-dropcap-col flex-1 min-w-0 leading-relaxed break-words text-left",children:e.jsx("span",{className:`kjb-verse-text notranslate inline [&_em]:italic [&_em]:text-foreground/75 box-decoration-clone rounded transition-colors duration-200 py-[0.1em] ${ue?ne:"px-[0.3em]"} ${v?"cursive-em-style":""} ${ue?Xe:b?"":"hover:bg-secondary/60"}`,style:{display:"inline",...v?{fontSize:`${g/100*1.125}rem`}:fe},dangerouslySetInnerHTML:{__html:Fe}})})]})]}),!b&&Me]}):e.jsxs("span",{id:a,"data-pilcrow":We&&!m?"true":void 0,className:`block relative scroll-mt-24 ${We&&!m?"mt-12":"mt-3"}`,children:[le,e.jsxs("span",{onClick:rt,className:"flex items-start leading-relaxed rounded cursor-pointer px-[0.4em] py-[0.15em] gap-[0.6em] w-full",children:[e.jsx("sup",{className:"text-accent font-sans font-bold text-[0.6em] shrink-0 select-none mt-[0.2em] mr-[0.3em] inline-block text-right w-[1.6em]",children:r.verse}),e.jsxs("span",{className:`flex-1 min-w-0 flex items-start gap-[0.6em] ${b&&i?"bg-primary/10 border border-primary/30 rounded-[0.5em] px-[0.3em] py-[0.1em]":""}`,children:[b&&e.jsx("span",{className:"shrink-0 mt-[0.2em] text-primary",children:i?e.jsx(bt,{className:"w-[1.1em] h-[1.1em]"}):e.jsx(dr,{className:"w-[1.1em] h-[1.1em] text-muted-foreground"})}),ue?e.jsx("span",{className:`flex-1 min-w-0 leading-relaxed text-left ${A?"":"break-words"}`,children:e.jsx("span",{className:`kjb-verse-text notranslate inline [&_em]:italic [&_em]:text-foreground/75 ${v?"cursive-em-style":""} ${Xe} box-decoration-clone rounded ${ne} py-[0.1em]`,style:{display:"inline",...v?{fontSize:`${g/100*1.125}rem`}:fe},dangerouslySetInnerHTML:{__html:Fe}})}):e.jsx("span",{className:`flex-1 min-w-0 leading-relaxed text-left ${A?"":"break-words"}`,children:e.jsx("span",{className:`kjb-verse-text notranslate inline [&_em]:italic [&_em]:text-foreground/75 transition-colors duration-200 rounded box-decoration-clone px-[0.3em] py-[0.1em] ${v?"cursive-em-style":""} ${b?"":"hover:bg-secondary/60"}`,style:{display:"inline",...v?{fontSize:`${g/100*1.125}rem`}:fe},dangerouslySetInnerHTML:{__html:Fe}})})]})]}),!b&&Me]})}function sa({type:r,book:n}){if(r==="testament-old")return e.jsx("div",{className:"notranslate flex flex-col items-center px-4 pt-8 pb-12",children:e.jsxs("div",{className:"max-w-2xl text-center space-y-6",children:[e.jsx("p",{className:"font-serif text-base tracking-[0.2em] text-foreground font-normal",children:"THE"}),e.jsx("h1",{className:"font-serif text-7xl md:text-8xl font-bold text-foreground leading-tight",children:"HOLY BIBLE"}),e.jsx("p",{className:"font-serif text-base md:text-lg font-normal text-foreground tracking-[0.05em]",children:"CONTAINING THE"}),e.jsx("p",{className:"font-serif text-lg md:text-xl font-normal text-foreground tracking-[0.05em]",children:"OLD AND NEW TESTAMENTS"}),e.jsx("div",{className:"py-8",children:e.jsxs("p",{className:"font-serif text-sm md:text-base font-normal text-foreground leading-relaxed tracking-[0.02em]",children:["TRANSLATED OUT OF THE ORIGINAL TONGUES: AND WITH",e.jsx("br",{}),"THE FORMER TRANSLATIONS DILIGENTLY COMPARED",e.jsx("br",{}),"AND REVISED, BY HIS MAJESTY'S SPECIAL COMMAND"]})}),e.jsx("div",{className:"py-4",children:e.jsx("p",{className:"font-serif text-sm md:text-base font-normal text-foreground tracking-[0.02em]",children:"APPOINTED TO BE READ IN CHURCHES"})}),e.jsx("div",{className:"pt-8",children:e.jsx("p",{className:"font-serif text-base md:text-lg font-normal text-foreground tracking-[0.1em]",children:"AUTHORISED KING JAMES BIBLE"})})]})});if(r==="testament-new")return e.jsx("div",{className:"notranslate flex flex-col items-center px-4 pt-8 pb-8",children:e.jsxs("div",{className:"max-w-xl text-center space-y-4",children:[e.jsx("p",{className:"font-serif text-base tracking-[0.3em] text-foreground font-normal",children:"THE"}),e.jsxs("h1",{className:"font-serif text-5xl md:text-6xl lg:text-7xl font-bold text-foreground leading-tight",children:["NEW",e.jsx("br",{}),"TESTAMENT"]}),e.jsxs("p",{className:"font-serif text-base md:text-lg font-normal text-foreground leading-relaxed",children:["OF",e.jsx("br",{}),"OUR LORD AND SAVIOUR",e.jsx("br",{}),e.jsx("span",{className:"font-bold",children:"JESUS CHRIST"})]}),e.jsx("div",{className:"py-4",children:e.jsxs("p",{className:"font-serif text-sm md:text-base font-normal text-foreground leading-relaxed",children:["TRANSLATED OUT OF THE ORIGINAL GREEK: AND WITH",e.jsx("br",{}),"THE FORMER TRANSLATIONS DILIGENTLY COMPARED",e.jsx("br",{}),"AND REVISED, BY HIS MAJESTY'S SPECIAL COMMAND"]})}),e.jsx("div",{className:"py-4",children:e.jsx("p",{className:"font-serif text-sm md:text-base font-normal text-foreground",children:"APPOINTED TO BE READ IN CHURCHES"})})]})});if(r==="main")return e.jsx("div",{className:"notranslate flex flex-col items-center px-4 pt-8 pb-12",children:e.jsxs("div",{className:"max-w-2xl text-center space-y-6",children:[e.jsx("p",{className:"font-serif text-base tracking-[0.2em] text-foreground font-normal",children:"THE"}),e.jsx("h1",{className:"font-serif text-7xl md:text-8xl font-bold text-foreground leading-tight",children:"HOLY BIBLE"}),e.jsx("p",{className:"font-serif text-base md:text-lg font-normal text-foreground tracking-[0.05em]",children:"CONTAINING THE"}),e.jsx("p",{className:"font-serif text-lg md:text-xl font-normal text-foreground tracking-[0.05em]",children:"OLD AND NEW TESTAMENTS"}),e.jsx("div",{className:"py-8",children:e.jsxs("p",{className:"font-serif text-sm md:text-base font-normal text-foreground leading-relaxed tracking-[0.02em]",children:["TRANSLATED OUT OF THE ORIGINAL TONGUES: AND WITH",e.jsx("br",{}),"THE FORMER TRANSLATIONS DILIGENTLY COMPARED",e.jsx("br",{}),"AND REVISED, BY HIS MAJESTY'S SPECIAL COMMAND"]})}),e.jsx("div",{className:"py-4",children:e.jsx("p",{className:"font-serif text-sm md:text-base font-normal text-foreground tracking-[0.02em]",children:"APPOINTED TO BE READ IN CHURCHES"})}),e.jsx("div",{className:"pt-8",children:e.jsx("p",{className:"font-serif text-base md:text-lg font-normal text-foreground tracking-[0.1em]",children:"AUTHORISED KING JAMES BIBLE"})})]})});if(r==="book"&&n){const a=n.testament==="new"?"New Testament":"Old Testament",l=n.chapters===1?"Chapter":"Chapters";return e.jsx("div",{className:"notranslate flex flex-col items-center justify-center px-4 pt-16 pb-16",children:e.jsxs("div",{className:"max-w-2xl text-center space-y-6",children:[e.jsx("p",{className:"font-serif text-sm tracking-[0.3em] uppercase text-muted-foreground",children:a}),e.jsx("h1",{className:"notranslate font-serif text-3xl md:text-4xl lg:text-5xl font-bold text-foreground leading-snug",children:n.name}),n.chapters>0&&e.jsxs("p",{className:"font-serif text-base md:text-lg text-muted-foreground",children:[n.chapters," ",l]}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"w-16 h-px bg-accent mx-auto"})})]})})}return null}const Sn=.6,Nn=.5;function kn(){try{const r=parseFloat(window.getComputedStyle(document.documentElement).getPropertyValue("--kjb-zoom-scale"));return Number.isFinite(r)&&r>0?r:1}catch{return 1}}function aa({bookName:r,chapter:n,baseFontRem:a,isCursive:l}){const o=u.useRef(null),t=u.useRef(null),m=u.useRef(null),[h,b]=u.useState(1),[x,c]=u.useState(!1),[i,N]=u.useState(null),j=`Chapter ${n}`,[C,I]=u.useState(kn);u.useEffect(()=>{const v=()=>I(kn());return window.addEventListener("kjb-layout-zoom-changed",v),window.addEventListener("resize",v),window.addEventListener("storage",v),()=>{window.removeEventListener("kjb-layout-zoom-changed",v),window.removeEventListener("resize",v),window.removeEventListener("storage",v)}},[]),u.useLayoutEffect(()=>{const v=o.current;if(!v||typeof ResizeObserver>"u")return;const y=new ResizeObserver(g=>{var L,D;const k=(D=(L=g[0])==null?void 0:L.contentRect)==null?void 0:D.width;k!=null&&N(k)});return y.observe(v),()=>y.disconnect()},[]),u.useLayoutEffect(()=>{b(1),c(!1)},[r,n,a,i,C]),u.useLayoutEffect(()=>{if(x)return;const v=o.current,y=t.current,g=m.current;if(!v||!y||!g)return;
12const k=parseFloat(getComputedStyle(v).columnGap)||16,L=y.scrollWidth+g.scrollWidth+k,D=Math.abs(y.offsetTop-g.offsetTop)>4;(L>v.clientWidth+.5||D)&&(h>Sn?b(R=>Math.max(Sn,R-.05)):(c(!0),b(1)))},[h,x,r,n,a,i,C]),u.useLayoutEffect(()=>{if(!x)return;const v=o.current,y=t.current,g=m.current;if(!v||!y||!g)return;(y.scrollWidth>v.clientWidth+.5||g.scrollWidth>v.clientWidth+.5)&&h>Nn&&b(L=>Math.max(Nn,L-.05))},[h,x,r,n,a,i,C]);const T=`${a*h}rem`;return e.jsxs("div",{className:`kjb-running-head mb-6 print:hidden ${l?"cursive-em-style":"font-serif"}`,children:[e.jsxs("div",{ref:o,"data-testid":"kjb-running-head","data-stacked":x?"true":"false",className:x?"flex flex-col items-center text-center gap-1 min-w-0":"flex flex-wrap justify-between items-baseline gap-4 min-w-0",children:[e.jsx("div",{className:"min-w-0 max-w-full",children:e.jsx("span",{ref:t,"data-testid":"kjb-running-head-book",className:`notranslate inline-block max-w-full font-semibold tracking-wide text-foreground ${x?"whitespace-normal break-words":"whitespace-nowrap"}`,style:{fontSize:T,fontStyle:"normal"},children:r})}),e.jsx("div",{className:"min-w-0 max-w-full",children:e.jsx("span",{ref:m,"data-testid":"kjb-running-head-chapter",className:"notranslate kjb-running-chapter inline-block max-w-full whitespace-nowrap font-semibold tracking-wide text-foreground",style:{fontSize:T,fontStyle:"normal"},children:j})})]}),e.jsx("div",{className:"pt-1.5",children:e.jsx("div",{className:"border-b border-border"})})]})}function oa({setHideHeader:r}){return Tn.createPortal(e.jsx("div",{className:"print:hidden fixed top-0 left-0 right-0 border-b border-border bg-background/95 backdrop-blur z-[110]",style:{paddingTop:"env(safe-area-inset-top)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"},children:e.jsx("div",{className:"w-full max-w-[120rem] mx-auto px-2 py-1.5 flex items-center justify-end gap-1",children:e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("button",{type:"button",onClick:()=>r(!1),className:"p-2 rounded-lg bg-secondary hover:bg-accent/20 text-foreground transition-all duration-200 hover:scale-105 active:scale-95 touch-manipulation flex items-center justify-center cursor-pointer",title:"Show header",children:e.jsx(Mt,{className:"w-4 h-4 rotate-180 transition-transform duration-200 pointer-events-none"})})})})}),document.body)}function la(r,n,a,l,o,t){u.useEffect(()=>{if(!n)try{const m=new URLSearchParams(window.location.search);let h=m.get("from");const b=m.get("q")||(o&&!/\d+\s*:\s*\d+/.test(o)?o:null);if((h==="daily"||h==="random")&&(o||t)&&(h=t?"gospel":"search"),!h&&(o||t)&&(h=t?"gospel":"search"),h==="search"&&!r.verse&&r.chapter!==0){const i=new URLSearchParams(window.location.search);if(i.get("book")===r.abbr&&Number(i.get("chapter"))===Number(r.chapter)&&i.get("verse"))return}let x=null;try{const i=JSON.parse(localStorage.getItem("kjb-position")||"{}");i&&i.abbr===r.abbr&&Number(i.chapter)===Number(r.chapter)&&Number(i.verse)===Number(r.verse)&&i.verseEnd&&Number(i.verseEnd)>Number(i.verse||0)&&(x=parseInt(i.verseEnd,10))}catch{}let c;r.chapter===0?c=r.abbr==="GEN"||r.abbr==="MAT"?`/read?titlePage=${r.abbr==="MAT"?"new":"old"}`:`/read?book=${r.abbr}&chapter=0`:(c=`/read?book=${r.abbr}&chapter=${r.chapter}`,r.verse&&(c+=`&verse=${r.verse}`),r.verse&&x&&(c+=`&verseEnd=${x}`),h&&(c+=`&from=${h}`),b&&(c+=`&q=${encodeURIComponent(b)}`)),a&&a!=="default"&&(c+=`${c.includes("?")?"&":"?"}font=${a}`),c!==window.location.pathname+window.location.search&&(l?l(c,{replace:!0}):window.history.replaceState({},"",c))}catch{}},[r.abbr,r.chapter,r.verse,n,a,l,o,t])}function ca(r,n,a,l){const o=u.useRef(null),t=u.useRef(!1),m=u.useRef("filter"),h=u.useRef(!1),b=(i,N,j=null)=>{try{let C=null;try{const I=JSON.parse(localStorage.getItem("kjb-position")||"{}");I.abbr===i&&I.chapter===N&&I.verse===j&&I.verseEnd&&(C=I.verseEnd)}catch{}localStorage.setItem("kjb-position",JSON.stringify({abbr:i,chapter:N,verse:j,verseEnd:C}))}catch{}};return{navigate:(i,N,j=null,C=!1,I=!1,T=!1,v=null,y=!1,g,k,L)=>{y||(g(),k(!1),L()),b(i,N,j),m.current="filter",t.current=!1,h.current=!0,n(i,N,j);try{let D;N===0?D=i==="GEN"||i==="MAT"?`/read?titlePage=${i==="MAT"?"new":"old"}`:`/read?book=${i}&chapter=0`:(D=`/read?book=${i}&chapter=${N}`,j&&(D+=`&verse=${j}`),v&&(D+=`&highlight=${v}`),y&&(D+="&from=search")),a(D,{replace:T||!1})}catch{}},returnToChapter:(i,N,j,C,I,T,v,y,g,k,L)=>{if(!(!i||!N)){if(C(!1),I(!1),T(new Set),v(new Set),y(null),g(null),k(!1),typeof j=="number"&&j>0)try{localStorage.setItem(`kjb-scroll-${i}-${N}`,String(Math.round(j)))}catch{}try{a("/read",{replace:!0})}catch{}h.current=!1,L(i,N,null)}},preSearchPosRef:o,rangeHighlightRef:t,resultViewRef:m,freshNavRef:h}}const ia=/^v\d+$/,Fn=r=>r?r.scrollTop:window.scrollY||0;function da(r){try{const n=document.querySelector(".kjb-reader-content");
12if(!n)return null;const a=Array.from(n.querySelectorAll("[id]")).filter(h=>ia.test(h.id));if(!a.length)return null;const l=r?r.getBoundingClientRect().top:0,o=h=>h.getBoundingClientRect().bottom>l;let t=0,m=a.length-1;for(;t<m;){const h=t+m>>1;o(a[h])?m=h:t=h+1}return o(a[t])?parseInt(a[t].id.slice(1),10):null}catch{return null}}function En(r,n,a=null){try{const l={y:Math.round(Fn(n)),vh:window.innerHeight,verse:da(n)||a&&a.verse||void 0};return localStorage.setItem(r,JSON.stringify(l)),{y:l.y,verse:l.verse||null,vh:l.vh}}catch{return null}}function ua(r,n,a=null){try{const l={y:Math.round(Fn(n)),vh:window.innerHeight,verse:a&&a.verse||void 0};return localStorage.setItem(r,JSON.stringify(l)),{y:l.y,verse:l.verse||null,vh:l.vh}}catch{return a}}function zn(r){try{const n=localStorage.getItem(r);if(!n)return null;if(n[0]==="{"){const l=JSON.parse(n);return{y:Number(l.y)||0,verse:l.verse||null,vh:Number(l.vh)||null}}const a=parseInt(n,10);return{y:Number.isFinite(a)?a:0,verse:null,vh:null}}catch{return null}}function fa(r,n,a,l,o,t,m,h,b,x,c,i,N,j,C,I,T,v,y,g,k,L){const D=u.useRef(!1),[A,R]=u.useState(0),V=u.useRef(null),ae=u.useRef(!1);u.useEffect(()=>{if(!(n||!D.current))try{const F=!!(L&&L.current&&l&&o.size>0&&!t&&!b);if(!(t&&!x.current||b||F)){try{const Ne=JSON.parse(localStorage.getItem("kjb-reader-toolbar-state")||"null");if(Ne&&Ne.abbr===r.abbr&&parseInt(Ne.chapter,10)===parseInt(r.chapter,10)&&(Ne.hasSearchContext||Ne.hasGospelContext)&&!x.current)return}catch{}localStorage.removeItem("kjb-reader-toolbar-state");return}const W={abbr:r.abbr,chapter:r.chapter,filterMode:l,selectedVerses:[...o],resultView:j.current,hasSearchContext:!!(t&&!x.current),hasGospelContext:b,hasReferenceContext:F,searchTerm:t&&!x.current?t:null,searchResultIndex:m,searchTotalResults:h,timestamp:Date.now()};localStorage.setItem("kjb-reader-toolbar-state",JSON.stringify(W)),console.log("[ToolbarState] Saved state:",W)}catch(F){console.error("[ToolbarState] Save error:",F)}},[l,o,t,x.current,b,m,h,r.abbr,r.chapter,n,A]),u.useLayoutEffect(()=>{if(n||a.length===0)return;const F=(P=!1)=>{if(!(P&&ae.current)){D.current=!0;try{V.current===null&&(V.current=new URLSearchParams(window.location.search).get("from")||"");const ve=V.current;if(ve==="daily"||ve==="random"){ae.current=!0,R(X=>X+1);return}const de=h>0||b;if((ve==="search"||ve==="gospel")&&o&&o.size>0&&de){try{const X=new URLSearchParams(window.location.search),Q=X.get("verse")?parseInt(X.get("verse"),10):null,Ee=localStorage.getItem("kjb-reader-toolbar-state"),q=Ee?JSON.parse(Ee):null;q&&!X.get("q")&&q.abbr===r.abbr&&q.chapter===r.chapter&&q.resultView==="full"&&q.filterMode===!1&&(q.hasSearchContext||q.hasReferenceContext)&&Q&&Array.isArray(q.selectedVerses)&&q.selectedVerses.includes(Q)&&(j.current="full",c(!1))}catch{}ae.current=!0,R(X=>X+1);return}const ke=localStorage.getItem("kjb-reader-toolbar-state");if(console.log("[ToolbarState] Restore attempt - saved:",ke),!ke){ae.current=!0,R(X=>X+1);return}const M=JSON.parse(ke);if(console.log("[ToolbarState] Parsed state:",M),M&&M.abbr===r.abbr&&M.chapter===r.chapter){console.log("[ToolbarState] Chapter match - restoring");const X=M.hasSearchContext||M.hasGospelContext||M.hasReferenceContext;if(M.hasReferenceContext&&L&&(L.current=!0),X&&M.filterMode!==void 0&&c(M.filterMode),X&&M.selectedVerses&&M.selectedVerses.length>0){const Q=new Set(M.selectedVerses);i(Q),N(Q),k&&k(Math.min(...Q))}if(M.resultView&&(console.log("[ToolbarState] Restoring resultView:",M.resultView),j.current=M.resultView),M.hasSearchContext&&M.searchTerm&&(console.log("[ToolbarState] Restoring search:",M.searchTerm),x.current=!1,C(M.searchTerm),I(M.searchResultIndex||
120),T(M.searchTotalResults||0)),M.hasGospelContext){console.log("[ToolbarState] Restoring gospel mode");const Q=tt();Q.results.length>0&&(v(!0),y(Q.index),g(Q.results.length))}}else console.log("[ToolbarState] Chapter mismatch - not restoring",{state:M,pos:r})}catch(ve){console.error("[ToolbarState] Restore error:",ve)}ae.current=!0,R(ve=>ve+1)}};ae.current=!1,F();const J=setTimeout(()=>F(!0),100),W=()=>{document.visibilityState==="visible"&&F(!0)},Ne=()=>F(!0);return window.addEventListener("focus",Ne),document.addEventListener("visibilitychange",W),()=>{clearTimeout(J),window.removeEventListener("focus",Ne),document.removeEventListener("visibilitychange",W)}},[n,r.abbr,r.chapter,a.length])}function ma({loading:r,verses:n,highlightVerse:a,highlightSection:l,abbr:o,chapter:t,scrollToVerseEl:m,topRef:h,freshNavRef:b,setHighlightVerse:x,setHighlightedVerses:c}){u.useLayoutEffect(()=>{if(r)return;if(a){m(a,!0);const g=()=>m(a),k=setTimeout(g,50),L=setTimeout(g,200),D=setTimeout(g,600),A=document.querySelector(".kjb-reader-content");let R=null;A&&window.ResizeObserver&&(R=new ResizeObserver(g),R.observe(A));const V=setTimeout(()=>R&&R.disconnect(),2e3);return()=>{clearTimeout(k),clearTimeout(L),clearTimeout(D),clearTimeout(V),R&&R.disconnect()}}const i=localStorage.getItem("kjb-last-reading");if(i&&!a)try{const g=JSON.parse(i);g&&g.abbr===o&&g.chapter===t&&g.verse&&(x(g.verse),c(new Set([g.verse])))}catch{}if(b.current){b.current=!1;const g=document.getElementById("kjb-scroll")||window;g.scrollTo({top:0});let k=!1;const L=()=>{k=!0};g.addEventListener("touchstart",L,{once:!0,passive:!0}),g.addEventListener("wheel",L,{once:!0,passive:!0}),g.addEventListener("pointerdown",L,{once:!0,passive:!0});const D=[120,350,700,1100].map(A=>setTimeout(()=>{k||g.scrollTo({top:0})},A));return()=>{D.forEach(clearTimeout),g.removeEventListener("touchstart",L),g.removeEventListener("wheel",L),g.removeEventListener("pointerdown",L)}}if(l)return;const N=zn(`kjb-scroll-${o}-${t}`);if(!N||N.y<=0)return;let j=N.y;try{const g=JSON.parse(localStorage.getItem("kjb-prev-reading-session")||"null");g&&g.abbr===o&&g.chapter===t&&typeof g.scrollY=="number"&&g.scrollY>0&&(j=Math.round(g.scrollY))}catch{}const C=()=>{const g=document.getElementById("kjb-scroll"),k=g||window,L=g?g.scrollHeight-g.clientHeight:document.documentElement.scrollHeight-window.innerHeight;if(L>=j-4){if(N.verse&&N.vh&&Math.abs(window.innerHeight-N.vh)>80){const D=document.getElementById(`v${N.verse}`);if(D&&g){const A=h.current?h.current.getBoundingClientRect().height:0,R=D.getBoundingClientRect().top-g.getBoundingClientRect().top+g.scrollTop-(A+48);return k.scrollTo({top:Math.min(Math.max(R,0),Math.max(L,0))}),!0}}return k.scrollTo({top:j}),!0}return!1};C();const I=[60,200,500,1e3,1800,3e3].map(g=>setTimeout(C,g)),T=document.querySelector(".kjb-reader-content");let v=null;T&&window.ResizeObserver&&(v=new ResizeObserver(()=>{C()&&v&&v.disconnect()}),v.observe(T));const y=setTimeout(()=>v&&v.disconnect(),5e3);return()=>{I.forEach(clearTimeout),clearTimeout(y),v&&v.disconnect()}},[n,r,a,l,o,t])}function ha(){const r={pos:null,verses:[],colophon:null,highlightVerse:null,selection:null,highlightSet:null,filterMode:!1};try{const n=new URLSearchParams(window.location.search);let a=null,l=null;const o=n.get("titlePage");if(o==="old"||o==="new")a={abbr:o==="new"?"MAT":"GEN",chapter:0};else{const j=Tt(n.get("book")),C=n.get("chapter");if(j&&C)a={abbr:j.abbr,chapter:parseInt(C,10)};else{const I=On();l=I,a={abbr:I.abbr,chapter:parseInt(I.chapter,10)}}}if(!a||Number.isNaN(a.chapter))return r;if(n.get("from")==="gospel")return{...r,pos:a};let t=n.get("verse")?parseInt(n.get("verse"),10):null,m=n.get("verseEnd")?parseInt(n.get("verseEnd"),10):null;if(l)t=t||l.verse||null,!m&&l.verseEnd&&l.verseEnd>(t||0)&&(m=parseInt(l.verseEnd,10));else if(!m&&t)try{const j=JSON.parse(localStorage.getItem(ot)||"{}");j.abbr===a.abbr&&parseInt(j.chapter,10)===a.chapter&&j.verseEnd&&(m=parseInt(j.verseEnd,10))}catch{}const h=n.get("from");let b=null,x=!1,c=null;if(t&&m&&m>t){b=new Set;for(let j=t;j<=m;j++)b.add(j);x=!0}else if(t&&h==="search"){let j=!1;try{const C=JSON.parse(localStorage.getItem("kjb-reader-toolbar-state")||"null");j=!!(C&&C.abbr===a.abbr&&parseInt(C.chapter,10)===a.chapter&&C.hasSearchContext&&C.resultView==="full")}catch{}j||(b=new Set([t]),x=!0)}else t&&(h==="daily"||h==="random")&&(c=new Set([t]));if(a.chapter===0)return{pos:a,verses:[],colophon:null,highlightVerse:null,selection:null,highlightSet:null,filterMode:!1};const i=Pt.find(j=>j.abbr===a.abbr);if(!i)return{...r,pos:a,highlightVerse:t,selection:b,highlightSet:c,filterMode:x};const N=$n(i.apiName,a.chapter);return N?{pos:a,verses:N.verses,colophon:N.colophon||null,highlightVerse:t,selection:b,highlightSet:c,filterMode:x}:{...r,pos:a,highlightVerse:t,selection:b,highlightSet:c,filterMode:x}}catch{return r}}function pa({verseNum:r,posRef:n,topRef:a,scrolledVerseRef:l,instant:o=!1}){var T;const t=document.getElementById(`v${r}`);if(!t)return;const m=((T=n.current)==null?void 0:T.occurrence)||0;Pn(t.querySelectorAll("mark[data-occ]"),m);const h=document.getElementById("kjb-scroll"),x=(a.current?a.current.getBoundingClientRect().height:0)+48,c=t.querySelector("sup, .kjb-dropcap-num");let i=c?c.getBoundingClientRect().top:t.getBoundingClientRect().top;const N=t.querySelector(".font-bold.text-center");N&&N.getBoundingClientRect().top<i&&(i=N.getBoundingClientRect().top);const j=h?Math.max(0,i-h.getBoundingClientRect().top+h.scrollTop-x):Math.max(0,i+window.scrollY-x),C=h?h.scrollTop:window.scrollY;if(Math.abs(C-j)<4)return;const I=!l.current||l.current.verse!==r;l.current={verse:r},(h||window).scrollTo({top:j,behavior:o?"auto":I?"smooth":"auto"})}function ga({tappedVerseNums:r,tappedVerseObjs:n,chapterSubscript:a,colophon:l,book:o,pos:t}){var i;if(!r||r.length===0)return"";const m=r[0],h=r[r.length-1],b=m===1,x=n.length>0&&h===parseInt(n[n.length-1].verse,10),c=lt(r);return Dr({text:n.map(N=>N.text).join(" "),subscript:b&&a||null,heading:((i=n[0])==null?void 0:i.heading)||null,colophon:x&&l||null,ref:`${o.short
12Name} ${t.chapter}:${c}`,url:sr({abbr:t.abbr,chapter:t.chapter,verse:m,verseEnd:h>m?h:void 0})})}function ba({verses:r,selectedVerses:n,selectedSections:a,book:l,pos:o,searchTerm:t,colophon:m}){const h=n.size>0?n:new Set(r.map(y=>parseInt(y.verse,10))),b=y=>h.has(parseInt(y.verse,10)),x=r.filter(b).sort((y,g)=>parseInt(y.verse,10)-parseInt(g.verse,10)),c=[];let i=[];x.forEach(y=>{const g=parseInt(y.verse,10);i.length===0||g===parseInt(i[i.length-1].verse,10)+1?i.push(y):(c.push(i),i=[y])}),i.length&&c.push(i);const N=Or(l.apiName,o.chapter)||null,j=r.length?parseInt(r[r.length-1].verse,10):null,C=a.size>0,I=!!N&&(a.has("subscript")||!C&&c.some(y=>y.some(g=>parseInt(g.verse,10)===1))),T=!!m&&(a.has("colophon")||!C&&c.some(y=>y.some(g=>parseInt(g.verse,10)===j)));return c.map((y,g)=>{var R;const k=y.map(V=>parseInt(V.verse,10)),L=lt(k),D=k[0],A=k[k.length-1];return Dr({text:y.map(V=>Ht(V.text)).join(" "),subscript:g===0&&I?N:null,heading:((R=y[0])==null?void 0:R.heading)||null,colophon:g===c.length-1&&T?m:null,ref:`${l.shortName} ${o.chapter}:${L}`,url:sr({abbr:o.abbr,chapter:o.chapter,verse:D,verseEnd:A>D?A:void 0,from:t?"search":void 0})})}).join(` 13 14âââ 15 16`)}function xa({verses:r,selectedVerses:n,selectedSections:a,book:l,pos:o,searchTerm:t,colophon:m}){const h=n.size>0?n:new Set(r.map(R=>parseInt(R.verse,10))),b=R=>h.has(parseInt(R.verse,10)),x=r.filter(b).sort((R,V)=>parseInt(R.verse,10)-parseInt(V.verse,10)),c=x.map(R=>{const V=`${parseInt(R.verse,10)} ${Ht(R.text).replace(/^¶\s*/,"")}`;return R.heading?`${R.heading} 17${V}`:V}),i=x.map(R=>parseInt(R.verse,10)),N=lt(i),j=`${l.shortName} ${o.chapter}:${N}`,C=i[0],I=i[i.length-1],T=sr({abbr:o.abbr,chapter:o.chapter,verse:C,verseEnd:I>C?I:void 0,from:t?"search":void 0}),v=[],y=x.some(R=>parseInt(R.verse,10)===1),g=Or(l.apiName,o.chapter)||null,k=r.length?parseInt(r[r.length-1].verse,10):null,L=k!=null&&x.some(R=>parseInt(R.verse,10)===k),D=a.size>0,A=x.length>1;return A&&v.push(ln(l.name)+` 18`+ln(`Chapter ${o.chapter}`)),g&&(a.has("subscript")||!D&&y)&&v.push(`¶ ${Ht(g).replace(/^[\u00B6\uFFFD¶]\s*/,"")}`),v.push(c.join(` 19 20`)),m&&(a.has("colophon")||!D&&L)&&v.push(`¶ ${Ht(m).replace(/^[\u00B6\uFFFD¶]\s*/,"")}`),A||v.push(`â ${j}`),v.push(`Read more: <${T}>`),v.join(` 21 22`)}function va(r,n,a,l,o,t,m,h,b,x,c,i,N,j,C,I,T,v,y,g,k,L,D,A,R,V,ae,F){const J=u.useRef(null);return{stepToResult:(P,ve=!1)=>{try{if(!(localStorage.getItem("kjb-pre-search")||localStorage.getItem("kjb-pre-jump"))){const Ie=document.getElementById("kjb-scroll"),he=Ie?Ie.scrollTop:window.scrollY,K=JSON.parse(localStorage.getItem("kjb-position")||"{}");K&&K.abbr&&K.chapter&&(localStorage.setItem("kjb-prev-reading-session",JSON.stringify({abbr:K.abbr,chapter:K.chapter,scrollY:he})),localStorage.setItem("kjb-pre-search",JSON.stringify({abbr:K.abbr,chapter:K.chapter,scrollY:he})),J.current={abbr:K.abbr,chapter:K.chapter,scrollY:he})}}catch{}if(!J.current)try{const q=document.getElementById("kjb-scroll"),Ie=q?q.scrollTop:window.scrollY,he=JSON.parse(localStorage.getItem("kjb-pre-search")||localStorage.getItem("kjb-pre-jump")||"null");if(he&&he.abbr&&he.chapter)J.current={abbr:he.abbr,chapter:he.chapter,scrollY:typeof he.scrollY=="number"?he.scrollY:Ie};else{const K=JSON.parse(localStorage.getItem("kjb-position")||"{}");K&&K.abbr&&K.chapter&&(J.current={abbr:K.abbr,chapter:K.chapter,scrollY:Ie})}}catch{}const de=P.section||null,ke=de?null:P.verse||null;T(de);const M=N.current!=="full";if(!de&&P.verse&&P.verseEnd&&parseInt(P.verseEnd,10)>parseInt(P.verse,10)){const q=parseInt(P.verse,10),Ie=parseInt(P.verseEnd,10),he=new Set;for(let K=q;K<=Ie;K++)he.add(K);C(he),I(he),j(M);try{const K=JSON.parse(localStorage.getItem("kjb-position")||"{}");localStorage.setItem("kjb-position",JSON.stringify({...K,abbr:P.abbr,chapter:P.chapter,verse:q,verseEnd:Ie}))}catch{}}else if(!de&&ke){const q=parseInt(ke,10),Ie=new Set([q]);C(Ie),I(Ie),j(M);try{const he=JSON.parse(localStorage.getItem("kjb-position")||"{}");localStorage.setItem("kjb-position",JSON.stringify({...he,abbr:P.abbr,chapter:P.chapter,verse:q,verseEnd:null}))}catch{}}else{!o&&!t&&j(!1);try{const q=JSON.parse(localStorage.getItem("kjb-position")||"{}");localStorage.setItem("kjb-position",JSON.stringify({...q,abbr:P.abbr,chapter:P.chapter,verse:P.verse||null,verseEnd:null}))}catch{}}const X=!n&&a.length>0&&r.current.abbr===P.abbr&&r.current.chapter===P.chapter,Q=X&&r.current.verse===ke;if(y({abbr:P.abbr,chapter:P.chapter,verse:ke,occurrence:P.occurrence||0}),v(ke),X){Q&&ke&&Ms(ke,P.occurrence||0,l);return}const Ee=!de&&P.verse&&P.verseEnd&&parseInt(P.verseEnd,10)>parseInt(P.verse,10)?parseInt(P.verseEnd,10):null;ve||g(P.abbr,P.chapter,ke,Ee)},clearSearchContext:()=>{L(),x(null),c(0),i(0);try{localStorage.removeItem("kjb-reader-toolbar-state")}catch{}try{localStorage.removeItem("kjb-last-reading")}catch{}F&&F(null);let P=null;try{const ve=localStorage.getItem("kjb-prev-reading-session");if(ve){const de=JSON.parse(ve);de&&de.abbr&&de.chapter&&(P={abbr:de.abbr,chapter:de.chapter,scrollY:de.scrollY})}}catch{}!P&&J.current&&J.current.abbr&&(P=J.current),J.current=null;try{localStorage.removeItem("kjb-pre-search")}catch{}j(!1),V(!1),I(new Set),C(new Set),v(null),T(null),ae(!1),P&&P.abbr&&P.chapter&&k(P.abbr,P.chapter,P.scrollY)},preSearchPosRef:J}}function ya({searchClearedRef:r,setSearchTerm:n,setSearchResultIndex:a,setSearchTotalResults:l,setGos
22pelMode:o,setGospelResultIndex:t,setGospelTotalResults:m}){try{const h=localStorage.getItem("kjb-reader-toolbar-state");if(!h)return;const b=JSON.parse(h);if(b&&b.hasSearchContext&&b.searchTerm&&(r.current=!1,n(b.searchTerm),a(b.searchResultIndex||0),l(b.searchTotalResults||0)),b&&b.hasGospelContext){const x=tt();x.results.length>0&&(o(!0),t(x.index),m(x.results.length))}}catch{}}function ja({hasSearchTerm:r,searchClearedRef:n,setSearchTerm:a,setSearchResultIndex:l,setSearchTotalResults:o}){try{const t=localStorage.getItem("kjb-search-term"),m=localStorage.getItem("kjb-search-results"),h=localStorage.getItem("kjb-search-index");if(!t||!m||r)return;const b=JSON.parse(m),x=h?parseInt(h,10):0;let c=null;try{c=JSON.parse(localStorage.getItem("kjb-position")||"null")}catch{}const i=j=>j&&c&&j.abbr===c.abbr&&parseInt(j.chapter,10)===parseInt(c.chapter,10),N=i(b[x])?x:b.findIndex(i);b.length>0&&N>=0&&(n.current=!1,a(t),l(N),o(b.length))}catch{}}function wa({setGospelMode:r,setGospelResultIndex:n,setGospelTotalResults:a}){try{const l=localStorage.getItem("kjb-gospel-results");if(!l)return;const o=JSON.parse(l),t=parseInt(localStorage.getItem("kjb-gospel-index")||"0",10);o.length>0&&(r(!0),n(t),a(o.length))}catch{}}function Sa(r,n,a){const l=u.useRef(n);u.useEffect(()=>{l.current=n},[n]);const o=u.useRef(0),t=u.useRef(0),m=u.useRef(!1);u.useEffect(()=>{const h=r.current;if(!h)return;const b=N=>{const j=N[0].clientX-N[1].clientX,C=N[0].clientY-N[1].clientY;return Math.hypot(j,C)},x=N=>{N.touches.length===2?(m.current=!0,o.current=b(N.touches),t.current=l.current):(m.current=!1,h.style.touchAction="")},c=N=>{if(!m.current||N.touches.length!==2)return;N.preventDefault();const j=b(N.touches)/(o.current||1),C=Math.round(t.current*j/5)*5,I=Math.max(75,Math.min(250,C));I!==l.current&&a(I)},i=N=>{N.touches.length<2&&(m.current=!1,h.style.touchAction="")};return h.addEventListener("touchstart",x,{passive:!1}),h.addEventListener("touchmove",c,{passive:!1}),h.addEventListener("touchend",i),h.addEventListener("touchcancel",i),()=>{h.removeEventListener("touchstart",x),h.removeEventListener("touchmove",c),h.removeEventListener("touchend",i),h.removeEventListener("touchcancel",i)}},[r,a])}const Hn="kjb-reading-progress";function Na(){try{return JSON.parse(localStorage.getItem(Hn)||"[]")}catch{return[]}}function ka(){return new Date().toISOString().slice(0,10)}async function Ea(r,n,a){if(!r||!n||n===0)return;const l=r,o=ka(),t=`${o}:${l}:${n}`,m=Na();m.some(b=>`${b.date}:${b.book}:${b.chapter}`===t)||(m.unshift({date:o,book:l,chapter:n,completed:!1}),localStorage.setItem(Hn,JSON.stringify(m)))}function Ia(r,n){const a=u.useRef("");u.useEffect(()=>{if(n||!(r!=null&&r.abbr)||!(r!=null&&r.chapter)||r.chapter===0)return;const l=`${r.abbr}:${r.chapter}`;l!==a.current&&(a.current=l,Ea(r.abbr,r.chapter))},[r==null?void 0:r.abbr,r==null?void 0:r.chapter,n])}function Qa(){var Qr,en,tn,rn;const{hideHeader:r,setHideHeader:n}=ms();u.useEffect(()=>()=>{var s;n(!1),document.fullscreenElement&&((s=document.exitFullscreen)==null||s.call(document).catch(()=>{}))},[n]);const a=hs(),l=ps(),[o]=u.useState(ha),[t,m]=u.useState(()=>o.pos?{...o.pos,verse:null}:{...On(),verse:null}),[h,b]=u.useState(o.verses),[x,c]=u.useState(o.colophon),[i,N]=u.useState(o.verses.length===0),[j,C]=u.useState(null),[I,T]=u.useState(o.highlightVerse),[v,y]=u.useState(null),[g,k]=u.useState(o.selection||o.highlightSet||new Set),[L,D]=u.useState(o.verses.length),[A,R]=u.useState(!1),[V,ae]=u.useState(!1),[F,J]=u.useState(null),[W,Ne]=u.useState(!1),[P,ve]=u.useState(()=>{try{const s=localStorage.getItem("kjb-flow");return s==="line"||s==="paragraph"?s:localStorage.getItem("kjb-layout")==="paragraph"?"paragraph":"line"}catch{return"line"}}),[de,ke]=u.useState(()=>{try{const s=localStorage.getItem("kjb-column");return s==="true"?!0:s==="false"?!1:localStorage.getItem("kjb-layout")==="column"?!0:window.matchMedia("(min-width: 1024px)").matches}catch{return!1}}),M=P==="paragraph",X=de,[Q,Ee]=u.useState(()=>{try{return parseInt(localStorage.getItem("kjb-zoom")||"100")}catch{return 100}}),[q,Ie]=u.useState(!1),[he,K]=u.useState(!1),[Re,Be]=u.useState(!1),[ut,St]=u.useState(()=>{try{return localStorage.getItem("kjb-highlight-color")||"yellow"}catch{return"yellow"}}),[G,se]=u.useState(o.selection||new Set),[Fe,rt]=u.useState(new Set),[pe,ee]=u.useState(o.filterMode),[le,Le]=u.useState(()=>{try{return localStorage.getItem("kjb-reader-font-family")||"serif"}catch{return"serif"}}),[ye,nt]=u.useState(nn),Xe=ye!=="default";u.useEffect(()=>{if(ye!=="default"&&le==="cursive"){Le("serif");try{localStorage.setItem("kjb-reader-font-family","serif")}catch{}}},[]);const[ne,ue]=u.useState(()=>{try{const s=new URLSearchParams(window.location.search);if(s.get("from")==="search"&&s.get("q"))return s.get("q")}catch{}return null}),[ft,Se]=u.useState(0),[Nt,Ce]=u.useState(0),fe=u.useRef(!1),Me=u.useRef(!1),We=u.useRef(!1),st=u.useRef(!0),kt=u.useRef(!1),d=u.useRef(null),B=u.useRef(null),[ge,oe]=u.useState(!1),[Ye,Te]=u.useState(()=>tt().index),[Et,_e]=u.useState(()=>tt().results.length),Lt=s=>
22{if(s==="dyslexic"||s==="hyperlegible"){an(s),nt(s),window.dispatchEvent(new Event("storage"));return}try{localStorage.setItem("kjb-reader-font-family",s)}catch{}Le(s),on(s),ye!=="default"&&(an("default"),nt("default")),window.dispatchEvent(new Event("storage"))},[Dt,ct]=u.useState(!1),[gr,Jt]=u.useState(!1),[It,mt]=u.useState(new Set),br=s=>{const f=parseInt(s,10);mt(p=>{const $=new Set(p);return $.has(f)?$.delete(f):$.add(f),$})},[,xr]=u.useState(0);u.useEffect(()=>{const s=()=>xr(f=>f+1);return window.addEventListener("kjb-highlights-changed",s),()=>window.removeEventListener("kjb-highlights-changed",s)},[]);const[Gt,Ot]=u.useState(!1),[Yt,ht]=u.useState(!1),[vr,ar]=u.useState(!1),[Mr,Ct]=u.useState(!1),[it,Je]=u.useState(()=>{try{const s=localStorage.getItem("kjb-last-reading");return s?JSON.parse(s):null}catch{return null}}),[Br,_t]=u.useState(()=>{try{const s=localStorage.getItem("kjb-prev-reading-session");return s?JSON.parse(s):null}catch{return null}});Ia(t,i),u.useEffect(()=>()=>{R(!1),ae(!1),Ne(!1),Ie(!1),K(!1)},[a.pathname]);const S=()=>{const s=P==="line"?"paragraph":"line";ve(s);try{localStorage.setItem("kjb-flow",s)}catch{}window.dispatchEvent(new Event("storage"))},te=()=>{ke(s=>{const f=!s;try{localStorage.setItem("kjb-column",String(f))}catch{}return window.dispatchEvent(new Event("storage")),f})},me=s=>{const f=Math.max(75,Math.min(250,Q+s));Ee(f);try{localStorage.setItem("kjb-zoom",String(f))}catch{}window.dispatchEvent(new Event("storage"))},Ue=s=>{const f=parseInt(s.target.value);Ee(f);try{localStorage.setItem("kjb-zoom",String(f))}catch{}window.dispatchEvent(new Event("storage"))},be=()=>{Ee(100);try{localStorage.setItem("kjb-zoom","100")}catch{}},Ut=()=>{if(mt(new Set),Re){Be(!1);let s=null;if(!fe.current&&(ne||ge))try{if(ge){const f=tt();s=f.results[f.index]||null}else{const f=gt();f.term&&(s=f.results[f.index]||null)}}catch{}if(s&&s.abbr===t.abbr&&parseInt(s.chapter,10)===parseInt(t.chapter,10)){qt(s,!0);return}se(new Set),ee(!1)}else Be(!0)};u.useEffect(()=>{mt(new Set)},[t.abbr,t.chapter]);const De=u.useMemo(()=>[...It].sort((s,f)=>s-f),[It]),pt=u.useMemo(()=>De.map(s=>h.find(f=>parseInt(f.verse,10)===s)).filter(Boolean),[De,h]),Jr=()=>ga({tappedVerseNums:De,tappedVerseObjs:pt,chapterSubscript:Qe,colophon:x,book:Pe,pos:t}),Mn=async()=>{await ur(Jr()),Ot(!0),setTimeout(()=>Ot(!1),1800)},Bn=async()=>{const s=Jr();if(!tr({text:s})){try{if(navigator.share)return await navigator.share({text:s})}catch(f){if((f==null?void 0:f.name)==="AbortError")return}await ur(s),ht(!0),setTimeout(()=>ht(!1),1800)}},Jn=()=>{if(De.length===0)return;De.every(f=>Ar(t.abbr,t.chapter,f))?De.forEach(f=>Rn(t.abbr,t.chapter,f)):(pt.forEach(f=>{const p=parseInt(f.verse,10);$r({abbr:t.abbr,chapter:t.chapter,verse:p,ref:`${Pe.shortName} ${t.chapter}:${p}`,text:Ht(f.text),folder:"Favourites"})}),ar(!0),setTimeout(()=>ar(!1),1800))},Gn=s=>{if(De.length!==0){if(!s){De.forEach(f=>mr(t.abbr,t.chapter,f));return}De.forEach(f=>$t(t.abbr,t.chapter,f,s))}},Yn=s=>{Be(!0),se(new Set([parseInt(s,10)]))},_n=s=>{se(f=>{const p=new Set(f),$=parseInt(s,10);return p.has($)?p.delete($):p.add($),p})};u.useEffect(()=>{Re||rt(new Set)},[Re]);const At=s=>Re?Fe.has(s):v===s,yr=s=>{Re?rt(f=>{const p=new Set(f);return p.has(s)?p.delete(s):p.add(s),p}):y(f=>f===s?null:s)},Un=()=>{se(new Set(h.map(f=>parseInt(f.verse,10))));const s=new Set;Qe&&s.add("subscript"),x&&s.add("colophon"),rt(s)},Gr=()=>ba({verses:h,selectedVerses:G,selectedSections:Fe,book:Pe,pos:t,searchTerm:ne,colophon:x}),Vn=async()=>{const s=Gr();await ur(s),ct(!0),setTimeout(()=>ct(!1),1800)},Yr=()=>xa({verses:h,selectedVerses:G,selectedSections:Fe,book:Pe,pos:t,searchTerm:ne,colophon:x}),qn=async()=>{const s=Yr();await ur(s),ct(!0),setTimeout(()=>ct(!1),1800)},Wn=()=>{G.size&&([...G].sort((s,f)=>s-f).forEach(s=>{const f=h.find(p=>parseInt(p.verse,10)===s);f&&$r({abbr:t.abbr,chapter:t.chapter,verse:s,ref:`${Pe.shortName} ${t.chapter}:${s}`,text:Ht(f.text),folder:"Favourites"})}),Jt(!0),setTimeout(()=>Jt(!1),1800))},Kn=s=>{G.size&&[...G].forEach(f=>$t(t.abbr,t.chapter,f,s||ut))},Zn=()=>
22{if(ee(!0),Be(!1),G.size>0){const s=Math.min(...G),f=Math.max(...G);let p=`/read?book=${t.abbr}&chapter=${t.chapter}&verse=${s}`;f>s&&(p+=`&verseEnd=${f}`);try{l(p,{replace:!0}),Xt(t.abbr,t.chapter,s,f>s?f:null)}catch{}}window.scrollTo({top:0,behavior:"smooth"}),setTimeout(()=>Ct(!1),3e3)},[Xn,or]=u.useState(!1),Qn=async()=>{const s=Gr(),p=G.size>0?`${Pe.shortName} ${t.chapter}:${lt([...G])}`:`${Pe.shortName} ${t.chapter}`;if(!tr({title:`${p}`,text:s})){try{if(navigator.share)return await navigator.share({title:`${p}`,text:s})}catch($){if(($==null?void 0:$.name)==="AbortError")return}try{await navigator.clipboard.writeText(s),or(!0),setTimeout(()=>or(!1),1800)}catch{}}},es=async()=>{const s=Yr(),p=G.size>0?`${Pe.shortName} ${t.chapter}:${lt([...G])}`:`${Pe.shortName} ${t.chapter}`;if(!tr({title:`${p}`,text:s})){try{if(navigator.share)return await navigator.share({title:`${p}`,text:s})}catch($){if(($==null?void 0:$.name)==="AbortError")return}try{await navigator.clipboard.writeText(s),or(!0),setTimeout(()=>or(!1),1800)}catch{}}},[ts,_r]=u.useState(!1),rs=async()=>{const s=G.size>0,f=s?`${Pe.shortName} ${t.chapter}:${lt([...G])}`:`${Pe.shortName} ${t.chapter}`,p=sr({abbr:t.abbr,chapter:t.chapter,verse:s?Math.min(...G):null,verseEnd:s?Math.max(...G):null}),$=`${f} 23 24<${p}>`;if(!tr({title:`${f}`,text:$})){try{if(navigator.share)return await navigator.share({title:`${f}`,text:$,url:p})}catch(z){if((z==null?void 0:z.name)==="AbortError")return}try{await navigator.clipboard.writeText($),_r(!0),setTimeout(()=>_r(!1),1800)}catch{}}},Ft=u.useRef(null),Ur=u.useRef(null),ns=u.useCallback(s=>{Ee(s);try{localStorage.setItem("kjb-zoom",String(s))}catch{}},[]);Sa(Ur,Q,ns);const ss=u.useRef(null),Ge=u.useRef(t);u.useEffect(()=>{Ge.current=t},[t]);const Pe=Pt.find(s=>s.abbr===t.abbr)||Pt[0],Qe=Or(Pe.apiName,t.chapter);la(t,i,ye,l,ne,ge);const at=t.chapter===0,Ve=u.useCallback(async(s,f,p,$=null)=>{C(null);const z=Pt.find(H=>H.abbr===s);if(!z){C("Book not found"),N(!1);return}if(p||T(null),f===0){b([]),c(null),D(0),N(!1),T(p||null),Xt(s,f);return}const ce=$n(z.apiName,f);if(ce){b(ce.verses),c(ce.colophon||null),D(ce.verses.length),p&&T(p),Xt(s,f,p||null,$||null),N(!1);return}N(!0),b([]),c(null),(document.getElementById("kjb-scroll")||window).scrollTo({top:0});try{const H=await ys(z.apiName,f);b(H.verses),c(H.colophon||null),D(H.verses.length),p&&T(p),Xt(s,f,p||null,$||null)}catch{C("Failed to load chapter. Please check your connection.")}N(!1)},[]);u.useEffect(()=>{var ze;if(kt.current)return;kt.current=!0,gs().catch(Z=>console.error("[BibleReader] Cache preload failed:",Z));const s=new URLSearchParams(window.location.search);let f=!!s.get("book")&&!!s.get("chapter")&&!s.get("from")&&!s.get("verse")&&!s.get("q");if(f)try{const Z=gt(),Y=(ze=Tt(s.get("book")))==null?void 0:ze.abbr,we=parseInt(s.get("chapter"),10),w=JSON.parse(localStorage.getItem("kjb-reader-toolbar-state")||"null");!!w&&w.hasSearchContext&&!!w.searchTerm&&w.abbr===Y&&parseInt(w.chapter,10)===we&&Z.term&&Z.results.some(ie=>ie&&ie.abbr===Y&&parseInt(ie.chapter,10)===we)&&(f=!1)}catch{}f||(ya({searchClearedRef:fe,setSearchTerm:ue,setSearchResultIndex:Se,setSearchTotalResults:Ce,setGospelMode:oe,setGospelResultIndex:Te,setGospelTotalResults:_e}),ja({hasSearchTerm:ne,searchClearedRef:fe,setSearchTerm:ue,setSearchResultIndex:Se,setSearchTotalResults:Ce}));try{const Z=localStorage.getItem("kjb-last-reading");if(Z){const Y=JSON.parse(Z);Y&&Je(Y)}}catch{}wa({setGospelMode:oe,setGospelResultIndex:Te,setGospelTotalResults:_e});const p=new URLSearchParams(window.location.search),$=p.get("book"),z=p.get("chapter"),ce=p.get("verse"),H=p.get("titlePage");if(H==="old"||H==="new"){const Z=H==="new"?"MAT":"GEN";m({abbr:Z,chapter:0,verse:null}),Ve(Z,0,null);return}const $e=Tt($);if($e&&z){const Z=parseInt(z,10),Y=ce?parseInt(ce,10):null;let we=p.get("verseEnd")?parseInt(p.get("verseEnd"),10):null;if(!we)try{const E=JSON.parse(localStorage.getItem(ot)||"{}");E.abbr===$e.abbr&&E.chapter===Z&&E.verseEnd&&(we=E.verseEnd)}catch{}const w=Y&&we&&we>Y;if(w){const E=new Set;for(let ie=Y;ie<=we;ie++)E.add(ie);
24se(E),k(E),ee(!0)}m({abbr:$e.abbr,chapter:Z,verse:Y}),T(Y||null),Ve($e.abbr,Z,Y,w?we:null)}else{let Z=!1;try{const Y=JSON.parse(localStorage.getItem(ot)||"{}");if(Y&&Y.abbr&&Y.chapter){const we=Y.verse&&Y.verseEnd&&Y.verseEnd>Y.verse;if(we){const w=new Set;for(let E=Y.verse;E<=Y.verseEnd;E++)w.add(E);se(w),k(w),ee(!0)}m({abbr:Y.abbr,chapter:Y.chapter,verse:Y.verse||null}),T(Y.verse||null),Ve(Y.abbr,Y.chapter,Y.verse||null,we?Y.verseEnd:null),Z=!0}}catch{}Z||Ve(t.abbr,t.chapter,null)}},[]),u.useEffect(()=>{if(B.current===a.search)return;B.current=a.search;const s=new URLSearchParams(a.search),f=s.get("titlePage");if(f==="old"||f==="new"){const w=f==="new"?"MAT":"GEN";ue(null),oe(!1),ee(!1),se(new Set),k(new Set),m({abbr:w,chapter:0,verse:null}),Ve(w,0,null);return}const p=Tt(s.get("book")),$=s.get("chapter"),z=s.get("from")==="search",ce=s.get("from")==="daily",H=s.get("from")==="random",$e=s.get("from")==="gospel";z||(Me.current=!1);const ze=s.get("highlight");y(ze==="colophon"||ze==="subscript"?ze:null);const Z=st.current;p&&$&&(st.current=!1);const Y=(w,E)=>Ge.current.abbr===w&&parseInt(Ge.current.chapter,10)===E;if(p&&$){const w=parseInt($,10),E=s.get("verse")?parseInt(s.get("verse"),10):null;let ie=s.get("verseEnd")?parseInt(s.get("verseEnd"),10):null;try{if(!ie){const U=JSON.parse(localStorage.getItem(ot)||"{}");U.abbr===p.abbr&&U.chapter===w&&U.verseEnd&&(ie=U.verseEnd)}}catch{}if(E&&ie&&ie>E){const U=new Set;for(let O=E;O<=ie;O++)U.add(O);se(U),k(U),ee(!0)}if(Z&&!E&&!ie&&!z&&!ce&&!H&&!$e&&!s.get("q")&&!ze&&Y(p.abbr,w))return;if($e){let U=tt();if(U.results.length===0){const O=$s(),je=Math.max(0,O.findIndex(_=>_.abbr===p.abbr&&_.chapter===w&&_.verse===E));sn(O,je),U={results:O,index:je}}if(U.results.length>0){const O=_=>_?parseInt(_,10):null,je=U.results.findIndex(_=>_&&_.abbr===p.abbr&&parseInt(_.chapter,10)===w&&(_.section?ze===_.section:O(_.verse)===O(E)));if(je>=0){oe(!0),Te(je),_e(U.results.length),qt(U.results[je],Z||Y(p.abbr,w));return}oe(!1),Te(0),_e(0);try{Ze(),localStorage.removeItem("kjb-gospel-results"),localStorage.removeItem("kjb-gospel-index"),localStorage.removeItem("kjb-reader-toolbar-state")}catch{}}}else oe(!1),Ze();if(z){let{term:U,index:O,results:je}=gt();const _=s.get("q"),Ke=!_&&je.length>1;if(Me.current=!_&&!Ke&&!!E,_&&je.length===0&&(je=[{abbr:p.abbr,chapter:w,verse:E,verseEnd:ie||null}],O=0,bs(je,O,_)),_||Ke)fe.current=!1,ue(_||U||""),Se(O),Ce(je.length);else if(E){const xe=je.findIndex(Ae=>Ae&&Ae.abbr===p.abbr&&parseInt(Ae.chapter,10)===w&&(Ae.verse?parseInt(Ae.verse,10):null)===E);xe>=0?(fe.current=!1,ue(U||""),Se(xe),Ce(je.length)):(fe.current=!0,ue(""),Se(0),Ce(0))}const He=xe=>xe&&xe.abbr===p.abbr&&parseInt(xe.chapter,10)===w&&(xe.verse?parseInt(xe.verse,10):null)===(E||null),re=je.findIndex(He);if(re>=0){if(_||Ke){Se(re);try{Tr(re)}catch{}}qt(je[re],Z||Y(p.abbr,w));return}if(!_&&E){fe.current=!0,ue(null),Se(0),Ce(0);try{ir(),localStorage.removeItem("kjb-search-term"),localStorage.removeItem("kjb-search-results"),localStorage.removeItem("kjb-search-index"),localStorage.removeItem("kjb-reader-toolbar-state")}catch{}}}else if(!ce&&!H){try{const O=localStorage.getItem("kjb-last-reading");Je(O?JSON.parse(O):null)}catch{Je(null)}const U=localStorage.getItem("kjb-reader-toolbar-state");if(U)try{const O=JSON.parse(U);if(O.abbr===(p==null?void 0:p.abbr)&&O.chapter===w&&Z){if(O.hasSearchContext&&O.searchTerm&&(fe.current=!1,ue(O.searchTerm),Se(O.searchResultIndex||
240),Ce(O.searchTotalResults||0)),O.hasGospelContext){const _=tt();_.results.length>0&&(oe(!0),Te(_.index),_e(_.results.length))}const je=O.hasSearchContext&&O.searchTerm||O.hasGospelContext||O.hasReferenceContext;if(O.hasReferenceContext&&(Me.current=!0),je&&(O.filterMode!==void 0&&ee(O.filterMode),O.selectedVerses&&O.selectedVerses.length>0)){const _=new Set(O.selectedVerses);se(_),k(_)}}else(ne||ge)&&(fe.current=!0,ue(null),Se(0),Ce(0),oe(!1),Ze())}catch{}else(ne||ge)&&(fe.current=!0,ue(null),Se(0),Ce(0),oe(!1),Ze())}if(Ge.current.abbr===p.abbr&&Ge.current.chapter===w&&Ge.current.verse===E&&!$e)return;if(ce||H){fe.current=!0,ue(null),Se(0),Ce(0),oe(!1),Ze(),ee(!1),se(new Set),We.current=!1;try{const U=localStorage.getItem("kjb-last-reading");if(U){const O=JSON.parse(U);Je(O)}}catch{}T(E||null),k(E?new Set([E]):new Set)}else if(T(E||null),E&&z){const U=new Set([E]);se(U),k(U),ee(!0)}else E||(ee(!1),se(new Set),k(new Set));if(m({abbr:p.abbr,chapter:w,verse:E}),!E&&Ge.current.abbr===p.abbr&&Ge.current.chapter===w&&(Ge.current.verse||ne||ge||pe)){Xt(p.abbr,w,null);let U=0;try{const O=JSON.parse(localStorage.getItem("kjb-prev-reading-session")||localStorage.getItem("kjb-pre-search")||"null");O&&O.abbr===p.abbr&&O.chapter===w&&typeof O.scrollY=="number"&&(U=Math.max(0,Math.round(O.scrollY)))}catch{}(document.getElementById("kjb-scroll")||window).scrollTo({top:U});return}E||(Vt.current=!0),(document.getElementById("kjb-scroll")||window).scrollTo({top:0}),Ve(p.abbr,w,E,E&&ie&&ie>E?ie:null);return}try{const w=JSON.parse(localStorage.getItem(ot)||"{}");if(w&&w.abbr&&w.chapter){const E=new URLSearchParams(window.location.search),ie=E.get("from")==="daily",U=E.get("from")==="random";let O=!1,je=!1,_=null;try{const He=localStorage.getItem("kjb-reader-toolbar-state");if(console.log("[BibleReader] Fallback restore - saved state:",He),He&&!ie&&!U){const re=JSON.parse(He);if(console.log("[BibleReader] Fallback restore - parsed state:",re),re&&re.abbr===w.abbr&&re.chapter===w.chapter){if(re.hasSearchContext&&re.searchTerm&&(fe.current=!1,ue(re.searchTerm),Se(re.searchResultIndex||
240),Ce(re.searchTotalResults||0)),re.hasGospelContext){const Ae=tt();Ae.results.length>0&&(oe(!0),Te(Ae.index),_e(Ae.results.length))}const xe=re.hasSearchContext&&re.searchTerm||re.hasGospelContext||re.hasReferenceContext;if(re.hasReferenceContext&&(Me.current=!0),xe&&(re.filterMode!==void 0&&(ee(re.filterMode),je=!0),re.selectedVerses&&re.selectedVerses.length>0)){const Ae=new Set(re.selectedVerses);se(Ae),k(Ae),O=!0,_=Math.min(...Ae)}re.resultView&&(lr.current=re.resultView)}}}catch(He){console.error("[BibleReader] Fallback restore error:",He)}const Ke=w.verse&&w.verseEnd&&w.verseEnd>w.verse;if(Ke){const He=new Set;for(let re=w.verse;re<=w.verseEnd;re++)He.add(re);se(He),k(He),ee(!0)}else!O&&!je&&(ee(!1),se(new Set),k(new Set));m({abbr:w.abbr,chapter:w.chapter,verse:w.verse||null}),T(_||w.verse||null),Ve(w.abbr,w.chapter,w.verse||null,Ke?w.verseEnd:null)}}catch(w){console.error("[BibleReader] Fallback restore error:",w)}try{const w=localStorage.getItem("kjb-last-reading");if(w){const E=JSON.parse(w);Je(E)}}catch{}const we=()=>{let w;try{w=JSON.parse(localStorage.getItem(ot)||"{}")}catch{return}if(!w||!Tt(w.abbr))return;const E=new URLSearchParams(window.location.search),ie=Tt(E.get("book")),U=E.get("chapter"),O=E.get("verse");if(ie&&U&&ie.abbr===w.abbr&&parseInt(U,10)===w.chapter&&parseInt(O||"0",10)===(w.verse||0)){w.verse||(Vt.current=!0),T(w.verse||null);return}const je=E.get("from")==="search",_=gt();if(je&&_.results.length>0){const xe=_.results[_.index]||_.results[0];if(xe&&xe.abbr===w.abbr&&xe.chapter===w.chapter){qt(xe);return}}const Ke=localStorage.getItem("kjb-last-reading");if(Ke)try{const xe=JSON.parse(Ke);xe&&xe.abbr===w.abbr&&xe.chapter===w.chapter&&xe.verse&&(T(xe.verse),k(new Set([xe.verse])),ee(!1))}catch{}const He=w.verse&&w.verseEnd&&w.verseEnd>w.verse;if(He){const xe=new Set;for(let Ae=w.verse;Ae<=w.verseEnd;Ae++)xe.add(Ae);se(xe),k(xe),ee(!0)}else Ke||(ee(!1),se(new Set),k(new Set));w.verse||(Vt.current=!0),m({abbr:w.abbr,chapter:w.chapter,verse:w.verse||null}),T(w.verse||null),Ge.current.abbr===w.abbr&&parseInt(Ge.current.chapter,10)===parseInt(w.chapter,10)||Ve(w.abbr,w.chapter,w.verse||null,He?w.verseEnd:null)};return window.addEventListener("kjb-navigate",we),()=>window.removeEventListener("kjb-navigate",we)},[a.search,Ve]);const jr=u.useCallback((s,f=!1)=>{pa({verseNum:s,posRef:Ge,topRef:Ft,scrolledVerseRef:d,instant:f})},[]);u.useEffect(()=>{if(i||!v)return;const s=v==="colophon"?"kjb-colophon-anchor":"kjb-subscript-anchor",f=()=>{const z=document.getElementById(s);if(!z)return;const ce=document.getElementById("kjb-scroll"),$e=(Ft.current?Ft.current.getBoundingClientRect().height:0)+48;if(ce){const ze=z.getBoundingClientRect().top-ce.getBoundingClientRect().top+ce.scrollTop-$e;ce.scrollTo({top:Math.max(0,ze),behavior:"smooth"})}else{const ze=z.getBoundingClientRect().top+window.scrollY-$e;window.scrollTo({top:Math.max(0,ze),behavior:"smooth"})}},p=setTimeout(f,250),$=setTimeout(f,650);return()=>{clearTimeout(p),clearTimeout($)}},[i,v,h,x,t.abbr,t.chapter]),u.useEffect(()=>{if(i||at)return;const s=`kjb-scroll-${t.abbr}-${t.chapter}`,f=document.getElementById("kjb-scroll"),p=f||window,$=()=>f?f.scrollTop:window.scrollY;let z=null;const ce=new URLSearchParams(window.location.search),H=["daily","random","search","gospel"].includes(ce.get("from")),$e=!!ce.get("verse"),ze=!!ce.get("highlight");if(!H&&!$e&&!ze&&t.abbr&&t.chapter)try{const E={abbr:t.abbr,chapter:t.chapter,scrollY:Math.round($())};localStorage.setItem("kjb-prev-reading-session",JSON.stringify(E))}catch{}let Z=zn(s);const Y=()=>{if(z&&(cancelAnimationFrame(z),z=null),Z=En(s,f,Z)||Z,!(ne||ge||it)&&t.abbr&&t.chapter)try{const ie={abbr:t.abbr,chapter:t.chapter,scrollY:Math.round($())};localStorage.setItem("kjb-prev-reading-session",JSON.stringify(ie))}catch{}},we=()=>{Z=ua(s,f,Z),!z&&(z=requestAnimationFrame(()=>{z=null,Z=En(s,f,Z)||Z;const E=new URLSearchParams(window.location.search);if(!(["daily","random","search","gospel"].includes(E.get("from"))||!!E.get("verse")||!!E.get("highlight"))&&!I&&!ne&&!ge&&!it&&t.abbr&&t.chapter)try{const U={abbr:t.abbr,chapter:t.chapter,scrollY:Math.round($())};localStorage.setItem("kjb-prev-reading-session",JSON.stringify(U))}catch{}}))},w=()=>{Y();const E=new URLSearchParams(window.location.search),ie=E.get("from")==="daily",U=E.get("from")==="random",O=E.get("from")==="search",je=E.get("from")==="gospel";if(!ie&&!U&&!O&&!je)try{const _=document.getElementById("kjb-scroll"),Ke=_?_.scrollTop:window.scrollY,He={abbr:t.abbr,chapter:t.chapter,scrollY:Math.round(Ke)};localStorage.setItem("kjb-prev-reading-session",JSON.stringify(He))}catch{}};return p.addEventListener("scroll",we,{passive:!0}),window.addEventListener("pagehide",w),window.addEventListener("beforeunload",w),document.addEventListener("visibilitychange",w),()=>{Y(),w(),p.removeEventListener("scroll",we),window.removeEventListener("pagehide",w),window.removeEventListener("beforeunload",w),document.removeEventListener("visibilitychange",w),z&&cancelAnimationFrame(z)}},[i,at,t.abbr,t.chapter]),u.useEffect(()=>{const s=()=>
24{if(pe&&G.size>0&&!ne&&!ge&&!Me.current)try{const p=t.chapter===0?window.location.pathname:`/read?book=${t.abbr}&chapter=${t.chapter}`;window.history.replaceState({},"",p),localStorage.setItem(ot,JSON.stringify({abbr:t.abbr,chapter:t.chapter,verse:null,verseEnd:null}))}catch{}},f=()=>{document.visibilityState==="hidden"&&s()};return window.addEventListener("pagehide",s),document.addEventListener("visibilitychange",f),()=>{window.removeEventListener("pagehide",s),document.removeEventListener("visibilitychange",f)}},[pe,G,ne,ge,t.abbr,t.chapter]),u.useEffect(()=>{const s=()=>{try{Ee(parseInt(localStorage.getItem("kjb-zoom")||"100"))}catch{}try{const f=localStorage.getItem("kjb-reader-font-family")||"serif";Le(f),on(f)}catch{}try{nt(nn())}catch{}try{if(!fe.current){const f=localStorage.getItem("kjb-search-term"),p=localStorage.getItem("kjb-search-results"),$=localStorage.getItem("kjb-search-index");if(f&&p){const z=JSON.parse(p);z.length>0&&(ue(f),Se($?parseInt($,10):0),Ce(z.length))}}}catch{}try{const f=localStorage.getItem("kjb-last-reading");if(f){const p=JSON.parse(f);p&&(Je(p),p.abbr===t.abbr&&p.chapter===t.chapter&&p.verse&&(T(p.verse),k(new Set([p.verse])),setTimeout(()=>jr(p.verse),100)))}}catch{}try{const f=localStorage.getItem("kjb-prev-reading-session");if(f){const p=JSON.parse(f);p&&_t(p)}}catch{}};return s(),window.addEventListener("storage",s),window.addEventListener("focus",s),window.addEventListener("kjb-fonts-changed",s),()=>{window.removeEventListener("storage",s),window.removeEventListener("focus",s),window.removeEventListener("kjb-fonts-changed",s)}},[a.pathname,t.abbr,t.chapter]),u.useEffect(()=>{const s=()=>{try{if(fe.current)return;const{term:f,index:p,results:$}=gt();if(ue(f||null),Se(p),Ce($.length),We.current){Je(null);return}const z=localStorage.getItem("kjb-last-reading");Je(z?JSON.parse(z):null)}catch{}};return window.addEventListener("focus",s),()=>{window.removeEventListener("focus",s)}},[]);const lr=u.useRef("filter");fa(t,i,h,pe,G,ne,ft,Nt,ge,fe,ee,se,k,lr,ue,Se,Ce,oe,Te,_e,T,Me);const{navigate:as,rangeHighlightRef:os,freshNavRef:Vt}=ca(t,Ve,l);ma({loading:i,verses:h,highlightVerse:I,highlightSection:v,abbr:t.abbr,chapter:t.chapter,scrollToVerseEl:jr,topRef:Ft,freshNavRef:Vt,setHighlightVerse:T,setHighlightedVerses:k}),u.useEffect(()=>{const s=()=>
24{if(Vt.current)return;const f=new URLSearchParams(window.location.search);if(!(f.get("book")&&f.get("chapter")))try{const p=JSON.parse(localStorage.getItem(ot)||"{}");if(!p||!p.abbr||!p.chapter||!Tt(p.abbr))return;const $=Ge.current;if(p.abbr===$.abbr&&p.chapter===$.chapter)return;const z=p.verse&&p.verseEnd&&p.verseEnd>p.verse;if(z){const ce=new Set;for(let H=p.verse;H<=p.verseEnd;H++)ce.add(H);se(ce),k(ce),ee(!0)}m({abbr:p.abbr,chapter:p.chapter,verse:p.verse||null}),T(p.verse||null),Ve(p.abbr,p.chapter,p.verse||null,z?p.verseEnd:null)}catch{}};return window.addEventListener("kjb-settings-synced",s),()=>window.removeEventListener("kjb-settings-synced",s)},[Ve]);const Vr=(s,f,p)=>{if(!(!s||!f)){if(y(null),Ct(!1),typeof p=="number"&&p>0)try{localStorage.setItem(`kjb-scroll-${s}-${f}`,String(Math.round(p)))}catch{}qe(s,f,null,!1,!1,!0),setTimeout(()=>{if(typeof p=="number"&&p>0){const $=document.getElementById("kjb-scroll");$?$.scrollTo({top:p,behavior:"auto"}):window.scrollTo({top:p,behavior:"auto"})}},400)}},{stepToResult:qt,clearSearchContext:qr}=va(Ge,i,h,Ft,ne,ge,oe,Te,_e,ue,Se,Ce,lr,ee,k,se,y,T,m,Ve,Vr,ir,sn,Cr,Ze,Be,Ct,Je);u.useEffect(()=>{console.log("[BibleReader] Render state:",{searchTerm:ne,gospelMode:ge,filterMode:pe,selectedVerses:G.size,highlightVerse:I,pos:t})},[ne,ge,pe,G,I,t]);const qe=(s,f,p=null,$=!1,z=!1,ce=!1,H=null,$e=!1)=>{const ze=s===t.abbr&&f===t.chapter,Z=document.getElementById("kjb-scroll"),Y=Z?Z.scrollTop:window.scrollY;if(t.abbr&&t.chapter&&!$&&!z){const we={abbr:t.abbr,chapter:t.chapter,scrollY:Y};try{localStorage.setItem("kjb-prev-reading-session",JSON.stringify(we))}catch{}_t(we)}if(($||z||!$e&&!ze)&&(fe.current=!0,ir(),ue(null),Se(0),Ce(0),oe(!1),Ze()),($||z)&&t.abbr&&t.chapter){We.current=!1;const we={abbr:s,chapter:f,fromDailyVerse:$,fromRandom:z,prevAbbr:t.abbr,prevChapter:t.chapter,prevScrollY:Y};try{localStorage.setItem("kjb-last-reading",JSON.stringify(we))}catch{}Je(we)}p?T(p):(T(null),ee(!1),Be(!1),se(new Set),k(new Set),Ct(!1)),y(H),m({abbr:s,chapter:f,verse:p}),as(s,f,p,$,z,ce,H,$e,ir,oe,Ze)},cr=()=>{ne&&qr(),ge&&(Ze(),oe(!1)),Je(null),We.current=!0,T(null),y(null),ee(!1),Be(!1),se(new Set),k(new Set);try{localStorage.removeItem("kjb-last-reading"),localStorage.removeItem("kjb-reader-toolbar-state")}catch{}};u.useMemo(()=>{const s=[{value:"",label:"Whole chapter"}];for(let f=1;f<=L;f++)s.push({value:f,label:`Verse ${f}`});return Qe&&s.push({value:"sub",label:"Subscript"}),x&&s.push({value:"col",label:"Colophon"}),s},[L,Qe,x]);const ls=s=>{if(Ne(!1),s==="sub"){cr(),qe(t.abbr,t.chapter,null,!1,!1,!1,"subscript");return}if(s==="col"){cr(),qe(t.abbr,t.chapter,null,!1,!1,!1,"colophon");return}if(s===""||s===void 0){cr(),qe(t.abbr,t.chapter,null);return}cr(),qe(t.abbr,t.chapter,Number(s))},Wr=(s=!1)=>{if(t.chapter<Pe.chapters)return qe(t.abbr,t.chapter+1,null,!1,!1,s),!0;if(t.abbr==="MAL")return qe("MAT",0,null,!1,!1,s),!0;const f=Nr(t.abbr);return f?(qe(f.abbr,1,null,!1,!1,s),!0):!1},Kr=()=>{if(t.chapter>1)qe(t.abbr,t.chapter-1);else if(t.abbr==="MAT"&&t.chapter===1)qe("MAT",0);else if(t.abbr==="GEN"&&t.chapter===1)qe("GEN",0);else{const s=Wt(t.abbr);s&&qe(s.abbr,s.chapters)}},wr=A||V||W||q||he,Sr=u.useCallback(()=>{R(!1),ae(!1),Ne(!1),Ie(!1),K(!1)},[]);u.useEffect(()=>{if(!wr)return;const s=f=>{f.target.closest("select")||f.target.closest('.kjb-reader-toolbar, .kjb-popover-panel, .kjb-selector-sheet, [role="menu"], [data-radix-popper-content-wrapper], [vaul-drawer], [data-vaul-drawer], [vaul-overlay], [data-vaul-overlay]')||Sr()};return document.addEventListener("click",s,!0),()=>document.removeEventListener("click",s,!0)},[wr,Sr]);const cs=!!(it&&!it.cleared&&it.abbr===t.abbr&&it.chapter===t.chapter),Zr=t.abbr==="REV"&&t.chapter===22,Xr=t.abbr==="GEN"&&t.chapter===0;return t.abbr==="GEN"&&t.chapter,e.jsxs("div",{onClick:s=>{s.target.closest('.kjb-verse-container, [id^="v"], h1, h2, h3, .kjb-subscript, .kjb-colophon, #kjb-colophon-anchor, #kjb-subscript-anchor, button, a, [role="menu"], [role="menuitem"], [data-radix-popper-content-wrapper]')||(T(null),y(null),mt(new Set),Re||k(new Set))},className:`w-full max-w-[120rem] mx-auto px-5 sm:px-8 lg:px-12 py-3 ${r?"pt-16":""}`,children:[!r&&e.jsx(Js,{topRef:Ft,hideHeader:r,setHideHeader:n,anyMenuOpen:wr,closeAllMenus:Sr,pos:t,book:Pe,isViewingTitlePage:at,showBookPicker:A,setShowBookPicker:R,showChapterPicker:V,setShowChapterPicker:ae,showVersePicker:W,setShowVersePicker:Ne,showZoomPopover:q,setShowZoomPopover:Ie,showFontPopover:he,setShowFontPopover:K,pendingBook:F,setPendingBook:J,navigate:qe,handleVersePick:ls,verseCount:L,chapterSubscript:Qe,colophon:x,highlightVerse:I,highlightSection:v,selectMode:Re,selectedVerses:G,filterMode:pe,setSelectMode:Be,setFilterMode:ee,setSelectedVerses:se,setHighlightedVerses:k,setShowFilterOverlay:Ct,setHighlightVerse:T,setHighlightSection:y,setTappedVerses:mt,zoomLevel:Q,adjustZoom:me,handleZoomChange:Ue,resetZoom:be,fontFamily:le,a11yActive:Xe,a11yFont:ye,handleFontChange:Lt,flowMode:P,toggleFlow:S,columnOn:de,toggleColumn:te,toggleSelectMode:Ut,paragraphMode:M,columnMode:X,verses:h,searchTerm:ne,gospelMode:ge,lastReadingActive:cs,lastReadingPos:it,gospelResultIndex:Ye,gospelTotalResults:Et,searchResultIndex:ft,searchTotalResults:Nt,setGospelResultIndex:Te,setSearchResultIndex:Se,stepToResult:qt,clearSearchContext:qr,setGos
24pelMode:oe,setLastReadingPos:Je,returnToChapter:Vr,scrollToVerseEl:jr,rangeHighlightRef:os,resultViewRef:lr,goPrev:Kr,goNext:Wr,isFirstChapterFirstBook:Xr,isLastChapterLastBook:Zr,copyFeedback:Dt,saveFeedback:gr,shareFeedback:Xn,shareLinkFeedback:ts,selectAllVerses:Un,handleCopySelected:Vn,handleCopyPerVerse:qn,handleSaveSelected:Wn,handleHighlightSelected:Kn,handleReadSelected:Zn,handleShareChapter:Qn,handleSharePerVerse:es,handleShareLink:rs,tappedVerseNums:De,handleTapHighlightToggle:Gn,handleTapCopy:Mn,handleTapShare:Bn,handleTapSave:Jn,tapCopyFeedback:Gt,tapShareFeedback:Yt,tapSaveFeedback:vr}),r&&e.jsx(oa,{setHideHeader:n}),!et()&&(A||V||W||q||he)&&e.jsx("div",{className:"fixed inset-0 z-[99]",onClick:()=>{R(!1),ae(!1),Ne(!1),Ie(!1),K(!1)}}),!at&&(!(pe&&G.size>0)||Qe)&&e.jsxs("div",{className:`text-center mb-6 pt-8 ${!X||t.chapter===1||pe&&G.size>0?"":"hidden print:block"}`,style:{fontSize:`${Q/100}rem`},children:[pe&&G.size>0?null:e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:`notranslate kjb-book-title ${le==="cursive"?"cursive-em-style":"font-serif"} text-3xl md:text-4xl font-bold text-foreground mb-2 leading-tight`,style:{fontStyle:"normal",fontWeight:"900"},children:Pe.name}),e.jsxs("p",{className:`notranslate kjb-chapter-heading font-sans text-muted-foreground tracking-widest uppercase mt-5 ${le==="cursive"?"cursive-em-style":""}`,style:{fontStyle:"normal",fontSize:`${Q/100*.875}rem`,fontWeight:le==="cursive"?"400":void 0},children:["Chapter ",t.chapter]})]}),Qe&&e.jsx("p",{onClick:()=>yr("subscript"),id:"kjb-subscript-anchor",className:`notranslate kjb-subscript text-sm text-muted-foreground mt-2 mb-4 max-w-lg mx-auto leading-relaxed text-center transition-colors duration-500 rounded-lg cursor-pointer ${le==="cursive"?"cursive-em-style":"font-serif"} ${At("subscript")?"bg-accent/20 ring-1 ring-accent/40 px-3 py-2":""}`,style:{fontStyle:"normal",fontSize:`${Q/100}rem`},children:e.jsx(kr,{text:Qe,searchTerm:At("subscript")?ne:null})})]}),e.jsxs("div",{ref:Ur,className:`kjb-reader-content leading-loose text-foreground ${le==="cursive"?"cursive-em-style":""}`,style:{fontSize:`${Q/100*1.125}rem`,lineHeight:Q>100?"1.8":"1.6",...le!=="cursive"?{fontFamily:Rt(le)}:{}},children:[i&&e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(xs,{className:"w-8 h-8 animate-spin text-accent"})}),j&&e.jsx("div",{className:"text-center py-16 text-destructive font-sans",children:j}),!i&&!j&&at&&e.jsx("div",{style:{fontFamily:"'Merriweather', 'Cormorant Garamond', Georgia, serif"},className:"kjb-titlepage [&_*]:!font-serif",children:e.jsx(sa,{type:t.abbr==="GEN"?"testament-old":t.abbr==="MAT"?"testament-new":"book",book:Pe})}),e.jsxs("div",{className:"relative",children:[!i&&!j&&h.length>0&&X&&!at&&t.chapter!==1&&e.jsx(aa,{bookName:Pe.name,chapter:t.chapter,baseFontRem:Q/100*.7,isCursive:le==="cursive"}),!i&&!j&&h.length>0&&(()=>{const s=H=>G.has(parseInt(H.verse,10))||G.has(String(H.verse)),f=pe&&G.size>0,p=h.filter(H=>!f||s(H)),$=X&&p.length>6,z=(H,$e)=>e.jsx(Cn.Fragment,{children:e.jsx(na,{verse:H,highlight:It.size>0?It.has(parseInt(H.verse,10)):parseInt(I,10)===parseInt(H.verse,10)||g.has(parseInt(H.verse,10)),id:`v${H.verse}`,bookName:Pe.name,abbr:t.abbr,chapter:t.chapter,isFirstVerse:$e,paragraphMode:M,selectMode:Re,isSelected:G.has(parseInt(H.verse,10))||G.has(String(H.verse)),onSelect:_n,onActivateSelect:Yn,totalVerses:L,colophon:h.length>0&&String(H.verse)===String(h[h.length-1].verse)?x:null,subscript:parseInt(H.verse,10)===1&&Qe||null,isCursive:le==="cursive",fontFamilyValue:Rt(le),zoomLevel:Q,columnMode:$,dropCap:$e&&parseInt(H.verse,10)===1,searchTerm:ne&&parseInt(I,10)===parseInt(H.verse,10)?ne:null,isDirectJump:parseInt(I,10)===parseInt(H.verse,10),onVerseTap:br})},`${t.abbr}-${t.chapter}-${H.verse}`),ce=X&&!at&&!(pe&&G.size>0)&&Qe?e.jsx("p",{onClick:()=>yr("subscript"),id:"kjb-subscript-anchor",className:`notranslate kjb-subscript text-center text-muted-foreground mb-4 leading-relaxed transition-colors duration-500 rounded-lg cursor-pointer ${le==="cursive"?"cursive-em-style":"font-serif"} ${At("subscript")?"bg-accent/20 ring-1 ring-accent/40 px-3 py-2":""}`,style:{fontStyle:"normal",fontSize:`${Q/100}rem`,breakInside:"avoid"},children:e.jsx(kr,{text:Qe,searchTerm:At("subscript")?ne:null})}):null;return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"relative",children:[$&&e.jsx("div",{"aria-hidden":"true","data-testid":"kjb-two-col-flow-divider",className:"absolute bottom-0 left-1/2 w-px -translate-x-1/2 pointer-events-none",style:{to
24p:!at&&t.chapter!==1?"-1.5rem":"0",backgroundColor:"hsl(var(--border))"}}),e.jsxs("div",{ref:$?ss:null,"data-testid":$?"kjb-two-col-container":void 0,className:`${$?"kjb-two-col text-left hyphens-auto":"text-left"} ${M?"text-left px-2 sm:px-4":""}`,style:$?{fontSize:"inherit",columnCount:2,columnGap:le==="cursive"?"3.5rem":"2.5rem",columnRule:"1px solid hsl(var(--border))"}:{fontSize:"inherit"},children:[ce,p.map((H,$e)=>z(H,$e===0))]})]})})})()]}),!i&&!j&&x&&(!(pe&&G.size>0)||h.length>0&&G.has(parseInt(h[h.length-1].verse,10)))&&e.jsx("div",{onClick:()=>yr("colophon"),id:"kjb-colophon-anchor",className:`${X?"mt-6 mb-4":"mt-12 mb-4 border-t border-border pt-6"} text-center transition-colors duration-500 rounded-lg cursor-pointer ${At("colophon")?"bg-accent/20 ring-1 ring-accent/40 px-3 py-2":""}`,children:e.jsx("p",{className:`notranslate kjb-colophon text-sm text-muted-foreground leading-relaxed ${le==="cursive"?"cursive-em-style":"font-serif"}`,style:{fontStyle:"normal",fontSize:`${Q/100}rem`,breakInside:"avoid"},children:e.jsx(kr,{text:x,searchTerm:At("colophon")?ne:null})})})]}),!i&&!j&&(t.abbr==="MAL"&&t.chapter===4||t.abbr==="REV"&&t.chapter===22)&&e.jsx("div",{className:"text-center mt-14 mb-12 select-none",children:e.jsx("p",{className:`notranslate text-foreground tracking-[0.35em] uppercase font-semibold kjb-end-marker ${le==="cursive"?"cursive-em-style":"font-serif"}`,style:{fontSize:`${Q/100*1.15}rem`,fontStyle:"normal"},children:js(Pe.apiName,t.chapter)||(t.abbr==="MAL"?"The End of the Prophets":"The End")})}),!i&&!j&&e.jsxs("div",{className:"hidden print:block mt-8 pt-4 border-t border-border text-sm text-muted-foreground text-center",children:["Printed on ",new Date().toLocaleDateString()," at ",new Date().toLocaleTimeString()]}),!i&&!j&&e.jsxs("div",{className:"print:hidden flex flex-nowrap justify-between gap-2 mt-8 pt-6 border-t border-border pb-2",children:[Xr?e.jsx("div",{className:"flex-1"}):e.jsxs("button",{onClick:Kr,"data-testid":"prev-chapter-btn",className:"flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg bg-secondary border border-border text-secondary-foreground font-sans text-sm font-medium hover:bg-accent/20 transition-colors min-h-[48px] touch-manipulation min-w-0",children:[e.jsx(Ir,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"hidden sm:inline truncate",children:at?`${(Qr=Wt(t.abbr))==null?void 0:Qr.shortName} ${(en=Wt(t.abbr))==null?void 0:en.chapters}`:t.chapter>1?`Chapter ${t.chapter-1}`:t.abbr==="MAT"?"New Testament Title Page":t.abbr==="GEN"?"Old Testament Title Page":`${(tn=Wt(t.abbr))==null?void 0:tn.shortName} ${(rn=Wt(t.abbr))==null?void 0:rn.chapters}`})]}),Zr?e.jsx("div",{className:"flex-1"}):e.jsxs("button",{onClick:()=>Wr(),"data-testid":"next-chapter-btn",className:"flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg bg-secondary border border-border text-secondary-foreground font-sans text-sm font-medium hover:bg-accent/20 transition-colors min-h-[48px] touch-manipulation min-w-0",children:[e.jsx("span",{className:"hidden sm:inline truncate",children:at?"Chapter 1":t.chapter<Pe.chapters?`Chapter ${t.chapter+1}`:t.abbr==="MAL"?"New Testament Title Page":Nr(t.abbr)?`${Nr(t.abbr).shortName} 1`:""}),e.jsx(zt,{className:"w-4 h-4 flex-shrink-0"})]})]})]})}export{Qa 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.