@krantho/studio 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantPanel-ECkcslXS.js → AssistantPanel-DpYeurU-.js} +1 -1
- package/dist/assets/{GraphBrowser-BBKTzzRV.js → GraphBrowser-Cm5q82MJ.js} +2 -2
- package/dist/assets/{GraphCanvas-Cct1E2As.js → GraphCanvas-CZJNUa_J.js} +1 -1
- package/dist/assets/{api-seo-CwGP6Bi2.js → api-seo-DeG5gsh6.js} +1 -1
- package/dist/assets/{collection-view--erTGbRH.js → collection-view-Bbr6ff-2.js} +1 -1
- package/dist/assets/{editor-page-XOJrwlcZ.js → editor-page-ydSt1TIL.js} +3 -3
- package/dist/assets/{fill-job-YPZFETW1.js → fill-job-CKtHKXwV.js} +1 -1
- package/dist/assets/{fill-run-view-B6rnYhKS.js → fill-run-view-ChrOLoV4.js} +1 -1
- package/dist/assets/{graph-config-DKVGDPTG.js → graph-config-CgXhm7XP.js} +1 -1
- package/dist/assets/{image-editor-BX-DHJDa.js → image-editor-CAZbOhRZ.js} +1 -1
- package/dist/assets/{index-CEQ7ZdKC.js → index-d5j-az5g.js} +2 -2
- package/dist/assets/{live-markdown-editor-DM8hYG3n.js → live-markdown-editor-DSsCNBWR.js} +1 -1
- package/dist/assets/{media-page-CeBC5FQS.js → media-page-DuSUjFO1.js} +1 -1
- package/dist/assets/{pulse-page-C00oCF2o.js → pulse-page-zRYAQJh6.js} +1 -1
- package/dist/assets/{setup-page-BHJcTaTH.js → setup-page-CshRkFJ-.js} +1 -1
- package/dist/assets/{site-BYsfQB_3.js → site-CGs9-oiw.js} +1 -1
- package/dist/assets/{site-model-C5bJvTbk.js → site-model-BXHOxNij.js} +1 -1
- package/dist/assets/{site-overview-5EhmXIR0.js → site-overview-B0Dnsj2N.js} +1 -1
- package/dist/assets/{structure-page-9d9MG7vU.js → structure-page-DpM1G-M9.js} +2 -2
- package/dist/assets/{use-drawer-actions-CR6Q0qdd.js → use-drawer-actions-BeAi2hJS.js} +1 -1
- package/dist/assets/{use-loaded-BBFak2E1.js → use-loaded-BNCu0C-c.js} +1 -1
- package/dist/assets/{use-locale-versions-BycCbBLd.js → use-locale-versions-CcJ_us1I.js} +1 -1
- package/dist/assets/vendor-markdown-BeOOOWTF.js +74 -0
- package/dist/index.html +1 -1
- package/package.json +5 -5
- package/dist/assets/vendor-markdown-pd8vs9n-.js +0 -74
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{i as r,n as i,t as a}from"./fill-run-view-B6rnYhKS.js";import{A as o,E as s,G as c,I as l,K as u,O as d,Ot as f,R as p,T as m,Tt as ee,V as te,W as ne,X as re,Z as ie,_ as ae,at as oe,b as se,ct as ce,d as h,dt as le,et as g,f as _,ft as ue,ht as de,k as v,nt as fe,o as pe,ot as me,pt as he,q as ge,rt as _e,s as y,v as ve,w as ye,y as be}from"./index-CEQ7ZdKC.js";import{i as b}from"./auth-CIpilSKF.js";import{n as xe,t as x}from"./use-loaded-BBFak2E1.js";import{n as S,t as C}from"./createLucideIcon-BklFHeMd.js";import{t as w}from"./trash-DzRCm500.js";import{t as T}from"./action-button-DIrhqMRc.js";import{c as Se,o as Ce,y as we}from"./api-seo-CwGP6Bi2.js";import{t as Te}from"./list-checks-BCEhMMVY.js";import{a as Ee,i as De,n as Oe,r as ke,s as Ae,t as je,u as Me}from"./fill-job-YPZFETW1.js";import{d as Ne,l as Pe,n as Fe,r as E,t as D,u as Ie}from"./format-C3ZX9yGM.js";import{t as O}from"./data-table-B1kqxrEw.js";import{t as Le}from"./empty-state-CeUZocHx.js";import{r as Re,t as ze}from"./vendor-router-B4czwg8X.js";import{t as Be}from"./guards-BFEDbduR.js";import{t as Ve}from"./source-CGZGd3Xy.js";import{t as He}from"./pencil-xdGZtrO4.js";import{t as Ue}from"./copy-V85khWct.js";import{t as We}from"./clock-DoBIVjZO.js";import{t as Ge}from"./send-kYpW5JED.js";import{i as k,t as Ke}from"./api-client-BRi_ki2Y.js";import{t as qe}from"./use-locale-versions-BycCbBLd.js";var Je={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Je.node;var Ye=C(Je),Xe={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};Xe.node;var Ze=C(Xe),Qe={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Qe.node;var $e=C(Qe),et={name:`list-tree`,size:24,node:[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]};et.node;var tt=C(et),nt={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};nt.node;var rt=C(nt),it={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};it.node;var at=C(it),ot={name:`refresh-ccw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]};ot.node;var st=C(ot),ct={name:`user-plus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};ct.node;var lt=C(ct);async function ut(){let{users:e}=await k(`/users`);return e}async function dt(e){return k(`/users`,{method:`POST`,body:JSON.stringify(e)})}async function A(e,t){return k(`/users/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)})}async function ft(e){await k(`/users/${encodeURIComponent(e)}`,{method:`DELETE`})}var pt={anthropic:{label:`Claude`,vendor:`Anthropic`,format:`anthropic`,baseUrl:`https://api.anthropic.com`,defaultModel:`claude-haiku-4-5`,chatPath:`/v1/messages`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`},"claude-code":{label:`Claude Code`,vendor:`Anthropic`,format:`anthropic`,baseUrl:`https://api.anthropic.com`,defaultModel:`claude-haiku-4-5-20251001`,chatPath:`/v1/messages`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`},openai:{label:`ChatGPT`,vendor:`OpenAI`,format:`openai`,baseUrl:`https://api.openai.com`,defaultModel:`gpt-4o`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_completion_tokens`,forbidTools:`tool_choice`,openObjects:`native`,reasoningParam:`reasoning_effort`},gemini:{label:`Gemini`,vendor:`Google`,format:`openai`,baseUrl:`https://generativelanguage.googleapis.com/v1beta/openai`,defaultModel:`gemini-3.6-flash`,chatPath:`/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`json_string`,reasoningParam:`reasoning_effort`},openrouter:{label:`OpenRouter`,vendor:`OpenRouter`,format:`openai`,baseUrl:`https://openrouter.ai/api`,defaultModel:`anthropic/claude-haiku-4.5`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`,reasoningParam:`reasoning`},ollama:{label:`Ollama`,vendor:`Ollama (on your own computer)`,format:`openai`,baseUrl:`http://localhost:11434`,defaultModel:`llama3.1`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`omit_tools`,openObjects:`native`,reasoningParam:`reasoning_effort`}},j=e(n(),1),mt=`claude-code`,ht=[`openrouter`,mt,`ollama`];function gt(e){return Object.hasOwn(pt,e)}function M(e){return gt(e)?pt[e]:null}function N(e){return M(e)?.label??e}function _t(e){return M(e)?.vendor??e}function vt(e){return ht.includes(e)}function yt(e){return e.providers.filter(e=>e.ready).sort((e,t)=>Number(t.active)-Number(e.active))}function bt(e){return e.providers.filter(e=>!e.ready&&!vt(e.provider))}function xt(e){return e.providers.filter(e=>!e.ready&&vt(e.provider))}function St(e,t=!0){return!e.configured||!e.provider?t?`AI help is off. Add a key below to turn it on.`:`AI help is off. An admin can add a key to turn it on.`:`AI help is on, using ${N(e.provider)}.`}function Ct(e){return!e.configured||!e.provider?`The AI`:`${N(e.provider)} · ${e.model??`its default model`}`}function wt(e){return e===`saved`?`Key saved here, encrypted.`:e===`environment`||e===`configuration`?`Set up by your developer.`:`Runs on your own computer.`}var Tt=/401|403|unauthori[sz]ed|invalid|incorrect|api[ -]?key|permission/i;function Et(e,t){let n=N(e);return t.success?`${n} works: it answered.`:Tt.test(t.error??``)?`${n} did not accept the key. Check that you copied all of it.`:`${n} did not answer: ${t.error??`no reason given`}.`}function P(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(!1);async function r(e){if(!n.current){n.current=!0,t(!0);try{await e()}finally{n.current=!1,t(!1)}}}return{busy:e,once:r}}function F(){let{busy:e,once:t}=P(),[n,r]=(0,j.useState)(null);return{busy:e,error:n,setError:r,run:(e,n)=>t(async()=>{r(null);try{await e()}catch(e){r(_(e,n))}})}}function Dt(e){let t=g(),{busy:n,once:r}=P();function i(e,n){r(async()=>{try{await e()}catch(e){t({text:_(e,n),tone:`error`})}})}async function a(e){let n=await d(e);t({text:Et(e,n),tone:n.success?`success`:`error`})}return{busy:n,turnOn:t=>i(async()=>{e(await v(t)),await a(t.provider)},`The key could not be saved`),use:n=>i(async()=>{e(await v({provider:n,use:!0})),t({text:`The site now uses ${N(n)}.`})},`The AI could not be changed`),save:n=>i(async()=>{e(await v(n)),t({text:`Saved the settings for ${N(n.provider)}.`})},`The settings could not be saved`),test:e=>i(()=>a(e),`The test failed`)}}var I=t();function L({title:e,children:t,confirmLabel:n,danger:r=!1,onConfirm:i,onClose:a}){let o=(0,j.useRef)(null),{busy:s,error:c,run:l}=F(),u=s?()=>void 0:a;return(0,I.jsxs)(h,{title:e,onClose:u,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{ref:o,onClick:u,"aria-disabled":s,children:`Cancel`}),(0,I.jsx)(S,{variant:r?`danger`:`primary`,"aria-disabled":s,onClick:()=>void l(i,`It did not work`),children:s?`Working…`:n})]}),initialFocus:o,busy:s,children:[(0,I.jsx)(`div`,{className:`setup-confirm`,children:t}),c&&(0,I.jsx)(R,{text:c})]})}function R({text:e}){return(0,I.jsx)(`p`,{role:`alert`,className:`setup-note setup-note--error`,children:e})}function Ot({id:e,label:t,hint:n,children:r}){return(0,I.jsxs)(`div`,{className:`setup-field`,children:[(0,I.jsx)(`label`,{htmlFor:e,children:t}),r,n&&(0,I.jsx)(`span`,{id:`${e}-hint`,className:`setup-hint`,children:n})]})}function z({label:e,value:t,onChange:n,disabled:r=!1,hint:i,type:a=`text`,placeholder:o}){let s=(0,j.useId)();return(0,I.jsx)(Ot,{id:s,label:e,hint:i,children:(0,I.jsx)(`input`,{id:s,type:a,className:`setup-input`,value:t,disabled:r,placeholder:o,"aria-describedby":i?`${s}-hint`:void 0,onChange:e=>n(e.target.value)})})}function B({label:e,value:t,onChange:n,disabled:r=!1,hint:i,options:a}){let o=(0,j.useId)(),s=e=>{let t=a.find(t=>t.value===e);t&&n(t.value)};return(0,I.jsx)(Ot,{id:o,label:e,hint:i,children:(0,I.jsx)(`select`,{id:o,className:`setup-input`,value:t,disabled:r,"aria-describedby":i?`${o}-hint`:void 0,onChange:e=>s(e.target.value),children:a.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})})}function kt({label:e,checked:t,onChange:n}){return(0,I.jsxs)(`label`,{className:`setup-check`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),e]})}function At({provider:e}){return(0,I.jsxs)(`div`,{className:`ai-card-title`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e)}),(0,I.jsx)(`span`,{className:`setup-muted`,children:_t(e)})]})}function jt({provider:e,onRemoved:t,onClose:n}){let r=g();async function i(){t(await ye(e)),r({text:`Removed the saved key for ${N(e)}.`}),n()}return(0,I.jsx)(L,{title:`Remove the key for ${N(e)}?`,confirmLabel:`Remove key`,danger:!0,onConfirm:i,onClose:n,children:(0,I.jsx)(`p`,{children:`The key saved here is deleted, and it cannot be shown again: you would have to paste it anew. A key set up by your developer is not touched.`})})}function Mt({status:e,actions:t}){let n=M(e.provider),[r,i]=(0,j.useState)(e.model??``),[a,o]=(0,j.useState)(e.baseUrl??``),s=e.provider===mt;return(0,I.jsxs)(`details`,{className:`ai-advanced`,children:[(0,I.jsx)(`summary`,{children:`Advanced`}),(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsx)(z,{label:`Model`,value:s?n?.defaultModel??``:r,onChange:i,disabled:s,placeholder:n?.defaultModel,hint:s?`Fixed: this one runs a single model.`:`Empty uses the default model.`}),(0,I.jsx)(z,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl,hint:`Only for a proxy or your own server. Empty uses the usual address.`}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(S,{"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a}),children:`Save`})})]})]})}function Nt({status:e,actions:t,readOnly:n,onChange:r}){let[i,a]=(0,j.useState)(!1),o=t.busy?`Working…`:null;return(0,I.jsxs)(`li`,{className:`ai-card ai-card--on`,children:[(0,I.jsxs)(`div`,{className:`ai-card-head`,children:[(0,I.jsx)(At,{provider:e.provider}),e.active&&(0,I.jsx)(y,{tone:`success`,icon:xe,children:`In use`})]}),(0,I.jsx)(`p`,{className:`setup-note`,children:wt(e.keySource)}),!n&&(0,I.jsxs)(`div`,{className:`setup-actions`,children:[!e.active&&(0,I.jsx)(T,{variant:`primary`,icon:at,reason:o,onClick:()=>t.use(e.provider),children:`Use this one`}),(0,I.jsx)(T,{icon:rt,reason:o,onClick:()=>t.test(e.provider),children:`Test`}),e.keySource===`saved`&&(0,I.jsx)(S,{variant:`ghost`,icon:w,onClick:()=>a(!0),children:`Remove key`})]}),!n&&(0,I.jsx)(Mt,{status:e,actions:t}),i&&(0,I.jsx)(jt,{provider:e.provider,onRemoved:r,onClose:()=>a(!1)})]})}function Pt({status:e,actions:t}){let[n,r]=(0,j.useState)(``),i=N(e.provider),a=()=>{t.turnOn({provider:e.provider,apiKey:n}),r(``)},o=t.busy?`Working…`:n.trim()===``?`Paste the key first.`:null;return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`div`,{className:`ai-card-head`,children:(0,I.jsx)(At,{provider:e.provider})}),(0,I.jsx)(z,{label:`${i} key`,type:`password`,value:n,onChange:r,hint:`Paste the key from ${_t(e.provider)}. It is saved encrypted and never shown again.`}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(T,{variant:`primary`,icon:$e,reason:o,onClick:a,children:`Turn on`})})]})}function Ft({status:e}){return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e.provider)}),(0,I.jsxs)(`p`,{className:`setup-note`,children:[`Runs on your Claude subscription, on your own machine only. Set the token`,` `,(0,I.jsx)(`code`,{children:`claude setup-token`}),` prints as `,(0,I.jsx)(`code`,{children:e.env}),`, and restart the site.`]})]})}function It({status:e,actions:t}){let n=M(e.provider),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)(``);return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e.provider)}),(0,I.jsx)(`p`,{className:`setup-note`,children:`Runs a model on your own computer. It needs no key.`}),(0,I.jsx)(z,{label:`Model`,value:r,onChange:i,placeholder:n?.defaultModel}),(0,I.jsx)(z,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(S,{variant:`primary`,"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a,use:!0}),children:`Turn on`})})]})}function Lt({status:e,actions:t}){return e.provider===`claude-code`?(0,I.jsx)(Ft,{status:e}):e.provider===`ollama`?(0,I.jsx)(It,{status:e,actions:t}):(0,I.jsx)(Pt,{status:e,actions:t})}function Rt({settings:e,providers:t,actions:n}){let r=e.providers.filter(e=>e.env!==``);return(0,I.jsxs)(`details`,{className:`ai-developer`,children:[(0,I.jsx)(`summary`,{children:`For developers`}),(0,I.jsxs)(`div`,{className:`setup-stack`,children:[t.length>0&&(0,I.jsx)(`ul`,{className:`ai-cards`,children:t.map(e=>(0,I.jsx)(Lt,{status:e,actions:n},e.provider))}),(0,I.jsxs)(`div`,{className:`setup-prose`,children:[(0,I.jsx)(`p`,{children:`A key can also be set in the environment of the machine that runs the site. A provider with a key there turns on at the next start, and no key is saved in the database.`}),(0,I.jsx)(`ul`,{className:`ai-variables`,children:r.map(e=>(0,I.jsxs)(`li`,{children:[N(e.provider),`: `,(0,I.jsx)(`code`,{children:e.env})]},e.provider))})]})]})]})}var zt={config:{icon:Ze,label:`Configuration`},database:{icon:Ye,label:`Database`},server:{icon:_e,label:`Server`}};function V({source:e,children:t}){let{icon:n,label:r}=zt[e];return(0,I.jsxs)(`p`,{className:`setup-source`,children:[(0,I.jsx)(y,{icon:n,children:r}),(0,I.jsx)(`span`,{children:t})]})}function H({title:e,sources:t,actions:n,children:r}){let i=(0,j.useId)();return(0,I.jsxs)(`section`,{className:`setup-section`,"aria-labelledby":i,children:[(0,I.jsxs)(`div`,{className:`setup-section-head`,children:[(0,I.jsx)(`h2`,{id:i,className:`setup-section-title`,children:e}),n&&(0,I.jsx)(`div`,{className:`setup-actions`,children:n})]}),(0,I.jsx)(`div`,{className:`setup-sources`,children:t}),r]})}function U({children:e,tone:t=`muted`}){return(0,I.jsx)(`p`,{className:t===`error`?`setup-note setup-note--error`:`setup-note`,children:e})}function W({what:e}){return(0,I.jsxs)(U,{children:[`Reading `,e,`…`]})}function G({message:e,onRetry:t}){return(0,I.jsxs)(`div`,{role:`alert`,className:`setup-row`,children:[(0,I.jsx)(U,{tone:`error`,children:e}),(0,I.jsx)(S,{size:`sm`,icon:we,onClick:t,children:`Try again`})]})}var Bt=new Map([[je,`Fill missing SEO`],[ke,`Meta only`],[Oe,`Force regenerate`]]);function Vt(e){return e.scope===`collection`?`${D(e.collection)}`:`the whole site`}function Ht(e){let t=e.state===`idle`?`Enrichment`:Bt.get(e.plan)??`Enrichment`;return e.state===`failed`?{text:`${t} failed: ${e.message}`,tone:`error`}:{text:`${t} finished. Setup › AI provider lists what each step did.`}}function Ut(){return(0,I.jsxs)(`div`,{className:`setup-prose`,children:[(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`strong`,{children:`Fill missing SEO`}),` writes meta descriptions and the Schema.org properties no one has set. `,(0,I.jsx)(`strong`,{children:`Meta only`}),` writes only the missing meta descriptions. Neither overwrites a value someone set. `,(0,I.jsx)(`strong`,{children:`Force regenerate`}),` writes both over every value, the editors' own included.`]}),(0,I.jsx)(`p`,{children:`What a run writes is saved at once: each meta description as a new version of its document and in the document's SEO settings, the Schema.org properties in those settings. The SEO settings have no versions, so the live pages' meta descriptions and structured data change straight away. A document someone else is editing keeps its meta description.`})]})}function Wt({scope:e,model:t,onConfirm:n,onClose:r}){return(0,I.jsxs)(L,{title:`Force regenerate SEO for ${Vt(e)}?`,confirmLabel:`Overwrite and regenerate`,danger:!0,onConfirm:n,onClose:r,children:[(0,I.jsxs)(`p`,{children:[t,` writes a new meta description and new Schema.org properties for every document in`,` `,Vt(e),`. It`,` `,(0,I.jsx)(`strong`,{children:`overwrites the values there now, the editors' own included`}),`.`]}),(0,I.jsx)(`p`,{children:`Each meta description is saved as a new version of its document and in the document's SEO settings; the Schema.org properties are written to those settings, which have no versions. The live pages' meta descriptions and structured data change at once: this is not a draft, there is nothing to publish first, and the SEO settings keep no earlier values to go back to. A document someone else is editing keeps its meta description.`})]})}function Gt(e,t,n){return e.state===`running`?`Enrichment is running.`:t?n?null:`Add an AI key first.`:`Enrichment is run by an admin.`}function Kt({reason:e,onRun:t,onForce:n}){return(0,I.jsxs)(`div`,{className:`setup-actions`,children:[(0,I.jsx)(T,{variant:`primary`,icon:Me,reason:e,onClick:()=>t(je),children:`Fill missing SEO`}),(0,I.jsx)(T,{icon:Te,reason:e,onClick:()=>t(ke),children:`Meta only`}),(0,I.jsx)(T,{variant:`danger`,icon:st,reason:e,onClick:n,children:`Force regenerate…`})]})}function qt(){let{loaded:e}=x(te,`The collections could not be read`);return e.state===`ready`?e.data.filter(e=>e.pages):[]}var Jt=(0,I.jsx)(V,{source:`database`,children:`Writes to the documents and their SEO settings in the site's database, with the AI in use above.`});function Yt({configured:e,admin:t,model:n}){let r=g(),o=Ae(),s=qt(),[c,l]=(0,j.useState)({scope:`all`}),[u,d]=(0,j.useState)(!1);(0,j.useEffect)(()=>()=>De(),[]);let f=(0,j.useCallback)(e=>Ee(c,e=>r(Ht(e)),e),[c,r]),p=Gt(o,t,e),m=o.state===`running`;return(0,I.jsxs)(H,{title:`Run across the site`,sources:Jt,children:[(0,I.jsx)(Ut,{}),(0,I.jsx)(i,{collections:s,value:c,disabled:m,onChange:l}),(0,I.jsx)(Kt,{reason:p,onRun:f,onForce:()=>d(!0)}),p&&!m&&(0,I.jsx)(`p`,{className:`setup-note`,children:p}),(0,I.jsx)(a,{run:o}),u&&(0,I.jsx)(Wt,{scope:c,model:n,onClose:()=>d(!1),onConfirm:async()=>{d(!1),f(Oe)||r({text:`Another run is going across the site, so Force regenerate did not start. Try again when it ends.`,tone:`error`})}})]})}function Xt({settings:e,readOnly:t,onChange:n}){let r=Dt(n),i=yt(e),a=bt(e);return(0,I.jsxs)(I.Fragment,{children:[i.length>0&&(0,I.jsxs)(`section`,{className:`ai-group`,"aria-labelledby":`ai-configured`,children:[(0,I.jsx)(`h3`,{id:`ai-configured`,className:`ai-group-title`,children:`Ready to use`}),(0,I.jsx)(`ul`,{className:`ai-cards`,children:i.map(e=>(0,I.jsx)(Nt,{status:e,actions:r,readOnly:t,onChange:n},e.provider))})]}),!t&&a.length>0&&(0,I.jsxs)(`section`,{className:`ai-group`,"aria-labelledby":`ai-available`,children:[(0,I.jsx)(`h3`,{id:`ai-available`,className:`ai-group-title`,children:i.length>0?`Add another`:`Add a key to turn one on`}),(0,I.jsx)(`ul`,{className:`ai-cards`,children:a.map(e=>(0,I.jsx)(Pt,{status:e,actions:r},e.provider))})]}),!t&&(0,I.jsx)(Rt,{settings:e,providers:xt(e),actions:r})]})}function Zt(){let e=b().hasRole(`admin`),{loaded:t,reload:n}=x(m,`The AI provider could not be read`),[r,i]=(0,j.useState)(null);if(t.state===`loading`)return(0,I.jsx)(W,{what:`the AI provider`});if(t.state===`error`)return(0,I.jsx)(G,{message:t.message,onRetry:n});let a=r??t.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(H,{title:`AI help`,sources:(0,I.jsx)(`p`,{className:`setup-source`,children:`An AI turns on when it has a key. Pick the one the site uses; the assistant lets editors pick another.`}),children:[(0,I.jsx)(`p`,{className:a.configured?`ai-status ai-status--on`:`ai-status`,role:`status`,children:St(a,e)}),(0,I.jsx)(Xt,{settings:a,readOnly:!e,onChange:i}),a.assistantProvider&&(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The assistant is set to `,N(a.assistantProvider),` in the site's configuration.`]})]}),(0,I.jsx)(Yt,{configured:a.configured,admin:e,model:Ct(a)})]})}var Qt={manual:`By hand`,"pre-restore":`Before a restore`,"pre-migration":`Before a migration`,"pre-import":`Before an import`};function K(e){return e.name?`v${e.version} · ${e.name}`:`v${e.version}`}function $t({checkpoint:e,onDone:t,onClose:n}){let r=g(),i=K(e);async function a(){await se(e.version),r({text:`Restored ${i}. A safety checkpoint of the state before was taken first.`}),t()}return(0,I.jsxs)(L,{title:`Restore ${i}?`,confirmLabel:`Restore checkpoint`,danger:!0,onConfirm:a,onClose:n,children:[(0,I.jsxs)(`p`,{children:[`Every document — the version being edited and the version that is live — the runtime fields and the media library's records go back to how they stood at`,` `,E(e.createdAt),`. Versions saved since stay in each document's history but are no longer current.`]}),(0,I.jsxs)(`p`,{children:[`A safety checkpoint, `,(0,I.jsxs)(`code`,{children:[`pre-restore-v`,e.version]}),`, is taken first, so you can return to how things are now. Settings, SEO configuration and people are not rewound.`]}),(0,I.jsx)(`p`,{children:`Every cached page is marked stale: its next visit may still get the old page while it is rendered again.`})]})}function en({checkpoint:e,onDone:t,onClose:n}){let r=g(),i=K(e);async function a(){await ve(e.version),r({text:`Deleted ${i}.`}),t()}return(0,I.jsx)(L,{title:`Delete ${i}?`,confirmLabel:`Delete checkpoint`,danger:!0,onConfirm:a,onClose:n,children:(0,I.jsx)(`p`,{children:`It can no longer be restored. The content stays as it is.`})})}function tn(e,t){return[{id:`name`,header:`Checkpoint`,primary:!0,cell:e=>K(e)},{id:`trigger`,header:`Taken`,cell:e=>(0,I.jsx)(y,{children:Qt[e.trigger]})},{id:`created`,header:`Created`,cell:e=>E(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>e?(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(S,{size:`sm`,icon:oe,"aria-label":`Restore ${K(n)}`,onClick:()=>t({kind:`restore`,checkpoint:n}),children:`Restore`}),(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-label":`Delete ${K(n)}`,onClick:()=>t({kind:`delete`,checkpoint:n}),children:`Delete`})]}):null}]}function nn({onCreated:e}){let t=g(),[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(!1);async function s(){if(!o.current){o.current=!0,a(!0);try{let i=await ae(n.trim()||void 0);t({text:`Created ${K(i)}.`}),r(``),e()}catch(e){t({text:_(e,`The checkpoint could not be created`),tone:`error`})}finally{o.current=!1,a(!1)}}}return(0,I.jsxs)(`form`,{className:`setup-inline-form`,onSubmit:e=>{e.preventDefault(),i||s()},children:[(0,I.jsx)(z,{label:`Name`,value:n,onChange:r,placeholder:`Before the spring relaunch`,hint:`Optional`}),(0,I.jsx)(S,{type:`submit`,variant:`primary`,icon:de,"aria-disabled":i,children:i?`Creating…`:`Create checkpoint`})]})}function rn(){return(0,I.jsx)(V,{source:`database`,children:`Stored in the site's database. A checkpoint marks a point in time and copies nothing; restoring one rewinds to it. The API lists each checkpoint's number, name, what took it and when — not its size or the schema version it was taken under.`})}function an(){let{hasRole:e}=b(),{loaded:t,reload:n}=x(be,`The checkpoints could not be read`),[r,i]=(0,j.useState)(null),a=()=>i(null),o=()=>{a(),n()};return(0,I.jsxs)(H,{title:`Checkpoints`,sources:(0,I.jsx)(rn,{}),children:[e(`editor`)?(0,I.jsx)(nn,{onCreated:n}):(0,I.jsx)(U,{children:`Editors and admins create checkpoints.`}),t.state===`loading`&&(0,I.jsx)(W,{what:`the checkpoints`}),t.state===`error`&&(0,I.jsx)(G,{message:t.message,onRetry:n}),t.state===`ready`&&t.data.length===0&&(0,I.jsx)(Le,{icon:de,title:`No checkpoints yet`,children:`Create one to mark the content store as it is now, so you can return to it.`}),t.state===`ready`&&t.data.length>0&&(0,I.jsx)(O,{caption:`Checkpoints, newest first`,columns:tn(e(`admin`),i),rows:t.data,rowKey:e=>String(e.version)}),r?.kind===`restore`&&(0,I.jsx)($t,{checkpoint:r.checkpoint,onDone:o,onClose:a}),r?.kind===`delete`&&(0,I.jsx)(en,{checkpoint:r.checkpoint,onDone:o,onClose:a})]})}async function on(e){let[t,n,r]=await Promise.all([te(),Ve(e,Se),Ve(e,async()=>(await Ce()).types)]);return{collections:t,configs:n,catalog:r}}function sn(e,t){return e.state===`ok`?e.value.find(e=>e.id===`collection:${t}`)?.config.entities.map(e=>e[`@type`])??[]:null}function cn(e,t){if(e.state!==`ok`||t===null)return null;let n=e.value.filter(e=>t.includes(e.type)&&e.richResult!==null).filter(e=>e.richResultStatus===`active`||e.richResultStatus===`restricted`).map(e=>e.richResult??``);return[...new Set(n)]}function ln(e){return e.collections.map(t=>{let n=t.pages?sn(e.configs,t.name):[];return{collection:t,rendersAt:pe(t,`:slug`),types:n,richResults:t.pages?cn(e.catalog,n):[]}})}function un(e){return e==null?null:typeof e==`string`?e:JSON.stringify(e)}function dn(e){return e.enum?`enum`:e.format===`uri`?`url`:e.format===`email`?`email`:String(e.type??`string`)}function fn(e,t){let n=new Set(e.schema.required??[]),r=Object.entries(e.schema.properties??{}).filter(([,e])=>!(Be(e)&&e._runtime)).map(([e,t])=>({name:e,type:dn(t),required:n.has(e),description:t.description??null,defaultValue:un(t.default),source:`code`,runtime:null})),i=t.map(e=>({name:e.name,type:e.type,required:e.required,description:e.description??null,defaultValue:un(e.default),source:`runtime`,runtime:e}));return[...r,...i]}var pn=[`string`,`textarea`,`number`,`boolean`,`date`,`enum`,`url`,`email`,`color`,`reference`],mn={string:`text (one line)`,textarea:`text (long)`,number:`number`,boolean:`yes/no`,date:`date`,enum:`choice`,url:`web address`,email:`email`,color:`color`,reference:`link to a page`,integer:`number`,array:`list`,object:`group`};function hn(e){return mn[e]??e}var q=e=>e==null?``:String(e);function gn(e){return{name:e?.name??``,type:e?.type??`string`,required:e?.required??!1,description:e?.description??``,defaultValue:q(e?.default),enumValues:e?.enumValues?.join(`, `)??``,refCollection:e?.refCollection??``,min:q(e?.min),max:q(e?.max),pattern:e?.pattern??``}}function J(e){return e===`string`||e===`textarea`||e===`number`}function _n(e){let t=e.defaultValue.trim();if(t)return e.type===`number`?Number(t):e.type===`boolean`?t===`true`:t}function Y(e){return e.enumValues.split(`,`).map(e=>e.trim()).filter(Boolean)}function vn(e){let t=e.defaultValue.trim();return t?e.type===`number`&&!Number.isFinite(Number(t))?`The default is a number.`:e.type===`boolean`&&t!==`true`&&t!==`false`?`The default is true or false.`:e.type===`enum`&&!Y(e).includes(t)?`The default is one of the values.`:null:null}function yn(e){if(!J(e.type))return null;let[t,n]=[e.min.trim(),e.max.trim()];return[t,n].some(e=>e&&!Number.isFinite(Number(e)))?`Minimum and maximum are numbers.`:t&&n&&Number(t)>Number(n)?`The minimum is not above the maximum.`:null}function bn(e){let t=e.pattern.trim();if(e.type!==`string`||!t)return null;try{return new RegExp(t),null}catch{return`The pattern is not a valid regular expression.`}}function xn(e){let t=e.name.trim();return t?/^[a-z][a-z0-9_-]*$/i.test(t)?e.type===`reference`&&!e.refCollection?`Choose the collection it refers to.`:e.type===`enum`&&new Set(Y(e)).size<2?`Give the enum two different values or more.`:yn(e)??bn(e)??vn(e):`A name starts with a letter and holds only letters, digits, hyphens and underscores.`:`A field needs a name.`}function Sn(e){let t=Y(e),n={name:e.name.trim(),type:e.type,required:e.required},r=_n(e);return r!==void 0&&(n.default=r),e.description.trim()&&(n.description=e.description.trim()),e.type===`enum`&&t.length>0&&(n.enumValues=t),e.type===`reference`&&(n.refCollection=e.refCollection),J(e.type)&&e.min.trim()&&(n.min=Number(e.min)),J(e.type)&&e.max.trim()&&(n.max=Number(e.max)),e.type===`string`&&e.pattern.trim()&&(n.pattern=e.pattern.trim()),n}var Cn=pn.map(e=>({value:e,label:hn(e)}));function wn({form:e,set:t}){let n=e.type===`number`;return(0,I.jsxs)(`div`,{className:`setup-field-row`,children:[(0,I.jsx)(z,{label:n?`Minimum`:`Minimum length`,type:`number`,value:e.min,onChange:t(`min`)}),(0,I.jsx)(z,{label:n?`Maximum`:`Maximum length`,type:`number`,value:e.max,onChange:t(`max`)})]})}function Tn(e){let{form:t,set:n,collections:r}=e,i=[{value:``,label:`Choose a collection`},...r.map(e=>({value:e.name,label:D(e.name)}))];return(0,I.jsxs)(I.Fragment,{children:[t.type===`enum`&&(0,I.jsx)(z,{label:`Values`,value:t.enumValues,onChange:n(`enumValues`),hint:`Separated by commas`}),t.type===`reference`&&(0,I.jsx)(B,{label:`Refers to`,value:t.refCollection,options:i,onChange:n(`refCollection`)}),J(t.type)&&(0,I.jsx)(wn,{form:t,set:n}),t.type===`string`&&(0,I.jsx)(z,{label:`Pattern`,value:t.pattern,onChange:n(`pattern`),hint:`A regular expression the value must match`})]})}function En({form:e,set:t,editing:n,collections:r}){let i=n?`A field keeps its name`:`The key documents store its value under`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:`Name`,value:e.name,onChange:t(`name`),disabled:n,hint:i}),(0,I.jsx)(B,{label:`Type`,value:e.type,options:Cn,onChange:t(`type`),disabled:n,hint:n?`A field keeps its type`:void 0}),(0,I.jsx)(kt,{label:`Required`,checked:e.required,onChange:t(`required`)}),(0,I.jsx)(z,{label:`Description`,value:e.description,onChange:t(`description`),hint:`Shown to editors under the field`}),(0,I.jsx)(z,{label:`Default`,value:e.defaultValue,onChange:t(`defaultValue`)}),(0,I.jsx)(Tn,{form:e,set:t,collections:r})]})}function Dn(e){let{collection:t,field:n,collections:r,onSave:i,onClose:a}=e,o=(0,j.useId)(),[s,c]=(0,j.useState)(()=>gn(n)),l=e=>t=>c(n=>({...n,[e]:t})),{busy:u,error:d,setError:f,run:p}=F();function m(e){e.preventDefault();let t=xn(s);t?f(t):p(()=>i(Sn(s)),`The field could not be saved`)}let ee=n?`Edit ${n.name}`:`Add a runtime field to ${D(t)}`;return(0,I.jsx)(h,{title:ee,onClose:a,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:a,children:`Cancel`}),(0,I.jsx)(S,{variant:`primary`,type:`submit`,form:o,"aria-disabled":u,children:u?`Saving…`:`Save field`})]}),busy:u,children:(0,I.jsxs)(`form`,{id:o,className:`setup-form`,onSubmit:m,children:[d&&(0,I.jsx)(R,{text:d}),(0,I.jsx)(En,{form:s,set:l,editing:n!==null,collections:r})]})})}function On(e){let t=g();return async()=>{if(e!==null)try{await navigator.clipboard.writeText(e),t({text:`Copied the Zod schema.`})}catch{t({text:`The browser did not allow copying; select the code instead.`,tone:`error`})}}}function kn({collection:e,onClose:t}){let n=(0,j.useCallback)(async()=>(await p(e)).code,[e]),{loaded:r,reload:i}=x(n,`The schema could not be exported`),a=r.state===`ready`?r.data:null,o=On(a),s=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:t,children:`Close`}),(0,I.jsx)(S,{variant:`primary`,icon:Ue,"aria-disabled":a===null,onClick:()=>void o(),children:`Copy`})]});return(0,I.jsxs)(h,{title:`${D(e)} as Zod`,onClose:t,actions:s,children:[(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The code fields and the runtime fields as one Zod schema. Paste it into`,` `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),` to make the runtime fields part of the code; code always wins over a runtime field of the same name.`]}),r.state===`loading`&&(0,I.jsx)(W,{what:`the schema`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),a!==null&&(0,I.jsx)(`section`,{className:`setup-code`,"aria-label":`Zod schema`,tabIndex:0,children:(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:a})})})]})}function An({field:e,onDialog:t}){return(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(S,{size:`sm`,icon:He,"aria-label":`Edit ${e.name}`,onClick:()=>t({kind:`edit`,field:e}),children:`Edit`}),(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-label":`Delete ${e.name}`,onClick:()=>t({kind:`delete`,field:e}),children:`Delete`})]})}function jn({field:e,admin:t,onDialog:n}){return e.runtime?t?(0,I.jsx)(An,{field:e.runtime,onDialog:n}):(0,I.jsx)(`span`,{className:`setup-muted`,children:`Admins edit runtime fields`}):(0,I.jsxs)(`span`,{className:`setup-locked`,children:[(0,I.jsx)(ce,{"aria-hidden":`true`}),`Defined in code, change it in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`; code always wins`]})}function Mn(e,t){return[{id:`field`,header:`Field`,primary:!0,cell:e=>(0,I.jsxs)(`span`,{className:`setup-name`,children:[(0,I.jsx)(`code`,{children:e.name}),e.description&&(0,I.jsx)(`span`,{className:`setup-muted`,children:e.description})]})},{id:`type`,header:`Type`,cell:e=>hn(e.type)},{id:`required`,header:`Required`,cell:e=>e.required?`Required`:`Optional`},{id:`default`,header:`Default`,cell:e=>e.defaultValue?(0,I.jsx)(`code`,{children:e.defaultValue}):`—`},{id:`source`,header:`Source`,cell:e=>e.source===`code`?(0,I.jsx)(y,{icon:ce,children:`Code`}):(0,I.jsx)(y,{tone:`accent`,children:`Runtime`})},{id:`edit`,header:`Edit`,cell:n=>(0,I.jsx)(jn,{field:n,admin:e,onDialog:t})}]}function Nn(e){let t=(0,j.useCallback)(async()=>{let[t,n]=await Promise.all([c(e),ne(e)]);return fn(t,n.fields)},[e]);return x(t,`The fields could not be read`)}function Pn({admin:e,onDialog:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{icon:Ze,onClick:()=>t({kind:`export`}),children:`Export as Zod`}),e&&(0,I.jsx)(S,{variant:`primary`,icon:me,onClick:()=>t({kind:`edit`,field:null}),children:`Add runtime field`})]})}function Fn({collection:e,collections:t,admin:n}){let{loaded:r,reload:i}=Nn(e),[a,o]=(0,j.useState)(null),s=D(e),c=(0,I.jsx)(Pn,{admin:n,onDialog:o});return(0,I.jsxs)(H,{title:`Fields of ${s}`,actions:c,sources:(0,I.jsx)(In,{}),children:[r.state===`loading`&&(0,I.jsx)(W,{what:`the fields`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(O,{caption:`Fields of ${s}`,columns:Mn(n,o),rows:r.data,rowKey:e=>`${e.source}:${e.name}`}),a&&(0,I.jsx)(Rn,{collection:e,collections:t,dialog:a,onClose:()=>o(null),onChanged:i})]})}function In(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{source:`config`,children:[`Code fields come from the collection's Zod schema in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`, read-only here.`]}),(0,I.jsx)(V,{source:`database`,children:`Runtime fields are stored in the site's database: added, edited and deleted here, and added to the collection's form at once.`})]})}function Ln({collection:e,name:t,onDone:n,onClose:r}){return(0,I.jsxs)(L,{title:`Delete the field ${t}?`,confirmLabel:`Delete field`,danger:!0,onConfirm:async()=>{await l(e,t),n(`Deleted the runtime field ${t}.`)},onClose:r,children:[(0,I.jsxs)(`p`,{children:[`The runtime field `,(0,I.jsx)(`code`,{children:t}),` is removed from `,D(e),`'s schema, so its form no longer shows it.`]}),(0,I.jsx)(`p`,{children:`Only the schema changes. Documents keep the values they already hold in the field; the form no longer shows them.`})]})}function Rn(e){let{collection:t,collections:n,dialog:r,onClose:i,onChanged:a}=e,o=g(),s=e=>{o({text:e}),i(),a()};return r.kind===`export`?(0,I.jsx)(kn,{collection:t,onClose:i}):r.kind===`delete`?(0,I.jsx)(Ln,{collection:t,name:r.field.name,onDone:s,onClose:i}):(0,I.jsx)(Dn,{collection:t,field:r.field,collections:n,onSave:async e=>{await ie(t,e),s(`Saved the runtime field ${e.name}.`)},onClose:i})}var X=`collection`;function zn({names:e,none:t}){return e===null?(0,I.jsx)(`span`,{className:`setup-muted`,children:`Not read`}):e.length===0?(0,I.jsx)(`span`,{className:`setup-muted`,children:t}):(0,I.jsx)(`span`,{className:`setup-chips`,children:e.map(e=>(0,I.jsx)(y,{children:e},e))})}function Bn({name:e}){return(0,I.jsxs)(`span`,{className:`setup-name`,children:[D(e),(0,I.jsx)(`code`,{className:`setup-muted`,children:e})]})}function Vn({name:e,open:t,onFields:n}){return(0,I.jsx)(S,{size:`sm`,icon:tt,variant:t?`primary`:`secondary`,"aria-label":`Fields of ${D(e)}`,"aria-pressed":t,onClick:()=>n(e),children:`Fields`})}function Hn(e,t){return[{id:`collection`,header:`Collection`,primary:!0,cell:e=>(0,I.jsx)(Bn,{name:e.collection.name})},{id:`renders`,header:`Renders at`,cell:e=>e.rendersAt?(0,I.jsx)(`code`,{children:e.rendersAt}):(0,I.jsx)(`span`,{className:`setup-muted`,children:`No pages`})},{id:`types`,header:`Schema.org types`,cell:e=>(0,I.jsx)(zn,{names:e.types,none:`None set`})},{id:`rich`,header:`Rich results`,cell:e=>(0,I.jsx)(zn,{names:e.richResults,none:`None`})},{id:`fields`,header:`Fields`,cell:n=>(0,I.jsx)(Vn,{name:n.collection.name,open:e===n.collection.name,onFields:t})}]}function Un({seo:e}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{source:`config`,children:[`The collections and where they render come from `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`, read-only here.`]}),e&&(0,I.jsxs)(V,{source:`database`,children:[`The Schema.org types are each collection's archetype, set in`,` `,(0,I.jsx)(ze,{to:f(`collection`),children:`Structure › Scopes & archetypes`}),`. The rich results are what the catalog says those types are eligible for.`]})]})}function Wn(){let[e,t]=Re(),n=e.get(X),r=(0,j.useRef)(null),i=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{n&&i.current&&r.current?.focus(),i.current=!1},[n]),{open:n,onFields:(0,j.useCallback)(e=>{i.current=!0,t({[X]:e},{replace:!0})},[t]),ref:r}}function Gn(){let e=Ie(Ne(),`seo`),t=b().hasRole(`admin`),n=(0,j.useCallback)(()=>on(e),[e]),{loaded:r,reload:i}=x(n,`The collections could not be read`),{open:a,onFields:o,ref:s}=Wn(),c=r.state===`ready`?r.data.collections:[],l=c.some(e=>e.name===a);return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(H,{title:`Collections & schema`,sources:(0,I.jsx)(Un,{seo:e}),children:[r.state===`loading`&&(0,I.jsx)(W,{what:`the collections`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(O,{caption:`Collections`,columns:Hn(a,o),rows:ln(r.data),rowKey:e=>e.collection.name})]}),a&&r.state===`ready`&&!l&&(0,I.jsxs)(U,{children:[`No collection is named `,a,`.`]}),a&&l&&(0,I.jsx)(`div`,{ref:s,tabIndex:-1,className:`setup-focus-target`,children:(0,I.jsx)(Fn,{collection:a,collections:c,admin:t},a)})]})}function Kn(e){return e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function qn(e){let t=[],n=Pe(e);n&&t.push({name:`Framework`,value:n}),t.push({name:`Persistence`,value:e.persistence},{name:`Auth`,value:e.authMode}),e.schemaVersion!==null&&t.push({name:`Schema version`,value:`v${String(e.schemaVersion).padStart(3,`0`)}`});for(let[n,r]of Object.entries(e.features))t.push({name:Kn(n),value:r});return t}function Jn({value:e}){return(0,I.jsx)(y,{tone:e===`disabled`||e===`none`?`neutral`:`success`,children:e})}var Yn=[{id:`name`,header:`Capability`,primary:!0,cell:e=>e.name},{id:`value`,header:`Value`,cell:e=>(0,I.jsx)(Jn,{value:e.value})}];function Xn(){let e=Ne();return(0,I.jsx)(H,{title:`Environment`,sources:(0,I.jsxs)(V,{source:`server`,children:[`What the running server reports (`,(0,I.jsx)(`code`,{children:`GET /api/capabilities`}),`), read-only. It follows the configuration and the persistence the server started with.`]}),children:(0,I.jsx)(O,{caption:`What the server reports`,columns:Yn,rows:qn(e),rowKey:e=>e.name})})}var Zn=[{id:`all`,label:`All`},{id:`pending`,label:`Pending`},{id:`delivered`,label:`Delivered`},{id:`failed`,label:`Failed`}];function Qn(e){return e.deliveredAt?`delivered`:e.attempts>=5?`failed`:`pending`}function $n(e){return e===null?`—`:e===0?`Network error`:String(e)}function er(e){switch(e){case`pending`:return`No delivery is waiting for another attempt.`;case`delivered`:return`No delivery has reached its webhook yet.`;case`failed`:return`No delivery has failed.`;default:return`Nothing has been sent yet.`}}function tr(e,t){let n=Math.ceil(t/25);return n>1?`Page ${e+1} of ${n}`:null}var nr={delivered:(0,I.jsx)(y,{tone:`success`,icon:he,children:`Delivered`}),pending:(0,I.jsx)(y,{tone:`warning`,icon:We,children:`Pending`}),failed:(0,I.jsx)(y,{tone:`danger`,icon:ue,children:`Failed`})};function rr(e,t){return[{id:`event`,header:`Event`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.event})},{id:`url`,header:`URL`,cell:e=>(0,I.jsx)(`span`,{className:`setup-url`,children:e.url})},{id:`state`,header:`State`,cell:e=>nr[Qn(e)]},{id:`http`,header:`HTTP`,numeric:!0,cell:e=>$n(e.status)},{id:`attempts`,header:`Attempts`,numeric:!0,cell:e=>`${e.attempts} / 5`},{id:`created`,header:`Created`,cell:e=>E(e.createdAt)},{id:`delivered`,header:`Delivered`,cell:e=>e.deliveredAt?E(e.deliveredAt):`—`},{id:`retry`,header:`Retry`,cell:n=>Qn(n)===`failed`?(0,I.jsx)(S,{size:`sm`,icon:Ge,"aria-disabled":e!==null,"aria-label":`Retry delivery ${n.id} of ${n.event}`,onClick:e===null?()=>t(n):void 0,children:e===n.id?`Retrying…`:`Retry`}):null}]}function ir({filter:e,onFilter:t}){return(0,I.jsxs)(`fieldset`,{className:`setup-segmented`,children:[(0,I.jsx)(`legend`,{className:`visually-hidden`,children:`Show deliveries`}),Zn.map(n=>(0,I.jsx)(S,{size:`sm`,variant:e===n.id?`primary`:`secondary`,"aria-pressed":e===n.id,onClick:()=>t(n.id),children:n.label},n.id))]})}function ar(e){let t=g(),[n,r]=(0,j.useState)(null),i=(0,j.useRef)(null);return{retrying:n,retry:(0,j.useCallback)(n=>{i.current===null&&(i.current=n.id,r(n.id),re(n.id).then(()=>t({text:`Sent delivery ${n.id} again. It shows as pending until the webhook answers.`})).catch(e=>t({text:_(e,`The delivery could not be retried`),tone:`error`})).finally(()=>{i.current=null,r(null),e()}))},[e,t])}}function or({page:e,total:t,onPage:n}){let r=tr(e,t);if(!r)return null;let i=Math.ceil(t/25)-1;return(0,I.jsxs)(`nav`,{"aria-label":`Pages of deliveries`,className:`setup-row`,children:[(0,I.jsx)(S,{size:`sm`,"aria-disabled":e===0,onClick:e===0?void 0:()=>n(e-1),children:`Previous`}),(0,I.jsx)(`span`,{className:`setup-muted`,children:r}),(0,I.jsx)(S,{size:`sm`,"aria-disabled":e>=i,onClick:e>=i?void 0:()=>n(e+1),children:`Next`})]})}async function sr(e,t){let n=e===`all`?void 0:e;try{return await ge({limit:25,offset:t*25,status:n})}catch(e){if(e instanceof Ke&&e.status===403)return null;throw e}}function cr({filter:e,page:t,revision:n,onPage:r}){let i=(0,j.useCallback)(()=>sr(e,t),[e,t]),{loaded:a,reload:o}=x(i,`The deliveries could not be read`),s=(0,j.useRef)(n);(0,j.useEffect)(()=>{s.current!==n&&(s.current=n,o())},[n,o]);let{retrying:c,retry:l}=ar(o);if(a.state===`loading`)return(0,I.jsx)(W,{what:`the deliveries`});if(a.state===`error`)return(0,I.jsx)(G,{message:a.message,onRetry:o});if(a.data===null)return(0,I.jsx)(U,{children:`Only admins see webhook deliveries.`});let{deliveries:u,total:d}=a.data;return u.length===0?(0,I.jsx)(lr,{filter:e}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`setup-muted`,children:d===1?`1 delivery`:`${d} deliveries`}),(0,I.jsx)(O,{caption:`Webhook deliveries`,columns:rr(c,l),rows:u,rowKey:e=>String(e.id)}),(0,I.jsx)(or,{page:t,total:d,onPage:r})]})}function lr({filter:e}){return(0,I.jsxs)(Le,{icon:fe,title:`No webhook deliveries`,children:[er(e),` `,e===`all`&&(0,I.jsxs)(I.Fragment,{children:[`Each webhook the API is created with (`,(0,I.jsxs)(`code`,{children:[`createApiHandlers(`,`{ webhooks }`,`)`]}),`) logs a delivery here when content is created, updated, published or deleted.`]})]})}function ur(){let[e,t]=(0,j.useState)(`all`),[n,r]=(0,j.useState)(0),[i,a]=(0,j.useState)(0);return(0,I.jsxs)(H,{title:`Webhook deliveries`,actions:(0,I.jsx)(S,{size:`sm`,icon:we,onClick:()=>a(e=>e+1),children:`Refresh`}),sources:(0,I.jsx)(V,{source:`database`,children:`The delivery log in the site's database: every webhook sent, its answer and its attempts. Delivery logging runs on SQLite only.`}),children:[(0,I.jsx)(ir,{filter:e,onFilter:e=>{t(e),r(0)}}),(0,I.jsx)(cr,{filter:e,page:n,revision:i,onPage:r})]})}var Z=e=>`${e.collection}/${e.slug}/${e.locale}`;function dr({version:e,item:t,defaultLocale:n,canCreate:r,created:i,busy:a,onCreate:o}){let{collection:s,slug:c,locale:l}=e;return t.locales.includes(l)?(0,I.jsx)(y,{tone:`success`,icon:xe,children:`Exists`}):i.has(Z(e))?(0,I.jsxs)(ze,{to:ee(s,c,l),children:[`Open the `,l,` draft`]}):!r||!t.locales.includes(n)?(0,I.jsx)(y,{tone:`warning`,children:`Missing`}):(0,I.jsx)(S,{size:`sm`,icon:le,"aria-disabled":a!==null,"aria-label":`Create the ${l} draft of ${c}`,onClick:a===null?()=>o(e):void 0,children:a===Z(e)?`Creating…`:`Create draft`})}function fr(e,t,n){return[{id:`slug`,header:`Document`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.slug})},...e.map(e=>({id:`locale-${e}`,header:e===t.defaultLocale?`${e} (default)`:e,cell:r=>(0,I.jsx)(dr,{...t,item:r,version:{collection:n,slug:r.slug,locale:e}})}))]}function pr(e){let t=g(),[n,r]=(0,j.useState)(new Set),[i,a]=(0,j.useState)(null);return{created:n,busy:i,onCreate:(0,j.useCallback)(n=>{a(Z(n)),qe(n.collection,n.slug,n.locale,e).then(()=>{r(e=>new Set([...e,Z(n)])),t({text:`Created the ${n.locale} draft of ${n.slug}, copied from ${e}.`})}).catch(e=>t({text:_(e,`The draft could not be created`),tone:`error`})).finally(()=>a(null))},[e,t])}}function mr({status:e,locales:t,cell:n}){let r=D(e.collection);return(0,I.jsxs)(`div`,{className:`setup-coverage`,children:[(0,I.jsx)(`h3`,{className:`setup-subtitle`,children:r}),e.items.length===0?(0,I.jsx)(`p`,{className:`setup-muted`,children:`No documents.`}):(0,I.jsx)(O,{caption:`${r}: versions per locale`,columns:fr(t,n,e.collection),rows:e.items,rowKey:e=>e.slug})]})}function hr({settings:e}){let t=b().hasRole(`editor`),n=`${e.defaultLocale}:${e.supportedLocales.join(`,`)}`,r=(0,j.useCallback)(()=>u(),[n]),{loaded:i,reload:a}=x(r,`Translation coverage could not be read`),o={...pr(e.defaultLocale),defaultLocale:e.defaultLocale,canCreate:t};return(0,I.jsxs)(H,{title:`Translation coverage`,sources:(0,I.jsxs)(V,{source:`database`,children:[`Each document's versions as the site's database holds them. Create draft copies the`,` `,e.defaultLocale,` version's fields and body into a new draft in that locale; it is not live until it is published.`]}),children:[i.state===`loading`&&(0,I.jsx)(W,{what:`translation coverage`}),i.state===`error`&&(0,I.jsx)(G,{message:i.message,onRetry:a}),i.state===`ready`&&i.data.collections.map(e=>(0,I.jsx)(mr,{status:e,locales:i.data.supportedLocales,cell:o},e.collection))]})}function gr(e){return e.configuredLocales.filter(t=>!e.supportedLocales.includes(t))}function _r(e,t){return[...e.supportedLocales,t]}function vr(e,t){return t===e.defaultLocale?e.supportedLocales:e.supportedLocales.filter(e=>e!==t)}function yr(){let{loaded:e,reload:t}=x(s,`The locales could not be read`),[n,r]=(0,j.useState)(null),i=(0,j.useCallback)(e=>r(e),[]);return n&&e.state===`ready`?{loaded:{state:`ready`,data:n},reload:t,set:i}:{loaded:e,reload:t,set:i}}function br({settings:e}){return e.source===`database`?(0,I.jsxs)(V,{source:`database`,children:[`The active locales are chosen here among the configured ones and stored in the site's database. The default locale is `,(0,I.jsx)(`code`,{children:`site.defaultLocale`}),` in the configuration.`]}):(0,I.jsxs)(V,{source:`config`,children:[`The locales are `,(0,I.jsx)(`code`,{children:`site.supportedLocales`}),` and the default locale is`,` `,(0,I.jsx)(`code`,{children:`site.defaultLocale`}),`, in `,(0,I.jsx)(`code`,{children:`krantho.config.ts`}),` or the environment. Setup chooses which of the configured locales are active; the default is set only in the configuration.`]})}function xr(e,t,n){return[{id:`locale`,header:`Locale`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.code})},{id:`default`,header:`Default`,cell:e=>e.isDefault?(0,I.jsx)(y,{tone:`accent`,children:`Default`}):null},{id:`actions`,header:`Actions`,cell:r=>e&&!r.isDefault?(0,I.jsx)(`span`,{className:`setup-row-actions`,children:(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-disabled":t,"aria-label":`Remove ${r.code}`,onClick:()=>n(r.code),children:`Remove`})}):null}]}function Sr({settings:e,busy:t,change:n}){let r=gr(e),[i,a]=(0,j.useState)(``),o=r.includes(i)?i:r[0];return o===void 0?(0,I.jsx)(U,{children:`Every locale in the configuration is active.`}):(0,I.jsxs)(`form`,{className:`setup-inline-form`,onSubmit:r=>{r.preventDefault(),t||n(_r(e,o),`Added ${o}.`)},children:[(0,I.jsx)(B,{label:`Configured locale`,value:o,onChange:a,hint:`A locale in site.supportedLocales that is not active`,options:r.map(e=>({value:e,label:e}))}),(0,I.jsx)(S,{type:`submit`,variant:`primary`,icon:me,"aria-disabled":t,children:`Add locale`})]})}function Cr(e){let t=g(),{busy:n,once:r}=P();return{busy:n,change:(n,i)=>{r(async()=>{try{e(await o(n)),t({text:i})}catch(e){t({text:_(e,`The locales could not be saved`),tone:`error`})}})}}}function wr({code:e,settings:t,onSaved:n,onClose:r}){let i=g();async function a(){n(await o(vr(t,e))),i({text:`Removed ${e}.`}),r()}return(0,I.jsx)(L,{title:`Remove the locale ${e}?`,confirmLabel:`Remove locale`,danger:!0,onConfirm:a,onClose:r,children:(0,I.jsxs)(`p`,{children:[`The site stops serving `,(0,I.jsx)(`code`,{children:e}),`. Documents already in that locale are kept, not deleted. Only the list of locales changes.`]})})}function Tr({settings:e,set:t}){let n=b().hasRole(`admin`),{busy:r,change:i}=Cr(t),[a,o]=(0,j.useState)(null),s=e.supportedLocales.map(t=>({code:t,isDefault:t===e.defaultLocale}));return(0,I.jsxs)(H,{title:`Locales`,sources:(0,I.jsx)(br,{settings:e}),children:[(0,I.jsx)(O,{caption:`Locales`,columns:xr(n,r,o),rows:s,rowKey:e=>e.code}),n?(0,I.jsx)(Sr,{settings:e,busy:r,change:i}):(0,I.jsx)(U,{children:`Only admins change the locales.`}),a&&(0,I.jsx)(wr,{code:a,settings:e,onSaved:t,onClose:()=>o(null)})]})}function Er(){let{loaded:e,reload:t,set:n}=yr();if(e.state===`loading`)return(0,I.jsx)(W,{what:`the locales`});if(e.state===`error`)return(0,I.jsx)(G,{message:e.message,onRetry:t});let r=e.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsx)(Tr,{settings:r,set:n}),r.supportedLocales.length>1&&(0,I.jsx)(hr,{settings:r})]})}var Dr=[{value:`admin`,label:`Admin`,can:`everything, including Setup and people`},{value:`editor`,label:`Editor`,can:`writes, publishes and takes checkpoints`},{value:`viewer`,label:`Viewer`,can:`reads`}];function Q(e){return e.roles[0]??`viewer`}function $(e){return e.name||e.email||e.id}var Or=Dr.map(e=>({value:e.value,label:`${e.label} — ${e.can}`}));function kr({form:e,setForm:t,editing:n}){let r=n?`An account keeps its email`:`They sign in with this address`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:`Email`,type:`email`,value:e.email,disabled:n,onChange:n=>t({...e,email:n}),hint:r}),(0,I.jsx)(z,{label:`Name`,value:e.name,onChange:n=>t({...e,name:n})}),(0,I.jsx)(B,{label:`Role`,value:e.role,options:Or,onChange:n=>t({...e,role:n}),hint:`Roles are site-wide: admin > editor > viewer`})]})}function Ar({user:e,onSave:t,onClose:n}){let r=(0,j.useId)(),[i,a]=(0,j.useState)(()=>({email:e?.email??``,name:e?.name??``,role:e?Q(e):`viewer`})),{busy:o,error:s,setError:c,run:l}=F();function u(n){if(n.preventDefault(),!e&&!i.email.trim()){c(`An account needs an email.`);return}let r={...i,email:i.email.trim(),name:i.name.trim()};l(()=>t(r),`The account could not be saved`)}let d=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:n,children:`Cancel`}),(0,I.jsx)(S,{variant:`primary`,type:`submit`,form:r,"aria-disabled":o,children:o?`Saving…`:e?`Save`:`Create user`})]}),f=e?`Edit ${$(e)}`:`Create user`;return(0,I.jsx)(h,{title:f,onClose:n,actions:d,busy:o,children:(0,I.jsxs)(`form`,{id:r,className:`setup-form`,onSubmit:u,children:[s&&(0,I.jsx)(R,{text:s}),(0,I.jsx)(kr,{form:i,setForm:a,editing:e!==null})]})})}var jr=e=>Dr.find(t=>t.value===Q(e))?.label??Q(e);function Mr(e,t){let n={kind:`edit`,label:`Edit`,icon:He,variant:`secondary`};return t?[n]:[n,{kind:`active`,label:e.isActive?`Deactivate`:`Activate`,icon:at,variant:`ghost`},{kind:`delete`,label:`Delete`,icon:w,variant:`ghost`}]}function Nr({user:e,self:t,onDialog:n}){let r=$(e),i=Mr(e,t);return(0,I.jsx)(`span`,{className:`setup-row-actions`,children:i.map(t=>(0,I.jsx)(S,{size:`sm`,variant:t.variant,icon:t.icon,"aria-label":`${t.label} ${r}`,onClick:()=>n({kind:t.kind,user:e}),children:t.label},t.kind))})}function Pr(e,t){return[{id:`name`,header:`Person`,primary:!0,cell:e=>e.name||(0,I.jsx)(`span`,{className:`setup-muted`,children:`No name`})},{id:`email`,header:`Email`,cell:e=>e.email??`—`},{id:`role`,header:`Role`,cell:e=>(0,I.jsx)(y,{tone:Q(e)===`admin`?`accent`:`neutral`,children:jr(e)})},{id:`status`,header:`Status`,cell:e=>e.isActive?(0,I.jsx)(y,{tone:`success`,children:`Active`}):(0,I.jsx)(y,{children:`Deactivated`})},{id:`sign-in`,header:`Signs in with`,cell:e=>e.oidcIssuer?`OIDC provider`:`Studio`},{id:`created`,header:`Created`,cell:e=>Fe(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>(0,I.jsx)(Nr,{user:n,self:n.id===e,onDialog:t})}]}async function Fr(e,t){return e?(await A(e.id,{name:t.name,role:t.role}),`Saved ${$(e)}: ${t.role}.`):`Created ${$(await dt({email:t.email,name:t.name||void 0,role:t.role}))} as ${t.role}.`}async function Ir(e,t){return e===`delete`?(await ft(t.id),`Deleted ${$(t)}.`):(await A(t.id,{isActive:!t.isActive}),`${t.isActive?`Deactivated`:`Activated`} ${$(t)}.`)}function Lr({user:e,onConfirm:t,onClose:n}){let r=e.isActive,i=r?`Deactivate`:`Activate`;return(0,I.jsx)(L,{title:`${i} ${$(e)}?`,confirmLabel:i,danger:r,onConfirm:t,onClose:n,children:(0,I.jsx)(`p`,{children:r?`They can no longer sign in, and their sessions can no longer be renewed; a session already open lasts until its access token expires.`:`They can sign in again, with their role.`})})}function Rr({dialog:e,onClose:t,onDone:n}){if(e.kind===`create`||e.kind===`edit`){let r=e.kind===`edit`?e.user:null;return(0,I.jsx)(Ar,{user:r,onSave:async e=>n(await Fr(r,e)),onClose:t})}let{kind:r,user:i}=e,a=async()=>n(await Ir(r,i));return r===`active`?(0,I.jsx)(Lr,{user:i,onConfirm:a,onClose:t}):(0,I.jsx)(L,{title:`Delete ${$(i)}?`,confirmLabel:`Delete account`,danger:!0,onConfirm:a,onClose:t,children:(0,I.jsx)(`p`,{children:`The account is removed from the site's database.`})})}function zr(){let e=g(),t=b().user?.id,{loaded:n,reload:r}=x(ut,`The accounts could not be read`),[i,a]=(0,j.useState)(null);return(0,I.jsxs)(H,{title:`People`,sources:(0,I.jsx)(V,{source:`database`,children:`The accounts in the site's database. Roles are site-wide: admin > editor > viewer. The API does not record when someone was last active.`}),actions:(0,I.jsx)(S,{variant:`primary`,icon:lt,onClick:()=>a({kind:`create`}),children:`Create user`}),children:[n.state===`loading`&&(0,I.jsx)(W,{what:`the accounts`}),n.state===`error`&&(0,I.jsx)(G,{message:n.message,onRetry:r}),n.state===`ready`&&(0,I.jsx)(O,{caption:`People`,columns:Pr(t,a),rows:n.data,rowKey:e=>e.id}),i&&(0,I.jsx)(Rr,{dialog:i,onClose:()=>a(null),onDone:t=>{a(null),e({text:t}),r()}})]})}function Br({tab:e}){switch(e){case`collections`:return(0,I.jsx)(Gn,{});case`locales`:return(0,I.jsx)(Er,{});case`ai`:return(0,I.jsx)(Zt,{});case`integrations`:return(0,I.jsx)(ur,{});case`checkpoints`:return(0,I.jsx)(an,{});case`people`:return(0,I.jsx)(zr,{});case`environment`:return(0,I.jsx)(Xn,{})}}function Vr({tab:e,tabs:t}){let n=(0,j.useId)(),i=(0,j.useCallback)(e=>`${n}-tab-${e}`,[n]);return(0,I.jsxs)(`div`,{className:`setup`,children:[(0,I.jsxs)(`header`,{className:`setup-header`,children:[(0,I.jsx)(`h1`,{className:`setup-title`,children:`Setup`}),(0,I.jsxs)(`p`,{className:`setup-lead`,children:[`How the site is configured. Each tab says where its values come from: the configuration —`,` `,(0,I.jsx)(`code`,{children:`krantho.config.ts`}),`, `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),` and the environment, read-only here — the site's database, changed here, or what the running server reports.`]})]}),(0,I.jsx)(r,{label:`Setup`,tabs:t,current:e,tabId:i,panelId:`${n}-panel`}),(0,I.jsx)(`div`,{id:`${n}-panel`,role:`tabpanel`,"aria-labelledby":i(e),className:`setup-panel`,children:(0,I.jsx)(Br,{tab:e})})]})}export{Vr as SetupPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{i as r,n as i,t as a}from"./fill-run-view-ChrOLoV4.js";import{A as o,E as s,G as c,I as l,K as u,O as d,Ot as f,R as p,T as m,Tt as ee,V as te,W as ne,X as re,Z as ie,_ as ae,at as oe,b as se,ct as ce,d as h,dt as le,et as g,f as _,ft as ue,ht as de,k as v,nt as fe,o as pe,ot as me,pt as he,q as ge,rt as _e,s as y,v as ve,w as ye,y as be}from"./index-d5j-az5g.js";import{i as b}from"./auth-CIpilSKF.js";import{n as xe,t as x}from"./use-loaded-BNCu0C-c.js";import{n as S,t as C}from"./createLucideIcon-BklFHeMd.js";import{t as w}from"./trash-DzRCm500.js";import{t as T}from"./action-button-DIrhqMRc.js";import{c as Se,o as Ce,y as we}from"./api-seo-DeG5gsh6.js";import{t as Te}from"./list-checks-BCEhMMVY.js";import{a as Ee,i as De,n as Oe,r as ke,s as Ae,t as je,u as Me}from"./fill-job-CKtHKXwV.js";import{d as Ne,l as Pe,n as Fe,r as E,t as D,u as Ie}from"./format-C3ZX9yGM.js";import{t as O}from"./data-table-B1kqxrEw.js";import{t as Le}from"./empty-state-CeUZocHx.js";import{r as Re,t as ze}from"./vendor-router-B4czwg8X.js";import{t as Be}from"./guards-BFEDbduR.js";import{t as Ve}from"./source-CGZGd3Xy.js";import{t as He}from"./pencil-xdGZtrO4.js";import{t as Ue}from"./copy-V85khWct.js";import{t as We}from"./clock-DoBIVjZO.js";import{t as Ge}from"./send-kYpW5JED.js";import{i as k,t as Ke}from"./api-client-BRi_ki2Y.js";import{t as qe}from"./use-locale-versions-CcJ_us1I.js";var Je={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Je.node;var Ye=C(Je),Xe={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};Xe.node;var Ze=C(Xe),Qe={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Qe.node;var $e=C(Qe),et={name:`list-tree`,size:24,node:[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]};et.node;var tt=C(et),nt={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};nt.node;var rt=C(nt),it={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};it.node;var at=C(it),ot={name:`refresh-ccw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]};ot.node;var st=C(ot),ct={name:`user-plus`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]};ct.node;var lt=C(ct);async function ut(){let{users:e}=await k(`/users`);return e}async function dt(e){return k(`/users`,{method:`POST`,body:JSON.stringify(e)})}async function A(e,t){return k(`/users/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)})}async function ft(e){await k(`/users/${encodeURIComponent(e)}`,{method:`DELETE`})}var pt={anthropic:{label:`Claude`,vendor:`Anthropic`,format:`anthropic`,baseUrl:`https://api.anthropic.com`,defaultModel:`claude-haiku-4-5`,chatPath:`/v1/messages`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`},"claude-code":{label:`Claude Code`,vendor:`Anthropic`,format:`anthropic`,baseUrl:`https://api.anthropic.com`,defaultModel:`claude-haiku-4-5-20251001`,chatPath:`/v1/messages`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`},openai:{label:`ChatGPT`,vendor:`OpenAI`,format:`openai`,baseUrl:`https://api.openai.com`,defaultModel:`gpt-4o`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_completion_tokens`,forbidTools:`tool_choice`,openObjects:`native`,reasoningParam:`reasoning_effort`},gemini:{label:`Gemini`,vendor:`Google`,format:`openai`,baseUrl:`https://generativelanguage.googleapis.com/v1beta/openai`,defaultModel:`gemini-3.6-flash`,chatPath:`/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`json_string`,reasoningParam:`reasoning_effort`},openrouter:{label:`OpenRouter`,vendor:`OpenRouter`,format:`openai`,baseUrl:`https://openrouter.ai/api`,defaultModel:`anthropic/claude-haiku-4.5`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`tool_choice`,openObjects:`native`,reasoningParam:`reasoning`},ollama:{label:`Ollama`,vendor:`Ollama (on your own computer)`,format:`openai`,baseUrl:`http://localhost:11434`,defaultModel:`llama3.1`,chatPath:`/v1/chat/completions`,maxTokensParam:`max_tokens`,forbidTools:`omit_tools`,openObjects:`native`,reasoningParam:`reasoning_effort`}},j=e(n(),1),mt=`claude-code`,ht=[`openrouter`,mt,`ollama`];function gt(e){return Object.hasOwn(pt,e)}function M(e){return gt(e)?pt[e]:null}function N(e){return M(e)?.label??e}function _t(e){return M(e)?.vendor??e}function vt(e){return ht.includes(e)}function yt(e){return e.providers.filter(e=>e.ready).sort((e,t)=>Number(t.active)-Number(e.active))}function bt(e){return e.providers.filter(e=>!e.ready&&!vt(e.provider))}function xt(e){return e.providers.filter(e=>!e.ready&&vt(e.provider))}function St(e,t=!0){return!e.configured||!e.provider?t?`AI help is off. Add a key below to turn it on.`:`AI help is off. An admin can add a key to turn it on.`:`AI help is on, using ${N(e.provider)}.`}function Ct(e){return!e.configured||!e.provider?`The AI`:`${N(e.provider)} · ${e.model??`its default model`}`}function wt(e){return e===`saved`?`Key saved here, encrypted.`:e===`environment`||e===`configuration`?`Set up by your developer.`:`Runs on your own computer.`}var Tt=/401|403|unauthori[sz]ed|invalid|incorrect|api[ -]?key|permission/i;function Et(e,t){let n=N(e);return t.success?`${n} works: it answered.`:Tt.test(t.error??``)?`${n} did not accept the key. Check that you copied all of it.`:`${n} did not answer: ${t.error??`no reason given`}.`}function P(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(!1);async function r(e){if(!n.current){n.current=!0,t(!0);try{await e()}finally{n.current=!1,t(!1)}}}return{busy:e,once:r}}function F(){let{busy:e,once:t}=P(),[n,r]=(0,j.useState)(null);return{busy:e,error:n,setError:r,run:(e,n)=>t(async()=>{r(null);try{await e()}catch(e){r(_(e,n))}})}}function Dt(e){let t=g(),{busy:n,once:r}=P();function i(e,n){r(async()=>{try{await e()}catch(e){t({text:_(e,n),tone:`error`})}})}async function a(e){let n=await d(e);t({text:Et(e,n),tone:n.success?`success`:`error`})}return{busy:n,turnOn:t=>i(async()=>{e(await v(t)),await a(t.provider)},`The key could not be saved`),use:n=>i(async()=>{e(await v({provider:n,use:!0})),t({text:`The site now uses ${N(n)}.`})},`The AI could not be changed`),save:n=>i(async()=>{e(await v(n)),t({text:`Saved the settings for ${N(n.provider)}.`})},`The settings could not be saved`),test:e=>i(()=>a(e),`The test failed`)}}var I=t();function L({title:e,children:t,confirmLabel:n,danger:r=!1,onConfirm:i,onClose:a}){let o=(0,j.useRef)(null),{busy:s,error:c,run:l}=F(),u=s?()=>void 0:a;return(0,I.jsxs)(h,{title:e,onClose:u,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{ref:o,onClick:u,"aria-disabled":s,children:`Cancel`}),(0,I.jsx)(S,{variant:r?`danger`:`primary`,"aria-disabled":s,onClick:()=>void l(i,`It did not work`),children:s?`Working…`:n})]}),initialFocus:o,busy:s,children:[(0,I.jsx)(`div`,{className:`setup-confirm`,children:t}),c&&(0,I.jsx)(R,{text:c})]})}function R({text:e}){return(0,I.jsx)(`p`,{role:`alert`,className:`setup-note setup-note--error`,children:e})}function Ot({id:e,label:t,hint:n,children:r}){return(0,I.jsxs)(`div`,{className:`setup-field`,children:[(0,I.jsx)(`label`,{htmlFor:e,children:t}),r,n&&(0,I.jsx)(`span`,{id:`${e}-hint`,className:`setup-hint`,children:n})]})}function z({label:e,value:t,onChange:n,disabled:r=!1,hint:i,type:a=`text`,placeholder:o}){let s=(0,j.useId)();return(0,I.jsx)(Ot,{id:s,label:e,hint:i,children:(0,I.jsx)(`input`,{id:s,type:a,className:`setup-input`,value:t,disabled:r,placeholder:o,"aria-describedby":i?`${s}-hint`:void 0,onChange:e=>n(e.target.value)})})}function B({label:e,value:t,onChange:n,disabled:r=!1,hint:i,options:a}){let o=(0,j.useId)(),s=e=>{let t=a.find(t=>t.value===e);t&&n(t.value)};return(0,I.jsx)(Ot,{id:o,label:e,hint:i,children:(0,I.jsx)(`select`,{id:o,className:`setup-input`,value:t,disabled:r,"aria-describedby":i?`${o}-hint`:void 0,onChange:e=>s(e.target.value),children:a.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})})}function kt({label:e,checked:t,onChange:n}){return(0,I.jsxs)(`label`,{className:`setup-check`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),e]})}function At({provider:e}){return(0,I.jsxs)(`div`,{className:`ai-card-title`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e)}),(0,I.jsx)(`span`,{className:`setup-muted`,children:_t(e)})]})}function jt({provider:e,onRemoved:t,onClose:n}){let r=g();async function i(){t(await ye(e)),r({text:`Removed the saved key for ${N(e)}.`}),n()}return(0,I.jsx)(L,{title:`Remove the key for ${N(e)}?`,confirmLabel:`Remove key`,danger:!0,onConfirm:i,onClose:n,children:(0,I.jsx)(`p`,{children:`The key saved here is deleted, and it cannot be shown again: you would have to paste it anew. A key set up by your developer is not touched.`})})}function Mt({status:e,actions:t}){let n=M(e.provider),[r,i]=(0,j.useState)(e.model??``),[a,o]=(0,j.useState)(e.baseUrl??``),s=e.provider===mt;return(0,I.jsxs)(`details`,{className:`ai-advanced`,children:[(0,I.jsx)(`summary`,{children:`Advanced`}),(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsx)(z,{label:`Model`,value:s?n?.defaultModel??``:r,onChange:i,disabled:s,placeholder:n?.defaultModel,hint:s?`Fixed: this one runs a single model.`:`Empty uses the default model.`}),(0,I.jsx)(z,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl,hint:`Only for a proxy or your own server. Empty uses the usual address.`}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(S,{"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a}),children:`Save`})})]})]})}function Nt({status:e,actions:t,readOnly:n,onChange:r}){let[i,a]=(0,j.useState)(!1),o=t.busy?`Working…`:null;return(0,I.jsxs)(`li`,{className:`ai-card ai-card--on`,children:[(0,I.jsxs)(`div`,{className:`ai-card-head`,children:[(0,I.jsx)(At,{provider:e.provider}),e.active&&(0,I.jsx)(y,{tone:`success`,icon:xe,children:`In use`})]}),(0,I.jsx)(`p`,{className:`setup-note`,children:wt(e.keySource)}),!n&&(0,I.jsxs)(`div`,{className:`setup-actions`,children:[!e.active&&(0,I.jsx)(T,{variant:`primary`,icon:at,reason:o,onClick:()=>t.use(e.provider),children:`Use this one`}),(0,I.jsx)(T,{icon:rt,reason:o,onClick:()=>t.test(e.provider),children:`Test`}),e.keySource===`saved`&&(0,I.jsx)(S,{variant:`ghost`,icon:w,onClick:()=>a(!0),children:`Remove key`})]}),!n&&(0,I.jsx)(Mt,{status:e,actions:t}),i&&(0,I.jsx)(jt,{provider:e.provider,onRemoved:r,onClose:()=>a(!1)})]})}function Pt({status:e,actions:t}){let[n,r]=(0,j.useState)(``),i=N(e.provider),a=()=>{t.turnOn({provider:e.provider,apiKey:n}),r(``)},o=t.busy?`Working…`:n.trim()===``?`Paste the key first.`:null;return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`div`,{className:`ai-card-head`,children:(0,I.jsx)(At,{provider:e.provider})}),(0,I.jsx)(z,{label:`${i} key`,type:`password`,value:n,onChange:r,hint:`Paste the key from ${_t(e.provider)}. It is saved encrypted and never shown again.`}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(T,{variant:`primary`,icon:$e,reason:o,onClick:a,children:`Turn on`})})]})}function Ft({status:e}){return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e.provider)}),(0,I.jsxs)(`p`,{className:`setup-note`,children:[`Runs on your Claude subscription, on your own machine only. Set the token`,` `,(0,I.jsx)(`code`,{children:`claude setup-token`}),` prints as `,(0,I.jsx)(`code`,{children:e.env}),`, and restart the site.`]})]})}function It({status:e,actions:t}){let n=M(e.provider),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)(``);return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:N(e.provider)}),(0,I.jsx)(`p`,{className:`setup-note`,children:`Runs a model on your own computer. It needs no key.`}),(0,I.jsx)(z,{label:`Model`,value:r,onChange:i,placeholder:n?.defaultModel}),(0,I.jsx)(z,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(S,{variant:`primary`,"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a,use:!0}),children:`Turn on`})})]})}function Lt({status:e,actions:t}){return e.provider===`claude-code`?(0,I.jsx)(Ft,{status:e}):e.provider===`ollama`?(0,I.jsx)(It,{status:e,actions:t}):(0,I.jsx)(Pt,{status:e,actions:t})}function Rt({settings:e,providers:t,actions:n}){let r=e.providers.filter(e=>e.env!==``);return(0,I.jsxs)(`details`,{className:`ai-developer`,children:[(0,I.jsx)(`summary`,{children:`For developers`}),(0,I.jsxs)(`div`,{className:`setup-stack`,children:[t.length>0&&(0,I.jsx)(`ul`,{className:`ai-cards`,children:t.map(e=>(0,I.jsx)(Lt,{status:e,actions:n},e.provider))}),(0,I.jsxs)(`div`,{className:`setup-prose`,children:[(0,I.jsx)(`p`,{children:`A key can also be set in the environment of the machine that runs the site. A provider with a key there turns on at the next start, and no key is saved in the database.`}),(0,I.jsx)(`ul`,{className:`ai-variables`,children:r.map(e=>(0,I.jsxs)(`li`,{children:[N(e.provider),`: `,(0,I.jsx)(`code`,{children:e.env})]},e.provider))})]})]})]})}var zt={config:{icon:Ze,label:`Configuration`},database:{icon:Ye,label:`Database`},server:{icon:_e,label:`Server`}};function V({source:e,children:t}){let{icon:n,label:r}=zt[e];return(0,I.jsxs)(`p`,{className:`setup-source`,children:[(0,I.jsx)(y,{icon:n,children:r}),(0,I.jsx)(`span`,{children:t})]})}function H({title:e,sources:t,actions:n,children:r}){let i=(0,j.useId)();return(0,I.jsxs)(`section`,{className:`setup-section`,"aria-labelledby":i,children:[(0,I.jsxs)(`div`,{className:`setup-section-head`,children:[(0,I.jsx)(`h2`,{id:i,className:`setup-section-title`,children:e}),n&&(0,I.jsx)(`div`,{className:`setup-actions`,children:n})]}),(0,I.jsx)(`div`,{className:`setup-sources`,children:t}),r]})}function U({children:e,tone:t=`muted`}){return(0,I.jsx)(`p`,{className:t===`error`?`setup-note setup-note--error`:`setup-note`,children:e})}function W({what:e}){return(0,I.jsxs)(U,{children:[`Reading `,e,`…`]})}function G({message:e,onRetry:t}){return(0,I.jsxs)(`div`,{role:`alert`,className:`setup-row`,children:[(0,I.jsx)(U,{tone:`error`,children:e}),(0,I.jsx)(S,{size:`sm`,icon:we,onClick:t,children:`Try again`})]})}var Bt=new Map([[je,`Fill missing SEO`],[ke,`Meta only`],[Oe,`Force regenerate`]]);function Vt(e){return e.scope===`collection`?`${D(e.collection)}`:`the whole site`}function Ht(e){let t=e.state===`idle`?`Enrichment`:Bt.get(e.plan)??`Enrichment`;return e.state===`failed`?{text:`${t} failed: ${e.message}`,tone:`error`}:{text:`${t} finished. Setup › AI provider lists what each step did.`}}function Ut(){return(0,I.jsxs)(`div`,{className:`setup-prose`,children:[(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`strong`,{children:`Fill missing SEO`}),` writes meta descriptions and the Schema.org properties no one has set. `,(0,I.jsx)(`strong`,{children:`Meta only`}),` writes only the missing meta descriptions. Neither overwrites a value someone set. `,(0,I.jsx)(`strong`,{children:`Force regenerate`}),` writes both over every value, the editors' own included.`]}),(0,I.jsx)(`p`,{children:`What a run writes is saved at once: each meta description as a new version of its document and in the document's SEO settings, the Schema.org properties in those settings. The SEO settings have no versions, so the live pages' meta descriptions and structured data change straight away. A document someone else is editing keeps its meta description.`})]})}function Wt({scope:e,model:t,onConfirm:n,onClose:r}){return(0,I.jsxs)(L,{title:`Force regenerate SEO for ${Vt(e)}?`,confirmLabel:`Overwrite and regenerate`,danger:!0,onConfirm:n,onClose:r,children:[(0,I.jsxs)(`p`,{children:[t,` writes a new meta description and new Schema.org properties for every document in`,` `,Vt(e),`. It`,` `,(0,I.jsx)(`strong`,{children:`overwrites the values there now, the editors' own included`}),`.`]}),(0,I.jsx)(`p`,{children:`Each meta description is saved as a new version of its document and in the document's SEO settings; the Schema.org properties are written to those settings, which have no versions. The live pages' meta descriptions and structured data change at once: this is not a draft, there is nothing to publish first, and the SEO settings keep no earlier values to go back to. A document someone else is editing keeps its meta description.`})]})}function Gt(e,t,n){return e.state===`running`?`Enrichment is running.`:t?n?null:`Add an AI key first.`:`Enrichment is run by an admin.`}function Kt({reason:e,onRun:t,onForce:n}){return(0,I.jsxs)(`div`,{className:`setup-actions`,children:[(0,I.jsx)(T,{variant:`primary`,icon:Me,reason:e,onClick:()=>t(je),children:`Fill missing SEO`}),(0,I.jsx)(T,{icon:Te,reason:e,onClick:()=>t(ke),children:`Meta only`}),(0,I.jsx)(T,{variant:`danger`,icon:st,reason:e,onClick:n,children:`Force regenerate…`})]})}function qt(){let{loaded:e}=x(te,`The collections could not be read`);return e.state===`ready`?e.data.filter(e=>e.pages):[]}var Jt=(0,I.jsx)(V,{source:`database`,children:`Writes to the documents and their SEO settings in the site's database, with the AI in use above.`});function Yt({configured:e,admin:t,model:n}){let r=g(),o=Ae(),s=qt(),[c,l]=(0,j.useState)({scope:`all`}),[u,d]=(0,j.useState)(!1);(0,j.useEffect)(()=>()=>De(),[]);let f=(0,j.useCallback)(e=>Ee(c,e=>r(Ht(e)),e),[c,r]),p=Gt(o,t,e),m=o.state===`running`;return(0,I.jsxs)(H,{title:`Run across the site`,sources:Jt,children:[(0,I.jsx)(Ut,{}),(0,I.jsx)(i,{collections:s,value:c,disabled:m,onChange:l}),(0,I.jsx)(Kt,{reason:p,onRun:f,onForce:()=>d(!0)}),p&&!m&&(0,I.jsx)(`p`,{className:`setup-note`,children:p}),(0,I.jsx)(a,{run:o}),u&&(0,I.jsx)(Wt,{scope:c,model:n,onClose:()=>d(!1),onConfirm:async()=>{d(!1),f(Oe)||r({text:`Another run is going across the site, so Force regenerate did not start. Try again when it ends.`,tone:`error`})}})]})}function Xt({settings:e,readOnly:t,onChange:n}){let r=Dt(n),i=yt(e),a=bt(e);return(0,I.jsxs)(I.Fragment,{children:[i.length>0&&(0,I.jsxs)(`section`,{className:`ai-group`,"aria-labelledby":`ai-configured`,children:[(0,I.jsx)(`h3`,{id:`ai-configured`,className:`ai-group-title`,children:`Ready to use`}),(0,I.jsx)(`ul`,{className:`ai-cards`,children:i.map(e=>(0,I.jsx)(Nt,{status:e,actions:r,readOnly:t,onChange:n},e.provider))})]}),!t&&a.length>0&&(0,I.jsxs)(`section`,{className:`ai-group`,"aria-labelledby":`ai-available`,children:[(0,I.jsx)(`h3`,{id:`ai-available`,className:`ai-group-title`,children:i.length>0?`Add another`:`Add a key to turn one on`}),(0,I.jsx)(`ul`,{className:`ai-cards`,children:a.map(e=>(0,I.jsx)(Pt,{status:e,actions:r},e.provider))})]}),!t&&(0,I.jsx)(Rt,{settings:e,providers:xt(e),actions:r})]})}function Zt(){let e=b().hasRole(`admin`),{loaded:t,reload:n}=x(m,`The AI provider could not be read`),[r,i]=(0,j.useState)(null);if(t.state===`loading`)return(0,I.jsx)(W,{what:`the AI provider`});if(t.state===`error`)return(0,I.jsx)(G,{message:t.message,onRetry:n});let a=r??t.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(H,{title:`AI help`,sources:(0,I.jsx)(`p`,{className:`setup-source`,children:`An AI turns on when it has a key. Pick the one the site uses; the assistant lets editors pick another.`}),children:[(0,I.jsx)(`p`,{className:a.configured?`ai-status ai-status--on`:`ai-status`,role:`status`,children:St(a,e)}),(0,I.jsx)(Xt,{settings:a,readOnly:!e,onChange:i}),a.assistantProvider&&(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The assistant is set to `,N(a.assistantProvider),` in the site's configuration.`]})]}),(0,I.jsx)(Yt,{configured:a.configured,admin:e,model:Ct(a)})]})}var Qt={manual:`By hand`,"pre-restore":`Before a restore`,"pre-migration":`Before a migration`,"pre-import":`Before an import`};function K(e){return e.name?`v${e.version} · ${e.name}`:`v${e.version}`}function $t({checkpoint:e,onDone:t,onClose:n}){let r=g(),i=K(e);async function a(){await se(e.version),r({text:`Restored ${i}. A safety checkpoint of the state before was taken first.`}),t()}return(0,I.jsxs)(L,{title:`Restore ${i}?`,confirmLabel:`Restore checkpoint`,danger:!0,onConfirm:a,onClose:n,children:[(0,I.jsxs)(`p`,{children:[`Every document — the version being edited and the version that is live — the runtime fields and the media library's records go back to how they stood at`,` `,E(e.createdAt),`. Versions saved since stay in each document's history but are no longer current.`]}),(0,I.jsxs)(`p`,{children:[`A safety checkpoint, `,(0,I.jsxs)(`code`,{children:[`pre-restore-v`,e.version]}),`, is taken first, so you can return to how things are now. Settings, SEO configuration and people are not rewound.`]}),(0,I.jsx)(`p`,{children:`Every cached page is marked stale: its next visit may still get the old page while it is rendered again.`})]})}function en({checkpoint:e,onDone:t,onClose:n}){let r=g(),i=K(e);async function a(){await ve(e.version),r({text:`Deleted ${i}.`}),t()}return(0,I.jsx)(L,{title:`Delete ${i}?`,confirmLabel:`Delete checkpoint`,danger:!0,onConfirm:a,onClose:n,children:(0,I.jsx)(`p`,{children:`It can no longer be restored. The content stays as it is.`})})}function tn(e,t){return[{id:`name`,header:`Checkpoint`,primary:!0,cell:e=>K(e)},{id:`trigger`,header:`Taken`,cell:e=>(0,I.jsx)(y,{children:Qt[e.trigger]})},{id:`created`,header:`Created`,cell:e=>E(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>e?(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(S,{size:`sm`,icon:oe,"aria-label":`Restore ${K(n)}`,onClick:()=>t({kind:`restore`,checkpoint:n}),children:`Restore`}),(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-label":`Delete ${K(n)}`,onClick:()=>t({kind:`delete`,checkpoint:n}),children:`Delete`})]}):null}]}function nn({onCreated:e}){let t=g(),[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(!1);async function s(){if(!o.current){o.current=!0,a(!0);try{let i=await ae(n.trim()||void 0);t({text:`Created ${K(i)}.`}),r(``),e()}catch(e){t({text:_(e,`The checkpoint could not be created`),tone:`error`})}finally{o.current=!1,a(!1)}}}return(0,I.jsxs)(`form`,{className:`setup-inline-form`,onSubmit:e=>{e.preventDefault(),i||s()},children:[(0,I.jsx)(z,{label:`Name`,value:n,onChange:r,placeholder:`Before the spring relaunch`,hint:`Optional`}),(0,I.jsx)(S,{type:`submit`,variant:`primary`,icon:de,"aria-disabled":i,children:i?`Creating…`:`Create checkpoint`})]})}function rn(){return(0,I.jsx)(V,{source:`database`,children:`Stored in the site's database. A checkpoint marks a point in time and copies nothing; restoring one rewinds to it. The API lists each checkpoint's number, name, what took it and when — not its size or the schema version it was taken under.`})}function an(){let{hasRole:e}=b(),{loaded:t,reload:n}=x(be,`The checkpoints could not be read`),[r,i]=(0,j.useState)(null),a=()=>i(null),o=()=>{a(),n()};return(0,I.jsxs)(H,{title:`Checkpoints`,sources:(0,I.jsx)(rn,{}),children:[e(`editor`)?(0,I.jsx)(nn,{onCreated:n}):(0,I.jsx)(U,{children:`Editors and admins create checkpoints.`}),t.state===`loading`&&(0,I.jsx)(W,{what:`the checkpoints`}),t.state===`error`&&(0,I.jsx)(G,{message:t.message,onRetry:n}),t.state===`ready`&&t.data.length===0&&(0,I.jsx)(Le,{icon:de,title:`No checkpoints yet`,children:`Create one to mark the content store as it is now, so you can return to it.`}),t.state===`ready`&&t.data.length>0&&(0,I.jsx)(O,{caption:`Checkpoints, newest first`,columns:tn(e(`admin`),i),rows:t.data,rowKey:e=>String(e.version)}),r?.kind===`restore`&&(0,I.jsx)($t,{checkpoint:r.checkpoint,onDone:o,onClose:a}),r?.kind===`delete`&&(0,I.jsx)(en,{checkpoint:r.checkpoint,onDone:o,onClose:a})]})}async function on(e){let[t,n,r]=await Promise.all([te(),Ve(e,Se),Ve(e,async()=>(await Ce()).types)]);return{collections:t,configs:n,catalog:r}}function sn(e,t){return e.state===`ok`?e.value.find(e=>e.id===`collection:${t}`)?.config.entities.map(e=>e[`@type`])??[]:null}function cn(e,t){if(e.state!==`ok`||t===null)return null;let n=e.value.filter(e=>t.includes(e.type)&&e.richResult!==null).filter(e=>e.richResultStatus===`active`||e.richResultStatus===`restricted`).map(e=>e.richResult??``);return[...new Set(n)]}function ln(e){return e.collections.map(t=>{let n=t.pages?sn(e.configs,t.name):[];return{collection:t,rendersAt:pe(t,`:slug`),types:n,richResults:t.pages?cn(e.catalog,n):[]}})}function un(e){return e==null?null:typeof e==`string`?e:JSON.stringify(e)}function dn(e){return e.enum?`enum`:e.format===`uri`?`url`:e.format===`email`?`email`:String(e.type??`string`)}function fn(e,t){let n=new Set(e.schema.required??[]),r=Object.entries(e.schema.properties??{}).filter(([,e])=>!(Be(e)&&e._runtime)).map(([e,t])=>({name:e,type:dn(t),required:n.has(e),description:t.description??null,defaultValue:un(t.default),source:`code`,runtime:null})),i=t.map(e=>({name:e.name,type:e.type,required:e.required,description:e.description??null,defaultValue:un(e.default),source:`runtime`,runtime:e}));return[...r,...i]}var pn=[`string`,`textarea`,`number`,`boolean`,`date`,`enum`,`url`,`email`,`color`,`reference`],mn={string:`text (one line)`,textarea:`text (long)`,number:`number`,boolean:`yes/no`,date:`date`,enum:`choice`,url:`web address`,email:`email`,color:`color`,reference:`link to a page`,integer:`number`,array:`list`,object:`group`};function hn(e){return mn[e]??e}var q=e=>e==null?``:String(e);function gn(e){return{name:e?.name??``,type:e?.type??`string`,required:e?.required??!1,description:e?.description??``,defaultValue:q(e?.default),enumValues:e?.enumValues?.join(`, `)??``,refCollection:e?.refCollection??``,min:q(e?.min),max:q(e?.max),pattern:e?.pattern??``}}function J(e){return e===`string`||e===`textarea`||e===`number`}function _n(e){let t=e.defaultValue.trim();if(t)return e.type===`number`?Number(t):e.type===`boolean`?t===`true`:t}function Y(e){return e.enumValues.split(`,`).map(e=>e.trim()).filter(Boolean)}function vn(e){let t=e.defaultValue.trim();return t?e.type===`number`&&!Number.isFinite(Number(t))?`The default is a number.`:e.type===`boolean`&&t!==`true`&&t!==`false`?`The default is true or false.`:e.type===`enum`&&!Y(e).includes(t)?`The default is one of the values.`:null:null}function yn(e){if(!J(e.type))return null;let[t,n]=[e.min.trim(),e.max.trim()];return[t,n].some(e=>e&&!Number.isFinite(Number(e)))?`Minimum and maximum are numbers.`:t&&n&&Number(t)>Number(n)?`The minimum is not above the maximum.`:null}function bn(e){let t=e.pattern.trim();if(e.type!==`string`||!t)return null;try{return new RegExp(t),null}catch{return`The pattern is not a valid regular expression.`}}function xn(e){let t=e.name.trim();return t?/^[a-z][a-z0-9_-]*$/i.test(t)?e.type===`reference`&&!e.refCollection?`Choose the collection it refers to.`:e.type===`enum`&&new Set(Y(e)).size<2?`Give the enum two different values or more.`:yn(e)??bn(e)??vn(e):`A name starts with a letter and holds only letters, digits, hyphens and underscores.`:`A field needs a name.`}function Sn(e){let t=Y(e),n={name:e.name.trim(),type:e.type,required:e.required},r=_n(e);return r!==void 0&&(n.default=r),e.description.trim()&&(n.description=e.description.trim()),e.type===`enum`&&t.length>0&&(n.enumValues=t),e.type===`reference`&&(n.refCollection=e.refCollection),J(e.type)&&e.min.trim()&&(n.min=Number(e.min)),J(e.type)&&e.max.trim()&&(n.max=Number(e.max)),e.type===`string`&&e.pattern.trim()&&(n.pattern=e.pattern.trim()),n}var Cn=pn.map(e=>({value:e,label:hn(e)}));function wn({form:e,set:t}){let n=e.type===`number`;return(0,I.jsxs)(`div`,{className:`setup-field-row`,children:[(0,I.jsx)(z,{label:n?`Minimum`:`Minimum length`,type:`number`,value:e.min,onChange:t(`min`)}),(0,I.jsx)(z,{label:n?`Maximum`:`Maximum length`,type:`number`,value:e.max,onChange:t(`max`)})]})}function Tn(e){let{form:t,set:n,collections:r}=e,i=[{value:``,label:`Choose a collection`},...r.map(e=>({value:e.name,label:D(e.name)}))];return(0,I.jsxs)(I.Fragment,{children:[t.type===`enum`&&(0,I.jsx)(z,{label:`Values`,value:t.enumValues,onChange:n(`enumValues`),hint:`Separated by commas`}),t.type===`reference`&&(0,I.jsx)(B,{label:`Refers to`,value:t.refCollection,options:i,onChange:n(`refCollection`)}),J(t.type)&&(0,I.jsx)(wn,{form:t,set:n}),t.type===`string`&&(0,I.jsx)(z,{label:`Pattern`,value:t.pattern,onChange:n(`pattern`),hint:`A regular expression the value must match`})]})}function En({form:e,set:t,editing:n,collections:r}){let i=n?`A field keeps its name`:`The key documents store its value under`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:`Name`,value:e.name,onChange:t(`name`),disabled:n,hint:i}),(0,I.jsx)(B,{label:`Type`,value:e.type,options:Cn,onChange:t(`type`),disabled:n,hint:n?`A field keeps its type`:void 0}),(0,I.jsx)(kt,{label:`Required`,checked:e.required,onChange:t(`required`)}),(0,I.jsx)(z,{label:`Description`,value:e.description,onChange:t(`description`),hint:`Shown to editors under the field`}),(0,I.jsx)(z,{label:`Default`,value:e.defaultValue,onChange:t(`defaultValue`)}),(0,I.jsx)(Tn,{form:e,set:t,collections:r})]})}function Dn(e){let{collection:t,field:n,collections:r,onSave:i,onClose:a}=e,o=(0,j.useId)(),[s,c]=(0,j.useState)(()=>gn(n)),l=e=>t=>c(n=>({...n,[e]:t})),{busy:u,error:d,setError:f,run:p}=F();function m(e){e.preventDefault();let t=xn(s);t?f(t):p(()=>i(Sn(s)),`The field could not be saved`)}let ee=n?`Edit ${n.name}`:`Add a runtime field to ${D(t)}`;return(0,I.jsx)(h,{title:ee,onClose:a,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:a,children:`Cancel`}),(0,I.jsx)(S,{variant:`primary`,type:`submit`,form:o,"aria-disabled":u,children:u?`Saving…`:`Save field`})]}),busy:u,children:(0,I.jsxs)(`form`,{id:o,className:`setup-form`,onSubmit:m,children:[d&&(0,I.jsx)(R,{text:d}),(0,I.jsx)(En,{form:s,set:l,editing:n!==null,collections:r})]})})}function On(e){let t=g();return async()=>{if(e!==null)try{await navigator.clipboard.writeText(e),t({text:`Copied the Zod schema.`})}catch{t({text:`The browser did not allow copying; select the code instead.`,tone:`error`})}}}function kn({collection:e,onClose:t}){let n=(0,j.useCallback)(async()=>(await p(e)).code,[e]),{loaded:r,reload:i}=x(n,`The schema could not be exported`),a=r.state===`ready`?r.data:null,o=On(a),s=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:t,children:`Close`}),(0,I.jsx)(S,{variant:`primary`,icon:Ue,"aria-disabled":a===null,onClick:()=>void o(),children:`Copy`})]});return(0,I.jsxs)(h,{title:`${D(e)} as Zod`,onClose:t,actions:s,children:[(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The code fields and the runtime fields as one Zod schema. Paste it into`,` `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),` to make the runtime fields part of the code; code always wins over a runtime field of the same name.`]}),r.state===`loading`&&(0,I.jsx)(W,{what:`the schema`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),a!==null&&(0,I.jsx)(`section`,{className:`setup-code`,"aria-label":`Zod schema`,tabIndex:0,children:(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:a})})})]})}function An({field:e,onDialog:t}){return(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(S,{size:`sm`,icon:He,"aria-label":`Edit ${e.name}`,onClick:()=>t({kind:`edit`,field:e}),children:`Edit`}),(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-label":`Delete ${e.name}`,onClick:()=>t({kind:`delete`,field:e}),children:`Delete`})]})}function jn({field:e,admin:t,onDialog:n}){return e.runtime?t?(0,I.jsx)(An,{field:e.runtime,onDialog:n}):(0,I.jsx)(`span`,{className:`setup-muted`,children:`Admins edit runtime fields`}):(0,I.jsxs)(`span`,{className:`setup-locked`,children:[(0,I.jsx)(ce,{"aria-hidden":`true`}),`Defined in code, change it in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`; code always wins`]})}function Mn(e,t){return[{id:`field`,header:`Field`,primary:!0,cell:e=>(0,I.jsxs)(`span`,{className:`setup-name`,children:[(0,I.jsx)(`code`,{children:e.name}),e.description&&(0,I.jsx)(`span`,{className:`setup-muted`,children:e.description})]})},{id:`type`,header:`Type`,cell:e=>hn(e.type)},{id:`required`,header:`Required`,cell:e=>e.required?`Required`:`Optional`},{id:`default`,header:`Default`,cell:e=>e.defaultValue?(0,I.jsx)(`code`,{children:e.defaultValue}):`—`},{id:`source`,header:`Source`,cell:e=>e.source===`code`?(0,I.jsx)(y,{icon:ce,children:`Code`}):(0,I.jsx)(y,{tone:`accent`,children:`Runtime`})},{id:`edit`,header:`Edit`,cell:n=>(0,I.jsx)(jn,{field:n,admin:e,onDialog:t})}]}function Nn(e){let t=(0,j.useCallback)(async()=>{let[t,n]=await Promise.all([c(e),ne(e)]);return fn(t,n.fields)},[e]);return x(t,`The fields could not be read`)}function Pn({admin:e,onDialog:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{icon:Ze,onClick:()=>t({kind:`export`}),children:`Export as Zod`}),e&&(0,I.jsx)(S,{variant:`primary`,icon:me,onClick:()=>t({kind:`edit`,field:null}),children:`Add runtime field`})]})}function Fn({collection:e,collections:t,admin:n}){let{loaded:r,reload:i}=Nn(e),[a,o]=(0,j.useState)(null),s=D(e),c=(0,I.jsx)(Pn,{admin:n,onDialog:o});return(0,I.jsxs)(H,{title:`Fields of ${s}`,actions:c,sources:(0,I.jsx)(In,{}),children:[r.state===`loading`&&(0,I.jsx)(W,{what:`the fields`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(O,{caption:`Fields of ${s}`,columns:Mn(n,o),rows:r.data,rowKey:e=>`${e.source}:${e.name}`}),a&&(0,I.jsx)(Rn,{collection:e,collections:t,dialog:a,onClose:()=>o(null),onChanged:i})]})}function In(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{source:`config`,children:[`Code fields come from the collection's Zod schema in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`, read-only here.`]}),(0,I.jsx)(V,{source:`database`,children:`Runtime fields are stored in the site's database: added, edited and deleted here, and added to the collection's form at once.`})]})}function Ln({collection:e,name:t,onDone:n,onClose:r}){return(0,I.jsxs)(L,{title:`Delete the field ${t}?`,confirmLabel:`Delete field`,danger:!0,onConfirm:async()=>{await l(e,t),n(`Deleted the runtime field ${t}.`)},onClose:r,children:[(0,I.jsxs)(`p`,{children:[`The runtime field `,(0,I.jsx)(`code`,{children:t}),` is removed from `,D(e),`'s schema, so its form no longer shows it.`]}),(0,I.jsx)(`p`,{children:`Only the schema changes. Documents keep the values they already hold in the field; the form no longer shows them.`})]})}function Rn(e){let{collection:t,collections:n,dialog:r,onClose:i,onChanged:a}=e,o=g(),s=e=>{o({text:e}),i(),a()};return r.kind===`export`?(0,I.jsx)(kn,{collection:t,onClose:i}):r.kind===`delete`?(0,I.jsx)(Ln,{collection:t,name:r.field.name,onDone:s,onClose:i}):(0,I.jsx)(Dn,{collection:t,field:r.field,collections:n,onSave:async e=>{await ie(t,e),s(`Saved the runtime field ${e.name}.`)},onClose:i})}var X=`collection`;function zn({names:e,none:t}){return e===null?(0,I.jsx)(`span`,{className:`setup-muted`,children:`Not read`}):e.length===0?(0,I.jsx)(`span`,{className:`setup-muted`,children:t}):(0,I.jsx)(`span`,{className:`setup-chips`,children:e.map(e=>(0,I.jsx)(y,{children:e},e))})}function Bn({name:e}){return(0,I.jsxs)(`span`,{className:`setup-name`,children:[D(e),(0,I.jsx)(`code`,{className:`setup-muted`,children:e})]})}function Vn({name:e,open:t,onFields:n}){return(0,I.jsx)(S,{size:`sm`,icon:tt,variant:t?`primary`:`secondary`,"aria-label":`Fields of ${D(e)}`,"aria-pressed":t,onClick:()=>n(e),children:`Fields`})}function Hn(e,t){return[{id:`collection`,header:`Collection`,primary:!0,cell:e=>(0,I.jsx)(Bn,{name:e.collection.name})},{id:`renders`,header:`Renders at`,cell:e=>e.rendersAt?(0,I.jsx)(`code`,{children:e.rendersAt}):(0,I.jsx)(`span`,{className:`setup-muted`,children:`No pages`})},{id:`types`,header:`Schema.org types`,cell:e=>(0,I.jsx)(zn,{names:e.types,none:`None set`})},{id:`rich`,header:`Rich results`,cell:e=>(0,I.jsx)(zn,{names:e.richResults,none:`None`})},{id:`fields`,header:`Fields`,cell:n=>(0,I.jsx)(Vn,{name:n.collection.name,open:e===n.collection.name,onFields:t})}]}function Un({seo:e}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{source:`config`,children:[`The collections and where they render come from `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`, read-only here.`]}),e&&(0,I.jsxs)(V,{source:`database`,children:[`The Schema.org types are each collection's archetype, set in`,` `,(0,I.jsx)(ze,{to:f(`collection`),children:`Structure › Scopes & archetypes`}),`. The rich results are what the catalog says those types are eligible for.`]})]})}function Wn(){let[e,t]=Re(),n=e.get(X),r=(0,j.useRef)(null),i=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{n&&i.current&&r.current?.focus(),i.current=!1},[n]),{open:n,onFields:(0,j.useCallback)(e=>{i.current=!0,t({[X]:e},{replace:!0})},[t]),ref:r}}function Gn(){let e=Ie(Ne(),`seo`),t=b().hasRole(`admin`),n=(0,j.useCallback)(()=>on(e),[e]),{loaded:r,reload:i}=x(n,`The collections could not be read`),{open:a,onFields:o,ref:s}=Wn(),c=r.state===`ready`?r.data.collections:[],l=c.some(e=>e.name===a);return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(H,{title:`Collections & schema`,sources:(0,I.jsx)(Un,{seo:e}),children:[r.state===`loading`&&(0,I.jsx)(W,{what:`the collections`}),r.state===`error`&&(0,I.jsx)(G,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(O,{caption:`Collections`,columns:Hn(a,o),rows:ln(r.data),rowKey:e=>e.collection.name})]}),a&&r.state===`ready`&&!l&&(0,I.jsxs)(U,{children:[`No collection is named `,a,`.`]}),a&&l&&(0,I.jsx)(`div`,{ref:s,tabIndex:-1,className:`setup-focus-target`,children:(0,I.jsx)(Fn,{collection:a,collections:c,admin:t},a)})]})}function Kn(e){return e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function qn(e){let t=[],n=Pe(e);n&&t.push({name:`Framework`,value:n}),t.push({name:`Persistence`,value:e.persistence},{name:`Auth`,value:e.authMode}),e.schemaVersion!==null&&t.push({name:`Schema version`,value:`v${String(e.schemaVersion).padStart(3,`0`)}`});for(let[n,r]of Object.entries(e.features))t.push({name:Kn(n),value:r});return t}function Jn({value:e}){return(0,I.jsx)(y,{tone:e===`disabled`||e===`none`?`neutral`:`success`,children:e})}var Yn=[{id:`name`,header:`Capability`,primary:!0,cell:e=>e.name},{id:`value`,header:`Value`,cell:e=>(0,I.jsx)(Jn,{value:e.value})}];function Xn(){let e=Ne();return(0,I.jsx)(H,{title:`Environment`,sources:(0,I.jsxs)(V,{source:`server`,children:[`What the running server reports (`,(0,I.jsx)(`code`,{children:`GET /api/capabilities`}),`), read-only. It follows the configuration and the persistence the server started with.`]}),children:(0,I.jsx)(O,{caption:`What the server reports`,columns:Yn,rows:qn(e),rowKey:e=>e.name})})}var Zn=[{id:`all`,label:`All`},{id:`pending`,label:`Pending`},{id:`delivered`,label:`Delivered`},{id:`failed`,label:`Failed`}];function Qn(e){return e.deliveredAt?`delivered`:e.attempts>=5?`failed`:`pending`}function $n(e){return e===null?`—`:e===0?`Network error`:String(e)}function er(e){switch(e){case`pending`:return`No delivery is waiting for another attempt.`;case`delivered`:return`No delivery has reached its webhook yet.`;case`failed`:return`No delivery has failed.`;default:return`Nothing has been sent yet.`}}function tr(e,t){let n=Math.ceil(t/25);return n>1?`Page ${e+1} of ${n}`:null}var nr={delivered:(0,I.jsx)(y,{tone:`success`,icon:he,children:`Delivered`}),pending:(0,I.jsx)(y,{tone:`warning`,icon:We,children:`Pending`}),failed:(0,I.jsx)(y,{tone:`danger`,icon:ue,children:`Failed`})};function rr(e,t){return[{id:`event`,header:`Event`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.event})},{id:`url`,header:`URL`,cell:e=>(0,I.jsx)(`span`,{className:`setup-url`,children:e.url})},{id:`state`,header:`State`,cell:e=>nr[Qn(e)]},{id:`http`,header:`HTTP`,numeric:!0,cell:e=>$n(e.status)},{id:`attempts`,header:`Attempts`,numeric:!0,cell:e=>`${e.attempts} / 5`},{id:`created`,header:`Created`,cell:e=>E(e.createdAt)},{id:`delivered`,header:`Delivered`,cell:e=>e.deliveredAt?E(e.deliveredAt):`—`},{id:`retry`,header:`Retry`,cell:n=>Qn(n)===`failed`?(0,I.jsx)(S,{size:`sm`,icon:Ge,"aria-disabled":e!==null,"aria-label":`Retry delivery ${n.id} of ${n.event}`,onClick:e===null?()=>t(n):void 0,children:e===n.id?`Retrying…`:`Retry`}):null}]}function ir({filter:e,onFilter:t}){return(0,I.jsxs)(`fieldset`,{className:`setup-segmented`,children:[(0,I.jsx)(`legend`,{className:`visually-hidden`,children:`Show deliveries`}),Zn.map(n=>(0,I.jsx)(S,{size:`sm`,variant:e===n.id?`primary`:`secondary`,"aria-pressed":e===n.id,onClick:()=>t(n.id),children:n.label},n.id))]})}function ar(e){let t=g(),[n,r]=(0,j.useState)(null),i=(0,j.useRef)(null);return{retrying:n,retry:(0,j.useCallback)(n=>{i.current===null&&(i.current=n.id,r(n.id),re(n.id).then(()=>t({text:`Sent delivery ${n.id} again. It shows as pending until the webhook answers.`})).catch(e=>t({text:_(e,`The delivery could not be retried`),tone:`error`})).finally(()=>{i.current=null,r(null),e()}))},[e,t])}}function or({page:e,total:t,onPage:n}){let r=tr(e,t);if(!r)return null;let i=Math.ceil(t/25)-1;return(0,I.jsxs)(`nav`,{"aria-label":`Pages of deliveries`,className:`setup-row`,children:[(0,I.jsx)(S,{size:`sm`,"aria-disabled":e===0,onClick:e===0?void 0:()=>n(e-1),children:`Previous`}),(0,I.jsx)(`span`,{className:`setup-muted`,children:r}),(0,I.jsx)(S,{size:`sm`,"aria-disabled":e>=i,onClick:e>=i?void 0:()=>n(e+1),children:`Next`})]})}async function sr(e,t){let n=e===`all`?void 0:e;try{return await ge({limit:25,offset:t*25,status:n})}catch(e){if(e instanceof Ke&&e.status===403)return null;throw e}}function cr({filter:e,page:t,revision:n,onPage:r}){let i=(0,j.useCallback)(()=>sr(e,t),[e,t]),{loaded:a,reload:o}=x(i,`The deliveries could not be read`),s=(0,j.useRef)(n);(0,j.useEffect)(()=>{s.current!==n&&(s.current=n,o())},[n,o]);let{retrying:c,retry:l}=ar(o);if(a.state===`loading`)return(0,I.jsx)(W,{what:`the deliveries`});if(a.state===`error`)return(0,I.jsx)(G,{message:a.message,onRetry:o});if(a.data===null)return(0,I.jsx)(U,{children:`Only admins see webhook deliveries.`});let{deliveries:u,total:d}=a.data;return u.length===0?(0,I.jsx)(lr,{filter:e}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`setup-muted`,children:d===1?`1 delivery`:`${d} deliveries`}),(0,I.jsx)(O,{caption:`Webhook deliveries`,columns:rr(c,l),rows:u,rowKey:e=>String(e.id)}),(0,I.jsx)(or,{page:t,total:d,onPage:r})]})}function lr({filter:e}){return(0,I.jsxs)(Le,{icon:fe,title:`No webhook deliveries`,children:[er(e),` `,e===`all`&&(0,I.jsxs)(I.Fragment,{children:[`Each webhook the API is created with (`,(0,I.jsxs)(`code`,{children:[`createApiHandlers(`,`{ webhooks }`,`)`]}),`) logs a delivery here when content is created, updated, published or deleted.`]})]})}function ur(){let[e,t]=(0,j.useState)(`all`),[n,r]=(0,j.useState)(0),[i,a]=(0,j.useState)(0);return(0,I.jsxs)(H,{title:`Webhook deliveries`,actions:(0,I.jsx)(S,{size:`sm`,icon:we,onClick:()=>a(e=>e+1),children:`Refresh`}),sources:(0,I.jsx)(V,{source:`database`,children:`The delivery log in the site's database: every webhook sent, its answer and its attempts. Delivery logging runs on SQLite only.`}),children:[(0,I.jsx)(ir,{filter:e,onFilter:e=>{t(e),r(0)}}),(0,I.jsx)(cr,{filter:e,page:n,revision:i,onPage:r})]})}var Z=e=>`${e.collection}/${e.slug}/${e.locale}`;function dr({version:e,item:t,defaultLocale:n,canCreate:r,created:i,busy:a,onCreate:o}){let{collection:s,slug:c,locale:l}=e;return t.locales.includes(l)?(0,I.jsx)(y,{tone:`success`,icon:xe,children:`Exists`}):i.has(Z(e))?(0,I.jsxs)(ze,{to:ee(s,c,l),children:[`Open the `,l,` draft`]}):!r||!t.locales.includes(n)?(0,I.jsx)(y,{tone:`warning`,children:`Missing`}):(0,I.jsx)(S,{size:`sm`,icon:le,"aria-disabled":a!==null,"aria-label":`Create the ${l} draft of ${c}`,onClick:a===null?()=>o(e):void 0,children:a===Z(e)?`Creating…`:`Create draft`})}function fr(e,t,n){return[{id:`slug`,header:`Document`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.slug})},...e.map(e=>({id:`locale-${e}`,header:e===t.defaultLocale?`${e} (default)`:e,cell:r=>(0,I.jsx)(dr,{...t,item:r,version:{collection:n,slug:r.slug,locale:e}})}))]}function pr(e){let t=g(),[n,r]=(0,j.useState)(new Set),[i,a]=(0,j.useState)(null);return{created:n,busy:i,onCreate:(0,j.useCallback)(n=>{a(Z(n)),qe(n.collection,n.slug,n.locale,e).then(()=>{r(e=>new Set([...e,Z(n)])),t({text:`Created the ${n.locale} draft of ${n.slug}, copied from ${e}.`})}).catch(e=>t({text:_(e,`The draft could not be created`),tone:`error`})).finally(()=>a(null))},[e,t])}}function mr({status:e,locales:t,cell:n}){let r=D(e.collection);return(0,I.jsxs)(`div`,{className:`setup-coverage`,children:[(0,I.jsx)(`h3`,{className:`setup-subtitle`,children:r}),e.items.length===0?(0,I.jsx)(`p`,{className:`setup-muted`,children:`No documents.`}):(0,I.jsx)(O,{caption:`${r}: versions per locale`,columns:fr(t,n,e.collection),rows:e.items,rowKey:e=>e.slug})]})}function hr({settings:e}){let t=b().hasRole(`editor`),n=`${e.defaultLocale}:${e.supportedLocales.join(`,`)}`,r=(0,j.useCallback)(()=>u(),[n]),{loaded:i,reload:a}=x(r,`Translation coverage could not be read`),o={...pr(e.defaultLocale),defaultLocale:e.defaultLocale,canCreate:t};return(0,I.jsxs)(H,{title:`Translation coverage`,sources:(0,I.jsxs)(V,{source:`database`,children:[`Each document's versions as the site's database holds them. Create draft copies the`,` `,e.defaultLocale,` version's fields and body into a new draft in that locale; it is not live until it is published.`]}),children:[i.state===`loading`&&(0,I.jsx)(W,{what:`translation coverage`}),i.state===`error`&&(0,I.jsx)(G,{message:i.message,onRetry:a}),i.state===`ready`&&i.data.collections.map(e=>(0,I.jsx)(mr,{status:e,locales:i.data.supportedLocales,cell:o},e.collection))]})}function gr(e){return e.configuredLocales.filter(t=>!e.supportedLocales.includes(t))}function _r(e,t){return[...e.supportedLocales,t]}function vr(e,t){return t===e.defaultLocale?e.supportedLocales:e.supportedLocales.filter(e=>e!==t)}function yr(){let{loaded:e,reload:t}=x(s,`The locales could not be read`),[n,r]=(0,j.useState)(null),i=(0,j.useCallback)(e=>r(e),[]);return n&&e.state===`ready`?{loaded:{state:`ready`,data:n},reload:t,set:i}:{loaded:e,reload:t,set:i}}function br({settings:e}){return e.source===`database`?(0,I.jsxs)(V,{source:`database`,children:[`The active locales are chosen here among the configured ones and stored in the site's database. The default locale is `,(0,I.jsx)(`code`,{children:`site.defaultLocale`}),` in the configuration.`]}):(0,I.jsxs)(V,{source:`config`,children:[`The locales are `,(0,I.jsx)(`code`,{children:`site.supportedLocales`}),` and the default locale is`,` `,(0,I.jsx)(`code`,{children:`site.defaultLocale`}),`, in `,(0,I.jsx)(`code`,{children:`krantho.config.ts`}),` or the environment. Setup chooses which of the configured locales are active; the default is set only in the configuration.`]})}function xr(e,t,n){return[{id:`locale`,header:`Locale`,primary:!0,cell:e=>(0,I.jsx)(`code`,{children:e.code})},{id:`default`,header:`Default`,cell:e=>e.isDefault?(0,I.jsx)(y,{tone:`accent`,children:`Default`}):null},{id:`actions`,header:`Actions`,cell:r=>e&&!r.isDefault?(0,I.jsx)(`span`,{className:`setup-row-actions`,children:(0,I.jsx)(S,{size:`sm`,variant:`ghost`,icon:w,"aria-disabled":t,"aria-label":`Remove ${r.code}`,onClick:()=>n(r.code),children:`Remove`})}):null}]}function Sr({settings:e,busy:t,change:n}){let r=gr(e),[i,a]=(0,j.useState)(``),o=r.includes(i)?i:r[0];return o===void 0?(0,I.jsx)(U,{children:`Every locale in the configuration is active.`}):(0,I.jsxs)(`form`,{className:`setup-inline-form`,onSubmit:r=>{r.preventDefault(),t||n(_r(e,o),`Added ${o}.`)},children:[(0,I.jsx)(B,{label:`Configured locale`,value:o,onChange:a,hint:`A locale in site.supportedLocales that is not active`,options:r.map(e=>({value:e,label:e}))}),(0,I.jsx)(S,{type:`submit`,variant:`primary`,icon:me,"aria-disabled":t,children:`Add locale`})]})}function Cr(e){let t=g(),{busy:n,once:r}=P();return{busy:n,change:(n,i)=>{r(async()=>{try{e(await o(n)),t({text:i})}catch(e){t({text:_(e,`The locales could not be saved`),tone:`error`})}})}}}function wr({code:e,settings:t,onSaved:n,onClose:r}){let i=g();async function a(){n(await o(vr(t,e))),i({text:`Removed ${e}.`}),r()}return(0,I.jsx)(L,{title:`Remove the locale ${e}?`,confirmLabel:`Remove locale`,danger:!0,onConfirm:a,onClose:r,children:(0,I.jsxs)(`p`,{children:[`The site stops serving `,(0,I.jsx)(`code`,{children:e}),`. Documents already in that locale are kept, not deleted. Only the list of locales changes.`]})})}function Tr({settings:e,set:t}){let n=b().hasRole(`admin`),{busy:r,change:i}=Cr(t),[a,o]=(0,j.useState)(null),s=e.supportedLocales.map(t=>({code:t,isDefault:t===e.defaultLocale}));return(0,I.jsxs)(H,{title:`Locales`,sources:(0,I.jsx)(br,{settings:e}),children:[(0,I.jsx)(O,{caption:`Locales`,columns:xr(n,r,o),rows:s,rowKey:e=>e.code}),n?(0,I.jsx)(Sr,{settings:e,busy:r,change:i}):(0,I.jsx)(U,{children:`Only admins change the locales.`}),a&&(0,I.jsx)(wr,{code:a,settings:e,onSaved:t,onClose:()=>o(null)})]})}function Er(){let{loaded:e,reload:t,set:n}=yr();if(e.state===`loading`)return(0,I.jsx)(W,{what:`the locales`});if(e.state===`error`)return(0,I.jsx)(G,{message:e.message,onRetry:t});let r=e.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsx)(Tr,{settings:r,set:n}),r.supportedLocales.length>1&&(0,I.jsx)(hr,{settings:r})]})}var Dr=[{value:`admin`,label:`Admin`,can:`everything, including Setup and people`},{value:`editor`,label:`Editor`,can:`writes, publishes and takes checkpoints`},{value:`viewer`,label:`Viewer`,can:`reads`}];function Q(e){return e.roles[0]??`viewer`}function $(e){return e.name||e.email||e.id}var Or=Dr.map(e=>({value:e.value,label:`${e.label} — ${e.can}`}));function kr({form:e,setForm:t,editing:n}){let r=n?`An account keeps its email`:`They sign in with this address`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{label:`Email`,type:`email`,value:e.email,disabled:n,onChange:n=>t({...e,email:n}),hint:r}),(0,I.jsx)(z,{label:`Name`,value:e.name,onChange:n=>t({...e,name:n})}),(0,I.jsx)(B,{label:`Role`,value:e.role,options:Or,onChange:n=>t({...e,role:n}),hint:`Roles are site-wide: admin > editor > viewer`})]})}function Ar({user:e,onSave:t,onClose:n}){let r=(0,j.useId)(),[i,a]=(0,j.useState)(()=>({email:e?.email??``,name:e?.name??``,role:e?Q(e):`viewer`})),{busy:o,error:s,setError:c,run:l}=F();function u(n){if(n.preventDefault(),!e&&!i.email.trim()){c(`An account needs an email.`);return}let r={...i,email:i.email.trim(),name:i.name.trim()};l(()=>t(r),`The account could not be saved`)}let d=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(S,{onClick:n,children:`Cancel`}),(0,I.jsx)(S,{variant:`primary`,type:`submit`,form:r,"aria-disabled":o,children:o?`Saving…`:e?`Save`:`Create user`})]}),f=e?`Edit ${$(e)}`:`Create user`;return(0,I.jsx)(h,{title:f,onClose:n,actions:d,busy:o,children:(0,I.jsxs)(`form`,{id:r,className:`setup-form`,onSubmit:u,children:[s&&(0,I.jsx)(R,{text:s}),(0,I.jsx)(kr,{form:i,setForm:a,editing:e!==null})]})})}var jr=e=>Dr.find(t=>t.value===Q(e))?.label??Q(e);function Mr(e,t){let n={kind:`edit`,label:`Edit`,icon:He,variant:`secondary`};return t?[n]:[n,{kind:`active`,label:e.isActive?`Deactivate`:`Activate`,icon:at,variant:`ghost`},{kind:`delete`,label:`Delete`,icon:w,variant:`ghost`}]}function Nr({user:e,self:t,onDialog:n}){let r=$(e),i=Mr(e,t);return(0,I.jsx)(`span`,{className:`setup-row-actions`,children:i.map(t=>(0,I.jsx)(S,{size:`sm`,variant:t.variant,icon:t.icon,"aria-label":`${t.label} ${r}`,onClick:()=>n({kind:t.kind,user:e}),children:t.label},t.kind))})}function Pr(e,t){return[{id:`name`,header:`Person`,primary:!0,cell:e=>e.name||(0,I.jsx)(`span`,{className:`setup-muted`,children:`No name`})},{id:`email`,header:`Email`,cell:e=>e.email??`—`},{id:`role`,header:`Role`,cell:e=>(0,I.jsx)(y,{tone:Q(e)===`admin`?`accent`:`neutral`,children:jr(e)})},{id:`status`,header:`Status`,cell:e=>e.isActive?(0,I.jsx)(y,{tone:`success`,children:`Active`}):(0,I.jsx)(y,{children:`Deactivated`})},{id:`sign-in`,header:`Signs in with`,cell:e=>e.oidcIssuer?`OIDC provider`:`Studio`},{id:`created`,header:`Created`,cell:e=>Fe(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>(0,I.jsx)(Nr,{user:n,self:n.id===e,onDialog:t})}]}async function Fr(e,t){return e?(await A(e.id,{name:t.name,role:t.role}),`Saved ${$(e)}: ${t.role}.`):`Created ${$(await dt({email:t.email,name:t.name||void 0,role:t.role}))} as ${t.role}.`}async function Ir(e,t){return e===`delete`?(await ft(t.id),`Deleted ${$(t)}.`):(await A(t.id,{isActive:!t.isActive}),`${t.isActive?`Deactivated`:`Activated`} ${$(t)}.`)}function Lr({user:e,onConfirm:t,onClose:n}){let r=e.isActive,i=r?`Deactivate`:`Activate`;return(0,I.jsx)(L,{title:`${i} ${$(e)}?`,confirmLabel:i,danger:r,onConfirm:t,onClose:n,children:(0,I.jsx)(`p`,{children:r?`They can no longer sign in, and their sessions can no longer be renewed; a session already open lasts until its access token expires.`:`They can sign in again, with their role.`})})}function Rr({dialog:e,onClose:t,onDone:n}){if(e.kind===`create`||e.kind===`edit`){let r=e.kind===`edit`?e.user:null;return(0,I.jsx)(Ar,{user:r,onSave:async e=>n(await Fr(r,e)),onClose:t})}let{kind:r,user:i}=e,a=async()=>n(await Ir(r,i));return r===`active`?(0,I.jsx)(Lr,{user:i,onConfirm:a,onClose:t}):(0,I.jsx)(L,{title:`Delete ${$(i)}?`,confirmLabel:`Delete account`,danger:!0,onConfirm:a,onClose:t,children:(0,I.jsx)(`p`,{children:`The account is removed from the site's database.`})})}function zr(){let e=g(),t=b().user?.id,{loaded:n,reload:r}=x(ut,`The accounts could not be read`),[i,a]=(0,j.useState)(null);return(0,I.jsxs)(H,{title:`People`,sources:(0,I.jsx)(V,{source:`database`,children:`The accounts in the site's database. Roles are site-wide: admin > editor > viewer. The API does not record when someone was last active.`}),actions:(0,I.jsx)(S,{variant:`primary`,icon:lt,onClick:()=>a({kind:`create`}),children:`Create user`}),children:[n.state===`loading`&&(0,I.jsx)(W,{what:`the accounts`}),n.state===`error`&&(0,I.jsx)(G,{message:n.message,onRetry:r}),n.state===`ready`&&(0,I.jsx)(O,{caption:`People`,columns:Pr(t,a),rows:n.data,rowKey:e=>e.id}),i&&(0,I.jsx)(Rr,{dialog:i,onClose:()=>a(null),onDone:t=>{a(null),e({text:t}),r()}})]})}function Br({tab:e}){switch(e){case`collections`:return(0,I.jsx)(Gn,{});case`locales`:return(0,I.jsx)(Er,{});case`ai`:return(0,I.jsx)(Zt,{});case`integrations`:return(0,I.jsx)(ur,{});case`checkpoints`:return(0,I.jsx)(an,{});case`people`:return(0,I.jsx)(zr,{});case`environment`:return(0,I.jsx)(Xn,{})}}function Vr({tab:e,tabs:t}){let n=(0,j.useId)(),i=(0,j.useCallback)(e=>`${n}-tab-${e}`,[n]);return(0,I.jsxs)(`div`,{className:`setup`,children:[(0,I.jsxs)(`header`,{className:`setup-header`,children:[(0,I.jsx)(`h1`,{className:`setup-title`,children:`Setup`}),(0,I.jsxs)(`p`,{className:`setup-lead`,children:[`How the site is configured. Each tab says where its values come from: the configuration —`,` `,(0,I.jsx)(`code`,{children:`krantho.config.ts`}),`, `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),` and the environment, read-only here — the site's database, changed here, or what the running server reports.`]})]}),(0,I.jsx)(r,{label:`Setup`,tabs:t,current:e,tabId:i,panelId:`${n}-panel`}),(0,I.jsx)(`div`,{id:`${n}-panel`,role:`tabpanel`,"aria-labelledby":i(e),className:`setup-panel`,children:(0,I.jsx)(Br,{tab:e})})]})}export{Vr as SetupPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{t as r}from"./vendor-router-B4czwg8X.js";import{r as i,u as a}from"./format-C3ZX9yGM.js";import{n as o}from"./use-loaded-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{t as r}from"./vendor-router-B4czwg8X.js";import{r as i,u as a}from"./format-C3ZX9yGM.js";import{n as o}from"./use-loaded-BNCu0C-c.js";import{t as s}from"./circle-dashed-cuYrILNo.js";import{t as c}from"./circle-x-peGpq98w.js";import{t as l}from"./corner-down-right-BpwOGRFR.js";import{t as u}from"./external-link-Dh7p8Ii6.js";import{f as d}from"./api-seo-DeG5gsh6.js";import{C as f,D as p,K as m,S as h,St as g,Tt as _,V as v,ft as y,j as b,x,z as S}from"./index-d5j-az5g.js";import{a as C,u as w}from"./site-model-BXHOxNij.js";import{t as T}from"./source-CGZGd3Xy.js";var E=t();function D(e,t){return _(e.collection,e.slug,e.locale===t?void 0:e.locale)}function O({row:e,baseUrl:t}){return e.path===null?null:e.liveVersion===null?(0,E.jsx)(`span`,{className:`site-url`,title:`Not published yet`,children:e.path}):(0,E.jsxs)(`a`,{className:`site-url site-url--link`,href:C(t,e.path),target:`_blank`,rel:`noreferrer`,"aria-label":`${e.path} on the site (opens in a new tab)`,children:[e.path,(0,E.jsx)(u,{className:`site-url-icon`,"aria-hidden":`true`})]})}function k({row:e,context:t}){return(0,E.jsxs)(`div`,{className:`site-page`,children:[(0,E.jsx)(x,{status:e.status,decorative:!0}),(0,E.jsxs)(`div`,{className:`site-page-text`,children:[(0,E.jsx)(r,{to:D(e,t.defaultLocale),className:`site-title`,children:e.title}),e.path===null?(0,E.jsx)(`span`,{className:`site-url`,children:`no URL, shared`}):(0,E.jsx)(O,{row:e,baseUrl:t.baseUrl})]})]})}function A({row:e,context:t}){return(0,E.jsxs)(`div`,{className:`site-page-text`,children:[(0,E.jsx)(r,{to:D(e,t.defaultLocale),className:`site-slug`,children:e.slug}),(0,E.jsx)(`span`,{className:`site-links`,children:(0,E.jsx)(O,{row:e,baseUrl:t.baseUrl})})]})}function j({row:e}){return(0,E.jsxs)(`span`,{className:`site-status site-status--${e.status}`,children:[(0,E.jsx)(x,{status:e.status,decorative:!0}),b[e.status]]})}function M({row:e}){return e.liveVersion===null?(0,E.jsxs)(`span`,{className:`site-muted`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,E.jsx)(`span`,{className:`visually-hidden`,children:`Not published`})]}):(0,E.jsxs)(`span`,{children:[`v`,e.liveVersion]})}function N({row:e}){return(0,E.jsx)(`time`,{dateTime:e.updatedAt,title:new Date(e.updatedAt).toLocaleString(),children:i(e.updatedAt)})}var P={covered:{icon:o,tone:`good`,text:`Own meta description`},fallback:{icon:l,tone:`muted`,text:`Falls back to description`},missing:{icon:y,tone:`warn`,text:`No meta description`}};function F(e,t){switch(e){case`valid`:return{icon:o,tone:`good`,text:`Structured data valid`};case`errors`:return{icon:c,tone:`bad`,text:`Structured data has errors`};case`not-live`:return{icon:s,tone:`muted`,text:`Structured data checked once live`};case`default-locale-only`:return{icon:s,tone:`muted`,text:`Structured data checked in ${t}`};case`failed`:return{icon:s,tone:`muted`,text:`Structured data unavailable`};case`off`:return null}}function I({line:e}){let t=e.icon;return(0,E.jsxs)(`span`,{className:`site-finding site-finding--${e.tone}`,children:[(0,E.jsx)(t,{className:`site-finding-icon`,"aria-hidden":`true`}),e.text]})}function L({row:e,context:t}){if(e.meta===null){let t=e.collection===g;return(0,E.jsx)(`span`,{className:`site-muted`,children:t?`Read by every page`:`No page`})}let n=e.graph===null?null:F(e.graph,t.defaultLocale);return(0,E.jsxs)(`span`,{className:`site-findability`,children:[(0,E.jsx)(I,{line:P[e.meta]}),n&&(0,E.jsx)(I,{line:n})]})}function R({row:e}){let{locales:t}=e;return t.state===`failed`?(0,E.jsx)(`span`,{className:`site-muted`,children:`Unavailable`}):t.state===`off`?(0,E.jsxs)(`span`,{className:`site-muted`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,E.jsx)(`span`,{className:`visually-hidden`,children:`Locale versions not tracked`})]}):(0,E.jsxs)(`span`,{className:`site-locales`,children:[t.present.map(e=>(0,E.jsx)(`code`,{className:`site-locale`,children:e},e)),t.missing.map(e=>(0,E.jsxs)(`code`,{className:`site-locale site-locale--missing`,title:`No ${e} version`,children:[e,(0,E.jsx)(`span`,{className:`visually-hidden`,children:` missing`})]},e))]})}function z(e){return e?[{id:`locales`,header:`Locales`,cell:e=>(0,E.jsx)(R,{row:e})}]:[]}var B={id:`status`,header:`Status`,width:`11rem`,cell:e=>(0,E.jsx)(j,{row:e})},V={id:`updated`,header:`Updated`,numeric:!0,width:`9.5rem`,cell:e=>(0,E.jsx)(N,{row:e})};function H(e,t){return[{id:`page`,header:`Page`,primary:!0,cell:t=>(0,E.jsx)(k,{row:t,context:e})},B,{id:`findability`,header:`Findability`,cell:t=>(0,E.jsx)(L,{row:t,context:e})},...z(t),V]}function U(e,t){return[{id:`slug`,header:`Slug`,primary:!0,cell:t=>(0,E.jsx)(A,{row:t,context:e})},B,{id:`live`,header:`Live`,numeric:!0,width:`4.5rem`,cell:e=>(0,E.jsx)(M,{row:e})},{id:`seo`,header:`SEO`,cell:t=>(0,E.jsx)(L,{row:t,context:e})},...z(t),V]}async function W(e){let[t,n,r]=await Promise.all([p(),v(),f()]),[i,o]=await Promise.all([T(a(e,`seo`),async()=>(await d()).pages),T(h(r),m)]);return{site:t,locales:r,collections:n,findings:i,translations:o}}function G(e,t){return e.map(e=>w(e,t))}function K(e,t){return{collection:e,defaultLocale:t.locales.defaultLocale,findings:t.findings,translations:t.translations}}async function q(e){let t=await W(e),n=t.locales.defaultLocale,r=await S({locale:n}),i=[],a=null;for(let e of t.collections){let n=G(r.filter(t=>t.meta.collection===e.name),K(e,t));e.name===`globals`?a=n:i.push({collection:e,rows:n})}let o=t.translations.state!==`off`;return{site:t.site,locales:t.locales,sections:i,layout:a,localization:o}}async function J(e,t,n){let r=await W(e),{supportedLocales:i,defaultLocale:a}=r.locales,o=n&&i.includes(n)?n:a,s=r.translations.state!==`off`,c=r.collections.find(e=>e.name===t&&e.name!==`globals`)??null,l={site:r.site,locales:r.locales,collection:c,locale:o,localization:s};if(!c)return{...l,rows:[]};let u=await S({collections:[c.name],locale:o});return{...l,rows:G(u,K(c,r))}}var Y=e(n(),1);function X(e,t){let[n,r]=(0,Y.useState)(0),i=(0,Y.useRef)(0),{ready:a,error:o}=t;return(0,Y.useEffect)(()=>{n!==i.current&&e!==`loading`&&(i.current=n,(e===`error`?o:a).current?.focus())},[n,e,a,o]),(0,Y.useCallback)(()=>r(e=>e+1),[])}export{H as a,U as i,J as n,D as o,q as r,X as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{n as r}from"./createLucideIcon-BklFHeMd.js";import{i,n as a,r as o}from"./findability-BrhtZ2yD.js";import{y as s}from"./api-seo-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{o as t,s as n}from"./vendor-diff-DGCTJYJ4.js";import{n as r}from"./createLucideIcon-BklFHeMd.js";import{i,n as a,r as o}from"./findability-BrhtZ2yD.js";import{y as s}from"./api-seo-DeG5gsh6.js";import{t as c}from"./triangle-exclamation-point-ttN5lZI0.js";import{M as l,o as u}from"./index-d5j-az5g.js";import{t as d}from"./empty-state-CeUZocHx.js";var f=e(n(),1),p=t();function m({title:e,message:t,onRetry:n,panelRef:i}){let a=(0,f.useId)();return(0,p.jsx)(`div`,{ref:i,className:`site-panel site-focus-target`,role:`alert`,"aria-labelledby":a,tabIndex:-1,children:(0,p.jsx)(d,{icon:c,title:e,titleId:a,action:(0,p.jsx)(r,{icon:s,onClick:n,children:`Try again`}),children:t})})}function h(e,t){if(!t.collection.pages)return null;let{findings:n,defaultLocale:r}=t;if(n.state!==`ok`)return n.state;if(e.meta.locale!==r)return`default-locale-only`;let i=n.value.find(t=>t.collection===e.meta.collection&&t.slug===e.meta.slug);return i?o(i)?`valid`:`errors`:`not-live`}function g(e,t){let{translations:n,collection:r}=t;if(n.state!==`ok`)return n;let i=n.value.collections.find(e=>e.collection===r.name)?.items.find(t=>t.slug===e.slug),a=new Set([...i?.locales??[],e.locale]),o=n.value.supportedLocales;return{state:`ok`,present:o.filter(e=>a.has(e)),missing:o.filter(e=>!a.has(e))}}function _(e,t){let{meta:n,fields:r}=e,o=r.title,s=t.collection.pages;return{collection:n.collection,slug:n.slug,locale:n.locale,title:a(o)?String(o):n.slug,status:l(n),version:n.version,liveVersion:n.liveVersion,updatedAt:n.createdAt,path:s?u(t.collection,n.slug):null,meta:s?i(r):null,graph:h(e,t),locales:g(n,t)}}var v=[`all`,`live`,`ahead`,`draft`],y=[`updated`,`slug`];function b(e){return v.some(t=>t===e)}function x(e){return y.some(t=>t===e)}function S(e){return e===`slug`?(e,t)=>e.slug.localeCompare(t.slug):(e,t)=>t.updatedAt.localeCompare(e.updatedAt)||e.slug.localeCompare(t.slug)}function C(e,t,n){return e.filter(e=>t===`all`||e.status===t).sort(S(n))}function w(e){let t=t=>e.filter(e=>e.status===t).length;return{total:e.length,live:t(`live`),ahead:t(`ahead`),draft:t(`draft`)}}function T(e,t){return`${e} of ${t}`}function E(e,t){return`${e.replace(/\/+$/,``)}${t}`}function D(e,t){return t.length>0&&t.every(t=>e.has(t))?new Set:new Set(t)}function O(e,t){return t.filter(t=>e.has(t))}export{E as a,C as c,D as d,m as f,b as i,w as l,v as n,O as o,x as r,T as s,y as t,_ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Ct as t,a as n,ut as r,x as i}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Ct as t,a as n,ut as r,x as i}from"./index-d5j-az5g.js";import{a}from"./findability-BrhtZ2yD.js";import{t as o}from"./createLucideIcon-BklFHeMd.js";import{o as s,s as c}from"./vendor-diff-DGCTJYJ4.js";import{t as l,u}from"./vendor-router-B4czwg8X.js";import{d,t as f}from"./format-C3ZX9yGM.js";import{n as p,t as m}from"./data-table-B1kqxrEw.js";import{t as h}from"./empty-state-CeUZocHx.js";import{f as g,l as _}from"./site-model-BXHOxNij.js";import{a as v,o as y,r as b,t as x}from"./site-CGs9-oiw.js";import{t as S}from"./use-loaded-BNCu0C-c.js";var C={name:`layout-template`,size:24,node:[[`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`}]]};C.node;var w=o(C),T=e(c(),1),E=s(),D={live:`live`,ahead:`draft ahead`,draft:`draft`},O=[`live`,`ahead`,`draft`];function k({counts:e}){let t=O.filter(t=>e[t]>0);return(0,E.jsxs)(`p`,{className:`site-summary`,children:[t.length===0&&(0,E.jsx)(`span`,{children:`No documents`}),t.map(t=>(0,E.jsxs)(`span`,{className:`site-summary-item`,children:[(0,E.jsx)(i,{status:t,decorative:!0}),(0,E.jsx)(`span`,{className:`site-summary-number`,children:e[t]}),` `,D[t]]},t))]})}function A({caption:e,rows:t,context:n,localization:r}){let i=u(),a=(0,T.useMemo)(()=>v(n,r),[n,r]);return(0,E.jsx)(m,{caption:e,columns:a,rows:t,rowKey:e=>e.slug,onRowClick:e=>i(y(e,n.defaultLocale))})}function j({section:e,context:r,localization:i}){let o=(0,T.useId)(),{collection:s,rows:c}=e,u=f(s.name),d=n(s);return(0,E.jsxs)(`section`,{className:`site-panel`,"aria-labelledby":o,children:[(0,E.jsxs)(`div`,{className:`site-panel-head`,children:[(0,E.jsxs)(`div`,{className:`site-panel-title`,children:[(0,E.jsx)(`h2`,{id:o,children:(0,E.jsx)(l,{to:t(s.name),children:u})}),(0,E.jsx)(`code`,{className:`site-pattern`,children:d??`no pages`})]}),(0,E.jsx)(k,{counts:_(c)})]}),c.length===0?(0,E.jsx)(h,{icon:a,title:`No ${u.toLowerCase()} yet`,children:`Documents you create in this collection show up here.`}):(0,E.jsx)(A,{caption:u,rows:c,context:r,localization:i})]})}function M({rows:e,context:t,localization:n}){let r=(0,T.useId)();return(0,E.jsxs)(`section`,{className:`site-panel`,"aria-labelledby":r,children:[(0,E.jsxs)(`div`,{className:`site-panel-head`,children:[(0,E.jsxs)(`div`,{className:`site-panel-title`,children:[(0,E.jsx)(`h2`,{id:r,children:`Layout`}),(0,E.jsx)(`span`,{className:`site-pattern-note`,children:`no URL, shared · read by every page`})]}),(0,E.jsx)(k,{counts:_(e)})]}),e.length===0?(0,E.jsx)(h,{icon:w,title:`No globals yet`,children:`Globals hold the frame every page shares: header, footer, contact.`}):(0,E.jsx)(A,{caption:`Layout`,rows:e,context:t,localization:n})]})}function N({data:e}){let{site:t}=e.site,n=(0,T.useMemo)(()=>({baseUrl:t.baseUrl,defaultLocale:e.locales.defaultLocale}),[t.baseUrl,e.locales.defaultLocale]);return(0,E.jsxs)(E.Fragment,{children:[e.sections.map(t=>(0,E.jsx)(j,{section:t,context:n,localization:e.localization},t.collection.name)),e.layout&&(0,E.jsx)(M,{rows:e.layout,context:n,localization:e.localization})]})}function P(){return(0,E.jsxs)(`div`,{className:`site-panel`,"aria-hidden":`true`,children:[(0,E.jsx)(`div`,{className:`site-panel-head`,children:(0,E.jsx)(`span`,{className:`site-skeleton-title`})}),(0,E.jsx)(p,{})]})}function F({headingRef:e,defaultLocale:t}){return(0,E.jsxs)(`header`,{className:`site-header`,children:[(0,E.jsx)(`h1`,{ref:e,className:`site-heading site-focus-target`,tabIndex:-1,children:`Site`}),(0,E.jsxs)(`p`,{className:`site-lede`,children:[`What you are editing: each collection's documents`,t&&(0,E.jsxs)(E.Fragment,{children:[` `,`in `,(0,E.jsx)(`code`,{children:t})]}),`, and the Layout every page shares.`]})]})}function I(){return(0,E.jsx)(`div`,{className:`site-panel`,children:(0,E.jsxs)(h,{icon:r,title:`No collections`,children:[`Collections are defined in code, in `,(0,E.jsx)(`code`,{children:`krantho.collections.ts`}),`.`]})})}function L(){let e=d(),t=(0,T.useCallback)(()=>b(e),[e]),{loaded:n,reload:r}=S(t,`The site could not load`),i=(0,T.useRef)(null),a=(0,T.useRef)(null),o=x(n.state,{ready:i,error:a}),s=()=>{r(),o()},c=n.state===`ready`?n.data:null;return(0,E.jsxs)(`div`,{className:`site`,"aria-busy":n.state===`loading`,children:[(0,E.jsx)(F,{headingRef:i,defaultLocale:c?.locales.defaultLocale??null}),n.state===`loading`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:`Loading the site…`}),(0,E.jsx)(P,{})]}),n.state===`error`&&(0,E.jsx)(g,{title:`The site could not load`,message:n.message,onRetry:s,panelRef:a}),c&&(0,E.jsx)(N,{data:c}),c&&c.sections.length===0&&(0,E.jsx)(I,{})]})}export{L as SiteOverview};
|