`:``;let e=t.url||t.sizes[0].url;e=e.split("/").pop(),i.insertAdjacentHTML("beforeend",`${e}`)}return i},e=>{var t=document.querySelector(".image.selected"),t=(t&&t.classList.remove("selected"),e.classList.add("selected"),e.getAttribute("data-media-id")),t=(selectedMediaId=t,e.querySelector("img, video"));t&&(selectedMediaSrc=t.src,selectedMediaAlt=t.alt||"")}),initMediaLibrary=(window.openMediaLibraryDialog=(e,t)=>{document.getElementById("media-library-dialog").showModal(),t&&(selectedMediaId=t,(n=document.querySelector(".image.selected"))&&n.classList.remove("selected"),n=document.querySelector(`.image[data-media-id="${t}"]`))&&n.classList.add("selected");var t=document.getElementById("media-library-save"),n=t.cloneNode(!0);t.parentNode.replaceChild(n,t),n.addEventListener("click",()=>{e(selectedMediaId,selectedMediaSrc,selectedMediaAlt),closeMediaLibraryDialog()}),document.querySelectorAll(".image").forEach(e=>e.addEventListener("click",()=>selectImage(e)))},window.closeMediaLibraryDialog=()=>{selectedMediaId=null,document.getElementById("media-library-dialog").close()},async()=>{document.getElementById("media-library-close").addEventListener("click",window.closeMediaLibraryDialog),(await window.getRegistry("media")).forEach(e=>{window.createMediaImage(e.media_id,e)}),document.getElementById("upload-media-open").addEventListener("click",()=>{window.openUploadMediaDialog((e,t)=>{var n=document.querySelector(".image.selected");n&&n.classList.remove("selected");let o=window.createMediaImage(e,t,!0);o.addEventListener("click",()=>selectImage(o)),selectedMediaId=e,selectedMediaSrc=t.url||t.sizes[0].url,selectedMediaAlt=t.alt||""})})}),pollForGithubActionStatus=(window.addEventListener("DOMContentLoaded",async()=>{await initMediaLibrary()}),window.closePublishOverlay=async()=>{document.getElementById("publish-dialog").close()},window.openConvertingOverlay=async()=>{var e=document.getElementById("publish-dialog");e.classList.add("converting"),e.classList.remove("uploading"),e.classList.remove("publishing"),e.classList.remove("refreshing"),e.showModal()},window.openUploadOverlay=async()=>{var e=document.getElementById("publish-dialog");e.classList.remove("converting"),e.classList.add("uploading"),e.classList.remove("publishing"),e.classList.remove("refreshing"),e.showModal()},window.openPublishOverlay=async()=>{var e=document.getElementById("publish-dialog");e.classList.remove("converting"),e.classList.remove("uploading"),e.classList.add("publishing"),e.classList.remove("refreshing"),e.showModal()},window.openRefreshOverlay=async()=>{var e=document.getElementById("publish-dialog");e.classList.remove("converting"),e.classList.remove("uploading"),e.classList.remove("publishing"),e.classList.add("refreshing"),e.showModal()},window.openPublishConfirmOverlay=async()=>{document.getElementById("publish-confirm-dialog").showModal()},window.closePublishConfirmOverlay=async()=>{document.getElementById("publish-confirm-dialog").close()},async(t=1)=>{var e=await fetch(window.CMS_CONFIG.server_endpoint+"/github_status?jwt_token="+document.cookie.split(window.CMS_CONFIG.cookie_name+"=")[1].split(";")[0],{method:"GET"}).then(e=>e.json());return console.log(`Poller response [${t}]`,e),0===parseInt(e.body.incomplete_runs)?(console.log("No GitHub Actions running"),!0):68<=t?(console.log("Poller exceeded 300 seconds"),!1):new Promise(e=>{setTimeout(()=>{e(pollForGithubActionStatus(t+1))},t<=20?3e3:5e3)}).then(e=>e)}),deepMerge=(window.startPublishRoutine=async(t=!0)=>{console.log("Publish routine started"),await new Promise(e=>{setTimeout(()=>{e(pollForGithubActionStatus())},2e3)}).then(e=>{console.log("Polling complete with status:",e),e?t?(console.log("Hard refresh"),location.reload(!0)):console.log("No refresh needed"):alert("Error publishing content")})},window.triggerBuild=async(e=!1,t=!0)=>{e?window.openPublishOverlay():window.openRefreshOverlay();let n=document.location.pathname.split("/index.html")[0];""===n&&(n="/"),200===(await fetch(window.CMS_CONFIG.server_endpoint+"/trigger_build?build="+(e?"prod":"cms")+(t?`&page_paths='${encodeURI(n)}'`:""),{method:"POST",mode:"cors",headers:{"Content-Type":"aplication/json"},body:JSON.stringify({jwt_token:document.cookie.split(window.CMS_CONFIG.cookie_name+"=")[1].split(";")[0],page_path:n})})).status&&await window.startPublishRoutine()},window.triggerRegistry=async(e,t)=>{let n=document.location.pathname.split("/index.html")[0];""===n&&(n="/"),(await fetch(window.CMS_CONFIG.server_endpoint+"/trigger_registry?registry="+e+(t?"&entry_type="+t:""),{method:"POST",mode:"cors",headers:{"Content-Type":"aplication/json"},body:JSON.stringify({jwt_token:document.cookie.split(window.CMS_CONFIG.cookie_name+"=")[1].split(";")[0],page_path:n})})).status},(...e)=>{let s=e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase();var t;let a=(t,n)=>{var o=Math.max(t.length,n.length),i=[];for(let e=0;e{for(var[n,o]of Object.entries(t)){var i=s(o);void 0!==e[n]?Array.isArray(o)?e[n]=a(e[n],t[n]):e[n]="object"===i?deepMerge(e[n],o):structuredClone(o):e[n]=structuredClone(o)}})(n,t):n=structuredClone(t)}return n}),publishFiles=async e=>{let t=document.location.pathname.split("/index.html")[0];return""===t&&(t="/"),await(await fetch(window.CMS_CONFIG.server_endpoint+"/upload_github",{method:"POST",mode:"cors",headers:{"Content-Type":"aplication/json"},body:JSON.stringify({files:JSON.stringify(e),user:window.user_email,action:"published",jwt_token:document.cookie.split(window.CMS_CONFIG.cookie_name+"=")[1].split(";")[0],page_path:t})})).json()},publishChanges=(window.delay=t=>new Promise(e=>setTimeout(e,t)),async()=>{if(location.pathname.includes("_entries")||location.pathname.includes("_pages"))await window.triggerBuild(!0,!1);else{var e,t,n=[];for(e of document.querySelectorAll("[data-content-changes]")){var o=e.getAttribute("data-content-id"),i=await window.getContentFile(o);if(!i||!i.content)return void alert("Error fetching content");i=deepMerge(i.content,i.content._changes),o=(delete i._changes,{path:`/data/content/${o}.json`,content:JSON.stringify(i)});n.push(o)}for(t of document.querySelectorAll("[data-config-id]")){var a=t.getAttribute("data-config-id"),d=await window.getConfigFile(a);if(!d||!d.content)return void alert("Error fetching config");d.content._changes&&(delete(d=deepMerge(d.content,d.content._changes))._changes,a={path:`/data/config/${a}.json`,content:JSON.stringify(d)},n.push(a),await window.delay(500))}var l=document.querySelector("html").getAttribute("data-page-id"),r=await window.getPageFile(l);r&&r.content&&r.content.is_private&&(r.content.is_private=!1,n.push({path:`/pages/${l}.json`,content:JSON.stringify(r.content)})),n.length<1?window.closePublishOverlay():(window.openUploadOverlay(),l=await publishFiles(n),console.log(l),200!==l.statusCode?alert("Error publishing content"):await window.triggerBuild(!0,!1))}}),initPublishOverlay=()=>{var e=document.getElementById("publish-confirm-save"),t=document.getElementById("publish-confirm-close");e.addEventListener("click",async()=>{window.closePublishConfirmOverlay(),window.openConvertingOverlay(),await publishChanges()}),t.addEventListener("click",()=>{window.closePublishConfirmOverlay()})},functionOnUpload=(document.addEventListener("DOMContentLoaded",initPublishOverlay),null),uploadMediaToAWS=(window.openUploadMediaDialog=e=>{document.getElementById("upload-media-dialog").showModal(),functionOnUpload=e},window.closeUploadMediaDialog=()=>{document.getElementById("upload-media-dialog").close()},async(e,t)=>{let n=document.location.pathname.split("/index.html")[0];""===n&&(n="/");t=await(await fetch(`${window.CMS_CONFIG.server_endpoint}/file_upload_url?filename=${t?t+"/":""}${e.name}&jwt_token=${document.cookie.split(window.CMS_CONFIG.cookie_name+"=")[1].split(";")[0]}&page_path=`+n,{method:"GET"})).json();return 200===t.statusCode?(await fetch(t.uploadURL,{method:"PUT",body:e})).ok?{statusCode:200,message:"Image uploaded"}:{statusCode:500,message:"Error uploading image"}:t}),uploadMediaFile=async e=>{let t=document.location.pathname.split("/index.html")[0];return""===t&&(t="/"),await(await fetch(window.CMS_CONFIG.server_endpoint+"/upload_github",{method:"POST",mode:"cors",headers:{"Content-Type":"aplication/json"},body:JSON.stringify({files:JSON.stringify(e),user:window.user_email,action:"uploaded media",jwt_token:document.cookie.split(window.CMS_CONFIG.cookie_name+"=")[1].split(";")[0],page_path:t})})).json()},validateUploadForm=e=>{e=e.querySelectorAll("input");let t=!0;return e.forEach(e=>{e.hasAttribute("required")&&""===e.value&&(t=!1)}),t},resizeToWebp=async(n,o,i,a)=>new Promise(t=>{var e=document.createElement("canvas");e.width=i,e.height=a,e.getContext("2d").drawImage(n,0,0,i,a),e.toBlob(async e=>{e=new File([e],o+`_${i}.webp`,{type:e.type});t(await uploadMediaToAWS(e,"images"))},"image/webp")}),renameFile=async(e,t,n)=>new File([e],t+"."+n,{type:e.type}),convertImages=async(t,a,d)=>new Promise(e=>{let i=new Image;i.addEventListener("load",async()=>{var o=[];for(let n=0;nd[n])t*=d[n]/e,e=d[n];else if(n{window.openUploadOverlay(),window.closeUploadMediaDialog();var t=new FormData(t),n=document.getElementById("file-input").files[0],o=t.get("filename"),i=o.replace(/[<>:"/\\|?*%\n\r]/g,"").replace(/\s+/g,"+"),a={name:o};if(n.type.includes("image")){var d=await convertImages(n,i,window.CMS_CONFIG.image_sizes);a.format="image/webp",a.sizes=d,a.alt=t.get("alt")||""}else{d=n.type.split("/")[1],t=await renameFile(n,o,d);let e=await uploadMediaToAWS(t,"files");if(200!==e.statusCode)return alert("Error uploading file",e.message),void window.closePublishOverlay();a.format=n.type,a.url=window.CMS_CONFIG.media_endpoint+`/files/${i}.`+d}o=i.slice(-12)+(new Date).getTime(),t=[{path:`/data/media/${o}.json`,content:JSON.stringify(a)}];let e=await uploadMediaFile(t);console.log(e),200===e.statusCode&&(await window.triggerRegistry("media"),functionOnUpload)&&functionOnUpload(o,a),window.closePublishOverlay()},initUploadMedia=async()=>{var e=document.getElementById("upload-media-close"),t=document.getElementById("upload-media-save");let n=document.getElementById("file-input");t.addEventListener("click",async e=>{e.preventDefault();e=document.getElementById("upload-media-form");validateUploadForm(e)?await submitUploadForm(e):alert("Please fill in all required fields")}),e.addEventListener("click",()=>{n.files=null,window.closeUploadMediaDialog()})};window.addEventListener("DOMContentLoaded",async()=>{await initUploadMedia()})MenuHelp mee DonatiesDoneerIn je testamentGrote giftenKom in actieStart je eigen actieDoe mee aan een sportevenementWord vrijwilligerSteun met jouw bedrijfWaarom Free a GirlSamenwerkenstart een bedrijfsactieOver Free a Girl Wat doen weRescueEmpowerJusticeIn NederlandStrategieWie zijn weAmbassadeursFoundersOns teamSamenwerkingsverbandenGovernanceNieuwsContact ContactDirect hulp nodigVacaturesVeelgestelde vragenWebshopMenuDoneerBedankt!undefined