1window.ForumEditor=(()=>{let g=null,S=null;const q='.forum-richtext[contenteditable="true"], textarea.forum-markdown-editor';function y(e){return e&&e.tagName==="TEXTAREA"}function E(e,t,n,o){e.focus();const r=e.selectionStart||0,i=e.selectionEnd||0,s=e.value,a=s.substring(r,i)||o||"",l=t+a+n;e.value=s.substring(0,r)+l+s.substring(i);const c=r+t.length+a.length;e.setSelectionRange(r+t.length,c),e.dispatchEvent(new Event("input",{bubbles:!0}))}function x(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function k(e){return String(e||"").replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function v(){return g&&document.body.contains(g)?g:document.querySelector(q)}function V(e){return e?e.querySelector(q):null}function O(e){const t=window.getSelection();if(!t||t.rangeCount===0||!e)return!1;const n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)||e===n.commonAncestorContainer}function h(e){const t=e||v(),n=window.getSelection();if(n&&n.rangeCount>0){const o=n.getRangeAt(0);t&&(t.contains(o.commonAncestorContainer)||t===o.commonAncestorContainer)&&(S=o.cloneRange())}}let R="",C="";function M(e,t,n){let o=n;if(!o||!e.contains(o.commonAncestorContainer)){const l=window.getSelection();l&&l.rangeCount>0&&e.contains(l.getRangeAt(0).commonAncestorContainer)&&(o=l.getRangeAt(0))}if(!o){e.insertAdjacentHTML("beforeend",t);const l=document.createRange();l.selectNodeContents(e),l.collapse(!1);const c=window.getSelection();c&&(c.removeAllRanges(),c.addRange(l)),S=l;return}o.deleteContents();const r=document.createElement("div");r.innerHTML=t;const i=document.createDocumentFragment();let s,a;for(;s=r.firstChild;)a=i.appendChild(s);if(o.insertNode(i),a){const l=document.createRange();l.setStartAfter(a),l.collapse(!0);const c=window.getSelection();c&&(c.removeAllRanges(),c.addRange(l)),S=l}}function H(e){if((e||g)&&S)try{const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(S))}catch{}}function p(e){var s;const t=e||v();if(!t)return;const n=(s=t.closest(".forum-markdown-editor"))==null?void 0:s.querySelector(".forum-editor-toolbar");if(!n)return;const o=O(t),r=window.getSelection(),i={bold:()=>o&&document.queryCommandState("bold"),italic:()=>o&&document.queryCommandState("italic"),underline:()=>o&&document.queryCommandState("underline"),strikethrough:()=>o&&(document.queryCommandState("strikeThrough")||document.queryCommandState("strikethrough")),insertUnorderedList:()=>o&&document.queryCommandState("insertUnorderedList"),insertOrderedList:()=>o&&document.queryCommandState("insertOrderedList"),quote:()=>{var l;if(!o||!r||r.rangeCount===0)return!1;const a=r.anchorNode;return!!(a&&((l=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement)!=null&&l.closest(".forum-editor-quote, blockquote")))},spoiler:()=>{var l;if(!o||!r||r.rangeCount===0)return!1;const a=r.anchorNode;return!!(a&&((l=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement)!=null&&l.closest(".forum-editor-sp
1oiler")))}};n.querySelectorAll("button[data-cmd]").forEach(a=>{const l=a.dataset.cmd;if(i[l]){const c=!!i[l]();a.classList.toggle("is-active",c)}})}function F(e){const t=window.getSelection();if(!t||t.rangeCount===0)return"";const n=t.getRangeAt(0);if(n.collapsed)return"";const o=document.createElement("div");return o.appendChild(n.cloneContents()),o.innerHTML}function T(e,t){e.focus();const n=window.getSelection();if(!n||n.rangeCount===0){e.insertAdjacentHTML("beforeend",t);return}const o=n.getRangeAt(0);o.deleteContents();const r=document.createElement("div");r.innerHTML=t;const i=document.createDocumentFragment();let s,a;for(;s=r.firstChild;)a=i.appendChild(s);if(o.insertNode(i),a){const l=o.cloneRange();l.setStartAfter(a),l.collapse(!0),n.removeAllRanges(),n.addRange(l),S=l}}function Y(e,t,n){if(!n)return;if(y(n)){switch(e){case"bold":E(n,"**","**","fet tekst");break;case"italic":E(n,"*","*","kursiv tekst");break;case"strikethrough":E(n,"~~","~~","gjennomstrek");break;case"underline":E(n,"[u]","[/u]","understreket tekst");break;case"insertUnorderedList":E(n,"- ","","Listeelement");break;case"insertOrderedList":E(n,"1. ","","Nummerert element");break;case"quote":E(n,`[quote] 2`,` 3[/quote]`,"Sitat");break;case"spoiler":E(n,"[spoiler]","[/spoiler]","Spoilertekst");break;case"link":W(n);break;case"image":X(n);break;default:e&&e.indexOf("embed-")===0&&j(n,t.dataset.embed||"Ekstern lenke");break}return}if(["bold","italic","underline","strikethrough","insertUnorderedList","insertOrderedList"].includes(e)){H(n),document.execCommand(e,!1,null),h(n),p(n);return}if(e==="link"){W(n);return}if(e==="image"){X(n);return}if(e==="quote"){Q(n);return}if(e==="spoiler"){J(n);return}e&&e.indexOf("embed-")===0&&j(n,t.dataset.embed||"Ekstern lenke")}function Q(e){H(e),e.focus();const t=F(),o='<blockquote class="forum-editor-quote" data-author="" data-ref=""><div class="forum-editor-quote-head">Sitat</div><div class="forum-editor-quote-body">'+(t.trim()?t:"<br>")+"</div></blockquote><p><br></p>";T(e,o),h(e),p(e)}function J(e){var L;H(e),e.focus();const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0),o=t.anchorNode,r=o?(L=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)==null?void 0:L.closest(".forum-editor-sp
3oiler, .forum-spoiler"):null;if(r&&e.contains(r)){const m=r.parentNode;for(;r.firstChild;)m.insertBefore(r.firstChild,r);m.removeChild(r),h(e),p(e);return}const s=Array.from(e.querySelectorAll("li")).filter(m=>{try{return n.intersectsNode(m)}catch{return!1}});if(s.length>1){const m=s.every(d=>d.querySelector(".forum-editor-spoiler, .forum-spoiler"));s.forEach(d=>{const f=d.querySelector(".forum-editor-spoiler, .forum-spoiler");if(m&&f){for(;f.firstChild;)f.parentNode.insertBefore(f.firstChild,f);f.remove()}else if(!m&&!f){const A=d.innerHTML.trim();A&&(d.innerHTML='<span class="forum-editor-spoiler">'+A+"</span>")}}),h(e),p(e);return}if(s.length===1&&n.toString().trim()===s[0].textContent.trim()){const m=s[0],d=m.querySelector(".forum-editor-spoiler, .forum-spoiler");if(d){for(;d.firstChild;)d.parentNode.insertBefore(d.firstChild,d);d.remove()}else{const f=m.innerHTML.trim();f&&(m.innerHTML='<span class="forum-editor-spoiler">'+f+"</span>")}h(e),p(e);return}const l=Array.from(e.querySelectorAll("p, div:not(.forum-markdown-editor):not(.forum-editor-toolbar), blockquote, h1, h2, h3, h4, h5, h6")).filter(m=>{try{return n.intersectsNode(m)&&m!==e&&!m.closest("li")}catch{return!1}});if(l.length>1){const m=l.every(d=>
3d.querySelector(".forum-editor-spoiler, .forum-spoiler"));l.forEach(d=>{const f=d.querySelector(".forum-editor-spoiler, .forum-spoiler");if(m&&f){for(;f.firstChild;)f.parentNode.insertBefore(f.firstChild,f);f.remove()}else if(!m&&!f){const A=d.innerHTML.trim();A&&A!=="<br>"&&(d.innerHTML='<span class="forum-editor-spoiler">'+A+"</span>")}}),h(e),p(e);return}const c=F(),w='<span class="forum-editor-spoiler">'+(c.trim()?c:"Spoilertekst")+"</span>"+(c.trim()?"":" ");T(e,w),h(e),p(e)}function z(e,t,n){const o=n?Number(n).toString(36):"",r=document.querySelector("#forum-reply-editor")||document.querySelector(q);if(!r)return;if(y(r)){const l=`[quote author="${e}" ref="${o}"] 4${t.trim()} 5[/quote] 6 7`;E(r,"","",l),r.scrollIntoView({behavior:"smooth",block:"center"});return}const i=l=>String(l).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),s=I(t.trim()),a='<blockquote class="forum-editor-quote" data-author="'+i(e)+'" data-ref="'+o+'"><div class="forum-editor-quote-head">Sitat fra '+i(e)+'</div><div class="forum-editor-quote-body">'+s+"</div></blockquote><p><br></p>";r.focus(),T(r,a),r.scrollIntoView({behavior:"smooth",block:"center"}),p(r)}function W(e){if(g=e,h(e),R="",C="",S&&!S.collapsed){const o=document.createElement("div");o.appendChild(S.cloneContents()),R=o.innerHTML.trim(),C=o.textContent.trim()}const t=document.getElementById("link-url-input");t&&(t.value="");const n=document.getElementById("link-modal");n&&(n.style.display="flex",document.body.classList.add("no-scroll")),setTimeout(()=>{t&&t.focus()},60)}window.pfConfirmLink=function(){const e=g||v(),t=document.getElementById("link-url-input");let n=t?t.value.trim():"";if(!e||!n){closeModal("link-modal");return}if(/^https?:\/\//i.test(n)||(n="https://"+n),y(e)){const i=C||"",s=i?`[${i}](${n})`:`[${n}](${n})`;E(e,"","",s),C="",closeModal("link-modal");return}const o=R||C,r=o?'<a href="'+k(n)+'" target="_blank" rel="noopener noreferrer">'+o+"</a>":'<a href="'+k(n)+'" target="_blank" rel="noopener noreferrer">'+x(n)+"</a> ";M(e,r,S),R="",C="",closeModal("link-modal"),p(e)},window.pfConfirmImageUpload=function(){const e=g||v(),t=document.getElementById("image-file-input");if(!t||!t.files||t.files.length===0||!e){closeModal("image-modal");return}const n=t.files[0],o=URL.createObjectURL(n),r=e.closest("form");if(r){t.removeAttribute("id"),t.name="forum_images[]",t.style.display="none",r.appendChild(t);const s=document.createElement("input");s.type="file",s.id="image-file-input",s.accept="image/*",s.style.display="none",s.onchange=function(){const l=document.getElementById("file-chosen-text");l&&(l.innerText=this.files[0]?this.files[0].name:"Ingen fil valgt")};const a=document.getElementById("image-upload-wrapper");a&&a.prepend(s)}if(y(e)){const s=`[bilde=${n.name}] 8`;E(e,"","",s),closeModal("image-modal");return}const i='<img src="'+k(o)+'" alt="'+k(n.name)+'" class="forum-editor-image" data-filename="'+k(n.name)+'"><p><br></p>';M(e,i,S),closeModal("image-modal"),p(e)};function j(e,t){g=e,h(e);const n=document.getElementById("embed-modal-title");n&&(n.innerText="Lim inn URL for "+t);const o=document.getElementById("embed-url-input");o&&(o.value="");const r=document.getElementById("embed-modal");r&&(r.style.display="flex",document.body.classList.add("no-scroll")),setTimeout(()=>{o&&o.focus()},60)}function K(e){const t=/^(https?:\/\/)?(www\.)?(youtube\.com\/(watch\?v=|shorts\/|embed\/)|youtu\.be\/)[a-zA-Z0-9_-]{11}/i,n=/^(https?:\/\/)?(www\.)?(twitter\.com|x\.com)\/[a-zA-Z0-9_]+\/status\/[0-9]+/i,o=/^(https?:\/\/)?(www\.)?bsky\.app\/profile\/[^\s\/]+\/post\/[a-zA-Z0-9]+/i,r=/^(https?:\/\/)?(open\.spotify\.com\/(?:intl-[a-z0-9_-]+\/)?(?:embed\/)?|spotify:)(track|album|playlist|episode|show|artist)[\/:][a-zA-Z0-9]+/i;return t.test(e)||n.test(e)||o.test(e)||r.test(e)}window.pfConfirmEmbed=function(){const e=g||v(),t=document.getElementById("embed-url-input");let n=t?t.value.trim():"";if(!e||!n){closeModal("embed-modal");return}if(/^https?:\/\//i.test(n)||(n="https://"+n),!K(n)){window.showToast?window.showToast("Ugyldig URL. Du kan bare bygge inn innhold fra YouTube, Twitter/X, Bluesky eller Spotify.","error"):alert("Ugyldig URL. Du kan bare bygge inn innhold fra YouTube, Twitter/X, Bluesky eller Spotify.");return}if(y(e)){const r=`[embed]${n}[/embed] 9`;E(e,"","",r),closeModal("embed-modal");return}const o='<div class="forum-editor-embed" data-url="'+k(n)+'"><i class="fa-solid fa-code"></i> Embed: <a href="'+k(n)+'" target="_blank" rel="noopener noreferrer">'+x(n)+"</a></div><p><br></p>";M(e,o,S),closeModal("embed-modal")};function X(e){g=e,h(e);const t=document.getElementById("image-modal");t&&(t.style.display="flex",document.body.classList.add("no-scroll"));const n=document.getElementById("image-file-input");n&&(n.value="");const o=document.getElementById("file-chosen-text");o&&(o.innerText="Ingen fil valgt")}function G(e){if(!e)return"";
9if(e.nodeType===Node.TEXT_NODE)return e.nodeValue;if(e.nodeType!==Node.ELEMENT_NODE)return"";const t=e.tagName.toLowerCase();if(e.classList&&(e.classList.contains("forum-editor-spoiler")||e.classList.contains("forum-spoiler")))return"[spoiler]"+b(e)+"[/spoiler]";if(e.classList&&e.classList.contains("forum-editor-embed"))return` 10 11[embed]`+(e.getAttribute("data-url")||(e.querySelector("a")?e.querySelector("a").getAttribute("href"):"")).trim()+`[/embed] 12 13`;if(t==="blockquote"||e.classList&&e.classList.contains("forum-editor-quote")){const n=e.getAttribute("data-author")||"",o=e.getAttribute("data-ref")||"",r=e.querySelector(".forum-editor-quote-body")||e,i=b(r).trim();let s="[quote";return n&&(s+=' author="'+n+'"'),o&&(s+=' ref="'+o+'"'),s+="]",` 14 15`+s+` 16`+i+` 17[/quote] 18 19`}if(t==="img"){const n=e.getAttribute("data-filename");if(n)return` 20[bilde=`+n+`] 21`;const o=e.getAttribute("src")||"";if(o.includes("/storage/forum_images/")){const r=o.split("/storage/forum_images/");return` 22[bilde=`+r[r.length-1]+`] 23`}return o?` 24[bilde=`+o+`] 25`:""}if(t==="strong"||t==="b"){const n=b(e);return n?"**"+n+"**":""}if(t==="em"||t==="i"){const n=b(e);return n?"*"+n+"*":""}if(t==="s"||t==="strike"||t==="del"){const n=b(e);return n?"~~"+n+"~~":""}if(t==="u"){const n=b(e);return n?"[u]"+n+"[/u]":""}if(t==="a"){const n=(e.getAttribute("href")||"").trim(),o=b(e).trim();return n?"["+(o||n)+"]("+n+")":o}if(t==="ul"){let n=` 26 27`;return(e.querySelectorAll(":scope > li").length>0?e.querySelectorAll(":scope > li"):e.querySelectorAll("li")).forEach(r=>{const i=b(r).trim();i&&(n+="- "+i+` 28`)}),n+` 29`}if(t==="ol"){let n=` 30 31`,o=1;return(e.querySelectorAll(":scope > li").length>0?e.querySelectorAll(":scope > li"):e.querySelectorAll("li")).forEach(i=>{const s=b(i).trim();s&&(n+=o+++". "+s+` 32`)}),n+` 33`}if(t==="li")return b(e)+` 34`;if(t==="br")return` 35`;if(t==="p"||t==="div"){const n=e.querySelector("img, iframe, .forum-editor-embed, .forum-editor-quote, blockquote"),o=e.textContent.replace(/[\u200B-\u200D\uFEFF]/g,"").trim();if(!n&&!o)return` 36 37 38 39`;const r=b(e);return r?` 40 41`+r+` 42 43`:` 44 45 46 47`}if(/^h[1-6]$/.test(t)){const n=parseInt(t[1],10);return` 48 49`+"#".repeat(n)+" "+b(e).trim()+` 50 51`}if(e.style){let n=b(e);return(e.style.fontWeight==="bold"||parseInt(e.style.fontWeight,10)>=700)&&(n="**"+n+"**"),e.style.fontStyle==="italic"&&(n="*"+n+"*"),e.style.textDecoration&&e.style.textDecoration.includes("underline")&&(n="[u]"+n+"[/u]"),e.style.textDecoration&&e.style.textDecoration.includes("line-through")&&(n="~~"+n+"~~"),n}return b(e)}function b(e){let t="";for(let n=e.firstChild;n;n=n.nextSibling)t+=G(n);return t}function N(e){if(!e)return"";let t=b(e);return t=t.replace(/\r\n/g,` 52`),t=t.replace(/\n{3,}/g,` 53 54`),t.trim()}function I(e){if(!e)return"<p><br></p>";let t=String(e);const n=/\[quote([^\]]*)\]((?:(?!\[quote)[\s\S])*?)\[\/quote\]/i;let o=0;for(;n.test(t)&&o<20;)o++,t=t.replace(n,(l,c,u)=>{let w="";const L=c.match(/(?:author=|=)(?:"|"|[â"â«'])(.*?)(?:"|"|[â"â»'])/i)||c.match(/^=(?:"|"|[â"â«'])?([^"\'\]\s]+)/i);L&&L[1]&&(w=L[1].trim());let m="";const d=c.match(/(?:post_id|ref)=(?:"|"|[â"â«'])?([a-z0-9]+)/i);d&&d[1]&&(m=d[1]);const f=x(w),A=w?"Sitat fra "+f:"Sitat";return` 55 56<blockquote class="forum-editor-quote" data-author="`+k(w)+'" data-ref="'+k(m)+'"><div class="forum-editor-quote-head">'+A+'</div><div class="forum-editor-quote-body">'+I(u.trim())+`</div></blockquote> 57 58`});t=t.replace(/\[bilde=(.*?)\]/gi,(l,c)=>{let u=c.trim();!u.startsWith("http")&&!u.startsWith("/")&&(u="/storage/forum_images/"+u);const w=c.split("/").pop();return` 59 60<p><img src="`+k(u)+'" data-filename="'+k(w)+'" class="forum-editor-image" alt="'+k(w)+`"></p> 61 62`}),t=t.replace(/\[embed\](.*?)\[\/embed\]/gi,(l,c)=>{const u=c.trim();return` 63 64<div class="forum-editor-embed" data-url="`+k(u)+'"><i class="fa-solid fa-code"></i> Embed: <a href="'+k(u)+'" target="_blank">'+x(u)+`</a></div> 65 66`}),t=t.replace(/\[spoiler(?:=[^\]]*?)?\]([\s\S]*?)\[\/spoiler\]/gi,(l,c)=>"[spoiler]"+c.trim().replace(/\r\n|\r|\n/g," __PF_BR__ ")+"[/spoiler]");const r=t.split(` 67`);let i="",s=!1,a="ul";for(let l=0;l<r.length;l++){const c=r[l];if(/^[-*+]\s+(.*)$/.test(c)){const u=c.match(/^[-*+]\s+(.*)$/);(!s||a!=="ul")&&(s&&(i+="</"+a+">"),i+="<ul>",s=!0,a="ul"),i+="<li>"+_(u[1])+"</li>";continue}if(/^\d+\.\s+(.*)$/.test(c)){const u=c.match(/^\d+\.\s+(.*)$/);(!s||a!=="ol")&&(s&&(i+="</"+a+">"),i+="<ol>",s=!0,a="ol"),i+="<li>"+_(u[1])+"</li>";continue}if(s&&(i+="</"+a+">",s=!1),c.trim()===" "||c.trim()==="<br>"){i+="<p><br></p>";continue}if(c.trim()!==""){if(/^<(blockquote|div|p|h[1-6]|ul|ol|img)/i.test(c.trim())){i+=c;continue}i+="<p>"+_(c)+"</p>"}}return s&&(i+="</"+a+">"),i||"<p><br></p>"}function _(e){if(!e)return"";let t=x(e);return t=t.replace(/\[spoiler(?:=[^\]]*?)?\]([\s\S]*?)\[\/spoiler\]/gi,'<span class="forum-editor-sp
67oiler">$1</span>'),t=t.replace(/\s*__PF_BR__\s*/g,"<br>"),t=t.replace(/\[u\]([\s\S]*?)\[\/u\]/gi,"<u>$1</u>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^_]+)__/g,"<strong>$1</strong>"),t=t.replace(new RegExp("(?<!\\*)\\*(?!\\*)([^*\\n]+?)(?<!\\*)\\*(?!\\*)","g"),"<em>$1</em>"),t=t.replace(new RegExp("(?<!_)_(?!_)([^_\\n]+?)(?<!_)_(?!_)","g"),"<em>$1</em>"),t=t.replace(/~~([^~]+)~~/g,"<s>$1</s>"),t=t.replace(/\[url=(https?:\/\/[^\]\s]+)\]([\s\S]*?)\[\/url\]/gi,'<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>'),t=t.replace(/\[url\](https?:\/\/[^\]\s]+)\[\/url\]/gi,'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replace(/\[(https?:\/\/[^\s\]]+)\s+(https?:\/\/[^\s\]]+)\]/gi,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/gi,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replace(/\n/g,"<br>"),t}function ee(e){if(!(!e||y(e))){try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch{}if(e.innerHTML.trim()===""||e.innerHTML.trim()==="<br>"){e.innerHTML="<p><br></p>";const t=document.createRange(),n=window.getSelection();e.firstChild&&(t.setStart(e.firstChild,0),t.collapse(!0),n.removeAllRanges(),n.addRange(t))}}}function D(){Array.from(document.querySelectorAll(".forum-modal, .modal-overlay, .crop-modal")).some(t=>t.style.display!=="none"&&t.style.display!=="")||document.body.classList.remove("no-scroll")}window.openEditModal=function(e,t){const n=document.getElementById("raw-content-"+e),o=n?n.value:"",r=document.getElementById("edit-post-form"),i=document.getElementById("edit-post-editor"),s=document.getElementById("edit-post-modal");if(!r||!i||!s)return;const a=t||"/forum/innlegg/"+e+"/oppdater";r.setAttribute("action",a),r.dataset.postId=e,y(i)?i.value=o:i.innerHTML=I(o);const l=document.getElementById("edit-post-content");l&&(l.value=o),s.style.display="flex",document.body.classList.add("no-scroll"),g=i,setTimeout(()=>{i.focus(),y(i)||p(i)},50)},window.submitPostEdit=function(){var c,u;const e=document.getElementById("edit-post-form"),t=document.getElementById("edit-post-editor");if(!e||!t)return;const n=e.querySelector(".btn-submit");n&&(n.disabled=!0);const o=y(t)?t.value.trim():N(t),r=document.getElementById("edit-post-content");r&&(r.value=o);const i=e.getAttribute("action"),s=e.dataset.postId;if(!i||!s){n&&(n.disabled=!1);return}const a=((c=e.querySelector('input[name="_token"]'))==null?void 0:c.value)||((u=document.querySelector('meta[name="csrf-token"]'))==null?void 0:u.getAttribute("content"));closeModal("edit-post-modal");const l=document.getElementById("post-"+s);if(l){const w=l.cloneNode(!0),L=l.getBoundingClientRect();Z(w,L)}if(typeof htmx<"u"){const w=htmx.ajax("PUT",i,{target:"#post-"+s,select:"#post-"+s,swap:"outerHTML",values:{_token:a,content:o},headers:{"X-CSRF-TOKEN":a,"HX-Request":"true"}});w&&typeof w.then=="function"?w.then(()=>{n&&(n.disabled=!1)}).catch(()=>{n&&(n.disabled=!1)}):n&&(n.disabled=!1)}};function Z(e,t){if(!e||!t)return;const n=document.createElement("div");n.className="forum-shatter-wrapper",n.style.top=t.top+window.scrollY+"px",n.style.left=t.left+window.scrollX+"px",n.style.width=t.width+"px",n.style.height=t.height+"px";const o=["polygon(0% 0%, 28% 0%, 22% 38%, 0% 32%)","polygon(28% 0%, 55% 0%, 50% 35%, 22% 38%)","polygon(55% 0%, 78% 0%, 82% 33%, 50% 35%)","polygon(78% 0%, 100% 0%, 100% 36%, 82% 33%)","polygon(0% 32%, 22% 38%, 26% 68%, 0% 72%)","polygon(22% 38%, 50% 35%, 48% 70%, 26% 68%)","polygon(50% 35%, 82% 33%, 76% 67%, 48% 70%)","polygon(82% 33%, 100% 36%, 100% 69%, 76% 67%)","polygon(0% 72%, 26% 68%, 24% 100%, 0% 100%)","polygon(26% 68%, 48% 70%, 52% 100%, 24% 100%)","polygon(48% 70%, 76% 67%, 74% 100%, 52% 100%)","polygon(76% 67%, 100% 69%, 100% 100%, 74% 100%)"];e.id="",e.style.margin="0",e.style.width=t.width+"px",e.style.height=t.height+"px",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.animation="none",e.classList.remove("post-just-edited","post-just-added","post-just-restored","post-just-deleted"),o.forEach(r=>{const i=document.createElement("div");i.className="forum-shatter-shard",i.style.clipPath=r;const s=e.cloneNode(!0);i.appendChild(s);const a=(Math.random()-.5)*150,l=160+Math.random()*240,c=(Math.random()-.5)*140,u=Math.random()*.04;i.style.setProperty("--shatter-x",a+"px"),i.style.setProperty("--shatter-y",l+"px"),i.style.setProperty("--shatter-rot",c+"deg"),i.style.animationDelay=u+"s",n.appendChild(i)}),document.body.appendChild(n),setTimeout(()=>{n.remove()},1e3)}function $(){try{return JSON.parse(localStorage.getItem("pf_forum_last_seen")||"{}")}catch{return{}}}function te(e){try{localStorage.setItem("pf_forum_last_seen",JSON.stringify(e))}catch{}}function P(){const e=document.getElementById("forum-messages-stack");if(!e)return;const t=e.dataset.topicId;if(!t)return;const n=e.querySelectorAll('.forum-message-block[id^="post-"]');let o=0;if(n.forEach(r=>{const i=parseInt(r.id.replace("post-",""),10);i>o&&(o=i)}),o>0){const r=$();(r[t]||0)<o&&(r[t]=o,te(r))}}function U(){const e=$();document.querySelectorAll(".forum-node-row[data-topic-id]").forEach(t=>{const n=t.dataset.topicId,o=parseInt(t.dataset.latestPostId||"0",10);n&&o>0&&((e[n]||0)<o?t.classList.add("has-unread"):t.classList.remove("has-unread"))})}function B(){document.querySelectorAll("blockquote.bluesky-embed").forEach(t=>{const o=(t.getAttribute("data-bluesky-uri")||"").match(/at:\/\/(did:[^\/]+|did%3A[^\/]+|[^\/]+)\/app\.bsky\.feed\.post\/([a-zA-Z0-9]+)/);
67if(o){const r=decodeURIComponent(o[1]),i=o[2],s="bsky-"+Math.random().toString(36).substring(2,9),a="https://embed.bsky.app/embed/"+r+"/app.bsky.feed.post/"+encodeURIComponent(i)+"?id="+s+"&colorMode=dark",l=document.createElement("iframe");l.id=s,l.src=a,l.style.width="100%",l.style.maxWidth="550px",l.style.minHeight="200px",l.style.border="none",l.style.display="block",l.style.margin="15px auto",l.style.borderRadius="12px",l.style.overflow="hidden",l.scrolling="no",l.setAttribute("frameborder","0"),t.replaceWith(l)}}),(window.PFConsent?window.PFConsent.isAllowed("bluesky"):!1)&&document.querySelectorAll('.pf-embed[data-embed="bluesky"]').forEach(t=>{const n=t.getAttribute("data-did")||"",o=t.getAttribute("data-post")||"";if(n&&o){const r="bsky-"+Math.random().toString(36).substring(2,9),i="https://embed.bsky.app/embed/"+n+"/app.bsky.feed.post/"+encodeURIComponent(o)+"?id="+r+"&colorMode=dark",s=document.createElement("iframe");s.id=r,s.src=i,s.style.width="100%",s.style.maxWidth="550px",s.style.minHeight="200px",s.style.border="none",s.style.display="block",s.style.margin="15px auto",s.style.borderRadius="12px",s.style.overflow="hidden",s.scrolling="no",s.setAttribute("frameborder","0"),t.replaceWith(s)}}),window.__bskyResizeListenerAttached||(window.__bskyResizeListenerAttached=!0,window.addEventListener("message",t=>{if(t.origin!=="https://embed.bsky.app")return;const n=t.data;n&&typeof n.height=="number"&&document.querySelectorAll('iframe[src*="embed.bsky.app"]').forEach(o=>{(n.id&&o.id===n.id||o.contentWindow===t.source)&&(o.style.height=n.height+"px")})})),window.twttr&&window.twttr.widgets&&typeof window.twttr.widgets.load=="function"&&window.twttr.widgets.load()}return document.addEventListener("click",e=>{const t=e.target.closest('.pf-embed[data-embed="bluesky"]');if(!t)return;e.preventDefault();const n=t.getAttribute("data-did")||"",o=t.getAttribute("data-post")||"";if(n&&o){const r="bsky-"+Math.random().toString(36).substring(2,9),i="https://embed.bsky.app/embed/"+n+"/app.bsky.feed.post/"+encodeURIComponent(o)+"?id="+r+"&colorMode=dark",s=document.createElement("iframe");s.id=r,s.src=i,s.style.width="100%",s.style.maxWidth="550px",s.style.minHeight="200px",s.style.border="none",s.style.display="block",s.style.margin="15px auto",s.style.borderRadius="12px",s.style.overflow="hidden",s.scrolling="no",s.setAttribute("frameborder","0"),t.replaceWith(s)}}),document.addEventListener("click",e=>{const t=e.target.closest(".forum-topic-title-link");if(!t)return;const n=t.dataset.topicId,o=t.dataset.postUrlTemplate;if(!n||!o)return;const i=$()[n];if(i&&i>0){e.preventDefault();const s=(i*997+1e5).toString(36),a=o.replace(":code",s);window.htmx?htmx.ajax("GET",a,{target:"#forum-main-content",select:".forum-dynamic-payload",swap:"innerHTML",pushUrl:!0}):window.location.href=a}}),document.addEventListener("DOMContentLoaded",()=>{P(),U(),B()}),document.addEventListener("htmx:afterSwap",e=>{e.detail.target&&(e.detail.target.id==="forum-main-content"||e.detail.target.id==="spa-root"||e.detail.target.id==="forum-messages-stack")&&(P(),U(),B())}),document.addEventListener("htmx:afterSettle",()=>{B()}),window.addEventListener("popstate",()=>{setTimeout(()=>{P(),U(),B()},50)}),window.closeModal=function(e){const t=document.getElementById(e);t&&(t.style.display="none"),D()},window.toggleEmbedMenu=function(e){e.stopPropagation();const t=e.currentTarget.closest(".forum-embed-dropdown");if(!t)return;const n=t.querySelector(".forum-embed-menu");n&&n.classList.toggle("show")},window.toggleMoreMenu=function(e){e.stopPropagation();const t=e.currentTarget.closest(".forum-more-dropdown");if(!t)return;const n=t.querySelector(".forum-more-menu");n&&(document.querySelectorAll(".forum-embed-menu.show").forEach(o=>o.classList.remove("show")),n.classList.toggle("show"))},window.toggleTopicMenu=function(e){e.stopPropagation();const t=e.currentTarget.closest(".forum-topic-dropdown");if(!t)return;const n=t.querySelector(".topic-dropdown-menu");n&&n.classList.toggle("show")},document.addEventListener("selectionchange",()=>{const e=v();e&&!y(e)&&O(e)&&(h(e),p(e))}),document.addEventListener("paste",e=>{const t=e.target.closest?e.target.closest(q):null;if(!t||y(t))return;e.preventDefault();const n=(e.clipboardData||window.clipboardData).getData("text/plain");if(n){if(document.queryCommandSupported("insertText"))document.execCommand("insertText",!1,n);else{const o=window.getSelection();if(o&&o.rangeCount>0){const r=o.getRangeAt(0);r.deleteContents();const i=document.createTextNode(n);
67r.insertNode(i),r.setStartAfter(i),r.collapse(!0),o.removeAllRanges(),o.addRange(r)}}h(t),p(t)}}),document.addEventListener("mousedown",e=>{e.target.closest(".forum-editor-toolbar button, .forum-embed-menu button, .forum-more-menu button")&&e.preventDefault()}),document.addEventListener("click",e=>{const t=e.target.closest(".forum-editor-toolbar button[data-cmd], .forum-embed-menu button[data-cmd], .forum-more-menu button[data-cmd]");if(!t)return;e.preventDefault();const n=V(t.closest(".forum-markdown-editor"))||g;if(!n)return;g=n;const o=t.dataset.cmd;Y(o,t,n)}),document.addEventListener("click",e=>{const t=e.target.closest(".quote-trigger");if(!t)return;e.preventDefault();const n=t.getAttribute("data-displayname")||"",o=t.getAttribute("data-post-id")||"",r=t.getAttribute("data-content")||"";z(n,r,o)}),document.addEventListener("click",e=>{e.target.classList&&e.target.classList.contains("forum-modal")&&e.target.id!=="edit-post-modal"&&(e.target.style.display="none",D()),e.target.closest(".forum-embed-dropdown")||document.querySelectorAll(".forum-embed-menu.show").forEach(t=>t.classList.remove("show")),e.target.closest(".forum-more-dropdown")||document.querySelectorAll(".forum-more-menu.show").forEach(t=>t.classList.remove("show")),e.target.closest(".forum-topic-dropdown")||document.querySelectorAll(".topic-dropdown-menu.show").forEach(t=>t.classList.remove("show"))}),document.addEventListener("keydown",e=>{if(e.key==="Escape"){document.querySelectorAll(".forum-modal:not(#edit-post-modal)").forEach(n=>n.style.display="none"),document.querySelectorAll(".forum-embed-menu.show, .topic-dropdown-menu.show, .forum-more-menu.show").forEach(n=>n.classList.remove("show")),D();return}const t=e.target.closest?e.target.closest(q):null;if(t){if(g=t,y(t))return;if(e.key==="Enter"&&e.shiftKey){e.preventDefault(),T(t,"<br>"),h(t);return}}}),document.addEventListener("focusin",e=>{const t=e.target.closest?e.target.closest(q):null;t&&(g=t,y(t)||(ee(t),h(t),p(t)))}),document.addEventListener("keyup",e=>{const t=e.target.closest?e.target.closest(q):null;t&&(g=t,y(t)||(h(t),p(t)))}),document.addEventListener("mouseup",e=>{const t=e.target.closest?e.target.closest(q):null;t&&(g=t,y(t)||(h(t),p(t)))}),document.addEventListener("htmx:configRequest",e=>{const t=e.detail.elt&&e.detail.elt.closest?e.detail.elt.closest("form"):null;if(!t)return;const n=t.querySelector("textarea.forum-markdown-editor");if(n){const a=n.value.trim(),l=n.getAttribute("name")||"content";e.detail.parameters[l]=a,e.detail.formData&&e.detail.formData.set(l,a);return}const o=t.querySelector('.forum-richtext[contenteditable="true"]');if(!o)return;const r=o.getAttribute("data-content-input")||"content",i=N(o),s=t.querySelector('input[name="'+r+'"]');s&&(s.value=i),e.detail.parameters[r]=i,e.detail.formData&&e.detail.formData.set(r,i)}),document.addEventListener("htmx:afterRequest",e=>{if(e.detail.successful){const t=e.detail.elt&&e.detail.elt.closest?e.detail.elt.closest("form"):null;if(t){const n=t.querySelector("textarea.forum-markdown-editor");n&&n.id!=="edit-post-editor"&&(n.value="");const o=t.querySelector('.forum-richtext[contenteditable="true"]');o&&o.id!=="edit-post-editor"&&(o.innerHTML="<p><br></p>",p(o)),t.querySelectorAll('input[name="forum_images[]"]').forEach(r=>r.remove())}}}),document.addEventListener("htmx:afterSwap",e=>{if(e.detail.target&&e.detail.target.id==="forum-messages-stack"){const t=e.detail.target.querySelector(".post-just-added:last-child");t&&setTimeout(()=>{t.scrollIntoView({behavior:"smooth",block:"center"})},50)}}),document.addEventListener("htmx:beforeRequest",e=>{var n;const t=e.detail.elt;if(t&&(t.hasAttribute("hx-delete")||t.tagName==="FORM"&&((n=t.getAttribute("method"))==null?void 0:n.toLowerCase())==="delete")){if(t.getAttribute("data-admin-soft-delete")==="true")return;const o=t.getAttribute("hx-target"),r=o?document.querySelector(o):t.closest(".forum-message-block");if(r&&r.classList.contains("forum-message-block")){const i=r.cloneNode(!0),s=r.getBoundingClientRect();r.style.height=s.height+"px",r.style.maxHeight=s.height+"px",r.style.visibility="hidden",Z(i,s),setTimeout(()=>{r.classList.add("forum-post-collapsing")},500)}}}),window.pfInsertQuotedPost=function(e,t,n){z(e,t,n)},{serialize:N,fromMarkdown:I,focusedEditor:v,inlineToHtml:_,updateToolbarState:p}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.