domma-cms 1.27.3 → 1.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/CLAUDE.md +2 -2
  3. package/admin/js/app.js +4 -4
  4. package/admin/js/lib/chats-arrange.js +2 -0
  5. package/admin/js/lib/launchers-arrange.js +2 -0
  6. package/admin/js/lib/menu-item-help.js +1 -1
  7. package/admin/js/lib/page-image-hosts.js +2 -2
  8. package/admin/js/lib/shortcode-form.js +6 -6
  9. package/admin/js/lib/shortcode-registry.js +1 -1
  10. package/admin/js/templates/chat-knowledge.html +96 -0
  11. package/admin/js/templates/chats.html +146 -0
  12. package/admin/js/templates/docs/usage-chat.html +96 -0
  13. package/admin/js/templates/docs/usage-launchers.html +83 -0
  14. package/admin/js/templates/docs/usage-media.html +14 -0
  15. package/admin/js/templates/docs/usage-navigation.html +3 -0
  16. package/admin/js/templates/docs/usage-shortcodes.html +8 -0
  17. package/admin/js/templates/documentation.html +8 -0
  18. package/admin/js/templates/launchers.html +105 -0
  19. package/admin/js/views/chat-knowledge.js +60 -0
  20. package/admin/js/views/chats.js +53 -0
  21. package/admin/js/views/doc-pages.js +1 -1
  22. package/admin/js/views/index.js +1 -1
  23. package/admin/js/views/launchers.js +230 -0
  24. package/admin/js/views/menu-editor.js +22 -22
  25. package/admin/js/views/page-editor.js +10 -10
  26. package/docs/DommaFeatures.md +30 -0
  27. package/docs/markdown-shortcodes.md +69 -16
  28. package/package.json +1 -1
  29. package/public/css/image-zoom.css +1 -0
  30. package/public/css/launcher-chat.css +1 -0
  31. package/public/css/launchers.css +1 -0
  32. package/public/css/site.css +1 -1
  33. package/public/js/image-zoom.mjs +30 -0
  34. package/public/js/launcher-chat.mjs +47 -0
  35. package/public/js/launcher-settings.mjs +2 -0
  36. package/public/js/launchers.mjs +12 -0
  37. package/public/js/motion-control.mjs +1 -1
  38. package/public/js/site.js +1 -1
  39. package/server/routes/api/chat.js +203 -0
  40. package/server/routes/api/chats.js +235 -0
  41. package/server/routes/api/launchers.js +50 -0
  42. package/server/routes/launcher-public.js +96 -0
  43. package/server/server.js +33 -0
  44. package/server/services/adapterRegistry.js +4 -4
  45. package/server/services/adapters/FileAdapter.js +18 -0
  46. package/server/services/adapters/MongoAdapter.js +14 -0
  47. package/server/services/chat/conversation.js +458 -0
  48. package/server/services/chat/launcher-bridge.js +73 -0
  49. package/server/services/chat/matcher.js +324 -0
  50. package/server/services/chat/settings.js +118 -0
  51. package/server/services/chat/store.js +532 -0
  52. package/server/services/collectionAccess.js +16 -0
  53. package/server/services/docs.js +2 -0
  54. package/server/services/launchers.js +172 -0
  55. package/server/services/markdown.js +175 -4
  56. package/server/services/number-fields-migration.js +4 -0
  57. package/server/services/permissionRegistry.js +12 -0
  58. package/server/services/presetCollections.js +75 -2
  59. package/server/services/renderer.js +86 -18
  60. package/server/services/roles.js +1 -1
  61. package/server/services/tools.js +1 -0
  62. package/server/templates/page.html +4 -2
@@ -0,0 +1,47 @@
1
+ const ae={waiting:3e3,open:3e3,bot:9e3,message:2e4},se=6e3,ne="/public/css/launcher-chat.css?v=20261031-chat",Y=()=>document.documentElement.classList.contains("dm-reduced-motion")||!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;function ie(){if(document.querySelector("link[data-dm-chat-css]"))return;const t=document.createElement("link");t.rel="stylesheet",t.href=ne,t.dataset.dmChatCss="",document.head.appendChild(t)}const B={get:t=>{try{return globalThis.S?.get?.(t)??null}catch{return null}},set:(t,s)=>{try{globalThis.S?.set?.(t,s)}catch{}},remove:t=>{try{globalThis.S?.remove?globalThis.S.remove(t):globalThis.S?.set?.(t,null)}catch{}}};async function C(t,s,i,l){const g=l?{"X-Chat-Token":l}:{};let u;try{u=t==="GET"?await H.get(s,{headers:g}):await H.post(s,i,{headers:g})}catch(f){const T=f?.data||f?.response?.data;throw new Error(T?.error||"The chat could not be reached. Check your connection and try again.")}if(u&&u.error)throw new Error(u.error);return u}const le=t=>{const s=t?new Date(t):null;return s&&!Number.isNaN(s.getTime())?s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""};function oe(t){const s=Array.isArray(t.suggestions)&&t.suggestions.length?[...t.suggestions.map(i=>({key:`${t.n}-${i.i}`,n:t.n,i:i.i,label:i.label})),{key:`${t.n}-none`,n:t.n,i:-1,label:"None of these"}]:[];return{key:`m${t.n}`,n:t.n,from:t.from,cls:`dm-chat-msg dm-chat-msg--${t.from}`,name:t.from==="visitor"?"You":t.name||(t.from==="system"?"":"The team"),text:typeof t.text=="string"?t.text:"",html:typeof t.html=="string"?t.html:"",links:(Array.isArray(t.links)?t.links:[]).map(i=>{const l=/^https?:/i.test(i.url);return{url:i.url,label:i.label,target:l?"_blank":"_self",rel:l?"noopener noreferrer":""}}),choices:s,time:le(t.at)}}const re=`
2
+ <div class="dm-chat" data-bind-class="rootClass.value">
3
+ <p class="dm-chat-status" data-bind-text="statusText.value"></p>
4
+ <div class="dm-chat-log" role="log" aria-live="polite" aria-relevant="additions" tabindex="0">
5
+ <div class="dm-chat-items" data-each="items.value key=key"></div>
6
+ <div class="dm-chat-msg dm-chat-msg--bot dm-chat-typing" data-bind-hidden="!typing.value" aria-hidden="true">
7
+ <div class="dm-chat-bubble"><span class="dm-chat-dot"></span><span class="dm-chat-dot"></span><span class="dm-chat-dot"></span></div>
8
+ </div>
9
+ </div>
10
+ <p class="dm-chat-error" role="alert" data-bind-hidden="!error.value" data-bind-text="error.value"></p>
11
+
12
+ <form class="dm-chat-details" data-bind-hidden="!showDetails.value" data-on-submit="sendDetails" novalidate>
13
+ <p class="dm-chat-details-intro" data-bind-text="detailsIntro.value"></p>
14
+ <label class="dm-chat-field"><span>Your name</span>
15
+ <input type="text" class="form-input" autocomplete="name" maxlength="80" data-model="detailsName.value"></label>
16
+ <label class="dm-chat-field"><span>Email</span>
17
+ <input type="email" class="form-input" autocomplete="email" maxlength="254" data-model="detailsEmail.value"></label>
18
+ <label class="dm-chat-field" data-bind-hidden="!detailsWantsMessage.value"><span>Message (optional)</span>
19
+ <textarea class="form-input" rows="2" maxlength="1000" data-model="detailsMessage.value"></textarea></label>
20
+ <button type="submit" class="btn btn-primary btn-sm" data-bind-disabled="busy.value">Send my details</button>
21
+ </form>
22
+
23
+ <div class="dm-chat-ended" data-bind-hidden="!ended.value">
24
+ <span>This chat has ended.</span>
25
+ <button type="button" class="btn btn-sm btn-outline" data-on-click="restart">Start a new chat</button>
26
+ </div>
27
+
28
+ <div class="dm-chat-actions" data-bind-hidden="ended.value">
29
+ <button type="button" class="dm-chat-action" data-bind-hidden="!canAskPerson.value" data-on-click="askPerson"
30
+ data-bind-disabled="busy.value" data-bind-text="personLabel.value"></button>
31
+ <button type="button" class="dm-chat-action dm-chat-action--end" data-bind-hidden="!hasChat.value" data-on-click="end"
32
+ data-bind-disabled="busy.value">End chat</button>
33
+ </div>
34
+
35
+ <form class="dm-chat-compose" data-bind-hidden="ended.value" data-on-submit="send">
36
+ <input type="text" name="website" class="dm-chat-hp" tabindex="-1" autocomplete="off" aria-hidden="true" data-model="hp.value">
37
+ <textarea class="form-input dm-chat-input" rows="1" maxlength="1000" placeholder="Type your message\u2026"
38
+ aria-label="Your message" data-model="draft.value" data-bind-disabled="ended.value"></textarea>
39
+ <button type="submit" class="btn btn-primary dm-chat-send" aria-label="Send" title="Send"
40
+ data-bind-disabled="!canSend.value"><span data-icon="send" data-icon-size="16" aria-hidden="true"></span></button>
41
+ </form>
42
+ </div>`,ce=`<div data-bind-class="cls" data-n="{{n}}">
43
+ <div class="dm-chat-who"><span>{{name}}</span> <time>{{time}}</time></div>
44
+ <div class="dm-chat-bubble"><span class="dm-chat-text">{{text}}</span><div class="dm-chat-html">{{{html}}}</div></div>
45
+ <div class="dm-chat-links">{{#each links key=url}}<a class="dm-chat-link" href="{{url}}" target="{{target}}" rel="{{rel}}">{{label}}</a>{{/each}}</div>
46
+ <div class="dm-chat-choices">{{#each choices key=key}}<button type="button" class="dm-chat-choice" data-n="{{n}}" data-i="{{i}}">{{label}}</button>{{/each}}</div>
47
+ </div>`;export function mountChat(t,{launcherId:s,title:i="Chat",chat:l={}}={}){if(!t||!s||!globalThis.M)return{destroy(){}};ie();const g=`chat:${s}`,u=Date.now(),f="/api/chat",T=`launcher=${encodeURIComponent(s)}`,r=M.observable({greeting:l.greeting||"Hi! How can we help?",botName:l.botName||"Assistant",bot:l.bot!==!1,staff:l.staff!==!1,askDetails:l.askDetails||"offline",staffOnline:!1}),b=M.observable([]),p=M.observable(null),S=M.observable(""),$=M.observable(""),D=M.observable(!1),y=M.observable(!1),L=M.observable(""),E=M.observable(!1),G=M.observable(""),K=M.observable(""),N=M.observable("");let o=B.get(g),k=0,n=!0,w=0,A=0;const c=()=>p.value?.status||"none",O=()=>({key:"greet",n:0,from:"bot",cls:"dm-chat-msg dm-chat-msg--bot",name:r.value.botName,text:r.value.greeting,html:"",links:[],choices:[],time:""}),Q={items:b,draft:S,hp:$,typing:D,busy:y,error:L,detailsName:G,detailsEmail:K,detailsMessage:N,ended:M.computed(()=>E.value||c()==="closed"),hasChat:M.computed(()=>!!p.value&&c()!=="closed"),showDetails:M.computed(()=>!!p.value?.askDetails&&c()!=="closed"),detailsWantsMessage:M.computed(()=>c()==="bot"),detailsIntro:M.computed(()=>c()==="waiting"?"So we can reach you if we get cut off:":"Leave your details and we will get back to you."),canAskPerson:M.computed(()=>{const e=r.value,a=c();return p.value?.askDetails||!(a==="none"||a==="bot")?!1:e.staff||e.askDetails!=="never"}),personLabel:M.computed(()=>r.value.staff?"Talk to a person":"Leave a message"),canSend:M.computed(()=>!y.value&&S.value.trim().length>0&&!(E.value||c()==="closed")),rootClass:M.computed(()=>Y()?"is-still":""),statusText:M.computed(()=>{const e=r.value;switch(c()){case"waiting":return"Waiting for a person - they will reply here.";case"open":return"You are chatting with our team.";case"message":return"Message left - we will get back to you by email.";case"closed":return"Chat ended.";default:return e.bot?`${e.botName} answers straight away${e.staff&&e.staffOnline?" - a person is available too.":"."}`:e.staff?e.staffOnline?"Someone is available to chat.":"Nobody is available right now - leave a message.":""}})};t.innerHTML=re;const v=t.firstElementChild;v.setAttribute("aria-label",i),v.querySelector(".dm-chat-items").innerHTML=ce;const m=v.querySelector(".dm-chat-log"),d=v.querySelector(".dm-chat-input");function W(e){L.value=e,clearTimeout(A),A=setTimeout(()=>{n&&(L.value="")},se)}function F(e=!1){const a=m.scrollHeight-m.scrollTop-m.clientHeight<80;!e&&!a||requestAnimationFrame(()=>{m.scrollTop=m.scrollHeight})}function _(e){if(!n||!e)return;e.token&&(o=e.token,B.set(g,o)),e.state&&(p.value=e.state),typeof e.state?.staffOnline=="boolean"&&(r.value={...r.peek(),staffOnline:e.state.staffOnline});const a=(Array.isArray(e.messages)?e.messages:[]).filter(h=>h.n>k);a.length&&(k=Math.max(k,...a.map(h=>h.n)),b.value=[...b.peek(),...a.map(oe)],F(a.some(h=>h.from==="visitor"))),z()}function z(){if(clearTimeout(w),!n||!o)return;const e=ae[c()];e&&(w=setTimeout(P,e))}async function P(){if(!(!n||!o)){if(document.hidden||!v.isConnected){z();return}try{const e=await C("GET",`${f}/state?${T}&after=${k}`,null,o);if(!n)return;if(!e.state){q();return}_(e)}catch{clearTimeout(w),n&&(w=setTimeout(P,15e3))}}}function q(){o=null,B.remove(g),p.value=null,k=0,b.value=[O()]}async function x(e,a,{thinking:h=!1}={}){if(y.peek())return!1;y.value=!0,L.value="",h&&!Y()&&(D.value=!0);const ee=Date.now();try{const R=await C("POST",`${f}/${e}`,{launcher:s,after:k,...a},o);if(h&&!Y()){const J=450-(Date.now()-ee);J>0&&await new Promise(te=>setTimeout(te,J))}return _(R),!0}catch(R){return n&&W(R.message),!1}finally{n&&(y.value=!1,D.value=!1)}}async function I(){const e=S.peek().trim();return!e||y.peek()||E.peek()||await x("send",{text:e,page:location.pathname,_hp:$.peek(),_t:u},{thinking:!0})&&(S.value="",d.focus()),!1}const Z=M.applyBindings(Q,v,{methods:{send:()=>(I(),!1),sendDetails:()=>(x("details",{name:G.peek(),email:K.peek(),message:N.peek()}).then(e=>{e&&(N.value="")}),!1),askPerson:()=>x("person",{page:location.pathname,_hp:$.peek(),_t:u},{thinking:!0}),end:async()=>{o&&await x("end",{})&&(E.value=!0,clearTimeout(w))},restart:()=>{E.value=!1,q(),d.focus()}}});window.Domma?.icons?.scan?.(v);const U=e=>{e.key==="Enter"&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),I())};d.addEventListener("keydown",U);const V=()=>{d.style.height="auto",d.style.height=Math.min(d.scrollHeight,120)+"px"};d.addEventListener("input",V);const X=e=>{const a=e.target.closest(".dm-chat-choice");!a||!m.contains(a)||x("pick",{n:Number(a.dataset.n),i:Number(a.dataset.i)},{thinking:!0})};m.addEventListener("click",X);const j=()=>{!document.hidden&&n&&o&&P()};return document.addEventListener("visibilitychange",j),b.value=[O()],(async()=>{try{const e=await C("GET",`${f}/config?${T}`);if(!n)return;r.value={...r.peek(),...e},p.peek()||(b.value=[O(),...b.peek().filter(a=>a.key!=="greet")])}catch(e){n&&W(e.message)}if(!(!o||!n))try{const e=await C("GET",`${f}/state?${T}&after=0`,null,o);if(!n)return;if(!e.state){q();return}_(e),F(!0)}catch{}})(),{destroy(){n&&(n=!1,clearTimeout(w),clearTimeout(A),d.removeEventListener("keydown",U),d.removeEventListener("input",V),m.removeEventListener("click",X),document.removeEventListener("visibilitychange",j),Z?.dispose?.(),t.innerHTML="")}}}
@@ -0,0 +1,2 @@
1
+ import{cssClasses as x}from"./css-classes.mjs";export const LAUNCHER_POSITIONS=["TL","TC","TR","ML","MR","BL","BC","BR"],LAUNCHER_POSITION_LABEL={TL:"Top left",TC:"Top centre",TR:"Top right",ML:"Middle left",MR:"Middle right",BL:"Bottom left",BC:"Bottom centre",BR:"Bottom right"},LAUNCHER_TRIGGER_STYLES=["icon","icon-text"],LAUNCHER_TOOLTIP_MODES=["label","custom","off"],LAUNCHER_DEVICES=["all","desktop","phone"],LAUNCHER_AUDIENCES=["everyone","signed-in","signed-out"],LAUNCHER_PAGE_MODES=["all","only","except"],LAUNCHER_ACTIONS=["modal","slideover","chat"],LAUNCHER_MODAL_KINDS=["page","form","block"],LAUNCHER_SLIDEOVER_KINDS=["page","form","block"],LAUNCHER_MODAL_SIZES=["xs","sm","md","lg","xl","xxl","full","screen","custom"],LAUNCHER_MODAL_HEIGHTS=["auto","sm","md","lg","full","custom"],LAUNCHER_WIDTH_UNITS=["px","%"],LAUNCHER_HEIGHT_UNITS=["px","vh"],LAUNCHER_MODAL_WIDTH_CSS=Object.freeze({xs:"320px",sm:"400px",md:"600px",lg:"800px",xl:"1140px",xxl:"1400px",full:"90vw"}),LAUNCHER_MODAL_HEIGHT_CSS=Object.freeze({sm:"40vh",md:"60vh",lg:"80vh",full:"90vh"}),LAUNCHER_SLIDEOVER_WIDTHS=["sm","md","lg","xl"],LAUNCHER_SIDES=["left","right"],LAUNCHER_ASK_DETAILS=["offline","always","never"],LAUNCHER_TOKENS=["primary","secondary","success","danger","warning","info","surface","text","background"],LAUNCHER_LIMITS=Object.freeze({nameMax:60,labelMax:40,tooltipMax:120,titleMax:80,iconMax:40,idMax:40,sizeMin:32,sizeMax:96,offsetMax:500,pathsMax:50,pathMax:200,greetingMax:300,botNameMax:40,widthPx:[240,2400],widthPct:[20,100],heightPx:[160,2e3],heightVh:[20,100]}),LAUNCHER_DEFAULTS=Object.freeze({enabled:!0,showDisc:!0,name:"New launcher",label:"Open",tooltipMode:"label",tooltip:"",icon:"message-circle",triggerStyle:"icon",position:"BR",offsetX:32,offsetY:32,size:52,radius:26,devices:"all",phone:Object.freeze({override:!1,position:"BR",offsetX:16,offsetY:16,size:48}),colours:Object.freeze({background:"",text:""}),class:"",pages:Object.freeze({mode:"all",paths:Object.freeze([])}),audience:"everyone",action:Object.freeze({type:"modal",kind:"page",ref:"",title:"",size:"lg",side:"right",width:"md",customWidth:900,widthUnit:"px",height:"auto",customHeight:70,heightUnit:"vh"}),chat:Object.freeze({greeting:"Hi! How can we help?",botName:"Assistant",bot:!0,staff:!0,askDetails:"offline"})});const c=(e,t,o)=>t.includes(e)?e:o;function p(e,t,o,i){const s=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;return Number.isFinite(s)?Math.min(i,Math.max(o,Math.round(s))):Math.min(i,Math.max(o,t))}function g(e,t,o=""){return typeof e!="string"?o:e.replace(/[\u0000-\u001f\u007f]/g," ").trim().replace(/\s+/g," ").slice(0,t)||o}const l=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};export const LAUNCHER_ID_RE=/^[a-z0-9][a-z0-9-]{0,39}$/;const m=/^[a-z0-9][a-z0-9-]{0,39}$/,_=/^\/[A-Za-z0-9._~\-/]*$/,M=/^[a-z0-9][a-z0-9_-]{0,99}$/i;export function launcherColour(e){if(typeof e!="string")return"";const t=e.trim().toLowerCase();return LAUNCHER_TOKENS.includes(t)||/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)?t:""}export function launcherColourCss(e){const t=launcherColour(e);return t?LAUNCHER_TOKENS.includes(t)?`var(--dm-${t})`:t:""}export function normaliseLauncherPath(e){if(typeof e!="string")return"";let t=e.trim().split(/[?#]/)[0].replace(/\s+/g,"");return!t||(t.startsWith("/")||(t="/"+t),t=t.replace(/\/{2,}/g,"/"),t.length>1&&(t=t.replace(/\/+$/,"")),t.length>LAUNCHER_LIMITS.pathMax||!/^\/[A-Za-z0-9._~\-/*]*$/.test(t))?"":t}export function launcherPathMatches(e,t){const o=normaliseLauncherPath(e||"/")||"/",i=normaliseLauncherPath(t);return i?i.endsWith("/*")&&o===(i.slice(0,-2)||"/")?!0:new RegExp("^"+i.split("*").map(n=>n.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i").test(o):!1}export function launcherShowsOn(e,t,o){if(!e||e.enabled===!1||e.audience==="signed-in"&&!o||e.audience==="signed-out"&&o)return!1;const i=e.pages.paths.some(s=>launcherPathMatches(t,s));return e.pages.mode==="only"?i:e.pages.mode==="except"?!i:!0}function b(e,t){const o=l(e);return{override:o.override===!0,position:c(o.position,LAUNCHER_POSITIONS,LAUNCHER_DEFAULTS.phone.position),offsetX:p(o.offsetX,LAUNCHER_DEFAULTS.phone.offsetX,0,LAUNCHER_LIMITS.offsetMax),offsetY:p(o.offsetY,LAUNCHER_DEFAULTS.phone.offsetY,0,LAUNCHER_LIMITS.offsetMax),size:p(o.size,Math.min(t,LAUNCHER_DEFAULTS.phone.size),LAUNCHER_LIMITS.sizeMin,LAUNCHER_LIMITS.sizeMax)}}function L(e){const t=l(e),o=c(t.type,LAUNCHER_ACTIONS,LAUNCHER_DEFAULTS.action.type),i=o==="modal"?LAUNCHER_MODAL_KINDS:LAUNCHER_SLIDEOVER_KINDS,s=o==="chat"?"page":c(t.kind,i,"page");let n=typeof t.ref=="string"?t.ref.trim():"";s==="page"?(n=n?normaliseLauncherPath(n):"",n.includes("*")&&(n="")):M.test(n)||(n=""),o==="chat"&&(n="");const r=LAUNCHER_DEFAULTS.action,a=c(t.widthUnit,LAUNCHER_WIDTH_UNITS,r.widthUnit),f=c(t.heightUnit,LAUNCHER_HEIGHT_UNITS,r.heightUnit);return{type:o,kind:s,ref:n,title:g(t.title,LAUNCHER_LIMITS.titleMax),size:c(t.size,LAUNCHER_MODAL_SIZES,r.size),side:c(t.side,LAUNCHER_SIDES,r.side),width:c(t.width,LAUNCHER_SLIDEOVER_WIDTHS,r.width),customWidth:p(t.customWidth,a==="%"?90:r.customWidth,...a==="%"?LAUNCHER_LIMITS.widthPct:LAUNCHER_LIMITS.widthPx),widthUnit:a,height:c(t.height,LAUNCHER_MODAL_HEIGHTS,r.height),customHeight:p(t.customHeight,f==="px"?600:r.customHeight,...f==="px"?LAUNCHER_LIMITS.heightPx:LAUNCHER_LIMITS.heightVh),heightUnit:f}}export function launcherModalBox(e){const t=e||LAUNCHER_DEFAULTS.action;if(t.size==="screen")return{width:"100vw",height:"100vh",screen:!0};const o=t.size==="custom"?t.widthUnit==="%"?`${t.customWidth}vw`:`${t.customWidth}px`:LAUNCHER_MODAL_WIDTH_CSS[t.size]||LAUNCHER_MODAL_WIDTH_CSS.lg,i=t.height==="custom"?`${t.customHeight}${t.heightUnit==="px"?"px":"vh"}`:LAUNCHER_MODAL_HEIGHT_CSS[t.height]||"";return{width:o,height:i,screen:!1}}export function normaliseLauncherChat(e){const t=l(e),o=LAUNCHER_DEFAULTS.chat;return{greeting:typeof t.greeting=="string"?t.greeting.replace(/\r\n?/g,`
2
+ `).replace(/[\u0000-\u0009\u000b-\u001f\u007f]/g," ").trim().slice(0,LAUNCHER_LIMITS.greetingMax):o.greeting,botName:g(t.botName,LAUNCHER_LIMITS.botNameMax,o.botName),bot:t.bot!==!1,staff:t.staff!==!1,askDetails:c(t.askDetails,LAUNCHER_ASK_DETAILS,o.askDetails)}}export function normaliseLauncher(e){const t=l(e),o=LAUNCHER_DEFAULTS,i=p(t.size,o.size,LAUNCHER_LIMITS.sizeMin,LAUNCHER_LIMITS.sizeMax),s=Math.floor(i/2),n=l(t.pages),r=(Array.isArray(n.paths)?n.paths:typeof n.paths=="string"?n.paths.split(/[\n,]+/):[]).map(normaliseLauncherPath).filter(Boolean).filter((f,u,h)=>h.indexOf(f)===u).slice(0,LAUNCHER_LIMITS.pathsMax),a=l(t.colours);return{id:typeof t.id=="string"&&LAUNCHER_ID_RE.test(t.id)?t.id:"",enabled:t.enabled!==!1,showDisc:t.showDisc!==!1,name:g(t.name,LAUNCHER_LIMITS.nameMax,o.name),label:g(t.label,LAUNCHER_LIMITS.labelMax,o.label),tooltipMode:c(t.tooltipMode,LAUNCHER_TOOLTIP_MODES,o.tooltipMode),tooltip:g(t.tooltip,LAUNCHER_LIMITS.tooltipMax,""),icon:typeof t.icon=="string"&&m.test(t.icon.trim())?t.icon.trim():o.icon,triggerStyle:c(t.triggerStyle,LAUNCHER_TRIGGER_STYLES,o.triggerStyle),position:c(t.position,LAUNCHER_POSITIONS,o.position),offsetX:p(t.offsetX,o.offsetX,0,LAUNCHER_LIMITS.offsetMax),offsetY:p(t.offsetY,o.offsetY,0,LAUNCHER_LIMITS.offsetMax),size:i,radius:Math.min(s,p(t.radius,o.radius,0,s)),devices:c(t.devices,LAUNCHER_DEVICES,o.devices),phone:b(t.phone,i),colours:{background:launcherColour(a.background),text:launcherColour(a.text)},class:x(typeof t.class=="string"?t.class:"").join(" "),pages:{mode:c(n.mode,LAUNCHER_PAGE_MODES,o.pages.mode),paths:r},audience:c(t.audience,LAUNCHER_AUDIENCES,o.audience),action:L(t.action),chat:normaliseLauncherChat(t.chat)}}export function launcherTooltip(e){return!e||e.tooltipMode==="off"?"":e.tooltipMode==="custom"?e.tooltip||e.label:e.triggerStyle==="icon-text"?"":e.label}export function launcherHref(e){return`#launcher-${e}`}export function newLauncherId(e=new Set,t=Math.random){for(let o=0;o<1e3;o++){const i="l-"+Math.floor(t()*2176782336).toString(36).padStart(6,"0");if(!e.has(i))return i}return"l-"+Date.now().toString(36)}export function normaliseLaunchers(e,t=Math.random){const o=Array.isArray(e)?e:Array.isArray(e?.launchers)?e.launchers:[],i=new Set;return o.filter(s=>s&&typeof s=="object"&&!Array.isArray(s)).map(s=>{const n=normaliseLauncher(s);return(!n.id||i.has(n.id))&&(n.id=newLauncherId(i,t)),i.add(n.id),n})}export function launcherReady(e){return e?e.action.type==="chat"?!0:!!e.action.ref:!1}export function publicLauncher(e){const t={id:e.id,disc:e.showDisc,label:e.label,tooltip:launcherTooltip(e),icon:e.icon,triggerStyle:e.triggerStyle,position:e.position,offsetX:e.offsetX,offsetY:e.offsetY,size:e.size,radius:e.radius,devices:e.devices,phone:e.phone,colours:{background:launcherColourCss(e.colours.background),text:launcherColourCss(e.colours.text)},class:e.class,action:{type:e.action.type,title:e.action.title||e.label,size:e.action.size,side:e.action.side,width:e.action.width,customWidth:e.action.customWidth,widthUnit:e.action.widthUnit,height:e.action.height,customHeight:e.action.customHeight,heightUnit:e.action.heightUnit}};return e.action.type==="chat"&&(t.chat={...e.chat}),t}export function launcherSpot(e,{w:t,h:o,vw:i,vh:s,offsetX:n,offsetY:r}){const a=e[1]==="L"?"L":e[1]==="R"?"R":"C",f=e[0],u=a==="L"?n:a==="R"?i-t-n:Math.round((i-t)/2+n),h=f==="T"?r:f==="B"?s-o-r:Math.round((s-o)/2+r);return{left:u,top:h}}const d=12,E=(e,t)=>e.left<t.right+d&&t.left<e.right+d&&e.top<t.bottom+d&&t.top<e.bottom+d;export function launcherStack(e,t,{w:o,h:i},s){const n=e[0]==="B";let r=t.top;for(let a=0;a<=s.length;a++){const f={left:t.left,top:r,right:t.left+o,bottom:r+i},u=s.find(h=>h&&h.right>h.left&&h.bottom>h.top&&E(f,h));if(!u)break;r=Math.round(n?u.top-d-i:u.bottom+d)}return{left:t.left,top:r}}
@@ -0,0 +1,12 @@
1
+ import{launcherModalBox as ie,launcherSpot as se,launcherStack as le}from"/public/js/launcher-settings.mjs?v=20261031-launchers-links";const Y="(max-width: 640px)",G=[".site-search-floating-trigger","#back-to-top-btn","#go-to-bottom-btn",".dm-theme-switcher:not(.dm-ts-inline)","nav.dm-breadcrumbs",".dm-motion-fab"].join(","),V={sm:"360px",md:"480px",lg:"640px",xl:"860px"},re=i=>String(i??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),J=()=>document.documentElement.classList.contains("dm-reduced-motion")||matchMedia("(prefers-reduced-motion: reduce)").matches,de=`
2
+ <button type="button" class="dm-launcher" data-id="{{id}}" data-bind-class="cls" data-bind-style="style.value"
3
+ data-bind-aria-expanded="expanded.value" data-bind-hidden="hidden.value" aria-haspopup="dialog" aria-label="{{label}}">
4
+ <span class="dm-launcher-icon" data-icon="{{icon}}" aria-hidden="true"></span>
5
+ <span class="dm-launcher-label" data-bind-hidden="!pill">{{label}}</span>
6
+ </button>`,ue=`
7
+ <div class="dm-launcher-chat-head">
8
+ <strong class="dm-launcher-chat-title" data-bind-text="title"></strong>
9
+ <button type="button" class="dm-launcher-chat-close" data-on-click="close" aria-label="Close"><span data-icon="x" aria-hidden="true"></span></button>
10
+ </div>
11
+ <div class="dm-launcher-chat-body"></div>
12
+ <p class="dm-launcher-note" data-bind-hidden="!note.value" data-bind-text="note.value"></p>`;function he(i){const s=i.getBoundingClientRect();return getComputedStyle(i).opacity!=="0"||i.offsetParent!==null?s:{top:Math.min(s.top,i.offsetTop),left:Math.min(s.left,i.offsetLeft),right:Math.max(s.right,i.offsetLeft+i.offsetWidth),bottom:Math.max(s.bottom,i.offsetTop+i.offsetHeight)}}function Q(i){window.Domma?.icons?.scan&&window.Domma.icons.scan(i)}function Z(i,{fill:s}){const c=document.createElement("iframe");if(c.className="dm-launcher-frame"+(s?" is-fill":""),c.title=i.action.title,c.src=`/_launcher/${encodeURIComponent(i.id)}`,c.setAttribute("loading","eager"),!s){let d=null;c.addEventListener("load",()=>{const L=c.contentDocument;if(!L?.body)return;const y=L.querySelector(".site-content")||L.body,T=()=>{c.style.height=`${Math.ceil(y.getBoundingClientRect().height)}px`};T(),d?.disconnect(),d=new ResizeObserver(T),d.observe(y)})}return c}export function mountLaunchers(i){if(!Array.isArray(i)||!i.length||document.querySelector(".dm-launchers"))return null;const s=M.observable(matchMedia(Y).matches),c=document.createElement("div");c.className="dm-launchers";const d=i.map(e=>{const n=a=>a&&e.phone?.override?{...e,...e.phone}:e,t=e.triggerStyle==="icon-text",o=a=>{const u=n(a),f={"--launcher-size":`${u.size}px`,"--launcher-radius":`${t?999:Math.min(e.radius,Math.floor(u.size/2))}px`,"--launcher-glyph":`${Math.round(u.size*20/52)}px`};return e.colours.background&&(f["--launcher-bg"]=e.colours.background),e.colours.text&&(f["--launcher-fg"]=e.colours.text),f},l=M.observable(-9999),r=M.observable(-9999);return{id:e.id,label:e.label,icon:e.icon,pill:t,launcher:e,look:n,left:l,top:r,cls:["dm-launcher--"+e.action.type,t?"dm-launcher--pill":"",e.class].filter(Boolean).join(" "),style:M.computed(()=>({...o(s.value),left:`${l.value}px`,top:`${r.value}px`})),expanded:M.observable("false"),hidden:M.computed(()=>e.disc===!1||e.devices==="desktop"&&s.value||e.devices==="phone"&&!s.value)}});c.innerHTML='<div class="dm-launchers-list" data-each="rows.value key=id"></div>',c.firstElementChild.innerHTML=de;const L=M.applyBindings({rows:M.observable(d)},c);document.body.appendChild(c),Q(c);const y=e=>c.querySelector(`.dm-launcher[data-id="${CSS.escape(e)}"]`),T={TL:"right",ML:"right",BL:"right",TR:"left",MR:"left",BR:"left",TC:"bottom",BC:"top"},A=new Map;for(const e of d){const n=e.launcher.tooltip,t=y(e.id);if(!(!n||!t||typeof E.tooltip!="function"))try{A.set(e.id,E.tooltip(t,{content:n,position:T[e.launcher.position]||"top",trigger:"hover focus",className:"dm-launcher-tip"}))}catch{}}function z(){const e=document.documentElement.clientWidth,n=window.innerHeight,t=[...document.querySelectorAll(G)].filter(o=>!c.contains(o)&&getComputedStyle(o).position==="fixed"&&getComputedStyle(o).display!=="none").map(he);for(const o of d){const l=y(o.id);if(!l||l.hidden)continue;const r=o.look(s.peek()),a=l.offsetWidth,u=l.offsetHeight,f=se(r.position,{w:a,h:u,vw:e,vh:n,offsetX:r.offsetX,offsetY:r.offsetY}),v=le(r.position,f,{w:a,h:u},t),b=Math.max(0,Math.min(e-a,v.left)),C=Math.max(0,Math.min(n-u,v.top));o.left.value=b,o.top.value=C,t.push({left:b,top:C,right:b+a,bottom:C+u})}}let R=0;const g=()=>{cancelAnimationFrame(R),R=requestAnimationFrame(z)},P=new MutationObserver(e=>{e.some(n=>[...n.addedNodes].some(t=>t.nodeType===1&&t.matches?.(G)))&&g()});P.observe(document.body,{childList:!0});const H=matchMedia(Y),q=()=>{s.value=H.matches,g()};H.addEventListener?.("change",q),window.addEventListener("resize",g),window.addEventListener("load",g,{once:!0}),z();let m=null;const ee=M.effect(()=>{const e=d.some(n=>n.expanded.value==="true"&&(n.launcher.action.type!=="chat"||s.value));document.documentElement.classList.toggle("dm-launcher-covering",e)});function K(){const e=m;m=null,e&&(e.row.expanded.value="false",e.close())}function te(e){const n=e.launcher,t=ie(n.action),o=E.modal({title:n.action.title,size:t.width,content:Z(n,{fill:!!t.height}),className:"dm-launcher-modal",bodyClass:"dm-launcher-modal-body",buttons:[],animation:J()?!1:"fade",onClosed:()=>{m?.row===e&&(m=null,e.expanded.value="false"),setTimeout(()=>{try{o.destroy()}catch{}},0)}});return o.element?.classList.add("dm-launcher-modal",`dm-launcher-modal--${n.action.size}`),o.element?.style.setProperty("--launcher-modal-w",t.width),t.height&&(o.element?.classList.add("dm-launcher-modal--fixed"),o.element?.style.setProperty("--launcher-modal-h",t.height)),o.open(),()=>{try{o.close()}catch{}}}function ne(e){const n=e.launcher,t=E.slideover({title:re(n.action.title),position:n.action.side,size:s.peek()?"full":V[n.action.width]||V.md,content:Z(n,{fill:!0}),bodyClass:"dm-launcher-so-body",animation:!J(),onClosed:()=>{m?.row===e&&(m=null,e.expanded.value="false"),setTimeout(()=>{try{t.destroy?.()}catch{}t.element?.remove()},0)}});return t.element?.classList.add("dm-launcher-so"),t.open(),()=>{try{t.close()}catch{}}}function oe(e,n){const t=e.launcher,o=y(e.id),l=o&&!o.hidden?o:null,r=l||(n?.isConnected?n:null),a=document.createElement("div");a.className="dm-launcher-chat",a.setAttribute("role","dialog"),a.setAttribute("aria-label",t.action.title),a.innerHTML=ue;const u=M.observable("");let f=null,v=!1;const b=()=>{if(!v){v=!0;try{f?.destroy?.()}catch{}C.dispose?.(),a.remove(),document.removeEventListener("keydown",U),window.removeEventListener("resize",N),m?.row===e&&(m=null,e.expanded.value="false"),(r?.isConnected?r:null)?.focus()}},C=M.applyBindings({title:t.action.title,note:u,close:b},a),U=h=>{h.key!=="Escape"||h.defaultPrevented||!a.contains(document.activeElement)||(h.preventDefault(),b())},N=()=>{if(s.peek()){a.classList.add("is-full"),a.removeAttribute("style");return}a.classList.remove("is-full");const h=document.documentElement.clientWidth,D=window.innerHeight,w=Math.min(380,h-24),x=Math.min(560,D-24),I=O=>Math.max(12,Math.min(h-w-12,O)),_=O=>Math.max(12,Math.min(D-x-12,O));let S,k;if(!l){S=I(t.position[1]==="L"?24:h-w-24),k=_(D-x-24),Object.assign(a.style,{left:`${S}px`,top:`${k}px`,width:`${w}px`,height:`${x}px`});return}const p=l.getBoundingClientRect(),X=p.left+p.width/2>h/2;t.position[0]==="M"?(S=I(X?p.left-w-12:p.right+12),k=_(p.top+p.height/2-x/2)):(S=I(X?p.right-w:p.left),k=t.position[0]==="T"?_(p.bottom+12):_(p.top-x-12)),Object.assign(a.style,{left:`${S}px`,top:`${k}px`,width:`${w}px`,height:`${x}px`})};document.body.appendChild(a),N(),Q(a),document.addEventListener("keydown",U),window.addEventListener("resize",N);const ce=a.querySelector(".dm-launcher-chat-body");return import("/public/js/launcher-chat.mjs").then(h=>{if(!v){if(typeof h.mountChat!="function")throw new Error("no mountChat");f=h.mountChat(ce,{launcherId:t.id,title:t.action.title,chat:t.chat||{}})}}).catch(()=>{v||(u.value="Chat is unavailable right now. Please try again later.")}),a.querySelector(".dm-launcher-chat-close")?.focus(),b}function $(e,n=null){const t=d.find(a=>a.id===e);if(!t)return;const o=m?.row===t;if(K(),o)return;t.expanded.value="true";try{A.get(t.id)?.close()}catch{}const l=t.launcher.action.type,r=l==="chat"?oe(t,n):l==="slideover"?ne(t):te(t);m={row:t,close:r}}const F=e=>{const n=e.target.closest(".dm-launcher");n&&$(n.dataset.id)};c.addEventListener("click",F);const W=/^#launcher-([a-z0-9][a-z0-9-]{0,39})$/,ae=e=>{const n=e.closest("[data-launcher]");if(n)return{el:n,id:n.dataset.launcher};const t=e.closest("a[href]"),o=t&&W.exec(t.getAttribute("href")||"");return o?{el:t,id:o[1]}:null},j=e=>{if(e.button>0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||c.contains(e.target))return;const n=e.target instanceof Element?ae(e.target):null;!n||!d.some(t=>t.id===n.id)||(e.preventDefault(),$(n.id,n.el))};document.addEventListener("click",j);const B=W.exec(location.hash);return B&&d.some(e=>e.id===B[1])&&(history.replaceState(history.state,"",location.pathname+location.search),setTimeout(()=>$(B[1]),0)),{place:z,launch:$,destroy(){K(),ee?.(),document.documentElement.classList.remove("dm-launcher-covering");for(const e of A.values())try{e.destroy()}catch{}A.clear(),cancelAnimationFrame(R),P.disconnect(),H.removeEventListener?.("change",q),window.removeEventListener("resize",g),window.removeEventListener("load",g),c.removeEventListener("click",F),document.removeEventListener("click",j),L?.dispose?.(),c.remove()}}}typeof window<"u"&&Array.isArray(window.__CMS_LAUNCHERS__)&&window.M&&window.E&&(window.DommaLaunchers=mountLaunchers(window.__CMS_LAUNCHERS__));
@@ -1 +1 @@
1
- import{applyClasses as f}from"/public/js/css-classes.mjs";const x="(prefers-reduced-motion: reduce)";export function reducedMotionOn(t={}){const e=globalThis.S?.get?.("reduced_motion");return e!=null?!!e:t.default==="on"?!0:t.default==="off"?!1:!!(window.matchMedia&&window.matchMedia(x).matches)}function s(t){globalThis.S?.set?.("reduced_motion",t),window.location.reload()}function C(t){const e=document.createElement("span");return e.className="dm-motion-icon",e.setAttribute("data-icon",t?"play":"pause"),e.setAttribute("aria-hidden","true"),e}function v(t,e){const i=t.control==="checkbox",o=document.createElement("input");o.type="checkbox",o.className=i?"footer-motion-checkbox":"form-switch-input",o.id="dm-motion-switch",o.checked=e,o.addEventListener("change",()=>s(o.checked));const n=document.createElement("span");n.className=i?"footer-motion-label":"form-switch-label",n.textContent=t.label;const a=document.createElement("label");return a.className=i?"footer-motion-check":"form-switch footer-motion-switch",a.title=t.label,a.append(o,n),a}function p(t,e,i,o){const n=document.createElement("button");if(n.type="button",n.className=i,n.id="dm-motion-toggle",n.setAttribute("aria-pressed",String(e)),n.setAttribute("aria-label",t.label),n.title=e?`${t.label}: on`:`${t.label}: off`,n.appendChild(C(e)),t.triggerStyle==="icon-text"){const a=document.createElement("span");a.className=o,a.textContent=t.label,n.appendChild(a)}return n.addEventListener("click",()=>s(!e)),n}const h=[".site-search-floating-trigger","#back-to-top-btn","#go-to-bottom-btn",".dm-theme-switcher:not(.dm-ts-inline)","nav.dm-breadcrumbs"].join(","),r=12;function E(t){const e=t.getBoundingClientRect();if(getComputedStyle(t).opacity!=="0"||t.offsetParent!==null)return e;const i=Math.min(e.top,t.offsetTop),o=Math.min(e.left,t.offsetLeft);return{top:i,left:o,right:Math.max(e.right,t.offsetLeft+t.offsetWidth),bottom:Math.max(e.bottom,t.offsetTop+t.offsetHeight),width:e.width,height:e.height}}const S=(t,e)=>t.left<e.right+r&&e.left<t.right+r&&t.top<e.bottom+r&&e.top<t.bottom+r;function g(t,e){const i=e.position==="TL"||e.position==="BL",o=e.position==="TL"||e.position==="TR";t.style.left=i?`${e.offsetX}px`:"auto",t.style.right=i?"auto":`${e.offsetX}px`;let n=e.offsetY;const a=()=>{t.style.top=o?`${n}px`:"auto",t.style.bottom=o?"auto":`${n}px`};a();const l=[...document.querySelectorAll(h)].filter(c=>c!==t&&getComputedStyle(c).position==="fixed"&&getComputedStyle(c).display!=="none");for(let c=0;c<l.length+1;c++){const w=t.getBoundingClientRect(),d=l.map(E).find(m=>m.width&&m.height&&S(w,m));if(!d)break;n=Math.round(o?d.bottom+r:window.innerHeight-d.top+r),a()}}function b(t,e){const i=t.triggerStyle==="icon-text",o=p(t,e,`dm-motion-fab${i?" dm-motion-fab--pill":""}`,"dm-motion-fab-label");return i||(o.style.width=`${t.iconSize}px`,o.style.height=`${t.iconSize}px`,o.style.borderRadius=`${t.iconRadius}px`,o.style.setProperty("--dm-motion-glyph",`${Math.round(t.iconSize*20/52)}px`)),f(o,t.class),o}function y(t,e){const i=()=>{t.isConnected&&g(t,e)};let o=0;const n=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(i)};return new MutationObserver(a=>{a.some(l=>[...l.addedNodes].some(c=>c.nodeType===1&&c.matches?.(h)))&&n()}).observe(document.body,{childList:!0}),window.addEventListener("resize",n),window.addEventListener("load",n,{once:!0}),i}const u=t=>{window.Domma?.icons?.scan&&window.Domma.icons.scan(t)};function k(t,e){const i=b(t,e);return document.body.appendChild(i),y(i,t)(),i}function L(t,e,i){let o=t.querySelector(".navbar-actions");o||(o=document.createElement("div"),o.className="navbar-actions",(t.querySelector(".navbar-container")||t).appendChild(o));const n=p(e,i,"dm-motion-nav","dm-motion-nav-label");f(n,e.class);let a=null,l=null;const c=()=>{if(getComputedStyle(o).display!=="none"){a?.remove(),n.isConnected||(o.appendChild(n),u(n));return}n.remove(),a||(a=b(e,i),l=y(a,e)),a.isConnected||(document.body.appendChild(a),u(a),l())};return c(),window.addEventListener("resize",c),n.isConnected?n:a}export function mountMotionControl(t,e={}){if(!t||t.enabled===!1||document.getElementById("dm-motion-toggle")||document.getElementById("dm-motion-switch"))return null;const i=reducedMotionOn(t);let o=null;if(t.placement==="footer"){if(!e.footer)return null;o=v(t,i),f(o,t.class),e.footer.appendChild(o)}else t.placement==="navbar"&&e.navbar?o=L(e.navbar,t,i):o=k(t,i);return u(o),o}
1
+ import{applyClasses as u}from"/public/js/css-classes.mjs";const x="(prefers-reduced-motion: reduce)";export function reducedMotionOn(t={}){const e=globalThis.S?.get?.("reduced_motion");return e!=null?!!e:t.default==="on"?!0:t.default==="off"?!1:!!(window.matchMedia&&window.matchMedia(x).matches)}function s(t){globalThis.S?.set?.("reduced_motion",t),window.location.reload()}function C(t){const e=document.createElement("span");return e.className="dm-motion-icon",e.setAttribute("data-icon",t?"play":"pause"),e.setAttribute("aria-hidden","true"),e}function v(t,e){const i=t.control==="checkbox",o=document.createElement("input");o.type="checkbox",o.className=i?"footer-motion-checkbox":"form-switch-input",o.id="dm-motion-switch",o.checked=e,o.addEventListener("change",()=>s(o.checked));const n=document.createElement("span");n.className=i?"footer-motion-label":"form-switch-label",n.textContent=t.label;const a=document.createElement("label");return a.className=i?"footer-motion-check":"form-switch footer-motion-switch",a.title=t.label,a.append(o,n),a}function p(t,e,i,o){const n=document.createElement("button");if(n.type="button",n.className=i,n.id="dm-motion-toggle",n.setAttribute("aria-pressed",String(e)),n.setAttribute("aria-label",t.label),n.title=e?`${t.label}: on`:`${t.label}: off`,n.appendChild(C(e)),t.triggerStyle==="icon-text"){const a=document.createElement("span");a.className=o,a.textContent=t.label,n.appendChild(a)}return n.addEventListener("click",()=>s(!e)),n}const h=[".site-search-floating-trigger","#back-to-top-btn","#go-to-bottom-btn",".dm-theme-switcher:not(.dm-ts-inline)","nav.dm-breadcrumbs",".dm-launcher"].join(","),r=12;function E(t){const e=t.getBoundingClientRect();if(getComputedStyle(t).opacity!=="0"||t.offsetParent!==null)return e;const i=Math.min(e.top,t.offsetTop),o=Math.min(e.left,t.offsetLeft);return{top:i,left:o,right:Math.max(e.right,t.offsetLeft+t.offsetWidth),bottom:Math.max(e.bottom,t.offsetTop+t.offsetHeight),width:e.width,height:e.height}}const S=(t,e)=>t.left<e.right+r&&e.left<t.right+r&&t.top<e.bottom+r&&e.top<t.bottom+r;function g(t,e){const i=e.position==="TL"||e.position==="BL",o=e.position==="TL"||e.position==="TR";t.style.left=i?`${e.offsetX}px`:"auto",t.style.right=i?"auto":`${e.offsetX}px`;let n=e.offsetY;const a=()=>{t.style.top=o?`${n}px`:"auto",t.style.bottom=o?"auto":`${n}px`};a();const l=[...document.querySelectorAll(h)].filter(c=>c!==t&&getComputedStyle(c).position==="fixed"&&getComputedStyle(c).display!=="none");for(let c=0;c<l.length+1;c++){const w=t.getBoundingClientRect(),d=l.map(E).find(m=>m.width&&m.height&&S(w,m));if(!d)break;n=Math.round(o?d.bottom+r:window.innerHeight-d.top+r),a()}}function b(t,e){const i=t.triggerStyle==="icon-text",o=p(t,e,`dm-motion-fab${i?" dm-motion-fab--pill":""}`,"dm-motion-fab-label");return i||(o.style.width=`${t.iconSize}px`,o.style.height=`${t.iconSize}px`,o.style.borderRadius=`${t.iconRadius}px`,o.style.setProperty("--dm-motion-glyph",`${Math.round(t.iconSize*20/52)}px`)),u(o,t.class),o}function y(t,e){const i=()=>{t.isConnected&&g(t,e)};let o=0;const n=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(i)};return new MutationObserver(a=>{a.some(l=>[...l.addedNodes].some(c=>c.nodeType===1&&c.matches?.(h)))&&n()}).observe(document.body,{childList:!0}),window.addEventListener("resize",n),window.addEventListener("load",n,{once:!0}),i}const f=t=>{window.Domma?.icons?.scan&&window.Domma.icons.scan(t)};function k(t,e){const i=b(t,e);return document.body.appendChild(i),y(i,t)(),i}function L(t,e,i){let o=t.querySelector(".navbar-actions");o||(o=document.createElement("div"),o.className="navbar-actions",(t.querySelector(".navbar-container")||t).appendChild(o));const n=p(e,i,"dm-motion-nav","dm-motion-nav-label");u(n,e.class);let a=null,l=null;const c=()=>{if(getComputedStyle(o).display!=="none"){a?.remove(),n.isConnected||(o.appendChild(n),f(n));return}n.remove(),a||(a=b(e,i),l=y(a,e)),a.isConnected||(document.body.appendChild(a),f(a),l())};return c(),window.addEventListener("resize",c),n.isConnected?n:a}export function mountMotionControl(t,e={}){if(!t||t.enabled===!1||document.getElementById("dm-motion-toggle")||document.getElementById("dm-motion-switch"))return null;const i=reducedMotionOn(t);let o=null;if(t.placement==="footer"){if(!e.footer)return null;o=v(t,i),u(o,t.class),e.footer.appendChild(o)}else t.placement==="navbar"&&e.navbar?o=L(e.navbar,t,i):o=k(t,i);return f(o),o}
package/public/js/site.js CHANGED
@@ -1 +1 @@
1
- import{applyMobileMenu as ae,initCarouselPopup as se}from"/public/js/mobile-ui.mjs?v=20261016-mobile-options";import{installSmoothCarets as ie}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 re,applyFloat as ce,applyHighlight as Y,applyItemHighlight as le,itemHighlightAttrs as de,isCurrentItem as K,menuAlign as me,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{applyMenuLook as ue,applyFooterLook as pe}from"/public/js/menu-cards.mjs?v=20261029-footer-bars";import{initPageMotion as fe}from"/public/js/page-motion.mjs?v=20261029-page-motion";import{applyFooterShowcase as he}from"/public/js/footer-showcase.mjs?v=20261029-footer-showcase";import{initFloatingMenus as ge}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 ye}from"/public/js/form-steps.mjs";import{mountMotionControl as ve}from"/public/js/motion-control.mjs?v=20261029-motion-under-switcher";import{applyFormClasses as te,applyFormEntrance as oe,applySubmitButtons as be,applyWizardButtons as we}from"/public/js/form-submit.mjs";import{captureFileFields as ne,destroyDropzones as Ce,fileBlueprint as Se,restoreFileFields as xe,setFileLimits as ke,splitFiles as Le,submitBody as $e,totalTooLarge as Ee,wireFileFields as Ae}from"/public/js/form-files.mjs";document.addEventListener("click",m=>{const i=m.target?.closest?.(".dm-banner__dismiss");i&&(m.preventDefault(),i.closest(".dm-banner")?.remove())}),$(()=>{ie(document);const m=window.__CMS_NAV__||{},i=window.__CMS_SITE__||{},D=i.brandingEnabled!==!1&&m.brand?.enabled!==!1;if(i.autoTheme?.enabled){let o=function(r){const d=(r||"07:00").split(":");return+d[0]*60+(+d[1]||0)},e=function(){const r=new Date,d=r.getHours()*60+r.getMinutes();return d>=o(s.dayStart)&&d<o(s.nightStart)?s.dayTheme:s.nightTheme},t=function(r){const d=s.apply&&s.apply[r]||{theme:r,custom:""};Domma.theme.set(d.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);d.custom&&document.body.classList.add(d.custom)};const s=i.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const L=$("#site-navbar");if(L.length&&m.brand){let e=function(u,f=0){return Array.isArray(u)?u.filter(h=>!(h&&(h.type==="spacer"||h.type==="theme-switcher"))).filter(h=>!(h&&h.type==="separator"&&f===0)).map(h=>h&&h.type==="separator"?{divider:!0}:Array.isArray(h?.items)?{...h,items:e(h.items,f+1)}:h):u};const s={...m.brand},o=s.size&&s.size!=="md"?` navbar-brand-${s.size}`:"";if(s.logo||s.icon||s.tagline){let u="";s.logo?u+=`<img src="${s.logo}" class="navbar-brand-logo" alt="${s.text||""}">`:s.icon&&(u+=`<span data-icon="${s.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),s.text&&(u+=`<span class="navbar-brand-text${o}">${s.text}</span>`),s.tagline&&(u+=`<small class="navbar-brand-tagline">${s.tagline}</small>`),s.html=u}else o&&s.text&&(s.html=`<span class="navbar-brand-text${o}">${s.text}</span>`);const t=e(m.items||[]),r=m.position==="floating",d=m.orientation==="vertical";L.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:D?s:null,items:t,variant:m.variant||"dark",position:r?"static":m.position||"sticky",collapsible:!0,appearOnHover:!!m.appearOnHover}),Domma.icons.scan("#site-navbar");const n=L.get(0);ae(n,m.mobile);const y=()=>{if(!d)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-${me(m)||"centre"}`),d&&L.get(0).classList.add("dm-nav-vertical",m.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const g=m.dock||{};d&&!r&&Te(n,m.side==="right"),!d&&g.hideOnScroll&&_e(n),Y(n,m),J(n,m),P(n,m.class),r&&(ce(L.get(0),m),ge(L.get(0).parentNode||document));const l=n.querySelector(".navbar-toggle"),b=n.querySelector(".navbar-collapse");if(l&&b){let u=null;const f=()=>{b.classList.contains("show")&&l.click()},h=()=>{u&&(u.remove(),u=null),document.body.classList.remove("dm-drawer-open")},p=()=>{u||(u=document.createElement("div"),u.className="dm-navbar-backdrop",u.addEventListener("click",f),document.body.appendChild(u),document.body.classList.add("dm-drawer-open"))};l.addEventListener("click",()=>{requestAnimationFrame(()=>{b.classList.contains("show")?(y(),p()):h()})}),b.addEventListener("click",x=>{x.target.closest("a")&&requestAnimationFrame(h)}),document.addEventListener("keydown",x=>{x.key==="Escape"&&b.classList.contains("show")&&f()})}const w=n.querySelector(".navbar-nav");if(w){const u=Array.from(w.children);let f=0;for(const h of m.items||[])if(!(h&&h.type==="separator")){if(h&&h.type==="spacer"){const p=document.createElement("li"),x=["xs","sm","md","lg","xl","flex"].includes(h.size)?h.size:"md";p.className=`dm-menu-spacer dm-menu-spacer--${x}`,p.setAttribute("aria-hidden","true"),w.insertBefore(p,u[f]||null);continue}if(h&&h.type==="theme-switcher"){const p=document.createElement("li");p.className="dm-menu-theme-switcher";const x=document.createElement("span");x.dataset.themeSwitcher="menu",x.dataset.position="inline",p.appendChild(x),w.insertBefore(p,u[f]||null);continue}f++}window.CMSThemeSwitcher?.scan(w)}n.querySelectorAll("[data-path]").forEach(u=>{const f=u.dataset.path.split(".").map(Number),h=f.length>1,p=f.reduce((M,N)=>M?.items?.[N],{items:t});if(!p)return;p.colour&&G(u,p.colour),p.pill&&!h&&re(u,p.pill),le(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"))}),ue(n,m,t),y()}let I=null;const C=$("#site-footer");if(C.length){let r=function(c){return String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},d=function(c){return r(c).replace(/'/g,"&#39;")},n=function(c){if(c&&c.type==="separator")return'<li class="footer-sep"><hr></li>';if(c&&c.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(c.size)?c.size:"md"}" aria-hidden="true"></li>`;if(c&&c.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const v=d(c.url||"#"),k=r(c.text||""),q=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",z=de(c),j=[z.hover&&` data-menu-item-hover="${d(z.hover)}"`,z.active&&` data-menu-item-active="${d(z.active)}"`].filter(Boolean).join(""),W=z.accent?` style="--dm-menu-highlight:${d(z.accent)}"`:"",B=X(c.class).join(" ");return`<li${B?` class="${d(B)}"`:""}><a href="${v}"${j}${W}>${k}</a>${q}</li>`},g=function(){if(!i.footer)return"";const c=Object.keys(o).filter(k=>s[k]);if(!c.length)return"";const v=X(i.footer.socialClass).join(" ");return`<div class="footer-social">${c.map(k=>{const{label:q,svg:z}=o[k];return`<a href="${s[k]}" target="_blank" rel="noopener noreferrer" aria-label="${q}" class="footer-social-link${v?` ${d(v)}`:""}">${z}</a>`}).join("")}</div>`},u=function(c){if(!c||c.type==="separator"||c.type==="spacer")return"";if(c.type==="theme-switcher")return`<li class="cms-footer-col">${n(c).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const v=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",k=w(c)?`<span class="cms-footer-col-title">${r(c.text||"")}</span>`:`<a class="cms-footer-col-title" href="${d(c.url||"#")}">${r(c.text||"")}</a>`,q=["cms-footer-col",...X(c.class)].join(" ");return`<li class="${d(q)}">${k}${v}</li>`},p=function(c,v,k=!1){return(c||[]).forEach(q=>{q&&(q.type==="separator"||q.type==="spacer"||q.type==="theme-switcher")||(k&&w(q)||v.push(q),Array.isArray(q.items)&&q.items.length&&p(q.items,v))}),v};const s=i.social||{},o={twitter:{label:"X / Twitter",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.742l7.73-8.835L1.254 2.25H8.08l4.259 5.629L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>'},facebook:{label:"Facebook",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>'},instagram:{label:"Instagram",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>'},linkedin:{label:"LinkedIn",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>'},github:{label:"GitHub",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>'},youtube:{label:"YouTube",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg>'}};let e='<div class="footer-inner container">';const t=window.__CMS_FOOTER__||{primary:[],legal:[],copyright:""},y=(()=>{const c=i.cookieConsent;if(!c||c.showSettingsLink===!1)return"";const v=k=>(k||[]).some(q=>q&&(q.url==="#cookie-settings"||v(q.items)));return v(t.primary)||v(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${r(c.settingsLinkText||"Cookie settings")}</a></li>`})(),l=["columns","row"].includes(i.footer?.layout)?i.footer.layout:"auto",b=i.footer?.look==="showcase"||l==="columns"||l==="auto"&&t.primary.some(c=>Array.isArray(c?.items)&&c.items.length),w=c=>b&&!c.url&&Array.isArray(c.items)&&c.items.length>0;if(b){const c=m.brand||{},v=D&&(c.text||i.title)||"",k=D?c.logo?`<img src="${d(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="${d(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&&m.brand?.icon&&h.setAttribute("data-icon",m.brand.icon),P(C.get(0),i.footer?.class),b&&he(C.get(0),i);const x=[...p(t.primary,[],!0),...p(t.legal,[])],M=C.get(0).querySelectorAll(".footer-nav a"),N=[];M.forEach((c,v)=>{const k=x[v];if(!k)return;if(N.push({a:c,item:k}),k.icon){const z=document.createElement("span");z.className="cms-footer-ic",z.setAttribute("data-icon",String(k.icon)),z.setAttribute("data-icon-size","15"),z.setAttribute("aria-hidden","true"),c.prepend(z)}k.colour&&G(c,k.colour);const q=U(k.badge);q&&c.appendChild(q),K(k.url,location.pathname)&&(c.classList.add("is-active"),c.setAttribute("aria-current","page"))}),Y(C.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(C.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(C.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(C.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(C.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(C.get(0).querySelector(".footer-nav--legal"),t.legalClass),pe(C.get(0),t,N),I=C.get(0).querySelector(".cms-footer-bottom")||C.get(0).querySelector(".footer-inner")}ve(i.motion||{enabled:i.footer?.showMotionToggle!==!1,default:i.footer?.motionDefault,placement:"footer",control:i.footer?.motionControl,label:"Reduce motion"},{footer:I,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const A=document.getElementById("site-sidebar");A&&qe(A),Domma.icons.scan(),Domma.syntax?.scan&&Domma.syntax.scan();const a=$(".page-body");if(a.length){a.find(".accordion").each(function(){Domma.elements.accordion(this,{allowMultiple:this.dataset.multi==="true"})}),a.find(".tabs").each(function(){Domma.elements.tabs(this)}),a.find(".carousel").each(function(){const o={primary:"--dm-primary",secondary:"--dm-secondary",accent:"--dm-primary",text:"--dm-text",surface:"--dm-surface",background:"--dm-background",success:"--dm-success",warning:"--dm-warning",danger:"--dm-danger",info:"--dm-info"},e=g=>{const l=String(g||"").trim();return l?o[l.toLowerCase()]?`var(${o[l.toLowerCase()]})`:CSS.supports("color",l)?l:"":""},t=e(this.dataset.background),r=e(this.dataset.arrowBackground),d=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),d&&this.style.setProperty("--dm-carousel-arrow-color",d);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),se(this)}),a.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),d=r?new Date(+r[1],+r[2]-1,+r[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(d)?o.duration=Math.max(0,d-Date.now()):this.dataset.duration&&(o.duration=(parseInt(this.dataset.duration,10)||0)*1e3);const n=/^dd:/i.test(e);o.format=n?"hh:mm:ss":e||(o.duration>=36e5?"hh:mm:ss":"mm:ss");const y=this,g=b=>String(b).padStart(2,"0"),l=b=>{const w=Math.max(0,Math.floor(b/1e3)),u=y.querySelector(".dm-timer-time");u&&(u.textContent=`${g(Math.floor(w/86400))}:${g(Math.floor(w%86400/3600))}:${g(Math.floor(w%3600/60))}:${g(w%60)}`)};n&&(o.onTick=l),Domma.elements.timer(this,o),n&&l(o.duration||0)}),a.find("[data-tooltip]:not(.dm-range-slider)").each(function(){Domma.elements.tooltip(this,{content:$(this).data("tooltip"),position:$(this).data("tooltip-position")||"top"})}),a.find(".dm-progression").each(function(){const o=Array.from(this.querySelectorAll(".dm-progression-item")).map(r=>{const d={title:r.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:r.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return r.dataset.date&&(d.date=r.dataset.date),r.dataset.status&&(d.status=r.dataset.status),r.dataset.eventIcon&&(d.icon=r.dataset.eventIcon),r.dataset.entryId&&(d._entryId=r.dataset.entryId),d}),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((d,n)=>{const y=o[n];if(!y)return;const g=d.querySelector(".dm-progression-title");if(y.icon&&g){const b=document.createElement("span");b.dataset.icon=y.icon,b.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",b.setAttribute("aria-hidden","true"),g.prepend(b)}const l=r[y.status];if(l&&g){const b=document.createElement("span");b.className=`badge badge-${l.tone} cms-timeline-status`,b.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const w=document.createElement("span");w.dataset.icon=l.icon,w.dataset.iconSize="14",w.setAttribute("aria-hidden","true"),b.append(w,document.createTextNode(l.label)),g.after(b)}})}Domma.icons.scan(this),o.length&&(this._dmCtx={instance:t,items:o})});try{Domma.effects.reveal(".page-body .hero",{animation:"slide-up",duration:480,threshold:.06,stagger:60,once:!1})}catch{}const s=matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.classList.contains("dm-reduced-motion");document.querySelectorAll(".page-body .row[data-reveal]").forEach(o=>{const e=o.dataset.revealMode||"stagger",t=o.dataset.revealAnimation||"slide-up",r=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),d=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,y=o.dataset.revealDirection==="rtl",g=o.dataset.revealReplay==="true",l=Array.from(o.children);if(s&&t.startsWith("swoosh"))return;const b={"slide-up":"translateY(30px)","slide-down":"translateY(-30px)","slide-left":"translateX(30px)","slide-right":"translateX(-30px)",zoom:"scale(0.85)",flip:"perspective(600px) rotateX(15deg)",swoosh:"translateY(36px) scale(0.96)"},w=p=>t!=="swoosh-sides"?b[t]||"":l.length>1&&p===0?"translateX(-64px) rotate(-1.5deg)":l.length>1&&p===l.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",u=t.startsWith("swoosh"),f=u?"cubic-bezier(.2,.8,.2,1)":"ease",h=(p,x)=>{p.style.opacity="0",p.style.transform=w(x),u&&(p.style.filter="blur(10px)")};l.forEach((p,x)=>{p.style.transition="none",h(p,x)}),o.offsetWidth,l.forEach((p,x)=>{p.style.transition=`opacity ${r}ms ${f}, transform ${r}ms ${f}`+(u?`, filter ${r}ms ${f}`:"");const M=y?l.length-1-x:x;p.style.transitionDelay=e==="stagger"?`${n+M*d}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const p=new IntersectionObserver(x=>{x.forEach(M=>{if(M.isIntersecting){if(M.target.offsetWidth,M.target.style.opacity="1",M.target.style.transform="",u&&(M.target.style.filter=""),!g){p.unobserve(M.target);const N=M.target;N.addEventListener("transitionend",function c(v){v.target!==N||v.propertyName!=="opacity"||(N.removeEventListener("transitionend",c),N.style.transition="",N.style.transitionDelay="")})}}else g&&M.boundingClientRect.top>0&&h(M.target,l.indexOf(M.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});l.forEach(x=>p.observe(x))}))}),fe(document.querySelector(".page-body")||document),a.find(".card[data-collapsible]").each(function(){const o=this.querySelector(".card-header");o&&o.addEventListener("click",()=>this.classList.toggle("is-collapsed"))}),a.find(".dm-so-trigger").each(function(){this.addEventListener("click",()=>{const o=this.dataset.soTarget,e=document.getElementById(o);if(!e)return;const t=E.slideover({title:e.dataset.soTitle||"",size:e.dataset.soSize||"md",position:e.dataset.soPosition||"right"});e.style.display="",t.setContent(e),t.open()})})}if(typeof $.setup=="function"){const s=Object.assign({},window.__CMS_DCONFIG__||{});if(document.querySelectorAll(".dm-page-config[data-config]").forEach(o=>{try{const e=V(o.dataset.config);Object.assign(s,e)}catch{}}),Object.keys(s).length>0){const o={};for(const[e,t]of Object.entries(s)){const r=t?.events?.click,{confirm:d,toast:n,alert:y,prompt:g,...l}=r||{};if(d||n||y||g){$(e).on("click",async function(W){if(W.preventDefault(),d&&!await E.confirm(d))return;let B=null;if(!(g&&(B=await E.prompt(g,{inputPlaceholder:l.promptPlaceholder||"",inputValue:l.promptDefault||""}),B===null))){{const O=$(l.target||this);l.toggleClass&&O.toggleClass(l.toggleClass),l.addClass&&O.addClass(l.addClass),l.removeClass&&O.removeClass(l.removeClass),B!==null&&(l.setText&&O.text(B),l.setVal&&O.val(B),l.setAttr&&O.attr(l.setAttr,B))}l.href&&(window.location.href=l.href),n&&E.toast(n,{type:l.toastType||"success"}),y&&E.alert(y)}});const{target:w,toggleClass:u,addClass:f,removeClass:h,setText:p,setVal:x,setAttr:M,href:N,toastType:c,promptPlaceholder:v,promptDefault:k,...q}=l,z={...t.events};Object.keys(q).length?z.click=w?{target:w,...q}:q:delete z.click;const j={...t,events:z};Object.keys(z).length||delete j.events,Object.keys(j).length&&(o[e]=j)}else o[e]=t}$.setup(o)}}a.length&&R(a.get(0))}),window.wireCTAButtons=R;function R(m){m.querySelectorAll(".dm-cta-trigger").forEach(i=>{i.__ctaWired||(i.__ctaWired=!0,i.addEventListener("click",async()=>{const D=i.dataset.action,L=i.dataset.entry,I=i.dataset.confirm;let C=S.get("auth_token");if(!C){E.toast("Please log in to perform this action.",{type:"warning"});return}if(I&&!await E.confirm(I))return;const A=Array.from(i.childNodes).map(s=>s.cloneNode(!0));i.disabled=!0,i.textContent="Running\u2026";const a=s=>fetch(`/api/actions/${D}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(i.dataset.scope?{entryId:L,scope:i.dataset.scope}:{entryId:L})});try{let s=await a(C);if(s.status===401){const e=S.get("auth_refresh_token");if(e){const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(t.ok){const{token:r}=await t.json();S.set("auth_token",r),C=r,s=await a(C)}}}const o=await s.json().catch(()=>({}));if(!s.ok||o.success===!1)throw new Error(o.error||o.message||`Error ${s.status}`);E.toast(o.message||"Action completed.",{type:"success"})}catch(s){E.toast(s.message||"Action failed.",{type:"error"})}finally{i.disabled=!1,i.textContent="",A.forEach(s=>i.appendChild(s)),Domma.icons.scan(i)}}))})}(function(){const i=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!i.length)return;const D=S.get("auth_token");function L(C,A){const a=document.createElement("div");a.className="dm-collection-display dm-collection-empty";const s=document.createElement("p");if(A){s.appendChild(document.createTextNode("Please "));const o=document.createElement("a");o.href="/login",o.textContent="sign in",s.appendChild(o),s.appendChild(document.createTextNode(" to view your entries."))}else s.textContent=C;return a.appendChild(s),a}function I(C,A){const a=document.createElement("template");a.innerHTML=A||"",C.replaceWith(a.content)}i.forEach(async C=>{const A=C.dataset.collectionAttrs;if(!A)return;if(!D){C.replaceChildren(L("",!0));return}const a=s=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({attrs:A})});try{let s=D,o=await a(s);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const r=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(r.ok){const{token:d}=await r.json();S.set("auth_token",d),s=d,o=await a(s)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));C.replaceChildren(L(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();I(C,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{C.replaceChildren(L("Unable to load entries.",!1))}}),setTimeout(()=>{typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(),typeof Domma<"u"&&Domma.syntax?.scan&&Domma.syntax.scan(),R(document.body)},100)})(),(function(){const i=document.querySelectorAll("[data-collection-table]");!i.length||typeof T>"u"||!T.create||i.forEach(D=>{let L;try{L=V(D.dataset.payload)}catch{return}const{columns:I,rows:C,search:A,sortable:a,exportable:s,pageSize:o,empty:e,ctaConfig:t,slug:r,exportCfg:d}=L;if(!I?.length)return;if(t){const g=I.findIndex(l=>l.key==="_cta");g!==-1&&(I[g]={key:"_cta",title:"",render:(l,b)=>{const w=document.createElement("button");if(w.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,w.dataset.action=t.action||"",t.scope&&(w.dataset.scope=t.scope),w.dataset.entry=b._entryId||"",t.confirm&&(w.dataset.confirm=t.confirm),t.icon){const u=document.createElement("span");u.dataset.icon=t.icon,w.appendChild(u),w.appendChild(document.createTextNode(" "))}return w.appendChild(document.createTextNode(t.label||"Run")),w}})}const n="col-table-"+Math.random().toString(36).slice(2,7),y=document.createElement("div");y.id=n,D.replaceChildren(y),T.create("#"+n,{data:C,columns:I,search:A,sortable:a,exportable:s,pageSize:o,emptyMessage:e}),t&&R(y),D._dmTable={columns:I,rows:C,slug:r,exportCfg:d,render(g){T.create("#"+n,{data:g,columns:I,search:A,sortable:a,exportable:s,pageSize:o,emptyMessage:e}),t&&R(y)}}})})(),(function(){const i=document.querySelectorAll("[data-form-inline]");if(!i.length||typeof F>"u")return;function D(a){const s=a&&a.logic;return!!(s&&(s.visibility||s.requirement))}function L(a,s){const o={};return(a||[]).forEach(e=>{if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const t=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),r=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,d={...e.formConfig||{}};d.span==="full"&&s&&(d.span=s);const n={type:r,required:D(e)?!1:e.required,label:e.label,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{hint:e.helper},...e.tooltip&&{tooltip:e.tooltip},...d}};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"?Se(e,n):n}),o}function I(a){const s={};return(a||[]).forEach(o=>{if(!(!o.name||o.type==="page-break"||o.type==="spacer")&&(o.type==="select"||o.type==="multiselect")&&o.required){const e=(o.options||[])[0];e&&(s[o.name]=typeof e=="object"?e.value:e)}}),s}function C(a,s){(s||[]).forEach(o=>{if(o.type!=="date"||!o.name)return;const e=a.querySelector(`[name="${o.name}"]`);e&&e.type!=="date"&&(e.type="date")})}function A(a,s,o){let e=a.querySelector(".cms-form-message");e||(e=document.createElement("p"),e.className="cms-form-message",a.appendChild(e)),e.textContent=s,e.style.cssText=o?"color:var(--dm-danger);margin-top:.75rem;":"color:var(--dm-success);margin-top:.75rem;"}i.forEach(a=>{let s;try{s=V(a.dataset.formInline)}catch{return}a.querySelector(":scope > .cms-form-embed-summary")?.remove();const o=s.fields||[],e=s.settings||{},t=Number(e.columns)===3?3:2,r=e.layout||"grid",d=o.some(u=>u.type==="page-break"),n=new Map;ke(a,s.fileLimits,n),Ae(a,o);const y=async u=>{if(a.dataset.triggerBlocked==="true"){const f=a._formLogicRuntime,h=f&&f.submitBlock?f.submitBlock().reasons:[];A(a,h.join(" ")||"This form cannot be submitted yet.",!0);const p=new Error("Blocked by a form trigger");throw p.formSubmitFailed=!0,p}try{const f=a.querySelector(".fb-form-honeypot"),h=f?.querySelector('input[type="text"]')||null,p=f?.querySelector('[name="_t"]')||null,x=Object.assign({},u);delete x._t,f?.dataset.hpName&&delete x[f.dataset.hpName],h!==null&&(x._hp=h.value),p!==null&&(x._t=p.value);const M=new Map(n);ne(a,M);const N=Le(x,o,M),c=Ee(a,N.files);if(c){A(a,c,!0);const k=new Error(c);throw k.formSubmitFailed=!0,k}const v=await H.post(`/api/forms/submit/${s.slug}`,N.files.size?$e(N.values,N.files).body:N.values);if(v&&v.error){A(a,v.error,!0);const k=new Error(v.error);throw k.formSubmitFailed=!0,k}if(v?.redirect){window.location.href=v.redirect;return}for(Ce(a);a.firstChild;)a.removeChild(a.firstChild);A(a,v?.message||e.successMessage||"Thank you for your submission.",!1)}catch(f){throw f.formSubmitFailed||A(a,f.message||"Submission failed. Please try again.",!0),f}},g=Date.now();function l(u){const f=u.querySelector("form");if(!f||f.querySelector(".fb-form-honeypot"))return;const h=document.createElement("div");h.className="fb-form-honeypot",h.setAttribute("aria-hidden","true");const p=document.createElement("input");p.name=f.querySelector('[name="website"]')?"_website":"website",h.dataset.hpName=p.name,p.type="text",p.tabIndex=-1,p.autocomplete="url",p.placeholder="https://",h.appendChild(p);const x=document.createElement("input");x.name="_t",x.type="hidden",x.value=g,h.appendChild(x),f.appendChild(h)}function b(u){if(!window.FormLogicEngine||!o.some(h=>h.logic||Array.isArray(h.triggers)&&h.triggers.length))return null;const f=new window.FormLogicEngine.FormLogicRuntime(s,a,u?{baseValues:u}:void 0);if(f.init(),a._formLogicRuntime=f,a._formLogicObserved)return f;if(a._formLogicObserved=!0,a.parentNode&&typeof MutationObserver<"u"){const h=new MutationObserver(function(p){for(const x of p)for(const M of x.removedNodes)if(M===a||M.nodeType===1&&M.contains&&M.contains(a)){a._formLogicRuntime&&a._formLogicRuntime.destroy(),h.disconnect();return}});h.observe(a.parentNode,{childList:!0,subtree:!1}),a._formLogicObserver=h}return f}let w=!1;if(a.addEventListener("dm-form-end",u=>{const f=u.detail?.validation;if(f&&!f.valid){Z(a,f.missing),ee(f);return}w||(w=!0,y(u.detail?.values||{}).catch(()=>{}).finally(()=>{w=!1}))}),d&&F.wizard){const u=ye(o,s.title),f=u.map(v=>({title:v.title,description:v.description,fields:L(v.fields,t)})),h=u.map(v=>v.fields);let p=0,x=null,M=null;const N=v=>{const k=window.FormLogicEngine;if(!k||!k.validateFields)return;const q=k.validateFields(a,h[p]||[]);q.valid||(v.preventDefault(),v.stopImmediatePropagation(),Z(a,q.missing),ee(q))},c=()=>{const v=h[p]||o;we(a,e),te(a,e,v),oe(a,e),C(a,v),Q(a,v),xe(a,n),e.honeypot!==!1&&l(a),x&&x.destroy(),x=b(M?.getStepData?M.getStepData():void 0),a.querySelectorAll(".wizard-next, .wizard-submit").forEach(k=>k.addEventListener("click",N,!0))};M=F.wizard(a,{schema:{steps:f},layout:r,columns:t,finishText:e.submitText||"Finish",onSubmit:y,onStepChange:v=>{ne(a,n),p=v,setTimeout(c,0)}}),a.addEventListener("dm-form-trigger",v=>{if(v.detail?.type!=="goto-step"||!M?.goToStep)return;const k=Number(v.detail.action.step);!Number.isFinite(k)||k<0||k>=f.length||k!==p&&M.goToStep(k)}),Promise.resolve(M).then(c)}else if(F.render){const u=F.render(a,L(o,t),I(o),{submitText:e.submitText||"Submit",layout:r,columns:t,onSubmit:y});Promise.resolve(u).then(function(){be(a,e,r),te(a,e,o),oe(a,e),C(a,o),Q(a,o),e.honeypot!==!1&&l(a),b()})}})})();function Te(m,i){const D=document.body,L=D.classList,I=new Set((D.dataset.railSite||"").split(" ").filter(Boolean)),C=()=>window.matchMedia("(min-width: 993px)").matches;m.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const r=t.textContent.trim();r&&(t.setAttribute("title",r),t.querySelector("svg, [data-icon]")||(t.dataset.initial=r.charAt(0).toUpperCase()))});const A=document.createElement("button");A.type="button",A.className="dm-nav-collapse-toggle";const a=()=>{const t=L.contains("dm-vnav-collapsed");A.setAttribute("aria-pressed",String(t)),A.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),A.title=A.getAttribute("aria-label");const r=i?"chevrons-left":"chevrons-right",d=i?"chevrons-right":"chevrons-left";A.innerHTML=`<span data-icon="${t?r:d}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(A)},s=t=>{L.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),a()};A.addEventListener("click",()=>s(!L.contains("dm-vnav-collapsed"))),a();const o=m.querySelector(".navbar-container")||m;o.insertBefore(A,o.firstChild?.nextSibling||null);const e=t=>{L.toggle("dm-vnav-autohide",t),L.toggle("dm-vnav-collapsible",!t&&I.has("collapsible")),t?L.remove("dm-vnav-collapsed"):I.has("collapsible")&&S.get("nav_collapsed")===!0&&L.add("dm-vnav-collapsed"),m.classList.remove("dm-nav-revealed"),a()};m.addEventListener("pointerdown",t=>{L.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!m.classList.contains("dm-nav-revealed")&&(m.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{m.contains(t.target)||m.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(m,{items:()=>{const t=L.contains("dm-vnav-autohide"),r=L.contains("dm-vnav-collapsed"),d=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:r?"Expand menu":"Collapse to icons",icon:r?"maximize":"minimize",disabled:!C()||t||!I.has("collapsible"),action:()=>s(!r)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!C(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!d,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(I.has("autohide")),L.toggle("dm-vnav-collapsed",!I.has("autohide")&&I.has("start-collapsed")),a()}}]}})}function _e(m){m.classList.add("dm-nav-scroll-hide");let i=window.scrollY,D=!1;window.addEventListener("scroll",()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const L=window.scrollY,I=m.matches(":focus-within")||m.querySelector(".navbar-dropdown.open, .navbar-collapse.show");L>i&&L>m.offsetHeight&&!I?m.classList.add("dm-nav-scrolled-away"):L<i&&m.classList.remove("dm-nav-scrolled-away"),i=L}))},{passive:!0})}function qe(m){let i={};try{i=JSON.parse(m.dataset.contents||"{}")}catch{}const D=m.closest(".site-main"),L=document.querySelector(".site-content"),I=new Set(String(i.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),C=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),A=n=>(L?[...L.querySelectorAll(n)]:[]).filter(C).filter(y=>!I.has(y.textContent.trim().toLowerCase())),a=i.headings==="h2"?A("h2"):i.headings==="h3"?A("h3"):i.headings==="h2h3"?A("h2, h3"):A("h2").length?A("h2"):A("h3");if(!a.length){D?.classList.add("no-sidebar-items");return}const s=new Set([...document.querySelectorAll("[id]")].map(n=>n.id)),o=document.createElement("nav");o.className="dm-contents",o.setAttribute("aria-label",i.title||"Page contents"),i.hover&&(o.dataset.menuHover=i.hover),i.selected&&(o.dataset.menuActive=i.selected),i.accent&&o.style.setProperty("--dm-menu-highlight",i.accent.startsWith("#")?i.accent:`var(--dm-${i.accent})`),i.font&&(o.style.fontFamily=i.font),i.fontSize&&(o.style.fontSize=i.fontSize),i.fontWeight&&(o.style.fontWeight=i.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=i.title||"",e.appendChild(t),o.appendChild(e);const r=document.createElement("ol");r.className="dm-contents-list"+(i.numbered?" is-numbered":"");const d=[];for(const n of a){if(!n.id){const l=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let b=l;for(let w=2;s.has(b);w++)b=`${l}-${w}`;s.add(b),n.id=b}const y=document.createElement("li");y.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const g=document.createElement("a");g.href=`#${n.id}`,g.textContent=n.textContent.trim(),y.appendChild(g),r.appendChild(y),d.push([n,g])}if(o.appendChild(r),m.replaceChildren(o),i.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,y=()=>{const l=d.find(([b])=>n.get(b))||null;d.forEach(([,b])=>{const w=l&&b===l[1];b.classList.toggle("is-active",!!w),w?b.setAttribute("aria-current","location"):b.removeAttribute("aria-current")})},g=new IntersectionObserver(l=>{l.forEach(b=>n.set(b.target,b.isIntersecting)),y()},{rootMargin:"-80px 0px -60% 0px"});d.forEach(([l])=>g.observe(l))}if(D?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const y=()=>{const g=D.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!g)),n.setAttribute("aria-label",g?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${g?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",D.classList.toggle("contents-collapsed")),y()}),y(),e.insertBefore(n,e.firstChild)}if(D?.classList.contains("contents-floating")&&i.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(m.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=m.getBoundingClientRect(),l=y.clientX-g.left,b=y.clientY-g.top,w=f=>{const h=Math.max(0,Math.min(window.innerWidth-g.width,f.clientX-l)),p=Math.max(0,Math.min(window.innerHeight-40,f.clientY-b));Object.assign(m.style,{left:`${h}px`,top:`${p}px`,right:"auto",bottom:"auto"})},u=()=>{document.removeEventListener("pointermove",w),S.set("contents_position",{x:parseInt(m.style.left,10),y:parseInt(m.style.top,10)})};document.addEventListener("pointermove",w),document.addEventListener("pointerup",u,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(m,{items:()=>{const n=D?.classList.contains("contents-collapsible"),y=D?.classList.contains("contents-collapsed"),g=d.find(([,l])=>l.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:y?"Show the contents":"Collapse to a button",icon:y?"list":"minimize",action:()=>m.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!g,action:async()=>{const l=`${location.origin}${location.pathname}#${g[0].id}`;try{await _.copyToClipboard(l),E.toast("Link copied.",{type:"success"})}catch{E.toast("Could not copy the link.",{type:"error"})}}},{label:"Back to the top",icon:"arrow-up",action:()=>window.scrollTo({top:0,behavior:"smooth"})}]}}),D?.classList.contains("contents-autohide")&&(m.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!m.classList.contains("is-revealed")&&(m.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{m.contains(n.target)||m.classList.remove("is-revealed")}))}
1
+ import{applyMobileMenu as se,initCarouselPopup as ie}from"/public/js/mobile-ui.mjs?v=20261016-mobile-options";import{installSmoothCarets as re}from"/public/js/smooth-caret.js";import{decodeBase64Json as V}from"/public/js/utf8-base64.mjs";import{makeBadgeEl as U,applyColour as G,applyPill as ce,applyFloat as le,applyHighlight as Y,applyItemHighlight as de,itemHighlightAttrs as me,isCurrentItem as K,menuAlign as ue,applyClasses as P,cssClasses as X,applyEntrance as J}from"/public/js/menu-decor.mjs?v=20261014-menu-entrance";import{applyMenuLook as pe,applyFooterLook as fe}from"/public/js/menu-cards.mjs?v=20261029-footer-bars";import{initPageMotion as he}from"/public/js/page-motion.mjs?v=20261029-page-motion";import{applyFooterShowcase as ge}from"/public/js/footer-showcase.mjs?v=20261029-footer-showcase";import{initFloatingMenus as ye}from"/public/js/menu-float.js?v=20260829-float-panel";import{enhancePickerFields as Q,markInvalidFields as Z,showValidationPopup as ee}from"/public/js/forms.js?v=20261031-form-entrance-forms";import{buildWizardSteps as ve}from"/public/js/form-steps.mjs";import{mountMotionControl as be}from"/public/js/motion-control.mjs?v=20261031-launchers";import{applyFormClasses as te,applyFormEntrance as oe,applySubmitButtons as we,applyWizardButtons as Ce}from"/public/js/form-submit.mjs";import{captureFileFields as ne,destroyDropzones as Se,fileBlueprint as xe,restoreFileFields as ke,setFileLimits as Le,splitFiles as $e,submitBody as Ee,totalTooLarge as Ae,wireFileFields as Te}from"/public/js/form-files.mjs";document.addEventListener("click",d=>{const i=d.target?.closest?.(".dm-banner__dismiss");i&&(d.preventDefault(),i.closest(".dm-banner")?.remove())}),$(()=>{re(document);const d=window.__CMS_NAV__||{},i=window.__CMS_SITE__||{},D=i.brandingEnabled!==!1&&d.brand?.enabled!==!1;if(i.autoTheme?.enabled){let o=function(r){const m=(r||"07:00").split(":");return+m[0]*60+(+m[1]||0)},e=function(){const r=new Date,m=r.getHours()*60+r.getMinutes();return m>=o(s.dayStart)&&m<o(s.nightStart)?s.dayTheme:s.nightTheme},t=function(r){const m=s.apply&&s.apply[r]||{theme:r,custom:""};Domma.theme.set(m.theme);for(const n of[...document.body.classList])n.startsWith("dm-custom-")&&document.body.classList.remove(n);m.custom&&document.body.classList.add(m.custom)};const s=i.autoTheme;t(e()),setInterval(()=>t(e()),6e4)}const L=$("#site-navbar");if(L.length&&d.brand){let e=function(u,f=0){return Array.isArray(u)?u.filter(h=>!(h&&(h.type==="spacer"||h.type==="theme-switcher"))).filter(h=>!(h&&h.type==="separator"&&f===0)).map(h=>h&&h.type==="separator"?{divider:!0}:Array.isArray(h?.items)?{...h,items:e(h.items,f+1)}:h):u};const s={...d.brand},o=s.size&&s.size!=="md"?` navbar-brand-${s.size}`:"";if(s.logo||s.icon||s.tagline){let u="";s.logo?u+=`<img src="${s.logo}" class="navbar-brand-logo" alt="${s.text||""}">`:s.icon&&(u+=`<span data-icon="${s.icon}" style="width:1.1em;height:1.1em;margin-right:.35em;vertical-align:middle;"></span>`),s.text&&(u+=`<span class="navbar-brand-text${o}">${s.text}</span>`),s.tagline&&(u+=`<small class="navbar-brand-tagline">${s.tagline}</small>`),s.html=u}else o&&s.text&&(s.html=`<span class="navbar-brand-text${o}">${s.text}</span>`);const t=e(d.items||[]),r=d.position==="floating",m=d.orientation==="vertical";L.get(0).querySelector(":scope > .cms-nojs-links")?.remove(),Domma.elements.navbar("#site-navbar",{brand:D?s:null,items:t,variant:d.variant||"dark",position:r?"static":d.position||"sticky",collapsible:!0,appearOnHover:!!d.appearOnHover}),Domma.icons.scan("#site-navbar");const n=L.get(0);se(n,d.mobile);const y=()=>{if(!m)return;const f=n.querySelector('a[aria-current="page"]')?.closest(".navbar-dropdown");f&&!f.classList.contains("open")&&f.querySelector(":scope > .navbar-dropdown-toggle")?.click()};n.classList.add(`dm-nav-align-${ue(d)||"centre"}`),m&&L.get(0).classList.add("dm-nav-vertical",d.side==="right"?"dm-nav-vertical-right":"dm-nav-vertical-left");const g=d.dock||{};m&&!r&&_e(n,d.side==="right"),!m&&g.hideOnScroll&&qe(n),Y(n,d),J(n,d),P(n,d.class),r&&(le(L.get(0),d),ye(L.get(0).parentNode||document));const l=n.querySelector(".navbar-toggle"),b=n.querySelector(".navbar-collapse");if(l&&b){let u=null;const f=()=>{b.classList.contains("show")&&l.click()},h=()=>{u&&(u.remove(),u=null),document.body.classList.remove("dm-drawer-open")},p=()=>{u||(u=document.createElement("div"),u.className="dm-navbar-backdrop",u.addEventListener("click",f),document.body.appendChild(u),document.body.classList.add("dm-drawer-open"))};l.addEventListener("click",()=>{requestAnimationFrame(()=>{b.classList.contains("show")?(y(),p()):h()})}),b.addEventListener("click",x=>{x.target.closest("a")&&requestAnimationFrame(h)}),document.addEventListener("keydown",x=>{x.key==="Escape"&&b.classList.contains("show")&&f()})}const w=n.querySelector(".navbar-nav");if(w){const u=Array.from(w.children);let f=0;for(const h of d.items||[])if(!(h&&h.type==="separator")){if(h&&h.type==="spacer"){const p=document.createElement("li"),x=["xs","sm","md","lg","xl","flex"].includes(h.size)?h.size:"md";p.className=`dm-menu-spacer dm-menu-spacer--${x}`,p.setAttribute("aria-hidden","true"),w.insertBefore(p,u[f]||null);continue}if(h&&h.type==="theme-switcher"){const p=document.createElement("li");p.className="dm-menu-theme-switcher";const x=document.createElement("span");x.dataset.themeSwitcher="menu",x.dataset.position="inline",p.appendChild(x),w.insertBefore(p,u[f]||null);continue}f++}window.CMSThemeSwitcher?.scan(w)}n.querySelectorAll("[data-path]").forEach(u=>{const f=u.dataset.path.split(".").map(Number),h=f.length>1,p=f.reduce((M,N)=>M?.items?.[N],{items:t});if(!p)return;p.colour&&G(u,p.colour),p.pill&&!h&&ce(u,p.pill),de(u,p),P(u.closest("li"),p.class);const x=U(p.badge);x&&u.appendChild(x),K(p.url,location.pathname)&&(u.classList.add("active"),u.setAttribute("aria-current","page"))}),pe(n,d,t),y()}let I=null;const C=$("#site-footer");if(C.length){let r=function(c){return String(c??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},m=function(c){return r(c).replace(/'/g,"&#39;")},n=function(c){if(c&&c.type==="separator")return'<li class="footer-sep"><hr></li>';if(c&&c.type==="spacer")return`<li class="dm-menu-spacer dm-menu-spacer--${["xs","sm","md","lg","xl","flex"].includes(c.size)?c.size:"md"}" aria-hidden="true"></li>`;if(c&&c.type==="theme-switcher")return'<li class="dm-menu-theme-switcher"><span data-theme-switcher="menu" data-position="inline"></span></li>';const v=m(c.url||"#"),k=r(c.text||""),q=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",z=me(c),j=[z.hover&&` data-menu-item-hover="${m(z.hover)}"`,z.active&&` data-menu-item-active="${m(z.active)}"`].filter(Boolean).join(""),W=z.accent?` style="--dm-menu-highlight:${m(z.accent)}"`:"",B=X(c.class).join(" ");return`<li${B?` class="${m(B)}"`:""}><a href="${v}"${j}${W}>${k}</a>${q}</li>`},g=function(){if(!i.footer)return"";const c=Object.keys(o).filter(k=>s[k]);if(!c.length)return"";const v=X(i.footer.socialClass).join(" ");return`<div class="footer-social">${c.map(k=>{const{label:q,svg:z}=o[k];return`<a href="${s[k]}" target="_blank" rel="noopener noreferrer" aria-label="${q}" class="footer-social-link${v?` ${m(v)}`:""}">${z}</a>`}).join("")}</div>`},u=function(c){if(!c||c.type==="separator"||c.type==="spacer")return"";if(c.type==="theme-switcher")return`<li class="cms-footer-col">${n(c).replace(/^<li[^>]*>|<\/li>$/g,"")}</li>`;const v=Array.isArray(c.items)&&c.items.length?`<ul>${c.items.map(n).join("")}</ul>`:"",k=w(c)?`<span class="cms-footer-col-title">${r(c.text||"")}</span>`:`<a class="cms-footer-col-title" href="${m(c.url||"#")}">${r(c.text||"")}</a>`,q=["cms-footer-col",...X(c.class)].join(" ");return`<li class="${m(q)}">${k}${v}</li>`},p=function(c,v,k=!1){return(c||[]).forEach(q=>{q&&(q.type==="separator"||q.type==="spacer"||q.type==="theme-switcher")||(k&&w(q)||v.push(q),Array.isArray(q.items)&&q.items.length&&p(q.items,v))}),v};const s=i.social||{},o={twitter:{label:"X / Twitter",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.742l7.73-8.835L1.254 2.25H8.08l4.259 5.629L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>'},facebook:{label:"Facebook",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>'},instagram:{label:"Instagram",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>'},linkedin:{label:"LinkedIn",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>'},github:{label:"GitHub",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>'},youtube:{label:"YouTube",svg:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg>'}};let e='<div class="footer-inner container">';const t=window.__CMS_FOOTER__||{primary:[],legal:[],copyright:""},y=(()=>{const c=i.cookieConsent;if(!c||c.showSettingsLink===!1)return"";const v=k=>(k||[]).some(q=>q&&(q.url==="#cookie-settings"||v(q.items)));return v(t.primary)||v(t.legal)?"":`<li class="cms-cookie-settings"><a href="#cookie-settings">${r(c.settingsLinkText||"Cookie settings")}</a></li>`})(),l=["columns","row"].includes(i.footer?.layout)?i.footer.layout:"auto",b=i.footer?.look==="showcase"||l==="columns"||l==="auto"&&t.primary.some(c=>Array.isArray(c?.items)&&c.items.length),w=c=>b&&!c.url&&Array.isArray(c.items)&&c.items.length>0;if(b){const c=d.brand||{},v=D&&(c.text||i.title)||"",k=D?c.logo?`<img src="${m(c.logo)}" class="cms-footer-brand-logo" alt="">`:c.icon?'<span class="cms-footer-brand-icon"></span>':"":"",q=String(i.footer?.blurb||"").trim();e='<div class="footer-inner footer-inner--columns container"><div class="cms-footer-top">',e+=`<div class="cms-footer-brand">${v||k?`<a class="cms-footer-brand-name" href="${m(c.url||"/")}">${k}<span>${r(v)}</span></a>`:""}${q?`<p class="cms-footer-blurb">${r(q)}</p>`:""}${g()}</div>`,t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary footer-nav--columns" aria-label="Footer"><ul>${t.primary.map(u).join("")}</ul></nav>`),e+='</div><div class="cms-footer-bottom">',t.copyright&&(e+=`<p class="cms-footer-copyright">${r(t.copyright)}</p>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal" aria-label="Legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+="</div>"}else t.copyright&&(e+=`<p>${r(t.copyright)}</p>`),t.primary.length&&(e+=`<nav class="footer-nav footer-nav--primary"><ul>${t.primary.map(n).join("")}</ul></nav>`),(t.legal.length||y)&&(e+=`<nav class="footer-nav footer-nav--legal"><ul>${t.legal.map(n).join("")}${y}</ul></nav>`),e+=g();e+="</div>",C.get(0).querySelector(":scope > .cms-nojs-links")?.remove();const f=C.get(0).querySelector(":scope > .cms-footer-blocks");f?.remove(),C.html(e),f&&C.get(0).prepend(f),window.CMSThemeSwitcher?.scan(C.get(0));const h=C.get(0).querySelector(".cms-footer-brand-icon");h&&d.brand?.icon&&h.setAttribute("data-icon",d.brand.icon),P(C.get(0),i.footer?.class),b&&ge(C.get(0),i);const x=[...p(t.primary,[],!0),...p(t.legal,[])],M=C.get(0).querySelectorAll(".footer-nav a"),N=[];M.forEach((c,v)=>{const k=x[v];if(!k)return;if(N.push({a:c,item:k}),k.icon){const z=document.createElement("span");z.className="cms-footer-ic",z.setAttribute("data-icon",String(k.icon)),z.setAttribute("data-icon-size","15"),z.setAttribute("aria-hidden","true"),c.prepend(z)}k.colour&&G(c,k.colour);const q=U(k.badge);q&&c.appendChild(q),K(k.url,location.pathname)&&(c.classList.add("is-active"),c.setAttribute("aria-current","page"))}),Y(C.get(0).querySelector(".footer-nav--primary"),{highlight:t.primaryHighlight}),Y(C.get(0).querySelector(".footer-nav--legal"),{highlight:t.legalHighlight}),J(C.get(0).querySelector(".footer-nav--primary"),{entrance:t.primaryEntrance}),J(C.get(0).querySelector(".footer-nav--legal"),{entrance:t.legalEntrance}),P(C.get(0).querySelector(".footer-nav--primary"),t.primaryClass),P(C.get(0).querySelector(".footer-nav--legal"),t.legalClass),fe(C.get(0),t,N),I=C.get(0).querySelector(".cms-footer-bottom")||C.get(0).querySelector(".footer-inner")}be(i.motion||{enabled:i.footer?.showMotionToggle!==!1,default:i.footer?.motionDefault,placement:"footer",control:i.footer?.motionControl,label:"Reduce motion"},{footer:I,navbar:document.querySelector("#site-navbar .navbar-container")?.closest("#site-navbar")||null});const A=document.getElementById("site-sidebar");A&&Me(A),Domma.icons.scan(),Domma.syntax?.scan&&Domma.syntax.scan();const a=$(".page-body");if(a.length){a.find(".accordion").each(function(){Domma.elements.accordion(this,{allowMultiple:this.dataset.multi==="true"})}),a.find(".tabs").each(function(){Domma.elements.tabs(this)}),a.find(".carousel").each(function(){const o={primary:"--dm-primary",secondary:"--dm-secondary",accent:"--dm-primary",text:"--dm-text",surface:"--dm-surface",background:"--dm-background",success:"--dm-success",warning:"--dm-warning",danger:"--dm-danger",info:"--dm-info"},e=g=>{const l=String(g||"").trim();return l?o[l.toLowerCase()]?`var(${o[l.toLowerCase()]})`:CSS.supports("color",l)?l:"":""},t=e(this.dataset.background),r=e(this.dataset.arrowBackground),m=e(this.dataset.arrowColor);t&&(this.style.setProperty("--dm-carousel-background",t),this.classList.add("dm-carousel-custom-background")),r&&this.style.setProperty("--dm-carousel-arrow-background",r),m&&this.style.setProperty("--dm-carousel-arrow-color",m);const n=["top","middle","bottom"].includes(this.dataset.arrowPosition)?this.dataset.arrowPosition:"middle";this.classList.add(`dm-carousel-arrows-${n}`);const y={autoplay:this.dataset.autoplay==="true",interval:parseInt(this.dataset.interval,10)||5e3,loop:this.dataset.loop!=="false",animation:this.dataset.animation||"slide",heightMode:this.dataset.heightMode==="average"?"average":"crop"};if(this.dataset.height){const g=Number(this.dataset.height);Number.isFinite(g)&&g>0&&(y.height=g)}if(this.dataset.animationDuration){const g=parseInt(this.dataset.animationDuration,10);Number.isFinite(g)&&(y.animationDuration=g)}this.dataset.animationEasing&&(y.animationEasing=this.dataset.animationEasing),this.dataset.ctx&&(this._dmCtxSlides=Array.from(this.querySelectorAll(".carousel-slide")).map(g=>g.cloneNode(!0)),this._dmCarouselOpts=y),this._dmCarousel=Domma.elements.carousel(this,y),ie(this)}),a.find(".dm-countdown").each(function(){const o={autoStart:!0},e=String(this.dataset.format||"").trim(),t=String(this.dataset.to||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t),m=r?new Date(+r[1],+r[2]-1,+r[3]).getTime():t?new Date(t).getTime():NaN;Number.isFinite(m)?o.duration=Math.max(0,m-Date.now()):this.dataset.duration&&(o.duration=(parseInt(this.dataset.duration,10)||0)*1e3);const n=/^dd:/i.test(e);o.format=n?"hh:mm:ss":e||(o.duration>=36e5?"hh:mm:ss":"mm:ss");const y=this,g=b=>String(b).padStart(2,"0"),l=b=>{const w=Math.max(0,Math.floor(b/1e3)),u=y.querySelector(".dm-timer-time");u&&(u.textContent=`${g(Math.floor(w/86400))}:${g(Math.floor(w%86400/3600))}:${g(Math.floor(w%3600/60))}:${g(w%60)}`)};n&&(o.onTick=l),Domma.elements.timer(this,o),n&&l(o.duration||0)}),a.find("[data-tooltip]:not(.dm-range-slider)").each(function(){Domma.elements.tooltip(this,{content:$(this).data("tooltip"),position:$(this).data("tooltip-position")||"top"})}),a.find(".dm-progression").each(function(){const o=Array.from(this.querySelectorAll(".dm-progression-item")).map(r=>{const m={title:r.querySelector(".dm-progression-item-title")?.textContent?.trim()||"",description:r.querySelector(".dm-progression-item-body")?.innerHTML?.trim()||""};return r.dataset.date&&(m.date=r.dataset.date),r.dataset.status&&(m.status=r.dataset.status),r.dataset.eventIcon&&(m.icon=r.dataset.eventIcon),r.dataset.entryId&&(m._entryId=r.dataset.entryId),m}),e=this.dataset.layout==="centred"?"centered":this.dataset.layout||"vertical",t=Domma.elements.progression(this,{layout:e,theme:this.dataset.theme||"minimal",mode:this.dataset.mode||"timeline",statusIcons:!0,allowHtml:!0,...o.length?{items:o}:{}});if((this.dataset.mode||"timeline")==="timeline"){const r={completed:{label:"Completed",icon:"check-circle",tone:"success"},planned:{label:"Planned",icon:"circle",tone:"secondary"},"in-progress":{label:"In progress",icon:"clock",tone:"primary"},blocked:{label:"Blocked",icon:"alert-circle",tone:"danger"}};this.querySelectorAll(".dm-progression-item").forEach((m,n)=>{const y=o[n];if(!y)return;const g=m.querySelector(".dm-progression-title");if(y.icon&&g){const b=document.createElement("span");b.dataset.icon=y.icon,b.style.cssText="display:inline-flex;vertical-align:middle;margin-right:.4em",b.setAttribute("aria-hidden","true"),g.prepend(b)}const l=r[y.status];if(l&&g){const b=document.createElement("span");b.className=`badge badge-${l.tone} cms-timeline-status`,b.style.cssText="display:inline-flex;align-items:center;gap:.35em;margin:.4rem 0";const w=document.createElement("span");w.dataset.icon=l.icon,w.dataset.iconSize="14",w.setAttribute("aria-hidden","true"),b.append(w,document.createTextNode(l.label)),g.after(b)}})}Domma.icons.scan(this),o.length&&(this._dmCtx={instance:t,items:o})});try{Domma.effects.reveal(".page-body .hero",{animation:"slide-up",duration:480,threshold:.06,stagger:60,once:!1})}catch{}const s=matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.classList.contains("dm-reduced-motion");document.querySelectorAll(".page-body .row[data-reveal]").forEach(o=>{const e=o.dataset.revealMode||"stagger",t=o.dataset.revealAnimation||"slide-up",r=parseInt(o.dataset.revealDuration,10)||(t.startsWith("swoosh")?700:400),m=parseInt(o.dataset.revealStagger,10)||(t.startsWith("swoosh")?90:60),n=parseInt(o.dataset.revealDelay,10)||0,y=o.dataset.revealDirection==="rtl",g=o.dataset.revealReplay==="true",l=Array.from(o.children);if(s&&t.startsWith("swoosh"))return;const b={"slide-up":"translateY(30px)","slide-down":"translateY(-30px)","slide-left":"translateX(30px)","slide-right":"translateX(-30px)",zoom:"scale(0.85)",flip:"perspective(600px) rotateX(15deg)",swoosh:"translateY(36px) scale(0.96)"},w=p=>t!=="swoosh-sides"?b[t]||"":l.length>1&&p===0?"translateX(-64px) rotate(-1.5deg)":l.length>1&&p===l.length-1?"translateX(64px) rotate(1.5deg)":"translateY(40px) scale(0.94)",u=t.startsWith("swoosh"),f=u?"cubic-bezier(.2,.8,.2,1)":"ease",h=(p,x)=>{p.style.opacity="0",p.style.transform=w(x),u&&(p.style.filter="blur(10px)")};l.forEach((p,x)=>{p.style.transition="none",h(p,x)}),o.offsetWidth,l.forEach((p,x)=>{p.style.transition=`opacity ${r}ms ${f}, transform ${r}ms ${f}`+(u?`, filter ${r}ms ${f}`:"");const M=y?l.length-1-x:x;p.style.transitionDelay=e==="stagger"?`${n+M*m}ms`:`${n}ms`}),requestAnimationFrame(()=>requestAnimationFrame(()=>{const p=new IntersectionObserver(x=>{x.forEach(M=>{if(M.isIntersecting){if(M.target.offsetWidth,M.target.style.opacity="1",M.target.style.transform="",u&&(M.target.style.filter=""),!g){p.unobserve(M.target);const N=M.target;N.addEventListener("transitionend",function c(v){v.target!==N||v.propertyName!=="opacity"||(N.removeEventListener("transitionend",c),N.style.transition="",N.style.transitionDelay="")})}}else g&&M.boundingClientRect.top>0&&h(M.target,l.indexOf(M.target))})},{threshold:.1,rootMargin:"100000px 0px 0px 0px"});l.forEach(x=>p.observe(x))}))}),he(document.querySelector(".page-body")||document),a.find(".card[data-collapsible]").each(function(){const o=this.querySelector(".card-header");o&&o.addEventListener("click",()=>this.classList.toggle("is-collapsed"))}),a.find(".dm-so-trigger").each(function(){this.addEventListener("click",()=>{const o=this.dataset.soTarget,e=document.getElementById(o);if(!e)return;const t=E.slideover({title:e.dataset.soTitle||"",size:e.dataset.soSize||"md",position:e.dataset.soPosition||"right"});e.style.display="",t.setContent(e),t.open()})})}if(typeof $.setup=="function"){const s=Object.assign({},window.__CMS_DCONFIG__||{});if(document.querySelectorAll(".dm-page-config[data-config]").forEach(o=>{try{const e=V(o.dataset.config);Object.assign(s,e)}catch{}}),Object.keys(s).length>0){const o={};for(const[e,t]of Object.entries(s)){const r=t?.events?.click,{confirm:m,toast:n,alert:y,prompt:g,...l}=r||{};if(m||n||y||g){$(e).on("click",async function(W){if(W.preventDefault(),m&&!await E.confirm(m))return;let B=null;if(!(g&&(B=await E.prompt(g,{inputPlaceholder:l.promptPlaceholder||"",inputValue:l.promptDefault||""}),B===null))){{const O=$(l.target||this);l.toggleClass&&O.toggleClass(l.toggleClass),l.addClass&&O.addClass(l.addClass),l.removeClass&&O.removeClass(l.removeClass),B!==null&&(l.setText&&O.text(B),l.setVal&&O.val(B),l.setAttr&&O.attr(l.setAttr,B))}l.href&&ae(l.href),n&&E.toast(n,{type:l.toastType||"success"}),y&&E.alert(y)}});const{target:w,toggleClass:u,addClass:f,removeClass:h,setText:p,setVal:x,setAttr:M,href:N,toastType:c,promptPlaceholder:v,promptDefault:k,...q}=l,z={...t.events};Object.keys(q).length?z.click=w?{target:w,...q}:q:delete z.click;const j={...t,events:z};Object.keys(z).length||delete j.events,Object.keys(j).length&&(o[e]=j)}else o[e]=t}$.setup(o)}}a.length&&R(a.get(0))}),window.wireCTAButtons=R;function ae(d){const i=document.body?.classList.contains("dm-launcher-embed")&&window.top!==window;(i?window.top:window).location.href=d}function R(d){d.querySelectorAll(".dm-cta-trigger").forEach(i=>{i.__ctaWired||(i.__ctaWired=!0,i.addEventListener("click",async()=>{const D=i.dataset.action,L=i.dataset.entry,I=i.dataset.confirm;let C=S.get("auth_token");if(!C){E.toast("Please log in to perform this action.",{type:"warning"});return}if(I&&!await E.confirm(I))return;const A=Array.from(i.childNodes).map(s=>s.cloneNode(!0));i.disabled=!0,i.textContent="Running\u2026";const a=s=>fetch(`/api/actions/${D}/public`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(i.dataset.scope?{entryId:L,scope:i.dataset.scope}:{entryId:L})});try{let s=await a(C);if(s.status===401){const e=S.get("auth_refresh_token");if(e){const t=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(t.ok){const{token:r}=await t.json();S.set("auth_token",r),C=r,s=await a(C)}}}const o=await s.json().catch(()=>({}));if(!s.ok||o.success===!1)throw new Error(o.error||o.message||`Error ${s.status}`);E.toast(o.message||"Action completed.",{type:"success"})}catch(s){E.toast(s.message||"Action failed.",{type:"error"})}finally{i.disabled=!1,i.textContent="",A.forEach(s=>i.appendChild(s)),Domma.icons.scan(i)}}))})}(function(){const i=document.querySelectorAll('.dm-collection-hydrate[data-collection-scope="mine"]');if(!i.length)return;const D=S.get("auth_token");function L(C,A){const a=document.createElement("div");a.className="dm-collection-display dm-collection-empty";const s=document.createElement("p");if(A){s.appendChild(document.createTextNode("Please "));const o=document.createElement("a");o.href="/login",o.textContent="sign in",s.appendChild(o),s.appendChild(document.createTextNode(" to view your entries."))}else s.textContent=C;return a.appendChild(s),a}function I(C,A){const a=document.createElement("template");a.innerHTML=A||"",C.replaceWith(a.content)}i.forEach(async C=>{const A=C.dataset.collectionAttrs;if(!A)return;if(!D){C.replaceChildren(L("",!0));return}const a=s=>fetch("/api/collections/render-scope",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({attrs:A})});try{let s=D,o=await a(s);if(o.status===401){const t=S.get("auth_refresh_token");if(t){const r=await fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(r.ok){const{token:m}=await r.json();S.set("auth_token",m),s=m,o=await a(s)}}}if(!o.ok){const{error:t}=await o.json().catch(()=>({}));C.replaceChildren(L(t||"Unable to load entries.",!1));return}const{html:e}=await o.json();I(C,e),window.DommaCollectionBrowser?.hydrate&&window.DommaCollectionBrowser.hydrate(document)}catch{C.replaceChildren(L("Unable to load entries.",!1))}}),setTimeout(()=>{typeof Domma<"u"&&Domma.icons?.scan&&Domma.icons.scan(),typeof Domma<"u"&&Domma.syntax?.scan&&Domma.syntax.scan(),R(document.body)},100)})(),(function(){const i=document.querySelectorAll("[data-collection-table]");!i.length||typeof T>"u"||!T.create||i.forEach(D=>{let L;try{L=V(D.dataset.payload)}catch{return}const{columns:I,rows:C,search:A,sortable:a,exportable:s,pageSize:o,empty:e,ctaConfig:t,slug:r,exportCfg:m}=L;if(!I?.length)return;if(t){const g=I.findIndex(l=>l.key==="_cta");g!==-1&&(I[g]={key:"_cta",title:"",render:(l,b)=>{const w=document.createElement("button");if(w.className=`btn btn-${t.style||"primary"} dm-cta-trigger`,w.dataset.action=t.action||"",t.scope&&(w.dataset.scope=t.scope),w.dataset.entry=b._entryId||"",t.confirm&&(w.dataset.confirm=t.confirm),t.icon){const u=document.createElement("span");u.dataset.icon=t.icon,w.appendChild(u),w.appendChild(document.createTextNode(" "))}return w.appendChild(document.createTextNode(t.label||"Run")),w}})}const n="col-table-"+Math.random().toString(36).slice(2,7),y=document.createElement("div");y.id=n,D.replaceChildren(y),T.create("#"+n,{data:C,columns:I,search:A,sortable:a,exportable:s,pageSize:o,emptyMessage:e}),t&&R(y),D._dmTable={columns:I,rows:C,slug:r,exportCfg:m,render(g){T.create("#"+n,{data:g,columns:I,search:A,sortable:a,exportable:s,pageSize:o,emptyMessage:e}),t&&R(y)}}})})(),(function(){const i=document.querySelectorAll("[data-form-inline]");if(!i.length||typeof F>"u")return;function D(a){const s=a&&a.logic;return!!(s&&(s.visibility||s.requirement))}function L(a,s){const o={};return(a||[]).forEach(e=>{if(e.type==="page-break"||e.type==="spacer"||!e.name)return;const t=e.type==="chooser"||!!(e.variant&&["select","radio","checkbox-group"].includes(e.type)),r=e.type==="checkbox"?"boolean":e.type==="date"||e.type==="icon"||e.type==="image"?"string":t?"chooser":e.type,m={...e.formConfig||{}};m.span==="full"&&s&&(m.span=s);const n={type:r,required:D(e)?!1:e.required,label:e.label,options:e.options,formConfig:{...e.placeholder&&{placeholder:e.placeholder},...e.helper&&{hint:e.helper},...e.tooltip&&{tooltip:e.tooltip},...m}};e.minLength!==void 0&&(n.minLength=e.minLength),e.maxLength!==void 0&&(n.maxLength=e.maxLength),e.min!==void 0&&(n.min=e.min),e.max!==void 0&&(n.max=e.max),t&&(e.variant&&(n.variant=e.variant),(e.multiple||e.type==="checkbox-group")&&(n.multiple=!0),e.density&&(n.density=e.density),e.columns&&(n.columns=e.columns),e.accent&&(n.accent=e.accent),e.accentStyle&&(n.accentStyle=e.accentStyle),e.glow&&(n.glow=!0),e.glowColour&&(n.glowColour=e.glowColour),e.shadow&&(n.shadow=e.shadow),e.shadowColour&&(n.shadowColour=e.shadowColour)),o[e.name]=e.type==="file"?xe(e,n):n}),o}function I(a){const s={};return(a||[]).forEach(o=>{if(!(!o.name||o.type==="page-break"||o.type==="spacer")&&(o.type==="select"||o.type==="multiselect")&&o.required){const e=(o.options||[])[0];e&&(s[o.name]=typeof e=="object"?e.value:e)}}),s}function C(a,s){(s||[]).forEach(o=>{if(o.type!=="date"||!o.name)return;const e=a.querySelector(`[name="${o.name}"]`);e&&e.type!=="date"&&(e.type="date")})}function A(a,s,o){let e=a.querySelector(".cms-form-message");e||(e=document.createElement("p"),e.className="cms-form-message",a.appendChild(e)),e.textContent=s,e.style.cssText=o?"color:var(--dm-danger);margin-top:.75rem;":"color:var(--dm-success);margin-top:.75rem;"}i.forEach(a=>{let s;try{s=V(a.dataset.formInline)}catch{return}a.querySelector(":scope > .cms-form-embed-summary")?.remove();const o=s.fields||[],e=s.settings||{},t=Number(e.columns)===3?3:2,r=e.layout||"grid",m=o.some(u=>u.type==="page-break"),n=new Map;Le(a,s.fileLimits,n),Te(a,o);const y=async u=>{if(a.dataset.triggerBlocked==="true"){const f=a._formLogicRuntime,h=f&&f.submitBlock?f.submitBlock().reasons:[];A(a,h.join(" ")||"This form cannot be submitted yet.",!0);const p=new Error("Blocked by a form trigger");throw p.formSubmitFailed=!0,p}try{const f=a.querySelector(".fb-form-honeypot"),h=f?.querySelector('input[type="text"]')||null,p=f?.querySelector('[name="_t"]')||null,x=Object.assign({},u);delete x._t,f?.dataset.hpName&&delete x[f.dataset.hpName],h!==null&&(x._hp=h.value),p!==null&&(x._t=p.value);const M=new Map(n);ne(a,M);const N=$e(x,o,M),c=Ae(a,N.files);if(c){A(a,c,!0);const k=new Error(c);throw k.formSubmitFailed=!0,k}const v=await H.post(`/api/forms/submit/${s.slug}`,N.files.size?Ee(N.values,N.files).body:N.values);if(v&&v.error){A(a,v.error,!0);const k=new Error(v.error);throw k.formSubmitFailed=!0,k}if(v?.redirect){ae(v.redirect);return}for(Se(a);a.firstChild;)a.removeChild(a.firstChild);A(a,v?.message||e.successMessage||"Thank you for your submission.",!1)}catch(f){throw f.formSubmitFailed||A(a,f.message||"Submission failed. Please try again.",!0),f}},g=Date.now();function l(u){const f=u.querySelector("form");if(!f||f.querySelector(".fb-form-honeypot"))return;const h=document.createElement("div");h.className="fb-form-honeypot",h.setAttribute("aria-hidden","true");const p=document.createElement("input");p.name=f.querySelector('[name="website"]')?"_website":"website",h.dataset.hpName=p.name,p.type="text",p.tabIndex=-1,p.autocomplete="url",p.placeholder="https://",h.appendChild(p);const x=document.createElement("input");x.name="_t",x.type="hidden",x.value=g,h.appendChild(x),f.appendChild(h)}function b(u){if(!window.FormLogicEngine||!o.some(h=>h.logic||Array.isArray(h.triggers)&&h.triggers.length))return null;const f=new window.FormLogicEngine.FormLogicRuntime(s,a,u?{baseValues:u}:void 0);if(f.init(),a._formLogicRuntime=f,a._formLogicObserved)return f;if(a._formLogicObserved=!0,a.parentNode&&typeof MutationObserver<"u"){const h=new MutationObserver(function(p){for(const x of p)for(const M of x.removedNodes)if(M===a||M.nodeType===1&&M.contains&&M.contains(a)){a._formLogicRuntime&&a._formLogicRuntime.destroy(),h.disconnect();return}});h.observe(a.parentNode,{childList:!0,subtree:!1}),a._formLogicObserver=h}return f}let w=!1;if(a.addEventListener("dm-form-end",u=>{const f=u.detail?.validation;if(f&&!f.valid){Z(a,f.missing),ee(f);return}w||(w=!0,y(u.detail?.values||{}).catch(()=>{}).finally(()=>{w=!1}))}),m&&F.wizard){const u=ve(o,s.title),f=u.map(v=>({title:v.title,description:v.description,fields:L(v.fields,t)})),h=u.map(v=>v.fields);let p=0,x=null,M=null;const N=v=>{const k=window.FormLogicEngine;if(!k||!k.validateFields)return;const q=k.validateFields(a,h[p]||[]);q.valid||(v.preventDefault(),v.stopImmediatePropagation(),Z(a,q.missing),ee(q))},c=()=>{const v=h[p]||o;Ce(a,e),te(a,e,v),oe(a,e),C(a,v),Q(a,v),ke(a,n),e.honeypot!==!1&&l(a),x&&x.destroy(),x=b(M?.getStepData?M.getStepData():void 0),a.querySelectorAll(".wizard-next, .wizard-submit").forEach(k=>k.addEventListener("click",N,!0))};M=F.wizard(a,{schema:{steps:f},layout:r,columns:t,finishText:e.submitText||"Finish",onSubmit:y,onStepChange:v=>{ne(a,n),p=v,setTimeout(c,0)}}),a.addEventListener("dm-form-trigger",v=>{if(v.detail?.type!=="goto-step"||!M?.goToStep)return;const k=Number(v.detail.action.step);!Number.isFinite(k)||k<0||k>=f.length||k!==p&&M.goToStep(k)}),Promise.resolve(M).then(c)}else if(F.render){const u=F.render(a,L(o,t),I(o),{submitText:e.submitText||"Submit",layout:r,columns:t,onSubmit:y});Promise.resolve(u).then(function(){we(a,e,r),te(a,e,o),oe(a,e),C(a,o),Q(a,o),e.honeypot!==!1&&l(a),b()})}})})();function _e(d,i){const D=document.body,L=D.classList,I=new Set((D.dataset.railSite||"").split(" ").filter(Boolean)),C=()=>window.matchMedia("(min-width: 993px)").matches;d.querySelectorAll(".navbar-link, .navbar-dropdown-toggle").forEach(t=>{const r=t.textContent.trim();r&&(t.setAttribute("title",r),t.querySelector("svg, [data-icon]")||(t.dataset.initial=r.charAt(0).toUpperCase()))});const A=document.createElement("button");A.type="button",A.className="dm-nav-collapse-toggle";const a=()=>{const t=L.contains("dm-vnav-collapsed");A.setAttribute("aria-pressed",String(t)),A.setAttribute("aria-label",t?"Expand menu":"Collapse menu"),A.title=A.getAttribute("aria-label");const r=i?"chevrons-left":"chevrons-right",m=i?"chevrons-right":"chevrons-left";A.innerHTML=`<span data-icon="${t?r:m}"></span>`,window.Domma&&Domma.icons&&Domma.icons.scan(A)},s=t=>{L.toggle("dm-vnav-collapsed",t),S.set("nav_collapsed",t),a()};A.addEventListener("click",()=>s(!L.contains("dm-vnav-collapsed"))),a();const o=d.querySelector(".navbar-container")||d;o.insertBefore(A,o.firstChild?.nextSibling||null);const e=t=>{L.toggle("dm-vnav-autohide",t),L.toggle("dm-vnav-collapsible",!t&&I.has("collapsible")),t?L.remove("dm-vnav-collapsed"):I.has("collapsible")&&S.get("nav_collapsed")===!0&&L.add("dm-vnav-collapsed"),d.classList.remove("dm-nav-revealed"),a()};d.addEventListener("pointerdown",t=>{L.contains("dm-vnav-autohide")&&t.pointerType!=="mouse"&&!d.classList.contains("dm-nav-revealed")&&(d.classList.add("dm-nav-revealed"),t.preventDefault())}),document.addEventListener("pointerdown",t=>{d.contains(t.target)||d.classList.remove("dm-nav-revealed")}),window.E&&typeof E.contextMenu=="function"&&E.contextMenu(d,{items:()=>{const t=L.contains("dm-vnav-autohide"),r=L.contains("dm-vnav-collapsed"),m=S.has("nav_autohide")||S.has("nav_collapsed");return[{header:"Menu"},{label:r?"Expand menu":"Collapse to icons",icon:r?"maximize":"minimize",disabled:!C()||t||!I.has("collapsible"),action:()=>s(!r)},{label:t?"Keep on screen":"Hide when not in use",icon:t?"eye":"eye-off",disabled:!C(),action:()=>{S.set("nav_autohide",!t),e(!t)}},{type:"divider"},{label:"Reset to the site's setting",icon:"refresh",disabled:!m,action:()=>{S.remove("nav_autohide"),S.remove("nav_collapsed"),e(I.has("autohide")),L.toggle("dm-vnav-collapsed",!I.has("autohide")&&I.has("start-collapsed")),a()}}]}})}function qe(d){d.classList.add("dm-nav-scroll-hide");let i=window.scrollY,D=!1;window.addEventListener("scroll",()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const L=window.scrollY,I=d.matches(":focus-within")||d.querySelector(".navbar-dropdown.open, .navbar-collapse.show");L>i&&L>d.offsetHeight&&!I?d.classList.add("dm-nav-scrolled-away"):L<i&&d.classList.remove("dm-nav-scrolled-away"),i=L}))},{passive:!0})}function Me(d){let i={};try{i=JSON.parse(d.dataset.contents||"{}")}catch{}const D=d.closest(".site-main"),L=document.querySelector(".site-content"),I=new Set(String(i.exclude||"").split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)),C=n=>!n.closest(".hero, .card, .accordion, .tabs, figure, #site-sidebar"),A=n=>(L?[...L.querySelectorAll(n)]:[]).filter(C).filter(y=>!I.has(y.textContent.trim().toLowerCase())),a=i.headings==="h2"?A("h2"):i.headings==="h3"?A("h3"):i.headings==="h2h3"?A("h2, h3"):A("h2").length?A("h2"):A("h3");if(!a.length){D?.classList.add("no-sidebar-items");return}const s=new Set([...document.querySelectorAll("[id]")].map(n=>n.id)),o=document.createElement("nav");o.className="dm-contents",o.setAttribute("aria-label",i.title||"Page contents"),i.hover&&(o.dataset.menuHover=i.hover),i.selected&&(o.dataset.menuActive=i.selected),i.accent&&o.style.setProperty("--dm-menu-highlight",i.accent.startsWith("#")?i.accent:`var(--dm-${i.accent})`),i.font&&(o.style.fontFamily=i.font),i.fontSize&&(o.style.fontSize=i.fontSize),i.fontWeight&&(o.style.fontWeight=i.fontWeight);const e=document.createElement("div");e.className="dm-contents-head";const t=document.createElement("p");t.className="dm-contents-title",t.textContent=i.title||"",e.appendChild(t),o.appendChild(e);const r=document.createElement("ol");r.className="dm-contents-list"+(i.numbered?" is-numbered":"");const m=[];for(const n of a){if(!n.id){const l=(n.textContent||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section";let b=l;for(let w=2;s.has(b);w++)b=`${l}-${w}`;s.add(b),n.id=b}const y=document.createElement("li");y.className=`dm-contents-item dm-contents-${n.tagName.toLowerCase()}`;const g=document.createElement("a");g.href=`#${n.id}`,g.textContent=n.textContent.trim(),y.appendChild(g),r.appendChild(y),m.push([n,g])}if(o.appendChild(r),d.replaceChildren(o),i.scrollSpy!==!1&&"IntersectionObserver"in window){const n=new Map,y=()=>{const l=m.find(([b])=>n.get(b))||null;m.forEach(([,b])=>{const w=l&&b===l[1];b.classList.toggle("is-active",!!w),w?b.setAttribute("aria-current","location"):b.removeAttribute("aria-current")})},g=new IntersectionObserver(l=>{l.forEach(b=>n.set(b.target,b.isIntersecting)),y()},{rootMargin:"-80px 0px -60% 0px"});m.forEach(([l])=>g.observe(l))}if(D?.classList.contains("contents-collapsible")){const n=document.createElement("button");n.type="button",n.className="dm-contents-toggle";const y=()=>{const g=D.classList.contains("contents-collapsed");n.setAttribute("aria-expanded",String(!g)),n.setAttribute("aria-label",g?"Show the contents":"Hide the contents"),n.title=n.getAttribute("aria-label"),n.innerHTML=`<span data-icon="${g?"list":"x"}"></span>`,window.Domma?.icons&&Domma.icons.scan(n)};n.addEventListener("click",()=>{S.set("contents_collapsed",D.classList.toggle("contents-collapsed")),y()}),y(),e.insertBefore(n,e.firstChild)}if(D?.classList.contains("contents-floating")&&i.movable){o.classList.add("is-movable");const n=S.get("contents_position");n&&Number.isFinite(n.x)&&Object.assign(d.style,{left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto"}),e.addEventListener("pointerdown",y=>{if(y.target.closest("button"))return;const g=d.getBoundingClientRect(),l=y.clientX-g.left,b=y.clientY-g.top,w=f=>{const h=Math.max(0,Math.min(window.innerWidth-g.width,f.clientX-l)),p=Math.max(0,Math.min(window.innerHeight-40,f.clientY-b));Object.assign(d.style,{left:`${h}px`,top:`${p}px`,right:"auto",bottom:"auto"})},u=()=>{document.removeEventListener("pointermove",w),S.set("contents_position",{x:parseInt(d.style.left,10),y:parseInt(d.style.top,10)})};document.addEventListener("pointermove",w),document.addEventListener("pointerup",u,{once:!0})})}window.E&&typeof E.contextMenu=="function"&&E.contextMenu(d,{items:()=>{const n=D?.classList.contains("contents-collapsible"),y=D?.classList.contains("contents-collapsed"),g=m.find(([,l])=>l.classList.contains("is-active"));return[{header:"Contents"},...n?[{label:y?"Show the contents":"Collapse to a button",icon:y?"list":"minimize",action:()=>d.querySelector(".dm-contents-toggle")?.click()}]:[],{label:"Copy a link to this section",icon:"link",disabled:!g,action:async()=>{const l=`${location.origin}${location.pathname}#${g[0].id}`;try{await _.copyToClipboard(l),E.toast("Link copied.",{type:"success"})}catch{E.toast("Could not copy the link.",{type:"error"})}}},{label:"Back to the top",icon:"arrow-up",action:()=>window.scrollTo({top:0,behavior:"smooth"})}]}}),D?.classList.contains("contents-autohide")&&(d.addEventListener("pointerdown",n=>{n.pointerType!=="mouse"&&!d.classList.contains("is-revealed")&&(d.classList.add("is-revealed"),n.preventDefault())}),document.addEventListener("pointerdown",n=>{d.contains(n.target)||d.classList.remove("is-revealed")}))}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Visitor chat - the public API behind a chat launcher (public/js/launcher-chat.mjs).
3
+ *
4
+ * GET /api/chat/config?launcher=ID - what the chat panel draws first: greeting, bot name, staff on/off
5
+ * GET /api/chat/state?launcher=ID&after=N - the chat's state and its messages after N (the poll)
6
+ * POST /api/chat/send {launcher, text, page?, after?, _hp?, _t?} - say something (starts a chat)
7
+ * POST /api/chat/pick {launcher, n, i, after?} - a "Did you mean" choice (i = -1: none of these)
8
+ * POST /api/chat/person {launcher, after?} - "Talk to a person"
9
+ * POST /api/chat/details {launcher, name, email, message?, after?} - the name-and-email form
10
+ * POST /api/chat/end {launcher} - the visitor ends the chat
11
+ *
12
+ * Every route answers 404 unless `launcher` names an enabled chat launcher
13
+ * (services/chat/launcher-bridge.js), and the launcher's chat settings are read
14
+ * here, never taken from the browser. A chat is the visitor's by a random token
15
+ * (`X-Chat-Token` header; only its hash is stored), sent back once, when the
16
+ * first message starts the chat. Plain text only, capped; a filled honeypot or
17
+ * a first message with no `_t` or within 1.5s of the panel opening is quietly dropped. An
18
+ * address may start 6 chats and send 120 messages an hour; the site takes `maxNewChatsPerHour` new
19
+ * chats an hour in all (Chats settings).
20
+ * No internal id reaches the browser: messages are numbered within the chat and
21
+ * choices by their place in the list.
22
+ */
23
+ import {chatLauncher} from '../../services/chat/launcher-bridge.js';
24
+ import {readChatSettings} from '../../services/chat/settings.js';
25
+ import {
26
+ createSession, getSession, knowledgeIndex, messagesAfter, sessionByToken, staffAvailable
27
+ } from '../../services/chat/store.js';
28
+ import {
29
+ publicMessage, publicState, visitorAsksForPerson, visitorDetails, visitorEnds, visitorPicks, visitorSays
30
+ } from '../../services/chat/conversation.js';
31
+
32
+ const int = (v, fallback = 0) => {
33
+ const n = Number(v);
34
+ return Number.isFinite(n) ? Math.trunc(n) : fallback;
35
+ };
36
+ const DWELL_MS = 1500;
37
+ /** New chats one address may start in an hour - past that, sending asks them to wait. */
38
+ export const NEW_CHATS_PER_HOUR = 6;
39
+ const started = new Map();
40
+
41
+ /** Every new chat in the last hour, from anyone: the site-wide cap (settings maxNewChatsPerHour). */
42
+ let siteStarts = [];
43
+ /** Messages one address may send in an hour, across all its chats (send, pick, person). */
44
+ export const MESSAGES_PER_HOUR = 120;
45
+ const writes = new Map();
46
+
47
+ /**
48
+ * Whether this address may start another chat now - within its own hourly
49
+ * allowance and the site's - and counts the start when it may.
50
+ */
51
+ export function mayStart(ip, at = Date.now(), siteMax = readChatSettings().maxNewChatsPerHour) {
52
+ const HOUR = 3_600_000;
53
+ siteStarts = siteStarts.filter(t => at - t < HOUR);
54
+ const recent = (started.get(ip) || []).filter(t => at - t < HOUR);
55
+ if (recent.length >= NEW_CHATS_PER_HOUR || siteStarts.length >= siteMax) { started.set(ip, recent); return false; }
56
+ recent.push(at);
57
+ started.set(ip, recent);
58
+ siteStarts.push(at);
59
+ // Keep the map small: forget addresses with nothing in the last hour.
60
+ if (started.size > 5000) for (const [k, v] of started) if (!v.some(t => at - t < HOUR)) started.delete(k);
61
+ return true;
62
+ }
63
+
64
+ /** Whether this address may send another message this hour; counts it when it may. */
65
+ export function mayWrite(ip, at = Date.now()) {
66
+ const HOUR = 3_600_000;
67
+ const recent = (writes.get(ip) || []).filter(t => at - t < HOUR);
68
+ if (recent.length >= MESSAGES_PER_HOUR) { writes.set(ip, recent); return false; }
69
+ recent.push(at);
70
+ writes.set(ip, recent);
71
+ if (writes.size > 5000) for (const [k, v] of writes) if (!v.some(t => at - t < HOUR)) writes.delete(k);
72
+ return true;
73
+ }
74
+
75
+ /** Tests. */
76
+ export function _resetStarts() { started.clear(); writes.clear(); siteStarts = []; }
77
+ const limit = (max, minutes = 1) => ({config: {rateLimit: {max, timeWindow: `${minutes} minute${minutes === 1 ? '' : 's'}`}}});
78
+
79
+ export async function chatPublicRoutes(fastify) {
80
+ /** The launcher the request names, or a 404 sent. */
81
+ async function launcherOf(request, reply) {
82
+ const id = request.method === 'GET' ? request.query?.launcher : request.body?.launcher;
83
+ const launcher = await chatLauncher(typeof id === 'string' ? id : '');
84
+ if (!launcher) {
85
+ reply.code(404).send({error: 'Chat is not available here.'});
86
+ return null;
87
+ }
88
+ return launcher;
89
+ }
90
+
91
+ /** The visitor's chat from their token - only on the launcher it started on. */
92
+ async function chatOf(request, launcher, opts) {
93
+ const token = request.headers['x-chat-token'];
94
+ const session = await sessionByToken(typeof token === 'string' ? token : '', opts);
95
+ return session && session.data.launcherId === launcher.id ? session : null;
96
+ }
97
+
98
+ /** The answer every chat route gives: the state and what is new since `after`. */
99
+ async function answer(session, launcher, after) {
100
+ const fresh = await getSession(session.id) || session;
101
+ const {byId} = await knowledgeIndex();
102
+ const messages = await messagesAfter(fresh.id, Math.max(0, after));
103
+ return {state: publicState(fresh, launcher.chat), messages: messages.map(m => publicMessage(m, launcher.chat, byId))};
104
+ }
105
+
106
+ const tooMany = (reply) => reply.code(429).send({error: 'You are sending messages too quickly. Please wait a while and try again.'});
107
+ const fail = (reply, result) => reply.code(result.code || 400).send({error: result.error});
108
+
109
+ fastify.get('/config', limit(60), async (request, reply) => {
110
+ const launcher = await launcherOf(request, reply);
111
+ if (!launcher) return;
112
+ const {greeting, botName, bot, staff, askDetails} = launcher.chat;
113
+ return {greeting, botName, bot, staff, askDetails, staffOnline: staff && staffAvailable().length > 0};
114
+ });
115
+
116
+ fastify.get('/state', limit(90), async (request, reply) => {
117
+ const launcher = await launcherOf(request, reply);
118
+ if (!launcher) return;
119
+ const session = await chatOf(request, launcher, {includeClosed: true});
120
+ // No chat to pick up (none yet, ended long ago, or wiped): the panel starts afresh.
121
+ if (!session) return {state: null, messages: []};
122
+ return answer(session, launcher, int(request.query?.after));
123
+ });
124
+
125
+ fastify.post('/send', limit(10), async (request, reply) => {
126
+ const launcher = await launcherOf(request, reply);
127
+ if (!launcher) return;
128
+ if (!mayWrite(request.ip)) return tooMany(reply);
129
+ const body = request.body || {};
130
+ if (typeof body.text !== 'string' || !body.text.trim()) return reply.code(400).send({error: 'Type a message first.'});
131
+ let session = await chatOf(request, launcher);
132
+ let token = null;
133
+ if (!session) {
134
+ // Bots: a filled honeypot, no time the panel opened, or a message faster than a person
135
+ // can type one. Look accepted, keep nothing.
136
+ const opened = int(body._t, NaN);
137
+ if (body._hp || !Number.isFinite(opened) || Date.now() - opened < DWELL_MS) {
138
+ return {state: {status: 'closed', askDetails: false, detailsGiven: false, staff: false, staffOnline: false, last: 0}, messages: []};
139
+ }
140
+ if (!mayStart(request.ip)) return reply.code(429).send({error: 'Too many new chats from here. Please wait a while and try again.'});
141
+ const made = await createSession({launcherId: launcher.id, page: body.page});
142
+ session = made.entry;
143
+ token = made.token;
144
+ }
145
+ const result = await visitorSays(session.id, body.text, launcher.chat);
146
+ if (result.error) return fail(reply, result);
147
+ return {...(token && {token}), ...await answer(result.session, launcher, token ? 0 : int(body.after))};
148
+ });
149
+
150
+ fastify.post('/pick', limit(15), async (request, reply) => {
151
+ const launcher = await launcherOf(request, reply);
152
+ if (!launcher) return;
153
+ if (!mayWrite(request.ip)) return tooMany(reply);
154
+ const session = await chatOf(request, launcher);
155
+ if (!session) return reply.code(404).send({error: 'This chat has ended.'});
156
+ const i = int(request.body?.i, NaN);
157
+ if (!Number.isInteger(i) || i < -1 || i > 9) return reply.code(400).send({error: 'Pick one of the choices.'});
158
+ const result = await visitorPicks(session.id, int(request.body?.n), i, launcher.chat);
159
+ if (result.error) return fail(reply, result);
160
+ return answer(result.session, launcher, int(request.body?.after));
161
+ });
162
+
163
+ fastify.post('/person', limit(10), async (request, reply) => {
164
+ const launcher = await launcherOf(request, reply);
165
+ if (!launcher) return;
166
+ if (!mayWrite(request.ip)) return tooMany(reply);
167
+ let session = await chatOf(request, launcher);
168
+ let token = null;
169
+ if (!session) {
170
+ // Asking for a person before saying anything starts the chat too.
171
+ const opened = int(request.body?._t, NaN);
172
+ if (request.body?._hp || !Number.isFinite(opened) || Date.now() - opened < DWELL_MS) {
173
+ return {state: {status: 'closed', askDetails: false, detailsGiven: false, staff: false, staffOnline: false, last: 0}, messages: []};
174
+ }
175
+ if (!mayStart(request.ip)) return reply.code(429).send({error: 'Too many new chats from here. Please wait a while and try again.'});
176
+ const made = await createSession({launcherId: launcher.id, page: request.body?.page});
177
+ session = made.entry;
178
+ token = made.token;
179
+ }
180
+ const result = await visitorAsksForPerson(session.id, launcher.chat);
181
+ if (result.error) return fail(reply, result);
182
+ return {...(token && {token}), ...await answer(result.session, launcher, token ? 0 : int(request.body?.after))};
183
+ });
184
+
185
+ fastify.post('/details', limit(6, 10), async (request, reply) => {
186
+ const launcher = await launcherOf(request, reply);
187
+ if (!launcher) return;
188
+ const session = await chatOf(request, launcher);
189
+ if (!session) return reply.code(404).send({error: 'This chat has ended.'});
190
+ const result = await visitorDetails(session.id, request.body || {}, launcher.chat);
191
+ if (result.error) return fail(reply, result);
192
+ return answer(result.session, launcher, int(request.body?.after));
193
+ });
194
+
195
+ fastify.post('/end', limit(10), async (request, reply) => {
196
+ const launcher = await launcherOf(request, reply);
197
+ if (!launcher) return;
198
+ const session = await chatOf(request, launcher);
199
+ if (!session) return {ok: true};
200
+ await visitorEnds(session.id);
201
+ return {ok: true};
202
+ });
203
+ }