domma-cms 1.47.5 → 1.48.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/CLAUDE.md +4 -0
  3. package/admin/js/api.js +1 -1
  4. package/admin/js/lib/api-tokens-arrange.js +3 -3
  5. package/admin/js/templates/api-tokens.html +16 -0
  6. package/admin/js/views/api-tokens.js +33 -6
  7. package/admin/js/views/page-editor.js +9 -9
  8. package/docs/DommaFeatures.md +2 -0
  9. package/docs/api-reference.md +97 -2
  10. package/docs/plugin-development.md +27 -1
  11. package/package.json +1 -1
  12. package/plugins/free-tier.lock.json +13 -11
  13. package/plugins/shopping-cart/CHANGELOG.md +6 -0
  14. package/plugins/shopping-cart/CLAUDE.md +7 -1
  15. package/plugins/shopping-cart/lib/render.js +16 -3
  16. package/plugins/shopping-cart/plugin.js +15 -3
  17. package/plugins/shopping-cart/plugin.json +1 -1
  18. package/plugins/shopping-cart/public/cart.js +17 -1
  19. package/plugins/shopping-cart/public/lib/orders.js +23 -0
  20. package/plugins/shopping-cart/public/shop.css +3 -1
  21. package/plugins/shopping-cart/tests/account-scope.test.js +102 -0
  22. package/plugins/shopping-cart/tests/accounts.test.js +1 -1
  23. package/plugins/shopping-cart/tests/checkout-wording.test.js +58 -0
  24. package/public/js/site.js +1 -1
  25. package/public/js/token-handover-page.mjs +2 -0
  26. package/public/js/token-handover.mjs +13 -0
  27. package/server/routes/api/api-tokens.js +116 -4
  28. package/server/routes/api/collections.js +69 -0
  29. package/server/routes/api/content-writes.js +334 -0
  30. package/server/routes/api/pages.js +21 -1
  31. package/server/routes/public.js +15 -0
  32. package/server/routes/token-handover-public.js +59 -0
  33. package/server/server.js +6 -0
  34. package/server/services/apiTokens.js +61 -16
  35. package/server/services/content.js +4 -2
  36. package/server/services/markdown.js +10 -10
  37. package/server/services/pluginScope.js +26 -0
  38. package/server/services/plugins.js +3 -2
  39. package/server/services/siteGitignore.js +2 -0
  40. package/server/services/tokenContentPolicy.js +369 -0
  41. package/server/services/tokenHandovers.js +143 -0
  42. package/server/services/tokenRecipes.js +207 -0
  43. package/server/templates/page.html +1 -1
  44. package/server/templates/token-handover.html +3 -0
package/public/js/site.js CHANGED
@@ -1 +1 @@
1
- import{applyMobileMenu as se,initCarouselPopup as ie}from"/public/js/mobile-ui.mjs?v=20261016-mobile-options";import{installSmoothCarets as re}from"/public/js/smooth-caret.js";import{decodeBase64Json as V}from"/public/js/utf8-base64.mjs";import{makeBadgeEl as U,applyColour as G,applyPill as ce,applyFloat as le,applyHighlight as Y,applyItemHighlight as de,itemHighlightAttrs as me,isCurrentItem as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261029-footer-bars";import{initPageMotion as he}from"/public/js/page-motion.mjs?v=20261029-page-motion";import{applyFooterShowcase as ge}from"/public/js/footer-showcase.mjs?v=20261029-footer-showcase";import{initFloatingMenus as ye}from"/public/js/menu-float.js?v=20260829-float-panel";import{enhancePickerFields as Q,markInvalidFields as Z,showValidationPopup as ee}from"/public/js/forms.js?v=20261031-form-entrance-forms";import{buildWizardSteps as ve}from"/public/js/form-steps.mjs";import{mountMotionControl as be}from"/public/js/motion-control.mjs?v=20261031-launchers";import{applyFormClasses as te,applyFormEntrance as oe,applySubmitButtons as we,applyWizardButtons as Ce}from"/public/js/form-submit.mjs";import{captureFileFields as ne,destroyDropzones as Se,fileBlueprint as xe,restoreFileFields as ke,setFileLimits as Le,splitFiles as $e,submitBody as Ee,totalTooLarge as Ae,wireFileFields as Te}from"/public/js/form-files.mjs";document.addEventListener("click",d=>{const i=d.target?.closest?.(".dm-banner__dismiss");i&&(d.preventDefault(),i.closest(".dm-banner")?.remove())}),$(()=>{re(document);const d=window.__CMS_NAV__||{},i=window.__CMS_SITE__||{},D=i.brandingEnabled!==!1&&d.brand?.enabled!==!1;if(i.autoTheme?.enabled){let o=function(r){const m=(r||"07:00").split(":");return+m[0]*60+(+m[1]||0)},e=function(){const r=new Date,m=r.getHours()*60+r.getMinutes();return m>=o(s.dayStart)&&m<o(s.nightStart)?s.dayTheme:s.nightTheme},t=function(r){const m=s.apply&&s.apply[r]||{theme:r,custom:""};Domma.theme.set(m.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);m.custom&&document.body.classList.add(m.custom)};const s=i.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const L=$("#site-navbar");if(L.length&&d.brand){let e=function(u,f=0){return Array.isArray(u)?u.filter(h=>!(h&&(h.type==="spacer"||h.type==="theme-switcher"))).filter(h=>!(h&&h.type==="separator"&&f===0)).map(h=>h&&h.type==="separator"?{divider:!0}:Array.isArray(h?.items)?{...h,items:e(h.items,f+1)}:h):u};const s={...d.brand},o=s.size&&s.size!=="md"?` navbar-brand-${s.size}`:"";if(s.logo||s.icon||s.tagline){let u="";s.logo?u+=`<img src="${s.logo}" class="navbar-brand-logo" alt="${s.text||""}">`:s.icon&&(u+=`<span data-icon="${s.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),s.text&&(u+=`<span class="navbar-brand-text${o}">${s.text}</span>`),s.tagline&&(u+=`<small class="navbar-brand-tagline">${s.tagline}</small>`),s.html=u}else o&&s.text&&(s.html=`<span class="navbar-brand-text${o}">${s.text}</span>`);const t=e(d.items||[]),r=d.position==="floating",m=d.orientation==="vertical";L.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:D?s:null,items:t,variant:d.variant||"dark",position:r?"static":d.position||"sticky",collapsible:!0,appearOnHover:!!d.appearOnHover}),Domma.icons.scan("#site-navbar");const n=L.get(0);se(n,d.mobile);const y=()=>{if(!m)return;const f=n.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");f&&!f.classList.contains("open")&&f.querySelector(":scope > .navbar-dropdown-toggle")?.click()};n.classList.add(`dm-nav-align-${ue(d)||"centre"}`),m&&L.get(0).classList.add("dm-nav-vertical",d.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const g=d.dock||{};m&&!r&&_e(n,d.side==="right"),!m&&g.hideOnScroll&&qe(n),Y(n,d),J(n,d),P(n,d.class),r&&(le(L.get(0),d),ye(L.get(0).parentNode||document));const l=n.querySelector(".navbar-toggle"),b=n.querySelector(".navbar-collapse");if(l&&b){let u=null;const f=()=>{b.classList.contains("show")&&l.click()},h=()=>{u&&(u.remove(),u=null),document.body.classList.remove("dm-drawer-open")},p=()=>{u||(u=document.createElement("div"),u.className="dm-navbar-backdrop",u.addEventListener("click",f),document.body.appendChild(u),document.body.classList.add("dm-drawer-open"))};l.addEventListener("click",()=>{requestAnimationFrame(()=>{b.classList.contains("show")?(y(),p()):h()})}),b.addEventListener("click",x=>{x.target.closest("a")&&requestAnimationFrame(h)}),document.addEventListener("keydown",x=>{x.key==="Escape"&&b.classList.contains("show")&&f()})}const w=n.querySelector(".navbar-nav");if(w){const u=Array.from(w.children);let f=0;for(const h of d.items||[])if(!(h&&h.type==="separator")){if(h&&h.type==="spacer"){const p=document.createElement("li"),x=["xs","sm","md","lg","xl","flex"].includes(h.size)?h.size:"md";p.className=`dm-menu-spacer dm-menu-spacer--${x}`,p.setAttribute("aria-hidden","true"),w.insertBefore(p,u[f]||null);continue}if(h&&h.type==="theme-switcher"){const p=document.createElement("li");p.className="dm-menu-theme-switcher";const x=document.createElement("span");x.dataset.themeSwitcher="menu",x.dataset.position="inline",p.appendChild(x),w.insertBefore(p,u[f]||null);continue}f++}window.CMSThemeSwitcher?.scan(w)}n.querySelectorAll("[data-path]").forEach(u=>{const f=u.dataset.path.split(".").map(Number),h=f.length>1,p=f.reduce((M,N)=>M?.items?.[N],{items:t});if(!p)return;p.colour&&G(u,p.colour),p.pill&&!h&&ce(u,p.pill),de(u,p),P(u.closest("li"),p.class);const x=U(p.badge);x&&u.appendChild(x),K(p.url,location.pathname)&&(u.classList.add("active"),u.setAttribute("aria-current","page"))}),pe(n,d,t),y()}let I=null;const C=$("#site-footer");if(C.length){let r=function(c){return String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},m=function(c){return r(c).replace(/'/g,"&#39;")},n=function(c){if(c&&c.type==="separator")return'<li class="footer-sep"><hr></li>';if(c&&c.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(c.size)?c.size:"md"}" aria-hidden="true"></li>`;if(c&&c.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const v=m(c.url||"#"),k=r(c.text||""),q=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",z=me(c),j=[z.hover&&` data-menu-item-hover="${m(z.hover)}"`,z.active&&` data-menu-item-active="${m(z.active)}"`].filter(Boolean).join(""),W=z.accent?` style="--dm-menu-highlight:${m(z.accent)}"`:"",B=X(c.class).join(" ");return`<li${B?` class="${m(B)}"`:""}><a href="${v}"${j}${W}>${k}</a>${q}</li>`},g=function(){if(!i.footer)return"";const c=Object.keys(o).filter(k=>s[k]);if(!c.length)return"";const v=X(i.footer.socialClass).join(" ");return`<div class="footer-social">${c.map(k=>{const{label:q,svg:z}=o[k];return`<a href="${s[k]}" target="_blank" rel="noopener noreferrer" aria-label="${q}" class="footer-social-link${v?` ${m(v)}`:""}">${z}</a>`}).join("")}</div>`},u=function(c){if(!c||c.type==="separator"||c.type==="spacer")return"";if(c.type==="theme-switcher")return`<li class="cms-footer-col">${n(c).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const v=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",k=w(c)?`<span class="cms-footer-col-title">${r(c.text||"")}</span>`:`<a class="cms-footer-col-title" href="${m(c.url||"#")}">${r(c.text||"")}</a>`,q=["cms-footer-col",...X(c.class)].join(" ");return`<li class="${m(q)}">${k}${v}</li>`},p=function(c,v,k=!1){return(c||[]).forEach(q=>{q&&(q.type==="separator"||q.type==="spacer"||q.type==="theme-switcher")||(k&&w(q)||v.push(q),Array.isArray(q.items)&&q.items.length&&p(q.items,v))}),v};const s=i.social||{},o={twitter:{label:"X / Twitter",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.742l7.73-8.835L1.254 2.25H8.08l4.259 5.629L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>'},facebook:{label:"Facebook",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>'},instagram:{label:"Instagram",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>'},linkedin:{label:"LinkedIn",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>'},github:{label:"GitHub",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>'},youtube:{label:"YouTube",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg>'}};let e='<div class="footer-inner container">';const t=window.__CMS_FOOTER__||{primary:[],legal:[],copyright:""},y=(()=>{const c=i.cookieConsent;if(!c||c.showSettingsLink===!1)return"";const v=k=>(k||[]).some(q=>q&&(q.url==="#cookie-settings"||v(q.items)));return v(t.primary)||v(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${r(c.settingsLinkText||"Cookie settings")}</a></li>`})(),l=["columns","row"].includes(i.footer?.layout)?i.footer.layout:"auto",b=i.footer?.look==="showcase"||l==="columns"||l==="auto"&&t.primary.some(c=>Array.isArray(c?.items)&&c.items.length),w=c=>b&&!c.url&&Array.isArray(c.items)&&c.items.length>0;if(b){const c=d.brand||{},v=D&&(c.text||i.title)||"",k=D?c.logo?`<img src="${m(c.logo)}" class="cms-footer-brand-logo" alt="">`:c.icon?'<span class="cms-footer-brand-icon"></span>':"":"",q=String(i.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${v||k?`<a class="cms-footer-brand-name" href="${m(c.url||"/")}">${k}<span>${r(v)}</span></a>`:""}${q?`<p class="cms-footer-blurb">${r(q)}</p>`:""}${g()}</div>`,t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${t.primary.map(u).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',t.copyright&&(e+=`<p class="cms-footer-copyright">${r(t.copyright)}</p>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+="</div>"}else t.copyright&&(e+=`<p>${r(t.copyright)}</p>`),t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary"><ul>${t.primary.map(n).join("")}</ul></nav>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+=g();e+="</div>",C.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const f=C.get(0).querySelector(":scope > .cms-footer-blocks");f?.remove(),C.html(e),f&&C.get(0).prepend(f),window.CMSThemeSwitcher?.scan(C.get(0));const h=C.get(0).querySelector(".cms-footer-brand-icon");h&&d.brand?.icon&&h.setAttribute("data-icon",d.brand.icon),P(C.get(0),i.footer?.class),b&&ge(C.get(0),i);const x=[...p(t.primary,[],!0),...p(t.legal,[])],M=C.get(0).querySelectorAll(".footer-nav a"),N=[];M.forEach((c,v)=>{const k=x[v];if(!k)return;if(N.push({a:c,item:k}),k.icon){const z=document.createElement("span");z.className="cms-footer-ic",z.setAttribute("data-icon",String(k.icon)),z.setAttribute("data-icon-size","15"),z.setAttribute("aria-hidden","true"),c.prepend(z)}k.colour&&G(c,k.colour);const q=U(k.badge);q&&c.appendChild(q),K(k.url,location.pathname)&&(c.classList.add("is-active"),c.setAttribute("aria-current","page"))}),Y(C.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(C.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(C.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(C.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(C.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(C.get(0).querySelector(".footer-nav--legal"),t.legalClass),fe(C.get(0),t,N),I=C.get(0).querySelector(".cms-footer-bottom")||C.get(0).querySelector(".footer-inner")}be(i.motion||{enabled:i.footer?.showMotionToggle!==!1,default:i.footer?.motionDefault,placement:"footer",control:i.footer?.motionControl,label:"Reduce motion"},{footer:I,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const A=document.getElementById("site-sidebar");A&&Me(A),Domma.icons.scan(),Domma.syntax?.scan&&Domma.syntax.scan();const a=$(".page-body");if(a.length){a.find(".accordion").each(function(){Domma.elements.accordion(this,{allowMultiple:this.dataset.multi==="true"})}),a.find(".tabs").each(function(){Domma.elements.tabs(this)}),a.find(".carousel").each(function(){const o={primary:"--dm-primary",secondary:"--dm-secondary",accent:"--dm-primary",text:"--dm-text",surface:"--dm-surface",background:"--dm-background",success:"--dm-success",warning:"--dm-warning",danger:"--dm-danger",info:"--dm-info"},e=g=>{const l=String(g||"").trim();return l?o[l.toLowerCase()]?`var(${o[l.toLowerCase()]})`:CSS.supports("color",l)?l:"":""},t=e(this.dataset.background),r=e(this.dataset.arrowBackground),m=e(this.dataset.arrowColor);t&&(this.style.setProperty("--dm-carousel-background",t),this.classList.add("dm-carousel-custom-background")),r&&this.style.setProperty("--dm-carousel-arrow-background",r),m&&this.style.setProperty("--dm-carousel-arrow-color",m);const n=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${n}`);const y={autoplay:this.dataset.autoplay==="true",interval:parseInt(this.dataset.interval,10)||5e3,loop:this.dataset.loop!=="false",animation:this.dataset.animation||"slide",heightMode:this.dataset.heightMode==="average"?"average":"crop"};if(this.dataset.height){const g=Number(this.dataset.height);Number.isFinite(g)&&g>0&&(y.height=g)}if(this.dataset.animationDuration){const g=parseInt(this.dataset.animationDuration,10);Number.isFinite(g)&&(y.animationDuration=g)}this.dataset.animationEasing&&(y.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(g=>g.cloneNode(!0)),this._dmCarouselOpts=y),this._dmCarousel=Domma.elements.carousel(this,y),ie(this)}),a.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),m=r?new Date(+r[1],+r[2]-1,+r[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(m)?o.duration=Math.max(0,m-Date.now()):this.dataset.duration&&(o.duration=(parseInt(this.dataset.duration,10)||0)*1e3);const n=/^dd:/i.test(e);o.format=n?"hh:mm:ss":e||(o.duration>=36e5?"hh:mm:ss":"mm:ss");const y=this,g=b=>String(b).padStart(2,"0"),l=b=>{const w=Math.max(0,Math.floor(b/1e3)),u=y.querySelector(".dm-timer-time");u&&(u.textContent=`${g(Math.floor(w/86400))}:${g(Math.floor(w%86400/3600))}:${g(Math.floor(w%3600/60))}:${g(w%60)}`)};n&&(o.onTick=l),Domma.elements.timer(this,o),n&&l(o.duration||0)}),a.find("[data-tooltip]:not(.dm-range-slider)").each(function(){Domma.elements.tooltip(this,{content:$(this).data("tooltip"),position:$(this).data("tooltip-position")||"top"})}),a.find(".dm-progression").each(function(){const o=Array.from(this.querySelectorAll(".dm-progression-item")).map(r=>{const m={title:r.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:r.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return r.dataset.date&&(m.date=r.dataset.date),r.dataset.status&&(m.status=r.dataset.status),r.dataset.eventIcon&&(m.icon=r.dataset.eventIcon),r.dataset.entryId&&(m._entryId=r.dataset.entryId),m}),e=this.dataset.layout==="centred"?"centered":this.dataset.layout||"vertical",t=Domma.elements.progression(this,{layout:e,theme:this.dataset.theme||"minimal",mode:this.dataset.mode||"timeline",statusIcons:!0,allowHtml:!0,...o.length?{items:o}:{}});if((this.dataset.mode||"timeline")==="timeline"){const r={completed:{label:"Completed",icon:"check-circle",tone:"success"},planned:{label:"Planned",icon:"circle",tone:"secondary"},"in-progress":{label:"In progress",icon:"clock",tone:"primary"},blocked:{label:"Blocked",icon:"alert-circle",tone:"danger"}};this.querySelectorAll(".dm-progression-item").forEach((m,n)=>{const y=o[n];if(!y)return;const g=m.querySelector(".dm-progression-title");if(y.icon&&g){const b=document.createElement("span");b.dataset.icon=y.icon,b.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",b.setAttribute("aria-hidden","true"),g.prepend(b)}const l=r[y.status];if(l&&g){const b=document.createElement("span");b.className=`badge badge-${l.tone} cms-timeline-status`,b.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const w=document.createElement("span");w.dataset.icon=l.icon,w.dataset.iconSize="14",w.setAttribute("aria-hidden","true"),b.append(w,document.createTextNode(l.label)),g.after(b)}})}Domma.icons.scan(this),o.length&&(this._dmCtx={instance:t,items:o})});try{Domma.effects.reveal(".page-body .hero",{animation:"slide-up",duration:480,threshold:.06,stagger:60,once:!1})}catch{}const s=matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.classList.contains("dm-reduced-motion");document.querySelectorAll(".page-body .row[data-reveal]").forEach(o=>{const e=o.dataset.revealMode||"stagger",t=o.dataset.revealAnimation||"slide-up",r=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),m=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,y=o.dataset.revealDirection==="rtl",g=o.dataset.revealReplay==="true",l=Array.from(o.children);if(s&&t.startsWith("swoosh"))return;const b={"slide-up":"translateY(30px)","slide-down":"translateY(-30px)","slide-left":"translateX(30px)","slide-right":"translateX(-30px)",zoom:"scale(0.85)",flip:"perspective(600px) rotateX(15deg)",swoosh:"translateY(36px) scale(0.96)"},w=p=>t!=="swoosh-sides"?b[t]||"":l.length>1&&p===0?"translateX(-64px) rotate(-1.5deg)":l.length>1&&p===l.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",u=t.startsWith("swoosh"),f=u?"cubic-bezier(.2,.8,.2,1)":"ease",h=(p,x)=>{p.style.opacity="0",p.style.transform=w(x),u&&(p.style.filter="blur(10px)")};l.forEach((p,x)=>{p.style.transition="none",h(p,x)}),o.offsetWidth,l.forEach((p,x)=>{p.style.transition=`opacity ${r}ms ${f}, transform ${r}ms ${f}`+(u?`, filter ${r}ms ${f}`:"");const M=y?l.length-1-x:x;p.style.transitionDelay=e==="stagger"?`${n+M*m}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const p=new IntersectionObserver(x=>{x.forEach(M=>{if(M.isIntersecting){if(M.target.offsetWidth,M.target.style.opacity="1",M.target.style.transform="",u&&(M.target.style.filter=""),!g){p.unobserve(M.target);const N=M.target;N.addEventListener("transitionend",function c(v){v.target!==N||v.propertyName!=="opacity"||(N.removeEventListener("transitionend",c),N.style.transition="",N.style.transitionDelay="")})}}else g&&M.boundingClientRect.top>0&&h(M.target,l.indexOf(M.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});l.forEach(x=>p.observe(x))}))}),he(document.querySelector(".page-body")||document),a.find(".card[data-collapsible]").each(function(){const o=this.querySelector(".card-header");o&&o.addEventListener("click",()=>this.classList.toggle("is-collapsed"))}),a.find(".dm-so-trigger").each(function(){this.addEventListener("click",()=>{const o=this.dataset.soTarget,e=document.getElementById(o);if(!e)return;const t=E.slideover({title:e.dataset.soTitle||"",size:e.dataset.soSize||"md",position:e.dataset.soPosition||"right"});e.style.display="",t.setContent(e),t.open()})})}if(typeof $.setup=="function"){const s=Object.assign({},window.__CMS_DCONFIG__||{});if(document.querySelectorAll(".dm-page-config[data-config]").forEach(o=>{try{const e=V(o.dataset.config);Object.assign(s,e)}catch{}}),Object.keys(s).length>0){const o={};for(const[e,t]of Object.entries(s)){const r=t?.events?.click,{confirm:m,toast:n,alert:y,prompt:g,...l}=r||{};if(m||n||y||g){$(e).on("click",async function(W){if(W.preventDefault(),m&&!await E.confirm(m))return;let B=null;if(!(g&&(B=await E.prompt(g,{inputPlaceholder:l.promptPlaceholder||"",inputValue:l.promptDefault||""}),B===null))){{const O=$(l.target||this);l.toggleClass&&O.toggleClass(l.toggleClass),l.addClass&&O.addClass(l.addClass),l.removeClass&&O.removeClass(l.removeClass),B!==null&&(l.setText&&O.text(B),l.setVal&&O.val(B),l.setAttr&&O.attr(l.setAttr,B))}l.href&&ae(l.href),n&&E.toast(n,{type:l.toastType||"success"}),y&&E.alert(y)}});const{target:w,toggleClass:u,addClass:f,removeClass:h,setText:p,setVal:x,setAttr:M,href:N,toastType:c,promptPlaceholder:v,promptDefault:k,...q}=l,z={...t.events};Object.keys(q).length?z.click=w?{target:w,...q}:q:delete z.click;const j={...t,events:z};Object.keys(z).length||delete j.events,Object.keys(j).length&&(o[e]=j)}else o[e]=t}$.setup(o)}}a.length&&R(a.get(0))}),window.wireCTAButtons=R;function ae(d){const i=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(i?window.top:window).location.href=d}function R(d){d.querySelectorAll(".dm-cta-trigger").forEach(i=>{i.__ctaWired||(i.__ctaWired=!0,i.addEventListener("click",async()=>{const D=i.dataset.action,L=i.dataset.entry,I=i.dataset.confirm;let C=S.get("auth_token");if(!C){E.toast("Please log in to perform this action.",{type:"warning"});return}if(I&&!await E.confirm(I))return;const A=Array.from(i.childNodes).map(s=>s.cloneNode(!0));i.disabled=!0,i.textContent="Running\u2026";const a=s=>fetch(`/api/actions/${D}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(i.dataset.scope?{entryId:L,scope:i.dataset.scope}:{entryId:L})});try{let s=await a(C);if(s.status===401){const e=S.get("auth_refresh_token");if(e){const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(t.ok){const{token:r}=await t.json();S.set("auth_token",r),C=r,s=await a(C)}}}const o=await s.json().catch(()=>({}));if(!s.ok||o.success===!1)throw new Error(o.error||o.message||`Error ${s.status}`);E.toast(o.message||"Action completed.",{type:"success"})}catch(s){E.toast(s.message||"Action failed.",{type:"error"})}finally{i.disabled=!1,i.textContent="",A.forEach(s=>i.appendChild(s)),Domma.icons.scan(i)}}))})}(function(){const i=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!i.length)return;const D=S.get("auth_token");function L(C,A){const a=document.createElement("div");a.className="dm-collection-display dm-collection-empty";const s=document.createElement("p");if(A){s.appendChild(document.createTextNode("Please "));const o=document.createElement("a");o.href="/login",o.textContent="sign in",s.appendChild(o),s.appendChild(document.createTextNode(" to view your entries."))}else s.textContent=C;return a.appendChild(s),a}function I(C,A){const a=document.createElement("template");a.innerHTML=A||"",C.replaceWith(a.content)}i.forEach(async C=>{const A=C.dataset.collectionAttrs;if(!A)return;if(!D){C.replaceChildren(L("",!0));return}const a=s=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({attrs:A})});try{let s=D,o=await a(s);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const r=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(r.ok){const{token:m}=await r.json();S.set("auth_token",m),s=m,o=await a(s)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));C.replaceChildren(L(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();I(C,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{C.replaceChildren(L("Unable to load entries.",!1))}}),setTimeout(()=>{typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(),typeof Domma<"u"&&Domma.syntax?.scan&&Domma.syntax.scan(),R(document.body)},100)})(),(function(){const i=document.querySelectorAll("[data-collection-table]");!i.length||typeof T>"u"||!T.create||i.forEach(D=>{let L;try{L=V(D.dataset.payload)}catch{return}const{columns:I,rows:C,search:A,sortable:a,exportable:s,pageSize:o,empty:e,ctaConfig:t,slug:r,exportCfg:m}=L;if(!I?.length)return;if(t){const g=I.findIndex(l=>l.key==="_cta");g!==-1&&(I[g]={key:"_cta",title:"",render:(l,b)=>{const w=document.createElement("button");if(w.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,w.dataset.action=t.action||"",t.scope&&(w.dataset.scope=t.scope),w.dataset.entry=b._entryId||"",t.confirm&&(w.dataset.confirm=t.confirm),t.icon){const u=document.createElement("span");u.dataset.icon=t.icon,w.appendChild(u),w.appendChild(document.createTextNode(" "))}return w.appendChild(document.createTextNode(t.label||"Run")),w}})}const n="col-table-"+Math.random().toString(36).slice(2,7),y=document.createElement("div");y.id=n,D.replaceChildren(y),T.create("#"+n,{data:C,columns:I,search:A,sortable:a,exportable:s,pageSize:o,emptyMessage:e}),t&&R(y),D._dmTable={columns:I,rows:C,slug:r,exportCfg:m,render(g){T.create("#"+n,{data:g,columns:I,search:A,sortable:a,exportable:s,pageSize:o,emptyMessage:e}),t&&R(y)}}})})(),(function(){const i=document.querySelectorAll("[data-form-inline]");if(!i.length||typeof F>"u")return;function D(a){const s=a&&a.logic;return!!(s&&(s.visibility||s.requirement))}function L(a,s){const o={};return(a||[]).forEach(e=>{if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const t=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),r=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,m={...e.formConfig||{}};m.span==="full"&&s&&(m.span=s);const n={type:r,required:D(e)?!1:e.required,label:e.label,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{hint:e.helper},...e.tooltip&&{tooltip:e.tooltip},...m}};e.minLength!==void 0&&(n.minLength=e.minLength),e.maxLength!==void 0&&(n.maxLength=e.maxLength),e.min!==void 0&&(n.min=e.min),e.max!==void 0&&(n.max=e.max),t&&(e.variant&&(n.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(n.multiple=!0),e.density&&(n.density=e.density),e.columns&&(n.columns=e.columns),e.accent&&(n.accent=e.accent),e.accentStyle&&(n.accentStyle=e.accentStyle),e.glow&&(n.glow=!0),e.glowColour&&(n.glowColour=e.glowColour),e.shadow&&(n.shadow=e.shadow),e.shadowColour&&(n.shadowColour=e.shadowColour)),o[e.name]=e.type==="file"?xe(e,n):n}),o}function I(a){const s={};return(a||[]).forEach(o=>{if(!(!o.name||o.type==="page-break"||o.type==="spacer")&&(o.type==="select"||o.type==="multiselect")&&o.required){const e=(o.options||[])[0];e&&(s[o.name]=typeof e=="object"?e.value:e)}}),s}function C(a,s){(s||[]).forEach(o=>{if(o.type!=="date"||!o.name)return;const e=a.querySelector(`[name="${o.name}"]`);e&&e.type!=="date"&&(e.type="date")})}function A(a,s,o){let e=a.querySelector(".cms-form-message");e||(e=document.createElement("p"),e.className="cms-form-message",a.appendChild(e)),e.textContent=s,e.style.cssText=o?"color:var(--dm-danger);margin-top:.75rem;":"color:var(--dm-success);margin-top:.75rem;"}i.forEach(a=>{let s;try{s=V(a.dataset.formInline)}catch{return}a.querySelector(":scope > .cms-form-embed-summary")?.remove();const o=s.fields||[],e=s.settings||{},t=Number(e.columns)===3?3:2,r=e.layout||"grid",m=o.some(u=>u.type==="page-break"),n=new Map;Le(a,s.fileLimits,n),Te(a,o);const y=async u=>{if(a.dataset.triggerBlocked==="true"){const f=a._formLogicRuntime,h=f&&f.submitBlock?f.submitBlock().reasons:[];A(a,h.join(" ")||"This form cannot be submitted yet.",!0);const p=new Error("Blocked by a form trigger");throw p.formSubmitFailed=!0,p}try{const f=a.querySelector(".fb-form-honeypot"),h=f?.querySelector('input[type="text"]')||null,p=f?.querySelector('[name="_t"]')||null,x=Object.assign({},u);delete x._t,f?.dataset.hpName&&delete x[f.dataset.hpName],h!==null&&(x._hp=h.value),p!==null&&(x._t=p.value);const M=new Map(n);ne(a,M);const N=$e(x,o,M),c=Ae(a,N.files);if(c){A(a,c,!0);const k=new Error(c);throw k.formSubmitFailed=!0,k}const v=await H.post(`/api/forms/submit/${s.slug}`,N.files.size?Ee(N.values,N.files).body:N.values);if(v&&v.error){A(a,v.error,!0);const k=new Error(v.error);throw k.formSubmitFailed=!0,k}if(v?.redirect){ae(v.redirect);return}for(Se(a);a.firstChild;)a.removeChild(a.firstChild);A(a,v?.message||e.successMessage||"Thank you for your submission.",!1)}catch(f){throw f.formSubmitFailed||A(a,f.message||"Submission failed. Please try again.",!0),f}},g=Date.now();function l(u){const f=u.querySelector("form");if(!f||f.querySelector(".fb-form-honeypot"))return;const h=document.createElement("div");h.className="fb-form-honeypot",h.setAttribute("aria-hidden","true");const p=document.createElement("input");p.name=f.querySelector('[name="website"]')?"_website":"website",h.dataset.hpName=p.name,p.type="text",p.tabIndex=-1,p.autocomplete="url",p.placeholder="https://",h.appendChild(p);const x=document.createElement("input");x.name="_t",x.type="hidden",x.value=g,h.appendChild(x),f.appendChild(h)}function b(u){if(!window.FormLogicEngine||!o.some(h=>h.logic||Array.isArray(h.triggers)&&h.triggers.length))return null;const f=new window.FormLogicEngine.FormLogicRuntime(s,a,u?{baseValues:u}:void 0);if(f.init(),a._formLogicRuntime=f,a._formLogicObserved)return f;if(a._formLogicObserved=!0,a.parentNode&&typeof MutationObserver<"u"){const h=new MutationObserver(function(p){for(const x of p)for(const M of x.removedNodes)if(M===a||M.nodeType===1&&M.contains&&M.contains(a)){a._formLogicRuntime&&a._formLogicRuntime.destroy(),h.disconnect();return}});h.observe(a.parentNode,{childList:!0,subtree:!1}),a._formLogicObserver=h}return f}let w=!1;if(a.addEventListener("dm-form-end",u=>{const f=u.detail?.validation;if(f&&!f.valid){Z(a,f.missing),ee(f);return}w||(w=!0,y(u.detail?.values||{}).catch(()=>{}).finally(()=>{w=!1}))}),m&&F.wizard){const u=ve(o,s.title),f=u.map(v=>({title:v.title,description:v.description,fields:L(v.fields,t)})),h=u.map(v=>v.fields);let p=0,x=null,M=null;const N=v=>{const k=window.FormLogicEngine;if(!k||!k.validateFields)return;const q=k.validateFields(a,h[p]||[]);q.valid||(v.preventDefault(),v.stopImmediatePropagation(),Z(a,q.missing),ee(q))},c=()=>{const v=h[p]||o;Ce(a,e),te(a,e,v),oe(a,e),C(a,v),Q(a,v),ke(a,n),e.honeypot!==!1&&l(a),x&&x.destroy(),x=b(M?.getStepData?M.getStepData():void 0),a.querySelectorAll(".wizard-next, .wizard-submit").forEach(k=>k.addEventListener("click",N,!0))};M=F.wizard(a,{schema:{steps:f},layout:r,columns:t,finishText:e.submitText||"Finish",onSubmit:y,onStepChange:v=>{ne(a,n),p=v,setTimeout(c,0)}}),a.addEventListener("dm-form-trigger",v=>{if(v.detail?.type!=="goto-step"||!M?.goToStep)return;const k=Number(v.detail.action.step);!Number.isFinite(k)||k<0||k>=f.length||k!==p&&M.goToStep(k)}),Promise.resolve(M).then(c)}else if(F.render){const u=F.render(a,L(o,t),I(o),{submitText:e.submitText||"Submit",layout:r,columns:t,onSubmit:y});Promise.resolve(u).then(function(){we(a,e,r),te(a,e,o),oe(a,e),C(a,o),Q(a,o),e.honeypot!==!1&&l(a),b()})}})})();function _e(d,i){const D=document.body,L=D.classList,I=new Set((D.dataset.railSite||"").split(" ").filter(Boolean)),C=()=>window.matchMedia("(min-width: 993px)").matches;d.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const r=t.textContent.trim();r&&(t.setAttribute("title",r),t.querySelector("svg, [data-icon]")||(t.dataset.initial=r.charAt(0).toUpperCase()))});const A=document.createElement("button");A.type="button",A.className="dm-nav-collapse-toggle";const a=()=>{const t=L.contains("dm-vnav-collapsed");A.setAttribute("aria-pressed",String(t)),A.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),A.title=A.getAttribute("aria-label");const r=i?"chevrons-left":"chevrons-right",m=i?"chevrons-right":"chevrons-left";A.innerHTML=`<span data-icon="${t?r:m}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(A)},s=t=>{L.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),a()};A.addEventListener("click",()=>s(!L.contains("dm-vnav-collapsed"))),a();const o=d.querySelector(".navbar-container")||d;o.insertBefore(A,o.firstChild?.nextSibling||null);const e=t=>{L.toggle("dm-vnav-autohide",t),L.toggle("dm-vnav-collapsible",!t&&I.has("collapsible")),t?L.remove("dm-vnav-collapsed"):I.has("collapsible")&&S.get("nav_collapsed")===!0&&L.add("dm-vnav-collapsed"),d.classList.remove("dm-nav-revealed"),a()};d.addEventListener("pointerdown",t=>{L.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!d.classList.contains("dm-nav-revealed")&&(d.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{d.contains(t.target)||d.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(d,{items:()=>{const t=L.contains("dm-vnav-autohide"),r=L.contains("dm-vnav-collapsed"),m=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:r?"Expand menu":"Collapse to icons",icon:r?"maximize":"minimize",disabled:!C()||t||!I.has("collapsible"),action:()=>s(!r)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!C(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!m,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(I.has("autohide")),L.toggle("dm-vnav-collapsed",!I.has("autohide")&&I.has("start-collapsed")),a()}}]}})}function qe(d){d.classList.add("dm-nav-scroll-hide");let i=window.scrollY,D=!1;window.addEventListener("scroll",()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const L=window.scrollY,I=d.matches(":focus-within")||d.querySelector(".navbar-dropdown.open, .navbar-collapse.show");L>i&&L>d.offsetHeight&&!I?d.classList.add("dm-nav-scrolled-away"):L<i&&d.classList.remove("dm-nav-scrolled-away"),i=L}))},{passive:!0})}function Me(d){let i={};try{i=JSON.parse(d.dataset.contents||"{}")}catch{}const D=d.closest(".site-main"),L=document.querySelector(".site-content"),I=new Set(String(i.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),C=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),A=n=>(L?[...L.querySelectorAll(n)]:[]).filter(C).filter(y=>!I.has(y.textContent.trim().toLowerCase())),a=i.headings==="h2"?A("h2"):i.headings==="h3"?A("h3"):i.headings==="h2h3"?A("h2, h3"):A("h2").length?A("h2"):A("h3");if(!a.length){D?.classList.add("no-sidebar-items");return}const s=new Set([...document.querySelectorAll("[id]")].map(n=>n.id)),o=document.createElement("nav");o.className="dm-contents",o.setAttribute("aria-label",i.title||"Page contents"),i.hover&&(o.dataset.menuHover=i.hover),i.selected&&(o.dataset.menuActive=i.selected),i.accent&&o.style.setProperty("--dm-menu-highlight",i.accent.startsWith("#")?i.accent:`var(--dm-${i.accent})`),i.font&&(o.style.fontFamily=i.font),i.fontSize&&(o.style.fontSize=i.fontSize),i.fontWeight&&(o.style.fontWeight=i.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=i.title||"",e.appendChild(t),o.appendChild(e);const r=document.createElement("ol");r.className="dm-contents-list"+(i.numbered?" is-numbered":"");const m=[];for(const n of a){if(!n.id){const l=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let b=l;for(let w=2;s.has(b);w++)b=`${l}-${w}`;s.add(b),n.id=b}const y=document.createElement("li");y.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const g=document.createElement("a");g.href=`#${n.id}`,g.textContent=n.textContent.trim(),y.appendChild(g),r.appendChild(y),m.push([n,g])}if(o.appendChild(r),d.replaceChildren(o),i.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,y=()=>{const l=m.find(([b])=>n.get(b))||null;m.forEach(([,b])=>{const w=l&&b===l[1];b.classList.toggle("is-active",!!w),w?b.setAttribute("aria-current","location"):b.removeAttribute("aria-current")})},g=new IntersectionObserver(l=>{l.forEach(b=>n.set(b.target,b.isIntersecting)),y()},{rootMargin:"-80px 0px -60% 0px"});m.forEach(([l])=>g.observe(l))}if(D?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const y=()=>{const g=D.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!g)),n.setAttribute("aria-label",g?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${g?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",D.classList.toggle("contents-collapsed")),y()}),y(),e.insertBefore(n,e.firstChild)}if(D?.classList.contains("contents-floating")&&i.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(d.style,{left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",y=>{if(y.target.closest("button"))return;const g=d.getBoundingClientRect(),l=y.clientX-g.left,b=y.clientY-g.top,w=f=>{const h=Math.max(0,Math.min(window.innerWidth-g.width,f.clientX-l)),p=Math.max(0,Math.min(window.innerHeight-40,f.clientY-b));Object.assign(d.style,{left:`${h}px`,top:`${p}px`,right:"auto",bottom:"auto"})},u=()=>{document.removeEventListener("pointermove",w),S.set("contents_position",{x:parseInt(d.style.left,10),y:parseInt(d.style.top,10)})};document.addEventListener("pointermove",w),document.addEventListener("pointerup",u,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(d,{items:()=>{const n=D?.classList.contains("contents-collapsible"),y=D?.classList.contains("contents-collapsed"),g=m.find(([,l])=>l.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:y?"Show the contents":"Collapse to a button",icon:y?"list":"minimize",action:()=>d.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!g,action:async()=>{const l=`${location.origin}${location.pathname}#${g[0].id}`;try{await _.copyToClipboard(l),E.toast("Link copied.",{type:"success"})}catch{E.toast("Could not copy the link.",{type:"error"})}}},{label:"Back to the top",icon:"arrow-up",action:()=>window.scrollTo({top:0,behavior:"smooth"})}]}}),D?.classList.contains("contents-autohide")&&(d.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!d.classList.contains("is-revealed")&&(d.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{d.contains(n.target)||d.classList.remove("is-revealed")}))}
1
+ import{applyMobileMenu as ae,initCarouselPopup as ie}from"/public/js/mobile-ui.mjs?v=20261016-mobile-options";import{installSmoothCarets as re}from"/public/js/smooth-caret.js";import{decodeBase64Json as V}from"/public/js/utf8-base64.mjs";import{makeBadgeEl as U,applyColour as G,applyPill as ce,applyFloat as le,applyHighlight as Y,applyItemHighlight as de,itemHighlightAttrs as me,isCurrentItem as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261029-footer-bars";import{initPageMotion as he}from"/public/js/page-motion.mjs?v=20261029-page-motion";import{applyFooterShowcase as ge}from"/public/js/footer-showcase.mjs?v=20261029-footer-showcase";import{initFloatingMenus as ye}from"/public/js/menu-float.js?v=20260829-float-panel";import{enhancePickerFields as Q,markInvalidFields as Z,showValidationPopup as ee}from"/public/js/forms.js?v=20261031-form-entrance-forms";import{buildWizardSteps as ve}from"/public/js/form-steps.mjs";import{mountMotionControl as be}from"/public/js/motion-control.mjs?v=20261031-launchers";import{applyFormClasses as te,applyFormEntrance as oe,applySubmitButtons as we,applyWizardButtons as Ce}from"/public/js/form-submit.mjs";import{captureFileFields as ne,destroyDropzones as Se,fileBlueprint as xe,restoreFileFields as ke,setFileLimits as Le,splitFiles as $e,submitBody as Ee,totalTooLarge as Ae,wireFileFields as Te}from"/public/js/form-files.mjs";document.addEventListener("click",l=>{const i=l.target?.closest?.(".dm-banner__dismiss");i&&(l.preventDefault(),i.closest(".dm-banner")?.remove())}),$(()=>{re(document);const l=window.__CMS_NAV__||{},i=window.__CMS_SITE__||{},D=i.brandingEnabled!==!1&&l.brand?.enabled!==!1;if(i.autoTheme?.enabled){let o=function(r){const m=(r||"07:00").split(":");return+m[0]*60+(+m[1]||0)},e=function(){const r=new Date,m=r.getHours()*60+r.getMinutes();return m>=o(a.dayStart)&&m<o(a.nightStart)?a.dayTheme:a.nightTheme},t=function(r){const m=a.apply&&a.apply[r]||{theme:r,custom:""};Domma.theme.set(m.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);m.custom&&document.body.classList.add(m.custom)};const a=i.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const L=$("#site-navbar");if(L.length&&l.brand){let e=function(u,f=0){return Array.isArray(u)?u.filter(h=>!(h&&(h.type==="spacer"||h.type==="theme-switcher"))).filter(h=>!(h&&h.type==="separator"&&f===0)).map(h=>h&&h.type==="separator"?{divider:!0}:Array.isArray(h?.items)?{...h,items:e(h.items,f+1)}:h):u};const a={...l.brand},o=a.size&&a.size!=="md"?` navbar-brand-${a.size}`:"";if(a.logo||a.icon||a.tagline){let u="";a.logo?u+=`<img src="${a.logo}" class="navbar-brand-logo" alt="${a.text||""}">`:a.icon&&(u+=`<span data-icon="${a.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),a.text&&(u+=`<span class="navbar-brand-text${o}">${a.text}</span>`),a.tagline&&(u+=`<small class="navbar-brand-tagline">${a.tagline}</small>`),a.html=u}else o&&a.text&&(a.html=`<span class="navbar-brand-text${o}">${a.text}</span>`);const t=e(l.items||[]),r=l.position==="floating",m=l.orientation==="vertical";L.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:D?a:null,items:t,variant:l.variant||"dark",position:r?"static":l.position||"sticky",collapsible:!0,appearOnHover:!!l.appearOnHover}),Domma.icons.scan("#site-navbar");const n=L.get(0);ae(n,l.mobile);const y=()=>{if(!m)return;const f=n.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");f&&!f.classList.contains("open")&&f.querySelector(":scope > .navbar-dropdown-toggle")?.click()};n.classList.add(`dm-nav-align-${ue(l)||"centre"}`),m&&L.get(0).classList.add("dm-nav-vertical",l.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const g=l.dock||{};m&&!r&&qe(n,l.side==="right"),!m&&g.hideOnScroll&&Me(n),Y(n,l),J(n,l),P(n,l.class),r&&(le(L.get(0),l),ye(L.get(0).parentNode||document));const d=n.querySelector(".navbar-toggle"),b=n.querySelector(".navbar-collapse");if(d&&b){let u=null;const f=()=>{b.classList.contains("show")&&d.click()},h=()=>{u&&(u.remove(),u=null),document.body.classList.remove("dm-drawer-open")},p=()=>{u||(u=document.createElement("div"),u.className="dm-navbar-backdrop",u.addEventListener("click",f),document.body.appendChild(u),document.body.classList.add("dm-drawer-open"))};d.addEventListener("click",()=>{requestAnimationFrame(()=>{b.classList.contains("show")?(y(),p()):h()})}),b.addEventListener("click",x=>{x.target.closest("a")&&requestAnimationFrame(h)}),document.addEventListener("keydown",x=>{x.key==="Escape"&&b.classList.contains("show")&&f()})}const w=n.querySelector(".navbar-nav");if(w){const u=Array.from(w.children);let f=0;for(const h of l.items||[])if(!(h&&h.type==="separator")){if(h&&h.type==="spacer"){const p=document.createElement("li"),x=["xs","sm","md","lg","xl","flex"].includes(h.size)?h.size:"md";p.className=`dm-menu-spacer dm-menu-spacer--${x}`,p.setAttribute("aria-hidden","true"),w.insertBefore(p,u[f]||null);continue}if(h&&h.type==="theme-switcher"){const p=document.createElement("li");p.className="dm-menu-theme-switcher";const x=document.createElement("span");x.dataset.themeSwitcher="menu",x.dataset.position="inline",p.appendChild(x),w.insertBefore(p,u[f]||null);continue}f++}window.CMSThemeSwitcher?.scan(w)}n.querySelectorAll("[data-path]").forEach(u=>{const f=u.dataset.path.split(".").map(Number),h=f.length>1,p=f.reduce((M,I)=>M?.items?.[I],{items:t});if(!p)return;p.colour&&G(u,p.colour),p.pill&&!h&&ce(u,p.pill),de(u,p),P(u.closest("li"),p.class);const x=U(p.badge);x&&u.appendChild(x),K(p.url,location.pathname)&&(u.classList.add("active"),u.setAttribute("aria-current","page"))}),pe(n,l,t),y()}let z=null;const C=$("#site-footer");if(C.length){let r=function(c){return String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},m=function(c){return r(c).replace(/'/g,"&#39;")},n=function(c){if(c&&c.type==="separator")return'<li class="footer-sep"><hr></li>';if(c&&c.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(c.size)?c.size:"md"}" aria-hidden="true"></li>`;if(c&&c.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const v=m(c.url||"#"),k=r(c.text||""),q=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",N=me(c),j=[N.hover&&` data-menu-item-hover="${m(N.hover)}"`,N.active&&` data-menu-item-active="${m(N.active)}"`].filter(Boolean).join(""),W=N.accent?` style="--dm-menu-highlight:${m(N.accent)}"`:"",B=X(c.class).join(" ");return`<li${B?` class="${m(B)}"`:""}><a href="${v}"${j}${W}>${k}</a>${q}</li>`},g=function(){if(!i.footer)return"";const c=Object.keys(o).filter(k=>a[k]);if(!c.length)return"";const v=X(i.footer.socialClass).join(" ");return`<div class="footer-social">${c.map(k=>{const{label:q,svg:N}=o[k];return`<a href="${a[k]}" target="_blank" rel="noopener noreferrer" aria-label="${q}" class="footer-social-link${v?` ${m(v)}`:""}">${N}</a>`}).join("")}</div>`},u=function(c){if(!c||c.type==="separator"||c.type==="spacer")return"";if(c.type==="theme-switcher")return`<li class="cms-footer-col">${n(c).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const v=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",k=w(c)?`<span class="cms-footer-col-title">${r(c.text||"")}</span>`:`<a class="cms-footer-col-title" href="${m(c.url||"#")}">${r(c.text||"")}</a>`,q=["cms-footer-col",...X(c.class)].join(" ");return`<li class="${m(q)}">${k}${v}</li>`},p=function(c,v,k=!1){return(c||[]).forEach(q=>{q&&(q.type==="separator"||q.type==="spacer"||q.type==="theme-switcher")||(k&&w(q)||v.push(q),Array.isArray(q.items)&&q.items.length&&p(q.items,v))}),v};const a=i.social||{},o={twitter:{label:"X / Twitter",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.742l7.73-8.835L1.254 2.25H8.08l4.259 5.629L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>'},facebook:{label:"Facebook",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>'},instagram:{label:"Instagram",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>'},linkedin:{label:"LinkedIn",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>'},github:{label:"GitHub",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>'},youtube:{label:"YouTube",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg>'}};let e='<div class="footer-inner container">';const t=window.__CMS_FOOTER__||{primary:[],legal:[],copyright:""},y=(()=>{const c=i.cookieConsent;if(!c||c.showSettingsLink===!1)return"";const v=k=>(k||[]).some(q=>q&&(q.url==="#cookie-settings"||v(q.items)));return v(t.primary)||v(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${r(c.settingsLinkText||"Cookie settings")}</a></li>`})(),d=["columns","row"].includes(i.footer?.layout)?i.footer.layout:"auto",b=i.footer?.look==="showcase"||d==="columns"||d==="auto"&&t.primary.some(c=>Array.isArray(c?.items)&&c.items.length),w=c=>b&&!c.url&&Array.isArray(c.items)&&c.items.length>0;if(b){const c=l.brand||{},v=D&&(c.text||i.title)||"",k=D?c.logo?`<img src="${m(c.logo)}" class="cms-footer-brand-logo" alt="">`:c.icon?'<span class="cms-footer-brand-icon"></span>':"":"",q=String(i.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${v||k?`<a class="cms-footer-brand-name" href="${m(c.url||"/")}">${k}<span>${r(v)}</span></a>`:""}${q?`<p class="cms-footer-blurb">${r(q)}</p>`:""}${g()}</div>`,t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${t.primary.map(u).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',t.copyright&&(e+=`<p class="cms-footer-copyright">${r(t.copyright)}</p>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+="</div>"}else t.copyright&&(e+=`<p>${r(t.copyright)}</p>`),t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary"><ul>${t.primary.map(n).join("")}</ul></nav>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+=g();e+="</div>",C.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const f=C.get(0).querySelector(":scope > .cms-footer-blocks");f?.remove(),C.html(e),f&&C.get(0).prepend(f),window.CMSThemeSwitcher?.scan(C.get(0));const h=C.get(0).querySelector(".cms-footer-brand-icon");h&&l.brand?.icon&&h.setAttribute("data-icon",l.brand.icon),P(C.get(0),i.footer?.class),b&&ge(C.get(0),i);const x=[...p(t.primary,[],!0),...p(t.legal,[])],M=C.get(0).querySelectorAll(".footer-nav a"),I=[];M.forEach((c,v)=>{const k=x[v];if(!k)return;if(I.push({a:c,item:k}),k.icon){const N=document.createElement("span");N.className="cms-footer-ic",N.setAttribute("data-icon",String(k.icon)),N.setAttribute("data-icon-size","15"),N.setAttribute("aria-hidden","true"),c.prepend(N)}k.colour&&G(c,k.colour);const q=U(k.badge);q&&c.appendChild(q),K(k.url,location.pathname)&&(c.classList.add("is-active"),c.setAttribute("aria-current","page"))}),Y(C.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(C.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(C.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(C.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(C.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(C.get(0).querySelector(".footer-nav--legal"),t.legalClass),fe(C.get(0),t,I),z=C.get(0).querySelector(".cms-footer-bottom")||C.get(0).querySelector(".footer-inner")}be(i.motion||{enabled:i.footer?.showMotionToggle!==!1,default:i.footer?.motionDefault,placement:"footer",control:i.footer?.motionControl,label:"Reduce motion"},{footer:z,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const A=document.getElementById("site-sidebar");A&&De(A),Domma.icons.scan(),Domma.syntax?.scan&&Domma.syntax.scan();const s=$(".page-body");if(s.length){s.find(".accordion").each(function(){Domma.elements.accordion(this,{allowMultiple:this.dataset.multi==="true"})}),s.find(".tabs").each(function(){Domma.elements.tabs(this)}),s.find(".carousel").each(function(){const o={primary:"--dm-primary",secondary:"--dm-secondary",accent:"--dm-primary",text:"--dm-text",surface:"--dm-surface",background:"--dm-background",success:"--dm-success",warning:"--dm-warning",danger:"--dm-danger",info:"--dm-info"},e=g=>{const d=String(g||"").trim();return d?o[d.toLowerCase()]?`var(${o[d.toLowerCase()]})`:CSS.supports("color",d)?d:"":""},t=e(this.dataset.background),r=e(this.dataset.arrowBackground),m=e(this.dataset.arrowColor);t&&(this.style.setProperty("--dm-carousel-background",t),this.classList.add("dm-carousel-custom-background")),r&&this.style.setProperty("--dm-carousel-arrow-background",r),m&&this.style.setProperty("--dm-carousel-arrow-color",m);const n=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${n}`);const y={autoplay:this.dataset.autoplay==="true",interval:parseInt(this.dataset.interval,10)||5e3,loop:this.dataset.loop!=="false",animation:this.dataset.animation||"slide",heightMode:this.dataset.heightMode==="average"?"average":"crop"};if(this.dataset.height){const g=Number(this.dataset.height);Number.isFinite(g)&&g>0&&(y.height=g)}if(this.dataset.animationDuration){const g=parseInt(this.dataset.animationDuration,10);Number.isFinite(g)&&(y.animationDuration=g)}this.dataset.animationEasing&&(y.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(g=>g.cloneNode(!0)),this._dmCarouselOpts=y),this._dmCarousel=Domma.elements.carousel(this,y),ie(this)}),s.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),m=r?new Date(+r[1],+r[2]-1,+r[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(m)?o.duration=Math.max(0,m-Date.now()):this.dataset.duration&&(o.duration=(parseInt(this.dataset.duration,10)||0)*1e3);const n=/^dd:/i.test(e);o.format=n?"hh:mm:ss":e||(o.duration>=36e5?"hh:mm:ss":"mm:ss");const y=this,g=b=>String(b).padStart(2,"0"),d=b=>{const w=Math.max(0,Math.floor(b/1e3)),u=y.querySelector(".dm-timer-time");u&&(u.textContent=`${g(Math.floor(w/86400))}:${g(Math.floor(w%86400/3600))}:${g(Math.floor(w%3600/60))}:${g(w%60)}`)};n&&(o.onTick=d),Domma.elements.timer(this,o),n&&d(o.duration||0)}),s.find("[data-tooltip]:not(.dm-range-slider)").each(function(){Domma.elements.tooltip(this,{content:$(this).data("tooltip"),position:$(this).data("tooltip-position")||"top"})}),s.find(".dm-progression").each(function(){const o=Array.from(this.querySelectorAll(".dm-progression-item")).map(r=>{const m={title:r.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:r.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return r.dataset.date&&(m.date=r.dataset.date),r.dataset.status&&(m.status=r.dataset.status),r.dataset.eventIcon&&(m.icon=r.dataset.eventIcon),r.dataset.entryId&&(m._entryId=r.dataset.entryId),m}),e=this.dataset.layout==="centred"?"centered":this.dataset.layout||"vertical",t=Domma.elements.progression(this,{layout:e,theme:this.dataset.theme||"minimal",mode:this.dataset.mode||"timeline",statusIcons:!0,allowHtml:!0,...o.length?{items:o}:{}});if((this.dataset.mode||"timeline")==="timeline"){const r={completed:{label:"Completed",icon:"check-circle",tone:"success"},planned:{label:"Planned",icon:"circle",tone:"secondary"},"in-progress":{label:"In progress",icon:"clock",tone:"primary"},blocked:{label:"Blocked",icon:"alert-circle",tone:"danger"}};this.querySelectorAll(".dm-progression-item").forEach((m,n)=>{const y=o[n];if(!y)return;const g=m.querySelector(".dm-progression-title");if(y.icon&&g){const b=document.createElement("span");b.dataset.icon=y.icon,b.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",b.setAttribute("aria-hidden","true"),g.prepend(b)}const d=r[y.status];if(d&&g){const b=document.createElement("span");b.className=`badge badge-${d.tone} cms-timeline-status`,b.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const w=document.createElement("span");w.dataset.icon=d.icon,w.dataset.iconSize="14",w.setAttribute("aria-hidden","true"),b.append(w,document.createTextNode(d.label)),g.after(b)}})}Domma.icons.scan(this),o.length&&(this._dmCtx={instance:t,items:o})});try{Domma.effects.reveal(".page-body .hero",{animation:"slide-up",duration:480,threshold:.06,stagger:60,once:!1})}catch{}const a=matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.classList.contains("dm-reduced-motion");document.querySelectorAll(".page-body .row[data-reveal]").forEach(o=>{const e=o.dataset.revealMode||"stagger",t=o.dataset.revealAnimation||"slide-up",r=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),m=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,y=o.dataset.revealDirection==="rtl",g=o.dataset.revealReplay==="true",d=Array.from(o.children);if(a&&t.startsWith("swoosh"))return;const b={"slide-up":"translateY(30px)","slide-down":"translateY(-30px)","slide-left":"translateX(30px)","slide-right":"translateX(-30px)",zoom:"scale(0.85)",flip:"perspective(600px) rotateX(15deg)",swoosh:"translateY(36px) scale(0.96)"},w=p=>t!=="swoosh-sides"?b[t]||"":d.length>1&&p===0?"translateX(-64px) rotate(-1.5deg)":d.length>1&&p===d.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",u=t.startsWith("swoosh"),f=u?"cubic-bezier(.2,.8,.2,1)":"ease",h=(p,x)=>{p.style.opacity="0",p.style.transform=w(x),u&&(p.style.filter="blur(10px)")};d.forEach((p,x)=>{p.style.transition="none",h(p,x)}),o.offsetWidth,d.forEach((p,x)=>{p.style.transition=`opacity ${r}ms ${f}, transform ${r}ms ${f}`+(u?`, filter ${r}ms ${f}`:"");const M=y?d.length-1-x:x;p.style.transitionDelay=e==="stagger"?`${n+M*m}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const p=new IntersectionObserver(x=>{x.forEach(M=>{if(M.isIntersecting){if(M.target.offsetWidth,M.target.style.opacity="1",M.target.style.transform="",u&&(M.target.style.filter=""),!g){p.unobserve(M.target);const I=M.target;I.addEventListener("transitionend",function c(v){v.target!==I||v.propertyName!=="opacity"||(I.removeEventListener("transitionend",c),I.style.transition="",I.style.transitionDelay="")})}}else g&&M.boundingClientRect.top>0&&h(M.target,d.indexOf(M.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});d.forEach(x=>p.observe(x))}))}),he(document.querySelector(".page-body")||document),s.find(".card[data-collapsible]").each(function(){const o=this.querySelector(".card-header");o&&o.addEventListener("click",()=>this.classList.toggle("is-collapsed"))}),s.find(".dm-so-trigger").each(function(){this.addEventListener("click",()=>{const o=this.dataset.soTarget,e=document.getElementById(o);if(!e)return;const t=E.slideover({title:e.dataset.soTitle||"",size:e.dataset.soSize||"md",position:e.dataset.soPosition||"right"});e.style.display="",t.setContent(e),t.open()})})}if(typeof $.setup=="function"){const a=Object.assign({},window.__CMS_DCONFIG__||{});if(document.querySelectorAll(".dm-page-config[data-config]").forEach(o=>{try{const e=V(o.dataset.config);Object.assign(a,e)}catch{}}),Object.keys(a).length>0){const o={};for(const[e,t]of Object.entries(a)){const r=t?.events?.click,{confirm:m,toast:n,alert:y,prompt:g,...d}=r||{};if(m||n||y||g){$(e).on("click",async function(W){if(W.preventDefault(),m&&!await E.confirm(m))return;let B=null;if(!(g&&(B=await E.prompt(g,{inputPlaceholder:d.promptPlaceholder||"",inputValue:d.promptDefault||""}),B===null))){{const O=$(d.target||this);d.toggleClass&&O.toggleClass(d.toggleClass),d.addClass&&O.addClass(d.addClass),d.removeClass&&O.removeClass(d.removeClass),B!==null&&(d.setText&&O.text(B),d.setVal&&O.val(B),d.setAttr&&O.attr(d.setAttr,B))}d.href&&se(d.href),n&&E.toast(n,{type:d.toastType||"success"}),y&&E.alert(y)}});const{target:w,toggleClass:u,addClass:f,removeClass:h,setText:p,setVal:x,setAttr:M,href:I,toastType:c,promptPlaceholder:v,promptDefault:k,...q}=d,N={...t.events};Object.keys(q).length?N.click=w?{target:w,...q}:q:delete N.click;const j={...t,events:N};Object.keys(N).length||delete j.events,Object.keys(j).length&&(o[e]=j)}else o[e]=t}$.setup(o)}}s.length&&R(s.get(0))}),window.wireCTAButtons=R;function se(l){if(!_e(l)){console.warn("[site] refused to go to",String(l).slice(0,60));return}const i=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(i?window.top:window).location.href=l}function _e(l){const i=String(l??"").replace(/[\u0000-\u0020\u007f-\u00a0\u200b-\u200f\ufeff]/g,"").toLowerCase();return!i||i.includes("\\")||i.startsWith("//")?!1:/^(\/|#|\?|\.\.?\/)/.test(i)||/^(https?:\/\/|mailto:|tel:)/.test(i)?!0:!/^[a-z][a-z0-9+.-]*:/.test(i)}function R(l){l.querySelectorAll(".dm-cta-trigger").forEach(i=>{i.__ctaWired||(i.__ctaWired=!0,i.addEventListener("click",async()=>{const D=i.dataset.action,L=i.dataset.entry,z=i.dataset.confirm;let C=S.get("auth_token");if(!C){E.toast("Please log in to perform this action.",{type:"warning"});return}if(z&&!await E.confirm(z))return;const A=Array.from(i.childNodes).map(a=>a.cloneNode(!0));i.disabled=!0,i.textContent="Running\u2026";const s=a=>fetch(`/api/actions/${D}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(i.dataset.scope?{entryId:L,scope:i.dataset.scope}:{entryId:L})});try{let a=await s(C);if(a.status===401){const e=S.get("auth_refresh_token");if(e){const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(t.ok){const{token:r}=await t.json();S.set("auth_token",r),C=r,a=await s(C)}}}const o=await a.json().catch(()=>({}));if(!a.ok||o.success===!1)throw new Error(o.error||o.message||`Error ${a.status}`);E.toast(o.message||"Action completed.",{type:"success"})}catch(a){E.toast(a.message||"Action failed.",{type:"error"})}finally{i.disabled=!1,i.textContent="",A.forEach(a=>i.appendChild(a)),Domma.icons.scan(i)}}))})}(function(){const i=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!i.length)return;const D=S.get("auth_token");function L(C,A){const s=document.createElement("div");s.className="dm-collection-display dm-collection-empty";const a=document.createElement("p");if(A){a.appendChild(document.createTextNode("Please "));const o=document.createElement("a");o.href="/login",o.textContent="sign in",a.appendChild(o),a.appendChild(document.createTextNode(" to view your entries."))}else a.textContent=C;return s.appendChild(a),s}function z(C,A){const s=document.createElement("template");s.innerHTML=A||"",C.replaceWith(s.content)}i.forEach(async C=>{const A=C.dataset.collectionAttrs;if(!A)return;if(!D){C.replaceChildren(L("",!0));return}const s=a=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({attrs:A})});try{let a=D,o=await s(a);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const r=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(r.ok){const{token:m}=await r.json();S.set("auth_token",m),a=m,o=await s(a)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));C.replaceChildren(L(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();z(C,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{C.replaceChildren(L("Unable to load entries.",!1))}}),setTimeout(()=>{typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(),typeof Domma<"u"&&Domma.syntax?.scan&&Domma.syntax.scan(),R(document.body)},100)})(),(function(){const i=document.querySelectorAll("[data-collection-table]");!i.length||typeof T>"u"||!T.create||i.forEach(D=>{let L;try{L=V(D.dataset.payload)}catch{return}const{columns:z,rows:C,search:A,sortable:s,exportable:a,pageSize:o,empty:e,ctaConfig:t,slug:r,exportCfg:m}=L;if(!z?.length)return;if(t){const g=z.findIndex(d=>d.key==="_cta");g!==-1&&(z[g]={key:"_cta",title:"",render:(d,b)=>{const w=document.createElement("button");if(w.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,w.dataset.action=t.action||"",t.scope&&(w.dataset.scope=t.scope),w.dataset.entry=b._entryId||"",t.confirm&&(w.dataset.confirm=t.confirm),t.icon){const u=document.createElement("span");u.dataset.icon=t.icon,w.appendChild(u),w.appendChild(document.createTextNode(" "))}return w.appendChild(document.createTextNode(t.label||"Run")),w}})}const n="col-table-"+Math.random().toString(36).slice(2,7),y=document.createElement("div");y.id=n,D.replaceChildren(y),T.create("#"+n,{data:C,columns:z,search:A,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(y),D._dmTable={columns:z,rows:C,slug:r,exportCfg:m,render(g){T.create("#"+n,{data:g,columns:z,search:A,sortable:s,exportable:a,pageSize:o,emptyMessage:e}),t&&R(y)}}})})(),(function(){const i=document.querySelectorAll("[data-form-inline]");if(!i.length||typeof F>"u")return;function D(s){const a=s&&s.logic;return!!(a&&(a.visibility||a.requirement))}function L(s,a){const o={};return(s||[]).forEach(e=>{if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const t=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),r=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,m={...e.formConfig||{}};m.span==="full"&&a&&(m.span=a);const n={type:r,required:D(e)?!1:e.required,label:e.label,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{hint:e.helper},...e.tooltip&&{tooltip:e.tooltip},...m}};e.minLength!==void 0&&(n.minLength=e.minLength),e.maxLength!==void 0&&(n.maxLength=e.maxLength),e.min!==void 0&&(n.min=e.min),e.max!==void 0&&(n.max=e.max),t&&(e.variant&&(n.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(n.multiple=!0),e.density&&(n.density=e.density),e.columns&&(n.columns=e.columns),e.accent&&(n.accent=e.accent),e.accentStyle&&(n.accentStyle=e.accentStyle),e.glow&&(n.glow=!0),e.glowColour&&(n.glowColour=e.glowColour),e.shadow&&(n.shadow=e.shadow),e.shadowColour&&(n.shadowColour=e.shadowColour)),o[e.name]=e.type==="file"?xe(e,n):n}),o}function z(s){const a={};return(s||[]).forEach(o=>{if(!(!o.name||o.type==="page-break"||o.type==="spacer")&&(o.type==="select"||o.type==="multiselect")&&o.required){const e=(o.options||[])[0];e&&(a[o.name]=typeof e=="object"?e.value:e)}}),a}function C(s,a){(a||[]).forEach(o=>{if(o.type!=="date"||!o.name)return;const e=s.querySelector(`[name="${o.name}"]`);e&&e.type!=="date"&&(e.type="date")})}function A(s,a,o){let e=s.querySelector(".cms-form-message");e||(e=document.createElement("p"),e.className="cms-form-message",s.appendChild(e)),e.textContent=a,e.style.cssText=o?"color:var(--dm-danger);margin-top:.75rem;":"color:var(--dm-success);margin-top:.75rem;"}i.forEach(s=>{let a;try{a=V(s.dataset.formInline)}catch{return}s.querySelector(":scope > .cms-form-embed-summary")?.remove();const o=a.fields||[],e=a.settings||{},t=Number(e.columns)===3?3:2,r=e.layout||"grid",m=o.some(u=>u.type==="page-break"),n=new Map;Le(s,a.fileLimits,n),Te(s,o);const y=async u=>{if(s.dataset.triggerBlocked==="true"){const f=s._formLogicRuntime,h=f&&f.submitBlock?f.submitBlock().reasons:[];A(s,h.join(" ")||"This form cannot be submitted yet.",!0);const p=new Error("Blocked by a form trigger");throw p.formSubmitFailed=!0,p}try{const f=s.querySelector(".fb-form-honeypot"),h=f?.querySelector('input[type="text"]')||null,p=f?.querySelector('[name="_t"]')||null,x=Object.assign({},u);delete x._t,f?.dataset.hpName&&delete x[f.dataset.hpName],h!==null&&(x._hp=h.value),p!==null&&(x._t=p.value);const M=new Map(n);ne(s,M);const I=$e(x,o,M),c=Ae(s,I.files);if(c){A(s,c,!0);const k=new Error(c);throw k.formSubmitFailed=!0,k}const v=await H.post(`/api/forms/submit/${a.slug}`,I.files.size?Ee(I.values,I.files).body:I.values);if(v&&v.error){A(s,v.error,!0);const k=new Error(v.error);throw k.formSubmitFailed=!0,k}if(v?.redirect){se(v.redirect);return}for(Se(s);s.firstChild;)s.removeChild(s.firstChild);A(s,v?.message||e.successMessage||"Thank you for your submission.",!1)}catch(f){throw f.formSubmitFailed||A(s,f.message||"Submission failed. Please try again.",!0),f}},g=Date.now();function d(u){const f=u.querySelector("form");if(!f||f.querySelector(".fb-form-honeypot"))return;const h=document.createElement("div");h.className="fb-form-honeypot",h.setAttribute("aria-hidden","true");const p=document.createElement("input");p.name=f.querySelector('[name="website"]')?"_website":"website",h.dataset.hpName=p.name,p.type="text",p.tabIndex=-1,p.autocomplete="url",p.placeholder="https://",h.appendChild(p);const x=document.createElement("input");x.name="_t",x.type="hidden",x.value=g,h.appendChild(x),f.appendChild(h)}function b(u){if(!window.FormLogicEngine||!o.some(h=>h.logic||Array.isArray(h.triggers)&&h.triggers.length))return null;const f=new window.FormLogicEngine.FormLogicRuntime(a,s,u?{baseValues:u}:void 0);if(f.init(),s._formLogicRuntime=f,s._formLogicObserved)return f;if(s._formLogicObserved=!0,s.parentNode&&typeof MutationObserver<"u"){const h=new MutationObserver(function(p){for(const x of p)for(const M of x.removedNodes)if(M===s||M.nodeType===1&&M.contains&&M.contains(s)){s._formLogicRuntime&&s._formLogicRuntime.destroy(),h.disconnect();return}});h.observe(s.parentNode,{childList:!0,subtree:!1}),s._formLogicObserver=h}return f}let w=!1;if(s.addEventListener("dm-form-end",u=>{const f=u.detail?.validation;if(f&&!f.valid){Z(s,f.missing),ee(f);return}w||(w=!0,y(u.detail?.values||{}).catch(()=>{}).finally(()=>{w=!1}))}),m&&F.wizard){const u=ve(o,a.title),f=u.map(v=>({title:v.title,description:v.description,fields:L(v.fields,t)})),h=u.map(v=>v.fields);let p=0,x=null,M=null;const I=v=>{const k=window.FormLogicEngine;if(!k||!k.validateFields)return;const q=k.validateFields(s,h[p]||[]);q.valid||(v.preventDefault(),v.stopImmediatePropagation(),Z(s,q.missing),ee(q))},c=()=>{const v=h[p]||o;Ce(s,e),te(s,e,v),oe(s,e),C(s,v),Q(s,v),ke(s,n),e.honeypot!==!1&&d(s),x&&x.destroy(),x=b(M?.getStepData?M.getStepData():void 0),s.querySelectorAll(".wizard-next, .wizard-submit").forEach(k=>k.addEventListener("click",I,!0))};M=F.wizard(s,{schema:{steps:f},layout:r,columns:t,finishText:e.submitText||"Finish",onSubmit:y,onStepChange:v=>{ne(s,n),p=v,setTimeout(c,0)}}),s.addEventListener("dm-form-trigger",v=>{if(v.detail?.type!=="goto-step"||!M?.goToStep)return;const k=Number(v.detail.action.step);!Number.isFinite(k)||k<0||k>=f.length||k!==p&&M.goToStep(k)}),Promise.resolve(M).then(c)}else if(F.render){const u=F.render(s,L(o,t),z(o),{submitText:e.submitText||"Submit",layout:r,columns:t,onSubmit:y});Promise.resolve(u).then(function(){we(s,e,r),te(s,e,o),oe(s,e),C(s,o),Q(s,o),e.honeypot!==!1&&d(s),b()})}})})();function qe(l,i){const D=document.body,L=D.classList,z=new Set((D.dataset.railSite||"").split(" ").filter(Boolean)),C=()=>window.matchMedia("(min-width: 993px)").matches;l.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const r=t.textContent.trim();r&&(t.setAttribute("title",r),t.querySelector("svg, [data-icon]")||(t.dataset.initial=r.charAt(0).toUpperCase()))});const A=document.createElement("button");A.type="button",A.className="dm-nav-collapse-toggle";const s=()=>{const t=L.contains("dm-vnav-collapsed");A.setAttribute("aria-pressed",String(t)),A.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),A.title=A.getAttribute("aria-label");const r=i?"chevrons-left":"chevrons-right",m=i?"chevrons-right":"chevrons-left";A.innerHTML=`<span data-icon="${t?r:m}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(A)},a=t=>{L.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),s()};A.addEventListener("click",()=>a(!L.contains("dm-vnav-collapsed"))),s();const o=l.querySelector(".navbar-container")||l;o.insertBefore(A,o.firstChild?.nextSibling||null);const e=t=>{L.toggle("dm-vnav-autohide",t),L.toggle("dm-vnav-collapsible",!t&&z.has("collapsible")),t?L.remove("dm-vnav-collapsed"):z.has("collapsible")&&S.get("nav_collapsed")===!0&&L.add("dm-vnav-collapsed"),l.classList.remove("dm-nav-revealed"),s()};l.addEventListener("pointerdown",t=>{L.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!l.classList.contains("dm-nav-revealed")&&(l.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{l.contains(t.target)||l.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(l,{items:()=>{const t=L.contains("dm-vnav-autohide"),r=L.contains("dm-vnav-collapsed"),m=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:r?"Expand menu":"Collapse to icons",icon:r?"maximize":"minimize",disabled:!C()||t||!z.has("collapsible"),action:()=>a(!r)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!C(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!m,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(z.has("autohide")),L.toggle("dm-vnav-collapsed",!z.has("autohide")&&z.has("start-collapsed")),s()}}]}})}function Me(l){l.classList.add("dm-nav-scroll-hide");let i=window.scrollY,D=!1;window.addEventListener("scroll",()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const L=window.scrollY,z=l.matches(":focus-within")||l.querySelector(".navbar-dropdown.open, .navbar-collapse.show");L>i&&L>l.offsetHeight&&!z?l.classList.add("dm-nav-scrolled-away"):L<i&&l.classList.remove("dm-nav-scrolled-away"),i=L}))},{passive:!0})}function De(l){let i={};try{i=JSON.parse(l.dataset.contents||"{}")}catch{}const D=l.closest(".site-main"),L=document.querySelector(".site-content"),z=new Set(String(i.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),C=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),A=n=>(L?[...L.querySelectorAll(n)]:[]).filter(C).filter(y=>!z.has(y.textContent.trim().toLowerCase())),s=i.headings==="h2"?A("h2"):i.headings==="h3"?A("h3"):i.headings==="h2h3"?A("h2, h3"):A("h2").length?A("h2"):A("h3");if(!s.length){D?.classList.add("no-sidebar-items");return}const a=new Set([...document.querySelectorAll("[id]")].map(n=>n.id)),o=document.createElement("nav");o.className="dm-contents",o.setAttribute("aria-label",i.title||"Page contents"),i.hover&&(o.dataset.menuHover=i.hover),i.selected&&(o.dataset.menuActive=i.selected),i.accent&&o.style.setProperty("--dm-menu-highlight",i.accent.startsWith("#")?i.accent:`var(--dm-${i.accent})`),i.font&&(o.style.fontFamily=i.font),i.fontSize&&(o.style.fontSize=i.fontSize),i.fontWeight&&(o.style.fontWeight=i.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=i.title||"",e.appendChild(t),o.appendChild(e);const r=document.createElement("ol");r.className="dm-contents-list"+(i.numbered?" is-numbered":"");const m=[];for(const n of s){if(!n.id){const d=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let b=d;for(let w=2;a.has(b);w++)b=`${d}-${w}`;a.add(b),n.id=b}const y=document.createElement("li");y.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const g=document.createElement("a");g.href=`#${n.id}`,g.textContent=n.textContent.trim(),y.appendChild(g),r.appendChild(y),m.push([n,g])}if(o.appendChild(r),l.replaceChildren(o),i.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,y=()=>{const d=m.find(([b])=>n.get(b))||null;m.forEach(([,b])=>{const w=d&&b===d[1];b.classList.toggle("is-active",!!w),w?b.setAttribute("aria-current","location"):b.removeAttribute("aria-current")})},g=new IntersectionObserver(d=>{d.forEach(b=>n.set(b.target,b.isIntersecting)),y()},{rootMargin:"-80px 0px -60% 0px"});m.forEach(([d])=>g.observe(d))}if(D?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const y=()=>{const g=D.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!g)),n.setAttribute("aria-label",g?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${g?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",D.classList.toggle("contents-collapsed")),y()}),y(),e.insertBefore(n,e.firstChild)}if(D?.classList.contains("contents-floating")&&i.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(l.style,{left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",y=>{if(y.target.closest("button"))return;const g=l.getBoundingClientRect(),d=y.clientX-g.left,b=y.clientY-g.top,w=f=>{const h=Math.max(0,Math.min(window.innerWidth-g.width,f.clientX-d)),p=Math.max(0,Math.min(window.innerHeight-40,f.clientY-b));Object.assign(l.style,{left:`${h}px`,top:`${p}px`,right:"auto",bottom:"auto"})},u=()=>{document.removeEventListener("pointermove",w),S.set("contents_position",{x:parseInt(l.style.left,10),y:parseInt(l.style.top,10)})};document.addEventListener("pointermove",w),document.addEventListener("pointerup",u,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(l,{items:()=>{const n=D?.classList.contains("contents-collapsible"),y=D?.classList.contains("contents-collapsed"),g=m.find(([,d])=>d.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:y?"Show the contents":"Collapse to a button",icon:y?"list":"minimize",action:()=>l.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!g,action:async()=>{const d=`${location.origin}${location.pathname}#${g[0].id}`;try{await _.copyToClipboard(d),E.toast("Link copied.",{type:"success"})}catch{E.toast("Could not copy the link.",{type:"error"})}}},{label:"Back to the top",icon:"arrow-up",action:()=>window.scrollTo({top:0,behavior:"smooth"})}]}}),D?.classList.contains("contents-autohide")&&(l.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!l.classList.contains("is-revealed")&&(l.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{l.contains(n.target)||l.classList.remove("is-revealed")}))}
@@ -0,0 +1,2 @@
1
+ import{connectionFileName as h,connectionNotes as y,curlExample as m,openConnection as b,readHandoverAddress as w}from"./token-handover.mjs";const c=document.querySelector("[data-dm-token-handover]"),{id:p,key:l}=w(location.search,location.hash);location.hash&&history.replaceState(null,"",location.pathname+location.search);function n(t,e={},o){const a=document.createElement(t);for(const[r,i]of Object.entries(e))a.setAttribute(r,i);return o!=null&&(a.textContent=o),a}function s(t,e="info"){c.replaceChildren(n("div",{class:`alert alert-${e}`,role:e==="danger"?"alert":"status"},t))}async function u(t,e){try{await navigator.clipboard.writeText(t),e.textContent="Copied"}catch{e.textContent="Copy failed - select it by hand"}}function k(t){const e=new Blob([JSON.stringify(t,null,2)+`
2
+ `],{type:"application/json"}),o=n("a",{href:URL.createObjectURL(e),download:h(t)});document.body.appendChild(o),o.click(),setTimeout(()=>{URL.revokeObjectURL(o.href),o.remove()},1e3)}function C(t){const e=n("div",{class:"card",style:"padding: 1.25rem;"});e.appendChild(n("h2",{style:"margin-top: 0;"},t.name||"API token")),e.appendChild(n("p",{},`For ${t.siteName||t.site}${t.project?` \xB7 project ${t.project}`:""}${t.draftsOnly?" \xB7 drafts only":""}`));const o=n("code",{style:"display: block; word-break: break-all; padding: .75rem; margin: .5rem 0;"},t.token);e.appendChild(o);const a=n("div",{style:"display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem;"}),r=n("button",{type:"button",class:"btn btn-primary"},"Copy the token");r.addEventListener("click",()=>u(t.token,r));const i=n("button",{type:"button",class:"btn btn-secondary"},"Download the connection file");i.addEventListener("click",()=>k(t)),a.append(r,i),e.appendChild(a),e.appendChild(n("p",{},"Save it now - this page cannot show it again. Keep it like a password: anyone holding it can do what it allows.")),e.appendChild(n("h3",{},"How to use it")),e.appendChild(n("pre",{style:"white-space: pre-wrap;"},y(t)));const d=m(t);d&&(e.appendChild(n("h3",{},"Example")),e.appendChild(n("pre",{style:"white-space: pre-wrap;"},d))),c.replaceChildren(e)}async function g(t){t.disabled=!0,t.textContent="Opening\u2026";let e;try{e=await H.post(`/api/token-handover/${encodeURIComponent(p)}/open`,{})}catch(o){const a=String(o?.message||"").replace(/^Error:\s*/,"");e={error:a&&!/fetch|network/i.test(a)?a:"The site could not be reached. Try again in a moment."}}if(!e||e.error||!e.ciphertext){s(e?.error||"This link could not be opened.","danger");return}try{C(await b({ciphertext:e.ciphertext,iv:e.iv,key:l}))}catch{s("The link was opened, but its key does not match - it may have been copied only in part. Ask for a new one.","danger")}}if(c)if(!p||!l)s("This link is not complete - the part after the # is missing or cut short. Copy the whole link, or ask for a new one.","warning");else{const t=n("button",{type:"button",class:"btn btn-primary btn-lg"},"Show the token");t.addEventListener("click",()=>g(t)),c.replaceChildren(t)}
@@ -0,0 +1,13 @@
1
+ export const CONNECTION_TYPE="domma-cms-api-token",CONNECTION_VERSION=1,HANDOVER_PAGE="/_token-handover";const p={pages:{read:"Read: GET {url} or GET {url}/<path>",create:`Create: POST {url}
2
+ body {"path": "/news/my-post", "frontmatter": {"title": "\u2026", "description": "\u2026", "tags": []}, "body": "Markdown\u2026"}`,update:`Change: PUT {url}/<path>
3
+ body {"frontmatter": {\u2026}, "body": "Markdown\u2026"}`},media:{create:`Upload: POST {url} as multipart/form-data, field "file" (JPEG, PNG, GIF, WebP, AVIF or PDF)
4
+ answers {"name", "url"} - use the url in a page`},blocks:{create:`Create: POST {url}
5
+ body {"name": "my-block", "content": "<div>\u2026</div>", "css": "\u2026"}`,update:`Change: PUT {url}/<name>
6
+ body {"content": "\u2026", "css": "\u2026"}`}},h={create:`Create: POST {url}
7
+ body {"data": {...the fields...}}`,read:"Read: GET {url} or GET {url}/<id>",update:`Change: PUT {url}/<id>
8
+ body {"data": {...every field...}} (the whole entry)`,delete:"Delete: DELETE {url}/<id>"};export function connectionFile({origin:e,siteName:r="",token:t,plaintext:n,authorId:c=null,now:o=Date.now()}){const i=String(e||"").replace(/\/+$/,""),l=Array.isArray(t?.scopes)?t.scopes:[],u=l.filter(a=>a?.collection).map(a=>({collection:a.collection,url:`${i}/api/v1/${encodeURIComponent(a.collection)}`,verbs:Array.isArray(a.verbs)&&a.verbs.length?[...a.verbs]:["create","read","update","delete"]})),d=l.filter(a=>a?.content).map(a=>({resource:a.content,url:`${i}/api/content/v1/${a.content}`,verbs:Array.isArray(a.verbs)&&a.verbs.length?[...a.verbs]:["read"]}));return{type:CONNECTION_TYPE,version:1,site:i,...r?{siteName:String(r)}:{},name:String(t?.name||""),project:String(t?.project||""),token:String(n||""),header:"Authorization: Bearer <token>",draftsOnly:t?.draftsOnly===!0,...t?.expiresAt?{expiresAt:t.expiresAt}:{},everything:l.length===0,collections:u,content:d,...c?{defaults:{authorId:String(c)}}:{},createdAt:new Date(o).toISOString()}}export function connectionNotes(e){const r=[];r.push(`Site: ${e.site}`),r.push(`Send every request with the header Authorization: Bearer ${e.token?"<the token>":""}`.trim()),e.draftsOnly&&r.push("Drafts only: whatever status you send, what you write is saved as a draft for a person to publish. You may change or delete only drafts."),e.everything&&r.push("Unscoped: every collection in the project that allows token access.");for(const t of e.collections||[]){r.push("",`${t.collection}:`);for(const n of t.verbs)r.push(` ${h[n].replaceAll("{url}",t.url)}`)}for(const t of e.content||[]){r.push("",`${t.resource} (Content API):`);for(const n of t.verbs)r.push(` ${(p[t.resource]?.[n]||"Read: GET {url}").replaceAll("{url}",t.url)}`)}return e.defaults?.authorId&&r.push("",`Credit entries to authorId "${e.defaults.authorId}" (the collection needs an author).`),r.join(`
9
+ `)}export function curlExample(e){const r=(e.collections||[]).find(o=>o.verbs.includes("create"));if(r){const o={title:"Hello",slug:"hello",content:"Written by a bot.",...e.draftsOnly?{status:"draft"}:{},...e.defaults?.authorId?{authorId:e.defaults.authorId}:{}};return`curl -X POST ${shellQuote(r.url)} \\
10
+ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \\
11
+ -d ${shellQuote(JSON.stringify({data:o}))}`}const t=(e.content||[]).find(o=>o.resource==="pages"&&o.verbs.includes("create"));if(t){const o={path:"/news/hello",frontmatter:{title:"Hello"},body:"Written by a bot."};return`curl -X POST ${shellQuote(t.url)} \\
12
+ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \\
13
+ -d ${shellQuote(JSON.stringify(o))}`}const n=(e.content||[]).find(o=>o.resource==="media");if(n)return`curl -X POST ${shellQuote(n.url)} -H "Authorization: Bearer $TOKEN" -F file=@picture.png`;const c=(e.collections||[])[0]||(e.content||[])[0];return c?`curl ${shellQuote(c.url)} -H "Authorization: Bearer $TOKEN"`:""}export function shellQuote(e){return`'${String(e).replace(/'/g,"'\\''")}'`}export function connectionFileName(e){let r="site";try{r=new URL(e.site).host.replace(/[:]/g,"-")}catch{}const t=String(e.name||"token").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"token";return`${r}-${t}.json`}const s=()=>{const e=globalThis.crypto?.subtle;if(!e)throw new Error("This browser cannot encrypt (no WebCrypto) - use the connection file instead.");return e};export function toB64url(e){let r="";for(const t of new Uint8Array(e))r+=String.fromCharCode(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}export function fromB64url(e){const r=String(e||"").replace(/-/g,"+").replace(/_/g,"/"),t=atob(r+"=".repeat((4-r.length%4)%4));return Uint8Array.from(t,n=>n.charCodeAt(0))}export async function sealConnection(e){const r=globalThis.crypto.getRandomValues(new Uint8Array(32)),t=globalThis.crypto.getRandomValues(new Uint8Array(12)),n=await s().importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),c=new TextEncoder().encode(JSON.stringify(e)),o=await s().encrypt({name:"AES-GCM",iv:t},n,c);return{ciphertext:toB64url(o),iv:toB64url(t),key:toB64url(r)}}export async function openConnection({ciphertext:e,iv:r,key:t}){const n=await s().importKey("raw",fromB64url(t),{name:"AES-GCM"},!1,["decrypt"]),c=await s().decrypt({name:"AES-GCM",iv:fromB64url(r)},n,fromB64url(e)),o=JSON.parse(new TextDecoder().decode(c));if(o?.type!==CONNECTION_TYPE)throw new Error("Not a Domma CMS token handover.");return o}export function handoverLink(e,r,t){return`${String(e).replace(/\/+$/,"")}${HANDOVER_PAGE}?h=${encodeURIComponent(r)}#k=${t}`}export function readHandoverAddress(e,r){const t=new URLSearchParams(String(e||"").replace(/^\?/,"")).get("h")||"",n=new URLSearchParams(String(r||"").replace(/^#/,"")).get("k")||"";return{id:/^[A-Za-z0-9_-]{32}$/.test(t)?t:"",key:/^[A-Za-z0-9_-]{43}$/.test(n)?n:""}}
@@ -6,6 +6,13 @@
6
6
  * POST /api/api-tokens - create; response carries the plaintext ONCE
7
7
  * PUT /api/api-tokens/:id - rename, enable/disable, edit scopes/expiry
8
8
  * DELETE /api/api-tokens/:id - revoke (immediate)
9
+ * GET /api/api-tokens/_recipe?project= - collections a "bot that writes drafts" token could write to
10
+ * POST /api/api-tokens/:id/handover - store an encrypted one-time handover (services/tokenHandovers.js)
11
+ *
12
+ * POST with `recipe: {collections: [{slug, verbs, addStatus?}]}` is the "Bot
13
+ * that writes drafts" starting point (services/tokenRecipes.js): the token gets
14
+ * those collection scopes and Drafts only, and each collection's verbs are
15
+ * opened in token mode (never narrowed) - which needs collections.update too.
9
16
  *
10
17
  * Tokens are project-scoped artefacts: non-super-admin users with a
11
18
  * `projects: []` access scope only see/manage tokens in their projects.
@@ -16,6 +23,7 @@ import {
16
23
  requirePermission as defaultRequirePermission
17
24
  } from '../../middleware/auth.js';
18
25
  import {
26
+ checkTokenInput,
19
27
  createToken,
20
28
  getTokenSanitised,
21
29
  listTokensSanitised,
@@ -23,6 +31,33 @@ import {
23
31
  updateToken
24
32
  } from '../../services/apiTokens.js';
25
33
  import {canSeeArtefact} from '../../services/projects.js';
34
+ import {holds} from '../../services/collectionAccess.js';
35
+ import {applyRecipe, othersLetIn, planRecipeFor, recipeCollections} from '../../services/tokenRecipes.js';
36
+ import {checkHandoverInput, createHandover, dropHandoversFor} from '../../services/tokenHandovers.js';
37
+
38
+ /**
39
+ * A token may only write content its maker could write by hand: a content scope
40
+ * with a write verb needs the same permission on its resource (pages.create,
41
+ * media.create, blocks.update…). Null when every one is held.
42
+ *
43
+ * @param {object} user
44
+ * @param {object[]} scopes
45
+ * @param {(user: object, resource: string, action: string) => boolean} [mayDo]
46
+ * @returns {string|null}
47
+ */
48
+ export function contentWriteDenial(user, scopes, mayDo = holds) {
49
+ for (const s of Array.isArray(scopes) ? scopes : []) {
50
+ if (s?.content === undefined || !Array.isArray(s.verbs)) continue;
51
+ for (const verb of s.verbs) {
52
+ if (verb === 'read') continue;
53
+ if (!mayDo(user, s.content, verb)) return `A token that may ${verb} ${s.content} needs you to hold ${s.content}.${verb} yourself.`;
54
+ }
55
+ }
56
+ return null;
57
+ }
58
+
59
+ /** How long after a token is made a handover link may still be made for it (the Token created panel). */
60
+ const HANDOVER_WINDOW_MS = 30 * 60_000;
26
61
 
27
62
  /** A token this close to its expiry is called out - SOON_DAYS in admin/js/lib/api-tokens-arrange.js. */
28
63
  const SOON_DAYS = 14;
@@ -83,12 +118,14 @@ export function apiTokensBadge(tokens = [], now = Date.now()) {
83
118
  * Register the api-tokens routes.
84
119
  *
85
120
  * @param {import('fastify').FastifyInstance} fastify
86
- * @param {{authenticate?: Function, requirePermission?: Function}} [opts]
121
+ * @param {{authenticate?: Function, requirePermission?: Function, mayChangeCollections?: (user: object) => boolean}} [opts]
87
122
  * @returns {Promise<void>}
88
123
  */
89
124
  export async function apiTokensRoutes(fastify, opts = {}) {
90
125
  const authenticate = opts.authenticate || defaultAuthenticate;
91
126
  const requirePermission = opts.requirePermission || defaultRequirePermission;
127
+ const mayChangeCollections = opts.mayChangeCollections || ((user) => holds(user, 'collections', 'update'));
128
+ const mayDo = opts.mayDo || holds;
92
129
 
93
130
  const canRead = {preHandler: [authenticate, requirePermission('api-tokens', 'read')]};
94
131
  const canCreate = {preHandler: [authenticate, requirePermission('api-tokens', 'create')]};
@@ -102,27 +139,101 @@ export async function apiTokensRoutes(fastify, opts = {}) {
102
139
  // There is no GET /api-tokens/:id, and ids are uuids - nothing can shadow this.
103
140
  fastify.get('/api-tokens/_count', canRead, async (request) => apiTokensBadge(await listTokensSanitised(request.user)));
104
141
 
142
+ fastify.get('/api-tokens/_recipe', canCreate, async (request, reply) => {
143
+ const project = String(request.query?.project || '');
144
+ if (!project) return reply.status(400).send({error: 'project is required'});
145
+ if (!canSeeArtefact(request.user, {meta: {project}})) return reply.status(403).send({error: 'Access denied for this project'});
146
+ return {
147
+ mayOpen: mayChangeCollections(request.user),
148
+ collections: await recipeCollections(project, request.user)
149
+ };
150
+ });
151
+
105
152
  fastify.post('/api-tokens', canCreate, async (request, reply) => {
106
- const {name, project, scopes, expiresAt, draftsOnly} = request.body || {};
153
+ const {name, project, scopes, expiresAt, draftsOnly, recipe} = request.body || {};
107
154
  if (project && !canSeeArtefact(request.user, {meta: {project}})) {
108
155
  return reply.status(403).send({error: 'Access denied for this project'});
109
156
  }
157
+ let plans = null;
158
+ let tokenScopes = scopes;
159
+ let drafts = draftsOnly;
160
+ if (recipe != null) {
161
+ if (!mayChangeCollections(request.user)) {
162
+ return reply.status(403).send({error: 'A bot token opens its collections to the token, which needs collections.update.'});
163
+ }
164
+ try {
165
+ plans = await planRecipeFor({project, collections: recipe?.collections, user: request.user});
166
+ } catch (err) {
167
+ return reply.status(err.statusCode || 400).send({error: err.message});
168
+ }
169
+ // The recipe's collection scopes replace any the form named; content scopes are kept.
170
+ const named = new Set(plans.map(p => p.slug));
171
+ const kept = (Array.isArray(scopes) ? scopes : []).filter(s => s?.content !== undefined || (s?.collection && !named.has(s.collection)));
172
+ tokenScopes = [...kept, ...(recipe.collections || []).map(c => ({collection: c.slug, verbs: [...c.verbs]}))];
173
+ const writesContent = kept.some(s => s?.content !== undefined && Array.isArray(s.verbs) && s.verbs.some(v => v !== 'read'));
174
+ if (!plans.length && !writesContent) {
175
+ return reply.status(400).send({error: 'Choose at least one collection, or pages, pictures or blocks, for the bot.'});
176
+ }
177
+ drafts = true;
178
+ // Opening a verb to tokens opens it to the project's OTHER tokens that reach the
179
+ // collection too (unscoped, or scoped to it without verbs) - and they may publish.
180
+ // Not without the admin seeing who, and saying yes.
181
+ const others = await othersLetIn(project, plans);
182
+ if (others.length && recipe.confirmOthers !== true) {
183
+ return reply.status(409).send({
184
+ error: 'Opening these collections to tokens lets other tokens of this project write to them too.',
185
+ others
186
+ });
187
+ }
188
+ }
189
+ const writeDenied = contentWriteDenial(request.user, tokenScopes, mayDo);
190
+ if (writeDenied) return reply.status(403).send({error: writeDenied});
191
+ try {
192
+ // Everything that could refuse the token is checked BEFORE a collection is changed.
193
+ await checkTokenInput({name, project, scopes: tokenScopes, expiresAt, draftsOnly: drafts});
194
+ } catch (err) {
195
+ return reply.status(400).send({error: err.message});
196
+ }
110
197
  try {
111
198
  const creator = request.user?.name || request.user?.email || null;
112
- const {entry, plaintext} = await createToken({name, project, scopes, expiresAt, draftsOnly, createdBy: creator});
199
+ const changed = plans ? await applyRecipe(plans) : null;
200
+ const {entry, plaintext} = await createToken({name, project, scopes: tokenScopes, expiresAt, draftsOnly: drafts, createdBy: creator});
113
201
  // The plaintext appears here and nowhere else - only the hash is stored.
114
- return reply.status(201).send({token: entry, plaintext});
202
+ return reply.status(201).send({token: entry, plaintext, ...(changed && {collections: changed})});
115
203
  } catch (err) {
116
204
  return reply.status(400).send({error: err.message});
117
205
  }
118
206
  });
119
207
 
208
+ fastify.post('/api-tokens/:id/handover', canCreate, async (request, reply) => {
209
+ const token = await getTokenSanitised(request.params.id);
210
+ if (!token) return reply.status(404).send({error: 'Token not found'});
211
+ if (!canSeeArtefact(request.user, {meta: {project: token.project}})) {
212
+ return reply.status(403).send({error: 'Access denied for this project'});
213
+ }
214
+ if (token.enabled === false) return reply.status(409).send({error: 'The token is switched off - switch it on first.'});
215
+ // Only from the Token created panel - the one time the token exists in a browser. A link
216
+ // made later could only hold what its maker typed, under this site's own address.
217
+ if (!(Date.now() - Date.parse(token.meta?.createdAt || 0) <= HANDOVER_WINDOW_MS)) {
218
+ return reply.status(409).send({error: 'A one-time link can only be made just after the token is created.'});
219
+ }
220
+ const input = checkHandoverInput(request.body);
221
+ if (!input.ok) return reply.status(400).send({error: input.error});
222
+ const created = await createHandover({
223
+ tokenId: token.id, ciphertext: input.ciphertext, iv: input.iv, lifetimeMs: input.lifetimeMs,
224
+ createdBy: request.user?.name || request.user?.email || null
225
+ });
226
+ return reply.status(201).send(created);
227
+ });
228
+
120
229
  fastify.put('/api-tokens/:id', canUpdate, async (request, reply) => {
121
230
  const existing = await getTokenSanitised(request.params.id);
122
231
  if (!existing) return reply.status(404).send({error: 'Token not found'});
123
232
  if (!canSeeArtefact(request.user, {meta: {project: existing.project}})) {
124
233
  return reply.status(403).send({error: 'Access denied for this project'});
125
234
  }
235
+ const writeDenied = contentWriteDenial(request.user, request.body?.scopes, mayDo);
236
+ if (writeDenied) return reply.status(403).send({error: writeDenied});
126
237
  try {
127
238
  return await updateToken(request.params.id, request.body || {});
128
239
  } catch (err) {
@@ -137,6 +248,7 @@ export async function apiTokensRoutes(fastify, opts = {}) {
137
248
  return reply.status(403).send({error: 'Access denied for this project'});
138
249
  }
139
250
  await revokeToken(request.params.id);
251
+ await dropHandoversFor(request.params.id);
140
252
  return {success: true};
141
253
  });
142
254
  }
@@ -63,6 +63,65 @@ import {PRESET_COLLECTION_SLUGS, USER_DATA_PRESET_SLUGS} from '../../services/pr
63
63
  import {ensureFormForCollection} from '../../services/forms.js';
64
64
  import {hooks} from '../../services/hooks.js';
65
65
  import {DRAFT_STATUS, authenticateApiToken, draftsOnlyDecision, scopeAllows} from '../../services/apiTokens.js';
66
+ import {contentRefusal, renderedContentRefusal} from '../../services/tokenContentPolicy.js';
67
+ import {listBlocks} from '../../services/blocks.js';
68
+
69
+ /** Field types whose value is rendered as Markdown on a page (the Blog's post body, a notes field). */
70
+ const RENDERED_TYPES = new Set(['textarea', 'markdown', 'richtext', 'html', 'wysiwyg', 'code']);
71
+
72
+ /**
73
+ * What an API token writes into a collection goes through the same content
74
+ * policy as its pages (services/tokenContentPolicy.js): entry values reach pages
75
+ * through the Blog, [collection] displays and block templates, and are reviewed
76
+ * there by an admin. Every string value: no HTML, no unsafe shortcodes or
77
+ * addresses; a rendered field's value is also rendered and the result judged.
78
+ *
79
+ * @param {object} schema
80
+ * @param {object} data
81
+ * @returns {Promise<string|null>}
82
+ */
83
+ async function tokenDataRefusal(schema, data) {
84
+ const blockNames = (await listBlocks()).map(b => b.name);
85
+ const types = Object.fromEntries((schema.fields || []).map(f => [f.name, f.type]));
86
+ const walk = async (value, key) => {
87
+ if (typeof value === 'string') {
88
+ const why = contentRefusal(value, {blockNames}) || (RENDERED_TYPES.has(types[key]) ? await renderedContentRefusal(value) : null);
89
+ return why ? `${key}: ${why}` : null;
90
+ }
91
+ if (Array.isArray(value)) { for (const v of value) { const w = await walk(v, key); if (w) return w; } return null; }
92
+ if (value && typeof value === 'object') { for (const [k, v] of Object.entries(value)) { const w = await walk(v, key || k); if (w) return w; } }
93
+ return null;
94
+ };
95
+ if (!data || typeof data !== 'object' || Array.isArray(data)) return 'data must be an object of the collection\'s fields';
96
+ for (const [key, value] of Object.entries(data)) {
97
+ // Only the collection's own fields: a key is printed by some views too.
98
+ if (!Object.hasOwn(types, key)) return `"${String(key).slice(0, 40)}" is not a field of this collection`;
99
+ const why = await walk(value, key);
100
+ if (why) return why;
101
+ }
102
+ return null;
103
+ }
104
+
105
+ /**
106
+ * A token's plain (not rendered) text values with straight quotes turned
107
+ * typographic (’ “ ”): such a value may be printed inside an attribute by a
108
+ * site's block template ({{field}} or {{{field}}}), where a straight quote would
109
+ * end it. Rendered fields are Markdown and keep theirs.
110
+ *
111
+ * @param {object} schema
112
+ * @param {object} data
113
+ * @returns {object}
114
+ */
115
+ function tokenPlainText(schema, data) {
116
+ const types = Object.fromEntries((schema.fields || []).map(f => [f.name, f.type]));
117
+ const curl = (v) => {
118
+ if (typeof v === 'string') return v.replace(/'/g, '\u2019').replace(/"(?=\S)/g, '\u201c').replace(/"/g, '\u201d');
119
+ if (Array.isArray(v)) return v.map(curl);
120
+ if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, curl(x)]));
121
+ return v;
122
+ };
123
+ return Object.fromEntries(Object.entries(data).map(([k, v]) => [k, RENDERED_TYPES.has(types[k]) ? v : curl(v)]));
124
+ }
66
125
  import {isProjectEnabled, resolveArtefactProject} from '../../services/projects.js';
67
126
  import {maskConnections, restoreConnections} from '../../services/connectionSecrets.js';
68
127
  import {
@@ -941,6 +1000,11 @@ export async function collectionsRoutes(fastify) {
941
1000
  const held = draftsOnlyDecision(request.apiToken, schema, 'create');
942
1001
  if (!held.ok) return reply.status(held.status).send({error: held.error});
943
1002
 
1003
+ if (request.apiToken) {
1004
+ const unsafe = await tokenDataRefusal(schema, request.body?.data);
1005
+ if (unsafe) return reply.status(400).send({error: unsafe});
1006
+ request.body.data = tokenPlainText(schema, request.body.data);
1007
+ }
944
1008
  try {
945
1009
  let data = pinOwner(request.params.slug, request.body?.data || {}, request.user);
946
1010
  if (held.field) data = {...data, [held.field]: DRAFT_STATUS};
@@ -978,6 +1042,11 @@ export async function collectionsRoutes(fastify) {
978
1042
  if (!held.ok) return reply.status(held.status).send({error: held.error});
979
1043
  }
980
1044
 
1045
+ if (request.apiToken) {
1046
+ const unsafe = await tokenDataRefusal(schema, request.body?.data);
1047
+ if (unsafe) return reply.status(400).send({error: unsafe});
1048
+ request.body.data = tokenPlainText(schema, request.body.data);
1049
+ }
981
1050
  try {
982
1051
  let data = pinOwner(request.params.slug, request.body?.data || {}, request.user, existing);
983
1052
  if (held.field) data = {...data, [held.field]: DRAFT_STATUS};