@blinkk/root-cms 3.0.1 → 3.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/ui/ui.js CHANGED
@@ -457,7 +457,7 @@ ${t.textContent}${r}
457
457
  ~~~`}return`${e}
458
458
  URL: ${t.url}
459
459
 
460
- [The file was uploaded, but its binary content was not inlined into this chat message.]`}async function jer(t,e){if(!Ger(t.name,e))return null;let r=await t.text();return r.length<=git?{text:r,truncated:!1}:{text:r.slice(0,git),truncated:!0}}function Ger(t,e){return e.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(r=>t.toLowerCase().endsWith(r))}function Wer(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".webp")?"image/webp":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".svg")?"image/svg+xml":e.endsWith(".pdf")?"application/pdf":e.endsWith(".json")?"application/json":e.endsWith(".csv")?"text/csv":e.endsWith(".md")?"text/markdown":e.endsWith(".txt")?"text/plain":"application/octet-stream"}function qer(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var H3,yit,bit,U3,git,zle=x(()=>{"use strict";dit();dX();Ve();zt();RB();PX();Ee();Fs();Sr();Tf();Xo();hit();RL();LC();bX();q();H3=[{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"suggest",label:"Suggest changes",description:"Research and propose edits without calling write tools."},{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],yit="root-cms.ai.executionMode",bit="root-cms.ai.selectedModel";U3="";git=1e5});function cr(t){$(()=>{let e=window.__ROOT_CTX?.rootConfig,r=e?.projectName||"Root CMS",o=e?.minimalBranding?r:`${r} \u2013 Root CMS`;document.title=t?`${t} \u2013 ${o}`:o},[t])}var Sn=x(()=>{"use strict";Ee()});var $le,xit=x(()=>{$le={name:"@blinkk/root-cms",version:"3.0.1",author:"s@blinkk.com",license:"MIT",engines:{node:">=16.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./client":{types:"./dist/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"tsup-node --config=./core/tsup.config.ts","//":"NOTE: esbuild is used here because tsup doesn't currently support aliases.","build:ui":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177",ai:"6.0.175",zod:"4.4.3","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@types/cli-progress":"3.11.6","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","@mantine/spotlight":"4.2.12","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.6","@vitest/browser-playwright":"4.1.6",concurrently:"7.6.0",esbuild:"0.25.9",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.56.1",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",tsup:"8.5.0",typescript:"5.9.2",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.0.1","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}}});function _it(){return d("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d("g",{"clip-path":"url(#clip0_1_318)",children:[d("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),d("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),d("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),d("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),d("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),d("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),d("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),d("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),d("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),d("defs",{children:d("clipPath",{id:"clip0_1_318",children:d("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var wit=x(()=>{"use strict";q()});var Cit=x(()=>{});function Sit(t){let[e,r]=R(!1);$(()=>{let n=navigator.userAgentData?.platform??navigator.platform;r(/mac/i.test(n||""))},[]);let o=()=>{oee()};return d("button",{type:"button",className:me("SearchBar",t.className),onClick:o,"aria-label":"Open search",children:[d(Ka,{className:"SearchBar__icon",size:16,stroke:1.5}),d("span",{className:"SearchBar__placeholder",children:"Search"}),d("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var Iit=x(()=>{"use strict";Cit();iee();zt();Ee();Sr();q()});var Tit=x(()=>{});function ht(t){return d("div",{className:"Layout",children:[d(ht.Top,{}),d(ht.Side,{}),d(ht.Main,{...t,children:t.children}),d(ht.Bottom,{})]})}function Yer(t){let r=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return r.length===4&&r[0]==="cms"&&r[1]==="content"}var np,In=x(()=>{"use strict";Ve();zt();Fs();xit();wit();Iit();Sr();Tit();q();np="1.5";ht.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,r=t.minimalBranding,{url:o}=Fo(),n=!Yer(o);return d("div",{className:"Layout__top",children:[r?d(Ie,{children:[d("a",{className:"Layout__top__logo",href:"/cms",children:e}),d("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",$le.version]})]}):d(Ie,{children:[d("a",{className:"Layout__top__logo",href:"/cms",children:d(_it,{})}),d("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",$le.version]}),d("div",{className:"Layout__top__project",children:e})]}),n&&d("div",{className:"Layout__top__search",children:d(Sit,{})})]})};ht.Side=()=>{let{url:t}=Fo(),e=t.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),i=l=>n.has(l),a=window.__ROOT_CTX.experiments||{},s=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return d("div",{className:"Layout__side",children:[d("div",{className:"Layout__side__buttons",children:[!i("home")&&d(ht.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:d(JW,{stroke:np})}),!i("content")&&d(ht.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:d(Jp,{stroke:np})}),a.taskManager&&d(ht.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:d(AW,{stroke:np})}),!i("releases")&&d(ht.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:d(ed,{stroke:np})}),!i("data")&&d(ht.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:d(p0,{stroke:np})}),!i("assets")&&d(ht.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:d(g1,{stroke:np})}),!i("translations")&&d(ht.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:d(mf,{stroke:np})}),(a.ai||window.__ROOT_CTX.ai)&&!i("ai")&&d(ht.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:d(hs,{stroke:np})}),o&&d(Ie,{children:[d("div",{className:"Layout__side__divider"}),Object.entries(o).map(([l,c])=>{let u=c.cmsUrl?.startsWith("/cms/")?c.cmsUrl:void 0,f=c.externalUrl,p=f??u??`/cms/tools/${l}`,h=f?void 0:p.replace(/\/*$/g,""),m=!f&&!!h&&(e===h||e.startsWith(`${h}/`));return d(ht.SideButton,{className:"Layout__side__tool",label:c.label||"",url:p,active:m,external:!!f,children:c.icon?d("img",{className:"Layout__side__tool__icon",src:c.icon,alt:c.label||""}):d(EW,{stroke:np})},l)}),d("div",{className:"Layout__side__divider"})]}),!i("settings")&&d(ht.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:d(nb,{stroke:np})})]}),d("div",{className:"Layout__side__user",children:d(ke,{shadow:"md",position:"right",control:d(xm,{children:d(Pm,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})}),children:[d(ke.Label,{children:d(Jt,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",r.email]})}),d(fa,{}),d(ke.Item,{color:"red",icon:d(s7,{style:{width:14,height:14}}),onClick:s,children:"Sign out"})]})})]})};ht.SideButton=t=>d(_e,{className:me("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:d("a",{className:me(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});ht.Main=t=>d("div",{className:"Layout__main",children:t.children});ht.Bottom=()=>d("div",{className:"Layout__bottom"})});var Eit={};yt(Eit,{AIPage:()=>Zer});function Zer(t){return cr("AI"),d(ht,{children:d(j3,{variant:"page",initialChatId:t.chatId})})}var kit=x(()=>{"use strict";zle();Sn();In();q()});var Pit=x(()=>{});function Rit(t){let[e,r]=R(t.value||null),[o,n]=R(null);t.value!==void 0&&t.value!==e&&r(t.value);let i=s=>{r(s),t.onChange&&t.onChange(s)},a={type:"file",label:""};return d("div",{className:me("FileUploader",t.className),children:d(vre,{field:t.field||a,value:e,setValue:i,loadingState:o,setLoadingState:n,variant:t.variant,showNamingOptions:t.showNamingOptions,accept:t.accept,allowEditing:t.allowEditing})})}var Dit=x(()=>{"use strict";Pit();Ee();Sr();qz();q()});var Ait=x(()=>{});function Mr(t){return d("div",{className:me(t.className,"Surface"),children:t.children})}var Hl=x(()=>{"use strict";Ait();Sr();q()});var Oit=x(()=>{});var Mit={};yt(Mit,{AssetsPage:()=>Jer});function Jer(){cr("Assets");let[t,e]=R(null),r=t?.gcsPath?`https://storage.googleapis.com${t.gcsPath}`:"";return d(ht,{children:d("div",{className:"AssetsPage","data-testid":"assets-page",children:[d("div",{className:"AssetsPage__header",children:[d(Vt,{size:"h1",children:"Assets"}),d(ft,{as:"p",children:"Upload assets to the project's GCS bucket."})]}),d(Mr,{className:"AssetsPage__content",children:[d(Rit,{value:t,onChange:e,showNamingOptions:!0,accept:["*/*"],allowEditing:!1,className:"AssetsPage__uploader"}),t&&r&&d("div",{className:"AssetsPage__urlGroup",children:[d(Vle,{label:"GCS URL",url:r}),d(Vle,{label:"Google Image Service URL",url:t.src})]}),t&&!r&&d("div",{className:"AssetsPage__urlGroup",children:d(Vle,{url:t.src})}),t&&d(J,{variant:"outline",fullWidth:!0,onClick:()=>e(null),mt:"md",children:"Upload another file"})]})]})})}function Vle(t){return d("div",{className:"AssetsPage__urlRow",children:[t.label&&d("div",{className:"AssetsPage__urlRow__label",children:t.label}),d("div",{className:"AssetsPage__urlRow__input",children:[d(Fr,{readOnly:!0,value:t.url,autosize:!0,minRows:1,size:"xs",radius:"xs",onClick:e=>e.target.select(),styles:{root:{flex:1,minWidth:0}}}),d(Xer,{url:t.url})]})]})}function Xer(t){let[e,r]=R(!1);return d(_e,{label:e?"Copied!":"Copy URL",position:"top",withArrow:!0,children:d(Ae,{variant:"default",size:"lg",onClick:()=>{navigator.clipboard.writeText(t.url).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})},children:d(dc,{size:16})})})}var Nit=x(()=>{"use strict";Ve();zt();Ee();Dit();Oi();Hl();mi();Sn();In();Oit();q()});var Fit=x(()=>{});var Lit=x(()=>{});function Bit(t){let e={},r=[],o={};if(Object.entries(t).forEach(([a,s])=>{e[a]={id:a,name:s.name||a,description:s.description,isGroup:!1,collection:s,children:[]}}),Object.entries(t).forEach(([a,s])=>{let l=e[a],c=s.group||"Content";c?(o[c]||(o[c]={id:`group:${c}`,name:c,isGroup:!0,children:[]}),o[c].children.push(l)):r.push(l)}),Object.keys(o).length>0&&r.length>0){let a={id:"group:Content",name:"Content",isGroup:!0,children:r},s=Object.values(o).sort((l,c)=>l.name.localeCompare(c.name));return[a,...s]}Object.values(o).forEach(a=>{r.push(a)});let i=a=>{a.sort((s,l)=>s.name.localeCompare(l.name)),a.forEach(s=>{s.children.length>0&&i(s.children)})};return i(r),r}var zit=x(()=>{"use strict"});function G3(t){let{collections:e,activeCollectionId:r,projectId:o}=t,[n,i]=ln(`root-cms::${o}::closed_groups`,[]),a=X(()=>Bit(e),[]),s=(l,c)=>{c?i(n.filter(u=>u!==l)):n.includes(l)||i([...n,l])};return d("div",{className:me(t.className,"CollectionTree"),children:[a.map(l=>d(Vit,{node:l,depth:0,activeCollectionId:r,closedGroups:n,onAccordionChange:s},l.id)),a.length===0&&d("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function Vit(t){let{node:e,depth:r,activeCollectionId:o,closedGroups:n,onAccordionChange:i}=t,a=e.children.length>0;return e.isGroup?a?d($it,{node:e,depth:r,activeCollectionId:o,closedGroups:n,onAccordionChange:i,label:d("div",{className:"CollectionTree__group__label",children:d("span",{children:e.name})})}):d("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${r*16}px`},children:[d(Jp,{size:20,strokeWidth:"1.75"}),d("span",{children:e.name})]}):a?d($it,{node:e,depth:r,activeCollectionId:o,closedGroups:n,onAccordionChange:i,label:d("div",{className:"CollectionTree__collection__label",children:d("a",{className:me("CollectionTree__collection-link",e.id===o&&"active"),href:`/cms/content/${e.id}`,onClick:s=>s.stopPropagation(),children:e.name})})}):d("a",{className:me("CollectionTree__collection",e.id===o&&"active"),href:`/cms/content/${e.id}`,children:[d("div",{className:"CollectionTree__collection__icon",children:d(Jp,{size:20,strokeWidth:"1.75"})}),d("div",{className:"CollectionTree__collection__content",children:[d("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&d("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function $it(t){let{node:e,depth:r,label:o,activeCollectionId:n,closedGroups:i,onAccordionChange:a}=t,s=!i.includes(e.id);return d("div",{className:"CollectionTree__accordion",children:d(ca,{iconPosition:"left",initialItem:s?0:-1,offsetIcon:!1,onChange:()=>a(e.id,!s),children:d(ca.Item,{label:o,children:d("div",{className:"CollectionTree__accordion__children",children:e.children.map(l=>d(Vit,{node:l,depth:r+1,activeCollectionId:n,closedGroups:i,onAccordionChange:a},l.id))})})})})}var Ule=x(()=>{"use strict";Lit();Ve();zt();Ee();yh();Sr();zit();q()});var Uit={};yt(Uit,{CollectionPage:()=>cD});function cD(t){let{route:e}=Fo(),r=window.__ROOT_CTX.rootConfig.projectId;cr(t.collection?t.collection:"Content"),$(()=>{let n=window.__ROOT_CTX.collections,i=`root-cms::${r}::last_collection`;if(t.collection)window.localStorage.setItem(i,t.collection);else{let a=window.localStorage.getItem(i);if(a&&n[a]){e(`/cms/content/${a}`);return}if(window.__ROOT_CTX.collections.Pages){e("/cms/content/Pages");return}let s=Object.keys(window.__ROOT_CTX.collections)||[];if(s.length>0){let l=s[0];e(`/cms/content/${l}`);return}console.warn("no collections")}},[t.collection,r]);let o=window.__ROOT_CTX.collections;return d(ht,{children:d("div",{className:"CollectionPage",children:d("div",{className:"CollectionPage__layout",children:[d("div",{className:"CollectionPage__side",children:d(G3,{collections:o,activeCollectionId:t.collection,projectId:r})}),d("div",{className:"CollectionPage__main",children:t.collection&&d(cD.Collection,{collection:t.collection},t.collection)})]})})})}var Hit=x(()=>{"use strict";Fit();Ve();zt();Ee();Fs();Ule();dd();Cte();t1();yL();jQ();Hl();zQ();yh();Sn();El();In();x4();Xo();Ic();q();cD.Collection=t=>{let{roles:e}=cn(),r=window.firebase.user.email||"",o=Nf(e,r),[n,i]=ln(`root::CollectionPage:${t.collection}:orderBy`,"modifiedAt"),[a,s]=ln(`root::CollectionPage:${t.collection}:showArchived`,!1),[l,c]=R(!1),u=window.__ROOT_CTX.collections[t.collection];if(!u)return route("/cms/content"),d(Ie,{});let f=[{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"},...u.sortOptions?.map(g=>({value:g.id,label:g.label}))||[]],[p,h,m]=T4(t.collection,{orderBy:n,includeArchived:a});return d(Ie,{children:[d(R4,{collection:t.collection,opened:l,onClose:()=>c(!1)}),d("div",{className:"CollectionPage__collection",children:d("div",{className:"CollectionPage__collection__docsTab",children:[!p&&d("div",{className:"CollectionPage__collection__docsTab__header",children:[d("div",{className:"CollectionPage__collection__docsTab__header__title",children:u.name||t.collection}),d("div",{className:"CollectionPage__collection__docsTab__controls",children:[d("div",{className:"CollectionPage__collection__docsTab__controls__showArchived",children:d(Mm,{size:"sm",color:"dark",label:"Show archived:",checked:a,onChange:g=>s(!!g.currentTarget.checked)})}),d("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[d("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),d(Lr,{size:"xs",value:n,onChange:g=>i(g||"modifiedAt"),data:f})]}),d("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:d(wn,{label:"You don't have access to create new documents",condition:!o,children:d(J,{color:"dark",size:"xs",leftIcon:d(f0,{size:16}),onClick:()=>c(!0),disabled:!o,children:"New"})})})]})]}),d(Mr,{className:"CollectionPage__collection__docsTab__content",children:p?d("div",{className:"CollectionPage__collection__docsTab__content__loading",children:d(gt,{color:"gray",size:"xl"})}):m.length===0?d("div",{class:"CollectionPage__collection__docsEmpty",children:[d("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),d("div",{class:"CollectionPage__collection__docsEmpty__button",children:d(wn,{label:"You don't have access to create new documents",condition:!o,children:d(J,{color:"dark",size:"xs",leftIcon:d(f0,{size:16}),onClick:()=>c(!0),disabled:!o,children:"New"})})})]}):d(cD.DocsList,{collection:t.collection,docs:m,reloadDocs:()=>h()})})]})})]})};cD.DocsList=t=>{let e=t.collection,r=window.__ROOT_CTX.collections[t.collection];if(!r)throw new Error(`could not find collection: ${e}`);let o=!!r.url,n=t.docs||[];function i(a){return o?dP({collectionId:e,slug:a}):""}return d("div",{className:"CollectionPage__collection__docsList",children:n.map(a=>{let s=`/cms/content/${e}/${a.slug}`,l=i(a.slug),c=a.fields||{},u=ti(c,r.preview?.title||"meta.title"),f=ti(c,r.preview?.image||"meta.image")||r.preview?.defaultImage;return d("div",{className:"CollectionPage__collection__docsList__doc",children:[d("div",{className:"CollectionPage__collection__docsList__doc__image",children:d("a",{href:s,children:d(c0,{file:f,width:120,height:90,withPlaceholder:!f?.src})})}),d("a",{className:"CollectionPage__collection__docsList__doc__content",href:s,children:[d("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[d("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:a.id}),d(ig,{doc:a})]}),d("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:u||"[UNTITLED]"}),o&&l&&d("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:l})]}),d("div",{className:"CollectionPage__collection__docsList__doc__controls",children:d(Ez,{docId:a.id,data:a,onAction:p=>{(p.action==="archive"||p.action==="copy"||p.action==="unarchive"||p.action==="delete"||p.action==="unpublish"||p.action==="locked"||p.action==="unlocked")&&t.reloadDocs()}})})]},a.id)})})}});var jit=x(()=>{});var Wit={};yt(Wit,{ComparePage:()=>Qer});function Qer(){let{query:t}=Fo();cr("Compare");let e=X(()=>Git(t.left||""),[t.left]),r=X(()=>Git(t.right||""),[t.right]);return d(ht,{children:d("div",{className:"ComparePage",children:e&&r?d(X4,{className:"ComparePage__diff",left:e,right:r}):d("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function Git(t){let[e,r]=String(t).split("@");return e&&r?{docId:e,versionId:r}:null}var qit=x(()=>{"use strict";jit();Ee();Fs();gee();Sn();In();q()});var Kit=x(()=>{});function Xit(t){let e=t.dataSource;return Zit(e.archivedAt)?d(_e,{...Yit,label:`Archived ${Jit(e.archivedAt)} by ${e.archivedBy}`,children:d(vn,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):Zit(e.publishedAt)?d(_e,{...Yit,label:`Published ${Jit(e.publishedAt)} by ${e.publishedBy}`,children:d(vn,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):d(vn,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function Zit(t){return!!(t&&t.toMillis)}function Jit(t){return t?.toMillis?lc(t.toMillis()):lc(new Date().getTime())}var Yit,Qit=x(()=>{"use strict";Ve();vl();q();Yit={transition:"pop"}});function eat(t){let e=ttr(t.timestamp),[r,o]=R(e>0?lc(e,{style:"short"}):"never");return e?($(()=>{let n=window.setInterval(()=>{o(lc(e,{style:"short"}))},6e4);return()=>window.clearInterval(n)},[]),d(_e,{transition:"pop",label:`${etr(e)} by ${t.email}`,children:lc(e,{style:"short"})})):d("div",{children:r})}function etr(t){return new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ttr(t){return typeof t=="number"?t:t?.toMillis?t.toMillis():0}var tat=x(()=>{"use strict";Ve();Ee();vl();q()});var rat=x(()=>{});function xI(t){let e=t.dataSource,[r,o]=R(!1),[n,i]=R(t.action==="sync"?e.syncedAt:e.publishedAt),[a,s]=R(t.action==="sync"?e.syncedBy:e.publishedBy),l=Of(),{roles:c}=cn(),u=window.firebase.user.email||"",f=wa(c,u),p=t.action==="publish",h=!!e.archivedAt;async function m(){o(!0);let v=`data-source-${t.action}-${e.id}`;ge({id:v,loading:!0,title:`Running Data Source ${t.action}`,message:`Updating ${e.id}...`,autoClose:!1,disallowClose:!0});try{t.action==="sync"?(e.type==="gsheet"&&!l.isLoggedIn()&&await l.login(),await RDe(e.id)):t.action==="publish"&&await DDe(e.id),i(Nt.now()),s(window.firebase.user.email),o(!1),t.onAction&&t.onAction(),xr({id:v,title:"Success",message:`Updated Data Source ${e.id}`,autoClose:!1})}catch(y){console.error(y);let b=y;typeof y=="object"&&y.body&&(b=String(y.body)),o(!1),xr({id:v,title:`Data Source ${t.action} failed`,message:String(b),color:"red",autoClose:!1})}}let g="";return t.action==="sync"?g="Sync data to a draft state":t.action==="publish"&&(g="Publish synced data to prod"),d("div",{className:"DataSourceStatusButton",children:[d("div",{className:"DataSourceStatusButton__label",children:!r&&d(eat,{timestamp:n,email:a})}),d("div",{className:"DataSourceStatusButton__button",children:d(wn,{label:h?"Data source is archived":"You don't have access to publish this data source",condition:h||p&&!f,children:d(_e,{transition:"pop",label:g,disabled:h||p&&!f,children:d(J,{variant:"default",size:"xs",compact:!0,onClick:()=>m(),loading:r,disabled:h||p&&!f,children:t.action})})})})]})}var Hle=x(()=>{"use strict";Ve();_o();an();Ee();jC();El();qp();Ic();dd();tat();rat();q()});var oat={};yt(oat,{DataPage:()=>jle});function jle(){cr("Data Sources");let{roles:t}=cn(),e=window.firebase.user.email||"",r=Nf(t,e);return d(ht,{children:d("div",{className:"DataPage",children:[d("div",{className:"DataPage__header",children:[d(Vt,{size:"h1",children:"Data Sources"}),d(ft,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),d("div",{className:"DataPage__header__buttons",children:d(wn,{label:"You don't have access to create new data sources",condition:!r,children:d(J,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",disabled:!r,style:r?void 0:{pointerEvents:"none"},children:"New data source"})})})]}),d(jle.DataSourcesTable,{})]})})}var nat=x(()=>{"use strict";Kit();Ve();zt();Ee();dd();Qit();Hle();Oi();Hl();mi();yh();Sn();El();In();qp();Ic();q();jle.DataSourcesTable=()=>{let[t,e]=R(!0),[r,o]=R([]),[n,i]=ln("root::DataPage:showArchived",!1),a=u=>!!u&&u.startsWith("https://docs.google.com/spreadsheets/");async function s(){let u=await i0();o(u),e(!1)}let l=X(()=>r.some(u=>!!u.archivedAt),[r]),c=X(()=>r.filter(u=>{let f=!!u.archivedAt;return n?!0:!f}),[r,n]);return $(()=>{s()},[]),d(Mr,{className:"DataPage__DataSourcesTable",children:[t&&d(gt,{color:"gray",size:"xl"}),!t&&d(Ie,{children:[l&&d("div",{className:"DataPage__DataSourcesTable__filters",children:d(Mm,{size:"sm",color:"dark",label:"Show archived",checked:n,onChange:u=>i(!!u.currentTarget.checked)})}),c.length>0&&d(pi,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[d("thead",{children:d("tr",{children:[d("th",{children:"id"}),d("th",{children:"description"}),d("th",{children:"type"}),d("th",{children:"url"}),d("th",{children:"status"}),d("th",{children:"last synced"}),d("th",{children:"last published"})]})}),d("tbody",{children:c.map(u=>d("tr",{children:[d("td",{children:d("a",{href:`/cms/data/${u.id}`,children:u.id})}),d("td",{children:u.description||""}),d("td",{children:u.type}),d("td",{children:a(u.url)?d("div",{className:"DataPage__DataSourcesTable__url",children:[d(_e,{label:"Open spreadsheet",children:d(Ae,{component:"a",href:u.url,target:"_blank",rel:"noreferrer",variant:"filled",color:"green",size:"sm","aria-label":"Open spreadsheet",children:d(pc,{size:16,stroke:"2.25"})})}),d("a",{className:"DataPage__DataSourcesTable__url__text",href:u.url,target:"_blank",rel:"noreferrer",children:u.url})]}):u.url||""}),d("td",{children:d(Xit,{dataSource:u})}),d("td",{children:d(xI,{dataSource:u,action:"sync"})}),d("td",{children:d(xI,{dataSource:u,action:"publish"})})]},u.id))})]}),c.length===0&&d(ft,{as:"p",children:"No data sources found for this filter."})]})]})}});var iat=x(()=>{});var aat={};yt(aat,{DataSourcePage:()=>Eu});function Eu(t){cr(`Data Source: ${t.id}`);let[e,r]=R(!0),[o,n]=R(null),[i,a]=R(null),s=t.id;async function l(){let u=await cc(s);if(n(u),u){let f=await aL(s,{mode:"draft"});a(f)}r(!1)}$(()=>{l()},[]);function c(u){u==="sync"&&l()}return d(ht,{children:d("div",{className:"DataSourcePage",children:[d("div",{className:"DataSourcePage__header",children:[d(Yn,{className:"DataSourcePage__header__breadcrumbs",children:[d("a",{href:"/cms/data",children:"Data"}),d("div",{children:s})]}),d("div",{className:"DataSourcePage__header__titleWrap",children:[d(Vt,{size:"h1",children:["Data Source: ",s]}),d("div",{className:"DataSourcePage__header__controls",children:d(_e,{label:"Configure",children:d(Ae,{component:"a",href:`/cms/data/${t.id}/edit`,children:d(nb,{size:24,stroke:"1.5"})})})})]}),o?.description&&d(ft,{as:"p",children:o.description})]}),o&&d(Eu.SyncStatus,{dataSource:o,onAction:c}),e?d(gt,{color:"gray",size:"xl"}):o?d(Eu.DataSection,{dataSource:o,data:i}):d("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}var sat=x(()=>{"use strict";Ve();zt();Ee();Hle();Oi();Hl();mi();Sn();In();qp();iat();q();Eu.SyncStatus=t=>{let e=t.dataSource;return d("div",{className:"DataSourcePage__SyncStatus",children:[d(Vt,{size:"h2",children:"Status"}),d(Mr,{className:"DataSourcePage__SyncStatus__content",children:d(pi,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[d("thead",{children:d("tr",{children:[d("th",{children:"last synced"}),d("th",{children:"last published"})]})}),d("tbody",{children:d("tr",{children:[d("td",{children:d(xI,{dataSource:e,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),d("td",{children:d(xI,{dataSource:e,action:"publish"})})]})})]})})]})};Eu.DataSection=t=>{let{data:e,headers:r}=t.data||{},o=t.dataSource;if(!e)return null;let n=o.dataFormat||"map";if(o.type==="gsheet"){let i=r,a=[];if(n==="array")a=e;else if(n==="map"){let s=e;if(!i){let l=new Set;s.forEach(c=>{for(let u in c)u&&l.add(u)}),i=Array.from(l)}s.forEach(l=>{a.push(i.map(c=>l[c]||""))})}return d(Eu.DataSectionWrap,{dataSource:o,children:d(Eu.DataTable,{headers:i,rows:a})})}return o.type==="http"?d(Eu.DataSectionWrap,{dataSource:o,children:d(Eu.DefaultDataDisplay,{data:e})}):(console.log(`unsupported data type: ${o.type}`),null)};Eu.DataSectionWrap=t=>d("div",{className:"DataSourcePage__DataSection",children:[d("div",{className:"DataSourcePage__DataSection__header",children:[d(Vt,{size:"h2",children:"Data"}),d("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&d(_e,{label:"Open spreadsheet",children:d(Ae,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:d(pc,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&d(J,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),d(Mr,{className:"DataSourcePage__DataSection__content",children:t.children})]});Eu.DataTable=t=>{let e=t.headers||[],r=t.rows||[];return d("div",{className:"DataSourcePage__DataTable",children:d(pi,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e.length>0&&d("thead",{children:d("tr",{children:e.map(o=>d("th",{children:o},o))})}),d("tbody",{children:r.map((o,n)=>d("tr",{children:o.map((i,a)=>d("td",{children:i},a))},n))})]})})};Eu.DefaultDataDisplay=t=>{let e=t.data;return typeof e=="object"?d(Am,{value:JSON.stringify(e,null,2),minRows:20,maxRows:100}):d(Fr,{value:String(e),minRows:12,maxRows:100})}});function lat(t,e,r={}){let{query:o,route:n}=Fo(),{replace:i=!1,serialize:a=g=>String(g),deserialize:s=g=>g}=r,l=V(e),c=V(a),u=V(s);l.current=e,c.current=a,u.current=s;let f=ae(()=>{let g=o[t];return g!==void 0?u.current(g):l.current},[o,t]),[p,h]=R(f);$(()=>{h(f())},[f]);let m=ae(g=>{h(g);let v=new URL(window.location.href),y=c.current(g);y===String(l.current)||y===""?v.searchParams.delete(t):v.searchParams.set(t,y);let b=v.pathname+v.search;n(b,i)},[t,i,n]);return[p,m]}function W3(t,e=""){return lat(t,e)}function uD(t,e=[]){return lat(t,e,{serialize:r=>Array.isArray(r)?r.join(","):"",deserialize:r=>r?r.split(",").filter(Boolean):e})}var q3=x(()=>{"use strict";Ee();Fs()});var cat=x(()=>{});var uat={};yt(uat,{DocTranslationsPage:()=>Rx});function Rx(t){cr(`Translations: ${t.collection}/${t.slug}`);let[e,r]=R(!0),[o,n]=R(!1),[i,a]=R([]),[s,l]=R({}),[c,u]=R(null),[f,p]=R(!1),[h,m]=R({}),[g,v]=R(!1),y=t.collection,b=t.slug,_=`${y}/${b}`,C=G4(),I=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||[],[S,T]=uD("locale",I);async function k(){try{let[M,z,F]=await Promise.all([H4(_),su(),dL(_)]);a(M),l(z),u(F),r(!1)}catch(M){console.error(M),r(!1),n(!0)}}if($(()=>{k()},[]),o)return d(Rx.NotFound,{docId:_});function P(M,z,F){p(!0),m(U=>{let j={...U},G=j[M]??{};return G.source=M,G[z]=F,j[M]=G,j})}async function D(){v(!0),await Vr(async()=>{console.log("EditTranslationsModal.onSave()");let M=`edit-translations-${_}`;ge({id:M,loading:!0,title:"Saving translations",message:`Updating for ${_}...`,autoClose:!1,disallowClose:!0});let z=Object.values(h);console.log(z),await og(_,z),xr({id:M,title:"Saved translations",message:`Updated translations for ${_}!`,autoClose:!0}),m({}),p(!1)}),v(!1)}function O(M){S.length===I.length?T([M]):T(I)}return d(ht,{children:d("div",{className:"DocTranslationsPage",children:[d("div",{className:"DocTranslationsPage__header",children:[d(Yn,{className:"DocTranslationsPage__header__breadcrumbs",children:[d("a",{href:`/cms/content/${y}`,children:y}),d("a",{href:`/cms/content/${y}/${b}`,children:b}),d("div",{children:"translations"})]}),d("div",{className:"DocTranslationsPage__header__titleWrap",children:d(Vt,{size:"h1",children:["Translations: ",_]})}),d("div",{className:"DocTranslationsPage__header__controls",children:[c&&d("div",{className:"DocTranslationsPage__header__linkedSheet",children:d("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[d(_e,{label:"Open Google Sheet",children:d(Ae,{component:"a",href:au(c),target:"_blank",variant:"filled",color:"green",size:"sm",children:d(pc,{size:16,strokeWidth:2.25})})}),d(J,{variant:"default",size:"xs",leftIcon:d(sg,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),d(J,{variant:"default",size:"xs",leftIcon:d(tb,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),d(ke,{className:"DocTranslationsPage__toolsMenu",control:d(_e,{label:"Tools",children:d(Ae,{variant:"default",children:d(lg,{size:16})})}),size:220,children:d(ke.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:d(ob,{size:16}),onClick:()=>C.open({docId:_,sourceStrings:i,onPruned:M=>{l(z=>{let F={...z};return M.forEach(U=>delete F[U]),F})}}),children:"Prune unused strings"})})]})]}),d("div",{className:me("DocTranslationsPage__content",e&&"DocTranslationsPage__content--loading"),children:e?d(gt,{color:"gray",size:"xl"}):d(Rx.Table,{locales:S,sourceStrings:i,translationsMap:s,onChange:P,changesMap:h,onSelectLocale:M=>O(M)})}),d("div",{className:"DocTranslationsPage__footer",children:d("div",{className:"DocTranslationsPage__footer__buttons",children:d(J,{variant:"filled",color:"dark",disabled:!f,loading:g,onClick:()=>D(),children:"Save"})})})]})})}var dat=x(()=>{"use strict";Ve();_o();zt();Ee();Oi();q4();Sn();q3();In();Sr();Qn();gP();Wp();uc();Gi();cat();q();Rx.NotFound=t=>d(ht,{children:d("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:d("div",{className:"DocTranslationsPage__error",children:[d("div",{className:"DocTranslationsPage__error__icon",children:d(m1,{size:60})}),d("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",t.docId]})]})})});Rx.Table=t=>{let r=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||[],o=X(()=>{let i={};return Object.values(t.translationsMap).forEach(a=>{i[a.source]=a}),i},[t.translationsMap]);function n(i,a){return{translation:(o[i]||{})[a]||"",hasChanges:!1}}return d("div",{className:"DocTranslationsPage__TableWrap",children:d("table",{className:"DocTranslationsPage__Table",children:[d("thead",{children:d("tr",{children:[d("th",{className:"DocTranslationsPage__Table__sourceCellHeader",children:d("div",{className:"DocTranslationsPage__Table__headerLabel",children:"source"})}),t.locales.map(i=>d("th",{onClick:()=>t.onSelectLocale(i),className:"DocTranslationsPage__Table__localeHeader",children:d(_e,{className:"DocTranslationsPage__Table__headerTooltip",placement:"start",withArrow:!0,label:t.locales.length===r.length?`Show only ${i}`:"Show all locales",children:d("div",{className:"DocTranslationsPage__Table__headerLabel",children:i})})},i))]})}),d("tbody",{children:t.sourceStrings.map(i=>d("tr",{children:[d("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:d("div",{className:"DocTranslationsPage__Table__sourceCell",children:i})}),t.locales.map(a=>{let s=n(i,a);return d("td",{children:d(Rx.Textarea,{source:i,locale:a,value:s.translation,onChange:t.onChange,changesMap:t.changesMap})},a)})]},i))})]})})};Rx.Textarea=t=>{let e=V(null),[r,o]=R(t.value),n=null;t.locale in(t.changesMap[t.source]||{})&&(n=t.changesMap[t.source][t.locale]);let i=n!==null&&n!==t.value;function a(){window.requestAnimationFrame(()=>{let s=e.current;s.style.minHeight="auto";let l=s.scrollHeight;s.style.minHeight=`${l}px`})}return $(()=>{a()},[r]),d("textarea",{ref:e,className:me("DocTranslationsPage__Textarea",i&&"DocTranslationsPage__Textarea--hasChanges",!r&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>a(),rows:1,onChange:s=>{let l=s.target.value;o(l),t.onChange(t.source,t.locale,l)},value:r})}});var fat=x(()=>{});var pat=x(()=>{});async function hat(t,e){let o=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:e})})).json();if(!o.success)throw new Error(o.error||"Check failed.");return o.data}function mat(t){let e=window.__ROOT_CTX.checks||[],r=t.docId.split("/")[0],o=e.filter(l=>!l.collections||l.collections.includes(r)),[n,i]=R({}),a=ae(async l=>{i(c=>({...c,[l]:{loading:!0}}));try{let c=await hat(l,t.docId);i(u=>({...u,[l]:{loading:!1,result:c}}))}catch(c){i(u=>({...u,[l]:{loading:!1,error:c.message||"Unknown error."}}))}},[t.docId]),s=ae(async()=>{let l={};for(let c of o)l[c.id]={loading:!0};i(l);for(let c of o)try{let u=await hat(c.id,t.docId);i(f=>({...f,[c.id]:{loading:!1,result:u}}))}catch(u){i(f=>({...f,[c.id]:{loading:!1,error:u.message||"Unknown error."}}))}},[t.docId,o]);return d("div",{className:"ChecksPanel",children:[d("div",{className:"ChecksPanel__header",children:[d("div",{className:"ChecksPanel__header__title",children:"Checks"}),d(J,{variant:"default",size:"xs",compact:!0,leftIcon:d(d7,{size:12}),onClick:s,children:"Run All"})]}),d("div",{className:"ChecksPanel__body",children:d("div",{className:"ChecksPanel__checks",children:o.map(l=>{let c=n[l.id];return d(rtr,{check:l,state:c,onRun:()=>a(l.id)},l.id)})})})]})}function rtr(t){let{check:e,state:r,onRun:o}=t;return d("div",{className:"ChecksPanel__check",children:[d("div",{className:"ChecksPanel__check__header",children:[d("div",{className:"ChecksPanel__check__label",children:[e.label,r?.result&&d(itr,{status:r.result.status})]}),d(J,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:r?.loading,onClick:o,children:"Run"})]}),e.description&&d("div",{className:"ChecksPanel__check__description",children:e.description}),r?.result&&d("div",{className:me("ChecksPanel__check__result",`ChecksPanel__check__result--${r.result.status}`),children:d(hu,{code:r.result.message})}),r?.error&&d("div",{className:"ChecksPanel__check__error",children:r.error})]})}function itr(t){let e=otr[t.status],r=ntr[t.status],o=t.status.charAt(0).toUpperCase()+t.status.slice(1);return d(vn,{className:"ChecksPanel__statusBadge",color:e,size:"sm",variant:"filled",leftSection:d(r,{size:10}),children:o})}var otr,ntr,gat=x(()=>{"use strict";pat();Ve();zt();Ee();Sr();LC();q();otr={success:"green",warning:"yellow",error:"red"},ntr={success:kn,warning:d0,error:qi}});var vat=x(()=>{});function yat(t){let{device:e,expandVertically:r,iframeUrl:o,localeOptions:n,selectedLocale:i,onToggleDevice:a,onToggleExpandVertically:s,onReloadClick:l,onOpenNewTab:c,onLocaleChange:u}=t;return d("div",{className:"DocumentPagePreviewBar",children:[d("div",{className:"DocumentPagePreviewBar__devices",children:[d(_e,{label:"Mobile",children:d(Ae,{className:me("DocumentPagePreviewBar__device",e==="mobile"&&"active"),onClick:()=>a("mobile"),children:d(zW,{size:16})})}),d(_e,{label:"Tablet",children:d(Ae,{className:me("DocumentPagePreviewBar__device",e==="tablet"&&"active"),onClick:()=>a("tablet"),children:d(BW,{size:16})})}),d(_e,{label:"Desktop",children:d(Ae,{className:me("DocumentPagePreviewBar__device",e==="desktop"&&"active"),onClick:()=>a("desktop"),children:d(LW,{size:16})})}),d(_e,{label:"Expand",children:d(Ae,{className:me("DocumentPagePreviewBar__device",r&&"active"),"aria-pressed":r,disabled:e==="",onClick:s,children:d(r1,{size:16})})})]}),d("div",{className:"DocumentPagePreviewBar__navbar",children:d("div",{className:"DocumentPagePreviewBar__navbar__url",children:o})}),d("div",{className:"DocumentPagePreviewBar__locales",children:d(Lr,{data:n,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:d(S1,{size:16,strokeWidth:1.5}),value:i,onChange:f=>{u(f)}})}),d("div",{className:"DocumentPagePreviewBar__buttons",children:[d(_e,{label:"Reload",children:d(Ae,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:l,children:d(m7,{size:16})})}),d(_e,{label:"Open new tab",children:d(Ae,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:c,children:d(Ls,{size:16})})})]})]})}var bat=x(()=>{"use strict";vat();Ve();zt();Sr();q()});var xat=x(()=>{});function _at(t){let e=t.docId.split("/")[0],r=$C(e),o=gi(),n=V(null),[i,a]=R(""),[s,l]=R([]),[c,u]=R(!1),f=V("");f.current=i;let p=V(r.schema?.fields||[]);p.current=r.schema?.fields||[];let h=V(r.schema?.types||{});h.current=r.schema?.types||{};let m=X(()=>WC(v=>{let y=v.trim();if(!y){l([]),u(!1);return}let b=o.controller?.getData()?.fields||{},_=crt(y,b,p.current,h.current);l(_),u(!0)},150),[o.controller]);$(()=>{m(i)},[i,m]),xVe(()=>{f.current.trim()&&m(f.current)}),$(()=>{t.autoFocus&&requestAnimationFrame(()=>{n.current?.focus(),n.current?.select()})},[t.autoFocus]),$(()=>{let v=()=>{n.current?.focus(),n.current?.select()};return window.addEventListener("root:focus-search",v),()=>window.removeEventListener("root:focus-search",v)},[]);let g=v=>{ltr(v)};return d("div",{className:"SearchPanel",children:[d("div",{className:"SearchPanel__header",children:[d("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&d(Ae,{size:"xs",onClick:t.onClose,title:"Close search",children:d(qi,{size:14})})]}),d("div",{className:"SearchPanel__searchInput",children:[d("span",{className:"SearchPanel__searchInput__icon",children:d(Ka,{size:14})}),d("input",{ref:n,type:"text",className:"SearchPanel__searchInput__input",value:i,onInput:v=>a(v.currentTarget.value),onKeyDown:v=>{v.key==="Escape"&&t.onClose&&(v.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),d("div",{className:"SearchPanel__body",children:[!c&&!i.trim()&&d("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),c&&s.length===0&&d("div",{className:"SearchPanel__empty",children:["No matches for ",d("strong",{children:i}),"."]}),s.length>0&&d(Ie,{children:[d("div",{className:"SearchPanel__resultsCount",children:[s.length," ",s.length===1?"match":"matches"]}),d("ul",{className:"SearchPanel__results",children:s.map((v,y)=>d(atr,{result:v,onClick:()=>g(v)},`${v.deepKey}:${y}`))})]})]})]})}function atr(t){let{result:e}=t;return d("li",{className:"SearchPanel__result",children:d("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[d("div",{className:"SearchPanel__result__label",children:e.label}),d("div",{className:"SearchPanel__result__snippet",children:str(e.snippet,e.matches)}),d("div",{className:"SearchPanel__result__meta",children:[d("span",{className:"SearchPanel__result__type",children:e.fieldType}),e.richTextBlock&&d("span",{className:"SearchPanel__result__badge",children:"in block"}),e.richTextInline&&d("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function str(t,e){if(!e||e.length===0)return t;let r=[],o=0;for(let n of e)n.start>o&&r.push({text:t.slice(o,n.start),match:!1}),r.push({text:t.slice(n.start,n.end),match:!0}),o=n.end;return o<t.length&&r.push({text:t.slice(o),match:!1}),r.map((n,i)=>n.match?d("mark",{children:n.text},i):d("span",{children:n.text},i))}function ltr(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let e=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(rD,{detail:e}))},350)}else if(t.richTextInline){let e=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(oD,{detail:e}))},350)}}var wat=x(()=>{"use strict";xat();Ve();zt();Ee();k4();Zi();ez();Use();q()});var Cat=x(()=>{});function dD(t){let{className:e,localStorageId:r,children:o}=t,[n,i]=ln(`root::SplitPanel:${r}`,350),[a,s]=R(!1),[l,c]=R(0),u=X(()=>new Set,[]),f=V(null),p=V(null),h={onResize:g=>(u.add(g),()=>{u.delete(g)})};if($(()=>{let g=()=>s(!1);window.addEventListener("mouseup",g);let v=f.current;return v&&c(v.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",g)},[]),$(()=>{let g=v=>{let y=v.clientX-l;i(y),u.forEach(b=>b())};return a&&window.addEventListener("mousemove",g),()=>window.removeEventListener("mousemove",g)},[a]),o?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let m={"--panel-size":`${n}px`};return d(ctr.Provider,{value:h,children:d("div",{className:me(e,"SplitPanel",a&&"dragging"),ref:f,style:m,children:[o[0],d("div",{className:"SplitPanel__divider",ref:p,onMouseDown:()=>s(!0)}),o[1]]})})}var ctr,Sat=x(()=>{"use strict";hn();Ee();yh();Sr();Cat();q();ctr=Pt(null);dD.Item=t=>d("div",{className:me("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children})});var Tat={};yt(Tat,{DocumentPage:()=>Wle});function Gle(t,e,r=""){let o=b4({collectionId:t,slug:e}),n=new URLSearchParams(window.location.search);n.set("preview","true"),n.delete("locale"),n.delete("modal");let i=`${n.toString()}${window.location.hash}`;return r?`${b4({collectionId:t,slug:e,locale:r})}?${i}`:`${o}?${i}`}function Wle(t){let e=t.collection,r=t.slug,o=`${e}/${r}`,{roles:n}=cn(),i=window.firebase.user.email||"",a=Nf(n,i);return d(nz,{docId:o,readOnly:!a,children:d(utr,{...t,canEdit:a})})}function utr(t){let e=t.canEdit,r=t.collection,o=t.slug,n=`${r}/${o}`;cr(n);let i=window.__ROOT_CTX.collections[r],a=gi(),s=!!i?.url,[l,c]=ln(`root::DocumentPage::previewVisible::${r}`,s),u=X(()=>(window.__ROOT_CTX.checks||[]).some(W=>!W.collections||W.collections.includes(r)),[r]),[f,p]=ln("root::DocumentPage::checksVisible",!1),h=V(f);h.current=f;let[m,g]=ln("root::DocumentPage::searchVisible",!1),v=V(m);v.current=m;let y=!!(window.__ROOT_CTX.ai||window.__ROOT_CTX.experiments?.ai),[b,_]=ln("root::DocumentPage::aiVisible",!1),C=V(b);C.current=b,$(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:f}))},[f]),$(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:m}))},[m]),$(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:b}))},[b]);let[E,I]=ln("root::DocumentPage::searchPanelWidth",360),[S,T]=R(E),[k,P]=R(!1),D=V(null);if($(()=>{let te=()=>{let W=!h.current;p(()=>W),W&&(g(()=>!1),_(()=>!1))};return window.addEventListener("root:toggle-checks",te),()=>window.removeEventListener("root:toggle-checks",te)},[]),$(()=>{let te=()=>{let W=!v.current;g(()=>W),W&&(p(()=>!1),_(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",te),()=>window.removeEventListener("root:toggle-search",te)},[]),$(()=>{let te=()=>{let W=!C.current;_(()=>W),W&&(p(()=>!1),g(()=>!1))};return window.addEventListener("root:toggle-ai",te),()=>window.removeEventListener("root:toggle-ai",te)},[]),$(()=>{if(!k)return;let te=ee=>{let Y=D.current;if(!Y)return;let ie=Y.getBoundingClientRect(),ne=Math.max(240,Math.min(ie.right-ee.clientX,800));T(ne)},W=()=>{P(!1),T(ee=>(I(()=>ee),ee))};return window.addEventListener("mousemove",te),window.addEventListener("mouseup",W),()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",W)}},[k]),!i)return d("div",{children:"Could not find collection."});let O=ae(()=>{if(!s)return;let te=Gle(r,o),W=window.open(te,"_blank","noopener,noreferrer");W&&W.focus()},[s,r,o]),M=ae(()=>{e&&a.controller&&a.controller.flush()},[e,a.controller]),z=D4(),F=ae(()=>{let te=a.controller?.getData()?.fields||{};z.open({data:te,onSave:W=>{a.controller&&W&&typeof W=="object"&&(a.controller.updateKey("fields",W),a.controller.flush()),z.close()}})},[a.controller]),U=ae(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),j=ae(()=>{y&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[y]),G=ae(()=>{_(()=>!1)},[_]);return yT([["mod+S",M],["mod+shift+F",U],["mod+I",j]]),d(ht,{children:d("div",{className:me("DocumentPage__layout",k&&"DocumentPage__layout--dragging"),ref:D,children:[d(dD,{className:"DocumentPage",localStorageId:"DocumentPage",children:[d(dD.Item,{className:me("DocumentPage__side",(!s||!l)&&"DocumentPage__side--expanded"),children:[d("div",{className:"DocumentPage__side__header",children:[d("div",{className:"DocumentPage__side__header__nav",children:[d("a",{href:`/cms/content/${r}`,children:d(Ae,{className:"DocumentPage__side__header__back",children:d(wW,{size:16})})}),d("div",{className:"DocumentPage__side__header__docId",children:n})]}),d("div",{className:"DocumentPage__side__header__buttons",children:[d(wn,{label:"You don't have access to edit this document",condition:!e,children:d(J,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:d(c1,{size:16}),onClick:()=>M(),disabled:!e,children:"Save"})}),d(wn,{label:"You don't have access to edit this document",condition:!e,children:d(_e,{label:"Edit JSON",disabled:!e,children:d(Ae,{className:"DocumentPage__side__header__editJson",onClick:()=>F(),disabled:!e,children:d(n1,{size:14})})})}),s&&d(Ie,{children:[d(_e,{label:l?"Hide preview":"Show preview",children:d(Ae,{className:"DocumentPage__side__header__previewToggle",onClick:()=>c(!l),children:l?d(r7,{size:16}):d(o7,{size:16})})}),!l&&d(_e,{label:"Open preview in new tab",children:d(Ae,{className:"DocumentPage__side__header__openNewTab",onClick:O,children:d(Ls,{size:16})})})]})]})]}),d("div",{className:me("DocumentPage__side__editor",(!s||!l)&&!f&&!m&&!b&&"DocumentPage__side__editor--centered"),children:d(kr,{docId:n})})]}),d(dD.Item,{className:me("DocumentPage__main",(!s||!l)&&"DocumentPage__main--hidden"),fluid:!0,children:s&&l&&d(Wle.Preview,{docId:n},n)})]}),u&&f&&d(ftr,{docId:n}),m&&d(Ie,{children:[d("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>P(!0)}),d("div",{className:"DocumentPage__search",style:{flexBasis:`${S}px`},children:d(_at,{docId:n,autoFocus:!0,onClose:()=>g(()=>!1)})})]}),y&&b&&d(dtr,{docId:n,onClose:G})]})})}function dtr(t){let[e,r]=ln("root::DocumentPage::aiPanelWidth",420),[o,n]=R(e),i=V(null),a=V(o),s=V(),l=X(()=>d(j3,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),c=ae(()=>{let u=i.current?.parentElement;if(!u)return;a.current=o,u.classList.add("DocumentPage__layout--dragging");let f=m=>{let g=i.current?.parentElement;if(!g)return;let v=g.getBoundingClientRect(),y=Math.max(280,Math.min(v.right-m.clientX,800));a.current=y,n(y)},p=()=>{u.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",h),s.current=void 0},h=()=>{p(),r(()=>a.current)};s.current=p,window.addEventListener("mousemove",f),window.addEventListener("mouseup",h)},[o,r]);return $(()=>()=>s.current?.(),[]),d(Ie,{children:[d("div",{className:"DocumentPage__aiDivider",ref:i,onMouseDown:c}),d("div",{className:"DocumentPage__ai",style:{flexBasis:`${o}px`},children:l})]})}function ftr(t){let[e,r]=ln("root::DocumentPage::checksPanelWidth",360),[o,n]=R(e),i=V(null),a=V(o),s=V(),l=X(()=>d(mat,{docId:t.docId}),[t.docId]),c=ae(()=>{let u=i.current?.parentElement;if(!u)return;a.current=o,u.classList.add("DocumentPage__layout--dragging");let f=m=>{let g=i.current?.parentElement;if(!g)return;let v=g.getBoundingClientRect(),y=Math.max(200,Math.min(v.right-m.clientX,800));a.current=y,n(y)},p=()=>{u.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",h),s.current=void 0},h=()=>{p(),r(()=>a.current)};s.current=p,window.addEventListener("mousemove",f),window.addEventListener("mouseup",h)},[o,r]);return $(()=>()=>s.current?.(),[]),d(Ie,{children:[d("div",{className:"DocumentPage__checksDivider",ref:i,onMouseDown:c}),d("div",{className:"DocumentPage__checks",style:{flexBasis:`${o}px`},children:l})]})}function ptr(t){let e=new Intl.DisplayNames(["en"],{type:"language"}),o=t.split("_")[0];return`${e.of(o)||t} (${t})`}var Iat,Eat=x(()=>{"use strict";fat();Ve();Cr();zt();Ee();gat();dd();nD();bat();O4();zle();wat();Sat();Zi();yh();Sn();El();q3();In();Sr();x4();Ic();q();Iat={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};Wle.Preview=t=>{let e=gi();if(e.loading)return null;let[r,o]=t.docId.split("/"),i=window.__ROOT_CTX.collections[r];if(!i)throw new Error(`collection not found: ${r}`);if(!i.url)return null;let a=i.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",s=MQ({collectionId:r,slug:o}),l=b4({collectionId:r,slug:o}),c=`${a}${s}`,[u,f]=R(c),[p,h]=ln("root::DocumentPage::preview::device",""),[m,g]=ln("root::DocumentPage::preview::expandVertically",!1),[v,y]=R({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[b,_]=W3("locale",""),C=V(null),E=V(null),I=e.controller.getLocales()||[],S=Gle(r,o,b),T=X(()=>[{value:"",label:"Select locale"},...I.map(F=>({value:F,label:ptr(F)}))],[I]);function k(){if(document.hidden)return;let F=C.current;F.src="about:blank",window.requestAnimationFrame(()=>{F.src!==S?F.src=S:F.contentWindow.location.reload()})}$(()=>{let F=C.current;function U(){let G=F.contentWindow;if(G&&l===s&&!G.location.href.startsWith("about:blank")){let te=G.location.pathname;f(`${a}${te}`)}}F.addEventListener("load",U);let j=e.controller?.onFlush(()=>{k()});return()=>{j(),F.removeEventListener("load",U)}},[]),$(()=>{let F=C.current;F.src=S},[b]);let P=ae(F=>{h(U=>{let j=U===F?"":F;return j===""&&g(!1),j})},[h,g]),D=ae(()=>{h(F=>(F&&g(U=>!U),F))},[h,g]),O=ae(()=>{e.controller&&e.controller.flush().then(()=>k())},[e.controller]),M=ae(()=>{let F=Gle(r,o,b),U=window.open(F,"_blank","noopener,noreferrer");U&&U.focus()},[r,o,b]),z=ae(()=>{if(p===""){let Se={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};y(je=>je["--iframe-width"]===Se["--iframe-width"]&&je["--iframe-height"]===Se["--iframe-height"]&&je["--iframe-scale"]===Se["--iframe-scale"]?je:Se);return}let F=E.current;if(!F)return;let U=F.getBoundingClientRect(),[j,G]=Iat[p],te=20,W=Math.max(U.width-2*te,0),ee=Math.max(U.height-2*te,0),Y=W>0&&j>0?W/j:1,ie=ee>0&&G>0?ee/G:1,ne=Math.min(Y,ie,1),le=Number(ne.toFixed(4))||1,pe=m?`${ee/le}px`:`${G}px`,Re={"--iframe-width":`${j}px`,"--iframe-height":pe,"--iframe-scale":String(le)};y(Se=>Se["--iframe-width"]===Re["--iframe-width"]&&Se["--iframe-height"]===Re["--iframe-height"]&&Se["--iframe-scale"]===Re["--iframe-scale"]?Se:Re)},[p,m]);return $(()=>{z();let F=E.current;if(!F)return;let U=0,j=()=>{window.cancelAnimationFrame(U),U=window.requestAnimationFrame(z)},G=new window.ResizeObserver(j);return G.observe(F),window.addEventListener("resize",j),()=>{window.cancelAnimationFrame(U),G.disconnect(),window.removeEventListener("resize",j)}},[z]),d("div",{className:"DocumentPage__main__preview",children:[d(yat,{device:p,expandVertically:m,iframeUrl:u,localeOptions:T,selectedLocale:b,onToggleDevice:P,onToggleExpandVertically:D,onReloadClick:O,onOpenNewTab:M,onLocaleChange:_}),d("div",{className:"DocumentPage__main__previewFrame","data-device":p||"full",ref:E,style:v,children:[d("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:p?void 0:"none"},children:p?`${p}: ${Iat[p].join("x")}`:""}),d("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:d("iframe",{ref:C,title:"iframe preview"})})]})]})}});var kat=x(()=>{});function K3(t){let{route:e}=Fo(),r=V(null),o=Of(),[n,i]=R(!1),[a,s]=R(o.enabled?"gsheet":"http"),[l,c]=R("map"),[u,f]=R("GET"),[p,h]=R(!1),[m,g]=R(1),[v,y]=R("hours"),[b,_]=R(!1),[C,E]=R(""),[I,S]=R(!!t.dataSourceId),[T,k]=R(null),P="";a==="http"?P=htr:a==="gsheet"&&(P=mtr);async function D(z){await Vr(async()=>{let F=await cc(z);k(F),s(F?.type||"http"),c(F?.dataFormat||"map"),F?.cron?(h(F.cron.enabled||!1),g(F.cron.interval||1),y(F.cron.unit||"hours"),_(F.cron.autoPublish||!1)):(h(!1),g(1),y("hours"),_(!1))}),S(!1)}$(()=>{t.dataSourceId&&(S(!0),D(t.dataSourceId))},[t.dataSourceId]);async function O(){E("");let z=r.current;function F(te){let W=z.elements[te];return W?W.value.trim():""}let U=t.dataSourceId||F("id");if(!U){E("missing id");return}if(!tg(U)){E("id is invalid (alphanumeric characters and dashes only)");return}let j=F("url");if(!j){E("missing url");return}let G={id:U,description:F("description"),type:a,url:j,previewUrl:F("previewUrl")};if(a==="http"){if(!gtr(j)){E("invalid url");return}G.httpOptions={method:u};let te=F("httpHeaders");if(te&&(G.httpOptions.headers=vtr(te)),u==="POST"){let W=F("httpBody");W&&(G.httpOptions.body=W)}}else if(a==="gsheet"){if(!rg(j)?.spreadsheetId){E("failed to parse spreadsheet url");return}G.dataFormat=l||"map"}p?G.cron={enabled:!0,interval:m,unit:v,autoPublish:b}:G.cron={enabled:!1,interval:m,unit:v};try{k(G),i(!0),t.dataSourceId?(await EDe(t.dataSourceId,G),ge({title:"Saved data source",message:`Successfully updated ${U}`,autoClose:5e3}),i(!1)):(await TDe(U,G),ge({title:"Added data source",message:`Successfully added ${U}`,autoClose:5e3}),i(!1),e(`/cms/data/${U}`))}catch(te){console.error(te),ge({title:"Failed to save data source",message:String(te),color:"red",autoClose:!1}),i(!1)}}let M=[{value:"http",label:"HTTP"}];return(o.enabled||a==="gsheet")&&M.push({value:"gsheet",label:"Google Sheet"}),d("form",{className:"DataSourceForm",ref:r,onSubmit:z=>{z.preventDefault(),O()},children:[d(tu,{visible:I}),d("div",{className:"DataSourceForm__input",children:d(Lr,{name:"type",label:"Type",data:M,value:a,onChange:z=>s(z),size:"xs",radius:0,dropdownComponent:"div"})}),d(ur,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.dataSourceId,disabled:!!t.dataSourceId}),d(Fr,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:T?.description}),d(ur,{className:"DataSourceForm__input",name:"url",label:"URL",description:P,size:"xs",radius:0,value:T?.url}),a==="http"&&d(Ie,{children:[d("div",{className:"DataSourceForm__input",children:d(Lr,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:u,onChange:z=>f(z),size:"xs",radius:0,dropdownComponent:"div"})}),d(Fr,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ytr(T?.httpOptions?.headers||{})}),u==="POST"&&d(Fr,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:T?.httpOptions?.body})]}),a==="gsheet"&&d("div",{className:"DataSourceForm__input",children:[d(Lr,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:l,onChange:z=>c(z),size:"xs",radius:0,dropdownComponent:"div"}),l==="array"&&d("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",d("code",{children:"[[header1, header2], [foo, bar]]"})]}),l==="map"&&d("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",d("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),d("div",{className:"DataSourceForm__section",children:[d("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),d(Si,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:p,onChange:z=>h(z.currentTarget.checked),size:"xs"}),p&&d("div",{className:"DataSourceForm__cron",children:[d("div",{className:"DataSourceForm__cron__row",children:[d("span",{children:"Run every"}),d(Rp,{className:"DataSourceForm__cron__interval",value:m,onChange:z=>g(Number(z)||1),min:1,size:"xs",radius:0}),d(Lr,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:v,onChange:z=>y(z),size:"xs",radius:0,dropdownComponent:"div"})]}),d(Si,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:b,onChange:z=>_(z.currentTarget.checked),size:"xs"})]})]}),d(ur,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:T?.previewUrl}),d(J,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:n,children:t.buttonLabel||"Save"}),C&&d("div",{className:"DataSourceForm__error",children:["Error: ",C]})]})}function gtr(t){let e,r=t.startsWith("/")?"http://localhost":void 0;try{e=new URL(t,r)}catch(o){return console.error(o),!1}return e.protocol==="http:"||e.protocol==="https:"}function vtr(t){let e={};return t.split(`
460
+ [The file was uploaded, but its binary content was not inlined into this chat message.]`}async function jer(t,e){if(!Ger(t.name,e))return null;let r=await t.text();return r.length<=git?{text:r,truncated:!1}:{text:r.slice(0,git),truncated:!0}}function Ger(t,e){return e.startsWith("text/")?!0:[".css",".js",".jsx",".json",".md",".mdx",".mjs",".scss",".ts",".tsx",".txt",".yaml",".yml"].some(r=>t.toLowerCase().endsWith(r))}function Wer(t){let e=t.toLowerCase();return e.endsWith(".png")?"image/png":e.endsWith(".webp")?"image/webp":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".gif")?"image/gif":e.endsWith(".svg")?"image/svg+xml":e.endsWith(".pdf")?"application/pdf":e.endsWith(".json")?"application/json":e.endsWith(".csv")?"text/csv":e.endsWith(".md")?"text/markdown":e.endsWith(".txt")?"text/plain":"application/octet-stream"}function qer(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var H3,yit,bit,U3,git,zle=x(()=>{"use strict";dit();dX();Ve();zt();RB();PX();Ee();Fs();Sr();Tf();Xo();hit();RL();LC();bX();q();H3=[{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"suggest",label:"Suggest changes",description:"Research and propose edits without calling write tools."},{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],yit="root-cms.ai.executionMode",bit="root-cms.ai.selectedModel";U3="";git=1e5});function cr(t){$(()=>{let e=window.__ROOT_CTX?.rootConfig,r=e?.projectName||"Root CMS",o=e?.minimalBranding?r:`${r} \u2013 Root CMS`;document.title=t?`${t} \u2013 ${o}`:o},[t])}var Sn=x(()=>{"use strict";Ee()});var $le,xit=x(()=>{$le={name:"@blinkk/root-cms",version:"3.0.2",author:"s@blinkk.com",license:"MIT",engines:{node:">=16.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./client":{types:"./dist/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"tsup-node --config=./core/tsup.config.ts","//":"NOTE: esbuild is used here because tsup doesn't currently support aliases.","build:ui":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177",ai:"6.0.175",zod:"4.4.3","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@types/cli-progress":"3.11.6","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","@mantine/spotlight":"4.2.12","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.6","@vitest/browser-playwright":"4.1.6",concurrently:"7.6.0",esbuild:"0.25.9",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.56.1",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",tsup:"8.5.0",typescript:"5.9.2",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.0.2","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}}});function _it(){return d("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d("g",{"clip-path":"url(#clip0_1_318)",children:[d("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),d("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),d("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),d("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),d("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),d("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),d("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),d("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),d("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),d("defs",{children:d("clipPath",{id:"clip0_1_318",children:d("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var wit=x(()=>{"use strict";q()});var Cit=x(()=>{});function Sit(t){let[e,r]=R(!1);$(()=>{let n=navigator.userAgentData?.platform??navigator.platform;r(/mac/i.test(n||""))},[]);let o=()=>{oee()};return d("button",{type:"button",className:me("SearchBar",t.className),onClick:o,"aria-label":"Open search",children:[d(Ka,{className:"SearchBar__icon",size:16,stroke:1.5}),d("span",{className:"SearchBar__placeholder",children:"Search"}),d("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var Iit=x(()=>{"use strict";Cit();iee();zt();Ee();Sr();q()});var Tit=x(()=>{});function ht(t){return d("div",{className:"Layout",children:[d(ht.Top,{}),d(ht.Side,{}),d(ht.Main,{...t,children:t.children}),d(ht.Bottom,{})]})}function Yer(t){let r=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return r.length===4&&r[0]==="cms"&&r[1]==="content"}var np,In=x(()=>{"use strict";Ve();zt();Fs();xit();wit();Iit();Sr();Tit();q();np="1.5";ht.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,r=t.minimalBranding,{url:o}=Fo(),n=!Yer(o);return d("div",{className:"Layout__top",children:[r?d(Ie,{children:[d("a",{className:"Layout__top__logo",href:"/cms",children:e}),d("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",$le.version]})]}):d(Ie,{children:[d("a",{className:"Layout__top__logo",href:"/cms",children:d(_it,{})}),d("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",$le.version]}),d("div",{className:"Layout__top__project",children:e})]}),n&&d("div",{className:"Layout__top__search",children:d(Sit,{})})]})};ht.Side=()=>{let{url:t}=Fo(),e=t.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),i=l=>n.has(l),a=window.__ROOT_CTX.experiments||{},s=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return d("div",{className:"Layout__side",children:[d("div",{className:"Layout__side__buttons",children:[!i("home")&&d(ht.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:d(JW,{stroke:np})}),!i("content")&&d(ht.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:d(Jp,{stroke:np})}),a.taskManager&&d(ht.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:d(AW,{stroke:np})}),!i("releases")&&d(ht.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:d(ed,{stroke:np})}),!i("data")&&d(ht.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:d(p0,{stroke:np})}),!i("assets")&&d(ht.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:d(g1,{stroke:np})}),!i("translations")&&d(ht.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:d(mf,{stroke:np})}),(a.ai||window.__ROOT_CTX.ai)&&!i("ai")&&d(ht.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:d(hs,{stroke:np})}),o&&d(Ie,{children:[d("div",{className:"Layout__side__divider"}),Object.entries(o).map(([l,c])=>{let u=c.cmsUrl?.startsWith("/cms/")?c.cmsUrl:void 0,f=c.externalUrl,p=f??u??`/cms/tools/${l}`,h=f?void 0:p.replace(/\/*$/g,""),m=!f&&!!h&&(e===h||e.startsWith(`${h}/`));return d(ht.SideButton,{className:"Layout__side__tool",label:c.label||"",url:p,active:m,external:!!f,children:c.icon?d("img",{className:"Layout__side__tool__icon",src:c.icon,alt:c.label||""}):d(EW,{stroke:np})},l)}),d("div",{className:"Layout__side__divider"})]}),!i("settings")&&d(ht.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:d(nb,{stroke:np})})]}),d("div",{className:"Layout__side__user",children:d(ke,{shadow:"md",position:"right",control:d(xm,{children:d(Pm,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})}),children:[d(ke.Label,{children:d(Jt,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",r.email]})}),d(fa,{}),d(ke.Item,{color:"red",icon:d(s7,{style:{width:14,height:14}}),onClick:s,children:"Sign out"})]})})]})};ht.SideButton=t=>d(_e,{className:me("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:d("a",{className:me(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});ht.Main=t=>d("div",{className:"Layout__main",children:t.children});ht.Bottom=()=>d("div",{className:"Layout__bottom"})});var Eit={};yt(Eit,{AIPage:()=>Zer});function Zer(t){return cr("AI"),d(ht,{children:d(j3,{variant:"page",initialChatId:t.chatId})})}var kit=x(()=>{"use strict";zle();Sn();In();q()});var Pit=x(()=>{});function Rit(t){let[e,r]=R(t.value||null),[o,n]=R(null);t.value!==void 0&&t.value!==e&&r(t.value);let i=s=>{r(s),t.onChange&&t.onChange(s)},a={type:"file",label:""};return d("div",{className:me("FileUploader",t.className),children:d(vre,{field:t.field||a,value:e,setValue:i,loadingState:o,setLoadingState:n,variant:t.variant,showNamingOptions:t.showNamingOptions,accept:t.accept,allowEditing:t.allowEditing})})}var Dit=x(()=>{"use strict";Pit();Ee();Sr();qz();q()});var Ait=x(()=>{});function Mr(t){return d("div",{className:me(t.className,"Surface"),children:t.children})}var Hl=x(()=>{"use strict";Ait();Sr();q()});var Oit=x(()=>{});var Mit={};yt(Mit,{AssetsPage:()=>Jer});function Jer(){cr("Assets");let[t,e]=R(null),r=t?.gcsPath?`https://storage.googleapis.com${t.gcsPath}`:"";return d(ht,{children:d("div",{className:"AssetsPage","data-testid":"assets-page",children:[d("div",{className:"AssetsPage__header",children:[d(Vt,{size:"h1",children:"Assets"}),d(ft,{as:"p",children:"Upload assets to the project's GCS bucket."})]}),d(Mr,{className:"AssetsPage__content",children:[d(Rit,{value:t,onChange:e,showNamingOptions:!0,accept:["*/*"],allowEditing:!1,className:"AssetsPage__uploader"}),t&&r&&d("div",{className:"AssetsPage__urlGroup",children:[d(Vle,{label:"GCS URL",url:r}),d(Vle,{label:"Google Image Service URL",url:t.src})]}),t&&!r&&d("div",{className:"AssetsPage__urlGroup",children:d(Vle,{url:t.src})}),t&&d(J,{variant:"outline",fullWidth:!0,onClick:()=>e(null),mt:"md",children:"Upload another file"})]})]})})}function Vle(t){return d("div",{className:"AssetsPage__urlRow",children:[t.label&&d("div",{className:"AssetsPage__urlRow__label",children:t.label}),d("div",{className:"AssetsPage__urlRow__input",children:[d(Fr,{readOnly:!0,value:t.url,autosize:!0,minRows:1,size:"xs",radius:"xs",onClick:e=>e.target.select(),styles:{root:{flex:1,minWidth:0}}}),d(Xer,{url:t.url})]})]})}function Xer(t){let[e,r]=R(!1);return d(_e,{label:e?"Copied!":"Copy URL",position:"top",withArrow:!0,children:d(Ae,{variant:"default",size:"lg",onClick:()=>{navigator.clipboard.writeText(t.url).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})},children:d(dc,{size:16})})})}var Nit=x(()=>{"use strict";Ve();zt();Ee();Dit();Oi();Hl();mi();Sn();In();Oit();q()});var Fit=x(()=>{});var Lit=x(()=>{});function Bit(t){let e={},r=[],o={};if(Object.entries(t).forEach(([a,s])=>{e[a]={id:a,name:s.name||a,description:s.description,isGroup:!1,collection:s,children:[]}}),Object.entries(t).forEach(([a,s])=>{let l=e[a],c=s.group||"Content";c?(o[c]||(o[c]={id:`group:${c}`,name:c,isGroup:!0,children:[]}),o[c].children.push(l)):r.push(l)}),Object.keys(o).length>0&&r.length>0){let a={id:"group:Content",name:"Content",isGroup:!0,children:r},s=Object.values(o).sort((l,c)=>l.name.localeCompare(c.name));return[a,...s]}Object.values(o).forEach(a=>{r.push(a)});let i=a=>{a.sort((s,l)=>s.name.localeCompare(l.name)),a.forEach(s=>{s.children.length>0&&i(s.children)})};return i(r),r}var zit=x(()=>{"use strict"});function G3(t){let{collections:e,activeCollectionId:r,projectId:o}=t,[n,i]=ln(`root-cms::${o}::closed_groups`,[]),a=X(()=>Bit(e),[]),s=(l,c)=>{c?i(n.filter(u=>u!==l)):n.includes(l)||i([...n,l])};return d("div",{className:me(t.className,"CollectionTree"),children:[a.map(l=>d(Vit,{node:l,depth:0,activeCollectionId:r,closedGroups:n,onAccordionChange:s},l.id)),a.length===0&&d("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function Vit(t){let{node:e,depth:r,activeCollectionId:o,closedGroups:n,onAccordionChange:i}=t,a=e.children.length>0;return e.isGroup?a?d($it,{node:e,depth:r,activeCollectionId:o,closedGroups:n,onAccordionChange:i,label:d("div",{className:"CollectionTree__group__label",children:d("span",{children:e.name})})}):d("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${r*16}px`},children:[d(Jp,{size:20,strokeWidth:"1.75"}),d("span",{children:e.name})]}):a?d($it,{node:e,depth:r,activeCollectionId:o,closedGroups:n,onAccordionChange:i,label:d("div",{className:"CollectionTree__collection__label",children:d("a",{className:me("CollectionTree__collection-link",e.id===o&&"active"),href:`/cms/content/${e.id}`,onClick:s=>s.stopPropagation(),children:e.name})})}):d("a",{className:me("CollectionTree__collection",e.id===o&&"active"),href:`/cms/content/${e.id}`,children:[d("div",{className:"CollectionTree__collection__icon",children:d(Jp,{size:20,strokeWidth:"1.75"})}),d("div",{className:"CollectionTree__collection__content",children:[d("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&d("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function $it(t){let{node:e,depth:r,label:o,activeCollectionId:n,closedGroups:i,onAccordionChange:a}=t,s=!i.includes(e.id);return d("div",{className:"CollectionTree__accordion",children:d(ca,{iconPosition:"left",initialItem:s?0:-1,offsetIcon:!1,onChange:()=>a(e.id,!s),children:d(ca.Item,{label:o,children:d("div",{className:"CollectionTree__accordion__children",children:e.children.map(l=>d(Vit,{node:l,depth:r+1,activeCollectionId:n,closedGroups:i,onAccordionChange:a},l.id))})})})})}var Ule=x(()=>{"use strict";Lit();Ve();zt();Ee();yh();Sr();zit();q()});var Uit={};yt(Uit,{CollectionPage:()=>cD});function cD(t){let{route:e}=Fo(),r=window.__ROOT_CTX.rootConfig.projectId;cr(t.collection?t.collection:"Content"),$(()=>{let n=window.__ROOT_CTX.collections,i=`root-cms::${r}::last_collection`;if(t.collection)window.localStorage.setItem(i,t.collection);else{let a=window.localStorage.getItem(i);if(a&&n[a]){e(`/cms/content/${a}`);return}if(window.__ROOT_CTX.collections.Pages){e("/cms/content/Pages");return}let s=Object.keys(window.__ROOT_CTX.collections)||[];if(s.length>0){let l=s[0];e(`/cms/content/${l}`);return}console.warn("no collections")}},[t.collection,r]);let o=window.__ROOT_CTX.collections;return d(ht,{children:d("div",{className:"CollectionPage",children:d("div",{className:"CollectionPage__layout",children:[d("div",{className:"CollectionPage__side",children:d(G3,{collections:o,activeCollectionId:t.collection,projectId:r})}),d("div",{className:"CollectionPage__main",children:t.collection&&d(cD.Collection,{collection:t.collection},t.collection)})]})})})}var Hit=x(()=>{"use strict";Fit();Ve();zt();Ee();Fs();Ule();dd();Cte();t1();yL();jQ();Hl();zQ();yh();Sn();El();In();x4();Xo();Ic();q();cD.Collection=t=>{let{roles:e}=cn(),r=window.firebase.user.email||"",o=Nf(e,r),[n,i]=ln(`root::CollectionPage:${t.collection}:orderBy`,"modifiedAt"),[a,s]=ln(`root::CollectionPage:${t.collection}:showArchived`,!1),[l,c]=R(!1),u=window.__ROOT_CTX.collections[t.collection];if(!u)return route("/cms/content"),d(Ie,{});let f=[{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"},...u.sortOptions?.map(g=>({value:g.id,label:g.label}))||[]],[p,h,m]=T4(t.collection,{orderBy:n,includeArchived:a});return d(Ie,{children:[d(R4,{collection:t.collection,opened:l,onClose:()=>c(!1)}),d("div",{className:"CollectionPage__collection",children:d("div",{className:"CollectionPage__collection__docsTab",children:[!p&&d("div",{className:"CollectionPage__collection__docsTab__header",children:[d("div",{className:"CollectionPage__collection__docsTab__header__title",children:u.name||t.collection}),d("div",{className:"CollectionPage__collection__docsTab__controls",children:[d("div",{className:"CollectionPage__collection__docsTab__controls__showArchived",children:d(Mm,{size:"sm",color:"dark",label:"Show archived:",checked:a,onChange:g=>s(!!g.currentTarget.checked)})}),d("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[d("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),d(Lr,{size:"xs",value:n,onChange:g=>i(g||"modifiedAt"),data:f})]}),d("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:d(wn,{label:"You don't have access to create new documents",condition:!o,children:d(J,{color:"dark",size:"xs",leftIcon:d(f0,{size:16}),onClick:()=>c(!0),disabled:!o,children:"New"})})})]})]}),d(Mr,{className:"CollectionPage__collection__docsTab__content",children:p?d("div",{className:"CollectionPage__collection__docsTab__content__loading",children:d(gt,{color:"gray",size:"xl"})}):m.length===0?d("div",{class:"CollectionPage__collection__docsEmpty",children:[d("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),d("div",{class:"CollectionPage__collection__docsEmpty__button",children:d(wn,{label:"You don't have access to create new documents",condition:!o,children:d(J,{color:"dark",size:"xs",leftIcon:d(f0,{size:16}),onClick:()=>c(!0),disabled:!o,children:"New"})})})]}):d(cD.DocsList,{collection:t.collection,docs:m,reloadDocs:()=>h()})})]})})]})};cD.DocsList=t=>{let e=t.collection,r=window.__ROOT_CTX.collections[t.collection];if(!r)throw new Error(`could not find collection: ${e}`);let o=!!r.url,n=t.docs||[];function i(a){return o?dP({collectionId:e,slug:a}):""}return d("div",{className:"CollectionPage__collection__docsList",children:n.map(a=>{let s=`/cms/content/${e}/${a.slug}`,l=i(a.slug),c=a.fields||{},u=ti(c,r.preview?.title||"meta.title"),f=ti(c,r.preview?.image||"meta.image")||r.preview?.defaultImage;return d("div",{className:"CollectionPage__collection__docsList__doc",children:[d("div",{className:"CollectionPage__collection__docsList__doc__image",children:d("a",{href:s,children:d(c0,{file:f,width:120,height:90,withPlaceholder:!f?.src})})}),d("a",{className:"CollectionPage__collection__docsList__doc__content",href:s,children:[d("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[d("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:a.id}),d(ig,{doc:a})]}),d("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:u||"[UNTITLED]"}),o&&l&&d("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:l})]}),d("div",{className:"CollectionPage__collection__docsList__doc__controls",children:d(Ez,{docId:a.id,data:a,onAction:p=>{(p.action==="archive"||p.action==="copy"||p.action==="unarchive"||p.action==="delete"||p.action==="unpublish"||p.action==="locked"||p.action==="unlocked")&&t.reloadDocs()}})})]},a.id)})})}});var jit=x(()=>{});var Wit={};yt(Wit,{ComparePage:()=>Qer});function Qer(){let{query:t}=Fo();cr("Compare");let e=X(()=>Git(t.left||""),[t.left]),r=X(()=>Git(t.right||""),[t.right]);return d(ht,{children:d("div",{className:"ComparePage",children:e&&r?d(X4,{className:"ComparePage__diff",left:e,right:r}):d("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function Git(t){let[e,r]=String(t).split("@");return e&&r?{docId:e,versionId:r}:null}var qit=x(()=>{"use strict";jit();Ee();Fs();gee();Sn();In();q()});var Kit=x(()=>{});function Xit(t){let e=t.dataSource;return Zit(e.archivedAt)?d(_e,{...Yit,label:`Archived ${Jit(e.archivedAt)} by ${e.archivedBy}`,children:d(vn,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):Zit(e.publishedAt)?d(_e,{...Yit,label:`Published ${Jit(e.publishedAt)} by ${e.publishedBy}`,children:d(vn,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):d(vn,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function Zit(t){return!!(t&&t.toMillis)}function Jit(t){return t?.toMillis?lc(t.toMillis()):lc(new Date().getTime())}var Yit,Qit=x(()=>{"use strict";Ve();vl();q();Yit={transition:"pop"}});function eat(t){let e=ttr(t.timestamp),[r,o]=R(e>0?lc(e,{style:"short"}):"never");return e?($(()=>{let n=window.setInterval(()=>{o(lc(e,{style:"short"}))},6e4);return()=>window.clearInterval(n)},[]),d(_e,{transition:"pop",label:`${etr(e)} by ${t.email}`,children:lc(e,{style:"short"})})):d("div",{children:r})}function etr(t){return new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ttr(t){return typeof t=="number"?t:t?.toMillis?t.toMillis():0}var tat=x(()=>{"use strict";Ve();Ee();vl();q()});var rat=x(()=>{});function xI(t){let e=t.dataSource,[r,o]=R(!1),[n,i]=R(t.action==="sync"?e.syncedAt:e.publishedAt),[a,s]=R(t.action==="sync"?e.syncedBy:e.publishedBy),l=Of(),{roles:c}=cn(),u=window.firebase.user.email||"",f=wa(c,u),p=t.action==="publish",h=!!e.archivedAt;async function m(){o(!0);let v=`data-source-${t.action}-${e.id}`;ge({id:v,loading:!0,title:`Running Data Source ${t.action}`,message:`Updating ${e.id}...`,autoClose:!1,disallowClose:!0});try{t.action==="sync"?(e.type==="gsheet"&&!l.isLoggedIn()&&await l.login(),await RDe(e.id)):t.action==="publish"&&await DDe(e.id),i(Nt.now()),s(window.firebase.user.email),o(!1),t.onAction&&t.onAction(),xr({id:v,title:"Success",message:`Updated Data Source ${e.id}`,autoClose:!1})}catch(y){console.error(y);let b=y;typeof y=="object"&&y.body&&(b=String(y.body)),o(!1),xr({id:v,title:`Data Source ${t.action} failed`,message:String(b),color:"red",autoClose:!1})}}let g="";return t.action==="sync"?g="Sync data to a draft state":t.action==="publish"&&(g="Publish synced data to prod"),d("div",{className:"DataSourceStatusButton",children:[d("div",{className:"DataSourceStatusButton__label",children:!r&&d(eat,{timestamp:n,email:a})}),d("div",{className:"DataSourceStatusButton__button",children:d(wn,{label:h?"Data source is archived":"You don't have access to publish this data source",condition:h||p&&!f,children:d(_e,{transition:"pop",label:g,disabled:h||p&&!f,children:d(J,{variant:"default",size:"xs",compact:!0,onClick:()=>m(),loading:r,disabled:h||p&&!f,children:t.action})})})})]})}var Hle=x(()=>{"use strict";Ve();_o();an();Ee();jC();El();qp();Ic();dd();tat();rat();q()});var oat={};yt(oat,{DataPage:()=>jle});function jle(){cr("Data Sources");let{roles:t}=cn(),e=window.firebase.user.email||"",r=Nf(t,e);return d(ht,{children:d("div",{className:"DataPage",children:[d("div",{className:"DataPage__header",children:[d(Vt,{size:"h1",children:"Data Sources"}),d(ft,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),d("div",{className:"DataPage__header__buttons",children:d(wn,{label:"You don't have access to create new data sources",condition:!r,children:d(J,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",disabled:!r,style:r?void 0:{pointerEvents:"none"},children:"New data source"})})})]}),d(jle.DataSourcesTable,{})]})})}var nat=x(()=>{"use strict";Kit();Ve();zt();Ee();dd();Qit();Hle();Oi();Hl();mi();yh();Sn();El();In();qp();Ic();q();jle.DataSourcesTable=()=>{let[t,e]=R(!0),[r,o]=R([]),[n,i]=ln("root::DataPage:showArchived",!1),a=u=>!!u&&u.startsWith("https://docs.google.com/spreadsheets/");async function s(){let u=await i0();o(u),e(!1)}let l=X(()=>r.some(u=>!!u.archivedAt),[r]),c=X(()=>r.filter(u=>{let f=!!u.archivedAt;return n?!0:!f}),[r,n]);return $(()=>{s()},[]),d(Mr,{className:"DataPage__DataSourcesTable",children:[t&&d(gt,{color:"gray",size:"xl"}),!t&&d(Ie,{children:[l&&d("div",{className:"DataPage__DataSourcesTable__filters",children:d(Mm,{size:"sm",color:"dark",label:"Show archived",checked:n,onChange:u=>i(!!u.currentTarget.checked)})}),c.length>0&&d(pi,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[d("thead",{children:d("tr",{children:[d("th",{children:"id"}),d("th",{children:"description"}),d("th",{children:"type"}),d("th",{children:"url"}),d("th",{children:"status"}),d("th",{children:"last synced"}),d("th",{children:"last published"})]})}),d("tbody",{children:c.map(u=>d("tr",{children:[d("td",{children:d("a",{href:`/cms/data/${u.id}`,children:u.id})}),d("td",{children:u.description||""}),d("td",{children:u.type}),d("td",{children:a(u.url)?d("div",{className:"DataPage__DataSourcesTable__url",children:[d(_e,{label:"Open spreadsheet",children:d(Ae,{component:"a",href:u.url,target:"_blank",rel:"noreferrer",variant:"filled",color:"green",size:"sm","aria-label":"Open spreadsheet",children:d(pc,{size:16,stroke:"2.25"})})}),d("a",{className:"DataPage__DataSourcesTable__url__text",href:u.url,target:"_blank",rel:"noreferrer",children:u.url})]}):u.url||""}),d("td",{children:d(Xit,{dataSource:u})}),d("td",{children:d(xI,{dataSource:u,action:"sync"})}),d("td",{children:d(xI,{dataSource:u,action:"publish"})})]},u.id))})]}),c.length===0&&d(ft,{as:"p",children:"No data sources found for this filter."})]})]})}});var iat=x(()=>{});var aat={};yt(aat,{DataSourcePage:()=>Eu});function Eu(t){cr(`Data Source: ${t.id}`);let[e,r]=R(!0),[o,n]=R(null),[i,a]=R(null),s=t.id;async function l(){let u=await cc(s);if(n(u),u){let f=await aL(s,{mode:"draft"});a(f)}r(!1)}$(()=>{l()},[]);function c(u){u==="sync"&&l()}return d(ht,{children:d("div",{className:"DataSourcePage",children:[d("div",{className:"DataSourcePage__header",children:[d(Yn,{className:"DataSourcePage__header__breadcrumbs",children:[d("a",{href:"/cms/data",children:"Data"}),d("div",{children:s})]}),d("div",{className:"DataSourcePage__header__titleWrap",children:[d(Vt,{size:"h1",children:["Data Source: ",s]}),d("div",{className:"DataSourcePage__header__controls",children:d(_e,{label:"Configure",children:d(Ae,{component:"a",href:`/cms/data/${t.id}/edit`,children:d(nb,{size:24,stroke:"1.5"})})})})]}),o?.description&&d(ft,{as:"p",children:o.description})]}),o&&d(Eu.SyncStatus,{dataSource:o,onAction:c}),e?d(gt,{color:"gray",size:"xl"}):o?d(Eu.DataSection,{dataSource:o,data:i}):d("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}var sat=x(()=>{"use strict";Ve();zt();Ee();Hle();Oi();Hl();mi();Sn();In();qp();iat();q();Eu.SyncStatus=t=>{let e=t.dataSource;return d("div",{className:"DataSourcePage__SyncStatus",children:[d(Vt,{size:"h2",children:"Status"}),d(Mr,{className:"DataSourcePage__SyncStatus__content",children:d(pi,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[d("thead",{children:d("tr",{children:[d("th",{children:"last synced"}),d("th",{children:"last published"})]})}),d("tbody",{children:d("tr",{children:[d("td",{children:d(xI,{dataSource:e,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),d("td",{children:d(xI,{dataSource:e,action:"publish"})})]})})]})})]})};Eu.DataSection=t=>{let{data:e,headers:r}=t.data||{},o=t.dataSource;if(!e)return null;let n=o.dataFormat||"map";if(o.type==="gsheet"){let i=r,a=[];if(n==="array")a=e;else if(n==="map"){let s=e;if(!i){let l=new Set;s.forEach(c=>{for(let u in c)u&&l.add(u)}),i=Array.from(l)}s.forEach(l=>{a.push(i.map(c=>l[c]||""))})}return d(Eu.DataSectionWrap,{dataSource:o,children:d(Eu.DataTable,{headers:i,rows:a})})}return o.type==="http"?d(Eu.DataSectionWrap,{dataSource:o,children:d(Eu.DefaultDataDisplay,{data:e})}):(console.log(`unsupported data type: ${o.type}`),null)};Eu.DataSectionWrap=t=>d("div",{className:"DataSourcePage__DataSection",children:[d("div",{className:"DataSourcePage__DataSection__header",children:[d(Vt,{size:"h2",children:"Data"}),d("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&d(_e,{label:"Open spreadsheet",children:d(Ae,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:d(pc,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&d(J,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),d(Mr,{className:"DataSourcePage__DataSection__content",children:t.children})]});Eu.DataTable=t=>{let e=t.headers||[],r=t.rows||[];return d("div",{className:"DataSourcePage__DataTable",children:d(pi,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e.length>0&&d("thead",{children:d("tr",{children:e.map(o=>d("th",{children:o},o))})}),d("tbody",{children:r.map((o,n)=>d("tr",{children:o.map((i,a)=>d("td",{children:i},a))},n))})]})})};Eu.DefaultDataDisplay=t=>{let e=t.data;return typeof e=="object"?d(Am,{value:JSON.stringify(e,null,2),minRows:20,maxRows:100}):d(Fr,{value:String(e),minRows:12,maxRows:100})}});function lat(t,e,r={}){let{query:o,route:n}=Fo(),{replace:i=!1,serialize:a=g=>String(g),deserialize:s=g=>g}=r,l=V(e),c=V(a),u=V(s);l.current=e,c.current=a,u.current=s;let f=ae(()=>{let g=o[t];return g!==void 0?u.current(g):l.current},[o,t]),[p,h]=R(f);$(()=>{h(f())},[f]);let m=ae(g=>{h(g);let v=new URL(window.location.href),y=c.current(g);y===String(l.current)||y===""?v.searchParams.delete(t):v.searchParams.set(t,y);let b=v.pathname+v.search;n(b,i)},[t,i,n]);return[p,m]}function W3(t,e=""){return lat(t,e)}function uD(t,e=[]){return lat(t,e,{serialize:r=>Array.isArray(r)?r.join(","):"",deserialize:r=>r?r.split(",").filter(Boolean):e})}var q3=x(()=>{"use strict";Ee();Fs()});var cat=x(()=>{});var uat={};yt(uat,{DocTranslationsPage:()=>Rx});function Rx(t){cr(`Translations: ${t.collection}/${t.slug}`);let[e,r]=R(!0),[o,n]=R(!1),[i,a]=R([]),[s,l]=R({}),[c,u]=R(null),[f,p]=R(!1),[h,m]=R({}),[g,v]=R(!1),y=t.collection,b=t.slug,_=`${y}/${b}`,C=G4(),I=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||[],[S,T]=uD("locale",I);async function k(){try{let[M,z,F]=await Promise.all([H4(_),su(),dL(_)]);a(M),l(z),u(F),r(!1)}catch(M){console.error(M),r(!1),n(!0)}}if($(()=>{k()},[]),o)return d(Rx.NotFound,{docId:_});function P(M,z,F){p(!0),m(U=>{let j={...U},G=j[M]??{};return G.source=M,G[z]=F,j[M]=G,j})}async function D(){v(!0),await Vr(async()=>{console.log("EditTranslationsModal.onSave()");let M=`edit-translations-${_}`;ge({id:M,loading:!0,title:"Saving translations",message:`Updating for ${_}...`,autoClose:!1,disallowClose:!0});let z=Object.values(h);console.log(z),await og(_,z),xr({id:M,title:"Saved translations",message:`Updated translations for ${_}!`,autoClose:!0}),m({}),p(!1)}),v(!1)}function O(M){S.length===I.length?T([M]):T(I)}return d(ht,{children:d("div",{className:"DocTranslationsPage",children:[d("div",{className:"DocTranslationsPage__header",children:[d(Yn,{className:"DocTranslationsPage__header__breadcrumbs",children:[d("a",{href:`/cms/content/${y}`,children:y}),d("a",{href:`/cms/content/${y}/${b}`,children:b}),d("div",{children:"translations"})]}),d("div",{className:"DocTranslationsPage__header__titleWrap",children:d(Vt,{size:"h1",children:["Translations: ",_]})}),d("div",{className:"DocTranslationsPage__header__controls",children:[c&&d("div",{className:"DocTranslationsPage__header__linkedSheet",children:d("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[d(_e,{label:"Open Google Sheet",children:d(Ae,{component:"a",href:au(c),target:"_blank",variant:"filled",color:"green",size:"sm",children:d(pc,{size:16,strokeWidth:2.25})})}),d(J,{variant:"default",size:"xs",leftIcon:d(sg,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),d(J,{variant:"default",size:"xs",leftIcon:d(tb,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),d(ke,{className:"DocTranslationsPage__toolsMenu",control:d(_e,{label:"Tools",children:d(Ae,{variant:"default",children:d(lg,{size:16})})}),size:220,children:d(ke.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:d(ob,{size:16}),onClick:()=>C.open({docId:_,sourceStrings:i,onPruned:M=>{l(z=>{let F={...z};return M.forEach(U=>delete F[U]),F})}}),children:"Prune unused strings"})})]})]}),d("div",{className:me("DocTranslationsPage__content",e&&"DocTranslationsPage__content--loading"),children:e?d(gt,{color:"gray",size:"xl"}):d(Rx.Table,{locales:S,sourceStrings:i,translationsMap:s,onChange:P,changesMap:h,onSelectLocale:M=>O(M)})}),d("div",{className:"DocTranslationsPage__footer",children:d("div",{className:"DocTranslationsPage__footer__buttons",children:d(J,{variant:"filled",color:"dark",disabled:!f,loading:g,onClick:()=>D(),children:"Save"})})})]})})}var dat=x(()=>{"use strict";Ve();_o();zt();Ee();Oi();q4();Sn();q3();In();Sr();Qn();gP();Wp();uc();Gi();cat();q();Rx.NotFound=t=>d(ht,{children:d("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:d("div",{className:"DocTranslationsPage__error",children:[d("div",{className:"DocTranslationsPage__error__icon",children:d(m1,{size:60})}),d("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",t.docId]})]})})});Rx.Table=t=>{let r=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||[],o=X(()=>{let i={};return Object.values(t.translationsMap).forEach(a=>{i[a.source]=a}),i},[t.translationsMap]);function n(i,a){return{translation:(o[i]||{})[a]||"",hasChanges:!1}}return d("div",{className:"DocTranslationsPage__TableWrap",children:d("table",{className:"DocTranslationsPage__Table",children:[d("thead",{children:d("tr",{children:[d("th",{className:"DocTranslationsPage__Table__sourceCellHeader",children:d("div",{className:"DocTranslationsPage__Table__headerLabel",children:"source"})}),t.locales.map(i=>d("th",{onClick:()=>t.onSelectLocale(i),className:"DocTranslationsPage__Table__localeHeader",children:d(_e,{className:"DocTranslationsPage__Table__headerTooltip",placement:"start",withArrow:!0,label:t.locales.length===r.length?`Show only ${i}`:"Show all locales",children:d("div",{className:"DocTranslationsPage__Table__headerLabel",children:i})})},i))]})}),d("tbody",{children:t.sourceStrings.map(i=>d("tr",{children:[d("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:d("div",{className:"DocTranslationsPage__Table__sourceCell",children:i})}),t.locales.map(a=>{let s=n(i,a);return d("td",{children:d(Rx.Textarea,{source:i,locale:a,value:s.translation,onChange:t.onChange,changesMap:t.changesMap})},a)})]},i))})]})})};Rx.Textarea=t=>{let e=V(null),[r,o]=R(t.value),n=null;t.locale in(t.changesMap[t.source]||{})&&(n=t.changesMap[t.source][t.locale]);let i=n!==null&&n!==t.value;function a(){window.requestAnimationFrame(()=>{let s=e.current;s.style.minHeight="auto";let l=s.scrollHeight;s.style.minHeight=`${l}px`})}return $(()=>{a()},[r]),d("textarea",{ref:e,className:me("DocTranslationsPage__Textarea",i&&"DocTranslationsPage__Textarea--hasChanges",!r&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>a(),rows:1,onChange:s=>{let l=s.target.value;o(l),t.onChange(t.source,t.locale,l)},value:r})}});var fat=x(()=>{});var pat=x(()=>{});async function hat(t,e){let o=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:e})})).json();if(!o.success)throw new Error(o.error||"Check failed.");return o.data}function mat(t){let e=window.__ROOT_CTX.checks||[],r=t.docId.split("/")[0],o=e.filter(l=>!l.collections||l.collections.includes(r)),[n,i]=R({}),a=ae(async l=>{i(c=>({...c,[l]:{loading:!0}}));try{let c=await hat(l,t.docId);i(u=>({...u,[l]:{loading:!1,result:c}}))}catch(c){i(u=>({...u,[l]:{loading:!1,error:c.message||"Unknown error."}}))}},[t.docId]),s=ae(async()=>{let l={};for(let c of o)l[c.id]={loading:!0};i(l);for(let c of o)try{let u=await hat(c.id,t.docId);i(f=>({...f,[c.id]:{loading:!1,result:u}}))}catch(u){i(f=>({...f,[c.id]:{loading:!1,error:u.message||"Unknown error."}}))}},[t.docId,o]);return d("div",{className:"ChecksPanel",children:[d("div",{className:"ChecksPanel__header",children:[d("div",{className:"ChecksPanel__header__title",children:"Checks"}),d(J,{variant:"default",size:"xs",compact:!0,leftIcon:d(d7,{size:12}),onClick:s,children:"Run All"})]}),d("div",{className:"ChecksPanel__body",children:d("div",{className:"ChecksPanel__checks",children:o.map(l=>{let c=n[l.id];return d(rtr,{check:l,state:c,onRun:()=>a(l.id)},l.id)})})})]})}function rtr(t){let{check:e,state:r,onRun:o}=t;return d("div",{className:"ChecksPanel__check",children:[d("div",{className:"ChecksPanel__check__header",children:[d("div",{className:"ChecksPanel__check__label",children:[e.label,r?.result&&d(itr,{status:r.result.status})]}),d(J,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:r?.loading,onClick:o,children:"Run"})]}),e.description&&d("div",{className:"ChecksPanel__check__description",children:e.description}),r?.result&&d("div",{className:me("ChecksPanel__check__result",`ChecksPanel__check__result--${r.result.status}`),children:d(hu,{code:r.result.message})}),r?.error&&d("div",{className:"ChecksPanel__check__error",children:r.error})]})}function itr(t){let e=otr[t.status],r=ntr[t.status],o=t.status.charAt(0).toUpperCase()+t.status.slice(1);return d(vn,{className:"ChecksPanel__statusBadge",color:e,size:"sm",variant:"filled",leftSection:d(r,{size:10}),children:o})}var otr,ntr,gat=x(()=>{"use strict";pat();Ve();zt();Ee();Sr();LC();q();otr={success:"green",warning:"yellow",error:"red"},ntr={success:kn,warning:d0,error:qi}});var vat=x(()=>{});function yat(t){let{device:e,expandVertically:r,iframeUrl:o,localeOptions:n,selectedLocale:i,onToggleDevice:a,onToggleExpandVertically:s,onReloadClick:l,onOpenNewTab:c,onLocaleChange:u}=t;return d("div",{className:"DocumentPagePreviewBar",children:[d("div",{className:"DocumentPagePreviewBar__devices",children:[d(_e,{label:"Mobile",children:d(Ae,{className:me("DocumentPagePreviewBar__device",e==="mobile"&&"active"),onClick:()=>a("mobile"),children:d(zW,{size:16})})}),d(_e,{label:"Tablet",children:d(Ae,{className:me("DocumentPagePreviewBar__device",e==="tablet"&&"active"),onClick:()=>a("tablet"),children:d(BW,{size:16})})}),d(_e,{label:"Desktop",children:d(Ae,{className:me("DocumentPagePreviewBar__device",e==="desktop"&&"active"),onClick:()=>a("desktop"),children:d(LW,{size:16})})}),d(_e,{label:"Expand",children:d(Ae,{className:me("DocumentPagePreviewBar__device",r&&"active"),"aria-pressed":r,disabled:e==="",onClick:s,children:d(r1,{size:16})})})]}),d("div",{className:"DocumentPagePreviewBar__navbar",children:d("div",{className:"DocumentPagePreviewBar__navbar__url",children:o})}),d("div",{className:"DocumentPagePreviewBar__locales",children:d(Lr,{data:n,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:d(S1,{size:16,strokeWidth:1.5}),value:i,onChange:f=>{u(f)}})}),d("div",{className:"DocumentPagePreviewBar__buttons",children:[d(_e,{label:"Reload",children:d(Ae,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:l,children:d(m7,{size:16})})}),d(_e,{label:"Open new tab",children:d(Ae,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:c,children:d(Ls,{size:16})})})]})]})}var bat=x(()=>{"use strict";vat();Ve();zt();Sr();q()});var xat=x(()=>{});function _at(t){let e=t.docId.split("/")[0],r=$C(e),o=gi(),n=V(null),[i,a]=R(""),[s,l]=R([]),[c,u]=R(!1),f=V("");f.current=i;let p=V(r.schema?.fields||[]);p.current=r.schema?.fields||[];let h=V(r.schema?.types||{});h.current=r.schema?.types||{};let m=X(()=>WC(v=>{let y=v.trim();if(!y){l([]),u(!1);return}let b=o.controller?.getData()?.fields||{},_=crt(y,b,p.current,h.current);l(_),u(!0)},150),[o.controller]);$(()=>{m(i)},[i,m]),xVe(()=>{f.current.trim()&&m(f.current)}),$(()=>{t.autoFocus&&requestAnimationFrame(()=>{n.current?.focus(),n.current?.select()})},[t.autoFocus]),$(()=>{let v=()=>{n.current?.focus(),n.current?.select()};return window.addEventListener("root:focus-search",v),()=>window.removeEventListener("root:focus-search",v)},[]);let g=v=>{ltr(v)};return d("div",{className:"SearchPanel",children:[d("div",{className:"SearchPanel__header",children:[d("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&d(Ae,{size:"xs",onClick:t.onClose,title:"Close search",children:d(qi,{size:14})})]}),d("div",{className:"SearchPanel__searchInput",children:[d("span",{className:"SearchPanel__searchInput__icon",children:d(Ka,{size:14})}),d("input",{ref:n,type:"text",className:"SearchPanel__searchInput__input",value:i,onInput:v=>a(v.currentTarget.value),onKeyDown:v=>{v.key==="Escape"&&t.onClose&&(v.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),d("div",{className:"SearchPanel__body",children:[!c&&!i.trim()&&d("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),c&&s.length===0&&d("div",{className:"SearchPanel__empty",children:["No matches for ",d("strong",{children:i}),"."]}),s.length>0&&d(Ie,{children:[d("div",{className:"SearchPanel__resultsCount",children:[s.length," ",s.length===1?"match":"matches"]}),d("ul",{className:"SearchPanel__results",children:s.map((v,y)=>d(atr,{result:v,onClick:()=>g(v)},`${v.deepKey}:${y}`))})]})]})]})}function atr(t){let{result:e}=t;return d("li",{className:"SearchPanel__result",children:d("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[d("div",{className:"SearchPanel__result__label",children:e.label}),d("div",{className:"SearchPanel__result__snippet",children:str(e.snippet,e.matches)}),d("div",{className:"SearchPanel__result__meta",children:[d("span",{className:"SearchPanel__result__type",children:e.fieldType}),e.richTextBlock&&d("span",{className:"SearchPanel__result__badge",children:"in block"}),e.richTextInline&&d("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function str(t,e){if(!e||e.length===0)return t;let r=[],o=0;for(let n of e)n.start>o&&r.push({text:t.slice(o,n.start),match:!1}),r.push({text:t.slice(n.start,n.end),match:!0}),o=n.end;return o<t.length&&r.push({text:t.slice(o),match:!1}),r.map((n,i)=>n.match?d("mark",{children:n.text},i):d("span",{children:n.text},i))}function ltr(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let e=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(rD,{detail:e}))},350)}else if(t.richTextInline){let e=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(oD,{detail:e}))},350)}}var wat=x(()=>{"use strict";xat();Ve();zt();Ee();k4();Zi();ez();Use();q()});var Cat=x(()=>{});function dD(t){let{className:e,localStorageId:r,children:o}=t,[n,i]=ln(`root::SplitPanel:${r}`,350),[a,s]=R(!1),[l,c]=R(0),u=X(()=>new Set,[]),f=V(null),p=V(null),h={onResize:g=>(u.add(g),()=>{u.delete(g)})};if($(()=>{let g=()=>s(!1);window.addEventListener("mouseup",g);let v=f.current;return v&&c(v.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",g)},[]),$(()=>{let g=v=>{let y=v.clientX-l;i(y),u.forEach(b=>b())};return a&&window.addEventListener("mousemove",g),()=>window.removeEventListener("mousemove",g)},[a]),o?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let m={"--panel-size":`${n}px`};return d(ctr.Provider,{value:h,children:d("div",{className:me(e,"SplitPanel",a&&"dragging"),ref:f,style:m,children:[o[0],d("div",{className:"SplitPanel__divider",ref:p,onMouseDown:()=>s(!0)}),o[1]]})})}var ctr,Sat=x(()=>{"use strict";hn();Ee();yh();Sr();Cat();q();ctr=Pt(null);dD.Item=t=>d("div",{className:me("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children})});var Tat={};yt(Tat,{DocumentPage:()=>Wle});function Gle(t,e,r=""){let o=b4({collectionId:t,slug:e}),n=new URLSearchParams(window.location.search);n.set("preview","true"),n.delete("locale"),n.delete("modal");let i=`${n.toString()}${window.location.hash}`;return r?`${b4({collectionId:t,slug:e,locale:r})}?${i}`:`${o}?${i}`}function Wle(t){let e=t.collection,r=t.slug,o=`${e}/${r}`,{roles:n}=cn(),i=window.firebase.user.email||"",a=Nf(n,i);return d(nz,{docId:o,readOnly:!a,children:d(utr,{...t,canEdit:a})})}function utr(t){let e=t.canEdit,r=t.collection,o=t.slug,n=`${r}/${o}`;cr(n);let i=window.__ROOT_CTX.collections[r],a=gi(),s=!!i?.url,[l,c]=ln(`root::DocumentPage::previewVisible::${r}`,s),u=X(()=>(window.__ROOT_CTX.checks||[]).some(W=>!W.collections||W.collections.includes(r)),[r]),[f,p]=ln("root::DocumentPage::checksVisible",!1),h=V(f);h.current=f;let[m,g]=ln("root::DocumentPage::searchVisible",!1),v=V(m);v.current=m;let y=!!(window.__ROOT_CTX.ai||window.__ROOT_CTX.experiments?.ai),[b,_]=ln("root::DocumentPage::aiVisible",!1),C=V(b);C.current=b,$(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:f}))},[f]),$(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:m}))},[m]),$(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:b}))},[b]);let[E,I]=ln("root::DocumentPage::searchPanelWidth",360),[S,T]=R(E),[k,P]=R(!1),D=V(null);if($(()=>{let te=()=>{let W=!h.current;p(()=>W),W&&(g(()=>!1),_(()=>!1))};return window.addEventListener("root:toggle-checks",te),()=>window.removeEventListener("root:toggle-checks",te)},[]),$(()=>{let te=()=>{let W=!v.current;g(()=>W),W&&(p(()=>!1),_(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",te),()=>window.removeEventListener("root:toggle-search",te)},[]),$(()=>{let te=()=>{let W=!C.current;_(()=>W),W&&(p(()=>!1),g(()=>!1))};return window.addEventListener("root:toggle-ai",te),()=>window.removeEventListener("root:toggle-ai",te)},[]),$(()=>{if(!k)return;let te=ee=>{let Y=D.current;if(!Y)return;let ie=Y.getBoundingClientRect(),ne=Math.max(240,Math.min(ie.right-ee.clientX,800));T(ne)},W=()=>{P(!1),T(ee=>(I(()=>ee),ee))};return window.addEventListener("mousemove",te),window.addEventListener("mouseup",W),()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",W)}},[k]),!i)return d("div",{children:"Could not find collection."});let O=ae(()=>{if(!s)return;let te=Gle(r,o),W=window.open(te,"_blank","noopener,noreferrer");W&&W.focus()},[s,r,o]),M=ae(()=>{e&&a.controller&&a.controller.flush()},[e,a.controller]),z=D4(),F=ae(()=>{let te=a.controller?.getData()?.fields||{};z.open({data:te,onSave:W=>{a.controller&&W&&typeof W=="object"&&(a.controller.updateKey("fields",W),a.controller.flush()),z.close()}})},[a.controller]),U=ae(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),j=ae(()=>{y&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[y]),G=ae(()=>{_(()=>!1)},[_]);return yT([["mod+S",M],["mod+shift+F",U],["mod+I",j]]),d(ht,{children:d("div",{className:me("DocumentPage__layout",k&&"DocumentPage__layout--dragging"),ref:D,children:[d(dD,{className:"DocumentPage",localStorageId:"DocumentPage",children:[d(dD.Item,{className:me("DocumentPage__side",(!s||!l)&&"DocumentPage__side--expanded"),children:[d("div",{className:"DocumentPage__side__header",children:[d("div",{className:"DocumentPage__side__header__nav",children:[d("a",{href:`/cms/content/${r}`,children:d(Ae,{className:"DocumentPage__side__header__back",children:d(wW,{size:16})})}),d("div",{className:"DocumentPage__side__header__docId",children:n})]}),d("div",{className:"DocumentPage__side__header__buttons",children:[d(wn,{label:"You don't have access to edit this document",condition:!e,children:d(J,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:d(c1,{size:16}),onClick:()=>M(),disabled:!e,children:"Save"})}),d(wn,{label:"You don't have access to edit this document",condition:!e,children:d(_e,{label:"Edit JSON",disabled:!e,children:d(Ae,{className:"DocumentPage__side__header__editJson",onClick:()=>F(),disabled:!e,children:d(n1,{size:14})})})}),s&&d(Ie,{children:[d(_e,{label:l?"Hide preview":"Show preview",children:d(Ae,{className:"DocumentPage__side__header__previewToggle",onClick:()=>c(!l),children:l?d(r7,{size:16}):d(o7,{size:16})})}),!l&&d(_e,{label:"Open preview in new tab",children:d(Ae,{className:"DocumentPage__side__header__openNewTab",onClick:O,children:d(Ls,{size:16})})})]})]})]}),d("div",{className:me("DocumentPage__side__editor",(!s||!l)&&!f&&!m&&!b&&"DocumentPage__side__editor--centered"),children:d(kr,{docId:n})})]}),d(dD.Item,{className:me("DocumentPage__main",(!s||!l)&&"DocumentPage__main--hidden"),fluid:!0,children:s&&l&&d(Wle.Preview,{docId:n},n)})]}),u&&f&&d(ftr,{docId:n}),m&&d(Ie,{children:[d("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>P(!0)}),d("div",{className:"DocumentPage__search",style:{flexBasis:`${S}px`},children:d(_at,{docId:n,autoFocus:!0,onClose:()=>g(()=>!1)})})]}),y&&b&&d(dtr,{docId:n,onClose:G})]})})}function dtr(t){let[e,r]=ln("root::DocumentPage::aiPanelWidth",420),[o,n]=R(e),i=V(null),a=V(o),s=V(),l=X(()=>d(j3,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),c=ae(()=>{let u=i.current?.parentElement;if(!u)return;a.current=o,u.classList.add("DocumentPage__layout--dragging");let f=m=>{let g=i.current?.parentElement;if(!g)return;let v=g.getBoundingClientRect(),y=Math.max(280,Math.min(v.right-m.clientX,800));a.current=y,n(y)},p=()=>{u.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",h),s.current=void 0},h=()=>{p(),r(()=>a.current)};s.current=p,window.addEventListener("mousemove",f),window.addEventListener("mouseup",h)},[o,r]);return $(()=>()=>s.current?.(),[]),d(Ie,{children:[d("div",{className:"DocumentPage__aiDivider",ref:i,onMouseDown:c}),d("div",{className:"DocumentPage__ai",style:{flexBasis:`${o}px`},children:l})]})}function ftr(t){let[e,r]=ln("root::DocumentPage::checksPanelWidth",360),[o,n]=R(e),i=V(null),a=V(o),s=V(),l=X(()=>d(mat,{docId:t.docId}),[t.docId]),c=ae(()=>{let u=i.current?.parentElement;if(!u)return;a.current=o,u.classList.add("DocumentPage__layout--dragging");let f=m=>{let g=i.current?.parentElement;if(!g)return;let v=g.getBoundingClientRect(),y=Math.max(200,Math.min(v.right-m.clientX,800));a.current=y,n(y)},p=()=>{u.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",h),s.current=void 0},h=()=>{p(),r(()=>a.current)};s.current=p,window.addEventListener("mousemove",f),window.addEventListener("mouseup",h)},[o,r]);return $(()=>()=>s.current?.(),[]),d(Ie,{children:[d("div",{className:"DocumentPage__checksDivider",ref:i,onMouseDown:c}),d("div",{className:"DocumentPage__checks",style:{flexBasis:`${o}px`},children:l})]})}function ptr(t){let e=new Intl.DisplayNames(["en"],{type:"language"}),o=t.split("_")[0];return`${e.of(o)||t} (${t})`}var Iat,Eat=x(()=>{"use strict";fat();Ve();Cr();zt();Ee();gat();dd();nD();bat();O4();zle();wat();Sat();Zi();yh();Sn();El();q3();In();Sr();x4();Ic();q();Iat={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};Wle.Preview=t=>{let e=gi();if(e.loading)return null;let[r,o]=t.docId.split("/"),i=window.__ROOT_CTX.collections[r];if(!i)throw new Error(`collection not found: ${r}`);if(!i.url)return null;let a=i.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",s=MQ({collectionId:r,slug:o}),l=b4({collectionId:r,slug:o}),c=`${a}${s}`,[u,f]=R(c),[p,h]=ln("root::DocumentPage::preview::device",""),[m,g]=ln("root::DocumentPage::preview::expandVertically",!1),[v,y]=R({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[b,_]=W3("locale",""),C=V(null),E=V(null),I=e.controller.getLocales()||[],S=Gle(r,o,b),T=X(()=>[{value:"",label:"Select locale"},...I.map(F=>({value:F,label:ptr(F)}))],[I]);function k(){if(document.hidden)return;let F=C.current;F.src="about:blank",window.requestAnimationFrame(()=>{F.src!==S?F.src=S:F.contentWindow.location.reload()})}$(()=>{let F=C.current;function U(){let G=F.contentWindow;if(G&&l===s&&!G.location.href.startsWith("about:blank")){let te=G.location.pathname;f(`${a}${te}`)}}F.addEventListener("load",U);let j=e.controller?.onFlush(()=>{k()});return()=>{j(),F.removeEventListener("load",U)}},[]),$(()=>{let F=C.current;F.src=S},[b]);let P=ae(F=>{h(U=>{let j=U===F?"":F;return j===""&&g(!1),j})},[h,g]),D=ae(()=>{h(F=>(F&&g(U=>!U),F))},[h,g]),O=ae(()=>{e.controller&&e.controller.flush().then(()=>k())},[e.controller]),M=ae(()=>{let F=Gle(r,o,b),U=window.open(F,"_blank","noopener,noreferrer");U&&U.focus()},[r,o,b]),z=ae(()=>{if(p===""){let Se={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};y(je=>je["--iframe-width"]===Se["--iframe-width"]&&je["--iframe-height"]===Se["--iframe-height"]&&je["--iframe-scale"]===Se["--iframe-scale"]?je:Se);return}let F=E.current;if(!F)return;let U=F.getBoundingClientRect(),[j,G]=Iat[p],te=20,W=Math.max(U.width-2*te,0),ee=Math.max(U.height-2*te,0),Y=W>0&&j>0?W/j:1,ie=ee>0&&G>0?ee/G:1,ne=Math.min(Y,ie,1),le=Number(ne.toFixed(4))||1,pe=m?`${ee/le}px`:`${G}px`,Re={"--iframe-width":`${j}px`,"--iframe-height":pe,"--iframe-scale":String(le)};y(Se=>Se["--iframe-width"]===Re["--iframe-width"]&&Se["--iframe-height"]===Re["--iframe-height"]&&Se["--iframe-scale"]===Re["--iframe-scale"]?Se:Re)},[p,m]);return $(()=>{z();let F=E.current;if(!F)return;let U=0,j=()=>{window.cancelAnimationFrame(U),U=window.requestAnimationFrame(z)},G=new window.ResizeObserver(j);return G.observe(F),window.addEventListener("resize",j),()=>{window.cancelAnimationFrame(U),G.disconnect(),window.removeEventListener("resize",j)}},[z]),d("div",{className:"DocumentPage__main__preview",children:[d(yat,{device:p,expandVertically:m,iframeUrl:u,localeOptions:T,selectedLocale:b,onToggleDevice:P,onToggleExpandVertically:D,onReloadClick:O,onOpenNewTab:M,onLocaleChange:_}),d("div",{className:"DocumentPage__main__previewFrame","data-device":p||"full",ref:E,style:v,children:[d("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:p?void 0:"none"},children:p?`${p}: ${Iat[p].join("x")}`:""}),d("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:d("iframe",{ref:C,title:"iframe preview"})})]})]})}});var kat=x(()=>{});function K3(t){let{route:e}=Fo(),r=V(null),o=Of(),[n,i]=R(!1),[a,s]=R(o.enabled?"gsheet":"http"),[l,c]=R("map"),[u,f]=R("GET"),[p,h]=R(!1),[m,g]=R(1),[v,y]=R("hours"),[b,_]=R(!1),[C,E]=R(""),[I,S]=R(!!t.dataSourceId),[T,k]=R(null),P="";a==="http"?P=htr:a==="gsheet"&&(P=mtr);async function D(z){await Vr(async()=>{let F=await cc(z);k(F),s(F?.type||"http"),c(F?.dataFormat||"map"),F?.cron?(h(F.cron.enabled||!1),g(F.cron.interval||1),y(F.cron.unit||"hours"),_(F.cron.autoPublish||!1)):(h(!1),g(1),y("hours"),_(!1))}),S(!1)}$(()=>{t.dataSourceId&&(S(!0),D(t.dataSourceId))},[t.dataSourceId]);async function O(){E("");let z=r.current;function F(te){let W=z.elements[te];return W?W.value.trim():""}let U=t.dataSourceId||F("id");if(!U){E("missing id");return}if(!tg(U)){E("id is invalid (alphanumeric characters and dashes only)");return}let j=F("url");if(!j){E("missing url");return}let G={id:U,description:F("description"),type:a,url:j,previewUrl:F("previewUrl")};if(a==="http"){if(!gtr(j)){E("invalid url");return}G.httpOptions={method:u};let te=F("httpHeaders");if(te&&(G.httpOptions.headers=vtr(te)),u==="POST"){let W=F("httpBody");W&&(G.httpOptions.body=W)}}else if(a==="gsheet"){if(!rg(j)?.spreadsheetId){E("failed to parse spreadsheet url");return}G.dataFormat=l||"map"}p?G.cron={enabled:!0,interval:m,unit:v,autoPublish:b}:G.cron={enabled:!1,interval:m,unit:v};try{k(G),i(!0),t.dataSourceId?(await EDe(t.dataSourceId,G),ge({title:"Saved data source",message:`Successfully updated ${U}`,autoClose:5e3}),i(!1)):(await TDe(U,G),ge({title:"Added data source",message:`Successfully added ${U}`,autoClose:5e3}),i(!1),e(`/cms/data/${U}`))}catch(te){console.error(te),ge({title:"Failed to save data source",message:String(te),color:"red",autoClose:!1}),i(!1)}}let M=[{value:"http",label:"HTTP"}];return(o.enabled||a==="gsheet")&&M.push({value:"gsheet",label:"Google Sheet"}),d("form",{className:"DataSourceForm",ref:r,onSubmit:z=>{z.preventDefault(),O()},children:[d(tu,{visible:I}),d("div",{className:"DataSourceForm__input",children:d(Lr,{name:"type",label:"Type",data:M,value:a,onChange:z=>s(z),size:"xs",radius:0,dropdownComponent:"div"})}),d(ur,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.dataSourceId,disabled:!!t.dataSourceId}),d(Fr,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:T?.description}),d(ur,{className:"DataSourceForm__input",name:"url",label:"URL",description:P,size:"xs",radius:0,value:T?.url}),a==="http"&&d(Ie,{children:[d("div",{className:"DataSourceForm__input",children:d(Lr,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:u,onChange:z=>f(z),size:"xs",radius:0,dropdownComponent:"div"})}),d(Fr,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ytr(T?.httpOptions?.headers||{})}),u==="POST"&&d(Fr,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:T?.httpOptions?.body})]}),a==="gsheet"&&d("div",{className:"DataSourceForm__input",children:[d(Lr,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:l,onChange:z=>c(z),size:"xs",radius:0,dropdownComponent:"div"}),l==="array"&&d("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",d("code",{children:"[[header1, header2], [foo, bar]]"})]}),l==="map"&&d("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",d("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),d("div",{className:"DataSourceForm__section",children:[d("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),d(Si,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:p,onChange:z=>h(z.currentTarget.checked),size:"xs"}),p&&d("div",{className:"DataSourceForm__cron",children:[d("div",{className:"DataSourceForm__cron__row",children:[d("span",{children:"Run every"}),d(Rp,{className:"DataSourceForm__cron__interval",value:m,onChange:z=>g(Number(z)||1),min:1,size:"xs",radius:0}),d(Lr,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:v,onChange:z=>y(z),size:"xs",radius:0,dropdownComponent:"div"})]}),d(Si,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:b,onChange:z=>_(z.currentTarget.checked),size:"xs"})]})]}),d(ur,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:T?.previewUrl}),d(J,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:n,children:t.buttonLabel||"Save"}),C&&d("div",{className:"DataSourceForm__error",children:["Error: ",C]})]})}function gtr(t){let e,r=t.startsWith("/")?"http://localhost":void 0;try{e=new URL(t,r)}catch(o){return console.error(o),!1}return e.protocol==="http:"||e.protocol==="https:"}function vtr(t){let e={};return t.split(`
461
461
  `).forEach(o=>{let n=o.indexOf(":");if(n===-1)return;let i=o.slice(0,n).trim(),a=o.slice(n+1).trim();i&&a&&(e[i]=a)}),e}function ytr(t){let e=[];for(let r in t){let o=t[r];e.push(`${r}: ${o}`)}return e.join(`
462
462
  `)}var htr,mtr,qle=x(()=>{"use strict";Ve();_o();Ee();Fs();Gp();jC();qp();Wp();Gi();kat();q();htr="Enter the URL to make the HTTP request.",mtr="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID"});var Pat=x(()=>{});var Rat={};yt(Rat,{EditDataSourcePage:()=>btr});function btr(t){cr(`Edit Data Source: ${t.id}`);let{route:e}=Fo(),[r,o]=R(null),n=lr(),i=gr(),{roles:a}=cn(),s=window.firebase.user.email||"",l=wa(a,s);$(()=>{cc(t.id).then(g=>{o(g)})},[t.id]);function c(){let g=`delete-data-source-${t.id}`,v=n.openConfirmModal({...i,title:"Delete data source",children:d(ft,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",d("code",{children:t.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{ge({id:g,title:"Deleting data source",message:`Deleting ${t.id} and synced data...`,loading:!0,autoClose:!1}),await MDe(t.id),xr({id:g,title:"Deleted data source",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),n.closeModal(v),e("/cms/data")}})}function u(){let g=`archive-data-source-${t.id}`,v=!!r?.publishedAt,y=n.openConfirmModal({...i,title:"Archive data source",children:d(ft,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive data source ",d("code",{children:t.id}),"? Archived data sources cannot be synced or published.",v&&d(Ie,{children:[" ","Note: previously published data will remain available until the data source is unpublished."]})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{ge({id:g,title:"Archiving data source",message:`Archiving ${t.id}...`,loading:!0,autoClose:!1}),await kDe(t.id);let b=await cc(t.id);o(b),xr({id:g,title:"Archived data source",message:`Successfully archived ${t.id}`,loading:!1,autoClose:5e3}),n.closeModal(y),e("/cms/data")}})}function f(){let g=`unarchive-data-source-${t.id}`,v=n.openConfirmModal({...i,title:"Unarchive data source",children:d(ft,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive data source"," ",d("code",{children:t.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{ge({id:g,title:"Unarchiving data source",message:`Unarchiving ${t.id}...`,loading:!0,autoClose:!1}),await PDe(t.id);let y=await cc(t.id);o(y),xr({id:g,title:"Unarchived data source",message:`Successfully unarchived ${t.id}`,loading:!1,autoClose:5e3}),n.closeModal(v),e(`/cms/data/${t.id}`)}})}function p(){let g=`unpublish-data-source-${t.id}`,v=n.openConfirmModal({...i,title:"Unpublish data source",children:d(ft,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unpublish data source"," ",d("code",{children:t.id}),"? The published data will be removed and will no longer be available to production. There is no undo."]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{ge({id:g,title:"Unpublishing data source",message:`Unpublishing ${t.id}...`,loading:!0,autoClose:!1}),await ADe(t.id);let y=await cc(t.id);o(y),xr({id:g,title:"Unpublished data source",message:`Successfully unpublished ${t.id}`,loading:!1,autoClose:5e3}),n.closeModal(v)}})}let h=!!r?.publishedAt,m=!!r?.archivedAt;return d(ht,{children:d("div",{className:"EditDataSourcePage",children:[d("div",{className:"EditDataSourcePage__header",children:[d(Yn,{className:"EditDataSourcePage__header__breadcrumbs",children:[d("a",{href:"/cms/data",children:"Data Sources"}),d("a",{href:`/cms/data/${t.id}`,children:t.id}),d("div",{children:"Edit"})]}),d("div",{className:"EditDataSourcePage__header__titleWrap",children:[d(Vt,{size:"h1",children:["Edit Data Source: ",t.id]}),d("div",{className:"EditDataSourcePage__header__controls",children:[h&&!m&&d(wn,{label:"You don't have access to unpublish data sources",condition:!l,children:d(_e,{label:"Unpublish",disabled:!l,children:d(Ae,{onClick:p,loading:!a,disabled:!l,children:d(s1,{size:20,stroke:"1.5"})})})}),d(wn,{label:"You don't have access to archive data sources",condition:!l,children:m?d(_e,{label:"Unarchive",disabled:!l,children:d(Ae,{onClick:f,loading:!a,disabled:!l,children:d(v1,{size:20,stroke:"1.5"})})}):d(_e,{label:"Archive",disabled:!l,children:d(Ae,{onClick:u,loading:!a,disabled:!l,children:d(eb,{size:20,stroke:"1.5"})})})}),d(_e,{label:"Delete",children:d(Ae,{onClick:c,children:d(I7,{size:20,stroke:"1.5"})})})]})]})]}),d(Mr,{className:"EditDataSourcePage__form",children:d(K3,{dataSourceId:t.id})})]})})}var Dat=x(()=>{"use strict";Ve();Zn();_o();zt();Ee();Fs();dd();qle();Oi();Hl();mi();Vn();Sn();El();In();qp();Ic();Pat();q()});var Aat=x(()=>{});function Pv(t){let{route:e}=Fo(),r=V(null),[o,n]=R(!1),[i,a]=R(""),[s,l]=R(!!t.releaseId),[c,u]=R(null),[f,p]=R([]),[h,m]=R([]),g=UC(),v=S3e(),{roles:y}=cn(),b=window.firebase.user.email||"",_=wa(y,b);async function C(P){console.log(P),await Vr(async()=>{let D=await Qu(P);u(D),p(D?.docIds||[]),m(D?.dataSourceIds||[])}),l(!1)}$(()=>{t.releaseId&&(l(!0),C(t.releaseId))},[t.releaseId]);async function E(){a("");let P=r.current;function D(z){let F=P.elements[z];return F?F.value.trim():""}let O=t.releaseId||D("id");if(!O){a("missing id");return}if(!tg(O)){a("id is invalid (alphanumeric characters and dashes only)");return}let M={id:O,description:D("description"),docIds:f,dataSourceIds:h};try{u(M),n(!0),t.releaseId?(await hL(t.releaseId,M),ge({title:"Saved release",message:`Updated ${O}`,autoClose:5e3}),n(!1)):(await pL(O,M),ge({title:"Added release",message:`Successfully added ${O}`,autoClose:5e3}),n(!1)),e(`/cms/releases/${O}`)}catch(z){console.error(z),ge({title:"Failed to save release",message:String(z),color:"red",autoClose:!1}),n(!1)}}function I(){g.open({multiSelect:!0,selectedDocIds:f,onChangeMulti:(P,D)=>{p(O=>{let M=[...O];if(D)M.push(P);else{let z=M.findIndex(F=>F===P);z>-1&&M.splice(z,1)}return console.log(M),M.sort()})}})}function S(){v.open({selectedDataSourceIds:h,onChange:(P,D)=>{m(O=>{let M=[...O];if(D)M.push(P);else{let z=M.indexOf(P);z>-1&&M.splice(z,1)}return M.sort()})}})}function T(P){console.log("onRemoveDoc()",P),p(D=>{let O=[...D],M=O.indexOf(P);return M!==-1&&O.splice(M,1),console.log(O),O})}function k(P){m(D=>{let O=[...D],M=O.indexOf(P);return M!==-1&&O.splice(M,1),O})}return d("form",{className:"ReleaseForm",ref:r,onSubmit:P=>{P.preventDefault(),E()},children:[d(tu,{visible:s}),d(ur,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,defaultValue:t.releaseId||mL(),disabled:!!t.releaseId}),d(Fr,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:c?.description,disabled:!_}),d(Wa,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[f.length>0&&d(Pv.DocPreviewCards,{docIds:f,onRemoveDoc:T,canEdit:_}),d(J,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>I(),disabled:!_,children:"Select"})]}),d(Wa,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[h.length>0&&d(Pv.DataSourceIds,{ids:h,onRemove:k,canEdit:_}),d(J,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>S(),disabled:!_,children:"Select"})]}),d("div",{className:"ReleaseForm__submit__buttons",children:d(wn,{label:"You don't have access to create or edit releases",condition:!_,children:d("span",{children:d(J,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:o,disabled:!_,children:t.buttonLabel||"Save"})})})}),i&&d("div",{className:"ReleaseForm__error",children:["Error: ",i]})]})}var Kle=x(()=>{"use strict";Ve();_o();zt();Ee();Fs();Gp();dd();El();Gi();Ic();ng();LQ();hP();u0();Aat();q();Pv.DocPreviewCards=t=>d("div",{className:"ReleaseForm__DocPreviewCards",children:t.docIds.map(e=>d("div",{className:"ReleaseForm__DocPreviewCards__card",children:[d(hf,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:e}),d("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[t.canEdit&&d("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:d(_e,{label:"Remove",children:d(Ae,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>t.onRemoveDoc(e),children:d(yn,{size:16})})})}),d("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:d(_e,{label:"Open",children:d(Ae,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${e}`,target:"_blank",children:d(Ls,{size:16})})})})]})]},e))});Pv.DataSourceIds=t=>d("div",{className:"ReleaseForm__DataSourceIds",children:t.ids.map(e=>d("div",{className:"ReleaseForm__DataSourceIds__item",children:[d("span",{className:"ReleaseForm__DataSourceIds__item__id",children:e}),t.canEdit&&d(Ae,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>t.onRemove(e),children:d(yn,{size:16})})]},e))})});var Oat=x(()=>{});var Mat={};yt(Mat,{EditReleasePage:()=>xtr});function xtr(t){cr(`Edit Release: ${t.id}`);let{route:e}=Fo(),[r,o]=R(null),n=lr(),i=gr(),{roles:a}=cn(),s=window.firebase.user.email||"",l=wa(a,s);$(()=>{Qu(t.id).then(f=>{o(f)})},[t.id]);function c(){let f=`archive-release-${t.id}`,p=n.openConfirmModal({...i,title:"Archive release",children:d(ft,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive release ",d("code",{children:t.id}),"?"]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{ge({id:f,title:"Archiving release",message:`Archiving ${t.id}...`,loading:!0,autoClose:!1}),await iAe(t.id);let h=await Qu(t.id);o(h),xr({id:f,title:"Archived release",message:`Successfully archived ${t.id}`,loading:!1,autoClose:5e3}),n.closeModal(p),e("/cms/releases")}})}function u(){let f=`unarchive-release-${t.id}`,p=n.openConfirmModal({...i,title:"Unarchive release",children:d(ft,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive release ",d("code",{children:t.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{ge({id:f,title:"Unarchiving release",message:`Unarchiving ${t.id}...`,loading:!0,autoClose:!1}),await aAe(t.id);let h=await Qu(t.id);o(h),xr({id:f,title:"Unarchived release",message:`Successfully unarchived ${t.id}`,loading:!1,autoClose:5e3}),n.closeModal(p),e(`/cms/releases/${t.id}`)}})}return d(ht,{children:d("div",{className:"EditReleasePage",children:[d("div",{className:"EditReleasePage__header",children:[d(Yn,{className:"EditReleasePage__header__breadcrumbs",children:[d("a",{href:"/cms/releases",children:"Releases"}),d("a",{href:`/cms/releases/${t.id}`,children:t.id}),d("div",{children:"Edit"})]}),d("div",{className:"EditReleasePage__header__titleWrap",children:[d(Vt,{size:"h1",children:["Edit Release: ",t.id]}),d("div",{className:"EditReleasePage__header__controls",children:d(wn,{label:"You don't have access to archive releases",condition:!l,children:r?.archivedAt?d(_e,{label:"Unarchive",disabled:!l,children:d(Ae,{onClick:u,loading:!a,disabled:!l,children:d(v1,{size:20,stroke:"1.5"})})}):d(_e,{label:"Archive",disabled:!l,children:d(Ae,{onClick:c,loading:!a,disabled:!l,children:d(eb,{size:20,stroke:"1.5"})})})})})]})]}),d(Pv,{releaseId:t.id})]})})}var Nat=x(()=>{"use strict";Ve();Zn();_o();zt();Ee();Fs();dd();Oi();Kle();mi();Vn();Sn();El();In();Ic();Oat();ng();q()});var Fat=x(()=>{});function Lat(t){let[e,r]=R(!0),[o,n]=R([]);return $(()=>{_De(t?{limit:t}:void 0).then(i=>{n(i),r(!1)})},[t]),{loading:e,actions:o}}function Y3(t){if(t.compact)return d(Str,{...t});let[e,r]=R(""),[o]=WV(e,300),[n,i]=R([]),[a,s]=R([]),[l,c]=R("all"),[u,f]=R(1),{actions:p,loading:h}=Lat(),m=X(()=>{let _=new Set;return p.forEach(C=>_.add(C.action)),Array.from(_).sort()},[p]),g=X(()=>{let _=new Set;return p.forEach(C=>{C.by&&_.add(C.by)}),Array.from(_).sort()},[p]),v=X(()=>{let _=Date.now();return p.filter(C=>{if(o){let E=o.toLowerCase(),I=C.action.toLowerCase().includes(E),S=C.by?.toLowerCase().includes(E),T=ktr(C.metadata).toLowerCase().includes(E);if(!I&&!S&&!T)return!1}if(n.length>0&&!n.includes(C.action)||a.length>0&&(!C.by||!a.includes(C.by)))return!1;if(l&&l!=="all"){let E=zat(C.timestamp);if(!E)return!1;let I=E.toMillis(),S=0;switch(l){case"1h":S=_-3600*1e3;break;case"24h":S=_-1440*60*1e3;break;case"7d":S=_-10080*60*1e3;break;case"30d":S=_-720*60*60*1e3;break}if(I<S)return!1}return!0})},[p,o,n,a,l]),y=t.compact?1:Math.ceil(v.length/Yle),b=X(()=>{if(t.compact)return v;let _=(u-1)*Yle;return v.slice(_,_+Yle)},[v,u,t.compact]);return $(()=>{f(1)},[o,n,a,l]),h?d("div",{className:`ActionsLog ActionsLog--loading ${t.className||""}`,children:d(gt,{color:"gray",size:"xl"})}):d("div",{className:`ActionsLog ${t.className||""}`,children:[!t.compact&&d("div",{className:"ActionsLog__tableHeader",children:[d("div",{className:"ActionsLog__filters",children:[d(ur,{className:"ActionsLog__filters__search",placeholder:"Search actions...",icon:d(Ka,{size:16}),value:e,onChange:_=>r(_.target.value)}),d(is,{className:"ActionsLog__filters__select",placeholder:"Filter by action",clearable:!0,searchable:!0,data:m,value:n,onChange:i}),d(is,{className:"ActionsLog__filters__select",placeholder:"Filter by user",clearable:!0,searchable:!0,data:g,value:a,onChange:s}),d(Lr,{className:"ActionsLog__filters__select",placeholder:"Filter by time",data:_tr,value:l,onChange:c})]}),d("div",{className:"ActionsLog__summary",children:["Showing ",b.length," of ",v.length," ","actions",v.length!==p.length&&` (filtered from ${p.length} total)`]})]}),d(Mr,{className:"ActionsLog__tableSurface",children:d(pi,{className:"ActionsLog__table",children:[d("thead",{children:d("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[d("th",{className:"ActionsLogs__table__header",children:"Timestamp"}),d("th",{className:"ActionsLogs__table__header",children:"User"}),d("th",{className:"ActionsLogs__table__header",children:"Action"}),d("th",{className:"ActionsLogs__table__header",children:"Details"}),d("th",{className:"ActionsLogs__table__header",children:"Links"})]})}),d("tbody",{children:[b.map((_,C)=>d("tr",{className:"ActionsLogs__table__row",children:[d("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:$at(_.timestamp)}),d("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:d("span",{className:"ActionsLogs__user",children:_.by?d(Ie,{children:[d(fd,{email:_.by,size:20}),d("span",{className:"ActionsLogs__user__email",children:_.by})]}):"\u2014"})}),d("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--action",children:d("span",{className:"ActionsLogs__action",children:_.action})}),d("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--metadata",children:d(Bat,{metadata:_.metadata})}),d("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--links",children:d(Zle,{action:_})})]},C)),b.length===0&&d("tr",{children:d("td",{colSpan:5,className:"ActionsLogs__table__col ActionsLogs__table__col--empty",children:"No actions found matching your filters."})})]})]})}),!t.compact&&y>1&&d("div",{className:"ActionsLog__pagination",children:d(UM,{total:y,value:u,onChange:f,size:"sm"})})]})}function Bat(t){let{metadata:e}=t;if(!e||Object.keys(e).length===0)return d("span",{className:"ActionsLogs__metadata--empty",children:"\u2014"});let r=Object.entries(e);return d("div",{className:"ActionsLogs__metadata",children:r.map(([o,n])=>d("div",{className:"ActionsLogs__metadata__item",children:[d("span",{className:"ActionsLogs__metadata__key",children:[o,":"]})," ",d("span",{className:"ActionsLogs__metadata__value",children:wtr(n)})]},o))})}function wtr(t){if(t==null)return"\u2014";if(Array.isArray(t))return t.length===0?"[]":t.length<=3?t.join(", "):`${t.slice(0,3).join(", ")} (+${t.length-3} more)`;if(typeof t=="object"){let e=Ctr(t);try{return JSON.stringify(e)}catch(r){console.error(r),console.error("failed to stringify json:",e)}}return String(t)}function Ctr(t){let e={};return Object.entries(t).forEach(([r,o])=>{r.startsWith("_")||(e[r]=o)}),e}function Zle(t){let{action:e}=t,r=[];function o(n){return t.label||n}return e.action!=="doc.delete"&&e.metadata?.docId&&r.push(d(_e,{transition:"pop",label:e.metadata.docId,children:d(J,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${e.metadata.docId}`,children:o("Open doc")})},"doc")),e.action!=="datasource.delete"&&e.metadata?.datasourceId&&r.push(d(_e,{transition:"pop",label:e.metadata.datasourceId,children:d(J,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${e.metadata.datasourceId}`,children:o("Open data source")})},"datasource")),e.action!=="release.delete"&&e.metadata?.releaseId&&r.push(d(_e,{transition:"pop",label:e.metadata.releaseId,children:d(J,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.metadata.releaseId}`,children:o("Open release")})},"release")),e.metadata?.sheetId&&r.push(d(J,{component:"a",variant:"default",size:"xs",compact:!0,href:au(e.metadata.sheetId),target:"_blank",children:o("Open sheet")},"sheet")),e.action.startsWith("acls.")&&r.push(d(J,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:o("Open settings")},"settings")),e.links&&e.links.forEach((n,i)=>{r.push(d(J,{component:"a",variant:"default",size:"xs",compact:!0,href:n.url,target:n.target,children:n.label},`link-${i}`))}),r.length===0?d("span",{className:"ActionsLogs__links--empty"}):(t.limit&&(r=r.slice(0,t.limit)),d("div",{className:"ActionsLogs__table__buttons",children:r}))}function Str(t){let{actions:e,loading:r}=Lat(t.limit||10);return r?d("div",{className:me(t.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:d(gt,{color:"gray",size:"xl"})}):d("div",{className:me(t.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:d(ca,{className:"ActionLogsCompact__table",multiple:!0,children:e.map((o,n)=>d(ca.Item,{label:d(Itr,{action:o}),children:d(Ttr,{action:o})},n))})})}function Itr(t){let e=t.action,r=Etr(e),o=t.action.by||"";return d("div",{className:"ActionLogsCompactItemPreview",children:[d("div",{className:"ActionLogsCompactItemPreview__user",children:d(fd,{email:o,size:20})}),d("div",{className:"ActionLogsCompactItemPreview__timestamp",children:$at(e.timestamp)}),d("div",{className:"ActionLogsCompactItemPreview__action",children:e.action}),d("div",{className:"ActionLogsCompactItemPreview__actionMetaId",children:r}),d("div",{className:"ActionLogsCompactItemPreview__buttons",children:d(Zle,{action:e,label:"Open",limit:1})})]})}function Ttr(t){let e=t.action,r={user:e.by,...e.metadata};return d("div",{className:"ActionLogsCompactItemDetails",children:[d(Bat,{metadata:r}),d(Zle,{action:e})]})}function Etr(t){for(let e of Object.keys(t.metadata||{}))if(e.toLowerCase().endsWith("id"))return t.metadata[e];return""}function zat(t){return t?t instanceof Nt?t:typeof t=="object"&&typeof t._seconds=="number"?new Nt(t._seconds,t._nanoseconds||0):typeof t=="object"&&typeof t.seconds=="number"?new Nt(t.seconds,t.nanoseconds||0):typeof t=="number"?Nt.fromMillis(t):null:null}function $at(t){let e=zat(t);if(!e)return"Invalid date";let r=e.toDate(),o=String(r.getMonth()+1).padStart(2,"0"),n=String(r.getDate()).padStart(2,"0"),i=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0");return`${o}/${n} ${i}:${a}`}function ktr(t){function e(r){return r===null?"null":typeof r>"u"?"undefined":typeof r=="string"?`"${r.replaceAll('"','\\"')}"`:typeof r!="object"?String(r):Array.isArray(r)?`[${r.map(e).join(", ")}]`:`{${Object.entries(r).map(([n,i])=>`${n}: ${e(i)}`).join(", ")}}`}return e(t)}var Yle,_tr,Jle=x(()=>{"use strict";Ve();Cr();zt();an();Ee();df();Sr();Wp();Hl();Dz();Fat();q();Yle=50,_tr=[{value:"all",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}]});var Vat=x(()=>{});var Uat={};yt(Uat,{LogsPage:()=>Ptr});function Ptr(){return cr("Action Logs"),d(ht,{children:d("div",{className:"LogsPage",children:[d("div",{className:"LogsPage__header",children:d(Vt,{size:"h1",children:"Action Logs"})}),d(Y3,{})]})})}var Hat=x(()=>{"use strict";Jle();Oi();Sn();In();Vat();q()});var jat=x(()=>{});var Gat={};yt(Gat,{NewDataSourcePage:()=>Rtr});function Rtr(){return cr("New Data Source"),d(ht,{children:d("div",{className:"NewDataSourcePage",children:[d("div",{className:"NewDataSourcePage__header",children:[d(Yn,{className:"NewDataSourcePage__header__breadcrumbs",children:[d("a",{href:"/cms/data",children:"Data Sources"}),d("div",{children:"New"})]}),d(Vt,{size:"h1",children:"Add Data Source"})]}),d(K3,{buttonLabel:"Create data source"})]})})}var Wat=x(()=>{"use strict";Ve();qle();Oi();Sn();In();jat();q()});var qat=x(()=>{});var Kat={};yt(Kat,{NewReleasePage:()=>Dtr});function Dtr(){return cr("New Release"),d(ht,{children:d("div",{className:"NewReleasePage",children:[d("div",{className:"NewReleasePage__header",children:[d(Yn,{className:"NewReleasePage__header__breadcrumbs",children:[d("a",{href:"/cms/releases",children:"Releases"}),d("div",{children:"New"})]}),d(Vt,{size:"h1",children:"Add Release"})]}),d(Pv,{buttonLabel:"Create release"})]})})}var Yat=x(()=>{"use strict";Ve();Oi();Kle();Sn();In();qat();q()});var Zat=x(()=>{});var Jat={};yt(Jat,{NotFoundPage:()=>Atr});function Atr(){return cr("Not Found"),d(ht,{children:d("div",{className:"NotFoundPage",children:[d("div",{className:"NotFoundPage__icon",children:d(m1,{size:60})}),d("h2",{className:"NotFoundPage__title",children:"Not Found"}),d("p",{className:"NotFoundPage__body",children:["Double-check the URL and try again or ",d("a",{href:"/cms",children:"go home"}),"."]})]})})}var Xat=x(()=>{"use strict";zt();Sn();In();Zat();q()});var Qat=x(()=>{});var est=x(()=>{});function Ntr(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId;return Ye(t,"Projects",e)}function Dx(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId;return Ye(e,"Projects",r,"Tasks",t)}function Ftr(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId;return Ye(t,"Projects",e,"Counters",Otr)}function rst(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId;return Ri(t,"Projects",e,"Tasks")}function ost(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId;return Ri(e,"Projects",r,"Tasks",t,"Comments")}function nst(t,e){let r=window.firebase.db,o=window.__ROOT_CTX.rootConfig.projectId;return Ye(r,"Projects",o,"Tasks",t,"Comments",e)}function Xle(t){let e=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId;return Ri(e,"Projects",r,"Tasks",t,"Events")}function Ltr(t){return Ye(Xle(t))}async function Btr(){let t=await Rr(Ntr());return t.exists()&&(t.data()||{}).settings?.defaultAssignee||null}async function ist(t){if(!t.title)throw new Error("missing task title");let e=window.firebase.db,r=t.assignee??await Btr(),o=t.priority||"normal",n="new",i=ast(t.targetLaunchDate),a=await cf(e,async s=>{let l=Ftr(),u=(await s.get(l)).data()||{},f=typeof u.lastTaskId=="number"?u.lastTaskId:0,p=Math.floor(f)+1,h=Dx(String(p));for(let m=0;m<Mtr;m++){if(h=Dx(String(p)),!(await s.get(h)).exists())return s.set(l,{lastTaskId:p,updatedAt:Qt()},{merge:!0}),s.set(h,{id:String(p),title:t.title,description:t.description||"",assignee:r??null,priority:o,status:n,targetLaunchDate:i,createdAt:Qt(),createdBy:window.firebase.user.email||"",updatedAt:Qt(),updatedBy:window.firebase.user.email||""}),String(p);p+=1}throw new Error("unable to allocate a task id")});return Bt("tasks.create",{metadata:{taskId:a}}),a}function ast(t){return t instanceof Date?Nt.fromDate(t):t??null}function Z3(t){let e=Qh(t);return!["closed","complete","completed","done","resolved"].includes(e)}function Qh(t){let e=(t||"new").trim().toLowerCase();return e==="open"?"new":e==="blocked"?"in-progress":["done","complete","completed","resolved"].includes(e)?"closed":e}function ztr(t){return t.sort((e,r)=>{let o=e.createdAt?.toMillis?.()||0;return(r.createdAt?.toMillis?.()||0)-o})}function sst(t){return ztr(t.docs.map(e=>({...e.data(),id:e.id})))}function lst(t,e){return ml(rst(),r=>{t(sst(r))},e)}function cst(t,e){return ml(rst(),r=>{t(sst(r).filter(o=>Z3(o.status)))},e)}function ust(t,e,r){return ml(Dx(t),o=>{if(!o.exists()){e(null);return}e({...o.data(),id:o.id})},r)}function dst(t,e,r){return ml(Uo(ost(t),Di("createdAt","asc")),o=>{e(o.docs.map(n=>({...n.data(),id:n.id})))},r)}function fst(t,e,r){return ml(Uo(Xle(t),Di("createdAt","asc")),o=>{e(o.docs.map(n=>({...n.data(),id:n.id})))},r)}async function pst(t,e){if(!t)throw new Error("missing task id");let r=e?.trim()||null;await fD(t,"assignee",r)&&Bt("tasks.updateAssignee",{metadata:{taskId:t,assignee:r}})}async function hst(t,e){if(!t)throw new Error("missing task id");let r=e.trim();if(!r)throw new Error("missing title");await fD(t,"title",r)&&Bt("tasks.updateTitle",{metadata:{taskId:t}})}async function mst(t,e){if(!t)throw new Error("missing task id");if(!e)throw new Error("missing status");let r=e.trim();await fD(t,"status",r)&&Bt("tasks.updateStatus",{metadata:{taskId:t,status:e}})}async function gst(t,e){if(!t)throw new Error("missing task id");await fD(t,"priority",e)&&Bt("tasks.updatePriority",{metadata:{taskId:t,priority:e}})}async function vst(t,e){if(!t)throw new Error("missing task id");let r=ast(e);await fD(t,"targetLaunchDate",r)&&Bt("tasks.updateTargetLaunchDate",{metadata:{taskId:t}})}async function yst(t,e){if(!t)throw new Error("missing task id");await no(Dx(t),{description:e,updatedAt:Qt(),updatedBy:window.firebase.user.email||""}),Bt("tasks.updateDescription",{metadata:{taskId:t}})}async function bst(t,e){if(!t)throw new Error("missing task id");if(!e?.src)throw new Error("missing attachment file");let r=window.firebase.db,o=Dx(t),n=window.firebase.user.email||"",i={...e,id:Ye(Xle(t)).id,attachedAt:Nt.now(),attachedBy:n};return await cf(r,async a=>{let s=await a.get(o);if(!s.exists())throw new Error("task not found");let l=s.data(),c=_st(l.attachments);a.update(o,{attachments:[...c,i],updatedAt:Qt(),updatedBy:n})}),Bt("tasks.attachment.add",{metadata:{taskId:t,attachmentId:i.id,filename:i.filename||i.src}}),i}async function xst(t,e){if(!t||!e)throw new Error("missing task or attachment id");let r=window.firebase.db,o=Dx(t),n=window.firebase.user.email||"",i;await cf(r,async s=>{let l=await s.get(o);if(!l.exists())throw new Error("task not found");let c=l.data(),u=_st(c.attachments);return i=u.find(f=>f.id===e),i?(s.update(o,{attachments:u.filter(f=>f.id!==e),updatedAt:Qt(),updatedBy:n}),!0):!1})&&Bt("tasks.attachment.remove",{metadata:{taskId:t,attachmentId:e,filename:i?.filename||i?.src||""}})}async function fD(t,e,r){let o=window.firebase.db,n=Dx(t),i=Ltr(t),a=window.firebase.user.email||"";return cf(o,async s=>{let l=await s.get(n);if(!l.exists())throw new Error("task not found");let c=l.data(),u=tst(c[e]),f=tst(r);return $tr(u,f)?!1:(s.update(n,{[e]:f,updatedAt:Qt(),updatedBy:a}),s.set(i,{id:i.id,taskId:t,type:"metadata",field:e,oldValue:u,newValue:f,createdAt:Qt(),createdBy:a}),!0)})}function tst(t){return t instanceof Nt||typeof t=="string"?t:null}function $tr(t,e){return t instanceof Nt&&e instanceof Nt?t.toMillis()===e.toMillis():t===e}function _st(t){return Array.isArray(t)?t.filter(e=>!!(e?.id&&e?.src)):[]}async function wst(t,e,r,o){if(!t)throw new Error("missing task id");if(!e)throw new Error("missing comment content");let n=Sst(e),i=typeof e=="string"?e:Ist(e);if(!i.trim()&&!n)throw new Error("missing comment content");let a=Ye(ost(t)),s=a.id,l=(o?.mentions||[]).map(c=>c.toLowerCase());return await ya(a,{id:s,taskId:t,parentId:r||null,content:i,body:n,mentions:l,createdAt:Qt(),createdBy:window.firebase.user.email||"",history:[]}),Bt("tasks.comment.add",{metadata:{taskId:t,commentId:s,parentId:r||null,mentions:l}}),s}async function Cst(t,e,r,o){if(!t||!e)throw new Error("missing task or comment id");if(!r)throw new Error("missing comment content");let n=Sst(r),i=typeof r=="string"?r:Ist(r);if(!i.trim()&&!n)throw new Error("missing comment content");let a=nst(t,e),s=await Rr(a);if(!s.exists())throw new Error("comment not found");let l=s.data(),c=(o?.mentions||[]).map(u=>u.toLowerCase());await no(a,{content:i,body:n,mentions:c,updatedAt:Qt(),updatedBy:window.firebase.user.email||"",isDeleted:!1,history:Xm({action:"edit",content:l.content,body:l.body||null,changedAt:Nt.now(),changedBy:window.firebase.user.email||""})}),Bt("tasks.comment.edit",{metadata:{taskId:t,commentId:e,mentions:c}})}function Sst(t){return typeof t=="string"?null:t}function Ist(t){return t?.blocks?.length?t.blocks.map(e=>Vtr(e)).filter(Boolean).join(`
463
463
  `).trim():""}function Vtr(t){switch(t.type){case"paragraph":case"heading":case"quote":return Est(t.data?.text||"");case"orderedList":case"unorderedList":return(t.data?.items||[]).map(e=>Tst(e)).filter(Boolean).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkk/root-cms",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "author": "s@blinkk.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -154,10 +154,10 @@
154
154
  "vite": "8.0.13",
155
155
  "vitest": "4.1.6",
156
156
  "yjs": "13.6.27",
157
- "@blinkk/root": "3.0.1"
157
+ "@blinkk/root": "3.0.2"
158
158
  },
159
159
  "peerDependencies": {
160
- "@blinkk/root": "3.0.1",
160
+ "@blinkk/root": "3.0.2",
161
161
  "firebase-admin": ">=11",
162
162
  "firebase-functions": ">=4"
163
163
  },