@krantho/studio 1.0.0 → 1.0.2
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 +8 -0
- package/dist/assets/GraphBrowser-BBKTzzRV.js +2 -0
- package/dist/assets/GraphCanvas-Cct1E2As.js +1 -0
- package/dist/assets/{action-button-Co7fp7HS.js → action-button-DIrhqMRc.js} +1 -1
- package/dist/assets/{api-seo-2H6_VoWE.js → api-seo-CwGP6Bi2.js} +1 -1
- package/dist/assets/{arduino-CEYAtK6G.js → arduino-DKR9_xyJ.js} +1 -1
- package/dist/assets/{arrow-down-CsgZZR1B.js → arrow-down-B5kfR2lG.js} +1 -1
- package/dist/assets/{arrow-left-DKjipJjb.js → arrow-left-7opbl8fu.js} +1 -1
- package/dist/assets/{auth-GRfs02w7.js → auth-CIpilSKF.js} +1 -1
- package/dist/assets/{c-C8PoWFx3.js → c-CEM0h_nK.js} +1 -1
- package/dist/assets/{circle-check-big-zoQrH4Hp.js → circle-check-big-DQjpuxcC.js} +1 -1
- package/dist/assets/{circle-dashed-Cu2MEHnb.js → circle-dashed-cuYrILNo.js} +1 -1
- package/dist/assets/{circle-x-DMb3ZtiK.js → circle-x-peGpq98w.js} +1 -1
- package/dist/assets/{clike-jjKDqbJf.js → clike-BlGBRct5.js} +1 -1
- package/dist/assets/{clock-CzpAlvS3.js → clock-DoBIVjZO.js} +1 -1
- package/dist/assets/collection-view--erTGbRH.js +5 -0
- package/dist/assets/{copy-DloNx7rC.js → copy-V85khWct.js} +1 -1
- package/dist/assets/{corner-down-right-D2cWjQTP.js → corner-down-right-BpwOGRFR.js} +1 -1
- package/dist/assets/{cpp-BNrDeSFM.js → cpp-C0nea612.js} +1 -1
- package/dist/assets/createLucideIcon-BklFHeMd.js +1 -0
- package/dist/assets/{csharp-C2EQRp-I.js → csharp-C430X67Y.js} +1 -1
- package/dist/assets/{data-table-D8BsE1pn.js → data-table-B1kqxrEw.js} +1 -1
- package/dist/assets/editor-page-XOJrwlcZ.js +27 -0
- package/dist/assets/{empty-state-CU7q3Ypl.js → empty-state-CeUZocHx.js} +1 -1
- package/dist/assets/{export-helpers-B2KV_EB5.js → export-helpers-C_HVpJN9.js} +1 -1
- package/dist/assets/{external-link-BRKJTCZG.js → external-link-Dh7p8Ii6.js} +1 -1
- package/dist/assets/{fill-job-D41ra-DR.js → fill-job-YPZFETW1.js} +1 -1
- package/dist/assets/{fill-run-view-DFeyjdsI.js → fill-run-view-B6rnYhKS.js} +1 -1
- package/dist/assets/{findability-CUYOthYI.js → findability-BrhtZ2yD.js} +1 -1
- package/dist/assets/{format-pPdsDgeS.js → format-C3ZX9yGM.js} +1 -1
- package/dist/assets/{go-BTdFQSkQ.js → go-2ldyX7zA.js} +1 -1
- package/dist/assets/graph-config-DKVGDPTG.js +1 -0
- package/dist/assets/image-editor-BX-DHJDa.js +1 -0
- package/dist/assets/index-CEQ7ZdKC.js +2 -0
- package/dist/assets/{info-B69U-gXd.js → info-Cxkabti5.js} +1 -1
- package/dist/assets/{java-OEPW09uX.js → java-BaDy4FT-.js} +1 -1
- package/dist/assets/{javascript-DWFokqmn.js → javascript-DoKZVVG7.js} +1 -1
- package/dist/assets/{kotlin-lSpEPTBz.js → kotlin-aNSUnDDr.js} +1 -1
- package/dist/assets/{layers-BQ89qo5R.js → layers-0VWe0rKm.js} +1 -1
- package/dist/assets/{list-checks-DmMdd-uP.js → list-checks-BCEhMMVY.js} +1 -1
- package/dist/assets/live-markdown-editor-DM8hYG3n.js +54 -0
- package/dist/assets/{markdown-D0Y7CUbI.js → markdown-ChIsYjIt.js} +1 -1
- package/dist/assets/{markup-Bfi2BWVm.js → markup-C09yLKTH.js} +1 -1
- package/dist/assets/{markup-templating-BkH2dBCn.js → markup-templating-DNhq-UOv.js} +1 -1
- package/dist/assets/media-page-CeBC5FQS.js +1 -0
- package/dist/assets/{meter-mJxPk3I3.js → meter-ZOLJ0WhG.js} +1 -1
- package/dist/assets/{objectivec-Cv_qlwGW.js → objectivec-s2I4Tn1D.js} +1 -1
- package/dist/assets/{pen-line-CZkcVGBd.js → pen-line-B524Nue8.js} +1 -1
- package/dist/assets/{pencil-BHnNXVY1.js → pencil-xdGZtrO4.js} +1 -1
- package/dist/assets/{php-MrfIyKXK.js → php-B_6N-5RT.js} +1 -1
- package/dist/assets/pulse-page-C00oCF2o.js +1 -0
- package/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
- package/dist/assets/{rotate-ccw-CjpQmti_.js → rotate-ccw-BgARBEK3.js} +1 -1
- package/dist/assets/ruby-C8GJZDTg.js +1 -0
- package/dist/assets/{save-kXwhieDK.js → save-ClSXW9cb.js} +1 -1
- package/dist/assets/{send-ib_sr-OU.js → send-kYpW5JED.js} +1 -1
- package/dist/assets/setup-page-BHJcTaTH.js +1 -0
- package/dist/assets/{site-XpqFn80l.js → site-BYsfQB_3.js} +1 -1
- package/dist/assets/site-model-C5bJvTbk.js +1 -0
- package/dist/assets/site-overview-5EhmXIR0.js +1 -0
- package/dist/assets/structure-page-9d9MG7vU.js +2 -0
- package/dist/assets/{trash-Cknp3eZ5.js → trash-DzRCm500.js} +1 -1
- package/dist/assets/triangle-exclamation-point-ttN5lZI0.js +1 -0
- package/dist/assets/{typescript-Brau3Puh.js → typescript-s_P45ayF.js} +1 -1
- package/dist/assets/{upload-BvBYjswd.js → upload-CaqQJaUr.js} +1 -1
- package/dist/assets/{use-drawer-actions-DChrztN2.js → use-drawer-actions-CR6Q0qdd.js} +1 -1
- package/dist/assets/{use-loaded-C3hBdQe0.js → use-loaded-BBFak2E1.js} +1 -1
- package/dist/assets/{use-locale-versions-Bp4V9fN-.js → use-locale-versions-BycCbBLd.js} +1 -1
- package/dist/assets/{vendor-diff-Dm2YfgXt.js → vendor-diff-DGCTJYJ4.js} +14 -14
- package/dist/assets/vendor-markdown-pd8vs9n-.js +74 -0
- package/dist/assets/{vendor-media-yY6fAUvp.js → vendor-media-DXSmPN_d.js} +1 -1
- package/dist/assets/vendor-react-CXaWJ_ii.js +15 -0
- package/dist/assets/{vendor-reactflow-5Qvgw90M.js → vendor-reactflow-CMKi7AEX.js} +1 -1
- package/dist/assets/vendor-router-B4czwg8X.js +1 -0
- package/dist/index.html +8 -8
- package/package.json +27 -27
- package/dist/assets/AssistantPanel-CzFfUizn.js +0 -8
- package/dist/assets/GraphBrowser-DvcHXw-i.js +0 -2
- package/dist/assets/GraphCanvas-Bq75rYgC.js +0 -1
- package/dist/assets/collection-view-BlqX2SDN.js +0 -5
- package/dist/assets/createLucideIcon-D_HN41p3.js +0 -1
- package/dist/assets/editor-page-C8G81B5n.js +0 -27
- package/dist/assets/graph-config-ZUe9BjGK.js +0 -1
- package/dist/assets/image-editor-Bmjrioxz.js +0 -1
- package/dist/assets/index-DVe5jFLX.js +0 -2
- package/dist/assets/live-markdown-editor-CTvxOTrh.js +0 -53
- package/dist/assets/media-page-DYRRse48.js +0 -1
- package/dist/assets/pulse-page-B44AnguJ.js +0 -1
- package/dist/assets/rolldown-runtime-Dd_uD5pT.js +0 -1
- package/dist/assets/ruby-DGkU311C.js +0 -1
- package/dist/assets/setup-page-x51U8px6.js +0 -1
- package/dist/assets/site-model-DX8WxTJg.js +0 -1
- package/dist/assets/site-overview--k6hNYk0.js +0 -1
- package/dist/assets/structure-page-BW1y8L1n.js +0 -2
- package/dist/assets/triangle-alert-C4yqbtOC.js +0 -1
- package/dist/assets/vendor-markdown-DlwjVoJi.js +0 -66
- package/dist/assets/vendor-react-DMqGe90A.js +0 -15
- package/dist/assets/vendor-router-DjV3D6zM.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,s as n}from"./vendor-diff-Dm2YfgXt.js";import{t as r}from"./vendor-router-DjV3D6zM.js";import{i}from"./auth-GRfs02w7.js";import{d as a,i as o,n as s,u as c}from"./format-pPdsDgeS.js";import{i as l,n as u,r as d,t as f}from"./createLucideIcon-D_HN41p3.js";import{c as ee,d as p,i as te,l as ne,n as re,o as ie,p as ae,r as m,s as h,t as g,u as _}from"./use-drawer-actions-DChrztN2.js";import{t as oe}from"./copy-DloNx7rC.js";import{t as se}from"./external-link-BRKJTCZG.js";import{t as ce}from"./layers-BQ89qo5R.js";import{t as le}from"./list-checks-DmMdd-uP.js";import{t as ue}from"./pencil-BHnNXVY1.js";import{t as v}from"./save-kXwhieDK.js";import{t as y}from"./trash-Cknp3eZ5.js";import{A as de,C as fe,D as pe,E as me,M as he,N as b,O as ge,P as _e,S as ve,_ as ye,a as be,b as xe,c as x,d as S,f as Se,g as Ce,h as C,i as we,j as Te,l as w,m as T,n as E,o as D,p as O,r as k,t as Ee,u as A,v as De,w as Oe,x as ke,y as j}from"./media-model-D4F1Farw.js";import{Et as Ae,Tt as je,d as M,et as N,f as P,it as Me,mt as Ne,tt as F}from"./index-DVe5jFLX.js";import{t as Pe}from"./empty-state-CU7q3Ypl.js";import{t as I}from"./action-button-Co7fp7HS.js";import{n as Fe}from"./guards-BFEDbduR.js";var L={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};L.node;var Ie=f(L),R={name:`copy-plus`,size:24,node:[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};R.node;var Le=f(R),z={name:`file-image`,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`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};z.node;var B=f(z),V={name:`folder-input`,size:24,node:[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]};V.node;var Re=f(V),H={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};H.node;var ze=f(H),U={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};U.node;var Be=f(U),W={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};W.node;var Ve=f(W),G=e(n(),1),K=t();async function He(e){let[t]=e;return t&&e.length===1?(await fe(t.id),{deleted:[t.id],skipped:[]}):ke(e.map(e=>e.id))}function Ue({items:e,references:t}){let n=e.filter(e=>(O(t(e.id))??0)>0),r=e.filter(e=>O(t(e.id))===null);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:`media-delete-list`,children:e.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`strong`,{children:e.filename}),` — `,T(t(e.id))]},e.id))}),n.length>0&&(0,K.jsxs)(`p`,{className:`media-warning`,role:`note`,children:[x(n.length),` `,n.length===1?`is`:`are`,` used by documents. Their pages lose the image: the documents still point at a file that is gone.`]}),r.length>0&&(0,K.jsxs)(`p`,{className:`media-warning`,role:`note`,children:[`The references of `,x(r.length),` are not read yet or could not be read, so they may be in use.`]}),(0,K.jsx)(`p`,{children:`This cannot be undone.`})]})}function We({outcome:e,items:t}){let n=e=>t.find(t=>t.id===e)?.filename??e;return(0,K.jsxs)(`div`,{role:`status`,children:[(0,K.jsxs)(`p`,{children:[`Deleted `,x(e.deleted.length),`.`]}),e.skipped.length>0&&(0,K.jsx)(`ul`,{className:`media-delete-list`,children:e.skipped.map(e=>(0,K.jsxs)(`li`,{children:[n(e.id),`: `,e.reason]},e.id))})]})}function Ge({phase:e,count:t,safe:n,onClose:r,onRun:i}){if(e.name===`done`||e.name===`failed`)return(0,K.jsx)(u,{ref:n,onClick:r,children:`Close`});let a=e.name===`working`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{ref:n,"aria-disabled":a,onClick:a?void 0:r,children:`Cancel`}),(0,K.jsx)(u,{variant:`danger`,"aria-disabled":a,onClick:a?void 0:i,children:a?`Deleting…`:`Delete ${x(t)}`})]})}function Ke(e){let[t,n]=(0,G.useState)({name:`ask`});async function r(){n({name:`working`});try{let t=await He(e.items);n({name:`done`,outcome:t}),e.onDone(t.deleted)}catch(e){n({name:`failed`,message:P(e,`Delete failed`)})}}return{phase:t,run:r}}function qe(e){let{phase:t,run:n}=Ke(e),r=(0,G.useRef)(null);(0,G.useEffect)(()=>{(t.name===`done`||t.name===`failed`)&&r.current?.focus()},[t.name]);let i=t.name===`working`;return(0,K.jsxs)(M,{title:e.items.length===1?`Delete file`:`Delete files`,onClose:i?()=>void 0:e.onClose,initialFocus:r,busy:i,actions:(0,K.jsx)(Ge,{phase:t,count:e.items.length,safe:r,onClose:e.onClose,onRun:()=>void n()}),children:[t.name===`done`&&(0,K.jsx)(We,{outcome:t.outcome,items:e.items}),t.name===`failed`&&(0,K.jsx)(`p`,{role:`alert`,children:t.message}),(t.name===`ask`||t.name===`working`)&&(0,K.jsx)(Ue,{items:e.items,references:e.references})]})}function Je({item:e,canEdit:t}){return t?(0,K.jsxs)(r,{to:Ae(e.id),className:l(`secondary`,`sm`),children:[(0,K.jsx)(p,{className:`ui-button-icon`,"aria-hidden":`true`}),`Crop & hotspot`]}):(0,K.jsx)(I,{size:`sm`,icon:p,reason:k,onClick:()=>void 0,children:`Crop & hotspot`})}function Ye({item:e,reason:t,onReplaced:n}){let r=(0,G.useRef)(null),i=te(e,n);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{ref:r,type:`file`,accept:`image/*`,hidden:!0,"aria-label":`Replace ${e.filename}`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&i.run(t)}}),(0,K.jsx)(I,{size:`sm`,icon:ne,reason:t??(i.busy?`Replacing…`:null),onClick:()=>r.current?.click(),children:i.busy?`Replacing…`:`Replace`})]})}function Xe({item:e}){let t=g(),n=Fe(e.url);return(0,K.jsxs)(`div`,{className:`media-actions`,children:[A(e)&&(0,K.jsx)(u,{size:`sm`,icon:oe,onClick:()=>t(De(e),`Markdown`),children:`Copy markdown`}),(0,K.jsx)(u,{size:`sm`,variant:`ghost`,icon:Ve,onClick:()=>t(e.id,`ID`),children:`Copy ID`}),n&&(0,K.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:l(`ghost`,`sm`),children:[(0,K.jsx)(se,{className:`ui-button-icon`,"aria-hidden":`true`}),`Open original`,(0,K.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]})]})}function Ze(e){let{item:t,canEdit:n}=e,r=n?null:k,i=re(t,e.onDuplicated);return(0,K.jsxs)(`div`,{className:`media-actions`,children:[A(t)&&(0,K.jsx)(Je,{item:t,canEdit:n}),(0,K.jsx)(Ye,{item:t,reason:r,onReplaced:e.onReplaced}),(0,K.jsx)(I,{size:`sm`,icon:Le,reason:r??(i.busy?`Duplicating…`:null),onClick:()=>void i.run(),children:`Duplicate`}),(0,K.jsx)(I,{size:`sm`,variant:`danger`,icon:y,reason:r,onClick:e.onDelete,children:`Delete`})]})}function Qe({tags:e,disabled:t,onRemove:n}){return e.length===0?null:(0,K.jsx)(`ul`,{className:`media-tags`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`media-tag`,children:[e,(0,K.jsx)(`button`,{type:`button`,className:`media-tag-remove`,"aria-label":`Remove ${e}`,disabled:t,onClick:()=>n(e),children:(0,K.jsx)(F,{"aria-hidden":`true`})})]},e))})}function $e({id:e,known:t,tags:n}){return(0,K.jsx)(`datalist`,{id:e,children:t.filter(e=>!n.includes(e)).map(e=>(0,K.jsx)(`option`,{value:e},e))})}function et({tags:e,known:t,disabled:n,onChange:r}){let i=(0,G.useId)(),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(``);function c(t){if(t.key!==`Enter`&&t.key!==`,`)return;t.preventDefault();let n=o.trim();n&&!e.includes(n)&&r([...e,n]),s(``)}function l(t){r(e.filter(e=>e!==t)),a.current?.focus()}return(0,K.jsxs)(`div`,{className:`media-field`,children:[(0,K.jsx)(`label`,{htmlFor:i,className:`media-label`,children:`Tags`}),(0,K.jsx)(Qe,{tags:e,disabled:n,onRemove:l}),(0,K.jsx)(`input`,{ref:a,id:i,className:`media-input`,list:`${i}-known`,placeholder:`Type a tag and press Enter`,value:o,disabled:n,onChange:e=>s(e.target.value),onKeyDown:c}),(0,K.jsx)($e,{id:`${i}-known`,known:t,tags:e})]})}var tt=5e3;function q(e){if(!e||e.state===`loading`)return`wait`;if(e.state===`failed`)return{count:null};let t=e.documents.length;return t===0?`save`:{count:t}}function nt(e,t){let[n,r]=(0,G.useState)({phase:`idle`}),i=(0,G.useRef)(t);i.current=t;let a=(0,G.useCallback)(e=>{e===`wait`?r({phase:`checking`}):e===`save`?(r({phase:`idle`}),i.current()):r({phase:`confirm`,count:e.count})},[]),o=n.phase===`checking`;return(0,G.useEffect)(()=>{if(!o)return;let t=q(e);if(t!==`wait`){a(t);return}let n=setTimeout(()=>a({count:null}),tt);return()=>clearTimeout(n)},[o,e,a]),{state:n,request:()=>a(q(e)),confirm:()=>{r({phase:`idle`}),i.current()},cancel:()=>r({phase:`idle`})}}function rt({count:e,onConfirm:t,onCancel:n}){let r=(0,G.useRef)(null);return(0,K.jsx)(M,{title:`Rename a file in use`,onClose:n,initialFocus:r,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{ref:r,onClick:n,children:`Cancel`}),(0,K.jsx)(u,{variant:`primary`,onClick:t,children:`Rename`})]}),children:(0,K.jsx)(`p`,{children:Ce(e)})})}function J({label:e,value:t,disabled:n,note:r,onChange:i}){let a=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`media-field`,children:[(0,K.jsx)(`label`,{htmlFor:a,className:`media-label`,children:e}),(0,K.jsx)(`input`,{id:a,className:`media-input`,value:t,disabled:n,"aria-describedby":r?`${a}-note`:void 0,onChange:e=>i(e.target.value)}),r&&(0,K.jsx)(`p`,{id:`${a}-note`,className:`media-note`,children:r})]})}function it({item:e,folders:t,disabled:n,onMoved:r}){let i=(0,G.useId)(),a=m(e,r);return(0,K.jsxs)(`div`,{className:`media-field`,children:[(0,K.jsx)(`label`,{htmlFor:i,className:`media-label`,children:`Folder`}),(0,K.jsxs)(`select`,{id:i,className:`media-select`,value:e.folder??``,disabled:n||a.busy,onChange:e=>void a.run(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`No folder`}),t.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}function at({canEdit:e,busy:t,checking:n}){return e?(0,K.jsx)(u,{type:`submit`,variant:`primary`,size:`sm`,icon:v,"aria-disabled":t||n,children:n?`Checking references…`:t?`Saving…`:`Save`}):(0,K.jsx)(I,{size:`sm`,icon:v,reason:k,onClick:()=>void 0,children:`Save`})}var ot=`No alt text: screen readers and search engines get no description of the image.`;function st({props:e,details:t,change:n}){let r=!e.canEdit;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Name`,value:t.filename,disabled:r,onChange:e=>n({filename:e})}),(0,K.jsx)(J,{label:`Alt text`,value:t.altText,disabled:r,note:t.altText.trim()?void 0:ot,onChange:e=>n({altText:e})}),(0,K.jsx)(et,{tags:t.tags,known:e.knownTags,disabled:r,onChange:e=>n({tags:e})}),e.folders&&e.folders.length>0&&(0,K.jsx)(it,{item:e.item,folders:e.folders,disabled:r,onMoved:e.onSaved})]})}function ct(e){let{item:t}=e,[n,r]=(0,G.useState)({filename:t.filename,altText:t.altText,tags:[...t.tags]}),i=ie(t,e.onSaved),a=nt(e.references,()=>void i.run(n)),o=e=>r(t=>({...t,...e}));function s(r){r.preventDefault(),e.canEdit&&!i.busy&&a.state.phase===`idle`&&(n.filename===t.filename?i.run(n):a.request())}return(0,K.jsxs)(`form`,{className:`media-details`,"aria-label":`Details`,onSubmit:s,children:[(0,K.jsx)(st,{props:e,details:n,change:o}),(0,K.jsx)(at,{canEdit:e.canEdit,busy:i.busy,checking:a.state.phase===`checking`}),a.state.phase===`confirm`&&(0,K.jsx)(rt,{count:a.state.count,onCancel:a.cancel,onConfirm:a.confirm})]})}function lt({references:e}){return(0,K.jsxs)(`div`,{className:`media-references`,children:[(0,K.jsx)(`p`,{className:`media-references-count`,children:T(e)}),e?.state===`ready`&&e.documents.length>0&&(0,K.jsx)(`ul`,{className:`media-reference-list`,children:e.documents.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(r,{to:je(e.collection,e.slug),className:`media-link`,children:[e.collection,`/`,e.slug]}),` `,(0,K.jsxs)(`span`,{className:`media-reference-fields`,children:[`(`,e.fields.join(`, `),`)`]})]},`${e.collection}/${e.slug}`))})]})}function ut({item:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`media-drawer-preview`,children:A(e)?(0,K.jsx)(`img`,{src:j(e,`lg`),alt:e.altText}):(0,K.jsx)(B,{"aria-hidden":`true`})}),(0,K.jsxs)(`dl`,{className:`media-facts`,children:[(0,K.jsx)(`dt`,{children:`Kind`}),(0,K.jsx)(`dd`,{children:S(e.mimeType)}),(0,K.jsx)(`dt`,{children:`Dimensions`}),(0,K.jsx)(`dd`,{children:D(e)??`None stored`}),(0,K.jsx)(`dt`,{children:`Size`}),(0,K.jsx)(`dd`,{children:o(e.size)}),(0,K.jsx)(`dt`,{children:`Uploaded`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`time`,{dateTime:e.createdAt,children:s(e.createdAt)})}),(0,K.jsx)(`dt`,{children:`Stable URL`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{className:`media-url`,children:xe(e.id)})})]})]})}function dt({titleId:e,item:t,onClose:n}){let r=(0,G.useRef)(null);return(0,G.useEffect)(()=>{r.current?.focus()},[]),(0,K.jsxs)(`div`,{className:`media-drawer-head`,children:[(0,K.jsx)(`h2`,{id:e,ref:r,tabIndex:-1,className:`media-drawer-title`,children:t.filename}),(0,K.jsx)(d,{icon:F,label:`Close details`,onClick:n})]})}function ft(e){let{item:t,permissions:n}=e,r=(0,G.useId)();function i(t){t.key!==`Escape`||t.defaultPrevented||(t.stopPropagation(),e.onClose())}return(0,K.jsxs)(`section`,{className:`media-drawer`,"aria-labelledby":r,onKeyDown:i,children:[(0,K.jsx)(dt,{titleId:r,item:t,onClose:e.onClose}),(0,K.jsx)(ut,{item:t}),(0,K.jsx)(lt,{references:e.references}),(0,K.jsx)(Xe,{item:t}),(0,K.jsx)(Ze,{item:t,canEdit:n.canEdit,onReplaced:t=>e.onChanged(t,!0),onDuplicated:e.onDuplicated,onDelete:e.onDelete}),(0,K.jsx)(ct,{item:t,references:e.references,folders:e.folders,knownTags:e.knownTags,canEdit:n.canEdit,onSaved:t=>e.onChanged(t,!1)},`${t.id}:${t.url}`)]})}function Y(e){let{label:t,submitLabel:n,onCancel:r}=e,i=(0,G.useId)(),[a,o]=(0,G.useState)(e.initial),[s,c]=(0,G.useState)(!1);async function l(t){t.preventDefault(),a.trim()&&!s&&(c(!0),await e.onSubmit(a.trim()),c(!1))}return(0,K.jsxs)(`form`,{className:`media-folder-form`,onSubmit:e=>void l(e),children:[(0,K.jsx)(`label`,{htmlFor:i,className:`media-label`,children:t}),(0,K.jsx)(`input`,{id:i,className:`media-input`,value:a,autoFocus:!0,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Escape`&&r()}),(0,K.jsxs)(`div`,{className:`media-actions`,children:[(0,K.jsx)(u,{size:`sm`,variant:`primary`,type:`submit`,"aria-disabled":s,children:n}),(0,K.jsx)(u,{size:`sm`,variant:`ghost`,onClick:r,children:`Cancel`})]})]})}function pt({folder:e,onClose:t,onDeleted:n}){let r=N(),i=(0,G.useRef)(null);async function a(){try{await Oe(e.id),r({text:`Folder ${e.name} deleted.`}),n()}catch(e){r({text:P(e,`The folder could not be deleted`),tone:`error`})}t()}return(0,K.jsx)(M,{title:`Delete folder`,onClose:t,initialFocus:i,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{ref:i,onClick:t,children:`Cancel`}),(0,K.jsx)(u,{variant:`danger`,onClick:()=>void a(),children:`Delete folder`})]}),children:(0,K.jsxs)(`p`,{children:[`Delete the folder `,(0,K.jsx)(`strong`,{children:e.name}),`? Only an empty folder can be deleted; its files stay in the library.`]})})}function mt(e){let t=N();async function n(n,r){try{e(await n())}catch(e){t({text:P(e,r),tone:`error`})}}return{create:(e,t)=>n(async()=>(await ve(t,e?.id??null)).id,`The folder could not be created`),rename:(e,t)=>n(async()=>{await _e(e.id,t)},`The folder could not be renamed`)}}function ht({props:e,onEdit:t}){let n=e.canEdit?null:k;return(0,K.jsxs)(`div`,{className:`media-folder-actions`,children:[(0,K.jsx)(I,{size:`sm`,icon:ze,reason:n,onClick:()=>t(`new`),children:`New folder`}),e.selected&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I,{size:`sm`,variant:`ghost`,icon:ue,reason:n,onClick:()=>t(`rename`),children:`Rename folder`}),(0,K.jsx)(I,{size:`sm`,variant:`ghost`,icon:y,reason:e.canAdminister?null:`Deleting several files at once, or a folder, needs the admin role.`,onClick:()=>t(`delete`),children:`Delete folder`})]})]})}function gt(e){let{selected:t,onChanged:n}=e,[r,i]=(0,G.useState)(`none`),a=()=>i(`none`),o=mt(e=>{a(),n(e)});return r===`new`?(0,K.jsx)(Y,{label:t?`New folder in ${t.name}`:`New folder`,initial:``,submitLabel:`Create`,onSubmit:e=>o.create(t,e),onCancel:a}):r===`rename`&&t?(0,K.jsx)(Y,{label:`Folder name`,initial:t.name,submitLabel:`Rename`,onSubmit:e=>o.rename(t,e),onCancel:a}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ht,{props:e,onEdit:i}),r===`delete`&&t&&(0,K.jsx)(pt,{folder:t,onClose:a,onDeleted:()=>n()})]})}function _t({value:e}){return e==null?null:(0,K.jsxs)(`span`,{className:`media-folder-count`,children:[e,(0,K.jsxs)(`span`,{className:`visually-hidden`,children:[` `,e===1?`file`:`files`]})]})}function X(e){let{icon:t}=e;function n(t){let n=t.dataTransfer.getData(E);n&&(t.preventDefault(),e.onDropMedia(n))}return(0,K.jsxs)(`button`,{type:`button`,className:`media-folder`,"aria-pressed":e.pressed,onClick:e.onSelect,onDragOver:e=>{e.dataTransfer.types.includes(`application/krantho-media-id`)&&e.preventDefault()},onDrop:n,children:[(0,K.jsx)(t,{className:`media-folder-icon`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`media-folder-name`,children:e.label}),(0,K.jsx)(_t,{value:e.count})]})}function vt({row:e,open:t,onToggle:n}){if(!e.hasChildren)return(0,K.jsx)(`span`,{className:`media-folder-toggle-space`,"aria-hidden":`true`});let r=t?ae:Ne;return(0,K.jsx)(`button`,{type:`button`,className:`media-folder-toggle`,"aria-expanded":t,"aria-label":`Subfolders of ${e.folder.name}`,onClick:n,children:(0,K.jsx)(r,{"aria-hidden":`true`})})}function yt({props:e}){let[t,n]=(0,G.useState)(new Set),r=e=>n(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return w(e.folders,t).map(n=>(0,K.jsxs)(`li`,{className:`media-folder-row`,style:{paddingInlineStart:`calc(${n.depth} * var(--space-4))`},children:[(0,K.jsx)(vt,{row:n,open:!t.has(n.folder.id),onToggle:()=>r(n.folder.id)}),(0,K.jsx)(X,{label:n.folder.name,count:e.counts.get(n.folder.id),pressed:e.selected===n.folder.id,icon:Be,onSelect:()=>e.onSelect(n.folder.id),onDropMedia:t=>e.onMove(t,n.folder.id)})]},n.folder.id))}function bt(e){let t=e.folders.find(t=>t.id===e.selected)??null;return(0,K.jsxs)(`nav`,{className:`media-folders`,"aria-label":`Folders`,children:[(0,K.jsx)(`h2`,{className:`media-folders-title`,children:`Folders`}),(0,K.jsxs)(`ul`,{className:`media-folder-list`,children:[(0,K.jsxs)(`li`,{className:`media-folder-row`,children:[(0,K.jsx)(`span`,{className:`media-folder-toggle-space`,"aria-hidden":`true`}),(0,K.jsx)(X,{label:`All files`,count:e.total,pressed:e.selected===null,icon:ce,onSelect:()=>e.onSelect(null),onDropMedia:t=>e.onMove(t,null)})]}),(0,K.jsx)(yt,{props:e})]}),(0,K.jsx)(gt,{selected:t,canEdit:e.permissions.canEdit,canAdminister:e.permissions.canAdminister,onChanged:e.onChanged})]})}function Z({item:e,references:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`media-tile-thumb`,children:[A(e)?(0,K.jsx)(`img`,{src:j(e,`md`),alt:``,loading:`lazy`}):(0,K.jsx)(B,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`media-tile-kind`,children:S(e.mimeType)})]}),(0,K.jsx)(`span`,{className:`media-tile-name`,children:e.filename}),(0,K.jsx)(`span`,{className:`media-tile-meta`,children:D(e)??`No pixel dimensions`}),(0,K.jsx)(`span`,{className:`media-tile-refs`,children:T(t)})]})}function xt({item:e,props:t}){let n=t.references(e.id);if(t.bulk){let r=t.selected.has(e.id);return(0,K.jsxs)(`label`,{className:`media-tile${r?` media-tile--selected`:``}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`media-tile-check`,"aria-label":`Select ${e.filename}`,checked:r,onChange:()=>t.onToggle(e.id)}),(0,K.jsx)(Z,{item:e,references:n})]})}return(0,K.jsx)(`button`,{type:`button`,className:`media-tile`,"data-media-id":e.id,"aria-pressed":t.open===e.id,draggable:t.draggable,onDragStart:t=>{t.dataTransfer.setData(E,e.id),t.dataTransfer.effectAllowed=`move`},onClick:()=>t.onOpen(e),children:(0,K.jsx)(Z,{item:e,references:n})})}function St(e){return(0,K.jsx)(`ul`,{className:`media-grid`,"aria-label":`Files`,children:e.items.map(t=>(0,K.jsx)(`li`,{children:(0,K.jsx)(xt,{item:t,props:e})},t.id))})}function Ct({info:e,read:t}){return(0,K.jsxs)(`header`,{className:`media-header`,children:[(0,K.jsx)(`h1`,{className:`media-title`,children:`Media`}),e?(0,K.jsxs)(`p`,{className:`media-lead`,children:[`Stored in `,(0,K.jsx)(`strong`,{className:`media-store`,children:e.storageLabel}),e.storagePath&&(0,K.jsxs)(K.Fragment,{children:[` `,`at `,(0,K.jsx)(`code`,{className:`media-store-path`,children:e.storagePath})]}),(0,K.jsxs)(`span`,{children:[` `,`· `,x(e.totalItems),`, `,o(e.totalSize)]})]}):(0,K.jsx)(`p`,{className:`media-lead`,children:t?`The media store could not be read.`:`Reading the media store…`})]})}function wt({value:e,onChange:t}){let n=(0,G.useId)();return(0,K.jsxs)(`span`,{className:`media-search`,children:[(0,K.jsx)(`label`,{htmlFor:n,className:`visually-hidden`,children:`Search media`}),(0,K.jsx)(Me,{className:`media-search-icon`,"aria-hidden":`true`}),(0,K.jsx)(`input`,{id:n,type:`search`,className:`media-input media-search-input`,placeholder:`Search by name`,value:e,onChange:e=>t(e.target.value)})]})}function Q(e){let t=(0,G.useId)();return(0,K.jsxs)(`span`,{className:`media-filter`,children:[(0,K.jsx)(`label`,{htmlFor:t,children:e.label}),(0,K.jsx)(`select`,{id:t,className:`media-select`,value:e.value,onChange:t=>{let n=e.options.find(e=>e.value===t.target.value);n&&e.onChange(n.value)},children:e.options.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Tt(e){let{filters:t,onFilters:n,tags:r}=e,i=[{value:``,label:`All tags`},...r.map(e=>({value:e,label:e}))];return(0,K.jsxs)(`div`,{className:`media-toolbar`,children:[(0,K.jsx)(wt,{value:t.search,onChange:e=>n({search:e})}),r.length>0&&(0,K.jsx)(Q,{label:`Tag`,value:t.tag,options:i,onChange:e=>n({tag:e})}),(0,K.jsx)(Q,{label:`Order this page`,value:e.sort,options:be.map(e=>({value:e,label:we[e]})),onChange:e.onSort}),(0,K.jsx)(u,{size:`sm`,icon:le,"aria-pressed":e.bulk,onClick:e.onBulk,children:`Bulk select`})]})}function Et(e){let t=e.count===0?`Select files to delete.`:null;return(0,K.jsxs)(`section`,{className:`media-selection`,"aria-label":`Selection`,children:[(0,K.jsxs)(`p`,{className:`media-selection-count`,role:`status`,children:[(0,K.jsx)(`span`,{className:`media-figure`,children:e.count}),` selected`]}),(0,K.jsxs)(`div`,{className:`media-actions`,children:[(0,K.jsx)(I,{size:`sm`,variant:`danger`,icon:y,reason:e.canDelete?t:Ee,onClick:e.onDelete,children:`Delete`}),(0,K.jsx)(u,{size:`sm`,variant:`ghost`,icon:Ie,onClick:e.onSelectPage,children:`Select this page`}),(0,K.jsx)(u,{size:`sm`,variant:`ghost`,icon:F,onClick:e.onClear,children:`Clear selection`})]})]})}function Dt({items:e,folder:t}){let n=e.length===1;return`Uploaded ${x(e.length)} to All files: an upload goes into no folder. Move ${n?`it`:`them`} to ${t.name} from ${n?`its`:`their`} details, or with Move here.`}async function Ot(e,t){let n=0;for(let r of e)await b(r.id,t.id),n++;return n}function kt({notice:e,onMoved:t,onDismiss:n}){let r=N(),[i,a]=(0,G.useState)(!1);async function o(){a(!0);try{let n=await Ot(e.items,e.folder);r({text:`Moved ${x(n)} to ${e.folder.name}.`}),t()}catch(e){r({text:P(e,`The files could not be moved`),tone:`error`}),a(!1)}}return(0,K.jsxs)(`div`,{className:`media-upload-notice`,role:`status`,children:[(0,K.jsx)(`p`,{children:Dt(e)}),(0,K.jsxs)(`div`,{className:`media-actions`,children:[(0,K.jsx)(u,{size:`sm`,variant:`primary`,icon:Re,"aria-disabled":i,onClick:i?void 0:()=>void o(),children:i?`Moving…`:`Move here`}),(0,K.jsx)(u,{size:`sm`,variant:`ghost`,icon:F,onClick:n,children:`Dismiss`})]})]})}var At={search:``,tag:``,folder:null,page:0},jt={read:!1,info:null,tags:[],folders:[],folderCounts:new Map};function Mt(e,t){return t?new Map(e.map(e=>[e.id,t.folderCounts[e.id]??0])):new Map}async function Nt(e){let[t,n,r]=await Promise.all([ge().catch(()=>null),de().catch(()=>[]),e?pe().catch(()=>[]):Promise.resolve([])]);return{read:!0,info:t,tags:n,folders:r,folderCounts:Mt(r,t)}}function $(e){return me({limit:24,offset:e.page*24,search:e.search||void 0,tag:e.tag||void 0,folder:e.folder??void 0})}function Pt(e,t){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(null);return(0,G.useEffect)(()=>{let t=!0;return $(e).then(e=>{t&&(r(e),a(null))}).catch(e=>t&&a(P(e,`Media could not be read`))),()=>{t=!1}},[e,t]),[n,i]}function Ft(e,t){let[n,r]=(0,G.useState)(jt);return(0,G.useEffect)(()=>{let t=!0;return Nt(e).then(e=>t&&r(e)),()=>{t=!1}},[e,t]),n}function It(e){let[t,n]=(0,G.useState)(At),[r,i]=(0,G.useState)(`newest`),[a,o]=(0,G.useState)(0),[s,c]=Pt(t,a),l=Ft(e,a),u=(0,G.useCallback)(e=>{n(t=>({...t,page:0,...e}))},[]),d=(0,G.useCallback)(()=>o(e=>e+1),[]);return{filters:t,setFilters:u,sort:r,setSort:i,listing:s,items:(0,G.useMemo)(()=>ye(s?.items??[],r),[s,r]),pageCount:Math.ceil((s?.total??0)/24),library:l,error:c,reload:d}}function Lt(e){queueMicrotask(()=>{([...document.querySelectorAll(`[data-media-id]`)].find(t=>t.getAttribute(`data-media-id`)===e)??document.getElementById(`studio-main`))?.focus()})}function Rt(e){let[t,n]=(0,G.useState)(null);return(0,G.useEffect)(()=>{n(t=>(t&&e.find(e=>e.id===t.id))??t)},[e]),{item:t,open:n,close:(0,G.useCallback)(()=>{n(e=>(e&&Lt(e.id),null))},[]),drop:(0,G.useCallback)(()=>n(null),[]),update:n}}function zt(){let[e,t]=(0,G.useState)(!1),[n,r]=(0,G.useState)(new Map),i=e=>r(t=>{let n=new Map(t);return e(n),n});return{on:e,toggleMode:()=>{t(e=>!e),r(new Map)},ids:new Set(n.keys()),items:[...n.values()],toggle:e=>i(t=>{t.delete(e.id)||t.set(e.id,e)}),add:e=>i(t=>{for(let n of e)t.set(n.id,n)}),remove:e=>i(t=>{for(let n of e)t.delete(n)}),clear:()=>r(new Map)}}function Bt(e){let[t,n]=(0,G.useState)(new Map),r=(0,G.useRef)(new Set),i=(0,G.useCallback)(e=>{n(t=>{let n=new Map(t);for(let[t,r]of e)n.set(t,r);return n})},[]),a=(0,G.useCallback)(e=>{r.current.add(e),i([[e,{state:`loading`}]]),Te(e).then(e=>({state:`ready`,documents:C(e.usage)})).catch(()=>({state:`failed`})).then(t=>i([[e,t]]))},[i]);return(0,G.useEffect)(()=>{let t=e.filter(e=>!r.current.has(e));if(t.length!==0){for(let e of t)r.current.add(e);i(t.map(e=>[e,{state:`loading`}])),he(t).then(e=>t.map(t=>[t,{state:`ready`,documents:C(e[t]??[])}])).catch(()=>t.map(e=>[e,{state:`failed`}])).then(e=>i(e))}},[e,i]),{of:(0,G.useCallback)(e=>t.get(e),[t]),refresh:a}}function Vt(){setTimeout(()=>{(document.activeElement===document.body||!document.activeElement)&&document.getElementById(`studio-main`)?.focus()},0)}function Ht({page:e}){let{media:t,selection:n,open:r}=e;if(t.error)return(0,K.jsx)(`p`,{role:`alert`,children:t.error});if(!t.listing)return(0,K.jsx)(`p`,{role:`status`,children:`Reading media…`});if(t.items.length===0){let e=t.filters.search||t.filters.tag||t.filters.folder;return(0,K.jsx)(Pe,{icon:_,title:e?`No files match`:`No media yet`,children:e?`Nothing here matches the search, tag and folder chosen.`:`Upload an image to start the library.`})}return(0,K.jsx)(St,{items:t.items,references:e.references.of,bulk:n.on,selected:n.ids,onToggle:e=>{let r=t.items.find(t=>t.id===e);r&&n.toggle(r)},open:r.item?.id??null,onOpen:r.open,draggable:e.hasFolders&&e.permissions.canEdit})}function Ut(e){let t=N();return(n,r)=>{b(n,r).then(()=>{t({text:`Moved.`}),e()}).catch(e=>t({text:P(e,`The file could not be moved`),tone:`error`}))}}function Wt({page:e}){let{media:t}=e,{library:n,filters:r,setFilters:i,reload:a}=t,o=Ut(a),s=(0,G.useRef)(r.folder);return s.current=r.folder,(0,G.useEffect)(()=>{let e=s.current;n.read&&e!==null&&(n.folders.some(t=>t.id===e)||i({folder:null}))},[n,i]),e.hasFolders?(0,K.jsx)(bt,{folders:n.folders,counts:n.folderCounts,total:n.info?.totalItems??null,selected:r.folder,onSelect:e=>i({folder:e}),permissions:e.permissions,onChanged:e=>{a(),e&&i({folder:e})},onMove:o}):null}function Gt({page:e}){let{media:t,permissions:n}=e,[r,i]=(0,G.useState)(null);function a(e){let n=t.library.folders.find(e=>e.id===t.filters.folder);i(n?{items:e,folder:n}:null),t.setFilters({page:0}),t.reload()}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ee,{blocked:n.canEdit?null:k,onUploaded:a}),r&&(0,K.jsx)(kt,{notice:r,onDismiss:()=>i(null),onMoved:()=>{i(null),t.reload()}})]})}function Kt({page:e}){let{media:t,selection:n,permissions:r}=e;return(0,K.jsxs)(`div`,{className:`media-main`,children:[(0,K.jsx)(Gt,{page:e}),(0,K.jsx)(Tt,{filters:t.filters,onFilters:t.setFilters,tags:t.library.tags,sort:t.sort,onSort:t.setSort,bulk:n.on,onBulk:n.toggleMode}),n.on&&(0,K.jsx)(Et,{count:n.ids.size,canDelete:r.canAdminister,onDelete:()=>e.askDelete(n.items),onSelectPage:()=>n.add(t.items),onClear:n.clear}),(0,K.jsx)(Ht,{page:e}),(0,K.jsx)(h,{page:t.filters.page,count:t.pageCount,onPage:e=>t.setFilters({page:e})})]})}function qt({page:e}){let{media:t,open:n}=e,r=n.item;return r?(0,K.jsx)(ft,{item:r,references:e.references.of(r.id),folders:e.hasFolders?t.library.folders:null,knownTags:t.library.tags,permissions:e.permissions,onClose:n.close,onChanged:e=>{n.update(e),t.reload()},onDuplicated:e=>{t.reload(),n.open(e)},onDelete:()=>e.askDelete([r])},r.id):null}function Jt({page:e,items:t,onClose:n}){let{open:r,selection:i,media:a}=e;return(0,K.jsx)(qe,{items:t,references:e.references.of,onClose:()=>{n(),Vt()},onDone:e=>{r.item&&e.includes(r.item.id)&&r.drop(),i.remove(e),a.reload()}})}function Yt(){let{hasRole:e}=i(),t=c(a(),`mediaFolders`),n=It(t),r=Bt((0,G.useMemo)(()=>n.items.map(e=>e.id),[n.items])),o=Rt(n.items),s=zt(),[l,u]=(0,G.useState)(null),d={media:n,references:r,open:o,selection:s,permissions:Se(e),hasFolders:t,askDelete:e=>{for(let t of e)r.refresh(t.id);u(e)}};return(0,K.jsxs)(`div`,{className:`media${o.item?` media--drawer`:``}`,children:[(0,K.jsx)(Ct,{info:n.library.info,read:n.library.read}),(0,K.jsxs)(`div`,{className:`media-body`,children:[(0,K.jsx)(Wt,{page:d}),(0,K.jsx)(Kt,{page:d})]}),(0,K.jsx)(qt,{page:d}),l&&(0,K.jsx)(Jt,{page:d,items:l,onClose:()=>u(null)})]})}export{Yt as MediaPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,s as n}from"./vendor-diff-Dm2YfgXt.js";import{t as r}from"./vendor-router-DjV3D6zM.js";import{i}from"./auth-GRfs02w7.js";import{d as a,l as o,t as s,u as c}from"./format-pPdsDgeS.js";import{i as l,n as u,t as d}from"./createLucideIcon-D_HN41p3.js";import{a as ee,i as te,n as ne,r as re}from"./findability-CUYOthYI.js";import{t as f}from"./pen-line-CZkcVGBd.js";import{f as ie,y as ae}from"./api-seo-2H6_VoWE.js";import{t as p}from"./triangle-alert-C4yqbtOC.js";import{C as oe,Ct as m,D as h,Dt as g,K as _,M as v,S as y,St as se,Tt as b,V as ce,a as le,at as ue,ct as de,f as fe,ft as x,h as pe,i as S,lt as C,nt as w,ot as T,q as E,r as D,s as O,ut as k,x as A,z as j}from"./index-DVe5jFLX.js";import{t as M}from"./empty-state-CU7q3Ypl.js";import{i as N,n as P,r as F,t as I}from"./meter-mJxPk3I3.js";import{n as L,t as R}from"./source-CGZGd3Xy.js";var z={name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]};z.node;var B=d(z),V={name:`text-search`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M10 12H3`,key:`1ulcyk`}],[`path`,{d:`M10 19H3`,key:`108z41`}],[`circle`,{cx:`17`,cy:`15`,r:`3`,key:`1upz2a`}],[`path`,{d:`m21 19-1.9-1.9`,key:`dwi7p8`}]]};V.node;var H=d(V),U=e(n(),1),W=t(),me={live:`live`,ahead:`draft ahead`,draft:`draft`};function G({status:e,count:t}){return(0,W.jsxs)(`span`,{className:`collection-count${t===0?` collection-count--zero`:``}`,children:[(0,W.jsx)(A,{status:e,decorative:!0}),(0,W.jsx)(`span`,{className:`collection-count-number`,children:t}),` `,me[e]]})}function he({counts:e}){let{collection:t,live:n,ahead:i,draft:a}=e,o=le(t);return(0,W.jsx)(`li`,{children:(0,W.jsxs)(r,{to:m(t.name),className:`collection-row`,children:[(0,W.jsxs)(`span`,{className:`collection-name`,children:[s(t.name),o!==null&&(0,W.jsx)(`code`,{className:`collection-path`,children:o})]}),(0,W.jsxs)(`span`,{className:`collection-counts`,children:[(0,W.jsx)(G,{status:`live`,count:n}),i>0&&(0,W.jsx)(G,{status:`ahead`,count:i}),(0,W.jsx)(G,{status:`draft`,count:a})]})]})})}function ge({collections:e}){return(0,W.jsxs)(`section`,{className:`pulse-panel`,"aria-labelledby":`pulse-collections-title`,children:[(0,W.jsx)(`div`,{className:`pulse-panel-head`,children:(0,W.jsx)(`h2`,{id:`pulse-collections-title`,children:`Collections`})}),e.length===0?(0,W.jsxs)(M,{icon:k,title:`No collections`,children:[`Collections are defined in code, in `,(0,W.jsx)(`code`,{children:`krantho.collections.ts`}),`.`]}):(0,W.jsx)(`ul`,{className:`collection-list`,children:e.map(e=>(0,W.jsx)(he,{counts:e},e.collection.name))})]})}function K({icon:e,label:t,value:n,total:r,detail:i,children:a}){let o=(0,U.useId)();return(0,W.jsx)(`li`,{className:`pulse-figure`,children:(0,W.jsxs)(`figure`,{className:`pulse-figure-body`,"aria-labelledby":o,children:[(0,W.jsxs)(`figcaption`,{id:o,className:`pulse-figure-label`,children:[(0,W.jsx)(e,{"aria-hidden":`true`}),t]}),n===null?(0,W.jsx)(`p`,{className:`pulse-figure-value pulse-figure-value--unavailable`,children:`Unavailable`}):(0,W.jsxs)(`p`,{className:`pulse-figure-value`,children:[(0,W.jsx)(`span`,{className:`pulse-figure-number`,children:n}),r&&(0,W.jsx)(`span`,{className:`pulse-figure-total`,children:r})]}),a,(0,W.jsx)(`p`,{className:`pulse-figure-detail`,children:i})]})})}function q(e,t,n){return`${e} ${e===1?t:n}`}function _e({figure:e}){let t=e.pages===0?`No pages yet`:e.ahead===0?`None with unpublished changes`:`${e.ahead} with unpublished changes`;return(0,W.jsx)(K,{icon:ee,label:`Live pages`,value:e.live,total:`of ${q(e.pages,`page`,`pages`)}`,detail:t,children:(0,W.jsx)(I,{max:e.pages,segments:[{value:e.live-e.ahead,tone:`live`},{value:e.ahead,tone:`ahead`}]})})}function ve({figure:e}){let t=e.pages===0?`No pages yet`:`${e.fallback} fall back to description · ${e.missing} missing`;return(0,W.jsx)(K,{icon:H,label:`Meta descriptions`,value:e.covered,total:`of ${q(e.pages,`page`,`pages`)} set`,detail:t,children:(0,W.jsx)(I,{max:e.pages,segments:[{value:e.covered,tone:`live`},{value:e.fallback,tone:`ahead`},{value:e.missing,tone:`danger`}]})})}function ye({source:e}){if(e.state!==`ok`)return(0,W.jsx)(K,{icon:B,label:`Valid structured data`,value:null,detail:`The site's SEO findings could not be read`});let t=e.value,n=t.pages===0?`No live pages yet`:t.mainTypes.length>0?`Main types: ${t.mainTypes.join(`, `)}`:`No types search engines show as rich results`;return(0,W.jsx)(K,{icon:B,label:`Valid structured data`,value:t.valid,total:`of ${q(t.pages,`live page`,`live pages`)}`,detail:n,children:(0,W.jsx)(I,{max:t.pages,segments:[{value:t.valid,tone:`live`},{value:t.pages-t.valid,tone:`danger`}]})})}function be({live:e,coverage:t,structuredData:n}){return(0,W.jsxs)(`section`,{className:`pulse-figures-section`,"aria-labelledby":`pulse-figures-title`,children:[(0,W.jsx)(`h2`,{id:`pulse-figures-title`,className:`visually-hidden`,children:`Key figures`}),(0,W.jsxs)(`ul`,{className:`pulse-figures`,children:[(0,W.jsx)(_e,{figure:e}),(0,W.jsx)(ve,{figure:t}),n.state!==`off`&&(0,W.jsx)(ye,{source:n})]})]})}var xe={delivery:w,lock:de,ahead:f,meta:H,locale:C},Se={delivery:[`failed delivery`,`failed deliveries`],lock:[`more locked document`,`more locked documents`],ahead:[`more document with unpublished changes`,`more documents with unpublished changes`],meta:[`more page without a meta description`,`more pages without a meta description`],locale:[`more collection missing a locale`,`more collections missing a locale`]};function J({row:e}){let t=xe[e.kind];return(0,W.jsxs)(`li`,{className:`attention-row attention-row--${e.kind}`,children:[(0,W.jsx)(`span`,{className:`attention-icon`,"aria-hidden":`true`,children:(0,W.jsx)(t,{})}),(0,W.jsxs)(`div`,{className:`attention-text`,children:[(0,W.jsx)(`p`,{className:`attention-title`,children:e.title}),(0,W.jsx)(`p`,{className:`attention-detail`,children:e.detail})]}),(0,W.jsx)(r,{to:e.to,className:l(`secondary`,`sm`,`attention-action`),"aria-label":`${e.action}: ${e.title}`,children:e.action})]})}function Ce({kind:e,count:t}){let[n,r]=Se[e];return`${t} ${t===1?n:r}`}function we({attention:e,watched:t,unread:n}){let{rows:r,overflow:i}=e;return(0,W.jsxs)(`section`,{className:`pulse-panel`,"aria-labelledby":`pulse-attention-title`,children:[(0,W.jsxs)(`div`,{className:`pulse-panel-head`,children:[(0,W.jsx)(`h2`,{id:`pulse-attention-title`,children:`Needs attention`}),r.length>0&&(0,W.jsx)(`span`,{className:`pulse-count`,"aria-hidden":`true`,children:r.length+i.reduce((e,t)=>e+t.count,0)})]}),r.length===0?(0,W.jsxs)(M,{icon:x,title:`Nothing needs you right now`,children:[t,` show up here.`]}):(0,W.jsx)(`ul`,{className:`attention-list`,children:r.map(e=>(0,W.jsx)(J,{row:e},e.key))}),i.length>0&&(0,W.jsxs)(`p`,{className:`attention-more`,children:[`And `,i.map(Ce).join(`, `),`.`]}),n.length>0&&(0,W.jsxs)(`p`,{className:`pulse-unread`,children:[(0,W.jsx)(p,{"aria-hidden":`true`}),`Could not check `,n.join(` or `),`.`]})]})}var Te=[`delivery`,`lock`,`ahead`,`meta`,`locale`];function Y(e,t){let n=e.locale===t.defaultLocale?void 0:e.locale;return b(e.collection,e.slug,n)}function X(e,t){return t.updatedAt.localeCompare(e.updatedAt)}function Z(e){return e===`globals`?`Layout`:s(e)}function Ee(e,t){return e.filter(e=>e.status===`ahead`).sort(X).map(e=>({key:`ahead:${e.collection}/${e.slug}/${e.locale}`,kind:`ahead`,title:`${e.title} has unpublished changes`,detail:`${Z(e.collection)} · version ${e.liveVersion} is live, version ${e.version} is saved`,action:`Review`,to:Y(e,t)}))}function De(e,t){return e.filter(e=>t.pageCollections.has(e.collection)&&e.locale===t.defaultLocale&&e.metaDescription===`missing`).sort(X).map(e=>({key:`meta:${e.collection}/${e.slug}`,kind:`meta`,title:`${e.title} has no meta description`,detail:`${Z(e.collection)} · neither meta-description nor description is set`,action:`Fix`,to:Y(e,t)}))}function Oe(e){let t=new Map(e.documents.map(e=>[`${e.collection}/${e.slug}/${e.locale}`,e.title]));return[...e.locks??[]].sort((e,t)=>t.lockedAt.localeCompare(e.lockedAt)).map(n=>{let r=`${n.collection}/${n.slug}/${n.locale}`;return{key:`lock:${r}`,kind:`lock`,title:`${t.get(r)??n.slug} is being edited by ${D(n.lockedBy)}`,detail:`${Z(n.collection)} · locked until ${je(n.expiresAt)}`,action:`Open`,to:Y(n,e.scope)}})}function ke(e){if(!e||e.total===0)return[];let{total:t,latest:n}=e;return[{key:`delivery:failed`,kind:`delivery`,title:t===1?`1 webhook delivery failed`:`${t} webhook deliveries failed`,detail:n?`Latest: ${n.event} to ${n.url}`:`See the delivery log`,action:`Open log`,to:`/setup/integrations`}]}function Ae(e){return(e??[]).flatMap(e=>{let t=e.items.filter(e=>e.missing.length>0);if(t.length===0)return[];let n=[...new Set(t.flatMap(e=>e.missing))].sort(),r=t.length;return[{key:`locale:${e.collection}`,kind:`locale`,title:`${Z(e.collection)}: ${r} ${r===1?`document is`:`documents are`} missing a locale version`,detail:`No version in ${n.join(`, `)}`,action:`Locales`,to:`/setup/locales`}]})}function je(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function Me(e){let t={delivery:ke(e.deliveries),lock:Oe(e),ahead:Ee(e.documents,e.scope),meta:De(e.documents,e.scope),locale:Ae(e.translations)},n=[],r=[];for(let e of Te){let i=t[e];n.push(...i.slice(0,5)),i.length>5&&r.push({kind:e,count:i.length-5})}return{rows:n,overflow:r}}function Ne({site:e,framework:t}){return(0,W.jsxs)(`dl`,{className:`pulse-facts`,children:[(0,W.jsxs)(`div`,{className:`pulse-fact`,children:[(0,W.jsx)(`dt`,{children:`Domain`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.site.domain})})]}),o({framework:t})&&(0,W.jsxs)(`div`,{className:`pulse-fact`,children:[(0,W.jsx)(`dt`,{children:`Framework`}),(0,W.jsx)(`dd`,{children:o({framework:t})})]}),(0,W.jsxs)(`div`,{className:`pulse-fact`,children:[(0,W.jsx)(`dt`,{children:`Page cache`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.cache.pages})})]})]})}function Pe({site:e,loading:t,framework:n,pageCollection:i}){return(0,W.jsxs)(`header`,{className:`pulse-header`,children:[(0,W.jsxs)(`div`,{className:`pulse-header-text`,children:[e&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h1`,{className:`pulse-title`,children:e.site.name}),(0,W.jsx)(Ne,{site:e,framework:n})]}),!e&&t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`h1`,{className:`pulse-title`,children:[(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--title`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`visually-hidden`,children:`Pulse`})]}),(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--facts`,"aria-hidden":`true`})]}),!e&&!t&&(0,W.jsx)(`h1`,{className:`pulse-title`,children:`Pulse`})]}),i&&(0,W.jsxs)(r,{to:g(i.name),className:l(`primary`),children:[(0,W.jsx)(T,{className:`ui-button-icon`,"aria-hidden":`true`}),`New page`]})]})}function Fe({meta:e,fields:t}){let n=t.title;return{collection:e.collection,slug:e.slug,locale:e.locale,title:ne(n)?String(n):e.slug,status:v(e),version:e.version,liveVersion:e.liveVersion,updatedAt:e.createdAt,metaDescription:te(t)}}function Ie(e,t){return{pageCollections:new Set(e.filter(e=>e.pages).map(e=>e.name)),defaultLocale:t}}function Le(e,t){return e.filter(e=>t.pageCollections.has(e.collection)&&e.locale===t.defaultLocale)}function Re(e){return{pages:e.length,live:e.filter(e=>e.status!==`draft`).length,ahead:e.filter(e=>e.status===`ahead`).length}}function ze(e){let t=t=>e.filter(e=>e.metaDescription===t).length;return{pages:e.length,covered:t(`covered`),fallback:t(`fallback`),missing:t(`missing`)}}var Be=3;function Ve(e){let t=e.filter(re),n=new Map;for(let e of t)for(let t of new Set(e.features.map(e=>e.type)))n.set(t,(n.get(t)??0)+1);let r=[...n.entries()].sort(([e,t],[n,r])=>r-t||e.localeCompare(n)).slice(0,Be).map(([e])=>e);return{pages:e.length,valid:t.length,mainTypes:r}}function He(e,t,n){return e.filter(e=>e.name!==se).map(e=>{let r=t.filter(t=>t.collection===e.name&&t.locale===n),i=e=>r.filter(t=>t.status===e).length;return{collection:e,live:i(`live`),ahead:i(`ahead`),draft:i(`draft`)}})}function Q(){return(0,W.jsx)(`div`,{className:`pulse-figure`,children:(0,W.jsxs)(`div`,{className:`pulse-figure-body`,children:[(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--label`}),(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--number`}),(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--line`})]})})}var Ue=[`first`,`second`,`third`,`fourth`];function $({title:e,rows:t}){return(0,W.jsxs)(`div`,{className:`pulse-panel`,children:[(0,W.jsx)(`div`,{className:`pulse-panel-head`,children:(0,W.jsx)(`p`,{className:`pulse-panel-title`,children:e})}),Ue.slice(0,t).map(e=>(0,W.jsxs)(`div`,{className:`pulse-skeleton-row`,children:[(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--line`}),(0,W.jsx)(`span`,{className:`pulse-skeleton pulse-skeleton--short`})]},e))]})}function We(){return(0,W.jsxs)(`div`,{className:`pulse-skeleton-frame`,"aria-hidden":`true`,children:[(0,W.jsxs)(`div`,{className:`pulse-figures`,children:[(0,W.jsx)(Q,{}),(0,W.jsx)(Q,{}),(0,W.jsx)(Q,{})]}),(0,W.jsxs)(`div`,{className:`pulse-columns`,children:[(0,W.jsx)($,{title:`Needs attention`,rows:3}),(0,W.jsx)($,{title:`Collections`,rows:3})]}),(0,W.jsx)($,{title:`Recent activity`,rows:4})]})}var Ge={created:{tone:`neutral`,icon:T},saved:{tone:`neutral`,icon:f},published:{tone:`accent`,icon:x}};function Ke({entry:e,defaultLocale:t,now:n}){let{document:i,event:a}=e,o=i.locale===t?void 0:i.locale,c=Ge[a];return(0,W.jsxs)(`li`,{className:`activity-row`,children:[(0,W.jsx)(r,{to:b(i.collection,i.slug,o),className:`activity-slug`,children:i.slug}),(0,W.jsxs)(`span`,{className:`activity-collection`,children:[i.collection===`globals`?`Layout`:s(i.collection),o&&(0,W.jsx)(`code`,{className:`activity-locale`,children:o})]}),(0,W.jsx)(`span`,{className:`activity-event`,children:(0,W.jsx)(O,{tone:c.tone,icon:c.icon,children:P[a]})}),(0,W.jsx)(`time`,{className:`activity-time`,dateTime:i.updatedAt,title:new Date(i.updatedAt).toLocaleString(),children:N(i.updatedAt,n)})]})}function qe({entries:e,defaultLocale:t,now:n}){return(0,W.jsxs)(`section`,{className:`pulse-panel`,"aria-labelledby":`pulse-activity-title`,children:[(0,W.jsx)(`div`,{className:`pulse-panel-head`,children:(0,W.jsx)(`h2`,{id:`pulse-activity-title`,children:`Recent activity`})}),e.length===0?(0,W.jsx)(M,{icon:ue,title:`No activity yet`,children:`New documents, saved drafts and publishes show up here.`}):(0,W.jsx)(`ol`,{className:`activity-list`,children:e.map(e=>(0,W.jsx)(Ke,{entry:e,defaultLocale:t,now:n},`${e.document.collection}/${e.document.slug}/${e.document.locale}`))})]})}async function Je(e){return(await j()).filter(t=>e.includes(t.meta.locale)).map(Fe)}async function Ye(){let{deliveries:e,total:t}=await E({status:`failed`,limit:1});return{total:t,latest:e[0]??null}}async function Xe(e){let[t,n,r]=await Promise.all([h(),ce(),oe()]),[i,a,o,s,l]=await Promise.all([Je(r.supportedLocales),R(!0,pe),R(c(e,`seo`),async()=>(await ie()).pages),R(c(e,`webhookDeliveries`),Ye),R(y(r),async()=>(await _()).collections)]);return{site:t,locales:r,collections:n,documents:i,locks:a,findings:o,deliveries:s,translations:l}}function Ze(){let e=a(),[t,n]=(0,U.useState)({state:`loading`}),[r,i]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let t=!0;return n({state:`loading`}),Xe(e).then(e=>{t&&n({state:`ready`,data:e})}).catch(e=>{t&&n({state:`error`,message:fe(e,`Pulse could not load`)})}),()=>{t=!1}},[e,r]),{pulse:t,reload:(0,U.useCallback)(()=>i(e=>e+1),[])}}function Qe(e){let t=[`unpublished changes`,`edit locks`,`pages without a meta description`];e.deliveries.state!==`off`&&t.unshift(`failed webhook deliveries`),e.translations.state!==`off`&&t.push(`missing locale versions`);let n=t.pop(),r=`${t.join(`, `)} and ${n}`;return r.charAt(0).toUpperCase()+r.slice(1)}function $e(e){return[[e.locks,`edit locks`],[e.deliveries,`webhook deliveries`],[e.translations,`locale versions`]].filter(([e])=>e.state===`failed`).map(([,e])=>e)}function et(e,t){return(0,U.useMemo)(()=>{let n=Date.now(),r=Ie(e.collections,e.locales.defaultLocale),i=Le(e.documents,r),a=L(e.locks),o=e.findings;return{now:n,live:Re(i),coverage:ze(i),structuredData:o.state===`ok`?{state:`ok`,value:Ve(o.value)}:o,attention:Me({documents:e.documents,scope:r,locks:a?S(a,t,n):null,deliveries:L(e.deliveries),translations:L(e.translations)}),collections:He(e.collections,e.documents,r.defaultLocale),activity:F(e.documents)}},[e,t])}function tt({data:e,user:t}){let n=et(e,t);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(be,{live:n.live,coverage:n.coverage,structuredData:n.structuredData}),(0,W.jsxs)(`div`,{className:`pulse-columns`,children:[(0,W.jsx)(we,{attention:n.attention,watched:Qe(e),unread:$e(e)}),(0,W.jsx)(ge,{collections:n.collections})]}),(0,W.jsx)(qe,{entries:n.activity,defaultLocale:e.locales.defaultLocale,now:n.now})]})}function nt({message:e,onRetry:t}){return(0,W.jsx)(`div`,{className:`pulse-panel`,role:`alert`,children:(0,W.jsx)(M,{icon:p,title:`Pulse could not load`,action:(0,W.jsx)(u,{icon:ae,onClick:t,children:`Try again`}),children:e})})}function rt(){let{pulse:e,reload:t}=Ze(),{user:n,hasRole:r}=i(),o=a(),s=e.state===`ready`?e.data:null,c=r(`editor`)?s?.collections.find(e=>e.pages)??null:null;return(0,W.jsxs)(`div`,{className:`pulse`,"aria-busy":e.state===`loading`,children:[(0,W.jsx)(Pe,{site:s?.site??null,loading:e.state===`loading`,framework:o.framework,pageCollection:c}),e.state===`loading`&&(0,W.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:`Loading Pulse…`}),e.state===`error`&&(0,W.jsx)(nt,{message:e.message,onRetry:t}),e.state===`loading`&&(0,W.jsx)(We,{}),s&&(0,W.jsx)(tt,{data:s,user:n})]})}export{rt as PulsePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});export{l as i,s as n,u as r,o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./clike-jjKDqbJf.js";t.displayName=`ruby`,t.aliases=[`rb`];function t(t){t.register(e),(function(e){e.languages.ruby=e.languages.extend(`clike`,{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),e.languages.insertBefore(`ruby`,`operator`,{"double-colon":{pattern:/::/,alias:`punctuation`}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:e.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:`punctuation`}}};delete e.languages.ruby.function;var n=`(?:`+[`([^a-zA-Z0-9\\s{(\\[<=])(?:(?!\\1)[^\\\\]|\\\\[\\s\\S])*\\1`,`\\((?:[^()\\\\]|\\\\[\\s\\S]|\\((?:[^()\\\\]|\\\\[\\s\\S])*\\))*\\)`,`\\{(?:[^{}\\\\]|\\\\[\\s\\S]|\\{(?:[^{}\\\\]|\\\\[\\s\\S])*\\})*\\}`,`\\[(?:[^\\[\\]\\\\]|\\\\[\\s\\S]|\\[(?:[^\\[\\]\\\\]|\\\\[\\s\\S])*\\])*\\]`,`<(?:[^<>\\\\]|\\\\[\\s\\S]|<(?:[^<>\\\\]|\\\\[\\s\\S])*>)*>`].join(`|`)+`)`,r=`(?:"(?:\\\\.|[^"\\\\\\r\\n])*"|(?:\\b[a-zA-Z_]\\w*|[^\\s\\0-\\x7F]+)[?!]?|\\$.)`;e.languages.insertBefore(`ruby`,`keyword`,{"regex-literal":[{pattern:RegExp(`%r`+n+`[egimnosux]{0,6}`),greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(`(^|[^:]):`+r),lookbehind:!0,greedy:!0},{pattern:RegExp(`([\\r\\n{(,][ \\t]*)`+r+`(?=:(?!:))`),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),e.languages.insertBefore(`ruby`,`string`,{"string-literal":[{pattern:RegExp(`%[qQiIwWs]?`+n),greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:`heredoc-string`,greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:`heredoc-string`,greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(`%x`+n),greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:`string`}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:`string`}}}]}),delete e.languages.ruby.string,e.languages.insertBefore(`ruby`,`number`,{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),e.languages.rb=e.languages.ruby})(t)}export{t as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,s as n}from"./vendor-diff-Dm2YfgXt.js";import{r,t as i}from"./vendor-router-DjV3D6zM.js";import{i as a}from"./auth-GRfs02w7.js";import{d as o,l as s,n as c,r as l,t as u,u as d}from"./format-pPdsDgeS.js";import{n as f,t as p}from"./createLucideIcon-D_HN41p3.js";import{n as m,t as h}from"./use-loaded-C3hBdQe0.js";import{t as g}from"./clock-CzpAlvS3.js";import{t as ee}from"./copy-DloNx7rC.js";import{t as te}from"./list-checks-DmMdd-uP.js";import{t as ne}from"./pencil-BHnNXVY1.js";import{c as re,o as ie,y as ae}from"./api-seo-2H6_VoWE.js";import{t as oe}from"./send-ib_sr-OU.js";import{a as se,i as ce,n as le,r as ue,s as de,t as fe,u as pe}from"./fill-job-D41ra-DR.js";import{t as _}from"./trash-Cknp3eZ5.js";import{i as v,t as me}from"./api-client-BRi_ki2Y.js";import{A as y,E as he,G as ge,I as _e,K as ve,O as ye,Ot as be,R as xe,T as Se,Tt as Ce,V as we,W as Te,X as Ee,Z as De,_ as Oe,at as ke,b as Ae,ct as je,d as b,dt as Me,et as x,f as S,ft as Ne,ht as Pe,k as C,nt as Fe,o as Ie,ot as Le,pt as Re,q as ze,rt as Be,s as w,v as Ve,w as He,y as Ue}from"./index-DVe5jFLX.js";import{t as We}from"./empty-state-CU7q3Ypl.js";import{t as T}from"./action-button-Co7fp7HS.js";import{t as Ge}from"./guards-BFEDbduR.js";import{t as Ke}from"./use-locale-versions-Bp4V9fN-.js";import{t as qe}from"./source-CGZGd3Xy.js";import{i as Je,n as Ye,t as Xe}from"./fill-run-view-DFeyjdsI.js";import{t as E}from"./data-table-D8BsE1pn.js";var Ze={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`}]]};Ze.node;var Qe=p(Ze),$e={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`}]]};$e.node;var et=p($e),tt={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`}]]};tt.node;var nt=p(tt),rt={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`}]]};rt.node;var it=p(rt),D={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`]};D.node;var at=p(D),ot={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`}]]};ot.node;var st=p(ot),ct={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`}]]};ct.node;var lt=p(ct),ut={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`}]]};ut.node;var dt=p(ut);async function ft(){let{users:e}=await v(`/users`);return e}async function pt(e){return v(`/users`,{method:`POST`,body:JSON.stringify(e)})}async function mt(e,t){return v(`/users/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)})}async function ht(e){await v(`/users/${encodeURIComponent(e)}`,{method:`DELETE`})}var O={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`}},k=e(n(),1),A=`claude-code`,gt=[`openrouter`,A,`ollama`];function _t(e){return Object.hasOwn(O,e)}function j(e){return _t(e)?O[e]:null}function M(e){return j(e)?.label??e}function N(e){return j(e)?.vendor??e}function vt(e){return gt.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 ${M(e.provider)}.`}function Ct(e){return!e.configured||!e.provider?`The AI`:`${M(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=M(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,k.useState)(!1),n=(0,k.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,k.useState)(null);return{busy:e,error:n,setError:r,run:(e,n)=>t(async()=>{r(null);try{await e()}catch(e){r(S(e,n))}})}}function Dt(e){let t=x(),{busy:n,once:r}=P();function i(e,n){r(async()=>{try{await e()}catch(e){t({text:S(e,n),tone:`error`})}})}async function a(e){let n=await ye(e);t({text:Et(e,n),tone:n.success?`success`:`error`})}return{busy:n,turnOn:t=>i(async()=>{e(await C(t)),await a(t.provider)},`The key could not be saved`),use:n=>i(async()=>{e(await C({provider:n,use:!0})),t({text:`The site now uses ${M(n)}.`})},`The AI could not be changed`),save:n=>i(async()=>{e(await C(n)),t({text:`Saved the settings for ${M(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,k.useRef)(null),{busy:s,error:c,run:l}=F(),u=s?()=>void 0:a;return(0,I.jsxs)(b,{title:e,onClose:u,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{ref:o,onClick:u,"aria-disabled":s,children:`Cancel`}),(0,I.jsx)(f,{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 z({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 B({label:e,value:t,onChange:n,disabled:r=!1,hint:i,type:a=`text`,placeholder:o}){let s=(0,k.useId)();return(0,I.jsx)(z,{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 V({label:e,value:t,onChange:n,disabled:r=!1,hint:i,options:a}){let o=(0,k.useId)(),s=e=>{let t=a.find(t=>t.value===e);t&&n(t.value)};return(0,I.jsx)(z,{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 Ot({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 kt({provider:e}){return(0,I.jsxs)(`div`,{className:`ai-card-title`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:M(e)}),(0,I.jsx)(`span`,{className:`setup-muted`,children:N(e)})]})}function At({provider:e,onRemoved:t,onClose:n}){let r=x();async function i(){t(await He(e)),r({text:`Removed the saved key for ${M(e)}.`}),n()}return(0,I.jsx)(L,{title:`Remove the key for ${M(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 jt({status:e,actions:t}){let n=j(e.provider),[r,i]=(0,k.useState)(e.model??``),[a,o]=(0,k.useState)(e.baseUrl??``),s=e.provider===A;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)(B,{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)(B,{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)(f,{"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a}),children:`Save`})})]})]})}function Mt({status:e,actions:t,readOnly:n,onChange:r}){let[i,a]=(0,k.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)(kt,{provider:e.provider}),e.active&&(0,I.jsx)(w,{tone:`success`,icon:m,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:st,reason:o,onClick:()=>t.use(e.provider),children:`Use this one`}),(0,I.jsx)(T,{icon:at,reason:o,onClick:()=>t.test(e.provider),children:`Test`}),e.keySource===`saved`&&(0,I.jsx)(f,{variant:`ghost`,icon:_,onClick:()=>a(!0),children:`Remove key`})]}),!n&&(0,I.jsx)(jt,{status:e,actions:t}),i&&(0,I.jsx)(At,{provider:e.provider,onRemoved:r,onClose:()=>a(!1)})]})}function Nt({status:e,actions:t}){let[n,r]=(0,k.useState)(``),i=M(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)(kt,{provider:e.provider})}),(0,I.jsx)(B,{label:`${i} key`,type:`password`,value:n,onChange:r,hint:`Paste the key from ${N(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:nt,reason:o,onClick:a,children:`Turn on`})})]})}function Pt({status:e}){return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:M(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 Ft({status:e,actions:t}){let n=j(e.provider),[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(``);return(0,I.jsxs)(`li`,{className:`ai-card`,children:[(0,I.jsx)(`h3`,{className:`ai-card-name`,children:M(e.provider)}),(0,I.jsx)(`p`,{className:`setup-note`,children:`Runs a model on your own computer. It needs no key.`}),(0,I.jsx)(B,{label:`Model`,value:r,onChange:i,placeholder:n?.defaultModel}),(0,I.jsx)(B,{label:`Address`,type:`url`,value:a,onChange:o,placeholder:n?.baseUrl}),(0,I.jsx)(`div`,{className:`setup-actions`,children:(0,I.jsx)(f,{variant:`primary`,"aria-disabled":t.busy,onClick:()=>t.save({provider:e.provider,model:r,baseUrl:a,use:!0}),children:`Turn on`})})]})}function It({status:e,actions:t}){return e.provider===`claude-code`?(0,I.jsx)(Pt,{status:e}):e.provider===`ollama`?(0,I.jsx)(Ft,{status:e,actions:t}):(0,I.jsx)(Nt,{status:e,actions:t})}function Lt({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)(It,{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:[M(e.provider),`: `,(0,I.jsx)(`code`,{children:e.env})]},e.provider))})]})]})]})}var Rt={config:{icon:et,label:`Configuration`},database:{icon:Qe,label:`Database`},server:{icon:Be,label:`Server`}};function H({source:e,children:t}){let{icon:n,label:r}=Rt[e];return(0,I.jsxs)(`p`,{className:`setup-source`,children:[(0,I.jsx)(w,{icon:n,children:r}),(0,I.jsx)(`span`,{children:t})]})}function U({title:e,sources:t,actions:n,children:r}){let i=(0,k.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 W({children:e,tone:t=`muted`}){return(0,I.jsx)(`p`,{className:t===`error`?`setup-note setup-note--error`:`setup-note`,children:e})}function G({what:e}){return(0,I.jsxs)(W,{children:[`Reading `,e,`…`]})}function K({message:e,onRetry:t}){return(0,I.jsxs)(`div`,{role:`alert`,className:`setup-row`,children:[(0,I.jsx)(W,{tone:`error`,children:e}),(0,I.jsx)(f,{size:`sm`,icon:ae,onClick:t,children:`Try again`})]})}var zt=new Map([[fe,`Fill missing SEO`],[ue,`Meta only`],[le,`Force regenerate`]]);function Bt(e){return e.scope===`collection`?`${u(e.collection)}`:`the whole site`}function Vt(e){let t=e.state===`idle`?`Enrichment`:zt.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 Ht(){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 Ut({scope:e,model:t,onConfirm:n,onClose:r}){return(0,I.jsxs)(L,{title:`Force regenerate SEO for ${Bt(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`,` `,Bt(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 Wt(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 Gt({reason:e,onRun:t,onForce:n}){return(0,I.jsxs)(`div`,{className:`setup-actions`,children:[(0,I.jsx)(T,{variant:`primary`,icon:pe,reason:e,onClick:()=>t(fe),children:`Fill missing SEO`}),(0,I.jsx)(T,{icon:te,reason:e,onClick:()=>t(ue),children:`Meta only`}),(0,I.jsx)(T,{variant:`danger`,icon:lt,reason:e,onClick:n,children:`Force regenerate…`})]})}function Kt(){let{loaded:e}=h(we,`The collections could not be read`);return e.state===`ready`?e.data.filter(e=>e.pages):[]}var qt=(0,I.jsx)(H,{source:`database`,children:`Writes to the documents and their SEO settings in the site's database, with the AI in use above.`});function Jt({configured:e,admin:t,model:n}){let r=x(),i=de(),a=Kt(),[o,s]=(0,k.useState)({scope:`all`}),[c,l]=(0,k.useState)(!1);(0,k.useEffect)(()=>()=>ce(),[]);let u=(0,k.useCallback)(e=>se(o,e=>r(Vt(e)),e),[o,r]),d=Wt(i,t,e),f=i.state===`running`;return(0,I.jsxs)(U,{title:`Run across the site`,sources:qt,children:[(0,I.jsx)(Ht,{}),(0,I.jsx)(Ye,{collections:a,value:o,disabled:f,onChange:s}),(0,I.jsx)(Gt,{reason:d,onRun:u,onForce:()=>l(!0)}),d&&!f&&(0,I.jsx)(`p`,{className:`setup-note`,children:d}),(0,I.jsx)(Xe,{run:i}),c&&(0,I.jsx)(Ut,{scope:o,model:n,onClose:()=>l(!1),onConfirm:async()=>{l(!1),u(le)||r({text:`Another run is going across the site, so Force regenerate did not start. Try again when it ends.`,tone:`error`})}})]})}function Yt({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)(Mt,{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)(Nt,{status:e,actions:r},e.provider))})]}),!t&&(0,I.jsx)(Lt,{settings:e,providers:xt(e),actions:r})]})}function Xt(){let e=a().hasRole(`admin`),{loaded:t,reload:n}=h(Se,`The AI provider could not be read`),[r,i]=(0,k.useState)(null);if(t.state===`loading`)return(0,I.jsx)(G,{what:`the AI provider`});if(t.state===`error`)return(0,I.jsx)(K,{message:t.message,onRetry:n});let o=r??t.data;return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(U,{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:o.configured?`ai-status ai-status--on`:`ai-status`,role:`status`,children:St(o,e)}),(0,I.jsx)(Yt,{settings:o,readOnly:!e,onChange:i}),o.assistantProvider&&(0,I.jsxs)(`p`,{className:`setup-note`,children:[`The assistant is set to `,M(o.assistantProvider),` in the site's configuration.`]})]}),(0,I.jsx)(Jt,{configured:o.configured,admin:e,model:Ct(o)})]})}var Zt={manual:`By hand`,"pre-restore":`Before a restore`,"pre-migration":`Before a migration`,"pre-import":`Before an import`};function q(e){return e.name?`v${e.version} · ${e.name}`:`v${e.version}`}function Qt({checkpoint:e,onDone:t,onClose:n}){let r=x(),i=q(e);async function a(){await Ae(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`,` `,l(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 $t({checkpoint:e,onDone:t,onClose:n}){let r=x(),i=q(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 en(e,t){return[{id:`name`,header:`Checkpoint`,primary:!0,cell:e=>q(e)},{id:`trigger`,header:`Taken`,cell:e=>(0,I.jsx)(w,{children:Zt[e.trigger]})},{id:`created`,header:`Created`,cell:e=>l(e.createdAt)},{id:`actions`,header:`Actions`,cell:n=>e?(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(f,{size:`sm`,icon:ke,"aria-label":`Restore ${q(n)}`,onClick:()=>t({kind:`restore`,checkpoint:n}),children:`Restore`}),(0,I.jsx)(f,{size:`sm`,variant:`ghost`,icon:_,"aria-label":`Delete ${q(n)}`,onClick:()=>t({kind:`delete`,checkpoint:n}),children:`Delete`})]}):null}]}function tn({onCreated:e}){let t=x(),[n,r]=(0,k.useState)(``),[i,a]=(0,k.useState)(!1),o=(0,k.useRef)(!1);async function s(){if(!o.current){o.current=!0,a(!0);try{let i=await Oe(n.trim()||void 0);t({text:`Created ${q(i)}.`}),r(``),e()}catch(e){t({text:S(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)(B,{label:`Name`,value:n,onChange:r,placeholder:`Before the spring relaunch`,hint:`Optional`}),(0,I.jsx)(f,{type:`submit`,variant:`primary`,icon:Pe,"aria-disabled":i,children:i?`Creating…`:`Create checkpoint`})]})}function nn(){return(0,I.jsx)(H,{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 rn(){let{hasRole:e}=a(),{loaded:t,reload:n}=h(Ue,`The checkpoints could not be read`),[r,i]=(0,k.useState)(null),o=()=>i(null),s=()=>{o(),n()};return(0,I.jsxs)(U,{title:`Checkpoints`,sources:(0,I.jsx)(nn,{}),children:[e(`editor`)?(0,I.jsx)(tn,{onCreated:n}):(0,I.jsx)(W,{children:`Editors and admins create checkpoints.`}),t.state===`loading`&&(0,I.jsx)(G,{what:`the checkpoints`}),t.state===`error`&&(0,I.jsx)(K,{message:t.message,onRetry:n}),t.state===`ready`&&t.data.length===0&&(0,I.jsx)(We,{icon:Pe,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)(E,{caption:`Checkpoints, newest first`,columns:en(e(`admin`),i),rows:t.data,rowKey:e=>String(e.version)}),r?.kind===`restore`&&(0,I.jsx)(Qt,{checkpoint:r.checkpoint,onDone:s,onClose:o}),r?.kind===`delete`&&(0,I.jsx)($t,{checkpoint:r.checkpoint,onDone:s,onClose:o})]})}async function an(e){let[t,n,r]=await Promise.all([we(),qe(e,re),qe(e,async()=>(await ie()).types)]);return{collections:t,configs:n,catalog:r}}function on(e,t){return e.state===`ok`?e.value.find(e=>e.id===`collection:${t}`)?.config.entities.map(e=>e[`@type`])??[]:null}function sn(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 cn(e){return e.collections.map(t=>{let n=t.pages?on(e.configs,t.name):[];return{collection:t,rendersAt:Ie(t,`:slug`),types:n,richResults:t.pages?sn(e.catalog,n):[]}})}function ln(e){return e==null?null:typeof e==`string`?e:JSON.stringify(e)}function un(e){return e.enum?`enum`:e.format===`uri`?`url`:e.format===`email`?`email`:String(e.type??`string`)}function dn(e,t){let n=new Set(e.schema.required??[]),r=Object.entries(e.schema.properties??{}).filter(([,e])=>!(Ge(e)&&e._runtime)).map(([e,t])=>({name:e,type:un(t),required:n.has(e),description:t.description??null,defaultValue:ln(t.default),source:`code`,runtime:null})),i=t.map(e=>({name:e.name,type:e.type,required:e.required,description:e.description??null,defaultValue:ln(e.default),source:`runtime`,runtime:e}));return[...r,...i]}var fn=[`string`,`textarea`,`number`,`boolean`,`date`,`enum`,`url`,`email`,`color`,`reference`],pn={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 mn(e){return pn[e]??e}var J=e=>e==null?``:String(e);function hn(e){return{name:e?.name??``,type:e?.type??`string`,required:e?.required??!1,description:e?.description??``,defaultValue:J(e?.default),enumValues:e?.enumValues?.join(`, `)??``,refCollection:e?.refCollection??``,min:J(e?.min),max:J(e?.max),pattern:e?.pattern??``}}function Y(e){return e===`string`||e===`textarea`||e===`number`}function gn(e){let t=e.defaultValue.trim();if(t)return e.type===`number`?Number(t):e.type===`boolean`?t===`true`:t}function X(e){return e.enumValues.split(`,`).map(e=>e.trim()).filter(Boolean)}function _n(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`&&!X(e).includes(t)?`The default is one of the values.`:null:null}function vn(e){if(!Y(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 yn(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 bn(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(X(e)).size<2?`Give the enum two different values or more.`:vn(e)??yn(e)??_n(e):`A name starts with a letter and holds only letters, digits, hyphens and underscores.`:`A field needs a name.`}function xn(e){let t=X(e),n={name:e.name.trim(),type:e.type,required:e.required},r=gn(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),Y(e.type)&&e.min.trim()&&(n.min=Number(e.min)),Y(e.type)&&e.max.trim()&&(n.max=Number(e.max)),e.type===`string`&&e.pattern.trim()&&(n.pattern=e.pattern.trim()),n}var Sn=fn.map(e=>({value:e,label:mn(e)}));function Cn({form:e,set:t}){let n=e.type===`number`;return(0,I.jsxs)(`div`,{className:`setup-field-row`,children:[(0,I.jsx)(B,{label:n?`Minimum`:`Minimum length`,type:`number`,value:e.min,onChange:t(`min`)}),(0,I.jsx)(B,{label:n?`Maximum`:`Maximum length`,type:`number`,value:e.max,onChange:t(`max`)})]})}function wn(e){let{form:t,set:n,collections:r}=e,i=[{value:``,label:`Choose a collection`},...r.map(e=>({value:e.name,label:u(e.name)}))];return(0,I.jsxs)(I.Fragment,{children:[t.type===`enum`&&(0,I.jsx)(B,{label:`Values`,value:t.enumValues,onChange:n(`enumValues`),hint:`Separated by commas`}),t.type===`reference`&&(0,I.jsx)(V,{label:`Refers to`,value:t.refCollection,options:i,onChange:n(`refCollection`)}),Y(t.type)&&(0,I.jsx)(Cn,{form:t,set:n}),t.type===`string`&&(0,I.jsx)(B,{label:`Pattern`,value:t.pattern,onChange:n(`pattern`),hint:`A regular expression the value must match`})]})}function Tn({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)(B,{label:`Name`,value:e.name,onChange:t(`name`),disabled:n,hint:i}),(0,I.jsx)(V,{label:`Type`,value:e.type,options:Sn,onChange:t(`type`),disabled:n,hint:n?`A field keeps its type`:void 0}),(0,I.jsx)(Ot,{label:`Required`,checked:e.required,onChange:t(`required`)}),(0,I.jsx)(B,{label:`Description`,value:e.description,onChange:t(`description`),hint:`Shown to editors under the field`}),(0,I.jsx)(B,{label:`Default`,value:e.defaultValue,onChange:t(`defaultValue`)}),(0,I.jsx)(wn,{form:e,set:t,collections:r})]})}function En(e){let{collection:t,field:n,collections:r,onSave:i,onClose:a}=e,o=(0,k.useId)(),[s,c]=(0,k.useState)(()=>hn(n)),l=e=>t=>c(n=>({...n,[e]:t})),{busy:d,error:p,setError:m,run:h}=F();function g(e){e.preventDefault();let t=bn(s);if(t){m(t);return}h(()=>i(xn(s)),`The field could not be saved`)}let ee=n?`Edit ${n.name}`:`Add a runtime field to ${u(t)}`;return(0,I.jsx)(b,{title:ee,onClose:a,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{onClick:a,children:`Cancel`}),(0,I.jsx)(f,{variant:`primary`,type:`submit`,form:o,"aria-disabled":d,children:d?`Saving…`:`Save field`})]}),busy:d,children:(0,I.jsxs)(`form`,{id:o,className:`setup-form`,onSubmit:g,children:[p&&(0,I.jsx)(R,{text:p}),(0,I.jsx)(Tn,{form:s,set:l,editing:n!==null,collections:r})]})})}function Dn(e){let t=x();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 On({collection:e,onClose:t}){let n=(0,k.useCallback)(async()=>(await xe(e)).code,[e]),{loaded:r,reload:i}=h(n,`The schema could not be exported`),a=r.state===`ready`?r.data:null,o=Dn(a),s=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{onClick:t,children:`Close`}),(0,I.jsx)(f,{variant:`primary`,icon:ee,"aria-disabled":a===null,onClick:()=>void o(),children:`Copy`})]});return(0,I.jsxs)(b,{title:`${u(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)(G,{what:`the schema`}),r.state===`error`&&(0,I.jsx)(K,{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 kn({field:e,onDialog:t}){return(0,I.jsxs)(`span`,{className:`setup-row-actions`,children:[(0,I.jsx)(f,{size:`sm`,icon:ne,"aria-label":`Edit ${e.name}`,onClick:()=>t({kind:`edit`,field:e}),children:`Edit`}),(0,I.jsx)(f,{size:`sm`,variant:`ghost`,icon:_,"aria-label":`Delete ${e.name}`,onClick:()=>t({kind:`delete`,field:e}),children:`Delete`})]})}function An({field:e,admin:t,onDialog:n}){return e.runtime?t?(0,I.jsx)(kn,{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)(je,{"aria-hidden":`true`}),`Defined in code, change it in `,(0,I.jsx)(`code`,{children:`krantho.collections.ts`}),`; code always wins`]})}function jn(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=>mn(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)(w,{icon:je,children:`Code`}):(0,I.jsx)(w,{tone:`accent`,children:`Runtime`})},{id:`edit`,header:`Edit`,cell:n=>(0,I.jsx)(An,{field:n,admin:e,onDialog:t})}]}function Mn(e){let t=(0,k.useCallback)(async()=>{let[t,n]=await Promise.all([ge(e),Te(e)]);return dn(t,n.fields)},[e]);return h(t,`The fields could not be read`)}function Nn({admin:e,onDialog:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{icon:et,onClick:()=>t({kind:`export`}),children:`Export as Zod`}),e&&(0,I.jsx)(f,{variant:`primary`,icon:Le,onClick:()=>t({kind:`edit`,field:null}),children:`Add runtime field`})]})}function Pn({collection:e,collections:t,admin:n}){let{loaded:r,reload:i}=Mn(e),[a,o]=(0,k.useState)(null),s=u(e),c=(0,I.jsx)(Nn,{admin:n,onDialog:o});return(0,I.jsxs)(U,{title:`Fields of ${s}`,actions:c,sources:(0,I.jsx)(Fn,{}),children:[r.state===`loading`&&(0,I.jsx)(G,{what:`the fields`}),r.state===`error`&&(0,I.jsx)(K,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(E,{caption:`Fields of ${s}`,columns:jn(n,o),rows:r.data,rowKey:e=>`${e.source}:${e.name}`}),a&&(0,I.jsx)(Ln,{collection:e,collections:t,dialog:a,onClose:()=>o(null),onChanged:i})]})}function Fn(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(H,{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)(H,{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 In({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 _e(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 `,u(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 Ln(e){let{collection:t,collections:n,dialog:r,onClose:i,onChanged:a}=e,o=x(),s=e=>{o({text:e}),i(),a()};return r.kind===`export`?(0,I.jsx)(On,{collection:t,onClose:i}):r.kind===`delete`?(0,I.jsx)(In,{collection:t,name:r.field.name,onDone:s,onClose:i}):(0,I.jsx)(En,{collection:t,field:r.field,collections:n,onSave:async e=>{await De(t,e),s(`Saved the runtime field ${e.name}.`)},onClose:i})}var Rn=`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)(w,{children:e},e))})}function Bn({name:e}){return(0,I.jsxs)(`span`,{className:`setup-name`,children:[u(e),(0,I.jsx)(`code`,{className:`setup-muted`,children:e})]})}function Vn({name:e,open:t,onFields:n}){return(0,I.jsx)(f,{size:`sm`,icon:it,variant:t?`primary`:`secondary`,"aria-label":`Fields of ${u(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)(H,{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)(H,{source:`database`,children:[`The Schema.org types are each collection's archetype, set in`,` `,(0,I.jsx)(i,{to:be(`collection`),children:`Structure › Scopes & archetypes`}),`. The rich results are what the catalog says those types are eligible for.`]})]})}function Wn(){let[e,t]=r(),n=e.get(Rn),i=(0,k.useRef)(null),a=(0,k.useRef)(!1);return(0,k.useEffect)(()=>{n&&a.current&&i.current?.focus(),a.current=!1},[n]),{open:n,onFields:(0,k.useCallback)(e=>{a.current=!0,t({[Rn]:e},{replace:!0})},[t]),ref:i}}function Gn(){let e=d(o(),`seo`),t=a().hasRole(`admin`),n=(0,k.useCallback)(()=>an(e),[e]),{loaded:r,reload:i}=h(n,`The collections could not be read`),{open:s,onFields:c,ref:l}=Wn(),u=r.state===`ready`?r.data.collections:[],f=u.some(e=>e.name===s);return(0,I.jsxs)(`div`,{className:`setup-stack`,children:[(0,I.jsxs)(U,{title:`Collections & schema`,sources:(0,I.jsx)(Un,{seo:e}),children:[r.state===`loading`&&(0,I.jsx)(G,{what:`the collections`}),r.state===`error`&&(0,I.jsx)(K,{message:r.message,onRetry:i}),r.state===`ready`&&(0,I.jsx)(E,{caption:`Collections`,columns:Hn(s,c),rows:cn(r.data),rowKey:e=>e.collection.name})]}),s&&r.state===`ready`&&!f&&(0,I.jsxs)(W,{children:[`No collection is named `,s,`.`]}),s&&f&&(0,I.jsx)(`div`,{ref:l,tabIndex:-1,className:`setup-focus-target`,children:(0,I.jsx)(Pn,{collection:s,collections:u,admin:t},s)})]})}function Kn(e){return e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function qn(e){let t=[],n=s(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)(w,{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=o();return(0,I.jsx)(U,{title:`Environment`,sources:(0,I.jsxs)(H,{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)(E,{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)(w,{tone:`success`,icon:Ne,children:`Delivered`}),pending:(0,I.jsx)(w,{tone:`warning`,icon:g,children:`Pending`}),failed:(0,I.jsx)(w,{tone:`danger`,icon:Re,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=>l(e.createdAt)},{id:`delivered`,header:`Delivered`,cell:e=>e.deliveredAt?l(e.deliveredAt):`—`},{id:`retry`,header:`Retry`,cell:n=>Qn(n)===`failed`?(0,I.jsx)(f,{size:`sm`,icon:oe,"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)(f,{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=x(),[n,r]=(0,k.useState)(null),i=(0,k.useRef)(null);return{retrying:n,retry:(0,k.useCallback)(n=>{i.current===null&&(i.current=n.id,r(n.id),Ee(n.id).then(()=>t({text:`Sent delivery ${n.id} again. It shows as pending until the webhook answers.`})).catch(e=>t({text:S(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)(f,{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)(f,{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 ze({limit:25,offset:t*25,status:n})}catch(e){if(e instanceof me&&e.status===403)return null;throw e}}function cr({filter:e,page:t,revision:n,onPage:r}){let i=(0,k.useCallback)(()=>sr(e,t),[e,t]),{loaded:a,reload:o}=h(i,`The deliveries could not be read`),s=(0,k.useRef)(n);(0,k.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)(G,{what:`the deliveries`});if(a.state===`error`)return(0,I.jsx)(K,{message:a.message,onRetry:o});if(a.data===null)return(0,I.jsx)(W,{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)(E,{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)(We,{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,k.useState)(`all`),[n,r]=(0,k.useState)(0),[i,a]=(0,k.useState)(0);return(0,I.jsxs)(U,{title:`Webhook deliveries`,actions:(0,I.jsx)(f,{size:`sm`,icon:ae,onClick:()=>a(e=>e+1),children:`Refresh`}),sources:(0,I.jsx)(H,{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:a,busy:o,onCreate:s}){let{collection:c,slug:l,locale:u}=e;return t.locales.includes(u)?(0,I.jsx)(w,{tone:`success`,icon:m,children:`Exists`}):a.has(Z(e))?(0,I.jsxs)(i,{to:Ce(c,l,u),children:[`Open the `,u,` draft`]}):!r||!t.locales.includes(n)?(0,I.jsx)(w,{tone:`warning`,children:`Missing`}):(0,I.jsx)(f,{size:`sm`,icon:Me,"aria-disabled":o!==null,"aria-label":`Create the ${u} draft of ${l}`,onClick:o===null?()=>s(e):void 0,children:o===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=x(),[n,r]=(0,k.useState)(new Set),[i,a]=(0,k.useState)(null);return{created:n,busy:i,onCreate:(0,k.useCallback)(n=>{a(Z(n)),Ke(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:S(e,`The draft could not be created`),tone:`error`})).finally(()=>a(null))},[e,t])}}function mr({status:e,locales:t,cell:n}){let r=u(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)(E,{caption:`${r}: versions per locale`,columns:fr(t,n,e.collection),rows:e.items,rowKey:e=>e.slug})]})}function hr({settings:e}){let t=a().hasRole(`editor`),n=`${e.defaultLocale}:${e.supportedLocales.join(`,`)}`,r=(0,k.useCallback)(()=>ve(),[n]),{loaded:i,reload:o}=h(r,`Translation coverage could not be read`),s={...pr(e.defaultLocale),defaultLocale:e.defaultLocale,canCreate:t};return(0,I.jsxs)(U,{title:`Translation coverage`,sources:(0,I.jsxs)(H,{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)(G,{what:`translation coverage`}),i.state===`error`&&(0,I.jsx)(K,{message:i.message,onRetry:o}),i.state===`ready`&&i.data.collections.map(e=>(0,I.jsx)(mr,{status:e,locales:i.data.supportedLocales,cell:s},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}=h(he,`The locales could not be read`),[n,r]=(0,k.useState)(null),i=(0,k.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)(H,{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)(H,{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)(w,{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)(f,{size:`sm`,variant:`ghost`,icon:_,"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,k.useState)(``),o=r.includes(i)?i:r[0];return o===void 0?(0,I.jsx)(W,{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)(V,{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)(f,{type:`submit`,variant:`primary`,icon:Le,"aria-disabled":t,children:`Add locale`})]})}function Cr(e){let t=x(),{busy:n,once:r}=P();return{busy:n,change:(n,i)=>{r(async()=>{try{e(await y(n)),t({text:i})}catch(e){t({text:S(e,`The locales could not be saved`),tone:`error`})}})}}}function wr({code:e,settings:t,onSaved:n,onClose:r}){let i=x();async function a(){n(await y(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=a().hasRole(`admin`),{busy:r,change:i}=Cr(t),[o,s]=(0,k.useState)(null),c=e.supportedLocales.map(t=>({code:t,isDefault:t===e.defaultLocale}));return(0,I.jsxs)(U,{title:`Locales`,sources:(0,I.jsx)(br,{settings:e}),children:[(0,I.jsx)(E,{caption:`Locales`,columns:xr(n,r,s),rows:c,rowKey:e=>e.code}),n?(0,I.jsx)(Sr,{settings:e,busy:r,change:i}):(0,I.jsx)(W,{children:`Only admins change the locales.`}),o&&(0,I.jsx)(wr,{code:o,settings:e,onSaved:t,onClose:()=>s(null)})]})}function Er(){let{loaded:e,reload:t,set:n}=yr();if(e.state===`loading`)return(0,I.jsx)(G,{what:`the locales`});if(e.state===`error`)return(0,I.jsx)(K,{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)(B,{label:`Email`,type:`email`,value:e.email,disabled:n,onChange:n=>t({...e,email:n}),hint:r}),(0,I.jsx)(B,{label:`Name`,value:e.name,onChange:n=>t({...e,name:n})}),(0,I.jsx)(V,{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,k.useId)(),[i,a]=(0,k.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)(f,{onClick:n,children:`Cancel`}),(0,I.jsx)(f,{variant:`primary`,type:`submit`,form:r,"aria-disabled":o,children:o?`Saving…`:e?`Save`:`Create user`})]}),p=e?`Edit ${$(e)}`:`Create user`;return(0,I.jsx)(b,{title:p,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:ne,variant:`secondary`};return t?[n]:[n,{kind:`active`,label:e.isActive?`Deactivate`:`Activate`,icon:st,variant:`ghost`},{kind:`delete`,label:`Delete`,icon:_,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)(f,{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)(w,{tone:Q(e)===`admin`?`accent`:`neutral`,children:jr(e)})},{id:`status`,header:`Status`,cell:e=>e.isActive?(0,I.jsx)(w,{tone:`success`,children:`Active`}):(0,I.jsx)(w,{children:`Deactivated`})},{id:`sign-in`,header:`Signs in with`,cell:e=>e.oidcIssuer?`OIDC provider`:`Studio`},{id:`created`,header:`Created`,cell:e=>c(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 mt(e.id,{name:t.name,role:t.role}),`Saved ${$(e)}: ${t.role}.`):`Created ${$(await pt({email:t.email,name:t.name||void 0,role:t.role}))} as ${t.role}.`}async function Ir(e,t){return e===`delete`?(await ht(t.id),`Deleted ${$(t)}.`):(await mt(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=x(),t=a().user?.id,{loaded:n,reload:r}=h(ft,`The accounts could not be read`),[i,o]=(0,k.useState)(null);return(0,I.jsxs)(U,{title:`People`,sources:(0,I.jsx)(H,{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)(f,{variant:`primary`,icon:dt,onClick:()=>o({kind:`create`}),children:`Create user`}),children:[n.state===`loading`&&(0,I.jsx)(G,{what:`the accounts`}),n.state===`error`&&(0,I.jsx)(K,{message:n.message,onRetry:r}),n.state===`ready`&&(0,I.jsx)(E,{caption:`People`,columns:Pr(t,o),rows:n.data,rowKey:e=>e.id}),i&&(0,I.jsx)(Rr,{dialog:i,onClose:()=>o(null),onDone:t=>{o(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)(Xt,{});case`integrations`:return(0,I.jsx)(ur,{});case`checkpoints`:return(0,I.jsx)(rn,{});case`people`:return(0,I.jsx)(zr,{});case`environment`:return(0,I.jsx)(Xn,{})}}function Vr({tab:e,tabs:t}){let n=(0,k.useId)(),r=(0,k.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)(Je,{label:`Setup`,tabs:t,current:e,tabId:r,panelId:`${n}-panel`}),(0,I.jsx)(`div`,{id:`${n}-panel`,role:`tabpanel`,"aria-labelledby":r(e),className:`setup-panel`,children:(0,I.jsx)(Br,{tab:e})})]})}export{Vr as SetupPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,s as n}from"./vendor-diff-Dm2YfgXt.js";import{n as r}from"./createLucideIcon-D_HN41p3.js";import{i,n as a,r as o}from"./findability-CUYOthYI.js";import{y as s}from"./api-seo-2H6_VoWE.js";import{t as c}from"./triangle-alert-C4yqbtOC.js";import{M as l,o as u}from"./index-DVe5jFLX.js";import{t as d}from"./empty-state-CU7q3Ypl.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 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,s as n}from"./vendor-diff-Dm2YfgXt.js";import{t as r,u as i}from"./vendor-router-DjV3D6zM.js";import{d as a,t as o}from"./format-pPdsDgeS.js";import{t as s}from"./createLucideIcon-D_HN41p3.js";import{t as c}from"./use-loaded-C3hBdQe0.js";import{a as l}from"./findability-CUYOthYI.js";import{Ct as u,a as d,ut as f,x as p}from"./index-DVe5jFLX.js";import{t as m}from"./empty-state-CU7q3Ypl.js";import{f as h,l as g}from"./site-model-DX8WxTJg.js";import{n as _,t as v}from"./data-table-D8BsE1pn.js";import{a as y,o as b,r as x,t as S}from"./site-XpqFn80l.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=s(C),T=e(n(),1),E=t(),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)(p,{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 a=i(),o=(0,T.useMemo)(()=>y(n,r),[n,r]);return(0,E.jsx)(v,{caption:e,columns:o,rows:t,rowKey:e=>e.slug,onRowClick:e=>a(b(e,n.defaultLocale))})}function j({section:e,context:t,localization:n}){let i=(0,T.useId)(),{collection:a,rows:s}=e,c=o(a.name),f=d(a);return(0,E.jsxs)(`section`,{className:`site-panel`,"aria-labelledby":i,children:[(0,E.jsxs)(`div`,{className:`site-panel-head`,children:[(0,E.jsxs)(`div`,{className:`site-panel-title`,children:[(0,E.jsx)(`h2`,{id:i,children:(0,E.jsx)(r,{to:u(a.name),children:c})}),(0,E.jsx)(`code`,{className:`site-pattern`,children:f??`no pages`})]}),(0,E.jsx)(k,{counts:g(s)})]}),s.length===0?(0,E.jsx)(m,{icon:l,title:`No ${c.toLowerCase()} yet`,children:`Documents you create in this collection show up here.`}):(0,E.jsx)(A,{caption:c,rows:s,context:t,localization:n})]})}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:g(e)})]}),e.length===0?(0,E.jsx)(m,{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)(_,{})]})}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)(m,{icon:f,title:`No collections`,children:[`Collections are defined in code, in `,(0,E.jsx)(`code`,{children:`krantho.collections.ts`}),`.`]})})}function L(){let e=a(),t=(0,T.useCallback)(()=>x(e),[e]),{loaded:n,reload:r}=c(t,`The site could not load`),i=(0,T.useRef)(null),o=(0,T.useRef)(null),s=S(n.state,{ready:i,error:o}),l=()=>{r(),s()},u=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:u?.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)(h,{title:`The site could not load`,message:n.message,onRetry:l,panelRef:o}),u&&(0,E.jsx)(N,{data:u}),u&&u.sections.length===0&&(0,E.jsx)(I,{})]})}export{L as SiteOverview};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphBrowser-DvcHXw-i.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/vendor-diff-Dm2YfgXt.js","assets/createLucideIcon-D_HN41p3.js","assets/createLucideIcon-DO6kYgVn.css","assets/graph-config-ZUe9BjGK.js","assets/use-loaded-C3hBdQe0.js","assets/index-DVe5jFLX.js","assets/vendor-react-DMqGe90A.js","assets/vendor-react-DLioOiRN.css","assets/vendor-router-DjV3D6zM.js","assets/auth-GRfs02w7.js","assets/format-pPdsDgeS.js","assets/api-client-BRi_ki2Y.js","assets/index-Buq8auz3.css","assets/copy-DloNx7rC.js","assets/corner-down-right-D2cWjQTP.js","assets/findability-CUYOthYI.js","assets/layers-BQ89qo5R.js","assets/guards-BFEDbduR.js","assets/graph-config-mZyX0Lqo.css","assets/circle-check-big-zoQrH4Hp.js","assets/circle-x-DMb3ZtiK.js","assets/export-helpers-B2KV_EB5.js","assets/external-link-BRKJTCZG.js","assets/save-kXwhieDK.js","assets/trash-Cknp3eZ5.js","assets/triangle-alert-C4yqbtOC.js","assets/upload-BvBYjswd.js","assets/catalog-offer-CeRRk2Zo.js","assets/GraphBrowser-U_-D112C.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,o as n,s as r}from"./vendor-diff-Dm2YfgXt.js";import{r as i,t as a}from"./vendor-router-DjV3D6zM.js";import{i as o}from"./auth-GRfs02w7.js";import{n as s,t as c}from"./format-pPdsDgeS.js";import{i as l,n as u,t as d}from"./createLucideIcon-D_HN41p3.js";import{t as f}from"./arrow-down-CsgZZR1B.js";import{C as p,D as m,E as ee,S as te,c as ne,d as re,i as ie,n as ae,s as oe,u as se,w as ce,x as le}from"./graph-config-ZUe9BjGK.js";import{t as h}from"./use-loaded-C3hBdQe0.js";import{t as ue}from"./circle-dashed-Cu2MEHnb.js";import{t as de}from"./circle-x-DMb3ZtiK.js";import{a as fe,i as pe,n as me,t as he}from"./export-helpers-B2KV_EB5.js";import{t as g}from"./external-link-BRKJTCZG.js";import{a as _,r as v}from"./findability-CUYOthYI.js";import{t as ge}from"./info-B69U-gXd.js";import{t as _e}from"./layers-BQ89qo5R.js";import{t as ve}from"./list-checks-DmMdd-uP.js";import{t as ye}from"./pen-line-CZkcVGBd.js";import{t as be}from"./rotate-ccw-CjpQmti_.js";import{_ as xe,a as Se,c as Ce,d as we,f as Te,g as Ee,h as De,i as Oe,m as ke,n as Ae,o as je,p as Me,t as Ne,y as Pe}from"./api-seo-2H6_VoWE.js";import{t as Fe}from"./save-kXwhieDK.js";import{a as Ie,c as Le,i as Re,o as ze,s as Be,u as y}from"./fill-job-D41ra-DR.js";import{t as b}from"./triangle-alert-C4yqbtOC.js";import{D as Ve,G as He,Ot as x,V as Ue,a as We,c as S,ct as Ge,d as C,et as w,f as T,ft as Ke,l as qe,s as E,st as Je,wt as D,xt as Ye,yt as Xe}from"./index-DVe5jFLX.js";import{n as Ze,t as Qe}from"./catalog-offer-CeRRk2Zo.js";import{t as $e}from"./vendor-reactflow-5Qvgw90M.js";import{t as O}from"./empty-state-CU7q3Ypl.js";import{t as k}from"./action-button-Co7fp7HS.js";import{n as et}from"./guards-BFEDbduR.js";import{t as A}from"./source-CGZGd3Xy.js";import{i as tt,n as nt,r as rt,t as it}from"./fill-run-view-DFeyjdsI.js";import{t as at}from"./data-table-D8BsE1pn.js";var ot={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};ot.node;var st=d(ot),ct={name:`file-search`,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`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]};ct.node;var lt=d(ct),ut={name:`sparkle`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}]]};ut.node;var dt=d(ut),ft={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};ft.node;var pt=d(ft),j=e(r(),1);function M(e){return e.status>=200&&e.status<300}async function N(e){try{let t=await fetch(e,{credentials:`omit`,cache:`no-store`});return{path:e,status:t.status,text:await t.text()}}catch{return{path:e,status:0,text:``}}}function P(e){return e.status===0?`The site did not answer at ${e.path}.`:e.status===404?`The site serves nothing at ${e.path} (HTTP 404).`:`The site answered ${e.path} with HTTP ${e.status}.`}function F(e,t){return e.getElementsByTagNameNS(`*`,t)[0]?.textContent?.trim()||void 0}function mt(e){let t=new DOMParser().parseFromString(e,`application/xml`);return t.getElementsByTagName(`parsererror`).length>0||t.documentElement.localName!==`urlset`?null:[...t.getElementsByTagNameNS(`*`,`url`)].flatMap(e=>{let t=F(e,`loc`);return t?[{loc:t,lastmod:F(e,`lastmod`),changefreq:F(e,`changefreq`),priority:F(e,`priority`)}]:[]})}function I(e,t){return M(e)?e.text.trimEnd()===t.trimEnd()?`krantho`:`own`:`none`}function ht(e,t){return e===null?`krantho's own llms.txt could not be read, so where this one comes from could not be determined.`:e===`own`?`Written by the site's own /llms.txt route, not by krantho: it differs from what krantho's API builds, and Studio does not change it.`:t===`snapshot`?`Served from krantho's API: the snapshot saved through the assistant, until another is saved.`:t===`generated`?`Served from krantho's API, built from the live pages on each request: the site's name, the site entity's description as its summary, then each collection with pages and a link per live, indexable page with its description.`:`Served from krantho's API, which did not say how it made it: its origin could not be determined.`}function gt(e){switch(e){case`krantho`:return`The site serves this at /robots.txt.`;case`own`:return`The site's /robots.txt is answered by its own route, so what is saved here does not reach it.`;case`none`:return`The site serves no /robots.txt: route it to /api/seo/robots.txt to serve this.`}}async function _t(){let e=await N(`/sitemap.xml`);return M(e)?{served:e,entries:mt(e.text),krantho:null}:{served:e,entries:null,krantho:await Me().then(e=>e.urls,()=>null)}}async function vt(){let[e,t,n,r,i]=await Promise.all([_t(),N(`/robots.txt`),Se(),N(`/llms.txt`),Oe().catch(()=>null)]);return{sitemap:e,robots:{served:t,krantho:n},llms:{served:r,krantho:i}}}var L=t();function R({title:e,lead:t,aside:n,id:r,children:i}){let a=(0,j.useId)();return(0,L.jsxs)(`section`,{id:r,className:`structure-card`,"aria-labelledby":a,children:[(0,L.jsxs)(`div`,{className:`structure-card-head`,children:[(0,L.jsx)(`h3`,{id:a,className:`structure-card-title`,children:e}),n]}),t&&(0,L.jsx)(`p`,{className:`structure-note`,children:t}),i]})}function z({types:e}){return e.length===0?(0,L.jsx)(`span`,{className:`structure-muted`,children:`None set`}):(0,L.jsx)(`span`,{className:`structure-chips`,children:e.map(e=>(0,L.jsx)(E,{children:e},e))})}function B(e,t,n,r){return e?t?`Saving…`:r===`save`&&!n?`Change the text first.`:null:`robots.txt is changed by an admin.`}function yt(e){let t=w(),[n,r]=(0,j.useState)(null);async function i(n,i){r(n);try{t({text:await i()}),e()}catch(e){t({text:T(e,`robots.txt could not be saved`),tone:`error`})}finally{r(null)}}return{busy:n,save:e=>void i(`save`,async()=>(await Ee(e),`Override saved. /api/seo/robots.txt now serves it.`)),reset:()=>void i(`reset`,async()=>await De()?`Override removed. krantho generates robots.txt again.`:`There was no override: krantho already generates robots.txt.`)}}function bt(e){let[t,n]=(0,j.useState)(e),[r,i]=(0,j.useState)(e);return r!==e&&(i(e),n(e)),[t,n]}function xt(e){let{busy:t,save:n,reset:r}=yt(e.onSaved),i=e.draft!==e.served;return(0,L.jsxs)(`div`,{className:`structure-actions`,children:[(0,L.jsx)(k,{variant:`primary`,icon:Fe,reason:B(e.admin,t,i,`save`),onClick:()=>n(e.draft),children:t===`save`?`Saving…`:`Save`}),(0,L.jsx)(k,{icon:be,reason:B(e.admin,t,i,`reset`),onClick:r,children:t===`reset`?`Resetting…`:`Reset`})]})}function St({robots:e,site:t,admin:n,onSaved:r}){let[i,a]=bt(e.krantho),o=(0,j.useId)(),s=ke(t);return(0,L.jsxs)(R,{title:`robots.txt`,lead:`${s?`The override saved in Studio`:`Generated by krantho: every crawler allowed, the sitemap named`}. ${gt(I(e.served,e.krantho))}`,children:[(0,L.jsxs)(`div`,{className:`structure-row`,children:[(0,L.jsx)(`label`,{htmlFor:o,className:`structure-label`,children:`robots.txt`}),(0,L.jsx)(E,{tone:s?`accent`:`neutral`,children:s?`Override`:`Generated`})]}),(0,L.jsx)(`textarea`,{id:o,className:`structure-textarea`,rows:8,spellCheck:!1,value:i,readOnly:!n,onChange:e=>a(e.target.value)}),(0,L.jsx)(xt,{draft:i,served:e.krantho,admin:n,onSaved:r})]})}async function Ct(){let[e,t,n,r]=await Promise.all([Ve(),Ue(),A(!0,Ce),A(!0,je)]);return{site:e,collections:t,configs:n,catalog:r}}function wt(){return Te()}function V(e,t){return e.find(e=>e.id===t)??null}function H(e,t){return e.filter(e=>e.scope===t)}function Tt(e){return e.state===`ok`?new Set(e.value.types.filter(e=>e.siteLevel).map(e=>e.type)):new Set}function Et(e){if(e.state!==`ok`)return new Set;let t=e.value.types.filter(e=>e.siteLevel&&!e.documentLevel);return new Set(t.map(e=>e.type))}var Dt=[{id:`loc`,header:`URL`,primary:!0,cell:e=>{let t=et(e.loc);return t?(0,L.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`structure-link`,children:[e.loc,(0,L.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]}):e.loc}},{id:`lastmod`,header:`Last modified`,cell:e=>e.lastmod?`${s(e.lastmod)} UTC`:`—`},{id:`changefreq`,header:`Change frequency`,cell:e=>e.changefreq??`—`},{id:`priority`,header:`Priority`,numeric:!0,cell:e=>e.priority??`—`}];function Ot({entries:e,caption:t}){return e.length===0?(0,L.jsx)(`p`,{className:`structure-note`,children:`It lists no URL.`}):(0,L.jsx)(at,{caption:t,columns:Dt,rows:e,rowKey:e=>e.loc})}var kt=e=>e.map(e=>({...e}));function At({sitemap:e}){let{served:t,entries:n,krantho:r}=e;return M(t)?(0,L.jsx)(R,{title:`Sitemap`,lead:`As the site serves it at /sitemap.xml${n?`: ${n.length} URL${n.length===1?``:`s`}`:``}. krantho lists every live, indexable page of the collections with pages.`,children:n?(0,L.jsx)(Ot,{entries:n,caption:`Sitemap as served`}):(0,L.jsx)(`p`,{className:`structure-note`,children:`What the site serves at /sitemap.xml is not a sitemap.`})}):(0,L.jsx)(R,{title:`Sitemap`,lead:`${P(t)} What krantho's API builds at /api/seo/sitemap from the live pages:`,children:r?(0,L.jsx)(Ot,{entries:kt(r),caption:`Sitemap krantho builds`}):(0,L.jsx)(`p`,{className:`structure-note`,children:`krantho's sitemap could not be read either.`})})}function jt({llms:e}){let{served:t,krantho:n}=e;if(!M(t))return(0,L.jsx)(R,{title:`llms.txt`,lead:`${P(t)} krantho's API serves one at /api/seo/llms.txt; route /llms.txt to it to serve it.`});let r=n?I(t,n.text):null;return(0,L.jsxs)(R,{title:`llms.txt`,lead:(0,L.jsxs)(L.Fragment,{children:[`As the site serves it at /llms.txt, read-only.`,` `,ht(r,n?.origin??null)]}),children:[(0,L.jsx)(`section`,{className:`structure-text`,tabIndex:0,"aria-label":`llms.txt as served`,children:(0,L.jsx)(`pre`,{children:t.text})}),(0,L.jsxs)(`a`,{href:`/llms.txt`,target:`_blank`,rel:`noreferrer`,className:`structure-link`,children:[`Open /llms.txt`,(0,L.jsx)(g,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]})]})}function Mt({base:e,admin:t,state:n}){let r=(0,j.useCallback)(()=>vt(),[]),{loaded:i,reload:a}=h(r,`What crawlers read could not be read`),o=e.configs.state===`ok`?V(e.configs.value,`site`):null,s=(0,j.useCallback)(()=>{a(),n.reloadBase()},[a,n]);return i.state===`loading`?(0,L.jsx)(`p`,{className:`structure-note`,children:`Reading what the site serves…`}):i.state===`error`?(0,L.jsx)(`p`,{className:`structure-note structure-note--error`,children:i.message}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`structure-tab-lead`,children:`What search engines and assistants fetch from the site's own addresses, read as they read them.`}),(0,L.jsx)(At,{sitemap:i.data.sitemap}),(0,L.jsx)(St,{robots:i.data.robots,site:o?.config??null,admin:t,onSaved:s}),(0,L.jsx)(jt,{llms:i.data.llms})]})}function Nt({provider:e,reason:t}){return e===`missing`?(0,L.jsxs)(`p`,{className:`structure-note`,children:[`No language model is set up. Set one up in`,` `,(0,L.jsx)(a,{to:Ye,children:`Setup › AI provider`}),`.`]}):t?(0,L.jsx)(`p`,{className:`structure-note`,children:t}):null}function Pt(){return(0,L.jsxs)(`p`,{className:`structure-modal-lead`,children:[`Fills what is `,(0,L.jsx)(`em`,{children:`missing`}),` — meta descriptions and the Schema.org properties no one has set — with the language model set up in Setup › AI provider. It never overwrites a value someone set. What it fills is saved to each document at once: the meta description as a new version and in the document's SEO settings, the Schema.org properties in those settings. The SEO settings have no versions, so the structured data on the live pages — and the meta descriptions the site reads from them first — change straight away.`]})}function Ft({collections:e,admin:t,run:n,onStart:r,onClose:i}){let[a,o]=(0,j.useState)({scope:`all`}),s=se(),c=n.state===`running`,l=c?`Enrichment is running.`:rt(t,s);return(0,L.jsxs)(C,{title:`Fill what's missing`,onClose:i,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{onClick:i,children:c?`Close (it keeps running)`:`Close`}),(0,L.jsx)(k,{variant:`primary`,icon:y,reason:l,onClick:()=>r(a),children:`Fill what's missing`})]}),children:[(0,L.jsx)(Pt,{}),(0,L.jsx)(nt,{collections:e,value:a,disabled:c,onChange:o}),!c&&(0,L.jsx)(Nt,{provider:s,reason:l}),(0,L.jsx)(it,{run:n})]})}var It=e($e(),1);function Lt(e){return{width:e.length*7+12,height:16}}function Rt(e){let t=new It.default.graphlib.Graph({multigraph:!0});t.setGraph({rankdir:`LR`,nodesep:28,ranksep:96,marginx:16,marginy:16}),t.setDefaultEdgeLabel(()=>({}));for(let n of e.nodes)t.setNode(n.key,{width:216,height:96});return e.edges.forEach((e,n)=>{t.setEdge(e.from,e.to,{...Lt(e.property),labelpos:`c`},`e${n}`)}),t}function zt(e){let t=Rt(e);It.default.layout(t);let n=e.nodes.map(e=>{let n=t.node(e.key);return{key:e.key,x:n?.x??0,y:n?.y??0}}),r=e.edges.map((e,n)=>{let r=t.edge({v:e.from,w:e.to,name:`e${n}`}),i=r?.points??[],a=i[Math.floor(i.length/2)]??{x:0,y:0};return{key:`e${n}`,property:e.property,points:i,labelX:r?.x??a.x,labelY:r?.y??a.y}}),i=t.graph();return{width:i.width??0,height:i.height??0,nodes:n,edges:r}}var U={site:{label:`site`,meaning:`A site entity: every page states it`},collection:{label:`collection`,meaning:`From the collection's archetype`},route:{label:`URL pattern`,meaning:`From a URL pattern's override`},document:{label:`document`,meaning:`From this page's own SEO settings`},derived:{label:`derived`,meaning:`Composed by krantho for the page: no scope sets it`}};function Bt(e,t,n){let r=t=>e.find(e=>e.id===t)?.config??null;return{document:r(`doc:${t}/${n}`),collection:r(`collection:${t}`),routes:e.filter(e=>e.scope===`route`).map(e=>e.config)}}var W=(e,t)=>e?.entities.some(e=>e[`@type`]===t)??!1;function Vt(e,t,n){return e.scope===`site`?`site`:t?W(n.document,e.type)?`document`:n.routes.some(t=>W(t,e.type))?`route`:W(n.collection,e.type)?`collection`:`derived`:`derived`}function Ht(e,t,n){return e.filter(e=>e.nodeId&&t?e.nodeId===t:e.type===n)}function Ut(e,t,n,r){let i=t.id!==``&&r.resolved.some(e=>e.id===t.id),a=Ht(r.features,t.id,t.type);return{key:t.id||`node-${n}`,id:t.id,type:p(e[`@type`])??t.type,kind:Vt(t,i,r.scopes),propertyCount:t.rows.length,features:a,missing:[...new Set(a.flatMap(e=>e.missing))],view:t}}function Wt(e,t){let n=new Map(e.filter(e=>e.id).map(e=>[e.id,e.key])),r=[];return t.forEach((t,i)=>{let a=e[i]?.key;if(a){for(let[e,i]of Object.entries(t))if(!e.startsWith(`@`))for(let t of ne(i)){let i=n.get(t);i&&i!==a&&r.push({from:a,to:i,property:e})}}}),r}function Gt(e){let t=oe({nodes:e.nodes,resolved:e.resolved,siteTypes:e.siteTypes}),n=e.nodes.flatMap((n,r)=>{let i=t[r];return i?[Ut(n,i,r,e)]:[]});return{nodes:n,edges:Wt(n,e.nodes)}}function Kt(e){let t=new Set(e.nodes.map(e=>e.kind)),n=[`site`,`collection`,`document`,`derived`];return Object.keys(U).filter(e=>n.includes(e)||t.has(e))}function qt(e,t){let n=new Map(e.nodes.map(e=>[e.key,e.type])),r=e.edges.filter(e=>e.from===t).map(e=>`${e.property} → ${n.get(e.to)??e.to}`);return[...new Set(r)]}var Jt={site:ee,collection:_e,route:ce,document:_,derived:dt};function Yt(e){return e===1?`1 property`:`${e} properties`}function Xt(e){if(e.features.length===0)return null;let t=[...new Set(e.features.map(e=>e.feature))].join(`, `),n=e.features.every(e=>e.eligible),r=e.features.every(e=>e.eligible||e.status===`restricted`);return{text:`${t}${n?``:r?` · on conditions`:` · not eligible`}`,eligible:n}}function G({kind:e}){let t=Jt[e];return(0,L.jsxs)(`span`,{className:S(`neutral`,`structure-kind`),title:U[e].meaning,children:[(0,L.jsx)(t,{className:`ui-chip-icon`,"aria-hidden":`true`}),U[e].label]})}function Zt({node:e}){let t=Xt(e);return(0,L.jsxs)(`span`,{className:`structure-node-chips`,children:[(0,L.jsx)(`span`,{className:S(`neutral`),children:Yt(e.propertyCount)}),t&&(0,L.jsxs)(`span`,{className:S(t.eligible?`success`:`warning`),children:[t.eligible?(0,L.jsx)(Ke,{className:`ui-chip-icon`,"aria-hidden":`true`}):(0,L.jsx)(m,{className:`ui-chip-icon`,"aria-hidden":`true`}),t.text]}),e.missing.length>0&&(0,L.jsxs)(`span`,{className:S(`danger`),children:[(0,L.jsx)(b,{className:`ui-chip-icon`,"aria-hidden":`true`}),e.missing.length,` missing`]})]})}function Qt({node:e}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`structure-node-head`,children:[(0,L.jsx)(`span`,{className:`structure-node-type`,children:e.type}),(0,L.jsx)(G,{kind:e.kind})]}),(0,L.jsx)(`code`,{className:`structure-node-id`,title:e.id||void 0,children:e.id?te(e.id):`no @id`}),(0,L.jsx)(Zt,{node:e})]})}function $t(e){return e.map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)}function en({edge:e,marker:t}){return(0,L.jsxs)(`g`,{children:[(0,L.jsx)(`path`,{d:$t(e.points),className:`structure-canvas-edge`,markerEnd:`url(#${t})`}),(0,L.jsx)(`text`,{x:e.labelX,y:e.labelY,className:`structure-canvas-label`,textAnchor:`middle`,dominantBaseline:`middle`,children:e.property})]})}function tn(e){let t=(0,j.useId)();return(0,L.jsxs)(`svg`,{className:`structure-canvas-edges`,width:e.width,height:e.height,"aria-hidden":`true`,children:[(0,L.jsx)(`defs`,{children:(0,L.jsx)(`marker`,{id:t,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`8`,markerHeight:`8`,orient:`auto`,children:(0,L.jsx)(`path`,{d:`M0,0 L8,4 L0,8 z`,className:`structure-canvas-arrow`})})}),e.edges.map(e=>(0,L.jsx)(en,{edge:e,marker:t},e.key))]})}function nn({node:e,links:t,x:n,y:r,selected:i,onSelect:a}){return(0,L.jsxs)(`button`,{type:`button`,className:`structure-node structure-node--canvas`,"data-kind":e.kind,"aria-pressed":i,style:{left:n-108,top:r-48,width:216,height:96},onClick:()=>a(e.key),children:[(0,L.jsx)(Qt,{node:e}),t.length>0&&(0,L.jsxs)(`span`,{className:`visually-hidden`,children:[`Links: `,t.join(`; `)]})]})}function rn({graph:e,selected:t,onSelect:n}){let r=(0,j.useMemo)(()=>zt(e),[e]),i=new Map(e.nodes.map(e=>[e.key,e]));return(0,L.jsx)(`section`,{className:`structure-canvas`,"aria-label":`Graph canvas`,tabIndex:0,children:(0,L.jsxs)(`div`,{className:`structure-canvas-stage`,style:{width:r.width,height:r.height},children:[(0,L.jsx)(tn,{edges:r.edges,width:r.width,height:r.height}),r.nodes.map(r=>{let a=i.get(r.key);return a?(0,L.jsx)(nn,{node:a,links:qt(e,r.key),x:r.x,y:r.y,selected:t===r.key,onSelect:n},r.key):null})]})})}function an({graph:e,selected:t,onSelect:n}){return(0,L.jsx)(`ul`,{className:`structure-graph-list`,"aria-label":`Graph nodes`,children:e.nodes.map(r=>{let i=qt(e,r.key);return(0,L.jsxs)(`li`,{className:`structure-graph-item`,children:[(0,L.jsx)(`button`,{type:`button`,className:`structure-node structure-node--list`,"data-kind":r.kind,"aria-pressed":t===r.key,onClick:()=>n(r.key),children:(0,L.jsx)(Qt,{node:r})}),i.length>0&&(0,L.jsx)(`ul`,{className:`structure-graph-links`,"aria-label":`Links of ${r.type}`,children:i.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`code`,{children:e})},e))})]},r.key)})})}function on(e){let{node:t,collection:n,slug:r}=e;return t.kind===`site`?x(`site`):D(n,r)}function sn(e){switch(e.node.kind){case`site`:return`Every page states it. Its values are set in Scopes & archetypes › Site entities, or come from the site section of krantho.config.ts.`;case`collection`:return`Its type comes from the collection's archetype; its values from the page's fields and the SEO settings. Set a value for this page in its Data mode.`;case`route`:return`Its type comes from a URL pattern's override. Set a value for this page in its Data mode.`;case`document`:return`Its type comes from this page's own SEO settings, which its Data mode edits.`;case`derived`:return`krantho composes it for the page from what the page states (its address, its trail, its dates). Change those, not this node.`}}function cn({feature:e,props:t}){return(0,L.jsxs)(`li`,{className:`structure-missing`,children:[(0,L.jsx)(b,{className:`structure-missing-icon`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`structure-missing-text`,children:[t.readerName(e.reader),`'s `,e.feature,` needs`,` `,e.missing.map((e,t)=>(0,L.jsxs)(`span`,{children:[t>0&&`, `,(0,L.jsx)(`code`,{children:e})]},e)),`.`,` `,(0,L.jsxs)(`a`,{href:e.source,target:`_blank`,rel:`noreferrer`,className:`structure-link`,children:[`The rule `,(0,L.jsx)(`span`,{className:`visually-hidden`,children:`(opens in a new tab)`})]})]}),(0,L.jsxs)(a,{to:on(t),className:l(`secondary`,`sm`),children:[(0,L.jsx)(pt,{className:`ui-button-icon`,"aria-hidden":`true`}),`Fix `,(0,L.jsx)(`span`,{className:`visually-hidden`,children:e.feature})]})]})}function ln(e){let{node:t}=e,n=t.features.filter(e=>e.missing.length>0),r=[...new Set(t.features.flatMap(e=>e.conditions))];return(0,L.jsxs)(`section`,{className:`structure-card structure-node-card`,"aria-label":`Selected node: ${t.type}`,children:[(0,L.jsxs)(`div`,{className:`structure-card-head`,children:[(0,L.jsx)(`h3`,{className:`structure-card-title`,children:`Selected node`}),(0,L.jsx)(G,{kind:t.kind})]}),n.length>0&&(0,L.jsx)(`ul`,{className:`structure-missing-list`,"aria-label":`Missing requirements`,children:n.map(t=>(0,L.jsx)(cn,{feature:t,props:e},`${t.reader}:${t.feature}`))}),(0,L.jsxs)(`p`,{className:`structure-note`,children:[U[t.kind].meaning,`. `,sn(e)]}),r.map(e=>(0,L.jsxs)(`p`,{className:`structure-note`,children:[`Shown on a condition: `,e,`.`]},e)),(0,L.jsx)(ie,{views:[t.view]})]})}function un(e){let t=new DOMParser().parseFromString(e,`text/html`),n=[],r=0;for(let e of t.querySelectorAll(`script[type="application/ld+json"]`))try{n.push(JSON.parse(e.textContent??``))}catch{r++}return{scripts:n,nodes:n.flatMap(ae),unreadable:r}}function dn(e){return e.scripts.length===1?e.scripts[0]:e.scripts}async function fn(e){let{page:t}=e,[n,r]=await Promise.all([N(t.path),we(t.collection,t.slug)]);if(!M(n))return{state:`unserved`,reason:P(n)};let i=un(n.text);return i.nodes.length===0?{state:`unserved`,reason:`The page at ${t.path} serves no JSON-LD.`}:{state:`served`,served:i,graph:Gt({nodes:i.nodes,resolved:r.entities,siteTypes:e.siteTypes,scopes:Bt(e.configs,t.collection,t.slug),features:t.features})}}function pn(e,t){let n=(0,j.useRef)(e);(0,j.useLayoutEffect)(()=>{n.current=e});let r=`${e.page.collection}/${e.page.slug}`,i=(0,j.useCallback)(()=>fn(n.current),[r]),{loaded:a,reload:o}=h(i,`The page could not be read`),s=(0,j.useRef)(t);return(0,j.useEffect)(()=>{s.current!==t&&(s.current=t,o())},[t,o]),a}var mn=`(min-width: 1200px)`,hn=`page`,K=e=>`${e.collection}/${e.slug}`;function gn(e){let[t,n]=i(),r=t.get(hn);return[e.find(e=>K(e)===r)??e[0]??null,e=>{n(t=>{let n=new URLSearchParams(t);return n.set(hn,e),n},{replace:!0})}]}function _n({pages:e,value:t,onChange:n}){let r=(0,j.useId)();return(0,L.jsxs)(`div`,{className:`structure-field`,children:[(0,L.jsx)(`label`,{htmlFor:r,children:`Page`}),(0,L.jsx)(`select`,{id:r,className:`structure-select`,value:t,onChange:e=>n(e.target.value),children:e.map(e=>(0,L.jsxs)(`option`,{value:K(e),children:[e.path,` · `,K(e)]},K(e)))})]})}function vn({graph:e}){return(0,L.jsx)(`ul`,{className:`structure-legend`,"aria-label":`Where each node comes from`,children:Kt(e).map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(G,{kind:e}),(0,L.jsx)(`span`,{className:`structure-legend-text`,children:U[e].meaning})]},e))})}function yn(e){return e.nodes.find(e=>e.kind!==`site`&&e.kind!==`derived`)??e.nodes[0]??null}function bn({page:e,served:t}){function n(){let n=pe(e.collection,e.slug);he(me(dn(t)),n,`application/ld+json`)}return(0,L.jsxs)(`div`,{className:`structure-actions`,children:[(0,L.jsx)(u,{size:`sm`,icon:fe,onClick:n,children:`Export JSON-LD`}),(0,L.jsxs)(a,{to:D(e.collection,e.slug),className:l(`secondary`,`sm`),children:[(0,L.jsx)(ye,{className:`ui-button-icon`,"aria-hidden":`true`}),`Edit or import in Data mode`]})]})}function xn({page:e,served:t,graph:n,readerName:r}){let i=Xe(mn),[a,o]=(0,j.useState)(null),s=n.nodes.find(e=>e.key===a)??yn(n);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`structure-row`,children:[(0,L.jsx)(vn,{graph:n}),(0,L.jsx)(bn,{page:e,served:t})]}),(0,L.jsx)(i?rn:an,{graph:n,selected:s?.key??null,onSelect:o}),s&&(0,L.jsx)(ln,{node:s,collection:e.collection,slug:e.slug,readerName:r}),t.unreadable>0&&(0,L.jsxs)(`p`,{className:`structure-note`,children:[t.unreadable,` JSON-LD script`,t.unreadable===1?` is`:`s are`,` not valid JSON: search engines skip `,t.unreadable===1?`it`:`them`,`.`]}),(0,L.jsxs)(`details`,{className:`structure-disclosure`,children:[(0,L.jsx)(`summary`,{children:`What the page emits · view-source`}),(0,L.jsx)(re,{data:dn(t),label:`application/ld+json · ${e.path}`})]})]})}function Sn({target:e,revision:t,readerName:n}){let r=pn(e,t);return r.state===`loading`?(0,L.jsxs)(`p`,{className:`structure-note`,children:[`Reading `,e.page.path,` as served…`]}):r.state===`error`?(0,L.jsx)(`p`,{className:`structure-note structure-note--error`,children:r.message}):r.data.state===`unserved`?(0,L.jsx)(O,{icon:lt,title:`The page could not be read as served`,children:r.data.reason}):(0,L.jsx)(xn,{page:e.page,served:r.data.served,graph:r.data.graph,readerName:n},`${e.page.collection}/${e.page.slug}`)}function Cn({findings:e,configs:t,siteTypes:n,revision:r}){let[i,a]=gn(e.pages),o=t=>e.readers.find(e=>e.id===t)?.name??t,s=(0,j.useMemo)(()=>i?{page:i,configs:t,siteTypes:n}:null,[i,t,n]);return!i||!s?(0,L.jsx)(O,{icon:Je,title:`No live pages yet`,children:`The graph is read from the pages the site serves. Publish a page to see its graph.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`structure-tab-lead`,children:`A live page's graph as the site serves it, in the default locale. Each node's values carry their source; its rich results follow the search engines' rules.`}),(0,L.jsx)(_n,{pages:e.pages,value:K(i),onChange:a}),(0,L.jsx)(Sn,{target:s,revision:r,readerName:o})]})}function wn({base:e,state:t}){let n=e.configs.state===`ok`?e.configs.value:[],r=(0,j.useMemo)(()=>Tt(e.catalog),[e.catalog]),{findings:i}=t;return i.state===`loading`?(0,L.jsx)(`p`,{className:`structure-note`,children:`Reading the live pages…`}):i.state===`error`?(0,L.jsx)(`p`,{className:`structure-note structure-note--error`,children:i.message}):(0,L.jsx)(Cn,{findings:i.data,configs:n,siteTypes:r,revision:t.revision})}var q=`google`;function Tn(e){return{collection:e.collection,slug:e.slug,path:e.path}}function En(e,t){return e.find(e=>e.id===t)?.name??t}function Dn(e,t){return{pages:new Map,card:{key:`${e.reader}:${e.feature}`,reader:e.reader,readerName:En(t,e.reader),feature:e.feature,status:e.status,applicable:0,eligible:0,missing:[],conditions:[...e.conditions],source:e.source,types:[e.type]}}}function On(e,t,n,r){let i=r.has(t.type);for(let r of t.missing){let a=e.missing.find(e=>e.property===r&&e.type===t.type);if(!a){let o=i?x(`site`):D(n.collection,n.slug);a={property:r,type:t.type,pages:[],fix:o,site:i},e.missing.push(a)}a.pages.some(e=>e.collection===n.collection&&e.slug===n.slug)||a.pages.push(Tn(n))}}function kn(e,t,n){let r=new Map;for(let i of e)for(let e of i.features){let a=`${e.reader}:${e.feature}`,o=r.get(a)??Dn(e,t);r.set(a,o),o.card.types.includes(e.type)||o.card.types.push(e.type);let s=`${i.collection}/${i.slug}`;o.pages.set(s,(o.pages.get(s)??!1)||e.eligible),On(o.card,e,i,n)}return r}function An(e,t,n){if(n.some(e=>e.id===q))for(let r of t){let t=r.richResultStatus;if(!r.richResult||t!==`active`&&t!==`restricted`)continue;let i=`${q}:${r.richResult}`,a=e.get(i);if(a){a.pages.size===0&&!a.card.types.includes(r.type)&&a.card.types.push(r.type);continue}let o={reader:q,feature:r.richResult,type:r.type,status:t,eligible:!1,missing:[],conditions:[],source:r.docsUrl};e.set(i,Dn(o,n))}}function jn(e,t,n,r=[]){let i=kn(e,t,n);An(i,r,t);let a=e=>{let n=t.findIndex(t=>t.id===e.reader);return n<0?t.length:n},o=e=>+(e.applicable===0);return[...i.values()].map(({card:e,pages:t})=>({...e,applicable:t.size,eligible:[...t.values()].filter(Boolean).length})).sort((e,t)=>a(e)-a(t)||o(e)-o(t)||e.feature.localeCompare(t.feature))}function Mn(e){return e.reduce((e,t)=>({eligible:e.eligible+t.eligible,applicable:e.applicable+t.applicable}),{eligible:0,applicable:0})}function Nn(e){return e.status===`restricted`?`conditional`:e.applicable===0?`unused`:e.eligible===e.applicable?`eligible`:e.eligible===0?`not-eligible`:`partly`}function Pn(e){return e?.configs.state===`ok`?V(e.configs.value,`site`)?.config.entities.length??0:null}function Fn(e,t){let n=Pn(e);if(t.state!==`ready`)return{graphs:null,siteEntities:n,rich:null};let{pages:r,readers:i}=t.data,a=jn(r,i,Et(e?.catalog??{state:`failed`}));return{graphs:{valid:r.filter(v).length,pages:r.length},siteEntities:n,rich:Mn(a)}}function In(e){return e.catalog.state===`ok`?e.catalog.value:null}var Ln={eligible:{label:`Eligible`,tone:`success`,icon:Ke},partly:{label:`Partly eligible`,tone:`warning`,icon:m},"not-eligible":{label:`Not eligible`,tone:`danger`,icon:de},conditional:{label:`Shown on conditions`,tone:`neutral`,icon:ue},unused:{label:`Not used yet`,tone:`neutral`,icon:st}};function Rn(e){let t=e.pages.slice(0,3).map(e=>e.path),n=e.pages.length-t.length;return`${t.join(`, `)}${n>0?` and ${n} more`:``}`}function zn({line:e,feature:t}){let n=e.site?`in Site entities`:`on ${e.pages[0]?.path??`the page`}`;return(0,L.jsxs)(`li`,{className:`structure-missing`,children:[(0,L.jsxs)(`span`,{className:`structure-missing-text`,children:[(0,L.jsxs)(`code`,{children:[e.type,`.`,e.property]}),` `,`missing on `,e.pages.length,` page`,e.pages.length===1?``:`s`,`: `,Rn(e),e.site&&` — a site entity, so one value fixes every page`]}),(0,L.jsxs)(a,{to:e.fix,className:l(`secondary`,`sm`),children:[(0,L.jsx)(pt,{className:`ui-button-icon`,"aria-hidden":`true`}),`Fix`,` `,(0,L.jsxs)(`span`,{className:`visually-hidden`,children:[t,`: `,e.property,` `,n]})]})]})}function Bn({card:e}){if(e.applicable===0){let t=e.types.length>0?` (${e.types.join(` or `)})`:``;return(0,L.jsxs)(`p`,{className:`structure-note`,children:[`No page of this site is of this type yet`,t,`.`]})}return e.missing.length===0?(0,L.jsx)(`p`,{className:`structure-note`,children:`Nothing is missing.`}):(0,L.jsx)(`ul`,{className:`structure-missing-list`,"aria-label":`What ${e.feature} is missing`,children:e.missing.map(t=>(0,L.jsx)(zn,{line:t,feature:e.feature},`${t.type}.${t.property}`))})}function Vn({card:e}){let t=(0,j.useId)(),n=Ln[Nn(e)];return(0,L.jsxs)(`section`,{className:`structure-card structure-rich-card`,"aria-labelledby":t,children:[(0,L.jsxs)(`div`,{className:`structure-card-head`,children:[(0,L.jsxs)(`h3`,{id:t,className:`structure-card-title`,children:[e.feature,` `,(0,L.jsxs)(`span`,{className:`structure-card-sub`,children:[`· `,e.readerName]})]}),(0,L.jsx)(E,{tone:n.tone,icon:n.icon,children:n.label})]}),(0,L.jsxs)(`p`,{className:`structure-rich-count`,children:[(0,L.jsxs)(`span`,{className:`structure-figure-value`,children:[e.eligible,` / `,e.applicable]}),` `,`live page`,e.applicable===1?``:`s`,` eligible`,e.status===`restricted`&&`: shown only under the rule's conditions`]}),e.conditions.map(e=>(0,L.jsxs)(`p`,{className:`structure-note`,children:[`Condition: `,e,`.`]},e)),(0,L.jsx)(Bn,{card:e}),(0,L.jsxs)(`a`,{href:e.source,target:`_blank`,rel:`noreferrer`,className:`structure-link`,children:[e.readerName,`'s rule`,(0,L.jsx)(g,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]})]})}function Hn({base:e,state:t}){let{findings:n}=t,r=(0,j.useMemo)(()=>Et(e.catalog),[e.catalog]),i=In(e),a=(0,j.useMemo)(()=>n.state===`ready`?jn(n.data.pages,n.data.readers,r,i?.types):[],[n,r,i]);return n.state===`loading`?(0,L.jsx)(`p`,{className:`structure-note`,children:`Reading the live pages…`}):n.state===`error`?(0,L.jsx)(`p`,{className:`structure-note structure-note--error`,children:n.message}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`structure-tab-lead`,children:`The features the search engines still show, by their own rules, checked on every live page in the default locale. A page is eligible when its entity has everything the rule requires.`}),a.length===0?(0,L.jsx)(O,{icon:y,title:`No rich result to show`,children:`The search engines' rules, as krantho reads them, list no feature they still show.`}):(0,L.jsx)(`div`,{className:`structure-rich-grid`,children:a.map(e=>(0,L.jsx)(Vn,{card:e},e.key))})]})}var Un=e=>e.map(e=>`${e.entityType}.${e.property}`).join(`, `);function Wn({doc:e,collection:t}){return(0,L.jsxs)(`li`,{children:[(0,L.jsx)(a,{to:D(t,e.slug),className:`structure-link`,children:e.title||e.slug}),e.orphanedProperties.length>0&&(0,L.jsxs)(`span`,{children:[` · unused: `,Un(e.orphanedProperties)]}),e.missingRequired.length>0&&(0,L.jsxs)(`span`,{children:[` · missing: `,Un(e.missingRequired)]})]})}function Gn({impact:e,collection:t}){if(e.affectedDocuments.length===0)return(0,L.jsx)(`p`,{children:`No page of the collection would lose a value or lack a required one.`});let{summary:n}=e;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{children:[`Of `,e.totalDocuments,` pages, `,n.documentsWithOrphans,` would keep values no chosen type reads, and `,n.documentsWithMissingRequired,` would lack values a chosen type requires:`]}),(0,L.jsx)(`ul`,{className:`structure-impact-list`,children:e.affectedDocuments.map(e=>(0,L.jsx)(Wn,{doc:e,collection:t},e.slug))})]})}function Kn({impact:e,collection:t}){return(0,L.jsxs)(`div`,{className:`structure-impact`,"aria-live":`polite`,children:[(0,L.jsx)(`h3`,{className:`structure-label`,children:`What the change does to the pages`}),e.state===`idle`&&(0,L.jsx)(`p`,{children:`Change the types to see which pages it touches.`}),e.state===`reading`&&(0,L.jsx)(`p`,{children:`Checking the collection's pages…`}),e.state===`error`&&(0,L.jsx)(`p`,{children:`The impact could not be read.`}),e.state===`ready`&&(0,L.jsx)(Gn,{impact:e.impact,collection:t})]})}function qn(e){if(e.state!==`ok`)return null;let t=e.value;return{siteEntities:V(t,`site`)?.config.entities.length??0,collections:H(t,`collection`).length,routes:H(t,`route`).length,documents:H(t,`document`).length}}function Jn(e){let t=e=>e||null;return[{label:`Name`,value:e.name,setting:`site.name`},{label:`Domain`,value:e.domain,setting:`site.domain`},{label:`Base URL`,value:e.baseUrl,setting:`site.baseUrl`},{label:`Language`,value:e.language,setting:`site.language`},{label:`Description`,value:t(e.description),setting:`site.description`},{label:`Alternate name`,value:t(e.alternateName),setting:`site.alternateName`},{label:`Logo`,value:t(e.logo),setting:`site.logo`},{label:`Profiles elsewhere`,value:e.sameAs.length>0?e.sameAs.join(`, `):null,setting:`site.sameAs`}]}var J=`The stored settings could not be read; reload before changing them.`;function Y(e,t){return e.state===`ok`?{state:`read`,config:V(e.value,t)?.config??null}:{state:`unread`}}function Yn(e,t){return e.filter(e=>e.pages).map(e=>{let n=Y(t,`collection:${e.name}`);return{collection:e,stored:n,types:n.state===`read`?n.config?.entities.map(e=>e[`@type`])??[]:null}})}function Xn(e,t){let n=e?.entities??[],r=t.map(e=>n.find(t=>t[`@type`]===e)??{"@type":e,properties:{}});return{...e??{},entities:r}}function Zn(e,t){let n=[];for(let r of t){let t=n.find(e=>e.category===r.category);t||(t={category:r.category,label:e.categories[r.category]??r.category,types:[]},n.push(t)),t.types.push(r)}return n}function Qn(e){return Zn(e,e.types.filter(e=>e.richResultStatus!==`retired`))}function $n(e,t){return Zn(e,e.types.filter(e=>e.documentLevel&&Ze(e,t.has(e.type))))}function er(e,t,n){let[r,i]=(0,j.useState)({state:`idle`}),a=t.join(`,`);return(0,j.useEffect)(()=>{if(!n||a===``){i({state:`idle`});return}let t=!0;return i({state:`reading`}),Ae(e,a).then(e=>t&&i({state:`ready`,impact:e}),()=>t&&i({state:`error`})),()=>{t=!1}},[e,a,n]),r}var tr=new Set([`status`,`locale`,`slug`,`version`,`source`,`changedBy`,`createdAt`,`updatedAt`]);function nr(e){let[t,n]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let t=!0;return He(e).then(e=>{let r=Object.keys(e.schema.properties??{});t&&n(r.filter(e=>!tr.has(e)))},()=>t&&n(null)),()=>{t=!1}},[e]),t}function rr(e){let t=Qe(e);if(t===`retired`)return`No longer shown in search results`;let n=e.richResult??`No search feature`;return t?`${n} · ${t}`:n}function ir(e){let{type:t}=e;return(0,L.jsxs)(`div`,{className:`structure-type-option`,children:[(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:e.checked,onChange:()=>e.onToggle(t.type)}),(0,L.jsx)(`span`,{className:`structure-type-name`,children:t.label}),(0,L.jsx)(`span`,{className:`structure-type-rich`,children:rr(t)})]}),t.docsUrl&&(0,L.jsxs)(`a`,{href:t.docsUrl,target:`_blank`,rel:`noreferrer`,className:`structure-link`,children:[`Docs`,(0,L.jsx)(g,{"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`visually-hidden`,children:[` for `,t.label,` (opens in a new tab)`]})]})]})}function ar(e){return(0,L.jsx)(`div`,{className:`structure-type-picker`,children:$n(e.catalog,e.chosen).map(t=>(0,L.jsxs)(`fieldset`,{className:`structure-type-group`,children:[(0,L.jsx)(`legend`,{children:t.label}),t.types.map(t=>(0,L.jsx)(ir,{type:t,checked:e.chosen.has(t.type),onToggle:e.onToggle},t.type))]},t.category))})}function or(e){let[t,n]=(0,j.useState)(()=>new Set(e)),r=[...t],i=r.length!==e.length||r.some(t=>!e.includes(t));function a(e){n(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})}return{chosen:t,types:r,changed:i,toggle:a}}function sr(e){let[t,n]=(0,j.useState)(!1),r=w(),i=e.row.collection.name;async function a(t){let{stored:a}=e.row;if(a.state!==`read`){r({text:J,tone:`error`});return}n(!0);try{await xe(`collection:${i}`,Xn(a.config,t));let n=c(i);r({text:`${n}'s archetype saved. Its pages' structured data has changed.`}),e.onSaved(),e.onClose()}catch(e){r({text:T(e,`The archetype could not be saved`),tone:`error`}),n(!1)}}return{saving:t,save:e=>void a(e)}}function cr(e){let t=e.row.collection.name,{chosen:n,types:r,changed:i,toggle:a}=or(e.row.types??[]),{saving:o,save:s}=sr(e),l=er(t,r,i),d=nr(t),f=o?`Saving…`:i?null:`Change the types first.`,p=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{onClick:e.onClose,children:`Cancel`}),(0,L.jsx)(k,{variant:`primary`,reason:f,onClick:()=>s(r),children:o?`Saving…`:`Save`})]});return(0,L.jsxs)(C,{title:`Change ${c(t)}'s archetype`,onClose:e.onClose,busy:o,actions:p,children:[(0,L.jsxs)(`p`,{className:`structure-modal-lead`,children:[`The Schema.org types every page of `,c(t),` states. They are saved to the collection's SEO settings, which have no versions: its pages' structured data changes at once. A page's own settings still win.`]}),d&&d.length>0&&(0,L.jsxs)(`p`,{className:`structure-note`,children:[`The types' properties can be filled from its fields: `,d.join(`, `),`.`]}),(0,L.jsx)(ar,{catalog:e.catalog,chosen:n,onToggle:a}),(0,L.jsx)(Kn,{impact:l,collection:t})]})}var X=(e,t,n)=>`${e} ${e===1?t:n}`,lr=[{id:`site`,title:`Site`,says:`Who the site is`,icon:ee,count:e=>X(e.siteEntities,`site entity`,`site entities`)},{id:`collection`,title:`Collection`,says:`What kind of page`,icon:_e,count:e=>X(e.collections,`collection archetype`,`collection archetypes`)},{id:`route`,title:`URL pattern`,says:`Overrides by route`,icon:ce,count:e=>X(e.routes,`URL pattern`,`URL patterns`)},{id:`document`,title:`Document`,says:`One page's own say, which wins over everything above`,icon:_,count:e=>X(e.documents,`page with its own settings`,`pages with their own settings`)}],ur=e=>`cascade-${e}`,Z=e=>`scope-${e}`;function dr({step:e,next:t,counts:n}){let r=e.icon;return(0,L.jsxs)(`li`,{id:ur(e.id),className:`structure-cascade-step`,children:[(0,L.jsx)(`span`,{className:`structure-cascade-icon`,"aria-hidden":`true`,children:(0,L.jsx)(r,{})}),(0,L.jsx)(`span`,{className:`structure-cascade-title`,children:(0,L.jsx)(`a`,{href:`#${Z(e.id)}`,className:`structure-link`,children:e.title})}),(0,L.jsx)(`span`,{className:`structure-cascade-says`,children:e.says}),(0,L.jsx)(`span`,{className:`structure-cascade-count`,children:n?e.count(n):`Not read`}),t&&(0,L.jsxs)(`a`,{href:`#${ur(t.id)}`,className:`structure-cascade-next`,children:[(0,L.jsx)(f,{"aria-hidden":`true`}),`Then: `,t.title]})]})}function fr({counts:e}){let t=(0,j.useId)();return(0,L.jsxs)(`section`,{className:`structure-cascade`,"aria-labelledby":t,children:[(0,L.jsx)(`h3`,{id:t,className:`structure-card-title`,children:`Four scopes, the narrowest wins`}),(0,L.jsx)(`ol`,{className:`structure-cascade-steps`,children:lr.map((t,n)=>(0,L.jsx)(dr,{step:t,next:lr[n+1],counts:e},t.id))}),(0,L.jsx)(`p`,{className:`structure-note`,children:`Site and collection are seeded from krantho.config.ts when the site starts; edits made here persist.`})]})}function pr(e,t,n){return e?n.state===`ok`?t?null:`The catalog could not be read.`:J:`Archetypes are changed by an admin.`}function mr(e,t){return[{id:`collection`,header:`Collection`,primary:!0,cell:e=>c(e.collection.name)},{id:`path`,header:`Renders at`,cell:e=>(0,L.jsx)(`code`,{children:We(e.collection)??`—`})},{id:`types`,header:`Schema.org types`,cell:e=>e.types?(0,L.jsx)(z,{types:e.types}):(0,L.jsx)(`span`,{className:`structure-muted`,children:`Not read`})},{id:`change`,header:`Change`,cell:n=>(0,L.jsxs)(k,{size:`sm`,icon:ye,reason:t,onClick:()=>e(n),children:[`Change`,` `,(0,L.jsxs)(`span`,{className:`visually-hidden`,children:[c(n.collection.name),`'s archetype`]})]})}]}function hr(e){let{collections:t,configs:n,catalog:r,admin:i,onSaved:a}=e,[o,s]=(0,j.useState)(null),c=(0,j.useMemo)(()=>Yn(t,n),[t,n]),l=pr(i,r,n);return(0,L.jsxs)(R,{id:Z(`collection`),title:`Collection archetypes`,lead:`What kind of page each collection's documents are. Seeded from krantho.config.ts (seo.collections) when the site starts; a change here persists.`,children:[(0,L.jsx)(at,{caption:`Collection archetypes`,columns:mr(s,l),rows:c,rowKey:e=>e.collection.name}),o&&r&&(0,L.jsx)(cr,{row:o,catalog:r,onClose:()=>s(null),onSaved:a})]})}var gr=(0,j.lazy)(()=>n(()=>import(`./GraphBrowser-DvcHXw-i.js`).then(e=>({default:e.GraphBrowser})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])));function _r({site:e}){return(0,L.jsx)(R,{title:`From krantho.config.ts`,lead:`The site's identity is code: every site entity reads it. Studio shows it; change it where it is set.`,children:(0,L.jsx)(`dl`,{className:`structure-identity`,children:Jn(e).map(e=>(0,L.jsxs)(`div`,{className:`structure-identity-row`,children:[(0,L.jsx)(`dt`,{children:e.label}),(0,L.jsxs)(`dd`,{children:[(0,L.jsxs)(`span`,{className:`structure-identity-value`,children:[(0,L.jsx)(Ge,{"aria-hidden":`true`}),e.value??(0,L.jsx)(`span`,{className:`structure-muted`,children:`Not set`})]}),(0,L.jsxs)(`span`,{className:`structure-identity-where`,children:[`Change it in krantho.config.ts (`,(0,L.jsx)(`code`,{children:e.setting}),`)`]})]})]},e.setting))})})}function vr(e){return{"@context":`https://schema.org`,"@graph":e.entities.map(e=>({"@type":e[`@type`],...e[`@id`]?{"@id":e[`@id`]}:{},...e.properties}))}}function yr(e){let[t,n]=(0,j.useState)(new Map),r=e.entities.map(e=>e[`@type`]).join(`,`);return(0,j.useEffect)(()=>{let e=!0;return Promise.allSettled(r.split(`,`).filter(Boolean).map(Ne)).then(t=>{let r=new Map;for(let e of t)e.status===`fulfilled`&&r.set(e.value.type.type,e.value);e&&n(r)}),()=>{e=!1}},[r]),t}function br(e){let t=w();return(0,j.useCallback)(async n=>{try{await xe(`site`,n),t({text:`Site entities saved. Every page's structured data has changed.`}),e()}catch(e){throw t({text:T(e,`The site entities could not be saved`),tone:`error`}),e}},[t,e])}var xr={entities:[]};function Sr(e,t){return t?J:e?`Kept in the site's SEO settings, which have no versions: Save changes every page's structured data at once.`:`Kept in the site's SEO settings. Changing them is for admins: here they are browsed and exported.`}function Cr({stored:e,catalogTypes:t,admin:n,onSaved:r}){let i=e.state===`read`?e.config??xr:xr,a=e.state!==`read`,o=n&&!a,s=(0,j.useMemo)(()=>vr(i),[i]),c=(0,j.useMemo)(()=>le(s),[s]),l=yr(i),u=(0,j.useMemo)(()=>new Set(i.entities.map(e=>e[`@type`])),[i]),d=br(r);return(0,L.jsx)(R,{title:`Site entities`,lead:Sr(n,a),children:!a&&(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(`p`,{className:`structure-note`,children:`Loading the graph browser…`}),children:(0,L.jsx)(gr,{model:c,catalogTypes:t,catalogDetails:l,rawData:s,configData:o?i:void 0,onSave:o?d:void 0,siteLevelTypeSet:u})})})}function wr(e){let[t,n]=(0,j.useState)({state:`loading`});return(0,j.useEffect)(()=>{let t=!0;return Ne(e).then(e=>t&&n({state:`ready`,detail:e}),()=>t&&n({state:`error`})),()=>{t=!1}},[e]),t}function Tr({detail:e}){return e.properties.length===0?(0,L.jsx)(`p`,{className:`structure-note`,children:`The catalog lists no property for it.`}):(0,L.jsxs)(`table`,{className:`structure-table`,children:[(0,L.jsxs)(`caption`,{className:`visually-hidden`,children:[`The properties of `,e.type.label]}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,children:`Property`}),(0,L.jsx)(`th`,{scope:`col`,children:`Importance`}),(0,L.jsx)(`th`,{scope:`col`,children:`Filled from`})]})}),(0,L.jsx)(`tbody`,{children:e.properties.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(`th`,{scope:`row`,children:[(0,L.jsx)(`code`,{children:e.property}),e.hint&&(0,L.jsxs)(`span`,{className:`structure-muted`,children:[` · `,e.hint]})]}),(0,L.jsx)(`td`,{children:e.importance}),(0,L.jsx)(`td`,{children:e.autoMapField?(0,L.jsx)(`code`,{children:e.autoMapField}):e.source})]},e.property))})]})}var Q=e=>(e??[]).join(`, `);function Er({rule:e}){return(0,L.jsxs)(`li`,{className:`structure-rule`,children:[(0,L.jsx)(`strong`,{children:e.readerName}),` · `,e.feature??`No search feature`,` ·`,` `,e.status===`restricted`?`shown only under conditions`:e.status===`active`?`shown`:`no search feature`,(e.required?.length??0)>0&&(0,L.jsxs)(`span`,{children:[` · requires `,Q(e.required)]}),e.oneOf?.map(e=>(0,L.jsxs)(`span`,{children:[` · one of `,Q(e)]},e.join())),(e.recommended?.length??0)>0&&(0,L.jsxs)(`span`,{children:[` · recommends `,Q(e.recommended)]}),e.conditions?.map(e=>(0,L.jsxs)(`span`,{children:[` · `,e]},e)),` `,(0,L.jsxs)(`a`,{href:e.source,target:`_blank`,rel:`noreferrer`,className:`structure-link`,children:[`Source, verified `,e.verifiedAt,(0,L.jsx)(g,{"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`visually-hidden`,children:` (opens in a new tab)`})]})]})}function Dr({type:e,onClose:t}){let n=wr(e),r=n.state===`ready`?n.detail.rules.filter(e=>e.status!==`retired`):[];return(0,L.jsxs)(C,{title:n.state===`ready`?n.detail.type.label:e,onClose:t,actions:(0,L.jsx)(u,{onClick:t,children:`Close`}),children:[n.state===`loading`&&(0,L.jsx)(`p`,{className:`structure-note`,children:`Reading the type…`}),n.state===`error`&&(0,L.jsx)(`p`,{className:`structure-note`,children:`The type could not be read.`}),n.state===`ready`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`structure-modal-lead`,children:n.detail.type.description}),(0,L.jsx)(`h3`,{className:`structure-label`,children:`Properties`}),(0,L.jsx)(Tr,{detail:n.detail}),(0,L.jsx)(`h3`,{className:`structure-label`,children:`The search engines' rules`}),r.length===0?(0,L.jsx)(`p`,{className:`structure-note`,children:`No active search engine has a rule for it beyond Schema.org.`}):(0,L.jsx)(`ul`,{className:`structure-rules`,children:r.map(e=>(0,L.jsx)(Er,{rule:e},e.reader))})]})]})}function Or(e){return!e.richResult||e.richResultStatus===`none`?`No search feature`:e.richResultStatus===`restricted`?`${e.richResult} · shown only under conditions`:e.richResult}function kr(e){return e.siteLevel&&e.documentLevel?`site or page`:e.siteLevel?`site`:`page`}function Ar({type:e,onDetail:t}){return(0,L.jsxs)(`li`,{className:`structure-catalog-type`,children:[(0,L.jsx)(`span`,{className:`structure-type-name`,children:e.label}),(0,L.jsx)(E,{children:kr(e)}),(0,L.jsx)(`span`,{className:`structure-type-rich`,children:Or(e)}),(0,L.jsxs)(u,{size:`sm`,variant:`ghost`,icon:ge,onClick:()=>t(e.type),children:[`Details `,(0,L.jsxs)(`span`,{className:`visually-hidden`,children:[`of `,e.label]})]})]})}function jr({catalog:e}){let[t,n]=(0,j.useState)(null);return(0,L.jsxs)(R,{id:`scope-catalog`,title:`The catalog`,lead:`The Schema.org types krantho composes, by what they describe; each with the search feature it can appear in by the search engines' rules.`,children:[Qn(e).map(e=>(0,L.jsxs)(`div`,{className:`structure-catalog-group`,children:[(0,L.jsx)(`h4`,{className:`structure-label`,children:e.label}),(0,L.jsx)(`ul`,{className:`structure-catalog-types`,children:e.types.map(e=>(0,L.jsx)(Ar,{type:e,onDetail:n},e.type))})]},e.category)),t&&(0,L.jsx)(Dr,{type:t,onClose:()=>n(null)})]})}var Mr=e=>e.config.entities.map(e=>e[`@type`]);function Nr({configs:e}){let t=H(e,`route`);return(0,L.jsx)(R,{id:Z(`route`),title:`URL patterns`,lead:`Overrides for the pages whose address matches a pattern; the most specific pattern wins. Seeded from krantho.config.ts (seo.routes).`,children:t.length===0?(0,L.jsx)(`p`,{className:`structure-note`,children:`No URL pattern has its own types.`}):(0,L.jsx)(`ul`,{className:`structure-scope-list`,children:t.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`code`,{children:e.id.replace(/^route:/,``)}),(0,L.jsx)(z,{types:Mr(e)})]},e.id))})})}function Pr({configs:e}){let t=H(e,`document`);return(0,L.jsx)(R,{id:Z(`document`),title:`Pages with their own settings`,lead:`One page's own say, which wins over everything above. A page's settings are edited in its Data mode.`,children:t.length===0?(0,L.jsx)(`p`,{className:`structure-note`,children:`No page has settings of its own.`}):(0,L.jsx)(`ul`,{className:`structure-scope-list`,children:t.map(e=>{let[t=``,n=``]=e.id.replace(/^doc:/,``).split(`/`);return(0,L.jsxs)(`li`,{children:[(0,L.jsxs)(a,{to:D(t,n),className:`structure-link`,children:[t,`/`,n]}),(0,L.jsx)(z,{types:Mr(e)})]},e.id)})})})}function Fr({base:e,admin:t,state:n}){let r=e.configs.state===`ok`?e.configs.value:[],i=In(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(fr,{counts:qn(e.configs)}),e.configs.state!==`ok`&&(0,L.jsx)(`p`,{className:`structure-note structure-note--error`,role:`alert`,children:`The SEO settings could not be read. Nothing stored can be changed until they are: reload the page.`}),(0,L.jsxs)(`div`,{id:Z(`site`),className:`structure-stack`,children:[(0,L.jsx)(_r,{site:e.site.site}),(0,L.jsx)(Cr,{stored:Y(e.configs,`site`),catalogTypes:i?.types??[],admin:t,onSaved:n.reloadBase})]}),(0,L.jsx)(hr,{collections:e.collections,configs:e.configs,catalog:i,admin:t,onSaved:n.reloadBase}),(0,L.jsx)(Nr,{configs:r}),(0,L.jsx)(Pr,{configs:r}),i&&(0,L.jsx)(jr,{catalog:i})]})}function Ir(e){return`${e} live page${e===1?``:`s`}`}function Lr({validate:e}){let t=w(),[n,r]=(0,j.useState)(!1);async function i(){r(!0);let n=await e();if(r(!1),!n){t({text:`The live pages' findings could not be read.`,tone:`error`});return}let i=n.pages.filter(v).length;t({text:`Validated ${Ir(n.pages.length)}: ${i} with a valid graph.`})}return(0,L.jsx)(u,{icon:ve,"aria-disabled":n,onClick:n?void 0:()=>void i(),children:n?`Validating…`:`Validate all pages`})}function Rr({fill:e}){return e.state===`running`?(0,L.jsxs)(`p`,{className:`structure-note`,children:[`Filling… `,ze(e.plan,e.step),` (`,Le[e.step],`). Open Fill what's missing to follow it.`]}):null}function zr(e){let t=e.siteName??`the site`;return(0,L.jsxs)(`header`,{className:`structure-header`,children:[(0,L.jsxs)(`div`,{className:`structure-header-text`,children:[(0,L.jsx)(`h1`,{className:`structure-title`,children:`Structure`}),(0,L.jsxs)(`p`,{className:`structure-lead`,children:[`How search engines and AI assistants read `,t,`. Every page carries one connected Schema.org graph — no one writes JSON-LD by hand.`]}),(0,L.jsx)(`div`,{role:`status`,children:(0,L.jsx)(Rr,{fill:e.fill})})]}),(0,L.jsxs)(`div`,{className:`structure-actions`,children:[(0,L.jsx)(Lr,{validate:e.validate}),(0,L.jsx)(k,{variant:`primary`,icon:y,reason:e.onFill?e.fillBlocker:`Reading the site…`,onClick:()=>e.onFill?.(),children:`Fill what's missing`})]})]})}function $({label:e,value:t,detail:n}){return(0,L.jsxs)(`div`,{className:`structure-figure`,children:[(0,L.jsx)(`dt`,{children:e}),(0,L.jsxs)(`dd`,{children:[(0,L.jsx)(`span`,{className:`structure-figure-value`,children:t??`—`}),(0,L.jsx)(`span`,{className:`structure-figure-detail`,children:t===null?`Not read`:n})]})]})}function Br({figures:e}){let{graphs:t,siteEntities:n,rich:r}=e,i=(0,j.useId)();return(0,L.jsxs)(`section`,{className:`structure-intro`,"aria-labelledby":i,children:[(0,L.jsx)(`h2`,{id:i,className:`structure-intro-title`,children:`One graph per page, assembled from four scopes`}),(0,L.jsxs)(`dl`,{className:`structure-figures`,children:[(0,L.jsx)($,{label:`Pages with a valid graph`,value:t?`${t.valid} / ${t.pages}`:null,detail:`Live pages no search engine's rules find an error in`}),(0,L.jsx)($,{label:`Site entities`,value:n===null?null:String(n),detail:`In every page's graph, from the site's SEO settings`}),(0,L.jsx)($,{label:`Eligible rich results`,value:r?`${r.eligible} / ${r.applicable}`:null,detail:`Features of live pages, by the search engines' rules`})]})]})}var Vr=`The live pages' findings could not be read`;function Hr(){let[e,t]=(0,j.useState)({state:`loading`}),n=(0,j.useRef)(!0),r=(0,j.useCallback)(async()=>{try{let e=await wt();return n.current&&t({state:`ready`,data:e}),e}catch(e){return n.current&&t({state:`error`,message:T(e,Vr)}),null}},[]);return(0,j.useEffect)(()=>(n.current=!0,r(),()=>{n.current=!1}),[r]),{findings:e,read:r}}function Ur(){let[e,t]=(0,j.useState)(0),n=(0,j.useCallback)(()=>t(e=>e+1),[]),{loaded:r,reload:i}=h(Ct,`Structure could not be read`),{findings:a,read:o}=Hr();return{base:r,findings:a,validate:(0,j.useCallback)(async()=>{let e=await o();return n(),e},[o,n]),reloadBase:(0,j.useCallback)(()=>{i(),o(),n()},[i,o,n]),revision:e}}var Wr=`fill`;function Gr({tab:e,...t}){switch(e){case`graph`:return(0,L.jsx)(wn,{...t});case`scopes`:return(0,L.jsx)(Fr,{...t});case`rich-results`:return(0,L.jsx)(Hn,{...t});case`crawlers`:return(0,L.jsx)(Mt,{...t})}}function Kr({message:e,onRetry:t}){return(0,L.jsx)(`div`,{role:`alert`,children:(0,L.jsx)(O,{icon:b,title:`Structure could not load`,action:(0,L.jsx)(u,{icon:Pe,onClick:t,children:`Try again`}),children:e})})}function qr(){let[e,t]=i(),[n,r]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{e.get(Wr)!==null&&(r(!0),t(e=>{let t=new URLSearchParams(e);return t.delete(Wr),t},{replace:!0}))},[e,t]),[n,r]}function Jr(e){return e.state===`failed`?{text:`Fill what's missing failed: ${e.message}`,tone:`error`}:{text:`Fill what's missing finished. Open it to see what each step filled.`}}function Yr(e){let t=Be(),n=w(),r=(0,j.useCallback)(e=>Ie(e,e=>n(Jr(e))),[n]),i=t.state===`running`,a=(0,j.useRef)(i);return(0,j.useEffect)(()=>{a.current&&!i&&e(),a.current=i},[i,e]),{run:t,start:r}}function Xr(e){let{tab:t,state:n}=e,r=(0,j.useId)(),i=(0,j.useCallback)(e=>`${r}-tab-${e}`,[r]);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tt,{label:`Structure`,tabs:qe,current:t,tabId:i,panelId:`${r}-panel`}),(0,L.jsxs)(`div`,{id:`${r}-panel`,role:`tabpanel`,"aria-labelledby":i(t),className:`structure-panel`,children:[n.base.state===`loading`&&(0,L.jsx)(`p`,{className:`structure-note`,children:`Reading Structure…`}),n.base.state===`error`&&(0,L.jsx)(Kr,{message:n.base.message,onRetry:n.reloadBase}),n.base.state===`ready`&&(0,L.jsx)(Gr,{tab:t,base:n.base.data,state:n,admin:e.admin})]})]})}function Zr({tab:e}){let t=Ur(),n=o().hasRole(`admin`),[r,i]=qr(),a=Yr(t.reloadBase),s=(0,j.useCallback)(()=>{i(!1),Re()},[i]),c=t.base.state===`ready`?t.base.data:null,l=(0,j.useMemo)(()=>Fn(c,t.findings),[c,t.findings]);return(0,L.jsxs)(`div`,{className:`structure`,"aria-busy":t.base.state===`loading`,children:[(0,L.jsx)(zr,{siteName:c?.site.site.name??null,fill:a.run,validate:t.validate,onFill:c?()=>i(!0):null,fillBlocker:n?null:`Enrichment is run by an admin.`}),(0,L.jsx)(Br,{figures:l}),(0,L.jsx)(Xr,{tab:e,state:t,admin:n}),r&&c&&(0,L.jsx)(Ft,{collections:c.collections.filter(e=>e.pages),admin:n,run:a.run,onStart:a.start,onClose:s})]})}export{Zr as StructurePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-D_HN41p3.js";var t={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};t.node;var n=e(t);export{n as t};
|