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