-`);this.error(e)}}showResponseError(t){t.status&&t.status>=400&&typeof t.data=="object"&&t.data.message&&this.error(t.data.message)}};var xt=class extends Error{constructor(t,e){super(t.statusText),this.data=e,this.headers=t.headers,this.redirected=t.redirected,this.status=t.status,this.statusText=t.statusText,this.url=t.url,this.original=t}},we=class{async getResponseContent(t){if(t.status===204)return null;let i=(t.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return i==="javascript"||i==="json"?t.json():t.text()}createXMLHttpRequest(t,e,i={}){let o=document.querySelector("meta[name=token]")?.getAttribute("content"),s=new XMLHttpRequest;for(let[r,a]of Object.entries(i))s.addEventListener(r,a.bind(s));return s.open(t,e),s.withCredentials=!0,s.setRequestHeader("X-CSRF-TOKEN",o||""),s}async request(t,e={}){let i=t;if(i.startsWith("http")||(i=window.baseUrl(i)),e.params){let c=new URL(i);for(let u of Object.keys(e.params)){let h=e.params[u];typeof h<"u"&&h!==null&&c.searchParams.set(u,h)}i=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(i,s),a=await this.getResponseContent(r)||"",l={data:a,headers:r.headers,redirected:r.redirected,status:r.status,statusText:r.statusText,url:r.url,original:r};if(!r.ok)throw new xt(r,a);return l}async dataRequest(t,e,i){let o={method:t,body:i};return typeof i=="object"&&!(i instanceof FormData)&&(o.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},o.body=JSON.stringify(i)),i instanceof FormData&&t!=="post"&&(i.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 i=Object.values(e);return i.every(s=>Array.isArray(s)&&s.every(r=>typeof r=="string"))?i.flat().join(" "):t}};var be=class{choice(t,e,i={}){i=Object.assign({},{count:String(e)},i);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,i)}performReplacements(t,e){let i=t.match(/:(\S+)/g);if(i===null)return t;let o=t;for(let s of i){let r=s.substring(1);typeof e[r]>"u"||(o=o.replace(s,e[r]))}return o}};var Ki={};ks(Ki,{AddRemoveRows:()=>xe,AjaxDeleteRow:()=>Le,AjaxForm:()=>Te,Attachments:()=>Se,AttachmentsList:()=>ke,AutoSubmit:()=>De,AutoSuggest:()=>$e,BackToTop:()=>Me,BookSort:()=>Xe,ChapterContents:()=>Ye,CodeEditor:()=>Je,CodeHighlighter:()=>Ze,CodeTextarea:()=>Qe,Collapsible:()=>tn,ConfirmDialog:()=>en,CustomCheckbox:()=>nn,DetailsHighlighter:()=>on,Dropdown:()=>sn,DropdownSearch:()=>rn,Dropzone:()=>an,EditorToolbox:()=>ln,EntityPermissions:()=>cn,EntitySearch:()=>dn,EntitySelector:()=>hn,EntitySelectorPopup:()=>un,EventEmitSelect:()=>pn,ExpandToggle:()=>mn,GlobalSearch:()=>fn,HeaderMobileToggle:()=>gn,ImageManager:()=>vn,ImagePicker:()=>wn,ListSortControl:()=>bn,LoadingButton:()=>yn,MarkdownEditor:()=>En,NewUserPassword:()=>Cn,Notification:()=>xn,OptionalInput:()=>Ln,PageComment:()=>Mn,PageCommentReference:()=>An,PageComments:()=>In,PageDisplay:()=>Hn,PageEditor:()=>Bn,PagePicker:()=>Rn,PermissionsTable:()=>On,Pointer:()=>_n,Popup:()=>Nn,SettingAppColorScheme:()=>Fn,SettingColorPicker:()=>qn,SettingHomepageControl:()=>Un,ShelfSort:()=>jn,ShortcutInput:()=>Kn,Shortcuts:()=>zn,SortRuleManager:()=>Gn,SortableList:()=>Xn,SubmitOnChange:()=>Yn,Tabs:()=>zt,TagManager:()=>Jn,TemplateManager:()=>Zn,ToggleSwitch:()=>Qn,TriLayout:()=>ti,UserSelect:()=>ei,WebhookEvents:()=>ni,WysiwygEditor:()=>ii,WysiwygEditorTinymce:()=>oi,WysiwygInput:()=>si});function mt(n,t,e){let i=null;return function(...s){let r=this,a=function(){i=null,e||n.apply(r,s)},l=e&&!i;i&&clearTimeout(i),i=window.setTimeout(a,t),l&&n.apply(r,s)}}function Ds(n){return n.nodeName==="DETAILS"}function Lt(n){if(!n)return;let t=n;for(;t.parentElement;)t=t.parentElement,Ds(t)&&!t.open&&(t.open=!0);n.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-link");n.style.outline=`2px dashed ${e}`,n.style.outlineOffset="5px",n.style.removeProperty("transition"),setTimeout(()=>{n.style.transition="outline linear 3s",n.style.outline="2px dashed rgba(0, 0, 0, 0)";let i=()=>{n.removeEventListener("transitionend",i),n.style.removeProperty("transition"),n.style.removeProperty("outline"),n.style.removeProperty("outlineOffset")};n.addEventListener("transitionend",i)},1e3)}function Qi(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function to(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}function eo(n){return new Promise(t=>{setTimeout(t,n)})}function no(n){let t=n,e=document.querySelector('meta[name="base-url"]');if(!e)throw new Error("Could not find expected base-url meta tag in document");let i=e.getAttribute("content")||"";return i[i.length-1]==="/"&&(i=i.slice(0,i.length-1)),t[0]==="/"&&(t=t.slice(1)),`${i}/${t}`}function Ms(){let n=document.querySelector('link[href*="/dist/styles.css?version="]');if(!n)throw new Error("Could not find expected style link in document for version use");return(n.getAttribute("href")||"").split("?version=").pop()||""}function io(n){return import(window.baseUrl(`dist/${n}.js?version=${Ms()}`))}function oo(n,t=0){let e=3735928559^t,i=1103547991^t;for(let o=0,s;o<n.length;o++)s=n.charCodeAt(o),e=Math.imul(e^s,2654435761),i=Math.imul(i^s,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(e^e>>>13,3266489909),String(4294967296*(2097151&i)+(e>>>0))}function ft(n){return n instanceof HTMLElement}function it(n,t={},e=[]){let i=document.createElement(n);for(let[o,s]of Object.entries(t))s===null?i.removeAttribute(o):i.setAttribute(o,s);for(let o of e)typeof o=="string"?i.append(document.createTextNode(o)):i.append(o);return i}function ai(n,t){let e=document.querySelectorAll(n);for(let i of e)t(i)}function ye(n,t,e){if(n)for(let i of t)n.addEventListener(i,e)}function L(n,t){Array.isArray(n)||(n=[n]);for(let e of n)e.addEventListener("click",t),e.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),t(i))})}function so(n,t,e){Array.isArray(t)||(t=[t]);let i=o=>{o.key===n&&e(o)};t.forEach(o=>o.addEventListener("keydown",i))}function Ht(n,t){so("Enter",n,t)}function ro(n,t){so("Escape",n,t)}function A(n,t,e,i){n.addEventListener(e,o=>{let s=o.target?.closest(t);s&&i.call(s,o,s)})}function ao(n,t){let e=document.querySelectorAll(n);t=t.toLowerCase();for(let i of e)if((i.textContent||"").toLowerCase().includes(t)&&ft(i))return i;return null}function Tt(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Bt(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function Qt(n){let t=n.querySelectorAll(".loading-container");for(let e of t)e.remove()}function Z(n){let t=document.createElement("div");t.innerHTML=n,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 li(n,t,e){if(!e.contains(n))throw new Error("ParentElement must be a prent of element");let i=t,o=n.nodeType===Node.TEXT_NODE?n:n.childNodes[t];for(;o!==e&&o;)o.previousSibling?(o=o.previousSibling,i+=o.textContent?.length||0):o=o.parentNode;return i}function Ee(n,t){if(t===0)return{node:n,offset:0};let e=0,i=null;for(let o=0;o<n.childNodes.length;o++)if(i=n.childNodes[o],i.nodeType===Node.TEXT_NODE){let s=(i.textContent||"").length;if(e+s>=t)return{node:i,offset:t-e};e+=s}else if(i.nodeType===Node.ELEMENT_NODE){let s=(i.textContent||"").length;if(e+s>=t)return Ee(i,t-e);e+=s}return null}function Ce(n){let t=(n.textContent||"").replace(/\s{2,}/g,"");return oo(t)}var d=class{constructor(){U(this,"$name","");U(this,"$el",null);U(this,"$refs",{});U(this,"$manyRefs",{});U(this,"$opts",{})}setup(){}$emit(t,e={}){e.from=this;let i=this.$name,o=new CustomEvent(`${i}-${t}`,{bubbles:!0,detail:e});this.$el.dispatchEvent(o)}};var xe=class extends d{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)),A(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=to(),i=t.querySelectorAll('[name*="randrowid"]');for(let o of i)o.name=o.name.split("randrowid").join(e)}};var Le=class extends d{constructor(){super(...arguments);this.deleteButtons=[]}setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete||[],L(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 Te=class extends d{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=>L(t,this.submitFakeForm.bind(this)))}submitFakeForm(){let t=new FormData,e=this.container.querySelectorAll("[name]");for(let i of e)t.append(i.getAttribute("name"),i.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 Se=class extends d{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 i=e.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(i);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(t){let e={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[i,o]of Object.entries(e))o.toggleAttribute("hidden",i!==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 ke=class extends d{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,di,hi,gt=class{constructor(t,e=null,i=null){Zi(this,vt);this.containers=[t],this.onEscape=e,this.onEnter=i,t.addEventListener("keydown",Zt(this,vt,di).bind(this))}shareHandlingToEl(t){this.containers.push(t),t.addEventListener("keydown",Zt(this,vt,di).bind(this))}focusNext(){let t=Zt(this,vt,hi).call(this),e=document.activeElement,o=(ft(e)?t.indexOf(e):-1)+1;o>=t.length&&(o=0),t[o].focus()}focusPrevious(){let t=Zt(this,vt,hi).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,di=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))},hi=function(){let t=[],e='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers){let o=[...i.querySelectorAll(e)].filter(s=>ft(s));t.push(...o)}return t};var ui={},$e=class extends d{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 i=e.target.textContent;i&&this.selectSuggestion(i)}).shareHandlingToEl(this.input),A(this.list,".text-item","click",(e,i)=>{this.selectSuggestion(i.textContent)}),this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.input.addEventListener("keydown",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 i={search:t,name:e},o=`${this.url}:${JSON.stringify(i)}`;if(ui[o])return ui[o];let s=await window.$http.get(this.url,i);return ui[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">${Qi(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 De=class extends d{setup(){this.form=this.$el,this.form.submit()}};var Me=class extends d{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,i=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function r(){let a=1-(Date.now()-o)/i,l=Math.abs(a*s);a>0?(e.scrollTop=l,requestAnimationFrame(r.bind(this))):e.scrollTop=t}requestAnimationFrame(r.bind(this))}};function lo(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(n,o).enumerable})),e.push.apply(e,i)}return e}function st(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?lo(Object(e),!0).forEach(function(i){As(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):lo(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function Oe(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(t){return typeof t}:Oe=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oe(n)}function As(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function et(){return et=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},et.apply(this,arguments)}function Is(n,t){if(n==null)return{};var e={},i=Object.keys(n),o,s;for(s=0;s<i.length;s++)o=i[s],!(t.indexOf(o)>=0)&&(e[o]=n[o]);return e}function Hs(n,t){if(n==null)return{};var e=Is(n,t),i,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(o=0;o<s.length;o++)i=s[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(e[i]=n[i])}return e}function Bs(n){return Ps(n)||Rs(n)||Os(n)||_s()}function Ps(n){if(Array.isArray(n))return xi(n)}function Rs(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Os(n,t){if(n){if(typeof n=="string")return xi(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);if(e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set")return Array.from(n);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return xi(n,t)}}function xi(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,i=new Array(t);e<t;e++)i[e]=n[e];return i}function _s(){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 Ns="1.15.6";function ct(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var dt=ct(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),ue=ct(/Edge/i),co=ct(/firefox/i),ae=ct(/safari/i)&&!ct(/chrome/i)&&!ct(/android/i),$i=ct(/iP(ad|od|hone)/i),yo=ct(/chrome/i)&&ct(/android/i),Eo={capture:!1,passive:!1};function E(n,t,e){n.addEventListener(t,e,!dt&&Eo)}function y(n,t,e){n.removeEventListener(t,e,!dt&&Eo)}function Ue(n,t){if(t){if(t[0]===">"&&(t=t.substring(1)),n)try{if(n.matches)return n.matches(t);if(n.msMatchesSelector)return n.msMatchesSelector(t);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(t)}catch{return!1}return!1}}function Co(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function j(n,t,e,i){if(n){e=e||document;do{if(t!=null&&(t[0]===">"?n.parentNode===e&&Ue(n,t):Ue(n,t))||i&&n===e)return n;if(n===e)break}while(n=Co(n))}return null}var ho=/\s+/g;function B(n,t,e){if(n&&t)if(n.classList)n.classList[e?"add":"remove"](t);else{var i=(" "+n.className+" ").replace(ho," ").replace(" "+t+" "," ");n.className=(i+(e?" "+t:"")).replace(ho," ")}}function f(n,t,e){var i=n&&n.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(e=n.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Dt(n,t){var e="";if(typeof n=="string")e=n;else do{var i=f(n,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(n=n.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function xo(n,t,e){if(n){var i=n.getElementsByTagName(t),o=0,s=i.length;if(e)for(;o<s;o++)e(i[o],o);return i}return[]}function ot(){var n=document.scrollingElement;return n||document.documentElement}function $(n,t,e,i,o){if(!(!n.getBoundingClientRect&&n!==window)){var s,r,a,l,c,u,h;if(n!==window&&n.parentNode&&n!==ot()?(s=n.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,h=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(t||e)&&n!==window&&(o=o||n.parentNode,!dt))do if(o&&o.getBoundingClientRect&&(f(o,"transform")!=="none"||e&&f(o,"position")!=="static")){var m=o.getBoundingClientRect();r-=m.top+parseInt(f(o,"border-top-width")),a-=m.left+parseInt(f(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(i&&n!==window){var g=Dt(o||n),C=g&&g.a,T=g&&g.d;g&&(r/=T,a/=C,h/=C,u/=T,l=r+u,c=a+h)}return{top:r,left:a,bottom:l,right:c,width:h,height:u}}}function uo(n,t,e){for(var i=yt(n,!0),o=$(n)[t];i;){var s=$(i)[e],r=void 0;if(e==="top"||e==="left"?r=o>=s:r=o<=s,!r)return i;if(i===ot())break;i=yt(i,!1)}return!1}function Ft(n,t,e,i){for(var o=0,s=0,r=n.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==v.ghost&&(i||r[s]!==v.dragged)&&j(r[s],e.draggable,n,!1)){if(o===t)return r[s];o++}s++}return null}function Di(n,t){for(var e=n.lastElementChild;e&&(e===v.ghost||f(e,"display")==="none"||t&&!Ue(e,t));)e=e.previousElementSibling;return e||null}function P(n,t){var e=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==v.clone&&(!t||Ue(n,t))&&e++;return e}function po(n){var t=0,e=0,i=ot();if(n)do{var o=Dt(n),s=o.a,r=o.d;t+=n.scrollLeft*s,e+=n.scrollTop*r}while(n!==i&&(n=n.parentNode));return[t,e]}function Fs(n,t){for(var e in n)if(n.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===n[e][i])return Number(e)}return-1}function yt(n,t){if(!n||!n.getBoundingClientRect)return ot();var e=n,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var o=f(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 ot();if(i||t)return e;i=!0}}while(e=e.parentNode);return ot()}function qs(n,t){if(n&&t)for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}function pi(n,t){return Math.round(n.top)===Math.round(t.top)&&Math.round(n.left)===Math.round(t.left)&&Math.round(n.height)===Math.round(t.height)&&Math.round(n.width)===Math.round(t.width)}var le;function Lo(n,t){return function(){if(!le){var e=arguments,i=this;e.length===1?n.call(i,e[0]):n.apply(i,e),le=setTimeout(function(){le=void 0},t)}}}function Us(){clearTimeout(le),le=void 0}function To(n,t,e){n.scrollLeft+=t,n.scrollTop+=e}function Mi(n){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(n).cloneNode(!0):e?e(n).clone(!0)[0]:n.cloneNode(!0)}function mo(n,t){f(n,"position","absolute"),f(n,"top",t.top),f(n,"left",t.left),f(n,"width",t.width),f(n,"height",t.height)}function mi(n){f(n,"position",""),f(n,"top",""),f(n,"left",""),f(n,"width",""),f(n,"height","")}function So(n,t,e){var i={};return Array.from(n.children).forEach(function(o){var s,r,a,l;if(!(!j(o,t.draggable,n,!1)||o.animated||o===e)){var c=$(o);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,c.left),i.top=Math.min((r=i.top)!==null&&r!==void 0?r:1/0,c.top),i.right=Math.max((a=i.right)!==null&&a!==void 0?a:-1/0,c.right),i.bottom=Math.max((l=i.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var _="Sortable"+new Date().getTime();function Vs(){var n=[],t;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(o){if(!(f(o,"display")==="none"||o===v.ghost)){n.push({target:o,rect:$(o)});var s=st({},n[n.length-1].rect);if(o.thisAnimationDuration){var r=Dt(o,!0);r&&(s.top-=r.f,s.left-=r.e)}o.fromRect=s}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(Fs(n,{target:i}),1)},animateAll:function(i){var o=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var s=!1,r=0;n.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=$(c),m=c.prevFromRect,g=c.prevToRect,C=a.rect,T=Dt(c,!0);T&&(h.top-=T.f,h.left-=T.e),c.toRect=h,c.thisAnimationDuration&&pi(m,h)&&!pi(u,h)&&(C.top-h.top)/(C.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=js(C,m,g,o.options)),pi(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=o.options.animation),o.animate(c,C,h,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 i=="function"&&i()},r):typeof i=="function"&&i(),n=[]},animate:function(i,o,s,r){if(r){f(i,"transition",""),f(i,"transform","");var a=Dt(this.el),l=a&&a.a,c=a&&a.d,u=(o.left-s.left)/(l||1),h=(o.top-s.top)/(c||1);i.animatingX=!!u,i.animatingY=!!h,f(i,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=Ws(i),f(i,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),f(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){f(i,"transition",""),f(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},r)}}}}function Ws(n){return n.offsetWidth}function js(n,t,e,i){return Math.sqrt(Math.pow(t.top-n.top,2)+Math.pow(t.left-n.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var Pt=[],fi={initializeByDefault:!0},pe={mount:function(t){for(var e in fi)fi.hasOwnProperty(e)&&!(e in t)&&(t[e]=fi[e]);Pt.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),Pt.push(t)},pluginEvent:function(t,e,i){var o=this;this.eventCanceled=!1,i.cancel=function(){o.eventCanceled=!0};var s=t+"Global";Pt.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][s]&&e[r.pluginName][s](st({sortable:e},i)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](st({sortable:e},i)))})},initializePlugins:function(t,e,i,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,et(i,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 i={};return Pt.forEach(function(o){typeof o.eventProperties=="function"&&et(i,o.eventProperties.call(e[o.pluginName],t))}),i},modifyOption:function(t,e,i){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],i))}),o}};function ie(n){var t=n.sortable,e=n.rootEl,i=n.name,o=n.targetEl,s=n.cloneEl,r=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,u=n.oldDraggableIndex,h=n.newDraggableIndex,m=n.originalEvent,g=n.putSortable,C=n.extraEventProperties;if(t=t||e&&e[_],!!t){var T,F=t.options,Y="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!dt&&!ue?T=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(T=document.createEvent("Event"),T.initEvent(i,!0,!0)),T.to=r||e,T.from=a||e,T.item=o||e,T.clone=s,T.oldIndex=l,T.newIndex=c,T.oldDraggableIndex=u,T.newDraggableIndex=h,T.originalEvent=m,T.pullMode=g?g.lastPutMode:void 0;var x=st(st({},C),pe.getEventProperties(i,t));for(var S in x)T[S]=x[S];e&&e.dispatchEvent(T),F[Y]&&F[Y].call(t,T)}}var zs=["evt"],V=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.evt,s=Hs(i,zs);pe.pluginEvent.bind(v)(t,e,st({dragEl:p,parentEl:I,ghostEl:b,rootEl:D,nextEl:$t,lastDownEl:_e,cloneEl:M,cloneHidden:bt,dragStarted:oe,putSortable:O,activeSortable:v.active,originalEvent:o,oldIndex:Nt,oldDraggableIndex:ce,newIndex:G,newDraggableIndex:wt,hideGhostForTarget:Mo,unhideGhostForTarget:Ao,cloneNowHidden:function(){bt=!0},cloneNowShown:function(){bt=!1},dispatchSortableEvent:function(a){q({sortable:e,name:a,originalEvent:o})}},s))};function q(n){ie(st({putSortable:O,cloneEl:M,targetEl:p,rootEl:D,oldIndex:Nt,oldDraggableIndex:ce,newIndex:G,newDraggableIndex:wt},n))}var p,I,b,D,$t,_e,M,bt,Nt,G,ce,wt,Ae,O,_t=!1,Ve=!1,We=[],St,Q,gi,vi,fo,go,oe,Rt,de,he=!1,Ie=!1,Ne,N,wi=[],Li=!1,je=[],Ke=typeof document<"u",He=$i,vo=ue||dt?"cssFloat":"float",Ks=Ke&&!yo&&!$i&&"draggable"in document.createElement("div"),ko=function(){if(Ke){if(dt)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),$o=function(t,e){var i=f(t),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=Ft(t,0,e),r=Ft(t,1,e),a=s&&f(s),l=r&&f(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+$(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+$(r).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&i[vo]==="none"||r&&i[vo]==="none"&&c+u>o)?"vertical":"horizontal"},Xs=function(t,e,i){var o=i?t.left:t.top,s=i?t.right:t.bottom,r=i?t.width:t.height,a=i?e.left:e.top,l=i?e.right:e.bottom,c=i?e.width:e.height;return o===a||s===l||o+r/2===a+c/2},Gs=function(t,e){var i;return We.some(function(o){var s=o[_].options.emptyInsertThreshold;if(!(!s||Di(o))){var r=$(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return i=o}}),i},Do=function(t){function e(s,r){return function(a,l,c,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||h))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 m=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===m||s.join&&s.indexOf(m)>-1}}var i={},o=t.group;(!o||Oe(o)!="object")&&(o={name:o}),i.name=o.name,i.checkPull=e(o.pull,!0),i.checkPut=e(o.put),i.revertClone=o.revertClone,t.group=i},Mo=function(){!ko&&b&&f(b,"display","none")},Ao=function(){!ko&&b&&f(b,"display","")};Ke&&!yo&&document.addEventListener("click",function(n){if(Ve)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Ve=!1,!1},!0);var kt=function(t){if(p){t=t.touches?t.touches[0]:t;var e=Gs(t.clientX,t.clientY);if(e){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[_]._onDragOver(i)}}},Ys=function(t){p&&p.parentNode[_]._isOutsideThisEl(t.target)};function v(n,t){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=t=et({},t),n[_]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return $o(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:v.supportPointer!==!1&&"PointerEvent"in window&&(!ae||$i),emptyInsertThreshold:5};pe.initializePlugins(this,n,e);for(var i in e)!(i in t)&&(t[i]=e[i]);Do(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:Ks,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?E(n,"pointerdown",this._onTapStart):(E(n,"mousedown",this._onTapStart),E(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(n,"dragover",this),E(n,"dragenter",this)),We.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),et(this,Vs())}v.prototype={constructor:v,_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,p):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=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(or(i),!p&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&ae&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=j(l,o.draggable,i,!1),!(l&&l.animated)&&_e!==l)){if(Nt=P(l),ce=P(l,o.draggable),typeof u=="function"){if(u.call(this,t,l,this)){q({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),V("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=j(c,h.trim(),i,!1),h)return q({sortable:e,rootEl:h,name:"filter",targetEl:l,fromEl:i,toEl:i}),V("filter",e,{evt:t}),!0}),u)){s&&t.preventDefault();return}o.handle&&!j(c,o.handle,i,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,i){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(i&&!p&&i.parentNode===s){var c=$(i);if(D=s,p=i,I=p.parentNode,$t=p.nextSibling,_e=i,Ae=r.group,v.dragged=p,St={target:p,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,p.style["will-change"]="all",l=function(){if(V("delayEnded",o,{evt:t}),v.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!co&&o.nativeDraggable&&(p.draggable=!0),o._triggerDragStart(t,e),q({sortable:o,name:"choose",originalEvent:t}),B(p,r.chosenClass,!0)},r.ignore.split(",").forEach(function(u){xo(p,u.trim(),bi)}),E(a,"dragover",kt),E(a,"mousemove",kt),E(a,"touchmove",kt),r.supportPointer?(E(a,"pointerup",o._onDrop),!this.nativeDraggable&&E(a,"pointercancel",o._onDrop)):(E(a,"mouseup",o._onDrop),E(a,"touchend",o._onDrop),E(a,"touchcancel",o._onDrop)),co&&this.nativeDraggable&&(this.options.touchStartThreshold=4,p.draggable=!0),V("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(ue||dt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(E(a,"pointerup",o._disableDelayedDrag),E(a,"pointercancel",o._disableDelayedDrag)):(E(a,"mouseup",o._disableDelayedDrag),E(a,"touchend",o._disableDelayedDrag),E(a,"touchcancel",o._disableDelayedDrag)),E(a,"mousemove",o._delayedDragTouchMoveHandler),E(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&E(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(){p&&bi(p),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;y(t,"mouseup",this._disableDelayedDrag),y(t,"touchend",this._disableDelayedDrag),y(t,"touchcancel",this._disableDelayedDrag),y(t,"pointerup",this._disableDelayedDrag),y(t,"pointercancel",this._disableDelayedDrag),y(t,"mousemove",this._delayedDragTouchMoveHandler),y(t,"touchmove",this._delayedDragTouchMoveHandler),y(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?E(document,"pointermove",this._onTouchMove):e?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(p,"dragend",this),E(D,"dragstart",this._onDragStart));try{document.selection?Fe(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(_t=!1,D&&p){V("dragStarted",this,{evt:e}),this.nativeDraggable&&E(document,"dragover",Ys);var i=this.options;!t&&B(p,i.dragClass,!1),B(p,i.ghostClass,!0),v.active=this,t&&this._appendGhost(),q({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Q){this._lastX=Q.clientX,this._lastY=Q.clientY,Mo();for(var t=document.elementFromPoint(Q.clientX,Q.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Q.clientX,Q.clientY),t!==e);)e=t;if(p.parentNode[_]._isOutsideThisEl(t),e)do{if(e[_]){var i=void 0;if(i=e[_]._onDragOver({clientX:Q.clientX,clientY:Q.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=Co(e));Ao()}},_onTouchMove:function(t){if(St){var e=this.options,i=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=b&&Dt(b,!0),a=b&&r&&r.a,l=b&&r&&r.d,c=He&&N&&po(N),u=(s.clientX-St.clientX+o.x)/(a||1)+(c?c[0]-wi[0]:0)/(a||1),h=(s.clientY-St.clientY+o.y)/(l||1)+(c?c[1]-wi[1]:0)/(l||1);if(!v.active&&!_t){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(b){r?(r.e+=u-(gi||0),r.f+=h-(vi||0)):r={a:1,b:0,c:0,d:1,e:u,f:h};var m="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");f(b,"webkitTransform",m),f(b,"mozTransform",m),f(b,"msTransform",m),f(b,"transform",m),gi=u,vi=h,Q=s}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!b){var t=this.options.fallbackOnBody?document.body:D,e=$(p,!0,He,!0,t),i=this.options;if(He){for(N=t;f(N,"position")==="static"&&f(N,"transform")==="none"&&N!==document;)N=N.parentNode;N!==document.body&&N!==document.documentElement?(N===document&&(N=ot()),e.top+=N.scrollTop,e.left+=N.scrollLeft):N=ot(),wi=po(N)}b=p.cloneNode(!0),B(b,i.ghostClass,!1),B(b,i.fallbackClass,!0),B(b,i.dragClass,!0),f(b,"transition",""),f(b,"transform",""),f(b,"box-sizing","border-box"),f(b,"margin",0),f(b,"top",e.top),f(b,"left",e.left),f(b,"width",e.width),f(b,"height",e.height),f(b,"opacity","0.8"),f(b,"position",He?"absolute":"fixed"),f(b,"zIndex","100000"),f(b,"pointerEvents","none"),v.ghost=b,t.appendChild(b),f(b,"transform-origin",fo/parseInt(b.style.width)*100+"% "+go/parseInt(b.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,o=t.dataTransfer,s=i.options;if(V("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}V("setupClone",this),v.eventCanceled||(M=Mi(p),M.removeAttribute("id"),M.draggable=!1,M.style["will-change"]="",this._hideClone(),B(M,this.options.chosenClass,!1),v.clone=M),i.cloneId=Fe(function(){V("clone",i),!v.eventCanceled&&(i.options.removeCloneOnHide||D.insertBefore(M,p),i._hideClone(),q({sortable:i,name:"clone"}))}),!e&&B(p,s.dragClass,!0),e?(Ve=!0,i._loopId=setInterval(i._emulateDragOver,50)):(y(document,"mouseup",i._onDrop),y(document,"touchend",i._onDrop),y(document,"touchcancel",i._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(i,o,p)),E(document,"drop",i),f(p,"transform","translateZ(0)")),_t=!0,i._dragStartId=Fe(i._dragStarted.bind(i,e,t)),E(document,"selectstart",i),oe=!0,window.getSelection().removeAllRanges(),ae&&f(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,o,s,r,a=this.options,l=a.group,c=v.active,u=Ae===l,h=a.sort,m=O||c,g,C=this,T=!1;if(Li)return;function F(Jt,Ls){V(Jt,C,st({evt:t,isOwner:u,axis:g?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:h,fromSortable:m,target:i,completed:x,onMove:function(Gi,Ts){return Be(D,e,p,o,Gi,$(Gi),t,Ts)},changed:S},Ls))}function Y(){F("dragOverAnimationCapture"),C.captureAnimationState(),C!==m&&m.captureAnimationState()}function x(Jt){return F("dragOverCompleted",{insertion:Jt}),Jt&&(u?c._hideClone():c._showClone(C),C!==m&&(B(p,O?O.options.ghostClass:c.options.ghostClass,!1),B(p,a.ghostClass,!0)),O!==C&&C!==v.active?O=C:C===v.active&&O&&(O=null),m===C&&(C._ignoreWhileAnimating=i),C.animateAll(function(){F("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==m&&(m.animateAll(),m._ignoreWhileAnimating=null)),(i===p&&!p.animated||i===e&&!i.animated)&&(Rt=null),!a.dragoverBubble&&!t.rootEl&&i!==document&&(p.parentNode[_]._isOutsideThisEl(t.target),!Jt&&kt(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),T=!0}function S(){G=P(p),wt=P(p,a.draggable),q({sortable:C,name:"change",toEl:e,newIndex:G,newDraggableIndex:wt,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=j(i,a.draggable,e,!0),F("dragOver"),v.eventCanceled)return T;if(p.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||C._ignoreWhileAnimating===i)return x(!1);if(Ve=!1,c&&!a.disabled&&(u?h||(r=I!==D):O===this||(this.lastPutMode=Ae.checkPull(this,c,p,t))&&l.checkPut(this,c,p,t))){if(g=this._getDirection(t,i)==="vertical",o=$(p),F("dragOverValid"),v.eventCanceled)return T;if(r)return I=D,Y(),this._hideClone(),F("revert"),v.eventCanceled||($t?D.insertBefore(p,$t):D.appendChild(p)),x(!0);var R=Di(e,a.draggable);if(!R||tr(t,g,this)&&!R.animated){if(R===p)return x(!1);if(R&&e===t.target&&(i=R),i&&(s=$(i)),Be(D,e,p,o,i,s,t,!!i)!==!1)return Y(),R&&R.nextSibling?e.insertBefore(p,R.nextSibling):e.appendChild(p),I=e,S(),x(!0)}else if(R&&Qs(t,g,this)){var at=Ft(e,0,a,!0);if(at===p)return x(!1);if(i=at,s=$(i),Be(D,e,p,o,i,s,t,!1)!==!1)return Y(),e.insertBefore(p,at),I=e,S(),x(!0)}else if(i.parentNode===e){s=$(i);var J=0,Et,Kt=p.parentNode!==e,K=!Xs(p.animated&&p.toRect||o,i.animated&&i.toRect||s,g),Xt=g?"top":"left",ut=uo(i,"top","top")||uo(p,"top","top"),Gt=ut?ut.scrollTop:void 0;Rt!==i&&(Et=s[Xt],he=!1,Ie=!K&&a.invertSwap||Kt),J=er(t,i,s,g,K?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,Ie,Rt===i);var lt;if(J!==0){var Ct=P(p);do Ct-=J,lt=I.children[Ct];while(lt&&(f(lt,"display")==="none"||lt===b))}if(J===0||lt===i)return x(!1);Rt=i,de=J;var Yt=i.nextElementSibling,pt=!1;pt=J===1;var ge=Be(D,e,p,o,i,s,t,pt);if(ge!==!1)return(ge===1||ge===-1)&&(pt=ge===1),Li=!0,setTimeout(Zs,30),Y(),pt&&!Yt?e.appendChild(p):i.parentNode.insertBefore(p,pt?Yt:i),ut&&To(ut,0,Gt-ut.scrollTop),I=p.parentNode,Et!==void 0&&!Ie&&(Ne=Math.abs(Et-$(i)[Xt])),S(),x(!0)}if(e.contains(p))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){y(document,"mousemove",this._onTouchMove),y(document,"touchmove",this._onTouchMove),y(document,"pointermove",this._onTouchMove),y(document,"dragover",kt),y(document,"mousemove",kt),y(document,"touchmove",kt)},_offUpEvents:function(){var t=this.el.ownerDocument;y(t,"mouseup",this._onDrop),y(t,"touchend",this._onDrop),y(t,"pointerup",this._onDrop),y(t,"pointercancel",this._onDrop),y(t,"touchcancel",this._onDrop),y(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(G=P(p),wt=P(p,i.draggable),V("drop",this,{evt:t}),I=p&&p.parentNode,G=P(p),wt=P(p,i.draggable),v.eventCanceled){this._nulling();return}_t=!1,Ie=!1,he=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ti(this.cloneId),Ti(this._dragStartId),this.nativeDraggable&&(y(document,"drop",this),y(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),ae&&f(document.body,"user-select",""),f(p,"transform",""),t&&(oe&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),b&&b.parentNode&&b.parentNode.removeChild(b),(D===I||O&&O.lastPutMode!=="clone")&&M&&M.parentNode&&M.parentNode.removeChild(M),p&&(this.nativeDraggable&&y(p,"dragend",this),bi(p),p.style["will-change"]="",oe&&!_t&&B(p,O?O.options.ghostClass:this.options.ghostClass,!1),B(p,this.options.chosenClass,!1),q({sortable:this,name:"unchoose",toEl:I,newIndex:null,newDraggableIndex:null,originalEvent:t}),D!==I?(G>=0&&(q({rootEl:I,name:"add",toEl:I,fromEl:D,originalEvent:t}),q({sortable:this,name:"remove",toEl:I,originalEvent:t}),q({rootEl:I,name:"sort",toEl:I,fromEl:D,originalEvent:t}),q({sortable:this,name:"sort",toEl:I,originalEvent:t})),O&&O.save()):G!==Nt&&G>=0&&(q({sortable:this,name:"update",toEl:I,originalEvent:t}),q({sortable:this,name:"sort",toEl:I,originalEvent:t})),v.active&&((G==null||G===-1)&&(G=Nt,wt=ce),q({sortable:this,name:"end",toEl:I,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){V("nulling",this),D=p=I=b=$t=M=_e=bt=St=Q=oe=G=wt=Nt=ce=Rt=de=O=Ae=v.dragged=v.ghost=v.clone=v.active=null,je.forEach(function(t){t.checked=!0}),je.length=gi=vi=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":p&&(this._onDragOver(t),Js(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,o=0,s=i.length,r=this.options;o<s;o++)e=i[o],j(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||ir(e));return t},sort:function(t,e){var i={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];j(a,this.options.draggable,o,!1)&&(i[s]=a)},this),e&&this.captureAnimationState(),t.forEach(function(s){i[s]&&(o.removeChild(i[s]),o.appendChild(i[s]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return j(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var o=pe.modifyOption(this,t,e);typeof o<"u"?i[t]=o:i[t]=e,t==="group"&&Do(i)},destroy:function(){V("destroy",this);var t=this.el;t[_]=null,y(t,"mousedown",this._onTapStart),y(t,"touchstart",this._onTapStart),y(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(y(t,"dragover",this),y(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(V("hideClone",this),v.eventCanceled)return;f(M,"display","none"),this.options.removeCloneOnHide&&M.parentNode&&M.parentNode.removeChild(M),bt=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(bt){if(V("showClone",this),v.eventCanceled)return;p.parentNode==D&&!this.options.group.revertClone?D.insertBefore(M,p):$t?D.insertBefore(M,$t):D.appendChild(M),this.options.group.revertClone&&this.animate(p,M),f(M,"display",""),bt=!1}}};function Js(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function Be(n,t,e,i,o,s,r,a){var l,c=n[_],u=c.options.onMove,h;return window.CustomEvent&&!dt&&!ue?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=n,l.dragged=e,l.draggedRect=i,l.related=o||t,l.relatedRect=s||$(t),l.willInsertAfter=a,l.originalEvent=r,n.dispatchEvent(l),u&&(h=u.call(c,l,r)),h}function bi(n){n.draggable=!1}function Zs(){Li=!1}function Qs(n,t,e){var i=$(Ft(e.el,0,e.options,!0)),o=So(e.el,e.options,b),s=10;return t?n.clientX<o.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<o.top-s||n.clientY<i.bottom&&n.clientX<i.left}function tr(n,t,e){var i=$(Di(e.el,e.options.draggable)),o=So(e.el,e.options,b),s=10;return t?n.clientX>o.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>o.bottom+s||n.clientX>i.right&&n.clientY>i.top}function er(n,t,e,i,o,s,r,a){var l=i?n.clientY:n.clientX,c=i?e.height:e.width,u=i?e.top:e.left,h=i?e.bottom:e.right,m=!1;if(!r){if(a&&Ne<c*o){if(!he&&(de===1?l>u+c*s/2:l<h-c*s/2)&&(he=!0),he)m=!0;else if(de===1?l<u+Ne:l>h-Ne)return-de}else if(l>u+c*(1-o)/2&&l<h-c*(1-o)/2)return nr(t)}return m=m||r,m&&(l<u+c*s/2||l>h-c*s/2)?l>u+c/2?1:-1:0}function nr(n){return P(p)<P(n)?1:-1}function ir(n){for(var t=n.tagName+n.className+n.src+n.href+n.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function or(n){je.length=0;for(var t=n.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&je.push(i)}}function Fe(n){return setTimeout(n,0)}function Ti(n){return clearTimeout(n)}Ke&&E(document,"touchmove",function(n){(v.active||_t)&&n.cancelable&&n.preventDefault()});v.utils={on:E,off:y,css:f,find:xo,is:function(t,e){return!!j(t,e,t,!1)},extend:qs,throttle:Lo,closest:j,toggleClass:B,clone:Mi,index:P,nextTick:Fe,cancelNextTick:Ti,detectDirection:$o,getChild:Ft,expando:_};v.get=function(n){return n[_]};v.mount=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(v.utils=st(st({},v.utils),i.utils)),pe.mount(i)})};v.create=function(n,t){return new v(n,t)};v.version=Ns;var H=[],se,Si,ki=!1,yi,Ei,ze,re;function sr(){function n(){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 n.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):i.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?y(document,"dragover",this._handleAutoScroll):(y(document,"pointermove",this._handleFallbackAutoScroll),y(document,"touchmove",this._handleFallbackAutoScroll),y(document,"mousemove",this._handleFallbackAutoScroll)),wo(),qe(),Us()},nulling:function(){ze=Si=se=ki=re=yi=Ei=null,H.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){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(ze=e,i||this.options.forceAutoScrollFallback||ue||dt||ae){Ci(e,this.options,a,i);var l=yt(a,!0);ki&&(!re||s!==yi||r!==Ei)&&(re&&wo(),re=setInterval(function(){var c=yt(document.elementFromPoint(s,r),!0);c!==l&&(l=c,qe()),Ci(e,o.options,c,i)},10),yi=s,Ei=r)}else{if(!this.options.bubbleScroll||yt(a,!0)===ot()){qe();return}Ci(e,this.options,yt(a,!1),!1)}}},et(n,{pluginName:"scroll",initializeByDefault:!0})}function qe(){H.forEach(function(n){clearInterval(n.pid)}),H=[]}function wo(){clearInterval(re)}var Ci=Lo(function(n,t,e,i){if(t.scroll){var o=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=ot(),c=!1,u;Si!==e&&(Si=e,qe(),se=t.scroll,u=t.scrollFn,se===!0&&(se=yt(e,!0)));var h=0,m=se;do{var g=m,C=$(g),T=C.top,F=C.bottom,Y=C.left,x=C.right,S=C.width,R=C.height,at=void 0,J=void 0,Et=g.scrollWidth,Kt=g.scrollHeight,K=f(g),Xt=g.scrollLeft,ut=g.scrollTop;g===l?(at=S<Et&&(K.overflowX==="auto"||K.overflowX==="scroll"||K.overflowX==="visible"),J=R<Kt&&(K.overflowY==="auto"||K.overflowY==="scroll"||K.overflowY==="visible")):(at=S<Et&&(K.overflowX==="auto"||K.overflowX==="scroll"),J=R<Kt&&(K.overflowY==="auto"||K.overflowY==="scroll"));var Gt=at&&(Math.abs(x-o)<=r&&Xt+S<Et)-(Math.abs(Y-o)<=r&&!!Xt),lt=J&&(Math.abs(F-s)<=r&&ut+R<Kt)-(Math.abs(T-s)<=r&&!!ut);if(!H[h])for(var Ct=0;Ct<=h;Ct++)H[Ct]||(H[Ct]={});(H[h].vx!=Gt||H[h].vy!=lt||H[h].el!==g)&&(H[h].el=g,H[h].vx=Gt,H[h].vy=lt,clearInterval(H[h].pid),(Gt!=0||lt!=0)&&(c=!0,H[h].pid=setInterval(function(){i&&this.layer===0&&v.active._onTouchMove(ze);var Yt=H[this.layer].vy?H[this.layer].vy*a:0,pt=H[this.layer].vx?H[this.layer].vx*a:0;typeof u=="function"&&u.call(v.dragged.parentNode[_],pt,Yt,n,ze,H[this.layer].el)!=="continue"||To(H[this.layer].el,pt,Yt)}.bind({layer:h}),24))),h++}while(t.bubbleScroll&&m!==l&&(m=yt(m,!1)));ki=c}},30),Io=function(t){var e=t.originalEvent,i=t.putSortable,o=t.dragEl,s=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=i||s;a();var u=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(r("spill"),this.onSpill({dragEl:o,putSortable:i}))}};function Ai(){}Ai.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var o=Ft(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:Io};et(Ai,{pluginName:"revertOnSpill"});function Ii(){}Ii.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,o=i||this.sortable;o.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),o.animateAll()},drop:Io};et(Ii,{pluginName:"removeOnSpill"});var w=[],X=[],te,tt,ee=!1,W=!1,Ot=!1,k,ne,Pe;function Ho(){function n(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?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),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(o,s){var r="";w.length&&tt===t?w.forEach(function(a,l){r+=(l?", ":"")+a.textContent}):r=s.textContent,o.setData("Text",r)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(e){var i=e.dragEl;k=i},delayEnded:function(){this.isMultiDrag=~w.indexOf(k)},setupClone:function(e){var i=e.sortable,o=e.cancel;if(this.isMultiDrag){for(var s=0;s<w.length;s++)X.push(Mi(w[s])),X[s].sortableIndex=w[s].sortableIndex,X[s].draggable=!1,X[s].style["will-change"]="",B(X[s],this.options.selectedClass,!1),w[s]===k&&B(X[s],this.options.chosenClass,!1);i._hideClone(),o()}},clone:function(e){var i=e.sortable,o=e.rootEl,s=e.dispatchSortableEvent,r=e.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||w.length&&tt===i&&(bo(!0,o),s("clone"),r()))},showClone:function(e){var i=e.cloneNowShown,o=e.rootEl,s=e.cancel;this.isMultiDrag&&(bo(!1,o),X.forEach(function(r){f(r,"display","")}),i(),Pe=!1,s())},hideClone:function(e){var i=this,o=e.sortable,s=e.cloneNowHidden,r=e.cancel;this.isMultiDrag&&(X.forEach(function(a){f(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),Pe=!0,r())},dragStartGlobal:function(e){var i=e.sortable;!this.isMultiDrag&&tt&&tt.multiDrag._deselectMultiDrag(),w.forEach(function(o){o.sortableIndex=P(o)}),w=w.sort(function(o,s){return o.sortableIndex-s.sortableIndex}),Ot=!0},dragStarted:function(e){var i=this,o=e.sortable;if(this.isMultiDrag){if(this.options.sort&&(o.captureAnimationState(),this.options.animation)){w.forEach(function(r){r!==k&&f(r,"position","absolute")});var s=$(k,!1,!0,!0);w.forEach(function(r){r!==k&&mo(r,s)}),W=!0,ee=!0}o.animateAll(function(){W=!1,ee=!1,i.options.animation&&w.forEach(function(r){mi(r)}),i.options.sort&&Re()})}},dragOver:function(e){var i=e.target,o=e.completed,s=e.cancel;W&&~w.indexOf(i)&&(o(!1),s())},revert:function(e){var i=e.fromSortable,o=e.rootEl,s=e.sortable,r=e.dragRect;w.length>1&&(w.forEach(function(a){s.addAnimationState({target:a,rect:W?$(a):r}),mi(a),a.fromRect=r,i.removeAnimationState(a)}),W=!1,rr(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(e){var i=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(),ee=!1,c.animation&&w.length>1&&(W||!o&&!r.options.sort&&!l)){var u=$(k,!1,!0,!0);w.forEach(function(m){m!==k&&(mo(m,u),a.appendChild(m))}),W=!0}if(!o)if(W||Re(),w.length>1){var h=Pe;r._showClone(i),r.options.animation&&!Pe&&h&&X.forEach(function(m){r.addAnimationState({target:m,rect:ne}),m.fromRect=ne,m.thisAnimationDuration=null})}else r._showClone(i)}},dragOverAnimationCapture:function(e){var i=e.dragRect,o=e.isOwner,s=e.activeSortable;if(w.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){ne=et({},i);var r=Dt(k,!0);ne.top-=r.f,ne.left-=r.e}},dragOverAnimationComplete:function(){W&&(W=!1,Re())},drop:function(e){var i=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(i){var h=this.options,m=s.children;if(!Ot)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),B(k,h.selectedClass,!~w.indexOf(k)),~w.indexOf(k))w.splice(w.indexOf(k),1),te=null,ie({sortable:r,rootEl:o,name:"deselect",targetEl:k,originalEvent:i});else{if(w.push(k),ie({sortable:r,rootEl:o,name:"select",targetEl:k,originalEvent:i}),i.shiftKey&&te&&r.el.contains(te)){var g=P(te),C=P(k);~g&&~C&&g!==C&&function(){var x,S;C>g?(S=g,x=C):(S=C,x=g+1);for(var R=h.filter;S<x;S++)if(!~w.indexOf(m[S])&&j(m[S],h.draggable,s,!1)){var at=R&&(typeof R=="function"?R.call(r,i,m[S],r):R.split(",").some(function(J){return j(m[S],J.trim(),s,!1)}));at||(B(m[S],h.selectedClass,!0),w.push(m[S]),ie({sortable:r,rootEl:o,name:"select",targetEl:m[S],originalEvent:i}))}}()}else te=k;tt=u}if(Ot&&this.isMultiDrag){if(W=!1,(s[_].options.sort||s!==o)&&w.length>1){var T=$(k),F=P(k,":not(."+this.options.selectedClass+")");if(!ee&&h.animation&&(k.thisAnimationDuration=null),u.captureAnimationState(),!ee&&(h.animation&&(k.fromRect=T,w.forEach(function(x){if(x.thisAnimationDuration=null,x!==k){var S=W?$(x):T;x.fromRect=S,u.addAnimationState({target:x,rect:S})}})),Re(),w.forEach(function(x){m[F]?s.insertBefore(x,m[F]):s.appendChild(x),F++}),l===P(k))){var Y=!1;w.forEach(function(x){if(x.sortableIndex!==P(x)){Y=!0;return}}),Y&&(a("update"),a("sort"))}w.forEach(function(x){mi(x)}),u.animateAll()}tt=u}(o===s||c&&c.lastPutMode!=="clone")&&X.forEach(function(x){x.parentNode&&x.parentNode.removeChild(x)})}},nullingGlobal:function(){this.isMultiDrag=Ot=!1,X.length=0},destroyGlobal:function(){this._deselectMultiDrag(),y(document,"pointerup",this._deselectMultiDrag),y(document,"mouseup",this._deselectMultiDrag),y(document,"touchend",this._deselectMultiDrag),y(document,"keydown",this._checkKeyDown),y(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(e){if(!(typeof Ot<"u"&&Ot)&&tt===this.sortable&&!(e&&j(e.target,this.options.draggable,this.sortable.el,!1))&&!(e&&e.button!==0))for(;w.length;){var i=w[0];B(i,this.options.selectedClass,!1),w.shift(),ie({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:e})}},_checkKeyDown:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},et(n,{pluginName:"multiDrag",utils:{select:function(e){var i=e.parentNode[_];!i||!i.options.multiDrag||~w.indexOf(e)||(tt&&tt!==i&&(tt.multiDrag._deselectMultiDrag(),tt=i),B(e,i.options.selectedClass,!0),w.push(e))},deselect:function(e){var i=e.parentNode[_],o=w.indexOf(e);!i||!i.options.multiDrag||!~o||(B(e,i.options.selectedClass,!1),w.splice(o,1))}},eventProperties:function(){var e=this,i=[],o=[];return w.forEach(function(s){i.push({multiDragElement:s,index:s.sortableIndex});var r;W&&s!==k?r=-1:W?r=P(s,":not(."+e.options.selectedClass+")"):r=P(s),o.push({multiDragElement:s,index:r})}),{items:Bs(w),clones:[].concat(X),oldIndicies:i,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 rr(n,t){w.forEach(function(e,i){var o=t.children[e.sortableIndex+(n?Number(i):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function bo(n,t){X.forEach(function(e,i){var o=t.children[e.sortableIndex+(n?Number(i):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function Re(){w.forEach(function(n){n!==k&&n.parentNode&&n.parentNode.removeChild(n)})}v.mount(new sr);v.mount(Ii,Ai);var ht=v;var Bo={name(n,t){let e=n.getAttribute("data-name").trim().toLowerCase(),i=t.getAttribute("data-name").trim().toLowerCase();return e.localeCompare(i)},created(n,t){let e=Number(n.getAttribute("data-created"));return Number(t.getAttribute("data-created"))-e},updated(n,t){let e=Number(n.getAttribute("data-updated"));return Number(t.getAttribute("data-updated"))-e},chaptersFirst(n,t){let e=n.getAttribute("data-type"),i=t.getAttribute("data-type");return e===i?0:e==="chapter"?-1:1},chaptersLast(n,t){let e=n.getAttribute("data-type"),i=t.getAttribute("data-type");return e===i?0:e==="chapter"?1:-1}},Po={up:{active(n,t){return!(n.previousElementSibling===null&&!t)},run(n,t){(n.previousElementSibling||t).insertAdjacentElement("beforebegin",n)}},down:{active(n,t){return!(n.nextElementSibling===null&&!t)},run(n,t){(n.nextElementSibling||t).insertAdjacentElement("afterend",n)}},next_book:{active(n,t,e){return e.nextElementSibling!==null},run(n,t,e){e.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,t,e){return e.previousElementSibling!==null},run(n,t,e){e.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,t){return n.dataset.type==="page"&&this.getNextChapter(n,t)},run(n,t){this.getNextChapter(n,t).querySelector("ul").prepend(n)},getNextChapter(n,t){let e=t||n,i=Array.from(e.parentElement.children),o=i.indexOf(e);return i.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(n,t){return n.dataset.type==="page"&&this.getPrevChapter(n,t)},run(n,t){this.getPrevChapter(n,t).querySelector("ul").append(n)},getPrevChapter(n,t){let e=t||n,i=Array.from(e.parentElement.children),o=i.indexOf(e);return i.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(n,t){return t||t===null&&n.nextElementSibling},run(n,t,e){e.querySelector("ul").append(n)}},book_start:{active(n,t){return t||t===null&&n.previousElementSibling},run(n,t,e){e.querySelector("ul").prepend(n)}},before_chapter:{active(n,t){return t},run(n,t){t.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,t){return t},run(n,t){t.insertAdjacentElement("afterend",n)}}},Xe=class extends d{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"),i=t.target.closest("[data-id]");this.runSortAction(i,e)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let t="",e=!1,i=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let r=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");e=t===a?!e:!1;let l=Bo[a];e&&i.includes(a)&&(l=function(u,h){return 0-Bo[a](u,h)});for(let c of r)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});t=a,this.updateMapInput()})}bookSelect(t){if(this.container.querySelector(`[data-type="book"][data-id="${t.id}"]`)!==null)return;let i=`${t.link}/sort-item`;window.$http.get(i).then(o=>{let s=Z(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")),i={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put(s,r,a){return a.getAttribute("data-type")==="page"}};for(let s of e)ht.create(s,{group:s.classList.contains("sort-list")?i:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let 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 i of e){let o=i.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(i.children).filter(r=>r.matches('[data-type="page"], [data-type="chapter"]'));for(let r=0;r<s.length;r++)this.addBookChildToMap(s[r],r,o,t)}return t}addBookChildToMap(t,e,i,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:i});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:i})}runSortAction(t,e){let i=t.parentElement.closest("li[data-id]"),o=t.parentElement.closest('[data-type="book"]');Po[e].run(t,i,o),this.updateMapInput(),this.updateMoveActionStateForAll(),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.focus()}updateMoveActionState(t){let e=t.parentElement.closest("li[data-id]"),i=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,i)}}updateMoveActionStateForAll(){let t=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let e of t)this.updateMoveActionState(e)}};var Ge=new WeakMap;function me(n,t,e=400,i=null){let o=Object.keys(t);for(let r of o)n.style.setProperty(r,t[r][0]);let s=()=>{for(let r of o)n.style.removeProperty(r);n.style.removeProperty("transition"),n.removeEventListener("transitionend",s),Ge.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${e}ms`;for(let r of o)n.style.setProperty(r,t[r][1]);n.addEventListener("transitionend",s),Ge.set(n,s)},15)}function fe(n){Ge.has(n)&&Ge.get(n)()}function Ro(n,t=400,e=null){fe(n),n.style.display="block",me(n,{opacity:["0","1"]},t,()=>{e&&e()})}function Oo(n,t=400,e=null){fe(n),me(n,{opacity:["1","0"]},t,()=>{n.style.display="none",e&&e()})}function qt(n,t=400){fe(n);let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":[`${e}px`,"0px"],overflow:["hidden","hidden"],"padding-top":[o,"0px"],"padding-bottom":[s,"0px"]};me(n,r,t,()=>{n.style.display="none"})}function Ut(n,t=400){fe(n),n.style.display="block";let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":["0px",`${e}px`],overflow:["hidden","hidden"],"padding-top":["0px",o],"padding-bottom":["0px",s]};me(n,r,t)}function _o(n,t=400){let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom");return()=>{fe(n);let r=n.getBoundingClientRect().height,a=getComputedStyle(n),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]};me(n,u,t)}}var Ye=class extends d{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"),Ut(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 Je=class extends d{constructor(){super(...arguments);U(this,"editor",null);U(this,"saveCallback",null);U(this,"cancelCallback",null);U(this,"history",{});U(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()}),L(this.languageButtons,e=>{let i=e.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),Ht(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),L(this.saveButton,()=>this.save()),A(this.historyList,"button","click",(e,i)=>{e.preventDefault();let o=i.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 i=e.dataset.lang,o=this.favourites.has(i);e.setAttribute("data-favourite",o?"true":"false"),A(e.parentElement,".lang-option-favorite-toggle","click",()=>{o=!o,o?this.favourites.add(i):this.favourites.delete(i),e.setAttribute("data-favourite",o?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:o}),this.sortLanguageList(),o&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((i,o)=>{let s=i.dataset.favourite==="true",r=o.dataset.favourite==="true";return s&&!r?-1:r&&!s||i.dataset.lang>o.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of e)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(e,i,o,s,r){this.languageInput.value=i,this.saveCallback=s,this.cancelCallback=r,await this.show(),this.languageInputChange(i),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 i=this.editorInput.parentElement;e?i.setAttribute("dir",e):i.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 i=e.toLowerCase();for(let o of this.languageButtons){let s=o.dataset.lang.toLowerCase().trim(),r=i===s;o.classList.toggle("active",r),r&&o.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(i=>{let o=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${o}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getContent();if(!e)return;let i=Object.keys(this.history).pop();if(this.history[i]===e)return;this.history[String(Date.now())]=e;let o=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,o)}};var Ze=class extends d{setup(){let t=this.$el;t.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(t)})}};var Qe=class extends d{async setup(){let{mode:t}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,t)}};var tn=class extends d{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"),Ut(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 en=class extends d{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,L(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 nn=class extends d{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 on=class extends d{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 sn=class extends d{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(),i=0,o=this.toggle.getBoundingClientRect().height,s=e.bottom>window.innerHeight,r=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`,s?i=window.innerHeight-e.top-o/2:i=e.top),s){this.menu.style.top="initial",this.menu.style.bottom=`${i}px`;let c=window.innerHeight-40-(window.innerHeight-r.bottom);this.menu.style.maxHeight=`${Math.floor(c)}px`}else{this.menu.style.top=`${i}px`,this.menu.style.bottom="initial";let c=window.innerHeight-40-r.top;this.menu.style.maxHeight=`${Math.floor(c)}px`}this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",c=>{this.menu.contains(c.target)||this.hide()});let a=this.menu.querySelector("input");a!==null&&a.focus(),this.showing=!0;let l=new Event("show");this.container.dispatchEvent(l),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()}),L(this.toggle,e=>{e.stopPropagation(),e.preventDefault(),this.show(e),e instanceof KeyboardEvent&&t.focusNext()})}};var rn=class extends d{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 i of e){let o=!t||i.textContent.toLowerCase().includes(t);i.style.display=o?"flex":"none",i.classList.toggle("hidden",!o)}}async loadList(t=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let e=await window.$http.get(this.getAjaxUrl(t)),i=_o(this.listContainerElem,80);this.listContainerElem.innerHTML=e.data,i()}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 Vt=class{constructor(t){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 Hi(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let t=document.createElement("textarea");t.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),t.value=n,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}var an=class extends d{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(){L(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let t=0,e=()=>{this.hideOverlay(),t=0};this.dropTarget.addEventListener("dragenter",i=>{i.preventDefault(),t+=1,t===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",e),this.dropTarget.addEventListener("dragleave",()=>{t-=1,t===0&&e()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),e(),!this.isActive)return;let s=new Vt(i.dataTransfer).getFiles();for(let r of s)this.createUploadFromFile(r)})}manualSelectHandler(){let t=it("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=it("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:i,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){i.setAttribute("data-status","error"),i.textContent=l,Qt(e),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,Qt(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 i=this,o=window.$http.createXMLHttpRequest("POST",this.url,{error(){t.markError(i.errorMessage)},readystatechange(){this.readyState===XMLHttpRequest.DONE&&this.status===200?t.markSuccess(i.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=it("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),i=it("div",{class:"dropzone-file-item-status"},[]),o=it("div",{class:"dropzone-file-item-progress"}),s=it("div",{class:"dropzone-file-item-image-wrap"},[e]),r=it("div",{class:"dropzone-file-item"},[s,it("div",{class:"dropzone-file-item-text-wrap"},[it("div",{class:"dropzone-file-item-label"},[t.name]),Bt(),i]),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:i,dismiss:a}}};var ln=class extends d{constructor(){super(...arguments);this.open=!1;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 i=e.target.closest("button");if(i instanceof HTMLButtonElement&&this.buttons.includes(i)){let o=i.dataset.tab||"";this.setActiveTab(o,!0)}})}toggle(){this.container.classList.toggle("open");let 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,i=!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");i&&!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 cn=class extends d{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,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of i)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 i=await window.$http.get(`/permissions/form-row/${this.entityType}/${t}`),o=Z(i.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(t){let e=t.closest(".item-list-row"),{roleId:i}=t.dataset,{roleName:o}=t.dataset,s=document.createElement("option");s.value=i,s.textContent=o,this.roleSelect.append(s),e.remove()}};var dn=class extends d{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()}),L(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(i=>{this.searchResults.innerHTML=i.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var hn=class extends d{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.search="",this.lastClick=0,this.setupListeners(),this.showLoading(),this.searchOptions.searchEndpoint&&this.initialLoad()}configureSearchOptions(t){Object.assign(this.searchOptions,t),this.reset(),this.searchInput.value=this.searchOptions.initialValue}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let t=0;this.searchInput.addEventListener("input",()=>{t=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-t<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",e=>{e.keyCode===13&&e.preventDefault()}),A(this.$el,"[data-entity-type]","keydown",e=>{if(e.ctrlKey&&e.code==="Enter"){let i=this.$el.closest("form");if(i){i.submit(),e.preventDefault();return}}e.code==="ArrowDown"&&this.focusAdjacent(!0),e.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",e=>{e.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(t=!0){let e=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),i=e.indexOf(document.activeElement),o=e[i+(t?1:-1)]||e[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");if(this.searchOptions.initialValue){this.searchEntities(this.searchOptions.initialValue);return}window.$http.get(this.searchUrl()).then(t=>{this.resultsContainer.innerHTML=t.data,this.hideLoading()})}searchUrl(){let t=`types=${encodeURIComponent(this.searchOptions.entityTypes)}&permission=${encodeURIComponent(this.searchOptions.entityPermission)}`;return`${this.searchOptions.searchEndpoint}?${t}`}searchEntities(t){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");this.input.value="";let e=`${this.searchUrl()}&term=${encodeURIComponent(t)}`;window.$http.get(e).then(i=>{this.resultsContainer.innerHTML=i.data,this.hideLoading()})}isDoubleClick(){let t=Date.now(),e=t-this.lastClick<300;return this.lastClick=t,e}onClick(t){let e=t.target.closest("[data-entity-type]");e&&(t.preventDefault(),t.stopPropagation(),this.selectItem(e))}selectItem(t){let e=this.isDoubleClick(),i=t.getAttribute("data-entity-type"),o=t.getAttribute("data-entity-id"),s=!t.classList.contains("selected")||e;this.unselectAll(),this.input.value=s?`${i}:${o}`:"";let r=t.getAttribute("href"),a=t.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:r};s?t.classList.add("selected"):window.$events.emit("entity-select-change",null),!(!e&&!s)&&(e&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(t){window.$events.emit("entity-select-confirm",t)}unselectAll(){let t=this.elem.querySelectorAll(".selected");for(let e of t)e.classList.remove("selected","primary-background")}};var un=class extends d{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(t,e={}){this.callback=t,this.getSelector().configureSearchOptions(e),this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(t){this.selection=t,t===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(t){this.hide(),this.getSelector().reset(),this.callback&&t&&this.callback(t)}};var pn=class extends d{setup(){this.container=this.$el,this.name=this.$opts.name,L(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var mn=class extends d{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){Ut(t,200)}close(t){qt(t,200)}click(t){t.preventDefault();let e=document.querySelectorAll(this.targetSelector);for(let i of e)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(t){window.$http.patch(this.updateEndpoint,{expand:t?"true":"false"})}};var fn=class extends d{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 i=Z(e);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(i),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var gn=class extends d{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 vn=class extends d{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(){L(this.filterTabs,i=>{this.resetAll(),this.filter=i.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",i=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),i.preventDefault()}),L(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),A(this.container,".load-more button","click",this.runLoadMore.bind(this)),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",i=>{i.target.src=window.baseUrl("loading_error.png")},!0),L(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),A(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),A(this.formContainer,"#image-manager-rebuild-thumbs","click",async(i,o)=>{o.disabled=!0,this.lastSelected&&await this.rebuildThumbnails(this.lastSelected.id),o.disabled=!1}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let t=this.listContainer.parentElement,e=[];t.addEventListener("wheel",i=>{if(!(Math.ceil(t.scrollHeight-t.scrollTop)===t.clientHeight)||i.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 i=e!=="gallery";this.dropzoneContainer.classList.toggle("hidden",i),this.uploadButton.classList.toggle("hidden",i),this.uploadHint.classList.toggle("hidden",i),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!i),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let 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),Qt(this.listContainer)}addReturnedHtmlElementsToList(t){let e=document.createElement("div");e.innerHTML=t;let i=e.querySelector(".load-more");i&&(i.remove(),this.loadMore.innerHTML=i.innerHTML),this.loadMore.toggleAttribute("hidden",!i),window.$components.init(e);for(let o of[...e.children])this.listContainer.appendChild(o)}setActiveFilterTab(t){for(let e of this.filterTabs){let i=e.dataset.filter===t;e.setAttribute("aria-selected",i?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value="",this.cancelSearch.toggleAttribute("hidden",!0)}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){Tt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}async onImageSelectEvent(t){let e=JSON.parse(t.detail.data),i=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&&!i?(t.target.classList.add("selected"),e=await this.loadImageEditForm(e.id)):i?i&&(e=this.lastSelected):this.resetEditForm(),this.selectButton.classList.toggle("hidden",o),i&&this.callback&&(this.callback(e),this.hide()),this.lastSelected=e,this.lastSelectedTime=Date.now()}async loadImageEditForm(t,e=!1){e||(this.formContainer.innerHTML="");let i=e?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${t}`,i);this.formContainer.innerHTML=o,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer);let s=this.formContainer.querySelector("#image-manager-form-image-data");return JSON.parse(s.text)}runLoadMore(){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 wn=class extends d{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 bn=class extends d{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 rt(n,t={},e=[]){let i=document.createElement(n),o=Object.keys(t);for(let s of o)t[s]!==null&&i.setAttribute(s,t[s]);for(let s of e)typeof s=="string"?i.append(document.createTextNode(s)):i.append(s);return i}var yn=class extends d{constructor(){super(...arguments);this.loadingEl=null}setup(){this.button=this.$el;let e=this.button.form,i=()=>{setTimeout(()=>this.showLoadingState(),10)};this.button.addEventListener("click",i),e&&e.addEventListener("submit",i)}showLoadingState(){this.button.disabled=!0,this.loadingEl||(this.loadingEl=rt("div",{class:"inline block"}),Tt(this.loadingEl),this.button.after(this.loadingEl))}};var En=class extends d{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(i=>i.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(i=>{this.editor=i,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,cmEditorView:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",t=>{let e=t.target.closest("button[data-action]");if(e===null)return;let i=e.getAttribute("data-action");if(i==="insertImage"&&this.editor.actions.showImageInsert(),i==="insertLink"&&this.editor.actions.showLinkSelector(),i==="insertDrawing"&&(t.ctrlKey||t.metaKey)){this.editor.actions.showImageManager();return}i==="insertDrawing"&&this.editor.actions.startDrawing(),i==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",t=>{let e=t.target.closest(".editor-toolbar-label");if(!e)return;let i=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of i)o.classList.remove("active");e.closest(".markdown-editor-wrap").classList.add("active")}),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",()=>{let e=this.elem.getBoundingClientRect(),i=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",i),window.removeEventListener("pointerup",o),this.display.style.pointerEvents=null,document.body.style.userSelect=null};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",i),window.addEventListener("pointerup",o)});let 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 Cn=class extends d{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 i of e)i.disabled=t;this.inputContainer.style.display=t?"none":"block"}};var xn=class extends d{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,i=Math.max(2e3,1e3+250*e);setTimeout(this.hide.bind(this),i)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var Ln=class extends d{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){L(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),L(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};function No(n){for(let t=1;t<5;t++)n.shortcuts.add(`meta+${t}`,"",["FormatBlock",!1,`h${t+1}`]);n.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+o","","InsertOrderedList"),n.shortcuts.add("meta+p","","InsertUnorderedList"),n.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),n.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),n.shortcuts.add("meta+9","",()=>{let t=n.selection.getNode(),e=t?t.closest(".callout"):null,i=["info","success","warning","danger"],s=(i.findIndex(a=>e&&e.classList.contains(a))+1)%i.length,r=i[s];n.formatter.apply(`callout${r}`)}),n.shortcuts.add("meta+shift+K","",()=>{let t=window.$components.first("entity-selector-popup"),e=n.selection.getContent({format:"text"}).trim();t.show(i=>{n.selection.isCollapsed()?n.insertContent(n.dom.createHTML("a",{href:i.link},n.dom.encode(i.name))):n.formatter.apply("link",{href:i.link}),n.selection.collapse(!1),n.focus()},{initialValue:e,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})})}function Fo(n){window.$events.listen("editor::replace",({html:t})=>{n.setContent(t)}),window.$events.listen("editor::append",({html:t})=>{let e=n.getContent()+t;n.setContent(e)}),window.$events.listen("editor::prepend",({html:t})=>{let e=t+n.getContent();n.setContent(e)}),window.$events.listen("editor::insert",({html:t})=>{n.insertContent(t)}),window.$events.listen("editor::focus",()=>{n.initialized&&n.focus()})}function ar(n,t){let e=n.dom.get(encodeURIComponent(t).replace(/!/g,"%21"));e&&(e.scrollIntoView(),n.selection.select(e,!0),n.selection.collapse(!1),n.focus())}function qo(n){let e=new URL(window.location).searchParams.get("content-id");e&&ar(n,e)}var Mt,Tn;function lr(n){return n&&!!(n.textContent||n.innerText)}async function cr(n,t){if(n===null||n.type.indexOf("image")!==0)throw new Error("Not an image file");let e=n.name||`image-${Date.now()}.png`,i=new FormData;return i.append("file",n,e),i.append("uploaded_to",t),(await window.$http.post(window.baseUrl("/images/gallery"),i)).data}function Uo(n,t,e){let i=new Vt(e.clipboardData||e.dataTransfer);if(!i.hasItems()||i.containsTabularData())return;let o=i.getImages();for(let s of o){let r=`image-${Math.random().toString(16).slice(2)}`,a=window.baseUrl("/loading.gif");e.preventDefault(),setTimeout(()=>{n.insertContent(`<p><img src="${a}" id="${r}"></p>`),cr(s,t.pageId).then(l=>{let c=l.name.replace(/"/g,""),u=`<img src="${l.thumbs.display}" alt="${c}" />`,h=n.dom.create("a",{target:"_blank",href:l.url},u);n.dom.replace(h,r)}).catch(l=>{n.dom.remove(r),window.$events.error(l?.data?.message||t.translations.imageUploadErrorText),console.error(l)})},10)}}function dr(n){let t=n.selection.getNode();t.nodeName==="IMG"&&(Mt=n.dom.getParent(t,".mceTemp"),!Mt&&t.parentNode.nodeName==="A"&&!lr(t.parentNode)&&(Mt=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(Tn=t)}function hr(n,t,e){let{dom:i}=n,o=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX,e.clientY,n.getDoc()),s=e.dataTransfer&&e.dataTransfer.getData("bookstack/template");s&&(e.preventDefault(),window.$http.get(`/templates/${s}`).then(r=>{n.selection.setRng(o),n.undoManager.transact(()=>{n.execCommand("mceInsertContent",!1,r.data.html)})})),i.getParent(o.startContainer,".mceTemp")?e.preventDefault():Mt&&(e.preventDefault(),n.undoManager.transact(()=>{n.selection.setRng(o),n.selection.setNode(Mt),i.remove(Mt)})),!e.isDefaultPrevented()&&Tn&&(e.preventDefault(),n.undoManager.transact(()=>{let r=n.selection.getNode(),a=n.selection.getRng(),l=r.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(Tn):l.before(Tn)})),e.isDefaultPrevented()||Uo(n,t,e),Mt=null}function ur(n,t){t.preventDefault(),n.focus();let i=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX??0,t.clientY??0,n.getDoc());n.selection.setRng(i)}function Vo(n,t){n.on("dragover",e=>ur(n,e)),n.on("dragstart",()=>dr(n)),n.on("drop",e=>hr(n,t,e)),n.on("paste",e=>Uo(n,t,e))}function Wo(n){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",n.textDirection==="rtl"?"ltr rtl":"","link customtable imagemanager-insert insertoverflow","code about fullscreen"].filter(i=>!!i).join(" | ")}function pr(n){n.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),n.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),n.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function mr(n){n.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(t){return t.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function fr(n){n.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(t){return t.closest("img")!==null&&!t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"image"})}function gr(n){n.ui.registry.addContextToolbar("objectcontexttoolbar",{predicate(t){return t.closest("img")!==null&&t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"media"})}function jo(n){pr(n),mr(n),fr(n),gr(n)}var vr={"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 zo(n){for(let[t,e]of Object.entries(vr))n.ui.registry.addIcon(t,e)}function wr(n){n.serializer.addNodeFilter("br",t=>{for(let e of t)if(e.parent&&e.parent.name==="code"){let i=window.tinymce.html.Node.create("#text");i.value=`
+`);this.error(e)}}showResponseError(t){t.status&&t.status>=400&&typeof t.data=="object"&&t.data.message&&this.error(t.data.message)}};var xt=class extends Error{constructor(t,e){super(t.statusText),this.data=e,this.headers=t.headers,this.redirected=t.redirected,this.status=t.status,this.statusText=t.statusText,this.url=t.url,this.original=t}},we=class{async getResponseContent(t){if(t.status===204)return null;let i=(t.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return i==="javascript"||i==="json"?t.json():t.text()}createXMLHttpRequest(t,e,i={}){let o=document.querySelector("meta[name=token]")?.getAttribute("content"),s=new XMLHttpRequest;for(let[r,a]of Object.entries(i))s.addEventListener(r,a.bind(s));return s.open(t,e),s.withCredentials=!0,s.setRequestHeader("X-CSRF-TOKEN",o||""),s}async request(t,e={}){let i=t;if(i.startsWith("http")||(i=window.baseUrl(i)),e.params){let c=new URL(i);for(let u of Object.keys(e.params)){let h=e.params[u];typeof h<"u"&&h!==null&&c.searchParams.set(u,h)}i=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(i,s),a=await this.getResponseContent(r)||"",l={data:a,headers:r.headers,redirected:r.redirected,status:r.status,statusText:r.statusText,url:r.url,original:r};if(!r.ok)throw new xt(r,a);return l}async dataRequest(t,e,i){let o={method:t,body:i};return typeof i=="object"&&!(i instanceof FormData)&&(o.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},o.body=JSON.stringify(i)),i instanceof FormData&&t!=="post"&&(i.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 i=Object.values(e);return i.every(s=>Array.isArray(s)&&s.every(r=>typeof r=="string"))?i.flat().join(" "):t}};var be=class{choice(t,e,i={}){i=Object.assign({},{count:String(e)},i);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,i)}performReplacements(t,e){let i=t.match(/:(\S+)/g);if(i===null)return t;let o=t;for(let s of i){let r=s.substring(1);typeof e[r]>"u"||(o=o.replace(s,e[r]))}return o}};var Ki={};ks(Ki,{AddRemoveRows:()=>xe,AjaxDeleteRow:()=>Le,AjaxForm:()=>Te,Attachments:()=>Se,AttachmentsList:()=>ke,AutoSubmit:()=>Me,AutoSuggest:()=>$e,BackToTop:()=>De,BookSort:()=>Xe,ChapterContents:()=>Ye,CodeEditor:()=>Je,CodeHighlighter:()=>Ze,CodeTextarea:()=>Qe,Collapsible:()=>tn,ConfirmDialog:()=>en,CustomCheckbox:()=>nn,DetailsHighlighter:()=>on,Dropdown:()=>sn,DropdownSearch:()=>rn,Dropzone:()=>an,EditorToolbox:()=>ln,EntityPermissions:()=>cn,EntitySearch:()=>dn,EntitySelector:()=>hn,EntitySelectorPopup:()=>un,EventEmitSelect:()=>pn,ExpandToggle:()=>mn,GlobalSearch:()=>fn,HeaderMobileToggle:()=>gn,ImageManager:()=>vn,ImagePicker:()=>wn,ListSortControl:()=>bn,LoadingButton:()=>yn,MarkdownEditor:()=>En,NewUserPassword:()=>Cn,Notification:()=>xn,OptionalInput:()=>Ln,PageComment:()=>Dn,PageCommentReference:()=>An,PageComments:()=>In,PageDisplay:()=>Hn,PageEditor:()=>Bn,PagePicker:()=>Rn,PermissionsTable:()=>On,Pointer:()=>_n,Popup:()=>Nn,SettingAppColorScheme:()=>Fn,SettingColorPicker:()=>qn,SettingHomepageControl:()=>Un,ShelfSort:()=>jn,ShortcutInput:()=>Kn,Shortcuts:()=>zn,SortRuleManager:()=>Gn,SortableList:()=>Xn,SubmitOnChange:()=>Yn,Tabs:()=>zt,TagManager:()=>Jn,TemplateManager:()=>Zn,ToggleSwitch:()=>Qn,TriLayout:()=>ti,UserSelect:()=>ei,WebhookEvents:()=>ni,WysiwygEditor:()=>ii,WysiwygEditorTinymce:()=>oi,WysiwygInput:()=>si});function mt(n,t,e){let i=null;return function(...s){let r=this,a=function(){i=null,e||n.apply(r,s)},l=e&&!i;i&&clearTimeout(i),i=window.setTimeout(a,t),l&&n.apply(r,s)}}function Ms(n){return n.nodeName==="DETAILS"}function Lt(n){if(!n)return;let t=n;for(;t.parentElement;)t=t.parentElement,Ms(t)&&!t.open&&(t.open=!0);n.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-link");n.style.outline=`2px dashed ${e}`,n.style.outlineOffset="5px",n.style.removeProperty("transition"),setTimeout(()=>{n.style.transition="outline linear 3s",n.style.outline="2px dashed rgba(0, 0, 0, 0)";let i=()=>{n.removeEventListener("transitionend",i),n.style.removeProperty("transition"),n.style.removeProperty("outline"),n.style.removeProperty("outlineOffset")};n.addEventListener("transitionend",i)},1e3)}function Qi(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function to(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}function eo(n){return new Promise(t=>{setTimeout(t,n)})}function no(n){let t=n,e=document.querySelector('meta[name="base-url"]');if(!e)throw new Error("Could not find expected base-url meta tag in document");let i=e.getAttribute("content")||"";return i[i.length-1]==="/"&&(i=i.slice(0,i.length-1)),t[0]==="/"&&(t=t.slice(1)),`${i}/${t}`}function Ds(){let n=document.querySelector('link[href*="/dist/styles.css?version="]');if(!n)throw new Error("Could not find expected style link in document for version use");return(n.getAttribute("href")||"").split("?version=").pop()||""}function io(n){return import(window.baseUrl(`dist/${n}.js?version=${Ds()}`))}function oo(n,t=0){let e=3735928559^t,i=1103547991^t;for(let o=0,s;o<n.length;o++)s=n.charCodeAt(o),e=Math.imul(e^s,2654435761),i=Math.imul(i^s,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(e^e>>>13,3266489909),String(4294967296*(2097151&i)+(e>>>0))}function ft(n){return n instanceof HTMLElement}function it(n,t={},e=[]){let i=document.createElement(n);for(let[o,s]of Object.entries(t))s===null?i.removeAttribute(o):i.setAttribute(o,s);for(let o of e)typeof o=="string"?i.append(document.createTextNode(o)):i.append(o);return i}function ai(n,t){let e=document.querySelectorAll(n);for(let i of e)t(i)}function ye(n,t,e){if(n)for(let i of t)n.addEventListener(i,e)}function L(n,t){Array.isArray(n)||(n=[n]);for(let e of n)e.addEventListener("click",t),e.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),t(i))})}function so(n,t,e){Array.isArray(t)||(t=[t]);let i=o=>{o.key===n&&e(o)};t.forEach(o=>o.addEventListener("keydown",i))}function Ht(n,t){so("Enter",n,t)}function ro(n,t){so("Escape",n,t)}function A(n,t,e,i){n.addEventListener(e,o=>{let s=o.target?.closest(t);s&&i.call(s,o,s)})}function ao(n,t){let e=document.querySelectorAll(n);t=t.toLowerCase();for(let i of e)if((i.textContent||"").toLowerCase().includes(t)&&ft(i))return i;return null}function Tt(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Bt(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function Qt(n){let t=n.querySelectorAll(".loading-container");for(let e of t)e.remove()}function Z(n){let t=document.createElement("div");t.innerHTML=n,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 li(n,t,e){if(!e.contains(n))throw new Error("ParentElement must be a prent of element");let i=t,o=n.nodeType===Node.TEXT_NODE?n:n.childNodes[t];for(;o!==e&&o;)o.previousSibling?(o=o.previousSibling,i+=o.textContent?.length||0):o=o.parentNode;return i}function Ee(n,t){if(t===0)return{node:n,offset:0};let e=0,i=null;for(let o=0;o<n.childNodes.length;o++)if(i=n.childNodes[o],i.nodeType===Node.TEXT_NODE){let s=(i.textContent||"").length;if(e+s>=t)return{node:i,offset:t-e};e+=s}else if(i.nodeType===Node.ELEMENT_NODE){let s=(i.textContent||"").length;if(e+s>=t)return Ee(i,t-e);e+=s}return null}function Ce(n){let t=(n.textContent||"").replace(/\s{2,}/g,"");return oo(t)}var d=class{constructor(){U(this,"$name","");U(this,"$el",null);U(this,"$refs",{});U(this,"$manyRefs",{});U(this,"$opts",{})}setup(){}$emit(t,e={}){e.from=this;let i=this.$name,o=new CustomEvent(`${i}-${t}`,{bubbles:!0,detail:e});this.$el.dispatchEvent(o)}};var xe=class extends d{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)),A(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=to(),i=t.querySelectorAll('[name*="randrowid"]');for(let o of i)o.name=o.name.split("randrowid").join(e)}};var Le=class extends d{constructor(){super(...arguments);this.deleteButtons=[]}setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete||[],L(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 Te=class extends d{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=>L(t,this.submitFakeForm.bind(this)))}submitFakeForm(){let t=new FormData,e=this.container.querySelectorAll("[name]");for(let i of e)t.append(i.getAttribute("name"),i.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 Se=class extends d{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 i=e.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(i);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(t){let e={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[i,o]of Object.entries(e))o.toggleAttribute("hidden",i!==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 ke=class extends d{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,di,hi,gt=class{constructor(t,e=null,i=null){Zi(this,vt);this.containers=[t],this.onEscape=e,this.onEnter=i,t.addEventListener("keydown",Zt(this,vt,di).bind(this))}shareHandlingToEl(t){this.containers.push(t),t.addEventListener("keydown",Zt(this,vt,di).bind(this))}focusNext(){let t=Zt(this,vt,hi).call(this),e=document.activeElement,o=(ft(e)?t.indexOf(e):-1)+1;o>=t.length&&(o=0),t[o].focus()}focusPrevious(){let t=Zt(this,vt,hi).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,di=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))},hi=function(){let t=[],e='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers){let o=[...i.querySelectorAll(e)].filter(s=>ft(s));t.push(...o)}return t};var ui={},$e=class extends d{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 i=e.target.textContent;i&&this.selectSuggestion(i)}).shareHandlingToEl(this.input),A(this.list,".text-item","click",(e,i)=>{this.selectSuggestion(i.textContent)}),this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.input.addEventListener("keydown",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 i={search:t,name:e},o=`${this.url}:${JSON.stringify(i)}`;if(ui[o])return ui[o];let s=await window.$http.get(this.url,i);return ui[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">${Qi(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 Me=class extends d{setup(){this.form=this.$el,this.form.submit()}};var De=class extends d{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,i=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function r(){let a=1-(Date.now()-o)/i,l=Math.abs(a*s);a>0?(e.scrollTop=l,requestAnimationFrame(r.bind(this))):e.scrollTop=t}requestAnimationFrame(r.bind(this))}};function lo(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(n,o).enumerable})),e.push.apply(e,i)}return e}function st(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?lo(Object(e),!0).forEach(function(i){As(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):lo(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function Oe(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(t){return typeof t}:Oe=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oe(n)}function As(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function et(){return et=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},et.apply(this,arguments)}function Is(n,t){if(n==null)return{};var e={},i=Object.keys(n),o,s;for(s=0;s<i.length;s++)o=i[s],!(t.indexOf(o)>=0)&&(e[o]=n[o]);return e}function Hs(n,t){if(n==null)return{};var e=Is(n,t),i,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(o=0;o<s.length;o++)i=s[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(e[i]=n[i])}return e}function Bs(n){return Ps(n)||Rs(n)||Os(n)||_s()}function Ps(n){if(Array.isArray(n))return xi(n)}function Rs(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Os(n,t){if(n){if(typeof n=="string")return xi(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);if(e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set")return Array.from(n);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return xi(n,t)}}function xi(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,i=new Array(t);e<t;e++)i[e]=n[e];return i}function _s(){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 Ns="1.15.6";function ct(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var dt=ct(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),ue=ct(/Edge/i),co=ct(/firefox/i),ae=ct(/safari/i)&&!ct(/chrome/i)&&!ct(/android/i),$i=ct(/iP(ad|od|hone)/i),yo=ct(/chrome/i)&&ct(/android/i),Eo={capture:!1,passive:!1};function E(n,t,e){n.addEventListener(t,e,!dt&&Eo)}function y(n,t,e){n.removeEventListener(t,e,!dt&&Eo)}function Ue(n,t){if(t){if(t[0]===">"&&(t=t.substring(1)),n)try{if(n.matches)return n.matches(t);if(n.msMatchesSelector)return n.msMatchesSelector(t);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(t)}catch{return!1}return!1}}function Co(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function j(n,t,e,i){if(n){e=e||document;do{if(t!=null&&(t[0]===">"?n.parentNode===e&&Ue(n,t):Ue(n,t))||i&&n===e)return n;if(n===e)break}while(n=Co(n))}return null}var ho=/\s+/g;function B(n,t,e){if(n&&t)if(n.classList)n.classList[e?"add":"remove"](t);else{var i=(" "+n.className+" ").replace(ho," ").replace(" "+t+" "," ");n.className=(i+(e?" "+t:"")).replace(ho," ")}}function f(n,t,e){var i=n&&n.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(e=n.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Mt(n,t){var e="";if(typeof n=="string")e=n;else do{var i=f(n,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(n=n.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function xo(n,t,e){if(n){var i=n.getElementsByTagName(t),o=0,s=i.length;if(e)for(;o<s;o++)e(i[o],o);return i}return[]}function ot(){var n=document.scrollingElement;return n||document.documentElement}function $(n,t,e,i,o){if(!(!n.getBoundingClientRect&&n!==window)){var s,r,a,l,c,u,h;if(n!==window&&n.parentNode&&n!==ot()?(s=n.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,h=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(t||e)&&n!==window&&(o=o||n.parentNode,!dt))do if(o&&o.getBoundingClientRect&&(f(o,"transform")!=="none"||e&&f(o,"position")!=="static")){var m=o.getBoundingClientRect();r-=m.top+parseInt(f(o,"border-top-width")),a-=m.left+parseInt(f(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(i&&n!==window){var g=Mt(o||n),C=g&&g.a,T=g&&g.d;g&&(r/=T,a/=C,h/=C,u/=T,l=r+u,c=a+h)}return{top:r,left:a,bottom:l,right:c,width:h,height:u}}}function uo(n,t,e){for(var i=yt(n,!0),o=$(n)[t];i;){var s=$(i)[e],r=void 0;if(e==="top"||e==="left"?r=o>=s:r=o<=s,!r)return i;if(i===ot())break;i=yt(i,!1)}return!1}function Ft(n,t,e,i){for(var o=0,s=0,r=n.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==v.ghost&&(i||r[s]!==v.dragged)&&j(r[s],e.draggable,n,!1)){if(o===t)return r[s];o++}s++}return null}function Mi(n,t){for(var e=n.lastElementChild;e&&(e===v.ghost||f(e,"display")==="none"||t&&!Ue(e,t));)e=e.previousElementSibling;return e||null}function P(n,t){var e=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==v.clone&&(!t||Ue(n,t))&&e++;return e}function po(n){var t=0,e=0,i=ot();if(n)do{var o=Mt(n),s=o.a,r=o.d;t+=n.scrollLeft*s,e+=n.scrollTop*r}while(n!==i&&(n=n.parentNode));return[t,e]}function Fs(n,t){for(var e in n)if(n.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===n[e][i])return Number(e)}return-1}function yt(n,t){if(!n||!n.getBoundingClientRect)return ot();var e=n,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var o=f(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 ot();if(i||t)return e;i=!0}}while(e=e.parentNode);return ot()}function qs(n,t){if(n&&t)for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}function pi(n,t){return Math.round(n.top)===Math.round(t.top)&&Math.round(n.left)===Math.round(t.left)&&Math.round(n.height)===Math.round(t.height)&&Math.round(n.width)===Math.round(t.width)}var le;function Lo(n,t){return function(){if(!le){var e=arguments,i=this;e.length===1?n.call(i,e[0]):n.apply(i,e),le=setTimeout(function(){le=void 0},t)}}}function Us(){clearTimeout(le),le=void 0}function To(n,t,e){n.scrollLeft+=t,n.scrollTop+=e}function Di(n){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(n).cloneNode(!0):e?e(n).clone(!0)[0]:n.cloneNode(!0)}function mo(n,t){f(n,"position","absolute"),f(n,"top",t.top),f(n,"left",t.left),f(n,"width",t.width),f(n,"height",t.height)}function mi(n){f(n,"position",""),f(n,"top",""),f(n,"left",""),f(n,"width",""),f(n,"height","")}function So(n,t,e){var i={};return Array.from(n.children).forEach(function(o){var s,r,a,l;if(!(!j(o,t.draggable,n,!1)||o.animated||o===e)){var c=$(o);i.left=Math.min((s=i.left)!==null&&s!==void 0?s:1/0,c.left),i.top=Math.min((r=i.top)!==null&&r!==void 0?r:1/0,c.top),i.right=Math.max((a=i.right)!==null&&a!==void 0?a:-1/0,c.right),i.bottom=Math.max((l=i.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var _="Sortable"+new Date().getTime();function Vs(){var n=[],t;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(o){if(!(f(o,"display")==="none"||o===v.ghost)){n.push({target:o,rect:$(o)});var s=st({},n[n.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(i){n.push(i)},removeAnimationState:function(i){n.splice(Fs(n,{target:i}),1)},animateAll:function(i){var o=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var s=!1,r=0;n.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=$(c),m=c.prevFromRect,g=c.prevToRect,C=a.rect,T=Mt(c,!0);T&&(h.top-=T.f,h.left-=T.e),c.toRect=h,c.thisAnimationDuration&&pi(m,h)&&!pi(u,h)&&(C.top-h.top)/(C.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=js(C,m,g,o.options)),pi(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=o.options.animation),o.animate(c,C,h,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 i=="function"&&i()},r):typeof i=="function"&&i(),n=[]},animate:function(i,o,s,r){if(r){f(i,"transition",""),f(i,"transform","");var a=Mt(this.el),l=a&&a.a,c=a&&a.d,u=(o.left-s.left)/(l||1),h=(o.top-s.top)/(c||1);i.animatingX=!!u,i.animatingY=!!h,f(i,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=Ws(i),f(i,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),f(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){f(i,"transition",""),f(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},r)}}}}function Ws(n){return n.offsetWidth}function js(n,t,e,i){return Math.sqrt(Math.pow(t.top-n.top,2)+Math.pow(t.left-n.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var Pt=[],fi={initializeByDefault:!0},pe={mount:function(t){for(var e in fi)fi.hasOwnProperty(e)&&!(e in t)&&(t[e]=fi[e]);Pt.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),Pt.push(t)},pluginEvent:function(t,e,i){var o=this;this.eventCanceled=!1,i.cancel=function(){o.eventCanceled=!0};var s=t+"Global";Pt.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][s]&&e[r.pluginName][s](st({sortable:e},i)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](st({sortable:e},i)))})},initializePlugins:function(t,e,i,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,et(i,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 i={};return Pt.forEach(function(o){typeof o.eventProperties=="function"&&et(i,o.eventProperties.call(e[o.pluginName],t))}),i},modifyOption:function(t,e,i){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],i))}),o}};function ie(n){var t=n.sortable,e=n.rootEl,i=n.name,o=n.targetEl,s=n.cloneEl,r=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,u=n.oldDraggableIndex,h=n.newDraggableIndex,m=n.originalEvent,g=n.putSortable,C=n.extraEventProperties;if(t=t||e&&e[_],!!t){var T,F=t.options,Y="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!dt&&!ue?T=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(T=document.createEvent("Event"),T.initEvent(i,!0,!0)),T.to=r||e,T.from=a||e,T.item=o||e,T.clone=s,T.oldIndex=l,T.newIndex=c,T.oldDraggableIndex=u,T.newDraggableIndex=h,T.originalEvent=m,T.pullMode=g?g.lastPutMode:void 0;var x=st(st({},C),pe.getEventProperties(i,t));for(var S in x)T[S]=x[S];e&&e.dispatchEvent(T),F[Y]&&F[Y].call(t,T)}}var zs=["evt"],V=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.evt,s=Hs(i,zs);pe.pluginEvent.bind(v)(t,e,st({dragEl:p,parentEl:I,ghostEl:b,rootEl:M,nextEl:$t,lastDownEl:_e,cloneEl:D,cloneHidden:bt,dragStarted:oe,putSortable:O,activeSortable:v.active,originalEvent:o,oldIndex:Nt,oldDraggableIndex:ce,newIndex:G,newDraggableIndex:wt,hideGhostForTarget:Do,unhideGhostForTarget:Ao,cloneNowHidden:function(){bt=!0},cloneNowShown:function(){bt=!1},dispatchSortableEvent:function(a){q({sortable:e,name:a,originalEvent:o})}},s))};function q(n){ie(st({putSortable:O,cloneEl:D,targetEl:p,rootEl:M,oldIndex:Nt,oldDraggableIndex:ce,newIndex:G,newDraggableIndex:wt},n))}var p,I,b,M,$t,_e,D,bt,Nt,G,ce,wt,Ae,O,_t=!1,Ve=!1,We=[],St,Q,gi,vi,fo,go,oe,Rt,de,he=!1,Ie=!1,Ne,N,wi=[],Li=!1,je=[],Ke=typeof document<"u",He=$i,vo=ue||dt?"cssFloat":"float",Ks=Ke&&!yo&&!$i&&"draggable"in document.createElement("div"),ko=function(){if(Ke){if(dt)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),$o=function(t,e){var i=f(t),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),s=Ft(t,0,e),r=Ft(t,1,e),a=s&&f(s),l=r&&f(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+$(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+$(r).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&i[vo]==="none"||r&&i[vo]==="none"&&c+u>o)?"vertical":"horizontal"},Xs=function(t,e,i){var o=i?t.left:t.top,s=i?t.right:t.bottom,r=i?t.width:t.height,a=i?e.left:e.top,l=i?e.right:e.bottom,c=i?e.width:e.height;return o===a||s===l||o+r/2===a+c/2},Gs=function(t,e){var i;return We.some(function(o){var s=o[_].options.emptyInsertThreshold;if(!(!s||Mi(o))){var r=$(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return i=o}}),i},Mo=function(t){function e(s,r){return function(a,l,c,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||h))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 m=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===m||s.join&&s.indexOf(m)>-1}}var i={},o=t.group;(!o||Oe(o)!="object")&&(o={name:o}),i.name=o.name,i.checkPull=e(o.pull,!0),i.checkPut=e(o.put),i.revertClone=o.revertClone,t.group=i},Do=function(){!ko&&b&&f(b,"display","none")},Ao=function(){!ko&&b&&f(b,"display","")};Ke&&!yo&&document.addEventListener("click",function(n){if(Ve)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Ve=!1,!1},!0);var kt=function(t){if(p){t=t.touches?t.touches[0]:t;var e=Gs(t.clientX,t.clientY);if(e){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[_]._onDragOver(i)}}},Ys=function(t){p&&p.parentNode[_]._isOutsideThisEl(t.target)};function v(n,t){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=t=et({},t),n[_]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return $o(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:v.supportPointer!==!1&&"PointerEvent"in window&&(!ae||$i),emptyInsertThreshold:5};pe.initializePlugins(this,n,e);for(var i in e)!(i in t)&&(t[i]=e[i]);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:Ks,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?E(n,"pointerdown",this._onTapStart):(E(n,"mousedown",this._onTapStart),E(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(n,"dragover",this),E(n,"dragenter",this)),We.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),et(this,Vs())}v.prototype={constructor:v,_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,p):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=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(or(i),!p&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&ae&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=j(l,o.draggable,i,!1),!(l&&l.animated)&&_e!==l)){if(Nt=P(l),ce=P(l,o.draggable),typeof u=="function"){if(u.call(this,t,l,this)){q({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),V("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=j(c,h.trim(),i,!1),h)return q({sortable:e,rootEl:h,name:"filter",targetEl:l,fromEl:i,toEl:i}),V("filter",e,{evt:t}),!0}),u)){s&&t.preventDefault();return}o.handle&&!j(c,o.handle,i,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,i){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(i&&!p&&i.parentNode===s){var c=$(i);if(M=s,p=i,I=p.parentNode,$t=p.nextSibling,_e=i,Ae=r.group,v.dragged=p,St={target:p,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,p.style["will-change"]="all",l=function(){if(V("delayEnded",o,{evt:t}),v.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!co&&o.nativeDraggable&&(p.draggable=!0),o._triggerDragStart(t,e),q({sortable:o,name:"choose",originalEvent:t}),B(p,r.chosenClass,!0)},r.ignore.split(",").forEach(function(u){xo(p,u.trim(),bi)}),E(a,"dragover",kt),E(a,"mousemove",kt),E(a,"touchmove",kt),r.supportPointer?(E(a,"pointerup",o._onDrop),!this.nativeDraggable&&E(a,"pointercancel",o._onDrop)):(E(a,"mouseup",o._onDrop),E(a,"touchend",o._onDrop),E(a,"touchcancel",o._onDrop)),co&&this.nativeDraggable&&(this.options.touchStartThreshold=4,p.draggable=!0),V("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(ue||dt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(E(a,"pointerup",o._disableDelayedDrag),E(a,"pointercancel",o._disableDelayedDrag)):(E(a,"mouseup",o._disableDelayedDrag),E(a,"touchend",o._disableDelayedDrag),E(a,"touchcancel",o._disableDelayedDrag)),E(a,"mousemove",o._delayedDragTouchMoveHandler),E(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&E(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(){p&&bi(p),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;y(t,"mouseup",this._disableDelayedDrag),y(t,"touchend",this._disableDelayedDrag),y(t,"touchcancel",this._disableDelayedDrag),y(t,"pointerup",this._disableDelayedDrag),y(t,"pointercancel",this._disableDelayedDrag),y(t,"mousemove",this._delayedDragTouchMoveHandler),y(t,"touchmove",this._delayedDragTouchMoveHandler),y(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?E(document,"pointermove",this._onTouchMove):e?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(p,"dragend",this),E(M,"dragstart",this._onDragStart));try{document.selection?Fe(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(_t=!1,M&&p){V("dragStarted",this,{evt:e}),this.nativeDraggable&&E(document,"dragover",Ys);var i=this.options;!t&&B(p,i.dragClass,!1),B(p,i.ghostClass,!0),v.active=this,t&&this._appendGhost(),q({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Q){this._lastX=Q.clientX,this._lastY=Q.clientY,Do();for(var t=document.elementFromPoint(Q.clientX,Q.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Q.clientX,Q.clientY),t!==e);)e=t;if(p.parentNode[_]._isOutsideThisEl(t),e)do{if(e[_]){var i=void 0;if(i=e[_]._onDragOver({clientX:Q.clientX,clientY:Q.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=Co(e));Ao()}},_onTouchMove:function(t){if(St){var e=this.options,i=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=b&&Mt(b,!0),a=b&&r&&r.a,l=b&&r&&r.d,c=He&&N&&po(N),u=(s.clientX-St.clientX+o.x)/(a||1)+(c?c[0]-wi[0]:0)/(a||1),h=(s.clientY-St.clientY+o.y)/(l||1)+(c?c[1]-wi[1]:0)/(l||1);if(!v.active&&!_t){if(i&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(b){r?(r.e+=u-(gi||0),r.f+=h-(vi||0)):r={a:1,b:0,c:0,d:1,e:u,f:h};var m="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");f(b,"webkitTransform",m),f(b,"mozTransform",m),f(b,"msTransform",m),f(b,"transform",m),gi=u,vi=h,Q=s}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!b){var t=this.options.fallbackOnBody?document.body:M,e=$(p,!0,He,!0,t),i=this.options;if(He){for(N=t;f(N,"position")==="static"&&f(N,"transform")==="none"&&N!==document;)N=N.parentNode;N!==document.body&&N!==document.documentElement?(N===document&&(N=ot()),e.top+=N.scrollTop,e.left+=N.scrollLeft):N=ot(),wi=po(N)}b=p.cloneNode(!0),B(b,i.ghostClass,!1),B(b,i.fallbackClass,!0),B(b,i.dragClass,!0),f(b,"transition",""),f(b,"transform",""),f(b,"box-sizing","border-box"),f(b,"margin",0),f(b,"top",e.top),f(b,"left",e.left),f(b,"width",e.width),f(b,"height",e.height),f(b,"opacity","0.8"),f(b,"position",He?"absolute":"fixed"),f(b,"zIndex","100000"),f(b,"pointerEvents","none"),v.ghost=b,t.appendChild(b),f(b,"transform-origin",fo/parseInt(b.style.width)*100+"% "+go/parseInt(b.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,o=t.dataTransfer,s=i.options;if(V("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}V("setupClone",this),v.eventCanceled||(D=Di(p),D.removeAttribute("id"),D.draggable=!1,D.style["will-change"]="",this._hideClone(),B(D,this.options.chosenClass,!1),v.clone=D),i.cloneId=Fe(function(){V("clone",i),!v.eventCanceled&&(i.options.removeCloneOnHide||M.insertBefore(D,p),i._hideClone(),q({sortable:i,name:"clone"}))}),!e&&B(p,s.dragClass,!0),e?(Ve=!0,i._loopId=setInterval(i._emulateDragOver,50)):(y(document,"mouseup",i._onDrop),y(document,"touchend",i._onDrop),y(document,"touchcancel",i._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(i,o,p)),E(document,"drop",i),f(p,"transform","translateZ(0)")),_t=!0,i._dragStartId=Fe(i._dragStarted.bind(i,e,t)),E(document,"selectstart",i),oe=!0,window.getSelection().removeAllRanges(),ae&&f(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,o,s,r,a=this.options,l=a.group,c=v.active,u=Ae===l,h=a.sort,m=O||c,g,C=this,T=!1;if(Li)return;function F(Jt,Ls){V(Jt,C,st({evt:t,isOwner:u,axis:g?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:h,fromSortable:m,target:i,completed:x,onMove:function(Gi,Ts){return Be(M,e,p,o,Gi,$(Gi),t,Ts)},changed:S},Ls))}function Y(){F("dragOverAnimationCapture"),C.captureAnimationState(),C!==m&&m.captureAnimationState()}function x(Jt){return F("dragOverCompleted",{insertion:Jt}),Jt&&(u?c._hideClone():c._showClone(C),C!==m&&(B(p,O?O.options.ghostClass:c.options.ghostClass,!1),B(p,a.ghostClass,!0)),O!==C&&C!==v.active?O=C:C===v.active&&O&&(O=null),m===C&&(C._ignoreWhileAnimating=i),C.animateAll(function(){F("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==m&&(m.animateAll(),m._ignoreWhileAnimating=null)),(i===p&&!p.animated||i===e&&!i.animated)&&(Rt=null),!a.dragoverBubble&&!t.rootEl&&i!==document&&(p.parentNode[_]._isOutsideThisEl(t.target),!Jt&&kt(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),T=!0}function S(){G=P(p),wt=P(p,a.draggable),q({sortable:C,name:"change",toEl:e,newIndex:G,newDraggableIndex:wt,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=j(i,a.draggable,e,!0),F("dragOver"),v.eventCanceled)return T;if(p.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||C._ignoreWhileAnimating===i)return x(!1);if(Ve=!1,c&&!a.disabled&&(u?h||(r=I!==M):O===this||(this.lastPutMode=Ae.checkPull(this,c,p,t))&&l.checkPut(this,c,p,t))){if(g=this._getDirection(t,i)==="vertical",o=$(p),F("dragOverValid"),v.eventCanceled)return T;if(r)return I=M,Y(),this._hideClone(),F("revert"),v.eventCanceled||($t?M.insertBefore(p,$t):M.appendChild(p)),x(!0);var R=Mi(e,a.draggable);if(!R||tr(t,g,this)&&!R.animated){if(R===p)return x(!1);if(R&&e===t.target&&(i=R),i&&(s=$(i)),Be(M,e,p,o,i,s,t,!!i)!==!1)return Y(),R&&R.nextSibling?e.insertBefore(p,R.nextSibling):e.appendChild(p),I=e,S(),x(!0)}else if(R&&Qs(t,g,this)){var at=Ft(e,0,a,!0);if(at===p)return x(!1);if(i=at,s=$(i),Be(M,e,p,o,i,s,t,!1)!==!1)return Y(),e.insertBefore(p,at),I=e,S(),x(!0)}else if(i.parentNode===e){s=$(i);var J=0,Et,Kt=p.parentNode!==e,K=!Xs(p.animated&&p.toRect||o,i.animated&&i.toRect||s,g),Xt=g?"top":"left",ut=uo(i,"top","top")||uo(p,"top","top"),Gt=ut?ut.scrollTop:void 0;Rt!==i&&(Et=s[Xt],he=!1,Ie=!K&&a.invertSwap||Kt),J=er(t,i,s,g,K?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,Ie,Rt===i);var lt;if(J!==0){var Ct=P(p);do Ct-=J,lt=I.children[Ct];while(lt&&(f(lt,"display")==="none"||lt===b))}if(J===0||lt===i)return x(!1);Rt=i,de=J;var Yt=i.nextElementSibling,pt=!1;pt=J===1;var ge=Be(M,e,p,o,i,s,t,pt);if(ge!==!1)return(ge===1||ge===-1)&&(pt=ge===1),Li=!0,setTimeout(Zs,30),Y(),pt&&!Yt?e.appendChild(p):i.parentNode.insertBefore(p,pt?Yt:i),ut&&To(ut,0,Gt-ut.scrollTop),I=p.parentNode,Et!==void 0&&!Ie&&(Ne=Math.abs(Et-$(i)[Xt])),S(),x(!0)}if(e.contains(p))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){y(document,"mousemove",this._onTouchMove),y(document,"touchmove",this._onTouchMove),y(document,"pointermove",this._onTouchMove),y(document,"dragover",kt),y(document,"mousemove",kt),y(document,"touchmove",kt)},_offUpEvents:function(){var t=this.el.ownerDocument;y(t,"mouseup",this._onDrop),y(t,"touchend",this._onDrop),y(t,"pointerup",this._onDrop),y(t,"pointercancel",this._onDrop),y(t,"touchcancel",this._onDrop),y(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(G=P(p),wt=P(p,i.draggable),V("drop",this,{evt:t}),I=p&&p.parentNode,G=P(p),wt=P(p,i.draggable),v.eventCanceled){this._nulling();return}_t=!1,Ie=!1,he=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ti(this.cloneId),Ti(this._dragStartId),this.nativeDraggable&&(y(document,"drop",this),y(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),ae&&f(document.body,"user-select",""),f(p,"transform",""),t&&(oe&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),b&&b.parentNode&&b.parentNode.removeChild(b),(M===I||O&&O.lastPutMode!=="clone")&&D&&D.parentNode&&D.parentNode.removeChild(D),p&&(this.nativeDraggable&&y(p,"dragend",this),bi(p),p.style["will-change"]="",oe&&!_t&&B(p,O?O.options.ghostClass:this.options.ghostClass,!1),B(p,this.options.chosenClass,!1),q({sortable:this,name:"unchoose",toEl:I,newIndex:null,newDraggableIndex:null,originalEvent:t}),M!==I?(G>=0&&(q({rootEl:I,name:"add",toEl:I,fromEl:M,originalEvent:t}),q({sortable:this,name:"remove",toEl:I,originalEvent:t}),q({rootEl:I,name:"sort",toEl:I,fromEl:M,originalEvent:t}),q({sortable:this,name:"sort",toEl:I,originalEvent:t})),O&&O.save()):G!==Nt&&G>=0&&(q({sortable:this,name:"update",toEl:I,originalEvent:t}),q({sortable:this,name:"sort",toEl:I,originalEvent:t})),v.active&&((G==null||G===-1)&&(G=Nt,wt=ce),q({sortable:this,name:"end",toEl:I,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){V("nulling",this),M=p=I=b=$t=D=_e=bt=St=Q=oe=G=wt=Nt=ce=Rt=de=O=Ae=v.dragged=v.ghost=v.clone=v.active=null,je.forEach(function(t){t.checked=!0}),je.length=gi=vi=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":p&&(this._onDragOver(t),Js(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,o=0,s=i.length,r=this.options;o<s;o++)e=i[o],j(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||ir(e));return t},sort:function(t,e){var i={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];j(a,this.options.draggable,o,!1)&&(i[s]=a)},this),e&&this.captureAnimationState(),t.forEach(function(s){i[s]&&(o.removeChild(i[s]),o.appendChild(i[s]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return j(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var o=pe.modifyOption(this,t,e);typeof o<"u"?i[t]=o:i[t]=e,t==="group"&&Mo(i)},destroy:function(){V("destroy",this);var t=this.el;t[_]=null,y(t,"mousedown",this._onTapStart),y(t,"touchstart",this._onTapStart),y(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(y(t,"dragover",this),y(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(V("hideClone",this),v.eventCanceled)return;f(D,"display","none"),this.options.removeCloneOnHide&&D.parentNode&&D.parentNode.removeChild(D),bt=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(bt){if(V("showClone",this),v.eventCanceled)return;p.parentNode==M&&!this.options.group.revertClone?M.insertBefore(D,p):$t?M.insertBefore(D,$t):M.appendChild(D),this.options.group.revertClone&&this.animate(p,D),f(D,"display",""),bt=!1}}};function Js(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function Be(n,t,e,i,o,s,r,a){var l,c=n[_],u=c.options.onMove,h;return window.CustomEvent&&!dt&&!ue?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=n,l.dragged=e,l.draggedRect=i,l.related=o||t,l.relatedRect=s||$(t),l.willInsertAfter=a,l.originalEvent=r,n.dispatchEvent(l),u&&(h=u.call(c,l,r)),h}function bi(n){n.draggable=!1}function Zs(){Li=!1}function Qs(n,t,e){var i=$(Ft(e.el,0,e.options,!0)),o=So(e.el,e.options,b),s=10;return t?n.clientX<o.left-s||n.clientY<i.top&&n.clientX<i.right:n.clientY<o.top-s||n.clientY<i.bottom&&n.clientX<i.left}function tr(n,t,e){var i=$(Mi(e.el,e.options.draggable)),o=So(e.el,e.options,b),s=10;return t?n.clientX>o.right+s||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>o.bottom+s||n.clientX>i.right&&n.clientY>i.top}function er(n,t,e,i,o,s,r,a){var l=i?n.clientY:n.clientX,c=i?e.height:e.width,u=i?e.top:e.left,h=i?e.bottom:e.right,m=!1;if(!r){if(a&&Ne<c*o){if(!he&&(de===1?l>u+c*s/2:l<h-c*s/2)&&(he=!0),he)m=!0;else if(de===1?l<u+Ne:l>h-Ne)return-de}else if(l>u+c*(1-o)/2&&l<h-c*(1-o)/2)return nr(t)}return m=m||r,m&&(l<u+c*s/2||l>h-c*s/2)?l>u+c/2?1:-1:0}function nr(n){return P(p)<P(n)?1:-1}function ir(n){for(var t=n.tagName+n.className+n.src+n.href+n.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function or(n){je.length=0;for(var t=n.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&je.push(i)}}function Fe(n){return setTimeout(n,0)}function Ti(n){return clearTimeout(n)}Ke&&E(document,"touchmove",function(n){(v.active||_t)&&n.cancelable&&n.preventDefault()});v.utils={on:E,off:y,css:f,find:xo,is:function(t,e){return!!j(t,e,t,!1)},extend:qs,throttle:Lo,closest:j,toggleClass:B,clone:Di,index:P,nextTick:Fe,cancelNextTick:Ti,detectDirection:$o,getChild:Ft,expando:_};v.get=function(n){return n[_]};v.mount=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(v.utils=st(st({},v.utils),i.utils)),pe.mount(i)})};v.create=function(n,t){return new v(n,t)};v.version=Ns;var H=[],se,Si,ki=!1,yi,Ei,ze,re;function sr(){function n(){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 n.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):i.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?y(document,"dragover",this._handleAutoScroll):(y(document,"pointermove",this._handleFallbackAutoScroll),y(document,"touchmove",this._handleFallbackAutoScroll),y(document,"mousemove",this._handleFallbackAutoScroll)),wo(),qe(),Us()},nulling:function(){ze=Si=se=ki=re=yi=Ei=null,H.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){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(ze=e,i||this.options.forceAutoScrollFallback||ue||dt||ae){Ci(e,this.options,a,i);var l=yt(a,!0);ki&&(!re||s!==yi||r!==Ei)&&(re&&wo(),re=setInterval(function(){var c=yt(document.elementFromPoint(s,r),!0);c!==l&&(l=c,qe()),Ci(e,o.options,c,i)},10),yi=s,Ei=r)}else{if(!this.options.bubbleScroll||yt(a,!0)===ot()){qe();return}Ci(e,this.options,yt(a,!1),!1)}}},et(n,{pluginName:"scroll",initializeByDefault:!0})}function qe(){H.forEach(function(n){clearInterval(n.pid)}),H=[]}function wo(){clearInterval(re)}var Ci=Lo(function(n,t,e,i){if(t.scroll){var o=(n.touches?n.touches[0]:n).clientX,s=(n.touches?n.touches[0]:n).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=ot(),c=!1,u;Si!==e&&(Si=e,qe(),se=t.scroll,u=t.scrollFn,se===!0&&(se=yt(e,!0)));var h=0,m=se;do{var g=m,C=$(g),T=C.top,F=C.bottom,Y=C.left,x=C.right,S=C.width,R=C.height,at=void 0,J=void 0,Et=g.scrollWidth,Kt=g.scrollHeight,K=f(g),Xt=g.scrollLeft,ut=g.scrollTop;g===l?(at=S<Et&&(K.overflowX==="auto"||K.overflowX==="scroll"||K.overflowX==="visible"),J=R<Kt&&(K.overflowY==="auto"||K.overflowY==="scroll"||K.overflowY==="visible")):(at=S<Et&&(K.overflowX==="auto"||K.overflowX==="scroll"),J=R<Kt&&(K.overflowY==="auto"||K.overflowY==="scroll"));var Gt=at&&(Math.abs(x-o)<=r&&Xt+S<Et)-(Math.abs(Y-o)<=r&&!!Xt),lt=J&&(Math.abs(F-s)<=r&&ut+R<Kt)-(Math.abs(T-s)<=r&&!!ut);if(!H[h])for(var Ct=0;Ct<=h;Ct++)H[Ct]||(H[Ct]={});(H[h].vx!=Gt||H[h].vy!=lt||H[h].el!==g)&&(H[h].el=g,H[h].vx=Gt,H[h].vy=lt,clearInterval(H[h].pid),(Gt!=0||lt!=0)&&(c=!0,H[h].pid=setInterval(function(){i&&this.layer===0&&v.active._onTouchMove(ze);var Yt=H[this.layer].vy?H[this.layer].vy*a:0,pt=H[this.layer].vx?H[this.layer].vx*a:0;typeof u=="function"&&u.call(v.dragged.parentNode[_],pt,Yt,n,ze,H[this.layer].el)!=="continue"||To(H[this.layer].el,pt,Yt)}.bind({layer:h}),24))),h++}while(t.bubbleScroll&&m!==l&&(m=yt(m,!1)));ki=c}},30),Io=function(t){var e=t.originalEvent,i=t.putSortable,o=t.dragEl,s=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=i||s;a();var u=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(r("spill"),this.onSpill({dragEl:o,putSortable:i}))}};function Ai(){}Ai.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var o=Ft(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:Io};et(Ai,{pluginName:"revertOnSpill"});function Ii(){}Ii.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,o=i||this.sortable;o.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),o.animateAll()},drop:Io};et(Ii,{pluginName:"removeOnSpill"});var w=[],X=[],te,tt,ee=!1,W=!1,Ot=!1,k,ne,Pe;function Ho(){function n(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?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),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(o,s){var r="";w.length&&tt===t?w.forEach(function(a,l){r+=(l?", ":"")+a.textContent}):r=s.textContent,o.setData("Text",r)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(e){var i=e.dragEl;k=i},delayEnded:function(){this.isMultiDrag=~w.indexOf(k)},setupClone:function(e){var i=e.sortable,o=e.cancel;if(this.isMultiDrag){for(var s=0;s<w.length;s++)X.push(Di(w[s])),X[s].sortableIndex=w[s].sortableIndex,X[s].draggable=!1,X[s].style["will-change"]="",B(X[s],this.options.selectedClass,!1),w[s]===k&&B(X[s],this.options.chosenClass,!1);i._hideClone(),o()}},clone:function(e){var i=e.sortable,o=e.rootEl,s=e.dispatchSortableEvent,r=e.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||w.length&&tt===i&&(bo(!0,o),s("clone"),r()))},showClone:function(e){var i=e.cloneNowShown,o=e.rootEl,s=e.cancel;this.isMultiDrag&&(bo(!1,o),X.forEach(function(r){f(r,"display","")}),i(),Pe=!1,s())},hideClone:function(e){var i=this,o=e.sortable,s=e.cloneNowHidden,r=e.cancel;this.isMultiDrag&&(X.forEach(function(a){f(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),Pe=!0,r())},dragStartGlobal:function(e){var i=e.sortable;!this.isMultiDrag&&tt&&tt.multiDrag._deselectMultiDrag(),w.forEach(function(o){o.sortableIndex=P(o)}),w=w.sort(function(o,s){return o.sortableIndex-s.sortableIndex}),Ot=!0},dragStarted:function(e){var i=this,o=e.sortable;if(this.isMultiDrag){if(this.options.sort&&(o.captureAnimationState(),this.options.animation)){w.forEach(function(r){r!==k&&f(r,"position","absolute")});var s=$(k,!1,!0,!0);w.forEach(function(r){r!==k&&mo(r,s)}),W=!0,ee=!0}o.animateAll(function(){W=!1,ee=!1,i.options.animation&&w.forEach(function(r){mi(r)}),i.options.sort&&Re()})}},dragOver:function(e){var i=e.target,o=e.completed,s=e.cancel;W&&~w.indexOf(i)&&(o(!1),s())},revert:function(e){var i=e.fromSortable,o=e.rootEl,s=e.sortable,r=e.dragRect;w.length>1&&(w.forEach(function(a){s.addAnimationState({target:a,rect:W?$(a):r}),mi(a),a.fromRect=r,i.removeAnimationState(a)}),W=!1,rr(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(e){var i=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(),ee=!1,c.animation&&w.length>1&&(W||!o&&!r.options.sort&&!l)){var u=$(k,!1,!0,!0);w.forEach(function(m){m!==k&&(mo(m,u),a.appendChild(m))}),W=!0}if(!o)if(W||Re(),w.length>1){var h=Pe;r._showClone(i),r.options.animation&&!Pe&&h&&X.forEach(function(m){r.addAnimationState({target:m,rect:ne}),m.fromRect=ne,m.thisAnimationDuration=null})}else r._showClone(i)}},dragOverAnimationCapture:function(e){var i=e.dragRect,o=e.isOwner,s=e.activeSortable;if(w.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){ne=et({},i);var r=Mt(k,!0);ne.top-=r.f,ne.left-=r.e}},dragOverAnimationComplete:function(){W&&(W=!1,Re())},drop:function(e){var i=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(i){var h=this.options,m=s.children;if(!Ot)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),B(k,h.selectedClass,!~w.indexOf(k)),~w.indexOf(k))w.splice(w.indexOf(k),1),te=null,ie({sortable:r,rootEl:o,name:"deselect",targetEl:k,originalEvent:i});else{if(w.push(k),ie({sortable:r,rootEl:o,name:"select",targetEl:k,originalEvent:i}),i.shiftKey&&te&&r.el.contains(te)){var g=P(te),C=P(k);~g&&~C&&g!==C&&function(){var x,S;C>g?(S=g,x=C):(S=C,x=g+1);for(var R=h.filter;S<x;S++)if(!~w.indexOf(m[S])&&j(m[S],h.draggable,s,!1)){var at=R&&(typeof R=="function"?R.call(r,i,m[S],r):R.split(",").some(function(J){return j(m[S],J.trim(),s,!1)}));at||(B(m[S],h.selectedClass,!0),w.push(m[S]),ie({sortable:r,rootEl:o,name:"select",targetEl:m[S],originalEvent:i}))}}()}else te=k;tt=u}if(Ot&&this.isMultiDrag){if(W=!1,(s[_].options.sort||s!==o)&&w.length>1){var T=$(k),F=P(k,":not(."+this.options.selectedClass+")");if(!ee&&h.animation&&(k.thisAnimationDuration=null),u.captureAnimationState(),!ee&&(h.animation&&(k.fromRect=T,w.forEach(function(x){if(x.thisAnimationDuration=null,x!==k){var S=W?$(x):T;x.fromRect=S,u.addAnimationState({target:x,rect:S})}})),Re(),w.forEach(function(x){m[F]?s.insertBefore(x,m[F]):s.appendChild(x),F++}),l===P(k))){var Y=!1;w.forEach(function(x){if(x.sortableIndex!==P(x)){Y=!0;return}}),Y&&(a("update"),a("sort"))}w.forEach(function(x){mi(x)}),u.animateAll()}tt=u}(o===s||c&&c.lastPutMode!=="clone")&&X.forEach(function(x){x.parentNode&&x.parentNode.removeChild(x)})}},nullingGlobal:function(){this.isMultiDrag=Ot=!1,X.length=0},destroyGlobal:function(){this._deselectMultiDrag(),y(document,"pointerup",this._deselectMultiDrag),y(document,"mouseup",this._deselectMultiDrag),y(document,"touchend",this._deselectMultiDrag),y(document,"keydown",this._checkKeyDown),y(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(e){if(!(typeof Ot<"u"&&Ot)&&tt===this.sortable&&!(e&&j(e.target,this.options.draggable,this.sortable.el,!1))&&!(e&&e.button!==0))for(;w.length;){var i=w[0];B(i,this.options.selectedClass,!1),w.shift(),ie({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:e})}},_checkKeyDown:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},et(n,{pluginName:"multiDrag",utils:{select:function(e){var i=e.parentNode[_];!i||!i.options.multiDrag||~w.indexOf(e)||(tt&&tt!==i&&(tt.multiDrag._deselectMultiDrag(),tt=i),B(e,i.options.selectedClass,!0),w.push(e))},deselect:function(e){var i=e.parentNode[_],o=w.indexOf(e);!i||!i.options.multiDrag||!~o||(B(e,i.options.selectedClass,!1),w.splice(o,1))}},eventProperties:function(){var e=this,i=[],o=[];return w.forEach(function(s){i.push({multiDragElement:s,index:s.sortableIndex});var r;W&&s!==k?r=-1:W?r=P(s,":not(."+e.options.selectedClass+")"):r=P(s),o.push({multiDragElement:s,index:r})}),{items:Bs(w),clones:[].concat(X),oldIndicies:i,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 rr(n,t){w.forEach(function(e,i){var o=t.children[e.sortableIndex+(n?Number(i):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function bo(n,t){X.forEach(function(e,i){var o=t.children[e.sortableIndex+(n?Number(i):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function Re(){w.forEach(function(n){n!==k&&n.parentNode&&n.parentNode.removeChild(n)})}v.mount(new sr);v.mount(Ii,Ai);var ht=v;var Bo={name(n,t){let e=n.getAttribute("data-name").trim().toLowerCase(),i=t.getAttribute("data-name").trim().toLowerCase();return e.localeCompare(i)},created(n,t){let e=Number(n.getAttribute("data-created"));return Number(t.getAttribute("data-created"))-e},updated(n,t){let e=Number(n.getAttribute("data-updated"));return Number(t.getAttribute("data-updated"))-e},chaptersFirst(n,t){let e=n.getAttribute("data-type"),i=t.getAttribute("data-type");return e===i?0:e==="chapter"?-1:1},chaptersLast(n,t){let e=n.getAttribute("data-type"),i=t.getAttribute("data-type");return e===i?0:e==="chapter"?1:-1}},Po={up:{active(n,t){return!(n.previousElementSibling===null&&!t)},run(n,t){(n.previousElementSibling||t).insertAdjacentElement("beforebegin",n)}},down:{active(n,t){return!(n.nextElementSibling===null&&!t)},run(n,t){(n.nextElementSibling||t).insertAdjacentElement("afterend",n)}},next_book:{active(n,t,e){return e.nextElementSibling!==null},run(n,t,e){e.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,t,e){return e.previousElementSibling!==null},run(n,t,e){e.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,t){return n.dataset.type==="page"&&this.getNextChapter(n,t)},run(n,t){this.getNextChapter(n,t).querySelector("ul").prepend(n)},getNextChapter(n,t){let e=t||n,i=Array.from(e.parentElement.children),o=i.indexOf(e);return i.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(n,t){return n.dataset.type==="page"&&this.getPrevChapter(n,t)},run(n,t){this.getPrevChapter(n,t).querySelector("ul").append(n)},getPrevChapter(n,t){let e=t||n,i=Array.from(e.parentElement.children),o=i.indexOf(e);return i.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(n,t){return t||t===null&&n.nextElementSibling},run(n,t,e){e.querySelector("ul").append(n)}},book_start:{active(n,t){return t||t===null&&n.previousElementSibling},run(n,t,e){e.querySelector("ul").prepend(n)}},before_chapter:{active(n,t){return t},run(n,t){t.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,t){return t},run(n,t){t.insertAdjacentElement("afterend",n)}}},Xe=class extends d{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"),i=t.target.closest("[data-id]");this.runSortAction(i,e)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let t="",e=!1,i=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let r=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");e=t===a?!e:!1;let l=Bo[a];e&&i.includes(a)&&(l=function(u,h){return 0-Bo[a](u,h)});for(let c of r)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});t=a,this.updateMapInput()})}bookSelect(t){if(this.container.querySelector(`[data-type="book"][data-id="${t.id}"]`)!==null)return;let i=`${t.link}/sort-item`;window.$http.get(i).then(o=>{let s=Z(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")),i={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put(s,r,a){return a.getAttribute("data-type")==="page"}};for(let s of e)ht.create(s,{group:s.classList.contains("sort-list")?i:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let 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 i of e){let o=i.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(i.children).filter(r=>r.matches('[data-type="page"], [data-type="chapter"]'));for(let r=0;r<s.length;r++)this.addBookChildToMap(s[r],r,o,t)}return t}addBookChildToMap(t,e,i,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:i});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:i})}runSortAction(t,e){let i=t.parentElement.closest("li[data-id]"),o=t.parentElement.closest('[data-type="book"]');Po[e].run(t,i,o),this.updateMapInput(),this.updateMoveActionStateForAll(),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.focus()}updateMoveActionState(t){let e=t.parentElement.closest("li[data-id]"),i=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,i)}}updateMoveActionStateForAll(){let t=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let e of t)this.updateMoveActionState(e)}};var Ge=new WeakMap;function me(n,t,e=400,i=null){let o=Object.keys(t);for(let r of o)n.style.setProperty(r,t[r][0]);let s=()=>{for(let r of o)n.style.removeProperty(r);n.style.removeProperty("transition"),n.removeEventListener("transitionend",s),Ge.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${e}ms`;for(let r of o)n.style.setProperty(r,t[r][1]);n.addEventListener("transitionend",s),Ge.set(n,s)},15)}function fe(n){Ge.has(n)&&Ge.get(n)()}function Ro(n,t=400,e=null){fe(n),n.style.display="block",me(n,{opacity:["0","1"]},t,()=>{e&&e()})}function Oo(n,t=400,e=null){fe(n),me(n,{opacity:["1","0"]},t,()=>{n.style.display="none",e&&e()})}function qt(n,t=400){fe(n);let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":[`${e}px`,"0px"],overflow:["hidden","hidden"],"padding-top":[o,"0px"],"padding-bottom":[s,"0px"]};me(n,r,t,()=>{n.style.display="none"})}function Ut(n,t=400){fe(n),n.style.display="block";let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom"),r={"max-height":["0px",`${e}px`],overflow:["hidden","hidden"],"padding-top":["0px",o],"padding-bottom":["0px",s]};me(n,r,t)}function _o(n,t=400){let e=n.getBoundingClientRect().height,i=getComputedStyle(n),o=i.getPropertyValue("padding-top"),s=i.getPropertyValue("padding-bottom");return()=>{fe(n);let r=n.getBoundingClientRect().height,a=getComputedStyle(n),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]};me(n,u,t)}}var Ye=class extends d{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"),Ut(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 Je=class extends d{constructor(){super(...arguments);U(this,"editor",null);U(this,"saveCallback",null);U(this,"cancelCallback",null);U(this,"history",{});U(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()}),L(this.languageButtons,e=>{let i=e.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),Ht(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),L(this.saveButton,()=>this.save()),A(this.historyList,"button","click",(e,i)=>{e.preventDefault();let o=i.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 i=e.dataset.lang,o=this.favourites.has(i);e.setAttribute("data-favourite",o?"true":"false"),A(e.parentElement,".lang-option-favorite-toggle","click",()=>{o=!o,o?this.favourites.add(i):this.favourites.delete(i),e.setAttribute("data-favourite",o?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:o}),this.sortLanguageList(),o&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((i,o)=>{let s=i.dataset.favourite==="true",r=o.dataset.favourite==="true";return s&&!r?-1:r&&!s||i.dataset.lang>o.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of e)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(e,i,o,s,r){this.languageInput.value=i,this.saveCallback=s,this.cancelCallback=r,await this.show(),this.languageInputChange(i),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 i=this.editorInput.parentElement;e?i.setAttribute("dir",e):i.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 i=e.toLowerCase();for(let o of this.languageButtons){let s=o.dataset.lang.toLowerCase().trim(),r=i===s;o.classList.toggle("active",r),r&&o.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(i=>{let o=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${o}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getContent();if(!e)return;let i=Object.keys(this.history).pop();if(this.history[i]===e)return;this.history[String(Date.now())]=e;let o=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,o)}};var Ze=class extends d{setup(){let t=this.$el;t.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(t)})}};var Qe=class extends d{async setup(){let{mode:t}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,t)}};var tn=class extends d{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"),Ut(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 en=class extends d{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,L(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 nn=class extends d{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 on=class extends d{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 sn=class extends d{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(),i=0,o=this.toggle.getBoundingClientRect().height,s=e.bottom>window.innerHeight,r=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`,s?i=window.innerHeight-e.top-o/2:i=e.top),s){this.menu.style.top="initial",this.menu.style.bottom=`${i}px`;let c=window.innerHeight-40-(window.innerHeight-r.bottom);this.menu.style.maxHeight=`${Math.floor(c)}px`}else{this.menu.style.top=`${i}px`,this.menu.style.bottom="initial";let c=window.innerHeight-40-r.top;this.menu.style.maxHeight=`${Math.floor(c)}px`}this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",c=>{this.menu.contains(c.target)||this.hide()});let a=this.menu.querySelector("input");a!==null&&a.focus(),this.showing=!0;let l=new Event("show");this.container.dispatchEvent(l),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()}),L(this.toggle,e=>{e.stopPropagation(),e.preventDefault(),this.show(e),e instanceof KeyboardEvent&&t.focusNext()})}};var rn=class extends d{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 i of e){let o=!t||i.textContent.toLowerCase().includes(t);i.style.display=o?"flex":"none",i.classList.toggle("hidden",!o)}}async loadList(t=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let e=await window.$http.get(this.getAjaxUrl(t)),i=_o(this.listContainerElem,80);this.listContainerElem.innerHTML=e.data,i()}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 Vt=class{constructor(t){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 Hi(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let t=document.createElement("textarea");t.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),t.value=n,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}var an=class extends d{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(){L(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let t=0,e=()=>{this.hideOverlay(),t=0};this.dropTarget.addEventListener("dragenter",i=>{i.preventDefault(),t+=1,t===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",e),this.dropTarget.addEventListener("dragleave",()=>{t-=1,t===0&&e()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),e(),!this.isActive)return;let s=new Vt(i.dataTransfer).getFiles();for(let r of s)this.createUploadFromFile(r)})}manualSelectHandler(){let t=it("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=it("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:i,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){i.setAttribute("data-status","error"),i.textContent=l,Qt(e),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,Qt(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 i=this,o=window.$http.createXMLHttpRequest("POST",this.url,{error(){t.markError(i.errorMessage)},readystatechange(){this.readyState===XMLHttpRequest.DONE&&this.status===200?t.markSuccess(i.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=it("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),i=it("div",{class:"dropzone-file-item-status"},[]),o=it("div",{class:"dropzone-file-item-progress"}),s=it("div",{class:"dropzone-file-item-image-wrap"},[e]),r=it("div",{class:"dropzone-file-item"},[s,it("div",{class:"dropzone-file-item-text-wrap"},[it("div",{class:"dropzone-file-item-label"},[t.name]),Bt(),i]),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:i,dismiss:a}}};var ln=class extends d{constructor(){super(...arguments);this.open=!1;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 i=e.target.closest("button");if(i instanceof HTMLButtonElement&&this.buttons.includes(i)){let o=i.dataset.tab||"";this.setActiveTab(o,!0)}})}toggle(){this.container.classList.toggle("open");let 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,i=!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");i&&!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 cn=class extends d{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,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of i)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 i=await window.$http.get(`/permissions/form-row/${this.entityType}/${t}`),o=Z(i.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(t){let e=t.closest(".item-list-row"),{roleId:i}=t.dataset,{roleName:o}=t.dataset,s=document.createElement("option");s.value=i,s.textContent=o,this.roleSelect.append(s),e.remove()}};var dn=class extends d{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()}),L(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(i=>{this.searchResults.innerHTML=i.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var hn=class extends d{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.search="",this.lastClick=0,this.setupListeners(),this.showLoading(),this.searchOptions.searchEndpoint&&this.initialLoad()}configureSearchOptions(t){Object.assign(this.searchOptions,t),this.reset(),this.searchInput.value=this.searchOptions.initialValue}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let t=0;this.searchInput.addEventListener("input",()=>{t=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-t<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",e=>{e.keyCode===13&&e.preventDefault()}),A(this.$el,"[data-entity-type]","keydown",e=>{if(e.ctrlKey&&e.code==="Enter"){let i=this.$el.closest("form");if(i){i.submit(),e.preventDefault();return}}e.code==="ArrowDown"&&this.focusAdjacent(!0),e.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",e=>{e.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(t=!0){let e=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),i=e.indexOf(document.activeElement),o=e[i+(t?1:-1)]||e[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");if(this.searchOptions.initialValue){this.searchEntities(this.searchOptions.initialValue);return}window.$http.get(this.searchUrl()).then(t=>{this.resultsContainer.innerHTML=t.data,this.hideLoading()})}searchUrl(){let t=`types=${encodeURIComponent(this.searchOptions.entityTypes)}&permission=${encodeURIComponent(this.searchOptions.entityPermission)}`;return`${this.searchOptions.searchEndpoint}?${t}`}searchEntities(t){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");this.input.value="";let e=`${this.searchUrl()}&term=${encodeURIComponent(t)}`;window.$http.get(e).then(i=>{this.resultsContainer.innerHTML=i.data,this.hideLoading()})}isDoubleClick(){let t=Date.now(),e=t-this.lastClick<300;return this.lastClick=t,e}onClick(t){let e=t.target.closest("[data-entity-type]");e&&(t.preventDefault(),t.stopPropagation(),this.selectItem(e))}selectItem(t){let e=this.isDoubleClick(),i=t.getAttribute("data-entity-type"),o=t.getAttribute("data-entity-id"),s=!t.classList.contains("selected")||e;this.unselectAll(),this.input.value=s?`${i}:${o}`:"";let r=t.getAttribute("href"),a=t.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:r};s?t.classList.add("selected"):window.$events.emit("entity-select-change",null),!(!e&&!s)&&(e&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(t){window.$events.emit("entity-select-confirm",t)}unselectAll(){let t=this.elem.querySelectorAll(".selected");for(let e of t)e.classList.remove("selected","primary-background")}};var un=class extends d{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(t,e={}){this.callback=t,this.getSelector().configureSearchOptions(e),this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(t){this.selection=t,t===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(t){this.hide(),this.getSelector().reset(),this.callback&&t&&this.callback(t)}};var pn=class extends d{setup(){this.container=this.$el,this.name=this.$opts.name,L(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var mn=class extends d{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){Ut(t,200)}close(t){qt(t,200)}click(t){t.preventDefault();let e=document.querySelectorAll(this.targetSelector);for(let i of e)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(t){window.$http.patch(this.updateEndpoint,{expand:t?"true":"false"})}};var fn=class extends d{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 i=Z(e);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(i),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var gn=class extends d{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 vn=class extends d{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(){L(this.filterTabs,i=>{this.resetAll(),this.filter=i.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",i=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),i.preventDefault()}),L(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),A(this.container,".load-more button","click",this.runLoadMore.bind(this)),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",i=>{i.target.src=window.baseUrl("loading_error.png")},!0),L(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),A(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),A(this.formContainer,"#image-manager-rebuild-thumbs","click",async(i,o)=>{o.disabled=!0,this.lastSelected&&await this.rebuildThumbnails(this.lastSelected.id),o.disabled=!1}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let t=this.listContainer.parentElement,e=[];t.addEventListener("wheel",i=>{if(!(Math.ceil(t.scrollHeight-t.scrollTop)===t.clientHeight)||i.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 i=e!=="gallery";this.dropzoneContainer.classList.toggle("hidden",i),this.uploadButton.classList.toggle("hidden",i),this.uploadHint.classList.toggle("hidden",i),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!i),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let 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),Qt(this.listContainer)}addReturnedHtmlElementsToList(t){let e=document.createElement("div");e.innerHTML=t;let i=e.querySelector(".load-more");i&&(i.remove(),this.loadMore.innerHTML=i.innerHTML),this.loadMore.toggleAttribute("hidden",!i),window.$components.init(e);for(let o of[...e.children])this.listContainer.appendChild(o)}setActiveFilterTab(t){for(let e of this.filterTabs){let i=e.dataset.filter===t;e.setAttribute("aria-selected",i?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value="",this.cancelSearch.toggleAttribute("hidden",!0)}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){Tt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}async onImageSelectEvent(t){let e=JSON.parse(t.detail.data),i=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&&!i?(t.target.classList.add("selected"),e=await this.loadImageEditForm(e.id)):i?i&&(e=this.lastSelected):this.resetEditForm(),this.selectButton.classList.toggle("hidden",o),i&&this.callback&&(this.callback(e),this.hide()),this.lastSelected=e,this.lastSelectedTime=Date.now()}async loadImageEditForm(t,e=!1){e||(this.formContainer.innerHTML="");let i=e?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${t}`,i);this.formContainer.innerHTML=o,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer);let s=this.formContainer.querySelector("#image-manager-form-image-data");return JSON.parse(s.text)}runLoadMore(){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 wn=class extends d{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 bn=class extends d{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 rt(n,t={},e=[]){let i=document.createElement(n),o=Object.keys(t);for(let s of o)t[s]!==null&&i.setAttribute(s,t[s]);for(let s of e)typeof s=="string"?i.append(document.createTextNode(s)):i.append(s);return i}var yn=class extends d{constructor(){super(...arguments);this.loadingEl=null}setup(){this.button=this.$el;let e=this.button.form,i=()=>{setTimeout(()=>this.showLoadingState(),10)};this.button.addEventListener("click",i),e&&e.addEventListener("submit",i)}showLoadingState(){this.button.disabled=!0,this.loadingEl||(this.loadingEl=rt("div",{class:"inline block"}),Tt(this.loadingEl),this.button.after(this.loadingEl))}};var En=class extends d{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(i=>i.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(i=>{this.editor=i,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,cmEditorView:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",t=>{let e=t.target.closest("button[data-action]");if(e===null)return;let i=e.getAttribute("data-action");if(i==="insertImage"&&this.editor.actions.showImageInsert(),i==="insertLink"&&this.editor.actions.showLinkSelector(),i==="insertDrawing"&&(t.ctrlKey||t.metaKey)){this.editor.actions.showImageManager();return}i==="insertDrawing"&&this.editor.actions.startDrawing(),i==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",t=>{let e=t.target.closest(".editor-toolbar-label");if(!e)return;let i=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of i)o.classList.remove("active");e.closest(".markdown-editor-wrap").classList.add("active")}),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",()=>{let e=this.elem.getBoundingClientRect(),i=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",i),window.removeEventListener("pointerup",o),this.display.style.pointerEvents=null,document.body.style.userSelect=null};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",i),window.addEventListener("pointerup",o)});let 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 Cn=class extends d{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 i of e)i.disabled=t;this.inputContainer.style.display=t?"none":"block"}};var xn=class extends d{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,i=Math.max(2e3,1e3+250*e);setTimeout(this.hide.bind(this),i)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var Ln=class extends d{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){L(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),L(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};function No(n){for(let t=1;t<5;t++)n.shortcuts.add(`meta+${t}`,"",["FormatBlock",!1,`h${t+1}`]);n.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),n.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),n.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),n.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),n.shortcuts.add("meta+o","","InsertOrderedList"),n.shortcuts.add("meta+p","","InsertUnorderedList"),n.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),n.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),n.shortcuts.add("meta+9","",()=>{let t=n.selection.getNode(),e=t?t.closest(".callout"):null,i=["info","success","warning","danger"],s=(i.findIndex(a=>e&&e.classList.contains(a))+1)%i.length,r=i[s];n.formatter.apply(`callout${r}`)}),n.shortcuts.add("meta+shift+K","",()=>{let t=window.$components.first("entity-selector-popup"),e=n.selection.getContent({format:"text"}).trim();t.show(i=>{n.selection.isCollapsed()?n.insertContent(n.dom.createHTML("a",{href:i.link},n.dom.encode(i.name))):n.formatter.apply("link",{href:i.link}),n.selection.collapse(!1),n.focus()},{initialValue:e,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})})}function Fo(n){window.$events.listen("editor::replace",({html:t})=>{n.setContent(t)}),window.$events.listen("editor::append",({html:t})=>{let e=n.getContent()+t;n.setContent(e)}),window.$events.listen("editor::prepend",({html:t})=>{let e=t+n.getContent();n.setContent(e)}),window.$events.listen("editor::insert",({html:t})=>{n.insertContent(t)}),window.$events.listen("editor::focus",()=>{n.initialized&&n.focus()})}function ar(n,t){let e=n.dom.get(encodeURIComponent(t).replace(/!/g,"%21"));e&&(e.scrollIntoView(),n.selection.select(e,!0),n.selection.collapse(!1),n.focus())}function qo(n){let e=new URL(window.location).searchParams.get("content-id");e&&ar(n,e)}var Dt,Tn;function lr(n){return n&&!!(n.textContent||n.innerText)}async function cr(n,t){if(n===null||n.type.indexOf("image")!==0)throw new Error("Not an image file");let e=n.name||`image-${Date.now()}.png`,i=new FormData;return i.append("file",n,e),i.append("uploaded_to",t),(await window.$http.post(window.baseUrl("/images/gallery"),i)).data}function Uo(n,t,e){let i=new Vt(e.clipboardData||e.dataTransfer);if(!i.hasItems()||i.containsTabularData())return;let o=i.getImages();for(let s of o){let r=`image-${Math.random().toString(16).slice(2)}`,a=window.baseUrl("/loading.gif");e.preventDefault(),setTimeout(()=>{n.insertContent(`<p><img src="${a}" id="${r}"></p>`),cr(s,t.pageId).then(l=>{let c=l.name.replace(/"/g,""),u=`<img src="${l.thumbs.display}" alt="${c}" />`,h=n.dom.create("a",{target:"_blank",href:l.url},u);n.dom.replace(h,r)}).catch(l=>{n.dom.remove(r),window.$events.error(l?.data?.message||t.translations.imageUploadErrorText),console.error(l)})},10)}}function dr(n){let t=n.selection.getNode();t.nodeName==="IMG"&&(Dt=n.dom.getParent(t,".mceTemp"),!Dt&&t.parentNode.nodeName==="A"&&!lr(t.parentNode)&&(Dt=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(Tn=t)}function hr(n,t,e){let{dom:i}=n,o=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX,e.clientY,n.getDoc()),s=e.dataTransfer&&e.dataTransfer.getData("bookstack/template");s&&(e.preventDefault(),window.$http.get(`/templates/${s}`).then(r=>{n.selection.setRng(o),n.undoManager.transact(()=>{n.execCommand("mceInsertContent",!1,r.data.html)})})),i.getParent(o.startContainer,".mceTemp")?e.preventDefault():Dt&&(e.preventDefault(),n.undoManager.transact(()=>{n.selection.setRng(o),n.selection.setNode(Dt),i.remove(Dt)})),!e.isDefaultPrevented()&&Tn&&(e.preventDefault(),n.undoManager.transact(()=>{let r=n.selection.getNode(),a=n.selection.getRng(),l=r.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(Tn):l.before(Tn)})),e.isDefaultPrevented()||Uo(n,t,e),Dt=null}function ur(n,t){t.preventDefault(),n.focus();let i=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX??0,t.clientY??0,n.getDoc());n.selection.setRng(i)}function Vo(n,t){n.on("dragover",e=>ur(n,e)),n.on("dragstart",()=>dr(n)),n.on("drop",e=>hr(n,t,e)),n.on("paste",e=>Uo(n,t,e))}function Wo(n){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",n.textDirection==="rtl"?"ltr rtl":"","link customtable imagemanager-insert insertoverflow","code about fullscreen"].filter(i=>!!i).join(" | ")}function pr(n){n.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),n.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),n.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function mr(n){n.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(t){return t.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function fr(n){n.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(t){return t.closest("img")!==null&&!t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"image"})}function gr(n){n.ui.registry.addContextToolbar("objectcontexttoolbar",{predicate(t){return t.closest("img")!==null&&t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"media"})}function jo(n){pr(n),mr(n),fr(n),gr(n)}var vr={"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 zo(n){for(let[t,e]of Object.entries(vr))n.ui.registry.addIcon(t,e)}function wr(n){n.serializer.addNodeFilter("br",t=>{for(let e of t)if(e.parent&&e.parent.name==="code"){let i=window.tinymce.html.Node.create("#text");i.value=`