domma-cms 1.48.2 → 1.49.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.
- package/CHANGELOG.md +9 -0
- package/CLAUDE.md +14 -0
- package/admin/css/admin.css +1 -1
- package/admin/js/app.js +2 -2
- package/admin/js/lib/admin-scope.js +1 -1
- package/admin/js/lib/plugin-chrome.js +1 -1
- package/admin/js/lib/sidebar-arrange.js +1 -1
- package/admin/js/lib/sidebar-grouping.js +1 -1
- package/admin/js/lib/sidebar-renderer.js +5 -5
- package/admin/js/views/menu-editor.js +1 -1
- package/admin/js/views/settings.js +2 -2
- package/docs/plugin-development.md +40 -0
- package/package.json +1 -1
- package/public/js/form-embed.js +1 -0
- package/public/js/forms.js +2 -2
- package/public/js/site.js +1 -1
- package/server/routes/api/auth.js +6 -7
- package/server/routes/api/forms.js +43 -3
- package/server/routes/api/plugins.js +12 -1
- package/server/routes/api/sidebar.js +47 -6
- package/server/services/adminAccess.js +20 -0
- package/server/services/collections.js +3 -2
- package/server/services/formContext.js +166 -0
- package/server/templates/page.html +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{api as
|
|
1
|
+
import{api as $,apiRequest as w}from"../api.js";import{placeTools as Oe,WITHHELD_URL as Re}from"../lib/sidebar-grouping.js";import{addBannerAction as me}from"../lib/plugin-chrome.js";import{helpPopovers as Ie}from"../lib/help-popover.js";import{openMenuAt as G,sidebarCount as fe}from"../lib/tool-kit.js";import{changedTabs as Ae,describeCacheKey as J,draftOf as De,expiresIn as He,formFromDraft as Pe,siteSettingsForm as $e,homeValue as Be,siteSettingsPayload as je,siteUrlError as he,settingsProblems as Ue,snapshot as ve,TAB_FIELDS as qe}from"../lib/site-settings-arrange.js";import{pickMedia as _e}from"../lib/media-picker.js";import{makeIconInput as Ke}from"../lib/shortcode-modal.js";import{fmtDateTime as Fe}from"../lib/dates.js";const Q=/^\/settings(\?.*)?$/,be="#/settings",g="settings.draft",We=`
|
|
2
2
|
<div class="stx-problem">
|
|
3
3
|
<span class="stx-chip" data-bind-class="tone === 'danger' ? 'is-bad' : 'is-warn'">{{label}}</span>
|
|
4
4
|
<span>{{text}}</span>
|
|
@@ -8,4 +8,4 @@ import{api as D,apiRequest as k}from"../api.js";import{placeTools as Oe}from"../
|
|
|
8
8
|
<span class="stx-main"><strong>{{path}}</strong><small>{{meta}}</small></span>
|
|
9
9
|
<span class="stx-chip">{{expires}}</span>
|
|
10
10
|
<button type="button" class="stx-kebab" aria-label="Actions for {{path}}" title="Actions">\u22EE</button>
|
|
11
|
-
</div>`,$=["general","branding","email","cookies","cache"];async function Ne(c,l){const[r,w]=await Promise.all([H.get("/api/sidebar/menu").catch(()=>({items:[]})),H.get("/api/sidebar/registered-items").catch(()=>[])]),n=new Map([["/","Dashboard (built in)"]]),i=(v,u)=>{for(const o of v||[]){if(!o||o.hidden||o.restricted)continue;const m=typeof o.url=="string"?o.url:"";m.startsWith("#/")&&m.length>2&&!n.has(m.slice(1))&&n.set(m.slice(1),`${u?`${u} \u203A `:""}${o.text||m}`),i(o.items,o.url?u:o.text||u)}};i(Oe(r?.items||[],w||[]),""),n.has(l)||n.set(l,`${l} (not in the sidebar)`),c.replaceChildren();for(const[v,u]of n){const o=document.createElement("option");o.value=v,o.textContent=u,c.appendChild(o)}}let f=null,ye=!1;function Ve(){ye||!window.R?.use||(ye=!0,R.use((c,l,r)=>!(Q.test(l?.path||"")&&!Q.test(c?.path||""))||!f?.dirty()?r():E.confirm("You have unsaved settings. Leave anyway? They are kept as a draft for your next visit (not the SMTP password).").then(n=>{n?r():history.replaceState(null,"","#/settings")})),M.subscribe("router:afterChange",({to:c}={})=>{if(f&&!Q.test(c?.path||"")){const l=f;f=null,l.dispose()}}))}export const settingsView={templateUrl:"/admin/js/templates/settings.html",async onMount(c){if(Ve(),f){const e=f;f=null,e.dispose()}const l=[],r=e=>(l.push(e),e);let w=!1;const n=c.get(0).querySelector(".stx")||c.get(0),i=()=>!w&&n.isConnected,v=E.loader(c.get(0),{type:"dots"});let u;try{u=await D.settings.get()}catch(e){v.destroy(),E.toast(`Could not load the settings: ${e.message||e}`,{type:"error"});return}if(v.destroy(),!n.isConnected)return;const o=M.observable(u||{}),m=De(u||{}),s={};for(const[e,t]of Object.entries(m))s[e]=M.observable(t);const j=()=>Object.fromEntries(Object.keys(s).map(e=>[e,s[e].value])),X=()=>Object.fromEntries(Object.keys(s).map(e=>[e,s[e].peek()])),b=M.observable(m),q=M.computed(()=>ve(b.value)),C=M.computed(()=>ve(j())!==q.value),x=M.observable(!1),T=M.observable(""),Z=M.observable(!1);D.plugins.policy().then(e=>{i()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const U=M.observable(!1),ee=M.computed(()=>{const e=new Set(Ie(j(),b.value));return Object.fromEntries(Object.keys(qe).map(t=>[t,e.has(t)]))}),_=M.observable([]);r(M.effect(()=>{_.value=je(j(),o.value).map(e=>({...e,label:e.tone==="danger"?"Mail":"Check"}))}));const te=M.observable(""),L=M.observable(!1),O=M.observable(""),A=M.observable(""),p=M.observable(null),K=M.observable([]),F=M.observable(""),z=M.observable(!0),N=M.observable(""),ae=M.observable([]);r(M.effect(()=>{const e=F.value.trim().toLowerCase(),t=Date.now();ae.value=[...K.value].reverse().filter(a=>!e||String(a.key).toLowerCase().includes(e)||(a.tags||[]).some(d=>String(d).toLowerCase().includes(e))).map(a=>{const d=J(a.key);return{id:a.key,path:d.path,meta:[d.page?`as ${d.role}`:"not a page",(a.tags||[]).join(", ")].filter(Boolean).join(" \xB7 "),expires:Pe(a.expiresAt,t)}})}));const ge={...s,saving:x,dirty:C,tabs:ee,problems:_,testTo:te,testing:L,testResult:O,testTone:A,cacheQuery:F,cacheLoading:z,cacheError:N,cacheRows:ae,errorText:T,problemsText:M.computed(()=>_.value.length?"yes":""),siteUrlError:M.computed(()=>he(s.siteUrl.value)),noSmtp:M.computed(()=>!String(s.smtpHost.value||"").trim()),mayAllowInsecureTLS:Z,dirtyEmail:M.computed(()=>ee.value.email),cacheOn:M.computed(()=>p.value?.enabled===!0),cacheState:M.computed(()=>{const e=p.value;return e?e.enabled?`On (${e.driver})`:"Off":"Status unknown"}),cacheSize:M.computed(()=>{const e=p.value;return e?.enabled&&e.size!==null&&e.size!==void 0?`${e.size}${e.maxItems?` of ${e.maxItems}`:""} entries`:""}),cacheHits:M.computed(()=>{const e=p.value?.hitRate;return e==null?"":`${Math.round(e*100)}% served from the cache`}),cacheToggleText:M.computed(()=>p.value?.enabled?"Turn off":"Turn on"),cacheEmpty:M.computed(()=>F.value.trim()?"Nothing matches.":p.value?.enabled?"The cache is empty - pages are cached as visitors open them.":"The cache is off.")};async function V(){if(x.peek())return;const e=X(),t=b.peek(),a=he(e.siteUrl);if(a){E.toast(`Site URL: ${a}`,{type:"error"});return}x.value=!0,T.value="";const d=String(e.title).trim()!==String(t.title).trim();try{await D.settings.save(He(e,o.peek(),{adminHomeReady:U.peek()}));const B=await D.settings.get().catch(()=>null);if(!i())return;B&&(o.value=B);const Le={...e,smtpPass:""};s.smtpPass.value="",b.value=Le;try{S.remove?S.remove(g):S.set(g,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(d||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"].some(pe=>e[pe]!==t[pe]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),fe(be),E.toast("Settings saved.",{type:"success"})}catch(B){T.value=B.message||"Could not save the settings.",E.toast("Settings not saved - see the message at the top.",{type:"error"})}finally{x.value=!1}}async function we(){await E.confirm("Throw away your unsaved settings?")&&(se(b.peek()),T.value="")}function se(e){for(const[t,a]of Object.entries(e))s[t]&&(s[t].value=a)}async function ke(){if(!L.peek()){L.value=!0,A.value="",O.value="Sending\u2026";try{const e=await k("/settings/test-email",{method:"POST",body:JSON.stringify({to:te.peek().trim()||void 0})});if(!i())return;O.value=e?.message||"Test email sent.",A.value="is-ok"}catch(e){if(!i())return;O.value=e.message||"Could not send the test email.",A.value="is-bad"}finally{L.value=!1}}}async function P(){z.value=!0;try{const[e,t]=await Promise.all([k("/cache/status").catch(()=>null),k("/cache/keys")]);if(!i())return;p.value=e,K.value=Array.isArray(t?.entries)?t.entries:[],N.value=""}catch(e){if(!i())return;N.value=`Could not read the cache: ${e.message||e}`}finally{z.value=!1}}async function Ee(){if(await E.confirm("Clear the whole response cache? The next visitor to each page renders it afresh.")){try{await k("/cache/clear",{method:"POST"}),E.toast("Cache cleared.",{type:"success"})}catch(e){E.toast(e.message||"Could not clear the cache.",{type:"error"})}i()&&await P()}}async function Se(){const e=p.peek()?.enabled===!0;if(!(e&&!await E.confirm("Turn the response cache off? Every visit will render its page afresh until it is turned back on. The choice is saved (config/cache.json)."))){try{p.value=await k("/cache/toggle",{method:"POST",body:JSON.stringify({enabled:!e})}),E.toast(e?"Cache turned off.":"Cache turned on.",{type:"success"}),fe(be)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}i()&&await P()}}const ne=e=>K.peek().find(t=>t.key===e);function Me(e){const t=ne(e);if(!t)return[];const a=J(t.key);return[{header:a.path},{label:"Open the page",icon:"external-link",disabled:!a.page,action:()=>window.open(a.path,"_blank","noopener")},{label:"Copy key",icon:"copy",action:async()=>{try{await navigator.clipboard.writeText(t.key),E.toast("Key copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}},...a.page?[{label:"Copy address",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(new URL(a.path,location.origin).href),E.toast("Address copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}}]:[]]}n.querySelector(".stx-problems").innerHTML=Fe;const y=n.querySelector(".stx-list");y.innerHTML=ze;const W=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),oe=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");$.includes(oe)&&W.activate($.indexOf(oe));const Ce=M.applyBindings(ge,n,{methods:{save:V,discard:we,sendTest:ke,refreshCache:P,clearCache:Ee,toggleCache:Se,pickBrandImage:async e=>{const t=await Ue({title:"Choose a branding image",current:s[e].peek()});t&&i()&&(s[e].value=t)},clearBrandImage:e=>{s[e].value=""},goTab:e=>{const t=$.indexOf(e);t>=0&&W.activate(t)}}});r(()=>Ce.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,a=_e("Choose an icon",s[t].peek());a.input.id=`stx-${t}`,a.input.classList.add("form-input");const d=()=>{s[t].value=a.input.value};a.input.addEventListener("input",d),r(()=>a.input.removeEventListener("input",d)),r(M.effect(()=>{a.input.value=s[t].value})),e.appendChild(a.el)}r(Re(n,{position:"bottom"}));const xe=e=>{const t=e.target.closest("[data-go]");if(!t)return;const a=$.indexOf(t.dataset.go);a>=0&&W.activate(a)};n.querySelector(".stx-problems").addEventListener("click",xe);const Y=n.querySelector("#stx-admin-home");Ne(Y,$e(s.adminHome.peek())).then(()=>{i()&&(Y.value=s.adminHome.peek(),U.value=!0)}).catch(()=>{});const Te=E.contextMenu(y,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>Me(e.dataset.id)});r(()=>Te?.destroy?.());const re=e=>{const t=ne(e.dataset.id),a=t&&J(t.key);a?.page?window.open(a.path,"_blank","noopener"):G(e)},ie=e=>{const t=e.target.closest(".stx-row");if(!t)return;const a=e.target.closest(".stx-kebab");if(a){G(a);return}re(t)},ce=e=>{const t=e.target.closest(".stx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),G(t)):e.key==="Enter"&&e.target===t&&re(t))};y.addEventListener("click",ie),y.addEventListener("keydown",ce),r(()=>{y.removeEventListener("click",ie),y.removeEventListener("keydown",ce)}),me(c,{id:"settings-view-site",icon:"external-link",title:"View site",onClick:()=>window.open("/","_blank","noopener")}),me(c,{id:"settings-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>V()});const le=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),V())};document.addEventListener("keydown",le,!0),r(()=>document.removeEventListener("keydown",le,!0));const ue=()=>{if(C.peek())try{S.set(g,{form:Ae(X()),base:q.peek(),at:new Date().toISOString()})}catch{}},de=e=>{C.peek()&&(ue(),e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",de),r(()=>window.removeEventListener("beforeunload",de)),f={dirty:()=>C.peek(),dispose(){w=!0,ue(),l.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(n),P();let h=null;try{h=S.get(g)}catch{}if(h?.form){try{S.remove?S.remove(g):S.set(g,null)}catch{}const e=h.base&&h.base!==q.peek(),t=h.at?` (${Ke(h.at)})`:"",a=e?`You left unsaved settings${t}, but the saved settings have changed since. Restore your version anyway?`:`You left unsaved settings${t}. Restore them?`;await E.confirm(a)&&i()&&(se(Be(b.peek(),h.form)),U.peek()&&(Y.value=s.adminHome.peek()))}}};
|
|
11
|
+
</div>`,B=["general","branding","email","cookies","cache"];async function Ne(c,l){const[r,y]=await Promise.all([H.get("/api/sidebar/menu").catch(()=>({items:[]})),H.get("/api/sidebar/registered-items").catch(()=>[])]),n=new Map([["/","Dashboard (built in)"]]),i=(p,u)=>{for(const o of p||[]){if(!o||o.hidden||o.restricted)continue;const a=typeof o.url=="string"?o.url:"";a.startsWith(Re)||(a.startsWith("#/")&&a.length>2&&!n.has(a.slice(1))&&n.set(a.slice(1),`${u?`${u} \u203A `:""}${o.text||a}`),i(o.items,o.url?u:o.text||u))}},k=(y||[]).filter(p=>!/^~\d+$/.test(String(p?.item?.text||"")));i(Oe(r?.items||[],k),""),n.has(l)||n.set(l,`${l} (not in the sidebar)`),c.replaceChildren();for(const[p,u]of n){const o=document.createElement("option");o.value=p,o.textContent=u,c.appendChild(o)}}let f=null,ge=!1;function Ve(){ge||!window.R?.use||(ge=!0,R.use((c,l,r)=>!(Q.test(l?.path||"")&&!Q.test(c?.path||""))||!f?.dirty()?r():E.confirm("You have unsaved settings. Leave anyway? They are kept as a draft for your next visit (not the SMTP password).").then(n=>{n?r():history.replaceState(null,"","#/settings")})),M.subscribe("router:afterChange",({to:c}={})=>{if(f&&!Q.test(c?.path||"")){const l=f;f=null,l.dispose()}}))}export const settingsView={templateUrl:"/admin/js/templates/settings.html",async onMount(c){if(Ve(),f){const e=f;f=null,e.dispose()}const l=[],r=e=>(l.push(e),e);let y=!1;const n=c.get(0).querySelector(".stx")||c.get(0),i=()=>!y&&n.isConnected,k=E.loader(c.get(0),{type:"dots"});let p;try{p=await $.settings.get()}catch(e){k.destroy(),E.toast(`Could not load the settings: ${e.message||e}`,{type:"error"});return}if(k.destroy(),!n.isConnected)return;const u=M.observable(p||{}),o=$e(p||{}),a={};for(const[e,t]of Object.entries(o))a[e]=M.observable(t);const j=()=>Object.fromEntries(Object.keys(a).map(e=>[e,a[e].value])),X=()=>Object.fromEntries(Object.keys(a).map(e=>[e,a[e].peek()])),v=M.observable(o),U=M.computed(()=>ve(v.value)),x=M.computed(()=>ve(j())!==U.value),C=M.observable(!1),T=M.observable(""),Z=M.observable(!1);$.plugins.policy().then(e=>{i()&&(Z.value=e?.signedOnly===!1)}).catch(()=>{});const q=M.observable(!1),ee=M.computed(()=>{const e=new Set(Ae(j(),v.value));return Object.fromEntries(Object.keys(qe).map(t=>[t,e.has(t)]))}),_=M.observable([]);r(M.effect(()=>{_.value=Ue(j(),u.value).map(e=>({...e,label:e.tone==="danger"?"Mail":"Check"}))}));const te=M.observable(""),L=M.observable(!1),O=M.observable(""),A=M.observable(""),m=M.observable(null),K=M.observable([]),F=M.observable(""),W=M.observable(!0),z=M.observable(""),se=M.observable([]);r(M.effect(()=>{const e=F.value.trim().toLowerCase(),t=Date.now();se.value=[...K.value].reverse().filter(s=>!e||String(s.key).toLowerCase().includes(e)||(s.tags||[]).some(d=>String(d).toLowerCase().includes(e))).map(s=>{const d=J(s.key);return{id:s.key,path:d.path,meta:[d.page?`as ${d.role}`:"not a page",(s.tags||[]).join(", ")].filter(Boolean).join(" \xB7 "),expires:He(s.expiresAt,t)}})}));const ye={...a,saving:C,dirty:x,tabs:ee,problems:_,testTo:te,testing:L,testResult:O,testTone:A,cacheQuery:F,cacheLoading:W,cacheError:z,cacheRows:se,errorText:T,problemsText:M.computed(()=>_.value.length?"yes":""),siteUrlError:M.computed(()=>he(a.siteUrl.value)),noSmtp:M.computed(()=>!String(a.smtpHost.value||"").trim()),mayAllowInsecureTLS:Z,dirtyEmail:M.computed(()=>ee.value.email),cacheOn:M.computed(()=>m.value?.enabled===!0),cacheState:M.computed(()=>{const e=m.value;return e?e.enabled?`On (${e.driver})`:"Off":"Status unknown"}),cacheSize:M.computed(()=>{const e=m.value;return e?.enabled&&e.size!==null&&e.size!==void 0?`${e.size}${e.maxItems?` of ${e.maxItems}`:""} entries`:""}),cacheHits:M.computed(()=>{const e=m.value?.hitRate;return e==null?"":`${Math.round(e*100)}% served from the cache`}),cacheToggleText:M.computed(()=>m.value?.enabled?"Turn off":"Turn on"),cacheEmpty:M.computed(()=>F.value.trim()?"Nothing matches.":m.value?.enabled?"The cache is empty - pages are cached as visitors open them.":"The cache is off.")};async function N(){if(C.peek())return;const e=X(),t=v.peek(),s=he(e.siteUrl);if(s){E.toast(`Site URL: ${s}`,{type:"error"});return}C.value=!0,T.value="";const d=String(e.title).trim()!==String(t.title).trim();try{await $.settings.save(je(e,u.peek(),{adminHomeReady:q.peek()}));const P=await $.settings.get().catch(()=>null);if(!i())return;P&&(u.value=P);const Le={...e,smtpPass:""};a.smtpPass.value="",v.value=Le;try{S.remove?S.remove(g):S.set(g,null)}catch{}document.dispatchEvent(new CustomEvent("dm:admin-home-changed")),(d||["adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"].some(pe=>e[pe]!==t[pe]))&&document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild")),fe(be),E.toast("Settings saved.",{type:"success"})}catch(P){T.value=P.message||"Could not save the settings.",E.toast("Settings not saved - see the message at the top.",{type:"error"})}finally{C.value=!1}}async function we(){await E.confirm("Throw away your unsaved settings?")&&(ae(v.peek()),T.value="")}function ae(e){for(const[t,s]of Object.entries(e))a[t]&&(a[t].value=s)}async function ke(){if(!L.peek()){L.value=!0,A.value="",O.value="Sending\u2026";try{const e=await w("/settings/test-email",{method:"POST",body:JSON.stringify({to:te.peek().trim()||void 0})});if(!i())return;O.value=e?.message||"Test email sent.",A.value="is-ok"}catch(e){if(!i())return;O.value=e.message||"Could not send the test email.",A.value="is-bad"}finally{L.value=!1}}}async function D(){W.value=!0;try{const[e,t]=await Promise.all([w("/cache/status").catch(()=>null),w("/cache/keys")]);if(!i())return;m.value=e,K.value=Array.isArray(t?.entries)?t.entries:[],z.value=""}catch(e){if(!i())return;z.value=`Could not read the cache: ${e.message||e}`}finally{W.value=!1}}async function Ee(){if(await E.confirm("Clear the whole response cache? The next visitor to each page renders it afresh.")){try{await w("/cache/clear",{method:"POST"}),E.toast("Cache cleared.",{type:"success"})}catch(e){E.toast(e.message||"Could not clear the cache.",{type:"error"})}i()&&await D()}}async function Se(){const e=m.peek()?.enabled===!0;if(!(e&&!await E.confirm("Turn the response cache off? Every visit will render its page afresh until it is turned back on. The choice is saved (config/cache.json)."))){try{m.value=await w("/cache/toggle",{method:"POST",body:JSON.stringify({enabled:!e})}),E.toast(e?"Cache turned off.":"Cache turned on.",{type:"success"}),fe(be)}catch(t){E.toast(t.message||"Could not change the cache.",{type:"error"})}i()&&await D()}}const ne=e=>K.peek().find(t=>t.key===e);function Me(e){const t=ne(e);if(!t)return[];const s=J(t.key);return[{header:s.path},{label:"Open the page",icon:"external-link",disabled:!s.page,action:()=>window.open(s.path,"_blank","noopener")},{label:"Copy key",icon:"copy",action:async()=>{try{await navigator.clipboard.writeText(t.key),E.toast("Key copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}},...s.page?[{label:"Copy address",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(new URL(s.path,location.origin).href),E.toast("Address copied.",{type:"success"})}catch{E.toast("Could not copy - your browser blocked the clipboard.",{type:"warning"})}}}]:[]]}n.querySelector(".stx-problems").innerHTML=We;const b=n.querySelector(".stx-list");b.innerHTML=ze;const V=E.tabs(n.querySelector(".stx-tabs"),{tabSelector:".tab-item",panelSelector:".tab-panel"}),oe=new URLSearchParams(location.hash.split("?")[1]||"").get("tab");B.includes(oe)&&V.activate(B.indexOf(oe));const xe=M.applyBindings(ye,n,{methods:{save:N,discard:we,sendTest:ke,refreshCache:D,clearCache:Ee,toggleCache:Se,pickBrandImage:async e=>{const t=await _e({title:"Choose a branding image",current:a[e].peek()});t&&i()&&(a[e].value=t)},clearBrandImage:e=>{a[e].value=""},goTab:e=>{const t=B.indexOf(e);t>=0&&V.activate(t)}}});r(()=>xe.dispose());for(const e of n.querySelectorAll("[data-brand-icon]")){const t=e.dataset.brandIcon,s=Ke("Choose an icon",a[t].peek());s.input.id=`stx-${t}`,s.input.classList.add("form-input");const d=()=>{a[t].value=s.input.value};s.input.addEventListener("input",d),r(()=>s.input.removeEventListener("input",d)),r(M.effect(()=>{s.input.value=a[t].value})),e.appendChild(s.el)}r(Ie(n,{position:"bottom"}));const Ce=e=>{const t=e.target.closest("[data-go]");if(!t)return;const s=B.indexOf(t.dataset.go);s>=0&&V.activate(s)};n.querySelector(".stx-problems").addEventListener("click",Ce);const Y=n.querySelector("#stx-admin-home");Ne(Y,Be(a.adminHome.peek())).then(()=>{i()&&(Y.value=a.adminHome.peek(),q.value=!0)}).catch(()=>{});const Te=E.contextMenu(b,{cursor:"glyph",match:".stx-row",inherit:!1,density:"compact",items:e=>Me(e.dataset.id)});r(()=>Te?.destroy?.());const re=e=>{const t=ne(e.dataset.id),s=t&&J(t.key);s?.page?window.open(s.path,"_blank","noopener"):G(e)},ie=e=>{const t=e.target.closest(".stx-row");if(!t)return;const s=e.target.closest(".stx-kebab");if(s){G(s);return}re(t)},ce=e=>{const t=e.target.closest(".stx-row");t&&(e.key==="F10"&&e.shiftKey?(e.preventDefault(),G(t)):e.key==="Enter"&&e.target===t&&re(t))};b.addEventListener("click",ie),b.addEventListener("keydown",ce),r(()=>{b.removeEventListener("click",ie),b.removeEventListener("keydown",ce)}),me(c,{id:"settings-view-site",icon:"external-link",title:"View site",onClick:()=>window.open("/","_blank","noopener")}),me(c,{id:"settings-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>N()});const le=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),N())};document.addEventListener("keydown",le,!0),r(()=>document.removeEventListener("keydown",le,!0));const ue=()=>{if(x.peek())try{S.set(g,{form:De(X()),base:U.peek(),at:new Date().toISOString()})}catch{}},de=e=>{x.peek()&&(ue(),e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",de),r(()=>window.removeEventListener("beforeunload",de)),f={dirty:()=>x.peek(),dispose(){y=!0,ue(),l.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(n),D();let h=null;try{h=S.get(g)}catch{}if(h?.form){try{S.remove?S.remove(g):S.set(g,null)}catch{}const e=h.base&&h.base!==U.peek(),t=h.at?` (${Fe(h.at)})`:"",s=e?`You left unsaved settings${t}, but the saved settings have changed since. Restore your version anyway?`:`You left unsaved settings${t}. Restore them?`;await E.confirm(s)&&i()&&(ae(Pe(v.peek(),h.form)),q.peek()&&(Y.value=a.adminHome.peek()))}}};
|
|
@@ -723,6 +723,46 @@ fields. Optional frontmatter: `title` (the tab label; default from the file name
|
|
|
723
723
|
|
|
724
724
|
---
|
|
725
725
|
|
|
726
|
+
## Domma Forms in an admin panel
|
|
727
|
+
|
|
728
|
+
A plugin can ask its users to fill in a site form (built under Forms) inside one of its own panels, and know
|
|
729
|
+
afterwards that a given entry was made by that user, on that form, for that record of the plugin's.
|
|
730
|
+
|
|
731
|
+
1. **Sign the context on the server** - in your own route, for the signed-in user you are answering:
|
|
732
|
+
|
|
733
|
+
```js
|
|
734
|
+
import {signFormContext} from '../../server/services/formContext.js';
|
|
735
|
+
const contextToken = signFormContext({form: 'right-to-represent', userId: request.user.id, context: {proposal: id}});
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
Up to 20 keys, string / number / boolean values. The token is HMAC-signed and expires after 30 minutes. It is
|
|
739
|
+
signed, not secret - the browser can read the context, so put nothing private in it - and it can be sent more than
|
|
740
|
+
once while it lasts: check the entry you are handed, and accept one.
|
|
741
|
+
|
|
742
|
+
2. **Render it in the panel** (admin JS):
|
|
743
|
+
|
|
744
|
+
```js
|
|
745
|
+
const {renderForm} = await import('/public/js/form-embed.js');
|
|
746
|
+
const form = await renderForm(panel, 'right-to-represent', {token: () => S.get('auth_token'), contextToken,
|
|
747
|
+
onSubmitted: ({entryId}) => { /* send entryId to your route */ }});
|
|
748
|
+
// form.destroy() when the panel closes
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
3. **Check the entry on the server** before acting on it:
|
|
752
|
+
|
|
753
|
+
```js
|
|
754
|
+
import {readFormEntry, removeFormEntry} from '../../server/services/formContext.js';
|
|
755
|
+
const entry = await readFormEntry('right-to-represent', entryId); // null: no such entry on this form
|
|
756
|
+
// entry.meta.createdBy === the user; entry.meta.context === what you signed
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
The submit route keeps `meta.context` only from a post signed in with a Bearer token whose user the context was
|
|
760
|
+
signed for, on that form, before it expires - anything else is refused (401/403, or 400 when it expired) and nothing
|
|
761
|
+
is stored. A context sent any other way (`_context` in the body) is dropped. `onSubmitted` gets `entryId: null` when
|
|
762
|
+
nothing was stored (an end-form set not to record) - treat that as not sent. An entry edited later keeps its meta: compare
|
|
763
|
+
`meta.updatedAt` with `meta.createdAt` if the answers must be as sent. When the person's data is erased, use
|
|
764
|
+
`removeFormEntry`, and `formEntriesBy(form, userId)` for the entries they sent but your plugin never used. Feature-detect an older core: `import('../../server/services/formContext.js').catch(() => null)`.
|
|
765
|
+
|
|
726
766
|
## Dashboard widgets
|
|
727
767
|
|
|
728
768
|
With **Dashboard Pro**, admins build their own Dashboard from widgets the Tools offer. A widget ships
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FORM_EMBED_VERSION=1;let s=null;function c(r,o){return document.querySelector(r)?Promise.resolve():new Promise(t=>{const n=o();n.addEventListener("load",()=>t(),{once:!0}),n.addEventListener("error",()=>t(),{once:!0}),document.head.appendChild(n)})}function d(){return s||(s=(async()=>(await c('link[data-dm-forms-css], link[href^="/public/css/forms.css"]',()=>{const r=Object.assign(document.createElement("link"),{rel:"stylesheet",href:"/public/css/forms.css?v=20261031-forms-reduce-motion"});return r.setAttribute("data-dm-forms-css","1"),r}),window.FormLogicEngine||await c('script[src^="/public/js/form-logic-engine.js"]',()=>Object.assign(document.createElement("script"),{src:"/public/js/form-logic-engine.js?v=20261031-forms-reduce-motion"})),globalThis.__DM_FORMS_EMBED__=!0,import("/public/js/forms.js?v=20261109-form-embed")))(),s)}export async function renderForm(r,o,{token:t="",contextToken:n="",onSubmitted:i=null}={}){if(!r||!/^[a-z0-9][a-z0-9-]{0,99}$/.test(String(o||"")))throw new Error("renderForm: a container and a form slug are needed");const m=await d(),e=document.createElement("div");return e.className="dm-form-embed",e.setAttribute("data-form",o),e.__dmFormEmbed={token:typeof t=="function"?t:String(t||""),contextToken:String(n||""),onSubmitted:i},r.appendChild(e),m.renderFormTarget(e),{element:e,destroy:()=>{e.__dmFormEmbed=null,e.remove()}}}
|
package/public/js/forms.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{installSmoothCarets as
|
|
2
|
-
`).replace(/<[^>]+>/g,""))}function P(n){return String(n).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function N(n,r){let t=!1;n.addEventListener("dm-form-end",function(e){const i=e.detail&&e.detail.validation;if(i&&!i.valid){markInvalidFields(n,i.missing),showValidationPopup(i);return}t||(t=!0,n.classList.add("fb-form-loading"),Promise.resolve(r(e.detail&&e.detail.values||{})).catch(function(){}).finally(function(){t=!1,n.classList.remove("fb-form-loading")}))})}function x(n,r,t){const e=n.querySelector(".fb-form-success, .fb-form-error");e&&e.remove();const i=document.createElement("div");i.className=t==="success"?"fb-form-success":"fb-form-error",i.textContent=r,n.appendChild(i)}function z(n,r){if(n._formLogicRuntime=r,n._formLogicObserver&&(n._formLogicObserver.disconnect(),n._formLogicObserver=null),!n.parentNode||typeof MutationObserver>"u"||n._formLogicObserved)return;n._formLogicObserved=!0;const t=new MutationObserver(function(e){for(const i of e)for(const o of i.removedNodes)if(o===n||o.nodeType===1&&o.contains&&o.contains(n)){n._formLogicRuntime&&n._formLogicRuntime.destroy(),t.disconnect();return}});t.observe(n.parentNode,{childList:!0,subtree:!1}),n._formLogicObserver=t}function se(n){const r=n&&n.logic;return!!(r&&(r.visibility||r.requirement))}function O(n,r){const t={};return n.forEach(function(e){if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const i=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),o=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":i?"chooser":e.type,d={...e.formConfig||{}};d.span==="full"&&r&&(d.span=r);const s={type:o,label:e.label||e.name,required:se(e)?!1:e.required||!1,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{helperText:e.helper},...e.tooltip&&{tooltip:e.tooltip},...d}};e.minLength!==void 0&&(s.minLength=e.minLength),e.maxLength!==void 0&&(s.maxLength=e.maxLength),e.min!==void 0&&(s.min=e.min),e.max!==void 0&&(s.max=e.max),i&&(e.variant&&(s.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(s.multiple=!0),e.density&&(s.density=e.density),e.columns&&(s.columns=e.columns),e.accent&&(s.accent=e.accent),e.accentStyle&&(s.accentStyle=e.accentStyle),e.glow&&(s.glow=!0),e.glowColour&&(s.glowColour=e.glowColour),e.shadow&&(s.shadow=e.shadow),e.shadowColour&&(s.shadowColour=e.shadowColour)),t[e.name]=e.type==="file"?te(e,s):s}),t}function ce(n){const r={};return n.forEach(function(t){if(!(!t.name||t.type==="page-break"||t.type==="spacer")&&(t.type==="select"||t.type==="multiselect")&&t.required){const e=(t.options||[])[0];e&&(r[t.name]=typeof e=="object"?e.value:e)}}),r}function D(n,r){(r||[]).forEach(function(t){if(t.type!=="date"||!t.name)return;const e=n.querySelector('[name="'+t.name+'"]');e&&e.type!=="date"&&(e.type="date")})}const M="padding:.45rem .7rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:.85em;flex-shrink:0;line-height:1.2;";function V(n){const r=document.createElement("div");r.style.cssText="position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;padding:20px;";const t=document.createElement("div");t.style.cssText="background:var(--dm-surface-overlay,var(--dm-surface));color:var(--dm-text);border:1px solid var(--dm-border);border-radius:10px;width:100%;max-width:560px;max-height:75vh;display:flex;flex-direction:column;gap:.6rem;padding:1rem;box-shadow:var(--dm-shadow-lg,0 12px 40px rgba(0,0,0,.35));";const e=document.createElement("div");e.style.cssText="display:flex;align-items:center;justify-content:space-between;gap:.5rem;";const i=document.createElement("strong");i.textContent=n;const o=document.createElement("button");o.type="button",o.textContent="\xD7",o.setAttribute("aria-label","Close"),o.style.cssText=M+"font-size:1rem;padding:.15rem .55rem;",e.appendChild(i),e.appendChild(o),t.appendChild(e);const d=document.createElement("div");d.style.cssText="display:flex;flex-direction:column;gap:.6rem;overflow:hidden;min-height:0;",t.appendChild(d),r.appendChild(t);const s=l=>{l.key==="Escape"&&a()};function a(){document.removeEventListener("keydown",s),r.remove()}return o.addEventListener("click",a),r.addEventListener("click",l=>{l.target===r&&a()}),document.addEventListener("keydown",s),document.body.appendChild(r),{body:d,close:a}}function le(n){const{body:r,close:t}=V("Choose an icon"),e=document.createElement("input");e.type="text",e.placeholder="Search icons\u2026",e.className="form-input",e.style.cssText="padding:.45rem .6rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:var(--dm-input-bg,transparent);color:var(--dm-text);",r.appendChild(e);const i=document.createElement("div");i.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(46px,1fr));gap:4px;overflow-y:auto;min-height:0;",r.appendChild(i);const o=window.I&&typeof I.list=="function"?I.list():[],d=o.map(s=>{const a=document.createElement("button");a.type="button",a.title=s,a.dataset.iconName=s,a.style.cssText="display:flex;align-items:center;justify-content:center;padding:.55rem 0;border:1px solid transparent;border-radius:6px;background:transparent;color:inherit;cursor:pointer;";const l=document.createElement("span");return l.setAttribute("data-icon",s),l.setAttribute("data-icon-size","18"),a.appendChild(l),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--dm-border)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="transparent"}),a.addEventListener("click",()=>{t(),n(s)}),i.appendChild(a),a});if(!o.length){const s=document.createElement("p");s.textContent="Icon engine unavailable - type an icon name into the field instead.",i.appendChild(s)}window.I?.scan?.(i),e.addEventListener("input",()=>{const s=e.value.trim().toLowerCase();d.forEach(a=>{a.style.display=!s||a.dataset.iconName.includes(s)?"":"none"})}),e.focus()}async function ue(){const n=typeof S<"u"&&S.get?S.get("auth_token"):null;if(!n)return{error:"auth"};const r=i=>fetch("/api/media",{headers:{Authorization:"Bearer "+i}});let t;try{if(t=await r(n),t.status===401&&S.get("auth_refresh_token")){const i=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:S.get("auth_refresh_token")})});if(i.ok){const{token:o}=await i.json();S.set("auth_token",o),t=await r(o)}}}catch{return{error:"load"}}if(!t.ok)return{error:t.status===401||t.status===403?"auth":"load"};const e=await t.json().catch(()=>[]);return{files:(Array.isArray(e)?e:[]).filter(i=>/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(i.name||i.url||""))}}function de(n){const{body:r,close:t}=V("Choose an image"),e=document.createElement("p");e.textContent="Loading media library\u2026",e.style.cssText="margin:0;font-size:.85em;color:var(--dm-text-muted);",r.appendChild(e),ue().then(({files:i,error:o})=>{if(o){e.textContent=o==="auth"?"Sign in with media access to browse the library - or paste an image URL into the field.":"Could not load the media library - paste an image URL into the field instead.";return}if(!i.length){e.textContent="No images in the media library yet.";return}e.remove();const d=document.createElement("div");d.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:8px;overflow-y:auto;min-height:0;",i.forEach(s=>{const a=document.createElement("button");a.type="button",a.title=s.name||s.url,a.style.cssText="display:flex;flex-direction:column;gap:.25rem;padding:.35rem;border:1px solid var(--dm-border);border-radius:8px;background:transparent;color:inherit;cursor:pointer;min-width:0;";const l=document.createElement("img");l.src=s.url,l.alt=s.name||"",l.loading="lazy",l.style.cssText="width:100%;height:72px;object-fit:cover;border-radius:5px;";const h=document.createElement("span");h.textContent=s.name||s.url,h.style.cssText="font-size:.68em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",a.appendChild(l),a.appendChild(h),a.addEventListener("click",()=>{t(),n(s.url)}),d.appendChild(a)}),r.appendChild(d)})}function W(n,r){n.value=r,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}function U(n){const r=document.createElement("div");return r.style.cssText="display:flex;align-items:center;gap:.5rem;",n.parentNode.insertBefore(r,n),r.appendChild(n),n.style.flex="1",n.style.minWidth="0",r}function H(n){const r=document.createElement("button");return r.type="button",r.textContent=n,r.style.cssText=M,r}function me(n){if(!window.I||typeof I.list!="function")return;const r=U(n),t=document.createElement("span");t.style.cssText="display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);";const e=()=>{t.textContent="";const o=n.value.trim();if(!o)return;const d=document.createElement("span");d.setAttribute("data-icon",o),d.setAttribute("data-icon-size","16"),t.appendChild(d),window.I?.scan?.(t)};n.addEventListener("input",e),e();const i=H("Browse");i.addEventListener("click",()=>le(o=>{W(n,o),e()})),r.appendChild(t),r.appendChild(i)}function pe(n){const r=U(n),t=document.createElement("img");t.alt="",t.style.cssText="width:2rem;height:2rem;flex-shrink:0;object-fit:cover;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);display:none;";const e=()=>{const o=n.value.trim();t.style.display=o?"":"none",o&&(t.src=o)};n.addEventListener("input",e),e();const i=H("Browse");i.addEventListener("click",()=>de(o=>{W(n,o),e()})),r.appendChild(t),r.appendChild(i)}export function enhancePickerFields(n,r){const t=typeof n=="string"?document.querySelector(n):n;t&&(r||[]).forEach(function(e){if(!e.name||e.type!=="icon"&&e.type!=="image")return;const i=t.querySelector('[name="'+e.name+'"]');!i||i.dataset.pickerEnhanced||(i.dataset.pickerEnhanced="1",e.type==="icon"?me(i):pe(i))})}function _(n,r){const t=document.createElement("div");t.className="fb-form-honeypot",t.setAttribute("aria-hidden","true");const e=document.createElement("input");e.name=n.querySelector('[name="website"]')?"_website":"website",t.dataset.hpName=e.name,e.type="text",e.tabIndex=-1,e.autocomplete="url",e.placeholder="https://",t.appendChild(e);const i=document.createElement("input");i.name="_t",i.type="hidden",i.value=r||Date.now(),t.appendChild(i),n.appendChild(t)}function K(n,r){const t=n.querySelector("form");if(!t)return;const e=Array.from(t.querySelectorAll(".form-group"));let i=0;r.forEach(function(o){if(o.type==="spacer"){const d=document.createElement("div");d.className="fb-spacer";const s=e[i];if(s)t.insertBefore(d,s);else{const a=t.querySelector('[type="submit"]');a?t.insertBefore(d,a):t.appendChild(d)}}else o.type!=="page-break"&&i++})}function C(n,r,t,e,i,o,d){const s=i||e,a=s.querySelector(".fb-form-honeypot"),l=a?.querySelector('input[type="text"]')?.value||"",h=a?.querySelector('[name="_t"]')?.value||"",u=Object.assign({},r);delete u._t,a?.dataset.hpName&&delete u[a.dataset.hpName];const c=new Map(o||[]);L(s,c);const f=oe(u,d,c),p=ie(e,f.files);if(p)return x(e,p,"error"),Promise.resolve();const{body:w,headers:b}=re(Object.assign(f.values,{_hp:l,_t:h}),f.files);return fetch("/api/forms/submit/"+n,{method:"POST",headers:b,body:w}).then(y=>y.json().then(v=>({ok:y.ok,body:v}))).then(y=>{y.ok&&y.body.ok?(Z(e),e.textContent="",x(e,y.body.message||t.successMessage||"Thank you.","success")):x(e,y.body.error||"Something went wrong.","error")}).catch(()=>{x(e,"Unable to submit. Please check your connection.","error")})}function fe(n,r,t,e,i){const o=document.createElement("form");o.noValidate=!0,r.forEach(function(a){const l=document.createElement("div");l.className="form-group",l.style.marginBottom="1.25rem",a.name&&(l.dataset.field=a.name);const h=document.createElement("label");if(h.className="form-label",h.textContent=a.label||a.name,a.required){const c=document.createElement("span");c.textContent=" *",c.style.color="var(--dm-danger)",h.appendChild(c)}let u;a.type==="textarea"?(u=document.createElement("textarea"),u.rows=a.formConfig?.rows||4,u.className="form-input"):a.type==="select"?(u=document.createElement("select"),u.className="form-input",(a.options||[]).forEach(function(c){const f=document.createElement("option");f.value=typeof c=="string"?c:c.value??"",f.textContent=typeof c=="string"?c:c.label||f.value,u.appendChild(f)})):(u=document.createElement("input"),u.type=a.type==="icon"||a.type==="image"?"text":a.type||"text",u.className="form-input",a.placeholder&&(u.placeholder=a.placeholder),a.type==="file"&&(a.file?.accept&&(u.accept=a.file.accept),a.multiple&&(u.multiple=!0))),u.name=a.name,u.required=a.required||!1,l.appendChild(h),l.appendChild(u),o.appendChild(l)}),t.honeypot&&_(o);const d=document.createElement("button");if(d.type="submit",d.className="btn btn-primary",d.textContent=t.submitText||"Submit",Q(t,"stacked").length||G(t)){const a=document.createElement("div");a.className="form-group form-buttons",a.appendChild(d),o.appendChild(a)}else o.appendChild(d);if(o.addEventListener("submit",function(a){a.preventDefault();const l={};if(r.forEach(function(u){const c=o.querySelector('[name="'+u.name+'"]');c&&(l[u.name]=c.value)}),window.FormLogicEngine&&i){const u=window.FormLogicEngine,c=[],f=[];if(r.forEach(function(p){if(u.evaluateFieldVisibility(p,l)==="hidden"){delete l[p.name];return}const b=u.evaluateFieldRequirement(p,l),y=l[p.name];b&&(!y||!String(y).trim())&&c.push(p.label||p.name);const v=u.validateField(p,y||"",l);v.length&&f.push(v[0].message)}),c.length||f.length){const p=[];c.length&&p.push("Required: "+c.join(", ")),f.length&&p.push(f.join("; ")),x(n,p.join(". "),"error");return}}const h=X(o,r);if(h.length){x(n,h.join(" "),"error");return}if(n.dataset.triggerBlocked==="true"){const u=n._formLogicRuntime,c=u&&u.submitBlock?u.submitBlock().reasons:[];x(n,c.join(" ")||"This form cannot be submitted yet.","error");return}n.classList.add("fb-form-loading"),d.disabled=!0,C(e,l,t,n,o,null,r).finally(function(){n.classList.remove("fb-form-loading"),d.disabled=!1})}),n.appendChild(o),j(o,t,"stacked"),F(o,t,r),T(n,t),enhancePickerFields(n,r),ee(n,r),N(n,function(a){return C(e,a,t,n,o,null,r)}),window.FormLogicEngine&&i&&q(r)){const a=new window.FormLogicEngine.FormLogicRuntime(i,n);a.init(),n._formLogicRuntime=a}}function he(n){const r=n.getAttribute("data-form");r&&fetch("/api/forms/"+r+"/public").then(t=>{if(!t.ok)throw new Error("Form not found: "+r);return t.json()}).then(t=>{const e=t.fields||[],i=t.settings||{},o=document.createElement("div");o.className="fb-form-wrapper",n.appendChild(o),B(o,t.fileLimits);const d=e.some(s=>s.type==="page-break");if(typeof Domma<"u"&&Domma.forms){const s=Number(i.columns)===3?3:2,a=i.layout||"grid";if(d&&Domma.forms.wizard){const l=Y(e,t.title),h=l.map(m=>m.fields),u=l.map(function(m){return{title:m.title,description:m.description,fields:O(m.fields,s)}});let c=0,f=null,p=null;const w=Date.now(),b=new Map;B(o,t.fileLimits,b),R(o,e);const y=function(m){const g=window.FormLogicEngine;if(!g||!g.validateFields)return;const k=g.validateFields(o,h[c]||[]);k.valid||(m.preventDefault(),m.stopImmediatePropagation(),markInvalidFields(o,k.missing),showValidationPopup(k))},v=function(){const m=h[c]||e;if($(o,i),F(o,i,m),T(o,i),D(o,m),enhancePickerFields(o,m),ne(o,b),m.some(g=>g.type==="spacer")&&K(o,m),i.honeypot){const g=o.querySelector("form");g&&_(g,w)}window.FormLogicEngine&&q(e)&&(f&&f.destroy(),f=new window.FormLogicEngine.FormLogicRuntime(t,o,{baseValues:p&&p.getStepData?p.getStepData():{}}),f.init(),z(o,f)),o.querySelectorAll(".wizard-next, .wizard-submit").forEach(g=>g.addEventListener("click",y,!0))};p=Domma.forms.wizard(o,{schema:{steps:u},layout:a,columns:s,finishText:i.submitText||"Finish",onStepChange:function(m){L(o,b),c=m,setTimeout(v,0)},onSubmit:function(m){return L(o,b),C(r,m,i,o,null,b,e)}}),N(o,function(m){return L(o,b),C(r,m,i,o,null,b,e)}),o.addEventListener("dm-form-trigger",function(m){if(!m.detail||m.detail.type!=="goto-step"||!p||!p.goToStep)return;const g=Number(m.detail.action.step);!isFinite(g)||g<0||g>=u.length||g!==c&&p.goToStep(g)}),Promise.resolve(p).then(v)}else if(Domma.forms.render){const l=O(e,s),h=ce(e);R(o,e),N(o,function(c){return C(r,c,i,o,null,null,e)});const u=Domma.forms.render(o,l,h,{submitText:i.submitText||"Submit",layout:a,columns:s,onSubmit:function(c){return C(r,c,i,o,null,null,e)}});Promise.resolve(u).then(function(){if(j(o,i,a),F(o,i,e),T(o,i),D(o,e),enhancePickerFields(o,e),window.FormLogicEngine&&q(e)){const c=new window.FormLogicEngine.FormLogicRuntime(t,o);c.init(),z(o,c)}if(e.some(c=>c.type==="spacer")&&K(o,e),i.honeypot){const c=o.querySelector("form");c&&_(c)}})}}else fe(o,e.filter(s=>s.type!=="page-break"&&s.type!=="spacer"),i,r,t)}).catch(t=>{const e=document.createElement("p");e.textContent="Form unavailable.",e.style.cssText="color:var(--dm-danger);font-style:italic;",n.appendChild(e),console.warn("[forms]",t.message)})}
|
|
1
|
+
import{installSmoothCarets as R}from"/public/js/smooth-caret.js";import{buildWizardSteps as Q}from"/public/js/form-steps.mjs";import{applyFormClasses as _,applyFormEntrance as q,applySubmitButtons as A,applyWizardButtons as X,resolveSecondaryButton as Z,submitWrapperClasses as ee}from"/public/js/form-submit.mjs";import{captureFileFields as F,checkFileInputs as te,destroyDropzones as ne,enhanceFileInputs as oe,fileBlueprint as re,restoreFileFields as ie,setFileLimits as P,splitFiles as se,submitBody as ae,totalTooLarge as ce,wireFileFields as z}from"/public/js/form-files.mjs";if(globalThis.__DM_FORMS_EMBED__!==!0){R(document);const t=document.querySelectorAll("[data-form]");t.length&&t.forEach(G)}const le=t=>t?.closest?.("[data-form]")?.__dmFormEmbed||null;export function renderFormTarget(t){R(t),G(t)}function N(t){return(t||[]).some(r=>r.logic||Array.isArray(r.triggers)&&r.triggers.length)}function ue(t,r){const n=t.querySelector('[name="'+r+'"], [name="'+r+'[]"]')||t.querySelector('[data-chooser-field="'+r+'"]');if(!n)return null;const e=n.closest("form")||t;let i=n;for(;i.parentNode&&i.parentNode!==e;)i=i.parentNode;return i}export function markInvalidFields(t,r){t.querySelectorAll(".fb-field-invalid").forEach(e=>e.classList.remove("fb-field-invalid"));let n=null;(r||[]).forEach(function(e){const i=ue(t,e.name);i&&(i.classList.add("fb-field-invalid"),n||(n=i))}),n&&n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center"})}export function showValidationPopup(t){const r=(t.missing||[]).map(e=>"<strong>"+D(e.label)+"</strong> is required.").concat((t.errors||[]).map(D)),n=r.join("<br>");if(typeof E<"u"&&E.alert){E.alert(n,{title:"Please complete this step"});return}window.alert(r.join(`
|
|
2
|
+
`).replace(/<[^>]+>/g,""))}function D(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function j(t,r){let n=!1;t.addEventListener("dm-form-end",function(e){const i=e.detail&&e.detail.validation;if(i&&!i.valid){markInvalidFields(t,i.missing),showValidationPopup(i);return}n||(n=!0,t.classList.add("fb-form-loading"),Promise.resolve(r(e.detail&&e.detail.values||{})).catch(function(){}).finally(function(){n=!1,t.classList.remove("fb-form-loading")}))})}function k(t,r,n){const e=t.querySelector(".fb-form-success, .fb-form-error");e&&e.remove();const i=document.createElement("div");i.className=n==="success"?"fb-form-success":"fb-form-error",i.textContent=r,t.appendChild(i)}function M(t,r){if(t._formLogicRuntime=r,t._formLogicObserver&&(t._formLogicObserver.disconnect(),t._formLogicObserver=null),!t.parentNode||typeof MutationObserver>"u"||t._formLogicObserved)return;t._formLogicObserved=!0;const n=new MutationObserver(function(e){for(const i of e)for(const o of i.removedNodes)if(o===t||o.nodeType===1&&o.contains&&o.contains(t)){t._formLogicRuntime&&t._formLogicRuntime.destroy(),n.disconnect();return}});n.observe(t.parentNode,{childList:!0,subtree:!1}),t._formLogicObserver=n}function de(t){const r=t&&t.logic;return!!(r&&(r.visibility||r.requirement))}function V(t,r){const n={};return t.forEach(function(e){if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const i=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),o=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":i?"chooser":e.type,d={...e.formConfig||{}};d.span==="full"&&r&&(d.span=r);const a={type:o,label:e.label||e.name,required:de(e)?!1:e.required||!1,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{helperText:e.helper},...e.tooltip&&{tooltip:e.tooltip},...d}};e.minLength!==void 0&&(a.minLength=e.minLength),e.maxLength!==void 0&&(a.maxLength=e.maxLength),e.min!==void 0&&(a.min=e.min),e.max!==void 0&&(a.max=e.max),i&&(e.variant&&(a.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(a.multiple=!0),e.density&&(a.density=e.density),e.columns&&(a.columns=e.columns),e.accent&&(a.accent=e.accent),e.accentStyle&&(a.accentStyle=e.accentStyle),e.glow&&(a.glow=!0),e.glowColour&&(a.glowColour=e.glowColour),e.shadow&&(a.shadow=e.shadow),e.shadowColour&&(a.shadowColour=e.shadowColour)),n[e.name]=e.type==="file"?re(e,a):a}),n}function me(t){const r={};return t.forEach(function(n){if(!(!n.name||n.type==="page-break"||n.type==="spacer")&&(n.type==="select"||n.type==="multiselect")&&n.required){const e=(n.options||[])[0];e&&(r[n.name]=typeof e=="object"?e.value:e)}}),r}function W(t,r){(r||[]).forEach(function(n){if(n.type!=="date"||!n.name)return;const e=t.querySelector('[name="'+n.name+'"]');e&&e.type!=="date"&&(e.type="date")})}const U="padding:.45rem .7rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:.85em;flex-shrink:0;line-height:1.2;";function H(t){const r=document.createElement("div");r.style.cssText="position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;padding:20px;";const n=document.createElement("div");n.style.cssText="background:var(--dm-surface-overlay,var(--dm-surface));color:var(--dm-text);border:1px solid var(--dm-border);border-radius:10px;width:100%;max-width:560px;max-height:75vh;display:flex;flex-direction:column;gap:.6rem;padding:1rem;box-shadow:var(--dm-shadow-lg,0 12px 40px rgba(0,0,0,.35));";const e=document.createElement("div");e.style.cssText="display:flex;align-items:center;justify-content:space-between;gap:.5rem;";const i=document.createElement("strong");i.textContent=t;const o=document.createElement("button");o.type="button",o.textContent="\xD7",o.setAttribute("aria-label","Close"),o.style.cssText=U+"font-size:1rem;padding:.15rem .55rem;",e.appendChild(i),e.appendChild(o),n.appendChild(e);const d=document.createElement("div");d.style.cssText="display:flex;flex-direction:column;gap:.6rem;overflow:hidden;min-height:0;",n.appendChild(d),r.appendChild(n);const a=l=>{l.key==="Escape"&&s()};function s(){document.removeEventListener("keydown",a),r.remove()}return o.addEventListener("click",s),r.addEventListener("click",l=>{l.target===r&&s()}),document.addEventListener("keydown",a),document.body.appendChild(r),{body:d,close:s}}function pe(t){const{body:r,close:n}=H("Choose an icon"),e=document.createElement("input");e.type="text",e.placeholder="Search icons\u2026",e.className="form-input",e.style.cssText="padding:.45rem .6rem;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);background:var(--dm-input-bg,transparent);color:var(--dm-text);",r.appendChild(e);const i=document.createElement("div");i.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(46px,1fr));gap:4px;overflow-y:auto;min-height:0;",r.appendChild(i);const o=window.I&&typeof I.list=="function"?I.list():[],d=o.map(a=>{const s=document.createElement("button");s.type="button",s.title=a,s.dataset.iconName=a,s.style.cssText="display:flex;align-items:center;justify-content:center;padding:.55rem 0;border:1px solid transparent;border-radius:6px;background:transparent;color:inherit;cursor:pointer;";const l=document.createElement("span");return l.setAttribute("data-icon",a),l.setAttribute("data-icon-size","18"),s.appendChild(l),s.addEventListener("mouseenter",()=>{s.style.borderColor="var(--dm-border)"}),s.addEventListener("mouseleave",()=>{s.style.borderColor="transparent"}),s.addEventListener("click",()=>{n(),t(a)}),i.appendChild(s),s});if(!o.length){const a=document.createElement("p");a.textContent="Icon engine unavailable - type an icon name into the field instead.",i.appendChild(a)}window.I?.scan?.(i),e.addEventListener("input",()=>{const a=e.value.trim().toLowerCase();d.forEach(s=>{s.style.display=!a||s.dataset.iconName.includes(a)?"":"none"})}),e.focus()}async function fe(){const t=typeof S<"u"&&S.get?S.get("auth_token"):null;if(!t)return{error:"auth"};const r=i=>fetch("/api/media",{headers:{Authorization:"Bearer "+i}});let n;try{if(n=await r(t),n.status===401&&S.get("auth_refresh_token")){const i=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:S.get("auth_refresh_token")})});if(i.ok){const{token:o}=await i.json();S.set("auth_token",o),n=await r(o)}}}catch{return{error:"load"}}if(!n.ok)return{error:n.status===401||n.status===403?"auth":"load"};const e=await n.json().catch(()=>[]);return{files:(Array.isArray(e)?e:[]).filter(i=>/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(i.name||i.url||""))}}function he(t){const{body:r,close:n}=H("Choose an image"),e=document.createElement("p");e.textContent="Loading media library\u2026",e.style.cssText="margin:0;font-size:.85em;color:var(--dm-text-muted);",r.appendChild(e),fe().then(({files:i,error:o})=>{if(o){e.textContent=o==="auth"?"Sign in with media access to browse the library - or paste an image URL into the field.":"Could not load the media library - paste an image URL into the field instead.";return}if(!i.length){e.textContent="No images in the media library yet.";return}e.remove();const d=document.createElement("div");d.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:8px;overflow-y:auto;min-height:0;",i.forEach(a=>{const s=document.createElement("button");s.type="button",s.title=a.name||a.url,s.style.cssText="display:flex;flex-direction:column;gap:.25rem;padding:.35rem;border:1px solid var(--dm-border);border-radius:8px;background:transparent;color:inherit;cursor:pointer;min-width:0;";const l=document.createElement("img");l.src=a.url,l.alt=a.name||"",l.loading="lazy",l.style.cssText="width:100%;height:72px;object-fit:cover;border-radius:5px;";const y=document.createElement("span");y.textContent=a.name||a.url,y.style.cssText="font-size:.68em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",s.appendChild(l),s.appendChild(y),s.addEventListener("click",()=>{n(),t(a.url)}),d.appendChild(s)}),r.appendChild(d)})}function J(t,r){t.value=r,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function K(t){const r=document.createElement("div");return r.style.cssText="display:flex;align-items:center;gap:.5rem;",t.parentNode.insertBefore(r,t),r.appendChild(t),t.style.flex="1",t.style.minWidth="0",r}function Y(t){const r=document.createElement("button");return r.type="button",r.textContent=t,r.style.cssText=U,r}function ge(t){if(!window.I||typeof I.list!="function")return;const r=K(t),n=document.createElement("span");n.style.cssText="display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);";const e=()=>{n.textContent="";const o=t.value.trim();if(!o)return;const d=document.createElement("span");d.setAttribute("data-icon",o),d.setAttribute("data-icon-size","16"),n.appendChild(d),window.I?.scan?.(n)};t.addEventListener("input",e),e();const i=Y("Browse");i.addEventListener("click",()=>pe(o=>{J(t,o),e()})),r.appendChild(n),r.appendChild(i)}function ye(t){const r=K(t),n=document.createElement("img");n.alt="",n.style.cssText="width:2rem;height:2rem;flex-shrink:0;object-fit:cover;border:1px solid var(--dm-border);border-radius:var(--dm-radius-md,6px);display:none;";const e=()=>{const o=t.value.trim();n.style.display=o?"":"none",o&&(n.src=o)};t.addEventListener("input",e),e();const i=Y("Browse");i.addEventListener("click",()=>he(o=>{J(t,o),e()})),r.appendChild(n),r.appendChild(i)}export function enhancePickerFields(t,r){const n=typeof t=="string"?document.querySelector(t):t;n&&(r||[]).forEach(function(e){if(!e.name||e.type!=="icon"&&e.type!=="image")return;const i=n.querySelector('[name="'+e.name+'"]');!i||i.dataset.pickerEnhanced||(i.dataset.pickerEnhanced="1",e.type==="icon"?ge(i):ye(i))})}function B(t,r){const n=document.createElement("div");n.className="fb-form-honeypot",n.setAttribute("aria-hidden","true");const e=document.createElement("input");e.name=t.querySelector('[name="website"]')?"_website":"website",n.dataset.hpName=e.name,e.type="text",e.tabIndex=-1,e.autocomplete="url",e.placeholder="https://",n.appendChild(e);const i=document.createElement("input");i.name="_t",i.type="hidden",i.value=r||Date.now(),n.appendChild(i),t.appendChild(n)}function $(t,r){const n=t.querySelector("form");if(!n)return;const e=Array.from(n.querySelectorAll(".form-group"));let i=0;r.forEach(function(o){if(o.type==="spacer"){const d=document.createElement("div");d.className="fb-spacer";const a=e[i];if(a)n.insertBefore(d,a);else{const s=n.querySelector('[type="submit"]');s?n.insertBefore(d,s):n.appendChild(d)}}else o.type!=="page-break"&&i++})}function L(t,r,n,e,i,o,d){const a=i||e,s=a.querySelector(".fb-form-honeypot"),l=s?.querySelector('input[type="text"]')?.value||"",y=s?.querySelector('[name="_t"]')?.value||"",u=Object.assign({},r);delete u._t,s?.dataset.hpName&&delete u[s.dataset.hpName];const c=new Map(o||[]);F(a,c);const h=se(u,d,c),p=ce(e,h.files);if(p)return k(e,p,"error"),Promise.resolve();const b=le(e),v=b?.contextToken?{_context_token:b.contextToken}:{},{body:x,headers:C}=ae(Object.assign(h.values,{_hp:l,_t:y},v),h.files),m=()=>(typeof b?.token=="function"?b.token():b?.token)||"",g=f=>fetch("/api/forms/submit/"+t,{method:"POST",body:x,credentials:b?"omit":"same-origin",headers:Object.assign({},C,f?{Authorization:"Bearer "+f}:{})});return g(b?m():"").then(async f=>{const w=typeof S<"u"&&S.get?S.get("auth_refresh_token"):null;if(!(b&&f.status===401&&w))return f;const O=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:w})});if(!O.ok)return f;const{token:T}=await O.json();return T?(S.set("auth_token",T),g(T)):f}).then(f=>f.json().then(w=>({ok:f.ok,body:w}))).then(f=>{if(f.ok&&f.body.ok){if(ne(e),e.textContent="",k(e,f.body.message||n.successMessage||"Thank you.","success"),b?.onSubmitted)try{b.onSubmitted({entryId:f.body.entryId||null,message:f.body.message||""})}catch(w){console.warn("[forms] onSubmitted:",w?.message||w)}}else k(e,f.body.error||"Something went wrong.","error")}).catch(()=>{k(e,"Unable to submit. Please check your connection.","error")})}function be(t,r,n,e,i){const o=document.createElement("form");o.noValidate=!0,r.forEach(function(s){const l=document.createElement("div");l.className="form-group",l.style.marginBottom="1.25rem",s.name&&(l.dataset.field=s.name);const y=document.createElement("label");if(y.className="form-label",y.textContent=s.label||s.name,s.required){const c=document.createElement("span");c.textContent=" *",c.style.color="var(--dm-danger)",y.appendChild(c)}let u;s.type==="textarea"?(u=document.createElement("textarea"),u.rows=s.formConfig?.rows||4,u.className="form-input"):s.type==="select"?(u=document.createElement("select"),u.className="form-input",(s.options||[]).forEach(function(c){const h=document.createElement("option");h.value=typeof c=="string"?c:c.value??"",h.textContent=typeof c=="string"?c:c.label||h.value,u.appendChild(h)})):(u=document.createElement("input"),u.type=s.type==="icon"||s.type==="image"?"text":s.type||"text",u.className="form-input",s.placeholder&&(u.placeholder=s.placeholder),s.type==="file"&&(s.file?.accept&&(u.accept=s.file.accept),s.multiple&&(u.multiple=!0))),u.name=s.name,u.required=s.required||!1,l.appendChild(y),l.appendChild(u),o.appendChild(l)}),n.honeypot&&B(o);const d=document.createElement("button");if(d.type="submit",d.className="btn btn-primary",d.textContent=n.submitText||"Submit",ee(n,"stacked").length||Z(n)){const s=document.createElement("div");s.className="form-group form-buttons",s.appendChild(d),o.appendChild(s)}else o.appendChild(d);if(o.addEventListener("submit",function(s){s.preventDefault();const l={};if(r.forEach(function(u){const c=o.querySelector('[name="'+u.name+'"]');c&&(l[u.name]=c.value)}),window.FormLogicEngine&&i){const u=window.FormLogicEngine,c=[],h=[];if(r.forEach(function(p){if(u.evaluateFieldVisibility(p,l)==="hidden"){delete l[p.name];return}const v=u.evaluateFieldRequirement(p,l),x=l[p.name];v&&(!x||!String(x).trim())&&c.push(p.label||p.name);const C=u.validateField(p,x||"",l);C.length&&h.push(C[0].message)}),c.length||h.length){const p=[];c.length&&p.push("Required: "+c.join(", ")),h.length&&p.push(h.join("; ")),k(t,p.join(". "),"error");return}}const y=te(o,r);if(y.length){k(t,y.join(" "),"error");return}if(t.dataset.triggerBlocked==="true"){const u=t._formLogicRuntime,c=u&&u.submitBlock?u.submitBlock().reasons:[];k(t,c.join(" ")||"This form cannot be submitted yet.","error");return}t.classList.add("fb-form-loading"),d.disabled=!0,L(e,l,n,t,o,null,r).finally(function(){t.classList.remove("fb-form-loading"),d.disabled=!1})}),t.appendChild(o),A(o,n,"stacked"),_(o,n,r),q(t,n),enhancePickerFields(t,r),oe(t,r),j(t,function(s){return L(e,s,n,t,o,null,r)}),window.FormLogicEngine&&i&&N(r)){const s=new window.FormLogicEngine.FormLogicRuntime(i,t);s.init(),t._formLogicRuntime=s}}function G(t){const r=t.getAttribute("data-form");r&&fetch("/api/forms/"+r+"/public").then(n=>{if(!n.ok)throw new Error("Form not found: "+r);return n.json()}).then(n=>{const e=n.fields||[],i=n.settings||{},o=document.createElement("div");o.className="fb-form-wrapper",t.appendChild(o),P(o,n.fileLimits);const d=e.some(a=>a.type==="page-break");if(typeof Domma<"u"&&Domma.forms){const a=Number(i.columns)===3?3:2,s=i.layout||"grid";if(d&&Domma.forms.wizard){const l=Q(e,n.title),y=l.map(m=>m.fields),u=l.map(function(m){return{title:m.title,description:m.description,fields:V(m.fields,a)}});let c=0,h=null,p=null;const b=Date.now(),v=new Map;P(o,n.fileLimits,v),z(o,e);const x=function(m){const g=window.FormLogicEngine;if(!g||!g.validateFields)return;const f=g.validateFields(o,y[c]||[]);f.valid||(m.preventDefault(),m.stopImmediatePropagation(),markInvalidFields(o,f.missing),showValidationPopup(f))},C=function(){const m=y[c]||e;if(X(o,i),_(o,i,m),q(o,i),W(o,m),enhancePickerFields(o,m),ie(o,v),m.some(g=>g.type==="spacer")&&$(o,m),i.honeypot){const g=o.querySelector("form");g&&B(g,b)}window.FormLogicEngine&&N(e)&&(h&&h.destroy(),h=new window.FormLogicEngine.FormLogicRuntime(n,o,{baseValues:p&&p.getStepData?p.getStepData():{}}),h.init(),M(o,h)),o.querySelectorAll(".wizard-next, .wizard-submit").forEach(g=>g.addEventListener("click",x,!0))};p=Domma.forms.wizard(o,{schema:{steps:u},layout:s,columns:a,finishText:i.submitText||"Finish",onStepChange:function(m){F(o,v),c=m,setTimeout(C,0)},onSubmit:function(m){return F(o,v),L(r,m,i,o,null,v,e)}}),j(o,function(m){return F(o,v),L(r,m,i,o,null,v,e)}),o.addEventListener("dm-form-trigger",function(m){if(!m.detail||m.detail.type!=="goto-step"||!p||!p.goToStep)return;const g=Number(m.detail.action.step);!isFinite(g)||g<0||g>=u.length||g!==c&&p.goToStep(g)}),Promise.resolve(p).then(C)}else if(Domma.forms.render){const l=V(e,a),y=me(e);z(o,e),j(o,function(c){return L(r,c,i,o,null,null,e)});const u=Domma.forms.render(o,l,y,{submitText:i.submitText||"Submit",layout:s,columns:a,onSubmit:function(c){return L(r,c,i,o,null,null,e)}});Promise.resolve(u).then(function(){if(A(o,i,s),_(o,i,e),q(o,i),W(o,e),enhancePickerFields(o,e),window.FormLogicEngine&&N(e)){const c=new window.FormLogicEngine.FormLogicRuntime(n,o);c.init(),M(o,c)}if(e.some(c=>c.type==="spacer")&&$(o,e),i.honeypot){const c=o.querySelector("form");c&&B(c)}})}}else be(o,e.filter(a=>a.type!=="page-break"&&a.type!=="spacer"),i,r,n)}).catch(n=>{const e=document.createElement("p");e.textContent="Form unavailable.",e.style.cssText="color:var(--dm-danger);font-style:italic;",t.appendChild(e),console.warn("[forms]",n.message)})}
|
package/public/js/site.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},m=function(c){return r(c).replace(/'/g,"'")},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")}))}
|
|
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=20261109-form-embed";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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},m=function(c){return r(c).replace(/'/g,"'")},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")}))}
|
|
@@ -25,11 +25,11 @@ import {config, getConfig} from '../../config.js';
|
|
|
25
25
|
import {getRegisteredSidebarItems, hooks} from '../../services/hooks.js';
|
|
26
26
|
import {getMenu} from '../../services/menus.js';
|
|
27
27
|
import {resolveAdminHome} from '../../services/adminHome.js';
|
|
28
|
+
import {adminAccessFor} from '../../services/adminAccess.js';
|
|
28
29
|
import {adminBrandFor} from '../../services/adminBrand.js';
|
|
29
30
|
import {authenticate, checkVisibility} from '../../middleware/auth.js';
|
|
30
|
-
import {
|
|
31
|
+
import {getRoleLevel} from '../../services/roles.js';
|
|
31
32
|
import {getEffectiveRegistry, GROUP_ORDER} from '../../services/permissionRegistry.js';
|
|
32
|
-
import {getEffectiveRoles} from '../../services/userRoles.js';
|
|
33
33
|
import {
|
|
34
34
|
clearResetToken,
|
|
35
35
|
countUsers,
|
|
@@ -236,12 +236,9 @@ export async function authRoutes(fastify) {
|
|
|
236
236
|
fastify.get('/auth/permissions', {preHandler: [authenticate]}, async (request) => {
|
|
237
237
|
// Every role the user holds, not just the primary one - the server
|
|
238
238
|
// grants on the union, so the sidebar must hide on the union too.
|
|
239
|
-
const roles = getEffectiveRoles(request.user);
|
|
240
|
-
const allResources = getEffectiveRegistry().map(r => r.key);
|
|
241
|
-
const permissions = getPermissionsForRoles(roles, allResources);
|
|
242
239
|
// adminScope: null = the whole admin; otherwise {home, allow} - the
|
|
243
240
|
// screens this user's roles confine them to (see roles.getAdminScope).
|
|
244
|
-
const adminScope =
|
|
241
|
+
const {permissions, adminScope} = adminAccessFor(request.user);
|
|
245
242
|
// adminHome: the screen `#/` opens for this user - see services/adminHome.js.
|
|
246
243
|
// The menu is read only when a site home has to be checked against it.
|
|
247
244
|
let adminHome = await resolveAdminHome({
|
|
@@ -255,7 +252,9 @@ export async function authRoutes(fastify) {
|
|
|
255
252
|
// Dashboard Pro's "Open on my boards" - for a user the admin does not confine.
|
|
256
253
|
if (!adminScope && isDashboardPro() && (await readPrefs(request.user)).home) adminHome = '/dashboards';
|
|
257
254
|
// adminBrand: the admin's name and mark for the top bar, sidebar header and tab title.
|
|
258
|
-
|
|
255
|
+
// A confined user is shown none of the admin's chrome (versions included) - see admin-scope.js.
|
|
256
|
+
return {permissions, adminScope, adminHome, ...(!adminScope && {versions: frameworkVersions()}),
|
|
257
|
+
adminBrand: adminBrandFor(getConfig('site'))};
|
|
259
258
|
});
|
|
260
259
|
|
|
261
260
|
// GET /api/auth/permissions-registry - returns the full permissions registry,
|