1/*! For license information please see 9999.f0c60c99.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkdocfluence_dashboard=self.webpackChunkdocfluence_dashboard||[]).push([[9999],{9999(e,t,a){a.r(t),a.d(t,{default:()=>G});var s=a(22555),n=a(5544),r=a(64793),l=a(9950),o=a(79401),i=a(42989),c=a(84814),d=a(62343),p=a(38554),u=a(7838),x=a(29126),h=a(61878),m=a(67637),g=a(66987),b=a(13147),f=a(36230);const y=(0,f.A)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);var v=a(31641),j=a(71742);const w=(0,f.A)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);var N=a(27304),k=a(70446),A=a(52828),S=a(99189),C=a(90521),E=a(44414);const L="https://historyandphysical.net";function H(e,t){const a=(e||L).replace(/\/+$/,"");return t&&"index"!==t?"".concat(a,"/").concat(encodeURI(t)):a+"/"}const P=/^\s*<!--\s*(title|description)\s*:\s*([\s\S]*?)\s*-->[ \t]*\r?\n?/;function T(e){let t=e||"";const a={title:"",description:""};for(let s=0;s<2;s++){const e=t.match(P);if(!e)break;a[e[1]]=e[2].trim(),t=t.slice(e[0].length)}return{seo:a,body:t}}function I(e,t){const a=[];return e.title&&a.push("\x3c!-- title: ".concat(e.title.replace(/-->/g,"")," --\x3e")),e.description&&a.push("\x3c!-- description: ".concat(e.description.replace(/-->/g,"")," --\x3e")),(a.length?a.join("\n")+"\n":"")+(t||"")}function F(e){const t=e||"";if(!/<script\b/i.test(t))return{visual:t,scripts:""};try{const e=(new DOMParser).parseFromString("<body>"+t+"</body>","text/html"),a=Array.from(e.body.children).filter(e=>"SCRIPT"===e.tagName);if(!a.length)return{visual:t,scripts:""};const s=[];a.forEach(e=>{const t=e.previousSibling;t&&8===t.nodeType&&(s.push("\x3c!--"+t.nodeValue+"--\x3e"),t.remove()),s.push(e.outerHTML),e.remove()});const n=e.body.innerHTML.replace(/\s+$/,"");return/<script\b/i.test(n)?{visual:t,scripts:""}:{visual:n,scripts:"\n"+s.join("\n")+"\n"}}catch(a){return{visual:t,scripts:""}}}function M(e){return/<script\b/i.test(F(e).visual)}const D={nav:{pre:'<header class="masthead"><div class="shell masthead-inner"><nav class="nav" aria-label="Primary">',post:"</nav></div></header>",leaf:!0,contents:!0},footer:{pre:'<footer class="footer">',post:"</footer>",leaf:!0,contents:!1}};const R=["Pages","Service pages","Blog, podcast and contact","Site-wide","Legal","Unwired"];function B(e){let t=e.page,a=e.active,s=e.onClick;return(0,E.jsxs)("button",{onClick:s,className:"w-full text-left px-3 py-2 rounded-lg mb-1 border ".concat(a?"border-accent bg-accent/5":"border-transparent hover:bg-gray-50"),children:[(0,E.jsxs)("span",{className:"flex items-center gap-2",children:[(0,E.jsx)("span",{className:"text-sm font-bold text-[#1A1A2E] truncate",children:t.title||t.part}),!t.wired&&(0,E.jsxs)("span",{className:"text-[9px] font-bold uppercase px-1.5 py-0.5 rounded bg-amber-100 text-amber-700 shrink-0",children:["unwired",(0,E.jsx)(r.A,{k:"SitePagesAdmin.js:unwired"})]})]}),(0,E.jsx)("span",{className:"block text-[11px] text-gray-400 truncate",children:t.fname?"/".concat("index"===t.fname?"":t.fname):"parts/".concat(t.part,".html")})]})}function _(e){let t=e.on,a=e.yes,s=e.no;return(0,E.jsx)("span",{className:"text-[9px] font-bold uppercase px-1.5 py-0.5 rounded whitespace-nowrap ".concat(t?"bg-green-100 text-green-700":"bg-gray-100 text-gray-500"),children:t?a:s})}function W(e){let t=e.siteId;const a=(0,l.useState)(null),s=(0,n.A)(a,2),r=s[0],c=s[1],d=(0,l.useState)(""),p=(0,n.A)(d,2),u=p[0],x=p[1],h=(0,l.useState)(null),m=(0,n.A)(h,2),g=m[0],b=m[1];(0,l.useEffect)(()=>{c(null),b(null),o.FH.siteSettingsGet(t).then(e=>c(e.settings||{})).catch(e=>b(e.message))},[t]);if(g)return(0,E.jsx)("p",{className:"text-xs text-alert mb-3",children:g});if(!r||void 0===r.lead_magnet_optin)return null;const f=e=>{let a=e.k,s=e.label,n=e.hint;return(0,E.jsxs)("label",{className:"flex items-center gap-3 py-1.5 cursor-pointer",children:[(0,E.jsx)("button",{type:"button",role:"switch","aria-checked":!!r[a],disabled:!!u,onClick:()=>(async e=>{if(r){x(e),b(null);try{const a=await o.FH.siteSettingsSet(t,{[e]:!r[e]});c(a.settings||{})}catch(a){b(a.message)}finally{x("")}}})(a),className:"relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ".concat(r[a]?"bg-accent":"bg-gray-300"," disabled:opacity-60"),children:(0,E.jsx)("span",{className:"absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-all ".concat(r[a]?"left-[18px]":"left-0.5")})}),(0,E.jsxs)("span",{className:"text-xs",children:[(0,E.jsx)("span",{className:"font-bold text-[#1A1A2E]",children:s}),(0,E.jsxs)("span",{className:"text-gray-500",children:[" ",n]}),u===a&&(0,E.jsx)(i.A,{className:"inline w-3 h-3 ml-1 animate-spin text-gray-400"})]})]})};return(0,E.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 px-4 py-2.5 mb-4",children:[(0,E.jsx)("p",{className:"text-[11px] font-bold uppercase tracking-wide text-gray-400 mb-1",children:"Lead magnet (free guide opt-in)"}),(0,E.jsx)(f,{k:"lead_magnet_optin",label:"Guide opt-in on the site",hint:"the signup band on every page and the card inside posts and episodes. Off hides them all, including the popup. The /guide page stays reachable by link."}),(0,E.jsx)(f,{k:"lead_magnet_popup",label:"Exit popup",hint:"the before-you-go window shown once per visitor every two weeks."})]})}function V(e){let t=e.siteId;const a=(0,l.useState)([]),s=(0,n.A)(a,2),r=s[0],d=s[1],p=(0,l.useState)(!0),u=(0,n.A)(p,2),x=u[0],h=u[1],m=(0,l.useState)(null),g=(0,n.A)(m,2),b=g[0],f=g[1],y=(0,l.useState)(null),v=(0,n.A)(y,2),j=v[0],w=v[1],N=(0,l.useCallback)(()=>{h(!0),o.FH.sitePagesTestimonials(t).then(e=>{d(e.testimonials||[]),f(null)}
2).catch(e=>f(e.message)).finally(()=>h(!1))},[t]);(0,l.useEffect)(N,[N]);return(0,E.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[x&&(0,E.jsxs)("p",{className:"text-xs text-gray-400 flex items-center gap-1.5 py-2",children:[(0,E.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"})," Loading testimonials\u2026"]}),b&&(0,E.jsx)("p",{className:"text-xs text-alert py-2",children:b}),!x&&!b&&0===r.length&&(0,E.jsx)("p",{className:"text-sm text-gray-400 py-6 text-center",children:"No testimonials yet."}),r.length>0&&(0,E.jsx)("div",{className:"overflow-x-auto",children:(0,E.jsxs)("table",{className:"w-full text-xs",children:[(0,E.jsx)("thead",{children:(0,E.jsxs)("tr",{className:"text-left text-[10px] uppercase tracking-widest text-gray-400 border-b border-gray-100",children:[(0,E.jsx)("th",{className:"py-2 pr-3",children:"Who"}),(0,E.jsx)("th",{className:"py-2 pr-3",children:"Testimonial"}),(0,E.jsx)("th",{className:"py-2 pr-3",children:"Permission"}),(0,E.jsx)("th",{className:"py-2 pr-3",children:"Status"}),(0,E.jsx)("th",{className:"py-2"})]})}),(0,E.jsx)("tbody",{children:r.map(e=>(0,E.jsxs)("tr",{className:"border-b border-gray-50 align-top",children:[(0,E.jsxs)("td",{className:"py-2 pr-3 whitespace-nowrap",children:[(0,E.jsx)("span",{className:"font-bold text-[#1A1A2E]",children:e.name||"Anonymous"}),e.role&&(0,E.jsx)("span",{className:"block text-gray-400",children:e.role}),(0,E.jsx)("span",{className:"block text-gray-300",children:(e.created_at||"").slice(0,10)})]}),(0,E.jsx)("td",{className:"py-2 pr-3 text-gray-700 max-w-xl whitespace-pre-wrap",children:e.text}),(0,E.jsx)("td",{className:"py-2 pr-3",children:(0,E.jsx)(_,{on:!!e.permission,yes:"granted",no:"not granted"})}),(0,E.jsx)("td",{className:"py-2 pr-3",children:(0,E.jsx)(_,{on:!!e.published,yes:"published",no:"hidden"})}),(0,E.jsxs)("td",{className:"py-2 whitespace-nowrap",children:[(0,E.jsx)("button",{disabled:j===e.id||!e.published&&!e.permission,onClick:()=>(async(e,a)=>{w(e.id);try{const s=await o.FH.sitePagesTestimonialPublish(t,e.id,a);s.ok?N():f(s.error||"Could not update.")}catch(s){f(s.message)}finally{w(null)}})(e,!e.published),className:"text-[11px] font-bold px-2 py-1 rounded border border-gray-200 text-gray-600 hover:border-accent hover:text-accent disabled:opacity-40 mr-1",children:e.published?"Hide":"Publish"}),(0,E.jsx)("button",{disabled:j===e.id,onClick:()=>(async e=>{if(window.confirm("Delete this testimonial? This cannot be undone.")){w(e.id);try{await o.FH.sitePagesTestimonialDelete(t,e.id),N()}catch(a){f(a.message)}finally{w(null)}}})(e),className:"text-[11px] font-bold px-2 py-1 rounded border border-gray-200 text-gray-400 hover:border-alert hover:text-alert disabled:opacity-40",children:(0,E.jsx)(c.A,{className:"w-3 h-3 inline"})})]})]},e.id))})]})})]})}
2function q(e){let t=e.body,a=e.head,s=e.origin,n=e.onChange,r=e.frame,o=void 0===r?null:r;const i=(0,l.useRef)(null),c=(0,l.useRef)(t),d=!(!o||!o.leaf),p=(0,l.useMemo)(()=>'<!doctype html><html><head><meta charset="utf-8">\n<base href="'.concat((s||"").replace(/"/g,""),'/">\n').concat(a||"","\n<style>\n html,body{min-height:100%}\n body{margin:0;padding:").concat(o?"0":"1rem 1.25rem",';cursor:text}\n [data-df-root]:focus{outline:none}\n [data-df-root] *:hover{outline:1px dashed rgba(255,98,40,.45);outline-offset:2px}\n [data-df-root] [contenteditable="true"]:focus{outline:2px solid rgba(255,98,40,.8);outline-offset:2px}\n [data-df-root] img{max-width:100%}\n ').concat(o&&o.contents?"[data-df-root]{display:contents}":"","\n</style></head>\n<body>").concat(o?o.pre:"","<div data-df-root ").concat(d?"":'contenteditable="true"',' spellcheck="true">').concat(t||"","</div>").concat(o?o.post:"","\n<script>\n document.addEventListener('click', function(e){ var a = e.target.closest && e.target.closest('a'); if (a) e.preventDefault(); }, true);\n var root = document.querySelector('[data-df-root]');\n var LEAF = ").concat(d?"true":"false",";\n function armLeaves(){\n if (!LEAF) return;\n root.querySelectorAll('a,p,h1,h2,h3,h4,h5,h6,span,li,small,strong,em,b,i').forEach(function(el){\n var hasBlock = Array.prototype.some.call(el.children, function(c){ return !/^(A|SPAN|STRONG|EM|B|I|SMALL|BR)$/.test(c.tagName); });\n if (!hasBlock && (el.textContent || '').trim()) el.setAttribute('contenteditable', 'true');\n });\n }\n armLeaves(); window.armLeaves = armLeaves;\n var t = null;\n function cleanHtml(){\n var c = root.cloneNode(true);\n c.querySelectorAll('[contenteditable]').forEach(function(el){ el.removeAttribute('contenteditable'); });\n return c.innerHTML;\n }\n root.addEventListener('input', function(){ clearTimeout(t); t = setTimeout(function(){ parent.postMessage({ dfEdit: cleanHtml() }, '*'); }, 250); });\n document.addEventListener('paste', function(e){\n // plain text only, so pasted Word/Docs markup never lands in the site\n e.preventDefault(); var txt = (e.clipboardData || window.clipboardData).getData('text/plain');\n document.execCommand('insertText', false, txt);\n });\n window.addEventListener('message', function(e){\n var d = e.data || {};\n if (d.dfInsertImage) { document.execCommand('insertHTML', false, '<img src=\"' + d.dfInsertImage + '\" alt=\"' + (d.dfAlt || '') + '\" loading=\"lazy\">'); parent.postMessage({ dfEdit: cleanHtml() }, '*'); }\n if (d.dfCmd) { document.execCommand(d.dfCmd, false, d.dfArg || null); parent.postMessage({ dfEdit: cleanHtml() }, '*'); }\n });\n<\/script></body></html>"),[a,s,o,d]);return(0,l.useEffect)(()=>{const e=e=>{var t;if(e.source!==(null===(t=i.current)||void 0===t?void 0:t.contentWindow))return;const a=e.data||{};"string"===typeof a.dfEdit&&(c.current=a.dfEdit,n(a.dfEdit))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[n]),(0,l.useEffect)(()=>{var e;if(t===c.current)return;const a=null===(e=i.current)||void 0===e?void 0:e.contentDocument,s=a&&a.querySelector("[data-df-root]");if(s){s.innerHTML=t||"",c.current=t;try{i.current.contentWindow.armLeaves&&i.current.contentWindow.armLeaves()}catch(n){}}},[t]),(0,E.jsx)("iframe",{ref:i,title:"Visual editor",srcDoc:p,sandbox:"allow-scripts allow-same-origin",className:"w-full rounded-lg border border-gray-200 bg-white",style:{height:"68vh"},onLoad:()=>{c.current=t}})}function G(){const e=(0,C.ip)(),t=e.activeSiteId,a=e.activeSite,c=t||"historyandphysical",f=a&&a.url||L,P=(0,l.useState)("pages"),_=(0,n.A)(P,2),G=_[0],O=_[1],U=(0,l.useState)([]),z=(0,n.A)(U,2),$=z[0],K=z[1],J=(0,l.useState)(null),Q=(0,n.A)(J,2),X=Q[0],Y=Q[1],Z=(0,l.useState)(!0),ee=(0,n.A)(Z,2),te=ee[0],ae=ee[1],se=(0,l.useState)(""),ne=(0,n.A)(se,2),re=ne[0],le=ne[1],oe=(0,l.useState)(null),ie=(0,n.A)(oe,2),ce=ie[0],de=ie[1],pe=(0,l.useState)(""),ue=(0,n.A)(pe,2),xe=ue[0],he=ue[1],me=(0,l.useState)(""),ge=(0,n.A)(me,2),be=ge[0],fe=ge[1],ye=(0,l.useState)(!1),ve=(0,n.A)(ye,2),je=ve[0],we=ve[1],Ne=(0,l.useState)("visual"),ke=(0,n.A)(Ne,2),Ae=ke[0],Se=ke[1],Ce=(0,l.useState)({origin:"",head:""}),Ee=(0,n.A)(Ce,2),Le=Ee[0],He=Ee[1],Pe=(0,l.useState)(0),Te=(0,n.A)(Pe,2),Ie=Te[0],Fe=Te[1],Me=(0,l.useState)(!1),De=(0,n.A)(Me,2),Re=De[0],Be=De[1],_e=(0,l.useState)(null),We=(0,n.A)(_e,2),Ve=We[0],qe=We[1],Ge=(0,l.useState)([]),Oe=(0,n.A)(Ge,2),Ue=Oe[0],ze=Oe[1],$e=(0,l.useState)(""),Ke=(0,n.A)($e,2),Je=Ke[0],Qe=Ke[1],Xe=(0,l.useState)(!1),Ye=(0,n.A)(Xe,2),Ze=Ye[0],et=Ye[1],tt=(0,l.useState)(""),at=(0,n.A)(tt,2),st=at[0],nt=at[1],rt=(0,l.useState)(!1),lt=(0,n.A)(rt,2),ot=lt[0],it=lt[1],ct=(0,l.useRef)(null),dt=(0,l.useMemo)(()=>T(xe),[xe]),pt=dt.seo,ut=dt.body,xt=(0,l.useMemo)(()=>F(ut),[ut]),ht=xt.visual,mt=(xt.scripts,e=>{he(I((0,s.A)((0,s.A)({},pt),e),ut)),qe(null)}),gt=(0,l.useCallback)(e=>{he(t=>I(T(t).seo,e)),qe(null)},[]),bt=(0,l.useCallback)(e=>{he(t=>{const a=T(t),s=a.seo,n=F(a.body).scripts;return I(s,(e||"").replace(/\s+$/,"")+(n||"\n"))}),qe(null)},[]),ft=(0,l.useCallback)(()=>{ae(!0),o.FH.sitePagesList(c).then(e=>{K(e.pages||[]),Y(null)}
2).catch(e=>Y(e.message)).finally(()=>ae(!1))},[c]);(0,l.useEffect)(ft,[ft]),(0,l.useEffect)(()=>{o.FH.sitePagesHead(c).then(He).catch(()=>He({origin:f,head:""}))},[c,f]);const yt=(0,l.useCallback)(e=>{de(e),qe(null),Qe(""),et(!1),we(!0),o.FH.sitePageGet(c,e.part).then(e=>{he(e.content),fe(e.content),Se(M(T(e.content).body)?"html":"visual")}).catch(e=>qe({ok:!1,message:e.message})).finally(()=>we(!1)),o.FH.sitePageBackups(c,e.part).then(e=>ze(e.backups||[])).catch(()=>ze([]))},[c]),vt=ce&&xe!==be,jt=(0,l.useRef)(null);(0,l.useEffect)(()=>{if("visual"!==Ae||!vt||Re)return;const e=setTimeout(()=>{jt.current&&jt.current(!0)},1500);return()=>clearTimeout(e)},[xe,Ae,vt,Re]);const wt=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(ce&&vt&&!Re){Be(!0),qe(null);try{const t=await o.FH.sitePageSave(c,ce.part,xe);t.ok?(fe(xe),Fe(e=>e+1),qe({ok:!0,message:!0===e?"Saved automatically. The change is live.":"Saved. The change is live on the site."}),o.FH.sitePageBackups(c,ce.part).then(e=>ze(e.backups||[])).catch(()=>{})):qe({ok:!1,message:t.error||"The check failed; the change was rolled back."})}catch(t){qe({ok:!1,message:t.message})}finally{Be(!1)}}};jt.current=wt;const Nt=async()=>{if(!(!ce||ot||st.trim().length<3)){it(!0),qe(null);try{const e=await o.FH.sitePageAiEdit(c,ce.part,xe,st.trim());e.ok&&e.content?(he(e.content),qe({ok:!0,message:"AI applied the change in the editor. Review it, then Save to publish."}),nt("")):qe({ok:!1,message:e.error||"AI returned nothing usable."})}catch(e){qe({ok:!1,message:e.message})}finally{it(!1)}}},kt=(e,t)=>{var a;const s=document.querySelector('iframe[title="Visual editor"]');null===s||void 0===s||null===(a=s.contentWindow)||void 0===a||a.postMessage({dfCmd:e,dfArg:t},"*")},At=(0,l.useMemo)(()=>{const e=re.trim().toLowerCase();return e?$.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.fname||"").toLowerCase().includes(e)||t.part.toLowerCase().includes(e)):$},[$,re]),St=(0,l.useMemo)(()=>{const e={};return At.forEach(t=>{const a=function(e){const t=e.part||"";return["nav","footer"].includes(t)?"Site-wide":["insights","podcast","contact","contact-aside"].includes(t)?"Blog, podcast and contact":["privacy","terms"].includes(t)?"Legal":(e.fname||"").includes("/")?"Service pages":e.wired?"Pages":"Unwired"}(t);(e[a]=e[a]||[]).push(t)}),R.filter(t=>{var a;return null===(a=e[t])||void 0===a?void 0:a.length}).map(t=>[t,e[t]])},[At]),Ct=M(ut),Et=[{key:"visual",label:"Visual",Icon:d.A,disabled:Ct},{key:"html",label:"HTML",Icon:p.A},{key:"preview",label:"Live preview",Icon:u.A,disabled:!(null!==ce&&void 0!==ce&&ce.fname)}];return(0,E.jsxs)("div",{children:[(0,E.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,E.jsxs)("div",{children:[(0,E.jsxs)("h1",{className:"text-xl font-black text-[#1A1A2E] flex items-center gap-2",children:[(0,E.jsx)(x.A,{className:"w-5 h-5 text-accent"})," Website"]}),(0,E.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"pages"===G?"Every page of ".concat(a&&a.label||"your site",": pages, service pages, navigation, footer, blog and podcast headers, contact and legal. Edit visually, in HTML, or ask AI. Saving publishes to the live site; a failed check rolls back automatically."):"Visitor feedback from the site. Only testimonials whose writer checked the permission box can be published."})]}),(0,E.jsxs)("div",{className:"flex items-center gap-2",children:[(0,E.jsx)("button",{onClick:()=>O("pages"===G?"testimonials":"pages"),className:"flex items-center gap-1.5 px-3 py-2 text-xs font-bold rounded-lg border ".concat("testimonials"===G?"border-accent text-accent bg-accent/5":"border-gray-200 text-gray-600 hover:border-gray-300"),children:"pages"===G?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h.A,{className:"w-3.5 h-3.5"})," Testimonials"]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.A,{className:"w-3.5 h-3.5"})," Pages"]})}),"pages"===G&&(0,E.jsxs)("button",{onClick:async()=>{if(!Re){Be(!0),qe(null);try{const e=await o.FH.sitePagesRebuild(c);qe(e.ok?{ok:!0,message:"Site checked and rebuilt."}:{ok:!1,message:e.error||e.output||"Build failed."})}catch(e){qe({ok:!1,message:e.message})}finally{Be(!1)}}},disabled:Re,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-bold rounded-lg border border-gray-200 text-gray-600 hover:border-gray-300 disabled:opacity-50",children:[Re?(0,E.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,E.jsx)(g.A,{className:"w-3.5 h-3.5"}
2),"Check site"]})]})]}),"testimonials"===G&&(0,E.jsx)(V,{siteId:c}),"pages"===G&&(0,E.jsx)(W,{siteId:c}),(0,E.jsxs)("div",{className:"pages"===G?"grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-4 items-start":"hidden",children:[(0,E.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-3",children:[(0,E.jsxs)("div",{className:"relative mb-2",children:[(0,E.jsx)(b.A,{className:"w-3.5 h-3.5 text-gray-300 absolute left-2.5 top-1/2 -translate-y-1/2"}),(0,E.jsx)("input",{type:"text",value:re,placeholder:"Search pages\u2026",onChange:e=>le(e.target.value),className:"w-full border border-gray-200 rounded-lg pl-8 pr-3 py-2 text-sm focus:outline-none focus:border-accent",style:{color:"#1A1A2E"}})]}),te&&(0,E.jsxs)("p",{className:"text-xs text-gray-400 flex items-center gap-1.5 px-1 py-2",children:[(0,E.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"})," Loading pages\u2026"]}),X&&(0,E.jsx)("p",{className:"text-xs text-alert px-1 py-2",children:X}),(0,E.jsxs)("div",{className:"max-h-[72vh] overflow-y-auto pr-0.5",children:[St.map(e=>{let t=(0,n.A)(e,2),a=t[0],s=t[1];return(0,E.jsxs)("div",{className:"mb-2",children:[(0,E.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-400 px-2 pt-2 pb-1",children:a}),s.map(e=>(0,E.jsx)(B,{page:e,active:(null===ce||void 0===ce?void 0:ce.part)===e.part,onClick:()=>yt(e)},e.part))]},a)}),!te&&!X&&0===At.length&&(0,E.jsx)("p",{className:"text-xs text-gray-400 px-1 py-2",children:"No pages match."})]})]}),(0,E.jsx)("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:ce?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-3",children:[(0,E.jsxs)("div",{className:"min-w-0",children:[(0,E.jsx)("p",{className:"text-sm font-bold text-[#1A1A2E] truncate",children:ce.title||ce.part}),(0,E.jsxs)("p",{className:"text-[11px] text-gray-400",children:[ce.fname?H(f,ce.fname).replace(/^https?:\/\//,""):"parts/".concat(ce.part,".html (not wired to a page)"),vt&&(0,E.jsx)("span",{className:"ml-2 text-amber-600 font-bold",children:"unsaved changes"})]})]}),(0,E.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[ce.fname&&(0,E.jsxs)("a",{href:H(f,ce.fname),target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-xs font-bold text-accent hover:underline",children:[(0,E.jsx)(v.A,{className:"w-3.5 h-3.5"})," Open live"]}),(0,E.jsxs)("button",{onClick:wt,disabled:Re||!vt||je,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-bold rounded-lg bg-accent text-white hover:opacity-90 disabled:opacity-50",children:[Re?(0,E.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,E.jsx)(j.A,{className:"w-3.5 h-3.5"}),Re?"Publishing\u2026":"Save & publish"]})]})]}),(0,E.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-3",children:[(0,E.jsx)("div",{className:"flex items-center gap-1 bg-gray-50 rounded-lg p-1",children:Et.map(e=>{let t=e.key,a=e.label,s=e.Icon,n=e.disabled;return(0,E.jsxs)("button",{disabled:n,onClick:()=>Se(t),title:n&&"visual"===t?"This page embeds a script block, so it is edited as HTML.":"",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold rounded-md transition disabled:opacity-40 ".concat(Ae===t?"bg-white shadow-sm text-[#1A1A2E]":"text-gray-500 hover:text-[#1A1A2E]"),children:[(0,E.jsx)(s,{className:"w-3.5 h-3.5"})," ",a]},t)})}),(0,E.jsxs)("div",{className:"flex items-center gap-1.5",children:["visual"===Ae&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("button",{onClick:()=>kt("bold"),className:"px-2 py-1.5 text-xs font-black rounded border border-gray-200 text-gray-600 hover:border-gray-300",title:"Bold",children:"B"}),(0,E.jsx)("button",{onClick:()=>kt("italic"),className:"px-2 py-1.5 text-xs italic rounded border border-gray-200 text-gray-600 hover:border-gray-300",title:"Italic",children:"I"}),(0,E.jsx)("button",{onClick:()=>{const e=window.prompt("Link address (for example /contact or https://\u2026):");e&&kt("createLink",e)},className:"px-2 py-1.5 text-xs rounded border border-gray-200 text-gray-600 hover:border-gray-300",title:"Link",children:"Link"}),(0,E.jsx)("button",{onClick:()=>kt("unlink"),className:"px-2 py-1.5 text-xs rounded border border-gray-200 text-gray-600 hover:border-gray-300",title:"Remove link",children:"Unlink"})]}),(0,E.jsx)("input",{ref:ct,type:"file",accept:"image/*",className:"hidden",onChange:e=>{var t;return(async t=>{if(t){Be(!0),qe(null);try{const e=await o.FH.sitePageUpload(c,t);if(e.ok){const t=window.prompt("Describe the image for search engines and screen readers (alt text):","")||"",a=document.querySelector('iframe[title="Visual editor"]');
2"visual"===Ae&&null!==a&&void 0!==a&&a.contentWindow?a.contentWindow.postMessage({dfInsertImage:e.url,dfAlt:t.replace(/"/g,"")},"*"):gt((ut||"")+'\n<img src="'.concat(e.url,'" alt="').concat(t.replace(/"/g,""),'" loading="lazy">\n')),qe({ok:!0,message:"Uploaded ".concat(e.name,". Position it, then Save.")})}}catch(e){qe({ok:!1,message:e.message})}finally{Be(!1),ct.current&&(ct.current.value="")}}})(null===(t=e.target.files)||void 0===t?void 0:t[0])}}),(0,E.jsxs)("button",{onClick:()=>{var e;return null===(e=ct.current)||void 0===e?void 0:e.click()},disabled:Re,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold rounded-lg border border-gray-200 text-gray-600 hover:border-gray-300 disabled:opacity-50",children:[(0,E.jsx)(w,{className:"w-3.5 h-3.5"})," Image"]}),(0,E.jsxs)("button",{onClick:()=>et(e=>!e),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold rounded-lg border ".concat(Ze?"border-accent text-accent bg-accent/5":"border-gray-200 text-gray-600 hover:border-gray-300"),children:[(0,E.jsx)(N.A,{className:"w-3.5 h-3.5"})," Ask AI"]})]})]}),Ze&&(0,E.jsxs)("div",{className:"mb-3 rounded-lg border border-accent/30 bg-accent/5 p-3",children:[(0,E.jsx)("p",{className:"text-xs font-bold text-[#1A1A2E] mb-1",children:"Describe the change"}),(0,E.jsx)("p",{className:"text-[11px] text-gray-500 mb-2",children:'For example: "Shorten the intro to two sentences", "Add a paragraph about telehealth after the first section", "Change the button to say Book a call". The result appears in the editor for review; nothing is published until you save.'}),(0,E.jsxs)("div",{className:"flex gap-2",children:[(0,E.jsx)("input",{type:"text",value:st,onChange:e=>nt(e.target.value),onKeyDown:e=>{"Enter"===e.key&&Nt()},placeholder:"What should change on this page?",className:"flex-1 border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-accent",style:{color:"#1A1A2E"}}),(0,E.jsxs)("button",{onClick:Nt,disabled:ot||st.trim().length<3,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-bold rounded-lg bg-[#1A1A2E] text-white hover:opacity-90 disabled:opacity-50",children:[ot?(0,E.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,E.jsx)(N.A,{className:"w-3.5 h-3.5"}),ot?"Working\u2026":"Apply"]})]})]}),(ce.fname||pt.title||pt.description)&&(0,E.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mb-3",children:[(0,E.jsxs)("label",{className:"block",children:[(0,E.jsxs)("span",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-400",children:["Search title",(0,E.jsx)(r.A,{k:"SitePagesAdmin.js:Search title"})]}),(0,E.jsx)("input",{type:"text",value:pt.title,onChange:e=>mt({title:e.target.value}),placeholder:"Shown in Google and the browser tab",className:"mt-1 w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-accent",style:{color:"#1A1A2E"}})]}),(0,E.jsxs)("label",{className:"block",children:[(0,E.jsxs)("span",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-400",children:["Search description ",(0,E.jsxs)("span",{className:"normal-case tracking-normal text-gray-300",children:["(",pt.description.length,"/160)"]})]}),(0,E.jsx)("input",{type:"text",value:pt.description,onChange:e=>mt({description:e.target.value}),placeholder:"One or two sentences shown under the title in search results",className:"mt-1 w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-accent",style:{color:"#1A1A2E"}})]})]}),je?(0,E.jsxs)("p",{className:"text-xs text-gray-400 flex items-center gap-1.5 py-6",children:[(0,E.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"})," Loading page\u2026"]}):"visual"===Ae?(0,E.jsx)(q,{body:ht,head:Le.head,origin:Le.origin||f,onChange:bt,frame:D[null===ce||void 0===ce?void 0:ce.part]||null}):"preview"===Ae?(0,E.jsx)("iframe",{title:"Live preview",src:"".concat(H(f,ce.fname)).concat(ce.fname&&ce.fname.includes("?")?"&":"?","_df=").concat(Ie),className:"w-full rounded-lg border border-gray-200 bg-white",style:{height:"68vh"}},Ie):(0,E.jsx)("textarea",{value:xe,spellCheck:!1,onChange:e=>{he(e.target.value),qe(null)},rows:26,className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-xs leading-relaxed focus:outline-none focus:border-accent font-mono",style:{color:"#1A1A2E",tabSize:2,minHeight:"60vh"}}),Ve&&(0,E.jsxs)("div",{className:"mt-3 rounded-lg p-3 border ".concat(Ve.ok?"bg-green-50 border-green-100":"bg-red-50 border-red-100"),children:[(0,E.jsxs)("p",{className:"text-xs font-bold flex items-center gap-1.5 ".concat(Ve.ok?"text-[#1A1A2E]":"text-alert"),children:[Ve.ok?(0,E.jsx)(k.A,{className:"w-3.5 h-3.5 text-success"}):(0,E.jsx)(A.A,{className:"w-3.5 h-3.5"}),Ve.ok?"Done":"Not applied"]}),(0,E.jsx)("p",{className:"text-[11px] text-gray-500 mt-1 whitespace-pre-wrap break-words",children:Ve.message})]}),(0,E.jsxs)("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-gray-100",children:[(0,E.jsxs)("span",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-400",children:["Versions",(0,E.jsx)(r.A,{k:"SitePagesAdmin.js:Versions"})]}),(0,E.jsxs)("select",{value:Je,disabled:0===Ue.length,onChange:e=>Qe(e.target.value),className:"border border-gray-200 rounded-lg px-2 py-1.5 text-xs focus:outline-none focus:border-accent",style:{color:"#1A1A2E"},children:[(0,E.jsx)("option",{value:"",children:0===Ue.length?"No earlier versions yet":"".concat(Ue.length," earlier version").concat(1===Ue.length?"":"s","\u2026")}),Ue.map(e=>(0,E.jsx)("option",{value:e.timestamp,children:e.mtime||e.timestamp},e.timestamp))]}),(0,E.jsxs)("button",{onClick:async()=>
2{if(ce&&Je&&!Re){Be(!0),qe(null);try{const e=await o.FH.sitePageRestore(c,ce.part,Je);if(e.ok){const e=await o.FH.sitePageGet(c,ce.part);he(e.content),fe(e.content),Fe(e=>e+1),qe({ok:!0,message:"Restored the version from ".concat(Je,". It is live.")}),o.FH.sitePageBackups(c,ce.part).then(e=>ze(e.backups||[])).catch(()=>{})}else qe({ok:!1,message:e.error||"The check failed; the restore was undone."})}catch(e){qe({ok:!1,message:e.message})}finally{Be(!1)}}},disabled:Re||!Je,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold rounded-lg border border-gray-200 text-gray-600 hover:border-gray-300 disabled:opacity-50",children:[(0,E.jsx)(S.A,{className:"w-3.5 h-3.5"})," Restore this version"]}),vt&&(0,E.jsx)("button",{onClick:()=>{he(be),qe(null)},className:"ml-auto text-xs font-bold text-gray-400 hover:text-[#1A1A2E]",children:"Discard changes"})]})]}):(0,E.jsxs)("div",{className:"py-12 text-center",children:[(0,E.jsx)(y,{className:"w-8 h-8 text-gray-200 mx-auto mb-2"}),(0,E.jsx)("p",{className:"text-sm text-gray-400",children:"Pick a page on the left. Edit it visually, in HTML, or describe the change and let AI make it."})]})})]})]})}}}]);
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.