mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-07-22 13:44:04 +03:00
34 lines
203 KiB
JavaScript
34 lines
203 KiB
JavaScript
// See the "/licenses" URI for full package license details
|
|
var ho=Object.defineProperty;var uo=n=>{throw TypeError(n)};var Vs=(n,e,t)=>e in n?ho(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var zs=(n,e)=>{for(var t in e)ho(n,t,{get:e[t],enumerable:!0})};var d=(n,e,t)=>Vs(n,typeof e!="symbol"?e+"":e,t),Ks=(n,e,t)=>e.has(n)||uo("Cannot "+t);var po=(n,e,t)=>e.has(n)?uo("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t);var ee=(n,e,t)=>(Ks(n,e,"access private method"),t);var Ee=class{constructor(){d(this,"listeners",{});d(this,"stack",[])}emit(e,t={}){this.stack.push({name:e,data:t});let i=this.listeners[e]||[];for(let o of i)o(t)}listen(e,t){typeof this.listeners[e]>"u"&&(this.listeners[e]=[]),this.listeners[e].push(t)}remove(e,t){let i=this.listeners[e]||[],o=i.indexOf(t);o!==-1&&i.splice(o,1)}emitPublic(e,t,i){let o=new CustomEvent(t,{detail:i,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){let t=Object.values(e.data).flat().join(`
|
|
`);this.error(t)}}showResponseError(e){e.status&&e.status>=400&&typeof e.data=="object"&&e.data.message&&this.error(e.data.message)}};var Dt=class extends Error{constructor(t,i){super(t.statusText);d(this,"data");d(this,"headers");d(this,"original");d(this,"redirected");d(this,"status");d(this,"statusText");d(this,"url");this.data=i,this.headers=t.headers,this.redirected=t.redirected,this.status=t.status,this.statusText=t.statusText,this.url=t.url,this.original=t}},Ce=class{async getResponseContent(e){if(e.status===204)return null;let i=(e.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return i==="javascript"||i==="json"?e.json():e.text()}createXMLHttpRequest(e,t,i={}){let o=document.querySelector("meta[name=token]")?.getAttribute("content"),s=new XMLHttpRequest;for(let[r,a]of Object.entries(i))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 i=e;if(i.startsWith("http")||(i=window.baseUrl(i)),t.params){let c=new URL(i);for(let p of Object.keys(t.params)){let m=t.params[p];typeof m<"u"&&m!==null&&c.searchParams.set(p,m)}i=c.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(i,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 Dt(r,a);return l}async dataRequest(e,t,i){let o={method:e,body:i};return typeof i=="object"&&!(i instanceof FormData)&&(o.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},o.body=JSON.stringify(i)),i instanceof FormData&&e!=="post"&&(i.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 i=Object.values(t);return i.every(s=>Array.isArray(s)&&s.every(r=>typeof r=="string"))?i.flat().join(" "):e}};var xe=class{choice(e,t,i={}){i=Object.assign({},{count:String(t)},i);let o=e.split("|"),s=/^{([0-9]+)}/,r=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let c=l.match(s);if(c!==null&&Number(c[1])===t){a=l.replace(s,"").trim();break}let p=l.match(r);if(p!==null&&Number(p[1])<=t&&(p[2]==="*"||Number(p[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,i)}performReplacements(e,t){let i=e.match(/:(\S+)/g);if(i===null)return e;let o=e;for(let s of i){let r=s.substring(1);typeof t[r]>"u"||(o=o.replace(s,t[r]))}return o}};var ao={};zs(ao,{AddRemoveRows:()=>ke,AjaxDeleteRow:()=>$e,AjaxForm:()=>Me,ApiNav:()=>De,Attachments:()=>Ae,AttachmentsList:()=>Ie,AutoSubmit:()=>Be,AutoSuggest:()=>He,BackToTop:()=>Pe,BookSort:()=>Ze,ChapterContents:()=>tn,CodeEditor:()=>en,CodeHighlighter:()=>nn,CodeTextarea:()=>on,Collapsible:()=>sn,ConfirmDialog:()=>rn,CustomCheckbox:()=>an,DetailsHighlighter:()=>ln,Dropdown:()=>cn,DropdownSearch:()=>dn,Dropzone:()=>hn,EditorToolbox:()=>un,EntityPermissions:()=>pn,EntitySearch:()=>mn,EntitySelector:()=>fn,EntitySelectorPopup:()=>gn,EventEmitSelect:()=>vn,ExpandToggle:()=>bn,GlobalSearch:()=>wn,HeaderMobileToggle:()=>yn,ImageManager:()=>En,ImagePicker:()=>Cn,ListSortControl:()=>xn,LoadingButton:()=>Tn,MarkdownEditor:()=>Ln,NewUserPassword:()=>Sn,Notification:()=>kn,OptionalInput:()=>$n,PageComment:()=>Mn,PageCommentReference:()=>Dn,PageComments:()=>An,PageDisplay:()=>In,PageEditor:()=>Hn,PagePicker:()=>Pn,PermissionsTable:()=>Rn,Pointer:()=>On,Popup:()=>Nn,SettingAppColorScheme:()=>_n,SettingColorPicker:()=>Fn,SettingHomepageControl:()=>qn,ShelfSort:()=>Un,ShortcutInput:()=>zn,Shortcuts:()=>Vn,SortRuleManager:()=>Xn,SortableList:()=>Kn,SubmitOnChange:()=>Gn,Tabs:()=>Qt,TagManager:()=>Yn,TemplateManager:()=>Jn,ToggleSwitch:()=>Zn,ToolboxContents:()=>ei,TriLayout:()=>ni,UserSelect:()=>ii,WebhookEvents:()=>oi,WysiwygEditor:()=>si,WysiwygEditorTinymce:()=>hi,WysiwygInput:()=>ui});function mt(n,e,t){let i=null;return function(...s){let r=this,a=function(){i=null,t||n.apply(r,s)},l=t&&!i;i&&clearTimeout(i),i=window.setTimeout(a,e),l&&n.apply(r,s)}}function Xs(n){return n.nodeName==="DETAILS"}function At(n){if(!n)return;let e=n;for(;e.parentElement;)e=e.parentElement,Xs(e)&&!e.open&&(e.open=!0);n.scrollIntoView({behavior:"smooth"});let t=getComputedStyle(document.body).getPropertyValue("--color-link");n.style.outline=`2px dashed ${t}`,n.style.outlineOffset="5px",n.style.removeProperty("transition"),setTimeout(()=>{n.style.transition="outline linear 3s",n.style.outline="2px dashed rgba(0, 0, 0, 0)";let i=()=>{n.removeEventListener("transitionend",i),n.style.removeProperty("transition"),n.style.removeProperty("outline"),n.style.removeProperty("outlineOffset")};n.addEventListener("transitionend",i)},1e3)}function mo(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function fo(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}function go(n){return new Promise(e=>{setTimeout(e,n)})}function vo(n){let e=n,t=document.querySelector('meta[name="base-url"]');if(!t)throw new Error("Could not find expected base-url meta tag in document");let i=t.getAttribute("content")||"";return i[i.length-1]==="/"&&(i=i.slice(0,i.length-1)),e[0]==="/"&&(e=e.slice(1)),`${i}/${e}`}function Gs(){let n=document.querySelector('link[href*="/dist/styles.css?version="]');if(!n)throw new Error("Could not find expected style link in document for version use");return(n.getAttribute("href")||"").split("?version=").pop()||""}function bo(n){return import(window.baseUrl(`dist/${n}.js?version=${Gs()}`))}function wo(n,e=0){let t=3735928559^e,i=1103547991^e;for(let o=0,s;o<n.length;o++)s=n.charCodeAt(o),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),String(4294967296*(2097151&i)+(t>>>0))}function xt(n){return n instanceof HTMLElement}function Q(n,e={},t=[]){let i=document.createElement(n);for(let[o,s]of Object.entries(e))s===null?i.removeAttribute(o):i.setAttribute(o,s);for(let o of t)typeof o=="string"?i.append(document.createTextNode(o)):i.append(o);return i}function mi(n,e){let t=document.querySelectorAll(n);for(let i of t)e(i)}function Te(n,e,t){if(n)for(let i of e)n.addEventListener(i,t)}function H(n,e){Array.isArray(n)||(n=[n]);for(let t of n)t.addEventListener("click",e),t.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e(i))})}function yo(n,e,t){Array.isArray(e)||(e=[e]);let i=o=>{o.key===n&&t(o)};e.forEach(o=>o.addEventListener("keydown",i))}function qt(n,e){yo("Enter",n,e)}function Eo(n,e){yo("Escape",n,e)}function W(n,e,t,i){n.addEventListener(t,o=>{let s=o.target?.closest(e);s&&i.call(s,o,s)})}function Co(n,e){let t=document.querySelectorAll(n);e=e.toLowerCase();for(let i of t)if((i.textContent||"").toLowerCase().includes(e)&&xt(i))return i;return null}function It(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Wt(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function ne(n){let e=n.querySelectorAll(".loading-container");for(let t of e)t.remove()}function lt(n){let e=document.createElement("div");e.innerHTML=n,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 fi(n,e,t){if(!t.contains(n))throw new Error("ParentElement must be a prent of element");let i=e,o=n.nodeType===Node.TEXT_NODE?n:n.childNodes[e];for(;o!==t&&o;)o.previousSibling?(o=o.previousSibling,i+=o.textContent?.length||0):o=o.parentNode;return i}function Le(n,e){if(e===0)return{node:n,offset:0};let t=0,i=null;for(let o=0;o<n.childNodes.length;o++)if(i=n.childNodes[o],i.nodeType===Node.TEXT_NODE){let s=(i.textContent||"").length;if(t+s>=e)return{node:i,offset:e-t};t+=s}else if(i.nodeType===Node.ELEMENT_NODE){let s=(i.textContent||"").length;if(t+s>=e)return Le(i,e-t);t+=s}return null}function Se(n){let e=(n.textContent||"").replace(/\s{2,}/g,"");return wo(e)}function xo(n){let e=n;do{if(window.getComputedStyle(e).overflowY==="scroll")return e;e=e.parentElement}while(e);return document.body}var h=class{constructor(){d(this,"$name","");d(this,"$el",null);d(this,"$refs",{});d(this,"$manyRefs",{});d(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let i=this.$name,o=new CustomEvent(`${i}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(o)}};var ke=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=fo(),i=e.querySelectorAll('[name*="randrowid"]');for(let o of i)o.name=o.name.split("randrowid").join(t)}};var $e=class extends h{constructor(){super(...arguments);d(this,"row");d(this,"url");d(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 Me=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 i of t)e.append(i.getAttribute("name"),i.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 De=class extends h{constructor(){super(...arguments);d(this,"select");d(this,"sidebar");d(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,i=document.getElementById(`sidebar-header-${t}`),o=document.getElementById(`section-${t}`);if(i&&o){let s=i.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 Ae=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 i=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(i);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[i,o]of Object.entries(t))o.toggleAttribute("hidden",i!==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 Ie=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 Lt,vi,bi,Tt=class{constructor(e,t=null,i=null){po(this,Lt);d(this,"containers");d(this,"onEscape");d(this,"onEnter");this.containers=[e],this.onEscape=t,this.onEnter=i,e.addEventListener("keydown",ee(this,Lt,vi).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",ee(this,Lt,vi).bind(this))}focusNext(){let e=ee(this,Lt,bi).call(this),t=document.activeElement,o=(xt(t)?e.indexOf(t):-1)+1;o>=e.length&&(o=0),e[o].focus()}focusPrevious(){let e=ee(this,Lt,bi).call(this),t=document.activeElement,o=(xt(t)?e.indexOf(t):-1)-1;o<0&&(o=e.length-1),e[o].focus()}};Lt=new WeakSet,vi=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))},bi=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers){let o=[...i.querySelectorAll(t)].filter(s=>xt(s));e.push(...o)}return e};var wi={},He=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 Tt(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault();let i=t.target.textContent;i&&this.selectSuggestion(i)}).shareHandlingToEl(this.input),W(this.list,".text-item","click",(t,i)=>{this.selectSuggestion(i.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 i={search:e,name:t},o=`${this.url}:${JSON.stringify(i)}`;if(wi[o])return wi[o];let s=await window.$http.get(this.url,i);return wi[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">${mo(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 Be=class extends h{setup(){this.form=this.$el,this.form.submit()}};var Pe=class extends h{setup(){if(this.button=this.$el,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.button.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,i=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function r(){let a=1-(Date.now()-o)/i,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(r.bind(this))):t.scrollTop=e}requestAnimationFrame(r.bind(this))}};function Di(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function Ys(n){if(Array.isArray(n))return Di(n)}function Js(n,e,t){return(e=or(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ht(){return ht=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ht.apply(null,arguments)}function Zs(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Qs(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(n,o).enumerable})),t.push.apply(t,i)}return t}function gt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?To(Object(t),!0).forEach(function(i){Js(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):To(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function tr(n,e){if(n==null)return{};var t,i,o=er(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)t=s[i],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(o[t]=n[t])}return o}function er(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}function nr(n){return Ys(n)||Zs(n)||sr(n)||Qs()}function ir(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function or(n){var e=ir(n,"string");return typeof e=="symbol"?e:e+""}function Ai(n){"@babel/helpers - typeof";return Ai=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},Ai(n)}function sr(n,e){if(n){if(typeof n=="string")return Di(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Di(n,e):void 0}}var rr="1.15.7";function vt(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var bt=vt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),fe=vt(/Edge/i),Lo=vt(/firefox/i),de=vt(/safari/i)&&!vt(/chrome/i)&&!vt(/android/i),Ri=vt(/iP(ad|od|hone)/i),Po=vt(/chrome/i)&&vt(/android/i),Ro={capture:!1,passive:!1};function I(n,e,t){n.addEventListener(e,t,!bt&&Ro)}function A(n,e,t){n.removeEventListener(e,t,!bt&&Ro)}function ze(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function Oo(n){return n.host&&n!==document&&n.host.nodeType&&n.host!==n?n.host:n.parentNode}function ot(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&ze(n,e):ze(n,e))||i&&n===t)return n;if(n===t)break}while(n=Oo(n))}return null}var So=/\s+/g;function K(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(So," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(So," ")}}function C(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Rt(n,e){var t="";if(typeof n=="string")t=n;else do{var i=C(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(t)}function No(n,e,t){if(n){var i=n.getElementsByTagName(e),o=0,s=i.length;if(t)for(;o<s;o++)t(i[o],o);return i}return[]}function ft(){var n=document.scrollingElement;return n||document.documentElement}function _(n,e,t,i,o){if(!(!n.getBoundingClientRect&&n!==window)){var s,r,a,l,c,p,m;if(n!==window&&n.parentNode&&n!==ft()?(s=n.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,c=s.right,p=s.height,m=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,p=window.innerHeight,m=window.innerWidth),(e||t)&&n!==window&&(o=o||n.parentNode,!bt))do if(o&&o.getBoundingClientRect&&(C(o,"transform")!=="none"||t&&C(o,"position")!=="static")){var b=o.getBoundingClientRect();r-=b.top+parseInt(C(o,"border-top-width")),a-=b.left+parseInt(C(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(i&&n!==window){var y=Rt(o||n),u=y&&y.a,f=y&&y.d;y&&(r/=f,a/=u,m/=u,p/=f,l=r+p,c=a+m)}return{top:r,left:a,bottom:l,right:c,width:m,height:p}}}function ko(n,e,t){for(var i=$t(n,!0),o=_(n)[e];i;){var s=_(i)[t],r=void 0;if(t==="top"||t==="left"?r=o>=s:r=o<=s,!r)return i;if(i===ft())break;i=$t(i,!1)}return!1}function Xt(n,e,t,i){for(var o=0,s=0,r=n.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==L.ghost&&(i||r[s]!==L.dragged)&&ot(r[s],t.draggable,n,!1)){if(o===e)return r[s];o++}s++}return null}function Oi(n,e){for(var t=n.lastElementChild;t&&(t===L.ghost||C(t,"display")==="none"||e&&!ze(t,e));)t=t.previousElementSibling;return t||null}function X(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==L.clone&&(!e||ze(n,e))&&t++;return t}function $o(n){var e=0,t=0,i=ft();if(n)do{var o=Rt(n),s=o.a,r=o.d;e+=n.scrollLeft*s,t+=n.scrollTop*r}while(n!==i&&(n=n.parentNode));return[e,t]}function ar(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function $t(n,e){if(!n||!n.getBoundingClientRect)return ft();var t=n,i=!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 ft();if(i||e)return t;i=!0}}while(t=t.parentNode);return ft()}function lr(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function yi(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var he;function _o(n,e){return function(){if(!he){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),he=setTimeout(function(){he=void 0},e)}}}function cr(){clearTimeout(he),he=void 0}function Fo(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function Ni(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function Mo(n,e){C(n,"position","absolute"),C(n,"top",e.top),C(n,"left",e.left),C(n,"width",e.width),C(n,"height",e.height)}function Ei(n){C(n,"position",""),C(n,"top",""),C(n,"left",""),C(n,"width",""),C(n,"height","")}function qo(n,e,t){var i={};return Array.from(n.children).forEach(function(o){var s,r,a,l;if(!(!ot(o,e.draggable,n,!1)||o.animated||o===t)){var c=_(o);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,c.left),i.top=Math.min((r=i.top)!==null&&r!==void 0?r:1/0,c.top),i.right=Math.max((a=i.right)!==null&&a!==void 0?a:-1/0,c.right),i.bottom=Math.max((l=i.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var Y="Sortable"+new Date().getTime();function dr(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(o){if(!(C(o,"display")==="none"||o===L.ghost)){n.push({target:o,rect:_(o)});var s=gt({},n[n.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(i){n.push(i)},removeAnimationState:function(i){n.splice(ar(n,{target:i}),1)},animateAll:function(i){var o=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var s=!1,r=0;n.forEach(function(a){var l=0,c=a.target,p=c.fromRect,m=_(c),b=c.prevFromRect,y=c.prevToRect,u=a.rect,f=Rt(c,!0);f&&(m.top-=f.f,m.left-=f.e),c.toRect=m,c.thisAnimationDuration&&yi(b,m)&&!yi(p,m)&&(u.top-m.top)/(u.left-m.left)===(p.top-m.top)/(p.left-m.left)&&(l=ur(u,b,y,o.options)),yi(m,p)||(c.prevFromRect=p,c.prevToRect=m,l||(l=o.options.animation),o.animate(c,u,m,l)),l&&(s=!0,r=Math.max(r,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof i=="function"&&i()},r):typeof i=="function"&&i(),n=[]},animate:function(i,o,s,r){if(r){C(i,"transition",""),C(i,"transform","");var a=Rt(this.el),l=a&&a.a,c=a&&a.d,p=(o.left-s.left)/(l||1),m=(o.top-s.top)/(c||1);i.animatingX=!!p,i.animatingY=!!m,C(i,"transform","translate3d("+p+"px,"+m+"px,0)"),this.forRepaintDummy=hr(i),C(i,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),C(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){C(i,"transition",""),C(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},r)}}}}function hr(n){return n.offsetWidth}function ur(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var jt=[],Ci={initializeByDefault:!0},ge={mount:function(e){for(var t in Ci)Ci.hasOwnProperty(t)&&!(t in e)&&(e[t]=Ci[t]);jt.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),jt.push(e)},pluginEvent:function(e,t,i){var o=this;this.eventCanceled=!1,i.cancel=function(){o.eventCanceled=!0};var s=e+"Global";jt.forEach(function(r){t[r.pluginName]&&(t[r.pluginName][s]&&t[r.pluginName][s](gt({sortable:t},i)),t.options[r.pluginName]&&t[r.pluginName][e]&&t[r.pluginName][e](gt({sortable:t},i)))})},initializePlugins:function(e,t,i,o){jt.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,ht(i,c.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 i={};return jt.forEach(function(o){typeof o.eventProperties=="function"&&ht(i,o.eventProperties.call(t[o.pluginName],e))}),i},modifyOption:function(e,t,i){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],i))}),o}};function re(n){var e=n.sortable,t=n.rootEl,i=n.name,o=n.targetEl,s=n.cloneEl,r=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,p=n.oldDraggableIndex,m=n.newDraggableIndex,b=n.originalEvent,y=n.putSortable,u=n.extraEventProperties;if(e=e||t&&t[Y],!!e){var f,w=e.options,E="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!bt&&!fe?f=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(f=document.createEvent("Event"),f.initEvent(i,!0,!0)),f.to=r||t,f.from=a||t,f.item=o||t,f.clone=s,f.oldIndex=l,f.newIndex=c,f.oldDraggableIndex=p,f.newDraggableIndex=m,f.originalEvent=b,f.pullMode=y?y.lastPutMode:void 0;var v=gt(gt({},u),ge.getEventProperties(i,e));for(var T in v)f[T]=v[T];t&&t.dispatchEvent(f),w[E]&&w[E].call(e,f)}}var pr=["evt"],nt=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.evt,s=tr(i,pr);ge.pluginEvent.bind(L)(e,t,gt({dragEl:g,parentEl:j,ghostEl:M,rootEl:F,nextEl:Pt,lastDownEl:We,cloneEl:q,cloneHidden:kt,dragStarted:ae,putSortable:G,activeSortable:L.active,originalEvent:o,oldIndex:Kt,oldDraggableIndex:ue,newIndex:at,newDraggableIndex:St,hideGhostForTarget:Vo,unhideGhostForTarget:zo,cloneNowHidden:function(){kt=!0},cloneNowShown:function(){kt=!1},dispatchSortableEvent:function(a){tt({sortable:t,name:a,originalEvent:o})}},s))};function tt(n){re(gt({putSortable:G,cloneEl:q,targetEl:g,rootEl:F,oldIndex:Kt,oldDraggableIndex:ue,newIndex:at,newDraggableIndex:St},n))}var g,j,M,F,Pt,We,q,kt,Kt,at,ue,St,Re,G,zt=!1,Ke=!1,Xe=[],Ht,ct,xi,Ti,Do,Ao,ae,Ut,pe,me=!1,Oe=!1,je,J,Li=[],Ii=!1,Ge=[],Je=typeof document<"u",Ne=Ri,Io=fe||bt?"cssFloat":"float",mr=Je&&!Po&&!Ri&&"draggable"in document.createElement("div"),Wo=(function(){if(Je){if(bt)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}})(),jo=function(e,t){var i=C(e),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=Xt(e,0,t),r=Xt(e,1,t),a=s&&C(s),l=r&&C(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+_(s).width,p=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+_(r).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var m=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===m)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&i[Io]==="none"||r&&i[Io]==="none"&&c+p>o)?"vertical":"horizontal"},fr=function(e,t,i){var o=i?e.left:e.top,s=i?e.right:e.bottom,r=i?e.width:e.height,a=i?t.left:t.top,l=i?t.right:t.bottom,c=i?t.width:t.height;return o===a||s===l||o+r/2===a+c/2},gr=function(e,t){var i;return Xe.some(function(o){var s=o[Y].options.emptyInsertThreshold;if(!(!s||Oi(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 i=o}}),i},Uo=function(e){function t(s,r){return function(a,l,c,p){var m=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||m))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,c,p),r)(a,l,c,p);var b=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===b||s.join&&s.indexOf(b)>-1}}var i={},o=e.group;(!o||Ai(o)!="object")&&(o={name:o}),i.name=o.name,i.checkPull=t(o.pull,!0),i.checkPut=t(o.put),i.revertClone=o.revertClone,e.group=i},Vo=function(){!Wo&&M&&C(M,"display","none")},zo=function(){!Wo&&M&&C(M,"display","")};Je&&!Po&&document.addEventListener("click",function(n){if(Ke)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Ke=!1,!1},!0);var Bt=function(e){if(g){e=e.touches?e.touches[0]:e;var t=gr(e.clientX,e.clientY);if(t){var i={};for(var o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[Y]._onDragOver(i)}}},vr=function(e){g&&g.parentNode[Y]._isOutsideThisEl(e.target)};function L(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=ht({},e),n[Y]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return jo(n,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:L.supportPointer!==!1&&"PointerEvent"in window&&(!de||Ri),emptyInsertThreshold:5};ge.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);Uo(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:mr,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?I(n,"pointerdown",this._onTapStart):(I(n,"mousedown",this._onTapStart),I(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(I(n,"dragover",this),I(n,"dragenter",this)),Xe.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ht(this,dr())}L.prototype={constructor:L,_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,i=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,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,p=o.filter;if(Lr(i),!g&&!(/mousedown|pointerdown/.test(r)&&e.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&de&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=ot(l,o.draggable,i,!1),!(l&&l.animated)&&We!==l)){if(Kt=X(l),ue=X(l,o.draggable),typeof p=="function"){if(p.call(this,e,l,this)){tt({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),nt("filter",t,{evt:e}),s&&e.preventDefault();return}}else if(p&&(p=p.split(",").some(function(m){if(m=ot(c,m.trim(),i,!1),m)return tt({sortable:t,rootEl:m,name:"filter",targetEl:l,fromEl:i,toEl:i}),nt("filter",t,{evt:e}),!0}),p)){s&&e.preventDefault();return}o.handle&&!ot(c,o.handle,i,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,i){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(i&&!g&&i.parentNode===s){var c=_(i);if(F=s,g=i,j=g.parentNode,Pt=g.nextSibling,We=i,Re=r.group,L.dragged=g,Ht={target:g,clientX:(t||e).clientX,clientY:(t||e).clientY},Do=Ht.clientX-c.left,Ao=Ht.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,g.style["will-change"]="all",l=function(){if(nt("delayEnded",o,{evt:e}),L.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!Lo&&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(p){No(g,p.trim(),Si)}),I(a,"dragover",Bt),I(a,"mousemove",Bt),I(a,"touchmove",Bt),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)),Lo&&this.nativeDraggable&&(this.options.touchStartThreshold=4,g.draggable=!0),nt("delayStart",this,{evt:e}),r.delay&&(!r.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(fe||bt))){if(L.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&&Si(g),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;A(e,"mouseup",this._disableDelayedDrag),A(e,"touchend",this._disableDelayedDrag),A(e,"touchcancel",this._disableDelayedDrag),A(e,"pointerup",this._disableDelayedDrag),A(e,"pointercancel",this._disableDelayedDrag),A(e,"mousemove",this._delayedDragTouchMoveHandler),A(e,"touchmove",this._delayedDragTouchMoveHandler),A(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?Ue(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",vr);var i=this.options;!e&&K(g,i.dragClass,!1),K(g,i.ghostClass,!0),L.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,Vo();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 i=void 0;if(i=t[Y]._onDragOver({clientX:ct.clientX,clientY:ct.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=Oo(t));zo()}},_onTouchMove:function(e){if(Ht){var t=this.options,i=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,c=Ne&&J&&$o(J),p=(s.clientX-Ht.clientX+o.x)/(a||1)+(c?c[0]-Li[0]:0)/(a||1),m=(s.clientY-Ht.clientY+o.y)/(l||1)+(c?c[1]-Li[1]:0)/(l||1);if(!L.active&&!zt){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(M){r?(r.e+=p-(xi||0),r.f+=m-(Ti||0)):r={a:1,b:0,c:0,d:1,e:p,f:m};var b="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");C(M,"webkitTransform",b),C(M,"mozTransform",b),C(M,"msTransform",b),C(M,"transform",b),xi=p,Ti=m,ct=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!M){var e=this.options.fallbackOnBody?document.body:F,t=_(g,!0,Ne,!0,e),i=this.options;if(Ne){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=ft()),t.top+=J.scrollTop,t.left+=J.scrollLeft):J=ft(),Li=$o(J)}M=g.cloneNode(!0),K(M,i.ghostClass,!1),K(M,i.fallbackClass,!0),K(M,i.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",Ne?"absolute":"fixed"),C(M,"zIndex","100000"),C(M,"pointerEvents","none"),L.ghost=M,e.appendChild(M),C(M,"transform-origin",Do/parseInt(M.style.width)*100+"% "+Ao/parseInt(M.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,o=e.dataTransfer,s=i.options;if(nt("dragStart",this,{evt:e}),L.eventCanceled){this._onDrop();return}nt("setupClone",this),L.eventCanceled||(q=Ni(g),q.removeAttribute("id"),q.draggable=!1,q.style["will-change"]="",this._hideClone(),K(q,this.options.chosenClass,!1),L.clone=q),i.cloneId=Ue(function(){nt("clone",i),!L.eventCanceled&&(i.options.removeCloneOnHide||F.insertBefore(q,g),i._hideClone(),tt({sortable:i,name:"clone"}))}),!t&&K(g,s.dragClass,!0),t?(Ke=!0,i._loopId=setInterval(i._emulateDragOver,50)):(A(document,"mouseup",i._onDrop),A(document,"touchend",i._onDrop),A(document,"touchcancel",i._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(i,o,g)),I(document,"drop",i),C(g,"transform","translateZ(0)")),zt=!0,i._dragStartId=Ue(i._dragStarted.bind(i,t,e)),I(document,"selectstart",i),ae=!0,window.getSelection().removeAllRanges(),de&&C(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,o,s,r,a=this.options,l=a.group,c=L.active,p=Re===l,m=a.sort,b=G||c,y,u=this,f=!1;if(Ii)return;function w(te,js){nt(te,u,gt({evt:e,isOwner:p,axis:y?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:m,fromSortable:b,target:i,completed:v,onMove:function(co,Us){return _e(F,t,g,o,co,_(co),e,Us)},changed:T},js))}function E(){w("dragOverAnimationCapture"),u.captureAnimationState(),u!==b&&b.captureAnimationState()}function v(te){return w("dragOverCompleted",{insertion:te}),te&&(p?c._hideClone():c._showClone(u),u!==b&&(K(g,G?G.options.ghostClass:c.options.ghostClass,!1),K(g,a.ghostClass,!0)),G!==u&&u!==L.active?G=u:u===L.active&&G&&(G=null),b===u&&(u._ignoreWhileAnimating=i),u.animateAll(function(){w("dragOverAnimationComplete"),u._ignoreWhileAnimating=null}),u!==b&&(b.animateAll(),b._ignoreWhileAnimating=null)),(i===g&&!g.animated||i===t&&!i.animated)&&(Ut=null),!a.dragoverBubble&&!e.rootEl&&i!==document&&(g.parentNode[Y]._isOutsideThisEl(e.target),!te&&Bt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),f=!0}function T(){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(),i=ot(i,a.draggable,t,!0),w("dragOver"),L.eventCanceled)return f;if(g.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||u._ignoreWhileAnimating===i)return v(!1);if(Ke=!1,c&&!a.disabled&&(p?m||(r=j!==F):G===this||(this.lastPutMode=Re.checkPull(this,c,g,e))&&l.checkPut(this,c,g,e))){if(y=this._getDirection(e,i)==="vertical",o=_(g),w("dragOverValid"),L.eventCanceled)return f;if(r)return j=F,E(),this._hideClone(),w("revert"),L.eventCanceled||(Pt?F.insertBefore(g,Pt):F.appendChild(g)),v(!0);var S=Oi(t,a.draggable);if(!S||Er(e,y,this)&&!S.animated){if(S===g)return v(!1);if(S&&t===e.target&&(i=S),i&&(s=_(i)),_e(F,t,g,o,i,s,e,!!i)!==!1)return E(),S&&S.nextSibling?t.insertBefore(g,S.nextSibling):t.appendChild(g),j=t,T(),v(!0)}else if(S&&yr(e,y,this)){var x=Xt(t,0,a,!0);if(x===g)return v(!1);if(i=x,s=_(i),_e(F,t,g,o,i,s,e,!1)!==!1)return E(),t.insertBefore(g,x),j=t,T(),v(!0)}else if(i.parentNode===t){s=_(i);var D=0,P,B=g.parentNode!==t,k=!fr(g.animated&&g.toRect||o,i.animated&&i.toRect||s,y),O=y?"top":"left",R=ko(i,"top","top")||ko(g,"top","top"),U=R?R.scrollTop:void 0;Ut!==i&&(P=s[O],me=!1,Oe=!k&&a.invertSwap||B),D=Cr(e,i,s,y,k?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,Oe,Ut===i);var V;if(D!==0){var pt=X(g);do pt-=D,V=j.children[pt];while(V&&(C(V,"display")==="none"||V===M))}if(D===0||V===i)return v(!1);Ut=i,pe=D;var Ct=i.nextElementSibling,et=!1;et=D===1;var Mt=_e(F,t,g,o,i,s,e,et);if(Mt!==!1)return(Mt===1||Mt===-1)&&(et=Mt===1),Ii=!0,setTimeout(wr,30),E(),et&&!Ct?t.appendChild(g):i.parentNode.insertBefore(g,et?Ct:i),R&&Fo(R,0,U-R.scrollTop),j=g.parentNode,P!==void 0&&!Oe&&(je=Math.abs(P-_(i)[O])),T(),v(!0)}if(t.contains(g))return v(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){A(document,"mousemove",this._onTouchMove),A(document,"touchmove",this._onTouchMove),A(document,"pointermove",this._onTouchMove),A(document,"dragover",Bt),A(document,"mousemove",Bt),A(document,"touchmove",Bt)},_offUpEvents:function(){var e=this.el.ownerDocument;A(e,"mouseup",this._onDrop),A(e,"touchend",this._onDrop),A(e,"pointerup",this._onDrop),A(e,"pointercancel",this._onDrop),A(e,"touchcancel",this._onDrop),A(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(at=X(g),St=X(g,i.draggable),nt("drop",this,{evt:e}),j=g&&g.parentNode,at=X(g),St=X(g,i.draggable),L.eventCanceled){this._nulling();return}zt=!1,Oe=!1,me=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Hi(this.cloneId),Hi(this._dragStartId),this.nativeDraggable&&(A(document,"drop",this),A(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),de&&C(document.body,"user-select",""),C(g,"transform",""),e&&(ae&&(e.cancelable&&e.preventDefault(),!i.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&&A(g,"dragend",this),Si(g),g.style["will-change"]="",ae&&!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})),L.active&&((at==null||at===-1)&&(at=Kt,St=ue),tt({sortable:this,name:"end",toEl:j,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){nt("nulling",this),F=g=j=M=Pt=q=We=kt=Ht=ct=ae=at=St=Kt=ue=Ut=pe=G=Re=L.dragged=L.ghost=L.clone=L.active=null;var e=this.el;Ge.forEach(function(t){e.contains(t)&&(t.checked=!0)}),Ge.length=xi=Ti=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":g&&(this._onDragOver(e),br(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,o=0,s=i.length,r=this.options;o<s;o++)t=i[o],ot(t,r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Tr(t));return e},sort:function(e,t){var i={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];ot(a,this.options.draggable,o,!1)&&(i[s]=a)},this),t&&this.captureAnimationState(),e.forEach(function(s){i[s]&&(o.removeChild(i[s]),o.appendChild(i[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 i=this.options;if(t===void 0)return i[e];var o=ge.modifyOption(this,e,t);typeof o<"u"?i[e]=o:i[e]=t,e==="group"&&Uo(i)},destroy:function(){nt("destroy",this);var e=this.el;e[Y]=null,A(e,"mousedown",this._onTapStart),A(e,"touchstart",this._onTapStart),A(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(A(e,"dragover",this),A(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Xe.splice(Xe.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!kt){if(nt("hideClone",this),L.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),L.eventCanceled)return;g.parentNode==F&&!this.options.group.revertClone?F.insertBefore(q,g):Pt?F.insertBefore(q,Pt):F.appendChild(q),this.options.group.revertClone&&this.animate(g,q),C(q,"display",""),kt=!1}}};function br(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function _e(n,e,t,i,o,s,r,a){var l,c=n[Y],p=c.options.onMove,m;return window.CustomEvent&&!bt&&!fe?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=n,l.dragged=t,l.draggedRect=i,l.related=o||e,l.relatedRect=s||_(e),l.willInsertAfter=a,l.originalEvent=r,n.dispatchEvent(l),p&&(m=p.call(c,l,r)),m}function Si(n){n.draggable=!1}function wr(){Ii=!1}function yr(n,e,t){var i=_(Xt(t.el,0,t.options,!0)),o=qo(t.el,t.options,M),s=10;return e?n.clientX<o.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<o.top-s||n.clientY<i.bottom&&n.clientX<i.left}function Er(n,e,t){var i=_(Oi(t.el,t.options.draggable)),o=qo(t.el,t.options,M),s=10;return e?n.clientX>o.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>o.bottom+s||n.clientX>i.right&&n.clientY>i.top}function Cr(n,e,t,i,o,s,r,a){var l=i?n.clientY:n.clientX,c=i?t.height:t.width,p=i?t.top:t.left,m=i?t.bottom:t.right,b=!1;if(!r){if(a&&je<c*o){if(!me&&(pe===1?l>p+c*s/2:l<m-c*s/2)&&(me=!0),me)b=!0;else if(pe===1?l<p+je:l>m-je)return-pe}else if(l>p+c*(1-o)/2&&l<m-c*(1-o)/2)return xr(e)}return b=b||r,b&&(l<p+c*s/2||l>m-c*s/2)?l>p+c/2?1:-1:0}function xr(n){return X(g)<X(n)?1:-1}function Tr(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function Lr(n){Ge.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&Ge.push(i)}}function Ue(n){return setTimeout(n,0)}function Hi(n){return clearTimeout(n)}Je&&I(document,"touchmove",function(n){(L.active||zt)&&n.cancelable&&n.preventDefault()});L.utils={on:I,off:A,css:C,find:No,is:function(e,t){return!!ot(e,t,e,!1)},extend:lr,throttle:_o,closest:ot,toggleClass:K,clone:Ni,index:X,nextTick:Ue,cancelNextTick:Hi,detectDirection:jo,getChild:Xt,expando:Y};L.get=function(n){return n[Y]};L.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(L.utils=gt(gt({},L.utils),i.utils)),ge.mount(i)})};L.create=function(n,e){return new L(n,e)};L.version=rr;var z=[],le,Bi,Pi=!1,ki,$i,Ye,ce;function Sr(){function n(){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 n.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?I(document,"dragover",this._handleAutoScroll):this.options.supportPointer?I(document,"pointermove",this._handleFallbackAutoScroll):i.touches?I(document,"touchmove",this._handleFallbackAutoScroll):I(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?A(document,"dragover",this._handleAutoScroll):(A(document,"pointermove",this._handleFallbackAutoScroll),A(document,"touchmove",this._handleFallbackAutoScroll),A(document,"mousemove",this._handleFallbackAutoScroll)),Ho(),Ve(),cr()},nulling:function(){Ye=Bi=le=Pi=ce=ki=$i=null,z.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){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(Ye=t,i||this.options.forceAutoScrollFallback||fe||bt||de){Mi(t,this.options,a,i);var l=$t(a,!0);Pi&&(!ce||s!==ki||r!==$i)&&(ce&&Ho(),ce=setInterval(function(){var c=$t(document.elementFromPoint(s,r),!0);c!==l&&(l=c,Ve()),Mi(t,o.options,c,i)},10),ki=s,$i=r)}else{if(!this.options.bubbleScroll||$t(a,!0)===ft()){Ve();return}Mi(t,this.options,$t(a,!1),!1)}}},ht(n,{pluginName:"scroll",initializeByDefault:!0})}function Ve(){z.forEach(function(n){clearInterval(n.pid)}),z=[]}function Ho(){clearInterval(ce)}var Mi=_o(function(n,e,t,i){if(e.scroll){var o=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,r=e.scrollSensitivity,a=e.scrollSpeed,l=ft(),c=!1,p;Bi!==t&&(Bi=t,Ve(),le=e.scroll,p=e.scrollFn,le===!0&&(le=$t(t,!0)));var m=0,b=le;do{var y=b,u=_(y),f=u.top,w=u.bottom,E=u.left,v=u.right,T=u.width,S=u.height,x=void 0,D=void 0,P=y.scrollWidth,B=y.scrollHeight,k=C(y),O=y.scrollLeft,R=y.scrollTop;y===l?(x=T<P&&(k.overflowX==="auto"||k.overflowX==="scroll"||k.overflowX==="visible"),D=S<B&&(k.overflowY==="auto"||k.overflowY==="scroll"||k.overflowY==="visible")):(x=T<P&&(k.overflowX==="auto"||k.overflowX==="scroll"),D=S<B&&(k.overflowY==="auto"||k.overflowY==="scroll"));var U=x&&(Math.abs(v-o)<=r&&O+T<P)-(Math.abs(E-o)<=r&&!!O),V=D&&(Math.abs(w-s)<=r&&R+S<B)-(Math.abs(f-s)<=r&&!!R);if(!z[m])for(var pt=0;pt<=m;pt++)z[pt]||(z[pt]={});(z[m].vx!=U||z[m].vy!=V||z[m].el!==y)&&(z[m].el=y,z[m].vx=U,z[m].vy=V,clearInterval(z[m].pid),(U!=0||V!=0)&&(c=!0,z[m].pid=setInterval(function(){i&&this.layer===0&&L.active._onTouchMove(Ye);var Ct=z[this.layer].vy?z[this.layer].vy*a:0,et=z[this.layer].vx?z[this.layer].vx*a:0;typeof p=="function"&&p.call(L.dragged.parentNode[Y],et,Ct,n,Ye,z[this.layer].el)!=="continue"||Fo(z[this.layer].el,et,Ct)}.bind({layer:m}),24))),m++}while(e.bubbleScroll&&b!==l&&(b=$t(b,!1)));Pi=c}},30),Ko=function(e){var t=e.originalEvent,i=e.putSortable,o=e.dragEl,s=e.activeSortable,r=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=i||s;a();var p=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,m=document.elementFromPoint(p.clientX,p.clientY);l(),c&&!c.el.contains(m)&&(r("spill"),this.onSpill({dragEl:o,putSortable:i}))}};function _i(){}_i.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.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(),i&&i.animateAll()},drop:Ko};ht(_i,{pluginName:"revertOnSpill"});function Fi(){}Fi.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,o=i||this.sortable;o.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),o.animateAll()},drop:Ko};ht(Fi,{pluginName:"removeOnSpill"});var $=[],rt=[],ie,dt,oe=!1,it=!1,Vt=!1,N,se,Fe;function Xo(){function n(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 n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var i=t.dragEl;N=i},delayEnded:function(){this.isMultiDrag=~$.indexOf(N)},setupClone:function(t){var i=t.sortable,o=t.cancel;if(this.isMultiDrag){for(var s=0;s<$.length;s++)rt.push(Ni($[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);i._hideClone(),o()}},clone:function(t){var i=t.sortable,o=t.rootEl,s=t.dispatchSortableEvent,r=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||$.length&&dt===i&&(Bo(!0,o),s("clone"),r()))},showClone:function(t){var i=t.cloneNowShown,o=t.rootEl,s=t.cancel;this.isMultiDrag&&(Bo(!1,o),rt.forEach(function(r){C(r,"display","")}),i(),Fe=!1,s())},hideClone:function(t){var i=this,o=t.sortable,s=t.cloneNowHidden,r=t.cancel;this.isMultiDrag&&(rt.forEach(function(a){C(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),Fe=!0,r())},dragStartGlobal:function(t){var i=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 i=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&&Mo(r,s)}),it=!0,oe=!0}o.animateAll(function(){it=!1,oe=!1,i.options.animation&&$.forEach(function(r){Ei(r)}),i.options.sort&&qe()})}},dragOver:function(t){var i=t.target,o=t.completed,s=t.cancel;it&&~$.indexOf(i)&&(o(!1),s())},revert:function(t){var i=t.fromSortable,o=t.rootEl,s=t.sortable,r=t.dragRect;$.length>1&&($.forEach(function(a){s.addAnimationState({target:a,rect:it?_(a):r}),Ei(a),a.fromRect=r,i.removeAnimationState(a)}),it=!1,kr(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(t){var i=t.sortable,o=t.isOwner,s=t.insertion,r=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(s){if(o&&r._hideClone(),oe=!1,c.animation&&$.length>1&&(it||!o&&!r.options.sort&&!l)){var p=_(N,!1,!0,!0);$.forEach(function(b){b!==N&&(Mo(b,p),a.appendChild(b))}),it=!0}if(!o)if(it||qe(),$.length>1){var m=Fe;r._showClone(i),r.options.animation&&!Fe&&m&&rt.forEach(function(b){r.addAnimationState({target:b,rect:se}),b.fromRect=se,b.thisAnimationDuration=null})}else r._showClone(i)}},dragOverAnimationCapture:function(t){var i=t.dragRect,o=t.isOwner,s=t.activeSortable;if($.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){se=ht({},i);var r=Rt(N,!0);se.top-=r.f,se.left-=r.e}},dragOverAnimationComplete:function(){it&&(it=!1,qe())},drop:function(t){var i=t.originalEvent,o=t.rootEl,s=t.parentEl,r=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,p=c||this.sortable;if(i){var m=this.options,b=s.children;if(!Vt)if(m.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),K(N,m.selectedClass,!~$.indexOf(N)),~$.indexOf(N))$.splice($.indexOf(N),1),ie=null,re({sortable:r,rootEl:o,name:"deselect",targetEl:N,originalEvent:i});else{if($.push(N),re({sortable:r,rootEl:o,name:"select",targetEl:N,originalEvent:i}),i.shiftKey&&ie&&r.el.contains(ie)){var y=X(ie),u=X(N);~y&&~u&&y!==u&&(function(){var v,T;u>y?(T=y,v=u):(T=u,v=y+1);for(var S=m.filter;T<v;T++)if(!~$.indexOf(b[T])&&ot(b[T],m.draggable,s,!1)){var x=S&&(typeof S=="function"?S.call(r,i,b[T],r):S.split(",").some(function(D){return ot(b[T],D.trim(),s,!1)}));x||(K(b[T],m.selectedClass,!0),$.push(b[T]),re({sortable:r,rootEl:o,name:"select",targetEl:b[T],originalEvent:i}))}})()}else ie=N;dt=p}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(!oe&&m.animation&&(N.thisAnimationDuration=null),p.captureAnimationState(),!oe&&(m.animation&&(N.fromRect=f,$.forEach(function(v){if(v.thisAnimationDuration=null,v!==N){var T=it?_(v):f;v.fromRect=T,p.addAnimationState({target:v,rect:T})}})),qe(),$.forEach(function(v){b[w]?s.insertBefore(v,b[w]):s.appendChild(v),w++}),l===X(N))){var E=!1;$.forEach(function(v){if(v.sortableIndex!==X(v)){E=!0;return}}),E&&(a("update"),a("sort"))}$.forEach(function(v){Ei(v)}),p.animateAll()}dt=p}(o===s||c&&c.lastPutMode!=="clone")&&rt.forEach(function(v){v.parentNode&&v.parentNode.removeChild(v)})}},nullingGlobal:function(){this.isMultiDrag=Vt=!1,rt.length=0},destroyGlobal:function(){this._deselectMultiDrag(),A(document,"pointerup",this._deselectMultiDrag),A(document,"mouseup",this._deselectMultiDrag),A(document,"touchend",this._deselectMultiDrag),A(document,"keydown",this._checkKeyDown),A(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 i=$[0];K(i,this.options.selectedClass,!1),$.shift(),re({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,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(n,{pluginName:"multiDrag",utils:{select:function(t){var i=t.parentNode[Y];!i||!i.options.multiDrag||~$.indexOf(t)||(dt&&dt!==i&&(dt.multiDrag._deselectMultiDrag(),dt=i),K(t,i.options.selectedClass,!0),$.push(t))},deselect:function(t){var i=t.parentNode[Y],o=$.indexOf(t);!i||!i.options.multiDrag||!~o||(K(t,i.options.selectedClass,!1),$.splice(o,1))}},eventProperties:function(){var t=this,i=[],o=[];return $.forEach(function(s){i.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:nr($),clones:[].concat(rt),oldIndicies:i,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 kr(n,e){$.forEach(function(t,i){var o=e.children[t.sortableIndex+(n?Number(i):0)];o?e.insertBefore(t,o):e.appendChild(t)})}function Bo(n,e){rt.forEach(function(t,i){var o=e.children[t.sortableIndex+(n?Number(i):0)];o?e.insertBefore(t,o):e.appendChild(t)})}function qe(){$.forEach(function(n){n!==N&&n.parentNode&&n.parentNode.removeChild(n)})}L.mount(new Sr);L.mount(Fi,_i);var wt=L;var Go={name(n,e){let t=n.getAttribute("data-name").trim().toLowerCase(),i=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(i)},created(n,e){let t=Number(n.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated(n,e){let t=Number(n.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?-1:1},chaptersLast(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?1:-1}},Yo={up:{active(n,e){return!(n.previousElementSibling===null&&!e)},run(n,e){(n.previousElementSibling||e).insertAdjacentElement("beforebegin",n)}},down:{active(n,e){return!(n.nextElementSibling===null&&!e)},run(n,e){(n.nextElementSibling||e).insertAdjacentElement("afterend",n)}},next_book:{active(n,e,t){return t.nextElementSibling!==null},run(n,e,t){t.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,e,t){return t.previousElementSibling!==null},run(n,e,t){t.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,e){return n.dataset.type==="page"&&this.getNextChapter(n,e)},run(n,e){this.getNextChapter(n,e).querySelector("ul").prepend(n)},getNextChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),o=i.indexOf(t);return i.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(n,e){return n.dataset.type==="page"&&this.getPrevChapter(n,e)},run(n,e){this.getPrevChapter(n,e).querySelector("ul").append(n)},getPrevChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),o=i.indexOf(t);return i.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(n,e){return e||e===null&&n.nextElementSibling},run(n,e,t){t.querySelector("ul").append(n)}},book_start:{active(n,e){return e||e===null&&n.previousElementSibling},run(n,e,t){t.querySelector("ul").prepend(n)}},before_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("afterend",n)}}},Ze=class extends h{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,wt.mount(new Xo);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"),i=e.target.closest("[data-id]");this.runSortAction(i,t)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let e="",t=!1,i=["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=Go[a];t&&i.includes(a)&&(l=function(p,m){return 0-Go[a](p,m)});for(let c of r)Array.from(c.children).filter(m=>m.matches("li")).sort(l).forEach(m=>{c.appendChild(m)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let i=`${e.link}/sort-item`;window.$http.get(i).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")),i={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)wt.create(s,{group:s.classList.contains("sort-list")?i: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 i of t){let o=i.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(i.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,i,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:i});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)o.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:i})}runSortAction(e,t){let i=e.parentElement.closest("li[data-id]"),o=e.parentElement.closest('[data-type="book"]');Yo[t].run(e,i,o),this.updateMapInput(),this.updateMoveActionStateForAll(),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus()}updateMoveActionState(e){let t=e.parentElement.closest("li[data-id]"),i=e.parentElement.closest('[data-type="book"]');for(let[o,s]of Object.entries(Yo)){let r=e.querySelector(`[data-move="${o}"]`);r.disabled=!s.active(e,t,i)}}updateMoveActionStateForAll(){let e=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let t of e)this.updateMoveActionState(t)}};var Qe=new WeakMap;function ve(n,e,t=400,i=null){let o=Object.keys(e);for(let r of o)n.style.setProperty(r,e[r][0]);let s=()=>{for(let r of o)n.style.removeProperty(r);n.style.removeProperty("transition"),n.removeEventListener("transitionend",s),Qe.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${t}ms`;for(let r of o)n.style.setProperty(r,e[r][1]);n.addEventListener("transitionend",s),Qe.set(n,s)},15)}function be(n){Qe.has(n)&&Qe.get(n)()}function Jo(n,e=400,t=null){be(n),n.style.display="block",ve(n,{opacity:["0","1"]},e,()=>{t&&t()})}function Zo(n,e=400,t=null){be(n),ve(n,{opacity:["1","0"]},e,()=>{n.style.display="none",t&&t()})}function Gt(n,e=400){be(n);let t=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":[`${t}px`,"0px"],overflow:["hidden","hidden"],"padding-top":[o,"0px"],"padding-bottom":[s,"0px"]};ve(n,r,e,()=>{n.style.display="none"})}function Yt(n,e=400){be(n),n.style.display="block";let t=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":["0px",`${t}px`],overflow:["hidden","hidden"],"padding-top":["0px",o],"padding-bottom":["0px",s]};ve(n,r,e)}function Qo(n,e=400){let t=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom");return()=>{be(n);let r=n.getBoundingClientRect().height,a=getComputedStyle(n),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),p={height:[`${t}px`,`${r}px`],overflow:["hidden","hidden"],"padding-top":[o,l],"padding-bottom":[s,c]};ve(n,p,e)}}var tn=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","false"),Gt(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var en=class extends h{constructor(){super(...arguments);d(this,"editor",null);d(this,"saveCallback",null);d(this,"cancelCallback",null);d(this,"history",{});d(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 i=t.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),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,i)=>{t.preventDefault();let o=i.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 i=t.dataset.lang,o=this.favourites.has(i);t.setAttribute("data-favourite",o?"true":"false"),W(t.parentElement,".lang-option-favorite-toggle","click",()=>{o=!o,o?this.favourites.add(i):this.favourites.delete(i),t.setAttribute("data-favourite",o?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:o}),this.sortLanguageList(),o&&t.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let t=this.languageButtons.sort((i,o)=>{let s=i.dataset.favourite==="true",r=o.dataset.favourite==="true";return s&&!r?-1:r&&!s||i.dataset.lang>o.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of t)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(t,i,o,s,r){this.languageInput.value=i,this.saveCallback=s,this.cancelCallback=r,await this.show(),this.languageInputChange(i),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 i=this.editorInput.parentElement;t?i.setAttribute("dir",t):i.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 i=t.toLowerCase();for(let o of this.languageButtons){let s=o.dataset.lang.toLowerCase().trim(),r=i===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(i=>{let o=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${o}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let t=this.editor.getContent();if(!t)return;let i=Object.keys(this.history).pop();if(this.history[i]===t)return;this.history[String(Date.now())]=t;let o=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,o)}};var nn=class extends h{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(e)})}};var on=class extends h{async setup(){let{mode:e}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var sn=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","false"),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 rn=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 an=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.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 ln=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 cn=class extends h{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,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(),i=0,o=this.toggle.getBoundingClientRect().height,s=xo(this.menu).getBoundingClientRect(),r=t.bottom>s.bottom,a=this.container.getBoundingClientRect();if(this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,r?i=window.innerHeight-t.top-o/2:i=t.top),r){this.menu.style.top="initial",this.menu.style.bottom=`${i}px`;let p=window.innerHeight-40-(window.innerHeight-a.bottom);this.menu.style.maxHeight=`${Math.floor(p)}px`}else{this.menu.style.top=`${i}px`,this.menu.style.bottom="initial";let p=window.innerHeight-40-a.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 l=this.menu.querySelector("input");l!==null&&l.focus(),this.showing=!0;let c=new Event("show");this.container.dispatchEvent(c),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.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let e=new Tt(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),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 dn=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=mt(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 i of t){let o=!e||i.textContent.toLowerCase().includes(e);i.style.display=o?"flex":"none",i.classList.toggle("hidden",!o)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),i=Qo(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,i()}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){d(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 qi(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let e=document.createElement("textarea");e.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),e.value=n,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var hn=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",i=>{i.preventDefault(),e+=1,e===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",t),this.dropTarget.addEventListener("dragleave",()=>{e-=1,e===0&&t()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),t(),!this.isActive)return;let s=new Jt(i.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:i,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){i.setAttribute("data-status","error"),i.textContent=l,ne(t),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,ne(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 i=this,o=window.$http.createXMLHttpRequest("POST",this.url,{error(){e.markError(i.errorMessage)},readystatechange(){this.readyState===XMLHttpRequest.DONE&&this.status===200?e.markSuccess(i.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"}),i=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(),i]),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:i,dismiss:a}}};var un=class extends h{constructor(){super(...arguments);d(this,"container");d(this,"buttons");d(this,"contentElements");d(this,"toggleButton");d(this,"editorWrapEl");d(this,"open",!1);d(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 i=t.target.closest("button");if(i instanceof HTMLButtonElement&&this.buttons.includes(i)){let o=i.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,i=!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");i&&!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 pn=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,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of i)o.disabled=t,o.checked=!1}),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 i=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),o=lt(i.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),{roleId:i}=e.dataset,{roleName:o}=e.dataset,s=document.createElement("option");s.value=i,s.textContent=o,this.roleSelect.append(s),t.remove()}};var mn=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(i=>{this.searchResults.innerHTML=i.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 fn=class extends h{constructor(){super(...arguments);d(this,"elem");d(this,"input");d(this,"searchInput");d(this,"loading");d(this,"resultsContainer");d(this,"searchOptions");d(this,"search","");d(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",i=>{i.keyCode===13&&i.preventDefault()}),W(this.$el,"[data-entity-type]","keydown",(i=>{if(i.ctrlKey&&i.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),i.preventDefault();return}}i.code==="ArrowDown"&&this.focusAdjacent(!0),i.code==="ArrowUp"&&this.focusAdjacent(!1)})),this.searchInput.addEventListener("keydown",i=>{i.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(t=!0){let i=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),o=i.indexOf(document.activeElement),s=i[o+(t?1:-1)]||i[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 i=`${this.searchUrl()}&term=${encodeURIComponent(t)}`;window.$http.get(i).then(o=>{this.resultsContainer.innerHTML=o.data,this.hideLoading()})}isDoubleClick(){let t=Date.now(),i=t-this.lastClick<300;return this.lastClick=t,i}onClick(t){let i=t.target.closest("[data-entity-type]");i instanceof HTMLElement&&(t.preventDefault(),t.stopPropagation(),this.selectItem(i))}selectItem(t){let i=this.isDoubleClick(),o=t.getAttribute("data-entity-type"),s=t.getAttribute("data-entity-id"),r=!t.classList.contains("selected")||i;this.unselectAll(),this.input.value=r?`${o}:${s}`:"";let a=t.getAttribute("href")||"",l=t.querySelector(".entity-list-item-name")?.textContent||"",c={id:Number(s),name:l,link:a};r?t.classList.add("selected"):window.$events.emit("entity-select-change"),!(!i&&!r)&&(i&&this.confirmSelection(c),r&&window.$events.emit("entity-select-change",c))}confirmSelection(t){window.$events.emit("entity-select-confirm",t)}unselectAll(){let t=this.elem.querySelectorAll(".selected");for(let i of t)i.classList.remove("selected","primary-background")}};var gn=class extends h{constructor(){super(...arguments);d(this,"container");d(this,"selectButton");d(this,"selectorEl");d(this,"callback",null);d(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,i={}){this.callback=t,this.getSelector().configureSearchOptions(i),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 vn=class extends h{setup(){this.container=this.$el,this.name=this.$opts.name,H(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var bn=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 i of t)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var wn=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=mt(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 Tt(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let i=lt(t);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(i),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 yn=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 En=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.loadMore,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,i=>{this.resetAll(),this.filter=i.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",i=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),i.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",i=>{i.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(i,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",i=>{if(!(Math.ceil(e.scrollHeight-e.scrollTop)===e.clientHeight)||i.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 i=t!=="gallery";this.dropzoneContainer.classList.toggle("hidden",i),this.uploadButton.classList.toggle("hidden",i),this.uploadHint.classList.toggle("hidden",i),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!i),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),ne(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e;let i=t.querySelector(".load-more");i&&(i.remove(),this.loadMore.innerHTML=i.innerHTML),this.loadMore.toggleAttribute("hidden",!i),window.$components.init(t);for(let o of[...t.children])this.listContainer.appendChild(o)}setActiveFilterTab(e){for(let t of this.filterTabs){let i=t.dataset.filter===e;t.setAttribute("aria-selected",i?"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),i=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&&!i?(e.target.classList.add("selected"),t=await this.loadImageEditForm(t.id)):i?i&&(t=this.lastSelected):this.resetEditForm(),this.selectButton.classList.toggle("hidden",o),i&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let i=t?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${e}`,i);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 Cn=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")}};var xn=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(n,e={},t=[]){let i=document.createElement(n),o=Object.keys(e);for(let s of o)e[s]!==null&&i.setAttribute(s,e[s]);for(let s of t)typeof s=="string"?i.append(document.createTextNode(s)):i.append(s);return i}var Tn=class extends h{constructor(){super(...arguments);d(this,"button");d(this,"loadingEl",null)}setup(){this.button=this.$el;let t=this.button.form,i=()=>{setTimeout(()=>this.showLoadingState(),10)};this.button.addEventListener("click",i),t&&t.addEventListener("submit",i)}showLoadingState(){this.button.disabled=!0,this.loadingEl||(this.loadingEl=Z("div",{class:"inline block"}),It(this.loadingEl),this.button.after(this.loadingEl))}};var Ln=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(i=>i.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(i=>{this.editor=i,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 i=t.getAttribute("data-action");if(i==="insertImage"&&this.editor.actions.showImageInsert(),i==="insertLink"&&this.editor.actions.showLinkSelector(),i==="insertDrawing"&&(e.ctrlKey||e.metaKey)){this.editor.actions.showImageManager();return}i==="insertDrawing"&&this.editor.actions.startDrawing(),i==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",e=>{let t=e.target.closest(".editor-toolbar-label");if(!t)return;let i=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of i)o.classList.remove("active");t.closest(".markdown-editor-wrap").classList.add("active")}),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",()=>{let t=this.elem.getBoundingClientRect(),i=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",i),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",i),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 Sn=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 i of t)i.disabled=e;this.inputContainer.style.display=e?"none":"block"}};var kn=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,i=Math.max(2e3,1e3+250*t);setTimeout(this.hide.bind(this),i)}}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 $n=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 Mn=class extends h{constructor(){super(...arguments);d(this,"commentId");d(this,"commentLocalId");d(this,"deletedText");d(this,"updatedText");d(this,"archiveText");d(this,"wysiwygEditor",null);d(this,"wysiwygTextDirection");d(this,"container");d(this,"contentContainer");d(this,"form");d(this,"formCancel");d(this,"editButton");d(this,"deleteButton");d(this,"replyButton");d(this,"archiveButton");d(this,"input")}setup(){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"),i=this.input.value,o=Z("div",{class:"comment-editor-container"});this.input.parentElement?.appendChild(o),this.input.hidden=!0,this.wysiwygEditor=t.createCommentEditorInstance(o,i,{darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:window.editor_translations}),this.wysiwygEditor.focus()}async update(t){t.preventDefault();let i=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 Dt&&window.$events.showValidationErrors(s),this.form.toggleAttribute("hidden",!1),i.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 i=window.$components.allWithinElement(t,"page-comment-reference");for(let o of i)o.hideMarker();t.remove()}window.$events.success(this.deletedText)}async archive(){this.showLoading();let i=this.archiveButton.dataset.isArchived==="true"?"unarchive":"archive",o=await window.$http.put(`/comment/${this.commentId}/${i}`);window.$events.success(this.archiveText);let s={new_thread_dom:lt(o.data)};this.$emit(i,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 ts='<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 es='<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 Zt=null,Dn=class extends h{constructor(){super(...arguments);d(this,"link");d(this,"reference");d(this,"markerWrap",null);d(this,"viewCommentText");d(this,"jumpToThreadText");d(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 i=t.detail.tab,o=t.detail.open;i==="comments"&&o&&this.link.checkVisibility()?this.showForEditor():this.hideMarker()})),window.addEventListener("toggle",t=>{t.target instanceof HTMLElement&&t.target.contains(this.link)&&window.requestAnimationFrame(()=>{this.link.checkVisibility()?this.showForEditor():this.hideMarker()})},{capture:!0}),window.addEventListener("tabs-change",(t=>{let i=t.detail.showing;if(!i.startsWith("comment-tab-panel"))return;document.getElementById(i)?.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 i=()=>{this.hideMarker(),setTimeout(()=>{window.$events.remove("editor-html-change",i)},1)};window.$events.listen("editor-html-change",i)}updateMarker(t){this.link.classList.remove("outdated","missing"),this.markerWrap&&this.markerWrap.remove();let[i,o,s]=this.reference.split(":"),r=document.getElementById(i);if(!r){this.link.classList.add("outdated","missing");return}Se(r)!==o&&this.link.classList.add("outdated");let l=Z("button",{type:"button",class:"content-comment-marker",title:this.viewCommentText});l.innerHTML=ts,l.addEventListener("click",p=>{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",p=>{p.preventDefault(),At(r)});let c=mt(()=>{this.positionMarker(r,s)},50,!1).bind(this);window.addEventListener("resize",c)}positionMarker(t,i){if(!this.markerWrap)return;let o=this.markerWrap.parentElement,s=o.getBoundingClientRect(),r=t.getBoundingClientRect(),[a,l]=i.split("-");if(a&&l){let m=new Range,b=Le(t,Number(a)),y=Le(t,Number(l));b&&y&&(m.setStart(b.node,b.offset),m.setEnd(y.node,y.offset),r=m.getBoundingClientRect())}let c=r.left-s.left,p=r.top-s.top+o.scrollTop;this.markerWrap.style.left=`${c}px`,this.markerWrap.style.top=`${p}px`,this.markerWrap.style.width=`${r.width}px`,this.markerWrap.style.height=`${r.height}px`}hideMarker(){Zt&&Zt(),this.markerWrap?.remove(),this.markerWrap=null}showCommentAtMarker(t){Zt&&Zt(),t.hidden=!0;let i=this.link.closest(".comment-box"),o=i.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=es;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 c=()=>{l.remove(),t.hidden=!1,window.removeEventListener("click",p),Zt=null},p=y=>{t.parentElement.contains(y.target)||c()};window.addEventListener("click",p),Zt=c,r.addEventListener("click",c.bind(this)),a.addEventListener("click",()=>{c(),i.scrollIntoView({behavior:"smooth"});let y=i.querySelector(".header");y.classList.add("anim-highlight"),y.addEventListener("animationend",()=>y.classList.remove("anim-highlight"))});let m=l.getBoundingClientRect(),b=document.querySelector(".page-content")?.getBoundingClientRect();if(b&&m.right>b.right){let y=m.right-b.right;l.style.left=`-${y}px`}}};var Qt=class extends h{constructor(){super(...arguments);d(this,"container");d(this,"tabList");d(this,"tabs");d(this,"panels");d(this,"activeUnder");d(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 i=t.target.closest('[role="tab"]');i instanceof HTMLElement&&this.tabs.includes(i)&&this.show(i.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 i={showing:t};this.$emit("change",i)}updateActiveState(){let t=window.innerWidth<this.activeUnder;t!==this.active&&(t?this.activate():this.deactivate(),this.active=t)}activate(){let t=this.panels.find(i=>!i.hasAttribute("hidden"))||this.panels[0];this.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 An=class extends h{constructor(){super(...arguments);d(this,"elem");d(this,"pageId");d(this,"container");d(this,"commentCountBar");d(this,"activeTab");d(this,"archivedTab");d(this,"addButtonContainer");d(this,"archiveContainer");d(this,"activeContainer");d(this,"replyToRow");d(this,"referenceRow");d(this,"formContainer");d(this,"form");d(this,"formInput");d(this,"formReplyLink");d(this,"formReferenceLink");d(this,"addCommentButton");d(this,"hideFormButton");d(this,"removeReplyToButton");d(this,"removeReferenceButton");d(this,"wysiwygTextDirection");d(this,"wysiwygEditor",null);d(this,"createdText");d(this,"countText");d(this,"archivedCountText");d(this,"parentId",null);d(this,"contentReference","");d(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 i=Wt();i.classList.add("px-l"),this.form.after(i),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),i.remove()}updateCount(){let t=this.getActiveThreadCount();this.activeTab.textContent=window.$trans.choice(this.countText,t);let i=this.getArchivedThreadCount();this.archivedTab.textContent=window.$trans.choice(this.archivedCountText,i)}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 Qt&&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"),i=Z("div",{class:"comment-editor-container"});this.formInput.parentElement?.appendChild(i),this.formInput.hidden=!0,this.wysiwygEditor=t.createCommentEditorInstance(i,"<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,i){i.closest(".comment-branch").querySelector(".comment-branch-children").append(this.formContainer),this.showForm(),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[i]=t.split(":");this.formReferenceLink.href=`#${i}`,this.formReferenceLink.onclick=function(o){o.preventDefault();let s=document.getElementById(i);s&&At(s)}}};function Dr(n,e){mi(`#page-navigation a[href="#${n}"]`,t=>{t.closest("li").classList.toggle("current-heading",e)})}function Ar(n){for(let e of n){let t=e.intersectionRatio===1;Dr(e.target.id,t)}}function Ir(n){let e={rootMargin:"0px 0px 0px 0px",threshold:1},t=new IntersectionObserver(Ar,e);for(let i of n)t.observe(i)}var In=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)}let e=document.querySelector(".sidebar-page-nav");e&&W(e,"a","click",(t,i)=>{t.preventDefault(),window.$components.first("tri-layout").showContent();let o=i.getAttribute("href").substr(1);this.goToText(o),window.history.pushState(null,null,`#${o}`)})}goToText(e){let t=document.getElementById(e);if(mi(".page-content [data-highlighted]",i=>{i.removeAttribute("data-highlighted"),i.style.backgroundColor=null}),t!==null)At(t);else{let i=Co(".page-content > div > *",e);i&&At(i)}}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&&Ir(t)}};function ns(n){let e=new Date(n*1e3),t=e.getHours(),i=e.getMinutes();return`${(t>9?"":"0")+t}:${(i>9?"":"0")+i}`}var Hn=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=mt(this.updateChangelogDisplay.bind(this),300,!1);this.changelogInput.addEventListener("input",()=>{let i=this.changelogInput.value.length;this.changelogCounter.innerText=`${i} / 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 i=!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} ${ns(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)),i=!0,this.autoSave.pendingChange=!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 i}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(i){console.error(i);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 i=this.discardDraft(!1),o=window.$http.delete(`/page-revisions/user-drafts/${this.pageId}`);await Promise.all([i,o]),window.$events.success(this.draftDeleteText),this.deleteDraftWrap.toggleAttribute("hidden",!0)}catch(i){console.error(i),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,i=window.$components.firstOnElement(this.switchDialogContainer,"confirm-dialog"),[o,s]=await Promise.all([this.saveDraft(),i.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 Bn(n,e){n.toggleAttribute("hidden",!e)}var Pn=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"})}setValue(e,t){this.value=e,this.input.value=e,this.controlView(t)}controlView(e){let t=this.value&&this.value!==0;if(Bn(this.resetButton,t),Bn(this.buttonSep,t),Bn(this.defaultDisplay,!t),Bn(this.display,t),t){let i=this.getAssetIdFromVal();this.display.textContent=`#${i}, ${e}`,this.display.href=window.baseUrl(`/link/${i}`)}}getAssetIdFromVal(){return Number(this.value)}};var Rn=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),i=Array.from(t.parentElement.children).indexOf(t),o=this.container.querySelectorAll(this.rowSelector),s=[];for(let r of o){let a=r.children[i];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 i of e)i.checked=!t,i.dispatchEvent(new Event("change"))}};var On=class extends h{constructor(){super(...arguments);d(this,"showing",!1);d(this,"isMakingSelection",!1);d(this,"targetElement",null);d(this,"targetSelectionRange",null);d(this,"pointer");d(this,"linkInput");d(this,"linkButton");d(this,"includeInput");d(this,"includeButton");d(this,"sectionModeButton");d(this,"commentButton");d(this,"modeToggles");d(this,"modeSections");d(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",()=>qi(this.includeInput.value)),this.linkButton.addEventListener("click",()=>qi(this.linkInput.value)),H([this.includeInput,this.linkInput],i=>{i.target.select(),i.stopPropagation()}),Te(this.pointer,["click","focus"],i=>{i.stopPropagation()}),Te(document.body,["click","focus"],()=>{!this.showing||this.isMakingSelection||this.hidePointer()}),Eo(this.pointer,this.hidePointer.bind(this));let t=document.querySelector(".page-content");Te(t,["mouseup","keyup"],i=>{i.stopPropagation();let o=i.target.closest('[id^="bkmrk"]');if(o instanceof HTMLElement&&(window.getSelection()||"").toString().length>0){let s=i instanceof MouseEvent?i.pageX:0;this.showPointerAtTarget(o,s,!1)}}),H(this.sectionModeButton,this.enterSectionSelectMode.bind(this)),H(this.modeToggles,i=>{let o=i.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,i,o){this.targetElement=t,this.targetSelectionRange=window.getSelection()?.getRangeAt(0)||null,this.updateDomForTarget(t),this.pointer.style.display="block";let s=t.getBoundingClientRect(),r=this.pointer.getBoundingClientRect(),l=Math.min(Math.max(i,s.left),s.right)-r.width/2,c=s.top-r.height-16;this.pointer.style.left=`${l}px`,this.pointer.style.top=`${c}px`,this.showing=!0,this.isMakingSelection=!0,setTimeout(()=>{this.isMakingSelection=!1},100);let p=()=>{this.hidePointer(),window.removeEventListener("scroll",p)};t.parentElement?.insertBefore(this.pointer,t),o||window.addEventListener("scroll",p,{passive:!0})}updateDomForTarget(t){let i=window.baseUrl(`/link/${this.pageId}#${t.id}`),o=`{{@${this.pageId}#${t.id}}}`;this.linkInput.value=i,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 i of t)i.setAttribute("tabindex","0");t[0].focus(),qt(t,i=>{this.showPointerAtTarget(i.target,0,!0),this.pointer.focus()})}createCommentAtPointer(){if(!this.targetElement)return;let t=this.targetElement.id,i=Se(this.targetElement),o="";if(this.targetSelectionRange){let a=this.targetSelectionRange.commonAncestorContainer;if(this.targetElement.contains(a)){let l=fi(this.targetSelectionRange.startContainer,this.targetSelectionRange.startOffset,this.targetElement),c=fi(this.targetSelectionRange.endContainer,this.targetSelectionRange.endOffset,this.targetElement);o=`${l}-${c}`}}let s=`${t}:${i}:${o}`;window.$components.first("page-comments").startNewComment(s)}};var Nn=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){Zo(this.container,120,e),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(e=null,t=null){Jo(this.container,120,e),this.onkeyup=i=>{i.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=t}};var _n=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 i of t){let o=i.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,i.value)}}updateLightForInput(e){let t=e.name.replace("-color","-color-light"),i=e.value,o=this.hexToRgb(i),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 Fn=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 qn=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"}};function Wn(n,e){return{move_up(t){let i=t.parentNode,o=Array.from(i.children).indexOf(t),s=Math.max(o-1,0);i.insertBefore(t,i.children[s]||null)},move_down(t){let i=t.parentNode,o=Array.from(i.children).indexOf(t),s=Math.min(o+2,i.children.length);i.insertBefore(t,i.children[s]||null)},remove(t){n.appendChild(t)},add(t){e.appendChild(t)}}}function jn(n,e){return t=>{let i=t.target.closest(".scroll-box-item button[data-action]");if(i){let o=i.closest(".scroll-box-item"),s=i.dataset.action;if(!s)throw new Error("No action defined for clicked button");let r=n[s];r(o),e()}}}var Un=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");for(let t of e)new wt(t,{group:"shelf-books",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){let e=Wn(this.allBookList,this.shelfBookList),t=jn(e,this.onChange.bind(this));this.elem.addEventListener("click",t),this.bookSearchInput.addEventListener("input",()=>{this.filterBooksByName(this.bookSearchInput.value)}),this.sortButtonContainer.addEventListener("click",i=>{let o=i.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,i=e.trim().toLowerCase();for(let o of t){let s=!e||o.textContent.toLowerCase().includes(i);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),i=e===this.lastSort;t.sort((o,s)=>{let r=o.dataset[e].toLowerCase(),a=s.dataset[e].toLowerCase();return i?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 Hr(n){let e={};for(let[t,i]of Object.entries(n))e[i]=t;return e}var Vn=class extends h{setup(){this.container=this.$el,this.mapById=JSON.parse(this.$opts.keyMap),this.mapByShortcut=Hr(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 i=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key].filter(s=>!!s).join(" + "),o=this.mapByShortcut[i];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]"),i=new Set;for(let s of t){let r=s.getAttribute("data-shortcut");if(i.has(r))continue;let a=this.mapById[r];this.showHintLabel(s,a,e),i.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,i){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`,i.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"],zn=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(i=>!!i).join(" + ")}stopListeningForInput(){this.input.removeEventListener("keydown",this.listenerRecordKey)}};var Kn=class extends h{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let e=new wt(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:e.toArray()})},setData(t,i){let o=i.getAttribute("data-drag-content");if(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 Xn=class extends h{constructor(){super(...arguments);d(this,"input");d(this,"configuredList");d(this,"availableList")}setup(){this.input=this.$refs.input,this.configuredList=this.$refs.configuredOperationsList,this.availableList=this.$refs.availableOperationsList,this.initSortable();let t=Wn(this.availableList,this.configuredList),i=jn(t,this.onChange.bind(this));this.$el.addEventListener("click",i)}initSortable(){let t=[this.configuredList,this.availableList];for(let i of t)new wt(i,{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(i=>i.getAttribute("data-id")).join(",")}};var Gn=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 Yn=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(i=>[...i.querySelectorAll("input")].filter(o=>o.value).length===0)!==void 0}};var Jn=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 i=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(i,"replace")}handleTemplateItemDragStart(e,t){let i=t.closest("[template-id]").getAttribute("template-id");e.dataTransfer.setData("bookstack/template",i),e.dataTransfer.setData("text/plain",i)}handleTemplateActionClick(e,t){e.stopPropagation();let i=t.getAttribute("template-action"),o=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(o,i)}async insertTemplate(e,t="replace"){let i=await window.$http.get(`/templates/${e}`),o=`editor::${t}`;window.$events.emit(o,i.data)}async handlePaginationClick(e,t){e.preventDefault();let i=t.getAttribute("href"),o=await window.$http.get(i);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 Zn=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 Pr(n,e){return document.createElement(n,e)}function Rr(n,e,t){return document.createElementNS(n,e,t)}function Or(){return Ot(document.createDocumentFragment())}function Nr(n){return document.createTextNode(n)}function _r(n){return document.createComment(n)}function Fr(n,e,t){if(yt(n)){let i=n;for(;i&&yt(i);)i=Ot(i).parent;n=i??n}yt(e)&&(e=Ot(e,n)),t&&yt(t)&&(t=Ot(t).firstChildNode),n.insertBefore(e,t)}function qr(n,e){n.removeChild(e)}function Wr(n,e){yt(e)&&(e=Ot(e,n)),n.appendChild(e)}function is(n){if(yt(n)){for(;n&&yt(n);)n=Ot(n).parent;return n??null}return n.parentNode}function jr(n){var e;if(yt(n)){let t=Ot(n),i=is(t);if(i&&t.lastChildNode){let o=Array.from(i.childNodes),s=o.indexOf(t.lastChildNode);return(e=o[s+1])!==null&&e!==void 0?e:null}return null}return n.nextSibling}function Ur(n){return n.tagName}function Vr(n,e){n.textContent=e}function zr(n){return n.textContent}function Kr(n){return n.nodeType===1}function Xr(n){return n.nodeType===3}function Gr(n){return n.nodeType===8}function yt(n){return n.nodeType===11}function Ot(n,e){var t,i,o;let s=n;return(t=s.parent)!==null&&t!==void 0||(s.parent=e??null),(i=s.firstChildNode)!==null&&i!==void 0||(s.firstChildNode=n.firstChild),(o=s.lastChildNode)!==null&&o!==void 0||(s.lastChildNode=n.lastChild),s}var Qn={createElement:Pr,createElementNS:Rr,createTextNode:Nr,createDocumentFragment:Or,createComment:_r,insertBefore:Fr,removeChild:qr,appendChild:Wr,parentNode:is,nextSibling:jr,tagName:Ur,setTextContent:Vr,getTextContent:zr,isElement:Kr,isText:Xr,isComment:Gr,isDocumentFragment:yt};function Et(n,e,t,i,o){let s=e===void 0?void 0:e.key;return{sel:n,data:e,children:t,text:i,elm:o,key:s}}var Wi=Array.isArray;function os(n){return typeof n=="string"||typeof n=="number"||n instanceof String||n instanceof Number}var ji=Et("",{},[],void 0,void 0);function we(n,e){var t,i;let o=n.key===e.key,s=((t=n.data)===null||t===void 0?void 0:t.is)===((i=e.data)===null||i===void 0?void 0:i.is),r=n.sel===e.sel,a=!n.sel&&n.sel===e.sel?typeof n.text==typeof e.text:!0;return r&&o&&s&&a}function Jr(){throw new Error("The document fragment is not supported on this platform.")}function Zr(n,e){return n.isElement(e)}function Qr(n,e){return n.isDocumentFragment(e)}function ta(n,e,t){var i;let o={};for(let s=e;s<=t;++s){let r=(i=n[s])===null||i===void 0?void 0:i.key;r!==void 0&&(o[r]=s)}return o}var ea=["create","update","remove","destroy","pre","post"];function Ui(n,e,t){let i={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:Qn;for(let u of ea)for(let f of n){let w=f[u];w!==void 0&&i[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,v,T,S;let x,D=u.data,P=D?.hook;(w=P?.init)===null||w===void 0||w.call(P,u);let B=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,pt=O!==-1||R!==-1?k.slice(0,Math.min(U,V)):k,Ct=D?.ns,et=Ct===void 0?o.createElement(pt,D):o.createElementNS(Ct,pt,D);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<i.create.length;++x)i.create[x](ji,u);if(os(u.text)&&(!Wi(B)||B.length===0)&&o.appendChild(et,o.createTextNode(u.text)),Wi(B))for(x=0;x<B.length;++x){let Mt=B[x];Mt!=null&&o.appendChild(et,l(Mt,f))}P!==void 0&&((v=P.create)===null||v===void 0||v.call(P,ji,u),P.insert!==void 0&&f.push(u))}else if(!((T=t?.experimental)===null||T===void 0)&&T.fragments&&u.children){for(u.elm=((S=o.createDocumentFragment)!==null&&S!==void 0?S:Jr)(),x=0;x<i.create.length;++x)i.create[x](ji,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 c(u,f,w,E,v,T){for(;E<=v;++E){let S=w[E];S!=null&&o.insertBefore(u,l(S,T),f)}}function p(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 v=0;v<i.destroy.length;++v)i.destroy[v](u);if(u.children!==void 0)for(let v=0;v<u.children.length;++v){let T=u.children[v];T!=null&&typeof T!="string"&&p(T)}}}function m(u,f,w,E){for(var v,T;w<=E;++w){let S,x=f[w];if(x!=null)if(x.sel!==void 0){p(x),S=i.remove.length+1;let D=a(x.elm,S);for(let B=0;B<i.remove.length;++B)i.remove[B](x,D);let P=(T=(v=x?.data)===null||v===void 0?void 0:v.hook)===null||T===void 0?void 0:T.remove;P!==void 0?P(x,D):D()}else x.children?(p(x),m(u,x.children,0,x.children.length-1)):o.removeChild(u,x.elm)}}function b(u,f,w,E){let v=0,T=0,S=f.length-1,x=f[0],D=f[S],P=w.length-1,B=w[0],k=w[P],O,R,U,V;for(;v<=S&&T<=P;)x==null?x=f[++v]:D==null?D=f[--S]:B==null?B=w[++T]:k==null?k=w[--P]:we(x,B)?(y(x,B,E),x=f[++v],B=w[++T]):we(D,k)?(y(D,k,E),D=f[--S],k=w[--P]):we(x,k)?(y(x,k,E),o.insertBefore(u,x.elm,o.nextSibling(D.elm)),x=f[++v],k=w[--P]):we(D,B)?(y(D,B,E),o.insertBefore(u,D.elm,x.elm),D=f[--S],B=w[++T]):(O===void 0&&(O=ta(f,v,S)),R=O[B.key],R===void 0?(o.insertBefore(u,l(B,E),x.elm),B=w[++T]):O[k.key]===void 0?(o.insertBefore(u,l(k,E),o.nextSibling(D.elm)),k=w[--P]):(U=f[R],U.sel!==B.sel?o.insertBefore(u,l(B,E),x.elm):(y(U,B,E),f[R]=void 0,o.insertBefore(u,U.elm,x.elm)),B=w[++T]));T<=P&&(V=w[P+1]==null?null:w[P+1].elm,c(u,V,w,T,P,E)),v<=S&&m(u,f,v,S)}function y(u,f,w){var E,v,T,S,x,D,P,B;let k=(E=f.data)===null||E===void 0?void 0:E.hook;(v=k?.prepatch)===null||v===void 0||v.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){(T=f.data)!==null&&T!==void 0||(f.data={}),(S=u.data)!==null&&S!==void 0||(u.data={});for(let V=0;V<i.update.length;++V)i.update[V](u,f);(P=(D=(x=f.data)===null||x===void 0?void 0:x.hook)===null||D===void 0?void 0:D.update)===null||P===void 0||P.call(D,u,f)}let R=u.children,U=f.children;f.text===void 0?R!==void 0&&U!==void 0?R!==U&&b(O,R,U,w):U!==void 0?(u.text!==void 0&&o.setTextContent(O,""),c(O,null,U,0,U.length-1,w)):R!==void 0?m(O,R,0,R.length-1):u.text!==void 0&&o.setTextContent(O,""):u.text!==f.text&&(R!==void 0&&m(O,R,0,R.length-1),o.setTextContent(O,f.text)),(B=k?.postpatch)===null||B===void 0||B.call(k,u,f)}return function(f,w){let E,v,T,S=[];for(E=0;E<i.pre.length;++E)i.pre[E]();for(Zr(o,f)?f=s(f):Qr(o,f)&&(f=r(f)),we(f,w)?y(f,w,S):(v=f.elm,T=o.parentNode(v),l(w,S),T!==null&&(o.insertBefore(T,w.elm,o.nextSibling(v)),m(T,[f],0,0))),E=0;E<S.length;++E)S[E].data.hook.insert(S[E]);for(E=0;E<i.post.length;++E)i.post[E]();return w}}function Vi(n,e,t){if(n.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let i=0;i<e.length;++i){let o=e[i];if(typeof o=="string")continue;let s=o.data;s!==void 0&&Vi(s,o.children,o.sel)}}function na(n){return n.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function ye(n,e){var t;let i=e!==void 0?e:Qn,o;if(i.isElement(n)){let s=n.id?"#"+n.id:"",r=(t=n.getAttribute("class"))===null||t===void 0?void 0:t.match(/[^\t\r\n\f ]+/g),a=r?"."+r.join("."):"",l=i.tagName(n).toLowerCase()+s+a,c={},p={},m={},b=[],y,u,f,w=n.attributes,E=n.childNodes;for(u=0,f=w.length;u<f;u++)y=w[u].nodeName,y.startsWith("data-")?p[na(y)]=w[u].nodeValue||"":y!=="id"&&y!=="class"&&(c[y]=w[u].nodeValue);for(u=0,f=E.length;u<f;u++)b.push(ye(E[u],e));return Object.keys(c).length>0&&(m.attrs=c),Object.keys(p).length>0&&(m.dataset=p),l.startsWith("svg")&&(l.length===3||l[3]==="."||l[3]==="#")&&Vi(m,b,l),Et(l,m,b,void 0,n)}else return i.isText(n)?(o=i.getTextContent(n),Et(void 0,void 0,void 0,o,n)):i.isComment(n)?(o=i.getTextContent(n),Et("!",{},[],o,n)):Et("",{},[],void 0,n)}var ia="http://www.w3.org/1999/xlink",oa="http://www.w3.org/2000/xmlns/",sa="http://www.w3.org/XML/1998/namespace";function ss(n,e){let t,i=e.elm,o=n.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?i.setAttribute(t,""):r===!1?i.removeAttribute(t):t.charCodeAt(0)!==120?i.setAttribute(t,r):t.charCodeAt(3)===58?i.setAttributeNS(sa,t,r):t.charCodeAt(5)===58?t.charCodeAt(1)===109?i.setAttributeNS(oa,t,r):i.setAttributeNS(ia,t,r):i.setAttribute(t,r))}for(t in o)t in s||i.removeAttribute(t)}}var zi={create:ss,update:ss};var rs=/[A-Z]/g;function as(n,e){let t=e.elm,i=n.data.dataset,o=e.data.dataset,s;if(!i&&!o||i===o)return;i=i||{},o=o||{};let r=t.dataset;for(s in i)s in o||(r?s in r&&delete r[s]:t.removeAttribute("data-"+s.replace(rs,"-$&").toLowerCase()));for(s in o)i[s]!==o[s]&&(r?r[s]=o[s]:t.setAttribute("data-"+s.replace(rs,"-$&").toLowerCase(),o[s]))}var Ki={create:as,update:as};var ti;function ra(){return ti||(ti=Ui([zi,Ki]),ti)}function ls(n,e){ra()(ye(n),ye(e))}var ei=class extends h{constructor(){super(...arguments);d(this,"container");d(this,"noneEl");d(this,"display");d(this,"isActive",!1)}setup(){this.container=this.$el,this.noneEl=this.$refs.none,this.display=this.$refs.display,window.addEventListener("editor-toolbox-change",(i=>{let o=i.detail.tab,s=i.detail.open;o==="contents"&&s?(this.isActive!==!0&&this.render(),this.isActive=!0):this.isActive=!1}));let t=mt(this.onContentChange.bind(this),500,!1);window.$events.listen("editor-html-change",t),window.$events.listen("editor-markdown-change",t),this.container.addEventListener("click",i=>{let o=i.target.closest("li[data-index]");o instanceof HTMLElement&&(i.preventDefault(),this.onHeaderSelect(o))})}onHeaderSelect(t){let i=t.getAttribute("data-id")||"",o=Number(t.getAttribute("data-index")||"");window.$events.emit("editor::focus-heading",{index:o,id:i})}onContentChange(){this.isActive&&this.render()}async render(){let t=await this.getEditorHtml(),i=this.parseHeadersFromHtml(t);this.rebaseHeaders(i);let o=this.headersToDom(i),s=this.display.firstElementChild;s||(s=document.createElement("ul"),this.display.appendChild(s)),ls(s,o),this.noneEl.hidden=i.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],c=Number(l.tagName.replace("H",""));r.push({text:l.textContent,level:c,id:l.id||"",index:a})}return r}rebaseHeaders(t){if(t.length!==0)do{var i=Math.min(...t.map(o=>o.level));if(i>1)for(let o of t)o.level--}while(i>1)}headersToDom(t){let i=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"},i)}};var ni=class extends h{constructor(){super(...arguments);d(this,"container");d(this,"tabs");d(this,"sidebarScrollContainers");d(this,"lastLayoutType","none");d(this,"onDestroy",null);d(this,"scrollCache",{content:0,info:0});d(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 i=t.target.dataset.tab||"";this.showTab(i)}showContent(){this.showTab("content",!1)}showTab(t,i=!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),i){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)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 i=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&&i),t.parentElement.classList.toggle("scroll-away-from-bottom",!s&&i))}};var ii=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 oi=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 si=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(i=>{let o=this.input.value;this.editor=i.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",i=>{this.editor&&(t?t=!1:(i.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 cs(n){for(let e=1;e<5;e++)n.shortcuts.add(`meta+${e}`,"",["FormatBlock",!1,`h${e+1}`]);n.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+o","","InsertOrderedList"),n.shortcuts.add("meta+p","","InsertUnorderedList"),n.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),n.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),n.shortcuts.add("meta+9","",()=>{let e=n.selection.getNode(),t=e?e.closest(".callout"):null,i=["info","success","warning","danger"],s=(i.findIndex(a=>t&&t.classList.contains(a))+1)%i.length,r=i[s];n.formatter.apply(`callout${r}`)}),n.shortcuts.add("meta+shift+K","",()=>{let e=window.$components.first("entity-selector-popup"),t=n.selection.getContent({format:"text"}).trim();e.show(i=>{n.selection.isCollapsed()?n.insertContent(n.dom.createHTML("a",{href:i.link},n.dom.encode(i.name))):n.formatter.apply("link",{href:i.link}),n.selection.collapse(!1),n.focus()},{initialValue:t,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})})}function aa(n,e){let t=n.dom.get(encodeURIComponent(e).replace(/!/g,"%21"));t&&(t.scrollIntoView(),n.selection.select(t,!0),n.selection.collapse(!1),n.focus())}function ds(n,e){let i=n.dom.select("h1, h2, h3, h4, h5, h6")[e];i&&(i.scrollIntoView(),n.selection.select(i,!0),n.selection.collapse(!1),n.focus())}function hs(n){let t=new URL(window.location).searchParams.get("content-id");t&&aa(n,t)}function us(n){window.$events.listen("editor::replace",({html:e})=>{n.setContent(e)}),window.$events.listen("editor::append",({html:e})=>{let t=n.getContent()+e;n.setContent(t)}),window.$events.listen("editor::prepend",({html:e})=>{let t=e+n.getContent();n.setContent(t)}),window.$events.listen("editor::insert",({html:e})=>{n.insertContent(e)}),window.$events.listen("editor::focus",()=>{n.initialized&&n.focus()}),window.$events.listen("editor::focus-heading",({index:e})=>{ds(n,e)})}var Nt,ri;function la(n){return n&&!!(n.textContent||n.innerText)}async function ca(n,e){if(n===null||n.type.indexOf("image")!==0)throw new Error("Not an image file");let t=n.name||`image-${Date.now()}.png`,i=new FormData;return i.append("file",n,t),i.append("uploaded_to",e),(await window.$http.post(window.baseUrl("/images/gallery"),i)).data}function ps(n,e,t){let i=new Jt(t.clipboardData||t.dataTransfer);if(!i.hasItems()||i.containsTabularData())return;let o=i.getImages();for(let s of o){let r=`image-${Math.random().toString(16).slice(2)}`,a=window.baseUrl("/loading.gif");t.preventDefault(),setTimeout(()=>{n.insertContent(`<p><img src="${a}" id="${r}"></p>`),ca(s,e.pageId).then(l=>{let c=l.name.replace(/"/g,""),p=`<img src="${l.thumbs.display}" alt="${c}" />`,m=n.dom.create("a",{target:"_blank",href:l.url},p);n.dom.replace(m,r)}).catch(l=>{n.dom.remove(r),window.$events.error(l?.data?.message||e.translations.imageUploadErrorText),console.error(l)})},10)}}function da(n){let e=n.selection.getNode();e.nodeName==="IMG"&&(Nt=n.dom.getParent(e,".mceTemp"),!Nt&&e.parentNode.nodeName==="A"&&!la(e.parentNode)&&(Nt=e.parentNode)),e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")==="false"&&(ri=e)}function ha(n,e,t){let{dom:i}=n,o=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX,t.clientY,n.getDoc()),s=t.dataTransfer&&t.dataTransfer.getData("bookstack/template");s&&(t.preventDefault(),window.$http.get(`/templates/${s}`).then(r=>{n.selection.setRng(o),n.undoManager.transact(()=>{n.execCommand("mceInsertContent",!1,r.data.html)})})),i.getParent(o.startContainer,".mceTemp")?t.preventDefault():Nt&&(t.preventDefault(),n.undoManager.transact(()=>{n.selection.setRng(o),n.selection.setNode(Nt),i.remove(Nt)})),!t.isDefaultPrevented()&&ri&&(t.preventDefault(),n.undoManager.transact(()=>{let r=n.selection.getNode(),a=n.selection.getRng(),l=r.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(ri):l.before(ri)})),t.isDefaultPrevented()||ps(n,e,t),Nt=null}function ua(n,e){e.preventDefault(),n.focus();let i=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX??0,e.clientY??0,n.getDoc());n.selection.setRng(i)}function ms(n,e){n.on("dragover",t=>ua(n,t)),n.on("dragstart",()=>da(n)),n.on("drop",t=>ha(n,e,t)),n.on("paste",t=>ps(n,e,t))}function fs(n){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",n.textDirection==="rtl"?"ltr rtl":"","link customtable imagemanager-insert insertoverflow","code about fullscreen"].filter(i=>!!i).join(" | ")}function pa(n){n.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),n.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),n.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function ma(n){n.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(e){return e.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function fa(n){n.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(e){return e.closest("img")!==null&&!e.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"image"})}function ga(n){n.ui.registry.addContextToolbar("objectcontexttoolbar",{predicate(e){return e.closest("img")!==null&&e.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"media"})}function gs(n){pa(n),ma(n),fa(n),ga(n)}var va={"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 vs(n){for(let[e,t]of Object.entries(va))n.ui.registry.addIcon(e,t)}function ba(n){n.serializer.addNodeFilter("br",e=>{for(let t of e)if(t.parent&&t.parent.name==="code"){let i=window.tinymce.html.Node.create("#text");i.value=`
|
|
`,t.replace(i)}})}function wa(n){n.parser.addNodeFilter("div",e=>{for(let t of e){let i=t.attr("id")||"",o=t.attr("class")||"";(i==="pointer"||o.includes("pointer"))&&t.remove()}})}function bs(n){ba(n),wa(n)}function ws(n){return n.tagName.toLowerCase()==="code-block"}function Es(n,e,t,i,o){let s=window.$components.first("code-editor"),r=n.selection.getBookmark();s.open(e,t,i,(a,l)=>{o(a,l),n.focus(),n.selection.moveToBookmark(r)},()=>{n.focus(),n.selection.moveToBookmark(r)})}function ys(n,e){let t=e.getAttribute("dir")||"";Es(n,e.getContent(),e.getLanguage(),t,(i,o)=>{e.setContent(i,o)})}function ya(n){let e=n.getDoc(),t=e.defaultView;class i extends t.HTMLElement{constructor(){super();d(this,"editor",null);this.attachShadow({mode:"open"});let r=document.head.querySelectorAll('link[rel="stylesheet"]:not([media="print"]),style'),a=Array.from(r).map(c=>c.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=c=>(c.split(" ").filter(m=>m.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 c=e.createElement("code");l.append(c),c.innerText=r,c.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 c of l)c.replaceWith(`
|
|
`);return a.textContent}connectedCallback(){let r=Date.now();if(this.editor)return;this.cleanChildContent();let a=this.getContent(),c=a.split(`
|
|
`).length*19.2+18+24;this.style.height=`${c}px`;let p=this.shadowRoot.querySelector(".CodeMirrorContainer"),m=b=>{this.editor=b.wysiwygView(p,this.shadowRoot,a,this.getLanguage()),setTimeout(()=>{this.style.height=null},12)};window.importVersioned("code").then(b=>{let y=Date.now()-r<20?20:0;setTimeout(()=>m(b),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",i)}function Ea(n){n.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>'),n.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){n.execCommand("codeeditor")}}),n.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){n.execCommand("codeeditor")}}),n.addCommand("codeeditor",()=>{let e=n.selection.getNode(),t=e.ownerDocument;if(ws(e))ys(n,e);else{let i=n.selection.getContent({format:"text"}),o=document.dir==="rtl"?"ltr":"";Es(n,i,"",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),n.insertContent(a.outerHTML)})}}),n.on("dblclick",()=>{let e=n.selection.getNode();ws(e)&&ys(n,e)}),n.on("PreInit",()=>{n.parser.addNodeFilter("pre",e=>{for(let t of e){let i=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&&i.attr("dir",s);let r=t.getAll("span");for(let a of r)a.unwrap();t.attr("style",null),t.wrap(i)}}),n.parser.addNodeFilter("code-block",e=>{for(let t of e)t.attr("contenteditable","false")}),n.serializer.addNodeFilter("code-block",e=>{for(let t of e){let i=t.attr("dir");i&&t.firstChild?t.firstChild.attr("dir",i):t.firstChild&&t.firstChild.attr("dir",null),t.unwrap()}})}),n.ui.registry.addContextToolbar("codeeditor",{predicate(e){return e.nodeName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),n.on("PreInit",()=>{ya(n)})}function Cs(){return Ea}function ai(n){return new Promise((e,t)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>t(n.error)})}function Ca(n,e){let t,i=()=>{if(t)return t;let o=indexedDB.open(n);return o.onupgradeneeded=()=>o.result.createObjectStore(e),t=ai(o),t.then(s=>{s.onclose=()=>t=void 0},()=>{}),t};return(o,s)=>i().then(r=>s(r.transaction(e,o).objectStore(e)))}var Xi;function Gi(){return Xi||(Xi=Ca("keyval-store","keyval")),Xi}function Yi(n,e=Gi()){return e("readonly",t=>ai(t.get(n)))}function Ji(n,e,t=Gi()){return t("readwrite",i=>(i.put(e,n),ai(i.transaction)))}function Zi(n,e=Gi()){return e("readwrite",t=>(t.delete(n),ai(t.transaction)))}var ut=null,eo,li,Qi,to="last-drawing-save";function no(n){ut?.contentWindow?.postMessage(JSON.stringify(n),eo)}function Ta(n){Ji(to,n.data),Qi&&Qi(n.data).then(()=>{Zi(to)})}function La(n){no({action:"export",format:"xmlpng",xml:n.xml,spin:"Updating drawing"})}function Sa(){li&&li().then(n=>{no({action:"load",autosave:1,xml:n})})}function ka(){let n={};ut&&(window.$events.emitPublic(ut,"editor-drawio::configure",{config:n}),no({action:"configure",config:n}))}function xs(){window.removeEventListener("message",Ts),ut&&document.body.removeChild(ut)}function Ts(n){if(!n.data||n.data.length<1||n.origin!==eo)return;let e=JSON.parse(n.data);e.event==="init"?Sa():e.event==="exit"?xs():e.event==="save"?La(e):e.event==="export"?Ta(e):e.event==="configure"&&ka()}async function $a(){let n=await Yi(to),e=document.getElementById("unsaved-drawing-dialog");e||console.error("Missing expected unsaved-drawing dialog"),n&&e&&await window.$components.firstOnElement(e,"confirm-dialog").show()&&(li=async()=>n)}async function Ls(n,e,t){li=e,Qi=t,await $a(),ut=document.createElement("iframe"),ut.setAttribute("frameborder","0"),window.addEventListener("message",Ts),ut.setAttribute("src",n),ut.setAttribute("class","fullscreen"),ut.style.backgroundColor="#FFFFFF",document.body.appendChild(ut),eo=new URL(n).origin}async function io(n,e){let t={image:n,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function ci(){xs()}async function Ss(n){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${n}`))).data.content}`}catch(e){throw e instanceof Dt&&window.$events.showResponseError(e),ci(),e}}var st=null,Ft=null,_t={};function oo(n){return n.hasAttribute("drawio-diagram")}function Da(n,e=null){st=n,Ft=e,window.$components.first("image-manager").show(i=>{if(e){let o=e.querySelector("img");st.undoManager.transact(()=>{st.dom.setAttrib(o,"src",i.url),st.dom.setAttrib(e,"drawio-diagram",i.id)})}else{let o=`<div drawio-diagram="${i.id}" contenteditable="false"><img src="${i.url}"></div>`;st.insertContent(o)}},"drawio")}async function Aa(n){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){ci();let s=Ft.querySelector("img");try{let r=await io(n,_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 go(5);let i=`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="${i}"></div>`),ci();try{let s=await io(n,_t.pageId);st.undoManager.transact(()=>{st.dom.setAttrib(i,"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 Ia(){if(!Ft)return Promise.resolve("");let n=Ft.getAttribute("drawio-diagram");return Ss(n)}function ks(n,e=null){st=n,Ft=e,Ls(_t.drawioUrl,Ia,Aa)}function Ha(n){n.addCommand("drawio",()=>{let e=n.selection.getNode();ks(n,oo(e)?e:null)}),n.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>`),n.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){n.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 i=n.selection.getNode();Da(n,oo(i)?i:null)}}}),n.on("dblclick",()=>{let e=n.selection.getNode();oo(e)&&ks(n,e)}),n.on("SetContent",()=>{let e=n.dom.select("body > div[drawio-diagram]");e.length&&n.undoManager.transact(()=>{for(let t of e)t.setAttribute("contenteditable","false")})})}function $s(n){return _t=n,Ha}function Ba(n){n.addCommand("InsertHorizontalRule",()=>{let e=document.createElement("hr"),t=n.selection.getNode(),{parentNode:i}=t;i.insertBefore(e,t)}),n.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){n.execCommand("InsertHorizontalRule")}})}function Ms(){return Ba}function Pa(n){n.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(t=>{let i=t.thumbs?.display||t.url,o=`<a href="${t.url}" target="_blank">`;o+=`<img src="${i}" alt="${t.name}">`,o+="</a>",n.execCommand("mceInsertContent",!1,o)},"gallery")}})}function Ds(){return Pa}function Ra(n){let e={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/tinymce")};n.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){window.tinymce.activeEditor.windowManager.openUrl(e)}})}function As(){return Ra}var Is=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table","hr"];function di(n){return n.selection.getNode().closest("details")}function Oa(n,e){let t=di(n);t&&(n.undoManager.transact(()=>{let i=t.querySelector("summary");i||(i=document.createElement("summary"),t.prepend(i)),i.textContent=e}),n.selection.select(t))}function Na(n){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();Oa(n,t),e.close()}}}function _a(n){let e=n.querySelector("summary");return e?e.textContent:""}function Hs(n){let e=di(n);n.windowManager.open(Na(n)).setData({summary:_a(e)})}function Fa(n){let e=n.selection.getNode().closest("details"),t=n.selection.getBookmark();if(e){let i=e.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");n.undoManager.transact(()=>{for(let o of i)e.parentNode.insertBefore(o,e);e.remove()})}n.focus(),n.selection.moveToBookmark(t)}function so(n){n.attr("contenteditable",null);let e=!1;for(let t of n.children())t.name==="doc-root"&&(t.unwrap(),e=!0);e&&so(n)}function qa(n){so(n),n.attr("contenteditable","false");let e=window.tinymce.html.Node.create("doc-root",{contenteditable:"true"}),t=null;for(let i of n.children()){if(i.name==="summary")continue;Is.includes(i.name)?(e.append(i),t=null):(t||(t=window.tinymce.html.Node.create("p"),e.append(t)),t.append(i))}n.append(e)}function Wa(n){n.parser.addNodeFilter("details",e=>{for(let t of e)qa(t)}),n.serializer.addNodeFilter("details",e=>{for(let t of e)so(t),t.attr("open",null)}),n.serializer.addNodeFilter("doc-root",e=>{for(let t of e)t.unwrap()})}function ja(n){n.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>'),n.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>'),n.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>'),n.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){n.execCommand("InsertDetailsBlock")}}),n.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){Fa(n)}}),n.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){Hs(n)}}),n.on("dblclick",e=>{let t=e?.target?.ownerDocument?.defaultView?.HTMLDetailsElement;t&&e.target instanceof t&&di(n)&&(Hs(n),e.preventDefault(),e.stopPropagation())}),n.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){di(n).toggleAttribute("open"),n.focus()}}),n.addCommand("InsertDetailsBlock",()=>{let e=n.selection.getContent({format:"html"}),t=document.createElement("details"),i=document.createElement("summary"),o=`details-${Date.now()}`;t.setAttribute("data-id",o),t.appendChild(i),e||(e="<p><br></p>"),t.innerHTML+=e,n.insertContent(t.outerHTML),n.focus();let s=n.dom.select(`[data-id="${o}"]`)[0]||null;if(s){let r=s.querySelector("doc-root > *");r&&r.focus(),s.removeAttribute("data-id")}}),n.ui.registry.addContextToolbar("details",{predicate(e){return e.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),n.on("PreInit",()=>{Wa(n)})}function Bs(){return ja}function Ua(n){n.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(i){let o=i.nodeName.toLowerCase()==="table",s=n.selection.getNode(),r=s.closest("table");return!o||!r?!1:r.querySelector("tr").contains(s)},position:"node",scope:"node"};n.ui.registry.addContextToolbar("customtabletoolbarfirstrow",e),n.addCommand("tableclearformatting",()=>{let i=n.dom.getParent(n.selection.getStart(),"table");if(!i)return;let o=["class","style","width","height"],s=[i,...i.querySelectorAll(o.map(r=>`[${r}]`).join(","))];for(let r of s)for(let a of o)r.removeAttribute(a)}),n.addCommand("tableclearsizes",()=>{let i=n.dom.getParent(n.selection.getStart(),"table");if(!i)return;let o=[i,...i.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 i=n.ui.registry.getAll().buttons;n.ui.registry.addMenuButton("customtable",{...i.table,fetch:o=>o("inserttable | cell row column | advtablesort | tableprops tableclearformatting tableclearsizes deletetable")}),n.ui.registry.addMenuItem("tableclearformatting",{icon:"tableclearformatting",text:"Clear table formatting",onSetup:i.tableprops.onSetup,onAction(){n.execCommand("tableclearformatting")}}),n.ui.registry.addMenuItem("tableclearsizes",{icon:"resize",text:"Resize to contents",onSetup:i.tableprops.onSetup,onAction(){n.execCommand("tableclearsizes")}}),n.off("PreInit",t)};n.on("PreInit",t)}function Ps(){return Ua}function Va(n){let e=n.closest("li");return e&&e.parentNode.nodeName==="UL"&&e.classList.contains("task-list-item")}function za(n,e,t){let i=e.getBoundingClientRect();n.clientX<=i.right&&n.clientX>=i.left&&n.clientY>=i.top&&n.clientY<=i.bottom||t.undoManager.transact(()=>{e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","checked")})}function Ka(n){n.attr("class","task-list-item");for(let e of n.children())e.name==="input"&&(e.attr("checked")==="checked"&&n.attr("checked","checked"),e.remove())}function Xa(n){let e=n.attr("checked")==="checked";n.attr("checked",null);let t={type:"checkbox",disabled:"disabled"};e&&(t.checked="checked");let i=window.tinymce.html.Node.create("input",t);i.shortEnded=!0,n.firstChild?n.insert(i,n.firstChild,!0):n.append(i)}function Ga(n){n.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>'),n.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(i){i.isActive()?n.execCommand("RemoveList"):n.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(i){n.on("NodeChange",o=>{let s=o.parents.find(a=>a.nodeName==="LI"),r=s&&s.classList.contains("task-list-item");i.setActive(!!r)})}});let e=n.ui.registry.getAll().buttons.bullist;e.onSetup=function(o){n.on("NodeChange",s=>{let r=s.parents.find(c=>c.nodeName==="LI"),a=r&&r.classList.contains("task-list-item"),l=r&&r.parentNode.nodeName==="UL";o.setActive(!!(l&&!a))})},e.onAction=function(){Va(n.selection.getNode())&&n.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),n.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let t=n.ui.registry.getAll().buttons.numlist;t.onAction=function(){n.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},n.on("PreInit",()=>{n.parser.addNodeFilter("li",i=>{for(let o of i)o.attributes.map.class==="task-list-item"&&Ka(o)}),n.serializer.addNodeFilter("li",i=>{for(let o of i)o.attributes.map.class==="task-list-item"&&Xa(o)})}),n.on("click",i=>{let o=i.target;o.nodeName==="LI"&&o.classList.contains("task-list-item")&&(za(i,o,n),i.preventDefault())})}function Rs(){return Ga}function Os(n){function e(t){let i=t.querySelector("iframe, video");if(!i)return;let o=[...i.classList.values()].filter(r=>r.startsWith("align-")),s=[...t.classList.values()].filter(r=>r.startsWith("align-"));t.classList.remove(...s),t.classList.add(...o)}n.on("SetContent",()=>{let t=n.dom.select("span.mce-preview-object");for(let i of t)e(i)}),n.on("FormatApply",t=>{let i=t.format.startsWith("align");if(!(t.node instanceof n.dom.doc.defaultView.HTMLElement)||!i||!t.node.matches(".mce-preview-object"))return;let s=t.node.querySelector("iframe, video");if(s){let r=(n.formatter.get(t.format)[0]?.classes||[])[0],a=!s.classList.contains(r),c=(t.node.getAttribute("data-mce-p-class")||"").split(" ").filter(m=>!m.startsWith("align-"));a&&c.push(r);let p=c.join(" ");t.node.setAttribute("data-mce-p-class",p),s.setAttribute("class",p),n.formatter.apply(t.format,{},s),e(t.node)}})}function Ns(n){let e=n.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 ro(n){let e=n.querySelectorAll('[dir],[style*="direction"]');for(let t of e)t.removeAttribute("dir"),t.style.direction=null;Ns(n),n.style.direction=null,n.style.textAlign=null,n.removeAttribute("align")}function _s(n){let e=[];n.on("TableSelectionChange",i=>{e=(i.cells||[]).map(o=>o.dom)}),n.on("TableSelectionClear",()=>{e=[]});let t={RemoveFormat:i=>{let o=["class","style","width","height","align"];for(let s of o)i.removeAttribute(s)},mceDirectionLTR:i=>{i.setAttribute("dir","ltr"),ro(i)},mceDirectionRTL:i=>{i.setAttribute("dir","rtl"),ro(i)},JustifyLeft:i=>{i.removeAttribute("align"),Ns(i)}};t.JustifyRight=t.JustifyLeft,t.JustifyCenter=t.JustifyLeft,t.JustifyFull=t.JustifyLeft,n.on("ExecCommand",i=>{let o=t[i.command];if(o)for(let s of e)o(s)})}function Fs(n){n.on("ExecCommand",e=>{let t=e.command;if(t!=="mceDirectionLTR"&&t!=="mceDirectionRTL")return;let i=n.selection.getSelectedBlocks();for(let o of i)ro(o)})}var Ya=[{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"}]}],Ja={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"}}},Za=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function Qa(n,e,t){if(t.filetype==="file"){let i=window.$components.first("entity-selector-popup"),o=this.selection.getContent({format:"text"}).trim();i.show(s=>{n(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=>{n(o.url,{alt:o.name})},"gallery")}function tl(n){let e=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist","tableadditions",n.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",Cs()),window.tinymce.PluginManager.add("customhr",Ms()),window.tinymce.PluginManager.add("imagemanager",Ds()),window.tinymce.PluginManager.add("about",As()),window.tinymce.PluginManager.add("details",Bs()),window.tinymce.PluginManager.add("tasklist",Rs()),window.tinymce.PluginManager.add("tableadditions",Ps()),n.drawioUrl&&(window.tinymce.PluginManager.add("drawio",$s(n)),e.push("drawio")),e.filter(t=>!!t)}function el(n){let e=document.head.innerHTML.split(`
|
|
`),t=e.findIndex(r=>r.trim()==="<!-- Start: custom user content -->"),i=e.findIndex(r=>r.trim()==="<!-- End: custom user content -->");if(t===-1||i===-1)return;let o=e.slice(t+1,i).join(`
|
|
`),s=n.createElement("div");s.innerHTML=o,n.head.append(...s.children)}function nl(n){return function(t){function i(){n.darkMode&&t.contentDocument.documentElement.classList.add("dark-mode"),window.$events.emit("editor-html-change","")}t.on("ExecCommand change input NodeChange ObjectResized",i),us(t),ms(t,n),t.on("init",()=>{i(),hs(t),window.editor=t,cs(t)}),t.on("PreInit",()=>{bs(t)}),Os(t),_s(t),Fs(t),window.$events.emitPublic(n.containerElement,"editor-tinymce::setup",{editor:t}),t.ui.registry.addButton("inlinecode",{tooltip:"Inline code",icon:"sourcecode",onAction(){t.execCommand("mceToggleFormat",!1,"code")}})}}function il(n){return`
|
|
html, body, html.dark-mode {
|
|
background: ${n.darkMode?"#222":"#fff"};
|
|
}
|
|
body {
|
|
padding-left: 15px !important;
|
|
padding-right: 15px !important;
|
|
height: initial !important;
|
|
margin:0!important;
|
|
margin-left: auto! important;
|
|
margin-right: auto !important;
|
|
overflow-y: hidden !important;
|
|
}`.trim().replace(`
|
|
`,"")}function qs(n){return window.tinymce.addI18n(n.language,n.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:n.darkMode?"tinymce-5-dark":"tinymce-5",body_class:"page-content",browser_spellcheck:!0,relative_urls:!1,language:n.language,directionality:n.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:tl(n),contextmenu:!1,toolbar:fs(n),content_style:il(n),style_formats:Ya,style_formats_merge:!1,media_alt_source:!1,media_poster:!1,formats:Ja,table_style_by_css:!0,table_use_colgroups:!0,file_picker_types:"file image",color_map:Za,file_picker_callback:Qa,paste_preprocess(t,i){let{content:o}=i;o.indexOf('<img src="file://')!==-1&&(i.content="")},init_instance_callback(t){el(t.getDoc())},setup(t){vs(t),gs(t),nl(n)(t)}}}var hi=class extends h{setup(){this.elem=this.$el,this.tinyMceConfig=qs({language:this.$opts.language,containerElement:this.elem,darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,drawioUrl:this.getDrawIoUrl(),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 ui=class extends h{constructor(){super(...arguments);d(this,"elem");d(this,"wysiwygEditor");d(this,"textDirection")}async setup(){this.elem=this.$el,this.textDirection=this.$opts.textDirection;let t=await window.importVersioned("wysiwyg"),i=Z("div",{class:"basic-editor-container"});this.elem.parentElement?.appendChild(i),this.elem.hidden=!0,this.wysiwygEditor=t.createBasicEditorInstance(i,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 lo(n){let e=i=>i.slice(0,1).toUpperCase()+i.slice(1),t=n.split("-");return t[0]+t.slice(1).map(e).join("")}function Ws(n){return n.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}function ol(n,e){let t={},i={},o=`${n}@`,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(c=>c.startsWith(o)).map(c=>c.replace(o,"")).map(lo);for(let c of l)t[c]=a,typeof i[c]>"u"&&(i[c]=[]),i[c].push(a)}return{refs:t,manyRefs:i}}function sl(n,e){let t={},i=`option:${n}:`;for(let{name:o,value:s}of e.attributes)if(o.startsWith(i)){let r=o.replace(i,"");t[lo(r)]=s||""}return t}var pi=class{constructor(){d(this,"components",{});d(this,"componentModelMap",{});d(this,"elementComponentMap",new WeakMap)}initComponent(e,t){let i=this.componentModelMap[e];if(i===void 0)return;let o=null;try{o=new i,o.$name=e,o.$el=t;let r=ol(e,t);o.$refs=r.refs,o.$manyRefs=r.manyRefs,o.$opts=sl(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 i of t){let o=`${i.getAttribute("component")||""} ${i.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let s of o)this.initComponent(s,i)}}register(e){let t=Object.keys(e);for(let i of t)this.componentModelMap[Ws(i)]=e[i]}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=vo;window.importVersioned=bo;window.$http=new Ce;window.$events=new Ee;window.$trans=new xe;window.$components=new pi;window.$components.register(ao);window.$components.init();
|
|
/*! Bundled license information:
|
|
|
|
sortablejs/modular/sortable.esm.js:
|
|
(**!
|
|
* Sortable 1.15.7
|
|
* @author RubaXa <trash@rubaxa.org>
|
|
* @author owenm <owen23355@gmail.com>
|
|
* @license MIT
|
|
*)
|
|
*/
|
|
//# sourceMappingURL=app.js.map
|