1// See the "/licenses" URI for full package license details 2var uo=Object.defineProperty;var po=i=>{throw TypeError(i)};var zs=(i,e,t)=>e in i?uo(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Ks=(i,e)=>{for(var t in e)uo(i,t,{get:e[t],enumerable:!0})};var c=(i,e,t)=>zs(i,typeof e!="symbol"?e+"":e,t),Xs=(i,e,t)=>e.has(i)||po("Cannot "+t);var mo=(i,e,t)=>e.has(i)?po("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t);var ie=(i,e,t)=>(Xs(i,e,"access private method"),t);var xe=class{constructor(){c(this,"listeners",{});c(this,"stack",[])}emit(e,t={}){this.stack.push({name:e,data:t});let n=this.listeners[e]||[];for(let o of n)o(t)}listen(e,t){typeof this.listeners[e]>"u"&&(this.listeners[e]=[]),this.listeners[e].push(t)}remove(e,t){let n=this.listeners[e]||[],o=n.indexOf(t);o!==-1&&n.splice(o,1)}emitPublic(e,t,n){let o=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(o)}success(e){this.emit("success",e)}error(e){this.emit("error",e)}showValidationErrors(e){if(e.status===422&&e.data instanceof Object){let t=e.data,o=Object.values(t.errors??t).flat().join(` 3`);this.error(o)}}showResponseError(e){e.status&&e.status>=400&&typeof e.data=="object"&&e.data.message&&this.error(e.data.message)}};var At=class extends Error{constructor(t,n){super(t.statusText);c(this,"data");c(this,"headers");c(this,"original");c(this,"redirected");c(this,"status");c(this,"statusText");c(this,"url");this.data=n,this.headers=t.headers,this.redirected=t.redirected,this.status=t.status,this.statusText=t.statusText,this.url=t.url,this.original=t}},Le=class{async getResponseContent(e){if(e.status===204)return null;let n=(e.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return n==="javascript"||n==="json"?e.json():e.text()}createXMLHttpRequest(e,t,n={}){let o=document.querySelector("meta[name=token]")?.getAttribute("content"),s=new XMLHttpRequest;for(let[r,a]of Object.entries(n))s.addEventListener(r,a.bind(s));return s.open(e,t),s.withCredentials=!0,s.setRequestHeader("X-CSRF-TOKEN",o||""),s}async request(e,t={}){let n=e;if(n.startsWith("http")||(n=window.baseUrl(n)),t.params){let d=new URL(n);for(let m of Object.keys(t.params)){let p=t.params[m];typeof p<"u"&&p!==null&&d.searchParams.set(m,p)}n=d.toString()}let o=document.querySelector("meta[name=token]")?.getAttribute("content")||"",s={...t,credentials:"same-origin"};s.headers={...s.headers||{},baseURL:window.baseUrl(""),"X-CSRF-TOKEN":o};let r=await fetch(n,s),a=await this.getResponseContent(r)||"",l={data:a,headers:r.headers,redirected:r.redirected,status:r.status,statusText:r.statusText,url:r.url,original:r};if(!r.ok)throw new At(r,a);return l}async dataRequest(e,t,n){let o={method:e,body:n};return typeof n=="object"&&!(n instanceof FormData)&&(o.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},o.body=JSON.stringify(n)),n instanceof FormData&&e!=="post"&&(n.append("_method",e),o.method="post"),this.request(t,o)}async get(e,t={}){return this.request(e,{method:"GET",params:t})}async post(e,t=null){return this.dataRequest("POST",e,t)}async put(e,t=null){return this.dataRequest("PUT",e,t)}async patch(e,t=null){return this.dataRequest("PATCH",e,t)}async delete(e,t=null){return this.dataRequest("DELETE",e,t)}formatErrorResponseText(e){let t=e.startsWith("{")?JSON.parse(e):{message:e};if(!t)return e;if(t.message||t.error)return t.message||t.error;let n=Object.values(t.errors||{});return n.length>0&&n.every(s=>Array.isArray(s)&&s.every(r=>typeof r=="string"))?n.flat().join(" "):e}};var Te=class{choice(e,t,n={}){n=Object.assign({},{count:String(t)},n);let o=e.split("|"),s=/^{([0-9]+)}/,r=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let d=l.match(s);if(d!==null&&Number(d[1])===t){a=l.replace(s,"").trim();break}let m=l.match(r);if(m!==null&&Number(m[1])<=t&&(m[2]==="*"||Number(m[2])>=t)){a=l.replace(r,"").trim();break}}return a===null&&o.length>1&&(a=t===1?o[0]:o[1]),a===null&&(a=o[0]),this.performReplacements(a,n)}performReplacements(e,t){let n=e.match(/:(\S+)/g);if(n===null)return e;let o=e;for(let s of n){let r=s.substring(1);typeof t[r]>"u"||(o=o.replace(s,t[r]))}return o}};var lo={};Ks(lo,{AddRemoveRows:()=>Me,AjaxDeleteRow:()=>Ae,AjaxForm:()=>De,ApiNav:()=>Ie,Attachments:()=>He,AttachmentsList:()=>Pe,AutoSubmit:()=>Re,AutoSuggest:()=>Be,BackToTop:()=>Oe,BookSort:()=>tn,ChapterContents:()=>nn,CodeEditor:()=>on,CodeHighlighter:()=>sn,CodeTextarea:()=>rn,Collapsible:()=>an,ConfirmDialog:()=>ln,CustomCheckbox:()=>cn,DetailsHighlighter:()=>dn,Dropdown:()=>hn,DropdownSearch:()=>un,Dropzone:()=>pn,EditorToolbox:()=>mn,EntityPermissions:()=>fn,EntitySearch:()=>gn,EntitySelector:()=>vn,EntitySelectorPopup:()=>bn,EventEmitSelect:()=>wn,ExpandToggle:()=>yn,GlobalSearch:()=>En,HeaderMobileToggle:()=>Cn,ImageManager:()=>xn,ImagePicker:()=>
3Ln,LayoutEditor:()=>Tn,ListSortControl:()=>Sn,LoadingButton:()=>kn,MarkdownEditor:()=>$n,NewUserPassword:()=>Mn,Notification:()=>An,OptionalInput:()=>Dn,PageComment:()=>In,PageCommentReference:()=>Hn,PageComments:()=>Pn,PageDisplay:()=>Bn,PageEditor:()=>Rn,PagePicker:()=>Nn,PermissionsTable:()=>_n,Pointer:()=>Fn,Popup:()=>qn,SettingAppColorScheme:()=>Wn,SettingColorPicker:()=>jn,SettingHomepageControl:()=>Un,ShelfSort:()=>Vn,ShortcutInput:()=>Kn,Shortcuts:()=>zn,SortRuleManager:()=>Gn,SortableList:()=>Xn,SubmitOnChange:()=>Yn,Tabs:()=>ee,TagManager:()=>Jn,TemplateManager:()=>Zn,ToggleSwitch:()=>Qn,ToolboxContents:()=>ni,TriLayout:()=>ii,UserSelect:()=>oi,WebhookEvents:()=>si,WysiwygEditor:()=>ri,WysiwygEditorTinymce:()=>ui,WysiwygInput:()=>pi});function ft(i,e,t){let n=null;return function(...s){let r=this,a=function(){n=null,t||i.apply(r,s)},l=t&&!n;n&&clearTimeout(n),n=window.setTimeout(a,e),l&&i.apply(r,s)}}function Gs(i){return i.nodeName==="DETAILS"}function Dt(i){if(!i)return;let e=i;for(;e.parentElement;)e=e.parentElement,Gs(e)&&!e.open&&(e.open=!0);i.scrollIntoView({behavior:"smooth"});let t=getComputedStyle(document.body).getPropertyValue("--color-link");i.style.outline=`2px dashed ${t}`,i.style.outlineOffset="5px",i.style.removeProperty("transition"),setTimeout(()=>{i.style.transition="outline linear 3s",i.style.outline="2px dashed rgba(0, 0, 0, 0)";let n=()=>{i.removeEventListener("transitionend",n),i.style.removeProperty("transition"),i.style.removeProperty("outline"),i.style.removeProperty("outlineOffset")};i.addEventListener("transitionend",n)},1e3)}function fo(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function go(){let i=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${i()+i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}function vo(i){return new Promise(e=>{setTimeout(e,i)})}function bo(i){let e=i,t=document.querySelector('meta[name="base-url"]');if(!t)throw new Error("Could not find expected base-url meta tag in document");let n=t.getAttribute("content")||"";return n[n.length-1]==="/"&&(n=n.slice(0,n.length-1)),e[0]==="/"&&(e=e.slice(1)),`${n}/${e}`}function Ys(){let i=document.querySelector('link[href*="/dist/styles.css?version="]');if(!i)throw new Error("Could not find expected style link in document for version use");return(i.getAttribute("href")||"").split("?version=").pop()||""}function wo(i){return import(window.baseUrl(`dist/${i}.js?version=${Ys()}`))}function yo(i,e=0){let t=3735928559^e,n=1103547991^e;for(let o=0,s;o<i.length;o++)s=i.charCodeAt(o),t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),String(4294967296*(2097151&n)+(t>>>0))}function xt(i){return i instanceof HTMLElement}function Q(i,e={},t=[]){let n=document.createElement(i);for(let[o,s]of Object.entries(e))s===null?n.removeAttribute(o):n.setAttribute(o,s);for(let o of t)typeof o=="string"?n.append(document.createTextNode(o)):n.append(o);return n}function fi(i,e){let t=document.querySelectorAll(i);for(let n of t)e(n)}function Se(i,e,t){if(i)for(let n of e)i.addEventListener(n,t)}function H(i,e){Array.isArray(i)||(i=[i]);for(let t of i)t.addEventListener("click",e),t.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),e(n))})}function Eo(i,e,t){Array.isArray(e)||(e=[e]);let n=o=>{o.key===i&&t(o)};e.forEach(o=>o.addEventListener("keydown",n))}function qt(i,e){Eo("Enter",i,e)}function Co(i,e){Eo("Escape",i,e)}function W(i,e,t,n){i.addEventListener(t,o=>{let s=o.target?.closest(e);s&&n.call(s,o,s)})}function xo(i,e){let t=document.querySelectorAll(i);e=e.toLowerCase();for(let n of t)if((n.textContent||"").toLowerCase().includes(e)&&xt(n))return n;return null}function It(i){i.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Wt(){let i=document.createElement("div");return i.classList.add("loading-container"),i.innerHTML="<div></div><div></div><div></div>",i}function oe(i){let e=i.querySelectorAll(".loading-container");for(let t of e)t.remove()}function lt(i){let e=document.createElement("div");e.innerHTML=i,window.$components.init(e);let t=e.children[0];if(!xt(t))throw new Error("Could not find child HTMLElement when creating DOM element from HTML");return t}function gi(i,e,t){if(!t.contains(i))throw new Error("ParentElement must be a prent of element");let n=e,o=i.nodeType===Node.TEXT_NODE?i:i.childNodes[e];for(;o!==t&&o;)o.previousSibling?(o=o.previousSibling,n+=o.textContent?.length||0):o=o.parentNode;return n}function ke(i,e){if(e===0)return{node:i,offset:0};let t=0,n=null;for(let o=0;o<i.childNodes.length;o++)if(n=i.childNodes[o],n.nodeType===Node.TEXT_NODE){let s=(n.textContent||"").length;if(t+s>=e)return{node:n,offset:e-t};t+=s}else if(n.nodeType===Node.ELEMENT_NODE){let s=(n.textContent||"").length;if(t+s>=e)return ke(n,e-t);t+=s}return null}function $e(i){let e=(i.textContent||"").replace(/\s{2,}/g,"");return yo(e)}function Lo(i){let e=i;
3do{if(window.getComputedStyle(e).overflowY==="scroll")return e;e=e.parentElement}while(e);return document.body}var h=class{constructor(){c(this,"$name","");c(this,"$el",null);c(this,"$refs",{});c(this,"$manyRefs",{});c(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let n=this.$name,o=new CustomEvent(`${n}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(o)}};var Me=class extends h{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),W(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.$components.init(e)}setClonedInputNames(e){let t=go(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}};var Ae=class extends h{constructor(){super(...arguments);c(this,"row");c(this,"url");c(this,"deleteButtons",[])}setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete||[],H(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(t=>{typeof t.data=="object"&&t.data.message&&window.$events.emit("success",t.data.message),this.row.remove()}).catch(()=>{this.row.style.removeProperty("opacity"),this.row.style.removeProperty("pointer-events")})}};var De=class extends h{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}qt(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>H(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let n of t)e.append(n.getAttribute("name"),n.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var Ie=class extends h{constructor(){super(...arguments);c(this,"select");c(this,"sidebar");c(this,"body")}setup(){this.select=this.$refs.select,this.sidebar=this.$refs.sidebar,this.body=this.$el.ownerDocument.documentElement,this.select.addEventListener("change",()=>{let t=this.select.value,n=document.getElementById(`sidebar-header-${t}`),o=document.getElementById(`section-${t}`);if(n&&o){let s=n.getBoundingClientRect().top-this.sidebar.getBoundingClientRect().top+this.sidebar.scrollTop;this.sidebar.scrollTo({top:s-120,behavior:"smooth"});let r=o.getBoundingClientRect().top+this.body.scrollTop;this.body.scrollTo({top:r-20,behavior:"smooth"})}})}};var He=class extends h{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.linksContainer=this.$refs.linksContainer,this.listPanel=this.$refs.listPanel,this.attachLinkButton=this.$refs.attachLinkButton,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-upload-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",()=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(n);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(e){let t={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[n,o]of Object.entries(t))o.toggleAttribute("hidden",n!==e)}reloadList(){this.stopEdit(),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.listPanel.innerHTML=e.data,window.$components.init(this.listPanel)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.showSection("edit"),It(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.showSection("list")}};var Pe=class extends h{setup(){this.container=this.$el,this.fileLinks=this.$manyRefs.linkTypeFile,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){for(let e of this.fileLinks)e.href.split("?")[1]!=="open=true"&&(e.href+="?open=true",e.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){for(let e of this.fileLinks)e.href=e.href.split("?")[0],e.removeAttribute("target")}};var Tt,bi,wi,Lt=class{constructor(e,t=null,n=null){mo(this,Tt);c(this,"containers");c(this,"onEscape");c(this,"onEnter");this.containers=[e],this.onEscape=t,this.onEnter=n,e.addEventListener("keydown",ie(this,Tt,bi).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",ie(this,Tt,bi).bind(this))}focusNext(){let e=ie(this,Tt,wi).call(this),t=document.activeElement,o=(xt(t)?e.indexOf(t):-1)+1;o>=e.length&&(o=0),e[o].focus()}focusPrevious(){let e=ie(this,Tt,wi).call(this),t=document.activeElement,o=(xt(t)?e.indexOf(t):-1)-1;o<0&&(o=e.length-1),e[o].focus()}};Tt=new WeakSet,bi=function(e){xt(e.target)&&e.target.matches("input")&&(e.key==="ArrowRight"||e.key==="ArrowLeft")||(e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):xt(document.activeElement)&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e))}
3,wi=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let n of this.containers){let o=[...n.querySelectorAll(t)].filter(s=>xt(s)&&s.checkVisibility());e.push(...o)}return e};var yi={},Be=class extends h{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){new Lt(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault();let n=t.target.textContent;n&&this.selectSuggestion(n)}).shareHandlingToEl(this.input),W(this.list,".text-item","click",(t,n)=>{this.selectSuggestion(n.textContent)}),this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.input.addEventListener("keydown",t=>{t.key==="Tab"&&this.hideSuggestions()})}selectSuggestion(e){this.input.value=e,this.lastPopulated=Date.now(),this.input.focus(),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hideSuggestions()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let e=this.getNameFilterIfNeeded(),t=this.input.value.toLowerCase(),o=(await this.loadSuggestions(t,e)).filter(s=>t===""||s.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(o)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let n={search:e,name:t},o=`${this.url}:${JSON.stringify(n)}`;if(yi[o])return yi[o];let s=await window.$http.get(this.url,n);return yi[o]=s.data,s.data}displaySuggestions(e){if(e.length===0){this.hideSuggestions();return}this.list.innerHTML=e.map(t=>`<li><div tabindex="0" class="text-item">${fo(t)}</div></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll(".text-item"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var Re=class extends h{setup(){this.form=this.$el,this.form.submit()}};var Oe=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"button");c(this,"progress");c(this,"progressPath");c(this,"targetElem");c(this,"showing",!1);c(this,"breakPoint",1200);c(this,"isAnimating",!1)}setup(){if(this.container=this.$el,this.button=this.$refs.button,this.progress=this.$refs.progress,this.progressPath=this.$refs.progressPath,this.targetElem=document.getElementById("header"),document.body.classList.contains("flexbox")){this.container.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this)),this.setupProgressBar()}setupProgressBar(){this.button.addEventListener("transitionstart",n=>{n.target===this.button&&(this.isAnimating=!0,this.renderProgressPath())});let t=n=>{n.target===this.button&&(this.isAnimating=!1)};this.button.addEventListener("transitionend",t),this.button.addEventListener("transitioncancel",t),this.renderProgressPath()}onPageScroll(){let t=document.documentElement.scrollTop||document.body.scrollTop||0;if(!this.showing&&t>this.breakPoint?(this.container.style.display="block",this.showing=!0,setTimeout(()=>{this.container.style.opacity="0.4"},1)):this.showing&&t<this.breakPoint&&(this.container.style.opacity="0",this.showing=!1,setTimeout(()=>{this.container.style.display="none"},500)),this.showing){let n=document.documentElement.scrollHeight-window.innerHeight,o=t/n*100;this.updateProgress(o)}}scrollToTop(){let t=this.targetElem.getBoundingClientRect().top,n=document.documentElement.scrollTop?document.documentElement:document.body,o=300,s=Date.now(),r=this.targetElem.getBoundingClientRect().top,a=()=>{let l=1-(Date.now()-s)/o,d=Math.abs(l*r);l>0?(n.scrollTop=d,requestAnimationFrame(a)):n.scrollTop=t};requestAnimationFrame(a)}renderProgressPath(){let t=this.button.getBoundingClientRect(),n=window.getComputedStyle(this.progress).insetInlineStart,o=Math.abs(Number(n.replace("px","")||0)),s=this.roundedRectPath(t.
3width,t.height,t.height/2,o);this.progressPath.setAttribute("d",s),this.isAnimating&&window.requestAnimationFrame(this.renderProgressPath.bind(this))}updateProgress(t){t<5&&(t=5),this.progressPath.setAttribute("stroke-dasharray",`${Math.ceil(t)} 100`)}roundedRectPath(t,n,o,s=1.5){let r=t+2*s,a=n+2*s,l=Math.min(o+s,r/2,a/2);return[`M ${r/2} 0`,`H ${r-l}`,`A ${l} ${l} 0 0 1 ${r} ${l}`,`V ${a-l}`,`A ${l} ${l} 0 0 1 ${r-l} ${a}`,`H ${l}`,`A ${l} ${l} 0 0 1 0 ${a-l}`,`V ${l}`,`A ${l} ${l} 0 0 1 ${l} 0`,"Z"].join(" ")}};function Di(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function Js(i){if(Array.isArray(i))return Di(i)}function Zs(i,e,t){return(e=sr(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ht(){return ht=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},ht.apply(null,arguments)}function Qs(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function tr(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 4In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(i,o).enumerable})),t.push.apply(t,n)}return t}function vt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?To(Object(t),!0).forEach(function(n){Zs(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):To(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function er(i,e){if(i==null)return{};var t,n,o=nr(i,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(n=0;n<s.length;n++)t=s[n],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(i,t)&&(o[t]=i[t])}return o}function nr(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}function ir(i){return Js(i)||Qs(i)||rr(i)||tr()}function or(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function sr(i){var e=or(i,"string");return typeof e=="symbol"?e:e+""}function Ii(i){"@babel/helpers - typeof";return Ii=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ii(i)}function rr(i,e){if(i){if(typeof i=="string")return Di(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Di(i,e):void 0}}var ar="1.15.7";function bt(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var wt=bt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),ve=bt(/Edge/i),So=bt(/firefox/i),ue=bt(/safari/i)&&!bt(/chrome/i)&&!bt(/android/i),Oi=bt(/iP(ad|od|hone)/i),Ro=bt(/chrome/i)&&bt(/android/i),Oo={capture:!1,passive:!1};function I(i,e,t){i.addEventListener(e,t,!wt&&Oo)}function D(i,e,t){i.removeEventListener(e,t,!wt&&Oo)}function Xe(i,e){if(e){if(e[0]===">"&&(e=e.substring(1)),i)try{if(i.matches)return i.matches(e);if(i.msMatchesSelector)return i.msMatchesSelector(e);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(e)}catch{return!1}return!1}}function No(i){return i.host&&i!==document&&i.host.nodeType&&i.host!==i?i.host:i.parentNode}function ot(i,e,t,n){if(i){t=t||document;do{if(e!=null&&(e[0]===">"?i.parentNode===t&&Xe(i,e):Xe(i,e))||n&&i===t)return i;if(i===t)break}while(i=No(i))}return null}var ko=/\s+/g;
vendor: 32,720 bytes, line 4
4function K(i,e,t){if(i&&e)if(i.classList)i.classList[t?"add":"remove"](e);else{var n=(" "+i.className+" ").replace(ko," ").replace(" "+e+" "," ");i.className=(n+(t?" "+e:"")).replace(ko," ")}}function C(i,e,t){var n=i&&i.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(t=i.currentStyle),e===void 0?t:t[e];!(e in n)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),n[e]=t+(typeof t=="string"?"":"px")}}function Rt(i,e){var t="";if(typeof i=="string")t=i;else do{var n=C(i,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(i=i.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(t)}function _o(i,e,t){if(i){var n=i.getElementsByTagName(e),o=0,s=n.length;if(t)for(;o<s;o++)t(n[o],o);return n}return[]}function gt(){var i=document.scrollingElement;return i||document.documentElement}function _(i,e,t,n,o){if(!(!i.getBoundingClientRect&&i!==window)){var s,r,a,l,d,m,p;if(i!==window&&i.parentNode&&i!==gt()?(s=i.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,d=s.right,m=s.height,p=s.width):(r=0,a=0,l=window.innerHeight,d=window.innerWidth,m=window.innerHeight,p=window.innerWidth),(e||t)&&i!==window&&(o=o||i.parentNode,!wt))do if(o&&o.getBoundingClientRect&&(C(o,"transform")!=="none"||t&&C(o,"position")!=="static")){var v=o.getBoundingClientRect();r-=v.top+parseInt(C(o,"border-top-width")),a-=v.left+parseInt(C(o,"border-left-width")),l=r+s.height,d=a+s.width;break}while(o=o.parentNode);if(n&&i!==window){var y=Rt(o||i),u=y&&y.a,f=y&&y.d;y&&(r/=f,a/=u,p/=u,m/=f,l=r+m,d=a+p)}return{top:r,left:a,bottom:l,right:d,width:p,height:m}}}function $o(i,e,t){for(var n=$t(i,!0),o=_(i)[e];n;){var s=_(n)[t],r=void 0;if(t==="top"||t==="left"?r=o>=s:r=o<=s,!r)return n;if(n===gt())break;n=$t(n,!1)}return!1}function Xt(i,e,t,n){for(var o=0,s=0,r=i.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==T.ghost&&(n||r[s]!==T.dragged)&&ot(r[s],t.draggable,i,!1)){if(o===e)return r[s];o++}s++}return null}function Ni(i,e){for(var t=i.lastElementChild;t&&(t===T.ghost||C(t,"display")==="none"||e&&!Xe(t,e));)t=t.previousElementSibling;return t||null}function X(i,e){var t=0;if(!i||!i.parentNode)return-1;for(;i=i.previousElementSibling;)i.nodeName.toUpperCase()!=="TEMPLATE"&&i!==T.clone&&(!e||Xe(i,e))&&t++;return t}function Mo(i){var e=0,t=0,n=gt();if(i)do{var o=Rt(i),s=o.a,r=o.d;e+=i.scrollLeft*s,t+=i.scrollTop*r}while(i!==n&&(i=i.parentNode));return[e,t]}function lr(i,e){for(var t in i)if(i.hasOwnProperty(t)){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===i[t][n])return Number(t)}return-1}function $t(i,e){if(!i||!i.getBoundingClientRect)return gt();var t=i,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=C(t);if(t.clientWidth<t.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return gt();if(n||e)return t;n=!0}}while(t=t.parentNode);return gt()}function cr(i,e){if(i&&e)for(var t in e)e.hasOwnProperty(t)&&(i[t]=e[t]);return i}function Ei(i,e){return Math.round(i.top)===Math.round(e.top)&&Math.round(i.left)===Math.round(e.left)&&Math.round(i.height)===Math.round(e.height)&&Math.round(i.width)===Math.round(e.width)}var pe;function Fo(i,e){return function(){if(!pe){var t=arguments,n=this;t.length===1?i.call(n,t[0]):i.apply(n,t),pe=setTimeout(function(){pe=void 0},e)}}}function dr(){clearTimeout(pe),pe=void 0}function qo(i,e,t){i.scrollLeft+=e,i.scrollTop+=t}function _i(i){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(i).cloneNode(!0):t?t(i).clone(!0)[0]:i.cloneNode(!0)}function Ao(i,e){C(i,"position","absolute"),C(i,"top",e.top),C(i,"left",e.left),C(i,"width",e.width),C(i,"height",e.height)}function Ci(i){C(i,"position",""),C(i,"top",""),C(i,"left",""),C(i,"width",""),C(i,"height","")}function Wo(i,e,t){var n={};return Array.from(i.children).forEach(function(o){var s,r,a,l;if(!(!ot(o,e.draggable,i,!1)||o.animated||o===t)){var d=_(o);n.left=Math.min((s=n.left)!==null&&s!==void 0?s:1/0,d.left),n.top=Math.min((r=n.top)!==null&&r!==void 0?r:1/0,d.top),n.right=Math.max((a=n.right)!==null&&a!==void 0?a:-1/0,d.right),n.bottom=Math.max((l=n.bottom)!==null&&l!==void 0?l:-1/0,d.bottom)}}),n.width=n.right-n.left,n.height=n.bottom-n.top,n.x=n.left,n.y=n.top,n}var Y="Sortable"+new Date().getTime();function hr(){var i=[],e;return{captureAnimationState:function(){if(i=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(C(o,"display")==="none"||o===T.ghost)){i.push({target:o,rect:_(o)});var s=vt({},i[i.length-1].rect);if(o.thisAnimationDuration){var r=Rt(o,!0);r&&(s.top-=r.f,s.left-=r.e)}o.fromRect=s}})}},addAnimationState:function(n){i.push(n)},removeAnimationState:function(n){i.splice(lr(i,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,r=0;i.forEach(function(a){var l=0,d=a.target,m=d.fromRect,p=_(d),v=d.prevFromRect,y=d.prevToRect,u=a.rect,f=Rt(d,!0);f&&(p.top-=f.f,p.left-=f.e),d.toRect=p,d.thisAnimationDuration&&Ei(v,p)&&!Ei(m,p)&&(u.top-p.top)/(u.left-p.left)===(m.top-p.top)/(m.left-p.left)&&(l=pr(u,v,y,o.options)),Ei(p,m)||(d.prevFromRect=m,d.prevToRect=p,l||(l=o.options.animation),o.animate(d,u,p,l)),l&&(s=!0,r=Math.max(r,l),clearTimeout(d.animationResetTimer),d.animationResetTimer=setTimeout(function(){d.animationTime=0,d.prevFromRect=null,d.fromRect=null,d.prevToRect=null,d.thisAnimationDuration=null},l),d.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof n=="function"&&n()},r):typeof n=="function"&&n(),i=[]},animate:function(n,o,s,r){if(r){C(n,"transition",""),C(n,"transform","");var a=Rt(this.el),l=a&&a.a,d=a&&a.d,m=(o.left-s.left)/(l||1),p=(o.top-s.top)/(d||1);n.animatingX=!!m,n.animatingY=!!p,C(n,"transform","translate3d("+m+"px,"+p+"px,0)"),this.forRepaintDummy=ur(n),C(n,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),C(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){C(n,"transition",""),C(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},r)}}}}function ur(i){return i.offsetWidth}function pr(i,e,t,n){return Math.sqrt(Math.pow(e.top-i.top,2)+Math.pow(e.left-i.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*n.animation}var jt=[],xi={initializeByDefault:!0},be={mount:function(e){for(var t in xi)xi.hasOwnProperty(t)&&!(t in e)&&(e[t]=xi[t]);jt.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),jt.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";jt.forEach(function(r){t[r.pluginName]&&(t[r.pluginName][s]&&t[r.pluginName][s](vt({sortable:t},n)),t.options[r.pluginName]&&t[r.pluginName][e]&&t[r.pluginName][e](vt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){jt.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var d=new a(e,t,e.options);d.sortable=e,d.options=e.options,e[l]=d,ht(n,d.defaults)}});for(var s in e.options)if(e.options.hasOwnProperty(s)){var r=this.modifyOption(e,s,e.options[s]);typeof r<"u"&&(e.options[s]=r)}},getEventProperties:function(e,t){var n={};return jt.forEach(function(o){typeof o.eventProperties=="function"&&ht(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return jt.forEach(function(s){e[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function le(i){var e=i.sortable,t=i.rootEl,n=i.name,o=i.targetEl,s=i.cloneEl,r=i.toEl,a=i.fromEl,l=i.oldIndex,d=i.newIndex,m=i.oldDraggableIndex,p=i.newDraggableIndex,v=i.originalEvent,y=i.putSortable,u=i.extraEventProperties;if(e=e||t&&t[Y],!!e){var f,w=e.options,E="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!wt&&!ve?f=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(f=document.createEvent("Event"),f.initEvent(n,!0,!0)),f.to=r||t,f.from=a||t,f.item=o||t,f.clone=s,f.oldIndex=l,f.newIndex=d,f.oldDraggableIndex=m,f.newDraggableIndex=p,f.originalEvent=v,f.pullMode=y?y.lastPutMode:void 0;var b=vt(vt({},u),be.getEventProperties(n,e));for(var L in b)f[L]=b[L];t&&t.dispatchEvent(f),w[E]&&w[E].call(e,f)}}var mr=["evt"],nt=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=er(n,mr);be.pluginEvent.bind(T)(e,t,vt({dragEl:g,parentEl:j,ghostEl:M,rootEl:F,nextEl:Bt,lastDownEl:Ue,cloneEl:q,cloneHidden:kt,dragStarted:ce,putSortable:G,activeSortable:T.active,originalEvent:o,oldIndex:Kt,oldDraggableIndex:me,newIndex:at,newDraggableIndex:St,hideGhostForTarget:zo,unhideGhostForTarget:Ko,cloneNowHidden:function(){kt=!0},cloneNowShown:function(){kt=!1},dispatchSortableEvent:function(a){tt({sortable:t,name:a,originalEvent:o})}},s))};function tt(i){le(vt({putSortable:G,cloneEl:q,targetEl:g,rootEl:F,oldIndex:Kt,oldDraggableIndex:me,newIndex:at,newDraggableIndex:St},i))}var g,j,M,F,Bt,Ue,q,kt,Kt,at,me,St,Ne,G,zt=!1,Ge=!1,Ye=[],Ht,ct,Li,Ti,Do,Io,ce,Ut,fe,ge=!1,_e=!1,Ve,J,Si=[],Hi=!1,Je=[],Qe=typeof document<"u",Fe=Oi,Ho=ve||wt?"cssFloat":"float",fr=Qe&&!Ro&&!Oi&&"draggable"in document.createElement("div"),jo=(function(){if(Qe){if(wt)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}})(),Uo=function(e,t){var n=C(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=Xt(e,0,t),r=Xt(e,1,t),a=s&&C(s),l=r&&C(r),d=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+_(s).width,m=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+_(r).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var p=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===p)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||d>=o&&n[Ho]==="none"||r&&n[Ho]==="none"&&d+m>o)?"vertical":"horizontal"},gr=function(e,t,n){var o=n?e.left:e.top,s=n?e.right:e.bottom,r=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,d=n?t.width:t.height;return o===a||s===l||o+r/2===a+d/2},vr=function(e,t){var n;return Ye.some(function(o){var s=o[Y].options.emptyInsertThreshold;if(!(!s||Ni(o))){var r=_(o),a=e>=r.left-s&&e<=r.right+s,l=t>=r.top-s&&t<=r.bottom+s;if(a&&l)return n=o}}),n},Vo=function(e){function t(s,r){return function(a,l,d,m){var p=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||p))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,d,m),r)(a,l,d,m);var v=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===v||s.join&&s.indexOf(v)>-1}}var n={},o=e.group;(!o||Ii(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=t(o.pull,!0),n.checkPut=t(o.put),n.revertClone=o.revertClone,e.group=n},zo=function(){!jo&&M&&C(M,"display","none")},Ko=function(){!jo&&M&&C(M,"display","")};Qe&&!Ro&&document.addEventListener("click",function(i){if(Ge)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),Ge=!1,!1},!0);var Pt=function(e){if(g){e=e.touches?e.touches[0]:e;var t=vr(e.clientX,e.clientY);if(t){var n={};for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[Y]._onDragOver(n)}}},br=function(e){g&&g.parentNode[Y]._isOutsideThisEl(e.target)};function T(i,e){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=e=ht({},e),i[Y]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Uo(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:T.supportPointer!==!1&&"PointerEvent"in window&&(!ue||Oi),emptyInsertThreshold:5};be.initializePlugins(this,i,t);for(var n in t)!(n in e)&&(e[n]=t[n]);Vo(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:fr,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?I(i,"pointerdown",this._onTapStart):(I(i,"mousedown",this._onTapStart),I(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(I(i,"dragover",this),I(i,"dragenter",this)),Ye.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ht(this,hr())}T.prototype={constructor:T,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Ut=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,g):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,o=this.options,s=o.preventOnFilter,r=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,m=o.filter;if(Sr(n),!g&&!(/mousedown|pointerdown/.test(r)&&e.button!==0||o.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&ue&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=ot(l,o.draggable,n,!1),!(l&&l.animated)&&Ue!==l)){if(Kt=X(l),me=X(l,o.draggable),typeof m=="function"){if(m.call(this,e,l,this)){tt({sortable:t,rootEl:d,name:"filter",targetEl:l,toEl:n,fromEl:n}),nt("filter",t,{evt:e}),s&&e.preventDefault();return}}else if(m&&(m=m.split(",").some(function(p){if(p=ot(d,p.trim(),n,!1),p)return tt({sortable:t,rootEl:p,name:"filter",targetEl:l,fromEl:n,toEl:n}),nt("filter",t,{evt:e}),!0}),m)){s&&e.preventDefault();return}o.handle&&!ot(d,o.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(n&&!g&&n.parentNode===s){var d=_(n);if(F=s,g=n,j=g.parentNode,Bt=g.nextSibling,Ue=n,Ne=r.group,T.dragged=g,Ht={target:g,clientX:(t||e).clientX,clientY:(t||e).clientY},Do=Ht.clientX-d.left,Io=Ht.clientY-d.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,g.style["will-change"]="all",l=function(){if(nt("delayEnded",o,{evt:e}),T.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!So&&o.nativeDraggable&&(g.draggable=!0),o._triggerDragStart(e,t),tt({sortable:o,name:"choose",originalEvent:e}),K(g,r.chosenClass,!0)},r.ignore.split(",").forEach(function(m){_o(g,m.trim(),ki)}),I(a,"dragover",Pt),I(a,"mousemove",Pt),I(a,"touchmove",Pt),r.supportPointer?(I(a,"pointerup",o._onDrop),!this.nativeDraggable&&I(a,"pointercancel",o._onDrop)):(I(a,"mouseup",o._onDrop),I(a,"touchend",o._onDrop),I(a,"touchcancel",o._onDrop)),So&&this.nativeDraggable&&(this.options.touchStartThreshold=4,g.draggable=!0),nt("delayStart",this,{evt:e}),r.delay&&(!r.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(ve||wt))){if(T.eventCanceled){this._onDrop();return}r.supportPointer?(I(a,"pointerup",o._disableDelayedDrag),I(a,"pointercancel",o._disableDelayedDrag)):(I(a,"mouseup",o._disableDelayedDrag),I(a,"touchend",o._disableDelayedDrag),I(a,"touchcancel",o._disableDelayedDrag)),I(a,"mousemove",o._delayedDragTouchMoveHandler),I(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&I(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,r.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){g&&ki(g),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;D(e,"mouseup",this._disableDelayedDrag),D(e,"touchend",this._disableDelayedDrag),D(e,"touchcancel",this._disableDelayedDrag),D(e,"pointerup",this._disableDelayedDrag),D(e,"pointercancel",this._disableDelayedDrag),D(e,"mousemove",this._delayedDragTouchMoveHandler),D(e,"touchmove",this._delayedDragTouchMoveHandler),D(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?I(document,"pointermove",this._onTouchMove):t?I(document,"touchmove",this._onTouchMove):I(document,"mousemove",this._onTouchMove):(I(g,"dragend",this),I(F,"dragstart",this._onDragStart));try{document.selection?ze(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(zt=!1,F&&g){nt("dragStarted",this,{evt:t}),this.nativeDraggable&&I(document,"dragover",br);var n=this.options;!e&&K(g,n.dragClass,!1),K(g,n.ghostClass,!0),T.active=this,e&&this._appendGhost(),tt({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(ct){this._lastX=ct.clientX,this._lastY=ct.clientY,zo();for(var e=document.elementFromPoint(ct.clientX,ct.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(ct.clientX,ct.clientY),e!==t);)t=e;if(g.parentNode[Y]._isOutsideThisEl(e),t)do{if(t[Y]){var n=void 0;if(n=t[Y]._onDragOver({clientX:ct.clientX,clientY:ct.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=No(t));Ko()}},_onTouchMove:function(e){if(Ht){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,r=M&&Rt(M,!0),a=M&&r&&r.a,l=M&&r&&r.d,d=Fe&&J&&Mo(J),m=(s.clientX-Ht.clientX+o.x)/(a||1)+(d?d[0]-Si[0]:0)/(a||1),p=(s.clientY-Ht.clientY+o.y)/(l||1)+(d?d[1]-Si[1]:0)/(l||1);if(!T.active&&!zt){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(M){r?(r.e+=m-(Li||0),r.f+=p-(Ti||0)):r={a:1,b:0,c:0,d:1,e:m,f:p};var v="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");C(M,"webkitTransform",v),C(M,"mozTransform",v),C(M,"msTransform",v),C(M,"transform",v),Li=m,Ti=p,ct=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!M){var e=this.options.fallbackOnBody?document.body:F,t=_(g,!0,Fe,!0,e),n=this.options;if(Fe){for(J=e;C(J,"position")==="static"&&C(J,"transform")==="none"&&J!==document;)J=J.parentNode;J!==document.body&&J!==document.documentElement?(J===document&&(J=gt()),t.top+=J.scrollTop,t.left+=J.scrollLeft):J=gt(),Si=Mo(J)}M=g.cloneNode(!0),K(M,n.ghostClass,!1),K(M,n.fallbackClass,!0),K(M,n.dragClass,!0),C(M,"transition",""),C(M,"transform",""),C(M,"box-sizing","border-box"),C(M,"margin",0),C(M,"top",t.top),C(M,"left",t.left),C(M,"width",t.width),C(M,"height",t.height),C(M,"opacity","0.8"),C(M,"position",Fe?"absolute":"fixed"),C(M,"zIndex","100000"),C(M,"pointerEvents","none"),T.ghost=M,e.appendChild(M),C(M,"transform-origin",Do/parseInt(M.style.width)*100+"% "+Io/parseInt(M.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(nt("dragStart",this,{evt:e}),T.eventCanceled){this._onDrop();return}nt("setupClone",this),T.eventCanceled||(q=_i(g),q.removeAttribute("id"),q.draggable=!1,q.style["will-change"]="",this._hideClone(),K(q,this.options.chosenClass,!1),T.clone=q),n.cloneId=ze(function(){nt("clone",n),!T.eventCanceled&&(n.options.removeCloneOnHide||F.insertBefore(q,g),n._hideClone(),tt({sortable:n,name:"clone"}))}),!t&&K(g,s.dragClass,!0),t?(Ge=!0,n._loopId=setInterval(n._emulateDragOver,50)):(D(document,"mouseup",n._onDrop),D(document,"touchend",n._onDrop),D(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,g)),I(document,"drop",n),C(g,"transform","translateZ(0)")),zt=!0,n._dragStartId=ze(n._dragStarted.bind(n,t,e)),I(document,"selectstart",n),ce=!0,window.getSelection().removeAllRanges(),ue&&C(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,r,a=this.options,l=a.group,d=T.active,m=Ne===l,p=a.sort,v=G||d,y,u=this,f=!1;if(Hi)return;function w(ne,Us){nt(ne,u,vt({evt:e,isOwner:m,axis:y?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:p,fromSortable:v,target:n,completed:b,onMove:function(ho,Vs){return qe(F,t,g,o,ho,_(ho),e,Vs)},changed:L},Us))}function E(){w("dragOverAnimationCapture"),u.captureAnimationState(),u!==v&&v.captureAnimationState()}function b(ne){return w("dragOverCompleted",{insertion:ne}),ne&&(m?d._hideClone():d._showClone(u),u!==v&&(K(g,G?G.options.ghostClass:d.options.ghostClass,!1),K(g,a.ghostClass,!0)),G!==u&&u!==T.active?G=u:u===T.active&&G&&(G=null),v===u&&(u._ignoreWhileAnimating=n),u.animateAll(function(){w("dragOverAnimationComplete"),u._ignoreWhileAnimating=null}),u!==v&&(v.animateAll(),v._ignoreWhileAnimating=null)),(n===g&&!g.animated||n===t&&!n.animated)&&(Ut=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(g.parentNode[Y]._isOutsideThisEl(e.target),!ne&&Pt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),f=!0}function L(){at=X(g),St=X(g,a.draggable),tt({sortable:u,name:"change",toEl:t,newIndex:at,newDraggableIndex:St,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=ot(n,a.draggable,t,!0),w("dragOver"),T.eventCanceled)return f;if(g.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||u._ignoreWhileAnimating===n)return b(!1);if(Ge=!1,d&&!a.disabled&&(m?p||(r=j!==F):G===this||(this.lastPutMode=Ne.checkPull(this,d,g,e))&&l.checkPut(this,d,g,e))){if(y=this._getDirection(e,n)==="vertical",o=_(g),w("dragOverValid"),T.eventCanceled)return f;if(r)return j=F,E(),this._hideClone(),w("revert"),T.eventCanceled||(Bt?F.insertBefore(g,Bt):F.appendChild(g)),b(!0);var S=Ni(t,a.draggable);if(!S||Cr(e,y,this)&&!S.animated){if(S===g)return b(!1);if(S&&t===e.target&&(n=S),n&&(s=_(n)),qe(F,t,g,o,n,s,e,!!n)!==!1)return E(),S&&S.nextSibling?t.insertBefore(g,S.nextSibling):t.appendChild(g),j=t,L(),b(!0)}else if(S&&Er(e,y,this)){var x=Xt(t,0,a,!0);if(x===g)return b(!1);if(n=x,s=_(n),qe(F,t,g,o,n,s,e,!1)!==!1)return E(),t.insertBefore(g,x),j=t,L(),b(!0)}else if(n.parentNode===t){s=_(n);var A=0,B,P=g.parentNode!==t,k=!gr(g.animated&&g.toRect||o,n.animated&&n.toRect||s,y),O=y?"top":"left",R=$o(n,"top","top")||$o(g,"top","top"),U=R?R.scrollTop:void 0;Ut!==n&&(B=s[O],ge=!1,_e=!k&&a.invertSwap||P),A=xr(e,n,s,y,k?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,_e,Ut===n);var V;if(A!==0){var mt=X(g);do mt-=A,V=j.children[mt];while(V&&(C(V,"display")==="none"||V===M))}if(A===0||V===n)return b(!1);Ut=n,fe=A;var Ct=n.nextElementSibling,et=!1;et=A===1;var Mt=qe(F,t,g,o,n,s,e,et);if(Mt!==!1)return(Mt===1||Mt===-1)&&(et=Mt===1),Hi=!0,setTimeout(yr,30),E(),et&&!Ct?t.appendChild(g):n.parentNode.insertBefore(g,et?Ct:n),R&&qo(R,0,U-R.scrollTop),j=g.parentNode,B!==void 0&&!_e&&(Ve=Math.abs(B-_(n)[O])),L(),b(!0)}if(t.contains(g))return b(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){D(document,"mousemove",this._onTouchMove),D(document,"touchmove",this._onTouchMove),D(document,"pointermove",this._onTouchMove),D(document,"dragover",Pt),D(document,"mousemove",Pt),D(document,"touchmove",Pt)},_offUpEvents:function(){var e=this.el.ownerDocument;D(e,"mouseup",this._onDrop),D(e,"touchend",this._onDrop),D(e,"pointerup",this._onDrop),D(e,"pointercancel",this._onDrop),D(e,"touchcancel",this._onDrop),D(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(at=X(g),St=X(g,n.draggable),nt("drop",this,{evt:e}),j=g&&g.parentNode,at=X(g),St=X(g,n.draggable),T.eventCanceled){this._nulling();return}zt=!1,_e=!1,ge=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Pi(this.cloneId),Pi(this._dragStartId),this.nativeDraggable&&(D(document,"drop",this),D(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),ue&&C(document.body,"user-select",""),C(g,"transform",""),e&&(ce&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),M&&M.parentNode&&M.parentNode.removeChild(M),(F===j||G&&G.lastPutMode!=="clone")&&q&&q.parentNode&&q.parentNode.removeChild(q),g&&(this.nativeDraggable&&D(g,"dragend",this),ki(g),g.style["will-change"]="",ce&&!zt&&K(g,G?G.options.ghostClass:this.options.ghostClass,!1),K(g,this.options.chosenClass,!1),tt({sortable:this,name:"unchoose",toEl:j,newIndex:null,newDraggableIndex:null,originalEvent:e}),F!==j?(at>=0&&(tt({rootEl:j,name:"add",toEl:j,fromEl:F,originalEvent:e}),tt({sortable:this,name:"remove",toEl:j,originalEvent:e}),tt({rootEl:j,name:"sort",toEl:j,fromEl:F,originalEvent:e}),tt({sortable:this,name:"sort",toEl:j,originalEvent:e})),G&&G.save()):at!==Kt&&at>=0&&(tt({sortable:this,name:"update",toEl:j,originalEvent:e}),tt({sortable:this,name:"sort",toEl:j,originalEvent:e})),T.active&&((at==null||at===-1)&&(at=Kt,St=me),tt({sortable:this,name:"end",toEl:j,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){nt("nulling",this),F=g=j=M=Bt=q=Ue=kt=Ht=ct=ce=at=St=Kt=me=Ut=fe=G=Ne=T.dragged=T.ghost=T.clone=T.active=null;var e=this.el;Je.forEach(function(t){e.contains(t)&&(t.checked=!0)}),Je.length=Li=Ti=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":g&&(this._onDragOver(e),wr(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,o=0,s=n.length,r=this.options;o<s;o++)t=n[o],ot(t,r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Tr(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];ot(a,this.options.draggable,o,!1)&&(n[s]=a)},this),t&&this.captureAnimationState(),e.forEach(function(s){n[s]&&(o.removeChild(n[s]),o.appendChild(n[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return ot(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var o=be.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&Vo(n)},destroy:function(){nt("destroy",this);var e=this.el;e[Y]=null,D(e,"mousedown",this._onTapStart),D(e,"touchstart",this._onTapStart),D(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(D(e,"dragover",this),D(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ye.splice(Ye.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!kt){if(nt("hideClone",this),T.eventCanceled)return;C(q,"display","none"),this.options.removeCloneOnHide&&q.parentNode&&q.parentNode.removeChild(q),kt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(kt){if(nt("showClone",this),T.eventCanceled)return;g.parentNode==F&&!this.options.group.revertClone?F.insertBefore(q,g):Bt?F.insertBefore(q,Bt):F.appendChild(q),this.options.group.revertClone&&this.animate(g,q),C(q,"display",""),kt=!1}}};function wr(i){i.dataTransfer&&(i.dataTransfer.dropEffect="move"),i.cancelable&&i.preventDefault()}function qe(i,e,t,n,o,s,r,a){var l,d=i[Y],m=d.options.onMove,p;return window.CustomEvent&&!wt&&!ve?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=i,l.dragged=t,l.draggedRect=n,l.related=o||e,l.relatedRect=s||_(e),l.willInsertAfter=a,l.originalEvent=r,i.dispatchEvent(l),m&&(p=m.call(d,l,r)),p}function ki(i){i.draggable=!1}function yr(){Hi=!1}function Er(i,e,t){var n=_(Xt(t.el,0,t.options,!0)),o=Wo(t.el,t.options,M),s=10;return e?i.clientX<o.left-s||i.clientY<n.top&&i.clientX<n.right:i.clientY<o.top-s||i.clientY<n.bottom&&i.clientX<n.left}function Cr(i,e,t){var n=_(Ni(t.el,t.options.draggable)),o=Wo(t.el,t.options,M),s=10;return e?i.clientX>o.right+s||i.clientY>n.bottom&&i.clientX>n.left:i.clientY>o.bottom+s||i.clientX>n.right&&i.clientY>n.top}function xr(i,e,t,n,o,s,r,a){var l=n?i.clientY:i.clientX,d=n?t.height:t.width,m=n?t.top:t.left,p=n?t.bottom:t.right,v=!1;if(!r){if(a&&Ve<d*o){if(!ge&&(fe===1?l>m+d*s/2:l<p-d*s/2)&&(ge=!0),ge)v=!0;else if(fe===1?l<m+Ve:l>p-Ve)return-fe}else if(l>m+d*(1-o)/2&&l<p-d*(1-o)/2)return Lr(e)}return v=v||r,v&&(l<m+d*s/2||l>p-d*s/2)?l>m+d/2?1:-1:0}function Lr(i){return X(g)<X(i)?1:-1}function Tr(i){for(var e=i.tagName+i.className+i.src+i.href+i.textContent,t=e.length,n=0;t--;)n+=e.charCodeAt(t);return n.toString(36)}function Sr(i){Je.length=0;for(var e=i.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&Je.push(n)}}function ze(i){return setTimeout(i,0)}function Pi(i){return clearTimeout(i)}Qe&&I(document,"touchmove",function(i){(T.active||zt)&&i.cancelable&&i.preventDefault()});T.utils={on:I,off:D,css:C,find:_o,is:function(e,t){return!!ot(e,t,e,!1)},extend:cr,throttle:Fo,closest:ot,toggleClass:K,clone:_i,index:X,nextTick:ze,cancelNextTick:Pi,detectDirection:Uo,getChild:Xt,expando:Y};T.get=function(i){return i[Y]};T.mount=function(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(T.utils=vt(vt({},T.utils),n.utils)),be.mount(n)})};T.create=function(i,e){return new T(i,e)};T.version=ar;var z=[],de,Bi,Ri=!1,$i,Mi,Ze,he;function kr(){function i(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return i.prototype={dragStarted:function(t){var n=t.originalEvent;this.sortable.nativeDraggable?I(document,"dragover",this._handleAutoScroll):this.options.supportPointer?I(document,"pointermove",this._handleFallbackAutoScroll):n.touches?I(document,"touchmove",this._handleFallbackAutoScroll):I(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?D(document,"dragover",this._handleAutoScroll):(D(document,"pointermove",this._handleFallbackAutoScroll),D(document,"touchmove",this._handleFallbackAutoScroll),D(document,"mousemove",this._handleFallbackAutoScroll)),Po(),Ke(),dr()},nulling:function(){Ze=Bi=de=Ri=he=$i=Mi=null,z.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,n){var o=this,s=(t.touches?t.touches[0]:t).clientX,r=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(s,r);if(Ze=t,n||this.options.forceAutoScrollFallback||ve||wt||ue){Ai(t,this.options,a,n);var l=$t(a,!0);Ri&&(!he||s!==$i||r!==Mi)&&(he&&Po(),he=setInterval(function(){var d=$t(document.elementFromPoint(s,r),!0);d!==l&&(l=d,Ke()),Ai(t,o.options,d,n)},10),$i=s,Mi=r)}else{if(!this.options.bubbleScroll||$t(a,!0)===gt()){Ke();return}Ai(t,this.options,$t(a,!1),!1)}}},ht(i,{pluginName:"scroll",initializeByDefault:!0})}function Ke(){z.forEach(function(i){clearInterval(i.pid)}),z=[]}function Po(){clearInterval(he)}var Ai=Fo(function(i,e,t,n){if(e.scroll){var o=(i.touches?i.touches[0]:i).clientX,s=(i.touches?i.touches[0]:i).clientY,r=e.scrollSensitivity,a=e.scrollSpeed,l=gt(),d=!1,m;Bi!==t&&(Bi=t,Ke(),de=e.scroll,m=e.scrollFn,de===!0&&(de=$t(t,!0)));var p=0,v=de;do{var y=v,u=_(y),f=u.top,w=u.bottom,E=u.left,b=u.right,L=u.width,S=u.height,x=void 0,A=void 0,B=y.scrollWidth,P=y.scrollHeight,k=C(y),O=y.scrollLeft,R=y.scrollTop;y===l?(x=L<B&&(k.overflowX==="auto"||k.overflowX==="scroll"||k.overflowX==="visible"),A=S<P&&(k.overflowY==="auto"||k.overflowY==="scroll"||k.overflowY==="visible")):(x=L<B&&(k.overflowX==="auto"||k.overflowX==="scroll"),A=S<P&&(k.overflowY==="auto"||k.overflowY==="scroll"));
vendor: 5,445 bytes, line 4
4var U=x&&(Math.abs(b-o)<=r&&O+L<B)-(Math.abs(E-o)<=r&&!!O),V=A&&(Math.abs(w-s)<=r&&R+S<P)-(Math.abs(f-s)<=r&&!!R);if(!z[p])for(var mt=0;mt<=p;mt++)z[mt]||(z[mt]={});(z[p].vx!=U||z[p].vy!=V||z[p].el!==y)&&(z[p].el=y,z[p].vx=U,z[p].vy=V,clearInterval(z[p].pid),(U!=0||V!=0)&&(d=!0,z[p].pid=setInterval(function(){n&&this.layer===0&&T.active._onTouchMove(Ze);var Ct=z[this.layer].vy?z[this.layer].vy*a:0,et=z[this.layer].vx?z[this.layer].vx*a:0;typeof m=="function"&&m.call(T.dragged.parentNode[Y],et,Ct,i,Ze,z[this.layer].el)!=="continue"||qo(z[this.layer].el,et,Ct)}.bind({layer:p}),24))),p++}while(e.bubbleScroll&&v!==l&&(v=$t(v,!1)));Ri=d}},30),Xo=function(e){var t=e.originalEvent,n=e.putSortable,o=e.dragEl,s=e.activeSortable,r=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var d=n||s;a();var m=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,p=document.elementFromPoint(m.clientX,m.clientY);l(),d&&!d.el.contains(p)&&(r("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function Fi(){}Fi.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,n=e.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var o=Xt(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(t,o):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:Xo};ht(Fi,{pluginName:"revertOnSpill"});function qi(){}qi.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable,o=n||this.sortable;o.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),o.animateAll()},drop:Xo};ht(qi,{pluginName:"removeOnSpill"});var $=[],rt=[],se,dt,re=!1,it=!1,Vt=!1,N,ae,We;function Go(){function i(e){for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this));e.options.avoidImplicitDeselect||(e.options.supportPointer?I(document,"pointerup",this._deselectMultiDrag):(I(document,"mouseup",this._deselectMultiDrag),I(document,"touchend",this._deselectMultiDrag))),I(document,"keydown",this._checkKeyDown),I(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(o,s){var r="";$.length&&dt===e?$.forEach(function(a,l){r+=(l?", ":"")+a.textContent}):r=s.textContent,o.setData("Text",r)}}}return i.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var n=t.dragEl;N=n},delayEnded:function(){this.isMultiDrag=~$.indexOf(N)},setupClone:function(t){var n=t.sortable,o=t.cancel;if(this.isMultiDrag){for(var s=0;s<$.length;s++)rt.push(_i($[s])),rt[s].sortableIndex=$[s].sortableIndex,rt[s].draggable=!1,rt[s].style["will-change"]="",K(rt[s],this.options.selectedClass,!1),$[s]===N&&K(rt[s],this.options.chosenClass,!1);n._hideClone(),o()}},clone:function(t){var n=t.sortable,o=t.rootEl,s=t.dispatchSortableEvent,r=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||$.length&&dt===n&&(Bo(!0,o),s("clone"),r()))},showClone:function(t){var n=t.cloneNowShown,o=t.rootEl,s=t.cancel;this.isMultiDrag&&(Bo(!1,o),rt.forEach(function(r){C(r,"display","")}),n(),We=!1,s())},hideClone:function(t){var n=this,o=t.sortable,s=t.cloneNowHidden,r=t.cancel;this.isMultiDrag&&(rt.forEach(function(a){C(a,"display","none"),n.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),We=!0,r())},dragStartGlobal:function(t){var n=t.sortable;!this.isMultiDrag&&dt&&dt.multiDrag._deselectMultiDrag(),$.forEach(function(o){o.sortableIndex=X(o)}),$=$.sort(function(o,s){return o.sortableIndex-s.sortableIndex}),Vt=!0},dragStarted:function(t){var n=this,o=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(o.captureAnimationState(),this.options.animation)){$.forEach(function(r){r!==N&&C(r,"position","absolute")});var s=_(N,!1,!0,!0);$.forEach(function(r){r!==N&&Ao(r,s)}),it=!0,re=!0}o.animateAll(function(){it=!1,re=!1,n.options.animation&&$.forEach(function(r){Ci(r)}),n.options.sort&&je()})}},dragOver:function(t){var n=t.target,o=t.completed,s=t.cancel;it&&~$.indexOf(n)&&(o(!1),s())},revert:function(t){var n=t.fromSortable,o=t.rootEl,s=t.sortable,r=t.dragRect;$.length>1&&($.forEach(function(a){s.addAnimationState({target:a,rect:it?_(a):r}),Ci(a),a.fromRect=r,n.removeAnimationState(a)}),it=!1,$r(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(t){var n=t.sortable,o=t.isOwner,s=t.insertion,r=t.activeSortable,a=t.parentEl,l=t.putSortable,d=this.options;if(s){if(o&&r._hideClone(),re=!1,d.animation&&$.length>1&&(it||!o&&!r.options.sort&&!l)){var m=_(N,!1,!0,!0);$.forEach(function(v){v!==N&&(Ao(v,m),a.appendChild(v))}),it=!0}if(!o)if(it||je(),$.length>1){var p=We;r._showClone(n),r.options.animation&&!We&&p&&rt.forEach(function(v){r.addAnimationState({target:v,rect:ae}),v.fromRect=ae,v.thisAnimationDuration=null})}else r._showClone(n)}},dragOverAnimationCapture:function(t){var n=t.dragRect,o=t.isOwner,s=t.activeSortable;if($.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){ae=ht({},n);var r=Rt(N,!0);ae.top-=r.f,ae.left-=r.e}},dragOverAnimationComplete:function(){it&&(it=!1,je())},drop:function(t){var n=t.originalEvent,o=t.rootEl,s=t.parentEl,r=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,d=t.putSortable,m=d||this.sortable;if(n){var p=this.options,v=s.children;if(!Vt)if(p.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(
4),K(N,p.selectedClass,!~$.indexOf(N)),~$.indexOf(N))$.splice($.indexOf(N),1),se=null,le({sortable:r,rootEl:o,name:"deselect",targetEl:N,originalEvent:n});else{if($.push(N),le({sortable:r,rootEl:o,name:"select",targetEl:N,originalEvent:n}),n.shiftKey&&se&&r.el.contains(se)){var y=X(se),u=X(N);~y&&~u&&y!==u&&(function(){var b,L;u>y?(L=y,b=u):(L=u,b=y+1);for(var S=p.filter;L<b;L++)if(!~$.indexOf(v[L])&&ot(v[L],p.draggable,s,!1)){var x=S&&(typeof S=="function"?S.call(r,n,v[L],r):S.split(",").some(function(A){return ot(v[L],A.trim(),s,!1)}));x||(K(v[L],p.selectedClass,!0),$.push(v[L]),le({sortable:r,rootEl:o,name:"select",targetEl:v[L],originalEvent:n}))}})()}else se=N;dt=m}if(Vt&&this.isMultiDrag){if(it=!1,(s[Y].options.sort||s!==o)&&$.length>1){var f=_(N),w=X(N,":not(."+this.options.selectedClass+")");if(!re&&p.animation&&(N.thisAnimationDuration=null),m.captureAnimationState(),!re&&(p.animation&&(N.fromRect=f,$.forEach(function(b){if(b.thisAnimationDuration=null,b!==N){var L=it?_(b):f;b.fromRect=L,m.addAnimationState({target:b,rect:L})}})),je(),$.forEach(function(b){v[w]?s.insertBefore(b,v[w]):s.appendChild(b),w++}),l===X(N))){var E=!1;$.forEach(function(b){if(b.sortableIndex!==X(b)){E=!0;return}}),E&&(a("update"),a("sort"))}$.forEach(function(b){Ci(b)}),m.animateAll()}dt=m}(o===s||d&&d.lastPutMode!=="clone")&&rt.forEach(function(b){b.parentNode&&b.parentNode.removeChild(b)})}},nullingGlobal:function(){this.isMultiDrag=Vt=!1,rt.length=0},destroyGlobal:function(){this._deselectMultiDrag(),D(document,"pointerup",this._deselectMultiDrag),D(document,"mouseup",this._deselectMultiDrag),D(document,"touchend",this._deselectMultiDrag),D(document,"keydown",this._checkKeyDown),D(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof Vt<"u"&&Vt)&&dt===this.sortable&&!(t&&ot(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;$.length;){var n=$[0];K(n,this.options.selectedClass,!1),$.shift(),le({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:n,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},ht(i,{pluginName:"multiDrag",utils:{select:function(t){var n=t.parentNode[Y];!n||!n.options.multiDrag||~$.indexOf(t)||(dt&&dt!==n&&(dt.multiDrag._deselectMultiDrag(),dt=n),K(t,n.options.selectedClass,!0),$.push(t))},deselect:function(t){var n=t.parentNode[Y],o=$.indexOf(t);!n||!n.options.multiDrag||!~o||(K(t,n.options.selectedClass,!1),$.splice(o,1))}},eventProperties:function(){var t=this,n=[],o=[];return $.forEach(function(s){n.push({multiDragElement:s,index:s.sortableIndex});var r;it&&s!==N?r=-1:it?r=X(s,":not(."+t.options.selectedClass+")"):r=X(s),o.push({multiDragElement:s,index:r})}),{items:ir($),clones:[].concat(rt),oldIndicies:n,newIndicies:o}},optionListeners:{multiDragKey:function(t){return t=t.toLowerCase(),t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}function $r(i,e){$.forEach(function(t,n){var o=e.children[t.sortableIndex+(i?Number(n):0)];o?e.insertBefore(t,o):e.appendChild(t)})}function Bo(i,e){rt.forEach(function(t,n){var o=e.children[t.sortableIndex+(i?Number(n):0)];o?e.insertBefore(t,o):e.appendChild(t)})}function je(){$.forEach(function(i){i!==N&&i.parentNode&&i.parentNode.removeChild(i)})}T.mount(new kr);T.mount(qi,Fi);var ut=T;var Yo={name(i,e){let t=i.getAttribute("data-name").trim().toLowerCase(),n=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(n)},created(i,e){let t=Number(i.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated(i,e){let t=Number(i.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst(i,e){let t=i.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?-1:1},chaptersLast(i,e){let t=i.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?1:-1}},Jo={up:{active(i,e){return!(i.previousElementSibling===null&&!e)},run(i,e){(i.previousElementSibling||e).insertAdjacentElement("beforebegin",i)}},down:{active(i,e){return!(i.nextElementSibling===null&&!e)},run(i,e){(i.nextElementSibling||e).insertAdjacentElement("afterend",i)}},next_book:{active(i,e,t){return t.nextElementSibling!==null},run(i,e,t){t.nextElementSibling.querySelector("ul").prepend(i)}},prev_book:{active(i,e,t){return t.previousElementSibling!==null},run(i,e,t){t.previousElementSibling.querySelector("ul").appendChild(i)}},next_chapter:{active(i,e){return i.dataset.type==="page"&&this.getNextChapter(i,e)},run(i,e){this.getNextChapter(i,e).querySelector("ul").prepend(i)},getNextChapter(i,e){let t=e||i,n=Array.from(t.parentElement.children),o=n.indexOf(t);return n.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(i,e){return i.dataset.type==="page"&&this.getPrevChapter(i,e)},run(i,e){this.getPrevChapter(i,e).querySelector("ul").append(i)},getPrevChapter(i,e){let t=e||i,n=Array.from(t.parentElement.children),o=n.indexOf(t);return n.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(i,e){return e||e===null&&i.nextElementSibling},run(i,e,t){t.querySelector("ul").append(i)}}
4,book_start:{active(i,e){return e||e===null&&i.previousElementSibling},run(i,e,t){t.querySelector("ul").prepend(i)}},before_chapter:{active(i,e){return e},run(i,e){e.insertAdjacentElement("beforebegin",i)}},after_chapter:{active(i,e){return e},run(i,e){e.insertAdjacentElement("afterend",i)}}},tn=class extends h{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,ut.mount(new Go);let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",e=>{if(e.target.matches("[data-move]")){let t=e.target.getAttribute("data-move"),n=e.target.closest("[data-id]");this.runSortAction(n,t)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let e="",t=!1,n=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let r=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");t=e===a?!t:!1;let l=Yo[a];t&&n.includes(a)&&(l=function(m,p){return 0-Yo[a](m,p)});for(let d of r)Array.from(d.children).filter(p=>p.matches("li")).sort(l).forEach(p=>{d.appendChild(p)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=`${e.link}/sort-item`;window.$http.get(n).then(o=>{let s=lt(o.data);this.sortContainer.append(s),this.setupBookSortable(s),this.updateMoveActionStateForAll(),s.querySelector("summary").focus()})}setupBookSortable(e){let t=Array.from(e.querySelectorAll(".sort-list, .sortable-page-sublist")),n={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put(s,r,a){return a.getAttribute("data-type")==="page"}};for(let s of t)ut.create(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let e=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let t of e)t.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",t)}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.container.querySelectorAll(".sort-list");for(let n of t){let o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(r=>r.matches('[data-type="page"], [data-type="chapter"]'));for(let r=0;r<s.length;r++)this.addBookChildToMap(s[r],r,o,e)}return e}addBookChildToMap(e,t,n,o){let s=e.getAttribute("data-type"),r=!1,a=e.getAttribute("data-id");o.push({id:a,sort:t,parentChapter:r,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let d=0;d<l.length;d++)o.push({id:l[d].getAttribute("data-id"),sort:d,parentChapter:a,type:"page",book:n})}runSortAction(e,t){let n=e.parentElement.closest("li[data-id]"),o=e.parentElement.closest('[data-type="book"]');Jo[t].run(e,n,o),this.updateMapInput(),this.updateMoveActionStateForAll(),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus()}updateMoveActionState(e){let t=e.parentElement.closest("li[data-id]"),n=e.parentElement.closest('[data-type="book"]');for(let[o,s]of Object.entries(Jo)){let r=e.querySelector(`[data-move="${o}"]`);r.disabled=!s.active(e,t,n)}}updateMoveActionStateForAll(){let e=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let t of e)this.updateMoveActionState(t)}};var en=new WeakMap;function we(i,e,t=400,n=null){let o=Object.keys(e);for(let r of o)i.style.setProperty(r,e[r][0]);let s=()=>{for(let r of o)i.style.removeProperty(r);i.style.removeProperty("transition"),i.removeEventListener("transitionend",s),en.delete(i),n&&n()};setTimeout(()=>{i.style.transition=`all ease-in-out ${t}ms`;for(let r of o)i.style.setProperty(r,e[r][1]);i.addEventListener("transitionend",s),en.set(i,s)},15)}function ye(i){en.has(i)&&en.get(i)()}function Zo(i,e=400,t=null){ye(i),i.style.display="block",we(i,{opacity:["0","1"]},e,()=>{t&&t()})}function Qo(i,e=400,t=null){ye(i),we(i,{opacity:["1","0"]},e,()=>{i.style.display="none",t&&t()})}function Gt(i,e=400){ye(i);let t=i.getBoundingClientRect().height,n=getComputedStyle(i),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),r={"max-height":[`${t}px`,"0px"],overflow:["hidden","hidden"],"padding-top":[o,"0px"],"padding-bottom":[s,"0px"]};we(i,r,e,()=>{i.style.display="none"})}function Yt(i,e=400){ye(i),i.style.display="block";let t=i.getBoundingClientRect().height,n=getComputedStyle(i),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),r={"max-height":["0px",`${t}px`],overflow:["hidden","hidden"],"padding-top":["0px",o],"padding-bottom":["0px",s]};we(i,r,e)}function ts(i,e=400){let t=i.getBoundingClientRect().height,n=getComputedStyle(i),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{ye(i);let r=i.getBoundingClientRect().height,a=getComputedStyle(i),l=a.getPropertyValue("padding-top"),d=a.getPropertyValue("padding-bottom"),m={height:[`${t}px`,`${r}px`],overflow:["hidden","hidden"],"padding-top":[o,l],"padding-bottom":[s,d]};we(i,m,e)}}var nn=class extends h{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),Yt(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","fal
4se"),Gt(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var on=class extends h{constructor(){super(...arguments);c(this,"editor",null);c(this,"saveCallback",null);c(this,"cancelCallback",null);c(this,"history",{});c(this,"historyKey","code_history")}setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",t=>{t.ctrlKey&&t.key==="Enter"&&this.save()}),H(this.languageButtons,t=>{let n=t.target.dataset.lang;this.languageInput.value=n,this.languageInputChange(n)}),qt(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),H(this.saveButton,()=>this.save()),W(this.historyList,"button","click",(t,n)=>{t.preventDefault();let o=n.dataset.time;this.editor&&this.editor.setContent(this.history[o])})}setupFavourites(){for(let t of this.languageButtons)this.setupFavouritesForButton(t);this.sortLanguageList()}setupFavouritesForButton(t){let n=t.dataset.lang,o=this.favourites.has(n);t.setAttribute("data-favourite",o?"true":"false"),W(t.parentElement,".lang-option-favorite-toggle","click",()=>{o=!o,o?this.favourites.add(n):this.favourites.delete(n),t.setAttribute("data-favourite",o?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:n,active:o}),this.sortLanguageList(),o&&t.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let t=this.languageButtons.sort((n,o)=>{let s=n.dataset.favourite==="true",r=o.dataset.favourite==="true";return s&&!r?-1:r&&!s||n.dataset.lang>o.dataset.lang?1:-1}).map(n=>n.parentElement);for(let n of t)this.languageOptionsContainer.append(n)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(t,n,o,s,r){this.languageInput.value=n,this.saveCallback=s,this.cancelCallback=r,await this.show(),this.languageInputChange(n),this.editor.setContent(t),this.setDirection(o)}async show(){let t=await window.importVersioned("code");this.editor||(this.editor=t.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}setDirection(t){let n=this.editorInput.parentElement;t?n.setAttribute("dir",t):n.removeAttribute("dir")}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(t){this.editor.setMode(t,this.editor.getContent())}languageInputChange(t){this.updateEditorMode(t);let n=t.toLowerCase();for(let o of this.languageButtons){let s=o.dataset.lang.toLowerCase().trim(),r=n===s;o.classList.toggle("active",r),r&&o.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let t=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",t.length===0),this.historyList.innerHTML=t.map(n=>{let o=new Date(parseInt(n,10)).toLocaleTimeString();return`<li><button type="button" data-time="${n}" class="text-item">${o}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let t=this.editor.getContent();if(!t)return;let n=Object.keys(this.history).pop();if(this.history[n]===t)return;this.history[String(Date.now())]=t;let o=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,o)}};var sn=class extends h{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}};var rn=class extends h{async setup(){let{mode:e}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var an=class extends h{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),Yt(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","fal
4se"),Gt(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var ln=class extends h{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,H(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(e=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var cn=class extends h{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.disabled||(this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange())}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var dn=class extends h{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var hn=class extends h{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.fixedPositionMenu=this.$opts.fixedPositionMenu==="true",this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),n=0,o=this.toggle.getBoundingClientRect().height,r=(this.fixedPositionMenu?this.body:Lo(this.menu)).getBoundingClientRect(),a=t.bottom>r.bottom,l=this.container.getBoundingClientRect();if(this.fixedPositionMenu&&(this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,a?n=window.innerHeight-t.top-o/2:n=t.top),a){this.menu.style.top="initial",this.menu.style.bottom=`${n}px`;let p=window.innerHeight-40-(window.innerHeight-l.bottom);this.menu.style.maxHeight=`${Math.floor(p)}px`}else{this.menu.style.top=`${n}px`,this.menu.style.bottom="initial";let p=window.innerHeight-40-l.top;this.menu.style.maxHeight=`${Math.floor(p)}px`}this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",p=>{this.menu.contains(p.target)||this.hide()});let d=this.menu.querySelector("input");d!==null&&d.focus(),this.showing=!0;let m=new Event("show");this.container.dispatchEvent(m),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.menu.style.maxHeight="",this.fixedPositionMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left=""),this.showing=!1}setupListeners(){let e=new Lt(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),H(this.toggle,t=>{t.stopPropagation(),t.preventDefault(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var un=class extends h{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=ft(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let n of t){let o=!e||n.textContent.toLowerCase().includes(e);n.style.display=o?"flex":"none",n.classList.toggle("hidden",!o)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),n=ts(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,n()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var Jt=class{constructor(e){c(this,"data");this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return!!e&&e.includes("\\trowd")}getImages(){return this.getFiles().filter(e=>e.type.includes("image"))}getFiles(){let{files:e}=this.data;return[...e]}};async function Wi(i){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(i);return}
4let e=document.createElement("textarea");e.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),e.value=i,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var pn=class extends h{setup(){this.container=this.$el,this.statusArea=this.$refs.statusArea,this.dropTarget=this.$refs.dropTarget,this.selectButtons=this.$manyRefs.selectButton||[],this.isActive=!0,this.url=this.$opts.url,this.method=(this.$opts.method||"post").toUpperCase(),this.successMessage=this.$opts.successMessage,this.errorMessage=this.$opts.errorMessage,this.uploadLimitMb=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.zoneText=this.$opts.zoneText,this.fileAcceptTypes=this.$opts.fileAccept,this.allowMultiple=this.$opts.allowMultiple==="true",this.setupListeners()}toggleActive(e){this.isActive=e}setupListeners(){H(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let e=0,t=()=>{this.hideOverlay(),e=0};this.dropTarget.addEventListener("dragenter",n=>{n.preventDefault(),e+=1,e===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",n=>{n.preventDefault()}),this.dropTarget.addEventListener("dragend",t),this.dropTarget.addEventListener("dragleave",()=>{e-=1,e===0&&t()}),this.dropTarget.addEventListener("drop",n=>{if(n.preventDefault(),t(),!this.isActive)return;let s=new Jt(n.dataTransfer).getFiles();for(let r of s)this.createUploadFromFile(r)})}manualSelectHandler(){let e=Q("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(e),e.click(),e.addEventListener("change",()=>{for(let t of e.files)this.createUploadFromFile(t);e.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let t=Q("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(t)}}hideOverlay(){let e=this.dropTarget.querySelector(".dropzone-overlay");e&&e.remove()}createUploadFromFile(e){let{dom:t,status:n,progress:o,dismiss:s}=this.createDomForFile(e);this.statusArea.append(t);let r=this,a={file:e,dom:t,updateProgress(l){o.textContent=`${l}%`,o.style.width=`${l}%`},markError(l){n.setAttribute("data-status","error"),n.textContent=l,oe(t),this.updateProgress(100)},markSuccess(l){n.setAttribute("data-status","success"),n.textContent=l,oe(t),setTimeout(s,2400),r.$emit("upload-success",{name:e.name})}};return e.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(e){let t=new FormData;t.append("file",e.file,e.file.name),this.method!=="POST"&&t.append("_method",this.method);let n=this,o=window.$http.createXMLHttpRequest("POST",this.url,{error(){e.markError(n.errorMessage)},readystatechange(){this.readyState===XMLHttpRequest.DONE&&this.status===200?e.markSuccess(n.successMessage):this.readyState===XMLHttpRequest.DONE&&this.status>=400&&e.markError(window.$http.formatErrorResponseText(this.responseText))}});o.upload.addEventListener("progress",s=>{let r=Math.min(Math.ceil(s.loaded/s.total*100),100);e.updateProgress(r)}),o.setRequestHeader("Accept","application/json"),o.send(t)}createDomForFile(e){let t=Q("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),n=Q("div",{class:"dropzone-file-item-status"},[]),o=Q("div",{class:"dropzone-file-item-progress"}),s=Q("div",{class:"dropzone-file-item-image-wrap"},[t]),r=Q("div",{class:"dropzone-file-item"},[s,Q("div",{class:"dropzone-file-item-text-wrap"},[Q("div",{class:"dropzone-file-item-label"},[e.name]),Wt(),n]),o]);e.type.startsWith("image/")&&(t.src=URL.createObjectURL(e));let a=()=>{r.classList.add("dismiss"),r.addEventListener("animationend",()=>{r.remove()})};return r.addEventListener("click",a),{dom:r,progress:o,status:n,dismiss:a}}};var mn=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"buttons");c(this,"contentElements");c(this,"toggleButton");c(this,"editorWrapEl");c(this,"open",!1);c(this,"tab","")}setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.editorWrapEl=this.container.closest(".page-editor"),this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent||"")}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",t=>{let n=t.target.closest("button");if(n instanceof HTMLButtonElement&&this.buttons.includes(n)){let o=n.dataset.tab||"";this.setActiveTab(o,!0)}})}toggle(){this.container.classList.toggle("open");let t=this.container.classList.contains("open");this.toggleButton.setAttribute("aria-expanded",t?"true":"false"),this.editorWrapEl.classList.toggle("toolbox-open",t),this.open=t,this.emitState()}setActiveTab(t,n=!1){for(let o of this.buttons)o.classList.remove("active"),o.dataset.tab===t&&o.classList.add("active");for(let o of this.contentElements)o.style.display="none",o.dataset.tabContent===t&&(o.style.display="block");n&&!this.container.classList.contains("open")&&this.toggle(),this.tab=t,this.emitState()}emitState(){let t={tab:this.tab,open:this.open};this.$emit("change",t)}};var fn=class extends h{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",e=>{let t=e.target.checked,n=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of n)o.disabled=t,o.checked=!1}
4),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",()=>{let e=this.roleSelect.value;e&&this.addRoleRow(e)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let n=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),o=lt(n.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),{roleId:n}=e.dataset,{roleName:o}=e.dataset,s=document.createElement("option");s.value=n,s.textContent=o,this.roleSelect.append(s),t.remove()}};var gn=class extends h{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),H(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var vn=class extends h{constructor(){super(...arguments);c(this,"elem");c(this,"input");c(this,"searchInput");c(this,"loading");c(this,"resultsContainer");c(this,"searchOptions");c(this,"search","");c(this,"lastClick",0)}setup(){this.elem=this.$el,this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.searchOptions={entityTypes:this.$opts.entityTypes||"page,book,chapter",entityPermission:this.$opts.entityPermission||"view",searchEndpoint:this.$opts.searchEndpoint||"",initialValue:this.searchInput.value||""},this.setupListeners(),this.showLoading(),this.searchOptions.searchEndpoint&&this.initialLoad()}configureSearchOptions(t){Object.assign(this.searchOptions,t),this.reset(),this.searchInput.value=this.searchOptions.initialValue}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let t=0;this.searchInput.addEventListener("input",()=>{t=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-t<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",n=>{n.keyCode===13&&n.preventDefault()}),W(this.$el,"[data-entity-type]","keydown",(n=>{if(n.ctrlKey&&n.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),n.preventDefault();return}}n.code==="ArrowDown"&&this.focusAdjacent(!0),n.code==="ArrowUp"&&this.focusAdjacent(!1)})),this.searchInput.addEventListener("keydown",n=>{n.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(t=!0){let n=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),o=n.indexOf(document.activeElement),s=n[o+(t?1:-1)]||n[0];s instanceof HTMLElement&&s.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");if(this.searchOptions.initialValue){this.searchEntities(this.searchOptions.initialValue);return}window.$http.get(this.searchUrl()).then(t=>{this.resultsContainer.innerHTML=t.data,this.hideLoading()})}searchUrl(){let t=`types=${encodeURIComponent(this.searchOptions.entityTypes)}&permission=${encodeURIComponent(this.searchOptions.entityPermission)}`;return`${this.searchOptions.searchEndpoint}?${t}`}searchEntities(t){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");this.input.value="";let n=`${this.searchUrl()}&term=${encodeURIComponent(t)}`;window.$http.get(n).then(o=>{this.resultsContainer.innerHTML=o.data,this.hideLoading()})}isDoubleClick(){let t=Date.now(),n=t-this.lastClick<300;return this.lastClick=t,n}onClick(t){let n=t.target.closest("[data-entity-type]");n instanceof HTMLElement&&(t.preventDefault(),t.stopPropagation(),this.selectItem(n))}selectItem(t){let n=this.isDoubleClick(),o=t.getAttribute("data-entity-type"),s=t.getAttribute("data-entity-id"),r=!t.classList.contains("selected")||n;this.unselectAll(),this.input.value=r?`${o}:${s}`:"";let a=t.getAttribute("href")||"",l=t.querySelector(".entity-list-item-name")?.textContent||"",d={id:Number(s),name:l,link:a};r?t.classList.add("selected"):window.$events.emit("entity-select-change"),!(!n&&!r)&&(n&&this.confirmSelection(d),r&&window.$events.emit("entity-select-change",d))}confirmSelection(t){window.$events.emit("entity-select-confirm",t)}unselectAll(){let t=this.elem.querySelectorAll(".selected");for(let n of t)n.classList.remove("selected","primary-background")}};var bn=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"selectButton");c(this,"selectorEl");c(this,"callback",null);c(this,"selection",null)}setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(t,n={}
4){this.callback=t,this.getSelector().configureSearchOptions(n),this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(t){this.selection=t.hasOwnProperty("id")?t:null,this.selection?this.selectButton.removeAttribute("disabled"):this.selectButton.setAttribute("disabled","true")}handleConfirmedSelection(t){this.hide(),this.getSelector().reset(),this.callback&&t&&this.callback(t)}};var wn=class extends h{setup(){this.container=this.$el,this.name=this.$opts.name,H(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var yn=class extends h{setup(){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(e){Yt(e,200)}close(e){Gt(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let n of t)(this.isOpen?this.close:this.open)(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var En=class extends h{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let e=ft(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:t}=this.input;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new Lt(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let n=lt(t);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(n),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var Cn=class extends h{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var xn=class extends h{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.uploadButton=this.$refs.uploadButton,this.uploadHint=this.$refs.uploadHint,this.formContainer=this.$refs.formContainer,this.formContainerPlaceholder=this.$refs.formContainerPlaceholder,this.dropzoneContainer=this.$refs.dropzoneContainer,this.loadMore=this.$refs.loadM
4ore,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){H(this.filterTabs,n=>{this.resetAll(),this.filter=n.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",n=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),n.preventDefault()}),H(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),W(this.container,".load-more button","click",this.runLoadMore.bind(this)),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",n=>{n.target.src=window.baseUrl("loading_error.png")},!0),H(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),W(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),W(this.formContainer,"#image-manager-rebuild-thumbs","click",async(n,o)=>{o.disabled=!0,this.lastSelected&&await this.rebuildThumbnails(this.lastSelected.id),o.disabled=!1}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let e=this.listContainer.parentElement,t=[];e.addEventListener("wheel",n=>{if(!(Math.ceil(e.scrollHeight-e.scrollTop)===e.clientHeight)||n.deltaY<1)return;let r=Date.now()-1e3;t.push(Date.now()),t=t.filter(a=>a>=r),t.length>5&&this.canLoadMore()&&this.runLoadMore()})}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show();let n=t!=="gallery";this.dropzoneContainer.classList.toggle("hidden",n),this.uploadButton.classList.toggle("hidden",n),this.uploadHint.classList.toggle("hidden",n),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!n),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),oe(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e;let n=t.querySelector(".load-more");n&&(n.remove(),this.loadMore.innerHTML=n.innerHTML),this.loadMore.toggleAttribute("hidden",!n),window.$components.init(t);for(let o of[...t.children])this.listContainer.appendChild(o)}setActiveFilterTab(e){for(let t of this.filterTabs){let n=t.dataset.filter===e;t.setAttribute("aria-selected",n?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value="",this.cancelSearch.toggleAttribute("hidden",!0)}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){It(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}async onImageSelectEvent(e){let t=JSON.parse(e.detail.data),n=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),!o&&!n?(e.target.classList.add("selected"),t=await this.loadImageEditForm(t.id)):n?n&&(t=this.lastSelected):this.resetEditForm(),this.selectButton.classList.toggle("hidden",o),n&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let n=t?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=o,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer);let s=this.formContainer.querySelector("#image-manager-form-image-data");return JSON.parse(s.text)}runLoadMore(){It(this.loadMore),this.page+=1,this.loadGallery()}canLoadMore(){return this.loadMore.querySelector("button")&&!this.loadMore.hasAttribute("hidden")}async rebuildThumbnails(e){try{let t=await window.$http.put(`/images/${e}/rebuild-thumbnails`);window.$events.success(t.data),this.refreshGallery()}catch(t){window.$events.showResponseError(t)}}};var Ln=class extends h{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};function Zt(...i){return{move_up(e){let t=e.parentNode,n=Array.from(t.children).indexOf(e),o=Math.max(n-1,0);t.insertBefore(e,t.children[o]||null)},move_down(e){let t=e.parentNode,n=Array.from(t.children).indexOf(e),o=Math.min(n+2,t.children.length);t.insertBefore(e,t.children[o]||null)},move_right(e){let t=e.parentNode,n=i.indexOf(t),o=Math.min(n+1,i.length-1);i[o].appendChild(e)},move_left(e){let t=e.parentNode,n=i.indexOf(t),o=Math.max(n-1,0);i[o].appendChild(e)},remove(e){let t=i.find(n=>n!==e.parentNode);t&&t.appendChild(e)},add(e){let t=i.find(n=>n!==e.parentNode);t&&t.appendChild(e)}}}function Qt(i,e){return t=>{let n=t.target.closest(".scroll-box-item button[data-action]");if(n){let o=n.closest(".scroll-box-item"),s=n.dataset.action;if(!s)throw new Error("No action defined for clicked button");let r=i[s];r(o),e()}}}var Tn=class extends h{constructor(){super(...arguments);c(this,"input");c(this,"columns");c(this,"actionMenus")}setup(){this.input=this.$refs.input,this.columns=this.$manyRefs.column||[],this.actionMenus=this.$manyRefs.actionMenu||[],this.initSortable();let t=this.columns.find(s=>s.dataset.column==="unused"),n=Zt(...this.columns);n.add=this.addBlockToLeastPopulated.bind(this),n.remove=function(s){t.appendChild(s)};let o=Qt(n,this.onChange.bind(this));for(let s of this.actionMenus)s.addEventListener("click",o)}initSortable(){let t=this.onChange.bind(this);for(let n of this.columns)new ut(n,{group:"layout-editor-blocks",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:t})}onChange(){let t={};for(let n of this.columns){let o=n.dataset.column||"";if(!o)continue;t[o]=[];let s=n.children;for(let r=0;r<s.length;r++){let l=s[r].dataset.blockId||"";l&&t[o].push(l)}}this.input.value=JSON.stringify(t,null,2)}addBlockToLeastPopulated(t){let n=100,o=null;for(let s of this.columns){let r=s.children.length;s.dataset.column!=="unused"&&r<n&&(o=s,n=r)}o&&o.appendChild(t)}};var Sn=class extends h{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};function Z(i,e={},t=[]){let n=document.createElement(i),o=Object.keys(e);for(let s of o)e[s]!==null&&n.setAttribute(s,e[s]);for(let s of t)typeof s=="string"?n.append(document.createTextNode(s)):n.append(s);return n}var kn=class extends h{constructor(){super(...arguments);c(this,"button");c(this,"loadingEl",null)}setup(){this.button=this.$el;let t=this.button.form,n=()=>{setTimeout(()=>this.showLoadingState(),10)};this.button.addEventListener("click",n),t&&t.addEventListener("submit",n)}showLoadingState(){this.button.disabled=!0,this.loadingEl||(this.loadingEl=Z("div",{class:"inline block"}),It(this.loadingEl),this.button.after(this.loadingEl))}};var $n=class extends h{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.display=this.$refs.display,this.input=this.$refs.input,this.divider=this.$refs.divider,this.displayWrap=this.$refs.displayWrap;let{settingContainer:e}=this.$refs,t=e.querySelectorAll('input[type="checkbox"]');this.editor=null,window.importVersioned("markdown").then(n=>n.init({pageId:this.pageId,container:this.elem,displayEl:this.display,inputEl:this.input,drawioUrl:this.getDrawioUrl(),settingInputs:Array.from(t),text:{serverUploadLimit:this.serverUploadLimitText,imageUploadError:this.imageUploadErrorText}})).then(n=>{this.editor=n,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,cmEditorView:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",e=>{let t=e.target.closest("button[data-action]");if(t===null)return;let n=t.getAttribute("data-action");if(n==="insertImage"&&this.editor.actions.showImageInsert(),n==="insertLink"&&this.editor.actions.showLinkSelector(),n==="insertDrawing"&&(e.ctrlKey||e.metaKey)){this.editor.actions.showImageManager();return}n==="insertDrawing"&&this.editor.actions.startDrawing(),n==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",e=>{let t=e.target.closest(".editor-toolbar-label");if(!t)return;let n=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of n)o.classList.remove("active");t.closest(".markdown-editor-wrap").classList.add("active")}),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",()=>{let t=this.elem.getBoundingClientRect(),n=s=>{let r=s.pageX-t.left,a=Math.min(Math.max(20,Math.floor(r/t.width*100)),80);this.displayWrap.style.flexBasis=`${100-a}%`,this.editor.settings.set("editorWidth",a)},o=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",o),this.display.style.pointerEvents=null,document.body.style.userSelect=null};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",n),window.addEventListener("pointerup",o)});let e=this.editor.settings.get("editorWidth");e&&(this.displayWrap.style.flexBasis=`${100-e}%`)}scrollToTextIfNeeded(){let t=new URL(window.location).searchParams.get("content-text");t&&this.editor.actions.scrollToText(t)}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e&&e.getAttribute("drawio-url")||""}async getContent(){return this.editor.actions.getContent()}};var Mn=class extends h{setup(){this.container=this.$el,this.inputContainer=this.$refs.inputContainer,this.inviteOption=this.container.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let e=this.inviteOption.value==="true",t=this.container.querySelectorAll("input[type=password]");for(let n of t)n.disabled=e;this.inputContainer.style.display=e?"none":"block"}};var An=class extends h{setup(){this.container=this.$el,this.type=this.$opts.type,this.textElem=this.container.querySelector("span"),this.autoHide=this.$opts.autoHide==="true",this.initialShow=this.$opts.show==="true",this.container.style.display="grid",window.$events.listen(this.type,e=>{this.show(e)}),this.container.addEventListener("click",this.hide.bind(this)),this.initialShow&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(e=""){if(this.container.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=e,this.container.style.display="grid",setTimeout(()=>{this.container.classList.add("showing")},1),this.autoHide){let t=e.split(" ").length,n=Math.max(2e3,1e3+250*t);setTimeout(this.hide.bind(this),n)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var Dn=class extends h{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){H(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),H(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};var In=class extends h{constructor(){super(...arguments);c(this,"commentId");c(this,"commentLocalId");c(this,"deletedText");c(this,"updatedText");c(this,"archiveText");c(this,"wysiwygEditor",null);c(this,"wysiwygTextDirection");c(this,"container");c(this,"contentContainer");c(this,"form");c(this,"formCancel");c(this,"editButton");c(this,"deleteButton");c(this,"replyButton");c(this,"archiveButton");c(this,"input")}
4setup(){this.commentId=this.$opts.commentId,this.commentLocalId=this.$opts.commentLocalId,this.deletedText=this.$opts.deletedText,this.updatedText=this.$opts.updatedText,this.archiveText=this.$opts.archiveText,this.wysiwygTextDirection=this.$opts.wysiwygTextDirection,this.container=this.$el,this.contentContainer=this.$refs.contentContainer,this.form=this.$refs.form,this.formCancel=this.$refs.formCancel,this.editButton=this.$refs.editButton,this.deleteButton=this.$refs.deleteButton,this.replyButton=this.$refs.replyButton,this.archiveButton=this.$refs.archiveButton,this.input=this.$refs.input,this.setupListeners()}setupListeners(){if(this.replyButton){let t={id:this.commentLocalId,element:this.container};this.replyButton.addEventListener("click",()=>this.$emit("reply",t))}this.editButton&&(this.editButton.addEventListener("click",this.startEdit.bind(this)),this.form.addEventListener("submit",this.update.bind(this)),this.formCancel.addEventListener("click",()=>this.toggleEditMode(!1))),this.deleteButton&&this.deleteButton.addEventListener("click",this.delete.bind(this)),this.archiveButton&&this.archiveButton.addEventListener("click",this.archive.bind(this))}toggleEditMode(t){this.contentContainer.toggleAttribute("hidden",t),this.form.toggleAttribute("hidden",!t)}async startEdit(){if(this.toggleEditMode(!0),this.wysiwygEditor){this.wysiwygEditor.focus();return}let t=await window.importVersioned("wysiwyg"),n=this.input.value,o=Z("div",{class:"comment-editor-container"});this.input.parentElement?.appendChild(o),this.input.hidden=!0,this.wysiwygEditor=t.createCommentEditorInstance(o,n,{darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:window.editor_translations}),this.wysiwygEditor.focus()}async update(t){t.preventDefault();let n=this.showLoading();this.form.toggleAttribute("hidden",!0);let o={html:await this.wysiwygEditor?.getContentAsHtml()||""};try{let s=await window.$http.put(`/comment/${this.commentId}`,o),r=lt(s.data);this.container.replaceWith(r),window.$events.success(this.updatedText)}catch(s){console.error(s),s instanceof At&&window.$events.showValidationErrors(s),this.form.toggleAttribute("hidden",!1),n.remove()}}async delete(){this.showLoading(),await window.$http.delete(`/comment/${this.commentId}`),this.$emit("delete");let t=this.container.closest(".comment-branch");if(t instanceof HTMLElement){let n=window.$components.allWithinElement(t,"page-comment-reference");for(let o of n)o.hideMarker();t.remove()}window.$events.success(this.deletedText)}async archive(){this.showLoading();let n=this.archiveButton.dataset.isArchived==="true"?"unarchive":"archive",o=await window.$http.put(`/comment/${this.commentId}/${n}`);window.$events.success(this.archiveText);let s={new_thread_dom:lt(o.data)};this.$emit(n,s);let r=this.container.closest(".comment-branch"),a=window.$components.allWithinElement(r,"page-comment-reference");for(let l of a)l.hideMarker();r.remove()}showLoading(){let t=Wt();return t.classList.add("px-l"),this.container.append(t),t}};var es='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.99 4c0-1.1-.89-2-1.99-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4zM18 14H6v-2h12zm0-3H6V9h12zm0-3H6V6h12z"/><path fill="none" d="M0 0h24v24H0z"/></svg>';var ns='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';var te=null,Hn=class extends h{constructor(){super(...arguments);c(this,"link");c(this,"reference");c(this,"markerWrap",null);c(this,"viewCommentText");c(this,"jumpToThreadText");c(this,"closeText")}setup(){this.link=this.$el,this.reference=this.$opts.reference,this.viewCommentText=this.$opts.viewCommentText,this.jumpToThreadText=this.$opts.jumpToThreadText,this.closeText=this.$opts.closeText,this.showForDisplay(),window.addEventListener("editor-toolbox-change",(t=>{let n=t.detail.tab,o=t.detail.open;n==="comments"&&o&&this.link.checkVisibility()?this.showForEditor():this.hideMarker()})),window.addEventListener("toggle",t=>{t.target instanceof HTMLElement&&t.target.contains(this.link)&&window.requestAnimationFrame(()=>
4{this.link.checkVisibility()?this.showForEditor():this.hideMarker()})},{capture:!0}),window.addEventListener("tabs-change",(t=>{let n=t.detail.showing;if(!n.startsWith("comment-tab-panel"))return;document.getElementById(n)?.contains(this.link)?this.showForDisplay():this.hideMarker()}))}showForDisplay(){let t=document.querySelector(".page-content");t instanceof HTMLElement&&this.link.checkVisibility()&&this.updateMarker(t)}showForEditor(){let t=document.querySelector(".editor-content-wrap");t instanceof HTMLElement&&this.updateMarker(t);let n=()=>{this.hideMarker(),setTimeout(()=>{window.$events.remove("editor-html-change",n)},1)};window.$events.listen("editor-html-change",n)}updateMarker(t){this.link.classList.remove("outdated","missing"),this.markerWrap&&this.markerWrap.remove();let[n,o,s]=this.reference.split(":"),r=document.getElementById(n);if(!r){this.link.classList.add("outdated","missing");return}$e(r)!==o&&this.link.classList.add("outdated");let l=Z("button",{type:"button",class:"content-comment-marker",title:this.viewCommentText});l.innerHTML=es,l.addEventListener("click",m=>{this.showCommentAtMarker(l)}),this.markerWrap=Z("div",{class:"content-comment-highlight"},[l]),t.append(this.markerWrap),this.positionMarker(r,s),this.link.href=`#${r.id}`,this.link.addEventListener("click",m=>{m.preventDefault(),Dt(r)});let d=ft(()=>{this.positionMarker(r,s)},50,!1).bind(this);window.addEventListener("resize",d)}positionMarker(t,n){if(!this.markerWrap)return;let o=this.markerWrap.parentElement,s=o.getBoundingClientRect(),r=t.getBoundingClientRect(),[a,l]=n.split("-");if(a&&l){let p=new Range,v=ke(t,Number(a)),y=ke(t,Number(l));v&&y&&(p.setStart(v.node,v.offset),p.setEnd(y.node,y.offset),r=p.getBoundingClientRect())}let d=r.left-s.left,m=r.top-s.top+o.scrollTop;this.markerWrap.style.left=`${d}px`,this.markerWrap.style.top=`${m}px`,this.markerWrap.style.width=`${r.width}px`,this.markerWrap.style.height=`${r.height}px`}hideMarker(){te&&te(),this.markerWrap?.remove(),this.markerWrap=null}showCommentAtMarker(t){te&&te(),t.hidden=!0;let n=this.link.closest(".comment-box"),o=n.closest(".comment-branch").cloneNode(!0),s=o.querySelectorAll(".actions, form");for(let y of s)y.remove();let r=Z("button",{type:"button",title:this.closeText});r.innerHTML=ns;let a=Z("button",{type:"button","data-action":"jump"},[this.jumpToThreadText]),l=Z("div",{class:"content-comment-window"},[Z("div",{class:"content-comment-window-actions"},[a,r]),Z("div",{class:"content-comment-window-content comment-container-compact comment-container-super-compact"},[o])]);t.parentElement?.append(l);let d=()=>{l.remove(),t.hidden=!1,window.removeEventListener("click",m),te=null},m=y=>{t.parentElement.contains(y.target)||d()};window.addEventListener("click",m),te=d,r.addEventListener("click",d.bind(this)),a.addEventListener("click",()=>{d(),n.scrollIntoView({behavior:"smooth"});let y=n.querySelector(".header");y.classList.add("anim-highlight"),y.addEventListener("animationend",()=>y.classList.remove("anim-highlight"))});let p=l.getBoundingClientRect(),v=document.querySelector(".page-content")?.getBoundingClientRect();if(v&&p.right>v.right){let y=p.right-v.right;l.style.left=`-${y}px`}}};var ee=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"tabList");c(this,"tabs");c(this,"panels");c(this,"activeUnder");c(this,"active",null)}setup(){this.container=this.$el,this.tabList=this.container.querySelector('[role="tablist"]'),this.tabs=Array.from(this.tabList.querySelectorAll('[role="tab"]')),this.panels=Array.from(this.container.querySelectorAll(':scope > [role="tabpanel"], :scope > * > [role="tabpanel"]')),this.activeUnder=this.$opts.activeUnder?Number(this.$opts.activeUnder):1e4,this.container.addEventListener("click",t=>{let n=t.target.closest('[role="tab"]');n instanceof HTMLElement&&this.tabs.includes(n)&&this.show(n.getAttribute("aria-controls")||"")}),window.addEventListener("resize",this.updateActiveState.bind(this),{passive:!0}),this.updateActiveState()}show(t){for(let o of this.panels)o.toggleAttribute("hidden",o.id!==t);for(let o of this.tabs){let r=o.getAttribute("aria-controls")===t;o.setAttribute("aria-selected",r?"true":"false")}let n={showing:t};this.$emit("change",n)}updateActiveState(){let t=window.innerWidth<this.activeUnder;t!==this.active&&(t?this.activate():this.deactivate(),this.active=t)}activate(){let t=this.panels.find(n=>!n.hasAttribute("hidden"))||this.panels[0];
4this.show(t.id),this.tabList.toggleAttribute("hidden",!1)}deactivate(){for(let t of this.panels)t.removeAttribute("hidden");for(let t of this.tabs)t.setAttribute("aria-selected","false");this.tabList.toggleAttribute("hidden",!0)}};var Pn=class extends h{constructor(){super(...arguments);c(this,"elem");c(this,"pageId");c(this,"container");c(this,"commentCountBar");c(this,"activeTab");c(this,"archivedTab");c(this,"addButtonContainer");c(this,"archiveContainer");c(this,"activeContainer");c(this,"replyToRow");c(this,"referenceRow");c(this,"formContainer");c(this,"form");c(this,"formInput");c(this,"formReplyLink");c(this,"formReferenceLink");c(this,"addCommentButton");c(this,"hideFormButton");c(this,"removeReplyToButton");c(this,"removeReferenceButton");c(this,"wysiwygTextDirection");c(this,"wysiwygEditor",null);c(this,"createdText");c(this,"countText");c(this,"archivedCountText");c(this,"parentId",null);c(this,"contentReference","");c(this,"formReplyText","")}setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.commentCountBar=this.$refs.commentCountBar,this.activeTab=this.$refs.activeTab,this.archivedTab=this.$refs.archivedTab,this.addButtonContainer=this.$refs.addButtonContainer,this.archiveContainer=this.$refs.archiveContainer,this.activeContainer=this.$refs.activeContainer,this.replyToRow=this.$refs.replyToRow,this.referenceRow=this.$refs.referenceRow,this.formContainer=this.$refs.formContainer,this.form=this.$refs.form,this.formInput=this.$refs.formInput,this.formReplyLink=this.$refs.formReplyLink,this.formReferenceLink=this.$refs.formReferenceLink,this.addCommentButton=this.$refs.addCommentButton,this.hideFormButton=this.$refs.hideFormButton,this.removeReplyToButton=this.$refs.removeReplyToButton,this.removeReferenceButton=this.$refs.removeReferenceButton,this.wysiwygTextDirection=this.$opts.wysiwygTextDirection,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.archivedCountText=this.$opts.archivedCountText,this.formReplyText=this.formReplyLink?.textContent||"",this.setupListeners()}setupListeners(){this.elem.addEventListener("page-comment-delete",()=>{setTimeout(()=>{this.updateCount(),this.hideForm()},1)}),this.elem.addEventListener("page-comment-reply",(t=>{this.setReply(t.detail.id,t.detail.element)})),this.elem.addEventListener("page-comment-archive",(t=>{this.archiveContainer.append(t.detail.new_thread_dom),setTimeout(()=>this.updateCount(),1)})),this.elem.addEventListener("page-comment-unarchive",(t=>{this.container.append(t.detail.new_thread_dom),setTimeout(()=>this.updateCount(),1)})),this.form&&(this.removeReplyToButton.addEventListener("click",this.removeReplyTo.bind(this)),this.removeReferenceButton.addEventListener("click",()=>this.setContentReference("")),this.hideFormButton.addEventListener("click",this.hideForm.bind(this)),this.addCommentButton.addEventListener("click",this.showForm.bind(this)),this.form.addEventListener("submit",this.saveComment.bind(this)))}async saveComment(t){t.preventDefault(),t.stopPropagation();let n=Wt();n.classList.add("px-l"),this.form.after(n),this.form.toggleAttribute("hidden",!0);let o={html:await this.wysiwygEditor?.getContentAsHtml()||"",parent_id:this.parentId||null,content_ref:this.contentReference};window.$http.post(`/comment/${this.pageId}`,o).then(s=>{let r=lt(s.data);o.parent_id?this.formContainer.after(r):this.container.append(r);let a=window.$components.allWithinElement(r,"page-comment-reference");for(let l of a)l.showForDisplay();window.$events.success(this.createdText),this.hideForm(),this.updateCount()}).catch(s=>{this.form.toggleAttribute("hidden",!1),window.$events.showValidationErrors(s)}),this.form.toggleAttribute("hidden",!1),n.remove()}updateCount(){let t=this.getActiveThreadCount();this.activeTab.textContent=window.$trans.choice(this.countText,t);let n=this.getArchivedThreadCount();this.archivedTab.textContent=window.$trans.choice(this.archivedCountText,n)}resetForm(){this.removeEditor(),this.formInput.value="",this.parentId=null,this.replyToRow.toggleAttribute("hidden",!0),this.container.append(this.formContainer),this.setContentReference("")}showForm(){this.removeEditor(),this.formContainer.toggleAttribute("hidden",!1),this.addButtonContainer.toggleAttribute("hidden",!0),this.formContainer.scrollIntoView({behavior:"smooth",block:"nearest"}),this.loadEditor();let t=window.$components.firstOnElement(this.elem,"tabs");t instanceof ee&&this.formContainer.closest("#comment-tab-panel-active")&&t.show("comment-tab-panel-active")}hideForm(){this.resetForm(),this.formContainer.toggleAttribute("hidden",!0),this.getActiveThreadCount()>0?this.activeContainer.append(this.addButtonContainer):this.commentCountBar.append(this.addButtonContainer),this.addButtonContainer.toggleAttribute("hidden",!1)}async loadEditor(){if(this.wysiwygEditor){this.wysiwygEditor.focus();return}let t=await window.importVersioned("wysiwyg"),n=Z("div",{class:"comment-editor-container"});this.formInput.parentElement?.appendChild(n),this.formInput.hidden=!0,this.wysiwygEditor=t.createCommentEditorInstance(n,"<p></p>",{darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.wysiwygTextDirection,translations:window.editor_translations}),this.wysiwygEditor.focus()}removeEditor(){this.wysiwygEditor&&(this.wysiwygEditor.remove(),this.wysiwygEditor=null)}getActiveThreadCount(){return this.container.querySelectorAll(":scope > .comment-branch:not([hidden])").length}getArchivedThreadCount(){return this.archiveContainer.querySelectorAll(":scope > .comment-branch").length}setReply(t,n){n.closest(".comment-branch").querySelector(".comment-branch-children").append(this.formContainer),this.show
4Form(),this.parentId=Number(t),this.replyToRow.toggleAttribute("hidden",!1),this.formReplyLink.textContent=this.formReplyText.replace("1234",String(this.parentId)),this.formReplyLink.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.toggleAttribute("hidden",!0),this.container.append(this.formContainer),this.showForm()}startNewComment(t){this.resetForm(),this.showForm(),this.setContentReference(t)}setContentReference(t){this.contentReference=t,this.referenceRow.toggleAttribute("hidden",!t);let[n]=t.split(":");this.formReferenceLink.href=`#${n}`,this.formReferenceLink.onclick=function(o){o.preventDefault();let s=document.getElementById(n);s&&Dt(s)}}};function Dr(i,e){fi(`#page-navigation a[href="#${i}"]`,t=>{t.closest("li").classList.toggle("current-heading",e)})}function Ir(i){for(let e of i){let t=e.intersectionRatio===1;Dr(e.target.id,t)}}function Hr(i){let e={rootMargin:"0px 0px 0px 0px",threshold:1},t=new IntersectionObserver(Ir,e);for(let n of i)t.observe(n)}var Bn=class extends h{setup(){if(this.container=this.$el,this.pageId=this.$opts.pageId,window.importVersioned("code").then(t=>t.highlight()),this.setupNavHighlighting(),window.location.hash){let t=window.location.hash.replace(/%20/g," ").substring(1);this.goToText(t)}
4let e=document.querySelector(".sidebar-page-nav");e&&W(e,"a","click",(t,n)=>{t.preventDefault(),window.$components.first("tri-layout").showContent();let o=n.getAttribute("href").substr(1);this.goToText(o),window.history.pushState(null,null,`#${o}`)})}goToText(e){let t=document.getElementById(e);if(fi(".page-content [data-highlighted]",n=>{n.removeAttribute("data-highlighted"),n.style.backgroundColor=null}),t!==null)Dt(t);else{let n=xo(".page-content > div > *",e);n&&Dt(n)}}setupNavHighlighting(){let e=document.querySelector(".sidebar-page-nav"),t=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");t.length>0&&e!==null&&Hr(t)}};function is(i){let e=new Date(i*1e3),t=e.getHours(),n=e.getMinutes();return`${(t>9?"":"0")+t}:${(n>9?"":"0")+n}`}var Rn=class extends h{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.deleteDraftButton=this.$refs.deleteDraft,this.deleteDraftWrap=this.$refs.deleteDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.changelogCounter=this.$refs.changelogCounter,this.changeEditorButtons=this.$manyRefs.changeEditor||[],this.switchDialogContainer=this.$refs.switchDialog,this.deleteDraftDialogContainer=this.$refs.deleteDraftDialog,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.draftDeleteText=this.$opts.draftDeleteText,this.draftDeleteFailText=this.$opts.draftDeleteFailText,this.setChangelogText=this.$opts.setChangelogText,this.autoSave={interval:null,frequency:3e4,last:0,pendingChange:!1},this.shownWarningsCache=new Set,this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this));let e=()=>{this.autoSave.pendingChange=!0};window.$events.listen("editor-html-change",e),window.$events.listen("editor-markdown-change",e),this.titleElem.addEventListener("input",e);let t=ft(this.updateChangelogDisplay.bind(this),300,!1);this.changelogInput.addEventListener("input",()=>{let n=this.changelogInput.value.length;this.changelogCounter.innerText=`${n} / 180`,t()}),H(this.saveDraftButton,this.saveDraft.bind(this)),H(this.discardDraftButton,this.discardDraft.bind(this)),H(this.deleteDraftButton,this.deleteDraft.bind(this)),H(this.changeEditorButtons,this.changeEditor.bind(this))}setInitialFocus(){if(this.hasDefaultTitle){this.titleElem.select();return}window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){this.autoSave.interval=window.setInterval(this.runAutoSave.bind(this),this.autoSave.frequency)}runAutoSave(){Date.now()-this.autoSave.last<this.autoSave.frequency/2||!this.autoSave.pendingChange||this.saveDraft()}savePage(){this.container.closest("form").requestSubmit()}async saveDraft(){let e={name:this.titleElem.value.trim()},t=await this.getEditorComponent().getContent();Object.assign(e,t);let n=!1;try{let o=await window.$http.put(`/ajax/page/${this.pageId}/save-draft`,e);this.isNewDraft||(this.discardDraftWrap.toggleAttribute("hidden",!1),this.deleteDraftWrap.toggleAttribute("hidden",!1)),this.draftNotifyChange(`${o.data.message} ${is(o.data.timestamp)}`),this.autoSave.last=Date.now(),o.data.warning&&!this.shownWarningsCache.has(o.data.warning)&&(window.$events.emit("warning",o.data.warning),this.shownWarningsCache.add(o.data.warning)),n=!0,this.autoSave.pen
4dingChange=!1}catch{try{let o=`draft-save-fail-${new Date().toISOString()}`;window.localStorage.setItem(o,JSON.stringify(e))}catch(o){console.error(o)}window.$events.emit("error",this.autosaveFailText)}return n}draftNotifyChange(e){this.draftDisplay.innerText=e,this.draftDisplayIcon.classList.add("visible"),window.setTimeout(()=>{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(e=!0){let t;try{t=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(n){console.error(n);return}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.discardDraftWrap.toggleAttribute("hidden",!0),window.$events.emit("editor::replace",{html:t.data.html,markdown:t.data.markdown}),this.titleElem.value=t.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),e&&window.$events.success(this.draftDiscardedText)}async deleteDraft(){if(await window.$components.firstOnElement(this.deleteDraftDialogContainer,"confirm-dialog").show())try{let n=this.discardDraft(!1),o=window.$http.delete(`/page-revisions/user-drafts/${this.pageId}`);await Promise.all([n,o]),window.$events.success(this.draftDeleteText),this.deleteDraftWrap.toggleAttribute("hidden",!0)}catch(n){console.error(n),window.$events.error(this.draftDeleteFailText)}}updateChangelogDisplay(){let e=this.changelogInput.value.trim();e.length===0?e=this.setChangelogText:e.length>16&&(e=`${e.slice(0,16)}...`),this.changelogDisplay.innerText=e}async changeEditor(e){e.preventDefault();let t=e.target.closest("a").href,n=window.$components.firstOnElement(this.switchDialogContainer,"confirm-dialog"),[o,s]=await Promise.all([this.saveDraft(),n.show()]);o&&s&&(window.location=t)}getEditorComponent(){return window.$components.first("markdown-editor")||window.$components.first("wysiwyg-editor")||window.$components.first("wysiwyg-editor-tinymce")}};function On(i,e){i.toggleAttribute("hidden",!e)}var Nn=class extends h{setup(){this.input=this.$refs.input,this.resetButton=this.$refs.resetButton,this.selectButton=this.$refs.selectButton,this.display=this.$refs.display,this.defaultDisplay=this.$refs.defaultDisplay,this.buttonSep=this.$refs.buttonSeperator,this.selectorEndpoint=this.$opts.selectorEndpoint,this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.display.addEventListener("click",e=>e.stopPropagation()),this.resetButton.addEventListener("click",()=>{this.setValue("","")})}showPopup(){window.$components.first("entity-selector-popup").show(t=>{this.setValue(t.id,t.name)},{initialValue:"",searchEndpoint:this.selectorEndpoint,entityTypes:"page",entityPermission:"view"})}
4setValue(e,t){this.value=e,this.input.value=e,this.controlView(t)}controlView(e){let t=this.value&&this.value!==0;if(On(this.resetButton,t),On(this.buttonSep,t),On(this.defaultDisplay,!t),On(this.display,t),t){let n=this.getAssetIdFromVal();this.display.textContent=`#${n}, ${e}`,this.display.href=window.baseUrl(`/link/${n}`)}}getAssetIdFromVal(){return Number(this.value)}};var _n=class extends h{setup(){this.container=this.$el,this.cellSelector=this.$opts.cellSelector||"td,th",this.rowSelector=this.$opts.rowSelector||"tr";for(let e of this.$manyRefs.toggleAll||[])e.addEventListener("click",this.toggleAllClick.bind(this));for(let e of this.$manyRefs.toggleRow||[])e.addEventListener("click",this.toggleRowClick.bind(this));for(let e of this.$manyRefs.toggleColumn||[])e.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(e){e.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(e){e.preventDefault(),this.toggleAllInElement(e.target.closest(this.rowSelector))}toggleColumnClick(e){e.preventDefault();let t=e.target.closest(this.cellSelector),n=Array.from(t.parentElement.children).indexOf(t),o=this.container.querySelectorAll(this.rowSelector),s=[];for(let r of o){let a=r.children[n];a&&s.push(...a.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(s)}toggleAllInElement(e){let t=e.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(t)}toggleAllInputs(e){let t=e.length>0?e[0].checked:!1;for(let n of e)n.checked=!t,n.dispatchEvent(new Event("change"))}};var Fn=class extends h{constructor(){super(...arguments);c(this,"showing",!1);c(this,"isMakingSelection",!1);c(this,"targetElement",null);c(this,"targetSelectionRange",null);c(this,"pointer");c(this,"linkInput");c(this,"linkButton");c(this,"includeInput");c(this,"includeButton");c(this,"sectionModeButton");c(this,"commentButton");c(this,"modeToggles");c(this,"modeSections");c(this,"pageId")}setup(){this.pointer=this.$refs.pointer,this.linkInput=this.$refs.linkInput,this.linkButton=this.$refs.linkButton,this.includeInput=this.$refs.includeInput,this.includeButton=this.$refs.includeButton,this.sectionModeButton=this.$refs.sectionModeButton,this.commentButton=this.$refs.commentButton,this.modeToggles=this.$manyRefs.modeToggle,this.modeSections=this.$manyRefs.modeSection,this.pageId=this.$opts.pageId,this.setupListeners()}setupListeners(){this.includeButton.addEventListener("click",()=>Wi(this.includeInput.value)),this.linkButton.addEventListener("click",()=>Wi(this.linkInput.value)),H([this.includeInput,this.linkInput],n=>{n.target.select(),n.stopPropagation()}),Se(this.pointer,["click","focus"],n=>{n.stopPropagation()}),Se(document.body,["click","focus"],()=>{!this.showing||this.isMakingSelection||this.hidePointer()}),Co(this.pointer,this.hidePointer.bind(this));let t=document.querySelector(".page-content");Se(t,["mouseup","keyup"],n=>{n.stopPropagation();let o=n.target.closest('[id^="bkmrk"]');if(o instanceof HTMLElement&&(window.getSelection()||"").toString().length>0){let s=n instanceof MouseEvent?n.pageX:0;this.showPointerAtTarget(o,s,!1)}}),H(this.sectionModeButton,this.enterSectionSelectMode.bind(this)),H(this.modeToggles,n=>{let o=n.target;for(let r of this.modeSections){let a=!r.contains(o);r.toggleAttribute("hidden",!a)}let s=this.modeToggles.find(r=>r!==o);s&&s.focus()}),this.commentButton&&H(this.commentButton,this.createCommentAtPointer.bind(this))}hidePointer(){this.pointer.style.removeProperty("display"),this.showing=!1,this.targetElement=null,this.targetSelectionRange=null}showPointerAtTarget(t,n,o){this.targetElement=t;let s=window.getSelection(),r=s?.direction||"";this.targetSelectionRange=s?.getRangeAt(0)||null,this.updateDomForTarget(t),this.pointer.style.display="block";let a=t.getBoundingClientRect(),l=this.pointer.getBoundingClientRect(),m=Math.min(Math.max(n,a.left),a.right)-l.width/2,p=a.top-l.height-16;this.pointer.style.left=`${m}px`,this.pointer.style.top=`${p}px`,this.showing=!0,this.isMakingSelection=!0,setTimeout(()=>{this.isMakingSelection=!1},100);let v=()=>{this.hidePointer(),window.removeEventListener("scroll",v)};r==="forward"?t.after(this.pointer):t.before(this.pointer),o||window.addEventListener("scroll",v,{passive:!0})}updateDomForTarget(t){let n=window.baseUrl(`/link/${this.pageId}#${t.id}`),o=`{{@${this.pageId}#${t.id}}}`;this.linkInput.value=n,this.includeInput.value=o;let s=this.pointer.querySelector("#pointer-edit");if(s instanceof HTMLAnchorElement&&t){let{editHref:r}=s.dataset,a=t.id,l=(t.textContent||"").substring(0,50);s.href=`${r}?content-id=${a}&content-text=${encodeURIComponent(l)}`}}enterSectionSelectMode(){let t=Array.from(document.querySelectorAll('.page-content [id^="bkmrk"]'));for(let n of t)n.setAttribute("tabindex","0");t[0].focus(),qt(t,n=>{this.showPointerAtTarget(n.target,0,!0),this.pointer.focus()})}createCommentAtPointer(){if(!this.targetElement)return;let t=this.targetElement.id,n=$e(this.targetElement),o="";if(this.targetSelectionRange){let a=this.targetSelectionRange.commonAncestorContainer;if(this.targetElement.contains(a)){let l=gi(this.targetSelectionRange.startContainer,this.targetSelectionRange.startOffset,this.targetElement),d=gi(this.targetSelectionRange.endContainer,this.targetSelectionRange.endOffset,this.targetElement);o=`${l}-${d}`}}let s=`${t}:${n}:${o}`;window.$components.first("page-comments").startNewComment(s)}};var qn=class extends h{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let e=null;this.container.addEventListener("mousedown",t=>{e=t.target}),this.container.addEventListener("click",t=>{t.target===this.container&&e===this.container&&this.hide()}),H(this.hideButtons,()=>this.hide())}hide(e=null){Qo(this.container,120,e),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(e=null,t=null){Zo(this.container,120,e),this.onkeyup=n=>{n.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=t}};var Wn=class extends h{setup(){this.container=this.$el,this.mode=this.$opts.mode,this.lightContainer=this.$refs.lightContainer,this.darkContainer=this.$refs.darkContainer,this.container.addEventListener("tabs-change",t=>{let o=t.detail.showing==="color-scheme-panel-light"?"light":"dark";this.handleModeChange(o)});let e=t=>{this.updateAppColorsFromInputs(),t.target.name.startsWith("setting-app-color")&&this.updateLightForInput(t.target)};this.container.addEventListener("change",e),this.container.addEventListener("input",e)}handleModeChange(e){this.mode=e;let t=e==="dark";document.documentElement.classList.toggle("dark-mode",t),this.updateAppColorsFromInputs()}updateAppColorsFromInputs(){let t=(this.mode==="dark"?this.darkContainer:this.lightContainer).querySelectorAll('input[type="color"]');for(let n of t){let o=n.name.split("-"),s=o.indexOf("color"),r=o.slice(1,s).join("-");r==="app"&&(r="primary");let a=`--color-${r}`;document.body.style.setProperty(a,n.value)}}updateLightForInput(e){let t=e.name.replace("-color","-color-light"),n=e.value,o=this.hexToRgb(n),s=`rgba(${[o.r,o.g,o.b,"0.15"].join(",")})`,r=this.container.querySelector(`input[name="${t}"][type="hidden"]`);r.value=s}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return{r:t?parseInt(t[1],16):0,g:t?parseInt(t[2],16):0,b:t?parseInt(t[3],16):0}}};var jn=class extends h{setup(){this.colorInput=this.$refs.input,this.resetButton=this.$refs.resetButton,this.defaultButton=this.$refs.defaultButton,this.currentColor=this.$opts.current,this.defaultColor=this.$opts.default,this.resetButton.addEventListener("click",()=>this.setValue(this.currentColor)),this.defaultButton.addEventListener("click",()=>this.setValue(this.defaultColor))}setValue(e){this.colorInput.value=e,this.colorInput.dispatchEvent(new Event("change",{bubbles:!0}))}};var Un=class extends h{setup(){this.typeControl=this.$refs.typeControl,this.pagePickerContainer=this.$refs.pagePickerContainer,this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}};var Vn=class extends h{setup(){this.elem=this.$el,this.input=this.$refs.input,this.shelfBookList=this.$refs.shelfBookList,this.allBookList=this.$refs.allBookList,this.bookSearchInput=this.$refs.bookSearch,this.sortButtonContainer=this.$refs.sortButtonContainer,this.lastSort=null,this.initSortable(),this.setupListeners()}initSortable(){let e=this.elem.querySelectorAll(".scroll-box");
4for(let t of e)new ut(t,{group:"shelf-books",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){let e=Zt(this.allBookList,this.shelfBookList),t=Qt(e,this.onChange.bind(this));this.elem.addEventListener("click",t),this.bookSearchInput.addEventListener("input",()=>{this.filterBooksByName(this.bookSearchInput.value)}),this.sortButtonContainer.addEventListener("click",n=>{let o=n.target.closest("button[data-sort]");o&&this.sortShelfBooks(o.dataset.sort)})}filterBooksByName(e){this.allBookList.style.height||(this.allBookList.style.height=`${this.allBookList.getBoundingClientRect().height}px`);let t=this.allBookList.children,n=e.trim().toLowerCase();for(let o of t){let s=!e||o.textContent.toLowerCase().includes(n);o.style.display=s?null:"none"}}onChange(){let e=Array.from(this.shelfBookList.querySelectorAll("[data-id]"));this.input.value=e.map(t=>t.getAttribute("data-id")).join(",")}sortShelfBooks(e){let t=Array.from(this.shelfBookList.children),n=e===this.lastSort;t.sort((o,s)=>{let r=o.dataset[e].toLowerCase(),a=s.dataset[e].toLowerCase();return n?a.localeCompare(r):r.localeCompare(a)});for(let o of t)this.shelfBookList.append(o);this.lastSort=this.lastSort===e?null:e,this.onChange()}};function Pr(i){let e={};for(let[t,n]of Object.entries(i))e[n]=t;return e}var zn=class extends h{setup(){this.container=this.$el,this.mapById=JSON.parse(this.$opts.keyMap),this.mapByShortcut=Pr(this.mapById),this.hintsShowing=!1,this.hideHints=this.hideHints.bind(this),this.hintAbortController=null,this.setupListeners()}setupListeners(){window.addEventListener("keydown",e=>{if(!e.target.closest("input, select, textarea, .cm-editor, .editor-container")){if(e.key==="?"){this.hintsShowing?this.hideHints():this.showHints();return}this.handleShortcutPress(e)}})}handleShortcutPress(e){let n=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key].filter(s=>!!s).join(" + "),o=this.mapByShortcut[n];o&&this.runShortcut(o)&&e.preventDefault()}runShortcut(e){let t=this.container.querySelector(`[data-shortcut="${e}"]`);return t?t.matches("input, textarea, select")?(t.focus(),!0):t.matches("a, button")?(t.click(),!0):t.matches("div[tabindex]")?(t.click(),t.focus(),!0):(console.error("Shortcut attempted to be ran for element type that does not have handling setup",t),!1):!1}showHints(){let e=document.createElement("div");e.classList.add("shortcut-container"),this.container.append(e);let t=this.container.querySelectorAll("[data-shortcut]"),n=new Set;for(let s of t){let r=s.getAttribute("data-shortcut");if(n.has(r))continue;let a=this.mapById[r];this.showHintLabel(s,a,e),n.add(r)}this.hintAbortController=new AbortController;let o=this.hintAbortController.signal;window.addEventListener("scroll",this.hideHints,{signal:o}),window.addEventListener("focus",this.hideHints,{signal:o}),window.addEventListener("blur",this.hideHints,{signal:o}),window.addEventListener("click",this.hideHints,{signal:o}),this.hintsShowing=!0}showHintLabel(e,t,n){let o=e.getBoundingClientRect(),s=document.createElement("div");s.classList.add("shortcut-hint"),s.textContent=t;let r=document.createElement("div");r.classList.add("shortcut-linkage"),r.style.left=`${o.x}px`,r.style.top=`${o.y}px`,r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,n.append(s,r);let a=s.getBoundingClientRect();s.style.insetInlineStart=`${o.x+o.width-(a.width+6)}px`,s.style.insetBlockStart=`${o.y+(o.height-a.height)/2}px`}hideHints(){this.container.querySelector(".shortcut-container").remove(),this.hintAbortController?.abort(),this.hintsShowing=!1}};var Br=["Control","Alt","Shift","Meta","Super"," ","+","Tab","Escape"],Kn=class extends h{setup(){this.input=this.$el,this.setupListeners()}setupListeners(){this.listenerRecordKey=this.listenerRecordKey.bind(this),this.input.addEventListener("focus",()=>{this.startListeningForInput()}),this.input.addEventListener("blur",()=>{this.stopListeningForInput()})}startListeningForInput(){this.input.addEventListener("keydown",this.listenerRecordKey)}listenerRecordKey(e){if(Br.includes(e.key))return;let t=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key];this.input.value=t.filter(n=>!!n).join(" + ")}stopListeningForInput(){this.input.removeEventListener("keydown",this.listenerRecordKey)}};var Xn=class extends h{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let e=new ut(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:e.toArray()})},setData(t,n){let o=n.getAttribute("data-drag-content");
4if(o){let s=JSON.parse(o);for(let[r,a]of Object.entries(s))t.setData(r,a)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}};var Gn=class extends h{constructor(){super(...arguments);c(this,"input");c(this,"configuredList");c(this,"availableList")}setup(){this.input=this.$refs.input,this.configuredList=this.$refs.configuredOperationsList,this.availableList=this.$refs.availableOperationsList,this.initSortable();let t=Zt(this.availableList,this.configuredList),n=Qt(t,this.onChange.bind(this));this.$el.addEventListener("click",n)}initSortable(){let t=[this.configuredList,this.availableList];for(let n of t)new ut(n,{group:"sort-rule-operations",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}onChange(){let t=Array.from(this.configuredList.querySelectorAll("[data-id]"));this.input.value=t.map(n=>n.getAttribute("data-id")).join(",")}};var Yn=class extends h{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",e=>{if(this.filter&&!e.target.matches(this.filter))return;let t=this.$el.closest("form");t&&t.submit()})}};var Jn=class extends h{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("input",e=>{let t=window.$components.firstOnElement(this.addRemoveComponentEl,"add-remove-rows");!this.hasEmptyRows()&&e.target.value&&t.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(n=>[...n.querySelectorAll("input")].filter(o=>o.value).length===0)!==void 0}};var Zn=class extends h{setup(){this.container=this.$el,this.list=this.$refs.list,this.searchInput=this.$refs.searchInput,this.searchButton=this.$refs.searchButton,this.searchCancel=this.$refs.searchCancel,this.setupListeners()}setupListeners(){W(this.container,"[template-action]","click",this.handleTemplateActionClick.bind(this)),W(this.container,".pagination a","click",this.handlePaginationClick.bind(this)),W(this.container,".template-item-content","click",this.handleTemplateItemClick.bind(this)),W(this.container,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.searchInput.addEventListener("keypress",e=>{e.key==="Enter"&&(e.preventDefault(),this.performSearch())}),this.searchButton.addEventListener("click",()=>this.performSearch()),this.searchCancel.addEventListener("click",()=>{this.searchInput.value="",this.performSearch()})}handleTemplateItemClick(e,t){let n=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(n,"replace")}handleTemplateItemDragStart(e,t){let n=t.closest("[template-id]").getAttribute("template-id");e.dataTransfer.setData("bookstack/template",n),e.dataTransfer.setData("text/plain",n)}handleTemplateActionClick(e,t){e.stopPropagation();let n=t.getAttribute("template-action"),o=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(o,n)}async insertTemplate(e,t="replace"){let n=await window.$http.get(`/templates/${e}`),o=`editor::${t}`;window.$events.emit(o,n.data)}async handlePaginationClick(e,t){e.preventDefault();let n=t.getAttribute("href"),o=await window.$http.get(n);this.list.innerHTML=o.data}async performSearch(){let e=this.searchInput.value,t=await window.$http.get("/templates",{search:e});this.searchCancel.style.display=e?"block":"none",this.list.innerHTML=t.data}};var Qn=class extends h{setup(){this.input=this.$el.querySelector("input[type=hidden]"),this.checkbox=this.$el.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let e=new Event("change");this.input.dispatchEvent(e)}};function Rr(i,e){return document.createElement(i,e)}function Or(i,e,t){return document.createElementNS(i,e,t)}function Nr(){return Ot(document.createDocumentFragment())}function _r(i){return document.createTextNode(i)}function Fr(i){return document.createComment(i)}function qr(i,e,t){if(yt(i)){let n=i;for(;n&&yt(n);)n=Ot(n).parent;i=n??i}yt(e)&&(e=Ot(e,i)),t&&yt(t)&&(t=Ot(t).firstChildNode),i.insertBefore(e,t)}function Wr(i,e){i.removeChild(e)}function jr(i,e){yt(e)&&(e=Ot(e,i)),i.appendChild(e)}function os(i){if(yt(i)){for(;i&&yt(i);)i=Ot(i).parent;return i??null}return i.parentNode}function Ur(i){var e;if(yt(i)){let t=Ot(i),n=os(t);if(n&&t.lastChildNode){let o=Array.from(n.childNodes),s=o.indexOf(t.lastChildNode);return(e=o[s+1])!==null&&e!==void 0?e:null}return null}return i.nextSibling}function Vr(i){return i.tagName}function zr(i,e){i.textContent=e}function Kr(i){return i.textContent}function Xr(i){return i.nodeType===1}function Gr(i){return i.nodeType===3}function Yr(i){return i.nodeType===8}function yt(i){return i.nodeType===11}function Ot(i,e){var t,n,o;let s=i;return(t=s.parent)!==null&&t!==void 0||(s.parent=e??null),(n=s.firstChildNode)!==null&&n!==void 0||(s.firstChildNode=i.firstChild),(o=s.lastChildNode)!==null&&o!==void 0||(s.lastChildNode=i.lastChild),s}var ti={createElement:Rr,createElementNS:Or,createTextNode:_r,createDocumentFragment:Nr,createComment:Fr,insertBefore:qr,removeChild:Wr,appendChild:jr,parentNode:os,nextSibling:Ur,tagName:Vr,setTextContent:zr,getTextContent:Kr,isElement:Xr,isText:Gr,isComment:Yr,isDocumentFragment:yt};function Et(i,e,t,n,o){let s=e===void 0?void 0:e.key;return{sel:i,data:e,children:t,text:n,elm:o,key:s}}var ji=Array.isArray;function ss(i){return typeof i=="string"||typeof i=="number"||i instanceof String||i instanceof Number}var Ui=Et("",{},[],void 0,void 0);function Ee(i,e){var t,n;let o=i.key===e.key,s=((t=i.data)===null||t===void 0?void 0:t.is)===((n=e.data)===null||n===void 0?void 0:n.is),r=i.sel===e.sel,a=!i.sel&&i.sel===e.sel?typeof i.text==typeof e.text:!0;return r&&o&&s&&a}function Zr(){throw new Error("The document fragment is not supported on this platform.")}function Qr(i,e){return i.isElement(e)}function ta(i,e){return i.isDocumentFragment(e)}function ea(i,e,t){var n;let o={};for(let s=e;s<=t;++s){let r=(n=i[s])===null||n===void 0?void 0:n.key;r!==void 0&&(o[r]=s)}return o}var na=["create","update","remove","destroy","pre","post"];function Vi(i,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:ti;for(let u of na)for(let f of i){let w=f[u];w!==void 0&&n[u].push(w)}function s(u){let f=u.id?"#"+u.id:"",w=u.getAttribute("class"),E=w?"."+w.split(" ").join("."):"";return Et(o.tagName(u).toLowerCase()+f+E,{},[],void 0,u)}function r(u){return Et(void 0,{},[],void 0,u)}function a(u,f){return function(){if(--f===0){let E=o.parentNode(u);E!==null&&o.removeChild(E,u)}}}function l(u,f){var w,E,b,L,S;let x,A=u.data,B=A?.hook;(w=B?.init)===null||w===void 0||w.call(B,u);let P=u.children,k=u.sel;if(k==="!")(E=u.text)!==null&&E!==void 0||(u.text=""),u.elm=o.createComment(u.text);else if(k==="")u.elm=o.createTextNode(u.text);else if(k!==void 0){let O=k.indexOf("#"),R=k.indexOf(".",O),U=O>0?O:k.length,V=R>0?R:k.length,mt=O!==-1||R!==-1?k.slice(0,Math.min(U,V)):k,Ct=A?.ns,et=Ct===void 0?o.createElement(mt,A):o.createElementNS(Ct,mt,A);for(u.elm=et,U<V&&et.setAttribute("id",k.slice(U+1,V)),R>0&&et.setAttribute("class",k.slice(V+1).replace(/\./g," ")),x=0;x<n.create.length;++x)n.create[x](Ui,u);if(ss(u.text)&&(!ji(P)||P.length===0)&&o.appendChild(et,o.createTextNode(u.text)),ji(P))for(x=0;x<P.length;++x){let Mt=P[x];Mt!=null&&o.appendChild(et,l(Mt,f))}B!==void 0&&((b=B.create)===null||b===void 0||b.call(B,Ui,u),B.insert!==void 0&&f.push(u))}else if(!((L=t?.experimental)===null||L===void 0)&&L.fragments&&u.children){for(u.elm=((S=o.createDocumentFragment)!==null&&S!==void 0?S:Zr)(),x=0;x<n.create.length;++x)n.create[x](Ui,u);for(x=0;x<u.children.length;++x){let O=u.children[x];O!=null&&o.appendChild(u.elm,l(O,f))}}else u.elm=o.createTextNode(u.text);return u.elm}function d(u,f,w,E,b,L){for(;E<=b;++E){let S=w[E];S!=null&&o.insertBefore(u,l(S,L),f)}}function m(u){var f,w;let E=u.data;if(E!==void 0){(w=(f=E?.hook)===null||f===void 0?void 0:f.destroy)===null||w===void 0||w.call(f,u);for(let b=0;b<n.destroy.length;++b)n.destroy[b](u);if(u.children!==void 0)for(let b=0;b<u.children.length;++b){let L=u.children[b];
4L!=null&&typeof L!="string"&&m(L)}}}function p(u,f,w,E){for(var b,L;w<=E;++w){let S,x=f[w];if(x!=null)if(x.sel!==void 0){m(x),S=n.remove.length+1;let A=a(x.elm,S);for(let P=0;P<n.remove.length;++P)n.remove[P](x,A);let B=(L=(b=x?.data)===null||b===void 0?void 0:b.hook)===null||L===void 0?void 0:L.remove;B!==void 0?B(x,A):A()}else x.children?(m(x),p(u,x.children,0,x.children.length-1)):o.removeChild(u,x.elm)}}function v(u,f,w,E){let b=0,L=0,S=f.length-1,x=f[0],A=f[S],B=w.length-1,P=w[0],k=w[B],O,R,U,V;for(;b<=S&&L<=B;)x==null?x=f[++b]:A==null?A=f[--S]:P==null?P=w[++L]:k==null?k=w[--B]:Ee(x,P)?(y(x,P,E),x=f[++b],P=w[++L]):Ee(A,k)?(y(A,k,E),A=f[--S],k=w[--B]):Ee(x,k)?(y(x,k,E),o.insertBefore(u,x.elm,o.nextSibling(A.elm)),x=f[++b],k=w[--B]):Ee(A,P)?(y(A,P,E),o.insertBefore(u,A.elm,x.elm),A=f[--S],P=w[++L]):(O===void 0&&(O=ea(f,b,S)),R=O[P.key],R===void 0?(o.insertBefore(u,l(P,E),x.elm),P=w[++L]):O[k.key]===void 0?(o.insertBefore(u,l(k,E),o.nextSibling(A.elm)),k=w[--B]):(U=f[R],U.sel!==P.sel?o.insertBefore(u,l(P,E),x.elm):(y(U,P,E),f[R]=void 0,o.insertBefore(u,U.elm,x.elm)),P=w[++L]));L<=B&&(V=w[B+1]==null?null:w[B+1].elm,d(u,V,w,L,B,E)),b<=S&&p(u,f,b,S)}function y(u,f,w){var E,b,L,S,x,A,B,P;let k=(E=f.data)===null||E===void 0?void 0:E.hook;(b=k?.prepatch)===null||b===void 0||b.call(k,u,f);let O=f.elm=u.elm;if(u===f)return;if(f.data!==void 0||f.text!==void 0&&f.text!==u.text){(L=f.data)!==null&&L!==void 0||(f.data={}),(S=u.data)!==null&&S!==void 0||(u.data={});for(let V=0;V<n.update.length;++V)n.update[V](u,f);(B=(A=(x=f.data)===null||x===void 0?void 0:x.hook)===null||A===void 0?void 0:A.update)===null||B===void 0||B.call(A,u,f)}let R=u.children,U=f.children;f.text===void 0?R!==void 0&&U!==void 0?R!==U&&v(O,R,U,w):U!==void 0?(u.text!==void 0&&o.setTextContent(O,""),d(O,null,U,0,U.length-1,w)):R!==void 0?p(O,R,0,R.length-1):u.text!==void 0&&o.setTextContent(O,""):u.text!==f.text&&(R!==void 0&&p(O,R,0,R.length-1),o.setTextContent(O,f.text)),(P=k?.postpatch)===null||P===void 0||P.call(k,u,f)}return function(f,w){let E,b,L,S=[];for(E=0;E<n.pre.length;++E)n.pre[E]();for(Qr(o,f)?f=s(f):ta(o,f)&&(f=r(f)),Ee(f,w)?y(f,w,S):(b=f.elm,L=o.parentNode(b),l(w,S),L!==null&&(o.insertBefore(L,w.elm,o.nextSibling(b)),p(L,[f],0,0))),E=0;E<S.length;++E)S[E].data.hook.insert(S[E]);for(E=0;E<n.post.length;++E)n.post[E]();return w}}function zi(i,e,t){if(i.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let o=e[n];if(typeof o=="string")continue;let s=o.data;s!==void 0&&zi(s,o.children,o.sel)}}function ia(i){return i.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Ce(i,e){var t;let n=e!==void 0?e:ti,o;if(n.isElement(i)){let s=i.id?"#"+i.id:"",r=(t=i.getAttribute("class"))===null||t===void 0?void 0:t.match(/[^\t\r\n\f ]+/g),a=r?"."+r.join("."):"",l=n.tagName(i).toLowerCase()+s+a,d={},m={},p={},v=[],y,u,f,w=i.attributes,E=i.childNodes;for(u=0,f=w.length;u<f;u++)y=w[u].nodeName,y.startsWith("data-")?m[ia(y)]=w[u].nodeValue||"":y!=="id"&&y!=="class"&&(d[y]=w[u].nodeValue);for(u=0,f=E.length;u<f;u++)v.push(Ce(E[u],e));return Object.keys(d).length>0&&(p.attrs=d),Object.keys(m).length>0&&(p.dataset=m),l.startsWith("svg")&&(l.length===3||l[3]==="."||l[3]==="#")&&zi(p,v,l),Et(l,p,v,void 0,i)}else return n.isText(i)?(o=n.getTextContent(i),Et(void 0,void 0,void 0,o,i)):n.isComment(i)?(o=n.getTextContent(i),Et("!",{},[],o,i)):Et("",{},[],void 0,i)}var oa="http://www.w3.org/1999/xlink",sa="http://www.w3.org/2000/xmlns/",ra="http://www.w3.org/XML/1998/namespace";function rs(i,e){let t,n=e.elm,o=i.data.attrs,s=e.data.attrs;if(!(!o&&!s)&&o!==s){o=o||{},s=s||{};for(t in s){let r=s[t];o[t]!==r&&(r===!0?n.setAttribute(t,""):r===!1?n.removeAttribute(t):t.charCodeAt(0)!==120?n.setAttribute(t,r):t.charCodeAt(3)===58?n.setAttributeNS(ra,t,r):t.charCodeAt(5)===58?t.charCodeAt(1)===109?n.setAttributeNS(sa,t,r):n.setAttributeNS(oa,t,r):n.setAttribute(t,r))}for(t in o)t in s||n.removeAttribute(t)}}var Ki={create:rs,update:rs};var as=/[A-Z]/g;function ls(i,e){let t=e.elm,n=i.data.dataset,o=e.data.dataset,s;if(!n&&!o||n===o)return;n=n||{},o=o||{};let r=t.dataset;for(s in n)s in o||(r?s in r&&delete r[s]:t.removeAttribute("data-"+s.replace(as,"-$&").toLowerCase()));for(s in o)n[s]!==o[s]&&(r?r[s]=o[s]:t.setAttribute("data-"+s.replace(as,"-$&").toLowerCase(),o[s]))}var Xi={create:ls,update:ls};var ei;function aa(){return ei||(ei=Vi([Ki,Xi]),ei)}function cs(i,e){aa()(Ce(i),Ce(e))}var ni=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"noneEl");c(this,"display");c(this,"isActive",!1)}setup(){this.container=this.$el,this.noneEl=this.$refs.none,this.display=this.$refs.display,window.addEventListener("editor-toolbox-change",(n=>{let o=n.detail.tab,s=n.detail.open;o==="contents"&&s?(this.isActive!==!0&&this.render(),this.isActive=!0):this.isActive=!1}));let t=ft(this.onContentChange.bind(this),500,!1);window.$events.listen("editor-html-change",t),window.$events.listen("editor-markdown-change",t),this.container.addEventListener("click",n=>{let o=n.target.closest("li[data-index]");o instanceof HTMLElement&&(n.preventDefault(),this.onHeaderSelect(o))})}onHeaderSelect(t){let n=t.getAttribute("data-id")||"",o=Number(t.getAttribute("data-index")||"");window.$events.emit("editor::focus-heading",{index:o,id:n})}onContentChange(){this.isActive&&this.render()}async render(){let t=await this.getEditorHtml(),n=this.parseHeadersFromHtml(t);this.rebaseHeaders(n);let o=this.headersToDom(n),s=this.display.firstElementChild;s||(s=document.createElement("ul"),this.display.appendChild(s)),cs(s,o),this.noneEl.hidden=n.length>0}async getEditorHtml(){return(await window.$components.first("page-editor").getEditorComponent().getContent()).html}parseHeadersFromHtml(t){let s=new DOMParser().parseFromString(t,"text/html").querySelectorAll("h1, h2, h3, h4, h5, h6"),r=[];for(let a=0;a<s.length;a++){let l=s[a],d=Number(l.tagName.replace("H",""));r.push({text:l.textContent,level:d,id:l.id||"",index:a})}return r}rebaseHeaders(t){if(t.length!==0)do{var n=Math.min(...t.map(o=>o.level));if(n>1)for(let o of t)o.level--}while(n>1)}headersToDom(t){let n=t.map(o=>Q("li",{"data-level":String(o.level),"data-index":String(o.index),"data-id":o.id,id:`page-contents-${o.id}`,class:`page-nav-item h${o.level}`},[Q("a",{class:"text-limit-lines-1 block",href:`#${o.id}`},[o.text]),Q("div",{class:"link-background sidebar-page-nav-bullet"})]));return Q("ul",{class:"sidebar-page-nav menu"},n)}};var ii=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"tabs");c(this,"sidebarScrollContainers");c(this,"lastLayoutType","none");c(this,"onDestroy",null);c(this,"scrollCache",{content:0,info:0});c(this,"lastTabShown","content")}setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.sidebarScrollContainers=this.$manyRefs.sidebarScrollContainer,this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",()=>{this.updateLayout()},{passive:!0}),this.setupSidebarScrollHandlers()}updateLayout(){let t="tablet";window.innerWidth<=1e3&&(t="mobile"),window.innerWidth>1400&&(t="desktop"),t!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),t==="desktop"?this.setupDesktop():t==="mobile"&&this.setupMobile(),this.lastLayoutType=t)}setupMobile(){for(let t of this.tabs)t.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let t of this.tabs)t.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(t){let n=t.target.dataset.tab||"";this.showTab(n)}showContent(){this.showTab("content",!1)}showTab(t,n=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let s of this.tabs){let r=s.dataset.tab===t;s.setAttribute("aria-selected",r?"true":"false")}let o=t==="info";if(this.container.classList.toggle("show-info",o),n){let r=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[t]||r,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[t]||r},50)}this.lastTabShown=t}setupSidebarScrollHandlers(){for(let t of this.sidebarScrollContainers
4)t.addEventListener("scroll",()=>this.handleSidebarScroll(t),{passive:!0}),this.handleSidebarScroll(t);window.addEventListener("resize",()=>{for(let t of this.sidebarScrollContainers)this.handleSidebarScroll(t)})}handleSidebarScroll(t){let n=t.clientHeight!==t.scrollHeight,o=t.scrollTop===0,s=t.scrollTop+t.clientHeight===t.scrollHeight;t.parentElement&&(t.parentElement.classList.toggle("scroll-away-from-top",!o&&n),t.parentElement.classList.toggle("scroll-away-from-bottom",!s&&n))}};var oi=class extends h{setup(){this.container=this.$el,this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,W(this.container,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(e,t){e.preventDefault(),this.input.value=t.getAttribute("data-id"),this.userInfoContainer.innerHTML=t.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}hide(){window.$components.firstOnElement(this.container,"dropdown").hide()}};var si=class extends h{setup(){this.checkboxes=this.$el.querySelectorAll('input[type="checkbox"]'),this.allCheckbox=this.$el.querySelector('input[type="checkbox"][value="all"]'),this.$el.addEventListener("change",e=>{e.target.checked&&e.target===this.allCheckbox?this.deselectIndividualEvents():e.target.checked&&(this.allCheckbox.checked=!1)})}deselectIndividualEvents(){for(let e of this.checkboxes)e!==this.allCheckbox&&(e.checked=!1)}};var ri=class extends h{setup(){this.elem=this.$el,this.editContainer=this.$refs.editContainer,this.input=this.$refs.input,this.editor=null;let e={...window.editor_translations,imageUploadErrorText:this.$opts.imageUploadErrorText,serverUploadLimitText:this.$opts.serverUploadLimitText};window.importVersioned("wysiwyg").then(n=>{let o=this.input.value;this.editor=n.createPageEditorInstance(this.editContainer,o,{drawioUrl:this.getDrawIoUrl(),pageId:Number(this.$opts.pageId),darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:e}),window.wysiwyg=this.editor});let t=!1;this.input.form.addEventListener("submit",n=>{this.editor&&(t?t=!1:(n.preventDefault(),t=!0,this.editor.getContentAsHtml().then(o=>{this.input.value=o,setTimeout(()=>{this.input.form.requestSubmit()},5)})))})}getDrawIoUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):""}async getContent(){return{html:await this.editor.getContentAsHtml()}}};function ds(i){for(let e=1;e<5;e++)i.shortcuts.add(`meta+${e}`,"",["FormatBlock",!1,`h${e+1}`]);i.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+o","","InsertOrderedList"),i.shortcuts.add("meta+p","","InsertUnorderedList"),i.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),i.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),i.shortcuts.add("meta+9","",()=>{let e=i.selection.getNode(),t=e?e.closest(".callout"):null,n=["info","success","warning","danger"],s=(n.findIndex(a=>t&&t.classList.contains(a))+1)%n.length,r=n[s];i.formatter.apply(`callout${r}`)}),i.shortcuts.add("meta+shift+K","",()=>{let e=window.$components.first("entity-selector-popup"),t=i.selection.getContent({format:"text"}).trim();e.show(n=>{i.selection.isCollapsed()?i.insertContent(i.dom.createHTML("a",{href:n.link},i.dom.encode(n.name))):i.formatter.apply("link",{href:n.link}),i.selection.collapse(!1),i.focus()},{initialValue:t,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})})}function la(i,e){let t=i.dom.get(encodeURIComponent(e).replace(/!/g,"%21"));t&&(t.scrollIntoView(),i.selection.select(t,!0),i.selection.collapse(!1),i.focus())}function hs(i,e){let n=i.dom.select("h1, h2, h3, h4, h5, h6")[e];n&&(n.scrollIntoView(),i.selection.select(n,!0),i.selection.collapse(!1),i.focus())}function us(i){let t=new URL(window.location).searchParams.get("content-id");t&&la(i,t)}function ps(i){window.$events.listen("editor::replace",({html:e})=>{i.setContent(e)}),window.$events.listen("editor::append",({html:e})=>{let t=i.getContent()+e;i.setContent(t)}),window.$events.listen("editor::prepend",({html:e})=>{let t=e+i.getContent();i.setContent(t)}),window.$events.listen("editor::insert",({html:e})=>{i.insertContent(e)}),window.$events.listen("editor::focus",()=>{i.initialized&&i.focus()}),window.$events.listen("editor::focus-heading",({index:e})=>{hs(i,e)})}var Nt,ai;function ca(i){return i&&!!(i.textContent||i.innerText)}async function da(i,e){if(i===null||i.type.indexOf("image")!==0)throw new Error("Not an image file");let t=i.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",i,t),n.append("uploaded_to",e),(await window.$http.post(window.baseUrl("/images/gallery"),n)).data}function ms(i,e,t){let n=new Jt(t.clipboardData||t.dataTransfer);if(!n.hasItems()||n.containsTabularData())return;let o=n.getImages();for(let s of o){let r=`image-${Math.random().toString(16).slice(2)}`,a=window.baseUrl("/loading.gif");t.preventDefault(),setTimeout(()=>{i.insertContent(`<p><img src="${a}" id="${r}"></p>`),da(s,e.pageId).then(l=>{let d=l.name.replace(/"/g,""),m=`<img src="${l.thumbs.display}" alt="${d}" />`,p=i.dom.create("a",{target:"_blank",href:l.url},m);i.dom.replace(p,r)}).catch(l=>{i.dom.remove(r),window.$events.error(l?.data?.message||e.translations.imageUploadErrorText),console.error(l)})},10)}}function ha(i){let e=i.selection.getNode();e.nodeName==="IMG"&&(Nt=i.dom.getParent(e,".mceTemp"),!Nt&&e.parentNode.nodeName==="A"&&!ca(e.parentNode)&&(Nt=e.parentNode)),e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")==="false"&&(ai=e)}function ua(i,e,t){let{dom:n}=i,o=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX,t.clientY,i.getDoc()),s=t.dataTransfer&&t.dataTransfer.getData("bookstack/template");s&&(t.preventDefault(),window.$http.get(`/templates/${s}`).then(r=>{i.selection.setRng(o),i.undoManager.transact(()=>{i.execCommand("mceInsertContent",!1,r.data.html)})})),n.getParent(o.startContainer,".mceTemp")?t.preventDefault():Nt&&(t.preventDefault(),i.undoManager.transact(()=>{i.selection.setRng(o),i.selection.setNode(Nt),n.remove(Nt)})),!t.isDefaultPrevented()&&ai&&(t.preventDefault(),i.undoManager.transact(()=>{let r=i.selection.getNode(),a=i.selection.getRng(),l=r.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(ai):l.before(ai)})),t.isDefaultPrevented()||ms(i,e,t),Nt=null}function pa(i,e){e.preventDefault(),i.focus();let n=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX??0,e.clientY??0,i.getDoc());i.selection.setRng(n)}function fs(i,e){i.on("dragover",t=>pa(i,t)),i.on("dragstart",()=>ha(i)),i.on("drop",t=>ua(i,e,t)),i.on("paste",t=>ms(i,e,t))}function gs(i){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright al
4ignjustify","bullist numlist listoverflow",i.textDirection==="rtl"?"ltr rtl":"","link customtable imagemanager-insert insertoverflow","code about fullscreen"].filter(n=>!!n).join(" | ")}function ma(i){i.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),i.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),i.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function fa(i){i.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(e){return e.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function ga(i){i.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(e){return e.closest("img")!==null&&!e.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"image"})}function va(i){i.ui.registry.addContextToolbar("objectcontexttoolbar",{predicate(e){return e.closest("img")!==null&&e.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"media"})}function vs(i){ma(i),fa(i),ga(i),va(i)}var ba={"table-delete-column":'<svg width="24" height="24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>',"table-delete-row":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>',"table-insert-column-after":'<svg width="24" height="24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>',"table-insert-column-before":'<svg width="24" height="24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>',"table-insert-row-above":'<svg width="24" height="24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>',"table-insert-row-after":'<svg width="24" height="24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>',table:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2ZM5 14v5h6v-5zm14 0h-6v5h6zm0-7h-6v5h6zM5 12h6V7H5Z"/></svg>',"table-delete-table":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>'};function bs(i){for(let[e,t]of Object.entries(ba))i.ui.registry.addIcon(e,t)}function wa(i){i.serializer.addNodeFilter("br",e=>{for(let t of e)if(t.parent&&t.parent.name==="code"){let n=window.tinymce.html.Node.create("#text");n.value=` 5`,t.replace(n)}})}function ya(i){i.parser.addNodeFilter("div",e=>{for(let t of e){let n=t.attr("id")||"",o=t.attr("class")||"";(n==="pointer"||o.includes("pointer"))&&t.remove()}})}
5function ws(i){wa(i),ya(i)}function ys(i){return i.tagName.toLowerCase()==="code-block"}function Cs(i,e,t,n,o){let s=window.$components.first("code-editor"),r=i.selection.getBookmark();s.open(e,t,n,(a,l)=>{o(a,l),i.focus(),i.selection.moveToBookmark(r)},()=>{i.focus(),i.selection.moveToBookmark(r)})}function Es(i,e){let t=e.getAttribute("dir")||"";Cs(i,e.getContent(),e.getLanguage(),t,(n,o)=>{e.setContent(n,o)})}function Ea(i){let e=i.getDoc(),t=e.defaultView;class n extends t.HTMLElement{constructor(){super();c(this,"editor",null);this.attachShadow({mode:"open"});let r=document.head.querySelectorAll('link[rel="stylesheet"]:not([media="print"]),style'),a=Array.from(r).map(d=>d.cloneNode(!0)),l=document.createElement("div");l.style.pointerEvents="none",l.contentEditable="false",l.classList.add("CodeMirrorContainer"),l.classList.toggle("dark-mode",document.documentElement.classList.contains("dark-mode")),this.shadowRoot.append(...a,l)}getLanguage(){let r=d=>(d.split(" ").filter(p=>p.startsWith("language-"))[0]||"").replace("language-",""),a=this.querySelector("code"),l=this.querySelector("pre");return r(l.className)||a&&r(a.className)||""}setContent(r,a){this.editor&&(this.editor.setContent(r),this.editor.setMode(a,r));let l=this.querySelector("pre");l||(l=e.createElement("pre"),this.append(l)),l.innerHTML="";let d=e.createElement("code");l.append(d),d.innerText=r,d.className=`language-${a}`}getContent(){let r=this.querySelector("code")||this.querySelector("pre"),a=document.createElement("pre");a.innerHTML=r.innerHTML.replace(/\ufeff/g,"");let l=a.querySelectorAll("br");for(let d of l)d.replaceWith(` 6`);return a.textContent}connectedCallback(){let r=Date.now();if(this.editor)return;this.cleanChildContent();let a=this.getContent(),d=a.split(` 7`).length*19.2+18+24;this.style.height=`${d}px`;let m=this.shadowRoot.querySelector(".CodeMirrorContainer"),p=v=>{this.editor=v.wysiwygView(m,this.shadowRoot,a,this.getLanguage()),setTimeout(()=>{this.style.height=null},12)};window.importVersioned("code").then(v=>{let y=Date.now()-r<20?20:0;setTimeout(()=>p(v),y)})}cleanChildContent(){let r=this.querySelector("pre");if(r)for(let a of r.childNodes)a.nodeName==="#text"&&a.textContent==="\uFEFF"&&a.remove()}}t.customElements.define("code-block",n)}function Ca(i){i.ui.registry.addIcon("codeblock",'<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5Z"/><path d="M11.103 15.423c.277.277.277.738 0 .922a.692.692 0 0 1-1.106 0l-4.057-3.78a.738.738 0 0 1 0-1.107l4.057-3.872c.276-.277.83-.277 1.106 0a.724.724 0 0 1 0 1.014L7.6 12.012ZM12.897 8.577c-.245-.312-.2-.675.08-.955.28-.281.727-.27 1.027.033l4.057 3.78a.738.738 0 0 1 0 1.107l-4.057 3.872c-.277.277-.83.277-1.107 0a.724.724 0 0 1 0-1.014l3.504-3.412z"/></svg>'),i.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){i.execCommand("codeeditor")}}),i.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){i.execCommand("codeeditor")}}),i.addCommand("codeeditor",()=>{let e=i.selection.getNode(),t=e.ownerDocument;if(ys(e))Es(i,e);else{let n=i.selection.getContent({format:"text"}),o=document.dir==="rtl"?"ltr":"";Cs(i,n,"",o,(s,r)=>{let a=t.createElement("pre"),l=t.createElement("code");l.classList.add(`language-${r}`),l.innerText=s,o&&a.setAttribute("dir",o),a.append(l),i.insertContent(a.outerHTML)})}}),i.on("dblclick",()=>{let e=i.selection.getNode();ys(e)&&Es(i,e)}),i.on("PreInit",()=>{i.parser.addNodeFilter("pre",e=>{for(let t of e){let n=window.tinymce.html.Node.create("code-block",{contenteditable:"false"}),o=t.children().filter(a=>a.name==="code")[0]||null,s=t.attr("dir")||o&&o.attr("dir")||"";s&&n.attr("dir",s);let r=t.getAll("span");for(let a of r)a.unwrap();t.attr("style",null),t.wrap(n)}}),i.parser.addNodeFilter("code-block",e=>{for(let t of e)t.attr("contenteditable","false")}),i.serializer.addNodeFilter("code-block",e=>{for(let t of e){let n=t.attr("dir");n&&t.firstChild?t.firstChild.attr("dir",n):t.firstChild&&t.firstChild.attr("dir",null),t.unwrap()}})}),i.ui.registry.addContextToolbar("codeeditor",{predicate(e){return e.no
7deName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),i.on("PreInit",()=>{Ea(i)})}function xs(){return Ca}function li(i){return new Promise((e,t)=>{i.oncomplete=i.onsuccess=()=>e(i.result),i.onabort=i.onerror=()=>t(i.error)})}function xa(i,e){let t,n=()=>{if(t)return t;let o=indexedDB.open(i);return o.onupgradeneeded=()=>o.result.createObjectStore(e),t=li(o),t.then(s=>{s.onclose=()=>t=void 0},()=>{t=void 0}),t};return(o,s)=>n().then(r=>s(r.transaction(e,o).objectStore(e)))}var Gi;function Yi(){return Gi||(Gi=xa("keyval-store","keyval")),Gi}function Ji(i,e=Yi()){return e("readonly",t=>li(t.get(i)))}function Zi(i,e,t=Yi()){return t("readwrite",n=>(n.put(e,i),li(n.transaction)))}function Qi(i,e=Yi()){return e("readwrite",t=>(t.delete(i),li(t.transaction)))}var pt=null,no,ci,to,eo="last-drawing-save";function io(i){pt?.contentWindow?.postMessage(JSON.stringify(i),no)}function Ta(i){Zi(eo,i.data),to&&to(i.data).then(()=>{Qi(eo)})}function Sa(i){io({action:"export",format:"xmlpng",xml:i.xml,spin:"Updating drawing"})}function ka(){ci&&ci().then(i=>{io({action:"load",autosave:1,xml:i})})}function $a(){let i={};pt&&(window.$events.emitPublic(pt,"editor-drawio::configure",{config:i}),io({action:"configure",config:i}))}function Ls(){window.removeEventListener("message",Ts),pt&&document.body.removeChild(pt)}function Ts(i){if(!i.data||i.data.length<1||i.origin!==no)return;let e=JSON.parse(i.data);e.event==="init"?ka():e.event==="exit"?Ls():e.event==="save"?Sa(e):e.event==="export"?Ta(e):e.event==="configure"&&$a()}async function Ma(){let i=await Ji(eo),e=document.getElementById("unsaved-drawing-dialog");e||console.error("Missing expected unsaved-drawing dialog"),i&&e&&await window.$components.firstOnElement(e,"confirm-dialog").show()&&(ci=async()=>i)}async function Ss(i,e,t){ci=e,to=t,await Ma(),pt=document.createElement("iframe"),pt.setAttribute("frameborder","0"),window.addEventListener("message",Ts),pt.setAttribute("src",i),pt.setAttribute("class","fullscreen"),pt.style.backgroundColor="#FFFFFF",document.body.appendChild(pt),no=new URL(i).origin}async function oo(i,e){let t={image:i,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function di(){Ls()}async function ks(i){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${i}`))).data.content}`}catch(e){throw e instanceof At&&window.$events.showResponseError(e),di(),e}}var st=null,Ft=null,_t={};function so(i){return i.hasAttribute("drawio-diagram")}function Da(i,e=null){st=i,Ft=e,window.$components.first("image-manager").show(n=>{if(e){let o=e.querySelector("img");st.undoManager.transact(()=>{st.dom.setAttrib(o,"src",n.url),st.dom.setAttrib(e,"drawio-diagram",n.id)})}else{let o=`<div drawio-diagram="${n.id}" contenteditable="false"><img src="${n.url}"></div>`;st.insertContent(o)}},"drawio")}async function Ia(i){let e=window.baseUrl("/loading.gif"),t=s=>{s.status===413?window.$events.emit("error",_t.translations.serverUploadLimitText):window.$events.emit("error",_t.translations.imageUploadErrorText),console.error(s)};if(Ft){di();let s=Ft.querySelector("img");try{let r=await oo(i,_t.pageId);st.undoManager.transact(()=>{st.dom.setAttrib(s,"src",r.url),st.dom.setAttrib(Ft,"drawio-diagram",r.id)})}catch(r){throw t(r),new Error(`Failed to save image with error: ${r}`,{cause:r})}return}await vo(5);let n=`drawing-${Math.random().toString(16).slice(2)}`,o=`drawing-wrap-${Math.random().toString(16).slice(2)}`;st.insertContent(`<div drawio-diagram contenteditable="false" id="${o}"><img src="${e}" id="${n}"></div>`),di();try{let s=await oo(i,_t.pageId);st.undoManager.transact(()=>{st.dom.setAttrib(n,"src",s.url),st.dom.setAttrib(o,"drawio-diagram",s.id)})}catch(s){throw st.dom.remove(o),t(s),new Error(`Failed to save image with error: ${s}`,{cause:s})}}function Ha(){if(!Ft)return Promise.resolve("");let i=Ft.getAttribute("drawio-diagram");return ks(i)}function $s(i,e=null){st=i,Ft=e,Ss(_t.drawioUrl,Ha,Ia)}function Pa(i){i.addCommand("drawio",()=>{let e=i.selection.getNode();$s(i,so(e)?e:null)}),i.ui.registry.addIcon("diagram",`<svg width="24" height="24" fill="${_t.darkMode?"#BBB":"#000000"}" xmlns="http://www.w3.org/2000/svg"><path d="M20.716 7.639V2.845h-4.794v1.598h-7.99V2.845H3.138v4.794h1.598v7.99H3.138v4.794h4.794v-1.598h7.99v1.598h4.794v-4.794h-1.598v-7.99zM4.736 4.443h1.598V6.04H4.736zm1.598 14.382H4.736v-1.598h1.598zm9.588-1.598h-7.99v-1.598H6.334v-7.99h1.598V6.04h7.99v1.598h1.598v7.99h-1.598zm3.196 1.598H17.52v-1.598h1.598zM17.52 6.04V4.443h1.598V6.04zm-4.21 7.19h-2.79l-.582 1.599H8.643l2.717-7.191h1.119l2.724 7.19h-1.302zm-2.43-1.006h2.086l-1.039-3.06z"/></svg>`),i.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){i.execCommand("drawio"),window.document.body.dispatchEvent(new Event("mousedown",{bubbles:!0}))},fetch(e){e([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(e,t){if(t==="drawing-manager"){let n=i.selection.getNode();Da(i,so(n)?n:null)}}}),i.on("dblclick",()=>{let e=i.selection.getNode();so(e)&&$s(i,e)}),i.on("SetContent",()=>{let e=i.dom.select("body > div[drawio-diagram]");e.length&&i.undoManager.transact(()=>{for(let t of e)t.setAttribute("contenteditable","false")})})}function Ms(i){return _t=i,Pa}
7function Ba(i){i.addCommand("InsertHorizontalRule",()=>{let e=document.createElement("hr"),t=i.selection.getNode(),{parentNode:n}=t;n.insertBefore(e,t)}),i.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){i.execCommand("InsertHorizontalRule")}})}function As(){return Ba}function Ra(i){i.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(t=>{let n=t.thumbs?.display||t.url,o=`<a href="${t.url}" target="_blank">`;o+=`<img src="${n}" alt="${t.name}">`,o+="</a>",i.execCommand("mceInsertContent",!1,o)},"gallery")}})}function Ds(){return Ra}function Oa(i){let e={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/tinymce")};i.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){window.tinymce.activeEditor.windowManager.openUrl(e)}})}function Is(){return Oa}var Hs=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table","hr"];function hi(i){return i.selection.getNode().closest("details")}function Na(i,e){let t=hi(i);t&&(i.undoManager.transact(()=>{let n=t.querySelector("summary");n||(n=document.createElement("summary"),t.prepend(n)),n.textContent=e}),i.selection.select(t))}function _a(i){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(e){let{summary:t}=e.getData();Na(i,t),e.close()}}}function Fa(i){let e=i.querySelector("summary");return e?e.textContent:""}function Ps(i){let e=hi(i);i.windowManager.open(_a(i)).setData({summary:Fa(e)})}function qa(i){let e=i.selection.getNode().closest("details"),t=i.selection.getBookmark();if(e){let n=e.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");i.undoManager.transact(()=>{for(let o of n)e.parentNode.insertBefore(o,e);e.remove()})}i.focus(),i.selection.moveToBookmark(t)}function ro(i){i.attr("contenteditable",null);let e=!1;for(let t of i.children())t.name==="doc-root"&&(t.unwrap(),e=!0);e&&ro(i)}function Wa(i){ro(i),i.attr("contenteditable","false");let e=window.tinymce.html.Node.create("doc-root",{contenteditable:"true"}),t=null;for(let n of i.children()){if(n.name==="summary")continue;Hs.includes(n.name)?(e.append(n),t=null):(t||(t=window.tinymce.html.Node.create("p"),e.append(t)),t.append(n))}i.append(e)}function ja(i){i.parser.addNodeFilter("details",e=>{for(let t of e)Wa(t)}),i.serializer.addNodeFilter("details",e=>{for(let t of e)ro(t),t.attr("open",null)}),i.serializer.addNodeFilter("doc-root",e=>{for(let t of e)t.unwrap()})}function Ua(i){i.ui.registry.addIcon("details",'<svg width="24" height="24"><path d="M8.2 9a.5.5 0 0 0-.4.8l4 5.6a.5.5 0 0 0 .8 0l4-5.6a.5.5 0 0 0-.4-.8ZM20.122 18.151h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7zM20.122 3.042h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7z"/></svg>'),i.ui.registry.addIcon("togglefold",'<svg height="24" width="24"><path d="M8.12 19.3c.39.39 1.02.39 1.41 0L12 16.83l2.47 2.47c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.02-.39-1.41 0l-3.17 3.17c-.4.38-.4 1.02-.01 1.41zm7.76-14.6c-.39-.39-1.02-.39-1.41 0L12 7.17 9.53 4.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.03 0 1.42l3.17 3.17c.39.39 1.02.39 1.41 0l3.17-3.17c.4-.39.4-1.03.01-1.42z"/></svg>'),i.ui.registry.addIcon("togglelabel",'<svg height="18" width="18" viewBox="0 0 24 24"><path d="M21.41,11.41l-8.83-8.83C12.21,2.21,11.7,2,11.17,2H4C2.9,2,2,2.9,2,4v7.17c0,0.53,0.21,1.04,0.59,1.41l8.83,8.83 c0.78,0.78,2.05,0.78,2.83,0l7.17-7.17C22.2,13.46,22.2,12.2,21.41,11.41z M6.5,8C5.67,8,5,7.33,5,6.5S5.67,5,6.5,5S8,5.67,8,6.5 S7.33,8,6.5,8z"/></svg>'),i.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){i.execCommand("InsertDetailsBlock")}}),i.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){qa(i)}}),i.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){Ps(i)}}),i.on("dblclick",e=>{let t=e?.target?.ownerDocument?.defaultView?.HTMLDetailsElement;t&&e.target instanceof t&&hi(i)&&(Ps(i),e.preventDefault(),e.stopPropagation())}),i.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){hi(i).toggleAttribute("open"),i.focus()}}),i.addCommand("InsertDetailsBlock",()=>{let e=i.selection.getContent({format:"html"}),t=document.createElement("details"),n=document.createElement("summary"),o=`details-${Date.now()}`;t.setAttribute("data-id",o),t.appendChild(n),e||(e="<p><br></p>"),t.innerHTML+=e,i.insertContent(t.outerHTML),i.focus();let s=i.dom.select(`[data-id="${o}"]`)[0]||null;if(s){let r=s.querySelector("doc-root > *");r&&r.focus(),s.removeAttribute("data-id")}}),i.ui.registry.addContextToolbar("details",{predicate(e){return e.no
7deName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),i.on("PreInit",()=>{ja(i)})}function Bs(){return Ua}function Va(i){i.ui.registry.addIcon("tableclearformatting",'<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 24 24"><path d="M15.53088 4.64727v-.82364c0-.453-.37063-.82363-.82363-.82363H4.82363C4.37063 3 4 3.37064 4 3.82363v3.29454c0 .453.37064.82364.82363.82364h9.88362c.453 0 .82363-.37064.82363-.82364v-.82363h.82364v3.29454H8.11817v7.4127c0 .453.37064.82364.82364.82364h1.64727c.453 0 .82363-.37064.82363-.82364v-5.76544h6.58907V4.64727Z"/><path d="m18.42672 19.51563-1.54687-1.54688-1.54688 1.54688c-.26751.2675-.70124.2675-.96875 0-.26751-.26752-.26751-.70124 0-.96876L15.9111 17l-1.54688-1.54688c-.26751-.2675-.26751-.70123 0-.96875.26751-.2675.70124-.2675.96875 0l1.54688 1.54688 1.54687-1.54688c.26751-.2675.70124-.2675.96875 0 .26751.26752.26751.70124 0 .96875L17.8486 17l1.54687 1.54688c.26751.2675.26751.70123 0 .96874-.26751.26752-.70124.26752-.96875 0z"/></svg>');let e={items:" | tablerowheader",predicate(n){let o=n.nodeName.toLowerCase()==="table",s=i.selection.getNode(),r=s.closest("table");return!o||!r?!1:r.querySelector("tr").contains(s)},position:"node",scope:"node"};i.ui.registry.addContextToolbar("customtabletoolbarfirstrow",e),i.addCommand("tableclearformatting",()=>{let n=i.dom.getParent(i.selection.getStart(),"table");if(!n)return;let o=["class","style","width","height"],s=[n,...n.querySelectorAll(o.map(r=>`[${r}]`).join(","))];for(let r of s)for(let a of o)r.removeAttribute(a)}),i.addCommand("tableclearsizes",()=>{let n=i.dom.getParent(i.selection.getStart(),"table");if(!n)return;let o=[n,...n.querySelectorAll("tr,td,th,tbody,thead,tfoot,th>*,td>*")];for(let s of o)s.removeAttribute("width"),s.removeAttribute("height"),s.style.height=null,s.style.width=null});let t=()=>{let n=i.ui.registry.getAll().buttons;i.ui.registry.addMenuButton("customtable",{...n.table,fetch:o=>o("inserttable | cell row column | advtablesort | tableprops tableclearformatting tableclearsizes deletetable")}),i.ui.registry.addMenuItem("tableclearformatting",{icon:"tableclearformatting",text:"Clear table formatting",onSetup:n.tableprops.onSetup,onAction(){i.execCommand("tableclearformatting")}}),i.ui.registry.addMenuItem("tableclearsizes",{icon:"resize",text:"Resize to contents",onSetup:n.tableprops.onSetup,onAction(){i.execCommand("tableclearsizes")}}),i.off("PreInit",t)};i.on("PreInit",t)}function Rs(){return Va}function za(i){let e=i.closest("li");return e&&e.parentNode.nodeName==="UL"&&e.classList.contains("task-list-item")}function Ka(i,e,t){let n=e.getBoundingClientRect();i.clientX<=n.right&&i.clientX>=n.left&&i.clientY>=n.top&&i.clientY<=n.bottom||t.undoManager.transact(()=>{e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","checked")})}function Xa(i){i.attr("class","task-list-item");for(let e of i.children())e.name==="input"&&(e.attr("checked")==="checked"&&i.attr("checked","checked"),e.remove())}function Ga(i){let e=i.attr("checked")==="checked";i.attr("checked",null);let t={type:"checkbox",disabled:"disabled"};e&&(t.checked="checked");let n=window.tinymce.html.Node.create("input",t);n.shortEnded=!0,i.firstChild?i.insert(n,i.firstChild,!0):i.append(n)}function Ya(i){i.ui.registry.addIcon("tasklist",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22,8c0-0.55-0.45-1-1-1h-7c-0.55,0-1,0.45-1,1s0.45,1,1,1h7C21.55,9,22,8.55,22,8z M13,16c0,0.55,0.45,1,1,1h7 c0.55,0,1-0.45,1-1c0-0.55-0.45-1-1-1h-7C13.45,15,13,15.45,13,16z M10.47,4.63c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25 c-0.39,0.39-1.02,0.39-1.42,0L2.7,8.16c-0.39-0.39-0.39-1.02,0-1.41c0.39-0.39,1.02-0.39,1.41,0l1.42,1.42l3.54-3.54 C9.45,4.25,10.09,4.25,10.47,4.63z M10.48,12.64c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25c-0.39,0.39-1.02,0.39-1.42,0L2.7,16.16 c-0.39-0.39-0.39-1.02,0-1.41s1.02-0.39,1.41,0l1.42,1.42l3.54-3.54C9.45,12.25,10.09,12.25,10.48,12.64L10.48,12.64z"/></svg>'),i.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(n){n.isActive()?i.execCommand("RemoveList"):i.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(n){i.on("NodeChange",o=>{let s=o.parents.find(a=>a.nodeName==="LI"),r=s&&s.classList.contains("task-list-item");
7n.setActive(!!r)})}});let e=i.ui.registry.getAll().buttons.bullist;e.onSetup=function(o){i.on("NodeChange",s=>{let r=s.parents.find(d=>d.nodeName==="LI"),a=r&&r.classList.contains("task-list-item"),l=r&&r.parentNode.nodeName==="UL";o.setActive(!!(l&&!a))})},e.onAction=function(){za(i.selection.getNode())&&i.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),i.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let t=i.ui.registry.getAll().buttons.numlist;t.onAction=function(){i.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},i.on("PreInit",()=>{i.parser.addNodeFilter("li",n=>{for(let o of n)o.attributes.map.class==="task-list-item"&&Xa(o)}),i.serializer.addNodeFilter("li",n=>{for(let o of n)o.attributes.map.class==="task-list-item"&&Ga(o)})}),i.on("click",n=>{let o=n.target;o.nodeName==="LI"&&o.classList.contains("task-list-item")&&(Ka(n,o,i),n.preventDefault())})}function Os(){return Ya}function Ns(i){function e(t){let n=t.querySelector("iframe, video");if(!n)return;let o=[...n.classList.values()].filter(r=>r.startsWith("align-")),s=[...t.classList.values()].filter(r=>r.startsWith("align-"));t.classList.remove(...s),t.classList.add(...o)}i.on("SetContent",()=>{let t=i.dom.select("span.mce-preview-object");for(let n of t)e(n)}),i.on("FormatApply",t=>{let n=t.format.startsWith("align");if(!(t.node instanceof i.dom.doc.defaultView.HTMLElement)||!n||!t.node.matches(".mce-preview-object"))return;let s=t.node.querySelector("iframe, video");if(s){let r=(i.formatter.get(t.format)[0]?.classes||[])[0],a=!s.classList.contains(r),d=(t.node.getAttribute("data-mce-p-class")||"").split(" ").filter(p=>!p.startsWith("align-"));a&&d.push(r);let m=d.join(" ");t.node.setAttribute("data-mce-p-class",m),s.setAttribute("class",m),i.formatter.apply(t.format,{},s),e(t.node)}})}function _s(i){let e=i.querySelectorAll('[align],[style*="text-align"],.align-center,.align-left,.align-right');for(let t of e)t.removeAttribute("align"),t.style.textAlign=null,t.classList.remove("align-center","align-right","align-left")}function ao(i){let e=i.querySelectorAll('[dir],[style*="direction"]');for(let t of e)t.removeAttribute("dir"),t.style.direction=null;_s(i),i.style.direction=null,i.style.textAlign=null,i.removeAttribute("align")}function Fs(i){let e=[];i.on("TableSelectionChange",n=>{e=(n.cells||[]).map(o=>o.dom)}),i.on("TableSelectionClear",()=>{e=[]});let t={RemoveFormat:n=>{let o=["class","style","width","height","align"];for(let s of o)n.removeAttribute(s)},mceDirectionLTR:n=>{n.setAttribute("dir","ltr"),ao(n)},mceDirectionRTL:n=>{n.setAttribute("dir","rtl"),ao(n)},JustifyLeft:n=>{n.removeAttribute("align"),_s(n)}};t.JustifyRight=t.JustifyLeft,t.JustifyCenter=t.JustifyLeft,t.JustifyFull=t.JustifyLeft,i.on("ExecCommand",n=>{let o=t[n.command];if(o)for(let s of e)o(s)})}function qs(i){i.on("ExecCommand",e=>{let t=e.command;if(t!=="mceDirectionLTR"&&t!=="mceDirectionRTL")return;let n=i.selection.getSelectedBlocks();for(let o of n)ao(o)})}var Ja=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],Za={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}},Qa=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function tl(i,e,t){if(t.filetype==="file"){let n=window.$components.first("entity-selector-popup"),o=this.selection.getContent({format:"text"}).trim();n.show(s=>{i(s.link,{text:s.name,title:s.name})},{initialValue:o,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}t.filetype==="image"&&window.$components.first("image-manager").show(o=>{i(o.url,{alt:o.name})},"gallery")}function el(i){let e=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist","tableadditions",i.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",xs()),window.tinymce.PluginManager.add("customhr",As()),window.tinymce.PluginManager.add("imagemanager",Ds()),window.tinymce.PluginManager.add("about",Is()),window.tinymce.PluginManager.add("details",Bs()),window.tinymce.PluginManager.add("tasklist",Os()),window.tinymce.PluginManager.add("tableadditions",Rs()),i.drawioUrl&&(window.tinymce.PluginManager.add("drawio",Ms(i)),e.push("drawio")),e.filter(t=>!!t)}function nl(i){let e=document.head.innerHTML.split(` 8`),t=e.findIndex(r=>r.trim()==="<!-- Start: custom user content -->"),n=e.findIndex(r=>r.trim()==="<!-- End: custom user content -->");if(t===-1||n===-1)return;let o=e.slice(t+1,n).join(` 9`),s=i.createElement("div");s.innerHTML=o,i.head.append(...s.children)}function il(i){return function(t){function n(){i.darkMode&&t.contentDocument.documentElement.classList.add("dark-mode"),window.$events.emit("editor-html-change","")}t.on("ExecCommand change input NodeChange ObjectResized",n),ps(t),fs(t,i),t.on("init",()=>{n(),us(t),window.editor=t,ds(t)}),t.on("PreInit",()=>{ws(t)}),Ns(t),Fs(t),qs(t),window.$events.emitPublic(i.containerElement,"editor-tinymce::setup",{editor:t}),t.ui.registry.addButton("inlinecode",{tooltip:"Inline code",icon:"sourcecode",onAction(){t.execCommand("mceToggleFormat",!1,"code")}})}}function ol(i){return` 10html, body, html.dark-mode { 11 background: ${i.darkMode?"#222":"#fff"}; 12} 13body { 14 padding-left: 15px !important; 15 padding-right: 15px !important; 16 height: initial !important; 17 margin:0!important; 18 margin-left: auto! important; 19 margin-right: auto !important; 20 overflow-y: hidden !important; 21}`.trim().replace(` 22`,"")}function Ws(i){return window.tinymce.addI18n(i.language,i.translationMap),{width:"100%",height:"100%",selector:"#html-editor",cache_suffix:`?version=${document.querySelector('script[src*="/dist/app.js"]').getAttribute("src").split("?version=")[1]}`,content_css:[window.baseUrl("/dist/styles.css")],branding:!1,skin:i.darkMode?"tinymce-5-dark":"tinymce-5",body_class:"page-content",browser_spellcheck:!0,relative_urls:!1,language:i.language,directionality:i.textDirection,remove_script_host:!1,document_base_url:window.baseUrl("/"),end_container_on_empty_block:!0,remove_trailing_brs:!1,statusbar:!1,menubar:!1,paste_data_images:!1,extended_valid_elements:"pre[*],svg[*],div[drawio-diagram],details[*],summary[*],div[*],li[class|checked|style]",automatic_uploads:!1,custom_elements:"doc-root,code-block",valid_children:["-div[p|h1|h2|h3|h4|h5|h6|blockquote|code-block]","+div[pre|img]","-doc-root[doc-root|#text]","-li[details]","+code-block[pre]","+doc-root[p|h1|h2|h3|h4|h5|h6|blockquote|code-block|div|hr]"].join(","),plugins:el(i),contextmenu:!1,toolbar:gs(i),content_style:ol(i),style_formats:Ja,style_formats_merge:!1,media_alt_source:!1,media_poster:!1,formats:Za,table_style_by_css:!0,table_use_colgroups:!0,file_picker_types:"file image",color_map:Qa,file_picker_callback:tl,paste_preprocess(t,n){let{content:o}=n;o.indexOf('<img src="file://')!==-1&&(n.content="")},init_instance_callback(t){nl(t.getDoc())},setup(t){bs(t),vs(t),il(i)(t)}}}var ui=class extends h{setup(){this.elem=this.$el,this.tinyMceConfig=Ws({language:this.$opts.language,containerElement:this.elem,darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,drawioUrl:this.getDrawIoUrl(
22),pageId:Number(this.$opts.pageId),translations:{imageUploadErrorText:this.$opts.imageUploadErrorText,serverUploadLimitText:this.$opts.serverUploadLimitText},translationMap:window.editor_translations}),window.$events.emitPublic(this.elem,"editor-tinymce::pre-init",{config:this.tinyMceConfig}),window.tinymce.init(this.tinyMceConfig).then(e=>{this.editor=e[0]})}getDrawIoUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):""}async getContent(){return{html:this.editor.getContent()}}};var pi=class extends h{constructor(){super(...arguments);c(this,"elem");c(this,"wysiwygEditor");c(this,"textDirection")}async setup(){this.elem=this.$el,this.textDirection=this.$opts.textDirection;let t=await window.importVersioned("wysiwyg"),n=Z("div",{class:"basic-editor-container"});this.elem.parentElement?.appendChild(n),this.elem.hidden=!0,this.wysiwygEditor=t.createBasicEditorInstance(n,this.elem.value,{darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.textDirection,translations:window.editor_translations}),this.wysiwygEditor.onChange(()=>{this.wysiwygEditor.getContentAsHtml().then(o=>{this.elem.value=o})})}};function co(i){let e=n=>n.slice(0,1).toUpperCase()+n.slice(1),t=i.split("-");return t[0]+t.slice(1).map(e).join("")}function js(i){return i.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}function sl(i,e){let t={},n={},o=`${i}@`,s=`[refs*="${o}"]`,r=[...e.querySelectorAll(s)];e.matches(s)&&r.push(e);for(let a of r){let l=(a.getAttribute("refs")||"").split(" ").filter(d=>d.startsWith(o)).map(d=>d.replace(o,"")).map(co);for(let d of l)t[d]=a,typeof n[d]>"u"&&(n[d]=[]),n[d].push(a)}return{refs:t,manyRefs:n}}function rl(i,e){let t={},n=`option:${i}:`;for(let{name:o,value:s}of e.attributes)if(o.startsWith(n)){let r=o.replace(n,"");t[co(r)]=s||""}return t}var mi=class{constructor(){c(this,"components",{});c(this,"componentModelMap",{});c(this,"elementComponentMap",new WeakMap)}initComponent(e,t){let n=this.componentModelMap[e];if(n===void 0)return;let o=null;try{o=new n,o.$name=e,o.$el=t;let r=sl(e,t);o.$refs=r.refs,o.$manyRefs=r.manyRefs,o.$opts=rl(e,t),o.setup()}catch(r){console.error("Failed to create component",r,e,t)}if(!o)return;typeof this.components[e]>"u"&&(this.components[e]=[]),this.components[e].push(o);let s=this.elementComponentMap.get(t)||{};s[e]=o,this.elementComponentMap.set(t,s)}init(e=document){let t=e.querySelectorAll("[component],[components]");for(let n of t){let o=`${n.getAttribute("component")||""} ${n.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let s of o)this.initComponent(s,n)}}register(e){let t=Object.keys(e);for(let n of t)this.componentModelMap[js(n)]=e[n]}first(e){return(this.components[e]||[null])[0]}get(e){return this.components[e]||[]}firstOnElement(e,t){return(this.elementComponentMap.get(e)||{})[t]||null}allWithinElement(e,t){return this.get(t).filter(o=>e.contains(o.$el))}};window.__DEV__=!1;window.baseUrl=bo;window.importVersioned=wo;window.$http=new Le;window.$events=new xe;window.$trans=new Te;window.$components=new mi;window.$components.register(lo);window.$components.init(); 23/*! Bundled license information: 24 25sortablejs/modular/sortable.esm.js: 26 (**! 27 * Sortable 1.15.7 28 * @author RubaXa <[email protected]> 29 * @author owenm <[email protected]> 30 * @license MIT 31 *) 32*/ 33//# sourceMappingURL=app.js.map
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.