vgapp 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/vgapp.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see vgapp.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vgapp=t():e.vgapp=t()}(this,()=>(()=>{"use strict";var e={188(e,t,i){i.d(t,{A:()=>p});var s=i(381),r=i(829);const n=new Map;function a(e){return n.has(e)?n.get(e):null}const o={set(e,t,i){a(e)||function(e){const t=new Map;n.set(e,t)}(e);const s=a(e);if(s.size>0&&!s.has(t)){const e=Array.from(s.keys())[0];return void console.error(`VGApp не допускает более одного экземпляра для каждого элемента. Связанный экземпляр: ${e}.`)}s.set(t,i)},get(e,t){const i=a(e);return i&&i.get(t)||null},remove(e,t){const i=a(e);i&&(i.delete(t),0===i.size&&n.delete(e))}};var l=i(667),h=i(647),d=i(810);class c{static get DEFAULTS(){return{enable:!1,in:"animate__fadeIn",out:"animate__fadeOut",duration:500}}constructor(e,t,i={}){this._element=e,this._nameKey=t,this._params=(0,s._v)(c.DEFAULTS,i),this._params.enable&&(0,s.vq)(e)&&(this._classes={animated:"animate__animated",duration:"animate__fast"},this._init())}_init(){const{classList:e}=this._element;e.add(this._classes.animated,this._classes.duration),e.contains("fade")&&e.remove("fade"),this._setupEventListeners()}_setupEventListeners(){h.A.on(this._element,`${this._nameKey}.show`,this._handleShow.bind(this),null),h.A.on(this._element,`${this._nameKey}.shown`,this._handleShown.bind(this),null),h.A.on(this._element,`${this._nameKey}.hide`,this._handleHide.bind(this),null),h.A.on(this._element,`${this._nameKey}.hidden`,this._handleHidden.bind(this),null)}_handleShow(){const{classList:e}=this._element,{in:t,out:i}=this._params;e.contains(i)&&e.remove(i),e.add(t)}_handleShown(){this._element.classList.add(this._classes.animated)}_handleHide(){const{classList:e}=this._element,{in:t,out:i}=this._params;e.contains(t)&&e.remove(t),e.add(i)}_handleHidden(){const{classList:e}=this._element,{in:t,out:i}=this._params;[...e].filter(e=>e.startsWith("animate__")).forEach(t=>e.remove(t)),e.add(this._classes.animated,this._classes.duration)}dispose(){h.A.off(this._element,`${this._nameKey}.show`,null,null),h.A.off(this._element,`${this._nameKey}.shown`,null,null),h.A.off(this._element,`${this._nameKey}.hide`,null,null),h.A.off(this._element,`${this._nameKey}.hidden`,null,null),[...this._element.classList].filter(e=>e.startsWith("animate__")).forEach(e=>this._element.classList.remove(e)),this._element=null}}const _=c;var u=i(11),m=i(601);const p=class{constructor(e){if(e){if(this._element=r.A.find(e),!this._element)throw new Error("Товарищ! Первый параметр не должен быть пустым!");this._params={},this._isLoaded=!1,o.set(this._element,this.constructor.NAME_KEY,this)}}_getParams(e,t){return new l.A(t,e).get()}dispose(){o.remove(this._element,this.constructor.NAME_KEY),h.A.off(this._element,this.constructor.EVENT_KEY);for(const e of Object.getOwnPropertyNames(this))this[e]=null}_route(e,t){if("function"!=typeof e)return this._requestRoute(e);let i=null,n=this._params.ajax.timeout||0;if(this._isLoaded)return;const a=e=>{"string"==typeof e?i&&(i.innerHTML=e):(0,s.Gv)(e)&&!(0,s.ze)(e)&&Object.values(e).forEach(e=>{"string"==typeof e&&i&&(i.innerHTML=e)})};if(!this._params.hasOwnProperty("ajax"))return;if(!this._params.ajax.route)return;!1 in this._params.ajax&&(this._params.ajax.method="get"),"target"in this._params.ajax&&this._params.ajax.target&&(i=r.A.find(this._params.ajax.target)),"loader"in this._params.ajax&&this._params.ajax.loader&&"output"in this._params.ajax&&this._params.ajax.output&&a((0,m.A)("string").div({class:"vg-loader"}));let o=(t,r)=>{"loader"in this._params.ajax&&this._params.ajax.loader&&a(""),"once"in this._params.ajax&&this._params.ajax.once&&(this._isLoaded=!0),"output"in this._params.ajax&&this._params.ajax.output&&a("response"in t?(0,s.OM)(t.response):t),(0,s.g7)(e,[r,t,i])};const l=new u.A;let h={onSuccess:e=>{o(e,"success")},onError:e=>{"loader"in this._params.ajax&&this._params.ajax.loader&&a(""),"function"!=typeof t?o(e,"error"):(0,s.g7)(t,[e])}};setTimeout(()=>{if("get"===this._params.ajax.method.toLowerCase()){const e=this._buildRouteUrl(this._params.ajax.data,this._params.ajax.route);l.get(e.toString(),h)}"post"===this._params.ajax.method.toLowerCase()&&l.post(this._params.ajax.route,this._params.ajax.data,h),"delete"===this._params.ajax.method.toLowerCase()&&l.delete(this._params.ajax.route,h)},n)}_requestRoute(e={}){const t=this._normalizeRouteRequestOptions(e);return u.A.requestRoute(t)}_buildRouteUrl(e={},t="",i={}){const s=this._normalizeRouteRequestOptions(Object.assign({},i,{params:e,route:t||i.route||""}));return u.A.buildRouteUrl(s.route,{params:s.params,baseParams:s.baseParams})}_normalizeRouteRequestOptions(e={}){const t=this._params&&(0,s.Gv)(this._params.request)?this._params.request:{},i=this._params&&(0,s.Gv)(this._params.ajax)?this._params.ajax:{},r=(0,s.Gv)(e)?e:{};return{route:String(r.route||r.endpoint||t.route||i.route||"").trim(),method:String(r.method||t.method||i.method||"GET").toUpperCase().trim()||"GET",credentials:String(r.credentials||t.credentials||"same-origin").trim()||"same-origin",headers:(0,s._v)({Accept:"application/json","X-Requested-With":"XMLHttpRequest"},(0,s.Gv)(t.headers)?t.headers:{},(0,s.Gv)(r.headers)?r.headers:{}),baseParams:(0,s._v)({},(0,s.Gv)(t.params)?t.params:{},(0,s.Gv)(r.baseParams)?r.baseParams:{},(0,s.Gv)(r.paramsBase)?r.paramsBase:{}),params:(0,s.Gv)(r.params)?r.params:{},body:void 0!==r.body?r.body:void 0!==r.data?r.data:null,signal:r.signal||null,responseType:String(r.responseType||r.parse||"auto").toLowerCase().trim()||"auto"}}_dismissElement(){let e=(0,d.z)("cross"),t=this._element.querySelector(".vg-btn-close");t&&(t.querySelector("svg")||t.insertAdjacentHTML("beforeend",e))}_queueCallback(e,t,i=!0,r){(0,s.dO)(e,t,i,r)}_animation(e,t,i={}){new _(e,t,i)}static getInstance(e){return o.get(r.A.find(e),this.NAME_KEY)}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,(0,s.ze)(t)?{}:t)}static boot(e={}){if("function"==typeof this.initAll)return this.initAll(e);if("function"!=typeof this.init)return null;if(e&&Object.prototype.hasOwnProperty.call(e,"element")){const{element:t,...i}=e;return this.init(t,i)}return null}static get DATA_KEY(){return`vg.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}}},810(e,t,i){i.d(t,{P:()=>h,z:()=>l});var s=i(647),r=i(381),n=i(829);const a={pdf:"file-pdf",doc:"file-word",docx:"file-word",odt:"file-word",rtf:"file-word",xls:"file-exel",xlsx:"file-exel",xlsm:"file-exel",ods:"file-exel",csv:"file-exel",zip:"file-zip",rar:"file-zip","7z":"file-zip",tar:"file-zip",gz:"file-zip",tgz:"file-zip",txt:"file-text",md:"file-text",log:"file-text",json:"file-text",xml:"file-text",yml:"file-text",yaml:"file-text",php:"file-php",png:"file-image",jpg:"file-image",jpeg:"file-image",gif:"file-image",webp:"file-image",svg:"file-image",bmp:"file-image",tif:"file-image",tiff:"file-image",heic:"file-image",heif:"file-image",avif:"file-image",mp3:"file-audio",wav:"file-audio",ogg:"file-audio",flac:"file-audio",aac:"file-audio",m4a:"file-audio",mp4:"file-video",webm:"file-video",mov:"file-video",mkv:"file-video",avi:"file-video"},o=e=>{if(!e)return"";const t=String(e).toLowerCase().split("#")[0].split("?")[0].split("/").pop()||"";return t.includes(".")&&t.split(".").pop()||""},l=e=>((e,t={})=>{const i=t[e];if(i)return i;const s=t[(e=>{const{type:t,ext:i}=(e=>{if(!e)return{type:"",ext:""};if("object"==typeof e){const t=String(e.type||"").toLowerCase(),i=String(e.name||e.path||e.url||"").toLowerCase();return{type:t,ext:o(i)}}return{type:"",ext:o(e)}})(e);return"application/pdf"===t?"file-pdf":t.includes("word")?"file-word":t.includes("excel")||t.includes("spreadsheet")?"file-exel":t.includes("zip")||t.includes("compressed")?"file-zip":t.startsWith("text/")?"file-text":t.startsWith("image/")?"file-image":t.startsWith("audio/")?"file-audio":t.startsWith("video/")?"file-video":a[i]||"file-generic"})(e)];return s||t["file-generic"]||""})(e,{minus:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dash" viewBox="0 0 16 16"><path d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8"/></svg>',plus:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16"><path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/></svg>',"dots-six-vertical":'<svg viewBox="64 64 896 896" focusable="false" data-icon="holder" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M300 276.5a56 56 0 1056-97 56 56 0 00-56 97zm0 284a56 56 0 1056-97 56 56 0 00-56 97zM640 228a56 56 0 10112 0 56 56 0 00-112 0zm0 284a56 56 0 10112 0 56 56 0 00-112 0zM300 844.5a56 56 0 1056-97 56 56 0 00-56 97zM640 796a56 56 0 10112 0 56 56 0 00-112 0z"></path></svg>',chevron:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 12.392L8.74146 9.13354L7.0918 10.7832L11.1751 14.8665C11.3939 15.0853 11.6906 15.2081 12 15.2081C12.3093 15.2081 12.606 15.0853 12.8248 14.8665L16.9081 10.7832L15.2585 9.13354L12 12.392Z" fill="black"/></svg>',danger:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36 4.5C53.3953 4.5 67.5 18.6047 67.5 36C67.5 53.3953 53.3953 67.5 36 67.5C18.6047 67.5 4.5 53.3953 4.5 36C4.5 18.6047 18.6047 4.5 36 4.5ZM44.9961 23.8237C44.9944 23.8242 44.9931 23.825 44.9902 23.8279L36 32.818L27.0098 23.8279C27.0069 23.825 27.0056 23.8242 27.0039 23.8237C27.0023 23.8232 27.0006 23.8232 26.999 23.8237C26.9975 23.8242 26.9961 23.825 26.9932 23.8279L23.8278 26.9932C23.825 26.9961 23.8243 26.9975 23.8237 26.9991C23.8232 27.0007 23.8232 27.0024 23.8237 27.004L23.8244 27.0056C23.8253 27.0071 23.8265 27.0085 23.8279 27.0098L32.818 36L23.8279 44.9903C23.825 44.9931 23.8242 44.9945 23.8237 44.9961C23.8232 44.9977 23.8232 44.9995 23.8237 45.0011C23.8242 45.0026 23.825 45.0039 23.8279 45.0068L26.9932 48.1723C26.9961 48.1751 26.9975 48.1758 26.9991 48.1764C27.0007 48.1769 27.0024 48.1769 27.004 48.1764C27.0056 48.1759 27.0069 48.1751 27.0098 48.1722L36 39.1819L44.9903 48.1721C44.9931 48.175 44.9945 48.1758 44.9961 48.1763C44.9977 48.1768 44.9995 48.1768 45.0011 48.1763C45.0026 48.1758 45.0039 48.175 45.0068 48.1721L48.1723 45.0068C48.1751 45.0039 48.1758 45.0025 48.1764 45.0009C48.1769 44.9993 48.1769 44.9976 48.1764 44.996L48.1757 44.9944C48.1747 44.9929 48.1736 44.9915 48.1722 44.9902L39.1819 36L48.1721 27.0098C48.175 27.0069 48.1758 27.0056 48.1763 27.0039C48.1768 27.0023 48.1768 27.0006 48.1763 26.999C48.1758 26.9975 48.175 26.9961 48.1721 26.9932L45.0068 23.8278C45.0039 23.825 45.0025 23.8243 45.0009 23.8237C44.9993 23.8232 44.9977 23.8232 44.9961 23.8237Z" fill="#000000"/></svg>',success:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36 4.5C18.6047 4.5 4.5 18.6047 4.5 36C4.5 53.3953 18.6047 67.5 36 67.5C53.3953 67.5 67.5 53.3953 67.5 36C67.5 18.6047 53.3953 4.5 36 4.5ZM49.6055 25.7133L34.7977 46.2445C34.5907 46.5334 34.3179 46.7688 34.0018 46.9312C33.6857 47.0935 33.3354 47.1782 32.9801 47.1782C32.6247 47.1782 32.2745 47.0935 31.9584 46.9312C31.6423 46.7688 31.3695 46.5334 31.1625 46.2445L22.3945 34.0945C22.1273 33.7219 22.3945 33.2016 22.8516 33.2016H26.1492C26.8664 33.2016 27.5484 33.5461 27.9703 34.1367L32.9766 41.0836L44.0297 25.7555C44.4516 25.1719 45.1266 24.8203 45.8508 24.8203H49.1484C49.6055 24.8203 49.8727 25.3406 49.6055 25.7133Z" fill="#000000"/></svg>',waiting:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M51 10.02C55.5248 12.6326 59.2888 16.3816 61.9194 20.8959C64.5501 25.4103 65.9561 30.5334 65.9983 35.7581C66.0405 40.9828 64.7174 46.1279 62.1601 50.6841C59.6027 55.2404 55.8997 59.0497 51.4177 61.735C46.9357 64.4203 41.8301 65.8885 36.6063 65.9942C31.3825 66.1 26.2216 64.8395 21.6347 62.3378C17.0477 59.836 13.1936 56.1796 10.454 51.7306C7.71439 47.2816 6.18423 42.1942 6.015 36.972L6 36L6.015 35.028C6.18301 29.847 7.69064 24.7979 10.3909 20.373C13.0912 15.9481 16.892 12.2984 21.4227 9.77969C25.9534 7.26098 31.0594 5.95923 36.243 6.00136C41.4266 6.04348 46.5108 7.42804 51 10.02ZM36 18C35.2652 18.0001 34.556 18.2699 34.0069 18.7582C33.4578 19.2465 33.107 19.9193 33.021 20.649L33 21V36L33.027 36.393C33.0954 36.9135 33.2992 37.407 33.618 37.824L33.879 38.124L42.879 47.124L43.161 47.37C43.6871 47.7782 44.3341 47.9998 45 47.9998C45.6659 47.9998 46.3129 47.7782 46.839 47.37L47.121 47.121L47.37 46.839C47.7782 46.3129 47.9998 45.6659 47.9998 45C47.9998 44.3341 47.7782 43.6872 47.37 43.161L47.121 42.879L39 34.755V21L38.979 20.649C38.893 19.9193 38.5422 19.2465 37.9931 18.7582C37.444 18.2699 36.7348 18.0001 36 18Z" fill="black"/></svg>',warning:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36.5 5C44.8543 5 52.8665 8.31874 58.7739 14.2261C64.6813 20.1335 68 28.1457 68 36.5C68 44.8543 64.6813 52.8665 58.7739 58.7739C52.8665 64.6813 44.8543 68 36.5 68C28.1457 68 20.1335 64.6813 14.2261 58.7739C8.31874 52.8665 5 44.8543 5 36.5C5 28.1457 8.31874 20.1335 14.2261 14.2261C20.1335 8.31874 28.1457 5 36.5 5ZM36.5 18.5C35.9287 18.4995 35.3635 18.6181 34.8406 18.8484C34.3178 19.0786 33.8487 19.4154 33.4633 19.8372C33.0779 20.259 32.7848 20.7565 32.6025 21.298C32.4203 21.8395 32.353 22.413 32.405 22.982L34.0475 41.009C34.1112 41.6151 34.397 42.1761 34.8499 42.5839C35.3028 42.9917 35.8906 43.2173 36.5 43.2173C37.1094 43.2173 37.6972 42.9917 38.1501 42.5839C38.603 42.1761 38.8888 41.6151 38.9525 41.009L40.5905 22.982C40.6424 22.4134 40.5753 21.8403 40.3933 21.2991C40.2114 20.7579 39.9186 20.2606 39.5337 19.8389C39.1488 19.4171 38.6803 19.0803 38.1579 18.8498C37.6356 18.6192 37.0709 18.5001 36.5 18.5ZM36.5 54.5C37.4548 54.5 38.3705 54.1207 39.0456 53.4456C39.7207 52.7705 40.1 51.8548 40.1 50.9C40.1 49.9452 39.7207 49.0295 39.0456 48.3544C38.3705 47.6793 37.4548 47.3 36.5 47.3C35.5452 47.3 34.6295 47.6793 33.9544 48.3544C33.2793 49.0295 32.9 49.9452 32.9 50.9C32.9 51.8548 33.2793 52.7705 33.9544 53.4456C34.6295 54.1207 35.5452 54.5 36.5 54.5Z" fill="#000000"/></svg>',info:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36 4.5C18.6047 4.5 4.5 18.6047 4.5 36C4.5 53.3953 18.6047 67.5 36 67.5C53.3953 67.5 67.5 53.3953 67.5 36C67.5 18.6047 53.3953 4.5 36 4.5ZM33.75 20.8125C33.75 20.5031 34.0031 20.25 34.3125 20.25H37.6875C37.9969 20.25 38.25 20.5031 38.25 20.8125V39.9375C38.25 40.2469 37.9969 40.5 37.6875 40.5H34.3125C34.0031 40.5 33.75 40.2469 33.75 39.9375V20.8125ZM36 51.75C35.1168 51.732 34.2759 51.3685 33.6577 50.7375C33.0395 50.1065 32.6932 49.2584 32.6932 48.375C32.6932 47.4916 33.0395 46.6435 33.6577 46.0125C34.2759 45.3815 35.1168 45.018 36 45C36.8832 45.018 37.7241 45.3815 38.3423 46.0125C38.9605 46.6435 39.3068 47.4916 39.3068 48.375C39.3068 49.2584 38.9605 50.1065 38.3423 50.7375C37.7241 51.3685 36.8832 51.732 36 51.75Z" fill="#000000"/></svg>',dots:'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 17C11.1046 17 12 16.1046 12 15C12 13.8954 11.1046 13 10 13C8.89543 13 8 13.8954 8 15C8 16.1046 8.89543 17 10 17Z" fill="black"/><path d="M10 12C11.1046 12 12 11.1046 12 10C12 8.89543 11.1046 8 10 8C8.89543 8 8 8.89543 8 10C8 11.1046 8.89543 12 10 12Z" fill="black"/><path d="M10 7C11.1046 7 12 6.10457 12 5C12 3.89543 11.1046 3 10 3C8.89543 3 8 3.89543 8 5C8 6.10457 8.89543 7 10 7Z" fill="black"/></svg>',remove:'<svg class="vg-icon-remove" width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7.05 5.636 12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414L12 13.414l-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636Z" fill="currentColor"/></svg>',cross:'<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.3149 0.340332C15.4478 0.20752 15.6027 0.118978 15.7798 0.074707C15.9569 0.0249023 16.134 0.0249023 16.311 0.074707C16.4881 0.118978 16.6431 0.20752 16.7759 0.340332C16.9142 0.473145 17.0055 0.630859 17.0498 0.813477C17.0941 0.99056 17.0941 1.16764 17.0498 1.34473C17.0055 1.52181 16.917 1.67676 16.7842 1.80957L1.80127 16.8008C1.67399 16.9281 1.52181 17.0111 1.34473 17.0498C1.16764 17.0941 0.987793 17.0941 0.805176 17.0498C0.628092 17.0111 0.470378 16.9253 0.332031 16.7925C0.199219 16.6597 0.110677 16.502 0.0664062 16.3193C0.0221354 16.1423 0.0221354 15.9652 0.0664062 15.7881C0.110677 15.611 0.196452 15.4588 0.32373 15.3315L15.3149 0.340332ZM16.7842 15.3232C16.917 15.4561 17.0028 15.6082 17.0415 15.7798C17.0858 15.9569 17.0858 16.134 17.0415 16.311C17.0028 16.4937 16.9142 16.6541 16.7759 16.7925C16.6431 16.9253 16.4881 17.0138 16.311 17.0581C16.134 17.1024 15.9569 17.1024 15.7798 17.0581C15.6027 17.0138 15.4478 16.9253 15.3149 16.7925L0.32373 1.80127C0.201986 1.67952 0.116211 1.53011 0.0664062 1.35303C0.0221354 1.17594 0.0221354 0.996094 0.0664062 0.813477C0.116211 0.630859 0.204753 0.473145 0.332031 0.340332C0.464844 0.20752 0.622559 0.118978 0.805176 0.074707C0.987793 0.0304362 1.16488 0.0304362 1.33643 0.074707C1.51351 0.118978 1.66846 0.204753 1.80127 0.332031L16.7842 15.3232Z" fill="#000"/></svg>',"eye-open":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z"/></svg>',"eye-hide":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"/></svg>',trash:'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.5013 3.33332H14.918C14.5193 1.39465 12.8139 0.0025 10.8346 0H9.16793C7.18867 0.0025 5.48328 1.39465 5.08461 3.33332H2.50129C2.04105 3.33332 1.66797 3.70641 1.66797 4.16664C1.66797 4.62687 2.04105 5 2.50129 5H3.33461V15.8333C3.33738 18.1334 5.20125 19.9973 7.50129 20H12.5013C14.8013 19.9973 16.6652 18.1334 16.668 15.8333V5H17.5013C17.9615 5 18.3346 4.62691 18.3346 4.16668C18.3346 3.70645 17.9615 3.33332 17.5013 3.33332ZM9.16797 14.1667C9.16797 14.6269 8.79488 15 8.33465 15C7.87437 15 7.50129 14.6269 7.50129 14.1667V9.16668C7.50129 8.70645 7.87437 8.33336 8.33461 8.33336C8.79484 8.33336 9.16793 8.70645 9.16793 9.16668V14.1667H9.16797ZM12.5013 14.1667C12.5013 14.6269 12.1282 15 11.668 15C11.2077 15 10.8346 14.6269 10.8346 14.1667V9.16668C10.8346 8.70645 11.2077 8.33336 11.668 8.33336C12.1282 8.33336 12.5013 8.70645 12.5013 9.16668V14.1667ZM6.81047 3.33332C7.16492 2.33523 8.10883 1.66793 9.16797 1.66664H10.8346C11.8938 1.66793 12.8377 2.33523 13.1921 3.33332H6.81047Z" fill="black" fill-opacity="0.5"/></svg>',spinner:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_290_5000)"><path d="M14.6414 8.58333C14.5128 10.1032 13.8685 11.5335 12.8153 12.6368C11.7621 13.7401 10.3634 14.4502 8.85109 14.6493C7.33883 14.8483 5.80396 14.5244 4.50113 13.7311C3.19831 12.9379 2.20584 11.7231 1.68838 10.2882C1.17092 8.85338 1.15958 7.28474 1.65623 5.84255C2.15289 4.40037 3.12769 3.17133 4.41891 2.35934C5.71013 1.54735 7.24015 1.20123 8.75514 1.37839C10.2701 1.55555 11.679 2.24534 12.748 3.33333H10.6667C10.4899 3.33333 10.3203 3.40357 10.1953 3.5286C10.0703 3.65362 10 3.82319 10 4C10 4.17681 10.0703 4.34638 10.1953 4.47141C10.3203 4.59643 10.4899 4.66667 10.6667 4.66667H13.4287C13.757 4.66649 14.0718 4.536 14.3039 4.30387C14.5361 4.07174 14.6665 3.75695 14.6667 3.42867V0.666667C14.6667 0.489856 14.5965 0.320286 14.4715 0.195262C14.3464 0.0702379 14.1769 0 14 0C13.8232 0 13.6537 0.0702379 13.5286 0.195262C13.4036 0.320286 13.3334 0.489856 13.3334 0.666667V2.052C11.9925 0.853819 10.2866 0.142989 8.4917 0.0344742C6.69675 -0.0740408 4.91768 0.426105 3.44222 1.45402C1.96675 2.48194 0.881175 3.97752 0.361055 5.69888C-0.159065 7.42024 -0.0833125 9.26672 0.57606 10.9397C1.23543 12.6127 2.43987 14.0143 3.99457 14.9179C5.54928 15.8215 7.36334 16.1742 9.14336 15.9191C10.9234 15.6639 12.5653 14.8157 13.8035 13.5117C15.0417 12.2077 15.8039 10.5242 15.9667 8.73333C15.9753 8.6405 15.9645 8.54688 15.9349 8.45846C15.9054 8.37003 15.8577 8.28873 15.795 8.21974C15.7323 8.15075 15.6559 8.09559 15.5707 8.05775C15.4854 8.01992 15.3933 8.00025 15.3 8C15.1374 7.99804 14.9799 8.05669 14.8581 8.16452C14.7364 8.27236 14.6591 8.42165 14.6414 8.58333Z" fill="black" fill-opacity="0.35"/></g><defs><clipPath id="clip0_290_5000"><rect width="16" height="16" fill="white"/></clipPath></defs></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.29448 19L3 12.8378L4.57362 11.2973L9.29448 15.9189L19.4264 6L21 7.54054L9.29448 19Z" fill="black"/></svg>',"cloud-dot":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.1401 13.925C14.2399 13.9266 14.3378 13.8983 14.4213 13.8438C14.5049 13.7893 14.5702 13.711 14.6089 13.6191C14.6476 13.5272 14.6579 13.4258 14.6385 13.3279C14.6192 13.2301 14.5709 13.1402 14.5001 13.07L12.0001 10.57L9.50011 13.07C9.4182 13.1657 9.3754 13.2887 9.38026 13.4145C9.38512 13.5404 9.43728 13.6597 9.52633 13.7488C9.61538 13.8378 9.73475 13.89 9.86058 13.8949C9.98642 13.8997 10.1095 13.8569 10.2051 13.775L11.5001 12.5V18.625C11.5001 18.7576 11.5528 18.8848 11.6466 18.9786C11.7403 19.0723 11.8675 19.125 12.0001 19.125C12.1327 19.125 12.2599 19.0723 12.3537 18.9786C12.4474 18.8848 12.5001 18.7576 12.5001 18.625V12.5L13.7851 13.785C13.8803 13.8768 14.0079 13.9271 14.1401 13.925Z" fill="black"/><path d="M18.46 9.71996C18.0211 9.77884 17.5751 9.7551 17.145 9.64996V9.76496L17.105 10.125L17.43 10.275C18.0502 10.5605 18.5545 11.0491 18.8595 11.6601C19.1645 12.271 19.2519 12.9677 19.1074 13.6351C18.9628 14.3024 18.5949 14.9005 18.0645 15.3305C17.5341 15.7605 16.8728 15.9966 16.19 16H13.5V17H16.19C17.0395 16.9958 17.8657 16.7214 18.5488 16.2163C19.2319 15.7112 19.7364 15.0017 19.9893 14.1907C20.2422 13.3797 20.2303 12.5092 19.9553 11.7054C19.6804 10.9016 19.1566 10.2062 18.46 9.71996Z" fill="black"/><path d="M4.80029 12.19C4.80848 11.2 5.19728 10.251 5.88612 9.53986C6.57495 8.82869 7.51101 8.40981 8.50029 8.37003H8.83529L8.95029 8.05503C9.2604 7.2496 9.81028 6.55878 10.5256 6.07591C11.241 5.59305 12.0873 5.34142 12.9503 5.35503C13.4051 5.35535 13.8572 5.42619 14.2903 5.56503C14.3299 5.23197 14.414 4.90573 14.5403 4.59503C14.0252 4.43613 13.4893 4.35523 12.9503 4.35503C11.9414 4.3468 10.9516 4.63029 10.1 5.1714C9.24844 5.7125 8.57138 6.48816 8.15029 7.40503C6.96363 7.53241 5.86506 8.09111 5.06315 8.97505C4.26125 9.85898 3.81186 11.0066 3.80029 12.2C3.8016 12.8321 3.92748 13.4577 4.17073 14.0411C4.41398 14.6245 4.76984 15.1543 5.21794 15.6001C5.66605 16.0459 6.19763 16.3989 6.78229 16.6392C7.36695 16.8794 7.99321 17.002 8.62529 17H10.5003V16H8.62529C7.61384 15.9987 6.64396 15.5974 5.92735 14.8836C5.21074 14.1698 4.80557 13.2015 4.80029 12.19Z" fill="black"/><path class="dot" d="M18 8.5C19.3807 8.5 20.5 7.38071 20.5 6C20.5 4.61929 19.3807 3.5 18 3.5C16.6193 3.5 15.5 4.61929 15.5 6C15.5 7.38071 16.6193 8.5 18 8.5Z" fill="black"/></svg>',"file-generic":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-exel":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111ZM64.2625 72.5125L56.5375 59.7125C56.2625 59.2625 55.775 58.9875 55.25 58.9875H50.45C50.1625 58.9875 49.8875 59.0625 49.65 59.225C48.95 59.6625 48.7375 60.5875 49.1875 61.3L59.475 77.6L49.05 94.2C48.9084 94.4277 48.8301 94.6891 48.8234 94.9571C48.8166 95.2252 48.8816 95.4902 49.0116 95.7247C49.1416 95.9592 49.3319 96.1547 49.5628 96.291C49.7937 96.4273 50.0569 96.4995 50.325 96.5H54.6375C55.1625 96.5 55.6375 96.225 55.9125 95.7875L63.75 83.1L71.5375 95.775C71.8125 96.225 72.3 96.4875 72.8125 96.4875H77.5C77.7875 96.4875 78.0625 96.4 78.3125 96.25C79.0125 95.8 79.2125 94.875 78.7625 94.175L68.2625 77.875L78.925 61.3125C79.0693 61.0855 79.1502 60.824 79.1591 60.5551C79.1681 60.2863 79.1048 60.0199 78.9759 59.7838C78.847 59.5477 78.6572 59.3505 78.4262 59.2126C78.1952 59.0748 77.9315 59.0013 77.6625 59H73.2C72.675 59 72.1875 59.275 71.9125 59.725L64.2625 72.5125Z" fill="black"/></svg>',"file-word":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111ZM66.0125 59H61.9875C61.3 59 60.7 59.4625 60.5375 60.1375L54.325 85L48.5625 60.1625C48.4 59.4875 47.8 59 47.1 59H42.675C42.4451 59.0004 42.2183 59.0535 42.0121 59.1553C41.806 59.2571 41.6259 59.4048 41.4858 59.5872C41.3458 59.7695 41.2494 59.9816 41.2042 60.207C41.159 60.4324 41.1661 60.6652 41.225 60.8875L50.5 95.3875C50.675 96.0375 51.275 96.5 51.95 96.5H55.95C56.625 96.5 57.225 96.05 57.4 95.3875L64 70.7625L70.6 95.3875C70.775 96.0375 71.375 96.5 72.05 96.5H76.025C76.7 96.5 77.3 96.05 77.475 95.3875L86.775 60.8875C86.8334 60.6653 86.8401 60.4326 86.7947 60.2074C86.7493 59.9822 86.6529 59.7703 86.5129 59.5881C86.3729 59.4059 86.1931 59.2582 85.9872 59.1562C85.7813 59.0543 85.5548 59.0009 85.325 59H80.875C80.175 59 79.575 59.4875 79.4125 60.1625L73.6875 85.05L67.4625 60.1375C67.3 59.4625 66.7 59 66.0125 59Z" fill="black"/></svg>',"file-pdf":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M66.4125 71.8L66.45 71.625C67.175 68.6375 68.0875 64.9125 67.375 61.5375C66.9 58.875 64.9375 57.8375 63.2625 57.7625C61.2875 57.675 59.525 58.8 59.0875 60.4375C58.2625 63.4375 59 67.5375 60.35 72.7625C58.65 76.8125 55.9375 82.7 53.95 86.2C50.25 88.1125 45.2875 91.0625 44.55 94.7875C44.4 95.475 44.575 96.35 44.9875 97.1375C45.45 98.0125 46.1875 98.6875 47.05 99.0125C47.425 99.15 47.875 99.2625 48.4 99.2625C50.6 99.2625 54.1625 97.4875 58.9125 89.3375C59.6375 89.1 60.3875 88.85 61.1125 88.6C64.5125 87.45 68.0375 86.25 71.225 85.7125C74.75 87.6 78.7625 88.8125 81.4875 88.8125C84.1875 88.8125 85.25 87.2125 85.65 86.25C86.35 84.5625 86.0125 82.4375 84.875 81.3C83.225 79.675 79.2125 79.25 72.9625 80.025C69.8875 78.15 67.875 75.6 66.4125 71.8ZM52.7 90.7875C50.9625 93.3125 49.65 94.575 48.9375 95.125C49.775 93.5875 51.4125 91.9625 52.7 90.7875ZM63.65 61.35C64.3 62.4625 64.2125 65.825 63.7125 67.525C63.1 65.0375 63.0125 61.5125 63.375 61.1C63.475 61.1125 63.5625 61.1875 63.65 61.35ZM63.45 76.4125C64.7875 78.725 66.475 80.7125 68.3375 82.1875C65.6375 82.8 63.175 83.8125 60.975 84.7125C60.45 84.925 59.9375 85.1375 59.4375 85.3375C61.1 82.325 62.4875 78.9125 63.45 76.4125ZM82.9 84.6C82.9125 84.625 82.925 84.6625 82.85 84.7125H82.825L82.8 84.75C82.7 84.8125 81.675 85.4125 77.2625 83.675C82.3375 83.4375 82.8875 84.5875 82.9 84.6ZM106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-zip":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M37 49H45V57H37V49ZM37 72.75V92.75H53V72.75H45V65H37V72.75ZM47 78.75V86.75H43V78.75H47ZM45 41H53V49H45V41ZM37 33H45V41H37V33ZM45 57H53V65H45V57ZM45 25H53V33H45V25ZM106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H37V25H45V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-text":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111ZM63 77.25H40C39.45 77.25 39 77.7 39 78.25V84.25C39 84.8 39.45 85.25 40 85.25H63C63.55 85.25 64 84.8 64 84.25V78.25C64 77.7 63.55 77.25 63 77.25ZM39 61.25V67.25C39 67.8 39.45 68.25 40 68.25H88C88.55 68.25 89 67.8 89 67.25V61.25C89 60.7 88.55 60.25 88 60.25H40C39.45 60.25 39 60.7 39 61.25Z" fill="black"/></svg>',"file-image":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M69.1375 63.6375L59.4125 76.0375L54.275 69.4875C54.1815 69.368 54.0619 69.2713 53.9255 69.2048C53.7891 69.1384 53.6393 69.1038 53.4875 69.1038C53.3357 69.1038 53.1859 69.1384 53.0495 69.2048C52.9131 69.2713 52.7935 69.368 52.7 69.4875L40.225 85.3875C40.1096 85.5349 40.038 85.7118 40.0183 85.8979C39.9987 86.0841 40.0319 86.272 40.114 86.4402C40.1962 86.6084 40.324 86.7501 40.4829 86.8491C40.6418 86.9481 40.8253 87.0004 41.0125 87H87C87.8375 87 88.3 86.0375 87.7875 85.3875L70.725 63.6375C70.6302 63.5178 70.5096 63.4211 70.3721 63.3546C70.2347 63.2881 70.0839 63.2536 69.9313 63.2536C69.7786 63.2536 69.6278 63.2881 69.4904 63.3546C69.3529 63.4211 69.2323 63.5178 69.1375 63.6375ZM45 55.25C45 56.5761 45.5268 57.8479 46.4645 58.7855C47.4021 59.7232 48.6739 60.25 50 60.25C51.3261 60.25 52.5979 59.7232 53.5355 58.7855C54.4732 57.8479 55 56.5761 55 55.25C55 53.9239 54.4732 52.6521 53.5355 51.7145C52.5979 50.7768 51.3261 50.25 50 50.25C48.6739 50.25 47.4021 50.7768 46.4645 51.7145C45.5268 52.6521 45 53.9239 45 55.25ZM106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-audio":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/><path d="M64.6781 93.0344C62.701 95.0114 60.2677 96 57.3781 96C54.4885 96 52.0552 95.0114 50.0781 93.0344C48.1011 91.0573 47.1125 88.624 47.1125 85.7344C47.1125 82.8448 48.1011 80.4115 50.0781 78.4344C52.0552 76.4573 54.4885 75.4688 57.3781 75.4688C58.4458 75.4657 59.4541 75.598 60.4031 75.8657C61.3521 76.1333 62.2448 76.5714 63.0813 77.1797V64.0625C63.0843 62.7728 63.5223 61.69 64.3953 60.814C65.2682 59.938 66.351 59.5 67.6438 59.5H76.7688C78.0615 59.5 79.1443 59.938 80.0172 60.814C80.8902 61.69 81.3282 62.7728 81.3313 64.0625C81.3343 65.3522 80.8978 66.435 80.0218 67.311C79.1458 68.187 78.0615 68.625 76.7688 68.625H67.6438V85.7344C67.6438 88.624 66.6552 91.0573 64.6781 93.0344Z" fill="black"/></svg>',"file-video":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/><path d="M44.2566 71.7109C44.2566 70.0637 44.911 68.4839 46.0758 67.3191C47.2405 66.1544 48.8203 65.5 50.4676 65.5H64.5457C66.1929 65.5 67.7727 66.1544 68.9375 67.3191C70.1023 68.4839 70.7566 70.0637 70.7566 71.7109V85.7891C70.7566 87.4363 70.1023 89.0161 68.9375 90.1809C67.7727 91.3456 66.1929 92 64.5457 92H50.4676C48.8203 92 47.2405 91.3456 46.0758 90.1809C44.911 89.0161 44.2566 87.4363 44.2566 85.7891V71.7109ZM79.4552 89.8187L72.4129 84.956V72.5391L79.4552 67.6763C81.3765 66.348 84 67.726 84 70.0613V87.4354C84 89.7707 81.3782 91.1454 79.4552 89.8187Z" fill="black"/></svg>',download:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/></svg>',play:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M10.804 8 5 4.633v6.734zm.792-.696a.802.802 0 0 1 0 1.392l-6.363 3.692C4.713 12.69 4 12.345 4 11.692V4.308c0-.653.713-.998 1.233-.696z"/></svg>',pause:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M6.25 5C5.56 5 5 5.56 5 6.25v3.5a1.25 1.25 0 1 0 2.5 0v-3.5C7.5 5.56 6.94 5 6.25 5m3.5 0c-.69 0-1.25.56-1.25 1.25v3.5a1.25 1.25 0 1 0 2.5 0v-3.5C11 5.56 10.44 5 9.75 5"/></svg>'}),h=(e,t="hide")=>{const i=`click.dismiss.${e.EVENT_KEY}`,a=e.NAME;s.A.on(document,i,`[data-vg-dismiss="${a}"]`,function(i){if(["A","AREA"].includes(this.tagName)&&i.preventDefault(),(0,r.d6)(this))return;const s=n.A.getSelectorFromElement(this)||this.closest(`.vg-${a}`);e.getOrCreateInstance(s)[t]()})}},355(e,t,i){i.d(t,{L:()=>d,default:()=>_,h:()=>o});var s=i(829),r=i(381),n=i(11),a=i(483);const o="application/x-vg-files-sortable";let l=!1,h=null;function d(){return l}function c(){h&&clearTimeout(h),h=setTimeout(()=>{l=!1,h=null},0)}const _=class{constructor(e,t={}){this._vg=e,this._params={handle:".file",itemSelector:"li.file",route:null,method:"POST",toast:!0,...t},!t.itemSelector&&t.handle&&(this._params.itemSelector=`li${t.handle}`),this._params.route||console.warn("VGFilesSortable: Не указан маршрут `route` для сохранения порядка."),this._params.lists?.length?this._list=this._params.lists.map(e=>s.A.find("."+e,this._vg._element)).find(e=>e):this._list=this._vg._nodes.list,(0,r.vq)(this._list)?(this._draggedItem=null,this._boundOnDragStart=this._onDragStart.bind(this),this._boundOnDragEnd=this._onDragEnd.bind(this),this._boundOnDragOver=this._onDragOver.bind(this),this._boundOnDrop=this._onDrop.bind(this),this._init()):console.error("VGFilesSortable: Не найден контейнер списка файлов")}_init(){this._enableDraggableItems(),this._setupEvents(),this._vg._triggerCallback("onSortableInit")}_enableDraggableItems(){this._list.querySelectorAll(this._params.itemSelector).forEach(e=>{e.setAttribute("draggable","true");const t=e.querySelector("img");t&&t.setAttribute("draggable","false")})}_setupEvents(){this._list.addEventListener("dragstart",this._boundOnDragStart),this._list.addEventListener("dragend",this._boundOnDragEnd),this._list.addEventListener("dragover",this._boundOnDragOver),this._list.addEventListener("drop",this._boundOnDrop)}_onDragStart(e){if(!e.target.closest(this._params.handle))return;const t=e.target.closest(this._params.itemSelector)||e.target.closest("li");t&&(this._draggedItem=t,h&&(clearTimeout(h),h=null),l=!0,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(o,"1"),e.dataTransfer.setData("text/plain","vgsortable"),t.classList.add("dragging"),requestAnimationFrame(()=>t.classList.add("dragging-transparent")))}_onDragEnd(e){this._draggedItem&&(this._draggedItem.classList.remove("dragging","dragging-transparent"),this._draggedItem=null,this._saveOrder()),c()}_onDragOver(e){if(!this._draggedItem)return;e.preventDefault(),e.dataTransfer.dropEffect="move";const t=e.target.closest(this._params.itemSelector)||e.target.closest("li");if(!t||t===this._draggedItem)return;const i=t.getBoundingClientRect(),s=i.height/2;e.clientY-i.top<s?this._list.insertBefore(this._draggedItem,t):this._list.insertBefore(this._draggedItem,t.nextSibling)}_onDrop(e){if(this._draggedItem)return e.preventDefault(),e.stopPropagation(),!1}_saveOrder(){const e=[...new Set(this._getUploadedIds())];e.length&&this._params.route&&(new n.A).post(this._params.route,{ids:e},{onSuccess:e=>a.A.run(e.response.message)})}_getUploadedIds(){return Array.from(this._list.querySelectorAll("[data-id]")).map(e=>(0,r.OM)(e.getAttribute("data-id"))||null).filter(e=>null!==e)}destroy(){this._list.removeEventListener("dragstart",this._boundOnDragStart),this._list.removeEventListener("dragend",this._boundOnDragEnd),this._list.removeEventListener("dragover",this._boundOnDragOver),this._list.removeEventListener("drop",this._boundOnDrop),this._draggedItem=null,c()}}},483(e,t,i){i.d(t,{A:()=>s});const s=i(614).A},614(e,t,i){i.d(t,{A:()=>T});var s=i(188),r=i(647),n=i(810),a=i(546),o=i(381),l=i(829);const h={enable:!1,selector:".vg-toast-wrapper",threshold:4,resizeEdgeSize:8,debug:!1},d=class{constructor(e,t,i={}){this._modalElement=e,this._dialogElement=t,this._options=this._normalizeOptions(i),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._dialogStartLeft=0,this._dialogStartTop=0,this._dialogWidth=0,this._dialogHeight=0,this._isEnabled=!1,this._previousUserSelect="",this._previousTransition="",this._previousWillChange="",this._initialRect=null,this._lockedIframes=[],this._debugElement=null,this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onNativeDragStart=this._onNativeDragStart.bind(this)}setOptions(e={}){this._options=this._normalizeOptions(e,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._dialogElement.addEventListener("pointerdown",this._onPointerDown),this._isEnabled=!0)}disable(){this._dialogElement&&this._isEnabled&&(this._dialogElement.removeEventListener("pointerdown",this._onPointerDown),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgToastDragging,this._setDebugVisibility(!1),this._isEnabled=!1)}syncPosition(){if(!this._isEnabled)return;if(!this._isPreparedForInteraction())return;const e=this._dialogElement.getBoundingClientRect(),t=this._dialogElement.offsetWidth||e.width,i=this._dialogElement.offsetHeight||e.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:e.left,a=Number.isFinite(r)?r:e.top,o=Math.max(0,window.innerWidth-t),l=Math.max(0,window.innerHeight-i),h=Math.min(o,Math.max(0,n)),d=Math.min(l,Math.max(0,a));this._dialogElement.style.left=`${h}px`,this._dialogElement.style.top=`${d}px`,this._updateDebugValues("synced")}_onPointerDown(e){if(0!==e.button)return;const t=this._resolveDragArea(e.target);t&&this._dialogElement.contains(t)&&(this._isPointerOnResizeEdge(e)||e.target.closest('input, textarea, select, button, a, [contenteditable="true"]')||t&&t.closest('[data-vg-dismiss="toast"]')||(this._pointerId=e.pointerId,this._dragTarget=e.target,this._isDragging=!1,e.preventDefault(),this._previousUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",this._initialRect=this._dialogElement.getBoundingClientRect(),this._dialogStartLeft=this._initialRect.left,this._dialogStartTop=this._initialRect.top,this._dialogWidth=this._initialRect.width,this._dialogHeight=this._initialRect.height,this._startX=e.clientX,this._startY=e.clientY,this._currentX=e.clientX,this._currentY=e.clientY,this._lockEmbeddedFrames(),this._modalElement.dataset.vgToastDragging="true",this._setDebugVisibility(!0),this._updateDebugValues("armed"),document.addEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement&&this._dialogElement.setPointerCapture&&this._dialogElement.setPointerCapture(e.pointerId),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)))}_onPointerMove(e){if(e.pointerId===this._pointerId){if(this._currentX=e.clientX,this._currentY=e.clientY,!this._isDragging){const t=this._currentX-this._startX,i=this._currentY-this._startY;if(Math.hypot(t,i)<this._options.threshold)return;this._isDragging=!0,this._dialogElement.style.touchAction="none",this._applyDragStyles(),this._preparePosition(this._initialRect),e.preventDefault(),this._updateDebugValues("dragging")}this._applyDragPosition()}}_onPointerUp(e){e.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._isDragging&&this._applyDragPosition(),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._dialogElement&&this._dialogElement.releasePointerCapture&&this._dialogElement.releasePointerCapture(e.pointerId),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgToastDragging,this._setDebugVisibility(this._options.debug),this._updateDebugValues("idle"))}_preparePosition(e=null){if(!this._dialogElement)return;const t=e||this._dialogElement.getBoundingClientRect();this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${t.left}px`,this._dialogElement.style.top=`${t.top}px`,this._dialogElement.style.width=`${t.width}px`,this._dialogElement.style.height=`${t.height}px`,this._dialogElement.style.transform="none",this._dialogElement.style.translate="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_isPointerOnResizeEdge(e){const t=this._dialogElement.getBoundingClientRect(),i=e.clientX-t.left,s=e.clientY-t.top,r=this._options.resizeEdgeSize,n=s>=0&&s<=r,a=s<=t.height&&s>=t.height-r,o=i>=0&&i<=r,l=i<=t.width&&i>=t.width-r;return n||a||o||l}_applyDragPosition(){if(null===this._pointerId||!this._isDragging)return;const e=this._currentX-this._startX,t=this._currentY-this._startY,i=Math.max(0,window.innerWidth-this._dialogWidth),s=Math.max(0,window.innerHeight-this._dialogHeight),r=Math.min(i,Math.max(0,this._dialogStartLeft+e)),n=Math.min(s,Math.max(0,this._dialogStartTop+t));this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._updateDebugValues("dragging")}_onNativeDragStart(e){null!==this._pointerId&&e.preventDefault()}_applyDragStyles(){this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top"}_restoreDragStyles(){this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const e=this._dialogElement.querySelectorAll("iframe");for(const t of e)this._lockedIframes.push({element:t,pointerEvents:t.style.pointerEvents}),t.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const e of this._lockedIframes)e.element.style.pointerEvents=e.pointerEvents;this._lockedIframes=[]}}_normalizeOptions(e,t=h){const i={...t,...e},s=Number(i.threshold),r=Number(i.resizeEdgeSize),n="string"==typeof i.selector&&i.selector.trim()?i.selector:h.selector;return{...i,selector:n,threshold:Number.isFinite(s)&&s>=0?s:h.threshold,resizeEdgeSize:Number.isFinite(r)&&r>0?r:h.resizeEdgeSize,debug:Boolean(i.debug)}}_resolveDragArea(e){try{return e.closest(this._options.selector)}catch(t){return e.closest(h.selector)}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="170px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="7",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues(this._isDragging?"dragging":"idle")):this._setDebugVisibility(!1)}_setDebugVisibility(e){this._debugElement&&(this._debugElement.style.display=e?"block":"none")}_updateDebugValues(e="idle"){if(!this._debugElement||!this._options.debug)return;const t=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`drag:${e} x:${Math.round(t.left)} y:${Math.round(t.top)} w:${Math.round(t.width)} h:${Math.round(t.height)}`}},c={enable:!1,minWidth:300,minHeight:160,edgeSize:8,debug:!1},_={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"},u=class{constructor(e,t,i={}){this._modalElement=e,this._dialogElement=t,this._contentElement=this._dialogElement?this._dialogElement.querySelector(".vg-toast-wrapper"):null,this._options=this._normalizeOptions(i),this._pointerId=null,this._direction="",this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._startWidth=0,this._startHeight=0,this._startLeft=0,this._startTop=0,this._startRight=0,this._startBottom=0,this._isEnabled=!1,this._observer=null,this._syncFrameId=null,this._resizeFrameId=null,this._lockedIframes=[],this._debugElement=null,this._previousMaxWidth="",this._previousMaxHeight="",this._previousPointerEvents="",this._previousMinHeight="",this._previousOverflow="",this._previousTransition="",this._previousWillChange="",this._previousContentHeight="",this._previousContentMaxHeight="",this._previousContentOverflow="",this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerLeave=this._onPointerLeave.bind(this),this._applyResizePosition=this._applyResizePosition.bind(this)}setOptions(e={}){this._options=this._normalizeOptions(e,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._modalElement.addEventListener("pointermove",this._onPointerMove),this._modalElement.addEventListener("pointerdown",this._onPointerDown),this._modalElement.addEventListener("pointerleave",this._onPointerLeave),this._startObserveSizeChanges(),this._isEnabled=!0)}disable(){this._isEnabled&&(this._modalElement.removeEventListener("pointermove",this._onPointerMove),this._modalElement.removeEventListener("pointerdown",this._onPointerDown),this._modalElement.removeEventListener("pointerleave",this._onPointerLeave),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._stopObserveSizeChanges(),this._pointerId=null,this._direction="",this._dialogElement.style.cursor="",delete this._modalElement.dataset.vgToastResizing,this._unlockEmbeddedFrames(),this._restoreResizeStyles(),this._setDebugVisibility(!1),this._isEnabled=!1)}syncToViewport(){if(this._modalElement&&"true"===this._modalElement.dataset.vgToastDragging)return;if(!this._isPreparedForInteraction())return;const e=this._dialogElement.getBoundingClientRect(),t=this._dialogElement.offsetWidth||e.width,i=this._dialogElement.offsetHeight||e.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:e.left,a=Number.isFinite(r)?r:e.top,o=window.innerWidth,l=window.innerHeight,h=Math.max(this._options.minWidth,Math.min(t,o)),d=Math.max(this._options.minHeight,Math.min(i,l)),c=Math.max(0,window.innerWidth-h),_=Math.max(0,window.innerHeight-d),u=Math.min(c,Math.max(0,n)),m=Math.min(_,Math.max(0,a));Math.abs(t-h)>.5&&(this._dialogElement.style.width=`${h}px`),Math.abs(i-d)>.5&&(this._dialogElement.style.height=`${d}px`),this._dialogElement.style.left=`${u}px`,this._dialogElement.style.top=`${m}px`,this._updateDebugValues()}_onPointerDown(e){if(0!==e.button)return;if(e.defaultPrevented)return;const t=this._getDirectionFromPointer(e);if(!t)return;e.preventDefault(),this._pointerId=e.pointerId,this._direction=t;const i=this._dialogElement.getBoundingClientRect();this._applyResizeStyles(),this._preparePosition(i),this._startX=e.clientX,this._startY=e.clientY,this._currentX=e.clientX,this._currentY=e.clientY,this._startWidth=i.width,this._startHeight=i.height,this._startLeft=i.left,this._startTop=i.top,this._startRight=i.right,this._startBottom=i.bottom,this._lockEmbeddedFrames(),this._modalElement.dataset.vgToastResizing="true",this._setDebugVisibility(!0),this._updateDebugValues(),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)}_onPointerMove(e){if(null===this._pointerId){const t=this._getDirectionFromPointer(e);return void(this._dialogElement.style.cursor=t?_[t]:"")}e.pointerId===this._pointerId&&(this._currentX=e.clientX,this._currentY=e.clientY,null===this._resizeFrameId&&(this._resizeFrameId=window.requestAnimationFrame(this._applyResizePosition)))}_applyResizePosition(){if(this._resizeFrameId=null,null===this._pointerId)return;const e=this._currentX-this._startX,t=this._currentY-this._startY;let i=this._startWidth,s=this._startHeight,r=this._startLeft,n=this._startTop;if(this._direction.includes("e")){const t=Math.max(this._options.minWidth,window.innerWidth-this._startLeft);i=Math.min(t,Math.max(this._options.minWidth,this._startWidth+e))}if(this._direction.includes("s")){const e=Math.max(this._options.minHeight,window.innerHeight-this._startTop);s=Math.min(e,Math.max(this._options.minHeight,this._startHeight+t))}if(this._direction.includes("w")){const t=this._startRight-this._options.minWidth;r=Math.min(t,Math.max(0,this._startLeft+e)),i=this._startRight-r}if(this._direction.includes("n")){const e=this._startBottom-this._options.minHeight;n=Math.min(e,Math.max(0,this._startTop+t)),s=this._startBottom-n}this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._dialogElement.style.width=`${i}px`,this._dialogElement.style.height=`${s}px`,this._updateDebugValues()}_onPointerUp(e){e.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._applyResizePosition(),this._pointerId=null,this._direction="",delete this._modalElement.dataset.vgToastResizing,this._unlockEmbeddedFrames(),this._setDebugVisibility(this._options.debug),this._updateDebugValues())}_onPointerLeave(){null===this._pointerId&&(this._dialogElement.style.cursor="")}_getDirectionFromPointer(e){const t=this._dialogElement.getBoundingClientRect(),i=e.clientX-t.left,s=e.clientY-t.top,r=this._options.edgeSize;if(!(i>=0&&i<=t.width&&s>=0&&s<=t.height))return"";const n=s>=0&&s<=r,a=s<=t.height&&s>=t.height-r,o=i>=0&&i<=r,l=i<=t.width&&i>=t.width-r;return n&&o?"nw":n&&l?"ne":a&&o?"sw":a&&l?"se":n?"n":a?"s":o?"w":l?"e":""}_preparePosition(e){this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${e.left}px`,this._dialogElement.style.top=`${e.top}px`,this._dialogElement.style.width=`${e.width}px`,this._dialogElement.style.height=`${e.height}px`,this._dialogElement.style.transform="none",this._dialogElement.style.translate="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_startObserveSizeChanges(){"undefined"==typeof ResizeObserver||this._observer||(this._observer=new ResizeObserver(()=>{null===this._pointerId&&(this._modalElement&&"true"===this._modalElement.dataset.vgToastDragging||null===this._syncFrameId&&(this._syncFrameId=window.requestAnimationFrame(()=>{this._syncFrameId=null,this.syncToViewport()})))}),this._observer.observe(this._dialogElement))}_stopObserveSizeChanges(){this._observer&&(this._observer.disconnect(),this._observer=null),null!==this._syncFrameId&&(window.cancelAnimationFrame(this._syncFrameId),this._syncFrameId=null)}_applyResizeStyles(){this._previousMaxWidth=this._dialogElement.style.maxWidth,this._previousMaxHeight=this._dialogElement.style.maxHeight,this._previousPointerEvents=this._dialogElement.style.pointerEvents,this._previousMinHeight=this._dialogElement.style.minHeight,this._previousOverflow=this._dialogElement.style.overflow,this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.maxWidth="none",this._dialogElement.style.maxHeight="none",this._dialogElement.style.pointerEvents="auto",this._dialogElement.style.minHeight=`${this._options.minHeight}px`,this._dialogElement.style.overflow="hidden",this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top, width, height",this._contentElement&&(this._previousContentHeight=this._contentElement.style.height,this._previousContentMaxHeight=this._contentElement.style.maxHeight,this._previousContentOverflow=this._contentElement.style.overflow,this._contentElement.style.height="100%",this._contentElement.style.maxHeight="100%",this._contentElement.style.overflow="auto")}_restoreResizeStyles(){this._dialogElement.style.maxWidth=this._previousMaxWidth,this._dialogElement.style.maxHeight=this._previousMaxHeight,this._dialogElement.style.pointerEvents=this._previousPointerEvents,this._dialogElement.style.minHeight=this._previousMinHeight,this._dialogElement.style.overflow=this._previousOverflow,this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange,this._contentElement&&(this._contentElement.style.height=this._previousContentHeight,this._contentElement.style.maxHeight=this._previousContentMaxHeight,this._contentElement.style.overflow=this._previousContentOverflow)}_normalizeOptions(e,t=c){const i={...t,...e},s=Number(i.minWidth),r=Number(i.minHeight),n=Number(i.edgeSize);return{...i,minWidth:Number.isFinite(s)&&s>0?s:c.minWidth,minHeight:Number.isFinite(r)&&r>0?r:c.minHeight,edgeSize:Number.isFinite(n)&&n>0?n:c.edgeSize,debug:Boolean(i.debug)}}_cancelResizeFrame(){null!==this._resizeFrameId&&(window.cancelAnimationFrame(this._resizeFrameId),this._resizeFrameId=null)}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const e=this._dialogElement.querySelectorAll("iframe");for(const t of e)this._lockedIframes.push({element:t,pointerEvents:t.style.pointerEvents}),t.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const e of this._lockedIframes)e.element.style.pointerEvents=e.pointerEvents;this._lockedIframes=[]}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="8px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="6",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues()):this._setDebugVisibility(!1)}_setDebugVisibility(e){this._debugElement&&(this._debugElement.style.display=e?"block":"none")}_updateDebugValues(){if(!this._debugElement||!this._options.debug)return;const e=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`w:${Math.round(e.width)} h:${Math.round(e.height)} x:${Math.round(e.left)} y:${Math.round(e.top)}`}},m="vg.toast",p="vg-toast-open",g="show",f="shown",b="vg-toast-effect-",v={none:"",fade:`${b}fade`,zoom:`${b}zoom`,blur:`${b}blur`,"slide-up":`${b}slide-up`,"slide-down":`${b}slide-down`},y=`${m}.hide`,w=`${m}.hidden`,E=`${m}.show`,A=`${m}.shown`,S=`${m}.loaded`,C=`keydown.dismiss.${m}`,x=`click.${m}.data.api`,L=`pointerdown.interaction.${m}`,I=`pointerup.interaction.${m}`,P=`pointercancel.interaction.${m}`,k={success:"success",error:"danger",warning:"warning",info:"info"},M={static:!0,placement:"bottom center",autohide:!1,delay:3e3,enableClickToast:!0,enableButtonClose:!1,keyboard:!0,theme:"dark",type:null,stack:{enable:!0,max:5},drag:{enable:!1,selector:".vg-toast-wrapper",threshold:4,resizeEdgeSize:8,debug:!1},resize:{enable:!1,edgeSize:8,minWidth:220,minHeight:64,debug:!1},animation:{enable:!0,in:"animate__backInUp",out:"animate__backOutDown",delay:300,effect:"none"},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0}};class D extends s.A{constructor(e,t={}){super(e,t),this._interactionDefaults={drag:{enable:!1,selector:".vg-toast-wrapper",threshold:4,resizeEdgeSize:8,debug:!1},resize:{enable:!1,edgeSize:8,minWidth:220,minHeight:64,debug:!1}},this._params=this._getParams(e,(0,o._v)(M,t)),this._dragHandler=new d(this._element,this._element),this._resizeHandler=new u(this._element,this._element),this._interactionConfig=this._resolveInteractionConfig(),this._dragHandler.setOptions(this._interactionConfig.drag),this._resizeHandler.setOptions(this._interactionConfig.resize),this._animation(this._element,D.NAME_KEY,this._params.animation),this._applyAnimationEffects(),this._dismissElement(),this._addEventListeners(),this._timeout=null,this._hideTimeout=null,this._isHiding=!1}static get NAME(){return"toast"}static get NAME_KEY(){return m}static run(e,t={},i){return D.build(e,t,i)}static build(e,t,i){const s=t&&"object"==typeof t?t:{},r=Object.prototype.hasOwnProperty.call(s,"autohide");(t=(0,o._v)(M,{static:!1,autohide:!0},s)).static&&!r&&(t.autohide=!1);const l="vg-toast-"+(0,o.PR)(),h=document.createElement("div");h.classList.add("vg-toast"),h.id=l,t.theme&&h.classList.add(`vg-toast-${t.theme}`),t.placement&&t.placement.split(" ").forEach(e=>h.classList.add(e));const d=document.createElement("div");if(d.classList.add("vg-toast-wrapper"),t.type){const e=k[t.type],i=e?(0,n.z)(e):"";if(i){const e=document.createElement("div");e.classList.add("vg-toast-icon");const t=a.A.toSafeHtmlString(i),s=document.createRange().createContextualFragment(t).firstElementChild;s&&e.append(s),d.append(e)}}const c=document.createElement("div");c.classList.add("vg-toast-content");const _=document.createElement("div");if(_.classList.add("vg-toast-body"),"string"==typeof e)_.innerHTML=e,c.append(_);else if(Array.isArray(e)){if(e.length>1){const t=document.createElement("div");t.classList.add("vg-toast-header"),t.innerHTML=e[0],c.append(t)}_.innerHTML=e[1],c.append(_)}if(d.append(c),t.enableButtonClose){h.classList.add("vg-toast-has-button");const e=document.createElement("div");e.classList.add("vg-toast-button"),e.innerHTML='<button class="vg-btn-close" data-vg-dismiss="toast"></button>',d.append(e)}h.append(d),document.body.append(h);const u=D.getOrCreateInstance(h,t);return t.animation&&(u._animation(h,D.NAME_KEY,t.animation),u._applyAnimationEffects()),(0,o.g7)(i,[u]),u.show(),u}toggle(e){return this._isShown()?this.hide():this.show(e)}show(e){if((0,o.d6)(this._element))return;const t=this._element;this._clearTimeout(),this._clearHideTimeout(),this._isHiding=!1,this._disableInteractionHandlers(),this._params=this._getParams(e||{},this._params),this._route((e,i)=>{this._element===t&&r.A.trigger(t,S,{stats:e,data:i})}),r.A.trigger(t,E,{relatedTarget:e}).defaultPrevented||(t.classList.remove(f),t.classList.add(g),document.body.classList.add(p),this._setPlacement(),this._queueCallback(()=>{this._element!==t||this._isHiding||(t.classList.add(f),this._toggleInteractionHandlers(),this._syncInteractiveBounds(),this._scheduleHide(),r.A.trigger(t,A,{relatedTarget:e}))},t,!0,this._params.animation.delay))}hide(){if((0,o.d6)(this._element)||this._isHiding)return;const e=this._element;this._clearTimeout(),this._clearHideTimeout(),r.A.trigger(e,y).defaultPrevented||(this._isHiding=!0,e.classList.remove(f),this._disableInteractionHandlers(),this._hideTimeout=setTimeout(()=>{this._hideTimeout=null,this._element===e&&(e.classList.remove(g),this._params.stack.enable&&this._setPlacement(),this._queueCallback(()=>{if(this._element!==e)return;l.A.find(".vg-toast.show")||document.body.classList.remove(p);const t=!this._params.static;this._isHiding=!1,r.A.trigger(e,w),this._element===e&&t&&this.dispose()},e,!1,this._params.animation.delay))},this._params.animation.delay))}dispose(){this._element&&(this._clearTimeout(),this._clearHideTimeout(),this._disableInteractionHandlers(),this._params.static||this._element.remove(),super.dispose())}_scheduleHide(){this._clearTimeout(),this._params.autohide&&(this._timeout=setTimeout(()=>this.hide(),this._params.delay))}_isShown(){return!!this._element&&this._element.classList.contains(g)}_enableStack(){const e=this._params.placement.includes("top")?"top":"bottom",t=l.A.findAll(`.vg-toast.show.${e}`).filter(e=>{const t=D.getInstance(e);return t?._params.stack.enable});if(!this._params.stack.enable)return t.filter(e=>e!==this._element).forEach(e=>D.getInstance(e).hide()),[{el:this._element,top:0}];t.length>=this._params.stack.max&&t.slice(0,t.length-this._params.stack.max+1).forEach(e=>D.getInstance(e).hide());const i=t.filter(e=>e!==this._element).reduce((e,t)=>e+t.clientHeight,0);return t.includes(this._element)?t.map((e,i)=>({el:e,top:t.slice(0,i).reduce((e,t)=>e+t.clientHeight,0)})):[{el:this._element,top:i}]}_setPlacement(){const e=this._enableStack(),t=this._params.placement.includes("top"),i=t?"top":"bottom",s=l.A.findAll(`.vg-toast.show.${i}`).filter(e=>{const t=D.getInstance(e);return t?._params.stack.enable}),r=s.length?s:e.map(e=>e.el);let n=0;r.forEach(e=>{const i=D.getInstance(e),s=i?._params.placement||this._params.placement,r=s.includes("center"),a=s.includes("left"),o=s.includes("right"),l=e.style;l.left="",l.right="",l.top="",l.bottom="",l.transform="",l.translate="",r?(l.left="50%",l.translate="-50% 0"):a?l.left="0":o?l.right="0":(l.left="50%",l.translate="-50% 0"),t?l.top=n+"px":l.bottom=n+"px",n+=e.offsetHeight})}_toggleInteractionHandlers(){this._interactionConfig=this._resolveInteractionConfig(),this._dragHandler.setOptions(this._interactionConfig.drag),this._resizeHandler.setOptions(this._interactionConfig.resize),this._interactionConfig.drag.enable?this._dragHandler.enable():this._dragHandler.disable(),this._interactionConfig.resize.enable?this._resizeHandler.enable():this._resizeHandler.disable()}_disableInteractionHandlers(){this._dragHandler.disable(),this._resizeHandler.disable()}_syncInteractiveBounds(){this._interactionConfig.resize.enable&&this._resizeHandler.syncToViewport(),this._interactionConfig.drag.enable&&this._dragHandler.syncPosition()}_resolveInteractionConfig(){return{drag:this._normalizeInteractionParams(this._params.drag,this._interactionDefaults.drag),resize:this._normalizeInteractionParams(this._params.resize,this._interactionDefaults.resize)}}_normalizeInteractionParams(e,t){if("boolean"==typeof e)return{...t,enable:e};if(e&&"object"==typeof e){const i=Object.prototype.hasOwnProperty.call(e,"enable");return{...t,...e,enable:!i||Boolean(e.enable)}}return{...t}}_applyAnimationEffects(){const e=this._element.classList;[...e].filter(e=>e.startsWith(b)).forEach(t=>e.remove(t)),this._resolveAnimationEffectClasses(this._params.animation?.effect).forEach(t=>e.add(t))}_resolveAnimationEffectClasses(e){const t=(Array.isArray(e)?e:[e]).filter(Boolean).map(e=>this._resolveAnimationEffectClass(e)).filter(Boolean);return Array.from(new Set(t))}_resolveAnimationEffectClass(e){if("string"!=typeof e)return"";const t=e.trim().toLowerCase();return t?Object.prototype.hasOwnProperty.call(v,t)?v[t]:e.trim():""}_clearTimeout(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)}_clearHideTimeout(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_addEventListeners(){this._params.keyboard&&r.A.on(document,C,e=>{"Escape"===e.key&&this._isShown()&&this.hide()}),this._params.enableClickToast&&(this._element.classList.add("vg-toast-pointer"),r.A.on(document,x,`#${this._element.id}`,()=>{this.hide()})),r.A.on(this._element,L,()=>{this._clearTimeout()});const e=()=>{this._isShown()&&this._scheduleHide()};r.A.on(this._element,I,e),r.A.on(this._element,P,e)}}(0,n.P)(D),r.A.on(document,x,'[data-vg-toggle="toast"]',function(e){const t=l.A.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,o.d6)(this)||(this.setAttribute("aria-expanded","true"),r.A.one(t,w,()=>{this.setAttribute("aria-expanded","false")}),D.getOrCreateInstance(t).toggle(this))});const T=D},11(e,t,i){i.d(t,{A:()=>r});var s=i(381);const r=class{static _toRouteQueryParamValue(e){return Array.isArray(e)?e.map(e=>String(e||"").trim()).filter(e=>""!==e).join(","):e}static buildRouteUrl(e,t={}){const i=String(e||"").trim();if(!i)throw new Error("Request endpoint is empty");const r=(0,s.Gv)(t.baseParams)?t.baseParams:{},n=(0,s.Gv)(t.params)?t.params:{},a=new URL(i,window.location.origin),o={...r,...n};return Object.keys(o).forEach(e=>{const t=this._toRouteQueryParamValue(o[e]);null!=t&&""!==t&&a.searchParams.set(e,String(t))}),a}static async requestRoute(e={}){const t=String(e.method||"GET").toUpperCase().trim()||"GET",i=(0,s.Gv)(e.headers)?{...e.headers}:{},r=String(e.credentials||"same-origin").trim()||"same-origin",n=(0,s.Gv)(e.baseParams)?e.baseParams:{},a=(0,s.Gv)(e.params)?e.params:{},o=void 0!==e.body&&null!==e.body,l="GET"===t||"HEAD"===t,h=String(e.route||e.endpoint||"").trim(),d=this.buildRouteUrl(h,{baseParams:n,params:l?a:{}}),c={method:t,credentials:r,headers:i,signal:e.signal||void 0};if(!l&&o){const t=e.body;"undefined"!=typeof FormData&&t instanceof FormData?(delete c.headers["Content-Type"],c.body=t):"string"==typeof t?(c.headers["Content-Type"]||(c.headers["Content-Type"]="application/json"),c.body=t):(c.headers["Content-Type"]||(c.headers["Content-Type"]="application/json"),c.body=JSON.stringify(t))}const _=await fetch(d.toString(),c),u=String(_.headers.get("content-type")||"").toLowerCase(),m="json"===e.responseType||"text"!==e.responseType&&u.includes("application/json"),p=await(async()=>{if(m)try{return await _.json()}catch(e){return await _.text()}return _.text()})();if(!_.ok){const e=p&&"object"==typeof p&&p.error&&"object"==typeof p.error?p.error:{},t="string"==typeof p&&p.trim()?p:_.statusText,i=String(e.message||t||"Request failed"),s=new Error(i);throw s.status=_.status,s.code=e.code||"REQUEST_FAILED",s.details=Array.isArray(e.details)?e.details:[],s.requestId=e.request_id||_.headers.get("X-Request-Id")||"",s.response=p,s}return p}constructor(e={}){this.baseUrl=e.baseUrl||"",this.defaultHeaders={"X-Requested-With":"XMLHttpRequest",...e.headers},this.withCredentials=e.withCredentials||!1,this.csrfToken=e._token||this._getCsrfToken()}_getCsrfToken(){const e=document.querySelector('meta[name="csrf-token"]');return e?e.getAttribute("content"):(console.warn('CSRF-токен не найден в <meta name="csrf-token">'),"")}request(e,{method:t="GET",body:i=null,headers:r={},signal:n=null,onProgress:a=null,onSuccess:o=s.lQ,onError:l=s.lQ,onUploadStart:h=s.lQ,onUploadEnd:d=s.lQ}={}){const c=this.baseUrl+e,_=i instanceof FormData,u={...this.defaultHeaders,...r},m="GET"===t.toUpperCase();return m&&(i=null),m||_||!this.csrfToken||(i||(i={}),"object"!=typeof i||Array.isArray(i)||(i._token=this.csrfToken)),_||"Content-Type"in r||(u["Content-Type"]="application/json"),_||a?this._makeXHR({method:t,url:c,body:i,headers:u,signal:n,onProgress:a,onSuccess:o,onError:l,onUploadStart:h,onUploadEnd:d}):this._makeFetch({url:c,method:t,body:m?void 0:this._serializeBody(i),headers:u,signal:n,withCredentials:this.withCredentials,onSuccess:o,onError:l})}_makeFetch({url:e,method:t,body:i,headers:r,signal:n,withCredentials:a,onSuccess:o,onError:l}){const h={method:t,headers:r,signal:n,credentials:a?"include":"same-origin",...void 0!==i&&{body:i}};fetch(e,h).then(e=>{const t=e.headers.get("content-type"),i=t&&t.includes("application/json");if(!e.ok)return Promise.reject((0,s.OM)({code:e.status,response:i?e.json().catch(()=>e.text()):e.text()}));let r={code:e.status};return r.response=i?e.json():e.text(),r}).then(e=>{e&&e.response instanceof Promise?e.response.then(t=>o({...e,response:t}),()=>{}):o(e)}).catch(e=>{"AbortError"!==e.name&&(e&&e.response instanceof Promise?e.response.then(t=>{l({...e,response:t})},()=>{l({...e,response:"Request failed"})}):l(e))})}_makeXHR({method:e,url:t,body:i,headers:r,signal:n,onProgress:a,onSuccess:o,onError:l,onUploadStart:h,onUploadEnd:d}){const c=new XMLHttpRequest;return c.open(e,t,!0),c.withCredentials=this.withCredentials,Object.keys(r).forEach(e=>{"content-type"===e.toLowerCase()&&i instanceof FormData||c.setRequestHeader(e,r[e])}),a&&c.upload.addEventListener("progress",e=>{e.lengthComputable&&a(Math.round(e.loaded/e.total*100),e)}),c.onload=()=>{if(c.status>=200&&c.status<300){const e={code:c.status,response:(0,s.OM)(c.responseText)};o(e)}else{const e=(0,s.OM)({code:c.status,response:c.responseText||`HTTP ${c.status}`});l(e)}d()},c.onerror=()=>{l((0,s.OM)({code:0,response:"Network Error"})),d()},c.ontimeout=()=>{l((0,s.OM)({code:0,response:"Request Timeout"})),d()},n&&n.addEventListener("abort",()=>{c.abort()}),h(),c.send(i),c}get(e,t={}){return this.request(e,{method:"GET",...t})}post(e,t,i={}){return this.request(e,{method:"POST",body:t,...i})}put(e,t,i={}){return this.request(e,{method:"PUT",body:t,...i})}delete(e,t={}){return this.request(e,{method:"DELETE",...t})}patch(e,t,i={}){return this.request(e,{method:"PATCH",body:t,...i})}_serializeBody(e){if(e&&!(e instanceof FormData))return JSON.stringify(e)}}},667(e,t,i){i.d(t,{A:()=>a});var s=i(381),r=i(23);class n{constructor(e,t=null){this._params=this.merge(e,t)}get(){return this._params}fromElement(e){return(0,s.vq)(e)?r.p.get(e):{}}static stringToNestedObject(e,t){return e.split("-").reduceRight((e,t)=>({[t]:e}),t)}merge(e,t){let i=(0,s._v)(e,this.fromElement(t));return Object.keys(i).forEach(e=>{if("params"===e&&(i=(0,s._v)(i,i.params),delete i.params),e.includes("-")){const t=n.stringToNestedObject(e,i[e]);i=(0,s._v)(i,t),delete i[e]}}),i}}const a=n},546(e,t,i){i.d(t,{A:()=>l});const s=new Set(["svg","g","path","line","polyline","polygon","circle","ellipse","rect","defs","symbol","title","use"]),r=new Set(["xmlns","viewbox","width","height","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","opacity","transform","class","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","points","d","role","focusable","aria-hidden","href","xlink:href"]);function n(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function a(e,t=s,i=r){if(!e)return null;if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||"");if(e.nodeType!==Node.ELEMENT_NODE)return null;const n=e.tagName.toLowerCase();if(!t.has(n))return null;const o=document.createElementNS("http://www.w3.org/2000/svg",n);return Array.from(e.attributes||[]).forEach(e=>{const t=e.name.toLowerCase(),s=e.value||"";i.has(t)&&!t.startsWith("on")&&("href"!==t&&"xlink:href"!==t||!s||s.startsWith("#"))&&o.setAttribute(t,s)}),Array.from(e.childNodes||[]).forEach(e=>{const s=a(e,t,i);s&&o.append(s)}),o}function o(e,{allowedSvgTags:t=s,allowedSvgAttrs:i=r}={}){if(null==e)return"";const o=String(e).trim();if(!o)return"";if(!o.includes("<"))return n(o);const l=document.createElement("template");return l.innerHTML=o,Array.from(l.content.childNodes).map(e=>a(e,t,i)).filter(Boolean).map(e=>e.nodeType===Node.TEXT_NODE?n(e.textContent||""):e.nodeType===Node.ELEMENT_NODE?e.outerHTML:"").join("")||n(o)}const l=class{static toSafeHtmlString(e,t){return o(e,t)}}},601(e,t,i){i.d(t,{A:()=>n});var s=i(810);class r{constructor(e="string"){this.mode=e,this.document="undefined"!=typeof document?document:null,this.tags={selfClosing:["img","input","br","hr","meta","link","area","base","col","command","embed","keygen","param","source","track","wbr"]}}setMode(e){return this.mode=e,this}element(e,t={},i=null,s={}){return"dom"===this.mode&&this.document?this._createDomElement(e,t,i,s):this._createHtmlString(e,t,i,s)}_createDomElement(e,t,i,s={}){const r=this.document.createElement(e);return this._setDomAttributes(r,t),null===i||this.tags.selfClosing.includes(e)||(Array.isArray(i)?i.forEach(e=>{"string"==typeof e?r.appendChild(this.document.createTextNode(e)):e instanceof Node&&r.appendChild(e)}):i instanceof Node?r.appendChild(i):"isHTML"in s&&s.isHTML?r.innerHTML=i:r.textContent=i),r}_setDomAttributes(e,t){t&&Object.entries(t).forEach(([t,i])=>{null!=i&&!1!==i&&(!0===i?e.setAttribute(t,""):e.setAttribute(t,String(i)))})}_createHtmlString(e,t,i,s=!1){const r=this._attributesToString(t);if(this.tags.selfClosing.includes(e))return`<${e}${r}>`;const n=null!==i?this._contentToString(i):"";return""===e?`${n}`:`<${e}${r}>${n}</${e}>`}_contentToString(e){return Array.isArray(e)?e.map(e=>e instanceof Node?this._nodeToString(e):String(e)).join(""):e instanceof Node?this._nodeToString(e):String(e)}_nodeToString(e){return e.outerHTML?e.outerHTML:String(e)}_attributesToString(e){if(!e||0===Object.keys(e).length)return"";const t=Object.entries(e).map(([e,t])=>null==t||!1===t?"":!0===t?e:`${e}="${String(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}"`).filter(e=>""!==e);return t.length?" "+t.join(" "):""}div(e={},t="",i={}){return this.element("div",e,t,i)}span(e={},t="",i={}){return this.element("span",e,t,i)}i(e={},t="",i={}){return this.element("i",e,t,i)}p(e={},t="",i={}){return this.element("p",e,t,i)}a(e,t="",i={},s={}){return this.element("a",{href:e,...i},t,s)}img(e,t="",i={}){return this.element("img",{src:e,alt:t,...i})}input(e,t="text",i="",s={}){return this.element("input",{type:t,name:e,value:i,...s})}button(e="",t="button",i={},s={}){return this.element("button",{type:t,...i},e,s)}form(e="",t="post",i={},s="",r={}){return this.element("form",{action:e,method:t,...i},s,r)}label(e,t,i={},s={}){return this.element("label",{for:e,...i},t,s)}textarea(e,t="",i={}){return this.element("textarea",{name:e,...i},t)}ul(e=[],t={},i=!1){let s=[];return s=i?e:e.map(e=>this.element("li",{},e)),this.element("ul",t,s)}li(e={},t,i){return this.element("li",e,t,i)}ol(e=[],t={}){const i=e.map(e=>this.element("li",{},e));return this.element("ol",t,i)}h4(e={},t="",i={}){return this.element("h4",e,t,i)}table(e=[],t=[],i={}){const s=e.map(e=>this.element("th",{},e)),r=this.element("tr",{},s),n=this.element("thead",{},r),a=t.map(e=>{const t=e.map(e=>this.element("td",{},e));return this.element("tr",{},t)}),o=this.element("tbody",{},a);return this.element("table",i,[n,o])}csrfToken(e){return this.element("input",{type:"hidden",name:"_token",value:e})}method(e){return this.element("input",{type:"hidden",name:"_method",value:e})}withEvents(e,t={}){return e instanceof Node&&"dom"===this.mode&&Object.entries(t).forEach(([t,i])=>{e.addEventListener(t,i)}),e}addClass(e,t){if(e instanceof Node&&"dom"===this.mode)e.classList.add(t);else if("string"==typeof e){const i=e.match(/<(\w+)([^>]*)>/);if(i){const[s,r,n]=i,a=this._addClassToAttributes(n,t);return e.replace(s,`<${r}${a}>`)}}return e}_addClassToAttributes(e,t){const i=e.match(/class="([^"]*)"/);if(i){const s=i[1],r=s?`${s} ${t}`:t;return e.replace(/class="[^"]*"/,`class="${r}"`)}return`${e} class="${t}"`}component(e,t={},i={}){const r={eye:e=>{const t=e.type||"open",i=this.element("",{},(0,s.z)(`eye-${t}`));return this.span({"data-vg-toggle":"pass","data-bs-toggle":"tooltip",title:"Скрыть",class:e.class||""},[i])},alert:e=>{const t=e.type||"info";return this.div({class:`alert alert-${t}`,role:"alert"},e.content||"")},card:e=>{const t=e.header?this.div({class:"card-header"},e.header):"",i=this.div({class:"card-body"},e.body||""),s=e.footer?this.div({class:"card-footer"},e.footer):"";return this.div({class:"card"},[t,i,s])}};return r[e]?r[e](t):this.div({class:`component-${e}`},"")}}const n=function(e="string"){const t=new r(e);return new Proxy(t,{get:(e,t)=>t in e?e[t].bind(e):function(i={},s="",r={}){return e.element(t,i,s,r)}})}},647(e,t,i){i.d(t,{A:()=>v});const s=/[^.]*(?=\..*)\.|.*/,r=/\..*/,n=/::\d+$/,a={mouseenter:"mouseover",mouseleave:"mouseout"},o=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","submit","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","popstate","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]),l={};let h=1;const d=(e,t=null)=>(e.uidEvent||(e.uidEvent=t?`${t}::${h++}`:h++),e.uidEvent),c=e=>{const t=d(e);return l[t]=l[t]||{},l[t]},_=(e,t,i)=>{const s="string"==typeof t,n=s?i:t||i;let l=e.replace(r,"");return a[l]&&(l=a[l]),o.has(l)||(l=e),[s,n,l]},u=(e,t,i,r,n)=>{if("string"!=typeof t||!e)return;const[a,o,l]=_(t,i,r),h=c(e),u=h[l]||={},p=m(u,o,a?i:null);if(p)return void(p.oneOff=p.oneOff&&n);let g=a?((e,t,i,s)=>{const r=function(r){const n=Array.from(e.querySelectorAll(t));for(let a=r.target;a&&a!==e;a=a.parentNode)if(n.includes(a))return f(r,{delegateTarget:a}),s&&b.off(e,r.type,t,i),i.apply(a,[r])};return r.delegationSelector=t,r.callable=i,r.oneOff=s,r.uidEvent=null,r})(e,i,o,n):((e,t,i)=>{const s=function(s){return f(s,{delegateTarget:e}),i&&b.off(e,s.type,t),t.apply(e,[s])};return s.delegationSelector=null,s.callable=t,s.oneOff=i,s.uidEvent=null,s})(e,o,n);const v=d(g,t.replace(s,""));g.uidEvent=v,u[v]=g,e.addEventListener(l,g,a)},m=(e,t,i)=>Object.values(e).find(e=>e.callable===t&&e.delegationSelector===i),p=(e,t,i,s,r)=>{const n=m(t[i],s,r);n&&(e.removeEventListener(i,n,Boolean(r)),delete t[i][n.uidEvent])},g=(e,t,i,s)=>{const r=t[i]||{};for(const[n,a]of Object.entries(r))n.includes(s)&&p(e,t,i,a.callable,a.delegationSelector)},f=(e,t={})=>{for(const[i,s]of Object.entries(t))try{e[i]=s}catch{Object.defineProperty(e,i,{configurable:!0,get:()=>s})}return e},b={on(e,t,i,s){u(e,t,i,s,!1)},one(e,t,i,s){u(e,t,i,s,!0)},off(e,t,i,s){if("string"!=typeof t||!e)return;const[r,a,o]=_(t,i,s),l=c(e),h=t.startsWith("."),d=o!==t;if(h){for(const i of Object.keys(l))g(e,l,i,t.slice(1));return}const u=l[o]||{};if(void 0===a)for(const[i,s]of Object.entries(u)){const r=i.replace(n,"");d&&!t.includes(r)||p(e,l,o,s.callable,s.delegationSelector)}else p(e,l,o,a,r?i:null)},trigger(e,t,i){if("string"!=typeof t||!e)return null;const s=f(new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:i}),i);return e.dispatchEvent(s),s}},v=b},23(e,t,i){i.d(t,{p:()=>r,x:()=>n});var s=i(381);const r={get(e,t="data",i=!0){if(!(0,s.vq)(e))return{};if("all"===t)return Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{});if("data"===t){const t=new Set(["data-vg-toggle","data-vg-target","data-vg-dismiss","data-vg-loaded"]),r={};return Array.from(e.attributes).filter(e=>e.name.startsWith("data-")).forEach(e=>{if(!t.has(e.name)){const t=i?e.name.slice(5):e.name;r[t]=(0,s.OM)(e.value)}}),r}return e.getAttribute(t)},has:(e,t)=>(0,s.vq)(e)&&e.hasAttribute(t),set(e,t,i){(0,s.vq)(e)&&t&&e.setAttribute(t,i)},remove(e,t){(0,s.vq)(e)&&t&&e.removeAttribute(t)},hide(e){(0,s.vq)(e)&&(e.style.display="none")},show(e,t="block"){(0,s.vq)(e)&&(e.style.display=t)}},n={remove(e,t){if(!(0,s.vq)(e)||!t)return;const i=Array.isArray(t)?t:t.split(" ").filter(Boolean);e.classList.remove(...i)},add(e,t,i=!1){if(!t)return;const r=Array.isArray(t)?t:t.split(" ").filter(Boolean);if(i)return r.join(" ");(0,s.vq)(e)&&e.classList.add(...r)},toggle(e,t,i=!0){(0,s.vq)(e)&&t&&e.classList.toggle(t,!!i)},replace(e,t,i){(0,s.vq)(e)&&t&&i&&e.classList.replace(t,i)},has:(e,t)=>(0,s.vq)(e)&&e.classList.contains(t)}},829(e,t,i){i.d(t,{A:()=>n});var s=i(381);const r=e=>{const t=e.getAttribute("data-vg-target");if(t&&"#"!==t)return t.trim();const i=e.getAttribute("href");if(!i||!i.includes("#")&&!i.startsWith("."))return null;const s=i.includes("#")&&!i.startsWith("#")?`#${i.split("#")[1]}`:i;return"#"!==s?s.trim():null},n={find(e,t=document.documentElement){if((0,s.vq)(e))return e;try{return t.querySelector(e)}catch(t){return console.warn("Invalid selector:",e,t),null}},findID(e,t=document){try{if("string"!=typeof e||""===e.trim())return null;const i=(t&&9===t.nodeType?t:t?.ownerDocument||document).getElementById(e);if(i)return t&&9!==t.nodeType?t.contains(i)?i:null:i;const s=t&&9===t.nodeType?t.documentElement:t;if(!s||"function"!=typeof s.querySelector)return null;const r=(e=>e&&window.CSS?.escape?CSS.escape(e):e.replace(/([:.#[]])/g,"\\$1"))(e);return s.querySelector(`#${r}`)}catch(t){return console.warn("Invalid ID in findID:",e,t),null}},findAll(e,t=document.documentElement){try{return Array.from(t.querySelectorAll(e))}catch(t){return console.warn("Invalid selector in findAll:",e,t),[]}},getSelectorFromElement(e){const t=r(e);return t&&this.find(t)?t:null},getElementFromSelector(e){const t=r(e);return t?this.find(t):null},getMultipleElementsFromSelector(e){const t=r(e);return t?this.findAll(t):[]},parents(e,t){const i=[];let s=e.parentElement?.closest(t);for(;s;)i.push(s),s=s.parentElement?.closest(t);return i},next(e,t){let i=e.nextElementSibling;for(;i;){if(i.matches(t))return[i];i=i.nextElementSibling}return[]},prev(e,t){let i=e.previousElementSibling;for(;i;){if(i.matches(t))return[i];i=i.previousElementSibling}return[]}}},381(e,t,i){i.d(t,{Ff:()=>v,Gv:()=>r,OM:()=>h,PR:()=>b,V6:()=>a,V8:()=>w,Xb:()=>E,_v:()=>d,d6:()=>o,dO:()=>u,g7:()=>c,iq:()=>y,lQ:()=>f,qm:()=>g,vq:()=>s,zN:()=>l,ze:()=>n});const s=e=>e?.nodeType===Node.ELEMENT_NODE,r=e=>e&&"object"==typeof e,n=e=>{if(!r(e))return!0;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},a=e=>{if(s(e))return e;if(e?.jquery)return e[0]||null;if("string"==typeof e&&""!==e.trim())try{return document.querySelector(e)}catch(t){return console.warn("Invalid selector:",e),null}return null},o=e=>!s(e)||!!e.classList.contains("disabled")||(void 0!==e.disabled?!!e.disabled:e.hasAttribute("disabled")&&"false"!==e.getAttribute("disabled")),l=e=>{if(!s(e)||0===e.getClientRects().length)return!1;if("hidden"===getComputedStyle(e).visibility)return!1;const t=e.closest("details:not([open])");if(!t)return!0;const i=e.closest("summary");return!(!i||i.parentNode!==t)},h=e=>{if("true"===e)return!0;if("false"===e)return!1;if("null"===e)return null;if(""===e)return null;if("number"==typeof e||e===Number(e))return Number(e);if("string"!=typeof e)return e;try{return JSON.parse(decodeURIComponent(e))}catch{return e}},d=(...e)=>{const t=e=>e&&"object"==typeof e;return e.reduce((e,i)=>t(i)?(Object.keys(i).forEach(s=>{const r=e[s],n=i[s];Array.isArray(r)&&Array.isArray(n)?e[s]=r.concat(n):t(r)&&t(n)?e[s]=d(r,n):e[s]=n}),e):e,{})},c=(e,t=[],i=e)=>"function"==typeof e?e(...t):i,_="transitionend",u=(e,t,i=!0,s)=>{if(!t)return void c(e);if(!i)return void c(e);const r=s??m(t)+5;let n=!1;const a=i=>{i.target===t&&(n=!0,t.removeEventListener(_,a),c(e))};t.addEventListener(_,a),setTimeout(()=>{n||p(t)},r)},m=e=>{if(!e)return 0;const{transitionDuration:t,transitionDelay:i}=getComputedStyle(e),s=t.split(", "),r=i.split(", ");return 1e3*((Number.parseFloat(s[0])||0)+(Number.parseFloat(r[0])||0))},p=e=>{e&&e.dispatchEvent(new Event(_))},g=e=>{e.offsetHeight},f=()=>{},b=(e=7)=>{let t="";for(let i=0;i<e;i++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return t},v=(e,t=!0)=>{const i="q w e r t y u i o p [ ] a s d f g h j k l ; ' z x c v b n m , .".split(" "),s="й ц у к е н г ш щ з х ъ ф ы в а п р о л д ж э я ч с м и т ь б ю".split(" "),r=t?i:s,n=t?s:i;let a=e;for(let e=0;e<r.length;e++){const t=r[e],i=n[e],s=r[e].toUpperCase(),o=n[e].toUpperCase();a=a.split(t).join(i).split(s).join(o)}return a},y=(e,t,i,s)=>{const r=e.length;let n=e.indexOf(t);return-1===n?i||!s?e[0]:e[r-1]:(n+=i?1:-1,s&&(n=(n%r+r)%r),e[Math.max(0,Math.min(n,r-1))])},w=()=>"rtl"===document.documentElement.dir;function E(){const e=navigator.userAgent,t=/Android|iPhone|iPad|iPod/i.test(e),i="ontouchstart"in window||navigator.maxTouchPoints>0,s=window.innerWidth<768,r=window.devicePixelRatio>=2;return t||i&&s&&r||function(){const e=navigator.userAgent,t=navigator.platform;if(!(/iPad/.test(e)||"MacIntel"===t&&navigator.maxTouchPoints>1))return{isiPadPro:!1};const i=window.screen.width*window.devicePixelRatio,s=window.screen.height*window.devicePixelRatio;return{isiPadPro:[{width:2048,height:2732},{width:1668,height:2388},{width:1668,height:2224}].some(e=>i===e.width&&s===e.height||i===e.height&&s===e.width),screenWidth:i,screenHeight:s,userAgent:e,platform:t}}().isiPadPro}}},t={};function i(s){var r=t[s];if(void 0!==r)return r.exports;var n=t[s]={exports:{}};return e[s](n,n.exports,i),n.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{var e=i(188),t=i(23),s=i(829),r=i(381);const n=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",a=".sticky-top",o="padding-right",l="margin-right",h=class{constructor(){}get _element(){return document.body}getWidth(){const e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}isOverflowing(){return this.getWidth()>0}hide(){if(this.isOverflowing()&&!(0,r.Xb)()){const e=this.getWidth();this._disableOverflow(),this._setStyle(n,o,e,t=>t+e),this._setStyle(a,l,e,t=>t-e),this._setStyle(this._element,o,e,t=>t+e)}else(0,r.Xb)()&&this._disableOverflow()}reset(){this._resetStyle(this._element,"overflow"),this._resetStyle(this._element,o),this._resetStyle(n,o),this._resetStyle(a,l)}_disableOverflow(){this._saveInitialStyle(this._element,"overflow"),this._element.style.overflow="hidden"}_setStyle(e,t,i,s){this._applyToElements(e,e=>{if(e!==this._element&&window.innerWidth>e.clientWidth+i)return;this._saveInitialStyle(e,t);const r=getComputedStyle(e).getPropertyValue(t),n=Number.parseFloat(r)||0;e.style.setProperty(t,`${s(n)}px`)})}_resetStyle(e,i){this._applyToElements(e,e=>{const s=t.p.get(e,i);null!==s?(t.p.remove(e,i),e.style.setProperty(i,s)):e.style.removeProperty(i)})}_saveInitialStyle(e,i){if(null!==t.p.get(e,i))return;const s=e.style.getPropertyValue(i);t.p.set(e,i,s)}_applyToElements(e,t){(0,r.vq)(e)?t(e):s.A.findAll(e,this._element).forEach(t)}};var d=i(601);const c="vg-backdrop",_="fade",u="show";class m{static get _rootEl(){return document.body}static _scrollbar=new h;static _backdrop=null;static _backdrops=[];static getElement(){return this._syncBackdrops(),this._backdrop}static isActive(){return this._syncBackdrops(),this._backdrops.length>0}static show(e){const t=this._append();(0,r.g7)(e,[t])}static hide(e,t=null){this._syncBackdrops();const i=t&&t.isConnected?t:this._backdrop;i?this._destroy(i).then(r.g7.bind(null,e)):(0,r.g7)(e)}static _append(){const e=(0,d.A)("dom").div({class:c});return this._rootEl.appendChild(e),this._backdrops.push(e),this._backdrop=e,requestAnimationFrame(()=>{t.x.add(e,u),setTimeout(()=>{e.isConnected&&t.x.add(e,_)},150)}),e}static _destroy(e){return new Promise(i=>{t.x.remove(e,_),setTimeout(()=>{t.x.remove(e,u),e.remove(),this._backdrops=this._backdrops.filter(t=>t!==e&&t.isConnected),this._backdrop=this._backdrops.length?this._backdrops[this._backdrops.length-1]:null,this._backdrop||this._scrollbar.reset(),i()},150)})}static _syncBackdrops(){this._backdrops=this._backdrops.filter(e=>e&&e.isConnected),this._backdrops.length||(this._backdrops=Array.from(this._rootEl.querySelectorAll(`.${c}`))),this._backdrop=this._backdrops.length?this._backdrops[this._backdrops.length-1]:null}}const p=m;var g=i(647),f=i(810);const b={enable:!1,selector:".vg-modal-content",threshold:4,resizeEdgeSize:8,debug:!1},v=class{constructor(e,t,i={}){this._modalElement=e,this._dialogElement=t,this._options=this._normalizeOptions(i),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._dialogStartLeft=0,this._dialogStartTop=0,this._dialogWidth=0,this._dialogHeight=0,this._isEnabled=!1,this._previousUserSelect="",this._previousTransition="",this._previousWillChange="",this._initialRect=null,this._lockedIframes=[],this._debugElement=null,this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onNativeDragStart=this._onNativeDragStart.bind(this)}setOptions(e={}){this._options=this._normalizeOptions(e,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._dialogElement.addEventListener("pointerdown",this._onPointerDown),this._isEnabled=!0)}disable(){this._dialogElement&&this._isEnabled&&(this._dialogElement.removeEventListener("pointerdown",this._onPointerDown),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgModalDragging,this._setDebugVisibility(!1),this._isEnabled=!1)}syncPosition(){if(!this._isEnabled)return;if(!this._isPreparedForInteraction())return;const e=this._dialogElement.getBoundingClientRect(),t=this._dialogElement.offsetWidth||e.width,i=this._dialogElement.offsetHeight||e.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:e.left,a=Number.isFinite(r)?r:e.top,o=Math.max(0,window.innerWidth-t),l=Math.max(0,window.innerHeight-i),h=Math.min(o,Math.max(0,n)),d=Math.min(l,Math.max(0,a));this._dialogElement.style.left=`${h}px`,this._dialogElement.style.top=`${d}px`,this._updateDebugValues("synced")}_onPointerDown(e){if(0!==e.button)return;const t=this._resolveDragArea(e.target);t&&this._dialogElement.contains(t)&&(this._isPointerOnResizeEdge(e)||e.target.closest('input, textarea, select, button, a, [contenteditable="true"]')||t&&t.closest('[data-vg-dismiss="modal"]')||(this._pointerId=e.pointerId,this._dragTarget=e.target,this._isDragging=!1,e.preventDefault(),this._previousUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",this._initialRect=this._dialogElement.getBoundingClientRect(),this._dialogStartLeft=this._initialRect.left,this._dialogStartTop=this._initialRect.top,this._dialogWidth=this._initialRect.width,this._dialogHeight=this._initialRect.height,this._startX=e.clientX,this._startY=e.clientY,this._currentX=e.clientX,this._currentY=e.clientY,this._lockEmbeddedFrames(),this._modalElement.dataset.vgModalDragging="true",this._setDebugVisibility(!0),this._updateDebugValues("armed"),document.addEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement&&this._dialogElement.setPointerCapture&&this._dialogElement.setPointerCapture(e.pointerId),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)))}_onPointerMove(e){if(e.pointerId===this._pointerId){if(this._currentX=e.clientX,this._currentY=e.clientY,!this._isDragging){const t=this._currentX-this._startX,i=this._currentY-this._startY;if(Math.hypot(t,i)<this._options.threshold)return;this._isDragging=!0,this._dialogElement.style.touchAction="none",this._applyDragStyles(),this._preparePosition(this._initialRect),e.preventDefault(),this._updateDebugValues("dragging")}this._applyDragPosition()}}_onPointerUp(e){e.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._isDragging&&this._applyDragPosition(),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._dialogElement&&this._dialogElement.releasePointerCapture&&this._dialogElement.releasePointerCapture(e.pointerId),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgModalDragging,this._setDebugVisibility(this._options.debug),this._updateDebugValues("idle"))}_preparePosition(e=null){if(!this._dialogElement)return;const t=e||this._dialogElement.getBoundingClientRect();this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${t.left}px`,this._dialogElement.style.top=`${t.top}px`,this._dialogElement.style.width=`${t.width}px`,this._dialogElement.style.height=`${t.height}px`,this._dialogElement.style.transform="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_isPointerOnResizeEdge(e){const t=this._dialogElement.getBoundingClientRect(),i=e.clientX-t.left,s=e.clientY-t.top,r=this._options.resizeEdgeSize,n=s>=0&&s<=r,a=s<=t.height&&s>=t.height-r,o=i>=0&&i<=r,l=i<=t.width&&i>=t.width-r;return n||a||o||l}_applyDragPosition(){if(null===this._pointerId||!this._isDragging)return;const e=this._currentX-this._startX,t=this._currentY-this._startY,i=Math.max(0,window.innerWidth-this._dialogWidth),s=Math.max(0,window.innerHeight-this._dialogHeight),r=Math.min(i,Math.max(0,this._dialogStartLeft+e)),n=Math.min(s,Math.max(0,this._dialogStartTop+t));this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._updateDebugValues("dragging")}_onNativeDragStart(e){null!==this._pointerId&&e.preventDefault()}_applyDragStyles(){this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top"}_restoreDragStyles(){this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const e=this._dialogElement.querySelectorAll("iframe");for(const t of e)this._lockedIframes.push({element:t,pointerEvents:t.style.pointerEvents}),t.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const e of this._lockedIframes)e.element.style.pointerEvents=e.pointerEvents;this._lockedIframes=[]}}_normalizeOptions(e,t=b){const i={...t,...e},s=Number(i.threshold),r=Number(i.resizeEdgeSize),n="string"==typeof i.selector&&i.selector.trim()?i.selector:b.selector;return{...i,selector:n,threshold:Number.isFinite(s)&&s>=0?s:b.threshold,resizeEdgeSize:Number.isFinite(r)&&r>0?r:b.resizeEdgeSize,debug:Boolean(i.debug)}}_resolveDragArea(e){try{return e.closest(this._options.selector)}catch(t){return e.closest(b.selector)}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="170px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="7",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues(this._isDragging?"dragging":"idle")):this._setDebugVisibility(!1)}_setDebugVisibility(e){this._debugElement&&(this._debugElement.style.display=e?"block":"none")}_updateDebugValues(e="idle"){if(!this._debugElement||!this._options.debug)return;const t=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`drag:${e} x:${Math.round(t.left)} y:${Math.round(t.top)} w:${Math.round(t.width)} h:${Math.round(t.height)}`}},y={enable:!1,minWidth:300,minHeight:160,edgeSize:8,debug:!1},w={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"},E=class{constructor(e,t,i={}){this._modalElement=e,this._dialogElement=t,this._contentElement=this._dialogElement?this._dialogElement.querySelector(".vg-modal-content"):null,this._options=this._normalizeOptions(i),this._pointerId=null,this._direction="",this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._startWidth=0,this._startHeight=0,this._startLeft=0,this._startTop=0,this._startRight=0,this._startBottom=0,this._isEnabled=!1,this._observer=null,this._syncFrameId=null,this._resizeFrameId=null,this._lockedIframes=[],this._debugElement=null,this._previousMaxWidth="",this._previousMaxHeight="",this._previousPointerEvents="",this._previousMinHeight="",this._previousOverflow="",this._previousTransition="",this._previousWillChange="",this._previousContentHeight="",this._previousContentMaxHeight="",this._previousContentOverflow="",this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerLeave=this._onPointerLeave.bind(this),this._applyResizePosition=this._applyResizePosition.bind(this)}setOptions(e={}){this._options=this._normalizeOptions(e,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._modalElement.addEventListener("pointermove",this._onPointerMove),this._modalElement.addEventListener("pointerdown",this._onPointerDown),this._modalElement.addEventListener("pointerleave",this._onPointerLeave),this._startObserveSizeChanges(),this._isEnabled=!0)}disable(){this._isEnabled&&(this._modalElement.removeEventListener("pointermove",this._onPointerMove),this._modalElement.removeEventListener("pointerdown",this._onPointerDown),this._modalElement.removeEventListener("pointerleave",this._onPointerLeave),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._stopObserveSizeChanges(),this._pointerId=null,this._direction="",this._dialogElement.style.cursor="",delete this._modalElement.dataset.vgModalResizing,this._unlockEmbeddedFrames(),this._restoreResizeStyles(),this._setDebugVisibility(!1),this._isEnabled=!1)}syncToViewport(){if(this._modalElement&&"true"===this._modalElement.dataset.vgModalDragging)return;if(!this._isPreparedForInteraction())return;const e=this._dialogElement.getBoundingClientRect(),t=this._dialogElement.offsetWidth||e.width,i=this._dialogElement.offsetHeight||e.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:e.left,a=Number.isFinite(r)?r:e.top,o=window.innerWidth,l=window.innerHeight,h=Math.max(this._options.minWidth,Math.min(t,o)),d=Math.max(this._options.minHeight,Math.min(i,l)),c=Math.max(0,window.innerWidth-h),_=Math.max(0,window.innerHeight-d),u=Math.min(c,Math.max(0,n)),m=Math.min(_,Math.max(0,a));Math.abs(t-h)>.5&&(this._dialogElement.style.width=`${h}px`),Math.abs(i-d)>.5&&(this._dialogElement.style.height=`${d}px`),this._dialogElement.style.left=`${u}px`,this._dialogElement.style.top=`${m}px`,this._updateDebugValues()}_onPointerDown(e){if(0!==e.button)return;if(e.defaultPrevented)return;const t=this._getDirectionFromPointer(e);if(!t)return;e.preventDefault(),this._pointerId=e.pointerId,this._direction=t;const i=this._dialogElement.getBoundingClientRect();this._applyResizeStyles(),this._preparePosition(i),this._startX=e.clientX,this._startY=e.clientY,this._currentX=e.clientX,this._currentY=e.clientY,this._startWidth=i.width,this._startHeight=i.height,this._startLeft=i.left,this._startTop=i.top,this._startRight=i.right,this._startBottom=i.bottom,this._lockEmbeddedFrames(),this._modalElement.dataset.vgModalResizing="true",this._setDebugVisibility(!0),this._updateDebugValues(),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)}_onPointerMove(e){if(null===this._pointerId){const t=this._getDirectionFromPointer(e);return void(this._dialogElement.style.cursor=t?w[t]:"")}e.pointerId===this._pointerId&&(this._currentX=e.clientX,this._currentY=e.clientY,null===this._resizeFrameId&&(this._resizeFrameId=window.requestAnimationFrame(this._applyResizePosition)))}_applyResizePosition(){if(this._resizeFrameId=null,null===this._pointerId)return;const e=this._currentX-this._startX,t=this._currentY-this._startY;let i=this._startWidth,s=this._startHeight,r=this._startLeft,n=this._startTop;if(this._direction.includes("e")){const t=Math.max(this._options.minWidth,window.innerWidth-this._startLeft);i=Math.min(t,Math.max(this._options.minWidth,this._startWidth+e))}if(this._direction.includes("s")){const e=Math.max(this._options.minHeight,window.innerHeight-this._startTop);s=Math.min(e,Math.max(this._options.minHeight,this._startHeight+t))}if(this._direction.includes("w")){const t=this._startRight-this._options.minWidth;r=Math.min(t,Math.max(0,this._startLeft+e)),i=this._startRight-r}if(this._direction.includes("n")){const e=this._startBottom-this._options.minHeight;n=Math.min(e,Math.max(0,this._startTop+t)),s=this._startBottom-n}this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._dialogElement.style.width=`${i}px`,this._dialogElement.style.height=`${s}px`,this._updateDebugValues()}_onPointerUp(e){e.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._applyResizePosition(),this._pointerId=null,this._direction="",delete this._modalElement.dataset.vgModalResizing,this._unlockEmbeddedFrames(),this._setDebugVisibility(this._options.debug),this._updateDebugValues())}_onPointerLeave(){null===this._pointerId&&(this._dialogElement.style.cursor="")}_getDirectionFromPointer(e){const t=this._dialogElement.getBoundingClientRect(),i=e.clientX-t.left,s=e.clientY-t.top,r=this._options.edgeSize;if(!(i>=0&&i<=t.width&&s>=0&&s<=t.height))return"";const n=s>=0&&s<=r,a=s<=t.height&&s>=t.height-r,o=i>=0&&i<=r,l=i<=t.width&&i>=t.width-r;return n&&o?"nw":n&&l?"ne":a&&o?"sw":a&&l?"se":n?"n":a?"s":o?"w":l?"e":""}_preparePosition(e){this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${e.left}px`,this._dialogElement.style.top=`${e.top}px`,this._dialogElement.style.width=`${e.width}px`,this._dialogElement.style.height=`${e.height}px`,this._dialogElement.style.transform="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_startObserveSizeChanges(){"undefined"==typeof ResizeObserver||this._observer||(this._observer=new ResizeObserver(()=>{null===this._pointerId&&(this._modalElement&&"true"===this._modalElement.dataset.vgModalDragging||null===this._syncFrameId&&(this._syncFrameId=window.requestAnimationFrame(()=>{this._syncFrameId=null,this.syncToViewport()})))}),this._observer.observe(this._dialogElement))}_stopObserveSizeChanges(){this._observer&&(this._observer.disconnect(),this._observer=null),null!==this._syncFrameId&&(window.cancelAnimationFrame(this._syncFrameId),this._syncFrameId=null)}_applyResizeStyles(){this._previousMaxWidth=this._dialogElement.style.maxWidth,this._previousMaxHeight=this._dialogElement.style.maxHeight,this._previousPointerEvents=this._dialogElement.style.pointerEvents,this._previousMinHeight=this._dialogElement.style.minHeight,this._previousOverflow=this._dialogElement.style.overflow,this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.maxWidth="none",this._dialogElement.style.maxHeight="none",this._dialogElement.style.pointerEvents="auto",this._dialogElement.style.minHeight=`${this._options.minHeight}px`,this._dialogElement.style.overflow="hidden",this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top, width, height",this._contentElement&&(this._previousContentHeight=this._contentElement.style.height,this._previousContentMaxHeight=this._contentElement.style.maxHeight,this._previousContentOverflow=this._contentElement.style.overflow,this._contentElement.style.height="100%",this._contentElement.style.maxHeight="100%",this._contentElement.style.overflow="auto")}_restoreResizeStyles(){this._dialogElement.style.maxWidth=this._previousMaxWidth,this._dialogElement.style.maxHeight=this._previousMaxHeight,this._dialogElement.style.pointerEvents=this._previousPointerEvents,this._dialogElement.style.minHeight=this._previousMinHeight,this._dialogElement.style.overflow=this._previousOverflow,this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange,this._contentElement&&(this._contentElement.style.height=this._previousContentHeight,this._contentElement.style.maxHeight=this._previousContentMaxHeight,this._contentElement.style.overflow=this._previousContentOverflow)}_normalizeOptions(e,t=y){const i={...t,...e},s=Number(i.minWidth),r=Number(i.minHeight),n=Number(i.edgeSize);return{...i,minWidth:Number.isFinite(s)&&s>0?s:y.minWidth,minHeight:Number.isFinite(r)&&r>0?r:y.minHeight,edgeSize:Number.isFinite(n)&&n>0?n:y.edgeSize,debug:Boolean(i.debug)}}_cancelResizeFrame(){null!==this._resizeFrameId&&(window.cancelAnimationFrame(this._resizeFrameId),this._resizeFrameId=null)}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const e=this._dialogElement.querySelectorAll("iframe");for(const t of e)this._lockedIframes.push({element:t,pointerEvents:t.style.pointerEvents}),t.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const e of this._lockedIframes)e.element.style.pointerEvents=e.pointerEvents;this._lockedIframes=[]}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="8px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="6",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues()):this._setDebugVisibility(!1)}_setDebugVisibility(e){this._debugElement&&(this._debugElement.style.display=e?"block":"none")}_updateDebugValues(){if(!this._debugElement||!this._options.debug)return;const e=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`w:${Math.round(e.width)} h:${Math.round(e.height)} x:${Math.round(e.left)} y:${Math.round(e.top)}`}},A={enable:!1,selector:".vg-modal-content",threshold:4,resizeEdgeSize:8,debug:!1},S={enable:!1,edgeSize:8,minWidth:300,minHeight:160,debug:!1},C=class{constructor(e,t,i,s){this._modalElement=e,this._dialogElement=t,this._contentElement=i,this._getParams="function"==typeof s?s:()=>({}),this._dragHandler=new v(this._modalElement,this._dialogElement),this._resizeHandler=new E(this._modalElement,this._dialogElement),this._config=this._resolveConfig(),this._bindHandlers()}toggleHandlers(){this._config=this._resolveConfig(),this._bindHandlers(),this._config.drag.enable?this._dragHandler.enable():this._dragHandler.disable(),this._config.resize.enable?this._resizeHandler.enable():this._resizeHandler.disable()}disableHandlers(){this._dragHandler.disable(),this._resizeHandler.disable()}syncBounds(){this._config.resize.enable&&this._resizeHandler.syncToViewport(),this._config.drag.enable&&this._dragHandler.syncPosition()}saveState(){const e=this._getStateConfig(),t=this._getStateStorageKey(e);if(e.enable&&t&&"undefined"!=typeof window&&window.localStorage)try{window.localStorage.setItem(t,JSON.stringify(this._captureState()))}catch(e){}}restoreState(){const e=this._getStateConfig(),t=this._getStateStorageKey(e);if(!e.enable||!t||"undefined"==typeof window||!window.localStorage)return!1;try{const e=window.localStorage.getItem(t);if(!e)return!1;const i=JSON.parse(e);return this._applyState(i),!0}catch(e){return!1}}dispose(){this.disableHandlers()}_bindHandlers(){this._dragHandler.setOptions(this._config.drag),this._resizeHandler.setOptions(this._config.resize)}_resolveConfig(){const e=this._getParams();return{drag:this._normalizeInteractionParams(e.drag,A),resize:this._normalizeInteractionParams(e.resize,S)}}_normalizeInteractionParams(e,t){if("boolean"==typeof e)return{...t,enable:e};if(e&&"object"==typeof e){const i=Object.prototype.hasOwnProperty.call(e,"enable");return{...t,...e,enable:!i||Boolean(e.enable)}}return{...t}}_getStateConfig(){const e=this._getParams();return this._normalizeStateParams(e.state)}_normalizeStateParams(e,t={enable:!0,key:""}){if("boolean"==typeof e)return{...t,enable:e};if(e&&"object"==typeof e){const i=Object.prototype.hasOwnProperty.call(e,"enable"),s="string"==typeof e.key?e.key.trim():"";return{...t,...e,key:s,enable:!i||Boolean(e.enable)}}return{...t}}_getStateStorageKey(e=this._getStateConfig()){return e.enable?"string"==typeof e.key&&e.key.trim()?e.key.trim():this._modalElement&&this._modalElement.id?`vg.modal.state:${window.location.pathname}:${this._modalElement.id}`:"":""}_captureState(){const e=this._dialogElement?this._dialogElement.style:null,t=this._contentElement||s.A.find(".vg-modal-content",this._dialogElement),i=t?t.style:null;return{dialog:e?{position:e.position,margin:e.margin,left:e.left,top:e.top,width:e.width,height:e.height,transform:e.transform,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minHeight:e.minHeight,overflow:e.overflow,pointerEvents:e.pointerEvents,transition:e.transition,willChange:e.willChange}:{},content:i?{height:i.height,maxHeight:i.maxHeight,overflow:i.overflow}:{}}}_applyState(e){if(!e||"object"!=typeof e)return;const t=e.dialog&&"object"==typeof e.dialog?e.dialog:{},i=e.content&&"object"==typeof e.content?e.content:{};this._dialogElement&&Object.keys(t).forEach(e=>{this._dialogElement.style[e]=t[e]||""});const r=this._contentElement||s.A.find(".vg-modal-content",this._dialogElement);r&&Object.keys(i).forEach(e=>{r.style[e]=i[e]||""})}},x="vg.modal",L="vg-modal-open",I="show",P="vg-modal-minimized-state",k="vg-btn-minimize",M="vg-modal-minimized-container",D="vg-modal-minimized",T=`${x}.minimize`,O=`${x}.minimized`,z=`${x}.restore`,N=`${x}.restored`;class ${constructor(e){this._modal=e,this._element=e._element,this._dialog=e._dialog,this._content=e._content,this._minimizedElement=null,this._isMinimized=!1}setup(){const e=this._getConfig();if(!e.enable||!this._content)return;if(s.A.find(`.${k}`,this._content))return;const t=document.createElement("button");t.type="button",t.className=k,t.setAttribute("aria-label",e.label||"Minimize"),t.innerHTML='<span aria-hidden="true"></span>';const i=s.A.find(".vg-btn-close",this._content);i&&i.parentNode?i.parentNode.insertBefore(t,i):this._content.prepend(t),g.A.on(t,`click.${x}.minimize`,e=>{e.preventDefault(),this.minimize(t)})}isMinimized(){return this._isMinimized}minimize(e){if(!this._getConfig().enable||!this._modal._isShown||this._isMinimized||this._modal._isTransitioning)return;if(g.A.trigger(this._element,T,{relatedTarget:e}).defaultPrevented)return;this._isMinimized=!0,this._modal._disableInteractionHandlers(),this._element.classList.remove(I),this._element.classList.add(P),this._element.style.display="none",this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),s.A.findAll('.vg-modal.show:not([data-vg-persistent="true"])').filter(e=>e!==this._element).length||document.body.classList.remove(L);const t=()=>{p.isActive()||this._modal._scrollBar.reset(),this._ensureElement(e),g.A.trigger(this._element,O,{relatedTarget:e})};this._modal._backdropElement?this._modal._hideBackdrop(t):t()}restore(e){if(!this._isMinimized||this._modal._isTransitioning)return;if(g.A.trigger(this._element,z,{relatedTarget:e}).defaultPrevented)return;const t=()=>{this.removeElement(),this._isMinimized=!1,this._element.classList.remove(P),this._element.style.display="block",this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),document.body.classList.add(L),(0,r.qm)(this._element),this._element.classList.add(I),this._modal._toggleInteractionHandlers(),this._modal._syncInteractiveBounds(),g.A.trigger(this._element,N,{relatedTarget:e})};if(this._modal._params.backdrop)return this._modal._scrollBar.hide(),void this._modal._showBackdrop(t);t()}reset(){this.removeElement(),this._isMinimized=!1,this._element.classList.remove(P)}dispose(){this.removeElement()}_getConfig(){const e=this._modal._params.minimize,t={enable:!1,title:"",text:"",label:"Minimize"};if("boolean"==typeof e)return{...t,enable:e};if(e&&"object"==typeof e){const i=Object.prototype.hasOwnProperty.call(e,"enable");return{...t,...e,enable:!i||Boolean(e.enable)}}return t}_ensureElement(e){if(this._minimizedElement&&this._minimizedElement.isConnected)return this._minimizedElement;const t=this._getConfig(),i=$.getContainer(),s=document.createElement("button");s.type="button",s.className=D,s.setAttribute("data-vg-modal-target",`#${this._element.id}`);const r=document.createElement("span");r.className=`${D}__title`,r.textContent=this._getTitle(t),s.append(r);const n=String(t.text||"").trim();if(n){const e=document.createElement("span");e.className=`${D}__text`,e.textContent=n,s.append(e)}return g.A.on(s,`click.${x}.restore`,t=>{t.preventDefault(),this.restore(s||e)}),i.append(s),this._minimizedElement=s,s}_getTitle(e){const t=String(e.title||"").trim();if(t)return t;const i=s.A.find(".vg-modal-title, .vg-modal-chat__name, [data-vg-modal-title]",this._element);return String(i?i.textContent:"").trim()||this._element.id||"Modal"}removeElement(){this._minimizedElement&&(this._minimizedElement.remove(),this._minimizedElement=null);const e=s.A.find(`.${M}`);e&&!e.children.length&&e.remove()}static getContainer(){let e=s.A.find(`.${M}`);return e||(e=document.createElement("div"),e.className=M,document.body.append(e),e)}}const H=$,F="vg.modal",R='.vg-modal.show:not([data-vg-persistent="true"])',B="data-vg-backdrop-owner",j="modal",U="vg-modal-open",q="show",V="vg-modal-static",W=`${F}.hide`,K=`${F}.hidden`,G=`${F}.show`,Y=`${F}.shown`,X=`${F}.resize`,Z=`${F}.loaded`,J=`keydown.dismiss.${F}`,Q=`hidePrevented.${F}`,ee=`click.${F}.data.api`,te=`mousedown.dismiss${F}`,ie=`click.dismiss${F}`,se=`mousedown.${F}.backdrop`,re=`DOMContentLoaded.${F}.data.api`,ne=`popstate.${F}.data.api`;class ae extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({backdrop:!0,persistent:!1,focus:!0,keyboard:!0,fields:[],hash:!1,centered:!1,dismiss:!0,minimize:{enable:!1,title:"",text:""},resize:{enable:!1,edgeSize:8,minWidth:300,minHeight:160,debug:!1},state:{enable:!0,key:""},drag:{enable:!1,selector:".vg-modal-content",threshold:4,resizeEdgeSize:8,debug:!1},sizes:{width:"",height:""},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0},animation:{enable:!1,in:"animate__rollIn",out:"animate__rollOut",delay:100,duration:800},classes:{general:"vg-modal",dialog:"vg-modal-dialog",content:"vg-modal-content",header:"vg-modal-header",title:"vg-modal-title",body:"vg-modal-body",footer:"vg-modal-footer"}},t)),this._button=null,this._dialog=s.A.find(".vg-modal-dialog",this._element),this._content=s.A.find(".vg-modal-content",this._dialog),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new h,this._backdropElement=null,this._isBackdropOwner=!1,this._interaction=new C(this._element,this._dialog,this._content,()=>this._params),this._minimized=new H(this),this._addEventListeners(),this._dismissElement(),this._minimized.setup(),this._params.animation.delay=this._params.animation.enable?this._params.animation.delay:0,this._animation(this._element,ae.NAME_KEY,this._params.animation),this._params.persistent?this._element.setAttribute("data-vg-persistent","true"):this._element.removeAttribute("data-vg-persistent")}static get NAME(){return"modal"}static get NAME_KEY(){return F}static init(e,t={},i){return ae.build(e,t,i)}static initAll(e={}){return s.A.findAll(".vg-modal").map(t=>ae.getOrCreateInstance(t,e))}static build(e,i={},s){if("string"!=typeof e)return;i&&"object"==typeof i||(i={});const n=document.getElementById(e);if(n){const e=ae.getOrCreateInstance(n,i);return(0,r.g7)(s,[e]),e}let a=document.createElement("div");a.classList.add("vg-modal"),a.classList.add("fade"),a.id=e;let o=document.createElement("div");o.classList.add("vg-modal-dialog"),i.centered&&o.classList.add("vg-modal-dialog-centered");let l=document.createElement("div");if(l.classList.add("vg-modal-content"),!Object.prototype.hasOwnProperty.call(i,"dismiss")||i.dismiss){let i=document.createElement("button");t.p.set(i,"type","button"),t.p.set(i,"data-vg-dismiss","modal"),t.p.set(i,"data-vg-target","#"+e),t.p.set(i,"aria-label","close"),i.classList.add("vg-btn-close"),l.append(i)}if(i.title){let e=document.createElement("div");e.classList.add("vg-modal-header");let t=document.createElement("div");t.classList.add("vg-modal-title"),ae._appendBuildContent(t,i.title,Boolean(i.html||i.titleHtml)),e.append(t),l.append(e)}let h=document.createElement("div");h.classList.add("vg-modal-body");const d=Object.prototype.hasOwnProperty.call(i,"body")?i.body:Object.prototype.hasOwnProperty.call(i,"content")?i.content:null;if(ae._appendBuildContent(h,d,Boolean(i.html||i.bodyHtml||i.contentHtml)),l.append(h),Object.prototype.hasOwnProperty.call(i,"footer")){let e=document.createElement("div");e.classList.add("vg-modal-footer"),ae._appendBuildContent(e,i.footer,Boolean(i.html||i.footerHtml)),l.append(e)}o.append(l),a.append(o),document.body.append(a);const c=ae.getOrCreateInstance(a,i);return"animation"in i&&c._animation(a,ae.NAME_KEY,i.animation),"sizes"in c._params&&c._params.sizes.width&&a.style.setProperty("--vg-modal-width",c._params.sizes.width),"sizes"in c._params&&c._params.sizes.height&&(o.style.height=c._params.sizes.height),(0,r.g7)(s,[c]),c}static _appendBuildContent(e,t,i=!1){e&&null!=t&&(Array.isArray(t)?t.forEach(t=>ae._appendBuildContent(e,t,i)):t instanceof Node?e.append(t):i?e.insertAdjacentHTML("beforeend",String(t)):e.append(document.createTextNode(String(t))))}toggle(e){return this._minimized.isMinimized()?this.restore(e):this._isShown?this.hide():this.show(e)}show(e){if(!(0,r.d6)(this._element)){if(this._minimized.isMinimized())return this.restore(e);if(!this._isShown&&!this._isTransitioning){if(this._params.ajax.route&&this._params.ajax.target&&!this._params.ajax.once){const e=s.A.find(this._params.ajax.target,this._element);e&&(e.innerHTML="")}g.A.trigger(this._element,G,{relatedTarget:e}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._params.hash&&(window.location.hash!==`#${this._element.id}`&&window.history.pushState(null,"vg-modal-open","#"+this._element.id),g.A.on(window,ne,()=>{this.hide()})),this._params.backdrop&&this._scrollBar.hide(),document.body.classList.add(U),this._addFieldsInModal(e),this._adjustDialog(),this._params.backdrop?this._showBackdrop(()=>this._showElement(e)):this._showElement(e))}}}minimize(e){return this._minimized.minimize(e)}restore(e){return this._minimized.restore(e)}hide(e=[],t=!1){this._isShown&&!this._isTransitioning&&(g.A.trigger(this._element,W).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,setTimeout(()=>{this._element.classList.remove(q),this._queueCallback(()=>this._hideModal(e,t),this._element,this._isAnimatedFade())},this._params.animation.delay)))}_hideModal(e,t){if(!t){if(this._saveInteractionState(),this._disableInteractionHandlers(),this._minimized.reset(),this._element.style.display="none",this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,s.A.findAll(R).filter(e=>e!==this._element).length||e.length)return void g.A.trigger(this._element,K);if(document.body.classList.remove(U),this._params.hash&&history.pushState("",document.title,window.location.pathname+window.location.search),!this._params.backdrop)return this._resetAdjustments(),p.isActive()||this._scrollBar.reset(),void g.A.trigger(this._element,K);this._hideBackdrop(()=>{this._resetAdjustments(),p.isActive()||this._scrollBar.reset(),g.A.trigger(this._element,K)})}}dispose(){this._minimized.dispose(),this._interaction.dispose(),super.dispose()}_showElement(e){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const t=s.A.find(".vg-modal-body",this._dialog);t&&(t.scrollTop=0),(0,r.qm)(this._element),this._element.classList.add(q),this._toggleInteractionHandlers(),this._queueCallback(()=>{this._isTransitioning=!1,g.A.trigger(this._element,Y,{relatedTarget:e}),this._syncInteractiveBounds(),this._params=this._getParams(e,this._params),this._restoreInteractionState(),this._syncInteractiveBounds(),this._route((t,i)=>{g.A.trigger(this._element,Z,{stats:t,data:i,relatedTarget:e}),this._syncInteractiveBounds()})},this._dialog,this._isAnimatedFade())}_showBackdrop(e){const t=p.getElement(),i=t?t.getAttribute(B):"";if(t&&"sidebar"!==i)return i||t.setAttribute(B,j),this._backdropElement=t,this._isBackdropOwner=!0,this._bindBackdropDismiss(t),void(0,r.g7)(e);p.show(t=>{this._backdropElement=t,this._isBackdropOwner=!0,t&&t.setAttribute(B,j),this._bindBackdropDismiss(t),(0,r.g7)(e)})}_hideBackdrop(e){if(!this._backdropElement||!this._isBackdropOwner)return this._backdropElement=null,this._isBackdropOwner=!1,void(0,r.g7)(e);p.hide(()=>{this._backdropElement=null,this._isBackdropOwner=!1,(0,r.g7)(e)},this._backdropElement)}_bindBackdropDismiss(e){e&&(g.A.off(e,se),g.A.one(e,se,()=>{"static"!==this._params.backdrop?this.hide():this._triggerBackdropTransition()}))}_toggleInteractionHandlers(){this._interaction.toggleHandlers()}_disableInteractionHandlers(){this._interaction.disableHandlers()}_syncInteractiveBounds(){this._interaction.syncBounds()}_saveInteractionState(){this._interaction.saveState()}_restoreInteractionState(){return this._interaction.restoreState()}_isAnimatedFade(){return this._element.classList.contains("fade")}_adjustDialog(){const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._scrollBar.getWidth(),i=t>0;if(i&&!e){const e=(0,r.V8)()?"paddingLeft":"paddingRight";this._element.style[e]=`${t}px`}if(!i&&e){const e=(0,r.V8)()?"paddingRight":"paddingLeft";this._element.style[e]=`${t}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}_addEventListeners(){g.A.on(document,J,e=>{"Escape"===e.key&&(this._params.keyboard?this.hide():this._triggerBackdropTransition())}),g.A.on(window,X,()=>{this._isShown&&!this._isTransitioning&&(this._adjustDialog(),this._syncInteractiveBounds())}),g.A.on(this._element,te,e=>{g.A.one(this._element,ie,t=>{this._element===e.target&&this._element===t.target&&("static"!==this._params.backdrop?this._params.backdrop&&this.hide():this._triggerBackdropTransition())})})}_triggerBackdropTransition(){if(g.A.trigger(this._element,Q).defaultPrevented)return;const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._element.style.overflowY;"hidden"===t||this._element.classList.contains(V)||(e||(this._element.style.overflowY="hidden"),this._element.classList.add(V),this._queueCallback(()=>{this._element.classList.remove(V),this._queueCallback(()=>{this._element.style.overflowY=t},this._dialog)},this._dialog))}_addFieldsInModal(e){this._params=this._getParams(e,this._params),this._params.fields.length&&this._params.fields.forEach(e=>{if(!1 in e&&!1 in e)return;let i=s.A.findAll("[data-"+e.name+"]",this._element);if(i.length)for(const s of i)switch(s.tagName){case"INPUT":s.value=e.value;break;case"FORM":s.action=e.value;break;case"IMG":t.p.set(s,"src",e.value);break;default:s.innerHTML=e.value}})}}(0,f.P)(ae),g.A.on(document,ee,'[data-vg-toggle="modal"]',function(e){const t=s.A.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&e.preventDefault(),g.A.one(t,G,e=>{e.defaultPrevented});const i=s.A.find(R);if(i){const e=ae.getInstance(i);e&&!e._params.persistent&&e.hide([i])}ae.getOrCreateInstance(t).toggle(this)});const oe=()=>{let e=window.location.hash.slice(1);if(!e)return;try{e=decodeURIComponent(e)}catch(e){return}const t=s.A.findID(e);if(!t||!t.classList.contains("vg-modal")||(0,r.d6)(t))return;const i=ae.getOrCreateInstance(t);i._params.hash&&!i._isShown&&i.show()};"loading"===document.readyState?g.A.on(document,re,oe):oe(),window.addEventListener("hashchange",oe);const le=ae,he=le,de=class{constructor(e){this.reference=e.reference,this.drop=e.drop,this.offset=e.offset||[0,0],this.boundary=e.boundary||"viewport",this.autoFlip=!1!==e.autoFlip,this.overflowProtection=!1!==e.overflowProtection,this.placement=e.placement||"bottom",this.fallbackPlacements=e.fallbackPlacements||[],this.clamp=!0===e.clamp,this.clampPadding=e.clampPadding??8,this.isMerge=!1!==e.isMerge}_getPlacementRect(e){return e.getBoundingClientRect()}_getViewportRect(){const e=document.documentElement;return{width:e.clientWidth,height:e.clientHeight,left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}_getOverflowConstraints(){const e=this._getPlacementRect(this.reference),t=this._getPlacementRect(this.drop),i=this._getBoundaryRect(),[s,r]=this.offset;let n=this.placement;if(this.overflowProtection){const a=this.autoFlip?Array.from(new Set([this.placement,...this.fallbackPlacements])):[this.placement];let o=null;for(const n of a){const a=this._calculatePosition(n,e,t,s,r),l=this._calculateOverflow(a,t,i);if((!o||l<o.overflow)&&(o={placement:n,position:a,overflow:l},0===l))break}n=o.placement;const l=this.clamp?this._clampPosition(o.position,t,i):o.position;this._setStyles(l)}else{const a=this._calculatePosition(n,e,t,s,r),o=this.clamp?this._clampPosition(a,t,i):a;this._setStyles(o)}this.drop.setAttribute("data-vg-placement",n)}_getBoundaryRect(){const e=this._getViewportRect();if(this.boundary instanceof Element)return this._intersectRects(e,this._getPlacementRect(this.boundary));if("string"==typeof this.boundary&&"viewport"!==this.boundary&&"clippingParents"!==this.boundary){const t=this.reference.closest(this.boundary);if(t)return this._intersectRects(e,this._getPlacementRect(t))}if("clippingParents"!==this.boundary)return e;let t=e,i=this.reference.parentElement;for(;i&&i!==document.body&&i!==document.documentElement;)this._isClippingElement(i)&&(t=this._intersectRects(t,this._getPlacementRect(i))),i=i.parentElement;return t}_isClippingElement(e){const t=window.getComputedStyle(e);return[t.overflow,t.overflowX,t.overflowY].some(e=>/(auto|scroll|hidden|clip)/.test(e||""))}_intersectRects(e,t){const i={left:Math.max(e.left,t.left),top:Math.max(e.top,t.top),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)};return i.width=Math.max(0,i.right-i.left),i.height=Math.max(0,i.bottom-i.top),i}_calculatePosition(e,t,i,s=0,r=0){let n,a;switch(e){case"top":n=t.top-i.height-r,a=t.left+(t.width-i.width)/2;break;case"top-start":n=t.top-i.height-r,a=t.left+s;break;case"top-end":n=t.top-i.height-r,a=t.right-i.width-s;break;case"bottom":n=t.bottom+r,a=t.left+(t.width-i.width)/2;break;case"bottom-start":default:n=t.bottom+r,a=t.left+s;break;case"bottom-end":n=t.bottom+r,a=t.right-i.width-s;break;case"left":n=t.top+(t.height-i.height)/2,a=t.left-i.width-s;break;case"left-start":n=t.top+r,a=t.left-i.width-s;break;case"left-end":n=t.bottom-i.height-r,a=t.left-i.width-s;break;case"right":n=t.top+(t.height-i.height)/2,a=t.right+s;break;case"right-start":n=t.top+r,a=t.right+s;break;case"right-end":n=t.bottom-i.height-r,a=t.right+s}return{top:n,left:a}}_calculateOverflow(e,t,i){let s=0;return e.left<i.left&&(s+=i.left-e.left),e.top<i.top&&(s+=i.top-e.top),e.left+t.width>i.right&&(s+=e.left+t.width-i.right),e.top+t.height>i.bottom&&(s+=e.top+t.height-i.bottom),s}_clampPosition(e,t,i){const s=this.clampPadding,r=i.bottom-t.height-s,n=i.right-t.width-s;return{top:Math.min(Math.max(e.top,i.top+s),r),left:Math.min(Math.max(e.left,i.left+s),n)}}_setStyles(e){if(!e||!this.drop)return;const t=this.drop.offsetParent;let i=e.top+window.pageYOffset,s=e.left+window.pageXOffset;if(t&&t!==document.body&&t!==document.documentElement){const r=this._getPlacementRect(t);i=e.top-r.top+t.scrollTop-t.clientTop,s=e.left-r.left+t.scrollLeft-t.clientLeft}this.isMerge?(0,r._v)(this.drop.style,{position:"absolute",top:`${i}px`,left:`${s}px`,margin:"0"}):(this.drop.style.position="absolute",this.drop.style.top=`${i}px`,this.drop.style.left=`${s}px`,this.drop.style.margin="0")}_setPlacement(){this._getOverflowConstraints()}},ce="vg.dropdown",_e="show",ue="fade",me="open",pe="vg-dropdown-content",ge='[data-vg-toggle="dropdown"]',fe=`${ce}.hide`,be=`${ce}.hidden`,ve=`${ce}.show`,ye=`${ce}.shown`,we=`${ce}.loaded`,Ee=`keyup.${ce}.data.api`,Ae=`keydown.${ce}.data.api`,Se=`click.${ce}.data.api`,Ce=`mouseover.${ce}.data.api`,xe=`mouseout.${ce}.data.api`;let Le=!1;class Ie extends e.A{constructor(e,t){super(e,t),this._params=this._getParams(e,(0,r._v)({placement:"auto",hover:!1,ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0},animation:{fade:!0,enable:!1,in:"animate__flipInY",out:"animate__flipOutY",delay:300}},t));const i=s.A.getElementFromSelector(this._element);this._parent=this._element.parentNode,this._drop=i||s.A.find(`.${pe}`,this._parent),this._drop&&(this._isPlacement=!1,this.isFade=this._params.animation.fade,this.isAnimation=this._params.animation.enable,this._params.animation.delay=this.isAnimation?this._params.animation.delay:0,this._animation(this._drop,Ie.NAME_KEY,this._params.animation))}static get NAME(){return"dropdown"}static get NAME_KEY(){return ce}toggle(){return this._isShown()?this.hide():this.show()}show(){if((0,r.d6)(this._element)||this._isShown())return;const e={relatedTarget:this._element};g.A.trigger(this._drop,ve,e).defaultPrevented||("ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach(e=>{g.A.on(e,"mouseover",r.lQ)}),this._element.setAttribute("aria-expanded","true"),this._element.classList.add(_e),this._drop.classList.add(_e),this._setPlacement(),this._queueCallback(()=>{this._element&&this._drop&&this._params&&(this._route((e,t)=>{g.A.trigger(this._element,we,{stats:e,data:t})}),this.isFade?this._drop.classList.add(ue):this.isAnimation||this._drop.classList.add(me),g.A.trigger(this._drop,ye,e))},this._drop,this.isAnimation||this.isFade,50))}hide(){!(0,r.d6)(this._element)&&this._isShown()&&this._completeHide({relatedTarget:this._element})}dispose(){this._element&&(this._element.classList.remove(_e),this._element.setAttribute("aria-expanded","false")),this._drop&&this._drop.classList.remove(_e,ue,me),super.dispose()}_isShown(){return this._element.classList.contains(_e)}_completeHide(e){g.A.trigger(this._drop,fe,e).defaultPrevented||("ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach(e=>{g.A.off(e,"mouseover",r.lQ)}),this._element.classList.remove(_e),this._element.setAttribute("aria-expanded","false"),this.isFade?this._drop.classList.remove(ue):this.isAnimation||this._drop.classList.remove(me),setTimeout(()=>{this._element&&this._drop&&this._params&&this._queueCallback(()=>{this._element&&this._drop&&(this._drop.classList.remove(_e),g.A.trigger(this._drop,be,e))},this._drop,this.isAnimation||this.isFade)},this._params.animation.delay))}_setPlacement(){if(!this._drop)return;let e="bottom-start",t=!1,i=!1;"auto"===this._params.placement?(t=!0,i=!0):e=this._params.placement,new de({reference:this._element,drop:this._drop,placement:e,boundary:"clippingParents",autoFlip:t,overflowProtection:i,fallbackPlacements:["bottom-end","top-start","top-end","right-start","left-start","right-end","left-end"]})._setPlacement(),this._isPlacement=!0}static init(e,t={}){const i=Ie.getOrCreateInstance(e,t);if(i._isDataApiInitialized)return i;if(i._isDataApiInitialized=!0,i._params.hover&&!(0,r.Xb)()){let e=null;g.A.on(i._parent,Ce,t=>{if(e)return;Ie.hideOpenToggles(t);const s=t.target.closest(".vg-dropdown");s&&i._parent.contains(s)&&(e=s,i.show())}),g.A.on(i._parent,xe,t=>{if(!e)return;let s=t.relatedTarget;for(;s&&s!==e;)s=s.parentNode;s!==e&&(e=null,i._completeHide({relatedTarget:i._element}))})}return Le||(g.A.on(document,Ee,ge,Ie.keydownHandler),g.A.on(document,Ae,`.${pe}`,Ie.keydownHandler),g.A.on(document,Ee,Ie.clearDrops),g.A.on(document,Se,Ie.clearDrops),Le=!0),g.A.on(e,Se,e=>{e.preventDefault(),i.toggle()}),i}static initAll(e={}){return s.A.findAll(ge).map(t=>Ie.init(t,e))}static hideOpenToggles(e){const t=s.A.findAll(`${ge}:not(.disabled):not(:disabled).${_e}`);for(const i of t){const t=Ie.getInstance(i);if(!t)continue;if(e.target.closest(`.${pe}`)===t._drop)return;if((e.composedPath?.()||[]).includes(t._element))continue;const s={relatedTarget:t._element};"click"===e.type&&(s.clickEvent=e),t._completeHide(s)}}static keydownHandler(e){const t=/input|textarea/i.test(e.target.tagName),i="Escape"===e.key,r=["ArrowUp","ArrowDown"].includes(e.key);if(!r&&!i)return;if(t&&!i)return;e.preventDefault();const n=this.matches(ge)?this:s.A.find(ge,e.delegateTarget?.parentNode);if(!n)return;const a=Ie.getOrCreateInstance(n);r?(e.stopPropagation(),a.show()):a._isShown()&&(e.stopPropagation(),a.hide(),n.focus())}static clearDrops(e){2===e.button||"keyup"===e.type&&"Tab"!==e.key||Ie.hideOpenToggles(e)}}const Pe=Ie,ke=JSON.parse('{"errors":{"400":"Неверный запрос","401":"Не авторизован","403":"Запрещено","404":"Не найдено","413":"Слишком большой запрос","419":"Проблемы с токеном CSRF","422":"Неверный запрос","500":"Внутренняя ошибка сервера","504":"Превышено время ожидания","went_wrong":"Что-то пошло не так, повторите позже"},"form-sender":{"bootstrap_not_found":"VGApp не удалось найти bootstrap, модалки не будут закрыты, попробуйте сделать это через коллбек afterSend."},"files":{"is-count":"Превышен лимит по количеству файлов","is-sizes":"Превышен размер файла","is-types":"Недопустимый тип файла","is-total-size":"Превышен максимально разрешённый размер для выбранных файлов","titles":"Удаление файлов","title":"Удаление файлa","descriptions":"Вы действительно хотите удалить все загруженные файлы с сервера?","description":"Вернуть будет невозможно","drop-active":"Отпустите, чтобы загрузить"},"filepreview":{"audio_title":"Аудио файл","image_title":"Просмотр изображения","image_thumbnail_alt":"Миниатюра изображения","text_title":"Просмотр текста","video_title":"Просмотр видео","pdf_title":"Просмотр PDF","office_title":"Просмотр документа","archive_title":"Просмотр архива","loading_text":"Загрузка...","loading_archive":"Загрузка архива...","loading_entry":"Загрузка файла из архива...","cannot_open_file":"Не удалось открыть файл","cannot_open_archive":"Не удалось открыть архив","cannot_preview_entry":"Не удалось открыть вложение","office_fallback":"Если встроенный превью не работает, скачайте файл.","invalid_zip":"Некорректный ZIP-файл","central_directory_not_found":"Центральный каталог не найден","archive_buffer_missing":"Буфер архива не доступен","entry_corrupted":"Файл в архиве поврежден","compression_not_supported":"Метод сжатия не поддерживается","deflate_not_supported":"Браузер не поддерживает распаковку Deflate","unknown_error":"Неизвестная ошибка","empty_file":"(пустой файл)","archive_empty_unsupported":"Архив пустой или не поддерживается.","archive_type_dir":"папка","archive_type_file":"файл","archive_table_name":"Имя","archive_table_type":"Тип","archive_table_packed":"Сжатый","archive_table_size":"Размер","archive_table_preview":"Превью","pdf_page":"Страница","pdf_zoom":"Масштаб"},"alert":{"title":"Заголовок по умолчанию","description":"Описание текущего действия","reason":"Алерт уже открыт"},"select":{"loading":"Загрузка"}}'),Me=JSON.parse('{"errors":{"title":"Ошибка","titles":"Ошибки"},"select":{"search":"Поиск..."}}'),De=JSON.parse('{"alert":{"agree":"Да, согласен","cancel":"Отмена"},"files":{"agree":"Да","cancel":"Нет"},"filepreview":{"open_audio":"Открыть плеер","open_image":"Открыть изображение","open_text":"Открыть текст","open_video":"Открыть видео","open_archive":"Открыть архив","open_pdf":"Открыть PDF","open_office":"Открыть документ","download":"Скачать","preview":"Превью","prev":"Назад","next":"Вперед","zoom_in":"Увеличить","zoom_out":"Уменьшить"},"loadmore":{"send":"Загружаю...","show":"Показываю...","text-ajax":"Загрузить еще","text-more":"Показать еще"},"rollup":{"less":"Свернуть","show":"Показать","more":" еще "},"select":{"load-more":"Загрузить еще"}}'),Te=JSON.parse('{"errors":{"400":"Bad Request","401":"Unauthorized","403":"Forbidden","404":"Not Found","413":"Payload Too Large","419":"Problems with the CSRF token","422":"Unprocessable Entity","500":"Internal Server Error","504":"Gateway Timeout","went_wrong":"Something went wrong, please repeat later"},"form-sender":{"bootstrap_not_found":"VGApp could not find bootstrap, the modals will not be closed, try to do this through the afterSend callback."},"files":{"is-count":"Exceeded the limit on the number of files","is-sizes":"File size exceeded","is-types":"Invalid file type","is-total-size":"The maximum allowed size for the selected files has been exceeded","titles":"Deleting files","title":"Deleting file","descriptions":"Do you really want to delete all uploaded files from the server?","description":"It will not be possible to return it","drop-active":"Release to upload"},"filepreview":{"audio_title":"Audio file","image_title":"Image preview","image_thumbnail_alt":"Image thumbnail","text_title":"Text preview","video_title":"Video preview","pdf_title":"PDF preview","office_title":"Office preview","archive_title":"Archive preview","loading_text":"Loading...","loading_archive":"Loading archive...","loading_entry":"Loading entry...","cannot_open_file":"Cannot open file","cannot_open_archive":"Cannot open archive","cannot_preview_entry":"Cannot preview entry","office_fallback":"If embedded preview is unavailable, download the file.","invalid_zip":"Invalid ZIP file","central_directory_not_found":"Central directory not found","archive_buffer_missing":"Archive buffer is missing","entry_corrupted":"Archive entry is corrupted","compression_not_supported":"Compression method is not supported","deflate_not_supported":"Deflate decompression is not supported by the browser","unknown_error":"Unknown error","empty_file":"(empty file)","archive_empty_unsupported":"Archive is empty or unsupported.","archive_type_dir":"dir","archive_type_file":"file","archive_table_name":"Name","archive_table_type":"Type","archive_table_packed":"Packed","archive_table_size":"Size","archive_table_preview":"Preview","pdf_page":"Page","pdf_zoom":"Zoom"},"alert":{"title":"Default header","description":"Description of the current action","reason":"Alert already open"},"select":{"loading":"Loading"}}'),Oe=JSON.parse('{"errors":{"title":"Error","titles":"Errors"},"select":{"search":"Search..."}}'),ze=JSON.parse('{"alert":{"agree":"Yeah, I agree","cancel":"Cancel"},"files":{"agree":"Yeah, I agree","cancel":"Cancel"},"filepreview":{"open_audio":"Open player","open_image":"Open image","open_text":"Open text","open_video":"Open video","open_archive":"Open archive","open_pdf":"Open PDF","open_office":"Open document","download":"Download","preview":"Preview","prev":"Prev","next":"Next","zoom_in":"Zoom +","zoom_out":"Zoom -"},"loadmore":{"send":"Uploading...","show":"I\'m showing you...","text-ajax":"Upload more","text-more":"Show more"},"rollup":{"less":"Roll up","show":"Show","more":" more "},"select":{"load-more":"Upload more"}}'),Ne={ru:(0,r.OM)({messages:ke,titles:Me,buttons:De}),en:(0,r.OM)({messages:Te,titles:Oe,buttons:ze})};class $e{constructor(e="en"){this.lang=e}get(){return Ne[this.lang]||Ne.en}}function He(e="en",t,i){const s=new $e(e).get();return s[t]?.[i]||{}}function Fe(e,t){return He(e,"titles",t)}function Re(e,t){return He(e,"messages",t)}function Be(e,t){return He(e,"buttons",t)}var je=i(667);const Ue="vg-alert",qe="show",Ve="fade",We="closing",Ke=`${Ue}-compact`,Ge="data-vg-alert-agree",Ye="data-vg-alert-cancel",Xe="alert",Ze="vg.alert";let Je=!1;class Qe{constructor(e={},t="ru"){this.lang=t,this._defaultParams={size:"default",render:{type:"modal",dismiss:!1},dropdown:{placement:"auto",hover:!1,animation:{fade:!0,enable:!1,in:"animate__flipInY",out:"animate__flipOutY",delay:300}},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0},modal:{centered:!1,backdrop:!0,overflow:!0,keyboard:!0,dismiss:!0,animation:{enable:!1,in:"animate__rollIn",out:"animate__rollOut",delay:300,duration:700}},mode:"confirm",theme:"danger",buttons:{},message:{}},this._elementsDefault={buttons:{agree:{element:"",tag:"button",type:"button",attr:{},toggle:Ge,class:["btn"],text:Be(this.lang,Xe).agree},cancel:{element:"",tag:"button",type:"button",attr:{},toggle:Ye,class:["btn"],text:Be(this.lang,Xe).cancel}},message:{title:Re(this.lang,Xe).title,description:Re(this.lang,Xe).description},icons:{danger:(0,f.z)("danger"),warning:(0,f.z)("warning"),success:(0,f.z)("success"),info:(0,f.z)("info")}},this._params=this._setParams(e)}static get NAME(){return Xe}static get NAME_KEY(){return Ze}static boot(){return this._bindDataApi(),null}static call(e={},t="ru"){const i=new Qe(e,t);if(Je)return Promise.reject({accepted:!1,reason:Re(i.lang,Ze).reason});Je=!0;const{element:n,render:a,type:o}=(()=>{if("overlay"===i._params.render.type){const e=i._buildOverlay();if(!e.element||!e.render){const e=i._buildModal();return{element:e._element,render:e,type:"modal"}}return{element:e.element,render:e.render,type:"overlay"}}if("modal"===i._params.render.type){const e=i._buildModal();return{element:e._element,render:e,type:"modal"}}if("dropdown"===i._params.render.type){const e=i._buildDropdown();if(!e.element||!e.render){const e=i._buildModal();return{element:e._element,render:e,type:"modal"}}return{element:e.element,render:e.render,type:"dropdown"}}})();"modal"===o||"dropdown"===o?a.show():"overlay"===o&&i._showOverlay(n);const l=s.A.find(`[${Ge}]`,n),h=s.A.find(`[${Ye}]`,n);return new Promise((e,t)=>{let s=!1;const d=(e=!0)=>{"modal"!==o&&"dropdown"!==o?"overlay"===o&&i._hideOverlay(n,()=>{i._params.render.dismiss&&e&&a.hide()}):a.hide()},c=t=>{t.preventDefault(),s=!0,m(),e({accepted:!0,timestamp:new Date}),d()},_=e=>{e.preventDefault(),s=!0,m(),t({accepted:!1,timestamp:new Date}),d(!1)},u=e=>{"Enter"===e.key&&l&&(e.preventDefault(),c(e)),"Escape"===e.key&&(e.preventDefault(),_(e))},m=()=>{Je=!1,document.removeEventListener("keydown",u),document.removeEventListener("click",p),l&&l.removeEventListener("click",c),h&&h.removeEventListener("click",_)},p=e=>{if("dropdown"!==o)return;const t=i._params.relatedTarget;n.contains(e.target)||(0,r.vq)(t)&&t.contains(e.target)||_(e)};"confirm"===i._params.mode&&(l&&l.addEventListener("click",c),h&&h.addEventListener("click",_)),"info"===i._params.mode&&h&&h.addEventListener("click",_),document.addEventListener("keydown",u),"modal"===o&&n.addEventListener("vg.modal.hide",()=>{s||(s=!0,m(),t({accepted:!1,timestamp:new Date}))},{once:!0}),"dropdown"===o&&(document.addEventListener("click",p),n.addEventListener("vg.dropdown.hidden",()=>{n._vgAlertDropdownParent&&!n._vgAlertDropdownParentWasSet&&n._vgAlertDropdownParent.classList.remove("vg-dropdown"),n.remove(),s||(s=!0,m(),t({accepted:!1,timestamp:new Date}))},{once:!0})),n.focus()})}static confirm(e,t={}){let i="ru";"lang"in t&&(i=t.lang||"ru",delete t.lang);const s=new Qe(t,i);"confirm"===s._params.mode&&at.getOrCreateInstance(e,s._params).run(Qe)}static _bindDataApi(){this._isDataApiBound||(this._isDataApiBound=!0,g.A.on(document,tt,et,function(e){e.preventDefault();const t=e.delegateTarget||this||e.target?.closest(et)||e.target;(0,r.zN)(t)&&(0,r.vq)(t)&&Qe.confirm(t,{buttons:{agree:{class:["btn-primary"]},cancel:{class:["btn-outline-primary"]}}})}))}_setParams(e){const t=(0,r._v)(this._defaultParams,e);return t.size="compact"===t.size?"compact":"default",t.buttons=(0,r._v)(this._elementsDefault.buttons,t.buttons),t.message=(0,r._v)(this._elementsDefault.message,t.message),t.icon=this._elementsDefault.icons[t.theme],t}_applySizeClass(e){return"compact"===this._params.size&&e?.classList.add(Ke),e}_buildModal(){const e=`${Ue}-${(0,r.PR)()}`;return he.build(e,this._params.modal,e=>{e._element.classList.add(`${Ue}-modal`),this._applySizeClass(e._element),s.A.find(".vg-modal-body",e._element).append(this._buildContent())})}_buildContent(){const e=(0,d.A)("dom");let i=null;this._params.icon&&(i=e.div({class:`${Ue}-content--icon`},this._params.icon,{isHTML:!0}));const s=document.createElement("div");t.x.add(s,"vg-alert-buttons"),"confirm"===this._params.mode&&(this._createButton(s,"cancel"),this._createButton(s,"agree")),"info"===this._params.mode&&this._createButton(s,"cancel");const r="compact"===this._params.size?` ${Ke}`:"";return e.div({class:`${Ue}-wrapper ${Ue}-${this._params.theme}${r}`},[e.div({class:`${Ue}-content`},[i,e.div({class:`${Ue}-content--message`},[e.div({class:`${Ue}-content--title`},this._params.message.title),e.div({class:`${Ue}-content--description`},this._params.message.description)])]),s])}_buildOverlay(){const e=this._params.relatedTarget,t=(0,r.vq)(e)?e.closest([".vg-modal",".vg-sidebar"].join(", ")):null;if(!t)return{element:null,render:null};const i=he.getOrCreateInstance(t),n=s.A.find(".vg-modal-content",i._element)||t,a=document.createElement("div");return a.className=`${Ue}-overlay`,this._applySizeClass(a),a.append(this._buildContent()),n.append(a),{element:a,render:i}}_showOverlay(e){e&&((0,r.qm)(e),requestAnimationFrame(()=>{e.classList.add(qe),(0,r.qm)(e),window.setTimeout(()=>{e.isConnected&&e.classList.add(Ve)},15)}))}_hideOverlay(e,t){if(!e)return void(0,r.g7)(t);const i=()=>{e.classList.remove(qe),e.classList.remove(We),e.remove(),(0,r.g7)(t)};e.classList.add(We);const n=s.A.find(`.${Ue}-wrapper`,e),a=this._getElementTransitionDuration(n);window.setTimeout(()=>{e.classList.remove(Ve);const t=this._getElementTransitionDuration(e,"::before");t?window.setTimeout(i,t):i()},a)}_getElementTransitionDuration(e,t=null){if(!e||"undefined"==typeof window)return 0;const i=window.getComputedStyle(e,t),s=i.transitionDuration.split(","),r=i.transitionDelay.split(",");return Math.max(...s.map((e,t)=>this._parseCssTime(e)+this._parseCssTime(r[t]||r[0]||"0s")))}_parseCssTime(e){const t=Number.parseFloat(e);return Number.isFinite(t)?e.trim().endsWith("ms")?t:1e3*t:0}_buildDropdown(){const e=this._params.relatedTarget;if(!(0,r.vq)(e)||!e.parentNode)return{element:null,render:null};const t=`${Ue}-dropdown-${(0,r.PR)()}`,i=e.parentNode,s=document.createElement("div"),n=document.createElement("div"),a=i.classList.contains("vg-dropdown");i.classList.add("vg-dropdown"),s.id=t,s.className=`vg-dropdown-content ${Ue}-dropdown`,this._applySizeClass(s),s.setAttribute("tabindex","-1"),s.setAttribute("role","dialog"),s._vgAlertDropdownParent=i,s._vgAlertDropdownParentWasSet=a,n.className="vg-dropdown-container",n.append(this._buildContent()),s.append(n),i.append(s);const o=Pe.getOrCreateInstance(e,(0,r._v)({placement:"bottom-start"},this._params.dropdown));return o._drop=s,o._parent=i,{element:s,render:o}}_createButton(e,t){const i=this._params.buttons[t];if(!i||i.element)return void e.insertAdjacentHTML("beforeend",i?.element||"");if(!i.tag)return;let s=null,n=[...new Set(i.class)].join(" "),a=(0,r._v)({class:n},i.attr);"button"===i.tag?s=(0,d.A)("dom").button(i.text,i.type,a):"a"===i.tag&&(s=(0,d.A)("dom").a("#",i.text,a)),s&&(s.setAttribute(i.toggle,"true"),e.appendChild(s))}}const et=`[data-vg-toggle="${Xe}"]`,tt=`click.${Ze}.data.api`,it=`${Ze}.loaded`,st=`${Ze}.accept`,rt=`${Ze}.reject`,nt=`${Ze}.finally`;class at extends e.A{constructor(e,t={}){super(e),this._params=this._getParams(e,(0,r._v)({},t))}static get NAME(){return Xe}static get NAME_KEY(){return Ze}run(e){"confirm"===this._params.mode&&(this._params.relatedTarget=this._element,e.call(this._params).then(e=>e.accepted?this._params.ajax.route?this._ajax():e:Promise.reject(e)).then(e=>{g.A.trigger(this._element,st,{vgalert:e})}).catch(e=>{g.A.trigger(this._element,rt,{vgalert:e})}).finally(()=>{g.A.trigger(this._element,nt,{vgalert:"finally"})}))}_ajax(){return new Promise(e=>{this._route((t,i)=>{g.A.trigger(this._element,it,{stats:t,data:i}),e({status:t,data:i})})})}}Qe._isDataApiBound=!1;const ot=Qe,lt="vg.collapse",ht="show",dt="vg-collapse",ct="vg-collapsing",_t=`:scope .${dt} .${dt}`,ut='[data-vg-toggle="collapse"]',mt=`${lt}.hide`,pt=`${lt}.hidden`,gt=`${lt}.show`,ft=`${lt}.shown`,bt=`${lt}.loaded`,vt=`click.${lt}.data.api`;class yt extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({toggle:!0,parent:null,ajax:{route:"",target:"",method:"get",loader:!1,once:!0,output:!0}},t)),this._params.parent=(0,r.V6)(this._params.parent)||null,this._isTransitioning=!1,this._triggerArray=[];const i=s.A.findAll(ut);for(const e of i){const t=s.A.getSelectorFromElement(e),i=s.A.findAll(t).filter(e=>e===this._element);null!==t&&i.length&&this._triggerArray.push(e)}this._initializeChildren(),this._params.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._params.toggle&&this.toggle()}static get NAME(){return"collapse"}static get NAME_KEY(){return lt}toggle(e){return this._isShown()?this.hide():this.show(e)}show(){if(this._isTransitioning||this._isShown())return;let e=[];if(this._params.parent&&(e=this._getFirstLevelChildren(".vg-collapse.show, .vg-collapse.vg-collapsing").filter(e=>e!==this._element).map(e=>yt.getOrCreateInstance(e,{toggle:!1}))),e.length&&e[0]._isTransitioning)return;if(g.A.trigger(this._element,gt).defaultPrevented)return;for(const t of e)t.hide();const t=this._getDimension();this._element.classList.remove(dt),this._element.classList.add(ct),this._element.style[t]="0",this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const i=`scroll${t[0].toUpperCase()+t.slice(1)}`;this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(ct),this._element.classList.add(dt,ht),this._element.style[t]="",this._route((e,t)=>{g.A.trigger(this._element,bt,{stats:e,data:t})}),g.A.trigger(this._element,ft)},this._element,!0),this._element.style[t]=`${this._element[i]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(g.A.trigger(this._element,mt).defaultPrevented)return;const e=this._getDimension();this._element.style[e]=`${this._element.getBoundingClientRect()[e]}px`,(0,r.qm)(this._element),this._element.classList.add(ct),this._element.classList.remove(dt,ht);for(const e of this._triggerArray){const t=s.A.getElementFromSelector(e);t&&!this._isShown(t)&&this._addAriaAndCollapsedClass([e],!1)}this._isTransitioning=!0,this._element.style[e]="",this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(ct),this._element.classList.add(dt),g.A.trigger(this._element,pt)},this._element,!0)}dispose(){super.dispose()}_isShown(e=this._element){return e.classList.contains(ht)}_addAriaAndCollapsedClass(e,t){if(e.length)for(const i of e)this._changeStateButton(i,t)}_initializeChildren(){if(!this._params.parent)return;const e=this._getFirstLevelChildren(ut);for(const t of e){const e=s.A.getElementFromSelector(t);e&&this._addAriaAndCollapsedClass([t],this._isShown(e))}}_getFirstLevelChildren(e){const t=s.A.findAll(_t,this._params.parent);return s.A.findAll(e,this._params.parent).filter(e=>!t.includes(e))}_changeStateButton(e,i){e.classList.toggle("vg-collapsed",!i),e.setAttribute("aria-expanded",i),e.innerHTML=t.p.get(e,`data-${i?"hide":"show"}-text`)||e.innerHTML}_getDimension(){return this._element.classList.contains("vg-collapse-horizontal")?"width":"height"}}g.A.on(document,vt,ut,function(e){("A"===e.target.tagName||e.delegateTarget&&"A"===e.delegateTarget.tagName)&&e.preventDefault(),s.A.getMultipleElementsFromSelector(this).forEach(function(e){yt.getOrCreateInstance(e,{toggle:!1}).toggle()})});const wt=yt,Et=wt,At={pathAttribute:"data-vg-filepreview",fieldsAttribute:"data-fields",validAttribute:"data-vg-filepreview-valid",errorAttribute:"data-vg-filepreview-error",errorValue:"invalid-file-path",fieldAttribute:"data-vg-filepreview-field",editableAttribute:"data-vg-filepreview-editable",editableFieldsAttribute:"data-vg-filepreview-editable-fields",missingFieldsAttribute:"data-vg-filepreview-missing-fields"},St=class{constructor(e,t={}){this._element=e,this._options=Object.assign({},At,t)}getFilePath(){if(!this._element)return"";const e=this._element.getAttribute(this._options.pathAttribute);return"string"==typeof e?e.trim():""}getFields(){if(!this._element)return[];const e=this._element.getAttribute(this._options.fieldsAttribute);return"string"==typeof e&&e.trim()?e.split(",").map(e=>e.trim()).filter(e=>e&&/^[-_a-zA-Z0-9]+$/.test(e)):[]}validateFilePath(e){if(!e||"#"===e||/^javascript:/i.test(e))return{isValid:!1,fileUrl:null};try{const t=new URL(e,window.location.origin),i=t.protocol;if(!["http:","https:","blob:","data:"].includes(i))return{isValid:!1,fileUrl:null};if("data:"===i||"blob:"===i)return{isValid:!0,fileUrl:t};const s=(t.pathname||"").split("/").filter(Boolean).pop()||"";return s&&s.includes(".")?{isValid:!0,fileUrl:t}:{isValid:!1,fileUrl:null}}catch{return{isValid:!1,fileUrl:null}}}syncState(e){this._element&&(this._element.setAttribute(this._options.validAttribute,e?"true":"false"),e?this._element.removeAttribute(this._options.errorAttribute):this._element.setAttribute(this._options.errorAttribute,this._options.errorValue))}resolveEditableFields(e=[]){return this._element&&Array.isArray(e)&&e.length?e.reduce((e,t)=>(e[t]=this._element.querySelector(`.${this._escapeClassName(t)}`),e),{}):{}}syncEditableFields(e={}){if(!this._element)return;this._element.querySelectorAll(`[${this._options.fieldAttribute}]`).forEach(e=>{e.removeAttribute(this._options.fieldAttribute),e.setAttribute(this._options.editableAttribute,"false")});const t=[],i=[];Object.entries(e).forEach(([e,s])=>{s?(s.setAttribute(this._options.fieldAttribute,e),s.setAttribute(this._options.editableAttribute,"true"),t.push(e)):i.push(e)}),t.length?this._element.setAttribute(this._options.editableFieldsAttribute,t.join(",")):this._element.removeAttribute(this._options.editableFieldsAttribute),i.length?this._element.setAttribute(this._options.missingFieldsAttribute,i.join(",")):this._element.removeAttribute(this._options.missingFieldsAttribute)}_escapeClassName(e){return window.CSS&&"function"==typeof window.CSS.escape?window.CSS.escape(e):String(e).replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}getFileMeta(e){const t="string"==typeof e?e.trim():"";if(!t)return{name:"",ext:"",originalName:"",isMedia:!1,sizeBytes:null,sizeText:""};try{const e=new URL(t,window.location.origin),i=e.pathname||"",s=e.searchParams,r=this._readOriginalName(s);let n=decodeURIComponent(i.split("/").pop()||"");n&&n.includes(".")||(n=r||n);const a=n.includes(".")?`.${n.split(".").pop()||""}`:"",o=this._readSize(s),l=[".mp3",".wav",".ogg",".flac",".aac",".m4a",".mp4",".webm",".mov",".mkv",".avi"];return{name:n,ext:a.toLowerCase(),originalName:r,isMedia:l.includes(a.toLowerCase()),sizeBytes:o,sizeText:this._formatSize(o)}}catch{const e=t.split("#")[0].split("?")[0];let i=decodeURIComponent(e.split("/").pop()||"");const s=this._readOriginalName(null);i&&i.includes(".")||(i=s||i);const r=i.includes(".")?`.${i.split(".").pop()||""}`:"",n=this._readSize(null);return{name:i,ext:r.toLowerCase(),originalName:s||"",isMedia:!1,sizeBytes:n,sizeText:this._formatSize(n)}}}_readOriginalName(e){const t=this._element?.getAttribute("data-original-name")||this._element?.getAttribute("data-vg-filepreview-original-name")||"";if(t)return String(t).trim();const i=["original_name","originalName","filename","name"];for(const t of i){const i=e.get(t);if(i)return String(i).trim()}return""}_readSize(e){const t=[this._element?.getAttribute("data-size"),this._element?.getAttribute("data-vg-filepreview-size")];for(const e of t){const t=this._parseSizeValue(e);if(null!==t)return t}if(!e)return null;const i=["size","size_bytes","bytes"];for(const t of i){const i=e.get(t),s=this._parseSizeValue(i);if(null!==s)return s}return null}_parseSizeValue(e){if(null==e)return null;const t=String(e).trim().toLowerCase();if(!t)return null;const i=t.match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|tb)?$/i);if(!i)return null;const s=Number.parseFloat(i[1]);if(!Number.isFinite(s)||s<0)return null;const r=(i[2]||"b").toLowerCase();return Math.round(s*({b:1,kb:1024,mb:1048576,gb:1073741824,tb:1099511627776}[r]||1))}_formatSize(e){if(!Number.isFinite(e)||e<0)return"";const t=["B","KB","MB","GB","TB"];let i=e,s=0;for(;i>=1024&&s<t.length-1;)i/=1024,s+=1;const r=i>=100||0===s?0:2;return`${i.toFixed(r)} ${t[s]}`}},Ct=new Set(["mp3"]),xt=(e,t=0)=>(127&e[t])<<21|(127&e[t+1])<<14|(127&e[t+2])<<7|127&e[t+3],Lt=(e,t,i)=>i?xt([e.getUint8(t),e.getUint8(t+1),e.getUint8(t+2),e.getUint8(t+3)],0):(e.getUint8(t)<<24|e.getUint8(t+1)<<16|e.getUint8(t+2)<<8|e.getUint8(t+3))>>>0,It=(e,t)=>{if(!e||!e.length)return"";try{if(0===t)return new TextDecoder("iso-8859-1").decode(e).replace(/\u0000/g,"").trim();if(1===t){if(e.length>=2){const t=e[0],i=e[1];if(255===t&&254===i)return new TextDecoder("utf-16le").decode(e.slice(2)).replace(/\u0000/g,"").trim();if(254===t&&255===i){const t=new Uint8Array(e.length-2);for(let i=2;i+1<e.length;i+=2)t[i-2]=e[i+1],t[i-1]=e[i];return new TextDecoder("utf-16le").decode(t).replace(/\u0000/g,"").trim()}}return new TextDecoder("utf-16le").decode(e).replace(/\u0000/g,"").trim()}if(2===t){const t=new Uint8Array(e.length);for(let i=0;i+1<e.length;i+=2)t[i]=e[i+1],t[i+1]=e[i];return new TextDecoder("utf-16le").decode(t).replace(/\u0000/g,"").trim()}return new TextDecoder("utf-8").decode(e).replace(/\u0000/g,"").trim()}catch{return""}},Pt=(e,t,i=1)=>{for(let s=t;s<e.length;s+=i)if(2===i){if(s+1<e.length&&0===e[s]&&0===e[s+1])return s}else if(0===e[s])return s;return-1},kt=e=>{if(!e||e.length<4)return null;const t=e[0];let i=1;const s=Pt(e,i);if(s<0)return null;const r=new TextDecoder("iso-8859-1").decode(e.slice(i,s)).trim();if(i=s+1,i>=e.length)return null;i+=1;const n=1===t||2===t,a=Pt(e,i,n?2:1);if(a>=0&&(i=a+(n?2:1)),i>=e.length)return null;const o=e.slice(i),l=r||"image/jpeg";return o.length?{mimeType:l,data:o}:null},Mt=async e=>{if(!(e instanceof File))return null;const t=(e=>{const t=String(e?.name||"").toLowerCase(),i=t.lastIndexOf(".");return i<0||i>=t.length-1?"":t.slice(i+1)})(e);if(!Ct.has(t))return null;if(!e.size)return null;try{const t=e.slice(0,Math.min(e.size,2097152)),i=(e=>{const t=new Uint8Array(e);if(t.length<10)return null;if(73!==t[0]||68!==t[1]||51!==t[2])return null;const i=t[3];if(i<2||i>4)return null;const s=xt(t,6),r=Math.min(t.length,s+10),n=new DataView(e,0,r);let a=10,o="",l=null;for(;a+10<=r;){const e=String.fromCharCode(n.getUint8(a),n.getUint8(a+1),n.getUint8(a+2),n.getUint8(a+3));if(!e.trim())break;const s=Lt(n,a+4,4===i);if(!s||s<1)break;const h=a+10,d=h+s;if(d>r)break;const c=t.slice(h,d);"TIT2"===e&&c.length>1&&(o=It(c.slice(1),c[0])||o),"APIC"!==e||l||(l=kt(c)),a=d}return{title:o,picture:l}})(await t.arrayBuffer());if(!i)return null;const s={};if(i.title&&(s.title=i.title),i.picture?.data?.length){const e=new Blob([i.picture.data],{type:i.picture.mimeType||"image/jpeg"});s.pictureBlob=e}return Object.keys(s).length?s:null}catch{return null}},Dt=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]);class Tt{constructor(){this._modalId="vg-filepreview-image-modal"}static getInstance(){return Tt._instance||(Tt._instance=new Tt),Tt._instance}open(e={}){const t=String(e.src||"").trim();if(!t)return;if(this._ensureModal(),!this._modal||!this._image)return;const i=String(e.defaultTitle||"").trim(),s=String(e.title||"").trim();this._title.textContent=s||i,this._image.src=t,this._image.alt=s||i,this._modal.show()}close(){this._modal&&this._modal.hide()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const e={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},t=document.getElementById(this._modalId);if(t)return this._root=t,this._modal=he.getOrCreateInstance(t,e),this._bindElements(t),void this._bindLifecycle(t);this._modal=he.build(this._modalId,e,e=>{const t=e._element;this._root=t,t.classList.add("vg-filepreview-image-modal");const i=t.querySelector(".vg-modal-body"),s=t.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=t.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="",this._image=document.createElement("img"),this._image.className="vg-filepreview-image-modal__img",this._image.loading="eager",this._image.decoding="async",r.appendChild(this._title),i.appendChild(this._image),this._bindLifecycle(t)})}_bindElements(e){this._title=e.querySelector(".vg-filepreview-image-modal__title"),this._image=e.querySelector(".vg-filepreview-image-modal__img")}_bindLifecycle(e){e&&!e.hasAttribute("data-vg-filepreview-image-lifecycle-bind")&&(e.setAttribute("data-vg-filepreview-image-lifecycle-bind","true"),e.addEventListener("vg.modal.hidden",()=>{this._destroyModal()}))}_destroyModal(){this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._image=null}}const Ot=Tt,zt=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".tif",".tiff",".heic",".heif",".avif"]),Nt=class{constructor(){this.name="image",this._modal=Ot.getInstance()}canRender(e={}){const t=String(e?.fileMeta?.ext||"").toLowerCase();return zt.has(t)}render(e={}){const t=e?.previewContainer,i=Boolean(e?.ui?.nameOnly),s=e?.i18n,r=e?.fileUrl?.href||e?.filePath||"";if(!r)return!1;const n=t=>{t&&t.preventDefault(),this._modal.open({src:r,title:e?.fileMeta?.name||s?.message("image_title")||"",defaultTitle:s?.message("image_title")||""})},a=e?.element?.querySelector(".name");a&&!a.hasAttribute("data-vg-filepreview-image-bind")&&(a.setAttribute("data-vg-filepreview-image-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n));const o=e?.element?.closest(".file")?.querySelector(".file-image .file-preview");if(o&&!o.hasAttribute("data-vg-filepreview-image-bind")&&(o.setAttribute("data-vg-filepreview-image-bind","true"),o.classList.add("is-preview-action"),o.addEventListener("click",n)),i)return Boolean(a||o);if(!t)return!1;const l=document.createElement("button");l.type="button",l.className="vg-filepreview-image-trigger",l.textContent=s?.button("open_image")||"",l.addEventListener("click",n),t.appendChild(l);const h=document.createElement("img");return h.className="vg-filepreview-image-thumb",h.src=r,h.alt=e?.fileMeta?.name||s?.message("image_thumbnail_alt")||"",h.loading="lazy",h.addEventListener("click",n),t.appendChild(h),!0}};class $t{constructor(){this._modalId="vg-filepreview-office-modal",this._labels={}}static getInstance(){return $t._instance||($t._instance=new $t),$t._instance}open(e={}){const t=String(e.src||"").trim();if(!t)return;if(this._ensureModal(),!this._modal||!this._frame)return;this._labels=e?.labels&&"object"==typeof e.labels?e.labels:{},this._src=t,this._downloadName=String(e.downloadName||"").trim();const i=String(e.defaultTitle||"").trim(),s=String(e.title||"").trim();this._title.textContent=s||i,this._fallback.textContent=this._label("fallback"),this._download.textContent=this._label("download"),this._frame.src=this._buildViewerUrl(t),this._modal.show()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){this._modal=he.build(this._modalId,{centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},e=>{const t=e._element;this._root=t,t.classList.add("vg-filepreview-office-modal");const i=t.querySelector(".vg-modal-body"),s=t.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=t.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._frame=document.createElement("iframe"),this._frame.className="vg-filepreview-office-modal__frame",this._frame.setAttribute("title","Office preview");const n=document.createElement("div");n.className="vg-filepreview-office-modal__footer",this._fallback=document.createElement("span"),this._fallback.className="vg-filepreview-office-modal__hint",this._download=document.createElement("button"),this._download.type="button",this._download.className="vg-filepreview-office-modal__btn",this._download.addEventListener("click",()=>this._downloadFile()),n.appendChild(this._fallback),n.appendChild(this._download),r.appendChild(this._title),i.appendChild(this._frame),s.appendChild(n),this._bindLifecycle(t)})}_buildViewerUrl(e){const t=new URL(e,window.location.origin).href;return`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(t)}`}_downloadFile(){if(!this._src)return;const e=document.createElement("a");e.href=this._src,this._downloadName&&e.setAttribute("download",this._downloadName),e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e)}_label(e){const t=this._labels?.[e];return String(t||"").trim()}_bindLifecycle(e){e&&!e.hasAttribute("data-vg-filepreview-office-lifecycle-bind")&&(e.setAttribute("data-vg-filepreview-office-lifecycle-bind","true"),e.addEventListener("vg.modal.hidden",()=>this._destroyModal()))}_destroyModal(){this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._frame=null,this._fallback=null,this._download=null,this._labels=null,this._src="",this._downloadName=""}}const Ht=$t,Ft=new Set([".doc",".docx",".xls",".xlsx",".ppt",".pptx",".odt",".ods",".odp"]),Rt=class{constructor(){this.name="office",this._modal=Ht.getInstance()}canRender(e={}){const t=String(e?.fileMeta?.ext||"").toLowerCase();return Ft.has(t)}render(e={}){const t=e?.previewContainer,i=Boolean(e?.ui?.nameOnly),s=e?.i18n,r=e?.fileUrl?.href||e?.filePath||"";if(!r)return!1;const n=t=>{t&&t.preventDefault(),this._modal.open({src:r,title:e?.fileMeta?.name||s?.message("office_title")||"",defaultTitle:s?.message("office_title")||"",downloadName:e?.fileMeta?.originalName||e?.fileMeta?.name||"",labels:{download:s?.button("download")||"",fallback:s?.message("office_fallback")||""}})},a=e?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-office-bind")&&(a.setAttribute("data-vg-filepreview-office-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!t)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-office-trigger",o.textContent=s?.button("open_office")||"",o.addEventListener("click",n),t.appendChild(o),!0}};class Bt{constructor(){this._modalId="vg-filepreview-pdf-modal",this._labels={},this._src="",this._downloadName="",this._page=1,this._zoom=100}static getInstance(){return Bt._instance||(Bt._instance=new Bt),Bt._instance}open(e={}){const t=String(e.src||"").trim();if(!t)return;if(this._ensureModal(),!this._modal||!this._frame)return;this._labels=e?.labels&&"object"==typeof e.labels?e.labels:{},this._src=t,this._downloadName=String(e.downloadName||"").trim(),this._page=1,this._zoom=100;const i=String(e.defaultTitle||"").trim(),s=String(e.title||"").trim();this._title.textContent=s||i,this._syncControls(),this._updateFrameSrc(),this._modal.show()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const e={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},t=document.getElementById(this._modalId);if(t)return this._root=t,this._modal=he.getOrCreateInstance(t,e),this._bindElements(t),void this._bindLifecycle(t);this._modal=he.build(this._modalId,e,e=>{const t=e._element;this._root=t,t.classList.add("vg-filepreview-pdf-modal");const i=t.querySelector(".vg-modal-body"),s=t.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-pdf-modal__body"),i.innerHTML="";let r=t.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title";const n=document.createElement("div");n.className="vg-filepreview-pdf-modal__toolbar",this._pagePrev=document.createElement("button"),this._pagePrev.type="button",this._pagePrev.className="vg-filepreview-pdf-modal__btn",this._pagePrev.setAttribute("data-role","page-prev"),this._pagePrev.addEventListener("click",()=>{this._page=Math.max(1,this._page-1),this._syncControls(),this._updateFrameSrc()}),this._pageInfo=document.createElement("span"),this._pageInfo.className="vg-filepreview-pdf-modal__meta",this._pageInfo.setAttribute("data-role","page"),this._pageNext=document.createElement("button"),this._pageNext.type="button",this._pageNext.className="vg-filepreview-pdf-modal__btn",this._pageNext.setAttribute("data-role","page-next"),this._pageNext.addEventListener("click",()=>{this._page+=1,this._syncControls(),this._updateFrameSrc()}),this._zoomOut=document.createElement("button"),this._zoomOut.type="button",this._zoomOut.className="vg-filepreview-pdf-modal__btn",this._zoomOut.setAttribute("data-role","zoom-out"),this._zoomOut.addEventListener("click",()=>{this._zoom=Math.max(50,this._zoom-10),this._syncControls(),this._updateFrameSrc()}),this._zoomIn=document.createElement("button"),this._zoomIn.type="button",this._zoomIn.className="vg-filepreview-pdf-modal__btn",this._zoomIn.setAttribute("data-role","zoom-in"),this._zoomIn.addEventListener("click",()=>{this._zoom=Math.min(300,this._zoom+10),this._syncControls(),this._updateFrameSrc()}),this._zoomInfo=document.createElement("span"),this._zoomInfo.className="vg-filepreview-pdf-modal__meta",this._zoomInfo.setAttribute("data-role","zoom"),this._download=document.createElement("button"),this._download.type="button",this._download.className="vg-filepreview-pdf-modal__btn primary",this._download.setAttribute("data-role","download"),this._download.addEventListener("click",()=>this._downloadFile()),n.appendChild(this._pagePrev),n.appendChild(this._pageInfo),n.appendChild(this._pageNext),n.appendChild(this._zoomOut),n.appendChild(this._zoomInfo),n.appendChild(this._zoomIn),n.appendChild(this._download),this._frame=document.createElement("iframe"),this._frame.className="vg-filepreview-pdf-modal__frame",this._frame.setAttribute("title","PDF preview"),r.appendChild(this._title),i.appendChild(this._frame),this._bindLifecycle(t)})}_bindElements(e){this._title=e.querySelector(".vg-filepreview-pdf-modal__title"),this._frame=e.querySelector(".vg-filepreview-pdf-modal__frame"),this._pagePrev=e.querySelector('.vg-filepreview-pdf-modal__btn[data-role="page-prev"]'),this._pageNext=e.querySelector('.vg-filepreview-pdf-modal__btn[data-role="page-next"]'),this._zoomOut=e.querySelector('.vg-filepreview-pdf-modal__btn[data-role="zoom-out"]'),this._zoomIn=e.querySelector('.vg-filepreview-pdf-modal__btn[data-role="zoom-in"]'),this._download=e.querySelector('.vg-filepreview-pdf-modal__btn[data-role="download"]'),this._pageInfo=e.querySelector('.vg-filepreview-pdf-modal__meta[data-role="page"]'),this._zoomInfo=e.querySelector('.vg-filepreview-pdf-modal__meta[data-role="zoom"]')}_bindLifecycle(e){e&&!e.hasAttribute("data-vg-filepreview-pdf-lifecycle-bind")&&(e.setAttribute("data-vg-filepreview-pdf-lifecycle-bind","true"),e.addEventListener("vg.modal.hidden",()=>this._destroyModal()))}_syncControls(){this._pageInfo&&this._zoomInfo&&(this._pagePrev.textContent=this._label("prevPage"),this._pageNext.textContent=this._label("nextPage"),this._zoomOut.textContent=this._label("zoomOut"),this._zoomIn.textContent=this._label("zoomIn"),this._download.textContent=this._label("download"),this._pageInfo.textContent=`${this._label("page")}: ${this._page}`,this._zoomInfo.textContent=`${this._label("zoom")}: ${this._zoom}%`)}_updateFrameSrc(){if(!this._frame||!this._src)return;const e=`#page=${this._page}&zoom=${this._zoom}`;this._frame.src=`${this._src}${e}`}_downloadFile(){if(!this._src)return;const e=document.createElement("a");e.href=this._src,this._downloadName&&e.setAttribute("download",this._downloadName),e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e)}_label(e){const t=this._labels?.[e];return String(t||"").trim()}_destroyModal(){this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._frame=null,this._labels=null,this._src=""}}const jt=Bt,Ut=new Set([".pdf"]),qt=class{constructor(){this.name="pdf",this._modal=jt.getInstance()}canRender(e={}){const t=String(e?.fileMeta?.ext||"").toLowerCase();return Ut.has(t)}render(e={}){const t=e?.previewContainer,i=Boolean(e?.ui?.nameOnly),s=e?.i18n,r=e?.fileUrl?.href||e?.filePath||"";if(!r)return!1;const n=t=>{t&&t.preventDefault(),this._modal.open({src:r,title:e?.fileMeta?.name||s?.message("pdf_title")||"",defaultTitle:s?.message("pdf_title")||"",labels:{page:s?.message("pdf_page")||"",zoom:s?.message("pdf_zoom")||"",zoomIn:s?.button("zoom_in")||"",zoomOut:s?.button("zoom_out")||"",prevPage:s?.button("prev")||"",nextPage:s?.button("next")||"",download:s?.button("download")||""},downloadName:e?.fileMeta?.originalName||e?.fileMeta?.name||"file.pdf"})},a=e?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-pdf-bind")&&(a.setAttribute("data-vg-filepreview-pdf-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!t)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-pdf-trigger",o.textContent=s?.button("open_pdf")||"",o.addEventListener("click",n),t.appendChild(o),!0}};class Vt{constructor(){this._modalId="vg-filepreview-text-modal",this._abortController=null,this._labels={}}static getInstance(){return Vt._instance||(Vt._instance=new Vt),Vt._instance}open(e={}){const t=String(e.src||"").trim();if(!t)return;if(this._ensureModal(),!this._modal||!this._content)return;this._labels=e?.labels&&"object"==typeof e.labels?e.labels:{};const i=String(e.defaultTitle||"").trim(),s=String(e.title||"").trim(),r=String(e.ext||"").toLowerCase();this._title.textContent=s||i,this._content.textContent=this._label("loading"),this._content.classList.remove("is-markdown"),this._modal.show(),this._loadText(t,{ext:r})}close(){this._modal&&this._modal.hide()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const e={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"600px",height:""},animation:{enable:!1}},t=document.getElementById(this._modalId);if(t)return this._root=t,this._modal=he.getOrCreateInstance(t,e),this._bindElements(t),void this._bindLifecycle(t);this._modal=he.build(this._modalId,e,e=>{const t=e._element;this._root=t,t.classList.add("vg-filepreview-text-modal");const i=t.querySelector(".vg-modal-body"),s=t.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-text-modal__body"),i.innerHTML="";let r=t.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="",this._content=document.createElement("pre"),this._content.className="vg-filepreview-text-modal__content",this._content.textContent="",r.appendChild(this._title),i.appendChild(this._content),this._bindLifecycle(t)})}_bindElements(e){this._title=e.querySelector(".vg-filepreview-text-modal__title"),this._content=e.querySelector(".vg-filepreview-text-modal__content")}_bindLifecycle(e){e&&!e.hasAttribute("data-vg-filepreview-text-lifecycle-bind")&&(e.setAttribute("data-vg-filepreview-text-lifecycle-bind","true"),e.addEventListener("vg.modal.hidden",()=>{this._destroyModal()}))}_loadText(e,t={}){const i=String(t.ext||"").toLowerCase(),s=`${e}|${i}`;if(Vt._cache.has(s)){const e=Vt._cache.get(s);return void this._renderLoadedText(e,i)}this._abortController&&this._abortController.abort(),this._abortController=new AbortController,fetch(e,{method:"GET",signal:this._abortController.signal}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.text()}).then(e=>{const t=e||"";Vt._cache.set(s,t),this._renderLoadedText(t,i)}).catch(e=>{this._content&&"AbortError"!==e?.name&&(this._content.classList.remove("is-markdown"),this._content.textContent=`${this._label("cannotOpen")}: ${e?.message||this._label("unknownError")}`)})}_renderLoadedText(e,t){if(!this._content)return;const i=String(e||"");".md"===t?(this._content.classList.add("is-markdown"),this._content.innerHTML=this._renderMarkdown(i)):(this._content.classList.remove("is-markdown"),this._content.textContent=i||this._label("emptyFile"))}_destroyModal(){this._abortController&&(this._abortController.abort(),this._abortController=null),this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._content=null,this._labels=null}_label(e,t=""){const i=this._labels?.[e];return"string"==typeof i&&i.trim()?i:t}_renderMarkdown(e){const t=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),i=e=>{let i=t(e);return i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*([^*]+)\*/g,"<em>$1</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,i)=>`<a href="${this._sanitizeUrl(i)}" target="_blank" rel="noopener noreferrer">${t}</a>`),i},s=String(e||"").split(/\r?\n/),r=[];let n=!1,a=!1;return s.forEach(e=>{const s=e||"";if(s.trim().startsWith("```"))return void(a?(a=!1,r.push("</code></pre>")):(a=!0,r.push("<pre><code>")));if(a)return void r.push(`${t(s)}\n`);if(!s.trim())return void(n&&(n=!1,r.push("</ul>")));const o=s.match(/^(#{1,6})\s+(.+)$/);if(o){n&&(n=!1,r.push("</ul>"));const e=o[1].length;return void r.push(`<h${e}>${i(o[2])}</h${e}>`)}const l=s.match(/^[-*]\s+(.+)$/);if(l)return n||(n=!0,r.push("<ul>")),void r.push(`<li>${i(l[1])}</li>`);n&&(n=!1,r.push("</ul>")),r.push(`<p>${i(s)}</p>`)}),n&&r.push("</ul>"),a&&r.push("</code></pre>"),r.join("")||`<p>${this._escapeHtml(this._label("emptyFile"))}</p>`}_escapeHtml(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}_sanitizeUrl(e){const t=String(e||"").trim();if(!t)return"#";try{const e=new URL(t,window.location.origin);if(["http:","https:","mailto:"].includes(e.protocol))return e.href}catch{return"#"}return"#"}}Vt._cache=new Map;const Wt=Vt,Kt=new Set([".txt",".md",".csv",".json",".xml",".yml",".yaml",".log",".ini",".conf",".env"]),Gt=class{constructor(){this.name="text",this._modal=Wt.getInstance()}canRender(e={}){const t=String(e?.fileMeta?.ext||"").toLowerCase();return Kt.has(t)}render(e={}){const t=e?.previewContainer,i=Boolean(e?.ui?.nameOnly),s=e?.i18n,r=e?.fileUrl?.href||e?.filePath||"";if(!r)return!1;const n=t=>{t&&t.preventDefault(),this._modal.open({src:r,title:e?.fileMeta?.name||s?.message("text_title")||"",defaultTitle:s?.message("text_title")||"",ext:e?.fileMeta?.ext||"",labels:{loading:s?.message("loading_text")||"",cannotOpen:s?.message("cannot_open_file")||"",unknownError:s?.message("unknown_error")||"",emptyFile:s?.message("empty_file")||""}})},a=e?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-text-bind")&&(a.setAttribute("data-vg-filepreview-text-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!t)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-text-trigger",o.textContent=s?.button("open_text")||"",o.addEventListener("click",n),t.appendChild(o),!0}};class Yt{constructor(){this._modalId="vg-filepreview-video-modal",this._playlist=[],this._currentIndex=-1,this._labels={},this._onKeyDown=e=>this._handleHotkeys(e)}static getInstance(){return Yt._instance||(Yt._instance=new Yt),Yt._instance}open(e={}){const t=String(e.src||"").trim();if(!t)return;if(this._ensureModal(),!this._modal||!this._video)return;const i=e?.playlist&&"object"==typeof e.playlist?e.playlist:null;if(this._labels=e?.labels&&"object"==typeof e.labels?e.labels:{},i?.tracks?.length){this._playlist=i.tracks;const e=this._playlist.findIndex(e=>String(e.src||"").trim()===t);this._currentIndex=e>=0?e:Number(i.currentIndex||0)}else this._playlist=[{src:t,title:String(e.title||"").trim()}],this._currentIndex=0;const s=String(e.defaultTitle||"").trim(),r=String(e.title||"").trim();this._title.textContent=r||s,this._syncNavigation(),this._video.src=t,this._video.load(),this._modal.show(),this._video.play().catch(()=>{})}close(){this._modal&&(this._modal.hide(),this._stop())}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const e={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},t=document.getElementById(this._modalId);if(t)return this._root=t,this._modal=he.getOrCreateInstance(t,e),this._bindElements(t),void this._bindEvents(t);this._modal=he.build(this._modalId,e,e=>{const t=e._element;this._root=t,t.classList.add("vg-filepreview-video-modal");const i=t.querySelector(".vg-modal-body"),s=t.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=t.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="";const n=document.createElement("div");n.className="vg-filepreview-video-modal__navigation",this._prevButton=document.createElement("button"),this._prevButton.type="button",this._prevButton.className="vg-filepreview-video-modal__nav-btn",this._prevButton.addEventListener("click",()=>this._goPrev()),this._nextButton=document.createElement("button"),this._nextButton.type="button",this._nextButton.className="vg-filepreview-video-modal__nav-btn",this._nextButton.addEventListener("click",()=>this._goNext()),n.appendChild(this._prevButton),n.appendChild(this._nextButton),this._video=document.createElement("video"),this._video.className="vg-filepreview-video-modal__video",this._video.controls=!0,this._video.preload="metadata",this._video.playsInline=!0,this._video.addEventListener("ended",()=>this._goNext(!0)),r.appendChild(this._title),r.appendChild(n),i.appendChild(this._video),this._bindEvents(t)})}_bindElements(e){this._title=e.querySelector(".vg-filepreview-video-modal__title"),this._video=e.querySelector(".vg-filepreview-video-modal__video")}_bindEvents(e){e&&!e.hasAttribute("data-vg-filepreview-video-bind")&&(e.setAttribute("data-vg-filepreview-video-bind","true"),document.addEventListener("keydown",this._onKeyDown),e.addEventListener("vg.modal.hidden",()=>{this._stop(),this._destroyModal()}))}_stop(){this._video&&(this._video.pause(),this._video.currentTime=0)}_destroyModal(){document.removeEventListener("keydown",this._onKeyDown),this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._prevButton=null,this._nextButton=null,this._video=null,this._playlist=[],this._currentIndex=-1,this._labels={}}_syncNavigation(){if(!this._prevButton||!this._nextButton)return;this._prevButton.textContent=this._labels.prev||"",this._nextButton.textContent=this._labels.next||"";const e=this._playlist.length>1;this._prevButton.disabled=!e,this._nextButton.disabled=!e}_goPrev(){this._playlist.length&&(this._currentIndex=this._currentIndex<=0?this._playlist.length-1:this._currentIndex-1,this._openCurrentTrack())}_goNext(e=!1){this._playlist.length&&(1!==this._playlist.length||e)&&(this._currentIndex=(this._currentIndex+1)%this._playlist.length,this._openCurrentTrack())}_openCurrentTrack(){const e=this._playlist[this._currentIndex];e?.src&&this.open({src:e.src,title:e.title||"",defaultTitle:e.title||"",playlist:{tracks:this._playlist,currentIndex:this._currentIndex},labels:this._labels})}_handleHotkeys(e){if(!this._root||!this._root.classList.contains("show"))return;const t=String(e?.target?.tagName||"").toUpperCase();["INPUT","TEXTAREA","SELECT"].includes(t)||("ArrowLeft"===e.key&&(e.preventDefault(),this._goPrev()),"ArrowRight"===e.key&&(e.preventDefault(),this._goNext()))}}const Xt=Yt,Zt=e=>{const t=e?.getAttribute("data-vg-filepreview")||"";return String(t).trim()},Jt=e=>{try{return new URL(e,window.location.origin).href}catch{return""}},Qt=(e,t="")=>{const i=e?.querySelector(".name"),s=String(i?.textContent||"").trim();if(s)return s;const r=String(t).split("/").pop()||"";return decodeURIComponent(r)},ei=e=>{const t=e?.querySelector(".original_name");return String(t?.textContent||"").trim()},ti=new Set([".mp4",".webm",".mov",".mkv",".avi",".m4v"]),ii=class{constructor(){this.name="video",this._modal=Xt.getInstance()}canRender(e={}){const t=String(e?.fileMeta?.ext||"").toLowerCase();return ti.has(t)}render(e={}){const t=e?.previewContainer,i=Boolean(e?.ui?.nameOnly),s=e?.i18n,r=e?.fileUrl?.href||e?.filePath||"";if(!r)return!1;const n={prev:s?.button("prev")||"",next:s?.button("next")||""},a=t=>{t&&t.preventDefault();const i=((e,t=()=>!0)=>{const i=Array.from(document.querySelectorAll('[data-vg-filepreview][data-vg-filepreview-valid="true"]')).map(e=>{const t=Zt(e),i=Jt(t),s=(e=>{if(!e)return"";const t=String(e).split("#")[0].split("?")[0].split("/").pop()||"";return t.includes(".")?`.${String(t.split(".").pop()||"").toLowerCase()}`:""})(t);return{element:e,path:t,src:i,ext:s,title:Qt(e,t),subtitle:ei(e)}}).filter(e=>e.src&&t(e.ext)),s=Jt(Zt(e)),r=i.findIndex(e=>e.src===s);return{tracks:i,currentIndex:r>=0?r:0}})(e?.element,e=>ti.has(e));this._modal.open({src:r,title:e?.fileMeta?.name||s?.message("video_title")||"",defaultTitle:s?.message("video_title")||"",playlist:i,labels:n})},o=e?.element?.querySelector(".name");if(o&&!o.hasAttribute("data-vg-filepreview-video-bind")&&(o.setAttribute("data-vg-filepreview-video-bind","true"),o.classList.add("is-preview-action"),o.addEventListener("click",a)),i)return Boolean(o);if(!t)return!1;const l=document.createElement("button");return l.type="button",l.className="vg-filepreview-video-trigger",l.textContent=s?.button("open_video")||"",l.addEventListener("click",a),t.appendChild(l),!0}};class si{constructor(){this._modalId="vg-filepreview-zip-modal",this._abortController=null,this._labels={},this._entries=[],this._arrayBuffer=null}static getInstance(){return si._instance||(si._instance=new si),si._instance}open(e={}){const t=String(e.src||"").trim();if(!t)return;if(this._ensureModal(),!this._modal||!this._content)return;this._labels=e?.labels&&"object"==typeof e.labels?e.labels:{};const i=String(e.defaultTitle||"").trim(),s=String(e.title||"").trim();this._title.textContent=s||i,this._content.innerHTML=`<div class="vg-filepreview-zip-modal__loading">${this._escapeHtml(this._label("loadingArchive"))}</div>`,this._modal.show(),this._loadZipEntries(t)}close(){this._modal&&this._modal.hide()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const e={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"800px"},animation:{enable:!1}},t=document.getElementById(this._modalId);if(t)return this._root=t,this._modal=he.getOrCreateInstance(t,e),this._bindElements(t),void this._bindLifecycle(t);this._modal=he.build(this._modalId,e,e=>{const t=e._element;this._root=t,t.classList.add("vg-filepreview-zip-modal");const i=t.querySelector(".vg-modal-body"),s=t.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=t.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="",this._content=document.createElement("div"),this._content.className="vg-filepreview-zip-modal__content",r.appendChild(this._title),i.appendChild(this._content),this._bindLifecycle(t)})}_bindElements(e){this._title=e.querySelector(".vg-filepreview-zip-modal__title"),this._content=e.querySelector(".vg-filepreview-zip-modal__content")}_bindLifecycle(e){e&&!e.hasAttribute("data-vg-filepreview-zip-lifecycle-bind")&&(e.setAttribute("data-vg-filepreview-zip-lifecycle-bind","true"),e.addEventListener("vg.modal.hidden",()=>{this._destroyModal()}))}_loadZipEntries(e){this._abortController&&this._abortController.abort(),this._abortController=new AbortController;const t=si._cache.get(e);if(t?.entries&&t?.arrayBuffer)return this._entries=t.entries,this._arrayBuffer=t.arrayBuffer,void this._renderEntries(this._entries);fetch(e,{method:"GET",signal:this._abortController.signal}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.arrayBuffer()}).then(t=>{const i=this._parseZipEntries(t);this._entries=i,this._arrayBuffer=t,si._cache.set(e,{entries:i,arrayBuffer:t}),this._renderEntries(i)}).catch(e=>{if("AbortError"!==e?.name&&this._content){const t=this._resolveErrorText(e);this._content.innerHTML=`<div class="vg-filepreview-zip-modal__error">${this._escapeHtml(this._label("cannotOpenArchive"))}: ${this._escapeHtml(t)}</div>`}})}_destroyModal(){this._abortController&&(this._abortController.abort(),this._abortController=null),this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._content=null,this._labels=null,this._entries=[],this._arrayBuffer=null}_parseZipEntries(e){const t=new DataView(e),i=t.byteLength;if(i<22)throw new Error("invalid_zip");const s=this._findEndOfCentralDirectory(t);if(s<0)throw new Error("central_directory_not_found");const r=t.getUint16(s+10,!0),n=t.getUint32(s+16,!0),a=new TextDecoder("utf-8",{fatal:!1}),o=[];let l=n;for(let s=0;s<r&&!(l+46>i)&&33639248===t.getUint32(l,!0);s+=1){const s=t.getUint32(l+20,!0),r=t.getUint32(l+24,!0),n=t.getUint16(l+10,!0),h=t.getUint16(l+28,!0),d=t.getUint16(l+30,!0),c=t.getUint16(l+32,!0),_=t.getUint32(l+42,!0),u=l+46,m=u+h;if(m>i)break;const p=new Uint8Array(e,u,h),g=a.decode(p);o.push({name:g,compressedSize:s,uncompressedSize:r,compressionMethod:n,localHeaderOffset:_,isDirectory:g.endsWith("/")}),l=m+d+c}return o}_findEndOfCentralDirectory(e){const t=Math.max(0,e.byteLength-65557);for(let i=e.byteLength-22;i>=t;i-=1)if(101010256===e.getUint32(i,!0))return i;return-1}_renderEntries(e){if(!this._content)return;if(!e.length)return void(this._content.innerHTML=`<div class="vg-filepreview-zip-modal__empty">${this._escapeHtml(this._label("archiveEmptyUnsupported"))}</div>`);const t=e.map((e,t)=>{const i=e.isDirectory?this._label("typeDir"):this._label("typeFile"),s=e.isDirectory?"-":this._formatSize(e.compressedSize),r=e.isDirectory?"-":this._formatSize(e.uncompressedSize),n=!e.isDirectory&&this._canPreviewEntry(e)?`<button type="button" class="vg-filepreview-zip-modal__entry-btn" data-entry-index="${t}">${this._escapeHtml(this._label("previewEntry"))}</button>`:"-";return`\n<tr>\n\t<td>${t+1}</td>\n\t<td class="name">${this._escapeHtml(e.name)}</td>\n\t<td>${i}</td>\n\t<td>${s}</td>\n\t<td>${r}</td>\n\t<td>${n}</td>\n</tr>`}).join("");this._content.innerHTML=`\n<table class="vg-filepreview-zip-modal__table">\n\t<thead>\n\t\t<tr>\n\t\t\t<th>#</th>\n\t\t\t<th>${this._escapeHtml(this._label("tableName"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tableType"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tablePacked"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tableSize"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tablePreview"))}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t${t}\n\t</tbody>\n</table>`,this._bindEntriesPreview()}_label(e,t=""){const i=this._labels?.[e];return"string"==typeof i&&i.trim()?i:t}_resolveErrorText(e){const t=String(e?.message||"").trim();return t?"invalid_zip"===t?this._label("invalidZip"):"central_directory_not_found"===t?this._label("centralDirectoryNotFound"):t:this._label("unknownError")}_formatSize(e){if(!Number.isFinite(e)||e<0)return"-";const t=["B","KB","MB","GB"];let i=e,s=0;for(;i>=1024&&s<t.length-1;)i/=1024,s+=1;const r=i>=100||0===s?0:2;return`${i.toFixed(r)} ${t[s]}`}_escapeHtml(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}_bindEntriesPreview(){this._content&&!this._content.hasAttribute("data-vg-filepreview-zip-preview-bind")&&(this._content.setAttribute("data-vg-filepreview-zip-preview-bind","true"),this._content.addEventListener("click",e=>{const t=e.target.closest("[data-entry-index]");if(!t)return;e.preventDefault();const i=Number(t.getAttribute("data-entry-index"));!Number.isFinite(i)||i<0||i>=this._entries.length||this._previewEntry(i)}))}_canPreviewEntry(e){if(!e||e.isDirectory||!e.name)return!1;const t=this._extractExtension(e.name);return new Set([".txt",".md",".json",".xml",".yml",".yaml",".csv",".log",".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"]).has(t)}async _previewEntry(e){if(!this._content)return;const t=this._entries[e];if(!t||!this._canPreviewEntry(t))return;let i=this._content.querySelector(".vg-filepreview-zip-modal__entry-preview");i||(i=document.createElement("div"),i.className="vg-filepreview-zip-modal__entry-preview",this._content.appendChild(i)),i.innerHTML=`<div class="vg-filepreview-zip-modal__entry-preview-loading">${this._escapeHtml(this._label("loadingEntry"))}</div>`;try{const e=await this._extractEntryBytes(t),s=this._extractExtension(t.name);if(this._isImageExtension(s)){const r=new Blob([e.buffer],{type:this._mimeByExtension(s)}),n=URL.createObjectURL(r);return i.innerHTML=`\n<div class="vg-filepreview-zip-modal__entry-preview-title">${this._escapeHtml(t.name)}</div>\n<img class="vg-filepreview-zip-modal__entry-preview-image" src="${n}" alt="${this._escapeHtml(t.name)}" />`,void setTimeout(()=>URL.revokeObjectURL(n),2e3)}const r=new TextDecoder("utf-8",{fatal:!1}).decode(e),n=this._escapeHtml(r||this._label("emptyFileInArchive"));i.innerHTML=`\n<div class="vg-filepreview-zip-modal__entry-preview-title">${this._escapeHtml(t.name)}</div>\n<pre class="vg-filepreview-zip-modal__entry-preview-text">${n}</pre>`}catch(e){i.innerHTML=`<div class="vg-filepreview-zip-modal__entry-preview-error">${this._escapeHtml(this._label("cannotPreviewEntry"))}: ${this._escapeHtml(e?.message||this._label("unknownError"))}</div>`}}async _extractEntryBytes(e){if(!this._arrayBuffer)throw new Error(this._label("archiveBufferMissing"));const t=new DataView(this._arrayBuffer),i=Number(e.localHeaderOffset||0);if(i+30>t.byteLength)throw new Error(this._label("entryCorrupted"));if(67324752!==t.getUint32(i,!0))throw new Error(this._label("entryCorrupted"));const s=i+30+t.getUint16(i+26,!0)+t.getUint16(i+28,!0),r=s+Number(e.compressedSize||0);if(r>t.byteLength)throw new Error(this._label("entryCorrupted"));const n=new Uint8Array(this._arrayBuffer.slice(s,r)),a=Number(e.compressionMethod||0);if(0===a)return n;if(8===a){if("undefined"==typeof DecompressionStream)throw new Error(this._label("deflateNotSupported"));const e=new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw")),t=await new Response(e).arrayBuffer();return new Uint8Array(t)}throw new Error(this._label("compressionNotSupported"))}_extractExtension(e){const t=String(e||"").toLowerCase().split("/").pop()||"";return t.includes(".")?`.${t.split(".").pop()||""}`:""}_isImageExtension(e){return new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"]).has(e)}_mimeByExtension(e){return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp"}[e]||"application/octet-stream"}}si._cache=new Map;const ri=si,ni=new Set([".zip"]),ai=class{constructor(){this.name="zip",this._modal=ri.getInstance()}canRender(e={}){const t=String(e?.fileMeta?.ext||"").toLowerCase();return ni.has(t)}render(e={}){const t=e?.previewContainer,i=Boolean(e?.ui?.nameOnly),s=e?.i18n,r=e?.fileUrl?.href||e?.filePath||"";if(!r)return!1;const n=t=>{t&&t.preventDefault(),this._modal.open({src:r,title:e?.fileMeta?.name||s?.message("archive_title")||"",defaultTitle:s?.message("archive_title")||"",labels:{loadingArchive:s?.message("loading_archive")||"",cannotOpenArchive:s?.message("cannot_open_archive")||"",unknownError:s?.message("unknown_error")||"",invalidZip:s?.message("invalid_zip")||"",centralDirectoryNotFound:s?.message("central_directory_not_found")||"",archiveEmptyUnsupported:s?.message("archive_empty_unsupported")||"",typeDir:s?.message("archive_type_dir")||"",typeFile:s?.message("archive_type_file")||"",tableName:s?.message("archive_table_name")||"",tableType:s?.message("archive_table_type")||"",tablePacked:s?.message("archive_table_packed")||"",tableSize:s?.message("archive_table_size")||"",tablePreview:s?.message("archive_table_preview")||"",previewEntry:s?.button("preview")||"",loadingEntry:s?.message("loading_entry")||"",cannotPreviewEntry:s?.message("cannot_preview_entry")||"",deflateNotSupported:s?.message("deflate_not_supported")||"",compressionNotSupported:s?.message("compression_not_supported")||"",entryCorrupted:s?.message("entry_corrupted")||"",archiveBufferMissing:s?.message("archive_buffer_missing")||"",emptyFileInArchive:s?.message("empty_file")||""}})},a=e?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-zip-bind")&&(a.setAttribute("data-vg-filepreview-zip-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!t)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-zip-trigger",o.textContent=s?.button("open_archive")||"",o.addEventListener("click",n),t.appendChild(o),!0}},oi=new Set(["ru","en"]),li=(e,t="ru")=>{const i=String(e||"").trim().toLowerCase();if(!i)return t;const s=i.split("-")[0];return oi.has(s)?s:t};class hi extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({validate:!0,lang:"ru",ui:{nameOnly:!1},preview:{audio:{enable:!0},video:{enable:!0},image:{enable:!0},archive:{enable:!0},text:{enable:!0},office:{enable:!0},pdf:{enable:!0}}},t)),this._filePath="",this._fileUrl=null,this._isValid=!1,this._fileMeta={},this._fields=[],this._editableFields={},this._helper=new St(this._element),this._renderers=[new Nt,new ii,new qt,new Rt,new ai,new Gt],this._lang=((e,t)=>{const i=li(e,"");if(i)return i;const s=li(t?.getAttribute("lang"),"");if(s)return s;const r=li(t?.closest("[lang]")?.getAttribute("lang"),"");if(r)return r;const n=li(document?.documentElement?.getAttribute("lang"),"");return n||(li(window?.navigator?.language,"")||"ru")})(this._params.lang,this._element),this._i18n=((e="ru")=>{const t=li(e,"ru"),i=Re(t,"filepreview")||{},s=Be(t,"filepreview")||{};return{lang:t,message:(e,t="")=>i[e]||t,button:(e,t="")=>s[e]||t}})(this._lang),this._inlineAudio=null,this._inlineAudioSrc="",this._inlineAudioButton=null,this._inlineAudioIcon=null,this._inlineAudioContainer=null,this._audioMetaPromise=null,this._audioMetaApplied=!1,this._audioCoverObjectUrl="",this._videoMetaPromise=null,this._videoMetaApplied=!1,this._videoCoverObjectUrl="",this._imageModal=null,this.init()}static get NAME(){return"filepreview"}static get NAME_KEY(){return"vg.filepreview"}get filePath(){return this._filePath}get fileUrl(){return this._fileUrl}get isValid(){return this._isValid}get fileMeta(){return this._fileMeta}get fields(){return this._fields}get editableFields(){return this._editableFields}init(){const e=this._helper.getFilePath();if(this._filePath=e,this._params.validate){const t=this._helper.validateFilePath(e);this._isValid=t.isValid,this._fileUrl=t.fileUrl}else this._isValid=!0,this._fileUrl=null;return this._helper.syncState(this._isValid),!!this._isValid&&(this._fileMeta=this._helper.getFileMeta(this._filePath),this.preview())}preview(){return this._setState("loading"),this._fields=this._helper.getFields(),this._editableFields=this._helper.resolveEditableFields(this._fields),this._helper.syncEditableFields(this._editableFields),this._renderIcon(),this._renderTextFields(),this._renderDownloadField(),this._enrichVideoMetadata(),this._renderPreview(),this._editableFields}_renderIcon(){const e=this._editableFields.icon;if(!e)return;const t=this._getImageIconSrc();if(t){e.innerHTML="";const i=document.createElement("img");return i.src=t,i.alt=this._fileMeta?.originalName||this._fileMeta?.name||"",i.className="vg-filepreview-icon-image",i.loading="lazy",i.addEventListener("error",()=>{this._renderDefaultIcon(e)}),this._isPreviewGroupEnabled("image")&&this._bindIconImageToModal(i,t),void e.appendChild(i)}this._renderDefaultIcon(e)}_renderTextFields(){const e=this._getDisplayName(),t=this._getFileName(),i=this._hasDataDrivenDisplayName(),s=this._editableFields.name;s&&(this._isAudioFile()&&this._isPreviewGroupEnabled("audio")?(this._renderAudioNameField(s),this._element.setAttribute("data-vg-filepreview-renderer","audio")):e&&(s.classList.remove("vg-filepreview-audio-inline"),s.textContent=e,this._applyNameClampStyles(s)));const r=this._editableFields.ext;r&&this._fileMeta.ext&&(r.textContent=this._fileMeta.ext);const n=this._editableFields.size;n&&this._fileMeta.sizeText&&(n.textContent=this._fileMeta.sizeText);const a=this._editableFields.original_name;if(a)return i&&t?(a.textContent=t,void this._applyNameClampStyles(a)):this._fileMeta.originalName?(a.textContent=this._fileMeta.originalName,void this._applyNameClampStyles(a)):void(this._fileMeta.isMedia&&(a.textContent=""))}_renderAudioNameField(e){const t=this._getDisplayName();if(!t)return;e.innerHTML="",e.classList.add("vg-filepreview-audio-inline");const i=document.createElement("button");i.type="button",i.className="vg-filepreview-audio-inline__toggle",i.setAttribute("aria-label","Play/Pause");const s=document.createElement("span");s.className="vg-filepreview-audio-inline__icon",i.appendChild(s);const r=document.createElement("span");r.className="vg-filepreview-audio-inline__name",r.textContent=t,this._applyNameClampStyles(r),r.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this._toggleInlineAudio()}),i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this._toggleInlineAudio()}),e.appendChild(i),e.appendChild(r),this._inlineAudioButton=i,this._inlineAudioIcon=s;const n=this._element?.classList?.contains("file")?this._element:this._element?.closest?.(".file");this._inlineAudioContainer=n||this._element||e,this._setInlineAudioProgress(0);const a=hi._activeAudioOwner===this&&this._inlineAudio&&!this._inlineAudio.paused;this._syncInlineAudioIcon(a),this._enrichAudioMetadata(r)}_toggleInlineAudio(){if(!this._isPreviewGroupEnabled("audio"))return;const e=this._fileUrl?.href||this._filePath||"";e&&this._inlineAudioButton&&(hi._activeAudioOwner&&hi._activeAudioOwner!==this&&hi._activeAudioOwner._stopInlineAudio(),this._inlineAudio&&this._inlineAudioSrc===e||(this._stopInlineAudio(),this._inlineAudio=new Audio(e),this._inlineAudioSrc=e,this._inlineAudio.addEventListener("ended",()=>{this._syncInlineAudioIcon(!1),this._setInlineAudioProgress(0)}),this._inlineAudio.addEventListener("timeupdate",()=>this._syncInlineAudioProgress()),this._inlineAudio.addEventListener("loadedmetadata",()=>this._syncInlineAudioProgress())),this._inlineAudio.paused?this._inlineAudio.play().then(()=>{hi._activeAudioOwner=this,this._syncInlineAudioIcon(!0)}).catch(()=>{this._syncInlineAudioIcon(!1)}):(this._inlineAudio.pause(),this._syncInlineAudioIcon(!1),hi._activeAudioOwner===this&&(hi._activeAudioOwner=null)))}_stopInlineAudio(){if(!this._inlineAudio)return this._syncInlineAudioIcon(!1),void this._setInlineAudioProgress(0);this._inlineAudio.pause(),this._inlineAudio.currentTime=0,this._syncInlineAudioIcon(!1),this._setInlineAudioProgress(0),hi._activeAudioOwner===this&&(hi._activeAudioOwner=null)}_syncInlineAudioIcon(e){this._inlineAudioIcon&&(this._inlineAudioIcon.innerHTML=e?(0,f.z)("pause")||"":(0,f.z)("play")||"")}_syncInlineAudioProgress(){if(!this._inlineAudio)return void this._setInlineAudioProgress(0);const e=Number(this._inlineAudio.duration||0),t=Number(this._inlineAudio.currentTime||0);if(!e||!Number.isFinite(e)||e<=0)return void this._setInlineAudioProgress(0);const i=Math.max(0,Math.min(100,t/e*100));this._setInlineAudioProgress(i)}_setInlineAudioProgress(e){if(!this._inlineAudioContainer)return;const t=Math.max(0,Math.min(100,Number(e)||0));this._inlineAudioContainer.style.setProperty("--vg-filepreview-audio-inline-progress",`${t}%`)}_renderDownloadField(){const e=this._editableFields.download;if(!e)return;const t=this._i18n?.button("download")||"",i=(0,f.z)("download")||"",s=String(e.tagName||"").toUpperCase();let r=null;if("A"===s||"BUTTON"===s?r=e:(r=e.querySelector("[data-vg-filepreview-download-control]"),r||(r=document.createElement("button"),r.type="button",e.innerHTML="",e.appendChild(r))),r.classList.add("vg-filepreview-download-trigger"),r.setAttribute("data-vg-filepreview-download-control","true"),"A"===s&&r===e?(r.setAttribute("href",this._fileUrl?.href||this._filePath||"#"),this._fileMeta?.name&&r.setAttribute("download",this._fileMeta.name)):"BUTTON"===String(r.tagName||"").toUpperCase()&&r.setAttribute("type","button"),!r.hasAttribute("data-vg-filepreview-download-content-init")){if(r.setAttribute("data-vg-filepreview-download-content-init","true"),r.innerHTML="",i){const e=document.createElement("span");e.className="vg-filepreview-download-trigger__icon",e.innerHTML=i,r.appendChild(e)}if(t){const e=document.createElement("span");e.className="vg-filepreview-download-trigger__text",e.textContent=t,r.appendChild(e)}}r.hasAttribute("data-vg-filepreview-download-bind")||(r.setAttribute("data-vg-filepreview-download-bind","true"),r.addEventListener("click",e=>{e.preventDefault(),this._downloadFile()}))}_downloadFile(){const e=this._fileUrl?.href||this._filePath||"";if(!e)return;const t=this._fileMeta?.originalName||this._fileMeta?.name||"file";fetch(e,{method:"GET",credentials:"same-origin"}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(e=>{const i=URL.createObjectURL(e);this._downloadByLink(i,t),setTimeout(()=>URL.revokeObjectURL(i),1e3)}).catch(()=>{this._downloadByLink(e,t)})}_downloadByLink(e,t){const i=document.createElement("a");i.href=e,i.style.display="none",i.rel="noopener noreferrer",t&&i.setAttribute("download",t),document.body.appendChild(i),i.click(),document.body.removeChild(i)}_enrichAudioMetadata(e=null){if(this._audioMetaApplied||this._audioMetaPromise||!this._isAudioFile())return;const t=this._fileUrl?.href||this._filePath||"";t&&(this._audioMetaPromise=this._createAudioFileFromSource(t).then(e=>e?Mt(e):null).then(t=>{if(!t)return!1;let i=!1;const s=String(t.title||"").trim();if(s){this._element.setAttribute("data-vg-filepreview-display-name",s),e&&(e.textContent=s,this._applyNameClampStyles(e));const t=this._editableFields?.original_name;t&&(t.textContent=this._getFileName(),this._applyNameClampStyles(t)),i=!0}if(t.pictureBlob instanceof Blob&&this._editableFields?.icon){this._audioCoverObjectUrl&&URL.revokeObjectURL(this._audioCoverObjectUrl),this._audioCoverObjectUrl=URL.createObjectURL(t.pictureBlob);const e=this._editableFields.icon;e.innerHTML="";const r=document.createElement("img");r.src=this._audioCoverObjectUrl,r.alt=s||this._fileMeta?.originalName||this._fileMeta?.name||"",r.className="vg-filepreview-icon-image",r.loading="lazy",r.addEventListener("error",()=>{this._renderDefaultIcon(e)}),this._bindIconImageToModal(r,this._audioCoverObjectUrl,s),e.appendChild(r),i=!0}return this._audioMetaApplied=!0,i}).catch(()=>!1).finally(()=>{this._audioMetaPromise=null}))}_enrichVideoMetadata(){if(!this._isPreviewGroupEnabled("video"))return;if(this._videoMetaApplied||this._videoMetaPromise||!this._isVideoFile())return;const e=this._fileUrl?.href||this._filePath||"";e&&(this._videoMetaPromise=this._createMediaFileFromSource(e,this._fileMeta?.originalName||this._fileMeta?.name||"video.mp4","video/mp4").then(e=>e?(async e=>{if(!(e instanceof File))return null;const t=(e=>{const t=String(e?.name||"").toLowerCase(),i=t.lastIndexOf(".");return i<0||i>=t.length-1?"":t.slice(i+1)})(e);if(!String(e.type||"").toLowerCase().startsWith("video/")&&!Dt.has(t))return null;if(!e.size)return null;let i="";try{i=URL.createObjectURL(e);const t=document.createElement("video");t.preload="metadata",t.muted=!0,t.playsInline=!0,t.crossOrigin="anonymous",t.src=i,await(s=t,r="loadedmetadata",new Promise((e,t)=>{const i=()=>{a(),e(!0)},n=()=>{a(),t(new Error(r))},a=()=>{s.removeEventListener(r,i),s.removeEventListener("error",n)};s.addEventListener(r,i,{once:!0}),s.addEventListener("error",n,{once:!0})}));const n=Number(t.videoWidth||0),a=Number(t.videoHeight||0),o=Number(t.duration||0);if(!(n&&a&&Number.isFinite(n)&&Number.isFinite(a)))return{duration:Number.isFinite(o)?o:0,width:0,height:0};const l=o>1?Math.min(1,Math.max(0,o/2)):0;await((e,t)=>new Promise((i,s)=>{const r=()=>{a(),i(!0)},n=()=>{a(),s(new Error("seek"))},a=()=>{e.removeEventListener("seeked",r),e.removeEventListener("error",n)};e.addEventListener("seeked",r,{once:!0}),e.addEventListener("error",n,{once:!0}),e.currentTime=t}))(t,l);const h=document.createElement("canvas");h.width=n,h.height=a;const d=h.getContext("2d");if(!d)return{duration:Number.isFinite(o)?o:0,width:n,height:a};d.drawImage(t,0,0,n,a);const c=await((e,t="image/jpeg",i=.92)=>new Promise(s=>{e.toBlob(e=>s(e||null),t,i)}))(h,"image/jpeg",.92);return{duration:Number.isFinite(o)?o:0,width:n,height:a,posterBlob:c||null}}catch{return null}finally{i&&URL.revokeObjectURL(i)}var s,r})(e):null).then(e=>{if(!(e&&e.posterBlob instanceof Blob&&this._editableFields?.icon))return!1;this._videoCoverObjectUrl&&URL.revokeObjectURL(this._videoCoverObjectUrl),this._videoCoverObjectUrl=URL.createObjectURL(e.posterBlob);const t=this._editableFields.icon;t.innerHTML="";const i=document.createElement("img");return i.src=this._videoCoverObjectUrl,i.alt=this._fileMeta?.originalName||this._fileMeta?.name||"",i.className="vg-filepreview-icon-image",i.loading="lazy",i.addEventListener("error",()=>{this._renderDefaultIcon(t)}),this._isPreviewGroupEnabled("video")&&this._bindIconImageToModal(i,this._videoCoverObjectUrl,i.alt),t.appendChild(i),this._videoMetaApplied=!0,!0}).catch(()=>!1).finally(()=>{this._videoMetaPromise=null}))}async _createAudioFileFromSource(e=""){const t=this._fileMeta?.originalName||this._fileMeta?.name||"audio.mp3";return this._createMediaFileFromSource(e,t,"audio/mpeg")}async _createMediaFileFromSource(e="",t="file",i="application/octet-stream"){try{const s=await fetch(e,{method:"GET",credentials:"same-origin"});if(!s.ok)return null;const r=await s.blob();return r&&r.size?new File([r],t,{type:r.type||i,lastModified:Date.now()}):null}catch{return null}}_bindIconImageToModal(e,t="",i=""){if(!e)return;const s=String(t||"").trim();if(!s)return;const r=String(i||this._fileMeta?.originalName||this._fileMeta?.name||"").trim();e.setAttribute("data-vg-filepreview-image-modal-src",s),e.setAttribute("data-vg-filepreview-image-modal-title",r),e.classList.add("is-preview-action"),e.hasAttribute("data-vg-filepreview-image-modal-bind")||(e.setAttribute("data-vg-filepreview-image-modal-bind","true"),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const i=String(e.getAttribute("data-vg-filepreview-image-modal-src")||"").trim();if(!i)return;const s=String(e.getAttribute("data-vg-filepreview-image-modal-title")||"").trim();this._imageModal||(this._imageModal=Ot.getInstance()),this._imageModal.open({src:i,title:s,defaultTitle:this._i18n?.message("image_title")||""})}))}_renderPreview(){const e=Boolean(this._params?.ui?.nameOnly)||!this._shouldRenderPreviewForCurrentFile(),t=this._resolvePreviewContainer({autoCreate:!e});if(!t&&!e)return void this._setState("error");t&&(t.innerHTML="");const i={element:this._element,filePath:this._filePath,fileUrl:this._fileUrl,fileMeta:this._fileMeta,previewContainer:t,lang:this._lang,i18n:this._i18n,ui:this._params?.ui||{}};let s=!1;if(this._renderers.forEach(e=>{if(!s&&"function"==typeof e?.canRender&&"function"==typeof e?.render&&this._isRendererEnabled(e?.name)&&e.canRender(i)){try{s=!0===e.render(i)}catch(e){s=!1}s&&this._element.setAttribute("data-vg-filepreview-renderer",e.name||"custom")}}),!s&&!e)return this._element.removeAttribute("data-vg-filepreview-renderer"),void this._setState("empty");this._setState("ready")}_resolvePreviewContainer(e={}){if(Object.prototype.hasOwnProperty.call(e,"autoCreate")&&!Boolean(e.autoCreate)){const e=this._editableFields.preview||this._element.querySelector('[data-vg-filepreview-slot="preview"]');return e&&(e.innerHTML="",e.classList.remove("preview"),e.setAttribute("hidden","hidden"),e.setAttribute("aria-hidden","true")),null}const t=this._editableFields.preview;if(t)return t.classList.add("preview"),t.removeAttribute("hidden"),t.removeAttribute("aria-hidden"),t.setAttribute("data-vg-filepreview-slot","preview"),t;const i=this._element.querySelector('[data-vg-filepreview-slot="preview"]');if(i)return i.classList.add("preview"),i.removeAttribute("hidden"),i.removeAttribute("aria-hidden"),this._editableFields.preview=i,i;const s=document.createElement("div");return s.className="preview",s.setAttribute("data-vg-filepreview-slot","preview"),this._element.appendChild(s),this._editableFields.preview=s,s}_shouldRenderPreviewForCurrentFile(){return this._isAudioFile()?this._isPreviewGroupEnabled("audio"):".pdf"===String(this._fileMeta?.ext||"").toLowerCase()?this._isPreviewGroupEnabled("pdf"):this._isVideoFile()?this._isPreviewGroupEnabled("video"):this._isImageFile()?this._isPreviewGroupEnabled("image"):this._isOfficeFile()?this._isPreviewGroupEnabled("office"):this._isArchiveFile()?this._isPreviewGroupEnabled("archive"):!!this._isTextFile()&&this._isPreviewGroupEnabled("text")}_isRendererEnabled(e=""){const t={image:"image",video:"video",pdf:"pdf",office:"office",zip:"archive",text:"text"}[String(e||"").trim()];return!t||this._isPreviewGroupEnabled(t)}_isPreviewGroupEnabled(e=""){const t=String(e||"").trim();if(!t)return!1;const i=this._params?.preview;if(!i||"object"!=typeof i||Array.isArray(i))return!1;if(!Object.prototype.hasOwnProperty.call(i,t))return!1;const s=i[t];return"boolean"==typeof s?s:!(!s||"object"!=typeof s||Array.isArray(s))&&!!Object.prototype.hasOwnProperty.call(s,"enable")&&Boolean(s.enable)}_getImageIconSrc(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".avif",".ico"].includes(e)&&(this._fileUrl?.href||this._filePath)||""}_isImageFile(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".avif",".ico",".tif",".tiff",".heic",".heif"].includes(e)}_isOfficeFile(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".doc",".docx",".xls",".xlsx",".ppt",".pptx",".odt",".ods",".odp"].includes(e)}_isArchiveFile(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".zip"].includes(e)}_isTextFile(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".txt",".md",".csv",".json",".xml",".yml",".yaml",".log",".ini",".conf",".env"].includes(e)}_renderDefaultIcon(e){const t=(0,f.z)(this._filePath);e.innerHTML=t||""}_applyNameClampStyles(e){e&&e.style&&(e.style.minWidth="60px",e.style.maxWidth="100%",e.style.overflow="hidden",e.style.textOverflow="ellipsis",e.style.whiteSpace="nowrap")}static init(e,t={}){return hi.getOrCreateInstance(e,t)}static stopActiveInlineAudio(){const e=hi._activeAudioOwner;e&&"function"==typeof e._stopInlineAudio&&e._stopInlineAudio(),hi._activeAudioOwner=null}static stopActiveInlineAudioIfDetached(e=[]){const t=hi._activeAudioOwner;t&&t._element&&Array.isArray(e)&&e.length&&e.some(e=>!(!e||"function"!=typeof e.contains)&&(e===t._element||e.contains(t._element)))&&(t._stopInlineAudio(),hi._activeAudioOwner=null)}_setState(e=""){const t=String(e||"").trim();t?this._element.setAttribute("data-vg-filepreview-state",t):this._element.removeAttribute("data-vg-filepreview-state")}_isAudioFile(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".mp3",".wav",".ogg",".flac",".aac",".m4a",".opus",".wma"].includes(e)}_isVideoFile(){const e=String(this._fileMeta?.ext||"").toLowerCase();return[".mp4",".webm",".mov",".mkv",".avi",".m4v",".ogv"].includes(e)}_getFileName(){return String(this._fileMeta?.originalName||this._fileMeta?.name||"").trim()}_getDataDisplayName(){return String(this._element?.getAttribute("data-name")||"").trim()||String(this._element?.getAttribute("data-vg-filepreview-display-name")||"").trim()}_hasDataDrivenDisplayName(){const e=this._getDataDisplayName();if(!e)return!1;const t=this._getFileName();return!t||e!==t}_getDisplayName(){return this._getDataDisplayName()||this._getFileName()}}const di=hi;class ci extends e.A{constructor(e,t={},i={}){super(e,t),this._params=this._getParams(e,(0,r._v)(i,t)),this._params.init="init"in t&&t.init||this._params.init,this._params.init?(this._isInitialized=!0,this._tpl=(0,d.A)("dom"),this._files=[],this._errors=new Set,this._validationErrorsByKey=new Map,this._fileObjectUrls=new Map,this._audioMetaPromises=new Map,this._nodes={stat:s.A.find(`.${this._getClass("stat")}`,this._element),info:s.A.find(`.${this._getClass("info")}`,this._element),drop:s.A.find(`.${this._getClass("drop")}`,this._element)},this.template='<li data-file="" class="file"><div class="file-image"></div><div class="file-info"></div><div class="file-remove"></div></li>',this._onNativeInputChange=e=>this.change(e?.target),this._init()):this._isInitialized=!1}_getClass(e){return{stat:"vg-files-stat","stat-progress":"vg-files-stat-progress",info:"vg-files-info","info-list":"vg-files-info--list",drop:"vg-files-drop","drop-list":"vg-files-drop--list","drop-message":"vg-files-drop-message",errors:"vg-files-errors"}[e]||""}_applyRenameToIncomingFiles(e){const t=this._params?.rename;return t&&Array.isArray(e)&&e.length?e.map((e,i)=>{if(!e)return e;let s=null;if("function"==typeof t?s=t(e,i):!0===t&&(s=this._generateRenamedFileName(e?.name||"file",i)),!s||"string"!=typeof s||""===s.trim())return e;if(e.name===s)return e;try{const t=new File([e],s,{type:e.type||"application/octet-stream",lastModified:e.lastModified||Date.now()});return["id","src","image"].forEach(i=>{void 0!==e[i]&&Object.defineProperty(t,i,{value:e[i],writable:!0,enumerable:!0})}),t}catch(t){return e}}):e}_generateRenamedFileName(e,t){const i=String(e||"file"),s=i.lastIndexOf("."),r=s>0&&s<i.length-1,n=r?i.slice(0,s):i,a=r?i.slice(s+1):"",o=Date.now(),l=t+1,h=n.trim()||"file";return a?`${h}_${o}_${l}.${a}`:`${h}_${o}_${l}`}_init(){this._isInitialized&&(1===Number(this._params?.limits?.count)?(this._preventOriginalInputFromSubmit(!0),this._cleanupFakeInputs()):this._preventOriginalInputFromSubmit(),this._addEventListener())}change(e=null){const t=e?.files;if(!t?.length)return;const i=this._applyRenameToIncomingFiles(Array.from(t)),s=1===Number(this._params?.limits?.count);if(Boolean(this._params?.replace)&&s)return this.clear(!1),this.append(i,!0),this._revokeUrls(),this._cleanupFakeInputs(),this._params.prepend&&this._files.reverse(),void this.build();this._params.allowed?(this.clear(),this.append(i,!0),this.build()):(this.append(i,!1),this.build())}build(){this._updateStat(),this._params.ajax?(this._render.init()?this._render.init():this._renderUI(this._files),this._renderUI(this._files)):(this._renderUI(this._files),1===Number(this._params?.limits?.count)?this._cleanupFakeInputs():this._generateHiddenInputs(this._files))}append(e,t=!0){const i=this._applyRenameToIncomingFiles(Array.from(e));let s;return s=t?i:this._mergeFilesByOrder(i,this._files,Boolean(this._params.prepend)),this._files=this._filterFiles(s),this._syncSingleInputSubmission(),this._renderErrors(),this._enrichAudioMetadata(this._files),this._files}_mergeFilesByOrder(e=[],t=[],i=!1){const s=i?[...e,...t]:[...t,...e],r=new Set,n=[];return s.forEach(e=>{const t=this._getFileKey(e);r.has(t)||(r.add(t),n.push(e))}),n}_getFileKey(e){return`${e.name}-${e.size}-${e.type}`}_getFileCustomData(e){const t=e?.customData;return!t||"object"!=typeof t||Array.isArray(t)?{}:t}_toDataAttributeKey(e){return e?String(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase():""}_toDataAttributeValue(e){if(null==e||""===e)return null;if("object"==typeof e)try{return JSON.stringify(e)}catch(t){return String(e)}return e}_buildFileDataAttributes(e,t={}){const i={...t},s=this._getFileCustomData(e);return Object.entries(s).forEach(([e,t])=>{const s=this._toDataAttributeKey(e);if(!s)return;const r=`data-${s}`;if(Object.prototype.hasOwnProperty.call(i,r))return;const n=this._toDataAttributeValue(t);null!==n&&(i[r]=n)}),i}_filterFiles(e){this._errors.clear(),this._validationErrorsByKey.clear();const{count:t,sizes:i,total:s}=this._params.limits,r=1024*i*1024,n=1024*s*1024;let a=0,o=0;const l=[];for(const i of e){const e=new Set;t>0&&o>=t?this._errors.add("is-count"):(this._params.types.length&&!this._params.types.includes(i.type)&&e.add("is-types"),i.size>r&&e.add("is-sizes"),!e.size&&n>0&&a+i.size>n&&e.add("is-total-size"),l.push(i),e.size?(e.forEach(e=>this._errors.add(e)),this._validationErrorsByKey.set(this._getFileKey(i),e)):(o+=1,a+=i.size))}return l}_isFileValid(e){return!this._validationErrorsByKey.has(this._getFileKey(e))}_syncSingleInputSubmission(){if(1!==Number(this._params?.limits?.count))return;const e=this._files[0],t=!this._params.ajax&&(!e||this._isFileValid(e));this._preventOriginalInputFromSubmit(t)}_getFileValidationMessages(e){const t=this._validationErrorsByKey.get(this._getFileKey(e));if(!t?.size)return[];const i=Re(this._params.lang,"files")||this._getFallbackErrors();return Array.from(t,e=>i[e]||e)}_getFileValidationLabel(e){const t=this._getFileValidationMessages(e);return t.length?[this._getShortValidationFileName(e?.name),t.join(". ")].filter(Boolean).join(" — "):""}_getFullFileValidationLabel(e){const t=this._getFileValidationMessages(e);return t.length?[String(e?.name||"").trim(),t.join(". ")].filter(Boolean).join(" — "):""}_getShortValidationFileName(e){const t=String(e||"").trim();if(t.length<=24)return t;const i=t.lastIndexOf("."),s=i>0&&t.length-i<=10,r=s?t.slice(0,i):t,n=s?t.slice(i):"";return`${r.slice(0,5)}...${n}`}_decorateValidationItem(e,i){return this._isFileValid(i)||(t.x.add(e,"failing"),t.x.add(e,"validation-error")),e}_forgetFileValidation(e){e&&(this._validationErrorsByKey.delete(this._getFileKey(e)),this._errors.clear(),this._validationErrorsByKey.forEach(e=>{e.forEach(e=>this._errors.add(e))}),this._renderErrors())}_getSizes(e,t=!1){const i=t?this._files.reduce((e,t)=>e+t.size,0):e,s=["byte","kilobyte","megabyte","gigabyte"],r=i>0?Math.min(Math.floor(Math.log(i)/Math.log(1024)),s.length-1):0,n=i/Math.pow(1024,r);return new Intl.NumberFormat(this._params.lang,{style:"unit",unit:s[r],unitDisplay:"short",maximumFractionDigits:2}).format(n)}_cleanupErrors(){this._errors.clear();const e=s.A.find(`.${this._getClass("errors")}`,this._element);e&&e.remove()}_renderErrors(){if(!this._errors.size){const e=s.A.find(`.${this._getClass("errors")}`,this._element);return void(e&&e.remove())}const e=Re(this._params.lang,"files")||this._getFallbackErrors();let t=s.A.find(`.${this._getClass("errors")}`,this._element);if(t?t.innerHTML="":(t=this._tpl.div({class:this._getClass("errors")}),this._element.prepend(t)),this._validationErrorsByKey.size){const i=new Set;return this._files.forEach(e=>{const s=this._getFileValidationLabel(e);if(!s)return;const r=this._validationErrorsByKey.get(this._getFileKey(e));r?.forEach(e=>i.add(e));const n=this._getFullFileValidationLabel(e),a={class:"error-item"};n&&n!==s&&(a.title=n),t.append(this._tpl.span(a,s))}),void this._errors.forEach(s=>{if(i.has(s))return;const r=e[s]||s;t.append(this._tpl.span({class:"error-item"},r))})}this._errors.forEach(i=>{const s=e[i]||i;t.append(this._tpl.span({class:"error-item"},s))})}_getFallbackErrors(){const{count:e,sizes:t,total:i}=this._params.limits;return{"is-count":`Limit: ${e}`,"is-sizes":`Max size: ${t}MB`,"is-total-size":`Total max size: ${i}MB`,"is-types":`Allowed: ${this._params.types.join(", ")}`}}_renderUI(e){this._nodes.drop?this._renderUIDropList(e):this._nodes.info&&this._renderInfoList(e),this._renderUIStatusDropInfoAjax(this._files)}_parseTemplate(){const e=this._render,t='<li data-file="" class="file"><div class="file-image"></div><div class="file-custom"><div class="file-info"></div><div class="file-remove"></div></div></li>';let i=this.template||t;e&&e.bufferTemplate&&(i=e.bufferTemplate);const s=document.createElement("div");s.innerHTML=i;let r=s.firstElementChild;r||(s.innerHTML=t,r=s.firstElementChild);const n=r.className||"",a=n?n.split(" ").filter(e=>""!==e.trim()):[],o=r.childElementCount,l=[];for(let e=0;e<o;e++)l.push({index:e,element:r.children[e],className:r.children[e].className});return{children:l,template:i,liClasses:a,liClassName:n}}_renderUIDropList(e){if(!this._nodes.drop)return;let i=s.A.find(`.${this._getClass("drop-list")}`,this._nodes.drop);i||(i=this._tpl.ul([],{class:this._getClass("drop-list")}));const r=this._parseTemplate().children,n=this._parseTemplate().liClasses.filter(e=>"file"!==e),a=document.createDocumentFragment();e.forEach(e=>{let t=[...n];this._params.detach&&t.push("with-remove"),this._params.customButtons?.hideOnUploadState&&t.push("hide-custom-buttons-on-upload-state"),this._params.sortable.enabled&&t.push("with-sortable"),1===this._params.limits.count&&(t.push("single"),e.type.startsWith("image/")?t.push("single-image"):t.push("single-file"));let i=[];r.forEach(t=>{const s=this._renderTemplatePart(t.element,e,null,{isDrop:!0});s&&i.push(s)});const s=this._tpl.li(this._buildFileDataAttributes(e,{"data-name":e.name,"data-size":e.size??0,"data-id":e.id||"",class:"file "+t.join(" ")}),i);a.appendChild(this._decorateValidationItem(s,e))}),i.innerHTML="",i.appendChild(a);const o=s.A.find(`.${this._getClass("drop-message")}`,this._nodes.drop);o&&(e.length?t.x.add(o,"has-files"):t.x.remove(o,"has-files"),1===Number(this._params?.limits?.count)&&(e.length?t.x.remove(o,"show"):t.x.add(o,"show"))),this._nodes.drop.appendChild(i),t.x.add(this._nodes.drop,"active")}_renderInfoList(e){if(!this._nodes.info)return;let i=s.A.find(`.${this._getClass("info-list")}`,this._element);i||(i=this._tpl.ul([],{class:this._getClass("info-list")}),this._nodes.info.appendChild(i)),this._params.info||t.x.add(i,"list-row");const r=this._parseTemplate().children,n=this._parseTemplate().liClasses.filter(e=>"file"!==e),a=Array.from(i.children||[]),o=new Map;a.forEach(e=>{const t=this._getInfoNodeKey(e);t&&(e.hasAttribute("data-file-key")||e.setAttribute("data-file-key",t),o.set(t,e))});const l=[];if(e.forEach((e,t)=>{const i=this._getFileKey(e),s=this._getInfoItemSignature(e,t),a=o.get(i);if(a&&a.getAttribute("data-vg-info-signature")===s){const e=a.querySelector(".iteration");return e&&(e.textContent=`${t+1}.`),l.push(a),void o.delete(i)}a&&(di.stopActiveInlineAudioIfDetached([a]),a.remove());const h=this._createInfoListItem(e,t,r,n,i,s);l.push(h),o.delete(i)}),o.size){const e=Array.from(o.values());di.stopActiveInlineAudioIfDetached(e),e.forEach(e=>e.remove())}l.forEach(e=>{i.appendChild(e)}),this._initFilePreviewInInfo(i),e.length?t.x.add(this._nodes.info,"show"):t.x.remove(this._nodes.info,"show")}_getInfoItemSignature(e,t){const i=this._resolveDisplayName(e),s=this._resolveFilePreviewPath(e);return`${e?.id||""}|${e?.name||""}|${e?.size??0}|${e?.type||""}|${i}|${s}`}_getInfoNodeKey(e){if(!e||"function"!=typeof e.getAttribute)return"";const t=String(e.getAttribute("data-file-key")||"").trim();if(t)return t;const i=String(e.getAttribute("data-name")||"").trim(),s=String(e.getAttribute("data-size")||"").trim(),r=String(e.getAttribute("data-type")||"").trim();if(i&&s&&r)return`${i}-${s}-${r}`;const n=String(e.getAttribute("data-file")||"").trim();if(!n)return"";try{const e=JSON.parse(n),t=String(e?.name||"").trim(),i=String(e?.size??"").trim(),s=String(e?.type||"").trim();if(t&&i&&s)return`${t}-${i}-${s}`}catch{return""}return""}_createInfoListItem(e,t,i,s,r,n){let a=[...s];this._params.image&&a.push("with-image"),this._params.info&&a.push("with-info"),this._params.detach&&a.push("with-remove"),this._params.customButtons?.hideOnUploadState&&a.push("hide-custom-buttons-on-upload-state"),this._params.sortable.enabled&&a.push("with-sortable");const o=this._resolveFilePreviewPath(e),l=this._resolveDisplayName(e);let h=[];i.forEach(i=>{const s=this._renderTemplatePart(i.element,e,t);s&&h.push(s)});const d={"data-name":e.name,"data-size":e.size??0,"data-type":e.type||"","data-id":e.id||"","data-file-key":r,"data-vg-info-signature":n,class:"file "+a.join(" ")+" "};o&&(d["data-vg-filepreview"]=o,d["data-fields"]="name,size,download",d["data-original-name"]=e.name||"",d["data-vg-filepreview-display-name"]=l||e.name||"");const c=this._tpl.li(this._buildFileDataAttributes(e,d),h);return this._decorateValidationItem(c,e)}_renderTemplatePart(e,t,i=null,s={}){if(!e)return null;const{isDrop:r=!1}=s,n=e?.classList;if(n?.contains("file-image"))return this._renderUIImage(t);if(n?.contains("file-info"))return r?null:this._renderUIInfo(t,i);if(n?.contains("file-remove"))return this._wrapInFileCustom(this._renderUIDetach(t));const a=e.cloneNode(!0);return this._replaceTemplateSlot(a,".file-image",()=>this._renderUIImage(t)),this._replaceTemplateSlot(a,".file-info",()=>r?null:this._renderUIInfo(t,i)),this._replaceTemplateSlot(a,".file-remove",()=>this._renderUIDetach(t)),this._wrapInFileCustom(a)}_wrapInFileCustom(e){if(!e)return null;if(e.classList?.contains("file-custom"))return e;const t=document.createElement("div");return t.className="file-custom",t.appendChild(e),t}_replaceTemplateSlot(e,t,i){(e?.matches&&e.matches(t)?[e]:Array.from(e.querySelectorAll(t))).forEach(e=>{const t=i();t?e.replaceWith(t):e.remove()})}_renderUIDetach(e){if(this._params.detach)return this._tpl.div({class:"file-remove"},[this._setButtonElement(e)])}_renderUIInfo(e,t){if(this._params.info){const i=this._resolveDisplayName(e);return this._tpl.div({class:"file-info"},[this._tpl.span({class:"iteration"},`${t+1}.`),this._tpl.span({class:"name"},i),this._tpl.span({class:"size"},`[${this._getSizes(e.size)}]`),this._tpl.span({class:"download"},"")])}}_renderUIImage(e){const t=this._tpl.div({class:"file-image"}),i=e?.src||e?.image;if(i)return t.appendChild(this._tpl.img(i,e.name||"",{class:"file-preview"})),t;const s=this._getFileCustomData(e),r=String(s.audioCover||"").trim();if(r)return t.appendChild(this._tpl.img(r,this._resolveDisplayName(e),{class:"file-preview"})),t;if(e?.type&&e.type.startsWith("image/")){const i=this._getFileObjectUrl(e);return i?(t.appendChild(this._tpl.img(i,e.name,{class:"file-preview"})),t):t}const n=this._getIconByFileType(e);return t.appendChild(this._tpl.i({},n,{isHTML:!0})),t}_resolveDisplayName(e){const t=this._getFileCustomData(e);return String(t.audioTitle||"").trim()||String(e?.name||"").trim()}_getIconByFileType(e){return(0,f.z)(e)}_resolveFilePreviewPath(e){return String(e?.src||e?.image||"").trim()||this._getFileObjectUrl(e)}_getFileObjectUrl(e){if(!(e&&"undefined"!=typeof File&&e instanceof File))return"";const t=this._getFileKey(e);if(this._fileObjectUrls.has(t))return this._fileObjectUrls.get(t);const i=URL.createObjectURL(e);return this._fileObjectUrls.set(t,i),i}_isAudioFile(e){if(!e)return!1;if(String(e.type||"").toLowerCase().startsWith("audio/"))return!0;const t=String(e.name||"").toLowerCase();return/\.(mp3|m4a|aac|wav|ogg|flac|opus|wma)$/.test(t)}_setFileCustomDataValue(e,t,i){e&&t&&(e.customData&&"object"==typeof e.customData&&!Array.isArray(e.customData)||Object.defineProperty(e,"customData",{value:{},writable:!0,enumerable:!0}),e.customData[t]=i)}_enrichAudioMetadata(e=[]){if(!Array.isArray(e)||!e.length)return;const t=[];e.forEach(e=>{if(!this._isAudioFile(e))return;const i=this._getFileKey(e);if(this._audioMetaPromises.has(i))return;const s=this._getFileCustomData(e);if(s.audioTitle||s.audioCover)return;const r=Mt(e).then(t=>{if(!t)return!1;let s=!1;if(t.title&&(this._setFileCustomDataValue(e,"audioTitle",t.title),s=!0),t.pictureBlob){const r=`cover:${i}`;let n=this._fileObjectUrls.get(r);n||(n=URL.createObjectURL(t.pictureBlob),this._fileObjectUrls.set(r,n)),this._setFileCustomDataValue(e,"audioCover",n),s=!0}return s}).catch(()=>!1).then(e=>(this._audioMetaPromises.delete(i),e));this._audioMetaPromises.set(i,r),t.push(r)}),t.length&&Promise.allSettled(t).then(e=>{e.some(e=>"fulfilled"===e.status&&!0===e.value)&&this._files.length&&this._renderUI(this._files)})}_initFilePreviewInInfo(e){if(!this._nodes.info||!e)return;const t=this._params?.lang||document.documentElement.lang||"ru";(s.A.findAll("[data-vg-filepreview]",e)||[]).forEach(e=>{di.getOrCreateInstance(e,{lang:t,ui:{nameOnly:!0}})})}_updateStat(){if(!this._nodes.stat)return;const e=this._getSizes(this._files,!0),i=s.A.find(`.${this._getClass("stat")}-count`,this._nodes.stat);i&&(i.innerHTML=this._files.length?`${this._files.length}<span>[${e}]</span>`:""),this._files.length?t.x.add(this._nodes.stat,"show"):t.x.remove(this._nodes.stat,"show")}_generateHiddenInputs(e){this._cleanupFakeInputs();const i=document.createDocumentFragment(),r=t.p.get(s.A.find("label",this._element),"for")||"",n=s.A.findID(r,this._element)?.name||s.A.findID(r,this._element)?.dataset.originalName||"files[]",a=n.endsWith("[]")?n.slice(0,-2):n;1===Number(this._params?.limits?.count)||(e.filter(e=>this._isFileValid(e)).forEach((e,s)=>{const r=document.createElement("input");r.type="file",r.name=`${a}[${s}]`,r.dataset.vgFiles="generated",t.p.hide(r);const n=new DataTransfer;n.items.add(e),r.files=n.files,i.appendChild(r)}),this._element.appendChild(i))}_cleanupFakeInputs(){s.A.findAll('[data-vg-files="generated"]',this._element).forEach(e=>e.remove())}clear(e=!0){const i=[];if(this._nodes.info){const e=s.A.find(`.${this._getClass("info-list")}`,this._element);e?.children?.length&&i.push(...Array.from(e.children))}if(this._nodes.drop){const e=s.A.find(`.${this._getClass("drop-list")}`,this._element);e?.children?.length&&i.push(...Array.from(e.children))}if(i.length&&di.stopActiveInlineAudioIfDetached(i),this._revokeUrls(),e&&this._resetFileInput(),this._cleanupFakeInputs(),this._cleanupErrors(),this._validationErrorsByKey.clear(),this._files=[],this._nodes.info){t.x.remove(this._nodes.info,"show");const e=s.A.find(`.${this._getClass("info-list")}`,this._element);e&&(e.innerHTML="")}if(this._nodes.drop){const e=s.A.find(`.${this._getClass("drop-list")}`,this._element);e&&(e.innerHTML="");const i=s.A.find(`.${this._getClass("drop-message")}`,this._element);i&&(t.x.remove(i,"has-files"),1===Number(this._params?.limits?.count)&&t.x.add(i,"show")),t.x.remove(this._nodes.drop,"active")}this._nodes.stat&&t.x.remove(this._nodes.stat,"show")}_revokeUrls(){this._fileObjectUrls.forEach(e=>{URL.revokeObjectURL(e)}),this._fileObjectUrls.clear(),this._audioMetaPromises.clear()}_resetFileInput(){s.A.findAll('[data-vg-toggle="files"]',this._element).forEach(e=>e.value="")}_preventOriginalInputFromSubmit(e=!1){const t=s.A.find('[data-vg-toggle="files"]',this._element);t&&(e||t.dataset.originalName?e&&t.dataset.originalName&&(t.name=t.dataset.originalName,delete t.dataset.originalName):(t.dataset.originalName=t.name,t.removeAttribute("name")))}_addEventListener(){s.A.findAll('[data-vg-toggle="files"]',this._element).forEach(e=>{e.removeEventListener("change",this._onNativeInputChange),e.addEventListener("change",this._onNativeInputChange)})}dispose(){this.clear(),super.dispose()}}const _i=ci;var ui=i(11);const mi=class{constructor(e={}){this.mode=e.mode||"sequential",this.maxParallel=e.maxParallel||3,this.maxConcurrent=e.maxConcurrent||1,this.retryAttempts=e.retryAttempts||3,this.retryDelay=e.retryDelay||1e3,this.uploads=new Map,this.completed=[],this.queue=[],this.waitingPromises=[],this.activeCount=0,this.isPaused=!1,this.callbacks={progress:[],complete:[],error:[],allComplete:[]},this._checkAllCompleteBound=this.checkAllComplete.bind(this)}async uploadFile(e,t,i={}){const s=this.generateId(),r={id:s,file:e,url:t,options:i,status:"pending",progress:0,attempts:0,result:null,error:null,startTime:null,endTime:null,controller:new AbortController,signal:null};return this.uploads.set(s,r),"sequential"===this.mode?this._addToSequentialQueue(r):this._startParallelUpload(r)}async uploadFiles(e,t,i={}){const s=e.map(e=>this.uploadFile(e,t,i));return(await Promise.allSettled(s)).map(e=>"fulfilled"===e.status?{file:e.value.file?.name,success:!0,result:e.value}:{file:e.reason?.file?.name||"unknown",success:!1,error:e.reason})}_addToSequentialQueue(e){return new Promise((t,i)=>{this.queue.push({uploadData:e,resolve:t,reject:i}),this._processSequentialQueue()})}async _processSequentialQueue(){if(this.isPaused||this.activeCount>=this.maxConcurrent||0===this.queue.length)return;const{uploadData:e,resolve:t,reject:i}=this.queue[0];this.activeCount++;try{t(await this._executeUpload(e))}catch(e){i(e)}finally{this.queue.shift(),this.activeCount--,await this._processSequentialQueue()}}async _startParallelUpload(e){this.activeCount>=this.maxParallel&&await new Promise(e=>this.waitingPromises.push(e)),this.activeCount++,e.startTime=Date.now();try{return await this._executeUpload(e)}finally{this.activeCount--,this._notifyWaiting()}}_notifyWaiting(){this.waitingPromises.length>0&&this.activeCount<this.maxParallel&&this.waitingPromises.shift()()}async _executeUpload(e,t=1){e.status="uploading",e.attempts=t,e.signal=e.controller.signal;try{const t=await this._performUpload(e);return this._completeUpload(e,t),t}catch(i){if("cancelled"===e.status)return;if(e.error=i,t<this.retryAttempts)return e.status="retrying",this.notifyProgress(e),await this._delay(this.retryDelay*Math.pow(2,t)),this._executeUpload(e,t+1);throw e.status="failed",e.endTime=Date.now(),this.notifyProgress(e),this.notifyError(e,i),this._checkAllCompleteBound(),i}}_performUpload(e){return new Promise((t,i)=>{const s=new ui.A,n=new FormData;n.append("file",e.file),n.append("_token",s._getCsrfToken()||""),e.options.additionalData&&Object.entries(e.options.additionalData).forEach(([e,t])=>{n.append(e,t)});const a={onProgress:(t,i)=>{e.progress=t,this.notifyProgress(e)},onSuccess:e=>{t((0,r.OM)(e))},onError:e=>{i((0,r.OM)(e))},signal:e.signal},o=s.post(e.url,n,a);e.xhr=o})}_completeUpload(e,t){e.status="completed",e.progress=100,e.result=t,e.endTime=Date.now(),this.completed.push({...e}),this.notifyComplete(e),this._checkAllCompleteBound()}cancelUpload(e){const t=this.uploads.get(e);if(!t||["completed","failed","cancelled"].includes(t.status))return!1;t.controller.abort(),t.xhr&&"function"==typeof t.xhr.abort&&t.xhr.abort(),t.status="cancelled",t.endTime=Date.now(),this.notifyProgress(t);const i=this.queue.findIndex(t=>t.uploadData.id===e);return i>-1&&this.queue.splice(i,1),!0}setMode(e,t=3){this.mode=e,this.maxParallel=t,"parallel"===e&&(this.queue=[],this._notifyWaiting())}pause(){this.isPaused=!0}resume(){this.isPaused=!1,"sequential"===this.mode?this._processSequentialQueue():this._notifyWaiting()}clear(){this.uploads.forEach((e,t)=>{this.cancelUpload(t)}),this.uploads.clear(),this.completed=[],this.queue=[],this.waitingPromises=[],this.activeCount=0}getStats(){const e=Array.from(this.uploads.values()),t=e.reduce((e,t)=>e+(t.file?.size||0),0);return{total:e.length,active:this.activeCount,pending:e.filter(e=>"pending"===e.status).length,uploading:e.filter(e=>"uploading"===e.status).length,completed:e.filter(e=>"completed"===e.status).length,failed:e.filter(e=>"failed"===e.status).length,cancelled:e.filter(e=>"cancelled"===e.status).length,mode:this.mode,isPaused:this.isPaused,queueLength:this.queue.length,totalSizeFormatted:(t/1048576).toFixed(2)+" MB"}}printDebugStats(){const e=this.getStats();console.group("--- Uploader Statistics ---"),console.table({Mode:e.mode,Status:e.isPaused?"Paused":"Running","Total Files":e.total,Uploading:e.uploading,Completed:e.completed,Failed:e.failed,Queue:e.queueLength}),console.log(`Total Size: ${e.totalSizeFormatted}`),console.groupEnd()}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_delay(e){return new Promise(t=>setTimeout(t,e))}checkAllComplete(){Array.from(this.uploads.values()).every(e=>["completed","failed","cancelled"].includes(e.status))&&this.uploads.size>0&&this.notifyAllComplete()}onProgress(e){this.callbacks.progress.push(e)}onComplete(e){this.callbacks.complete.push(e)}onError(e){this.callbacks.error.push(e)}onAllComplete(e){this.callbacks.allComplete.push(e)}notifyProgress(e){this.callbacks.progress.forEach(t=>this._safeCall(t,{...e,stats:this.getStats()}))}notifyComplete(e){this.callbacks.complete.forEach(t=>this._safeCall(t,e))}notifyError(e,t){this.callbacks.error.forEach(i=>this._safeCall(i,e,t))}notifyAllComplete(){this.callbacks.allComplete.forEach(e=>this._safeCall(e,{completed:this.completed,stats:this.getStats()}))}isIdle(){const e=this.activeCount>0,t=this.queue.length>0,i=this.waitingPromises.length>0,s=Array.from(this.uploads.values()).some(e=>["uploading","retrying","pending"].includes(e.status));return!(e||t||i||s)}offAll(){return this.callbacks.progress=[],this.callbacks.complete=[],this.callbacks.error=[],this.callbacks.allComplete=[],this}_safeCall(e,...t){try{e(...t)}catch(e){console.error("Callback error:",e)}}};var pi=i(355);const gi="vg-files-drop",fi=`${gi}--list`,bi="drop-active",vi="drop-hover",yi="vg.drop-and-drop";class wi extends e.A{constructor(e,t={}){super(e,t),this._element=e,this._params=t,this._files=null,this._input=null,this._init()}static get NAME(){return"drop-and-drop"}static get NAME_KEY(){return yi}_init(){wi._instances.add(this),this._params?.smartdrop&&(wi._smartInstances.add(this),this._bindGlobalEvents()),this._findInput(),this._setupEvents()}_findInput(){const{id:e,name:t}=this._element.dataset;e&&(this._input=document.getElementById(e)),!this._input&&t&&(this._input=s.A.find(`[name="${t}"]`)),this._input||(this._input=s.A.find('input[type="file"]',this._element)||s.A.find('input[type="file"]',this._element.parentNode))}_setupEvents(){(0,r.vq)(this._element)&&(g.A.on(this._element,`click.${yi}`,e=>{if("LABEL"!==this._element.tagName)return;const t=e.target?.closest?.(`.${fi}`);t&&this._element.contains(t)&&e.preventDefault()}),g.A.on(this._element,"dragover",e=>{if(e.preventDefault(),e.stopPropagation(),this._isSortableDrag(e))return t.x.remove(this._element,[bi,vi]),wi._setDropMessageTitleState(this._element,!1),void(e.dataTransfer.dropEffect="none");t.x.has(this._element,bi)||t.x.add(this._element,vi)}),g.A.on(this._element,"dragenter",e=>{if(e.preventDefault(),e.stopPropagation(),this._isSortableDrag(e))return t.x.remove(this._element,[bi,vi]),void wi._setDropMessageTitleState(this._element,!1);t.x.add(this._element,[bi,vi]),wi._setDropMessageTitleState(this._element,!0)}),g.A.on(this._element,"dragleave",e=>{if(e.preventDefault(),e.stopPropagation(),this._isSortableDrag(e))return t.x.remove(this._element,[bi,vi]),void wi._setDropMessageTitleState(this._element,!1);e.target!==this._element&&e.target.closest("."+gi)!==this._element||(t.x.remove(this._element,vi),setTimeout(()=>{this._element.matches(":hover")||(t.x.remove(this._element,bi),wi._setDropMessageTitleState(this._element,!1))},50))}),g.A.on(this._element,"drop",e=>{if(e.preventDefault(),e.stopPropagation(),t.x.remove(this._element,[bi,vi]),wi._setDropMessageTitleState(this._element,!1),this._isSortableDrag(e))return;const i=e.dataTransfer?.files;i&&i.length&&(this._files=i,(0,r.vq)(this._input)&&(this._input.files=i,g.A.trigger(this._input,"change")))}))}_bindGlobalEvents(){wi._isGlobalEventsBound||(wi._globalHandlers={dragenter:e=>this._updateSuggestedDrop(e),dragover:e=>this._updateSuggestedDrop(e),dragleave:e=>{this._isFileDrag(e)&&(null!==e.relatedTarget&&e.target!==document&&e.target!==document.documentElement||wi._clearSuggestedDrop())},drop:e=>{if(!this._isFileDrag(e))return void wi._clearSuggestedDrop();const t=wi._activeSuggestedDrop;if(t){const i=Array.from(wi._smartInstances).find(e=>e._element===t),s=e.dataTransfer?.files;i&&s&&s.length&&(0,r.vq)(i._input)&&(e.preventDefault(),e.stopPropagation(),i._files=s,i._input.files=s,g.A.trigger(i._input,"change"))}wi._clearSuggestedDrop()},dragend:()=>wi._clearSuggestedDrop()},g.A.on(document,"dragenter",wi._globalHandlers.dragenter),g.A.on(document,"dragover",wi._globalHandlers.dragover),g.A.on(document,"dragleave",wi._globalHandlers.dragleave),g.A.on(document,"drop",wi._globalHandlers.drop),g.A.on(document,"dragend",wi._globalHandlers.dragend),g.A.on(window,"dragenter",wi._globalHandlers.dragenter),g.A.on(window,"dragover",wi._globalHandlers.dragover),g.A.on(window,"dragleave",wi._globalHandlers.dragleave),g.A.on(window,"drop",wi._globalHandlers.drop),g.A.on(window,"dragend",wi._globalHandlers.dragend),wi._isGlobalEventsBound=!0)}_updateSuggestedDrop(e){if(!this._isFileDrag(e))return void wi._clearSuggestedDrop();const i=this._getVisibleDropZonesInViewport();if(1===i.length){const[s]=i;return wi._activeSuggestedDrop!==s&&(wi._clearSuggestedDrop(),t.x.add(s,bi),wi._setDropMessageTitleState(s,!0),wi._activeSuggestedDrop=s),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),void e.preventDefault()}wi._clearSuggestedDrop()}_isFileDrag(e){try{if(this._isSortableDrag(e))return!1;const t=e?.dataTransfer;return!!t&&(!!(t.files&&t.files.length>0)||(t.items&&t.items.length>0?Array.from(t.items).some(e=>"file"===e.kind):!!t.types&&Array.from(t.types).includes("Files")))}catch(e){return!1}}_isSortableDrag(e){if((0,pi.L)())return!0;if(document.querySelector(".dragging"))return!0;try{const t=e?.dataTransfer;return!!Array.from(t?.types||[]).includes(pi.h)||"1"===(t?.getData?.(pi.h)||"")||"vgsortable"===(t?.getData?.("text/plain")||"")}catch(e){return!1}}_getVisibleDropZonesInViewport(){return Array.from(s.A.findAll(`.${gi}`)||[]).filter(e=>this._isVisibleInViewport(e))}_isVisibleInViewport(e){if(!(0,r.vq)(e)||!e.isConnected)return!1;const t=window.getComputedStyle(e);if("none"===t.display||"hidden"===t.visibility||"0"===t.opacity)return!1;const i=e.getBoundingClientRect();return!(!i.width||!i.height)&&(i.bottom>0&&i.right>0&&i.top<window.innerHeight&&i.left<window.innerWidth)}static _clearSuggestedDrop(){wi._activeSuggestedDrop&&(wi._setDropMessageTitleState(wi._activeSuggestedDrop,!1),t.x.remove(wi._activeSuggestedDrop,bi),wi._activeSuggestedDrop=null)}static _setDropMessageTitleState(e,t){if(!(0,r.vq)(e))return;const i=s.A.find(".vg-files-drop-message .title",e);if(!i)return;const n=(i.getAttribute("data-drop-original-text")||"").trim()||(i.textContent||"").trim();i.setAttribute("data-drop-original-text",n);const a=(e.getAttribute("data-drop-active-text")||"").trim();i.textContent=t&&a?a:n}static _unbindGlobalEvents(){if(!wi._isGlobalEventsBound)return;const e=wi._globalHandlers||{};g.A.off(document,"dragenter",e.dragenter),g.A.off(document,"dragover",e.dragover),g.A.off(document,"dragleave",e.dragleave),g.A.off(document,"drop",e.drop),g.A.off(document,"dragend",e.dragend),g.A.off(window,"dragenter",e.dragenter),g.A.off(window,"dragover",e.dragover),g.A.off(window,"dragleave",e.dragleave),g.A.off(window,"drop",e.drop),g.A.off(window,"dragend",e.dragend),wi._isGlobalEventsBound=!1,wi._globalHandlers=null,wi._clearSuggestedDrop()}getFiles(){return this._files}dispose(){g.A.off(this._element,`click.${yi}`),g.A.off(this._element,"dragover"),g.A.off(this._element,"dragenter"),g.A.off(this._element,"dragleave"),g.A.off(this._element,"drop"),wi._instances.delete(this),wi._smartInstances.delete(this),wi._smartInstances.size||wi._unbindGlobalEvents(),this._input=null,this._files=null}init(){return this}}wi._instances=new Set,wi._smartInstances=new Set,wi._isGlobalEventsBound=!1,wi._activeSuggestedDrop=null,wi._globalHandlers=null;const Ei=wi;var Ai=i(483);const Si=class{constructor(e,t,i={}){this.module=e,this.element=(0,r.vq)(t)?t:null,this.element?(this._params=new je.A(i,t).get(),this._nodes={info:this.module._nodes.info,drop:this.module._nodes.drop},this.bufferTemplate="",this.parsedFiles=[]):console.error("Invalid element provided:",t)}init(){const e=this._nodes.info||this._nodes.drop;if(!e)return!1;const t=this._nodes.info?"info":"drop";return this._nativeRenderFiles(t,e)}_nativeRenderFiles(e,i){const r=s.A.find(`.vg-files-${e}--list`,i);if(!r)return!1;const n=Array.from(r.children).filter(e=>"LI"===e.tagName);return 0!==n.length&&(this._setTemplateInBuffer(n),!!this.bufferTemplate&&(this.parsedFiles=n.map(e=>{const i=t.p.get(e,"data-file");return i?this._parseDataFile(i):null}).filter(Boolean),!0))}_parseDataFile(e){const t=(0,r.OM)(e);if(!t||"object"!=typeof t||Array.isArray(t))return null;const i=this._extractBinaryMeta(t),s=this._toStringOrNull(t.name),n=this._toStringOrNull(t.id),a=this._toStringOrNull(t.src),o=this._toStringOrNull(t.type)||i.type||"application/octet-stream",l={id:n,name:s,size:this._toNumberOrNull(t.size)??i.size??0,type:o,src:a,lastModified:this._toNumberOrNull(t.lastModified??t["last-modified"])??i.lastModified??Date.now()};if(void 0!==t.image&&null!==t.image&&""!==t.image&&(l.image=t.image),!["id","name","size","type","src"].every(e=>{const t=l[e];return"size"===e?Number.isFinite(t):null!=t&&""!==t}))return null;const h={},d=new Set(["id","name","size","type","src","image","lastModified","last-modified"]);return Object.entries(t).forEach(([e,t])=>{d.has(e)||null!=t&&""!==t&&(h[e]=t)}),Object.keys(h).length&&(l.customData=h),l}_extractBinaryMeta(e){const t=e.file||e.blob||e.originFile||null;return t instanceof Blob?{size:this._toNumberOrNull(t.size)??null,type:this._toStringOrNull(t.type)||null,lastModified:(t instanceof File?this._toNumberOrNull(t.lastModified):null)??null}:{}}_toStringOrNull(e){if(null==e)return null;return String(e).trim()||null}_toNumberOrNull(e){if(null==e||""===e)return null;const t=Number(e);return Number.isFinite(t)?t:null}_setTemplateInBuffer(e){if(this.bufferTemplate||0===e.length)return;const i=e[0];t.p.has(i,"data-file")?this.bufferTemplate=i.outerHTML:(this.bufferTemplate=i.outerHTML,i.remove())}dispose(){this.bufferTemplate="",this.parsedFiles=[]}},Ci="files",xi="vg.files",Li='[data-vg-reload="file"]',Ii='[data-vg-dismiss="file"]',Pi="vg-files",ki=`${Pi}-stat`,Mi="completed",Di="pending",Ti="loading",Oi="failing",zi="loaded";class Ni extends _i{constructor(e,t={}){super(e,t,{init:!0,allowed:!1,lang:document.documentElement.lang||"ru",limits:{count:0,sizes:10,total:0},image:!1,detach:!0,info:!0,types:[],ajax:!1,prepend:!0,replace:!0,rename:!1,smartdrop:!1,customButtons:{hideOnUploadState:!0},uploads:{mode:"sequential",route:"",maxParallel:3,maxConcurrent:1,retryAttempts:1,retryDelay:1e3},removes:{buttons:null,all:{route:"",alert:!0,toast:!0,confirm:null,buttons:null},single:{route:"",alert:!0,toast:!0,confirm:null,buttons:null}},sortable:{enabled:!1,route:"",handle:".file",lists:["vg-files-info--list","vg-files-drop--list"]},callbacks:{onInit:null,onChange:null,onUploadStart:null,onUploadProgress:null,onUploadComplete:null,onUploadError:null,onUploadAllComplete:null,onRemoveFile:null,onClear:null,onReload:null}}),this._files=[],this._uploadedKeys=new Set,this._failingUploadedKeys=new Set,this._pendingUploadedKeys=new Set,this._unUploadedFiles=[],this._uploader=null,this._sortable=null,this._render=null,this.isRenderNonInit=!1,this._initExtended()}static get NAME(){return Ci}static get NAME_KEY(){return xi}_initExtended(){if(!this._isInitialized)return;if(this._render=new Si(this,this._element,this._params),this._params.ajax&&(this._params.allowed=!1),this.isRenderNonInit)return;this.isRenderNonInit=this._render.init();const e=this._render.parsedFiles;e.length&&this._addExternalFiles(e),this._params.allowed&&!this._params.ajax&&(this._params.detach=!1),this._nodes.drop&&(this._params.image=!0,this._params.detach=!0,this._setDropActiveText(),Ei.getOrCreateInstance(this._nodes.drop,this._params).init()),this._addEventListenerExtended(),this._renderStat(),this._triggerCallback("onInit",{element:this._element,files:e||[]})}_setDropActiveText(){if(!this._nodes.drop)return;const e=Re(this._params.lang,Ci)||{},t=(this._nodes.drop.getAttribute("data-drop-active-text")||"").trim()||e["drop-active"]||"Release to upload";this._nodes.drop.setAttribute("data-drop-active-text",t);const i=s.A.find(".vg-files-drop-message .title",this._nodes.drop);if(!i)return;const r=(i.getAttribute("data-drop-original-text")||"").trim()||(i.textContent||"").trim();i.setAttribute("data-drop-original-text",r)}_addExternalFiles(e){Array.isArray(e)&&e.length&&(e.forEach(e=>{if(!e?.name)return;const t={};"string"==typeof e.type&&(t.type=e.type),Number.isFinite(e.lastModified)&&(t.lastModified=e.lastModified);const i=new File([""],e.name,t);void 0!==e.id&&null!==e.id&&""!==e.id&&Object.defineProperty(i,"id",{value:e.id,writable:!0,enumerable:!0}),Number.isFinite(e.size)&&Object.defineProperty(i,"size",{value:e.size,writable:!0,enumerable:!0}),void 0!==e.src&&null!==e.src&&""!==e.src&&Object.defineProperty(i,"src",{value:e.src,writable:!0,enumerable:!0}),void 0!==e.image&&null!==e.image&&""!==e.image&&Object.defineProperty(i,"image",{value:e.image,writable:!0,enumerable:!0}),e.customData&&"object"==typeof e.customData&&!Array.isArray(e.customData)&&Object.defineProperty(i,"customData",{value:e.customData,writable:!0,enumerable:!0});const s=this._getFileKey(i);this._uploadedKeys.add(s),this._pendingUploadedKeys.delete(s),this._failingUploadedKeys.delete(s),this._files.push(i)}),this._renderUI(this._files),this._renderStat(),this._updateStat(),this._setStatItem("completed",this._uploadedKeys.size),this._params.sortable?.enabled&&this._params.sortable.route&&!this._sortable&&(this._sortable=new pi.default(this,this._params.sortable)),this._triggerCallback("onChange",{files:this._files}),g.A.trigger(this._element,`${xi}.change`,{files:this._files}))}_addEventListenerExtended(){s.A.findAll('[data-vg-toggle="files"]',this._element).forEach(e=>{this._onNativeInputChange&&e.removeEventListener("change",this._onNativeInputChange),e.addEventListener("change",e=>this._handleChange(e))})}_handleChange(e){const t=e?.target,i=this._snapshotInputFiles(t);this.change(t),this._params.ajax&&this.uploadAll(this._files);const s={files:this._files,input:e?.target||e?.src||"",inputFiles:i};this._triggerCallback("onChange",s),this._triggerEvent("change",{files:this._files,input:s.input,inputFiles:s.inputFiles})}_snapshotInputFiles(e){const t=e?.files;return t?.length?Array.from(t):[]}async uploadAll(e){if(!this._params.ajax||!this._params.uploads.route)return;this._uploadedKeys.size||this._failingUploadedKeys.clear();const t=e.filter(e=>this._isFileValid(e)&&!this._uploadedKeys.has(this._getFileKey(e)));if(this._setStatItem("failing",this._getFailingCount()),!t.length)return;this._uploader&&!this._uploader.isIdle()||(this._uploader=new mi({mode:this._params.uploads.mode,maxConcurrent:this._params.uploads.maxConcurrent,maxParallel:this._params.uploads.maxParallel,retryAttempts:this._params.uploads.retryAttempts,retryDelay:this._params.uploads.retryDelay}),this._setupUploadEventHandlers()),t.forEach(e=>{const t=this._getFileKey(e);this._pendingUploadedKeys.add(t),this._unUploadedFiles=this._unUploadedFiles.filter(e=>this._getFileKey(e)!==t)}),this._setStatItem("pending",this._pendingUploadedKeys.size);const i={additionalData:{timestamp:(new Date).toISOString(),source:"web_uploader",prepend:this._params.prepend}};this._triggerCallback("onUploadStart",{files:t,total:t.length}),this._triggerEvent("upload.start",{files:t,total:t.length});try{await this._uploader.uploadFiles(t,this._params.uploads.route,i)}catch(e){console.error("Bulk upload failed:",e)}}async upload(e){if(!this._params.ajax||!this._params.uploads.route)return;this._uploader&&!this._uploader.isIdle()||(this._uploader=new mi({mode:this._params.uploads.mode,maxConcurrent:this._params.uploads.maxConcurrent,maxParallel:this._params.uploads.maxParallel,retryAttempts:this._params.uploads.retryAttempts,retryDelay:this._params.uploads.retryDelay}));const i=this._getFileKey(e);this._pendingUploadedKeys.has(i)||(this._pendingUploadedKeys.add(i),this._setStatItem("pending",this._pendingUploadedKeys.size)),this._unUploadedFiles=this._unUploadedFiles.filter(e=>this._getFileKey(e)!==i);const s=this._getItemElement(e);s&&(t.x.remove(s,Oi),t.x.add(s,Ti),t.x.add(s,Di)),this._setupUploadEventHandlers(e);const r={additionalData:{timestamp:(new Date).toISOString(),source:"web_uploader"}};try{await this._uploader.uploadFiles([e],this._params.uploads.route,r)}catch(e){console.error("Upload failed:",e)}}_setupUploadEventHandlers(){"function"==typeof this._uploader.offAll?this._uploader.offAll():(this._uploader.off("progress"),this._uploader.off("complete"),this._uploader.off("error"),this._uploader.off("allComplete")),this._updateStat(!0),this._uploader.onProgress(e=>{const i=e.file,n=this._getItemElement(i);if(!n)return;t.x.add(n,Ti),t.x.add(n,Di);const a=this._getButtonElement(i);if((0,r.vq)(a)){const e=a.closest("li");if(e){const t=s.A.find(".file-remove",e);t&&(t.innerHTML="",t.appendChild(this._setButtonElement(i,!0)))}}const o={file:e.file,progress:e.progress,bytesSent:e.bytesSent,totalBytes:e.totalBytes};this._triggerCallback("onUploadProgress",o),this._triggerEvent("upload.progress",o)}),this._uploader.onComplete(e=>{const i=e.file,n=this._getFileKey(i),a=this._getItemElement(i);if(!a)return;t.x.replace(a,Ti,zi),t.x.remove(a,Di);const o=this._getButtonElement(i),l=(0,r.OM)(e.result?.response?.id)||e.id||i.lastModified;if(i.id=l,(0,r.vq)(o)&&l){const e=o.closest("li");if(e){t.p.set(e,"data-id",l),this._setButtonElement(i);const r=s.A.find(".file-remove",e);r&&(r.innerHTML="",r.appendChild(this._setButtonElement(i,!0,"completed")),t.x.add(e,Mi),setTimeout(()=>{r.innerHTML="",r.appendChild(this._setButtonElement(i)),t.x.remove(e,Mi)},1e3))}}this._uploadedKeys.add(n),this._failingUploadedKeys.delete(n),this._pendingUploadedKeys.delete(n),this._setStatItem("completed",this._uploadedKeys.size),this._setStatItem("pending",this._pendingUploadedKeys.size);const h={file:e.file,response:e.result?.response,status:e.result?.status,id:i.id};this._triggerCallback("onUploadComplete",h),this._triggerEvent("upload.complete",h)}),this._uploader.onError(e=>{const i=e.file,n=this._getFileKey(i),a=this._getItemElement(i);if(!a)return;this._uploadedKeys.delete(n),this._failingUploadedKeys.add(n),this._pendingUploadedKeys.delete(n),this._unUploadedFiles.push(i),t.x.remove(a,Di),t.x.replace(a,Ti,Oi),this._setStatItem("failing",this._getFailingCount()),this._setStatItem("pending",this._pendingUploadedKeys.size);const o=this._getButtonElement(i);if((0,r.vq)(o)){const e=o.closest("li");if(e){this._setButtonElement(i);const r=s.A.find(".file-remove",e);r&&(r.innerHTML="",r.appendChild(this._setFailingButtons(i)),t.x.add(e,Oi))}}const l={file:e.file};this._triggerCallback("onUploadError",l),this._triggerEvent("upload.error",l)}),this._uploader.onAllComplete(()=>{this._triggerEvent("upload.allComplete"),this._updateStat(!1),this._getFailingCount()||this._params.sortable?.enabled&&this._params.sortable.route&&Promise.resolve().then(i.bind(i,355)).then(e=>{this._sortable&&"function"==typeof this._sortable.destroy&&this._sortable.destroy(),this._sortable=new e.default(this,this._params.sortable)}).catch(e=>{console.error("Ошибка загрузки VGFilesSortable:",e)});const e={uploaded:this._uploadedKeys.size,failed:this._getFailingCount(),total:this._files.length};this._triggerCallback("onUploadAllComplete",e)})}reload(e){if(!this._params.ajax||!this._params.uploads.route)return;const i=t.p.get(e,"data"),s={name:i.name,size:i.size,type:i.type,lastModified:i["last-modified"]},r=this._getFileKey(s);if(!this._failingUploadedKeys.has(r))return;const n=this._unUploadedFiles.find(e=>this._getFileKey(e)===r);if(!n)return;this._failingUploadedKeys.delete(r),this._pendingUploadedKeys.add(r),this._setStatItem("failing",this._failingUploadedKeys.size),this._setStatItem("pending",this._pendingUploadedKeys.size);const a={button:e,file:n};this._triggerCallback("onReload",a),this._triggerEvent("reload",a),this.upload(n)}_runAjaxRequest(e,t){const i=this._params.ajax;this._params.ajax=e,this._route((e,s)=>{this._params.ajax=i,t(e,s)})}_normalizeConfirmResult(e){if(!0===e)return{accepted:!0,data:null};if(!1===e||null==e)return{accepted:!1,data:null};if("object"==typeof e){if("boolean"==typeof e.accepted)return{accepted:e.accepted,data:e.data??null};if(Object.prototype.hasOwnProperty.call(e,"data"))return{accepted:!0,data:e.data??null}}return{accepted:Boolean(e),data:null}}_runDefaultRemoveConfirm(e,t){return new Promise(i=>{ot.confirm(e,{lang:t.lang,ajax:t.ajax,buttons:t.buttons,message:t.message}),g.A.one(e,"vg.alert.accept",e=>{i({accepted:!0,data:e?.vgalert?.data??null})}),g.A.one(e,"vg.alert.reject",()=>{i({accepted:!1,data:null})})})}_isPlainObject(e){return e&&"object"==typeof e&&!Array.isArray(e)}_mergeButtonConfigs(...e){return e.reduce((e,t)=>this._isPlainObject(t)?(Object.entries(t).forEach(([t,i])=>{this._isPlainObject(e[t])&&this._isPlainObject(i)?e[t]=this._mergeButtonConfigs(e[t],i):e[t]=Array.isArray(i)?i.slice():i}),e):e,{})}_getDefaultRemoveConfirmButtons(){return{agree:{text:Be(this._params.lang,Ci).agree,class:["btn-danger"]},cancel:{text:Be(this._params.lang,Ci).cancel,class:["btn-outline-danger"]}}}_getRemoveConfirmButtons(e){return this._mergeButtonConfigs(this._getDefaultRemoveConfirmButtons(),this._params?.removes?.buttons,this._params?.removes?.[e]?.buttons)}_confirmRemove(e,t,i,s){const r=this._getRemoveConfirmButtons(e),n={type:e,trigger:t,lang:this._params.lang,ajax:i,buttons:r,message:s},a=this._params?.removes?.[e]?.confirm;return"function"==typeof a?Promise.resolve(a(n,this)).then(e=>this._normalizeConfirmResult(e)):this._runDefaultRemoveConfirm(t,n)}removeFile(e){const i=(0,r.OM)(t.p.get(e,"data-name")),n=(0,r.OM)(t.p.get(e,"data-size")),a=(0,r.OM)(t.p.get(e,"data-id")),o=()=>{const t={button:e,name:i,size:n,id:a,remaining:this._files.length};this._triggerCallback("onRemoveFile",t),this._triggerEvent("remove",t)},l=this._files.find(e=>e.name===i&&e.size===n);if(l){const e=this._getFileKey(l);this._uploadedKeys.delete(e),this._pendingUploadedKeys.delete(e),this._failingUploadedKeys.delete(e),this._forgetFileValidation(l)}if(this._getItemElement().forEach(e=>{const i=s.A.find("button",e);if(!i)return;const n=(0,r.OM)(t.p.get(i,"data-id")),a=(0,r.OM)(t.p.get(i,"data-name")),o=(0,r.OM)(t.p.get(i,"data-size"));this._files.forEach(e=>{e.name===a&&e.size===o&&(e.id=n)}),l?.name===a&&l?.size===o&&(l.id=n)}),this._params.ajax&&this._params.removes.single.route){if(!a)return this._files=this._files.filter(e=>!(e.name===i&&e.size===n)),this._updateStatsAfterRemove(),this._files.length?this.build():this.clear(!0),o(),void this._resetFileInput();const t=this._params.removes.single.route,s=t.includes("?")?"&":"?",r={route:`${t}${s}id=${encodeURIComponent(a)}`,method:"delete"},l=e=>{this._files=this._files.filter(e=>!(e.name===i&&e.size===n)),this._updateStatsAfterRemove(),this._files.length?this._renderUI(this._files):this.clear(!0,!0),this._params.removes.single.toast&&Ai.A.run(e?.response?.message),o()};if(this._params.removes.single.alert){const t={title:Re(this._params.lang,Ci).title,description:Re(this._params.lang,Ci).description};this._confirmRemove("single",e,r,t).then(e=>{e.accepted&&(e.data?l(e.data):this._runAjaxRequest(r,(e,t)=>{l(t)}))}).catch(()=>{})}else this._runAjaxRequest(r,(e,t)=>{l(t)})}else this._files=this._files.filter(e=>!(e.name===i&&e.size===n)),this._updateStatsAfterRemove(),this._files.length?this.build():this.clear(!0),o();this._resetFileInput()}_updateStatsAfterRemove(){this._setStatItem("completed",this._uploadedKeys.size),this._setStatItem("pending",this._pendingUploadedKeys.size),this._setStatItem("failing",this._getFailingCount()),this._updateStat()}_getItemElement(e=null){let t=`${this._getClass("info-list")}`;return this._nodes.drop&&(t=`${this._getClass("drop-list")}`),e?s.A.find(`.${t} li[data-name="${e.name}"][data-size="${e.size}"]`,this._element):s.A.findAll(`.${t} li.loaded`,this._element)}_getButtonElement(e){return s.A.find(`button[data-name="${e.name}"][data-size="${e.size}"]`,this._element)}_setButtonElement(e,t=!1,i=""){let s=(0,f.z)("remove"),r="data-vg-dismiss";return t&&(s=(0,f.z)("spinner"),"completed"===i?s=(0,f.z)("check"):r="data-vg-reload"),this._tpl.button([this._tpl.i({},s,{isHTML:!0})],"button",this._buildFileDataAttributes(e,{type:"button",[r]:"file","data-name":e.name,"data-size":e.size??0,"data-type":e.type||"","data-last-modified":e.lastModified||"","data-id":e.id||""}))}_setFailingButtons(e){return this._tpl.div({class:"file-failing-actions"},[this._setButtonElement(e,!0,"failing"),this._setButtonElement(e)])}_renderStat(){if(!this._nodes.stat)return;if(!this._params.ajax)return;const e=s.A.find(`.${ki}-progress`,this._nodes.stat);if(!e)return;let t=s.A.find(`.${ki}-progress-list`,e);t||(t=this._tpl.ul([this._tpl.li({class:"stat-item pending","data-count":"0",title:Re(this._params.lang,Ci).pending},[this._tpl.span({class:"stat-label"},(0,f.z)("cloud-dot"),{isHTML:!0}),this._tpl.span({class:"stat-value"},0)]),this._tpl.li({class:"stat-item completed","data-count":"0",title:Re(this._params.lang,Ci).completed},[this._tpl.span({class:"stat-label"},(0,f.z)("cloud-dot"),{isHTML:!0}),this._tpl.span({class:"stat-value"},0)]),this._tpl.li({class:"stat-item failing","data-count":"0",title:Re(this._params.lang,Ci).failing},[this._tpl.span({class:"stat-label"},(0,f.z)("cloud-dot"),{isHTML:!0}),this._tpl.span({class:"stat-value"},0)])],{class:ki+"-progress-list"},!0),e.appendChild(t))}_setStatItem(e,i){if(!this._nodes.stat)return;const r=s.A.find(`.${ki}-progress-list li.${e}`,this._nodes.stat);if(!r)return;t.p.set(r,"data-count",i);const n=s.A.find(".stat-value",r);n&&(n.innerHTML=i)}_renderUIStatusDropInfoAjax(e){this._params.ajax&&(e.forEach(e=>{const i=this._getItemElement(e);if(!i)return;const s=this._getFileKey(e);this._isFileValid(e)?this._uploadedKeys.has(s)?(t.x.replace(i,Di,Mi),t.x.add(i,zi)):this._failingUploadedKeys.has(s)?t.x.replace(i,Di,Oi):t.x.add(i,Di):(t.x.remove(i,Di),t.x.add(i,Oi))}),this._setStatItem("failing",this._getFailingCount()))}_getFailingCount(){const e=new Set(this._failingUploadedKeys);return this._validationErrorsByKey.forEach((t,i)=>e.add(i)),e.size}_triggerCallback(e,t){const i=this._params.callbacks?.[e];if("function"==typeof i)try{i.call(this,t,this)}catch(t){console.error(`${e} callback error:`,t)}}_triggerEvent(e,t={}){g.A.trigger(this._element,`${xi}.${e}`,t)}_getUploadedIds(){return Array.from(this._uploadedKeys).map(e=>{const t=this._files.find(t=>this._getFileKey(t)===e);return t?.id||null}).filter(e=>null!==e)}dispose(){this._sortable&&"function"==typeof this._sortable.destroy&&this._sortable.destroy(),this._sortable=null,this.clear(),this._uploader&&("function"==typeof this._uploader.destroy?this._uploader.destroy():("function"==typeof this._uploader.clear&&this._uploader.clear(),"function"==typeof this._uploader.offAll&&this._uploader.offAll())),super.dispose()}}g.A.on(document,`DOMContentLoaded.${xi}.data.api`,()=>{s.A.findAll(`.${Pi}`).forEach(e=>Ni.getOrCreateInstance(e))}),g.A.on(document,`click.${xi}.data.api`,Ii,function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation();const t=e.target.closest(`.${Pi}`);t&&Ni.getOrCreateInstance(t).removeFile(e.target.closest(Ii))}),g.A.on(document,`click.${xi}.data.api`,Li,function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation();const t=e.target.closest(`.${Pi}`);t&&Ni.getOrCreateInstance(t).reload(e.target.closest(Li))}),g.A.on(document,`click.${xi}.data.api`,'[data-vg-dismiss="vg-files"]',function(e){const t=e.target.closest(`.${Pi}`);if(!t)return;const i=Ni.getOrCreateInstance(t);if(i._params.ajax&&i._params.removes.all.route){e.preventDefault();const t={route:i._params.removes.all.route,method:"post",data:{ids:i._getUploadedIds()}},s=()=>{i.clear(!0,!0)};if(i._params.removes.all.alert){const r={title:Re(i._params.lang,Ci).title,description:Re(i._params.lang,Ci).descriptions};i._confirmRemove("all",e.target,t,r).then(e=>{if(e.accepted)return e.data?(i._params.removes.all.toast&&Ai.A.run(e.data?.response?.message),void s()):void i._runAjaxRequest(t,(e,t)=>{i._params.removes.all.toast&&t?.response?.message&&Ai.A.run(t.response.message),s()})}).catch(()=>{})}else i._runAjaxRequest(t,(e,t)=>{i._params.removes.all.toast&&t?.response?.message&&Ai.A.run(t.response.message),s()})}else i.clear(!0,!0)});const $i=Ni;var Hi=i(614);const Fi="vg.hideshowpass",Ri="show",Bi=`click.${Fi}.data.api`;class ji extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({parentClass:"vg-form-sender--content-pass"},t))}static get NAME(){return"hideshowpass"}static get NAME_KEY(){return Fi}toggle(e){return this._isShown()?this.hide(e):this.show(e)}show(e){e&&(this._params=this._getParams(e,this._params)),this._element.classList.add(Ri),e.remove(),this.build(!0),t.p.set(this._element,"type","text")}hide(e){this._element.classList.remove(Ri),e.remove(),this.build(!1),t.p.set(this._element,"type","password")}_isShown(){return this._element.classList.contains(Ri)}static init(e,t){ji.getOrCreateInstance(e,t).build(!1)}build(e=!1){let t=this._params.classes.join(" "),i="";const s=(0,d.A)("string");this._element.parentElement&&this._params.parentClass&&(this._element.parentElement.classList.add(this._params.parentClass),this._element.parentElement.classList.toggle("vg-form-sender--content-pass-focus-offset",!0===this._params.focus)),i=e?s.component("eye",{class:t,type:"hide"}):s.component("eye",{class:t}),this._element.insertAdjacentHTML(this._params.insert,i)}}g.A.on(document,Bi,'[data-vg-toggle="pass"]',function(e){const t=s.A.prev(this,"input");t&&(["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,r.d6)(this)||(this.setAttribute("aria-expanded",!0),ji.getOrCreateInstance(t.shift()).toggle(this)))});const Ui=ji,qi="form-sender",Vi="vg.fs",Wi="vg-form-sender-alert",Ki=`submit.${Vi}.data.api`;class Gi extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({response:{enabled:!1,errors:!1,title:"",message:""},redirect:{error:"",success:""},validate:!1,submit:!1,fields:[],timeout:50,pass:{focus:!1,template:"pass-open",classes:["vg-form-sender--hide-show-pass"],insert:"afterend"},alert:{enabled:!0,type:"modal",errors:!0,title:!0,delay:0,modal:{closeModalsBeforeModal:!0},toast:{closeModalsBeforeToast:!0}},ajax:{route:"",target:"",method:"get",timeout:1e3,loader:!1,output:!0},classes:{general:"vg-form-sender",alertCollapse:"vg-form-sender-collapse",alertModal:"vg-form-sender-modal",validation:"needs-validation",wasValidate:"was-validated",content:"vg-form-sender--content"},callback:{afterInit:r.lQ,afterValidateError:r.lQ,afterSuccess:r.lQ,afterError:r.lQ,afterSend:r.lQ},interceptors:{beforeSend:()=>new Promise((e,t)=>e()),success:!1,error:!1},button:{enabled:!0,disabled:!0,send:"Отправляем...",initial:"Отправить",spinner:{enabled:!1,element:'<span class="spinner-border spinner-border-sm me-2"></span>'},click:r.lQ},lang:"ru"},t)),this._button=null,this._cachedElements=new Map,this._initElements()}static get NAME(){return qi}static get NAME_KEY(){return Vi}_initElements(){this._button=s.A.find('[type="submit"]',this._element)||s.A.find('[form="'+this._element.id+'"]')||null;const e=s.A.findAll("input, textarea, select",this._element);this._cachedElements.set("fields",e),this._params.ajax.route=t.p.get(this._element,"action")||this._params.ajax.route,this._params.ajax.method=t.p.get(this._element,"method")||this._params.ajax.method,this._params.isBtnText="false"!==t.p.get(this._element,"data-btn-text"),this._params.isJsonParse="false"!==t.p.get(this._element,"data-json-parse"),this._params.isShowPass="true"===t.p.get(this._element,"data-show-pass"),this._button&&(this._params=this._getParams(this._button,this._params),this._params.button.initial=this._button.innerHTML.trim()||this._params.button.initial)}build(){this._element.classList.add(this._params.classes.general);const e=this._cachedElements.get("fields");return e&&e.forEach(e=>{(0,r.zN)(e)&&e.parentElement&&e.parentElement.classList.add(this._params.classes.content)}),this._params.validate&&(t.p.set(this._element,"novalidate",""),this._element.classList.add(this._params.classes.validation)),[...s.A.findAll('input[type="password"]',this._element)].forEach(e=>{Ui.init(e,this._params.pass)}),(0,r.g7)(this._params.callback.afterInit,[this._element,this]),this}request(e,t=null){const i=this;i._alertBefore();i._params.interceptors.beforeSend().then(()=>{(()=>{let s=new FormData(i._element);i._params.ajax.data=t?((e,t)=>{const i=new Set;return t.forEach((t,s)=>{i.has(s)||(e.delete(s),i.add(s)),e.append(s,t)}),e})(t,s):s,i._route(function(t,s){(0,r.g7)(i._params.callback.afterSend,[i._element,i,t,s]),i._element.classList.remove("was-validated"),i._params.response.enabled&&(s.response=i._params.response),i._params.alert.enabled&&("string"==typeof t&&"error"===t?i._params.redirect.error?window.location.href=i._params.redirect.error:(i._params.interceptors.error||i._alertError(e,s),(0,r.g7)(i._params.callback.afterError,[i._element,i,e,s])):"string"==typeof t&&"success"===t&&(i._params.redirect.success?window.location.href=i._params.redirect.success:(i._params.interceptors.success||i._alertSuccess(e,s),(0,r.g7)(i._params.callback.afterSuccess,[i._element,i,e,s]))))})})()}).catch(e=>{console.error(e)})}_alertBefore(){const e=this;if("collapse"===e._params.alert.type){const t=e._params.classes.alertCollapse;if(!e._cachedElements.has("collapses")||document.querySelector("."+t+".show")){const i=document.getElementsByClassName(t);e._cachedElements.set("collapses",i),[...i].forEach(function(e){e.classList.contains("show")&&wt.getOrCreateInstance(e,{toggle:!1}).hide()})}}e._statusButton("before"),g.A.trigger(e._element,"vg.fs.before",{vgformsender:{self:e}})}_alertError(e,t){const i=this;i._statusButton("after"),i._jsonParse(t,"error"),g.A.trigger(i._element,"vg.fs.error",{vgformsender:{event:e,self:i,data:t}})}_alertSuccess(e,t){const i=this;i._statusButton("after"),i._jsonParse(t,"success"),g.A.trigger(i._element,"vg.fs.success",{vgformsender:{event:e,self:i,data:t}})}_statusButton(e){if(this._button){if("before"===e){const e=this._button;this._params.button.initial=this._button.innerHTML.trim(),this._params.button.spinner.enabled&&this._button.insertAdjacentHTML("afterbegin",this._params.button.spinner.element),this._params.button.enabled&&(e.innerHTML=this._params.button.send),this._params.button.disabled&&t.p.set(this._button,"disabled","disabled"),(0,r.g7)(this._params.button.click,[this,this._button,"before"])}if("after"===e){if(this._params.button.enabled&&(this._button.innerHTML=this._params.button.initial),this._params.button.disabled&&t.p.remove(this._button,"disabled"),this._params.button.spinner.enabled){let e=this._button.querySelector(".spinner-border");e&&e.remove()}(0,r.g7)(this._params.button.click,[this,this._button,"after"])}}}_jsonParse(e,t){const i=this;i._params.isJsonParse?i.alert((0,r.OM)(e),t):i.alert(e,t)}_getValidationErrors(){return[...this._element.elements].filter(e=>"function"==typeof e?.checkValidity&&!e.checkValidity()).map(e=>({element:e,name:e.name||"",id:e.id||"",type:e.type||"",value:e.value,message:e.validationMessage||"",validity:{...e.validity}}))}_handleValidateError(e){return e.preventDefault(),e.stopPropagation(),this._element.classList.add(this._params.classes.wasValidate),(0,r.g7)(this._params.callback.afterValidateError,[this._element,this,e,this._getValidationErrors()]),!1}alert(e,t){if((0,r.Gv)(e))if("code"in e&&e.code&&200===e.code){if("response"in e&&e.response){let i=(0,r.OM)(e.response);"string"==typeof i?-1===i.indexOf("Parse error")&&-1===i.indexOf("syntax error")||(t="danger",e={response:{title:Fe(this._params.lang,"errors").title,message:Re(this._params.lang,"errors").went_wrong}}):"errors"in i&&(0,r.OM)(i.errors)&&(t=(0,r.OM)(i.errors)?"danger":"success")}}else t="danger";this._params.alert.enabled&&("modal"===this._params.alert.type&&this._alertModal(e,t),"collapse"===this._params.alert.type&&this._alertCollapse(e,t),"toast"===this._params.alert.type&&this._alertToast(e,t))}_alertModal(e,t){const i=this,n=i._params.alert.modal?.closeModalsBeforeModal,a=!n&&i._hasOpenedModals();n&&i._closeOpenedModals();let o=i._params.classes.general+"-"+(0,r.PR)(),l=s.A.find("."+i._params.classes.alertModal);l&&l.remove(),setTimeout(()=>{le.init(o,{dismiss:!0,classes:{alert:i._params.classes.alertModal}},function(r){let n=r._element;n.classList.add(i._params.classes.alertModal),a&&i._setStackedModalState(n);let o=s.A.find(".vg-modal-content",n);o&&o.classList.add(Wi,Wi+"-"+t);let l=s.A.find(".vg-modal-body",n);l&&l.append(i.setDataRelationStatus(n,t,e,"modal")),r.toggle(),i._params.alert.delay>0&&setTimeout(()=>{r.hide()},i._params.alert.delay)})},i._params.timeout)}_hasOpenedModals(){return Boolean(s.A.find(".modal.show, .vg-modal.show"))}_setStackedModalState(e){e&&(e.classList.add("vg-modal-stacked"),e.style.zIndex=this._getNextModalZIndex())}_getNextModalZIndex(){const e=s.A.findAll(".modal.show, .vg-modal.show, .ox-modal.is-open").map(e=>Number.parseInt(window.getComputedStyle(e).zIndex,10)).filter(e=>Number.isFinite(e));return String((e.length?Math.max(...e):1040)+10)}_closeOpenedModals(){[...document.getElementsByClassName("modal")].forEach(e=>{e&&e.classList.contains("show")&&("undefined"!=typeof bootstrap&&bootstrap.Modal?.getOrCreateInstance?bootstrap.Modal.getOrCreateInstance(e).hide():console.warn(Re(this._params.lang,qi).bootstrap_not_found))}),[...document.getElementsByClassName("vg-modal")].forEach(e=>{if(e&&e.classList.contains("show")){const t=le.getOrCreateInstance(e);t.hide([t])}}),[...document.getElementsByClassName("ox-modal")].forEach(e=>{e&&e.classList.contains("is-open")&&okaux.Modal.getOpenInstances().forEach(e=>{e.hide()})})}_alertCollapse(e,t){const i=this;let n=s.A.find("."+i._params.classes.alertCollapse);if(!n){n=document.createElement("div"),n.classList.add(i._params.classes.alertCollapse),n.classList.add("vg-collapse"),n.id=i._params.classes.general+"-"+(0,r.PR)();const s=i.setDataRelationStatus(n,t,e,"collapse");s.classList.add(Wi,Wi+"-"+t),n.append(s),i._element.prepend(n)}let a=wt.getOrCreateInstance(n,{toggle:!1});a.toggle(),i._params.alert.delay>0&&setTimeout(()=>{a.hide()},i._params.alert.delay)}_alertToast(e,t){const i=this._prepareAlertResponse(t,e),s=this._getToastParams(t);this._params.alert.toast?.closeModalsBeforeToast&&this._closeOpenedModals(),i.title?Hi.A.run([i.title,i.message],s):Hi.A.run(i.message,s)}_getToastParams(e){const t="error"===e?"danger":e,i="danger"===e?"error":e,s=this._params.alert.delay>0?this._params.alert.delay:3e3,n={},{closeModalsBeforeToast:a,...o}=this._params.alert.toast||{};return["static","placement","autohide","delay","enableClickToast","enableButtonClose","keyboard","theme","drag","resize","stack","animation","ajax"].forEach(e=>{e in this._params.alert&&(n[e]=this._params.alert[e])}),(0,r._v)({theme:t||"dark",type:i||null,enableButtonClose:!0,autohide:this._params.alert.delay>0,delay:s},n,o)}setDataRelationStatus(e,t,i,r){let n=s.A.find("."+Wi+"-content",e);const a=this._prepareAlertResponse(t,i),o=(a.title?(0,d.A)("string").h4({class:Wi+"-content--title"},a.title):"")+a.message;if(n)s.A.find(".vg-modal-body",e).innerHTML=o;else{const e=(0,d.A)("dom");n=e.div({class:Wi+"-"+r},[e.div({class:Wi+"-content"},[e.i({class:Wi+"-content--icon"},(0,f.z)(t),{isHTML:!0}),e.div({class:Wi+"-content--text"},o,{isHTML:!0})])])}return n}_prepareAlertResponse(e,t){let i=(0,r.OM)(t?.response)||t;if((0,r.Gv)(t)){if((0,r.Gv)(t.response)&&"view"in t.response)return{title:"",message:t.response.view};if("string"!=typeof i){if("danger"===e){if(i.title="title"in i?i.title:Fe(this._params.lang,"errors").title,"code"in t&&200!==t.code){const e={400:Re(this._params.lang,"errors")[400],401:Re(this._params.lang,"errors")[401],403:Re(this._params.lang,"errors")[403],404:Re(this._params.lang,"errors")[404],413:Re(this._params.lang,"errors")[413],419:Re(this._params.lang,"errors")[419],422:Re(this._params.lang,"errors")[422],500:Re(this._params.lang,"errors")[500],504:Re(this._params.lang,"errors")[504]};i.message=e[t.code]||Re(this._params.lang,"errors").went_wrong,i.title+=" ("+t.code+")"}if("errors"in i&&this._params.alert.errors){let e=(0,r.OM)(i.errors)||null;if(i.message=[],(0,r.Gv)(e))for(const t in e)Array.isArray(e[t])?e[t].forEach(e=>i.message.push(e)):i.message.push(e[t])}}const s=(0,d.A)("string");let n="";return Array.isArray(i.message)?i.message.forEach(e=>{n+=s.div({class:Wi+"-content--message"},e)}):n=s.div({class:Wi+"-content--message"},i.message),{title:this._params.alert.title&&i.title||"",message:n}}}return{title:"",message:"string"==typeof i?i:""}}static init(e,t={}){Gi.getOrCreateInstance(e,t).build()}static buttonClick(e,t,i="before"){const n=s.A.find(e);if(n){const e=Gi.getOrCreateInstance(n);n.addEventListener("vg.fs."+i,i=>{(0,r.g7)(t,[n,e])})}}}g.A.on(document,Ki,function(e){if(!t.p.has(e.target,"data-vgformsender"))return;const i=Gi.getOrCreateInstance(e.target,{});if(i){if(i._params.validate&&!i._element.checkValidity())return i._handleValidateError(e);if(!i._params.submit){e.preventDefault();const t=function(e,t){return t.forEach(function(t){(0,r.Gv)(t)&&Object.keys(t).forEach(function(i){let s=(0,r.OM)(t[i]);Array.isArray(s)||(0,r.Gv)(s)?e.append(i,JSON.stringify(s)):e.append(i,s)})}),e};let s=new FormData(i._element),n=i._params.fields;return Array.isArray(n)&&n.length&&(s=t(s,n)),i.request(e,s)}}});const Yi=Gi;function Xi(e){return Array.prototype.slice.call(arguments,1).forEach(t=>{t&&Object.keys(t).forEach(i=>{e[i]=t[i]})}),e}const Zi=function e(t,i){function s(e,s,r){if("undefined"==typeof document)return;if("number"==typeof(r=Xi({},i,r)).expires){const e=864e5;r.expires=new Date(Date.now()+r.expires*e)}r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);let n="";return Object.keys(r).forEach(e=>{if(r[e]&&(n+="; "+e,!0!==r[e])){const t=String(r[e]).split(";")[0];n+="="+t}}),document.cookie=e+"="+t.write(s,e)+n}return Object.create({set:s,get:function(e){if("undefined"==typeof document||arguments.length&&!e)return;const i=document.cookie?document.cookie.split("; "):[],s={};for(let r=0;r<i.length;r++){const n=i[r].split("="),a=n.slice(1).join("="),o=n[0];try{const i=decodeURIComponent(o);if(s[i]=t.read(a,i),e===i)break}catch(e){}}return e?s[e]:s},remove:function(e,t){s(e,"",Xi({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Xi({},this.attributes,t))},withConverter:function(t){return e(Xi({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(i)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),Ji="vg.lawcookie",Qi="show",es=`${Ji}.hide`,ts=`${Ji}.hidden`,is=`${Ji}.show`,ss=`${Ji}.shown`,rs=`click.${Ji}.data.api`;class ns extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({storage:"local",delay:500,cookie:{name:"lawCookie",value:"yes",attributes:{}},animation:{enable:!0,in:"animate__fadeInUp",out:"animate__fadeOutDown",delay:800},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0}},t)),this._storage=this._createStorage(),this._params.animation.delay=this._params.animation.enable?this._params.animation.delay:0,this._animation(this._element,ns.NAME_KEY,this._params.animation)}static get NAME(){return"lawcookie"}static get NAME_KEY(){return Ji}_isConsented(){return this._storage.get()===this._params.cookie.value}toggle(){return this._isConsented()?this.hide():this.show()}show(){(0,r.d6)(this._element)||this._isConsented()||g.A.trigger(this._element,is).defaultPrevented||(this._element.classList.add(Qi),this._queueCallback(()=>{g.A.trigger(this._element,ss)},this._element,!0,this._params.delay))}hide(){g.A.trigger(this._element,es).defaultPrevented||(this._element.classList.remove(Qi),this._queueCallback(()=>{g.A.trigger(this._element,ts)},this._element,!0,this._params.animation.delay))}_createStorage(){const{name:e,value:t,attributes:i}=this._params.cookie;return"cookie"===this._params.storage?{get:()=>Zi.get(e),set:()=>Zi.set(e,t,i)}:{get:()=>localStorage.getItem(e),set:()=>localStorage.setItem(e,t)}}accept(){this._storage.set()}static reset(){const{name:e}=ns.getDefaultParams().cookie;Zi.remove(e),localStorage.removeItem(e),location.reload()}static getDefaultParams(){return(0,r._v)({cookie:{name:"lawCookie"}},{})}dispose(){const{name:e}=this._params.cookie;Zi.remove(e),localStorage.removeItem(e),super.dispose()}static init(e,t={}){ns.getOrCreateInstance(e,t).toggle()}}(0,f.P)(ns),g.A.on(document,rs,'[data-vg-toggle="lawcookie"]',function(e){if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,r.d6)(this))return;const t=s.A.find("#vg-lawcookie");if(!t)return;const i=ns.getOrCreateInstance(t);i.accept(),i.hide()}),g.A.on(document,rs,'[data-vg-toggle="lawcookie-clear"]',function(e){if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,r.d6)(this))return;const t=s.A.find("#vg-lawcookie");t&&(ns.getOrCreateInstance(t).dispose(),ns.reset())});const as=ns,os="loadmore",ls="vg."+os,hs=`${ls}.loaded`,ds=`${ls}.before.load`,cs="vg-collapse",_s="show",us=`click.${ls}.data.api`;class ms extends e.A{static get NAME(){return os}static get NAME_KEY(){return ls}constructor(e,t){super(e,t),this._params=this._getParams(e,(0,r._v)({lang:document.documentElement.lang||"ru",limit:0,offset:0,output:!0,autohide:!0,animate:!1,append:"after",mode:"button",threshold:100,debug:!1,detach:!1,button:{text:"",send:"Загружаю...",show:"Показываю...",loader:!1,classes:[]},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!1,data:{}}},t)),this._observer=null,this._isScrollMode="scroll"===this._params.mode,this._isToggleElement=e.hasAttribute("data-vg-toggle"),this._params.button.send=Be(this._params.lang,os).send,this._params.button.show=Be(this._params.lang,os).show,this._params.button.text||(this._params.button.text=this._isToggleElement?this._element.innerHTML.trim()||Be(this._params.lang,os)["text-ajax"]:this._params.ajax.route?Be(this._params.lang,os)["text-ajax"]:Be(this._params.lang,os)["text-more"]),this._isToggleElement?this._initializeAsButton():this._initializeContainer()}_initializeAsButton(){this._isScrollMode&&this._initScrollMode()}_initializeContainer(){const{elements:e,limit:t}=this._params,i=this._element,r=s.A.findAll(`.${e}`,i);!this._params.ajax.route&&(r.length<=t||this._params.offset>=r.length)||(r.forEach((e,i)=>{e.classList.toggle(_s,i<t),e.classList.toggle(cs,i>=t)}),"button"===this._params.mode?this._createAndInsertButton(i):this._isScrollMode&&this._initScrollMode(),0===this._params.offset&&(this._params.offset=t))}_createAndInsertButton(e){const i=document.createElement("button"),s=(0,r.OM)(e.dataset.buttonText)||this._params.button.text,n={limit:this._params.limit,offset:this._params.offset||this._params.limit,output:this._params.output,autohide:this._params.autohide,animate:this._params.animate,append:this._params.append,mode:this._params.mode,threshold:this._params.threshold,debug:this._params.debug,detach:this._params.detach,elements:this._params.elements,"vg-toggle":"loadmore",target:`#${e.id}`};Object.assign(n,(0,r.OM)(e.dataset.params)),Object.keys(n).forEach(e=>{t.p.set(i,`data-${e}`,n[e])}),i.textContent=s,i.classList.add(...this._params.button.classes),e.parentNode.insertBefore(i,e.nextSibling)}_initScrollMode(){this._setupIntersectionObserver(),this._observeLastVisibleItem()}_setupIntersectionObserver(){this._observer||(this._observer=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&(this._params.debug&&console.log("[VGLoadMore] Пересечение — вызов toggle"),this.toggle())})},{root:null,rootMargin:`0px 0px ${this._params.threshold}px 0px`,threshold:.1}))}_observeLastVisibleItem(){if(!this._observer)return;this._observer.disconnect();const e=this._getTargetContainer(),t=s.A.findAll(`.${this._params.elements}`,e).filter(e=>e.classList.contains(_s)),i=t[t.length-1];i instanceof Element&&this._observer.observe(i)}toggle(e){this._params.debug&&console.log("[VGLoadMore] toggle()"),g.A.trigger(this._element,ds).defaultPrevented||((this._isToggleElement||["BUTTON","A"].includes(this._element.tagName)&&!this._isScrollMode)&&(this._element.disabled=!0,this._element.innerHTML=this._params.ajax.route?this._params.button.send:this._params.button.show),this._params.ajax.route?this.ajax(e):this.staticLoad(e))}ajax(e){const t=this._params.ajax.target?.trim();let i=null;if(i=t?s.A.find(t):this._element,!i)return void console.error("[VGLoadMore] target элемент не найден:",this._params.ajax.target);const n=this._params.button.text;this._params.ajax.data=(0,r._v)(this._params.ajax.data,{limit:this._params.limit,offset:this._params.offset}),this._route((t,s,a)=>{if("error"===t||"string"!=typeof s?.response)return;this._params.output&&i.insertAdjacentHTML("after"===this._params.append?"beforeend":"afterbegin",s.response),this._params.offset+=this._params.limit,this._restoreElementState(n),this._observeLastVisibleItem();const o=!s.response.trim();this._params.autohide&&o&&this._autohideTrigger(),g.A.trigger(this._element,hs,{stats:t,data:s}),(0,r.g7)(e,[this,s,a,t])},e=>{this._restoreElementState(n),console.error("[VGLoadMore] AJAX ошибка",e)})}staticLoad(e){const t=this._getTargetContainer(),i=s.A.findAll(`.${this._params.elements}`,t),n=this._params.offset,a=n+this._params.limit,o=i.slice(n,a);if(0===o.length)return;(this._isToggleElement||["BUTTON","A"].includes(this._element.tagName)&&!this._isScrollMode)&&(this._element.disabled=!0,this._element.innerHTML=this._params.button.show),o.forEach(e=>{e.classList.replace(cs,_s),this._params.animate&&(e.style.opacity=0,requestAnimationFrame(()=>{e.style.transition="opacity 0.3s ease",e.style.opacity=1}))}),this._params.offset=a,this._observeLastVisibleItem();const l=i.slice(a);this._params.autohide&&0===l.length&&this._autohideTrigger(),this._restoreElementState(this._params.button.text),g.A.trigger(this._element,hs,{stats:"success",data:{items:o,offset:this._params.offset,remaining:l.length}}),(0,r.g7)(e,[this,this._element])}_getTargetContainer(){return s.A.find(this._params.target)||(this._isToggleElement?this._element.parentNode:this._element)}_restoreElementState(e){(this._isToggleElement||"BUTTON"===this._element.tagName)&&!this._isScrollMode&&(this._element.disabled=!1,this._element.innerHTML=e)}_autohideTrigger(){this._isScrollMode?(this._observer?.disconnect(),this._observer=null):this._params.detach&&this._element.parentNode?this._element.remove():(this._element.classList.add(cs),this._element.setAttribute("aria-hidden","true"))}dispose(){this._observer?.disconnect(),super.dispose()}}g.A.on(document,"DOMContentLoaded",()=>{s.A.findAll("[data-vgloadmore]").forEach(e=>{!e.dataset.initialized&&ms.getOrCreateInstance(e),e.dataset.initialized="true"})}),g.A.on(document,us,'[data-vg-toggle="loadmore"]',function(e){["A","AREA"].includes(this.tagName)&&e.preventDefault(),ms.getOrCreateInstance(this).toggle()});const ps=ms,gs="vg.nav",fs="show",bs="fade",vs="active",ys=`${gs}.hide`,ws=`${gs}.hidden`,Es=`${gs}.show`,As=`${gs}.shown`,Ss=`mouseover.${gs}.data.api`,Cs=`mouseout.${gs}.data.api`,xs=`click.${gs}.data.api`,Ls=`keyup.${gs}.data.api`;class Is extends e.A{constructor(e,t={}){super(e),this._params=this._getParams(e,(0,r._v)({breakpoint:"lg",placement:"horizontal",hover:!0,dropListScroll:!0,hoversmoothfirstlevel:{enable:!1,horizontalOnly:!0},animation:{enable:!0,timeout:700},toggle:'<span class="default"></span>',hamburger:{enable:!0,always:!1,title:"",body:null,target:"#sidebar-nav"},callbacks:{afterInit:r.lQ,afterClick:r.lQ}},t)),this._classes={hamburgerActive:"vg-nav-hamburger-active",hamburgerAlways:"vg-nav-hamburger-always",hamburger:"vg-nav-hamburger",container:"vg-nav-container",wrapper:"vg-nav-wrapper",dropListScroll:"vg-nav-drop-list-scroll",active:"vg-nav-active",expand:"vg-nav-expand",cloned:"vg-nav-cloned",hover:"vg-nav-hover",flip:"vg-nav-flip",XXXL:"vg-nav-xxxl",XXL:"vg-nav-xxl",XL:"vg-nav-xl",LG:"vg-nav-lg",MD:"vg-nav-md",SM:"vg-nav-sm",XS:"vg-nav-xs"},this._navigation=null,this.navigation="."+this._classes.wrapper,!1===this._params.animation.enable&&(this._params.animation.timeout=10),this._openDrops=new Map,this._pointerPosition=null,this._handleScroll=this._handleScroll.bind(this),this._handleResize=this._handleResize.bind(this)}static get NAME(){return"nav"}static get NAME_KEY(){return gs}get navigation(){return this._navigation}set navigation(e){let t=s.A.find(e,this._element);t&&(this._navigation=t)}build(){if(!this.navigation)return;let e=this._params,i=this._classes;if(this._element.classList.add(i.container),this._element.classList.add("vg-nav-"+e.placement),this._element.classList.toggle(i.dropListScroll,!!e.dropListScroll),e.hamburger.always?this._element.classList.add(i.hamburgerAlways):e.breakpoint?!1!==e.breakpoint&&this._element.classList.add("vg-nav-"+e.breakpoint):this._element.classList.add(i.expand),e.hamburger.enable&&!s.A.find("."+i.hamburger,this._element)){const s=e.hamburger.target||"#sidebar-nav";let r="",n='<span class="'+i.hamburger+'--lines"><span></span><span></span><span></span></span>';e.hamburger.title&&(r='<span class="'+i.hamburger+'--title">'+e.hamburger.title+"</span>"),null!==e.hamburger.body&&(n=e.hamburger.body);let a=document.createElement("a");a.classList.add(i.hamburger),t.p.set(a,"data-vg-toggle","sidebar"),t.p.set(a,"href",s),a.innerHTML=r+n,this._element.append(a)}if(e.toggle){let t=[...s.A.findAll(".dropdown > a",this._element)],i='<span class="toggle">'+e.toggle+"</span>";t.length&&t.forEach(function(e){e.querySelector(".toggle")||e.closest(".dots")||(e.setAttribute("aria-expanded","false"),e.insertAdjacentHTML("beforeend",i))})}"afterInit"in this._params.callbacks&&(0,r.g7)(this._params.callbacks.afterInit,[this])}show(e){let t=e.relatedTarget;if(!t||(0,r.d6)(t))return;if(t.closest(".dropdown-content")||t.classList.add("first"),g.A.trigger(t,Es,{relatedTarget:e}).defaultPrevented)return;let i=s.A.find(".dropdown-content",t),n=t.firstElementChild;n&&n.setAttribute("aria-expanded","true"),i.classList.add(fs),t.classList.add(vs);const a=new de({reference:t,drop:i,placement:"bottom-start",fallbackPlacements:["top-start","bottom-end","top-end"],offset:[0,6],boundary:"clippingParents",autoFlip:!0,overflowProtection:!0});a._setPlacement(),this._openDrops.set(i,{reference:t,placement:a,scrollHandler:this._handleScroll,resizeHandler:this._handleResize}),window.addEventListener("scroll",this._handleScroll,{passive:!0,capture:!0}),window.addEventListener("resize",this._handleResize),this._queueCallback(()=>{i.classList.add(bs),g.A.trigger(t,As,e)},i,!0,10)}hide(e){const t=this;if("ontouchstart"in document.documentElement)for(const e of[].concat(...document.body.children))g.A.off(e,"mouseover",r.lQ);let i=e.relatedTarget;if("elm"in e&&e.elm&&(i=e.elm),i){if(g.A.trigger(i,ys).defaultPrevented)return;i.classList.remove(vs),i.classList.contains("first")&&i.classList.remove("first"),[...s.A.findAll("."+fs,i)].forEach(function(i,s){i.classList.remove(bs);let r=i.closest(".dropdown");r.classList.contains(vs)&&r.classList.remove(vs);let n=i.previousElementSibling;if(n&&n.setAttribute("aria-expanded","false"),0===s){const s=()=>{i.classList.remove(fs),g.A.trigger(i,ws,e)};t._queueCallback(s,i,!0,500)}const a=t._openDrops.get(i);a&&(window.removeEventListener("scroll",a.scrollHandler,{capture:!0}),window.removeEventListener("resize",a.resizeHandler),t._openDrops.delete(i))})}}_handleScroll(){for(const[e,t]of this._openDrops.entries())if(null!==e.offsetParent){if(t.placement._setPlacement(),!this._isElementInViewport(e)){const e=t.reference;this.hide({relatedTarget:e})}}else this._cleanupDrop(e)}_handleResize(){for(const[e,t]of this._openDrops.entries())null!==e.offsetParent&&t.placement._setPlacement()}_cleanupDrop(e){const t=this._openDrops.get(e);t&&(window.removeEventListener("scroll",t.scrollHandler,{capture:!0}),window.removeEventListener("resize",t.resizeHandler),this._openDrops.delete(e))}_isElementInViewport(e){const t=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,r=t.top<=i&&t.top+t.height>=0,n=t.left<=s&&t.left+t.width>=0;return r&&n}_updatePointerPosition(e){e&&"number"==typeof e.clientX&&"number"==typeof e.clientY&&(this._pointerPosition={x:e.clientX,y:e.clientY})}_isHorizontalPointerMove(e){if(!this._pointerPosition||!e)return!1;const t=e.clientX-this._pointerPosition.x,i=e.clientY-this._pointerPosition.y;return Math.abs(t)>Math.abs(i)&&Math.abs(t)>0}_isFirstLevelDropdown(e){return!!e&&!e.closest(".dropdown-content")}_hasDirectDropdownContent(e){return!(!e||!e.children)&&[...e.children].some(e=>e.classList&&e.classList.contains("dropdown-content"))}_isAdjacentDropdown(e,t){return!(!e||!t||e.parentElement!==t.parentElement||e.previousElementSibling!==t&&e.nextElementSibling!==t)}_canSmoothSwitchFirstLevel(e,t,i){const s=this._params.hoversmoothfirstlevel||{};return!(!s.enable||!t||!i||t===i||!this._isFirstLevelDropdown(t)||!this._isFirstLevelDropdown(i)||!this._hasDirectDropdownContent(t)||!this._hasDirectDropdownContent(i)||!this._isAdjacentDropdown(t,i)||s.horizontalOnly&&!this._isHorizontalPointerMove(e))}static init(e,t={}){const i=Is.getOrCreateInstance(e,t);i.build();let n=s.A.findAll(".dropdown",i.navigation);i._params.hover&&!(0,r.Xb)()&&(g.A.on(i.navigation,`mousemove.${gs}.data.api`,function(e){i._updatePointerPosition(e)}),[...n].forEach(function(e){let t=null;g.A.on(e,Ss,function(e){if(t)return;let s=e.target.closest(".dropdown");if(!s)return;if(!i.navigation.contains(s))return;t=s;const r=e.relatedTarget?.closest(".dropdown"),n=i._canSmoothSwitchFirstLevel(e,s,r);n||Is.hideOpenDrops(e);let a={relatedTarget:s};i.show(a),n&&r&&r.classList.contains(vs)&&i.hide({relatedTarget:r}),i._updatePointerPosition(e)}),g.A.on(e,Cs,function(e){if(!t)return;let s=e.relatedTarget?.closest(".dropdown"),r=s,n=t;for(;r;){if(r===t)return;r=r.parentNode}if(i._canSmoothSwitchFirstLevel(e,n,s))return t=null,void i._updatePointerPosition(e);t=null,i.hide({relatedTarget:r,elm:n}),i._updatePointerPosition(e)})}));const a=document.querySelector(i._params.hamburger.target||"#sidebar-nav");let o=i._element.querySelector("."+i._classes.hamburger);a&&o&&(a.addEventListener("vg.sidebar.show",function(){o.classList.add(i._classes.hamburgerActive)}),a.addEventListener("vg.sidebar.hide",function(){o.classList.remove(i._classes.hamburgerActive)}))}static clearDrops(e){2===e.button||"keyup"===e.type&&"Tab"!==e.key||Is.hideOpenDrops(e)}static hideOpenDrops(e){[...s.A.findAll(".dropdown:not(.disabled):not(:disabled).active")].forEach(t=>{let i=e.target;if(t!==i.closest(".dropdown")){const e=t.closest(".vg-nav"),s=Is.getInstance(e);if(!s)return;let r=!!e.querySelector(".first"),n=!!i.closest(".dropdown-content");if(r&&n)return;const a={relatedTarget:t};s.hide(a)}})}}g.A.on(document,Ls,Is.clearDrops),g.A.on(document,xs,Is.clearDrops),g.A.on(document,xs,".vg-nav a",function(e){if(!t.p.has(this,"aria-expanded"))return;let i=this.closest(".vg-nav");const n=Is.getOrCreateInstance(i);if("afterClick"in n._params.callbacks&&(0,r.g7)(n._params.callbacks.afterClick,[n,e,this]),n._params.hover&&!(0,r.Xb)())return;e.preventDefault();let a=this.parentNode;if(!a)return;if((0,r.d6)(a)||!(0,r.zN)(a))return;let o=!!i.querySelector(".first");if(this.closest(".dropdown-content")&&o){if(a.classList.contains("active"))return void n.hide({relatedTarget:a})}else[...s.A.findAll(".active",i)].forEach(function(e){n.hide({relatedTarget:e})});n.show({relatedTarget:a})});const Ps=Is;var ks=i(546);const Ms="nestable",Ds="vg.nestable",Ts='[data-vg-toggle="nestable"]',Os="is-dragging",zs="vg-nestable-placeholder",Ns="vg-nestable-inner",$s="vg-nestable-handle",Hs="vg-nestable-handle-icon",Fs="vg-nestable-collapse-toggle",Rs="vg-nestable-empty",Bs="is-drop-target",js="is-drop-denied",Us="is-drop-before",qs="is-drop-attachable",Vs="is-drop-inside",Ws="is-drop-after",Ks=`${Ds}.start`,Gs=`${Ds}.change`,Ys=`${Ds}.end`,Xs=`${Ds}.save`,Zs=`${Ds}.init`,Js=`${Ds}.refresh`,Qs=`${Ds}.pointerdown`,er=`${Ds}.move`,tr=`${Ds}.drop`,ir=`${Ds}.transfer`,sr=`${Ds}.placeholdermove`,rr=`${Ds}.destroy`,nr=`${Ds}.collapse`,ar=`${Ds}.expand`;class or extends e.A{static _groups=new Map;constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({disabled:!1,disabledattribute:"data-disabled",listselector:".vg-nestable-list",itemselector:".vg-nestable-item",handleselector:".vg-nestable-handle",idattribute:"data-id",serializedata:!0,childlistclass:"vg-nestable-list",handleicon:"",emptytext:"Drop items here",indent:18,maxdepth:6,moveaxis:"default",hoverthreshold:.25,neighborchangethreshold:0,showplaceholder:!0,group:"",connect:!1,accept:null,collapse:{enabled:!0,open:!0,showtext:(0,f.z)("plus"),hidetext:(0,f.z)("minus")},callbacks:{init:null,refresh:null,pointerdown:null,start:null,move:null,placeholdermove:null,drop:null,transfer:null,change:null,collapse:null,expand:null,end:null,save:null,destroy:null},ajax:{route:"",method:"post",field:"items",data:{},loader:!1,once:!1,output:!1,timeout:0}},t)),this._rootList=this._resolveRootList(),this._draggedItem=null,this._placeholder=null,this._dragElement=null,this._dragLayer=null,this._isDragging=!1,this._startSnapshot="",this._sourceInstance=this,this._lastDropInstance=this,this._activeDropList=null,this._activeDropItem=null,this._dragBaseDepth=1,this._mouse={startX:0,startY:0,startItemX:0,grabOffsetX:0,grabOffsetY:0,x:0,y:0},this._previousBodyCursor="",this._boundOnMouseDown=this._onMouseDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._boundOnMouseUp=this._onMouseUp.bind(this),this._boundOnPointerDown=this._onPointerDown.bind(this),this._boundOnPointerMove=this._onPointerMove.bind(this),this._boundOnPointerUp=this._onPointerUp.bind(this),this._boundOnPointerCancel=this._onPointerCancel.bind(this),this._boundOnTouchStart=this._onTouchStart.bind(this),this._boundOnTouchMove=this._onTouchMove.bind(this),this._boundOnTouchEnd=this._onTouchEnd.bind(this),this._boundOnTouchCancel=this._onTouchCancel.bind(this),this._boundOnKeyDown=this._onKeyDown.bind(this),this._supportsPointerEvents="undefined"!=typeof window&&"PointerEvent"in window,this._activePointerId=null,this._activeTouchId=null,this._keyboardDraggedItem=null,this._keyboardStartSnapshot="",this._keyboardOrigin=null,this._liveRegion=null,this._rootList&&(this._registerGroup(),this.refresh(),this._ensureLiveRegion(),this._bindEvents(),this._emit("init",{payload:this.serialize()}))}static get NAME(){return Ms}static get NAME_KEY(){return Ds}_getEventKey(e){switch(e){case"init":return Zs;case"refresh":return Js;case"pointerdown":return Qs;case"start":return Ks;case"move":return er;case"placeholdermove":return sr;case"drop":return tr;case"transfer":return ir;case"change":return Gs;case"end":return Ys;case"save":return Xs;case"destroy":return rr;case"collapse":return nr;case"expand":return ar;default:return`${Ds}.${e}`}}_emit(e,t={}){const i={action:e,instance:this,...t};g.A.trigger(this._element,this._getEventKey(e),i);const s=this._params?.callbacks?.[e];if("function"==typeof s)try{s(i)}catch(t){console.error(`[${Ms}] callback "${e}" failed`,t)}return i}_getGroupName(){const e=this._params?.group;return null==e?"":String(e).trim()}_registerGroup(){const e=this._getGroupName();e&&(or._groups.has(e)||or._groups.set(e,new Set),or._groups.get(e).add(this))}_unregisterGroup(){const e=this._getGroupName();if(!e||!or._groups.has(e))return;const t=or._groups.get(e);t.delete(this),t.size||or._groups.delete(e)}_getConnectedInstances(){if(!this._params.connect)return[this];const e=this._getGroupName();return e&&or._groups.has(e)?Array.from(or._groups.get(e)).filter(e=>e&&e._rootList):[this]}_findOwnerInstanceByElement(e){return e&&this._getConnectedInstances().find(t=>t._rootList&&t._rootList.contains(e))||null}_canAcceptItem(e,t){if(this._isTreeDisabled())return!1;const i=this._params?.accept;if("function"!=typeof i)return!0;try{return!!i(e,t,this)}catch(e){return console.error(`[${Ms}] accept() failed`,e),!1}}refresh(){const e=this._isTreeDisabled();this._element.classList.toggle("is-disabled",e),this._element.setAttribute("aria-disabled",e?"true":"false"),this._getItems().forEach(e=>{const t=this._ensureItemLayout(e),i=this._isItemDragDisabled(e);e.classList.toggle("is-drag-disabled",i),t&&(t.style.cursor=i?"not-allowed":"grab",t.style.userSelect="none",t.style.touchAction="none",t.setAttribute("aria-disabled",i?"true":"false"),["BUTTON","A","INPUT"].includes(t.tagName)||t.setAttribute("role","button"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.hasAttribute("aria-label")||t.setAttribute("aria-label","Drag item")),this._syncItemCollapse(e)}),this._syncEmptyState(),this._emit("refresh",{items:this._getItems().length})}expandItem(e){return this._setItemExpanded(e,!0)}collapseItem(e){return this._setItemExpanded(e,!1)}expandAll(){let e=0;return this._getItems().forEach(t=>{this.expandItem(t)&&(e+=1)}),e}collapseAll(){let e=0;return this._getItems().forEach(t=>{this.collapseItem(t)&&(e+=1)}),e}_setItemExpanded(e,t){const i="string"==typeof e?this._element.querySelector(e):e;if(!i||!i.matches?.(this._params.itemselector)||!this._rootList.contains(i))return!1;const s=this._getDirectChildBySelector(i,this._params.listselector);if(!s)return!1;if(s.classList.contains("show")===t)return!1;const r=wt.getOrCreateInstance(s,{toggle:!1});return t?r.show():r.hide(),this._emit(t?"expand":"collapse",{item:i,list:s,expanded:t}),!0}_syncEmptyState(){if(!this._rootList)return;const e=Array.from(this._rootList.children).some(e=>e.matches(this._params.itemselector));let t=this._getDirectChildBySelector(this._rootList,`.${Rs}`);if(e)return t?.remove(),void this._rootList.classList.remove("is-empty");t||(t=document.createElement("ol"===this._rootList.tagName?.toLowerCase()?"li":"div"),t.className=Rs,t.setAttribute("aria-live","polite"),this._rootList.append(t)),t.textContent=String(this._params.emptytext||"Drop items here"),this._rootList.classList.add("is-empty")}_syncItemCollapse(e){if(!e||!this._params.collapse?.enabled)return;const t=this._getDirectChildBySelector(e,`.${Ns}`),i=t?this._getDirectChildBySelector(t,`.${$s}`):null,s=this._getDirectChildBySelector(e,this._params.listselector);let r=t?this._getDirectChildBySelector(t,`.${Fs}`):null;if(!t||!s)return void(r&&r.remove());s.id||(s.id=`vg-nestable-collapse-${Math.random().toString(36).slice(2,10)}`);const n=s.classList.contains("vg-collapse");s.classList.add("vg-collapse"),n||(this._params.collapse.open?s.classList.add("show"):s.classList.remove("show")),r?i&&r.previousElementSibling!==i&&t.insertBefore(r,i.nextSibling):(r=document.createElement("button"),r.type="button",r.className=Fs,i?t.insertBefore(r,i.nextSibling):t.insertBefore(r,t.firstChild)),r.setAttribute("data-vg-toggle","collapse"),r.setAttribute("data-vg-target",`#${s.id}`),r.setAttribute("aria-controls",s.id);const a=ks.A.toSafeHtmlString(this._params.collapse.showtext||(0,f.z)("chevron")),o=ks.A.toSafeHtmlString(this._params.collapse.hidetext||(0,f.z)("chevron"));r.setAttribute("data-show-text",a),r.setAttribute("data-hide-text",o);const l=s.classList.contains("show");r.setAttribute("aria-expanded",l?"true":"false"),r.innerHTML=l?o:a,wt.getOrCreateInstance(s,{toggle:!1})}_ensureItemLayout(e){if(!e||!this._params.handleselector)return null;const t=this._ensureInnerLayout(e);let i=this._getDirectChildBySelector(t,this._params.handleselector);if(!i){const t=Array.from(e.querySelectorAll(this._params.handleselector)).find(t=>t.closest(this._params.itemselector)===e);t&&(i=t)}if(!i){if(this._params.handleselector!==`.${$s}`)return null;i=document.createElement("div"),i.classList.add($s)}if(i.parentElement===t&&i===t.firstElementChild||t.insertBefore(i,t.firstChild),!i.querySelector(`:scope > .${Hs}`)){const e=document.createElement("span");e.className=Hs,e.setAttribute("aria-hidden","true"),e.innerHTML=ks.A.toSafeHtmlString(this._params.handleicon||(0,f.z)("dots-six-vertical")||":::"),i.prepend(e)}return i}_ensureInnerLayout(e){let t=this._getDirectChildBySelector(e,`.${Ns}`);const i=this._getDirectChildBySelector(e,this._params.listselector);return t||(t=document.createElement("div"),t.className=Ns,e.insertBefore(t,i||e.firstChild)),Array.from(e.childNodes).filter(e=>e!==t&&!(e.nodeType===Node.ELEMENT_NODE&&e.matches(this._params.listselector))).forEach(e=>t.append(e)),t.parentElement!==e&&e.insertBefore(t,i||e.firstChild),t}_getDirectChildBySelector(e,t){return e&&t&&Array.from(e.children).find(e=>e.matches(t))||null}serialize(){return this._rootList?this._serializeList(this._rootList):[]}save(){const e=this.serialize(),t=this._params.ajax?.route;return t?(this._emit("save",{payload:e,status:"start"}),new Promise((i,s)=>{const n=this._params.ajax||{},a=n.field||"items",o=String(n.method||"post").toLowerCase(),l=Number(n.timeout||0),h=(0,r._v)(n.data||{},{[a]:e}),d=new ui.A,c={onSuccess:t=>{this._emit("save",{payload:e,status:"success",response:t}),i(t)},onError:t=>{this._emit("save",{payload:e,status:"error",error:t}),s(t)}};setTimeout(()=>{switch(o){case"get":d.get(t,c);break;case"delete":d.delete(t,c);break;default:d.post(t,h,c)}},l)})):(this._emit("save",{payload:e,status:"skipped"}),Promise.resolve(e))}dispose(){this._rootList&&(this._supportsPointerEvents?this._rootList.removeEventListener("pointerdown",this._boundOnPointerDown):(this._rootList.removeEventListener("mousedown",this._boundOnMouseDown),this._rootList.removeEventListener("touchstart",this._boundOnTouchStart)),this._rootList.removeEventListener("keydown",this._boundOnKeyDown)),document.removeEventListener("mousemove",this._boundOnMouseMove),document.removeEventListener("mouseup",this._boundOnMouseUp),document.removeEventListener("pointermove",this._boundOnPointerMove),document.removeEventListener("pointerup",this._boundOnPointerUp),document.removeEventListener("pointercancel",this._boundOnPointerCancel),document.removeEventListener("touchmove",this._boundOnTouchMove),document.removeEventListener("touchend",this._boundOnTouchEnd),document.removeEventListener("touchcancel",this._boundOnTouchCancel),this._clearDragState(),this._clearKeyboardDragState(),this._liveRegion?.parentElement&&this._liveRegion.remove(),this._liveRegion=null,this._unregisterGroup(),this._emit("destroy"),super.dispose()}_bindEvents(){this._rootList.addEventListener("keydown",this._boundOnKeyDown),this._supportsPointerEvents?this._rootList.addEventListener("pointerdown",this._boundOnPointerDown):(this._rootList.addEventListener("mousedown",this._boundOnMouseDown),this._rootList.addEventListener("touchstart",this._boundOnTouchStart,{passive:!1}))}_resolveRootList(){return this._element?this._element.matches(this._params.listselector)?this._element:this._element.querySelector(this._params.listselector):null}_getItems(e=this._rootList){return e?Array.from(e.querySelectorAll(this._params.itemselector)):[]}_onMouseDown(e){0===e.button&&(this._startInteraction(e.target,e.clientX,e.clientY,e),this._draggedItem&&(document.addEventListener("mousemove",this._boundOnMouseMove),document.addEventListener("mouseup",this._boundOnMouseUp)))}_onMouseMove(e){this._processDragMove(e.clientX,e.clientY,e)}_onMouseUp(){document.removeEventListener("mousemove",this._boundOnMouseMove),document.removeEventListener("mouseup",this._boundOnMouseUp),this._finishDrag()}_onPointerDown(e){"mouse"===e.pointerType&&0!==e.button||(this._startInteraction(e.target,e.clientX,e.clientY,e),this._draggedItem&&(this._activePointerId=e.pointerId,document.addEventListener("pointermove",this._boundOnPointerMove),document.addEventListener("pointerup",this._boundOnPointerUp),document.addEventListener("pointercancel",this._boundOnPointerCancel)))}_onPointerMove(e){this._draggedItem&&e.pointerId===this._activePointerId&&this._processDragMove(e.clientX,e.clientY,e)}_onPointerUp(e){e.pointerId===this._activePointerId&&(this._activePointerId=null,document.removeEventListener("pointermove",this._boundOnPointerMove),document.removeEventListener("pointerup",this._boundOnPointerUp),document.removeEventListener("pointercancel",this._boundOnPointerCancel),this._finishDrag())}_onPointerCancel(e){e.pointerId===this._activePointerId&&(this._activePointerId=null,document.removeEventListener("pointermove",this._boundOnPointerMove),document.removeEventListener("pointerup",this._boundOnPointerUp),document.removeEventListener("pointercancel",this._boundOnPointerCancel),this._cancelDrag())}_onTouchStart(e){if(null!==this._activeTouchId||!e.changedTouches?.length)return;const t=e.changedTouches[0];this._startInteraction(t.target,t.clientX,t.clientY,e),this._draggedItem&&(this._activeTouchId=t.identifier,document.addEventListener("touchmove",this._boundOnTouchMove,{passive:!1}),document.addEventListener("touchend",this._boundOnTouchEnd),document.addEventListener("touchcancel",this._boundOnTouchCancel))}_onTouchMove(e){if(!this._draggedItem||null===this._activeTouchId)return;const t=this._findTouchById(e.changedTouches,this._activeTouchId)||this._findTouchById(e.touches,this._activeTouchId);t&&this._processDragMove(t.clientX,t.clientY,e)}_onTouchEnd(e){null!==this._activeTouchId&&this._findTouchById(e.changedTouches,this._activeTouchId)&&(this._activeTouchId=null,document.removeEventListener("touchmove",this._boundOnTouchMove),document.removeEventListener("touchend",this._boundOnTouchEnd),document.removeEventListener("touchcancel",this._boundOnTouchCancel),this._finishDrag())}_onTouchCancel(){null!==this._activeTouchId&&(this._activeTouchId=null,document.removeEventListener("touchmove",this._boundOnTouchMove),document.removeEventListener("touchend",this._boundOnTouchEnd),document.removeEventListener("touchcancel",this._boundOnTouchCancel),this._cancelDrag())}_onKeyDown(e){if(this._isDragging||this._draggedItem)return;const t=e.target?.closest?.(this._params.itemselector);if(!t||!this._rootList.contains(t))return;const i=e.key,s=" "===i||"Enter"===i;if(s&&!this._keyboardDraggedItem){if(!this._isKeyboardDragHandle(e.target,t))return;return e.preventDefault(),void this._startKeyboardDrag(t)}if(!this._keyboardDraggedItem)return;if(t!==this._keyboardDraggedItem&&!this._keyboardDraggedItem.contains(t))return;if(s)return e.preventDefault(),void this._finishKeyboardDrag();if("Escape"===i)return e.preventDefault(),void this._finishKeyboardDrag({cancelled:!0});let r=!1,n="";const a=this._getMoveAxis(),o="horizontal"!==a,l="vertical"!==a;if("ArrowUp"===i){if(!o)return;e.preventDefault(),r=this._moveKeyboardUp(this._keyboardDraggedItem),n="Moved up."}else if("ArrowDown"===i){if(!o)return;e.preventDefault(),r=this._moveKeyboardDown(this._keyboardDraggedItem),n="Moved down."}else if("ArrowRight"===i){if(!l)return;e.preventDefault(),r=this._indentKeyboard(this._keyboardDraggedItem),n="Nested into previous item."}else if("ArrowLeft"===i){if(!l)return;e.preventDefault(),r=this._outdentKeyboard(this._keyboardDraggedItem),n="Moved out one level."}r&&(this._cleanupEmptyLists(),this.refresh(),this._keyboardDraggedItem.focus?.(),this._emit("move",{item:this._keyboardDraggedItem,targetInstance:this,keyboard:!0,mouse:null}),n&&this._announce(n))}_isKeyboardDragHandle(e,t){if(!e||!t)return!1;const i=this._params.handleselector;if(!i)return!0;const s=e.closest(i);return!(!s||!t.contains(s))}_startKeyboardDrag(e){!e||this._keyboardDraggedItem||this._isItemDragDisabled(e)?e&&this._isItemDragDisabled(e)&&this._announce("This item cannot be moved."):(this._keyboardDraggedItem=e,this._keyboardStartSnapshot=JSON.stringify(this.serialize()),this._keyboardOrigin={parent:e.parentElement,next:e.nextSibling},e.classList.add(Os),e.setAttribute("aria-grabbed","true"),this._emit("start",{item:e,payload:this.serialize(),keyboard:!0}),this._announce(this._getKeyboardDragInstructions()))}_finishKeyboardDrag(e={}){if(!this._keyboardDraggedItem)return;const t=this._keyboardDraggedItem,i=this._keyboardStartSnapshot?JSON.parse(this._keyboardStartSnapshot):[];if(e.cancelled&&this._keyboardOrigin?.parent){const{parent:e,next:i}=this._keyboardOrigin;e.insertBefore(t,i?.parentElement===e?i:null),this._cleanupEmptyLists(),this.refresh(),t.focus?.()}const s=this.serialize(),r=this._keyboardStartSnapshot!==JSON.stringify(s);this._emit("drop",{item:t,payload:s,previousPayload:i,changed:r,targetInstance:this,keyboard:!0,cancelled:!!e.cancelled}),r&&this._emit("change",{payload:s,previousPayload:i,keyboard:!0}),this._emit("end",{payload:s,changed:r,keyboard:!0,cancelled:!!e.cancelled}),e.cancelled?this._announce("Move cancelled."):r?this._announce("Item dropped."):this._announce("Item position unchanged."),r&&this._params.ajax?.route&&this.save(),this._clearKeyboardDragState()}_clearKeyboardDragState(){this._keyboardDraggedItem&&(this._keyboardDraggedItem.classList.remove(Os),this._keyboardDraggedItem.removeAttribute("aria-grabbed")),this._keyboardDraggedItem=null,this._keyboardStartSnapshot="",this._keyboardOrigin=null}_moveKeyboardUp(e){const t=this._getPreviousItem(e);return t?(e.parentElement.insertBefore(e,t),!0):(this._announce("Cannot move up."),!1)}_moveKeyboardDown(e){const t=this._getNextItem(e);return t?(e.parentElement.insertBefore(e,t.nextSibling),!0):(this._announce("Cannot move down."),!1)}_indentKeyboard(e){const t=this._getPreviousItem(e);if(!t||t===e||e.contains(t))return this._announce("Cannot nest here."),!1;const i=this._getOrCreateChildList(t);return this._isListDisabled(i)?(this._announce("This group cannot be changed."),!1):this._isDepthExceeded(i,e)?(this._announce("Maximum nesting depth reached."),!1):(i.append(e),!0)}_outdentKeyboard(e){const t=e.parentElement,i=t?.closest(this._params.itemselector);if(!i)return this._announce("Cannot move left."),!1;const s=i.parentElement;return s?(s.insertBefore(e,i.nextSibling),!0):(this._announce("Cannot move left."),!1)}_getMoveAxis(e=this._params){const t=String(e?.moveaxis||"default").trim().toLowerCase();return"vertical"===t||"horizontal"===t?t:"default"}_getKeyboardDragInstructions(){const e=this._getMoveAxis();return"vertical"===e?"Picked up item. Use Up/Down arrows to move, Enter or Space to drop, Escape to cancel.":"horizontal"===e?"Picked up item. Use Left/Right arrows to move, Enter or Space to drop, Escape to cancel.":"Picked up item. Use arrow keys to move, Enter or Space to drop, Escape to cancel."}_startInteraction(e,t,i,s){this._keyboardDraggedItem&&this._clearKeyboardDragState();const r=e?.closest?.(this._params.itemselector);if(!r||!this._rootList.contains(r))return;if(this._isItemDragDisabled(r))return;const n=this._params.handleselector;if(n){const t=e.closest(n);if(!t||!r.contains(t))return}s.preventDefault();const a=r.getBoundingClientRect();this._draggedItem=r,this._mouse.startX=t,this._mouse.startY=i,this._mouse.startItemX=a.left,this._mouse.grabOffsetX=t-a.left,this._mouse.grabOffsetY=i-a.top,this._mouse.x=t,this._mouse.y=i,this._isDragging=!1,this._startSnapshot="",this._emit("pointerdown",{item:this._draggedItem,mouse:{x:this._mouse.x,y:this._mouse.y}})}_processDragMove(e,t,i){if(!this._draggedItem)return;if(this._mouse.x=e,this._mouse.y=t,!this._isDragging){const e=Math.abs(this._mouse.x-this._mouse.startX),t=Math.abs(this._mouse.y-this._mouse.startY);if(e<3&&t<3)return;this._startDrag()}i.preventDefault(),this._moveDragElement(this._mouse.x,this._mouse.y);const s=this._getPointerTarget(this._mouse.x,this._mouse.y);if(!s)return this._setDropListState(null),void this._setDropItemState(null);const r=s.closest(`.${zs}`);if(r){const e=this._findOwnerInstanceByElement(r)||this._currentTargetInstance||this;return void this._tryIndentFromPlaceholder(this._mouse.x,e)}const n=this._findOwnerInstanceByElement(s)||this,a=s.closest(n._params.itemselector),o=this._resolveDropList(s,a,n);if(!o||!n._rootList.contains(o))return this._setDropListState(null),void this._setDropItemState(null);const l=this._resolveMode(this._mouse.x,this._mouse.y,a,n._params);if(n._isListDisabled(o))return this._setDropListState(o,!0),void this._setDropItemState(a,l,!0);if(!n._canAcceptItem(this._draggedItem,this._sourceInstance))return this._setDropListState(o,!0),void this._setDropItemState(a,l,!0);if(this._setDropItemState(a,l),this._emit("move",{item:this._draggedItem,hoveredItem:a,mode:l,targetInstance:n,mouse:{x:this._mouse.x,y:this._mouse.y}}),"keep"!==l){if("child"===l){let e=null;if(a){if(a===this._draggedItem||this._draggedItem.contains(a))return void this._setDropListState(null);e=a}else if(this._placePlaceholderWhenExplicitlyNeeded(o,this._mouse.y,n),this._placeholder?.parentElement)for(e=n._getPreviousItem(this._placeholder);e&&(e===this._draggedItem||this._draggedItem.contains(e));)e=n._getPreviousItem(e);if(!e)return this._setDropListState(null),void this._setDropItemState(null);const t=n._getOrCreateChildList(e);return n._isDepthExceeded(t,this._draggedItem)?(this._setDropListState(t,!0),void this._setDropItemState(e,l,!0)):(this._placePlaceholder(t,null),this._setDropListState(t),this._currentTargetInstance=n,void(this._lastDropInstance=n))}if(a){if(a===this._draggedItem||this._draggedItem.contains(a))return this._setDropListState(null),void this._setDropItemState(null);const e=a.parentElement;return n._isDepthExceeded(e,this._draggedItem)?(this._setDropListState(e,!0),void this._setDropItemState(a,l,!0)):("before"===l?this._placePlaceholder(e,a):this._placePlaceholder(e,a.nextSibling),this._setDropListState(e),this._currentTargetInstance=n,void(this._lastDropInstance=n))}this._placePlaceholderWhenExplicitlyNeeded(o,this._mouse.y,n),this._setDropListState(o),this._currentTargetInstance=n,this._lastDropInstance=n}else this._setDropListState(o)}_finishDrag(){if(!this._draggedItem)return;const e=this._draggedItem,t=this._isDragging,i=this._lastDropInstance||this,s=this._startSnapshot?JSON.parse(this._startSnapshot):[];let r=this.serialize(),n=i.serialize(),a=!1;if(t){const t=this._placeholder?.parentElement||null;t&&t.insertBefore(e,this._placeholder),e.style.display="",this._cleanupEmptyLists(),i!==this&&i._cleanupEmptyLists(),this.refresh(),i!==this&&i.refresh(),r=this.serialize(),n=i.serialize(),a=this._startSnapshot!==JSON.stringify(r)||i!==this}const o=r;this._emit("drop",{item:e,payload:o,previousPayload:s,changed:a,targetInstance:i}),a&&i!==this&&(this._emit("transfer",{item:e,from:this,to:i,sourcePayload:r,targetPayload:n}),i._emit("transfer",{item:e,from:this,to:i,sourcePayload:r,targetPayload:n}),i._emit("change",{payload:n,previousPayload:[]})),this._clearDragState(),a&&this._emit("change",{payload:o,previousPayload:s}),t&&this._emit("end",{payload:o,changed:a}),a&&(this._params.ajax?.route&&this.save(),i!==this&&i._params.ajax?.route&&i.save())}_cancelDrag(){if(!this._draggedItem)return;const e=this._isDragging;this._clearDragState(),e&&this._emit("end",{payload:this.serialize(),changed:!1,cancelled:!0})}_findTouchById(e,t){if(!e||null==t)return null;for(let i=0;i<e.length;i+=1)if(e[i].identifier===t)return e[i];return null}_startDrag(){this._draggedItem&&!this._isDragging&&(this._isDragging=!0,this._startSnapshot=JSON.stringify(this.serialize()),this._sourceInstance=this,this._sourceRoot=this._rootList,this._dragBaseDepth=this._getListDepth(this._draggedItem.parentElement),this._currentTargetInstance=this,this._lastDropInstance=this,this._placeholder=this._createPlaceholder(this._draggedItem),this._params.showplaceholder||this._placeholder.classList.add("vg-nestable-placeholder-hidden"),this._draggedItem.parentElement.insertBefore(this._placeholder,this._draggedItem.nextSibling),this._dragElement=this._createDragElement(this._draggedItem),this._dragLayer=document.createElement("div"),this._dragLayer.classList.add("vg-nestable-drag-layer"),this._element?.classList&&this._element.classList.forEach(e=>this._dragLayer.classList.add(e)),this._dragLayer.style.position="fixed",this._dragLayer.style.left="0",this._dragLayer.style.top="0",this._dragLayer.style.width="0",this._dragLayer.style.height="0",this._dragLayer.style.pointerEvents="none",this._dragLayer.style.zIndex="99999",document.body.append(this._dragLayer),this._dragLayer.append(this._dragElement),"undefined"!=typeof document&&document.body&&(this._previousBodyCursor=document.body.style.cursor||"",document.body.style.cursor="grabbing"),this._moveDragElement(this._mouse.x,this._mouse.y),this._draggedItem.classList.add(Os),this._draggedItem.style.display="none",this._draggedItem.setAttribute("aria-grabbed","true"),this._emit("start",{item:this._draggedItem,payload:this.serialize()}))}_createDragElement(e){const t=e.getBoundingClientRect(),i=e.cloneNode(!0);return i.classList.add("is-drag-ghost","vg-nestable-drag-element"),i.style.position="fixed",i.style.left=`${t.left}px`,i.style.top=`${t.top}px`,i.style.width=`${t.width}px`,i.style.zIndex="99999",i.style.pointerEvents="none",i.style.margin="0",i}_moveDragElement(e,t){if(!this._dragElement)return;const i=e-(Number(this._mouse.grabOffsetX)||0),s=t-(Number(this._mouse.grabOffsetY)||0);this._dragElement.style.left=`${i}px`,this._dragElement.style.top=`${s}px`}_getPointerTarget(e,t){const i=document.elementFromPoint(e,t);return i&&this._findOwnerInstanceByElement(i)?i:null}_resolveDropList(e,t,i=this){if(t)return t.parentElement;const s=e.closest(i._params.listselector);return s&&i._rootList.contains(s)?s:i._rootList}_resolveMode(e,t,i,s=this._params){if(!i)return"append";const r=this._getItemDropRect(i),n=t-r.top,a=e-r.left,o=parseFloat(s.indent),l=Number.isFinite(o)?o:0,h=Math.max(0,Number(this._mouse.grabOffsetX)||0)+l,d=this._getMoveAxis(s),c="horizontal"!==d,_="vertical"!==d,u=Math.max(0,Math.min(49,Number(s.neighborchangethreshold||0)));if(u>0){const e=u/100,t=r.height*e,i=r.height*(1-e);return _&&a>h&&n>t&&n<i?"child":c&&n<=t?"before":c&&n>=i?"after":"keep"}const m=Math.min(.45,Math.max(.05,Number(s.hoverthreshold||.25)));return _&&a>h&&n>=r.height*(.5-m)&&n<=r.height*(.5+m)?"child":c&&n<r.height*(.5-m)?"before":c&&n>r.height*(.5+m)?"after":"keep"}_getItemDropRect(e){const t=e?.querySelector?.(`:scope > .${Ns}`);return(t||e).getBoundingClientRect()}_tryIndentFromPlaceholder(e,t=this){if(!this._placeholder||"vertical"===this._getMoveAxis(t._params))return!1;if(!t._canAcceptItem(this._draggedItem,this._sourceInstance)||t._isListDisabled(this._placeholder.parentElement))return this._setDropListState(this._placeholder.parentElement,!0),this._setDropItemState(null),!1;const i=parseFloat(t._params.indent),s=Number.isFinite(i)?Math.max(1,i):18,r=Math.max(0,e-this._mouse.startX),n=this._dragBaseDepth+Math.floor(r/s);let a=this._placeholder.parentElement,o=t._getListDepth(a),l=null;for(;o>n;){const e=a.closest(t._params.itemselector),i=e?.parentElement;if(!e||!i)break;this._placePlaceholder(i,e.nextSibling),a=i,o=t._getListDepth(a)}for(;o<n;){for(l=t._getPreviousItem(this._placeholder);l&&(l===this._draggedItem||this._draggedItem.contains(l));)l=t._getPreviousItem(l);if(!l)break;const e=t._getOrCreateChildList(l);if(t._isListDisabled(e))return this._setDropListState(e,!0),this._setDropItemState(l,"child",!0),!1;if(t._isDepthExceeded(e,this._draggedItem))return this._setDropListState(e,!0),this._setDropItemState(l,"child",!0),!1;this._placePlaceholder(e,null),a=e,o=t._getListDepth(a)}const h=a.closest(t._params.itemselector),d=t._getPreviousItem(this._placeholder),c=r%s/s;return d&&d!==this._draggedItem&&c>=.35?(this._setDropItemState(d,"attachable"),l=d):h?(this._setDropItemState(h,"child"),l=h):d&&d!==this._draggedItem?(this._setDropItemState(d,"attachable"),l=d):this._setDropItemState(null),this._setDropListState(a),this._currentTargetInstance=t,this._lastDropInstance=t,this._emit("move",{item:this._draggedItem,hoveredItem:l,mode:o>this._dragBaseDepth?"child":"keep",targetInstance:t,mouse:{x:this._mouse.x,y:this._mouse.y}}),o>this._dragBaseDepth}_hasDisabledAttribute(e){if(!e||!this._params.disabledattribute)return!1;const t=e.getAttribute(this._params.disabledattribute);return null!==t&&!0===(0,r.OM)(""===t?"true":t)}_isTreeDisabled(){return!0===(0,r.OM)(this._params.disabled)||this._hasDisabledAttribute(this._element)}_isListDisabled(e){if(this._isTreeDisabled())return!0;let t=e;for(;t&&this._rootList.contains(t);){if(t.matches(this._params.listselector)&&this._hasDisabledAttribute(t))return!0;if(t===this._rootList)break;t=t.parentElement?.closest(this._params.listselector)||null}return!1}_isItemDragDisabled(e){return this._isTreeDisabled()||this._hasDisabledAttribute(e)||this._isListDisabled(e?.parentElement)}_getPreviousItem(e){let t=e?.previousElementSibling||null;for(;t&&!t.matches(this._params.itemselector);)t=t.previousElementSibling;return t}_getNextItem(e){let t=e?.nextElementSibling||null;for(;t&&!t.matches(this._params.itemselector);)t=t.nextElementSibling;return t}_getOrCreateChildList(e){let t=e.querySelector(`:scope > ${this._params.listselector}`);return t||(t=document.createElement(this._rootList.tagName||"ol"),this._params.childlistclass&&this._params.childlistclass.split(" ").filter(Boolean).forEach(e=>t.classList.add(e)),e.append(t),t)}_isDepthExceeded(e,t=this._draggedItem){const i=this._getListDepth(e),s=Number(this._params.maxdepth||1);return i+this._getItemSubtreeDepth(t)-1>s}_getListDepth(e){if(!e)return 1;let t=1,i=e;for(;i&&i!==this._rootList;){const e=i.closest(this._params.itemselector);if(!e)break;t+=1,i=e.parentElement?.closest(this._params.listselector)}return t}_getItemSubtreeDepth(e){if(!e)return 1;const t=this._getDirectChildBySelector(e,this._params.listselector);if(!t)return 1;const i=Array.from(t.children).filter(e=>e.matches(this._params.itemselector));return i.length?i.reduce((e,t)=>Math.max(e,this._getItemSubtreeDepth(t)),1)+1:1}_cleanupEmptyLists(){this._rootList&&Array.from(this._rootList.querySelectorAll(this._params.listselector)).forEach(e=>{e!==this._rootList&&(Array.from(e.children).some(e=>e.matches(this._params.itemselector))||e.remove())})}_createPlaceholder(e){const t=e.tagName&&"li"===e.tagName.toLowerCase()?"li":"div",i=document.createElement(t);return i.className=zs,i.style.height=`${Math.max(e.getBoundingClientRect().height,24)}px`,i.setAttribute("aria-hidden","true"),i}_placePlaceholder(e,t=null){if(!e||!this._placeholder)return;if(t===this._placeholder)return;const i=this._placeholder.parentElement,s=this._placeholder.nextSibling;i===e&&s===t||(e.insertBefore(this._placeholder,t),this._emit("placeholdermove",{parent:e,beforeNode:t,item:this._draggedItem}))}_placePlaceholderWhenExplicitlyNeeded(e,t,i=this){if(!e||i._isDepthExceeded(e,this._draggedItem))return;const s=Array.from(e.children).filter(e=>e.matches(this._params.itemselector));if(!s.length)return void this._placePlaceholder(e,null);const r=s[0],n=s[s.length-1],a=r.getBoundingClientRect(),o=n.getBoundingClientRect();t<=a.top+8?this._placePlaceholder(e,r):t>=o.bottom-8&&this._placePlaceholder(e,null)}_setDropListState(e,t=!1){this._activeDropList&&this._activeDropList!==e&&this._activeDropList.classList.remove(Bs,js),e?(e.classList.add(t?js:Bs),e.classList.remove(t?Bs:js),this._activeDropList=e):this._activeDropList=null}_setDropItemState(e,t="",i=!1){const s=[Us,qs,Vs,Ws,js];if(this._activeDropItem&&this._activeDropItem!==e&&this._activeDropItem.classList.remove(...s),!e||!["before","attachable","child","after"].includes(t))return this._activeDropItem&&this._activeDropItem.classList.remove(...s),void(this._activeDropItem=null);e.classList.remove(...s);const r={before:Us,attachable:qs,child:Vs,after:Ws};e.classList.add(r[t]),i&&e.classList.add(js),this._activeDropItem=e}_clearDragState(){this._setDropListState(null),this._setDropItemState(null),this._draggedItem&&(this._draggedItem.classList.remove(Os),this._draggedItem.style.display="",this._draggedItem.removeAttribute("aria-grabbed")),this._dragElement&&this._dragElement.parentElement&&this._dragElement.remove(),this._dragLayer&&this._dragLayer.parentElement&&this._dragLayer.remove(),"undefined"!=typeof document&&document.body&&(document.body.style.cursor=this._previousBodyCursor||""),this._placeholder&&this._placeholder.parentElement&&this._placeholder.remove(),this._draggedItem=null,this._placeholder=null,this._dragElement=null,this._dragLayer=null,this._previousBodyCursor="",this._isDragging=!1,this._currentTargetInstance=this,this._lastDropInstance=this,this._activePointerId=null,this._activeTouchId=null,this._dragBaseDepth=1}_ensureLiveRegion(){if(!this._element||this._liveRegion)return;const e=document.createElement("div");e.className="vg-nestable-live",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.width="1px",e.style.height="1px",e.style.margin="-1px",e.style.border="0",e.style.padding="0",e.style.clip="rect(0 0 0 0)",e.style.clipPath="inset(50%)",e.style.overflow="hidden",e.style.whiteSpace="nowrap",this._element.append(e),this._liveRegion=e}_announce(e){e&&(this._ensureLiveRegion(),this._liveRegion&&(this._liveRegion.textContent="",requestAnimationFrame(()=>{this._liveRegion&&(this._liveRegion.textContent=e)})))}_serializeList(e){return Array.from(e.children).filter(e=>e.matches(this._params.itemselector)).map(e=>{const t=(0,r.OM)(e.getAttribute(this._params.idattribute)),i=e.querySelector(`:scope > ${this._params.listselector}`),s={id:t??null};if(!1!==(0,r.OM)(this._params.serializedata)&&Array.from(e.attributes).forEach(e=>{if(!e.name.startsWith("data-")||e.name===this._params.idattribute)return;const t=e.name.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase());s[t]=(0,r.OM)(""===e.value?"true":e.value)}),i){const e=this._serializeList(i);e.length&&(s.children=e)}return s})}}g.A.on(document,`DOMContentLoaded.${Ds}.data.api`,()=>{s.A.findAll(Ts).forEach(e=>or.getOrCreateInstance(e))}),g.A.on(document,`click.${Ds}.data.api`,"[data-vg-nestable-action]",function(e){e.preventDefault();const t=this.getAttribute("data-vg-target"),i=t?s.A.find(t):this.closest(Ts);if(!i)return;const r=or.getOrCreateInstance(i),n=String(this.getAttribute("data-vg-nestable-action")||"").trim();["expandAll","collapseAll"].includes(n)&&r[n]()});const lr=or,hr="is-status-success",dr="is-status-warning",cr="is-status-danger",_r=[hr,dr,cr],ur=(e,t,i)=>{const s=i.max-i.min,r=s>0?(e-i.min)/s*100:0,n=Number(t?.status?.warningBelow),a=Number(t?.status?.dangerBelow),o=Number.isFinite(n)?n:60;return r<(Number.isFinite(a)?a:30)?"danger":r<o?"warning":"success"},mr=(e,t,i)=>{const s=((e,t,i)=>{if(!i.isRange)return t.from;const s="string"==typeof e?.status?.by?e.status.by.toLowerCase():"to";return"from"===s?t.from:"avg"===s?(t.from+t.to)/2:t.to})(e,t,i);return ur(s,e,t)},pr=(e,t)=>{e.classList.remove(..._r),"danger"!==t?"warning"!==t?e.classList.add(hr):e.classList.add(dr):e.classList.add(cr)},gr=(e,t)=>!Array.isArray(e?.labelWords)||e.labelWords.length<3?null:"danger"===t?e.labelWords[0]||null:"warning"===t?e.labelWords[1]||null:e.labelWords[2]||null,fr="vg.rangeslider",br="vg-range-slider",vr="is-hidden",yr=`${fr}.init`,wr=`${fr}.input`,Er=`${fr}.change`,Ar=`${fr}.update`,Sr={range:!1,min:0,max:100,step:1,start:null,connect:!0,tooltips:!0,labels:!0,separator:" - ",suffix:"",prefix:"",labelWords:null,skin:"default",ruler:{count:6,labels:!0,values:null,dimInactive:!1},status:{warningBelow:60,dangerBelow:30,by:"to"},name:{min:"",max:""},input:{min:null,max:null},output:{target:null,min:null,max:null},disabled:!1,onInit:null,onInput:null,onChange:null,onUpdate:null,formatValue:null};class Cr extends e.A{constructor(e,t={}){super(e,t),this._sourceInput=this._element.matches('input[type="range"]')?this._element:null,this._params=this._buildParams(t),this._isRange=this._resolveRangeMode(),this._listeners=[],this._handleResize=()=>this._syncUI(),this._dom={root:null,wrapper:null,fill:null,inputFrom:null,inputTo:null,tooltipFrom:null,tooltipTo:null,tooltipMerged:null,labelFrom:null,labelTo:null,labelSeparator:null,hiddenMin:null,hiddenMax:null,skin:null},this._state=this._buildState(),this._render(),this._bindEvents(),this._syncUI(),this._setDisabledState(this._params.disabled),this._emit(yr,"onInit")}static get NAME(){return"rangeslider"}static get NAME_KEY(){return fr}static init(e,t={}){return this.getOrCreateInstance(e,t)}getValue(){return this._isRange?[this._state.from,this._state.to]:this._state.from}setValue(e,t={}){const{silent:i=!1,emit:s="update"}=t;if(this._isRange){const t=Array.isArray(e)?e:[e,this._state.to],i=this._normalizeValue(t[0],this._state.min),s=this._normalizeValue(t[1],this._state.max);this._state.from=Math.min(i,s),this._state.to=Math.max(i,s)}else this._state.from=this._normalizeValue(e,this._state.min);this._syncUI(),i||this._emit("change"===s?Er:Ar,"change"===s?"onChange":"onUpdate")}enable(){this._setDisabledState(!1)}disable(){this._setDisabledState(!0)}dispose(){this._listeners.forEach(({element:e,type:t,handler:i})=>e.removeEventListener(t,i)),this._listeners=[],window.removeEventListener("resize",this._handleResize),super.dispose()}_buildParams(e){const t=this._getParams(this._element,(0,r._v)(Sr,e));return this._sourceInput&&(t.min=""!==this._sourceInput.min?(0,r.OM)(this._sourceInput.min):t.min,t.max=""!==this._sourceInput.max?(0,r.OM)(this._sourceInput.max):t.max,t.step=""!==this._sourceInput.step?(0,r.OM)(this._sourceInput.step):t.step,t.start=""!==this._sourceInput.value?(0,r.OM)(this._sourceInput.value):t.start,t.name=this._sourceInput.name||t.name,t.disabled=this._sourceInput.disabled||t.disabled),"string"==typeof t.name&&(t.name={min:t.name,max:t.name}),t.input&&"object"==typeof t.input||(t.input={min:null,max:null}),"string"==typeof t.output?t.output={target:t.output,min:null,max:null}:t.output&&"object"==typeof t.output?Object.prototype.hasOwnProperty.call(t.output,"target")||(t.output.target=null):t.output={target:null,min:null,max:null},!t.labelWords&&t.label&&"object"==typeof t.label&&Object.prototype.hasOwnProperty.call(t.label,"words")&&(t.labelWords=t.label.words),"string"==typeof t.labelWords?t.labelWords=t.labelWords.split(",").map(e=>e.trim()).filter(Boolean):Array.isArray(t.labelWords)||(t.labelWords=null),t}_buildState(){const e=Number((0,r.OM)(this._params.min)),t=Math.max(Number((0,r.OM)(this._params.max)),e),i=Number((0,r.OM)(this._params.step))||1,s=this._resolveStartValues(e,t);return{min:e,max:t>=e?t:e,step:i>0?i:1,from:s.from,to:s.to}}_resolveRangeMode(){return!this._sourceInput&&!0===(0,r.OM)(this._params.range)}_resolveStartValues(e,t){let i=e,s=t;if(this._isRange){const r=Array.isArray(this._params.start)?this._params.start:[this._params.from,this._params.to];i=this._normalizeValue(r[0],e,e,t),s=this._normalizeValue(r[1],t,e,t),i>s&&([i,s]=[s,i])}else{const r=this._params.start??this._params.value??e;i=this._normalizeValue(r,e,e,t),s=i}return{from:i,to:s}}_render(){const e=this._sourceInput?this._renderFromInput():this._renderFromContainer();this._dom.root=e,this._dom.wrapper=s.A.find(".vg-range-slider__wrapper",e),this._dom.fill=s.A.find(".vg-range-slider__fill",e),this._dom.inputFrom=s.A.find(".vg-range-slider__input--from",e),this._dom.inputTo=s.A.find(".vg-range-slider__input--to",e),this._dom.tooltipFrom=s.A.find(".vg-range-slider__tooltip--from",e),this._dom.tooltipTo=s.A.find(".vg-range-slider__tooltip--to",e),this._dom.tooltipMerged=s.A.find(".vg-range-slider__tooltip--merged",e),this._dom.labelFrom=s.A.find(".vg-range-slider__label--from",e),this._dom.labelTo=s.A.find(".vg-range-slider__label--to",e),this._dom.labelSeparator=s.A.find(".vg-range-slider__separator",e),this._dom.hiddenMin=e.querySelector('input[data-vgrangeslider-hidden="min"]'),this._dom.hiddenMax=e.querySelector('input[data-vgrangeslider-hidden="max"]'),this._dom.skin=((e,t,i,s)=>(e.classList.add("is-skin-default"),"ruler"===t.skin?(e.classList.add("is-skin-ruler"),((e,t,i,s,r)=>{const n=((e,t)=>{if(Array.isArray(e?.ruler?.values)&&e.ruler.values.length>0)return e.ruler.values.map(e=>Number(e)).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t);const i=Math.max(2,Number(e?.ruler?.count)||6),s=(t.max-t.min)/(i-1),r=[];for(let e=0;e<i;e++){const n=e===i-1?t.max:t.min+s*e;r.push(Number(n.toFixed(5)))}return r})(t,i),a=document.createElement("div");a.className="vg-range-slider__ruler",!0===t?.ruler?.dimInactive&&e.classList.add("is-ruler-dim-inactive");const o=n.map(e=>{const i=document.createElement("span");i.className="vg-range-slider__ruler-item",i.style.left=`${r(e)}px`,i.dataset.value=String(e);const n=document.createElement("span");if(n.className="vg-range-slider__ruler-mark",i.appendChild(n),!1!==t?.ruler?.labels){const t=document.createElement("span");t.className="vg-range-slider__ruler-label",t.textContent=s(e),i.appendChild(t)}return a.appendChild(i),i});return e.appendChild(a),{type:"ruler",root:a,ticks:o,values:n}})(e,t,i,s.formatValue,s.toPositionPx)):"status"===t.skin?(e.classList.add("is-skin-status"),pr(e,mr(t,i,s)),{type:"status",root:e}):(t.skin,null)))(e,this._params,this._state,{formatValue:e=>this._formatValue(e),toPositionPx:e=>this._toPositionPx(e)})}_renderFromInput(){const e=this._sourceInput,t=document.createElement("div");t.className=br;const i=document.createElement("div");i.className="vg-range-slider__wrapper";const s=document.createElement("div");s.className="vg-range-slider__track";const r=document.createElement("div");r.className="vg-range-slider__fill";const n=this._params.tooltips?this._createTooltip("from"):null,a=this._params.labels?this._createLabels(!1):null;return e.insertAdjacentElement("beforebegin",t),e.classList.add("vg-range-slider__input","vg-range-slider__input--from"),e.autocomplete="off",s.appendChild(r),i.appendChild(s),i.appendChild(e),n&&i.appendChild(n),t.appendChild(i),a&&t.appendChild(a),t}_renderFromContainer(){const e=this._element;e.classList.add(br),this._isRange&&e.classList.add("is-range"),e.innerHTML="";const t=document.createElement("div");t.className="vg-range-slider__wrapper";const i=document.createElement("div");i.className="vg-range-slider__track";const s=document.createElement("div");s.className="vg-range-slider__fill",i.appendChild(s),t.appendChild(i);const r=this._createRangeInput("from");if(t.appendChild(r),this._isRange){const e=this._createRangeInput("to");t.appendChild(e)}return this._params.tooltips&&(t.appendChild(this._createTooltip("from")),this._isRange&&t.appendChild(this._createTooltip("to")),this._isRange&&t.appendChild(this._createTooltip("merged"))),e.appendChild(t),this._params.labels&&e.appendChild(this._createLabels(this._isRange)),this._isRange?(this._ensureHiddenInput(e,"min",this._params.input?.min,this._params.name?.min),this._ensureHiddenInput(e,"max",this._params.input?.max,this._params.name?.max)):this._params.name?.min&&this._ensureHiddenInput(e,"min",this._params.input?.min,this._params.name.min),e}_createRangeInput(e){const t=document.createElement("input");return t.type="range",t.className=`vg-range-slider__input vg-range-slider__input--${e}`,t.min=String(this._state.min),t.max=String(this._state.max),t.step=String(this._state.step),t.value=String("to"===e?this._state.to:this._state.from),t.autocomplete="off",t}_createTooltip(e){const t=document.createElement("span");return t.className=`vg-range-slider__tooltip vg-range-slider__tooltip--${e}`,"merged"===e&&t.classList.add(vr),t}_createLabels(e){const t=document.createElement("div");t.className="vg-range-slider__labels";const i=document.createElement("span");if(i.className="vg-range-slider__label vg-range-slider__label--from",t.appendChild(i),e){const e=document.createElement("span");e.className="vg-range-slider__separator",e.textContent=this._params.separator,t.appendChild(e);const i=document.createElement("span");i.className="vg-range-slider__label vg-range-slider__label--to",t.appendChild(i)}return t}_ensureHiddenInput(e,t,i,r){let n=i?s.A.find(i):null;n||(n=document.createElement("input"),n.type="hidden",r&&(n.name=r),e.appendChild(n)),n.setAttribute("data-vgrangeslider-hidden",t)}_bindEvents(){const e=e=>t=>{const i=this._normalizeValue(t.target.value,this._state.min);this._isRange?"from"===e?(this._state.from=Math.min(i,this._state.to),t.target.value=String(this._state.from)):(this._state.to=Math.max(i,this._state.from),t.target.value=String(this._state.to)):this._state.from=i,this._syncUI(),this._emit(wr,"onInput")},t=()=>{this._syncUI(),this._emit(Er,"onChange")};[this._dom.inputFrom,this._dom.inputTo].filter(Boolean).forEach(i=>{const s=i.classList.contains("vg-range-slider__input--to")?"to":"from",r=e(s),n=t;i.addEventListener("input",r),i.addEventListener("change",n),this._listeners.push({element:i,type:"input",handler:r}),this._listeners.push({element:i,type:"change",handler:n})}),window.addEventListener("resize",this._handleResize)}_syncUI(){this._toPercent(this._state.from),this._toPercent(this._isRange?this._state.to:this._state.from);const e=this._toPositionPx(this._state.from),t=this._toPositionPx(this._isRange?this._state.to:this._state.from);if(this._dom.inputFrom&&(this._dom.inputFrom.value=String(this._state.from)),this._dom.inputTo&&(this._dom.inputTo.value=String(this._state.to)),this._dom.fill){const i=this._isRange?e:0,s=this._isRange?t-e:t;this._dom.fill.style.left=`${Math.max(i,0)}px`,this._dom.fill.style.width=`${Math.max(s,0)}px`}this._placeTooltip(this._dom.tooltipFrom,e,this._formatValue(this._state.from)),this._placeTooltip(this._dom.tooltipTo,t,this._formatValue(this._state.to)),this._syncTooltips(e,t),this._dom.labelFrom&&(this._dom.labelFrom.textContent=this._formatValue(this._state.from)),this._dom.labelTo&&(this._dom.labelTo.textContent=this._formatValue(this._state.to)),this._dom.labelSeparator&&(this._dom.labelSeparator.hidden=!this._isRange),this._syncTargets(),((e,t,i)=>{if(!e)return;if("status"===e.type)return pr(e.root,mr(i.params,t,i)),void((e,t,i)=>{const s=i?.dom?.labelFrom,r=i?.dom?.labelTo,n=gr(e,ur(t.from,e,t)),a=gr(e,ur(t.to,e,t));s&&n&&(s.textContent=n),r&&a&&(r.textContent=a)})(i.params,t,i);if("ruler"!==e.type)return;const s=t.from!==t.to||i.isRange;e.ticks.forEach((i,r)=>{const n=e.values[r],a=s?n>=t.from&&n<=t.to:n<=t.from;i.classList.toggle("is-active",a)})})(this._dom.skin,this._state,{isRange:this._isRange,params:this._params,dom:this._dom})}_syncTargets(){const e=this.getValue(),[t,i]=Array.isArray(e)?e:[e,e];this._dom.hiddenMin&&(this._dom.hiddenMin.value=String(t)),this._dom.hiddenMax&&(this._dom.hiddenMax.value=String(i)),this._setText(this._params.output?.target,this._isRange?`${this._formatValue(t)}${this._params.separator}${this._formatValue(i)}`:this._formatValue(t)),this._setText(this._params.output?.min,this._formatValue(t)),this._setText(this._params.output?.max,this._formatValue(i))}_setDisabledState(e){this._params.disabled=!!e,this._dom.root&&this._dom.root.classList.toggle("disabled",this._params.disabled),[this._dom.inputFrom,this._dom.inputTo].filter(Boolean).forEach(e=>{e.disabled=this._params.disabled})}_placeTooltip(e,t,i){e&&(e.textContent=i,e.style.left=`${t}px`)}_syncTooltips(e,t){const i=this._dom.tooltipMerged,s=this._dom.tooltipFrom,r=this._dom.tooltipTo;return this._isRange&&i&&s&&r?t-e<=s.offsetWidth/2+r.offsetWidth/2+8?(s.classList.add(vr),r.classList.add(vr),i.classList.remove(vr),i.textContent=`${this._formatValue(this._state.from)}${this._params.separator}${this._formatValue(this._state.to)}`,void(i.style.left=(e+t)/2+"px")):(s.classList.remove(vr),r.classList.remove(vr),void i.classList.add(vr)):(s&&s.classList.remove(vr),r&&r.classList.remove(vr),void(i&&i.classList.add(vr)))}_toPercent(e){const t=this._state.max-this._state.min;return t<=0?0:(e-this._state.min)/t*100}_toPositionPx(e){const t=this._dom?.wrapper,i=this._state.max-this._state.min;if(!t||i<=0)return 0;const s=(e-this._state.min)/i,r=getComputedStyle(this._dom.root||t),n=parseFloat(r.getPropertyValue("--vg-range-slider-thumb-size"))||0,a=t.clientWidth||0;return a<=0?0:a<=n?a/2:s*(a-n)+n/2}_normalizeValue(e,t,i=this._state?.min??0,s=this._state?.max??100){const n=Number((0,r.OM)(e)),a=Number.isFinite(n)?n:t,o=Math.min(Math.max(a,i),s),l=this._state?.step||this._params.step||1,h=Math.round((o-i)/l)*l+i;return Number(h.toFixed(5))}_formatValue(e){return"function"==typeof this._params.formatValue?this._params.formatValue.call(this,e,this._element):`${null==this._params.prefix?"":String(this._params.prefix)}${e}${null==this._params.suffix?"":String(this._params.suffix)}`}_getStatusBy(){if("string"!=typeof this._params?.status?.by)return"to";const e=this._params.status.by.toLowerCase();return["from","to","avg"].includes(e)?e:"to"}_getStatusPercentByValue(e){const t=this._state.max-this._state.min;return t<=0?0:(e-this._state.min)/t*100}_getStatusToneByValue(e){const t=this._getStatusPercentByValue(e),i=Number(this._params?.status?.warningBelow),s=Number(this._params?.status?.dangerBelow),r=Number.isFinite(i)?i:60;return t<(Number.isFinite(s)?s:30)?"danger":t<r?"warning":"success"}_getStatusLabelByTone(e){return!Array.isArray(this._params?.labelWords)||this._params.labelWords.length<3?null:"danger"===e?this._params.labelWords[0]||null:"warning"===e?this._params.labelWords[1]||null:this._params.labelWords[2]||null}_getStatusDetail(){const e=this._getStatusBy(),t=this._state.from,i=this._state.to,s="from"===e?t:"avg"===e?(t+i)/2:i,r=this._getStatusToneByValue(s);return{by:e,sourceValue:s,percent:Number(this._getStatusPercentByValue(s).toFixed(5)),tone:r,label:this._getStatusLabelByTone(r),from:{value:t,percent:Number(this._getStatusPercentByValue(t).toFixed(5)),tone:this._getStatusToneByValue(t),label:this._getStatusLabelByTone(this._getStatusToneByValue(t))},to:{value:i,percent:Number(this._getStatusPercentByValue(i).toFixed(5)),tone:this._getStatusToneByValue(i),label:this._getStatusLabelByTone(this._getStatusToneByValue(i))}}}_emit(e,t){const i={value:this.getValue(),from:this._state.from,to:this._state.to,min:this._state.min,max:this._state.max,step:this._state.step,status:this._getStatusDetail(),instance:this};g.A.trigger(this._element,e,i);const s=this._params[t];"function"==typeof s&&s.call(this,this._element,i)}_setText(e,t){if(!e)return;const i=s.A.find(e);i&&(i.textContent=t)}}g.A.on(document,"DOMContentLoaded",()=>{s.A.findAll("[data-vgrangeslider]").forEach(e=>{e.dataset.vgrangesliderInitialized||(Cr.getOrCreateInstance(e),e.dataset.vgrangesliderInitialized="true")})});const xr=Cr,Lr="rollup",Ir="vg.rollup",Pr="show",kr="vg-rollup-display--none",Mr=`${Ir}.hide`,Dr=`${Ir}.show`,Tr=`click.${Ir}.data.api`;class Or extends e.A{constructor(e,i={}){super(e,i);const s={lang:document.documentElement.lang||"ru",content:"text",cnt:0,fade:!0,transition:!1,number:!1,height:0,ellipsis:{line:null},more:" еще ",button:{enabled:!0,more:"Показать",less:"Свернуть",classes:""},callbacks:{init:()=>{},expand:()=>{},collapse:()=>{}}};let n=t.p.get(e,"data-lang")||"lang"in i?i.lang:s.lang;s.button.more=Be(n,Lr).show,s.button.less=Be(n,Lr).less,s.more=Be(n,Lr).more,this._params=this._getParams(e,(0,r._v)(s,i)),this.classes={container:"vg-rollup",hidden:"vg-rollup-content--hidden",fade:"vg-rollup-content--fade",ellipsis:"vg-rollup-content--ellipsis",button:"vg-rollup-content--button",transition:"vg-rollup-content--transition"},this.total=0,this.count=0,this.offset=0,this.isOffset=!1,this.build()}static get NAME(){return Lr}static get NAME_KEY(){return Ir}static toggle(e,t){const i=Or.getOrCreateInstance(e);i.isShow()?i._hide(t):i._show(t)}_show(e){t.x.add(this._element,Pr),e.innerHTML=this._params.button.less,t.p.set(e,"aria-expanded","true"),this.offset>0&&(e.innerHTML=this.isOffset?this._params.button.more:this._params.button.less,t.p.set(e,"aria-expanded",this.isOffset?"true":"false")),this.switch(this._element,!1),g.A.trigger(this._element,Dr,{relatedTarget:e})}_hide(e){let i=this._params.button.more;if(this._params.number){const e=this.total-this.count;e>0&&(i+=this._params.more+e)}t.x.remove(this._element,Pr),t.p.set(e,"aria-expanded","false"),e.textContent=i,this.switch(this._element,!0),g.A.trigger(this._element,Mr,{relatedTarget:e})}build(e=null,i=!0){const s=e||this._element,n=s.clientHeight,a=this._params.height||n/2,{fade:o,transition:l,button:h,number:d,content:c,elements:_,cnt:u,ellipsis:m}=this._params,p=null!==m.line,g=h.enabled&&i;t.x.add(s,this.classes.container),i?("text"===c&&n>a?this._setupTextContent(s,a,o,l,p,m.line,g,d):"elements"===c&&this._setupElementsContent(s,_,u,o,l,p,g,d),(0,r.g7)(this._params.callbacks.init,[s,this])):this.switch(s)}_setupTextContent(e,i,s,r,n,a,o,l){t.x.add(e,this.classes.hidden),e.style.height=i+"px",n&&a?(t.x.add(e,this.classes.ellipsis),e.style.lineClamp=Number(a)):n&&console.error("Переменная [data-line] или параметр[line] не должны быть пустыми"),r&&t.x.add(e,this.classes.transition),s&&t.x.add(e,this.classes.fade),o&&this._createButton(e,"",l)}_setupElementsContent(e,i,r,n,a,o,l,h){const d=s.A.findAll("."+i,e);this.total=d.length,this.count=r,d.forEach((e,i)=>{i>=r&&t.x.add(e,kr)});const c=l&&d.length>r;if(o&&t.x.add(e,this.classes.ellipsis),a&&t.x.add(e,this.classes.transition),n&&t.x.add(e,this.classes.fade),c){const t=this.total-this.count,i=h&&t>0?this._params.more+t:"";this._createButton(e,i,!1)}}_createButton(e,t="",i=!1){e.id||(e.id=`vg-rollup-${Math.random().toString(36).substr(2,9)}`);const s=this._params.button.more,r=`<div class="${this.classes.button}">\n <a href="#" aria-expanded="false" data-vg-toggle="rollup" class="${this._params.button.classes}" data-vg-target="#${e.id}">\n ${s}${t}\n </a>\n </div>`;e.insertAdjacentHTML("afterend",r)}switch(e,i=!1){if(i&&!this.isOffset){const{content:i}=this._params,n=e.clientHeight,a=this._params.height||n/2;if("text"===i&&n>a)t.x.add(e,this.classes.hidden),e.style.height=a+"px",this._params.ellipsis.line&&(t.x.add(e,this.classes.ellipsis),e.style.lineClamp=this._params.ellipsis.line),this._params.fade&&t.x.add(e,this.classes.fade),this._params.transition&&t.x.add(e,this.classes.transition),(0,r.g7)(this._params.callbacks.expand,[e,this]);else if("elements"===i){const i=s.A.findAll("."+this._params.elements,e);i.forEach((e,i)=>{i>=this.count&&t.x.add(e,kr)}),(0,r.g7)(this._params.callbacks.collapse,[e,i,this])}t.x.add(e,this.classes.container)}else{const{hidden:i,ellipsis:n,fade:a}=this.classes;t.x.remove(e,[i,n,a]),t.p.remove(e,"style"),"elements"===this._params.content&&s.A.findAll("."+this._params.elements,e).forEach(e=>t.x.remove(e,kr)),(0,r.g7)(this._params.callbacks.expand,[e,this])}}isShow(){return t.x.has(this._element,Pr)}static init(e,t={},i){const s=Or.getOrCreateInstance(e,t);(0,r.g7)(i,[s])}}g.A.on(document,Tr,'[data-vg-toggle="rollup"]',function(e){if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,r.d6)(this))return;const t=s.A.getElementFromSelector(this);t&&Or.toggle(t,this)});const zr=Or,Nr="vg.select",$r="vg-select",Hr="vg-select-list--option",Fr="vg-select-tag",Rr="vg-select-tag-remove",Br=`click.${Nr}.data.api`,jr=`keyup.${Nr}.data.api`,Ur=`reset.${Nr}.data.api`,qr=`keydown.${Nr}.data.api`,Vr=`${Nr}.change`,Wr=`${Nr}.search`,Kr=`${Nr}.select`,Gr=`${Nr}.deselect`,Yr='[data-vg-toggle="select"]',Xr="select",Zr="vg.select",Jr="show",Qr="active",en="vg-select",tn="vg-select-dropdown",sn="vg-select-list",rn="vg-select-list--option",nn="vg-select-current",an="vg-select-current--placeholder",on="vg-select-search",ln="vg-select-tags",hn="vg-select-tag",dn="vg-select-load-more",cn="vg-select-loading",_n="drop-up",un=`${Zr}.change`,mn=`${Zr}.hide`,pn=`${Zr}.hidden`,gn=`${Zr}.show`,fn=`${Zr}.shown`,bn=`${Zr}.init`,vn=`${Zr}.rebuild`,yn=`${Zr}.open`,wn=`${Zr}.close`,En=`${Zr}.select`,An=`${Zr}.clear`,Sn=`${Zr}.error`,Cn=`${Zr}.loadNext`,xn='[data-vg-toggle="select"]',Ln=`.${nn}`,In=`.${tn}`,Pn=`.${on} input`,kn=`.${sn}`,Mn=`.${dn}`,Dn=["inited","updating","exclude"];class Tn extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({lang:document.documentElement.lang||"ru",autosearch:!0,position:"none",search:{enabled:!1,route:"",remote:!1,delay:300,minterm:1,pagination:!1,pageParam:"page",termParam:"q",perpage:20,loadMoreText:"Загрузить ещё"},close:!0,tree:!1,exclude:"data-filter-param",placeholder:"",onInit:null,onShow:null,onHide:null,onChange:null,onSelect:null,onDeselect:null,onClear:null,onLoadNext:null},t)),this._observer=null,this._observerTimeout=null,this._visibilityTransitionId=0,this._drop=s.A.find(In,this._element),this._searchTerm="",this._currentPage=1,this._totalPages=null,this._loading=!1,"object"==typeof t.search&&(this._params.search.loadMoreText=Be(this._params.lang,Xr)["load-more"]||"Загрузить еще"),this._remoteSearchRequestId=0,this._remoteSearchAbortController=null,this._positioningScrollParent=null,this._boundUpdateDropdownPlacement=()=>this._updateDropdownPlacement(),this._initObserver(),this._syncSearch(),this._initLoadMoreButton(),this._triggerEvent(bn),this._callCallback("onInit")}static get NAME(){return Xr}static get NAME_KEY(){return Zr}static buildListOptions(e,i,r={}){let n=i.querySelector(`.${sn}`);n?n.innerHTML="":(n=document.createElement("ul"),t.x.add(n,sn),i.appendChild(n));const a=s.A.findAll("optgroup",e),o=document.createDocumentFragment(),l=this._isTreeEnabled(e,r);return a.length>0?(a.forEach(i=>{const r=document.createElement("ol");t.x.add(r,"vg-select-list--optgroup");const n=document.createElement("li");n.textContent=i.label.trim(),t.x.add(n,"vg-select-list--optgroup-title"),r.appendChild(n),Tn._createListItems(s.A.findAll("option",i),r,e,{tree:l,depth:l?1:0}),o.appendChild(r)}),n.appendChild(o)):Tn._createListItems(e.options,n,e,{tree:l,depth:0}),n}static _createListItems(e,i,s,n={}){const a=document.createDocumentFragment(),o=Number.isInteger(n.depth)?n.depth:0,l=!!n.tree;[...e].forEach(e=>{if(e.hidden)return;const i=e.getAttribute("value"),s=null==i?"":i,n=e.textContent.trim(),h=""===s&&""===n,d=document.createElement("li");if(d.textContent=n,d.dataset.index=String(e.index),d.dataset.value=s,d.classList.add(rn),t.p.set(d,"data-vg-toggle","select-option"),l){const t=e.dataset.level,i=Number.isFinite(Number(t))?parseInt(t,10):null,s=Math.max(0,null==i?o:i);d.dataset.level=String(s),d.style.paddingLeft=16+16*s+"px"}e.selected&&d.classList.add("selected"),e.disabled&&d.classList.add("disabled"),h&&(d.hidden=!0,d.style.display="none");const c=t.p.get(e);(0,r.ze)(c)||Object.keys(c).forEach(e=>{t.p.set(d,`data-${e}`,c[e])}),a.appendChild(d)}),i.appendChild(a)}static _isTreeEnabled(e,t={}){return"boolean"==typeof t.tree?t.tree:!(!e?.dataset||void 0===e.dataset.tree)&&!0===(0,r.OM)(e.dataset.tree)}static _getDataAttrCopyExclusions(e,t={}){const i=("string"==typeof t.exclude?t.exclude:e.dataset.exclude||"").split(",").map(e=>this._normalizeDataAttrKey(e)).filter(Boolean);return new Set([...Dn,...i])}static _normalizeDataAttrKey(e){return String(e||"").trim().replace(/^data-/,"").toLowerCase()}static _isSearchEnabled(e,t={}){if(!0===t.search?.enabled||!0===t.search?.remote)return!0;const i=t.autosearch;if(!1===i)return!1;const s=Number(i),r=!0!==i&&Number.isFinite(s)&&s>=0?s:7;return Array.from(e?.options||[]).filter(e=>!e.hidden&&(""!==e.value||""!==e.textContent.trim())).length>r}static isPlaceholderValue(e,t){const i=e.dataset.placeholderValue;return i?i.split(",").map(e=>e.trim()).includes(String(t)):null==t||""===String(t).trim()}static hasExplicitSelectedOption(e){return Array.from(e.options).some(e=>e.hasAttribute("selected"))}static hasSelectedValidOption(e){const t=e.selectedIndex;return-1!==t&&!this.isPlaceholderValue(e,e.options[t]?.value)}static build(e,i=!1,s={}){(i||"true"===e.dataset.inited)&&this.destroy(e);const n=document.createElement("div");n.classList.add(en),n.style.position="relative",e.classList.length&&[...e.classList].forEach(e=>n.classList.add(e)),(0,r.d6)(e)&&n.classList.add("disabled");const a=t.p.get(e);if(!(0,r.ze)(a)){const i=this._getDataAttrCopyExclusions(e,s);Object.keys(a).forEach(e=>{i.has(e)||t.p.set(n,`data-${e}`,a[e])})}const o=e.dataset.placeholder||"",l=e.multiple,h=document.createElement("div");if(h.classList.add(nn),h.setAttribute("data-vg-toggle","select"),h.setAttribute("aria-expanded","false"),h.setAttribute("role","button"),h.tabIndex=l?-1:0,l){const e=document.createElement("div");e.classList.add(ln),h.appendChild(e);const t=document.createElement("input");t.type="text",t.className="vg-select-multiple-input",t.style.cssText="border:0;outline:none;background:transparent;padding:0;margin:0;min-width:1px;width:1px;height:1px;line-height:1;font:inherit;opacity:0;",e.appendChild(t),t.addEventListener("focus",()=>{const e=Tn.getInstance(t.closest(`.${en}`));e&&!e._isShown()&&e.show()})}else{const t=e.selectedIndex,i=t>=0?e.options[t]:null,s=i?.textContent.trim()||"",r=o&&!this.hasSelectedValidOption(e);h.innerHTML=r?`<span class="${an}">${o}</span>`:s||"-"}n.appendChild(h);const d=document.createElement("div");return d.classList.add(tn),n.appendChild(d),this.buildListOptions(e,d,s),e.insertAdjacentElement("afterend",n),e.dataset.inited="true",this.getOrCreateInstance(n,s),this.updateUI(e),n}_syncSearch(){const e=this._element.previousElementSibling;if(!e||"SELECT"!==e.tagName||!this._drop)return;const t=Tn._isSearchEnabled(e,this._params),i=this._drop.querySelector(`.${on}`);if(!t)return void i?.remove();if(i)return;const s=document.createElement("div");s.classList.add(on);const r=document.createElement("input");let n;r.name="vg-select-search",r.type="text",r.placeholder=Fe(this._params.lang,Xr).search,r.autocomplete="off",r.setAttribute("role","searchbox"),s.appendChild(r),this._drop.insertBefore(s,this._drop.firstChild),r.addEventListener("input",e=>{const t=e.target.value.trim(),i=this._params;if(this._callCallback("onSearch",{term:t}),i.search.remote&&i.search.route){if(t.length<(i.search.minterm||1))return;clearTimeout(n),n=setTimeout(()=>{this._fetchRemoteData(t)},i.search.delay||300)}else this._filterLocalOptions(t)})}toggle(e){return this._isShown()?this.hide():this.show(e)}show(e){if((0,r.d6)(this._element))return;if(g.A.trigger(this._element,gn,{relatedTarget:e}).defaultPrevented)return;const t=++this._visibilityTransitionId;this._element.classList.add(Jr),this._element.classList.add(Qr),"none"!==this._getPositionMode()?this._setupDropdownPlacement():this._teardownDropdownPlacement(),"ontouchstart"in document.documentElement&&(document.body.style.pointerEvents="none"),this._element.querySelector(xn).setAttribute("aria-expanded","true");const i=this._element.querySelector(Pn);return i&&i.focus(),this._queueCallback(()=>{t===this._visibilityTransitionId&&this._isShown()&&(this._updateDropdownPlacement(),g.A.trigger(this._element,fn,{relatedTarget:e}),this._triggerEvent(yn),this._callCallback("onShow"))},this._drop,!0,50)}hide(){!(0,r.d6)(this._element)&&this._isShown()&&this._completeHide()}_completeHide(e={}){if(g.A.trigger(this._element,mn,e).defaultPrevented)return;const t=++this._visibilityTransitionId;this._teardownDropdownPlacement(),this._element.classList.remove(Qr),this._element.querySelector(xn).setAttribute("aria-expanded","false"),this._queueCallback(()=>{t===this._visibilityTransitionId&&(this._element.classList.remove(Jr),g.A.trigger(this._element,pn,e),this._triggerEvent(wn),this._callCallback("onHide"))},this._drop,!0,10),"ontouchstart"in document.documentElement&&(document.body.style.pointerEvents="")}_isShown(){return this._element.classList.contains(Jr)}_initObserver(){this._observer&&this._observer.disconnect();const e=this._element.previousElementSibling;e&&"SELECT"===e.tagName&&(this._observer=new MutationObserver(t=>{if(console.debug("VGSelect: Mutation detected",t),e.hasAttribute("data-updating"))return;if(!t.some(e=>"attributes"===e.type?["disabled","required","style","hidden"].includes(e.attributeName):"childList"===e.type||"characterData"===e.type))return;const i=this._isShown();clearTimeout(this._observerTimeout),this._observerTimeout=setTimeout(()=>{this._element.previousElementSibling!==e||e.hasAttribute("data-updating")||(this._updateFromMutation(),i&&requestAnimationFrame(()=>{this.show()}))},100)}),this._observer.observe(e,{attributes:!0,attributeFilter:["disabled","required","style","hidden"],childList:!0,subtree:!0,characterData:!0}))}_updateFromMutation(){const e=this._element.previousElementSibling;if(!e)return;(0,r.d6)(e)?this._element.classList.add("disabled"):this._element.classList.remove("disabled");const t=this._element.querySelector(In);Tn.buildListOptions(e,t,this._params),this._syncSearch(),Tn.updateUI(e)}dispose(){this._visibilityTransitionId++,this._observer&&(this._observer.disconnect(),this._observer=null),clearTimeout(this._observerTimeout),this._observerTimeout=null,this._teardownDropdownPlacement(),super.dispose()}_setupDropdownPlacement(){"none"!==this._getPositionMode()&&(this._teardownDropdownPlacement(),this._positioningScrollParent=this._getOverflowAncestor(this._element),window.addEventListener("resize",this._boundUpdateDropdownPlacement,{passive:!0}),window.addEventListener("scroll",this._boundUpdateDropdownPlacement,{passive:!0}),this._positioningScrollParent&&this._positioningScrollParent.addEventListener("scroll",this._boundUpdateDropdownPlacement,{passive:!0}),this._updateDropdownPlacement())}_teardownDropdownPlacement(){window.removeEventListener("resize",this._boundUpdateDropdownPlacement),window.removeEventListener("scroll",this._boundUpdateDropdownPlacement),this._positioningScrollParent&&this._positioningScrollParent.removeEventListener("scroll",this._boundUpdateDropdownPlacement),this._positioningScrollParent=null,this._element.classList.remove(_n),this._element.style.removeProperty("--vg-select-list-max-height")}_getPositionMode(){const e=this._params?.position,t=null==e?"none":String(e).trim().toLowerCase();return"auto"===t||"top"===t||"bottom"===t||"none"===t?t:"none"}_getOverflowAncestor(e){let t=e?.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){const e=window.getComputedStyle(t),i=e.overflowX||e.overflow||"visible",s=e.overflowY||e.overflow||"visible";if("visible"!==i||"visible"!==s)return t;t=t.parentElement}return null}_getClipRect(){const e={top:0,left:0,right:window.innerWidth,bottom:window.innerHeight},t=this._positioningScrollParent;if(!t)return e;const i=t.getBoundingClientRect();return{top:Math.max(e.top,i.top),left:Math.max(e.left,i.left),right:Math.min(e.right,i.right),bottom:Math.min(e.bottom,i.bottom)}}_updateDropdownPlacement(){if(!this._isShown())return;const e=this._getPositionMode();if("none"===e)return;const t=this._getClipRect(),i=this._element.getBoundingClientRect(),s=t.bottom-i.bottom,r=i.top-t.top,n="top"===e||"bottom"!==e&&r>s;this._element.classList.toggle(_n,n);const a=n?r:s,o=Math.max(80,Math.floor(a-12));Number.isFinite(o)&&o>0&&this._element.style.setProperty("--vg-select-list-max-height",`${o}px`)}static destroy(e){const t=e.nextElementSibling;t&&t.classList.contains(en)&&t.remove()}static updateUI(e){const t=e.nextElementSibling;if(!t||!t.classList.contains(en))return;const i=t.querySelector(Ln),s=e.dataset.placeholder||"",r=e.multiple,n=Tn.getInstance(t);if(r){const t=i.querySelector(`.${ln}`),r=t.querySelector("input"),a=t.querySelectorAll(`.${hn}`).length;t.innerHTML="",t.appendChild(r);const o=Array.from(e.selectedOptions);0===o.length&&a>0&&(n?._triggerEvent(An),n?._callCallback("onClear")),0===o.length?r.placeholder=s:(r.placeholder="",o.forEach(e=>{const i=document.createElement("div");i.classList.add(hn),i.innerHTML=`<span>${e.textContent}</span><svg class="vg-select-tag-remove" data-index="${e.index}" data-value="${e.getAttribute("value")??""}" width="14" height="14" viewBox="0 0 14 14"><line x1="2" y1="2" x2="12" y2="12" stroke="currentColor"/><line x1="12" y1="2" x2="2" y2="12" stroke="currentColor"/></svg>`,t.insertBefore(i,r)}))}else{const t=e.selectedIndex,r=t>=0?e.options[t]:null,n=r?.textContent.trim()||"",a=s&&!this.hasSelectedValidOption(e),o=a?s:n||"-";i.textContent!==o&&(i.innerHTML=a?`<span class="${an}">${s}</span>`:o)}}static changeSelector(e,t,i={}){const s=e.nextElementSibling,n=s?Tn.getInstance(s):null;e.setAttribute("data-updating","true");try{const s=e.querySelector(`option[value="${CSS.escape((0,r.OM)(t))}"]`);if(!s)return void n?._triggerEvent(Sn,{error:"Option not found",value:t});const a=s.selected,o=s.textContent.trim();e.multiple?s.selected=!1!==i?.selected:([...e.options].forEach(e=>e.selected=!1),s.selected=!0,e.value=s.value),this.updateUI(e);const l=new Event("change",{bubbles:!0,cancelable:!0});e.dispatchEvent(l),a||(g.A.trigger(e,un,{data:i}),n?._triggerEvent(En,{value:t,text:o,data:i}),n?._callCallback("onSelect",{value:t,text:o,data:i}))}finally{e.removeAttribute("data-updating")}}static changeSelectorByIndex(e,t,i={}){const s=e.nextElementSibling,r=s?Tn.getInstance(s):null;e.setAttribute("data-updating","true");try{const s=Number.isInteger(t)?e.options[t]:null;if(!s)return void r?._triggerEvent(Sn,{error:"Option not found by index",index:t});const n=s.selected,a=s.textContent.trim(),o=s.value;e.multiple?s.selected=!1!==i?.selected:([...e.options].forEach(e=>e.selected=!1),s.selected=!0,e.value=s.value),this.updateUI(e);const l=new Event("change",{bubbles:!0,cancelable:!0});e.dispatchEvent(l),n||(g.A.trigger(e,un,{data:i}),r?._triggerEvent(En,{value:o,text:a,data:i}),r?._callCallback("onSelect",{value:o,text:a,data:i}))}finally{e.removeAttribute("data-updating")}}_triggerEvent(e,t={}){g.A.trigger(this._element,e,t)}_callCallback(e,t=null){const i=this._params[e];"function"==typeof i&&i.call(this,this._element,t)}static init(e,t={},i=!1){this.build(e,i,t)}static clearDrops(e){const t=s.A.find(`.${en}.${Jr}`);if(!t)return;const i=e.target.closest(xn);if(i&&i.closest(`.${en}`)===t)return;if(e.composedPath().some(e=>e.classList?.contains(tn)))return;const r=Tn.getInstance(t);r&&r._completeHide({relatedTarget:e.target})}_initLoadMoreButton(){if(!this._params.search?.pagination||!this._params.search.remote)return;const e=this._element.querySelector(kn);if(!e)return;const t=document.createElement("li");t.className=dn,t.style.textAlign="center",t.style.padding="8px",t.style.cursor="pointer",t.style.color="#007bff",t.style.fontSize="14px",t.style.fontWeight="500",t.textContent=this._params.search.loadMoreText,t.addEventListener("click",()=>{!this._loading&&(null===this._totalPages||this._currentPage<this._totalPages)&&this._loadNextPage()}),e.appendChild(t),this._hideLoadMoreButton(!0)}_hideLoadMoreButton(e){const t=this._element.querySelector(Mn);t&&(t.style.display=e?"none":"block")}_showLoading(e){const t=this._element.querySelector(kn);let i=t.querySelector(`.${cn}`);e&&!i?(i=document.createElement("li"),i.className=cn,i.style.textAlign="center",i.style.padding="8px",i.textContent=Re(this._params.lang,Xr).loading,t.appendChild(i)):!e&&i&&i.remove()}async _loadNextPage(){const{route:e,pageParam:t="page",termParam:i="q",perpage:s=20}=this._params.search,r=this._currentPage+1,n=new URL(e,window.location.origin);n.searchParams.set(i,this._searchTerm),n.searchParams.set(t,r),n.searchParams.set("per_page",s),this._loading=!0,this._showLoading(!0),this._hideLoadMoreButton(!0);try{const e=await fetch(n,{headers:{"Content-Type":"application/json"}}),t=await e.json();Array.isArray(t.results)&&(Tn.addOptions(this._element.previousElementSibling,t,{preserve:!0}),this._currentPage=t.pagination?.current_page||r,this._totalPages=t.pagination?.total_pages||null,(null===this._totalPages||this._currentPage<this._totalPages)&&this._hideLoadMoreButton(!1),this._callCallback("onLoadNext",{page:this._currentPage,data:t}),this._triggerEvent(Cn,{page:this._currentPage,term:this._searchTerm}))}catch(e){console.error("VGSelect: Failed to load next page",e),this._triggerEvent(Sn,{error:"Pagination fetch failed",term:this._searchTerm}),this._hideLoadMoreButton(!1)}finally{this._showLoading(!1),this._loading=!1}}_fetchRemoteData(e){const{route:t,method:i="GET",pageParam:s="page",termParam:r="q",perpage:n=20}=this._params.search,a=new URL(t,window.location.origin);a.searchParams.set(r,e),a.searchParams.set(s,1),a.searchParams.set("per_page",n);const o=this._element.querySelector(Pn),l=this._isShown();this._searchTerm=e,this._currentPage=1,this._totalPages=null,this._remoteSearchAbortController&&this._remoteSearchAbortController.abort(),this._remoteSearchAbortController=new AbortController;const h=++this._remoteSearchRequestId,d=this._remoteSearchAbortController.signal;this._showLoading(!0),this._hideLoadMoreButton(!0),fetch(a,{method:i,headers:{"Content-Type":"application/json"},signal:d}).then(e=>e.json()).then(t=>{if(h!==this._remoteSearchRequestId)return;if((o?o.value.trim():"")!==e)return;const i=this._element.previousElementSibling;i&&([...i.querySelectorAll("option")].forEach(e=>{const t=e===i.options[0],s=""===(e.getAttribute("value")??""),r=""===(e.textContent||"").trim(),n=!0===e.hidden||e.hasAttribute("hidden"),a=e.hasAttribute("selected");t&&s&&r&&n&&a||e.hasAttribute("data-preserve")||e.closest("optgroup[data-preserve]")||e.remove()}),Tn.addOptions(i,t,{preserve:!0}),this._callCallback("onSearch",{term:e,data:t}),this._triggerEvent(vn,{term:e,data:t}),t.pagination&&(this._currentPage=t.pagination.current_page||1,this._totalPages=t.pagination.total_pages||null),(null===this._totalPages||this._currentPage<this._totalPages)&&this._hideLoadMoreButton(!1),l&&o&&(o.focus(),this._element.classList.add(Jr,Qr)))}).catch(t=>{t&&"AbortError"===t.name||(console.error("VGSelect: Remote search error",t),this._triggerEvent(Sn,{error:"Search request failed",term:e}),this._hideLoadMoreButton(!1))}).finally(()=>{h===this._remoteSearchRequestId&&this._showLoading(!1)})}static addOptions(e,t,i={}){const{preserve:s=!1}=i,r=e.nextElementSibling,n=r&&r.classList.contains(en),a=n?Tn.getInstance(r):null;let o=t;if(t&&t.results&&Array.isArray(t.results)&&(o=t.results),!Array.isArray(o))return void a?._triggerEvent(Sn,{error:"Invalid data format: expected array"});const l=this._isTreeEnabled(e,a?._params||{});s||([...e.querySelectorAll("option")].forEach(e=>{const t=e.closest("optgroup");""!==e.value&&(e.hasAttribute("data-preserve")||t&&t.hasAttribute("data-preserve")||e.remove())}),[...e.querySelectorAll("optgroup")].forEach(e=>{0!==e.children.length||e.hasAttribute("data-preserve")||e.remove()}));const h=(e,t,i=null)=>{const s=document.createElement("option"),r=Array.isArray(e.children)&&e.children.length>0;s.value=e.id||"",s.textContent=e.text||"",e.selected&&(s.selected=!0),e.disabled&&(s.disabled=!0),l&&Number.isInteger(i)&&(s.setAttribute("data-level",String(i)),r&&!s.value&&(s.disabled=!0)),Object.keys(e).filter(e=>!["id","text","selected","disabled","children"].includes(e)).forEach(t=>{s.setAttribute(`data-${t}`,e[t])}),t.appendChild(s)},d=(e,t,i=0)=>{e.forEach(e=>{h(e,t,i),Array.isArray(e.children)&&e.children.length>0&&d(e.children,t,i+1)})};if(l?d(o,e,0):o.forEach(t=>{if(t.children&&Array.isArray(t.children)){const i=document.createElement("optgroup");i.label=t.text||"",t.disabled&&(i.disabled=!0),t.children.forEach(e=>h(e,i)),e.appendChild(i)}else h(t,e)}),n){const t=r.querySelector(`.${tn}`);Tn.buildListOptions(e,t,a?._params||{}),a?._syncSearch(),a?._triggerEvent(vn)}else this.updateUI(e)}_filterLocalOptions(e){const t=this._drop.querySelector(`.${sn}`).querySelectorAll(`.${rn}`);e?(e=e.toLowerCase(),t.forEach(t=>{const i=t.textContent.toLowerCase();t.hidden=!i.includes(e)})):t.forEach(e=>e.hidden=!1)}}g.A.on(document,Br,e=>On.clearDrops(e)),g.A.on(document,Br,Yr,function(e){const t=e.target;if(t.closest(`.${Fr}`)||t.closest(`.${Rr}`))return void e.stopPropagation();const i=this.closest(`.${$r}`),r=On.getOrCreateInstance(i),n=s.A.find(`.${$r}.show`);n&&n!==i&&On.getInstance(n)?.hide(),r.toggle(this)}),g.A.on(document,Br,'[data-vg-toggle="select-option"]',function(e){const i=e.target;if(i.classList.contains("disabled"))return;const s=i.closest(`.${$r}`),r=s.previousElementSibling,n=r.multiple,a=i.dataset.index,o=Number.isFinite(Number(a))?parseInt(a,10):NaN,l=Number.isInteger(o)?r.options[o]:null;if(!l)return;const h=On.getInstance(s),d=l.selected,c=l.value;if(n)l.selected=!l.selected,i.classList.toggle("selected",l.selected),On.updateUI(r),r.dispatchEvent(new Event("change",{bubbles:!0})),g.A.trigger(r,Vr,{data:{value:c,title:i.textContent,...t.p.get(i)}}),l.selected?(h?._triggerEvent(Kr,{value:c,title:i.textContent,...t.p.get(i)}),h?._callCallback("onSelect",{value:c,title:i.textContent,...t.p.get(i)})):(h?._triggerEvent(Gr,{value:c,title:i.textContent,...t.p.get(i)}),h?._callCallback("onDeselect",{value:c,title:i.textContent,...t.p.get(i)}));else{if(d)return;s.querySelectorAll(`.${Hr}`).forEach(e=>e.classList.remove("selected")),i.classList.add("selected"),On.changeSelectorByIndex(r,o,{index:o,value:c,title:i.textContent,...t.p.get(i)}),!1!==h?._params?.close&&h?.hide()}}),g.A.on(document,jr,'[name="vg-select-search"]',function(e){const t=e.target,i=t.closest(".vg-select-dropdown"),s=i?.querySelector(".vg-select-list");if(!s)return;const n=t.closest(`.${$r}`),a=On.getInstance(n),o=s.querySelectorAll(`.${Hr}`),l=s.querySelectorAll(".vg-select-list--optgroup"),h=t.value.trim().toLowerCase(),d=[h,(0,r.Ff)(h),(0,r.Ff)(h,!0)];if(o.forEach(e=>{e.hidden=!1,e.style.display=""}),l.forEach(e=>{e.hidden=!1,e.style.display=""}),h){let e=0;l.length?l.forEach(t=>{const i=t.querySelectorAll(`.${Hr}`),s=Array.from(i).some(e=>{const t=e.textContent.toLowerCase();return d.some(e=>t.includes(e))});t.hidden=!s,t.style.display=s?"":"none",i.forEach(t=>{const i=t.textContent.toLowerCase(),s=d.some(e=>i.includes(e));t.hidden=!s,t.style.display=s?"":"none",s&&e++})}):o.forEach(t=>{const i=t.textContent.toLowerCase(),s=d.some(e=>i.includes(e));t.hidden=!s,t.style.display=s?"":"none",s&&e++}),a?._triggerEvent(Wr,{query:h,results:e}),a?._callCallback("onSearch",{query:h,results:e})}else a?._triggerEvent(Wr,{query:"",results:o.length}),a?._callCallback("onSearch",{query:"",results:o.length})}),g.A.on(document,Ur,"form",function(){s.A.findAll('select[data-inited="true"]',this).forEach(e=>On.build(e,!0))}),g.A.on(document,"keydown",Yr,function(e){const t=On.getInstance(this.closest(`.${$r}`));if(t)switch(e.key){case"Enter":case" ":e.preventDefault(),t.toggle();break;case"Escape":t._isShown()&&t.hide();break;case"ArrowDown":e.preventDefault(),t._isShown()||t.show()}}),g.A.on(document,Br,".vg-select-tags",function(e){const t=e.target.closest(`.${Rr}`);if(!t)return;e.preventDefault(),e.stopPropagation();const i=this.closest(`.${$r}`),s=i.previousElementSibling,r=t.dataset.index,n=Number.isFinite(Number(r))?parseInt(r,10):NaN,a=Number.isInteger(n)?s.options[n]:null,o=Number.isInteger(n)?i.querySelector(`.${Hr}[data-index="${n}"]`):null,l=On.getInstance(i);a&&(a.selected=!1,o&&o.classList.remove("selected"),On.updateUI(s),s.dispatchEvent(new Event("change",{bubbles:!0})),g.A.trigger(s,Vr,{data:{value:a.value}}),l?._triggerEvent(Gr,{value:a.value}),l?._callCallback("onDeselect",{value:a.value}))}),g.A.on(document,qr,".vg-select-multiple-input",function(e){if("Backspace"===e.key&&!e.target.value){const t=e.target,i=t.parentElement.querySelectorAll(`.${Fr}`);if(i.length>0){const e=i[i.length-1].querySelector("svg"),s=e?.dataset.index,r=Number.isFinite(Number(s))?parseInt(s,10):NaN,n=t.closest(`.${$r}`).previousElementSibling,a=Number.isInteger(r)?n.options[r]:null,o=Number.isInteger(r)?t.closest(`.${$r}`).querySelector(`.${Hr}[data-index="${r}"]`):null,l=On.getInstance(t.closest(`.${$r}`));a&&(a.selected=!1,o&&o.classList.remove("selected"),On.updateUI(n),n.dispatchEvent(new Event("change",{bubbles:!0})),g.A.trigger(n,Vr,{data:{value:a.value}}),l?._triggerEvent(Gr,{value:a.value}),l?._callCallback("onDeselect",{value:a.value}))}}});const On=Tn,zn=On,Nn="vg.sidebar",$n="data-vg-backdrop-owner",Hn="sidebar",Fn="show",Rn="vg-sidebar-open",Bn={HIDE:`${Nn}.hide`,HIDDEN:`${Nn}.hidden`,SHOW:`${Nn}.show`,SHOWN:`${Nn}.shown`,LOADED:`${Nn}.loaded`,KEYDOWN_DISMISS:`keydown.dismiss.${Nn}`,HIDE_PREVENTED:`hidePrevented.${Nn}`,CLICK_DATA_API:`click.${Nn}.data.api`,POPSTATE_DATA_API:`popstate.${Nn}.data.api`,DOM_LOADED_DATA_API:`DOMContentLoaded.${Nn}.data.api`};class jn extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)({backdrop:!0,overflow:!0,keyboard:!0,hash:!1,animation:{enable:!1,in:"animate__rollIn",out:"animate__rollOut",delay:800},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0}},t)),this._scrollBar=new h,this._backdropElement=null,this._params.animation.delay=this._params.animation.enable?this._params.animation.delay:0,this._addEventListeners(),this._dismissElement(),this._animation(this._element,Nn,this._params.animation)}static get NAME(){return"sidebar"}static get NAME_KEY(){return Nn}static getOpenSidebars(e=null){return s.A.findAll(".vg-sidebar.show").filter(t=>t!==e)}static getBackdropElement(){const e=s.A.findAll(`.vg-backdrop[${$n}="${Hn}"]`);return e.length?e[e.length-1]:null}toggle(e){return this._isShown()?this.hide():this.show(e)}_showPopstateHandler=null;show(e){if((0,r.d6)(this._element)||this._isShown())return;if(e&&(this._params=this._getParams(e,this._params)),this._route((e,t)=>{g.A.trigger(this._element,Bn.LOADED,{stats:e,data:t})}),g.A.trigger(this._element,Bn.SHOW,{relatedTarget:e}).defaultPrevented)return;const t=jn.getOpenSidebars(this._element).length>0;let i=null;this._params.backdrop&&(t?(i=jn.getBackdropElement(),i?this._backdropElement=i:p.show(e=>{i=e,this._backdropElement=e,e.setAttribute($n,Hn)})):p.show(e=>{i=e,this._backdropElement=e,e.setAttribute($n,Hn)})),this._params.overflow&&!t&&this._scrollBar.hide(),this._params.hash&&(history.pushState(null,"",`#${this._element.id}`),this._showPopstateHandler&&g.A.off(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler),this._showPopstateHandler=()=>this.hide(),g.A.on(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler)),this._element.classList.add(Fn),document.body.classList.add(Rn),this._queueCallback(()=>{const t=this._params.backdrop?i||jn.getBackdropElement():null;t&&g.A.on(t,"mousedown.vg.backdrop",()=>this.hide()),g.A.trigger(this._element,Bn.SHOWN,{relatedTarget:e})},this._element,!0,50)}hide(e=!1){if((0,r.d6)(this._element)||!this._isShown())return;if(g.A.trigger(this._element,Bn.HIDE).defaultPrevented)return;this._element.classList.remove(Fn);const t=jn.getOpenSidebars(this._element);t.length||document.body.classList.remove(Rn),setTimeout(()=>{this._element.setAttribute("aria-expanded","false"),this._queueCallback(()=>{e||(this._params.backdrop&&!t.length?p.hide(()=>{this._backdropElement=null,this._params.overflow&&!p.isActive()&&this._scrollBar.reset()},this._backdropElement||jn.getBackdropElement()):this._params.backdrop?this._backdropElement=null:this._params.overflow&&(t.length||p.isActive()||this._scrollBar.reset()),this._params.hash&&window.location.hash===`#${this._element.id}`&&history.replaceState("",document.title,window.location.pathname+window.location.search),this._showPopstateHandler&&(g.A.off(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler),this._showPopstateHandler=null),g.A.trigger(this._element,Bn.HIDDEN))},this._element,!0)},this._params.animation.delay)}dispose(){super.dispose(),g.A.off(this._element,Bn.HIDE),this._showPopstateHandler&&g.A.off(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler),this._scrollBar.reset()}_isShown(){return this._element.classList.contains(Fn)}_addEventListeners(){g.A.on(document,Bn.KEYDOWN_DISMISS,e=>{"Escape"===e.key&&(this._params.keyboard?this.hide():g.A.trigger(this._element,Bn.HIDE_PREVENTED))})}}(0,f.P)(jn),g.A.on(document,Bn.CLICK_DATA_API,'[data-vg-toggle="sidebar"]',function(e){const t=s.A.getElementFromSelector(this);t&&(["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,r.d6)(this)||(this.setAttribute("aria-expanded","true"),g.A.one(t,Bn.HIDDEN,()=>{this.setAttribute("aria-expanded","false")}),jn.getOrCreateInstance(t).toggle(this)))}),g.A.on(document,Bn.DOM_LOADED_DATA_API,function(){const e=window.location.hash.slice(1);if(!e)return;const t=s.A.find(`#${e}`);if(t&&t.classList.contains("vg-sidebar")&&!(0,r.d6)(t)){const e=jn.getOrCreateInstance(t);e._params.hash&&e.toggle()}});const Un=jn,qn="vg.spy",Vn=`.${qn}`,Wn=".data-api",Kn=`activate${Vn}`,Gn=`click${Vn}`,Yn=`load${Vn}${Wn}`,Xn="active",Zn="[href], [data-vg-target]",Jn=".nav-link",Qn=`${Jn}, .nav-item > ${Jn}, .list-group-item`;class ea extends e.A{constructor(e,t){super(e,t),this._params=this._configAfterMerge((0,r._v)({offset:null,rootMargin:"0px 0px -25%",smoothScroll:!0,target:this._element,threshold:[.1,.5,1]},t)),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement=null,this._activeTarget=null,this._observer=null,this._scrollbar=null,this._scrollbarListener=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get NAME(){return"spy"}static get NAME_KEY(){return qn}refresh(){this._initializeTargetsAndObservables(),this._updateRootElement(),this._maybeEnableSmoothScroll(),this._setupTracking()}_setupTracking(){this._updateSmoothScrollbar(),this._scrollbar?this._setupScrollbarTracking():(this._teardownScrollbarTracking(),this._rebuildObserver(),this._rootElement&&!this._isScrollableSelf(this._rootElement)&&window.Scrollbar&&setTimeout(()=>{this._scrollbar||(this._updateSmoothScrollbar(),this._scrollbar&&this._setupScrollbarTracking())},0))}_updateSmoothScrollbar(){const e=this._rootElement,t=window.Scrollbar;let i=null;e&&(i=e.scrollbar||null,!i&&t&&"function"==typeof t.get&&(i=t.get(e)||null)),i!==this._scrollbar&&(this._teardownScrollbarTracking(),this._scrollbar=i)}_setupScrollbarTracking(){this._scrollbar&&"function"==typeof this._scrollbar.addListener&&(this._observer&&this._observer.disconnect(),this._scrollbarListener&&"function"==typeof this._scrollbar.removeListener&&this._scrollbar.removeListener(this._scrollbarListener),this._scrollbarListener=e=>this._onScrollbarScroll(e),this._scrollbar.addListener(this._scrollbarListener),this._onScrollbarScroll(null))}_teardownScrollbarTracking(){this._scrollbar&&this._scrollbarListener&&"function"==typeof this._scrollbar.removeListener&&this._scrollbar.removeListener(this._scrollbarListener),this._scrollbarListener=null}_onScrollbarScroll(e){const t=e?.offset?.y??this._getParentScrollTop(),i=t>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=t;const s=this._getActivationLine(t),n=[];for(const[e,t]of this._observableSections.entries()){if(!t||!(0,r.zN)(t))continue;const i=this._targetLinks.get(e);i&&n.push({top:this._getSectionTop(t),link:i})}n.sort((e,t)=>e.top-t.top);let a=null;for(const e of n)if(e.top<=s)a=e.link;else if(!i)break;this._process(a)}_getActivationLine(e){const t=this._rootElement?this._rootElement.clientHeight:window.innerHeight||document.documentElement.clientHeight||0,i=(this._params.rootMargin||"").trim(),s=i?i.split(/\s+/):[],r=1===s.length||2===s.length?s[0]:s.length>=3?s[2]:null;if(r&&r.endsWith("%")){const i=Number.parseFloat(r);if(!Number.isNaN(i))return e+t*(1+i/100)}if(r&&r.endsWith("px")){const i=Number.parseFloat(r);if(!Number.isNaN(i))return e+t+i}return e+.75*t}_rebuildObserver(){this._observer&&this._observer.disconnect(),this._observer=this._getNewObserver();for(const e of this._observableSections.values())this._observer.observe(e)}_updateRootElement(){if(this._rootElement=this._normalizeScrollRoot(this._params.target),!this._rootElement&&this._isScrollableSelf(this._element)&&(this._rootElement=this._element),!this._rootElement){const e=this._observableSections.values().next().value||null;e&&this._isScrollable(e)?this._rootElement=e.parentElement:this._rootElement=e?this._getScrollParent(e):null}this._updateSmoothScrollbar(),this._previousScrollData.parentScrollTop=this._getParentScrollTop(),this._previousScrollData.visibleEntryTop=0}_normalizeScrollRoot(e){const t=(0,r.V6)(e);if(!t)return null;if(t===document.body||t===document.documentElement)return null;if(this._isScrollableSelf(t))return t;const i=window.Scrollbar;return t.scrollbar||i&&"function"==typeof i.get&&i.get(t)?t:null}_isScrollable(e){if(!(e instanceof HTMLElement))return!1;const t=e.parentElement;return!!t&&this._isScrollableSelf(t)}_isScrollableSelf(e){if(!(e instanceof HTMLElement))return!1;const t=getComputedStyle(e).overflowY;return!!/(auto|scroll|overlay)/.test(t)&&e.scrollHeight>e.clientHeight}_getScrollParent(e){for(let t=e.parentElement;t&&t!==document.body;t=t.parentElement)if(this._isScrollableSelf(t))return t;return null}_getSectionTop(e){if(this._rootElement){const t=this._rootElement.getBoundingClientRect(),i=e.getBoundingClientRect();return(this._scrollbar?.offset?.y??this._rootElement.scrollTop)+(i.top-t.top)}return(window.scrollY||document.documentElement.scrollTop||0)+e.getBoundingClientRect().top}_getParentScrollTop(){return this._scrollbar?this._scrollbar.offset?.y??0:this._rootElement?this._rootElement.scrollTop:window.scrollY||document.documentElement.scrollTop||0}dispose(){this._observer&&this._observer.disconnect(),this._teardownScrollbarTracking(),this._scrollbar=null,super.dispose()}_configAfterMerge(e){return e.target=(0,r.V6)(e.target)||document.body,null!=e.offset&&(e.rootMargin=`${e.offset}px 0px -30%`),"string"==typeof e.threshold&&(e.threshold=e.threshold.split(",").map(e=>Number.parseFloat(e.trim()))),e}_maybeEnableSmoothScroll(){this._params.smoothScroll&&(g.A.off(this._element,Gn),g.A.on(this._element,Gn,Zn,e=>{const t=e.delegateTarget||e.target,i=this._getTargetIdFromTrigger(t);if(!i)return;let n=this._observableSections.get(i);if(n||(n=s.A.findID(i),n&&(this._targetLinks.set(n.id,t),this._observableSections.set(n.id,n))),!n)return;if(!(0,r.zN)(n))return void setTimeout(()=>{const e=s.A.findID(i);if(!e||!(0,r.zN)(e))return;this._targetLinks.set(e.id,t),this._observableSections.set(e.id,e),this._updateRootElement(),this._setupTracking();const n=this._getSectionTop(e);this._scrollbar&&"function"==typeof this._scrollbar.scrollTo?this._scrollbar.scrollTo(0,n,600):this._rootElement?this._rootElement.scrollTo?this._rootElement.scrollTo({top:n,behavior:"smooth"}):this._rootElement.scrollTop=n:window.scrollTo?window.scrollTo({top:n,behavior:"smooth"}):document.documentElement.scrollTop=n,this._process(t)},0);e.preventDefault(),this._updateRootElement(),this._setupTracking();const a=this._getSectionTop(n),o=this._rootElement;return this._scrollbar&&"function"==typeof this._scrollbar.scrollTo?(this._scrollbar.scrollTo(0,a,600),void this._process(t)):o?(o.scrollTo?o.scrollTo({top:a,behavior:"smooth"}):o.scrollTop=a,void this._process(t)):(window.scrollTo?window.scrollTo({top:a,behavior:"smooth"}):document.documentElement.scrollTop=a,void this._process(t))}))}_getNewObserver(){const e={root:this._rootElement,rootMargin:this._params.rootMargin,threshold:this._params.threshold};return new IntersectionObserver(e=>this._observerCallback(e),e)}_observerCallback(e){const t=e=>this._targetLinks.get(e.target.id),i=this._getParentScrollTop(),s=i>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=i;for(const i of e){if(!i.isIntersecting){this._clearActiveClass(t(i));continue}const e=this._getSectionTop(i.target),r=e>=this._previousScrollData.visibleEntryTop;(s&&r||!s&&!r)&&(this._previousScrollData.visibleEntryTop=e,this._process(t(i)))}}_initializeTargetsAndObservables(){this._targetLinks.clear(),this._observableSections.clear();const e=s.A.findAll(Zn,this._element);for(const t of e){if((0,r.d6)(t))continue;const e=this._getTargetIdFromTrigger(t);if(!e)continue;const i=s.A.findID(e);i&&(this._targetLinks.set(i.id,t),this._observableSections.set(i.id,i))}}_process(e){this._activeTarget!==e&&(this._clearActiveClass(this._element),this._activeTarget=e,e&&(e.classList.add(Xn),this._activateParents(e),g.A.trigger(this._element,Kn,{relatedTarget:e})))}_activateParents(e){if(e.classList.contains("vg-dropdown-item")){const t=s.A.find('[data-vg-toggle="dropdown"]',e.closest(".vg-dropdown"));return void(t&&t.classList.add(Xn))}for(const t of s.A.parents(e,".nav, .list-group"))for(const e of s.A.prev(t,Qn))e.classList.add(Xn)}_clearActiveClass(e){if(!e)return;e.classList.remove(Xn);const t=s.A.findAll(`[href].${Xn}, [data-vg-target].${Xn}`,e);for(const e of t)e.classList.remove(Xn)}_getTargetIdFromTrigger(e){if(!e||"function"!=typeof e.getAttribute)return null;const t=(e.getAttribute("data-vg-target")||"").trim(),i=(e.getAttribute("href")||"").trim(),s=t&&"#"!==t?t:i&&(i.includes("#")||i.startsWith("#"))?i.includes("#")&&!i.startsWith("#")?`#${i.split("#")[1]}`:i:null;if(!s||"#"===s||!s.startsWith("#"))return null;const r=this._safeDecode(s);return r&&r.startsWith("#")&&r.length>1?r.slice(1):null}_safeDecode(e){try{return decodeURIComponent(e)}catch{try{return decodeURI(e)}catch{return e}}}}(()=>{let e=!1;const t=()=>{if(!e){e=!0;for(const e of s.A.findAll('[data-vg-toggle="spy"]'))ea.getOrCreateInstance(e)}};"loading"===document.readyState?g.A.on(document,`DOMContentLoaded${Vn}${Wn}`,t):t(),g.A.on(window,Yn,t)})();const ta=ea,ia="vg.tabs",sa=`${ia}.hide`,ra=`${ia}.hidden`,na=`${ia}.show`,aa=`${ia}.shown`,oa=`${ia}.loaded`,la=`keydown.${ia}`,ha=`load.${ia}`,da=`click.${ia}`,ca=`mouseover.${ia}`,_a=`mouseout.${ia}`,ua=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ma="ArrowRight",pa="ArrowDown",ga="Home",fa="End",ba="active",va="hover",ya="fade",wa="show",Ea="vg-tabs-slider",Aa='.vg-tabs-link:not([data-vg-toggle="dropdown"]), .list-group-item:not([data-vg-toggle="dropdown"]), [role="tab"]:not([data-vg-toggle="dropdown"])',Sa='[data-vg-toggle="tab"]',Ca={DROPDOWN_TOGGLE:'[data-vg-toggle="dropdown"]',DROPDOWN_MENU:".dropdown-content",TAB_CLASS:".vg-tabs",TAB_PANEL:'.list-group, .vg-tabs-panel, [role="tablist"]',OUTER:".vg-tabs-item, .list-group-item",INNER:Aa,DATA_TOGGLE:Sa,INNER_ELEM:`${Aa}, ${Sa}`,DATA_TOGGLE_ACTIVE:'.active[data-vg-toggle="tab"]'};class xa extends e.A{constructor(e,t){if(super(e,t),this._params=(0,r._v)({slide:!1,hash:!1,ajax:{route:"",target:"",method:"get",loader:!1,once:!0,output:!0}},this._params),this._parent=this._element.closest(Ca.TAB_PANEL),this._main_parent=this._parent?.closest(Ca.TAB_CLASS)||null,!this._parent)throw new TypeError(`${e.outerHTML} не имеет родителя с селектором ${Ca.INNER_ELEM}`);this._params=this._getParams(this._main_parent,this._params),this._params=this._getParams(this._element,this._params),this._setInitialAttributes(this._parent,this._getChildren()),this._setInitialSlider(),this._setTabHash(),g.A.on(this._element,la,e=>this._keydown(e))}static get NAME(){return"tabs"}static get NAME_KEY(){return ia}show(){const e=this._element;if(this._elemIsActive(e))return;const t=this._getActiveElem(),i=e,s=t?g.A.trigger(t,sa,{relatedTarget:i}):null;g.A.trigger(e,na,{relatedTarget:i}).defaultPrevented||s&&s.defaultPrevented||(this._deactivate(t,e),this._activate(e,i))}_elemIsActive(e){return e?.classList.contains(ba)||!1}_getActiveElem(){return this._getChildren().find(e=>this._elemIsActive(e))||null}_activate(e,t){if(!e)return;e.classList.add(ba);const i=s.A.getElementFromSelector(e);i&&this._activate(i,t),this._queueCallback(()=>{"tab"===e.getAttribute("role")?(this._route((e,t)=>{g.A.trigger(this._element,oa,{stats:e,data:t})}),e.removeAttribute("tabindex"),e.setAttribute("aria-selected","true"),this._toggleDropDown(e,!0),g.A.trigger(e,aa,{relatedTarget:t})):e.classList.add(wa)},e,e.classList.contains(ya))}_deactivate(e,t){if(!e)return;e.classList.remove(ba),e.blur();const i=s.A.getElementFromSelector(e);i&&this._deactivate(i,t),this._queueCallback(()=>{"tab"===e.getAttribute("role")?(e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),this._toggleDropDown(e,!1),g.A.trigger(e,ra,{relatedTarget:t})):e.classList.remove(wa)},e,e.classList.contains(ya))}_keydown(e){if(!ua.includes(e.key))return;e.stopPropagation(),e.preventDefault();const t=this._getChildren().filter(e=>!(0,r.d6)(e));let i;if([ga,fa].includes(e.key))i=t[e.key===ga?0:t.length-1];else{const s=[ma,pa].includes(e.key);i=(0,r.iq)(t,e.target,s,!0)}i&&(i.focus({preventScroll:!0}),xa.getOrCreateInstance(i).show())}_setTabHash(){if(!this._params.hash)return;const e=document.location.toString();if(!e.includes("#"))return;const t=e.split("#")[1],i=s.A.find(`[href="#${t}"]`,this._parent)||s.A.find(`[data-vg-target="#${t}"]`,this._element)||null;i&&xa.getOrCreateInstance(i).show()}_setInitialSlider(){if(!this._params.slide)return;let e=s.A.find(`.${Ea}`,this._main_parent);e||(e=document.createElement("span"),e.classList.add(Ea),this._main_parent.prepend(e)),this._main_parent.classList.add("vg-tabs-with-slider");const t=s.A.find(`.${ba}`,this._parent);if(!t)return;const{width:i,height:n}=window.getComputedStyle(t);t.classList.add(va),e.style.width=i,e.style.height=n,e.style.left=`${t.offsetLeft}px`,g.A.on(this._main_parent,ca,Ca.DATA_TOGGLE,t=>{const i=t.target;if(["A","AREA"].includes(i.tagName)&&t.preventDefault(),(0,r.d6)(i))return;const n=s.A.find(`.${va}`,this._parent);n&&n.classList.remove(va),i.classList.add(va);const{width:a,height:o}=window.getComputedStyle(i);e.style.width=a,e.style.height=o,e.style.left=`${i.offsetLeft}px`}),g.A.on(this._main_parent,_a,Ca.DATA_TOGGLE,()=>{const t=s.A.find(`.${ba}`,this._parent),{width:i,height:r}=window.getComputedStyle(t);s.A.findAll(`.${va}`,this._parent).forEach(e=>e.classList.remove(va)),t.classList.add(va),e.style.width=i,e.style.height=r,e.style.left=`${t.offsetLeft}px`})}_setInitialAttributes(e,t){this._setAttributeIfNotExists(e,"role","tablist"),t.forEach(e=>this._setInitialAttributesOnChild(e))}_setInitialAttributesOnChild(e){e=this._getInnerElement(e);const t=this._elemIsActive(e),i=this._getOuterElement(e);e.setAttribute("aria-selected",t),i!==e&&this._setAttributeIfNotExists(i,"role","presentation"),t||e.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(e,"role","tab"),this._setInitialAttributesOnTargetPanel(e)}_setInitialAttributesOnTargetPanel(e){const t=s.A.getElementFromSelector(e);t&&(this._setAttributeIfNotExists(t,"role","tabpanel"),e.id&&this._setAttributeIfNotExists(t,"aria-labelledby",e.id))}_setAttributeIfNotExists(e,t,i){e.hasAttribute(t)||e.setAttribute(t,i)}_getChildren(){return s.A.findAll(Ca.INNER_ELEM,this._parent)}_getInnerElement(e){return e.matches(Ca.INNER_ELEM)?e:s.A.find(Ca.INNER_ELEM,e)}_getOuterElement(e){return e.closest(Ca.OUTER)||e}_toggleDropDown(e,t){const i=this._getOuterElement(e);if(!i.classList.contains("dropdown"))return;const r=(e,r)=>{const n=s.A.find(e,i);n&&n.classList.toggle(r,t)};r(Ca.DROPDOWN_TOGGLE,ba),r(Ca.DROPDOWN_MENU,wa),i.setAttribute("aria-expanded",t)}}g.A.on(document,da,Ca.DATA_TOGGLE,function(e){["A","AREA"].includes(this.tagName)&&e.preventDefault(),(0,r.d6)(this)||xa.getOrCreateInstance(this).show()}),g.A.on(window,ha,()=>{s.A.findAll(Ca.DATA_TOGGLE_ACTIVE).forEach(e=>{xa.getOrCreateInstance(e)})});const La=xa,Ia="th",Pa='a, button, input, select, textarea, [contenteditable="true"], [data-vg-table-column-resize-handle]',ka=class{constructor(e,t={},i=e){this._table=e,this._headerTable=i,this._options=Object.assign({hover:!1,multiple:!1,multipleWithShift:!0},t),this._headers=[],this._originalRows=new Map,this._sorts=[],this._boundClick=this._handleClick.bind(this),this._boundKeydown=this._handleKeydown.bind(this)}init(){this._headers=this._getHeaders(),this._rememberOriginalRows(),this._table.classList.toggle("vg-table-sort-hover",!0===this._options.hover),this._headerTable.classList.toggle("vg-table-sort-hover",!0===this._options.hover),this._table.classList.toggle("vg-table-sort-multiple",!0===this._options.multiple),this._headerTable.classList.toggle("vg-table-sort-multiple",!0===this._options.multiple),this._headers.forEach(e=>{this._isSortable(e)&&(e.classList.add("vg-table-sortable"),e.setAttribute("aria-sort","none"),this._decorateHeader(e),e.hasAttribute("tabindex")||(e.tabIndex=0))}),this._headerTable.addEventListener("click",this._boundClick),this._headerTable.addEventListener("keydown",this._boundKeydown)}dispose(){this._headerTable.removeEventListener("click",this._boundClick),this._headerTable.removeEventListener("keydown",this._boundKeydown),this._table.classList.remove("vg-table-sort-hover"),this._headerTable.classList.remove("vg-table-sort-hover"),this._table.classList.remove("vg-table-sort-multiple"),this._headerTable.classList.remove("vg-table-sort-multiple"),this._headers.forEach(e=>{e.classList.remove("vg-table-sortable"),e.removeAttribute("aria-sort"),e.removeAttribute("data-sort-direction"),e.removeAttribute("data-sort-priority"),e.querySelector("[data-vg-table-sort-controls]")?.remove()}),this._sorts=[],this._syncColumnHighlight(),this._headers=[],this._originalRows.clear()}setSort(e,t="asc",i=!1){const s=this._resolveColumnIndex(e);return this.setSorts([{columnIndex:s,direction:t}],i)}setSorts(e=[],t=!1){const i=this._normalizeSorts(e);return!(e.length&&!i.length||(this._sorts=!0===this._options.multiple?i:i.slice(0,1),this._applySort(),this._syncHeaders(),t&&this._emitChange(),0))}getSort(){const e=this._sorts[0];if(!e)return null;const t=this._headers[e.index];return{columnIndex:e.index,field:t?String(t.getAttribute("data-field")||"").trim():"",direction:e.direction}}getSorts(){return this._sorts.map(e=>{const t=this._headers[e.index];return{columnIndex:e.index,field:t?String(t.getAttribute("data-field")||"").trim():"",direction:e.direction}})}getSortState(){const e=this.getSort();return e?Object.assign({},e,{sorts:this.getSorts()}):null}refresh(e=!1){if(e){const e=this.getSorts();this._headers=this._getHeaders(),this._headers.forEach(e=>{this._isSortable(e)&&(e.classList.add("vg-table-sortable"),e.hasAttribute("aria-sort")||e.setAttribute("aria-sort","none"),this._decorateHeader(e),e.hasAttribute("tabindex")||(e.tabIndex=0))}),this.setSorts(e,!1)}else this._syncColumnHighlight();return this.getSort()}clearSort(e=!1){this._sorts=[],!0!==this._options.remote&&this._restoreOriginalRows(),this._syncHeaders(),e&&this._emitChange()}_getHeaders(){const e=this._headerTable.tHead||this._headerTable.querySelector("thead");return e&&e.rows.length?Array.from(e.rows[e.rows.length-1].querySelectorAll(Ia)):[]}_isSortable(e){return"false"!==String(e.getAttribute("data-sort-enabled")||"").toLowerCase()}_rememberOriginalRows(){Array.from(this._table.tBodies||[]).forEach(e=>{this._originalRows.set(e,Array.from(e.rows))})}_restoreOriginalRows(){this._originalRows.forEach((e,t)=>{e.forEach(e=>t.append(e))})}_handleClick(e){if(e.target.closest(Pa))return;const t=e.target.closest(Ia);t&&this._headers.includes(t)&&this._isSortable(t)&&this._cycleSort(this._headers.indexOf(t),this._isMultipleMode(e))}_handleKeydown(e){if("Enter"!==e.key&&" "!==e.key)return;if(e.target.closest(Pa))return;const t=e.target.closest(Ia);t&&this._headers.includes(t)&&this._isSortable(t)&&(e.preventDefault(),this._cycleSort(this._headers.indexOf(t),this._isMultipleMode(e)))}_isMultipleMode(e){return!0===this._options.multiple&&(!1===this._options.multipleWithShift||!0===e?.shiftKey)}_cycleSort(e,t=!1){const i=this._sorts.find(t=>t.index===e);if(!i)return void this._setColumnSort(e,"asc",t);if("asc"===i.direction)return void this._setColumnSort(e,"desc",t);const s=t?this._sorts.filter(t=>t.index!==e):[];this.setSorts(s,!0)}_setColumnSort(e,t,i){const s=i?this._sorts.slice():[],r=s.findIndex(t=>t.index===e),n={columnIndex:e,direction:t};r>=0?s.splice(r,1,n):s.push(n),this.setSorts(s,!0)}_applySort(){!0!==this._options.remote&&this._sorts.length&&this._originalRows.forEach((e,t)=>{const i=new Map(e.map((e,t)=>[e,t])),s=Array.from(t.rows);s.sort((e,t)=>{for(const i of this._sorts){const s=this._headers[i.index],r=String(s?.getAttribute("data-sort-type")||"auto").toLowerCase(),n=this._compareCells(e.cells[i.index],t.cells[i.index],r);if(0!==n)return"desc"===i.direction?-n:n}return(i.get(e)??0)-(i.get(t)??0)}),s.forEach(e=>t.append(e))})}_compareCells(e,t,i){const s=this._getCellValue(e),r=this._getCellValue(t);if("number"===i||"auto"===i&&this._isNumeric(s)&&this._isNumeric(r))return this._toNumber(s)-this._toNumber(r);if("date"===i){const e=Date.parse(s),t=Date.parse(r);if(!Number.isNaN(e)&&!Number.isNaN(t))return e-t}return s.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}_getCellValue(e){return e?String(e.getAttribute("data-sort-value")??e.textContent??"").trim():""}_isNumeric(e){return""!==e&&Number.isFinite(this._toNumber(e))}_toNumber(e){return Number(String(e).replace(/\s/g,"").replace(",","."))}_decorateHeader(e){if(e.querySelector("[data-vg-table-sort-controls]"))return;const t=document.createElement("span");t.className="vg-table-sort-controls",t.setAttribute("data-vg-table-sort-controls",""),t.setAttribute("aria-hidden","true"),t.innerHTML='\n\t\t\t<span class="vg-table-sort-priority" data-vg-table-sort-priority hidden></span>\n\t\t\t<span class="vg-table-sort-chevron vg-table-sort-chevron-asc"></span>\n\t\t\t<span class="vg-table-sort-chevron vg-table-sort-chevron-desc"></span>\n\t\t',e.append(t)}_syncHeaders(){this._headers.forEach((e,t)=>{const i=this._sorts.findIndex(e=>e.index===t),s=i>=0?this._sorts[i].direction:null,r=e.querySelector("[data-vg-table-sort-priority]");e.setAttribute("aria-sort","asc"===s?"ascending":"desc"===s?"descending":"none"),s?(e.setAttribute("data-sort-direction",s),e.setAttribute("data-sort-priority",String(i+1)),r&&(r.textContent=String(i+1),r.hidden=this._sorts.length<2)):(e.removeAttribute("data-sort-direction"),e.removeAttribute("data-sort-priority"),r&&(r.hidden=!0))}),this._syncColumnHighlight()}_syncColumnHighlight(){const e=[...Array.from(this._headerTable.rows||[]),...Array.from(this._table.rows||[])].filter(e=>!e.hasAttribute("data-vg-table-state-row"));e.forEach(e=>{Array.from(e.cells||[]).forEach(e=>{e.removeAttribute("data-sorted-column"),e.removeAttribute("data-sorted-priority")})}),this._sorts.forEach((t,i)=>e.forEach(e=>{const s=e.cells[t.index];s&&(s.setAttribute("data-sorted-column","1"),s.setAttribute("data-sorted-priority",String(i+1)))}))}_normalizeSorts(e){const t=[],i=new Set;return(Array.isArray(e)?e:[]).forEach(e=>{const s=e?.field??e?.columnIndex??e?.index,r=this._resolveColumnIndex(s);r<0||i.has(r)||!this._isSortable(this._headers[r])||(i.add(r),t.push({index:r,direction:"desc"===String(e?.direction??e?.dir??"asc").toLowerCase()?"desc":"asc"}))}),t}_emitChange(){g.A.trigger(this._table,"sortchange.vg.table",{sort:this.getSort(),sorts:this.getSorts()})}_resolveColumnIndex(e){if("string"==typeof e)return this._headers.findIndex(t=>String(t.getAttribute("data-field")||"").trim()===e.trim());const t=Number.parseInt(e,10);return Number.isInteger(t)?t:-1}},Ma=class{constructor(e,t={}){this._scrollHost=e.closest(".vg-table-body")||e.closest(".vg-table-container")||e.closest(".vg-table-wrapper"),this._stateTarget=e.closest(".vg-table-wrapper")||this._scrollHost,this._onMove="function"==typeof t.onMove?t.onMove:null,this._active=!1,this._moved=!1,this._pointerId=null,this._startX=0,this._startScrollLeft=0,this._suppressClick=!1,this._suppressClickTimer=null,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundPointerCancel=this._handlePointerCancel.bind(this),this._boundClick=this._handleClick.bind(this)}init(){this._scrollHost&&(this._scrollHost.addEventListener("pointerdown",this._boundPointerDown),this._scrollHost.addEventListener("pointermove",this._boundPointerMove),this._scrollHost.addEventListener("pointerup",this._boundPointerUp),this._scrollHost.addEventListener("pointercancel",this._boundPointerCancel),this._scrollHost.addEventListener("click",this._boundClick,!0))}dispose(){this._scrollHost&&(this._scrollHost.removeEventListener("pointerdown",this._boundPointerDown),this._scrollHost.removeEventListener("pointermove",this._boundPointerMove),this._scrollHost.removeEventListener("pointerup",this._boundPointerUp),this._scrollHost.removeEventListener("pointercancel",this._boundPointerCancel),this._scrollHost.removeEventListener("click",this._boundClick,!0),this._scrollHost.classList.remove("is-panning"),this._stateTarget?.classList.remove("is-panning"),this._suppressClickTimer&&window.clearTimeout(this._suppressClickTimer),this._reset())}_handlePointerDown(e){e.isPrimary&&"mouse"===e.pointerType&&0===e.button&&e.shiftKey&&(this._scrollHost.scrollWidth<=this._scrollHost.clientWidth||e.target.closest('a, button, input, select, textarea, [contenteditable="true"], [role="button"]')||(this._active=!0,this._moved=!1,this._pointerId=e.pointerId,this._startX=e.clientX,this._startScrollLeft=this._scrollHost.scrollLeft,this._stateTarget.classList.add("is-panning"),e.cancelable&&e.preventDefault(),"function"==typeof this._scrollHost.setPointerCapture&&this._scrollHost.setPointerCapture(e.pointerId)))}_handlePointerMove(e){if(!this._active||e.pointerId!==this._pointerId)return;const t=e.clientX-this._startX;!this._moved&&Math.abs(t)>4&&(this._moved=!0),this._scrollHost.scrollLeft=this._startScrollLeft-t,this._onMove?.(this._scrollHost.scrollLeft),this._moved&&e.cancelable&&e.preventDefault()}_handlePointerUp(e){if(e.pointerId===this._pointerId){if("function"==typeof this._scrollHost.releasePointerCapture)try{this._scrollHost.releasePointerCapture(e.pointerId)}catch(e){}this._moved&&(this._suppressClick=!0,this._suppressClickTimer=window.setTimeout(()=>{this._suppressClick=!1,this._suppressClickTimer=null},0)),this._reset()}}_handlePointerCancel(e){e.pointerId===this._pointerId&&this._reset()}_handleClick(e){this._suppressClick&&(this._suppressClick=!1,this._suppressClickTimer&&window.clearTimeout(this._suppressClickTimer),this._suppressClickTimer=null,e.preventDefault(),e.stopImmediatePropagation())}_reset(){this._active=!1,this._moved=!1,this._pointerId=null,this._stateTarget?.classList.remove("is-panning")}},Da="tbody tr",Ta="vg-table-row-selected",Oa="data-vg-table-selected",za=class{constructor(e,t={}){this._table=e,this._options=Object.assign({click:!0,multiple:!1},t),this._boundClick=this._handleClick.bind(this)}init(){this._table.classList.toggle("vg-table-selection-click",!0===this._options.click),!0===this._options.click&&this._table.addEventListener("click",this._boundClick)}dispose(){this._table.removeEventListener("click",this._boundClick),this._table.classList.remove("vg-table-selection-click"),this.getSelectedRows().forEach(e=>this._setRowState(e,!1))}selectRow(e,t=!0,i=!0){const s=this._resolveRow(e);if(!s)return!1;const r=!0===t;return r===s.classList.contains(Ta)||(r&&!0!==this._options.multiple&&this.getSelectedRows().forEach(e=>{e!==s&&this._setRowState(e,!1)}),this._setRowState(s,r),i&&this._emitChange(s,r)),!0}toggleRow(e,t=!0){const i=this._resolveRow(e);return!!i&&this.selectRow(i,!i.classList.contains(Ta),t)}getSelectedRows(){return this._getRows().filter(e=>e.classList.contains(Ta))}clearSelection(e=!0){const t=this.getSelectedRows();return!!t.length&&(t.forEach(e=>this._setRowState(e,!1)),e&&this._emitChange(null,!1),!0)}_handleClick(e){if(e.target.closest('a, button, input, select, textarea, label, [contenteditable="true"], [role="button"], [data-vg-table-selection-ignore]'))return;const t=e.target.closest(Da);t&&this._table.contains(t)&&this.toggleRow(t)}_getRows(){return Array.from(this._table.tBodies||[]).flatMap(e=>Array.from(e.rows||[]))}_resolveRow(e){if(e instanceof Element){const t=e.matches(Da)?e:e.closest(Da);return t&&this._table.contains(t)?t:null}const t=Number.parseInt(e,10);return Number.isInteger(t)&&this._getRows()[t]||null}_setRowState(e,t){e.classList.toggle(Ta,t),t?e.setAttribute(Oa,"true"):e.removeAttribute(Oa)}_emitChange(e,t){const i=this.getSelectedRows(),s=this._getRows(),r=i.map(e=>e.getAttribute("data-row-key")||String(s.indexOf(e)));g.A.trigger(this._table,"selectionchange.vg.table",{row:e,selected:t,rows:i,keys:r})}},Na="pagechange.vg.table",$a="data-vg-table-pagination-generated",Ha=class{constructor(e,t={}){this._table=e,this._options=t,this._host=e.closest(".vg-table-wrapper")||e.parentElement,this._containers=[],this._dropdowns=[],this._page=this._positiveInt(t.page,1),this._perPage=this._clampPerPage(t.per),this._remote=!0===t.remote,this._totalRowsValue=0,this._totalPagesValue=this._remote?this._page:1,this._boundClick=this._handleClick.bind(this),this._boundChange=this._handleChange.bind(this),this._boundKeydown=this._handleKeydown.bind(this),this._boundFocusIn=this._handleFocusIn.bind(this),this._boundFocusOut=this._handleFocusOut.bind(this)}init(){this._restoreState(),this._containers=this._resolveContainers(),this._containers.forEach(e=>{e.addEventListener("click",this._boundClick),e.addEventListener("change",this._boundChange),e.addEventListener("keydown",this._boundKeydown),e.addEventListener("focusin",this._boundFocusIn),e.addEventListener("focusout",this._boundFocusOut)}),this.refresh()}dispose(){this._disposeDropdowns(),this._containers.forEach(e=>{e.removeEventListener("click",this._boundClick),e.removeEventListener("change",this._boundChange),e.removeEventListener("keydown",this._boundKeydown),e.removeEventListener("focusin",this._boundFocusIn),e.removeEventListener("focusout",this._boundFocusOut),e.hasAttribute($a)&&e.remove()}),this._rows().forEach(e=>{e.hidden="true"===e.getAttribute("data-vg-table-expand-hidden")||e.hasAttribute("data-vg-table-filter-hidden"),e.removeAttribute("data-vg-table-page-row")}),this._containers=[]}setPage(e,t=!1,i="api"){const s=this._clampPage(e);return s!==this._page&&(this._page=s,this._storeState(),this._render(),this._scroll(),t&&this._emit(Na,i),this._notify(i),!0)}setPerPage(e,t=!1,i="api"){const s=this._clampPerPage(e);return(s!==this._perPage||1!==this._page)&&(this._perPage=s,this._page=1,this._storeState(),this._render(),this._scroll(),t&&(this._emit("perpagechange.vg.table",i),this._emit(Na,i)),this._notify(i),!0)}setMeta(e={}){return this._remote?(this._totalRowsValue=this._nonNegativeInt(e.total,this._totalRowsValue),this._totalPagesValue=this._positiveInt(e.pages??e.totalPages,Math.max(1,Math.ceil(this._totalRowsValue/this._perPage))),this._perPage=this._clampPerPage(e.per_page??e.perPage??this._perPage),this._page=Math.min(this._positiveInt(e.page,this._page),this._totalPagesValue),this._storeState(),this._render(),this.getState()):this.getState()}getState(){return{page:this._page,perPage:this._perPage,totalPages:this._totalPages(),totalRows:this._remote?this._totalRowsValue:this._rows().length}}refresh(e=!1){return e&&(this._page=1),this._page=this._clampPage(this._page),this._render(),this.getState()}_render(){if(!this._remote){const e=this._rows(),t=(this._page-1)*this._perPage,i=t+this._perPage;e.forEach((e,s)=>{const r=s>=t&&s<i,n="true"===e.getAttribute("data-vg-table-expand-hidden");e.hidden=!r||n,e.setAttribute("data-vg-table-page-row",r?"visible":"hidden")})}const e=this._buildMarkup();this._disposeDropdowns(),this._containers.forEach(t=>{t.className=`vg-table-pagination vg-table-pagination--${this._positionFor(t)}`,t.innerHTML=e,this._initDropdowns(t)})}_buildMarkup(){const e=this._align(),t=this._options.size||{},i=this._options.quick||{},s=this._options.labels||{},r=this._buildPages(),n=!1===t.enabled?"":this._buildSizeMarkup(t),a=this._isQuickJumpEnabled()?`\n\t\t\t<label class="vg-table-pagination__quick">\n\t\t\t\t<span class="vg-table-pagination__sr-only">${i.label||"Перейти к странице"}</span>\n\t\t\t\t<input type="number" min="1" max="${this._totalPages()}" value="${this._page}" data-pagination-quick-input>\n\t\t\t\t<button type="button" class="vg-table-page vg-table-page--quick" data-pagination-quick-button>${i.button||"Перейти"}</button>\n\t\t\t</label>`:"";return`\n\t\t\t<div class="vg-table-pagination__inner vg-table-pagination__inner--${e}">\n\t\t\t\t${n}\n\t\t\t\t<nav class="vg-table-pagination__pages" aria-label="${s.aria||"Пагинация"}">\n\t\t\t\t\t<button type="button" class="vg-table-page vg-table-page--prev" data-pagination-page="prev" aria-label="${s.prev||"Назад"}" ${this._page<=1?"disabled":""}>${this._buildChevron("prev")}</button>\n\t\t\t\t\t${r.map(e=>this._buildPageButton(e)).join("")}\n\t\t\t\t\t<button type="button" class="vg-table-page vg-table-page--next" data-pagination-page="next" aria-label="${s.next||"Вперёд"}" ${this._page>=this._totalPages()?"disabled":""}>${this._buildChevron("next")}</button>\n\t\t\t\t</nav>\n\t\t\t\t${a}\n\t\t\t</div>`}_buildSizeMarkup(e){const t=this._sizeOptions();return`\n\t\t\t<label class="vg-table-pagination__size">\n\t\t\t\t${!1===e.label?"":`<span class="vg-table-pagination__size-heading">${e.label||"Строк на странице"}</span>`}\n\t\t\t\t<div class="vg-table-pagination__size-control vg-dropdown">\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\tmin="1"\n\t\t\t\t\t\tmax="${this._positiveInt(this._options.max,100)}"\n\t\t\t\t\t\tstep="1"\n\t\t\t\t\t\tinputmode="numeric"\n\t\t\t\t\t\tdata-pagination-per-page\n\t\t\t\t\t\tdata-vg-toggle="dropdown"\n\t\t\t\t\t\tvalue="${this._formatPerPage(this._perPage)}"\n\t\t\t\t\t\taria-label="${e.aria||e.label||"Строк на странице"}"\n\t\t\t\t\t\taria-haspopup="true"\n\t\t\t\t\t>\n\t\t\t\t\t<span class="vg-table-pagination__size-chevron" aria-hidden="true">\n\t\t\t\t\t\t<svg viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="M5 7.5L10 12.5L15 7.5" /></svg>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class="vg-dropdown-content vg-table-pagination__size-dropdown">\n\t\t\t\t\t\t<div class="vg-dropdown-container">\n\t\t\t\t\t\t\t${t.map(e=>`<button type="button" class="vg-table-pagination__size-option" data-pagination-per-page-option="${e}">${this._formatPerPage(e)}</button>`).join("")}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</label>`}_buildPageButton(e){if("object"==typeof e){const t=!1!==this._options.ellipsisHover,i=this._options.labels||{},s="prev"===e.direction?i.ellipsisPrev||"Перейти к предыдущим страницам":i.ellipsisNext||"Перейти к следующим страницам";return`<button type="button" class="vg-table-page vg-table-page--ellipsis${t?" vg-table-page--ellipsis-hover":""}" data-pagination-page="ellipsis-${e.direction}" aria-label="${s}"><span class="vg-table-page__ellipsis-dots" aria-hidden="true">…</span>${t?this._buildEllipsisChevron(e.direction):""}</button>`}const t=e===this._page;return`<button type="button" class="vg-table-page${t?" is-active":""}" data-pagination-page="${e}" ${t?'aria-current="page"':""}>${e}</button>`}_buildChevron(e){return`<svg class="vg-table-page__chevron" viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="${"prev"===e?"M12.5 4.5L7 10l5.5 5.5":"M7.5 4.5L13 10l-5.5 5.5"}" /></svg>`}_buildEllipsisChevron(e){return`<svg class="vg-table-page__ellipsis-chevron vg-table-page__ellipsis-chevron--${e}" viewBox="0 0 20 20" focusable="false" aria-hidden="true">${"prev"===e?'<path d="M10.5 5L5.5 10l5 5" /><path d="M15 5l-5 5 5 5" />':'<path d="M9.5 5l5 5-5 5" /><path d="M5 5l5 5-5 5" />'}</svg>`}_buildPages(){const e=this._totalPages(),t=Math.max(1,this._positiveInt(this._options.visible,5)),i=Math.max(1,this._positiveInt(this._options.threshold,5));if(!1===this._options.ellipsis||e<=i||e<=t+2)return this._range(1,e);let s=Math.max(2,this._page-Math.floor(t/2)),r=Math.min(e-1,s+t-1);s=Math.max(2,r-t+1);const n=[1];s>2&&n.push({direction:"prev"});for(let e=s;e<=r;e+=1)n.push(e);return r<e-1&&n.push({direction:"next"}),n.push(e),n}_handleClick(e){const t=e.target.closest("[data-pagination-per-page-option]");if(t){e.preventDefault();const i=t.getAttribute("data-pagination-per-page-option");return this.setPerPage(i,!0,"per-page"),void this._hideDropdown(t)}const i=e.target.closest("[data-pagination-quick-button]");if(i){const e=i.closest(".vg-table-pagination__quick")?.querySelector("[data-pagination-quick-input]");return void this.setPage(e?.value,!0,"quick")}const s=e.target.closest("[data-pagination-page]");if(!s||s.disabled)return;const r=s.getAttribute("data-pagination-page");"prev"!==r?"next"!==r?"ellipsis-prev"!==r?"ellipsis-next"!==r?this.setPage(r,!0,"page"):this.setPage(this._ellipsisTarget("next"),!0,"ellipsis"):this.setPage(this._ellipsisTarget("prev"),!0,"ellipsis"):this.setPage(this._page+1,!0,"next"):this.setPage(this._page-1,!0,"prev")}_handleChange(e){const t=e.target.closest("[data-pagination-per-page]");t&&this._applyPerPageInput(t)}_handleKeydown(e){const t=e.target.closest("[data-pagination-per-page]");if(t&&"Escape"===e.key)return this._hideDropdown(t),void t.blur();if(t&&"Enter"===e.key)return e.preventDefault(),void this._applyPerPageInput(t);if("Enter"!==e.key)return;const i=e.target.closest("[data-pagination-quick-input]");i&&(e.preventDefault(),this.setPage(i.value,!0,"quick"))}_handleFocusIn(e){const t=e.target.closest("[data-pagination-per-page]");t&&(t.value=String(this._perPage))}_handleFocusOut(e){const t=e.target.closest("[data-pagination-per-page]");if(!t)return;const i=e.relatedTarget instanceof Element?e.relatedTarget:null,s=t.closest(".vg-table-pagination__size-control");s&&i&&s.contains(i)||this._applyPerPageInput(t)}_applyPerPageInput(e){this.setPerPage(e.value,!0,"per-page"),e.value=this._formatPerPage(this._perPage)}_emit(e,t){g.A.trigger(this._table,e,Object.assign(this.getState(),{source:t}))}_notify(e){"function"==typeof this._options.onChange&&this._options.onChange(Object.assign(this.getState(),{source:e}))}_resolveContainers(){if(!this._host)return[];const e=this._position(),t=Array.from(this._host.querySelectorAll("[data-vg-table-pagination]"));if(t.length)return"both"===e?t:[t.find(t=>t.getAttribute("data-position")===e)||t[0]];const i="both"===e?["top","bottom"]:[e],s=this._table.closest(".vg-table-container")||this._table;return i.map(e=>{const t=document.createElement("div");return t.setAttribute($a,""),t.setAttribute("data-position",e),"top"===e?this._host.insertBefore(t,s):this._host.insertBefore(t,s.nextSibling),t})}_rows(){return Array.from(this._table.tBodies||[]).flatMap(e=>Array.from(e.rows||[])).filter(e=>!e.hasAttribute("data-vg-table-filter-hidden")&&!e.hasAttribute("data-vg-table-state-row"))}_totalPages(){return this._remote?Math.max(1,this._totalPagesValue):Math.max(1,Math.ceil(this._rows().length/this._perPage))}_clampPage(e){return Math.min(this._positiveInt(e,1),this._totalPages())}_clampPerPage(e){const t=this._positiveInt(this._options.max,100);return Math.min(this._positiveInt(e,10),t)}_sizeOptions(){const e=this._options.size||{},t=(Array.isArray(e.options)?e.options:[10,25,50,100]).map(e=>this._clampPerPage(e)).filter(e=>e>0);return t.push(this._perPage),Array.from(new Set(t)).sort((e,t)=>e-t)}_formatPerPage(e){const t=String((this._options.size||{}).suffix||"на страницу").trim();return t?`${this._positiveInt(e,this._perPage)} / ${t}`:String(this._positiveInt(e,this._perPage))}_initDropdowns(e){e.querySelectorAll('[data-pagination-per-page][data-vg-toggle="dropdown"]').forEach(e=>{const t=Pe.init(e,{placement:"auto",hover:!1,animation:{fade:!0,enable:!1,delay:120}});this._dropdowns.push({toggle:e,instance:t})})}_disposeDropdowns(){this._dropdowns.forEach(({instance:e})=>e?.dispose?.()),this._dropdowns=[]}_dropdownFor(e){const t=e.closest(".vg-table-pagination__size-control"),i=t?.querySelector("[data-pagination-per-page]");return this._dropdowns.find(e=>e.toggle===i)?.instance||null}_hideDropdown(e){this._dropdownFor(e)?.hide?.()}_position(){const e=String(this._options.position||"bottom").toLowerCase();return["top","bottom","both"].includes(e)?e:"bottom"}_positionFor(e){return e.getAttribute("data-position")||this._position().replace("both","bottom")}_align(){const e=String(this._options.align||"right").toLowerCase();return["left","center","right","between"].includes(e)?e:"right"}_isQuickJumpEnabled(){const e=(this._options.quick||{}).enabled;return"auto"===e?this._totalPages()>this._positiveInt(this._options.threshold,5):!0===e}_ellipsisTarget(e){const t=this._buildPages().filter(Number.isInteger);return"prev"===e?Math.max(1,(t[1]||2)-1):Math.min(this._totalPages(),(t[t.length-2]||this._totalPages()-1)+1)}_scroll(){const e=this._options.scroll;e&&!1!==e&&"undefined"!=typeof window&&("window"!==e?this._host?.scrollIntoView?.({block:"start",behavior:"smooth"}):window.scrollTo?.({top:0,behavior:"smooth"}))}_storageKey(){const e=String((this._options.storage||{}).key||"").trim();if(e)return e;if(this._table.id)return`vg:table:pagination:${this._table.id}`;const t="undefined"!=typeof window?window.location.pathname:"",i=Array.from(document.querySelectorAll("[data-vg-table]"));return`vg:table:pagination:${t}:${Math.max(0,i.indexOf(this._table))}`}_restoreState(){if("undefined"==typeof window||!window.localStorage)return;const e=this._options.persist||{};if(!0===e.page||!0===e.per)try{const t=JSON.parse(window.localStorage.getItem(this._storageKey())||"{}"),i=this._positiveInt(t.page,0),s=this._positiveInt(t.perPage,0);!0===e.page&&i>0&&(this._page=i),!0===e.per&&s>0&&(this._perPage=this._clampPerPage(s))}catch(e){}}_storeState(){if("undefined"==typeof window||!window.localStorage)return;const e=this._options.persist||{};if(!0!==e.page&&!0!==e.per)return;const t={};!0===e.page&&(t.page=this._page),!0===e.per&&(t.perPage=this._perPage);try{window.localStorage.setItem(this._storageKey(),JSON.stringify(t))}catch(e){}}_positiveInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>0?i:t}_nonNegativeInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>=0?i:t}_range(e,t){const i=[];for(let s=e;s<=t;s+=1)i.push(s);return i}},Fa="data-vg-table-expandable-generated",Ra="data-vg-table-expand-hidden",Ba="data-expand-depth",ja="data-vg-table-page-row",Ua=class{constructor(e,t={}){this._table=e,this._options=t,this._collapsed=new Set,this._seeded=new Set,this._rowById=new Map,this._childrenByParent=new Map,this._boundClick=this._handleClick.bind(this)}init(){return this._table.classList.add("vg-table-expandable"),this._table.addEventListener("click",this._boundClick),this.refresh()}dispose(){this._table.removeEventListener("click",this._boundClick),this._table.classList.remove("vg-table-expandable"),this._rows().forEach(e=>{e.removeAttribute(Ba),e.removeAttribute(Ra),e.style.removeProperty("--vg-table-expandable-depth"),e.hidden="hidden"===e.getAttribute(ja)||e.hasAttribute("data-vg-table-filter-hidden"),e.querySelectorAll(`[${Fa}]`).forEach(e=>e.remove());const t=this._findToggle(e);t&&(t.classList.remove("vg-table-expandable__toggle"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-label"),t.hidden=!1)}),this._collapsed.clear(),this._seeded.clear(),this._rowById.clear(),this._childrenByParent.clear()}refresh(){const e=this._rows(),t=this._idAttr(),i=this._parentAttr();this._rowById=new Map,this._childrenByParent=new Map;const s=new Map;e.forEach((e,r)=>{const n=`row-${r+1}`,a=String(e.getAttribute(t)||n).trim()||n;e.setAttribute(t,a),this._rowById.set(a,e);const o=String(e.getAttribute(i)||"").trim();s.set(a,o),o&&(this._childrenByParent.has(o)||this._childrenByParent.set(o,[]),this._childrenByParent.get(o).push(a))});const r=new Map;return this._rowById.forEach((e,t)=>{const i=this._depth(t,s,r,new Set),n=(this._childrenByParent.get(t)||[]).length>0;e.setAttribute(Ba,String(i)),e.style.setProperty("--vg-table-expandable-depth",String(i)),n&&!this._seeded.has(t)&&(this._initiallyCollapsed(e)&&this._collapsed.add(t),this._seeded.add(t)),this._syncToggle(e,t,n)}),this._rowById.forEach((e,t)=>{const i=this._hasCollapsedAncestor(t,s);i?e.setAttribute(Ra,"true"):e.removeAttribute(Ra),e.hidden=i||"hidden"===e.getAttribute(ja)||e.hasAttribute("data-vg-table-filter-hidden")}),this.getState()}toggle(e,t=null,i=!0){const s=this._resolveRow(e);if(!s)return!1;const r=String(s.getAttribute(this._idAttr())||"").trim();if(!r||!(this._childrenByParent.get(r)||[]).length)return!1;const n=null===t?this._collapsed.has(r):!0===t;return n?this._collapsed.delete(r):this._collapsed.add(r),this.refresh(),i&&this._emit(s,r,n),!0}expand(e,t=!0){return this.toggle(e,!0,t)}collapse(e,t=!0){return this.toggle(e,!1,t)}getState(){const e=Array.from(this._childrenByParent.keys()).filter(e=>this._rowById.has(e));return{expanded:e.filter(e=>!this._collapsed.has(e)),collapsed:e.filter(e=>this._collapsed.has(e))}}_handleClick(e){const t=e.target instanceof Element?e.target:e.target?.parentElement;let i=null;try{i=t?.closest(this._combinedToggleSelector())}catch(e){i=t?.closest("[data-expand-toggle]")}if(!i||!this._table.contains(i))return;e.preventDefault();const s=i.closest("tr");s&&this.toggle(s,null,!0)}_syncToggle(e,t,i){let s=this._findToggle(e);if(!s&&i){const i=e.cells?.[0];i&&(s=document.createElement("button"),s.type="button",s.setAttribute("data-expand-toggle",t),s.setAttribute(Fa,""),i.prepend(s))}if(!s)return;if(s.classList.add("vg-table-expandable__toggle"),s.hidden=!i,!i)return;const r=!this._collapsed.has(t),n=this._options.labels||{};s.setAttribute("data-expand-toggle",t),s.setAttribute("aria-expanded",String(r)),s.setAttribute("aria-label",r?n.collapse||"Свернуть дочерние строки":n.expand||"Развернуть дочерние строки")}_findToggle(e){try{return e.querySelector(this._combinedToggleSelector())}catch(t){return e.querySelector("[data-expand-toggle]")}}_combinedToggleSelector(){const e=String(this._options.toggleSelector||"[data-expand-toggle]").trim();return"[data-expand-toggle]"===e?e:`${e}, [data-expand-toggle]`}_depth(e,t,i,s){if(i.has(e))return i.get(e);if(s.has(e))return 0;s.add(e);const r=String(t.get(e)||"").trim(),n=r&&r!==e&&this._rowById.has(r)?this._depth(r,t,i,s)+1:0;return s.delete(e),i.set(e,n),n}_hasCollapsedAncestor(e,t){const i=new Set([e]);let s=String(t.get(e)||"").trim();for(;s&&!i.has(s);){if(this._collapsed.has(s))return!0;i.add(s),s=String(t.get(s)||"").trim()}return!1}_initiallyCollapsed(e){const t=e.getAttribute("data-expand-collapsed");return null===t?!0===this._options.collapsed:this._boolean(t)}_resolveRow(e){if(e instanceof Element){const t=e.matches("tbody tr")?e:e.closest("tbody tr");return t&&this._table.contains(t)?t:null}return this._rowById.get(String(e))||null}_rows(){return Array.from(this._table.tBodies||[]).flatMap(e=>Array.from(e.rows||[]))}_idAttr(){return String(this._options.idAttr||"data-expand-id").trim()||"data-expand-id"}_parentAttr(){return String(this._options.parentAttr||"data-expand-parent-id").trim()||"data-expand-parent-id"}_boolean(e){return!["false","0","off","no"].includes(String(e).toLowerCase())}_emit(e,t,i){const s={id:t,row:e,expanded:i,collapsed:!i};g.A.trigger(this._table,"rowtoggle.vg.table",s),g.A.trigger(this._table,i?"rowexpand.vg.table":"rowcollapse.vg.table",s)}},qa=["vg-table-wrapper--sticky-container","vg-table-wrapper--sticky-page"],Va=["vg-table-container--sticky-container","vg-table-container--sticky-page"],Wa=["--vg-table-sticky-top","--vg-table-sticky-max-height"],Ka="data-vg-table-sticky-generated",Ga=class{constructor(e,t,i,s={}){this._element=e,this._wrapper=t,this._container=i,this._params=s,this._head=e.tHead,this._header=null,this._headerTable=null,this._body=null,this._previousClasses=new Map,this._previousContainerClasses=new Map,this._previousStyles=new Map,this._columnWeights=new Map,this._hardColumnWidths=new Map,this._hasSourceColgroup=!1,this._resizeObserver=null,this._resizeFrame=null,this._boundScroll=this._syncScroll.bind(this),this._boundResize=this._scheduleRefresh.bind(this),this._boundPageScroll=this._syncStickyState.bind(this)}init(){if(!this._wrapper||!this._container||!this._head)return this;const e=this._measureColumns();return this._rememberColumnGeometry(e),qa.forEach(e=>this._previousClasses.set(e,this._wrapper.classList.contains(e))),Va.forEach(e=>this._previousContainerClasses.set(e,this._container.classList.contains(e))),Wa.forEach(e=>this._previousStyles.set(e,this._container.style.getPropertyValue(e))),this._wrapper.classList.add(`vg-table-wrapper--sticky-${this._params.mode}`),this._container.classList.add(`vg-table-container--sticky-${this._params.mode}`),null!==this._params.top&&""!==String(this._params.top).trim()&&this._container.style.setProperty("--vg-table-sticky-top",this._toCssLength(this._params.top,"0px")),this._container.style.setProperty("--vg-table-sticky-max-height",this._toCssLength(this._params.maxHeight,"24rem")),this._element.setAttribute("data-vg-table-sticky-header",this._params.mode),this._buildLayers(e),this._body.addEventListener("scroll",this._boundScroll,{passive:!0}),"undefined"!=typeof ResizeObserver?(this._resizeObserver=new ResizeObserver(this._boundResize),this._resizeObserver.observe(this._container),this._resizeObserver.observe(this._body)):"undefined"!=typeof window&&window.addEventListener("resize",this._boundResize),"page"===this._params.mode&&"undefined"!=typeof window&&window.addEventListener("scroll",this._boundPageScroll,{passive:!0}),this.refresh(),this}getHeaderTable(){return this._headerTable||this._element}getBody(){return this._body}syncScroll(){return this._syncScroll(),this}refresh(){if(!this._header||!this._headerTable||!this._body)return this;const e=this._resolveLayoutWidths();this._applyColgroup(this._headerTable,e),this._applyColgroup(this._element,e);const t=Math.max(0,this._body.offsetWidth-this._body.clientWidth);return this._header.style.paddingInlineEnd=`${t}px`,this._header.style.setProperty("--vg-table-sticky-scrollbar-width",`${t}px`),this._header.classList.toggle("vg-table-header--scrollbar",t>0),this._container.classList.toggle("vg-table-container--scrollbar",t>0),this._syncScroll(),this._syncStickyState(),this}dispose(){this._body&&this._body.removeEventListener("scroll",this._boundScroll),this._resizeObserver?.disconnect(),null!==this._resizeFrame&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(this._resizeFrame),this._resizeFrame=null),"undefined"!=typeof window&&(this._resizeObserver||window.removeEventListener("resize",this._boundResize),window.removeEventListener("scroll",this._boundPageScroll)),this._header?.classList.remove("is-stuck"),this._head&&this._headerTable?.contains(this._head)&&this._element.prepend(this._head),this._header?.remove(),this._container?.classList.remove("vg-table-container--scrollbar"),this._body?.contains(this._element)&&this._body.before(this._element),this._body?.remove(),this._element.querySelector(":scope > colgroup[data-vg-table-sticky-colgroup]")?.remove(),qa.forEach(e=>{this._wrapper.classList.toggle(e,!0===this._previousClasses.get(e))}),Va.forEach(e=>{this._container.classList.toggle(e,!0===this._previousContainerClasses.get(e))}),Wa.forEach(e=>{const t=this._previousStyles.get(e);t?this._container.style.setProperty(e,t):this._container.style.removeProperty(e)}),this._element.removeAttribute("data-vg-table-sticky-header")}_scheduleRefresh(){null===this._resizeFrame&&("function"==typeof requestAnimationFrame?this._resizeFrame=requestAnimationFrame(()=>{this._resizeFrame=null,this.refresh()}):this.refresh())}_buildLayers(e){this._header=this._element.ownerDocument.createElement("div"),this._header.className="vg-table-header",this._header.setAttribute(Ka,""),this._headerTable=this._element.ownerDocument.createElement("table"),this._headerTable.className=`${this._element.className} vg-table-header__table`,this._headerTable.style.cssText=this._element.style.cssText,this._headerTable.removeAttribute("data-vg-table");const t=this._element.querySelector(":scope > colgroup:not([data-vg-table-sticky-colgroup])");t?this._headerTable.append(t.cloneNode(!0)):this._applyColgroup(this._headerTable,e),this._headerTable.append(this._head),this._header.append(this._headerTable),this._body=this._element.ownerDocument.createElement("div"),this._body.className="vg-table-body",this._body.setAttribute(Ka,""),this._applyColgroup(this._element,e),this._element.before(this._header,this._body),this._body.append(this._element)}_measureColumns(){return this._measureBodyColumns()}_measureBodyColumns(){const e=this._head?.rows[this._head.rows.length-1],t=this._measureRow(e),i=Array.from(this._element.tBodies||[]).flatMap(e=>Array.from(e.rows||[]));for(const e of i){if(e.hidden||e.hasAttribute("data-vg-table-state-row")||e.hasAttribute("data-vg-table-skeleton")||e.hasAttribute("data-vg-table-skeleton-row"))continue;if(e.querySelector("[data-vg-table-state]"))continue;const i=this._measureRow(e);if(i.length===t.length&&i.some(e=>e>0))return i}return t}_measureRow(e){return e?Array.from(e.cells).flatMap(e=>{const t=Math.max(1,e.colSpan||1),i=e.getBoundingClientRect().width/t;return Array.from({length:t},()=>i)}):[]}_applyColgroup(e,t){if(!t.length)return;if(e.querySelector(":scope > colgroup:not([data-vg-table-sticky-colgroup])"))return;let i=e.querySelector(":scope > colgroup[data-vg-table-sticky-colgroup]");for(i||(i=e.ownerDocument.createElement("colgroup"),i.setAttribute("data-vg-table-sticky-colgroup",""),e.prepend(i));i.children.length<t.length;)i.append(e.ownerDocument.createElement("col"));for(;i.children.length>t.length;)i.lastElementChild.remove();const s=this._getHeaders();t.forEach((e,t)=>{const r=i.children[t];e>0?r.style.width=`${e}px`:r.style.removeProperty("width");const n=!0===s[t]?.hidden;r.hidden=n,r.toggleAttribute("data-vg-table-column-hidden",n)})}_rememberColumnGeometry(e){const t=this._getHeaders(),i=Array.from(this._element.querySelector(":scope > colgroup:not([data-vg-table-sticky-colgroup])")?.children||[]);this._hasSourceColgroup=i.length>0,t.forEach((t,s)=>{const r=this._columnKey(t,s);this._columnWeights.set(r,e[s]>0?e[s]:1),(this._hasDeclaredWidth(t)||this._hasDeclaredWidth(i[s]))&&this._hardColumnWidths.set(r,e[s]>0?e[s]:0)})}_resolveLayoutWidths(){const e=this._getHeaders(),t=this._measureBodyColumns();if(this._hasSourceColgroup||!e.length)return t;const i=Array.from(this._element.tBodies||[]).flatMap(e=>Array.from(e.rows||[])).find(e=>!e.hidden&&!e.hasAttribute("data-vg-table-state-row")),s=new Map,r=[];e.forEach((e,n)=>{const a=this._columnKey(e,n),o=i?.cells[n];if(this._hasDeclaredWidth(e)||this._hasDeclaredWidth(o)||this._hardColumnWidths.has(a)){const i=this._readDeclaredPixelWidth(e)||this._readDeclaredPixelWidth(o)||this._hardColumnWidths.get(a)||t[n]||0;this._hardColumnWidths.set(a,i),s.set(n,i)}else r.push(n)});const n=t.reduce((e,t)=>e+t,0),a=this._body?.clientWidth||this._container?.clientWidth||n,o=this._readTableMinimumWidth(),l=Math.max(a,o,0),h=Array.from(s.values()).reduce((e,t)=>e+t,0),d=Math.max(0,l-h),c=Array(e.length).fill(0);if(s.forEach((e,t)=>{c[t]=e}),!r.length)return c;const _=r.map(i=>{const s=this._columnKey(e[i],i);return this._columnWeights.get(s)||t[i]||1}),u=_.reduce((e,t)=>e+t,0)||r.length;let m=0;return r.forEach((e,t)=>{const i=t===r.length-1?Math.max(0,d-m):d*_[t]/u;c[e]=i,m+=i}),c}_getHeaders(){const e=Array.from(this._head?.rows||[]);return e.length?Array.from(e.at(-1).cells||[]):[]}_columnKey(e,t){return String(e?.getAttribute("data-field")||t).trim()}_hasDeclaredWidth(e){return!!e&&(e.hasAttribute("width")||e.hasAttribute("data-column-width")||Boolean(e.style?.width||e.style?.minWidth||e.style?.maxWidth))}_readDeclaredPixelWidth(e){if(!e||!this._hasDeclaredWidth(e))return 0;const t=e.style?.minWidth&&e.style.minWidth===e.style.maxWidth?Number.parseFloat(e.style.width||e.style.minWidth):0;if(Number.isFinite(t)&&t>0)return t;const i=e.getBoundingClientRect?.().width||e.offsetWidth||0;return i>0?i:0}_readTableMinimumWidth(){if("function"!=typeof getComputedStyle)return 0;const e=Number.parseFloat(getComputedStyle(this._element).minWidth||"0");return Number.isFinite(e)?e:0}_syncScroll(){this._header&&this._body&&(this._header.scrollLeft=this._body.scrollLeft)}_syncStickyState(){if(!this._header||"page"!==this._params.mode)return;const e=this._header.getBoundingClientRect(),t=this._container.getBoundingClientRect(),i=Number.parseFloat(window.getComputedStyle(this._header).top)||0,s=Math.abs(e.top-i)<=1,r=t.top<i&&t.bottom>i+e.height;this._header.classList.toggle("is-stuck",s&&r)}_toCssLength(e,t){if("number"==typeof e&&Number.isFinite(e))return`${Math.max(0,e)}px`;const i=String(e??"").trim();return i?/^\d+(?:\.\d+)?$/.test(i)?`${i}px`:i:t}},Ya="data-vg-table-fixed-side",Xa="data-vg-table-fixed-edge",Za="--vg-table-fixed-offset",Ja=["vg-table-wrapper--fixed-columns","vg-table-wrapper--fixed-columns-stack","is-vg-table-fixed-scrolled-start","is-vg-table-fixed-scrolled-end"],Qa=class{constructor(e,t,i={},s=null){this._element=e,this._wrapper=t,this._params=i,this._stickyHeader=s,this._headerTable=s?.getHeaderTable?.()||e,this._scrollHost=s?.getBody?.()||e.closest(".vg-table-container")||t,this._columns={left:[],right:[]},this._widths=[],this._previousClasses=new Map,this._activeEdges={left:null,right:null},this._resizeObserver=null,this._boundScroll=this._syncScrollState.bind(this),this._boundResize=this.refresh.bind(this)}init(){return this._wrapper&&this._scrollHost&&this._headerTable?.tHead?(Ja.forEach(e=>{this._previousClasses.set(e,this._wrapper.classList.contains(e))}),this._wrapper.classList.add("vg-table-wrapper--fixed-columns"),this._wrapper.classList.toggle("vg-table-wrapper--fixed-columns-stack","stack"===this._params.mode),this._element.setAttribute("data-vg-table-fixed-columns",this._params.mode),this._scrollHost.addEventListener("scroll",this._boundScroll,{passive:!0}),"undefined"!=typeof ResizeObserver?(this._resizeObserver=new ResizeObserver(this._boundResize),this._resizeObserver.observe(this._scrollHost),this._resizeObserver.observe(this._element)):"undefined"!=typeof window&&window.addEventListener("resize",this._boundResize),this.refresh(),this):this}refresh(){this._headerTable=this._stickyHeader?.getHeaderTable?.()||this._element,this._scrollHost=this._stickyHeader?.getBody?.()||this._element.closest(".vg-table-container")||this._wrapper;const e=this._getHeaders();return e.length?(this._clearCells(),this._columns=this._resolveColumns(e),this._widths=e.map((e,t)=>this._measureColumn(e,t)),this._applySide("left",this._columns.left,e),this._applySide("right",[...this._columns.right].reverse(),e),this._syncScrollState(!0),this):this}getState(){return{mode:this._params.mode,left:[...this._columns.left],right:[...this._columns.right]}}syncScroll(){return this._syncScrollState(),this}dispose(){this._scrollHost?.removeEventListener("scroll",this._boundScroll),this._resizeObserver?.disconnect(),this._resizeObserver||"undefined"==typeof window||window.removeEventListener("resize",this._boundResize),this._clearCells(),Ja.forEach(e=>{this._wrapper.classList.toggle(e,!0===this._previousClasses.get(e))}),this._element.removeAttribute("data-vg-table-fixed-columns")}_getHeaders(){const e=Array.from(this._headerTable.tHead?.rows||[]);return e.length?Array.from(e[e.length-1].cells):[]}_resolveColumns(e){const t={left:[],right:[]},i=(i,s)=>{const r=this._resolveIndex(s,e);r>=0&&!t[i].includes(r)&&t[i].push(r)},s=this._params.columns;return s&&"object"==typeof s&&!Array.isArray(s)?["left","right"].forEach(e=>{(Array.isArray(s[e])?s[e]:String(s[e]||"").split(",")).forEach(t=>i(e,t))}):String(s||"").split(";").forEach(e=>{const[t,s=""]=e.split(":"),r=String(t||"").trim().toLowerCase();["left","right"].includes(r)&&s.split(",").forEach(e=>i(r,e))}),e.forEach((e,t)=>{const s=String(e.getAttribute("data-fixed")||e.getAttribute("data-fixed-column")||"").toLowerCase();["left","right"].includes(s)&&i(s,t)}),t.left.sort((e,t)=>e-t),t.right.sort((e,t)=>e-t),t}_resolveIndex(e,t){const i=String(e??"").trim();if(!i)return-1;if(/^\d+$/.test(i)){const e=Number.parseInt(i,10);return e>=0&&e<t.length?e:-1}return t.findIndex(e=>String(e.dataset.field||"").trim()===i)}_measureColumn(e,t){const i=Array.from(this._element.tBodies[0]?.rows||[]).find(e=>!e.hasAttribute("data-vg-table-state-row")),s=i?.cells[t],r=this._element.querySelector(`:scope > colgroup > col:nth-child(${t+1})`),n=s?.getBoundingClientRect?.().width||e.getBoundingClientRect?.().width||s?.offsetWidth||e.offsetWidth;if(n>0)return n;const a=Number.parseFloat(r?.style.width||r?.getAttribute("width")||"0");return Number.isFinite(a)?a:0}_applySide(e,t,i){let s=0;t.forEach(t=>{this._cellsAt(t,i).forEach(t=>{t.setAttribute(Ya,e),t.style.setProperty(Za,`${s}px`)}),s+=this._widths[t]||0,"stack"===this._params.mode&&(s+=this._params.stackGap)})}_cellsAt(e,t=this._getHeaders()){const i=[];return t[e]&&i.push(t[e]),Array.from(this._element.tBodies||[]).forEach(t=>{Array.from(t.rows||[]).forEach(t=>{t.hasAttribute("data-vg-table-state-row")||t.cells[e]&&i.push(t.cells[e])})}),Array.from(this._element.tFoot?.rows||[]).forEach(t=>{t.cells[e]&&i.push(t.cells[e])}),i}_syncScrollState(e=!1){if(!this._scrollHost)return;const t=Math.max(0,this._scrollHost.scrollWidth-this._scrollHost.clientWidth),i=Math.max(0,Math.min(t,this._scrollHost.scrollLeft));if(this._wrapper.classList.toggle("is-vg-table-fixed-scrolled-start",i>.5),this._wrapper.classList.toggle("is-vg-table-fixed-scrolled-end",i<t-.5),"stack"!==this._params.mode)return this._setEdge("left",this._columns.left.at(-1)??null,e),void this._setEdge("right",this._columns.right[0]??null,e);const s=this._columns.left.filter(e=>{const t=this._widths.slice(0,e).reduce((e,t)=>e+t,0),s=this._stackOffset("left",e);return i>=t-s-.5}),r=this._widths.reduce((e,t)=>e+t,0),n=t-i,a=this._columns.right.filter(e=>{const t=this._widths.slice(0,e+1).reduce((e,t)=>e+t,0);return n>=r-t-this._stackOffset("right",e)-.5});this._setEdge("left",s.at(-1)??null,e),this._setEdge("right",a[0]??null,e)}_stackOffset(e,t){const i="left"===e?this._columns.left:[...this._columns.right].reverse();let s=0;for(const e of i){if(e===t)return s;s+=(this._widths[e]||0)+this._params.stackGap}return s}_setEdge(e,t,i=!1){(i||this._activeEdges[e]!==t)&&(this._allManagedCells().forEach(t=>{t.getAttribute(Xa)===e&&t.removeAttribute(Xa)}),null!==t&&this._cellsAt(t).forEach(t=>t.setAttribute(Xa,e)),this._activeEdges[e]=t)}_allManagedCells(){return Array.from(this._wrapper.querySelectorAll(`[${Ya}], [${Xa}]`))}_clearCells(){this._allManagedCells().forEach(e=>{e.removeAttribute(Ya),e.removeAttribute(Xa),e.style.removeProperty(Za)}),this._activeEdges={left:null,right:null}}},eo="data-vg-table-column-resize-handle",to="[data-vg-table-column], [data-column-field]",io="columnresize.vg.table",so="columnreorder.vg.table",ro="columnvisibilitychange.vg.table",no=class{constructor(e,t,i={},s={}){this._table=e,this._wrapper=t,this._options=i,this._hooks=s,this._headerTable=e,this._controls=null,this._originalOrder=[],this._originalCellStyles=new Map,this._originalVisibility=new Map,this._widths=new Map,this._hidden=new Set,this._drag={active:!1,from:-1},this._resize={active:!1,index:-1,field:"",startX:0,startWidth:0},this._suppressClick=!1,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundKeydown=this._handleKeydown.bind(this),this._boundDragStart=this._handleDragStart.bind(this),this._boundDragOver=this._handleDragOver.bind(this),this._boundDrop=this._handleDrop.bind(this),this._boundDragEnd=this._handleDragEnd.bind(this),this._boundClickCapture=this._handleClickCapture.bind(this),this._boundControlChange=this._handleControlChange.bind(this),this._boundControlClick=this._handleControlClick.bind(this)}init(){return this._headerTable=this._hooks.getHeaderTable?.()||this._table,this._originalOrder=this.getOrder(),this._rememberOriginalState(),this._controls=this._resolveControls(),!0===this._options.reorder?.enabled&&this._restoreOrder(),!0===this._options.resize?.enabled&&this._restoreWidths(),!0===this._options.visibility?.enabled&&this._restoreVisibility(),this._decorateHeaders(),this._bind(),this.refresh(),this}refresh(){return this._headerTable=this._hooks.getHeaderTable?.()||this._table,this._decorateHeaders(),this._widths.forEach((e,t)=>this._applyWidth(t,e)),this._hidden.forEach(e=>this._applyVisibility(e,!1)),this._syncControls(),this.getState()}getState(){const e=this.getOrder();return{order:e,widths:Object.fromEntries(this._widths),visible:e.filter(e=>!this._hidden.has(e)),hidden:e.filter(e=>this._hidden.has(e))}}getOrder(){return this._getHeaders().map((e,t)=>this._field(e,t))}setWidth(e,t,i=!0){if(!0!==this._options.resize?.enabled)return!1;const s=this._resolveIndex(e),r=this._field(this._getHeaders()[s],s);if(s<0||!r||this._hidden.has(r))return!1;const n=this._clampWidth(t);return this._widths.set(r,n),this._applyWidth(r,n),this._storeWidths(),this._hooks.refreshLayout?.(!1),i&&g.A.trigger(this._table,io,{field:r,columnIndex:s,width:n,widths:Object.fromEntries(this._widths)}),!0}move(e,t,i=!0){if(!0!==this._options.reorder?.enabled)return!1;const s=this._resolveIndex(e),r=this._resolveIndex(t),n=this._getHeaders();if(s<0||r<0||s===r||this._isLocked(n[s],s)||this._isLocked(n[r],r))return!1;const a=this._field(n[s],s);return this._moveColumn(s,r),this._storeOrder(),this._decorateHeaders(),this._syncControls(),this._hooks.refreshLayout?.(!0),i&&g.A.trigger(this._table,so,{field:a,fromIndex:s,toIndex:r,order:this.getOrder()}),!0}setVisible(e,t=!0,i=!0){if(!0!==this._options.visibility?.enabled)return!1;const s=this._resolveIndex(e),r=this._getHeaders()[s],n=this._field(r,s);if(s<0||!n||this._isLocked(r,s))return!1;const a=!1!==t;return!(!a&&!this._hidden.has(n)&&this.getState().visible.length<=this._minVisible()||(a?this._hidden.delete(n):this._hidden.add(n),this._applyVisibility(n,a),this._storeVisibility(),this._syncControls(),this._hooks.refreshLayout?.(!0),i&&g.A.trigger(this._table,ro,Object.assign({field:n,visible:a},this.getState())),0))}reset(e=!0){if(this._restoreOriginalOrder(),this._restoreOriginalStyles(),this._widths.clear(),this._hidden.clear(),this._clearStorage(),this._decorateHeaders(),this._syncControls(),this._hooks.refreshLayout?.(!0),e){const e=Object.assign({reset:!0},this.getState());g.A.trigger(this._table,io,e),g.A.trigger(this._table,so,e),g.A.trigger(this._table,ro,e)}return this.getState()}dispose(){this._unbind(),this._restoreOriginalOrder(),this._restoreOriginalStyles(),this._getHeaders().forEach(e=>{e.removeAttribute("data-vg-table-column-reorder"),e.removeAttribute("data-vg-table-column-dragging"),e.removeAttribute("data-vg-table-column-drag-over"),e.removeAttribute("draggable"),e.querySelector(`[${eo}]`)?.remove()}),this._wrapper?.classList.remove("vg-table-wrapper--column-resizing","vg-table-wrapper--column-dragging")}_bind(){this._headerTable.addEventListener("pointerdown",this._boundPointerDown),this._headerTable.addEventListener("keydown",this._boundKeydown),this._headerTable.addEventListener("dragstart",this._boundDragStart),this._headerTable.addEventListener("dragover",this._boundDragOver),this._headerTable.addEventListener("drop",this._boundDrop),this._headerTable.addEventListener("dragend",this._boundDragEnd),this._headerTable.addEventListener("click",this._boundClickCapture,!0),document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),this._controls?.addEventListener("change",this._boundControlChange),this._controls?.addEventListener("click",this._boundControlClick)}_unbind(){this._headerTable?.removeEventListener("pointerdown",this._boundPointerDown),this._headerTable?.removeEventListener("keydown",this._boundKeydown),this._headerTable?.removeEventListener("dragstart",this._boundDragStart),this._headerTable?.removeEventListener("dragover",this._boundDragOver),this._headerTable?.removeEventListener("drop",this._boundDrop),this._headerTable?.removeEventListener("dragend",this._boundDragEnd),this._headerTable?.removeEventListener("click",this._boundClickCapture,!0),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),this._controls?.removeEventListener("change",this._boundControlChange),this._controls?.removeEventListener("click",this._boundControlClick)}_decorateHeaders(){this._getHeaders().forEach((e,t)=>{const i=this._field(e,t),s=this._isLocked(e,t);if(!0===this._options.resize?.enabled&&!e.querySelector(`[${eo}]`)){const t=e.ownerDocument.createElement("span");t.className="vg-table-column-resize-handle",t.setAttribute(eo,""),t.setAttribute("role","separator"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("aria-label",this._resizeLabel(e)),t.setAttribute("aria-valuemin",String(this._options.resize.minWidth)),t.setAttribute("aria-valuemax",String(this._options.resize.maxWidth)),t.setAttribute("aria-valuenow",String(Math.round(e.getBoundingClientRect().width||e.offsetWidth||this._options.resize.minWidth))),t.tabIndex=0,e.append(t)}const r=e.querySelector(`[${eo}]`);r&&r.setAttribute("aria-label",this._resizeLabel(e)),!0===this._options.reorder?.enabled&&(e.setAttribute("data-vg-table-column-reorder",s?"locked":"enabled"),e.setAttribute("draggable",String(!s))),i&&this._hidden.has(i)&&this._applyVisibility(i,!1)})}_handlePointerDown(e){const t=e.target.closest?.(`[${eo}]`);if(!t||!0!==this._options.resize?.enabled)return;const i=t.closest("th"),s=this._getHeaders().indexOf(i);s<0||(e.preventDefault(),e.stopPropagation(),this._resize={active:!0,index:s,field:this._field(i,s),startX:e.clientX,startWidth:i.getBoundingClientRect().width||i.offsetWidth||this._options.resize.minWidth},this._wrapper?.classList.add("vg-table-wrapper--column-resizing"))}_handleKeydown(e){const t=e.target.closest?.(`[${eo}]`);if(!t||!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;const i=t.closest("th"),s=this._getHeaders().indexOf(i);if(s<0)return;e.preventDefault(),e.stopPropagation();const r=this._field(i,s),n=this._widths.get(r)||i.getBoundingClientRect().width||i.offsetWidth||this._options.resize.minWidth,a=e.shiftKey?25:10,o="Home"===e.key?this._options.resize.minWidth:"End"===e.key?this._options.resize.maxWidth:n+("ArrowRight"===e.key?a:-a);this.setWidth(r,o,!0)}_handlePointerMove(e){if(!this._resize.active)return;e.preventDefault();const t=this._clampWidth(this._resize.startWidth+e.clientX-this._resize.startX);this._widths.set(this._resize.field,t),this._applyWidth(this._resize.field,t),this._hooks.refreshLayout?.(!1)}_handlePointerUp(){if(!this._resize.active)return;const{field:e}=this._resize,t=this._widths.get(e);this._resize={active:!1,index:-1,field:"",startX:0,startWidth:0},this._wrapper?.classList.remove("vg-table-wrapper--column-resizing"),t&&(this._storeWidths(),g.A.trigger(this._table,io,{field:e,columnIndex:this._resolveIndex(e),width:t,widths:Object.fromEntries(this._widths)}))}_handleDragStart(e){const t=e.target.closest?.('th[data-vg-table-column-reorder="enabled"]');if(!t||e.target.closest?.(`[${eo}]`))return;const i=this._getHeaders().indexOf(t);if(!(i<0)&&(this._drag={active:!0,from:i},t.setAttribute("data-vg-table-column-dragging",""),this._wrapper?.classList.add("vg-table-wrapper--column-dragging"),e.dataTransfer)){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",String(i))}catch(e){}}}_handleDragOver(e){if(!this._drag.active)return;const t=e.target.closest?.('th[data-vg-table-column-reorder="enabled"]');t&&(e.preventDefault(),this._getHeaders().forEach(e=>e.toggleAttribute("data-vg-table-column-drag-over",e===t)))}_handleDrop(e){if(!this._drag.active)return;const t=e.target.closest?.('th[data-vg-table-column-reorder="enabled"]');if(!t)return;e.preventDefault();const i=this._getHeaders().indexOf(t),s=this._drag.from;this._finishDrag(),this.move(s,i,!0)}_handleDragEnd(){this._drag.active&&this._finishDrag()}_finishDrag(){this._getHeaders().forEach(e=>{e.removeAttribute("data-vg-table-column-dragging"),e.removeAttribute("data-vg-table-column-drag-over")}),this._drag={active:!1,from:-1},this._suppressClick=!0,this._wrapper?.classList.remove("vg-table-wrapper--column-dragging"),setTimeout(()=>{this._suppressClick=!1},0)}_handleClickCapture(e){(this._suppressClick||e.target.closest?.(`[${eo}]`))&&(e.preventDefault(),e.stopPropagation(),this._suppressClick=!1)}_handleControlChange(e){const t=e.target.closest?.(to);if(!t||!this._controls.contains(t))return;const i=t.getAttribute("data-vg-table-column")||t.getAttribute("data-column-field");this.setVisible(i,!1!==t.checked)||this._syncControls()}_handleControlClick(e){e.target.closest?.("[data-vg-table-columns-reset]")&&(e.preventDefault(),this.reset(!0))}_applyWidth(e,t){const i=this._resolveIndex(e);i<0||(this._cellsAt(i).forEach(e=>{this._rememberCellStyle(e),e.style.width=`${t}px`,e.style.minWidth=`${t}px`,e.style.maxWidth=`${t}px`}),this._colsAt(i).forEach(e=>{this._rememberCellStyle(e),e.style.width=`${t}px`,e.style.minWidth=`${t}px`,e.style.maxWidth=`${t}px`}),this._getHeaders()[i]?.querySelector(`[${eo}]`)?.setAttribute("aria-valuenow",String(t)))}_applyVisibility(e,t){const i=this._resolveIndex(e);i<0||[...this._cellsAt(i),...this._colsAt(i)].forEach(e=>{this._originalVisibility.has(e)||this._originalVisibility.set(e,e.hidden),e.hidden=!t,e.toggleAttribute("data-vg-table-column-hidden",!t)})}_moveColumn(e,t){new Set([...Array.from(this._headerTable.rows||[]),...Array.from(this._table.tBodies||[]).flatMap(e=>Array.from(e.rows||[])),...Array.from(this._table.tFoot?.rows||[])]).forEach(i=>this._moveNode(Array.from(i.cells||[]),e,t)),this._colgroups().forEach(i=>this._moveNode(Array.from(i.children||[]),e,t))}_moveNode(e,t,i){const s=e[t],r=e[i];s&&r&&s!==r&&(t<i?r.after(s):r.before(s))}_cellsAt(e){const t=[];return new Set([...Array.from(this._headerTable.rows||[]),...Array.from(this._table.tBodies||[]).flatMap(e=>Array.from(e.rows||[])),...Array.from(this._table.tFoot?.rows||[])]).forEach(i=>{!i.hasAttribute("data-vg-table-state-row")&&i.cells[e]&&t.push(i.cells[e])}),t}_colsAt(e){return this._colgroups().map(t=>t.children[e]).filter(Boolean)}_colgroups(){return Array.from(new Set([...Array.from(this._table.querySelectorAll(":scope > colgroup")),...Array.from(this._headerTable.querySelectorAll(":scope > colgroup"))]))}_getHeaders(){const e=Array.from(this._headerTable.tHead?.rows||[]);return e.length?Array.from(e.at(-1).cells||[]):[]}_field(e,t){return String(e?.getAttribute("data-field")||t).trim()}_resolveIndex(e){const t=this._getHeaders();if("number"==typeof e||/^\d+$/.test(String(e??"").trim())){const i=Number.parseInt(e,10);return i>=0&&i<t.length?i:-1}const i=String(e||"").trim();return t.findIndex((e,t)=>this._field(e,t)===i)}_isLocked(e,t){return!0===this._hooks.isFixed?.(this._field(e,t))}_minVisible(){return Math.max(1,Number.parseInt(this._options.visibility?.minVisible,10)||1)}_clampWidth(e){const t=Math.max(40,Number.parseInt(this._options.resize?.minWidth,10)||80),i=Math.max(t,Number.parseInt(this._options.resize?.maxWidth,10)||600);return Math.min(i,Math.max(t,Math.round(Number(e)||t)))}_resizeLabel(e){const t=String(e?.textContent||"").trim();return String(this._options.resize?.label||"Изменить ширину колонки {column}").replace("{column}",t)}_resolveControls(){const e=this._options.visibility?.controls;return"undefined"!=typeof Element&&e instanceof Element?e:e?this._table.ownerDocument.querySelector(String(e)):null}_syncControls(){this._controls?.querySelectorAll(to).forEach(e=>{const t=e.getAttribute("data-vg-table-column")||e.getAttribute("data-column-field"),i=this._resolveIndex(t);e.checked=i>=0&&!this._hidden.has(t),e.disabled=i<0||this._isLocked(this._getHeaders()[i],i)})}_rememberOriginalState(){this._getHeaders().forEach((e,t)=>{this._cellsAt(t).forEach(e=>{this._rememberCellStyle(e),this._originalVisibility.has(e)||this._originalVisibility.set(e,e.hidden)})}),this._colgroups().forEach(e=>Array.from(e.children).forEach(e=>this._rememberCellStyle(e)))}_rememberCellStyle(e){this._originalCellStyles.has(e)||this._originalCellStyles.set(e,{width:e.style.width,minWidth:e.style.minWidth,maxWidth:e.style.maxWidth})}_restoreOriginalStyles(){this._originalCellStyles.forEach((e,t)=>{t.style.width=e.width,t.style.minWidth=e.minWidth,t.style.maxWidth=e.maxWidth}),this._originalVisibility.forEach((e,t)=>{t.hidden=e,t.removeAttribute("data-vg-table-column-hidden")})}_restoreOriginalOrder(){this._originalOrder.forEach((e,t)=>{const i=this._resolveIndex(e);i>=0&&i!==t&&this._moveColumn(i,t)})}_storageKey(e,t){const i=this._options[e]||{};if(!0!==i.persist||"undefined"==typeof window)return"";return String(i.storageKey||"").trim()||(this._table.id?`vg-table:${this._table.id}:${t}`:"")}_readStorage(e,t,i){const s=this._storageKey(e,t);if(!s)return i;try{return JSON.parse(window.localStorage.getItem(s))??i}catch(e){return i}}_writeStorage(e,t,i){const s=this._storageKey(e,t);if(s)try{window.localStorage.setItem(s,JSON.stringify(i))}catch(e){}}_restoreOrder(){const e=this._readStorage("reorder","column-order",[]);Array.isArray(e)&&e.forEach((e,t)=>{const i=this._resolveIndex(e);i>=0&&i!==t&&!this._isLocked(this._getHeaders()[i],i)&&!this._isLocked(this._getHeaders()[t],t)&&this._moveColumn(i,t)})}_storeOrder(){this._writeStorage("reorder","column-order",this.getOrder())}_restoreWidths(){const e=this._readStorage("resize","column-widths",{});e&&"object"==typeof e&&!Array.isArray(e)&&Object.entries(e).forEach(([e,t])=>{this._resolveIndex(e)>=0&&this._widths.set(e,this._clampWidth(t))})}_storeWidths(){this._writeStorage("resize","column-widths",Object.fromEntries(this._widths))}_restoreVisibility(){const e=this._readStorage("visibility","hidden-columns",[]);Array.isArray(e)&&e.forEach(e=>{const t=this._resolveIndex(e);this._getHeaders().length-this._hidden.size>this._minVisible()&&t>=0&&!this._isLocked(this._getHeaders()[t],t)&&this._hidden.add(e)})}_storeVisibility(){this._writeStorage("visibility","hidden-columns",Array.from(this._hidden))}_clearStorage(){[["reorder","column-order"],["resize","column-widths"],["visibility","hidden-columns"]].forEach(([e,t])=>{const i=this._storageKey(e,t);if(i)try{window.localStorage.removeItem(i)}catch(e){}})}},ao="rowreorder.vg.table",oo="data-vg-table-row-dragging",lo="data-vg-table-row-drag-over",ho="data-vg-table-row-reorder",co='a, button, input, select, textarea, [contenteditable="true"]',_o=class{constructor(e,t,i={},s={}){this._table=e,this._wrapper=t,this._options=i,this._hooks=s,this._original=new Map,this._rowState=new WeakMap,this._handleState=new WeakMap,this._drag={row:null,fromIndex:-1,target:null,after:!1},this._boundDragStart=this._handleDragStart.bind(this),this._boundDragOver=this._handleDragOver.bind(this),this._boundDrop=this._handleDrop.bind(this),this._boundDragEnd=this._clearDrag.bind(this),this._boundKeydown=this._handleKeydown.bind(this)}init(){return Array.from(this._table.tBodies||[]).forEach(e=>this._original.set(e,this._rows(e))),this._restoreStoredOrder(),this.refresh(),this._table.addEventListener("dragstart",this._boundDragStart),this._table.addEventListener("dragover",this._boundDragOver),this._table.addEventListener("drop",this._boundDrop),this._table.addEventListener("dragend",this._boundDragEnd),this._table.addEventListener("keydown",this._boundKeydown),this}refresh(){return this._rows().forEach((e,t)=>this._decorate(e,t)),this.getState()}getState(){return{order:this._rows().map((e,t)=>this._key(e,t)),rows:this._rows()}}move(e,t,i="before",s=!0){const r=this._resolveRow(e),n=this._resolveRow(t);if(!r||!n||r===n||r.parentElement!==n.parentElement)return!1;if(this._disabled(r)||this._disabled(n))return!1;const a=this._rows(r.parentElement).indexOf(r),o="after"===String(i).toLowerCase();return!(!o&&r.nextElementSibling===n||o&&n.nextElementSibling===r||(r.parentElement.insertBefore(r,o?n.nextSibling:n),this._afterMove(r,a,s),0))}reset(e=!0){return this._original.forEach((e,t)=>e.forEach(e=>t.append(e))),this._clearStorage(),this.refresh(),this._hooks.refreshLayout?.(),e&&g.A.trigger(this._table,ao,Object.assign({reset:!0},this.getState())),this.getState()}dispose(){this._table.removeEventListener("dragstart",this._boundDragStart),this._table.removeEventListener("dragover",this._boundDragOver),this._table.removeEventListener("drop",this._boundDrop),this._table.removeEventListener("dragend",this._boundDragEnd),this._table.removeEventListener("keydown",this._boundKeydown),this._clearDrag(),this._rows().forEach(e=>this._undecorate(e)),this._original.forEach((e,t)=>e.forEach(e=>t.append(e))),this._original.clear()}_decorate(e,t){this._rowState.has(e)||this._rowState.set(e,{draggable:e.getAttribute("draggable"),tabindex:e.getAttribute("tabindex"),label:e.getAttribute("aria-label")});const i=this._disabled(e),s=this._mode();e.setAttribute(ho,i?"disabled":s),e.draggable=!i&&"row"===s,i||"row"!==s||(e.hasAttribute("tabindex")||(e.tabIndex=0),e.setAttribute("aria-label",this._handleLabel(e,t))),this._handles(e).forEach(r=>{this._handleState.has(r)||this._handleState.set(r,{draggable:r.getAttribute("draggable"),tabindex:r.getAttribute("tabindex"),role:r.getAttribute("role"),label:r.getAttribute("aria-label"),disabled:r.getAttribute("aria-disabled")}),r.draggable=!i&&"handle"===s,i||r.hasAttribute("tabindex")||(r.tabIndex=0),r.hasAttribute("role")||r.setAttribute("role","button"),r.setAttribute("aria-label",this._handleLabel(e,t)),r.toggleAttribute("aria-disabled",i)})}_undecorate(e){e.removeAttribute(ho),e.removeAttribute(oo),e.removeAttribute(lo);const t=this._rowState.get(e)||{};this._restoreAttribute(e,"draggable",t.draggable),this._restoreAttribute(e,"tabindex",t.tabindex),this._restoreAttribute(e,"aria-label",t.label),this._handles(e).forEach(e=>{const t=this._handleState.get(e)||{};this._restoreAttribute(e,"draggable",t.draggable),this._restoreAttribute(e,"tabindex",t.tabindex),this._restoreAttribute(e,"role",t.role),this._restoreAttribute(e,"aria-label",t.label),this._restoreAttribute(e,"aria-disabled",t.disabled)})}_restoreAttribute(e,t,i){null==i?e.removeAttribute(t):e.setAttribute(t,i)}_handleDragStart(e){const t=e.target.closest?.(`tr[${ho}]`);if(t&&!this._disabled(t))if("handle"!==this._mode()||e.target.closest?.(this._handleSelector())){if("row"===this._mode()&&e.target.closest?.(co))e.preventDefault();else if(this._drag={row:t,fromIndex:this._rows(t.parentElement).indexOf(t),target:null,after:!1},t.setAttribute(oo,""),this._wrapper?.classList.add("vg-table-wrapper--row-dragging"),e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",this._key(t,this._drag.fromIndex))}catch(e){}}}else e.preventDefault()}_handleDragOver(e){if(!this._drag.row)return;const t=e.target.closest?.(`tr[${ho}]`);if(!t||t===this._drag.row||t.parentElement!==this._drag.row.parentElement||this._disabled(t))return;e.preventDefault();const i=t.getBoundingClientRect(),s=e.clientY>i.top+i.height/2;this._rows().forEach(e=>e.removeAttribute(lo)),t.setAttribute(lo,s?"after":"before"),this._drag.target=t,this._drag.after=s}_handleDrop(e){if(!this._drag.row||!this._drag.target)return this._clearDrag();e.preventDefault();const{row:t,target:i,after:s,fromIndex:r}=this._drag;t.parentElement.insertBefore(t,s?i.nextSibling:i),this._clearDrag(),this._afterMove(t,r,!0)}_handleKeydown(e){if(!["ArrowUp","ArrowDown","Home","End"].includes(e.key))return;const t=e.target.closest?.(this._handleSelector()),i=t?.closest?.(`tr[${ho}]`)||("row"===this._mode()?e.target.closest?.(`tr[${ho}]`):null);if(!i||this._disabled(i))return;if(!t&&e.target!==i&&e.target.closest?.(co))return;const s=this._rows(i.parentElement).filter(e=>!this._disabled(e)),r=s.indexOf(i),n="Home"===e.key?s[0]:"End"===e.key?s.at(-1):s[r+("ArrowUp"===e.key?-1:1)];n&&n!==i&&(e.preventDefault(),this.move(i,n,"ArrowDown"===e.key||"End"===e.key?"after":"before",!0),(t||i).focus?.())}_afterMove(e,t,i){if(this.refresh(),this._storeOrder(),this._hooks.refreshLayout?.(),!i)return;const s=this._rows(e.parentElement),r=s.indexOf(e);g.A.trigger(this._table,ao,{row:e,key:this._key(e,r),fromIndex:t,toIndex:r,beforeRow:e.previousElementSibling||null,afterRow:e.nextElementSibling||null,order:s.map((e,t)=>this._key(e,t))})}_clearDrag(){this._rows().forEach(e=>{e.removeAttribute(oo),e.removeAttribute(lo)}),this._wrapper?.classList.remove("vg-table-wrapper--row-dragging"),this._drag={row:null,fromIndex:-1,target:null,after:!1}}_rows(e=null){return(e?[e]:Array.from(this._table.tBodies||[])).flatMap(e=>Array.from(e.rows||[])).filter(e=>!e.matches("[data-vg-table-state-row], [data-vg-table-skeleton-row]"))}_resolveRow(e){if("TR"===e?.tagName&&this._table.contains(e))return e;const t=this._rows();if("number"==typeof e)return t[Number.parseInt(e,10)]||null;const i=String(e||"").trim();return t.find((e,t)=>this._key(e,t)===i)||null}_key(e,t){return String(e.getAttribute(this._options.keyAttr||"data-row-key")??e.getAttribute("data-id")??t)}_disabled(e){return e.hasAttribute("data-row-reorder-disabled")}_mode(){return"row"===String(this._options.mode||"handle").toLowerCase()?"row":"handle"}_handleSelector(){return String(this._options.handleSelector||"[data-row-reorder-handle]").trim()||"[data-row-reorder-handle]"}_handles(e){return Array.from(e.querySelectorAll(this._handleSelector()))}_handleLabel(e,t){return String(this._options.labels?.handle||"Изменить позицию строки {row}").replace("{row}",this._key(e,t))}_storageKey(){return!0!==this._options.persist||"undefined"==typeof window?"":String(this._options.storageKey||"").trim()||(this._table.id?`vg-table:${this._table.id}:row-order`:"")}_storeOrder(){const e=this._storageKey();if(e)try{window.localStorage.setItem(e,JSON.stringify(this.getState().order))}catch(e){}}_restoreStoredOrder(){const e=this._storageKey();if(!e)return;let t=[];try{t=JSON.parse(window.localStorage.getItem(e))||[]}catch(e){return}Array.isArray(t)&&t.forEach((e,t)=>{const i=this._resolveRow(String(e)),s=this._rows(i?.parentElement)[t];i&&s&&i!==s&&!this._disabled(i)&&!this._disabled(s)&&s.before(i)})}_clearStorage(){const e=this._storageKey();if(e)try{window.localStorage.removeItem(e)}catch(e){}}},uo=class{constructor(e,t={},i={}){this._table=e,this._options=t,this._hooks=i,this._cache=new Map,this._controller=null,this._token=0,this._params={},this._lastMeta={},this._lastRequest=null,this._loading=!1,this._boundClick=this._handleClick.bind(this)}init(){return this._table.addEventListener("click",this._boundClick),this.load()}dispose(){this._token+=1,this._controller?.abort?.(),this._table.removeEventListener("click",this._boundClick),this._table.removeAttribute("aria-busy"),this._table.removeAttribute("data-vg-table-remote"),this._cache.clear(),this._controller=null}load(e={}){const t=this._hooks.getPagination?.()||{},i=this._positiveInt(e.page,t.page||1),s=this._positiveInt(e.perPage,t.perPage||10);return e.params&&"object"==typeof e.params&&!Array.isArray(e.params)&&this.setParams(e.params,!0===e.replaceParams),this._request(i,s,{force:!0===e.force,source:String(e.source||"api")})}reload(e={}){return this.load(Object.assign({},e,{force:!1!==e.force}))}setParams(e={},t=!1){const i=e&&"object"==typeof e&&!Array.isArray(e)?e:{};return this._params=t?Object.assign({},i):Object.assign({},this._params,i),Object.assign({},this._params)}clearCache(){this._cache.clear()}getState(){return{loading:this._loading,params:Object.assign({},this._params),meta:Object.assign({},this._lastMeta),request:this._lastRequest?Object.assign({},this._lastRequest):null}}export(e="csv",t={}){const i=String(t.route||this._options.export?.route||this._options.route||"").trim();if(!i)return"";const s=this._hooks.getPagination?.()||{},r=this._mapParams(this._buildParams(this._positiveInt(t.page,s.page||1),this._positiveInt(t.perPage,s.perPage||10)));r.format="xlsx"===String(e||"csv").toLowerCase()?"xlsx":"csv";const n=this._hooks.buildUrl(r,i,this._requestConfig(i));return!1!==t.open&&"undefined"!=typeof window&&window.open?.(n.toString(),"_blank","noopener"),n.toString()}async _request(e,t,i={}){const s=String(this._options.route||"").trim();if(!s)return null;const r=this._mapParams(this._buildParams(e,t)),n=String(this._options.method||"GET").toUpperCase(),a=this._cacheKey(s,n,r),o=i.force?null:this._readCache(a),l=Date.now(),h=++this._token,d={requestId:`vg-table-${Date.now()}-${h}`,page:e,perPage:t,params:Object.assign({},r),source:i.source,fromCache:Boolean(o)};if(this._lastRequest=d,this._controller?.abort?.(),this._controller=o||"function"!=typeof AbortController?null:new AbortController,this._loading=!0,this._table.setAttribute("data-vg-table-remote",""),this._table.setAttribute("aria-busy","true"),this._emit("beforeload.vg.table",d),!o){const e=this._hooks.renderLoading?.();e||this._renderState(this._label("loading","Загрузка…"),"loading")}try{const s=o||await this._hooks.request(this._buildRequest(r,this._controller?.signal,i.source));if(h!==this._token)return null;if(o||await this._waitMinLoadingDelay(l),h!==this._token)return null;o||this._writeCache(a,s);const n=this._applyResponse(s,e,t);return this._emit("requestsuccess.vg.table",Object.assign({},d,{response:s,meta:n.meta})),this._emit("dataloaded.vg.table",Object.assign({},d,n,{response:s})),this._emit("afterrender.vg.table",Object.assign({},d,{renderedCount:n.renderedCount,total:n.meta.total})),n}catch(e){return"AbortError"===e?.name||h!==this._token||(o||await this._waitMinLoadingDelay(l),h!==this._token||(this._hooks.renderError?.(e)||this._renderState(this._label("error","Не удалось загрузить данные"),"error"),this._emit("requesterror.vg.table",Object.assign({},d,{error:e})))),null}finally{h===this._token&&(this._loading=!1,this._table.setAttribute("aria-busy","false"),this._controller=null)}}_waitMinLoadingDelay(e){const t=this._nonNegativeInt(this._hooks.getLoadingMinDelay?.(),0)-Math.max(0,Date.now()-e);return t>0?new Promise(e=>window.setTimeout(e,t)):Promise.resolve()}_buildRequest(e,t,i="api"){const s=String(this._options.method||"GET").toUpperCase(),r="GET"===s||"HEAD"===s,n=this._requestConfig();return"retry"===i&&(n.headers["X-VGTable-Retry"]="1"),Object.assign(n,{method:s,params:r?e:{},body:r?null:e,signal:t,responseType:"json"})}_requestConfig(e=this._options.route){return{route:e,method:this._options.method,credentials:this._options.credentials,headers:Object.assign({},this._options.headers||{}),baseParams:Object.assign({},this._options.params||{})}}_buildParams(e,t){const i=Object.assign({},this._params,{page:e,per_page:t}),s=this._hooks.getSort?.(),r=Array.isArray(s?.sorts)&&s.sorts.length?s.sorts:s?.field?[s]:[];r.length&&(i.sort=r.map(e=>e.field).filter(Boolean).join(","),i.dir=r.map(e=>"desc"===e.direction?"desc":"asc").join(","));const n=this._responseMode();if(i.responsemode=n,"data"!==n){const e=String(this._options.viewparam||"").trim(),t=String(this._options.viewvalue||"").trim();e&&t&&(i[e]=t);const s=String(this._options.fieldsparam||"").trim(),r=this._fields();s&&r.length&&(i[s]=r.join(","))}return i}_mapParams(e){const t=this._options.parammap&&"object"==typeof this._options.parammap?this._options.parammap:{};return Object.keys(e).reduce((i,s)=>(i[String(Object.prototype.hasOwnProperty.call(t,s)?t[s]:s).trim()||s]=e[s],i),{})}_applyResponse(e,t,i){const s=this._extractRows(e),r=this._extractView(e),n=this._normalizeMeta(this._readPath(e,this._options.metapath),s,t,i),a=this._responseMode();let o=0;return("view"===a||"auto"===a&&"string"==typeof r&&""!==r.trim())&&"string"==typeof r&&""!==r.trim()?(this._body().innerHTML=r,o=this._body().rows.length):Array.isArray(s)&&s.length?o=this._renderRows(s):this._hooks.renderEmpty?.({rows:s,view:r,meta:n})||this._renderState(this._label("empty","Ничего не найдено"),"empty"),this._lastMeta=n,this._hooks.applyMeta?.(n),this._hooks.afterRender?.({rows:s,view:r,meta:n,renderedCount:o}),{rows:s,view:r,meta:n,renderedCount:o}}_renderRows(e){const t=this._body(),i=this._fields(),s=this._table.ownerDocument.createDocumentFragment();return e.forEach(e=>{const t=this._table.ownerDocument.createElement("tr");i.forEach(i=>{const s=this._table.ownerDocument.createElement("td"),r=this._readPath(e,i);s.textContent=null==r?"":String(r),t.append(s)}),s.append(t)}),t.replaceChildren(s),e.length}_renderState(e,t){const i=this._body(),s=this._table.ownerDocument.createElement("tr"),r=this._table.ownerDocument.createElement("td");r.colSpan=Math.max(1,this._fields().length||this._headerCells().length),r.setAttribute("data-vg-table-state",t);const n=this._table.ownerDocument.createElement("span");if(n.textContent=e,r.append(n),"error"===t){const e=this._table.ownerDocument.createElement("button");e.type="button",e.className="vg-table-state__retry",e.setAttribute("data-vg-table-retry",""),e.textContent=this._label("retry","Повторить"),r.append(e)}s.append(r),i.replaceChildren(s)}_label(e,t){return String(this._options.labels?.[e]||t||"")}_normalizeMeta(e,t,i,s){const r=e&&"object"==typeof e&&!Array.isArray(e)?e:{},n=this._positiveInt(r.page??r.current_page,i),a=this._positiveInt(r.per_page??r.perPage,s),o=this._nonNegativeInt(r.total,Array.isArray(t)?t.length:0),l=this._positiveInt(r.pages??r.last_page,Math.max(1,Math.ceil(o/a)));return Object.assign({},r,{page:Math.min(n,l),per_page:a,total:o,pages:l})}_extractRows(e){const t=this._readPath(e,this._options.datapath);return Array.isArray(t)?t:[]}_extractView(e){const t=this._readPath(e,this._options.viewpath);return"string"==typeof t?t:""}_readPath(e,t){const i=String(t||"").split(".").map(e=>e.trim()).filter(Boolean);let s=e;for(const e of i){if(!s||"object"!=typeof s||!Object.prototype.hasOwnProperty.call(s,e))return;s=s[e]}return s}_fields(){return this._headerCells().map(e=>String(e.getAttribute("data-field")||"").trim()).filter(Boolean)}_headerCells(){const e=this._hooks.getHeaderTable?.()||this._table,t=e.tHead||e.querySelector("thead");return t?.rows.length?Array.from(t.rows[t.rows.length-1].cells):[]}_body(){return this._table.tBodies[0]||this._table.createTBody()}_responseMode(){const e=String(this._options.responsemode||"data").toLowerCase();return["data","view","auto"].includes(e)?e:"data"}_cacheKey(e,t,i){return`${t}:${e}?${Object.keys(i).sort().map(e=>{const t=Array.isArray(i[e])?i[e].join(","):i[e];return`${encodeURIComponent(e)}=${encodeURIComponent(t??"")}`}).join("&")}`}_readCache(e){if(!1===this._options.cache?.enable)return null;const t=this._cache.get(e);if(!t)return null;const i=this._positiveInt(this._options.cache?.ttl,3e4);return Date.now()-t.createdAt>i?(this._cache.delete(e),null):(t.usedAt=Date.now(),t.response)}_writeCache(e,t){if(!1===this._options.cache?.enable)return;this._cache.set(e,{response:t,createdAt:Date.now(),usedAt:Date.now()});const i=this._positiveInt(this._options.cache?.max,30);if(this._cache.size<=i)return;const s=Array.from(this._cache.entries()).sort((e,t)=>e[1].usedAt-t[1].usedAt)[0];s&&this._cache.delete(s[0])}_handleClick(e){e.target.closest("[data-vg-table-retry]")&&this.reload({source:"retry"})}_emit(e,t){g.A.trigger(this._table,e,t)}_positiveInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>0?i:t}_nonNegativeInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>=0?i:t}},mo=class{constructor(e,t={},i=null){this._table=e,this._options=t,this._onChange="function"==typeof i?i:null,this._form=null,this._controls=[],this._timer=null,this._boundInput=this._handleInput.bind(this),this._boundChange=this._handleChange.bind(this),this._boundClick=this._handleClick.bind(this),this._boundSubmit=this._handleSubmit.bind(this)}init(){return this._form=this._resolveForm(),this._form?(this.refresh(),this._form.addEventListener("input",this._boundInput),this._form.addEventListener("change",this._boundChange),this._form.addEventListener("click",this._boundClick),this._form.addEventListener("submit",this._boundSubmit),this):this}dispose(){this._form&&(this._form.removeEventListener("input",this._boundInput),this._form.removeEventListener("change",this._boundChange),this._form.removeEventListener("click",this._boundClick),this._form.removeEventListener("submit",this._boundSubmit)),this._timer&&window.clearTimeout(this._timer),this._timer=null,this._controls=[],this._form=null}refresh(){return this._form?(this._controls=Array.from(this._form.querySelectorAll(`[${this._fieldAttr()}]`)).filter(e=>["INPUT","SELECT","TEXTAREA"].includes(e.tagName)),this.getState()):this.getState()}getState(){const e=new Map;this._controls.forEach(t=>{const i=String(t.getAttribute(this._fieldAttr())||"").trim();if(!i)return;e.has(i)||e.set(i,{field:i,type:String(t.getAttribute(this._typeAttr())||"text").trim()||"text",operator:String(t.getAttribute(this._operatorAttr())||this._options.defaultOperator||"eq").trim()||"eq",value:"",values:[]});const s=e.get(i),r=String(t.getAttribute(this._partAttr())||"value").toLowerCase(),n=this._readValue(t);if("operator"!==r){if("type"!==r)return Array.isArray(n)?(s.values=n,void(s.value=n.join(","))):void(("checkbox"!==t.type&&"radio"!==t.type||""!==n)&&(s.value=n));s.type=String(n||"text").trim()||"text"}else s.operator=String(n||this._options.defaultOperator||"eq").trim()||"eq"});const t={},i={};return e.forEach((e,s)=>{const r=this._normalizeItem(e);r&&(t[s]=r,i[s]=r.values.length?r.values.slice():r.value,r.operator&&(i[`${s}_op`]=r.operator))}),{filters:t,params:i,fields:Object.keys(t),meta:{count:Object.keys(t).length}}}getFields(){return this._fieldNames()}setValues(e={},t={}){const i=e&&"object"==typeof e?e:{};return this._controls.forEach(e=>{const t=String(e.getAttribute(this._fieldAttr())||"").trim();if(!t)return;const s="operator"===String(e.getAttribute(this._partAttr())||"value").toLowerCase()?`${t}_op`:t;this._writeValue(e,Object.prototype.hasOwnProperty.call(i,s)?i[s]:"")}),!0===t.emit&&this._emit(String(t.source||"api")),this.getState()}reset(e={}){return this._controls.forEach(e=>this._resetControl(e)),!1!==e.emit&&this._emit(String(e.source||"reset")),this.getState()}_handleInput(e){this._isControl(e.target)&&!this._isManual()&&(["checkbox","radio"].includes(String(e.target.type).toLowerCase())||"SELECT"===e.target.tagName?this._emit("input"):this._schedule("input"))}_handleChange(e){this._isControl(e.target)&&!this._isManual()&&(this._clearTimer(),this._emit("change"))}_handleClick(e){const t=this._options.buttons||{},i=this._closest(e.target,t.apply||"[data-filter-apply]");if(i&&this._form.contains(i))return e.preventDefault(),this._clearTimer(),void this._emit("apply");const s=this._closest(e.target,t.reset||"[data-filter-reset]");s&&this._form.contains(s)&&(e.preventDefault(),this._clearTimer(),this.reset({source:"reset"}))}_handleSubmit(e){this._isManual()&&(e.preventDefault(),this._clearTimer(),this._emit("submit"))}_emit(e){const t=Object.assign(this.getState(),{source:e});g.A.trigger(this._table,"filterschange.vg.table",t),this._onChange?.(t)}_schedule(e){this._clearTimer(),this._timer=window.setTimeout(()=>{this._timer=null,this._emit(e)},this._nonNegativeInt(this._options.debounce,300))}_clearTimer(){this._timer&&window.clearTimeout(this._timer),this._timer=null}_resolveForm(){if("undefined"!=typeof Element&&this._options.form instanceof Element)return this._options.form;const e=String(this._options.form||"").trim();if(!e)return null;try{return document.querySelector(e)}catch(e){return null}}_normalizeItem(e){let t=e.value,i=Array.isArray(e.values)?e.values.slice():[];return!1!==this._options.trim&&("string"==typeof t&&(t=t.trim()),i=i.map(e=>String(e??"").trim()).filter(Boolean)),!1===this._options.skipEmpty||i.length||null!=t&&""!==String(t)?{field:e.field,type:String(e.type||"text").toLowerCase(),operator:String(e.operator||this._options.defaultOperator||"eq").toLowerCase(),value:t??"",values:i}:null}_readValue(e){return"SELECT"===e.tagName&&e.multiple?Array.from(e.selectedOptions).map(e=>e.value).filter(Boolean):"checkbox"===e.type||"radio"===e.type?e.checked?e.getAttribute(this._valueAttr())??e.value??"1":"":e.value??""}_writeValue(e,t){if("checkbox"===e.type||"radio"===e.type){const i=Array.isArray(t)?t.map(String):[String(t??"")],s=String(e.getAttribute(this._valueAttr())??e.value??"1");return void(e.checked=i.includes(s)||"checkbox"===e.type&&["1","true","on"].includes(i[0]?.toLowerCase()))}if("SELECT"===e.tagName&&e.multiple){const i=new Set((Array.isArray(t)?t:String(t??"").split(",")).map(String));return void Array.from(e.options).forEach(e=>{e.selected=i.has(e.value)})}e.value=String(t??"")}_resetControl(e){"checkbox"===e.type||"radio"===e.type?e.checked=e.defaultChecked:"SELECT"===e.tagName?Array.from(e.options).forEach(e=>{e.selected=e.defaultSelected}):e.value=e.defaultValue||""}_fieldNames(){return Array.from(new Set(this._controls.map(e=>String(e.getAttribute(this._fieldAttr())||"").trim()).filter(Boolean)))}_isControl(e){return this._controls.includes(e)}_closest(e,t){if(!e?.closest)return null;const i=String(t||"").trim();if(!i)return null;try{return e.closest(i)}catch(e){return null}}_isManual(){return"manual"===String(this._options.apply||"auto").toLowerCase()}_fieldAttr(){return String(this._options.fieldAttr||"data-filter-field")}_partAttr(){return String(this._options.partAttr||"data-filter-part")}_typeAttr(){return String(this._options.typeAttr||"data-filter-type")}_valueAttr(){return String(this._options.valueAttr||"data-filter-value")}_operatorAttr(){return String(this._options.operatorAttr||"data-filter-operator")}_nonNegativeInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>=0?i:t}},po=class{constructor(e,t={},i=null){this._table=e,this._options=t,this._onChange="function"==typeof i?i:null,this._input=null,this._resetButtons=[],this._timer=null,this._boundInput=this._handleInput.bind(this),this._boundKeydown=this._handleKeydown.bind(this),this._boundReset=this._handleReset.bind(this)}init(){return this._input=this._resolveNode(this._options.input),this._input?(this._resetButtons=this._resolveNodes(this._options.button?.reset||"[data-search-reset]"),this._input.addEventListener("input",this._boundInput),this._input.addEventListener("keydown",this._boundKeydown),this._resetButtons.forEach(e=>e.addEventListener("click",this._boundReset)),this):this}dispose(){this._input?.removeEventListener("input",this._boundInput),this._input?.removeEventListener("keydown",this._boundKeydown),this._resetButtons.forEach(e=>e.removeEventListener("click",this._boundReset)),this._clearTimer(),this._input=null,this._resetButtons=[]}getState(){return{value:this._value(),param:String(this._options.param||"q").trim()||"q"}}setValue(e,t={}){return this._input?(this._input.value=String(e??""),this._clearTimer(),!0===t.emit&&this._emit(String(t.source||"api")),this.getState()):this.getState()}reset(e={}){return this.setValue("",{emit:!1!==e.emit,source:String(e.source||"reset")})}refresh(){return this.getState()}_handleInput(){this._schedule("input")}_handleKeydown(e){"Enter"===e.key&&(e.preventDefault(),this._clearTimer(),this._emit("enter"))}_handleReset(e){e.preventDefault(),this.reset({source:"reset"}),this._input?.focus?.()}_emit(e){const t=Object.assign(this.getState(),{source:e});g.A.trigger(this._table,"searchchange.vg.table",t),this._onChange?.(t)}_schedule(e){this._clearTimer(),this._timer=window.setTimeout(()=>{this._timer=null,this._emit(e)},this._nonNegativeInt(this._options.debounce,300))}_clearTimer(){this._timer&&window.clearTimeout(this._timer),this._timer=null}_value(){const e=String(this._input?.value??"");return!1===this._options.trim?e:e.trim()}_resolveNode(e){if("undefined"!=typeof Element&&e instanceof Element)return e;const t=String(e||"").trim();if(!t)return null;try{return document.querySelector(t)}catch(e){return null}}_resolveNodes(e){const t=String(e||"").trim();if(!t)return[];try{const e=this._input?.form||this._input?.closest?.("[data-search-controls]")||document,i=Array.from(e.querySelectorAll(t));return i.length?i:Array.from(document.querySelectorAll(t))}catch(e){return[]}}_nonNegativeInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>=0?i:t}},go="tr[data-vg-table-skeleton]",fo=class{constructor(e,t={},i={}){this._table=e,this._options=t,this._hooks=i}render(){if(!1===this._options.enabled)return 0;const e=this._body(),t=this._dataRows(),i=this._columnWidths(t[0]),s=this._hasHorizontalOverflow(),r=Math.max(1,i.length,this._headerCells().length),n=this._rowsCount(t),a=this._rowHeight(t[0]),o=this._table.ownerDocument.createDocumentFragment();for(let e=0;e<n;e+=1){const t=this._table.ownerDocument.createElement("tr");t.className="vg-table-skeleton-row",t.setAttribute("data-vg-table-skeleton",""),t.setAttribute("aria-hidden","true"),t.style.setProperty("--vg-table-skeleton-delay",`${(.08*e).toFixed(2)}s`),a>0&&t.style.setProperty("--vg-table-skeleton-row-height",`${a}px`);for(let e=0;e<r;e+=1){const r=this._table.ownerDocument.createElement("td");a>0&&(r.style.height=`${a}px`);const n=Number.isFinite(i[e])?Math.round(i[e]):0;s&&n>0&&(r.style.width=`${n}px`,r.style.minWidth=`${n}px`,r.style.maxWidth=`${n}px`);const o=this._table.ownerDocument.createElement("span");o.className="vg-table-skeleton-cell";const l=this._table.ownerDocument.createElement("span");l.className="vg-table-skeleton-line",o.append(l),r.append(o),t.append(r)}o.append(t)}return e.replaceChildren(o),this._hooks.afterRender?.(),n}dispose(){this._body().querySelectorAll(go).forEach(e=>e.remove())}_rowsCount(e){if(e.length)return e.length;const t=this._body().querySelectorAll(go).length;if(t)return t;const i=Number.parseInt(this._options.skeleton??this._options.rows,10);if(Number.isFinite(i)&&i>0)return i;const s=Number.parseInt(this._hooks.getPagination?.()?.perPage,10);return Number.isFinite(s)&&s>0?s:5}_columnWidths(e){const t=this._headerCells().map(e=>this._width(e));return t.some(e=>e>0)?t:e?Array.from(e.cells||[],e=>this._width(e)):[]}_headerCells(){const e=this._hooks.getHeaderTable?.()||this._table,t=e.tHead||e.querySelector("thead");return t?.rows.length?Array.from(t.rows[t.rows.length-1].cells):[]}_dataRows(){return Array.from(this._body().rows||[]).filter(e=>!e.matches(go)&&!e.querySelector("[data-vg-table-state]"))}_rowHeight(e){const t=e?Math.round(this._height(e)):0;if(t>0)return t;const i=this._hooks.getHeaderTable?.()||this._table,s=i.tHead||i.querySelector("thead"),r=s?.rows.length?s.rows[s.rows.length-1]:null;return r?Math.round(this._height(r)):0}_width(e){const t=e?.getBoundingClientRect?.().width;return Number.isFinite(t)&&t>0?t:0}_height(e){const t=e?.getBoundingClientRect?.().height;return Number.isFinite(t)&&t>0?t:0}_hasHorizontalOverflow(){const e=this._hooks.getScrollHost?.()||this._table.closest(".vg-table-body")||this._table.closest(".vg-table-container");return!!e&&e.scrollWidth-e.clientWidth>1}_body(){return this._table.tBodies[0]||this._table.createTBody()}},bo="statechange.vg.table",vo="data-vg-table-state-row",yo=class{constructor(e,t,i={},s={}){this._table=e,this._wrapper=t,this._options=i,this._hooks=s,this._state=null,this._boundClick=this._handleClick.bind(this)}init(){return this._table.addEventListener("click",this._boundClick),this}dispose(){this._table.removeEventListener("click",this._boundClick),this.clear(!1)}render(e,t=""){if(!1===this._options.enabled)return null;const i=["empty","filtered-empty","error"].includes(String(e))?String(e):"empty";this._removeRow();const s=this._table.ownerDocument.createElement("tr");s.setAttribute(vo,"");const r=this._table.ownerDocument.createElement("td");r.colSpan=this._columns(),r.setAttribute("data-vg-table-state",i),r.setAttribute("role","error"===i?"alert":"status");const n=this._table.ownerDocument.createElement("div");n.className="vg-table-state";const a=this._table.ownerDocument.createElement("span");a.className=`vg-table-state__icon vg-table-state__icon--${i}`,a.setAttribute("aria-hidden","true");const o=this._table.ownerDocument.createElement("span");o.className="vg-table-state__text",o.textContent=t||this._label(i),n.append(a,o);const l=this._actions(i);return l&&n.append(l),r.append(n),s.append(r),!0===this._hooks.remote?this._body().replaceChildren(s):this._body().append(s),this._state={type:i,message:o.textContent},this._wrapper?.setAttribute("data-vg-table-state",i),g.A.trigger(this._table,bo,this.getState()),this.getState()}clear(e=!0){const t=this._state;return this._removeRow(),this._state=null,this._wrapper?.removeAttribute("data-vg-table-state"),e&&t&&g.A.trigger(this._table,bo,{type:null,previous:t}),t}syncLocal(e=!1){const t=this._dataRows();if(!t.length)return this.render("empty");const i=t.filter(e=>!e.hasAttribute("data-vg-table-filter-hidden"));return e&&!i.length?this.render("filtered-empty"):(this.clear(),null)}getState(){return this._state?Object.assign({},this._state):null}_actions(e){if("error"!==e&&"filtered-empty"!==e)return null;const t=this._table.ownerDocument.createElement("span");t.className="vg-table-state__actions";const i=this._table.ownerDocument.createElement("button");return i.type="button",i.className="vg-table-state__action","error"===e?(i.setAttribute("data-vg-table-retry",""),i.textContent=this._label("retry")):(i.setAttribute("data-vg-table-state-reset",""),i.textContent=this._label("reset")),t.append(i),t}_handleClick(e){e.target.closest("[data-vg-table-state-reset]")&&(e.preventDefault(),this._hooks.reset?.())}_label(e){const t=this._options.labels||{};return String(t[e]||{empty:"Нет данных","filtered-empty":"По вашему запросу ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить",reset:"Сбросить фильтры"}[e]||"")}_columns(){const e=this._hooks.getHeaderTable?.()||this._table,t=Array.from(e.tHead?.rows||[]);return Math.max(1,t.length?t.at(-1).cells.length:1)}_dataRows(){return Array.from(this._table.tBodies||[]).flatMap(e=>Array.from(e.rows||[])).filter(e=>!e.hasAttribute(vo))}_removeRow(){this._body().querySelector(`[${vo}]`)?.remove()}_body(){return this._table.tBodies[0]||this._table.createTBody()}},wo="urlstateerror.vg.table",Eo=class{constructor(e,t={},i={}){this._table=e,this._options=t,this._hooks=i,this._state=null,this._boundPopState=this._handlePopState.bind(this)}init(){return!1!==this._options.listen&&"undefined"!=typeof window&&window.addEventListener("popstate",this._boundPopState),this}dispose(){"undefined"!=typeof window&&window.removeEventListener("popstate",this._boundPopState),this._state=null}read(e="api"){if("undefined"==typeof window)return this._emptyState();try{const t=new URLSearchParams(window.location.search||""),i=this._keys(),s=this._emptyState();if(this._include("pagination")&&(s.present.page=t.has(i.page),s.present.perPage=t.has(i.perPage),s.page=this._positiveInt(t.get(i.page),null),s.perPage=this._positiveInt(t.get(i.perPage),null)),this._include("sort")){s.present.sort=t.has(i.sort)||t.has(i.direction);const e=this._list(t.get(i.sort)),r=this._list(t.get(i.direction)),n=e.map((e,t)=>({field:e,direction:"desc"===String(r[t]||r[0]||"asc").toLowerCase()?"desc":"asc"}));s.sort=n.length?Object.assign({},n[0],{sorts:n}):null}return this._include("search")&&(s.present.search=t.has(i.search),s.search=String(t.get(i.search)||"")),this._include("filters")&&this._filterFields().forEach(e=>{const r=`${i.filterPrefix}${e}`,n=`${r}_op`,a=t.getAll(r);a.length&&(s.filters[e]=1===a.length?a[0]:a,s.present.filters=!0),t.has(n)&&(s.filters[`${e}_op`]=t.get(n),s.present.filters=!0)}),this._state=s,g.A.trigger(this._table,"urlstateread.vg.table",{source:e,state:this.getState()}),this.getState()}catch(e){return g.A.trigger(this._table,wo,{source:"read",error:e}),this._emptyState()}}write(e={}){if(!1===this._options.write||"undefined"==typeof window||!window.history)return null;try{const t=new URL(window.location.href),i=this._keys();if(this._managedKeys().forEach(e=>t.searchParams.delete(e)),this._include("pagination")&&(this._set(t,i.page,e.page||1),this._set(t,i.perPage,e.perPage||"")),this._include("sort")&&e.sort?.field){const s=Array.isArray(e.sort.sorts)&&e.sort.sorts.length?e.sort.sorts:[e.sort];this._set(t,i.sort,s.map(e=>e.field).filter(Boolean).join(",")),this._set(t,i.direction,s.map(e=>"desc"===e.direction?"desc":"asc").join(","))}this._include("search")&&this._set(t,i.search,e.search||""),this._include("filters")&&Object.entries(e.filters||{}).forEach(([e,s])=>{const r=`${i.filterPrefix}${e}`;(Array.isArray(s)?s:[s]).forEach(e=>this._append(t,r,e))});const s=`${t.pathname}${t.search}${t.hash}`;return s!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history["push"===this._options.mode?"pushState":"replaceState"]({},"",s),this._state=Object.assign({},e),g.A.trigger(this._table,"urlstatewrite.vg.table",{mode:this._options.mode,state:this.getState(),url:s}),s}catch(e){return g.A.trigger(this._table,wo,{source:"write",error:e}),null}}getState(){return this._state?JSON.parse(JSON.stringify(this._state)):null}_handlePopState(){this._hooks.apply?.(this.read("popstate"),{source:"popstate",clearMissing:!0})}_managedKeys(){const e=this._keys(),t=[];return this._include("pagination")&&t.push(e.page,e.perPage),this._include("sort")&&t.push(e.sort,e.direction),this._include("search")&&t.push(e.search),this._include("filters")&&this._filterFields().forEach(i=>t.push(`${e.filterPrefix}${i}`,`${e.filterPrefix}${i}_op`)),t.filter(Boolean)}_filterFields(){return this._hooks.getFilterFields?.()||[]}_keys(){const e=this._options.keys||{},t=String(this._options.prefix||"");return{page:`${t}${e.page||"page"}`,perPage:`${t}${e.perPage||"perPage"}`,sort:`${t}${e.sort||"sort"}`,direction:`${t}${e.direction||"dir"}`,search:`${t}${e.search||"search"}`,filterPrefix:`${t}${e.filterPrefix||"filter-"}`}}_include(e){return!1!==(this._options.include||{})[e]}_emptyState(){return{page:null,perPage:null,sort:null,search:"",filters:{},present:{page:!1,perPage:!1,sort:!1,search:!1,filters:!1}}}_set(e,t,i){null!=i&&""!==String(i)&&e.searchParams.set(t,String(i))}_append(e,t,i){null!=i&&""!==String(i)&&e.searchParams.append(t,String(i))}_positiveInt(e,t){const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>0?i:t}_list(e){return String(e||"").split(",").map(e=>e.trim()).filter(Boolean)}},Ao="ru",So={ru:{pagination:{size:{label:"Строк на странице",suffix:"на страницу"},quick:{label:"Перейти к странице",button:"Перейти"},labels:{aria:"Пагинация",prev:"Назад",next:"Вперёд",ellipsisPrev:"Перейти к предыдущим страницам",ellipsisNext:"Перейти к следующим страницам"}},expandable:{labels:{expand:"Развернуть дочерние строки",collapse:"Свернуть дочерние строки"}},state:{labels:{empty:"Нет данных","filtered-empty":"По вашему запросу ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить",reset:"Сбросить фильтры"}},columnResize:{label:"Изменить ширину колонки {column}"},rowReorder:{labels:{handle:"Изменить позицию строки {row}"}},remote:{loading:"Загрузка…",empty:"Ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить"}},en:{pagination:{size:{label:"Rows per page",suffix:"per page"},quick:{label:"Go to page",button:"Go"},labels:{aria:"Pagination",prev:"Previous",next:"Next",ellipsisPrev:"Jump to previous pages",ellipsisNext:"Jump to next pages"}},expandable:{labels:{expand:"Expand child rows",collapse:"Collapse child rows"}},state:{labels:{empty:"No data","filtered-empty":"No results found",error:"Failed to load data",retry:"Retry",reset:"Reset filters"}},columnResize:{label:"Resize column {column}"},rowReorder:{labels:{handle:"Change position of row {row}"}},remote:{loading:"Loading…",empty:"Nothing found",error:"Failed to load data",retry:"Retry"}}},Co=e=>e&&"object"==typeof e&&!Array.isArray(e),xo=(...e)=>e.reduce((e,t)=>Co(t)?(Object.entries(t).forEach(([t,i])=>{e[t]=Co(i)?xo(Co(e[t])?e[t]:{},i):i}),e):e,{}),Lo=e=>String(e||Ao).trim().toLowerCase().replace("_","-")||Ao,Io=(e,t={})=>{const i=xo({},So,t),s=i[Ao]||{},r=(e=>{const t=Lo(e),i=t.split("-")[0];return t===i?[t]:[t,i]})(e).map(e=>i[e]).find(Boolean)||s;return xo({},s,r)},Po=new Map,ko=e=>String(e||"").trim(),Mo=e=>Po.get(ko(e))||null,Do="table",To=`vg.${Do}`,Oo=".vg-table-wrapper",zo=".vg-table-container",No={locale:"ru",i18n:{},sort:{enabled:!0,hover:!0,multiple:!1,multipleWithShift:!0},pan:{enabled:!0},stickyHeader:{enabled:!1,mode:"container",top:null,maxHeight:"24rem"},fixedColumns:{enabled:!1,columns:"",mode:"fixed",stackGap:0},columnResize:{enabled:!1,minWidth:80,maxWidth:600,persist:!1,storageKey:"",label:"Изменить ширину колонки {column}"},columnReorder:{enabled:!1,persist:!1,storageKey:""},columnVisibility:{enabled:!1,controls:"",minVisible:1,persist:!1,storageKey:""},rowReorder:{enabled:!1,mode:"handle",handleSelector:"[data-row-reorder-handle]",keyAttr:"data-row-key",persist:!1,storageKey:"",labels:{handle:"Изменить позицию строки {row}"}},selection:{enabled:!1,click:!0,multiple:!1},expandable:{enabled:!1,idAttr:"data-expand-id",parentAttr:"data-expand-parent-id",toggleSelector:"[data-expand-toggle]",collapsed:!0,labels:{expand:"Развернуть дочерние строки",collapse:"Свернуть дочерние строки"}},search:{enabled:!1,input:"",param:"q",debounce:300,resetPage:!0,trim:!0,fields:[],button:{reset:"[data-search-reset]"}},filters:{enabled:!1,form:"",debounce:300,apply:"auto",resetPage:!0,skipEmpty:!0,trim:!0,defaultOperator:"eq",fieldAttr:"data-filter-field",partAttr:"data-filter-part",typeAttr:"data-filter-type",valueAttr:"data-filter-value",operatorAttr:"data-filter-operator",buttons:{apply:"[data-filter-apply]",reset:"[data-filter-reset]"}},state:{enabled:!0,labels:{empty:"Нет данных","filtered-empty":"По вашему запросу ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить",reset:"Сбросить фильтры"}},urlState:{enabled:!1,read:!0,write:!0,listen:!0,mode:"replace",prefix:"",keys:{page:"page",perPage:"perPage",sort:"sort",direction:"dir",search:"search",filterPrefix:"filter-"},include:{pagination:!0,sort:!0,search:!0,filters:!0}},loading:{enabled:!0,minDelay:500,skeleton:5},request:{route:"",method:"GET",credentials:"same-origin",headers:{Accept:"application/json"},params:{},parammap:{},responsemode:"data",datapath:"data",metapath:"meta",viewpath:"view.tbody",viewparam:"view",viewvalue:"rows",fieldsparam:"fields",cache:{enable:!0,ttl:3e4,max:30},export:{route:""}},pagination:{enabled:!1,page:1,per:10,max:100,position:"bottom",align:"right",ellipsis:!0,ellipsisHover:!0,threshold:5,visible:5,size:{enabled:!1,options:[10,25,50,100],label:"Строк на странице",suffix:"на страницу"},quick:{enabled:!1,label:"Перейти к странице",button:"Перейти"},persist:{page:!0,per:!0},storage:{key:""},scroll:!1,labels:{aria:"Пагинация",prev:"Назад",next:"Вперёд",ellipsisPrev:"Перейти к предыдущим страницам",ellipsisNext:"Перейти к следующим страницам"}}},$o="data-vg-table-filter-hidden";class Ho extends e.A{constructor(e,t={}){super(e,t);const i=Mo(e?.getAttribute?.("data-group-params"))||{},s=Lo(t.locale||i.locale||e?.getAttribute?.("data-locale")||No.locale),n=(0,r._v)({},i.i18n||{},t.i18n||{});this._dictionary=Io(s,n),this._params=this._getParams(e,(0,r._v)(No,this._dictionary,i,t,{locale:s,i18n:n})),this._params.locale=Lo(this._params.locale),this._normalizeSortDataOptions(),this._normalizeRequestDataOptions(),this._normalizePaginationDataOptions(),this._normalizeSearchDataOptions(),this._normalizeFiltersDataOptions(),this._normalizeStateDataOptions(),this._normalizeUrlStateDataOptions(),this._normalizeLoadingDataOptions(),this._normalizeExpandableDataOptions(),this._normalizeStickyHeaderDataOptions(),this._normalizeFixedColumnsDataOptions(),this._normalizeColumnsDataOptions(),this._normalizeRowReorderDataOptions(),this._sorting=null,this._panning=null,this._selection=null,this._expandable=null,this._pagination=null,this._filters=null,this._search=null,this._skeleton=null,this._states=null,this._urlState=null,this._applyingUrlState=!1,this._filtersState={filters:{},params:{},fields:[],meta:{count:0}},this._filterParamKeys=new Set,this._searchState={value:"",param:"q"},this._searchParamKey="",this._stickyHeader=null,this._fixedColumns=null,this._columns=null,this._rowReorder=null,this._remote=null,this._isRemote=Boolean(String(this._params.request.route||"").trim()),this._complex=!1,this._wrapper=null,this._ownsWrapper=!1,this._tableContainer=null,this._ownsTableContainer=!1,this._boundPaginationRefresh=this._refreshPagination.bind(this),this._boundLocalSortChange=this._handleLocalSortChange.bind(this),this._boundRemoteSortChange=this._handleRemoteSortChange.bind(this)}static get NAME(){return Do}static get NAME_KEY(){return To}static registerParamsGroup(e,t={}){return((e,t={})=>{const i=ko(e);return!(!i||!t||"object"!=typeof t||Array.isArray(t)||(Po.set(i,t),0))})(e,t)}static unregisterParamsGroup(e){return(e=>Po.delete(ko(e)))(e)}static getParamsGroup(e){return Mo(e)}init(){if(this._ensureWrapper(),this._ensureTableContainer(),this._syncComplexState(),this._stickyHeader||!0!==this._params.stickyHeader.enabled||(this._stickyHeader=new Ga(this._element,this._wrapper,this._tableContainer,this._params.stickyHeader),this._stickyHeader.init()),this._complex||this._columns||!this._hasColumnsFeatures()||(this._columns=new no(this._element,this._wrapper,{resize:this._params.columnResize,reorder:this._params.columnReorder,visibility:this._params.columnVisibility},{getHeaderTable:()=>this._stickyHeader?.getHeaderTable?.()||this._element,isFixed:e=>this._isFixedColumnField(e),refreshLayout:(e=!1)=>this._refreshColumnsLayout(e)}),this._columns.init()),this._complex||this._rowReorder||!0!==this._params.rowReorder.enabled||(this._rowReorder=new _o(this._element,this._wrapper,this._params.rowReorder,{refreshLayout:()=>this._refreshRowsLayout()}),this._rowReorder.init()),this._complex||this._sorting||!0!==this._params.sort.enabled||!0===this._params.rowReorder.enabled||(this._sorting=new ka(this._element,Object.assign({},this._params.sort,{remote:this._isRemote}),this._stickyHeader?.getHeaderTable()),this._sorting.init(),this._element.addEventListener("sortchange.vg.table",this._isRemote?this._boundRemoteSortChange:this._boundLocalSortChange)),this._complex||this._fixedColumns||!0!==this._params.fixedColumns.enabled||(this._fixedColumns=new Qa(this._element,this._wrapper,this._params.fixedColumns,this._stickyHeader),this._fixedColumns.init()),this._panning||!0!==this._params.pan.enabled||(this._panning=new Ma(this._element,{onMove:()=>{this._stickyHeader?.syncScroll?.(),this._fixedColumns?.syncScroll?.()}}),this._panning.init()),this._selection||!0!==this._params.selection.enabled||(this._selection=new za(this._element,this._params.selection),this._selection.init()),this._expandable||!0!==this._params.expandable.enabled||(this._expandable=new Ua(this._element,this._params.expandable),this._expandable.init()),this._pagination||!0!==this._params.pagination.enabled||(this._pagination=new Ha(this._element,Object.assign({},this._params.pagination,{remote:this._isRemote,onChange:e=>this._handlePaginationChange(e)})),this._pagination.init()),this._filters||!0!==this._params.filters.enabled||(this._filters=new mo(this._element,this._params.filters,e=>this._handleFiltersChange(e)),this._filters.init(),this._filtersState=this._filters.getState(),this._filterParamKeys=new Set(Object.keys(this._filtersState.params||{})),this._isRemote||this._applyLocalFilters(this._filtersState)),this._search||!0!==this._params.search.enabled||(this._search=new po(this._element,this._params.search,e=>this._handleSearchChange(e)),this._search.init(),this._searchState=this._search.getState(),this._searchParamKey=this._searchState.param,this._isRemote||this._applyLocalFilters(this._filtersState)),this._states||!0!==this._params.state.enabled||(this._states=new yo(this._element,this._wrapper,this._params.state,{remote:this._isRemote,getHeaderTable:()=>this._stickyHeader?.getHeaderTable()||this._element,reset:()=>this._resetQueryControls()}),this._states.init(),this._isRemote||this._states.syncLocal(this._hasActiveQuery())),this._urlState||!0!==this._params.urlState.enabled||(this._urlState=new Eo(this._element,this._params.urlState,{getFilterFields:()=>this._filters?.getFields?.()||[],apply:(e,t)=>this._applyUrlState(e,t)}),this._urlState.init(),!1!==this._params.urlState.read&&this._applyUrlState(this._urlState.read("init"),{source:"init",clearMissing:!1})),!this._remote&&this._isRemote){this._skeleton=new fo(this._element,this._params.loading,{getPagination:()=>this._pagination?.getState()||null,getHeaderTable:()=>this._stickyHeader?.getHeaderTable()||this._element,getScrollHost:()=>this._stickyHeader?.getBody()||this._tableContainer,afterRender:()=>{this._columns?.refresh?.(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}}),this._remote=new uo(this._element,Object.assign({},this._params.request,{labels:this._dictionary.remote||{}}),{request:e=>this._route(e),buildUrl:(e,t,i)=>this._buildRouteUrl(e,t,i),getPagination:()=>this._pagination?.getState()||{page:this._params.pagination.page,perPage:this._params.pagination.per},getSort:()=>this._sorting?.getSortState?.()||this._sorting?.getSort()||null,getHeaderTable:()=>this._stickyHeader?.getHeaderTable()||this._element,applyMeta:e=>this._pagination?.setMeta(e),afterRender:e=>this._afterRemoteRender(e),renderLoading:()=>this._skeleton?.render(),renderEmpty:()=>this._states?.render(this._hasActiveQuery()?"filtered-empty":"empty"),renderError:()=>this._states?.render("error"),getLoadingMinDelay:()=>this._params.loading.minDelay});const e=Object.assign({},this._filtersState.params||{});this._searchState.value&&(e[this._searchState.param]=this._searchState.value),Object.keys(e).length&&this._remote.setParams(e),this._remote.init()}return this}isRemote(){return this._isRemote}isComplex(){return this._complex}getLocale(){return this._params.locale}setLocale(e){const t=Lo(e);this._dictionary=Io(t,this._params.i18n||{}),this._params.locale=t,this._mergeLocale(this._params,this._dictionary),this._normalizePaginationDataOptions(),this._normalizeStateDataOptions(),this._normalizeExpandableDataOptions(),this._normalizeColumnsDataOptions(),this._normalizeRowReorderDataOptions(),this._remote&&(this._remote._options.labels=this._dictionary.remote||{}),this._pagination?.refresh?.(),this._expandable?.refresh?.(),this._columns?.refresh?.(),this._rowReorder?.refresh?.();const i=this._states?.getState?.();return i&&this._states.render(i.type),g.A.trigger(this._element,"localechange.vg.table",{locale:t}),t}_mergeLocale(e,t){return e&&t&&"object"==typeof t?(Object.entries(t).forEach(([t,i])=>{i&&"object"==typeof i&&!Array.isArray(i)?(e[t]&&"object"==typeof e[t]&&!Array.isArray(e[t])||(e[t]={}),this._mergeLocale(e[t],i)):e[t]=i}),e):e}_normalizeSortDataOptions(){const e=this._params.sort,t=e=>!["false","0","off","no"].includes(String(e).toLowerCase()),i=this._element.getAttribute("data-sort-multiple")??this._element.getAttribute("data-sort-multi"),s=this._element.getAttribute("data-sort-multiple-with-shift")??this._element.getAttribute("data-sort-multi-with-shift");null!==i&&(e.multiple=t(i)),null!==s&&(e.multipleWithShift=t(s))}_normalizeColumnsDataOptions(){const e=e=>!["false","0","off","no"].includes(String(e).toLowerCase()),t=(e,t,i)=>{const s=Number.parseInt(e,10);return Number.isFinite(s)&&s>=i?s:t};[["columnResize","column-resize"],["columnReorder","column-reorder"],["columnVisibility","column-visibility"]].forEach(([t,i])=>{const s=this._params[t];Object.prototype.hasOwnProperty.call(s,"enable")&&(s.enabled=e(s.enable));const r=this._element.getAttribute(`data-${i}-enable`)??this._element.getAttribute(`data-${i}-enabled`);null!==r&&(s.enabled=e(r));const n=this._element.getAttribute(`data-${i}-persist`);null!==n&&(s.persist=e(n));const a=this._element.getAttribute(`data-${i}-storage-key`);null!==a&&(s.storageKey=a)});const i=this._params.columnResize;i.minWidth=t(this._element.getAttribute("data-column-resize-min-width")??i.minWidth,80,40),i.maxWidth=t(this._element.getAttribute("data-column-resize-max-width")??i.maxWidth,600,i.minWidth),i.maxWidth=Math.max(i.minWidth,i.maxWidth);const s=this._params.columnVisibility,r=this._element.getAttribute("data-column-visibility-controls");null!==r&&(s.controls=r),s.minVisible=t(this._element.getAttribute("data-column-visibility-min-visible")??s.minVisible,1,1)}_normalizeRowReorderDataOptions(){const e=this._params.rowReorder,t=(e,t)=>{const i=this._element.getAttribute(`data-row-reorder-${e}`);null!==i&&t(i)},i=e=>["true","1","yes","on"].includes(String(e).toLowerCase());t("enable",t=>{e.enabled=i(t)}),t("enabled",t=>{e.enabled=i(t)}),t("mode",t=>{e.mode="row"===String(t).toLowerCase()?"row":"handle"}),t("handle-selector",t=>{e.handleSelector=String(t).trim()||e.handleSelector}),t("key-attr",t=>{e.keyAttr=String(t).trim()||e.keyAttr}),t("persist",t=>{e.persist=i(t)}),t("storage-key",t=>{e.storageKey=String(t).trim()})}_hasColumnsFeatures(){return!0===this._params.columnResize.enabled||!0===this._params.columnReorder.enabled||!0===this._params.columnVisibility.enabled}_normalizeRequestDataOptions(){this._params.request=(0,r._v)({},this._params.request,{headers:Object.assign({},this._params.request.headers),params:Object.assign({},this._params.request.params),parammap:Object.assign({},this._params.request.parammap),cache:Object.assign({},this._params.request.cache),export:Object.assign({},this._params.request.export)});const e=this._params.request,t=e=>this._element.getAttribute(`data-request-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=(e,t)=>{const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>0?i:t},n=(e,t)=>{try{const i=JSON.parse(e);return i&&"object"==typeof i&&!Array.isArray(i)?i:t}catch(e){return t}};i("route",t=>{e.route=t}),i("method",t=>{e.method=t}),i("credentials",t=>{e.credentials=t}),i("params",t=>{e.params=n(t,e.params)}),i("parammap",t=>{e.parammap=n(t,e.parammap)}),i("responsemode",t=>{e.responsemode=t}),i("datapath",t=>{e.datapath=t}),i("metapath",t=>{e.metapath=t}),i("viewpath",t=>{e.viewpath=t}),i("viewparam",t=>{e.viewparam=t}),i("viewvalue",t=>{e.viewvalue=t}),i("fieldsparam",t=>{e.fieldsparam=t}),i("cache-enable",t=>{e.cache.enable=(e=>!["false","0","off","no"].includes(String(e).toLowerCase()))(t)}),i("cache-ttl",t=>{e.cache.ttl=s(t,e.cache.ttl)}),i("cache-max",t=>{e.cache.max=s(t,e.cache.max)}),i("export-route",t=>{e.export.route=t}),e.route=String(e.route||"").trim(),e.method=String(e.method||"GET").toUpperCase(),e.credentials=String(e.credentials||"same-origin"),e.responsemode=["view","auto"].includes(String(e.responsemode).toLowerCase())?String(e.responsemode).toLowerCase():"data"}_syncComplexState(){const e=(this._isRemote?Array.from(this._element.tHead?.rows||[]):Array.from(this._element.rows||[])).some(e=>Array.from(e.cells||[]).some(e=>e.colSpan>1||e.rowSpan>1));this._complex=Boolean((this._element.tHead?.rows.length||0)>1||e),this._element.classList.toggle("vg-table-complex",this._complex),this._element.toggleAttribute("data-vg-table-complex",this._complex)}_normalizePaginationDataOptions(){this._params.pagination=(0,r._v)({},this._params.pagination,{size:Object.assign({},this._params.pagination.size),quick:Object.assign({},this._params.pagination.quick),persist:Object.assign({},this._params.pagination.persist),storage:Object.assign({},this._params.pagination.storage),labels:Object.assign({},this._params.pagination.labels)});const e=this._params.pagination,t=e=>this._element.getAttribute(`data-pagination-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase()),n=(e,t)=>{const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>0?i:t};i("enable",t=>{e.enabled=s(t)}),i("enabled",t=>{e.enabled=s(t)}),i("per-page",t=>{e.per=n(t,e.per)}),i("max-per-page",t=>{e.max=n(t,e.max)}),i("ellipsis",t=>{e.ellipsis=s(t)}),i("ellipsis-hover",t=>{e.ellipsisHover=s(t)}),i("ellipsis-after",t=>{e.threshold=n(t,e.threshold)}),i("max-visible-pages",t=>{e.visible=n(t,e.visible)}),i("show-per-page",t=>{e.size.enabled=s(t)}),i("show-per-page-label",t=>{e.size.label=!!s(t)&&"Строк на странице"}),i("per-page-label",t=>{e.size.label=t}),i("per-page-option-suffix",t=>{e.size.suffix=t}),i("per-page-options",t=>{e.size.options=(e=>String(e).replace(/^\[|\]$/g,"").split(",").map(e=>n(e.trim(),0)).filter(e=>e>0))(t)}),i("quick-jump",t=>{e.quick.enabled="auto"===t?"auto":s(t)}),i("quick-jump-button-label",t=>{e.quick.button=t}),i("persist-page",t=>{e.persist.page=s(t)}),i("persist-per-page",t=>{e.persist.per=s(t)}),i("storage-key",t=>{e.storage.key=t}),i("scroll-to-top",t=>{e.scroll=!!s(t)&&"table"}),i("scroll-to-window-top",t=>{s(t)&&(e.scroll="window")}),i("prev-label",t=>{e.labels.prev=t}),i("next-label",t=>{e.labels.next=t})}_normalizeSearchDataOptions(){this._params.search=(0,r._v)({},this._params.search,{button:Object.assign({},this._params.search.button)});const e=this._params.search,t=e=>this._element.getAttribute(`data-search-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase()),n=(e,t)=>{const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>=0?i:t},a=e=>{if(Array.isArray(e))return e.map(e=>String(e).trim()).filter(Boolean);try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(e=>String(e).trim()).filter(Boolean)}catch(e){}return String(e||"").split(",").map(e=>e.trim()).filter(Boolean)};Object.prototype.hasOwnProperty.call(e,"enable")&&(e.enabled=s(e.enable)),i("enable",t=>{e.enabled=s(t)}),i("enabled",t=>{e.enabled=s(t)}),i("input",t=>{e.input=t}),i("input-selector",t=>{e.input=t}),i("param",t=>{e.param=t}),i("debounce",t=>{e.debounce=n(t,e.debounce)}),i("debounce-ms",t=>{e.debounce=n(t,e.debounce)}),i("reset-page",t=>{e.resetPage=s(t)}),i("reset-page-on-change",t=>{e.resetPage=s(t)}),i("trim",t=>{e.trim=s(t)}),i("fields",t=>{e.fields=a(t)}),i("button-reset",t=>{e.button.reset=t}),e.fields=a(e.fields),e.param=String(e.param||"q").trim()||"q"}_normalizeFiltersDataOptions(){this._params.filters=(0,r._v)({},this._params.filters,{buttons:Object.assign({},this._params.filters.buttons)});const e=this._params.filters,t=e=>this._element.getAttribute(`data-filters-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase()),n=(e,t)=>{const i=Number.parseInt(e,10);return Number.isFinite(i)&&i>=0?i:t};Object.prototype.hasOwnProperty.call(e,"enable")&&(e.enabled=s(e.enable)),i("enable",t=>{e.enabled=s(t)}),i("enabled",t=>{e.enabled=s(t)}),i("form",t=>{e.form=t}),i("form-selector",t=>{e.form=t}),i("debounce",t=>{e.debounce=n(t,e.debounce)}),i("debounce-ms",t=>{e.debounce=n(t,e.debounce)}),i("apply",t=>{e.apply=t}),i("apply-mode",t=>{e.apply=t}),i("reset-page",t=>{e.resetPage=s(t)}),i("reset-page-on-change",t=>{e.resetPage=s(t)}),i("skip-empty",t=>{e.skipEmpty=s(t)}),i("trim",t=>{e.trim=s(t)}),i("trim-values",t=>{e.trim=s(t)}),i("default-operator",t=>{e.defaultOperator=t}),i("field-attr",t=>{e.fieldAttr=t}),i("part-attr",t=>{e.partAttr=t}),i("type-attr",t=>{e.typeAttr=t}),i("value-attr",t=>{e.valueAttr=t}),i("operator-attr",t=>{e.operatorAttr=t}),i("button-apply",t=>{e.buttons.apply=t}),i("button-reset",t=>{e.buttons.reset=t}),e.apply="manual"===String(e.apply).toLowerCase()?"manual":"auto"}_normalizeStateDataOptions(){this._params.state=(0,r._v)({},this._params.state,{labels:Object.assign({},this._params.state.labels)});const e=this._params.state,t=e=>this._element.getAttribute(`data-state-${e}`),i=t("enable")??t("enabled");null!==i&&(e.enabled=!["false","0","off","no"].includes(String(i).toLowerCase())),["empty","filtered-empty","error","retry","reset"].forEach(i=>{const s=t(`${i}-label`);null!==s&&(e.labels[i]=s)})}_normalizeUrlStateDataOptions(){this._params.urlState=(0,r._v)({},this._params.urlState,{keys:Object.assign({},this._params.urlState.keys),include:Object.assign({},this._params.urlState.include)});const e=this._params.urlState,t=e=>this._element.getAttribute(`data-url-state-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase());Object.prototype.hasOwnProperty.call(e,"enable")&&(e.enabled=s(e.enable)),i("enable",t=>{e.enabled=s(t)}),i("enabled",t=>{e.enabled=s(t)}),i("read",t=>{e.read=s(t)}),i("write",t=>{e.write=s(t)}),i("listen",t=>{e.listen=s(t)}),i("mode",t=>{e.mode=t}),i("prefix",t=>{e.prefix=t}),i("page-key",t=>{e.keys.page=t}),i("per-page-key",t=>{e.keys.perPage=t}),i("sort-key",t=>{e.keys.sort=t}),i("direction-key",t=>{e.keys.direction=t}),i("search-key",t=>{e.keys.search=t}),i("filter-prefix",t=>{e.keys.filterPrefix=t}),i("include-pagination",t=>{e.include.pagination=s(t)}),i("include-sort",t=>{e.include.sort=s(t)}),i("include-search",t=>{e.include.search=s(t)}),i("include-filters",t=>{e.include.filters=s(t)}),e.mode="push"===String(e.mode).toLowerCase()?"push":"replace"}_normalizeLoadingDataOptions(){const e=this._params.loading,t=e=>this._element.getAttribute(`data-loading-${e}`),i=(e,t,i=0)=>{const s=Number.parseInt(e,10);return Number.isFinite(s)&&s>=i?s:t},s=t("enable")??t("enabled");null!==s&&(e.enabled=!["false","0","off","no"].includes(String(s).toLowerCase()));const r=t("min-delay");null!==r&&(e.minDelay=i(r,e.minDelay));const n=t("skeleton")??t("skeleton-rows");null!==n&&(e.skeleton=i(n,e.skeleton,1))}_normalizeExpandableDataOptions(){const e=this._params.expandable;e.labels=Object.assign({},e.labels);const t=e=>this._element.getAttribute(`data-expandable-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase());Object.prototype.hasOwnProperty.call(e,"enable")&&(e.enabled=s(e.enable)),i("enable",t=>{e.enabled=s(t)}),i("enabled",t=>{e.enabled=s(t)}),i("id-attr",t=>{e.idAttr=t}),i("parent-attr",t=>{e.parentAttr=t}),i("toggle-selector",t=>{e.toggleSelector=t}),i("collapsed",t=>{e.collapsed=s(t)}),i("expand-label",t=>{e.labels.expand=t}),i("collapse-label",t=>{e.labels.collapse=t})}_normalizeStickyHeaderDataOptions(){this._params.stickyHeader=Object.assign({},this._params.stickyHeader);const e=this._params.stickyHeader,t=e=>this._element.getAttribute(`data-sticky-header-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase());Object.prototype.hasOwnProperty.call(e,"enable")&&(e.enabled=s(e.enable)),Object.prototype.hasOwnProperty.call(e,"max")&&(e.maxHeight=e.max),i("enable",t=>{e.enabled=s(t)}),i("enabled",t=>{e.enabled=s(t)}),i("mode",t=>{e.mode=t}),i("top",t=>{e.top=t}),i("top-offset",t=>{e.top=t}),i("max",t=>{e.maxHeight=t}),i("max-height",t=>{e.maxHeight=t}),e.mode="page"===String(e.mode).toLowerCase()?"page":"container"}_normalizeFixedColumnsDataOptions(){this._params.fixedColumns=Object.assign({},this._params.fixedColumns);const e=this._params.fixedColumns,t=e=>this._element.getAttribute(`data-fixed-columns-${e}`),i=(e,i)=>{const s=t(e);null!==s&&i(s)},s=e=>!["false","0","off","no"].includes(String(e).toLowerCase()),r=(e,t)=>{const i=Number.parseFloat(e);return Number.isFinite(i)&&i>=0?i:t};let n=null;Object.prototype.hasOwnProperty.call(e,"enable")&&(e.enabled=s(e.enable));const a=this._element.getAttribute("data-fixed-columns");null!==a&&(e.columns=a),i("enable",t=>{n=s(t),e.enabled=n}),i("enabled",t=>{n=s(t),e.enabled=n}),i("mode",t=>{e.mode=t}),i("stack-gap",t=>{e.stackGap=r(t,e.stackGap)}),e.mode="stack"===String(e.mode).toLowerCase()?"stack":"fixed",e.stackGap=r(e.stackGap,0);const o=Boolean(this._element.tHead?.querySelector("[data-fixed], [data-fixed-column]"));null===n&&(null!==a||o||e.columns&&"object"==typeof e.columns)&&(e.enabled=!0)}_ensureWrapper(){const e=this._element.closest(Oo);if(e)return void(this._wrapper=e);const t=this._element.ownerDocument.createElement("div");t.className=Oo.slice(1),t.setAttribute("data-vg-table-generated-wrapper",""),this._element.before(t),t.append(this._element),this._wrapper=t,this._ownsWrapper=!0}_removeGeneratedWrapper(){this._ownsWrapper&&this._wrapper&&(this._element.parentElement===this._wrapper&&this._wrapper.before(this._element),this._wrapper.children.length||this._wrapper.remove(),this._wrapper=null,this._ownsWrapper=!1)}_ensureTableContainer(){const e=this._element.closest(zo);if(e&&e.closest(Oo)===this._wrapper)return void(this._tableContainer=e);const t=this._element.ownerDocument.createElement("div");t.className=zo.slice(1),t.setAttribute("data-vg-table-generated-container",""),this._element.before(t),t.append(this._element),this._tableContainer=t,this._ownsTableContainer=!0}_removeGeneratedTableContainer(){this._ownsTableContainer&&this._tableContainer&&(this._element.parentElement===this._tableContainer&&this._tableContainer.before(this._element),this._tableContainer.children.length||this._tableContainer.remove(),this._tableContainer=null,this._ownsTableContainer=!1)}setSort(e,t="asc"){const i=!!this._sorting&&this._sorting.setSort(e,t);return i&&(this._refreshPagination(),this._syncUrlState()),i}setSorts(e=[]){const t=!!this._sorting&&this._sorting.setSorts(e);return t&&(this._refreshPagination(),this._syncUrlState()),t}getSort(){return this._sorting?this._sorting.getSort():null}getSorts(){return this._sorting?this._sorting.getSorts():[]}clearSort(){this._sorting&&(this._sorting.clearSort(),this._refreshPagination(),this._syncUrlState())}selectRow(e,t=!0,i=!0){return!!this._selection&&this._selection.selectRow(e,t,i)}toggleRow(e,t=!0){return!!this._selection&&this._selection.toggleRow(e,t)}getSelectedRows(){return this._selection?this._selection.getSelectedRows():[]}clearSelection(e=!0){return!!this._selection&&this._selection.clearSelection(e)}toggleExpanded(e,t=null,i=!1){return!!this._expandable&&this._expandable.toggle(e,t,i)}expandRow(e,t=!1){return!!this._expandable&&this._expandable.expand(e,t)}collapseRow(e,t=!1){return!!this._expandable&&this._expandable.collapse(e,t)}getExpandable(){return this._expandable?this._expandable.getState():null}refreshExpandable(){return this._expandable?this._expandable.refresh():null}setPage(e,t=!1){return!!this._pagination&&this._pagination.setPage(e,t)}setPerPage(e,t=!1){return!!this._pagination&&this._pagination.setPerPage(e,t)}getPagination(){return this._pagination?this._pagination.getState():null}refreshPagination(e=!1){return this._pagination?this._pagination.refresh(e):null}getFilters(){return this._filters?this._filters.getState():null}setFilters(e={},t=!0){return this._filters?this._filters.setValues(e,{emit:t,source:"api"}):null}resetFilters(e=!0){return this._filters?this._filters.reset({emit:e,source:"api-reset"}):null}refreshFilters(){return this._filters?this._filters.refresh():null}getSearch(){return this._search?this._search.getState():null}setSearch(e,t=!0){return this._search?this._search.setValue(e,{emit:t,source:"api"}):null}resetSearch(e=!0){return this._search?this._search.reset({emit:e,source:"api-reset"}):null}refreshSearch(){return this._search?this._search.refresh():null}getTableState(){return this._states?.getState()||null}showTableState(e,t=""){return this._states?.render(e,t)||null}clearTableState(){return this._states?.clear()||null}getUrlState(){return this._urlState?.getState()||null}refreshUrlState(){return this._urlState?this._applyUrlState(this._urlState.read("api"),{source:"api",clearMissing:!0}):null}reload(e={}){return this._remote?this._remote.reload(e):Promise.resolve(null)}setRequestParams(e={},t=!0,i=!1){if(!this._remote)return null;const s=this._remote.setParams(e,i);return t&&this._remote.reload({page:1,source:"params"}),s}getRequestState(){return this._remote?this._remote.getState():null}clearRequestCache(){this._remote?.clearCache()}exportRemote(e="csv",t={}){return this._remote?this._remote.export(e,t):""}refreshStickyHeader(){return this._stickyHeader?this._stickyHeader.refresh():null}refreshFixedColumns(){return this._fixedColumns?this._fixedColumns.refresh():null}getFixedColumns(){return this._fixedColumns?this._fixedColumns.getState():null}getColumns(){return this._columns?this._columns.getState():null}setColumnWidth(e,t,i=!0){return!!this._columns&&this._columns.setWidth(e,t,i)}moveColumn(e,t,i=!0){return!!this._columns&&this._columns.move(e,t,i)}setColumnVisible(e,t=!0,i=!0){return!!this._columns&&this._columns.setVisible(e,t,i)}resetColumns(e=!0){return this._columns?this._columns.reset(e):null}refreshColumns(){const e=this._columns?.refresh?.()||null;return this._refreshColumnsLayout(!0),e}getRowOrder(){return this._rowReorder?this._rowReorder.getState().order:[]}moveRow(e,t,i="before",s=!0){return!!this._rowReorder&&this._rowReorder.move(e,t,i,s)}resetRows(e=!0){return this._rowReorder?this._rowReorder.reset(e):null}refreshRowReorder(){return this._rowReorder?this._rowReorder.refresh():null}_refreshPagination(){this._pagination&&this._pagination.refresh(),this._expandable&&this._expandable.refresh()}_isFixedColumnField(e){const t=String(e||"").trim();if(!t)return!1;const i=this._stickyHeader?.getHeaderTable?.()||this._element,s=Array.from(i.tHead?.querySelectorAll("th")||[]).find(e=>String(e.getAttribute("data-field")||"").trim()===t);if(["left","right"].includes(String(s?.getAttribute("data-fixed")||s?.getAttribute("data-fixed-column")||"").toLowerCase()))return!0;const r=this._params.fixedColumns.columns;return r&&"object"==typeof r&&!Array.isArray(r)?["left","right"].some(e=>(Array.isArray(r[e])?r[e]:String(r[e]||"").split(",")).map(e=>String(e).trim()).includes(t)):String(r||"").split(";").some(e=>{const[,i=""]=e.split(":");return i.split(",").map(e=>e.trim()).includes(t)})}_refreshColumnsLayout(e=!1){this._sorting?.refresh?.(e),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}_refreshRowsLayout(){this._pagination?.refresh?.(!1),this._expandable?.refresh?.(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}_handleFiltersChange(e){this._filtersState=e&&"object"==typeof e?e:{filters:{},params:{},fields:[],meta:{count:0}};const t=["reset","api-reset"].includes(String(this._filtersState.source||""));if(t&&this._search&&(this._search.reset({emit:!1,source:"filters-reset"}),this._searchState=this._search.getState()),!this._isRemote)return this._applyLocalFilters(this._filtersState),void this._syncUrlState();const i=this._filtersState.params||{},s={};this._filterParamKeys.forEach(e=>{s[e]=""}),t&&this._searchParamKey&&(s[this._searchParamKey]=""),Object.assign(s,i),this._filterParamKeys=new Set(Object.keys(i)),this._remote?.setParams(s),this._syncUrlState();const r=this._pagination?.getState();!1!==this._params.filters.resetPage&&r?.page>1?this._pagination.setPage(1,!1,"filters"):this._remote?.load({source:"filters"})}_handleSearchChange(e){if(this._searchState=e&&"object"==typeof e?e:{value:"",param:"q"},!this._isRemote)return this._applyLocalFilters(this._filtersState,!1!==this._params.search.resetPage),void this._syncUrlState();const t=String(this._searchState.param||"q").trim()||"q",i={};this._searchParamKey&&(i[this._searchParamKey]=""),this._searchState.value&&(i[t]=this._searchState.value),this._searchParamKey=t,this._remote?.setParams(i),this._syncUrlState();const s=this._pagination?.getState();!1!==this._params.search.resetPage&&s?.page>1?this._pagination.setPage(1,!1,"search"):this._remote?.load({source:"search"})}_applyLocalFilters(e,t=!1!==this._params.filters.resetPage){const i=e?.filters&&"object"==typeof e.filters?e.filters:{},s=this._stickyHeader?.getHeaderTable?.()||this._element,r=Array.from(s.tHead?.rows||[]),n=r.length?Array.from(r.at(-1).cells||[]):[],a=new Map(n.map((e,t)=>[String(e.getAttribute("data-field")||"").trim(),t]));Array.from(this._element.tBodies||[]).flatMap(e=>Array.from(e.rows||[])).filter(e=>!e.hasAttribute("data-vg-table-state-row")).forEach(e=>{const t=Object.entries(i).every(([t,i])=>{const s=String(i?.field||t||"").trim(),r=a.has(s)?a.get(s):-1;if(r<0||!e.cells[r])return!0;const n=e.cells[r],o=n.getAttribute("data-filter-value")??n.textContent??"";return this._matchesFilterValue(o,i||{})})&&this._matchesSearchRow(e,n);e.toggleAttribute($o,!t),t?this._pagination||(e.hidden="true"===e.getAttribute("data-vg-table-expand-hidden")):e.hidden=!0}),this._pagination&&this._pagination.refresh(t),this._expandable?.refresh(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.(),this._states?.syncLocal(this._hasActiveQuery())}_matchesSearchRow(e,t){const i=String(this._searchState?.value||"").toLocaleLowerCase();if(!i)return!0;const s=new Set((this._params.search.fields||[]).map(e=>String(e).trim())),r=t.reduce((e,t,i)=>{const r=String(t.getAttribute("data-field")||"").trim();return"false"===t.getAttribute("data-search-enabled")||s.size&&!s.has(r)||e.push(i),e},[]),n=e.getAttribute("data-search-value"),a=null!==n?n:r.map(t=>{const i=e.cells[t];return i?.getAttribute("data-search-value")??i?.textContent??""}).join(" ");return String(a).toLocaleLowerCase().includes(i)}_matchesFilterValue(e,t){const i=Array.isArray(t.values)&&t.values.length?t.values:t.value,s=String(t.operator||t.type||"eq").toLowerCase().trim(),r=String(e??"").trim();if("empty"===s)return""===r;if("notempty"===s)return""!==r;if(Array.isArray(i)){const e=i.map(e=>String(e??"").toLocaleLowerCase().trim()).filter(Boolean).includes(r.toLocaleLowerCase());return"notin"===s?!e:e}const n=String(i??"").trim();if(!n)return!0;const a=r.toLocaleLowerCase(),o=n.toLocaleLowerCase();if("contains"===s)return a.includes(o);if("starts"===s)return a.startsWith(o);if("ends"===s)return a.endsWith(o);const l=Number.parseFloat(r.replace(",",".")),h=Number.parseFloat(n.replace(",",".")),d=Number.isFinite(l)&&Number.isFinite(h),c="date"===t.type?Date.parse(r):NaN,_="date"===t.type?Date.parse(n):NaN,u=Number.isFinite(c)&&Number.isFinite(_)?c:l,m=Number.isFinite(c)&&Number.isFinite(_)?_:h,p=d||Number.isFinite(c)&&Number.isFinite(_);return"neq"===s?p?u!==m:a!==o:"gt"===s&&p?u>m:"gte"===s&&p?u>=m:"lt"===s&&p?u<m:"lte"===s&&p?u<=m:p?u===m:a===o}_clearLocalFilters(){Array.from(this._element.tBodies||[]).flatMap(e=>Array.from(e.rows||[])).forEach(e=>{e.removeAttribute($o),e.hidden="true"===e.getAttribute("data-vg-table-expand-hidden")||"hidden"===e.getAttribute("data-vg-table-page-row")})}_handlePaginationChange(e){this._applyingUrlState||(this._syncUrlState(),this._isRemote?this._remote?.load({page:e.page,perPage:e.perPage,source:e.source}):this._states?.syncLocal(this._hasActiveQuery()))}_handleLocalSortChange(){this._refreshPagination(),this._syncUrlState()}_hasActiveQuery(){return Boolean(this._searchState?.value||Object.keys(this._filtersState?.filters||{}).length)}_collectUrlState(){const e=this._pagination?.getState()||{};return{page:e.page||1,perPage:e.perPage||this._params.pagination.per,sort:this._sorting?.getSortState?.()||this._sorting?.getSort()||null,search:this._searchState?.value||"",filters:Object.assign({},this._filtersState?.params||{})}}_syncUrlState(){return this._applyingUrlState||!this._urlState?null:this._urlState.write(this._collectUrlState())}_applyUrlState(e={},t={}){if(!e||"object"!=typeof e)return null;const i=!0===t.clearMissing,s=e.present||{},r=new Set(this._filterParamKeys),n=this._searchParamKey;this._applyingUrlState=!0;try{if(this._filters&&(i||s.filters)&&(this._filters.setValues(e.filters||{},{emit:!1}),this._filtersState=this._filters.getState(),this._filterParamKeys=new Set(Object.keys(this._filtersState.params||{}))),this._search&&(i||s.search)&&(this._search.setValue(e.search||"",{emit:!1}),this._searchState=this._search.getState(),this._searchParamKey=this._searchState.param),this._sorting&&(i||s.sort)&&(e.sort?.sorts?.length?this._sorting.setSorts(e.sort.sorts,!1):e.sort?.field?this._sorting.setSort(e.sort.field,e.sort.direction,!1):this._sorting.clearSort(!1)),this._pagination){const t=this._pagination.getState(),r=s.perPage?e.perPage:i?this._params.pagination.per:t.perPage,n=s.page?e.page:i?this._params.pagination.page:t.page;this._isRemote?this._pagination.setMeta({page:n||1,per_page:r||t.perPage,total:t.totalRows,pages:Math.max(1,n||1)}):(r&&this._pagination.setPerPage(r,!1,"urlstate"),n&&this._pagination.setPage(n,!1,"urlstate"))}if(this._isRemote||this._applyLocalFilters(this._filtersState,!1),this._remote){const e={};r.forEach(t=>{e[t]=""}),n&&(e[n]=""),Object.assign(e,this._filtersState.params||{}),this._searchState.value&&(e[this._searchState.param]=this._searchState.value),this._remote.setParams(e)}}finally{this._applyingUrlState=!1}if(this._remote&&"init"!==t.source){const e=this._pagination?.getState()||{};this._remote.load({page:e.page,perPage:e.perPage,source:t.source||"urlstate"})}return this._collectUrlState()}_resetQueryControls(){this._applyingUrlState=!0;try{this._filters?.reset({emit:!1}),this._search?.reset({emit:!1}),this._filtersState=this._filters?.getState()||{filters:{},params:{},fields:[],meta:{count:0}},this._searchState=this._search?.getState()||{value:"",param:this._searchParamKey||"q"};const e={};this._filterParamKeys.forEach(t=>{e[t]=""}),this._searchParamKey&&(e[this._searchParamKey]=""),this._filterParamKeys=new Set,this._remote?.setParams(e),this._pagination?.getState().page>1&&this._pagination.setPage(1,!1,"state-reset"),this._isRemote||this._applyLocalFilters(this._filtersState,!0)}finally{this._applyingUrlState=!1}this._syncUrlState(),this._remote&&this._remote.load({page:1,source:"state-reset"})}_handleRemoteSortChange(){if(!this._remote)return;this._syncUrlState();const e=this._pagination?.getState();e&&1!==e.page?this._pagination.setPage(1,!1,"sort"):this._remote.reload({page:1,source:"sort"})}_afterRemoteRender(e={}){e.renderedCount>0&&this._states?.clear(),this._columns?.refresh?.(),this._sorting?.refresh?.(),this._expandable?.refresh?.(),this._rowReorder?.refresh?.(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}dispose(){this._remote&&this._remote.dispose(),this._skeleton&&this._skeleton.dispose(),this._urlState&&this._urlState.dispose(),this._states&&this._states.dispose(),this._search&&this._search.dispose(),this._filters&&this._filters.dispose(),this._clearLocalFilters(),this._fixedColumns&&this._fixedColumns.dispose(),this._sorting&&this._sorting.dispose(),this._columns&&this._columns.dispose(),this._stickyHeader&&this._stickyHeader.dispose(),this._panning&&this._panning.dispose(),this._selection&&this._selection.dispose(),this._rowReorder&&this._rowReorder.dispose(),this._expandable&&this._expandable.dispose(),this._element.removeEventListener("sortchange.vg.table",this._boundPaginationRefresh),this._element.removeEventListener("sortchange.vg.table",this._boundLocalSortChange),this._element.removeEventListener("sortchange.vg.table",this._boundRemoteSortChange),this._pagination&&this._pagination.dispose(),this._element.classList.remove("vg-table-complex"),this._element.removeAttribute("data-vg-table-complex"),this._removeGeneratedTableContainer(),this._removeGeneratedWrapper(),super.dispose()}}g.A.on(document,"DOMContentLoaded",()=>{s.A.findAll("[data-vg-table]").forEach(e=>{Ho.getOrCreateInstance(e).init()})});const Fo=Ho,Ro="vg.tooltip",Bo='[data-vg-toggle="tooltip"]',jo='[data-vg-toggle="popover"]',Uo="vg-tooltip-open",qo="show",Vo="shown",Wo=`${Bo}.${qo}, ${jo}.${qo}`,Ko=`${Ro}.hide`,Go=`${Ro}.hidden`,Yo=`${Ro}.show`,Xo=`${Ro}.shown`,Zo=`click.${Ro}.data.api`,Jo=`mouseenter.${Ro}`,Qo=`mouseleave.${Ro}`,el=`click.dismiss.${Ro}`,tl=`keydown.dismiss.${Ro}`,il=["top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start","right-end"],sl={title:"",content:"",trigger:"hover",placement:"top",container:"body",popover:!1,html:!1,offset:[8,8],autoFlip:!0,overflowProtection:!0,fallbackPlacements:["bottom","right","left"],closeOnOutsideClick:!0,keyboard:!0,closeOther:!0,delay:{show:100,hide:100},arrow:{padding:8},custom:{class:""},animation:{enable:!0,in:"animate__backInUp",out:"animate__backOutDown",delay:300,effect:"none"}};class rl extends e.A{constructor(e,t={}){super(e,t),this._params=this._getParams(e,(0,r._v)(sl,t)),this._tooltip=null,this._isHiding=!1,this._showTimeout=null,this._hideTimeout=null,this._triggerObserver=null,this._fixTitle(),this._handleUpdate=()=>{this._element?.isConnected?this._isShown()&&this._setPlacement():this.dispose()}}static get NAME(){return"tooltip"}static get NAME_KEY(){return Ro}toggle(e){return this._isShown()?this.hide():this.show(e)}show(e){(0,r.d6)(this._element)||this._isShown()||(this._clearTimeouts(),this._showTimeout=setTimeout(()=>{this._showTimeout=null,this._element?.isConnected?g.A.trigger(this._element,Yo,{relatedTarget:e}).defaultPrevented||(this._params.closeOther&&this._hideOpenedTooltips(),this._isHiding=!1,this._createTooltip(),this._tooltip&&(this._tooltip.classList.remove(Vo),this._tooltip.classList.add(qo),this._element.classList.add(qo),document.body.classList.add(Uo),this._addWindowListeners(),this._observeTrigger(),requestAnimationFrame(()=>{this._tooltip&&(this._setPlacement(),this._queueCallback(()=>{this._tooltip&&!this._isHiding&&(this._tooltip.classList.add(Vo),g.A.trigger(this._element,Xo,{relatedTarget:e}))},this._tooltip,!0,this._params.animation.delay))}))):this.dispose()},this._params.delay.show))}hide(){this._clearTimeouts(),this._isShown()&&!this._isHiding&&this._tooltip&&(this._disconnectTriggerObserver(),this._hideTimeout=setTimeout(()=>{this._hideTimeout=null,g.A.trigger(this._element,Ko).defaultPrevented?this._observeTrigger():(this._removeWindowListeners(),this._isHiding=!0,this._tooltip.classList.remove(Vo),this._queueCallback(()=>{this._tooltip&&(this._tooltip.classList.remove(qo),this._element.classList.remove(qo),this._element.removeAttribute("aria-describedby"),this._tooltip.remove(),this._tooltip=null,this._isHiding=!1,s.A.find(".vg-tooltip.show")||document.body.classList.remove(Uo),g.A.trigger(this._element,Go))},this._tooltip,!1,this._params.animation.delay))},this._params.delay.hide))}dispose(){this._clearTimeouts(),this._removeWindowListeners(),this._disconnectTriggerObserver(),this._tooltip&&(this._tooltip.remove(),this._tooltip=null),this._element&&(this._element.classList.remove(qo,Vo),this._element.removeAttribute("aria-describedby"),Object.prototype.hasOwnProperty.call(this._element.dataset,"vgOriginalTitle")&&(this._element.setAttribute("title",this._element.dataset.vgOriginalTitle),this._element.removeAttribute("data-vg-original-title"))),s.A.find(".vg-tooltip.show")||document.body.classList.remove(Uo),super.dispose()}_isShown(){return!!this._element&&this._element.classList.contains(qo)}_createTooltip(){if(this._tooltip)return;const e=this._getTitle();if(!e)return;const t=`vg-tooltip-${(0,r.PR)()}`,i=document.createElement("div");i.id=t,i.className=`vg-tooltip ${this._params.placement} ${this._params.custom.class||""}`,i.setAttribute("role",this._params.popover?"dialog":"tooltip"),this._params.popover&&i.classList.add("vg-tooltip-popover");const n=document.createElement("div");if(n.classList.add("vg-tooltip-inner"),this._params.content){const t=document.createElement("div");t.classList.add("vg-tooltip-inner--title");const i=document.createElement("div");i.classList.add("vg-tooltip-inner--content"),this._params.html?(t.innerHTML=e,i.innerHTML=this._params.content):(t.textContent=e,i.textContent=this._params.content),n.append(t),n.append(i)}else this._params.html?n.innerHTML=e:n.textContent=e;const a=document.createElement("div");a.classList.add("vg-tooltip-arrow"),n.append(a),i.append(n);const o="body"===this._params.container?document.body:s.A.find(this._params.container);o&&(o.append(i),this._element.setAttribute("aria-describedby",t),this._tooltip=i,this._animation(this._tooltip,rl.NAME_KEY,this._params.animation))}_getTitle(){return this._params.title||this._element.dataset.vgTitle||this._element.dataset.vgOriginalTitle||""}_fixTitle(){const e=this._element.getAttribute("title");null!==e&&(this._element.setAttribute("data-vg-original-title",e),this._element.removeAttribute("title"))}_setPlacement(){this._tooltip&&(new de({reference:this._element,drop:this._tooltip,placement:this._params.placement,offset:this._params.offset,autoFlip:this._params.autoFlip,overflowProtection:this._params.overflowProtection,fallbackPlacements:this._params.fallbackPlacements,clamp:!0,isMerge:!1})._setPlacement(),this._syncPlacementClass(),this._setArrowPlacement())}_setArrowPlacement(){if(!this._tooltip)return;const e=this._tooltip.querySelector(".vg-tooltip-inner"),t=this._tooltip.querySelector(".vg-tooltip-arrow");if(!e||!t)return;const i=this._tooltip.getAttribute("data-vg-placement")||this._params.placement,s=this._element.getBoundingClientRect(),r=e.getBoundingClientRect(),n=s.left+s.width/2,a=s.top+s.height/2,o=this._params.arrow.padding;if(t.style.left="",t.style.right="",t.style.top="",t.style.bottom="",i.startsWith("top")||i.startsWith("bottom")){let e=n-r.left;e=Math.max(o,Math.min(e,r.width-o)),t.style.left=`${e}px`,t.style.transform="translateX(-50%) rotate(45deg)",i.startsWith("top")?t.style.bottom="-4px":t.style.top="-4px"}if(i.startsWith("left")||i.startsWith("right")){let e=a-r.top;e=Math.max(o,Math.min(e,r.height-o)),t.style.top=`${e}px`,t.style.transform="translateY(-50%) rotate(45deg)",i.startsWith("left")?t.style.right="-4px":t.style.left="-4px"}}_syncPlacementClass(){if(!this._tooltip)return;const e=this._tooltip.getAttribute("data-vg-placement");this._tooltip.classList.remove(...il),e&&this._tooltip.classList.add(e)}_hideOpenedTooltips(){s.A.findAll(".vg-tooltip.show").forEach(e=>{const t=e.id,i=s.A.find(`[aria-describedby="${t}"]`);if(!i)return void e.remove();if(i===this._element)return;const r=rl.getInstance(i);r?.hide()}),s.A.find(".vg-tooltip.show")||document.body.classList.remove(Uo)}_observeTrigger(){!this._triggerObserver&&this._element?.isConnected&&(this._triggerObserver=new MutationObserver(()=>{this._element?.isConnected||this.dispose()}),this._triggerObserver.observe(document.body,{childList:!0,subtree:!0}))}_disconnectTriggerObserver(){this._triggerObserver&&(this._triggerObserver.disconnect(),this._triggerObserver=null)}_addWindowListeners(){window.addEventListener("resize",this._handleUpdate),window.addEventListener("scroll",this._handleUpdate,!0)}_removeWindowListeners(){window.removeEventListener("resize",this._handleUpdate),window.removeEventListener("scroll",this._handleUpdate,!0)}_clearTimeouts(){this._showTimeout&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}}const nl=()=>s.A.findAll(Wo).map(e=>rl.getInstance(e)).filter(Boolean);g.A.on(document,tl,e=>{"Escape"===e.key&&nl().forEach(e=>{e._params.keyboard&&e._isShown()&&e.hide()})}),g.A.on(document,el,e=>{nl().forEach(t=>{t._params.closeOnOutsideClick&&(t._params.trigger.includes("click")||t._params.popover)&&t._isShown()&&(t._tooltip?.contains(e.target)||t._element.contains(e.target)||t.hide())})}),g.A.on(document,Jo,Bo,function(){const e=rl.getOrCreateInstance(this);e._params.trigger.includes("hover")&&e.show(this)}),g.A.on(document,Qo,Bo,function(){const e=rl.getOrCreateInstance(this);e._params.trigger.includes("hover")&&e.hide()}),g.A.on(document,Zo,Bo,function(e){const t=rl.getOrCreateInstance(this);t._params.popover&&(t._params.trigger="click"),t._params.trigger.includes("click")&&(e.preventDefault(),t.toggle(this))}),g.A.on(document,Zo,jo,function(e){e.preventDefault();const t=rl.getOrCreateInstance(this);t._params.popover=!0,t._params.trigger="click",t.toggle(this)});const al=rl,ol=[ot,Et,Pe,$i,di,Yi,as,ps,he,Ps,lr,xr,zr,zn,Un,ta,La,Fo,Ai.A,al];new class{constructor(e={}){this._modules=new Map,this._excludedModules=this._normalizeModuleNameList(e.excludeModules??e.exclude??e.without),this._initializer="function"==typeof e.initializer?e.initializer:null,this._isInitialized=!1}register(e,t){const i=this._normalizeModuleName(e),s=this._resolveModuleCandidate(t);if(!i)throw new Error("VGApp.register() ожидает строковое имя модуля первым аргументом.");return this._isModuleExcluded(i)||this._modules.set(i,s),this}boot(e={}){const t=this._normalizeBootConfig(e);this.exclude(t.excludeModules),this._ensureInitialized();for(const[e,i]of this._modules){if(this._isModuleExcluded(e))continue;if("function"!=typeof i?.boot)continue;const s=this._resolveModuleConfig(e,t.modulesConfig);i.boot(s)}return this}get(e){return this._ensureInitialized(),this._modules.get(this._normalizeModuleName(e))}has(e){return this._ensureInitialized(),this._modules.has(this._normalizeModuleName(e))}exclude(e){return this._normalizeModuleNameList(e).forEach(e=>{this._excludedModules.add(e),this._isInitialized&&this._deleteModuleByExcludedName(e)}),this}include(e){return this._normalizeModuleNameList(e).forEach(e=>{this._excludedModules.delete(e)}),this}isExcluded(e){return this._isModuleExcluded(e)}getExcluded(){return Array.from(this._excludedModules)}_resolveModuleCandidate(e){const t=e?.default??e;if(!t)throw new Error("VGApp.register() ожидает валидный модуль.");return t}_resolveModuleConfig(e,t){if(t&&"object"==typeof t)return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}_normalizeBootConfig(e){return e&&"object"==typeof e?{excludeModules:e.excludeModules??e.exclude??e.without??[],modulesConfig:e.modules&&"object"==typeof e.modules?e.modules:e}:{excludeModules:[],modulesConfig:{}}}_normalizeModuleNameList(e){if(!e)return new Set;const t="string"==typeof e?e.split(","):Array.from(e);return new Set(t.map(e=>this._normalizeExcludedModuleName(e)).filter(Boolean))}_normalizeModuleName(e){return String(e||"").trim()}_normalizeExcludedModuleName(e){return this._normalizeModuleName(e).toLowerCase()}_isModuleExcluded(e){return this._excludedModules.has(this._normalizeExcludedModuleName(e))}_deleteModuleByExcludedName(e){for(const t of this._modules.keys())this._normalizeExcludedModuleName(t)===e&&this._modules.delete(t)}_ensureInitialized(){this._isInitialized||"function"!=typeof this._initializer||(this._isInitialized=!0,this._initializer(this))}}({initializer:e=>{ol.forEach(t=>{e.register(t.NAME,t)})}})})(),i.r(s),s})());
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vgapp=e():t.vgapp=e()}(this,()=>(()=>{"use strict";var t={188(t,e,i){i.d(e,{A:()=>p});var s=i(381),r=i(829);const n=new Map;function a(t){return n.has(t)?n.get(t):null}const o={set(t,e,i){a(t)||function(t){const e=new Map;n.set(t,e)}(t);const s=a(t);if(s.size>0&&!s.has(e)){const t=Array.from(s.keys())[0];return void console.error(`VGApp не допускает более одного экземпляра для каждого элемента. Связанный экземпляр: ${t}.`)}s.set(e,i)},get(t,e){const i=a(t);return i&&i.get(e)||null},remove(t,e){const i=a(t);i&&(i.delete(e),0===i.size&&n.delete(t))}};var l=i(667),h=i(647),d=i(810);class c{static get DEFAULTS(){return{enable:!1,in:"animate__fadeIn",out:"animate__fadeOut",duration:500}}constructor(t,e,i={}){this._element=t,this._nameKey=e,this._params=(0,s._v)(c.DEFAULTS,i),this._params.enable&&(0,s.vq)(t)&&(this._classes={animated:"animate__animated",duration:"animate__fast"},this._init())}_init(){const{classList:t}=this._element;t.add(this._classes.animated,this._classes.duration),t.contains("fade")&&t.remove("fade"),this._setupEventListeners()}_setupEventListeners(){h.A.on(this._element,`${this._nameKey}.show`,this._handleShow.bind(this),null),h.A.on(this._element,`${this._nameKey}.shown`,this._handleShown.bind(this),null),h.A.on(this._element,`${this._nameKey}.hide`,this._handleHide.bind(this),null),h.A.on(this._element,`${this._nameKey}.hidden`,this._handleHidden.bind(this),null)}_handleShow(){const{classList:t}=this._element,{in:e,out:i}=this._params;t.contains(i)&&t.remove(i),t.add(e)}_handleShown(){this._element.classList.add(this._classes.animated)}_handleHide(){const{classList:t}=this._element,{in:e,out:i}=this._params;t.contains(e)&&t.remove(e),t.add(i)}_handleHidden(){const{classList:t}=this._element,{in:e,out:i}=this._params;[...t].filter(t=>t.startsWith("animate__")).forEach(e=>t.remove(e)),t.add(this._classes.animated,this._classes.duration)}dispose(){h.A.off(this._element,`${this._nameKey}.show`,null,null),h.A.off(this._element,`${this._nameKey}.shown`,null,null),h.A.off(this._element,`${this._nameKey}.hide`,null,null),h.A.off(this._element,`${this._nameKey}.hidden`,null,null),[...this._element.classList].filter(t=>t.startsWith("animate__")).forEach(t=>this._element.classList.remove(t)),this._element=null}}const _=c;var u=i(11),m=i(601);const p=class{constructor(t){if(t){if(this._element=r.A.find(t),!this._element)throw new Error("Товарищ! Первый параметр не должен быть пустым!");this._params={},this._isLoaded=!1,o.set(this._element,this.constructor.NAME_KEY,this)}}_getParams(t,e){return new l.A(e,t).get()}dispose(){o.remove(this._element,this.constructor.NAME_KEY),h.A.off(this._element,this.constructor.EVENT_KEY);for(const t of Object.getOwnPropertyNames(this))this[t]=null}_route(t,e){if("function"!=typeof t)return this._requestRoute(t);let i=null,n=this._params.ajax.timeout||0;if(this._isLoaded)return;const a=t=>{"string"==typeof t?i&&(i.innerHTML=t):(0,s.Gv)(t)&&!(0,s.ze)(t)&&Object.values(t).forEach(t=>{"string"==typeof t&&i&&(i.innerHTML=t)})};if(!this._params.hasOwnProperty("ajax"))return;if(!this._params.ajax.route)return;!1 in this._params.ajax&&(this._params.ajax.method="get"),"target"in this._params.ajax&&this._params.ajax.target&&(i=r.A.find(this._params.ajax.target)),"loader"in this._params.ajax&&this._params.ajax.loader&&"output"in this._params.ajax&&this._params.ajax.output&&a((0,m.A)("string").div({class:"vg-loader"}));let o=(e,r)=>{"loader"in this._params.ajax&&this._params.ajax.loader&&a(""),"once"in this._params.ajax&&this._params.ajax.once&&(this._isLoaded=!0),"output"in this._params.ajax&&this._params.ajax.output&&a("response"in e?(0,s.OM)(e.response):e),(0,s.g7)(t,[r,e,i])};const l=new u.A;let h={onSuccess:t=>{o(t,"success")},onError:t=>{"loader"in this._params.ajax&&this._params.ajax.loader&&a(""),"function"!=typeof e?o(t,"error"):(0,s.g7)(e,[t])}};setTimeout(()=>{if("get"===this._params.ajax.method.toLowerCase()){const t=this._buildRouteUrl(this._params.ajax.data,this._params.ajax.route);l.get(t.toString(),h)}"post"===this._params.ajax.method.toLowerCase()&&l.post(this._params.ajax.route,this._params.ajax.data,h),"delete"===this._params.ajax.method.toLowerCase()&&l.delete(this._params.ajax.route,h)},n)}_requestRoute(t={}){const e=this._normalizeRouteRequestOptions(t);return u.A.requestRoute(e)}_buildRouteUrl(t={},e="",i={}){const s=this._normalizeRouteRequestOptions(Object.assign({},i,{params:t,route:e||i.route||""}));return u.A.buildRouteUrl(s.route,{params:s.params,baseParams:s.baseParams})}_normalizeRouteRequestOptions(t={}){const e=this._params&&(0,s.Gv)(this._params.request)?this._params.request:{},i=this._params&&(0,s.Gv)(this._params.ajax)?this._params.ajax:{},r=(0,s.Gv)(t)?t:{};return{route:String(r.route||r.endpoint||e.route||i.route||"").trim(),method:String(r.method||e.method||i.method||"GET").toUpperCase().trim()||"GET",credentials:String(r.credentials||e.credentials||"same-origin").trim()||"same-origin",headers:(0,s._v)({Accept:"application/json","X-Requested-With":"XMLHttpRequest"},(0,s.Gv)(e.headers)?e.headers:{},(0,s.Gv)(r.headers)?r.headers:{}),baseParams:(0,s._v)({},(0,s.Gv)(e.params)?e.params:{},(0,s.Gv)(r.baseParams)?r.baseParams:{},(0,s.Gv)(r.paramsBase)?r.paramsBase:{}),params:(0,s.Gv)(r.params)?r.params:{},body:void 0!==r.body?r.body:void 0!==r.data?r.data:null,signal:r.signal||null,responseType:String(r.responseType||r.parse||"auto").toLowerCase().trim()||"auto"}}_dismissElement(){let t=(0,d.z)("cross"),e=this._element.querySelector(".vg-btn-close");e&&(e.querySelector("svg")||e.insertAdjacentHTML("beforeend",t))}_queueCallback(t,e,i=!0,r){(0,s.dO)(t,e,i,r)}_animation(t,e,i={}){new _(t,e,i)}static getInstance(t){return o.get(r.A.find(t),this.NAME_KEY)}static getOrCreateInstance(t,e={}){return this.getInstance(t)||new this(t,(0,s.ze)(e)?{}:e)}static boot(t={}){if("function"==typeof this.initAll)return this.initAll(t);if("function"!=typeof this.init)return null;if(t&&Object.prototype.hasOwnProperty.call(t,"element")){const{element:e,...i}=t;return this.init(e,i)}return null}static get DATA_KEY(){return`vg.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}}},810(t,e,i){i.d(e,{P:()=>h,z:()=>l});var s=i(647),r=i(381),n=i(829);const a={pdf:"file-pdf",doc:"file-word",docx:"file-word",odt:"file-word",rtf:"file-word",xls:"file-exel",xlsx:"file-exel",xlsm:"file-exel",ods:"file-exel",csv:"file-exel",zip:"file-zip",rar:"file-zip","7z":"file-zip",tar:"file-zip",gz:"file-zip",tgz:"file-zip",txt:"file-text",md:"file-text",log:"file-text",json:"file-text",xml:"file-text",yml:"file-text",yaml:"file-text",php:"file-php",png:"file-image",jpg:"file-image",jpeg:"file-image",gif:"file-image",webp:"file-image",svg:"file-image",bmp:"file-image",tif:"file-image",tiff:"file-image",heic:"file-image",heif:"file-image",avif:"file-image",mp3:"file-audio",wav:"file-audio",ogg:"file-audio",flac:"file-audio",aac:"file-audio",m4a:"file-audio",mp4:"file-video",webm:"file-video",mov:"file-video",mkv:"file-video",avi:"file-video"},o=t=>{if(!t)return"";const e=String(t).toLowerCase().split("#")[0].split("?")[0].split("/").pop()||"";return e.includes(".")&&e.split(".").pop()||""},l=t=>((t,e={})=>{const i=e[t];if(i)return i;const s=e[(t=>{const{type:e,ext:i}=(t=>{if(!t)return{type:"",ext:""};if("object"==typeof t){const e=String(t.type||"").toLowerCase(),i=String(t.name||t.path||t.url||"").toLowerCase();return{type:e,ext:o(i)}}return{type:"",ext:o(t)}})(t);return"application/pdf"===e?"file-pdf":e.includes("word")?"file-word":e.includes("excel")||e.includes("spreadsheet")?"file-exel":e.includes("zip")||e.includes("compressed")?"file-zip":e.startsWith("text/")?"file-text":e.startsWith("image/")?"file-image":e.startsWith("audio/")?"file-audio":e.startsWith("video/")?"file-video":a[i]||"file-generic"})(t)];return s||e["file-generic"]||""})(t,{minus:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dash" viewBox="0 0 16 16"><path d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8"/></svg>',plus:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16"><path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/></svg>',"dots-six-vertical":'<svg viewBox="64 64 896 896" focusable="false" data-icon="holder" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M300 276.5a56 56 0 1056-97 56 56 0 00-56 97zm0 284a56 56 0 1056-97 56 56 0 00-56 97zM640 228a56 56 0 10112 0 56 56 0 00-112 0zm0 284a56 56 0 10112 0 56 56 0 00-112 0zM300 844.5a56 56 0 1056-97 56 56 0 00-56 97zM640 796a56 56 0 10112 0 56 56 0 00-112 0z"></path></svg>',chevron:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 12.392L8.74146 9.13354L7.0918 10.7832L11.1751 14.8665C11.3939 15.0853 11.6906 15.2081 12 15.2081C12.3093 15.2081 12.606 15.0853 12.8248 14.8665L16.9081 10.7832L15.2585 9.13354L12 12.392Z" fill="black"/></svg>',danger:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36 4.5C53.3953 4.5 67.5 18.6047 67.5 36C67.5 53.3953 53.3953 67.5 36 67.5C18.6047 67.5 4.5 53.3953 4.5 36C4.5 18.6047 18.6047 4.5 36 4.5ZM44.9961 23.8237C44.9944 23.8242 44.9931 23.825 44.9902 23.8279L36 32.818L27.0098 23.8279C27.0069 23.825 27.0056 23.8242 27.0039 23.8237C27.0023 23.8232 27.0006 23.8232 26.999 23.8237C26.9975 23.8242 26.9961 23.825 26.9932 23.8279L23.8278 26.9932C23.825 26.9961 23.8243 26.9975 23.8237 26.9991C23.8232 27.0007 23.8232 27.0024 23.8237 27.004L23.8244 27.0056C23.8253 27.0071 23.8265 27.0085 23.8279 27.0098L32.818 36L23.8279 44.9903C23.825 44.9931 23.8242 44.9945 23.8237 44.9961C23.8232 44.9977 23.8232 44.9995 23.8237 45.0011C23.8242 45.0026 23.825 45.0039 23.8279 45.0068L26.9932 48.1723C26.9961 48.1751 26.9975 48.1758 26.9991 48.1764C27.0007 48.1769 27.0024 48.1769 27.004 48.1764C27.0056 48.1759 27.0069 48.1751 27.0098 48.1722L36 39.1819L44.9903 48.1721C44.9931 48.175 44.9945 48.1758 44.9961 48.1763C44.9977 48.1768 44.9995 48.1768 45.0011 48.1763C45.0026 48.1758 45.0039 48.175 45.0068 48.1721L48.1723 45.0068C48.1751 45.0039 48.1758 45.0025 48.1764 45.0009C48.1769 44.9993 48.1769 44.9976 48.1764 44.996L48.1757 44.9944C48.1747 44.9929 48.1736 44.9915 48.1722 44.9902L39.1819 36L48.1721 27.0098C48.175 27.0069 48.1758 27.0056 48.1763 27.0039C48.1768 27.0023 48.1768 27.0006 48.1763 26.999C48.1758 26.9975 48.175 26.9961 48.1721 26.9932L45.0068 23.8278C45.0039 23.825 45.0025 23.8243 45.0009 23.8237C44.9993 23.8232 44.9977 23.8232 44.9961 23.8237Z" fill="#000000"/></svg>',success:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36 4.5C18.6047 4.5 4.5 18.6047 4.5 36C4.5 53.3953 18.6047 67.5 36 67.5C53.3953 67.5 67.5 53.3953 67.5 36C67.5 18.6047 53.3953 4.5 36 4.5ZM49.6055 25.7133L34.7977 46.2445C34.5907 46.5334 34.3179 46.7688 34.0018 46.9312C33.6857 47.0935 33.3354 47.1782 32.9801 47.1782C32.6247 47.1782 32.2745 47.0935 31.9584 46.9312C31.6423 46.7688 31.3695 46.5334 31.1625 46.2445L22.3945 34.0945C22.1273 33.7219 22.3945 33.2016 22.8516 33.2016H26.1492C26.8664 33.2016 27.5484 33.5461 27.9703 34.1367L32.9766 41.0836L44.0297 25.7555C44.4516 25.1719 45.1266 24.8203 45.8508 24.8203H49.1484C49.6055 24.8203 49.8727 25.3406 49.6055 25.7133Z" fill="#000000"/></svg>',waiting:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M51 10.02C55.5248 12.6326 59.2888 16.3816 61.9194 20.8959C64.5501 25.4103 65.9561 30.5334 65.9983 35.7581C66.0405 40.9828 64.7174 46.1279 62.1601 50.6841C59.6027 55.2404 55.8997 59.0497 51.4177 61.735C46.9357 64.4203 41.8301 65.8885 36.6063 65.9942C31.3825 66.1 26.2216 64.8395 21.6347 62.3378C17.0477 59.836 13.1936 56.1796 10.454 51.7306C7.71439 47.2816 6.18423 42.1942 6.015 36.972L6 36L6.015 35.028C6.18301 29.847 7.69064 24.7979 10.3909 20.373C13.0912 15.9481 16.892 12.2984 21.4227 9.77969C25.9534 7.26098 31.0594 5.95923 36.243 6.00136C41.4266 6.04348 46.5108 7.42804 51 10.02ZM36 18C35.2652 18.0001 34.556 18.2699 34.0069 18.7582C33.4578 19.2465 33.107 19.9193 33.021 20.649L33 21V36L33.027 36.393C33.0954 36.9135 33.2992 37.407 33.618 37.824L33.879 38.124L42.879 47.124L43.161 47.37C43.6871 47.7782 44.3341 47.9998 45 47.9998C45.6659 47.9998 46.3129 47.7782 46.839 47.37L47.121 47.121L47.37 46.839C47.7782 46.3129 47.9998 45.6659 47.9998 45C47.9998 44.3341 47.7782 43.6872 47.37 43.161L47.121 42.879L39 34.755V21L38.979 20.649C38.893 19.9193 38.5422 19.2465 37.9931 18.7582C37.444 18.2699 36.7348 18.0001 36 18Z" fill="black"/></svg>',warning:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36.5 5C44.8543 5 52.8665 8.31874 58.7739 14.2261C64.6813 20.1335 68 28.1457 68 36.5C68 44.8543 64.6813 52.8665 58.7739 58.7739C52.8665 64.6813 44.8543 68 36.5 68C28.1457 68 20.1335 64.6813 14.2261 58.7739C8.31874 52.8665 5 44.8543 5 36.5C5 28.1457 8.31874 20.1335 14.2261 14.2261C20.1335 8.31874 28.1457 5 36.5 5ZM36.5 18.5C35.9287 18.4995 35.3635 18.6181 34.8406 18.8484C34.3178 19.0786 33.8487 19.4154 33.4633 19.8372C33.0779 20.259 32.7848 20.7565 32.6025 21.298C32.4203 21.8395 32.353 22.413 32.405 22.982L34.0475 41.009C34.1112 41.6151 34.397 42.1761 34.8499 42.5839C35.3028 42.9917 35.8906 43.2173 36.5 43.2173C37.1094 43.2173 37.6972 42.9917 38.1501 42.5839C38.603 42.1761 38.8888 41.6151 38.9525 41.009L40.5905 22.982C40.6424 22.4134 40.5753 21.8403 40.3933 21.2991C40.2114 20.7579 39.9186 20.2606 39.5337 19.8389C39.1488 19.4171 38.6803 19.0803 38.1579 18.8498C37.6356 18.6192 37.0709 18.5001 36.5 18.5ZM36.5 54.5C37.4548 54.5 38.3705 54.1207 39.0456 53.4456C39.7207 52.7705 40.1 51.8548 40.1 50.9C40.1 49.9452 39.7207 49.0295 39.0456 48.3544C38.3705 47.6793 37.4548 47.3 36.5 47.3C35.5452 47.3 34.6295 47.6793 33.9544 48.3544C33.2793 49.0295 32.9 49.9452 32.9 50.9C32.9 51.8548 33.2793 52.7705 33.9544 53.4456C34.6295 54.1207 35.5452 54.5 36.5 54.5Z" fill="#000000"/></svg>',info:'<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M36 4.5C18.6047 4.5 4.5 18.6047 4.5 36C4.5 53.3953 18.6047 67.5 36 67.5C53.3953 67.5 67.5 53.3953 67.5 36C67.5 18.6047 53.3953 4.5 36 4.5ZM33.75 20.8125C33.75 20.5031 34.0031 20.25 34.3125 20.25H37.6875C37.9969 20.25 38.25 20.5031 38.25 20.8125V39.9375C38.25 40.2469 37.9969 40.5 37.6875 40.5H34.3125C34.0031 40.5 33.75 40.2469 33.75 39.9375V20.8125ZM36 51.75C35.1168 51.732 34.2759 51.3685 33.6577 50.7375C33.0395 50.1065 32.6932 49.2584 32.6932 48.375C32.6932 47.4916 33.0395 46.6435 33.6577 46.0125C34.2759 45.3815 35.1168 45.018 36 45C36.8832 45.018 37.7241 45.3815 38.3423 46.0125C38.9605 46.6435 39.3068 47.4916 39.3068 48.375C39.3068 49.2584 38.9605 50.1065 38.3423 50.7375C37.7241 51.3685 36.8832 51.732 36 51.75Z" fill="#000000"/></svg>',dots:'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 17C11.1046 17 12 16.1046 12 15C12 13.8954 11.1046 13 10 13C8.89543 13 8 13.8954 8 15C8 16.1046 8.89543 17 10 17Z" fill="black"/><path d="M10 12C11.1046 12 12 11.1046 12 10C12 8.89543 11.1046 8 10 8C8.89543 8 8 8.89543 8 10C8 11.1046 8.89543 12 10 12Z" fill="black"/><path d="M10 7C11.1046 7 12 6.10457 12 5C12 3.89543 11.1046 3 10 3C8.89543 3 8 3.89543 8 5C8 6.10457 8.89543 7 10 7Z" fill="black"/></svg>',remove:'<svg class="vg-icon-remove" width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7.05 5.636 12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414L12 13.414l-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636Z" fill="currentColor"/></svg>',cross:'<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.3149 0.340332C15.4478 0.20752 15.6027 0.118978 15.7798 0.074707C15.9569 0.0249023 16.134 0.0249023 16.311 0.074707C16.4881 0.118978 16.6431 0.20752 16.7759 0.340332C16.9142 0.473145 17.0055 0.630859 17.0498 0.813477C17.0941 0.99056 17.0941 1.16764 17.0498 1.34473C17.0055 1.52181 16.917 1.67676 16.7842 1.80957L1.80127 16.8008C1.67399 16.9281 1.52181 17.0111 1.34473 17.0498C1.16764 17.0941 0.987793 17.0941 0.805176 17.0498C0.628092 17.0111 0.470378 16.9253 0.332031 16.7925C0.199219 16.6597 0.110677 16.502 0.0664062 16.3193C0.0221354 16.1423 0.0221354 15.9652 0.0664062 15.7881C0.110677 15.611 0.196452 15.4588 0.32373 15.3315L15.3149 0.340332ZM16.7842 15.3232C16.917 15.4561 17.0028 15.6082 17.0415 15.7798C17.0858 15.9569 17.0858 16.134 17.0415 16.311C17.0028 16.4937 16.9142 16.6541 16.7759 16.7925C16.6431 16.9253 16.4881 17.0138 16.311 17.0581C16.134 17.1024 15.9569 17.1024 15.7798 17.0581C15.6027 17.0138 15.4478 16.9253 15.3149 16.7925L0.32373 1.80127C0.201986 1.67952 0.116211 1.53011 0.0664062 1.35303C0.0221354 1.17594 0.0221354 0.996094 0.0664062 0.813477C0.116211 0.630859 0.204753 0.473145 0.332031 0.340332C0.464844 0.20752 0.622559 0.118978 0.805176 0.074707C0.987793 0.0304362 1.16488 0.0304362 1.33643 0.074707C1.51351 0.118978 1.66846 0.204753 1.80127 0.332031L16.7842 15.3232Z" fill="#000"/></svg>',"eye-open":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z"/></svg>',"eye-hide":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"/></svg>',trash:'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.5013 3.33332H14.918C14.5193 1.39465 12.8139 0.0025 10.8346 0H9.16793C7.18867 0.0025 5.48328 1.39465 5.08461 3.33332H2.50129C2.04105 3.33332 1.66797 3.70641 1.66797 4.16664C1.66797 4.62687 2.04105 5 2.50129 5H3.33461V15.8333C3.33738 18.1334 5.20125 19.9973 7.50129 20H12.5013C14.8013 19.9973 16.6652 18.1334 16.668 15.8333V5H17.5013C17.9615 5 18.3346 4.62691 18.3346 4.16668C18.3346 3.70645 17.9615 3.33332 17.5013 3.33332ZM9.16797 14.1667C9.16797 14.6269 8.79488 15 8.33465 15C7.87437 15 7.50129 14.6269 7.50129 14.1667V9.16668C7.50129 8.70645 7.87437 8.33336 8.33461 8.33336C8.79484 8.33336 9.16793 8.70645 9.16793 9.16668V14.1667H9.16797ZM12.5013 14.1667C12.5013 14.6269 12.1282 15 11.668 15C11.2077 15 10.8346 14.6269 10.8346 14.1667V9.16668C10.8346 8.70645 11.2077 8.33336 11.668 8.33336C12.1282 8.33336 12.5013 8.70645 12.5013 9.16668V14.1667ZM6.81047 3.33332C7.16492 2.33523 8.10883 1.66793 9.16797 1.66664H10.8346C11.8938 1.66793 12.8377 2.33523 13.1921 3.33332H6.81047Z" fill="black" fill-opacity="0.5"/></svg>',spinner:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_290_5000)"><path d="M14.6414 8.58333C14.5128 10.1032 13.8685 11.5335 12.8153 12.6368C11.7621 13.7401 10.3634 14.4502 8.85109 14.6493C7.33883 14.8483 5.80396 14.5244 4.50113 13.7311C3.19831 12.9379 2.20584 11.7231 1.68838 10.2882C1.17092 8.85338 1.15958 7.28474 1.65623 5.84255C2.15289 4.40037 3.12769 3.17133 4.41891 2.35934C5.71013 1.54735 7.24015 1.20123 8.75514 1.37839C10.2701 1.55555 11.679 2.24534 12.748 3.33333H10.6667C10.4899 3.33333 10.3203 3.40357 10.1953 3.5286C10.0703 3.65362 10 3.82319 10 4C10 4.17681 10.0703 4.34638 10.1953 4.47141C10.3203 4.59643 10.4899 4.66667 10.6667 4.66667H13.4287C13.757 4.66649 14.0718 4.536 14.3039 4.30387C14.5361 4.07174 14.6665 3.75695 14.6667 3.42867V0.666667C14.6667 0.489856 14.5965 0.320286 14.4715 0.195262C14.3464 0.0702379 14.1769 0 14 0C13.8232 0 13.6537 0.0702379 13.5286 0.195262C13.4036 0.320286 13.3334 0.489856 13.3334 0.666667V2.052C11.9925 0.853819 10.2866 0.142989 8.4917 0.0344742C6.69675 -0.0740408 4.91768 0.426105 3.44222 1.45402C1.96675 2.48194 0.881175 3.97752 0.361055 5.69888C-0.159065 7.42024 -0.0833125 9.26672 0.57606 10.9397C1.23543 12.6127 2.43987 14.0143 3.99457 14.9179C5.54928 15.8215 7.36334 16.1742 9.14336 15.9191C10.9234 15.6639 12.5653 14.8157 13.8035 13.5117C15.0417 12.2077 15.8039 10.5242 15.9667 8.73333C15.9753 8.6405 15.9645 8.54688 15.9349 8.45846C15.9054 8.37003 15.8577 8.28873 15.795 8.21974C15.7323 8.15075 15.6559 8.09559 15.5707 8.05775C15.4854 8.01992 15.3933 8.00025 15.3 8C15.1374 7.99804 14.9799 8.05669 14.8581 8.16452C14.7364 8.27236 14.6591 8.42165 14.6414 8.58333Z" fill="black" fill-opacity="0.35"/></g><defs><clipPath id="clip0_290_5000"><rect width="16" height="16" fill="white"/></clipPath></defs></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.29448 19L3 12.8378L4.57362 11.2973L9.29448 15.9189L19.4264 6L21 7.54054L9.29448 19Z" fill="black"/></svg>',"cloud-dot":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.1401 13.925C14.2399 13.9266 14.3378 13.8983 14.4213 13.8438C14.5049 13.7893 14.5702 13.711 14.6089 13.6191C14.6476 13.5272 14.6579 13.4258 14.6385 13.3279C14.6192 13.2301 14.5709 13.1402 14.5001 13.07L12.0001 10.57L9.50011 13.07C9.4182 13.1657 9.3754 13.2887 9.38026 13.4145C9.38512 13.5404 9.43728 13.6597 9.52633 13.7488C9.61538 13.8378 9.73475 13.89 9.86058 13.8949C9.98642 13.8997 10.1095 13.8569 10.2051 13.775L11.5001 12.5V18.625C11.5001 18.7576 11.5528 18.8848 11.6466 18.9786C11.7403 19.0723 11.8675 19.125 12.0001 19.125C12.1327 19.125 12.2599 19.0723 12.3537 18.9786C12.4474 18.8848 12.5001 18.7576 12.5001 18.625V12.5L13.7851 13.785C13.8803 13.8768 14.0079 13.9271 14.1401 13.925Z" fill="black"/><path d="M18.46 9.71996C18.0211 9.77884 17.5751 9.7551 17.145 9.64996V9.76496L17.105 10.125L17.43 10.275C18.0502 10.5605 18.5545 11.0491 18.8595 11.6601C19.1645 12.271 19.2519 12.9677 19.1074 13.6351C18.9628 14.3024 18.5949 14.9005 18.0645 15.3305C17.5341 15.7605 16.8728 15.9966 16.19 16H13.5V17H16.19C17.0395 16.9958 17.8657 16.7214 18.5488 16.2163C19.2319 15.7112 19.7364 15.0017 19.9893 14.1907C20.2422 13.3797 20.2303 12.5092 19.9553 11.7054C19.6804 10.9016 19.1566 10.2062 18.46 9.71996Z" fill="black"/><path d="M4.80029 12.19C4.80848 11.2 5.19728 10.251 5.88612 9.53986C6.57495 8.82869 7.51101 8.40981 8.50029 8.37003H8.83529L8.95029 8.05503C9.2604 7.2496 9.81028 6.55878 10.5256 6.07591C11.241 5.59305 12.0873 5.34142 12.9503 5.35503C13.4051 5.35535 13.8572 5.42619 14.2903 5.56503C14.3299 5.23197 14.414 4.90573 14.5403 4.59503C14.0252 4.43613 13.4893 4.35523 12.9503 4.35503C11.9414 4.3468 10.9516 4.63029 10.1 5.1714C9.24844 5.7125 8.57138 6.48816 8.15029 7.40503C6.96363 7.53241 5.86506 8.09111 5.06315 8.97505C4.26125 9.85898 3.81186 11.0066 3.80029 12.2C3.8016 12.8321 3.92748 13.4577 4.17073 14.0411C4.41398 14.6245 4.76984 15.1543 5.21794 15.6001C5.66605 16.0459 6.19763 16.3989 6.78229 16.6392C7.36695 16.8794 7.99321 17.002 8.62529 17H10.5003V16H8.62529C7.61384 15.9987 6.64396 15.5974 5.92735 14.8836C5.21074 14.1698 4.80557 13.2015 4.80029 12.19Z" fill="black"/><path class="dot" d="M18 8.5C19.3807 8.5 20.5 7.38071 20.5 6C20.5 4.61929 19.3807 3.5 18 3.5C16.6193 3.5 15.5 4.61929 15.5 6C15.5 7.38071 16.6193 8.5 18 8.5Z" fill="black"/></svg>',"file-generic":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-exel":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111ZM64.2625 72.5125L56.5375 59.7125C56.2625 59.2625 55.775 58.9875 55.25 58.9875H50.45C50.1625 58.9875 49.8875 59.0625 49.65 59.225C48.95 59.6625 48.7375 60.5875 49.1875 61.3L59.475 77.6L49.05 94.2C48.9084 94.4277 48.8301 94.6891 48.8234 94.9571C48.8166 95.2252 48.8816 95.4902 49.0116 95.7247C49.1416 95.9592 49.3319 96.1547 49.5628 96.291C49.7937 96.4273 50.0569 96.4995 50.325 96.5H54.6375C55.1625 96.5 55.6375 96.225 55.9125 95.7875L63.75 83.1L71.5375 95.775C71.8125 96.225 72.3 96.4875 72.8125 96.4875H77.5C77.7875 96.4875 78.0625 96.4 78.3125 96.25C79.0125 95.8 79.2125 94.875 78.7625 94.175L68.2625 77.875L78.925 61.3125C79.0693 61.0855 79.1502 60.824 79.1591 60.5551C79.1681 60.2863 79.1048 60.0199 78.9759 59.7838C78.847 59.5477 78.6572 59.3505 78.4262 59.2126C78.1952 59.0748 77.9315 59.0013 77.6625 59H73.2C72.675 59 72.1875 59.275 71.9125 59.725L64.2625 72.5125Z" fill="black"/></svg>',"file-word":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111ZM66.0125 59H61.9875C61.3 59 60.7 59.4625 60.5375 60.1375L54.325 85L48.5625 60.1625C48.4 59.4875 47.8 59 47.1 59H42.675C42.4451 59.0004 42.2183 59.0535 42.0121 59.1553C41.806 59.2571 41.6259 59.4048 41.4858 59.5872C41.3458 59.7695 41.2494 59.9816 41.2042 60.207C41.159 60.4324 41.1661 60.6652 41.225 60.8875L50.5 95.3875C50.675 96.0375 51.275 96.5 51.95 96.5H55.95C56.625 96.5 57.225 96.05 57.4 95.3875L64 70.7625L70.6 95.3875C70.775 96.0375 71.375 96.5 72.05 96.5H76.025C76.7 96.5 77.3 96.05 77.475 95.3875L86.775 60.8875C86.8334 60.6653 86.8401 60.4326 86.7947 60.2074C86.7493 59.9822 86.6529 59.7703 86.5129 59.5881C86.3729 59.4059 86.1931 59.2582 85.9872 59.1562C85.7813 59.0543 85.5548 59.0009 85.325 59H80.875C80.175 59 79.575 59.4875 79.4125 60.1625L73.6875 85.05L67.4625 60.1375C67.3 59.4625 66.7 59 66.0125 59Z" fill="black"/></svg>',"file-pdf":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M66.4125 71.8L66.45 71.625C67.175 68.6375 68.0875 64.9125 67.375 61.5375C66.9 58.875 64.9375 57.8375 63.2625 57.7625C61.2875 57.675 59.525 58.8 59.0875 60.4375C58.2625 63.4375 59 67.5375 60.35 72.7625C58.65 76.8125 55.9375 82.7 53.95 86.2C50.25 88.1125 45.2875 91.0625 44.55 94.7875C44.4 95.475 44.575 96.35 44.9875 97.1375C45.45 98.0125 46.1875 98.6875 47.05 99.0125C47.425 99.15 47.875 99.2625 48.4 99.2625C50.6 99.2625 54.1625 97.4875 58.9125 89.3375C59.6375 89.1 60.3875 88.85 61.1125 88.6C64.5125 87.45 68.0375 86.25 71.225 85.7125C74.75 87.6 78.7625 88.8125 81.4875 88.8125C84.1875 88.8125 85.25 87.2125 85.65 86.25C86.35 84.5625 86.0125 82.4375 84.875 81.3C83.225 79.675 79.2125 79.25 72.9625 80.025C69.8875 78.15 67.875 75.6 66.4125 71.8ZM52.7 90.7875C50.9625 93.3125 49.65 94.575 48.9375 95.125C49.775 93.5875 51.4125 91.9625 52.7 90.7875ZM63.65 61.35C64.3 62.4625 64.2125 65.825 63.7125 67.525C63.1 65.0375 63.0125 61.5125 63.375 61.1C63.475 61.1125 63.5625 61.1875 63.65 61.35ZM63.45 76.4125C64.7875 78.725 66.475 80.7125 68.3375 82.1875C65.6375 82.8 63.175 83.8125 60.975 84.7125C60.45 84.925 59.9375 85.1375 59.4375 85.3375C61.1 82.325 62.4875 78.9125 63.45 76.4125ZM82.9 84.6C82.9125 84.625 82.925 84.6625 82.85 84.7125H82.825L82.8 84.75C82.7 84.8125 81.675 85.4125 77.2625 83.675C82.3375 83.4375 82.8875 84.5875 82.9 84.6ZM106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-zip":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M37 49H45V57H37V49ZM37 72.75V92.75H53V72.75H45V65H37V72.75ZM47 78.75V86.75H43V78.75H47ZM45 41H53V49H45V41ZM37 33H45V41H37V33ZM45 57H53V65H45V57ZM45 25H53V33H45V25ZM106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H37V25H45V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-text":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111ZM63 77.25H40C39.45 77.25 39 77.7 39 78.25V84.25C39 84.8 39.45 85.25 40 85.25H63C63.55 85.25 64 84.8 64 84.25V78.25C64 77.7 63.55 77.25 63 77.25ZM39 61.25V67.25C39 67.8 39.45 68.25 40 68.25H88C88.55 68.25 89 67.8 89 67.25V61.25C89 60.7 88.55 60.25 88 60.25H40C39.45 60.25 39 60.7 39 61.25Z" fill="black"/></svg>',"file-image":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M69.1375 63.6375L59.4125 76.0375L54.275 69.4875C54.1815 69.368 54.0619 69.2713 53.9255 69.2048C53.7891 69.1384 53.6393 69.1038 53.4875 69.1038C53.3357 69.1038 53.1859 69.1384 53.0495 69.2048C52.9131 69.2713 52.7935 69.368 52.7 69.4875L40.225 85.3875C40.1096 85.5349 40.038 85.7118 40.0183 85.8979C39.9987 86.0841 40.0319 86.272 40.114 86.4402C40.1962 86.6084 40.324 86.7501 40.4829 86.8491C40.6418 86.9481 40.8253 87.0004 41.0125 87H87C87.8375 87 88.3 86.0375 87.7875 85.3875L70.725 63.6375C70.6302 63.5178 70.5096 63.4211 70.3721 63.3546C70.2347 63.2881 70.0839 63.2536 69.9313 63.2536C69.7786 63.2536 69.6278 63.2881 69.4904 63.3546C69.3529 63.4211 69.2323 63.5178 69.1375 63.6375ZM45 55.25C45 56.5761 45.5268 57.8479 46.4645 58.7855C47.4021 59.7232 48.6739 60.25 50 60.25C51.3261 60.25 52.5979 59.7232 53.5355 58.7855C54.4732 57.8479 55 56.5761 55 55.25C55 53.9239 54.4732 52.6521 53.5355 51.7145C52.5979 50.7768 51.3261 50.25 50 50.25C48.6739 50.25 47.4021 50.7768 46.4645 51.7145C45.5268 52.6521 45 53.9239 45 55.25ZM106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/></svg>',"file-audio":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/><path d="M64.6781 93.0344C62.701 95.0114 60.2677 96 57.3781 96C54.4885 96 52.0552 95.0114 50.0781 93.0344C48.1011 91.0573 47.1125 88.624 47.1125 85.7344C47.1125 82.8448 48.1011 80.4115 50.0781 78.4344C52.0552 76.4573 54.4885 75.4688 57.3781 75.4688C58.4458 75.4657 59.4541 75.598 60.4031 75.8657C61.3521 76.1333 62.2448 76.5714 63.0813 77.1797V64.0625C63.0843 62.7728 63.5223 61.69 64.3953 60.814C65.2682 59.938 66.351 59.5 67.6438 59.5H76.7688C78.0615 59.5 79.1443 59.938 80.0172 60.814C80.8902 61.69 81.3282 62.7728 81.3313 64.0625C81.3343 65.3522 80.8978 66.435 80.0218 67.311C79.1458 68.187 78.0615 68.625 76.7688 68.625H67.6438V85.7344C67.6438 88.624 66.6552 91.0573 64.6781 93.0344Z" fill="black"/></svg>',"file-video":'<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M106.825 36.075L79.925 9.175C79.175 8.425 78.1625 8 77.1 8H24C21.7875 8 20 9.7875 20 12V116C20 118.213 21.7875 120 24 120H104C106.213 120 108 118.213 108 116V38.9125C108 37.85 107.575 36.825 106.825 36.075ZM98.775 40.75H75.25V17.225L98.775 40.75ZM99 111H29V17H66.75V44C66.75 45.3924 67.3031 46.7277 68.2877 47.7123C69.2723 48.6969 70.6076 49.25 72 49.25H99V111Z" fill="black"/><path d="M44.2566 71.7109C44.2566 70.0637 44.911 68.4839 46.0758 67.3191C47.2405 66.1544 48.8203 65.5 50.4676 65.5H64.5457C66.1929 65.5 67.7727 66.1544 68.9375 67.3191C70.1023 68.4839 70.7566 70.0637 70.7566 71.7109V85.7891C70.7566 87.4363 70.1023 89.0161 68.9375 90.1809C67.7727 91.3456 66.1929 92 64.5457 92H50.4676C48.8203 92 47.2405 91.3456 46.0758 90.1809C44.911 89.0161 44.2566 87.4363 44.2566 85.7891V71.7109ZM79.4552 89.8187L72.4129 84.956V72.5391L79.4552 67.6763C81.3765 66.348 84 67.726 84 70.0613V87.4354C84 89.7707 81.3782 91.1454 79.4552 89.8187Z" fill="black"/></svg>',download:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/></svg>',play:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M10.804 8 5 4.633v6.734zm.792-.696a.802.802 0 0 1 0 1.392l-6.363 3.692C4.713 12.69 4 12.345 4 11.692V4.308c0-.653.713-.998 1.233-.696z"/></svg>',pause:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M6.25 5C5.56 5 5 5.56 5 6.25v3.5a1.25 1.25 0 1 0 2.5 0v-3.5C7.5 5.56 6.94 5 6.25 5m3.5 0c-.69 0-1.25.56-1.25 1.25v3.5a1.25 1.25 0 1 0 2.5 0v-3.5C11 5.56 10.44 5 9.75 5"/></svg>'}),h=(t,e="hide")=>{const i=`click.dismiss.${t.EVENT_KEY}`,a=t.NAME;s.A.on(document,i,`[data-vg-dismiss="${a}"]`,function(i){if(["A","AREA"].includes(this.tagName)&&i.preventDefault(),(0,r.d6)(this))return;const s=n.A.getSelectorFromElement(this)||this.closest(`.vg-${a}`);t.getOrCreateInstance(s)[e]()})}},355(t,e,i){i.d(e,{L:()=>d,default:()=>_,h:()=>o});var s=i(829),r=i(381),n=i(11),a=i(483);const o="application/x-vg-files-sortable";let l=!1,h=null;function d(){return l}function c(){h&&clearTimeout(h),h=setTimeout(()=>{l=!1,h=null},0)}const _=class{constructor(t,e={}){this._vg=t,this._params={handle:".file",itemSelector:"li.file",route:null,method:"POST",toast:!0,...e},!e.itemSelector&&e.handle&&(this._params.itemSelector=`li${e.handle}`),this._params.route||console.warn("VGFilesSortable: Не указан маршрут `route` для сохранения порядка."),this._params.lists?.length?this._list=this._params.lists.map(t=>s.A.find("."+t,this._vg._element)).find(t=>t):this._list=this._vg._nodes.list,(0,r.vq)(this._list)?(this._draggedItem=null,this._boundOnDragStart=this._onDragStart.bind(this),this._boundOnDragEnd=this._onDragEnd.bind(this),this._boundOnDragOver=this._onDragOver.bind(this),this._boundOnDrop=this._onDrop.bind(this),this._init()):console.error("VGFilesSortable: Не найден контейнер списка файлов")}_init(){this._enableDraggableItems(),this._setupEvents(),this._vg._triggerCallback("onSortableInit")}_enableDraggableItems(){this._list.querySelectorAll(this._params.itemSelector).forEach(t=>{t.setAttribute("draggable","true");const e=t.querySelector("img");e&&e.setAttribute("draggable","false")})}_setupEvents(){this._list.addEventListener("dragstart",this._boundOnDragStart),this._list.addEventListener("dragend",this._boundOnDragEnd),this._list.addEventListener("dragover",this._boundOnDragOver),this._list.addEventListener("drop",this._boundOnDrop)}_onDragStart(t){if(!t.target.closest(this._params.handle))return;const e=t.target.closest(this._params.itemSelector)||t.target.closest("li");e&&(this._draggedItem=e,h&&(clearTimeout(h),h=null),l=!0,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData(o,"1"),t.dataTransfer.setData("text/plain","vgsortable"),e.classList.add("dragging"),requestAnimationFrame(()=>e.classList.add("dragging-transparent")))}_onDragEnd(t){this._draggedItem&&(this._draggedItem.classList.remove("dragging","dragging-transparent"),this._draggedItem=null,this._saveOrder()),c()}_onDragOver(t){if(!this._draggedItem)return;t.preventDefault(),t.dataTransfer.dropEffect="move";const e=t.target.closest(this._params.itemSelector)||t.target.closest("li");if(!e||e===this._draggedItem)return;const i=e.getBoundingClientRect(),s=i.height/2;t.clientY-i.top<s?this._list.insertBefore(this._draggedItem,e):this._list.insertBefore(this._draggedItem,e.nextSibling)}_onDrop(t){if(this._draggedItem)return t.preventDefault(),t.stopPropagation(),!1}_saveOrder(){const t=[...new Set(this._getUploadedIds())];t.length&&this._params.route&&(new n.A).post(this._params.route,{ids:t},{onSuccess:t=>a.A.run(t.response.message)})}_getUploadedIds(){return Array.from(this._list.querySelectorAll("[data-id]")).map(t=>(0,r.OM)(t.getAttribute("data-id"))||null).filter(t=>null!==t)}destroy(){this._list.removeEventListener("dragstart",this._boundOnDragStart),this._list.removeEventListener("dragend",this._boundOnDragEnd),this._list.removeEventListener("dragover",this._boundOnDragOver),this._list.removeEventListener("drop",this._boundOnDrop),this._draggedItem=null,c()}}},483(t,e,i){i.d(e,{A:()=>s});const s=i(614).A},614(t,e,i){i.d(e,{A:()=>T});var s=i(188),r=i(647),n=i(810),a=i(546),o=i(381),l=i(829);const h={enable:!1,selector:".vg-toast-wrapper",threshold:4,resizeEdgeSize:8,debug:!1},d=class{constructor(t,e,i={}){this._modalElement=t,this._dialogElement=e,this._options=this._normalizeOptions(i),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._dialogStartLeft=0,this._dialogStartTop=0,this._dialogWidth=0,this._dialogHeight=0,this._isEnabled=!1,this._previousUserSelect="",this._previousTransition="",this._previousWillChange="",this._initialRect=null,this._lockedIframes=[],this._debugElement=null,this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onNativeDragStart=this._onNativeDragStart.bind(this)}setOptions(t={}){this._options=this._normalizeOptions(t,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._dialogElement.addEventListener("pointerdown",this._onPointerDown),this._isEnabled=!0)}disable(){this._dialogElement&&this._isEnabled&&(this._dialogElement.removeEventListener("pointerdown",this._onPointerDown),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgToastDragging,this._setDebugVisibility(!1),this._isEnabled=!1)}syncPosition(){if(!this._isEnabled)return;if(!this._isPreparedForInteraction())return;const t=this._dialogElement.getBoundingClientRect(),e=this._dialogElement.offsetWidth||t.width,i=this._dialogElement.offsetHeight||t.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:t.left,a=Number.isFinite(r)?r:t.top,o=Math.max(0,window.innerWidth-e),l=Math.max(0,window.innerHeight-i),h=Math.min(o,Math.max(0,n)),d=Math.min(l,Math.max(0,a));this._dialogElement.style.left=`${h}px`,this._dialogElement.style.top=`${d}px`,this._updateDebugValues("synced")}_onPointerDown(t){if(0!==t.button)return;const e=this._resolveDragArea(t.target);e&&this._dialogElement.contains(e)&&(this._isPointerOnResizeEdge(t)||t.target.closest('input, textarea, select, button, a, [contenteditable="true"]')||e&&e.closest('[data-vg-dismiss="toast"]')||(this._pointerId=t.pointerId,this._dragTarget=t.target,this._isDragging=!1,t.preventDefault(),this._previousUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",this._initialRect=this._dialogElement.getBoundingClientRect(),this._dialogStartLeft=this._initialRect.left,this._dialogStartTop=this._initialRect.top,this._dialogWidth=this._initialRect.width,this._dialogHeight=this._initialRect.height,this._startX=t.clientX,this._startY=t.clientY,this._currentX=t.clientX,this._currentY=t.clientY,this._lockEmbeddedFrames(),this._modalElement.dataset.vgToastDragging="true",this._setDebugVisibility(!0),this._updateDebugValues("armed"),document.addEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement&&this._dialogElement.setPointerCapture&&this._dialogElement.setPointerCapture(t.pointerId),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)))}_onPointerMove(t){if(t.pointerId===this._pointerId){if(this._currentX=t.clientX,this._currentY=t.clientY,!this._isDragging){const e=this._currentX-this._startX,i=this._currentY-this._startY;if(Math.hypot(e,i)<this._options.threshold)return;this._isDragging=!0,this._dialogElement.style.touchAction="none",this._applyDragStyles(),this._preparePosition(this._initialRect),t.preventDefault(),this._updateDebugValues("dragging")}this._applyDragPosition()}}_onPointerUp(t){t.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._isDragging&&this._applyDragPosition(),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._dialogElement&&this._dialogElement.releasePointerCapture&&this._dialogElement.releasePointerCapture(t.pointerId),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgToastDragging,this._setDebugVisibility(this._options.debug),this._updateDebugValues("idle"))}_preparePosition(t=null){if(!this._dialogElement)return;const e=t||this._dialogElement.getBoundingClientRect();this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${e.left}px`,this._dialogElement.style.top=`${e.top}px`,this._dialogElement.style.width=`${e.width}px`,this._dialogElement.style.height=`${e.height}px`,this._dialogElement.style.transform="none",this._dialogElement.style.translate="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_isPointerOnResizeEdge(t){const e=this._dialogElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,r=this._options.resizeEdgeSize,n=s>=0&&s<=r,a=s<=e.height&&s>=e.height-r,o=i>=0&&i<=r,l=i<=e.width&&i>=e.width-r;return n||a||o||l}_applyDragPosition(){if(null===this._pointerId||!this._isDragging)return;const t=this._currentX-this._startX,e=this._currentY-this._startY,i=Math.max(0,window.innerWidth-this._dialogWidth),s=Math.max(0,window.innerHeight-this._dialogHeight),r=Math.min(i,Math.max(0,this._dialogStartLeft+t)),n=Math.min(s,Math.max(0,this._dialogStartTop+e));this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._updateDebugValues("dragging")}_onNativeDragStart(t){null!==this._pointerId&&t.preventDefault()}_applyDragStyles(){this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top"}_restoreDragStyles(){this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const t=this._dialogElement.querySelectorAll("iframe");for(const e of t)this._lockedIframes.push({element:e,pointerEvents:e.style.pointerEvents}),e.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const t of this._lockedIframes)t.element.style.pointerEvents=t.pointerEvents;this._lockedIframes=[]}}_normalizeOptions(t,e=h){const i={...e,...t},s=Number(i.threshold),r=Number(i.resizeEdgeSize),n="string"==typeof i.selector&&i.selector.trim()?i.selector:h.selector;return{...i,selector:n,threshold:Number.isFinite(s)&&s>=0?s:h.threshold,resizeEdgeSize:Number.isFinite(r)&&r>0?r:h.resizeEdgeSize,debug:Boolean(i.debug)}}_resolveDragArea(t){try{return t.closest(this._options.selector)}catch(e){return t.closest(h.selector)}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="170px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="7",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues(this._isDragging?"dragging":"idle")):this._setDebugVisibility(!1)}_setDebugVisibility(t){this._debugElement&&(this._debugElement.style.display=t?"block":"none")}_updateDebugValues(t="idle"){if(!this._debugElement||!this._options.debug)return;const e=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`drag:${t} x:${Math.round(e.left)} y:${Math.round(e.top)} w:${Math.round(e.width)} h:${Math.round(e.height)}`}},c={enable:!1,minWidth:300,minHeight:160,edgeSize:8,debug:!1},_={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"},u=class{constructor(t,e,i={}){this._modalElement=t,this._dialogElement=e,this._contentElement=this._dialogElement?this._dialogElement.querySelector(".vg-toast-wrapper"):null,this._options=this._normalizeOptions(i),this._pointerId=null,this._direction="",this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._startWidth=0,this._startHeight=0,this._startLeft=0,this._startTop=0,this._startRight=0,this._startBottom=0,this._isEnabled=!1,this._observer=null,this._syncFrameId=null,this._resizeFrameId=null,this._lockedIframes=[],this._debugElement=null,this._previousMaxWidth="",this._previousMaxHeight="",this._previousPointerEvents="",this._previousMinHeight="",this._previousOverflow="",this._previousTransition="",this._previousWillChange="",this._previousContentHeight="",this._previousContentMaxHeight="",this._previousContentOverflow="",this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerLeave=this._onPointerLeave.bind(this),this._applyResizePosition=this._applyResizePosition.bind(this)}setOptions(t={}){this._options=this._normalizeOptions(t,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._modalElement.addEventListener("pointermove",this._onPointerMove),this._modalElement.addEventListener("pointerdown",this._onPointerDown),this._modalElement.addEventListener("pointerleave",this._onPointerLeave),this._startObserveSizeChanges(),this._isEnabled=!0)}disable(){this._isEnabled&&(this._modalElement.removeEventListener("pointermove",this._onPointerMove),this._modalElement.removeEventListener("pointerdown",this._onPointerDown),this._modalElement.removeEventListener("pointerleave",this._onPointerLeave),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._stopObserveSizeChanges(),this._pointerId=null,this._direction="",this._dialogElement.style.cursor="",delete this._modalElement.dataset.vgToastResizing,this._unlockEmbeddedFrames(),this._restoreResizeStyles(),this._setDebugVisibility(!1),this._isEnabled=!1)}syncToViewport(){if(this._modalElement&&"true"===this._modalElement.dataset.vgToastDragging)return;if(!this._isPreparedForInteraction())return;const t=this._dialogElement.getBoundingClientRect(),e=this._dialogElement.offsetWidth||t.width,i=this._dialogElement.offsetHeight||t.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:t.left,a=Number.isFinite(r)?r:t.top,o=window.innerWidth,l=window.innerHeight,h=Math.max(this._options.minWidth,Math.min(e,o)),d=Math.max(this._options.minHeight,Math.min(i,l)),c=Math.max(0,window.innerWidth-h),_=Math.max(0,window.innerHeight-d),u=Math.min(c,Math.max(0,n)),m=Math.min(_,Math.max(0,a));Math.abs(e-h)>.5&&(this._dialogElement.style.width=`${h}px`),Math.abs(i-d)>.5&&(this._dialogElement.style.height=`${d}px`),this._dialogElement.style.left=`${u}px`,this._dialogElement.style.top=`${m}px`,this._updateDebugValues()}_onPointerDown(t){if(0!==t.button)return;if(t.defaultPrevented)return;const e=this._getDirectionFromPointer(t);if(!e)return;t.preventDefault(),this._pointerId=t.pointerId,this._direction=e;const i=this._dialogElement.getBoundingClientRect();this._applyResizeStyles(),this._preparePosition(i),this._startX=t.clientX,this._startY=t.clientY,this._currentX=t.clientX,this._currentY=t.clientY,this._startWidth=i.width,this._startHeight=i.height,this._startLeft=i.left,this._startTop=i.top,this._startRight=i.right,this._startBottom=i.bottom,this._lockEmbeddedFrames(),this._modalElement.dataset.vgToastResizing="true",this._setDebugVisibility(!0),this._updateDebugValues(),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)}_onPointerMove(t){if(null===this._pointerId){const e=this._getDirectionFromPointer(t);return void(this._dialogElement.style.cursor=e?_[e]:"")}t.pointerId===this._pointerId&&(this._currentX=t.clientX,this._currentY=t.clientY,null===this._resizeFrameId&&(this._resizeFrameId=window.requestAnimationFrame(this._applyResizePosition)))}_applyResizePosition(){if(this._resizeFrameId=null,null===this._pointerId)return;const t=this._currentX-this._startX,e=this._currentY-this._startY;let i=this._startWidth,s=this._startHeight,r=this._startLeft,n=this._startTop;if(this._direction.includes("e")){const e=Math.max(this._options.minWidth,window.innerWidth-this._startLeft);i=Math.min(e,Math.max(this._options.minWidth,this._startWidth+t))}if(this._direction.includes("s")){const t=Math.max(this._options.minHeight,window.innerHeight-this._startTop);s=Math.min(t,Math.max(this._options.minHeight,this._startHeight+e))}if(this._direction.includes("w")){const e=this._startRight-this._options.minWidth;r=Math.min(e,Math.max(0,this._startLeft+t)),i=this._startRight-r}if(this._direction.includes("n")){const t=this._startBottom-this._options.minHeight;n=Math.min(t,Math.max(0,this._startTop+e)),s=this._startBottom-n}this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._dialogElement.style.width=`${i}px`,this._dialogElement.style.height=`${s}px`,this._updateDebugValues()}_onPointerUp(t){t.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._applyResizePosition(),this._pointerId=null,this._direction="",delete this._modalElement.dataset.vgToastResizing,this._unlockEmbeddedFrames(),this._setDebugVisibility(this._options.debug),this._updateDebugValues())}_onPointerLeave(){null===this._pointerId&&(this._dialogElement.style.cursor="")}_getDirectionFromPointer(t){const e=this._dialogElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,r=this._options.edgeSize;if(!(i>=0&&i<=e.width&&s>=0&&s<=e.height))return"";const n=s>=0&&s<=r,a=s<=e.height&&s>=e.height-r,o=i>=0&&i<=r,l=i<=e.width&&i>=e.width-r;return n&&o?"nw":n&&l?"ne":a&&o?"sw":a&&l?"se":n?"n":a?"s":o?"w":l?"e":""}_preparePosition(t){this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${t.left}px`,this._dialogElement.style.top=`${t.top}px`,this._dialogElement.style.width=`${t.width}px`,this._dialogElement.style.height=`${t.height}px`,this._dialogElement.style.transform="none",this._dialogElement.style.translate="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_startObserveSizeChanges(){"undefined"==typeof ResizeObserver||this._observer||(this._observer=new ResizeObserver(()=>{null===this._pointerId&&(this._modalElement&&"true"===this._modalElement.dataset.vgToastDragging||null===this._syncFrameId&&(this._syncFrameId=window.requestAnimationFrame(()=>{this._syncFrameId=null,this.syncToViewport()})))}),this._observer.observe(this._dialogElement))}_stopObserveSizeChanges(){this._observer&&(this._observer.disconnect(),this._observer=null),null!==this._syncFrameId&&(window.cancelAnimationFrame(this._syncFrameId),this._syncFrameId=null)}_applyResizeStyles(){this._previousMaxWidth=this._dialogElement.style.maxWidth,this._previousMaxHeight=this._dialogElement.style.maxHeight,this._previousPointerEvents=this._dialogElement.style.pointerEvents,this._previousMinHeight=this._dialogElement.style.minHeight,this._previousOverflow=this._dialogElement.style.overflow,this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.maxWidth="none",this._dialogElement.style.maxHeight="none",this._dialogElement.style.pointerEvents="auto",this._dialogElement.style.minHeight=`${this._options.minHeight}px`,this._dialogElement.style.overflow="hidden",this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top, width, height",this._contentElement&&(this._previousContentHeight=this._contentElement.style.height,this._previousContentMaxHeight=this._contentElement.style.maxHeight,this._previousContentOverflow=this._contentElement.style.overflow,this._contentElement.style.height="100%",this._contentElement.style.maxHeight="100%",this._contentElement.style.overflow="auto")}_restoreResizeStyles(){this._dialogElement.style.maxWidth=this._previousMaxWidth,this._dialogElement.style.maxHeight=this._previousMaxHeight,this._dialogElement.style.pointerEvents=this._previousPointerEvents,this._dialogElement.style.minHeight=this._previousMinHeight,this._dialogElement.style.overflow=this._previousOverflow,this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange,this._contentElement&&(this._contentElement.style.height=this._previousContentHeight,this._contentElement.style.maxHeight=this._previousContentMaxHeight,this._contentElement.style.overflow=this._previousContentOverflow)}_normalizeOptions(t,e=c){const i={...e,...t},s=Number(i.minWidth),r=Number(i.minHeight),n=Number(i.edgeSize);return{...i,minWidth:Number.isFinite(s)&&s>0?s:c.minWidth,minHeight:Number.isFinite(r)&&r>0?r:c.minHeight,edgeSize:Number.isFinite(n)&&n>0?n:c.edgeSize,debug:Boolean(i.debug)}}_cancelResizeFrame(){null!==this._resizeFrameId&&(window.cancelAnimationFrame(this._resizeFrameId),this._resizeFrameId=null)}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const t=this._dialogElement.querySelectorAll("iframe");for(const e of t)this._lockedIframes.push({element:e,pointerEvents:e.style.pointerEvents}),e.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const t of this._lockedIframes)t.element.style.pointerEvents=t.pointerEvents;this._lockedIframes=[]}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="8px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="6",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues()):this._setDebugVisibility(!1)}_setDebugVisibility(t){this._debugElement&&(this._debugElement.style.display=t?"block":"none")}_updateDebugValues(){if(!this._debugElement||!this._options.debug)return;const t=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`w:${Math.round(t.width)} h:${Math.round(t.height)} x:${Math.round(t.left)} y:${Math.round(t.top)}`}},m="vg.toast",p="vg-toast-open",g="show",f="shown",b="vg-toast-effect-",v={none:"",fade:`${b}fade`,zoom:`${b}zoom`,blur:`${b}blur`,"slide-up":`${b}slide-up`,"slide-down":`${b}slide-down`},y=`${m}.hide`,w=`${m}.hidden`,E=`${m}.show`,A=`${m}.shown`,S=`${m}.loaded`,C=`keydown.dismiss.${m}`,x=`click.${m}.data.api`,L=`pointerdown.interaction.${m}`,I=`pointerup.interaction.${m}`,P=`pointercancel.interaction.${m}`,M={success:"success",error:"danger",warning:"warning",info:"info"},k={static:!0,placement:"bottom center",autohide:!1,delay:3e3,enableClickToast:!0,enableButtonClose:!1,keyboard:!0,theme:"dark",type:null,stack:{enable:!0,max:5},drag:{enable:!1,selector:".vg-toast-wrapper",threshold:4,resizeEdgeSize:8,debug:!1},resize:{enable:!1,edgeSize:8,minWidth:220,minHeight:64,debug:!1},animation:{enable:!0,in:"animate__backInUp",out:"animate__backOutDown",delay:300,effect:"none"},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0}};class D extends s.A{constructor(t,e={}){super(t,e),this._interactionDefaults={drag:{enable:!1,selector:".vg-toast-wrapper",threshold:4,resizeEdgeSize:8,debug:!1},resize:{enable:!1,edgeSize:8,minWidth:220,minHeight:64,debug:!1}},this._params=this._getParams(t,(0,o._v)(k,e)),this._dragHandler=new d(this._element,this._element),this._resizeHandler=new u(this._element,this._element),this._interactionConfig=this._resolveInteractionConfig(),this._dragHandler.setOptions(this._interactionConfig.drag),this._resizeHandler.setOptions(this._interactionConfig.resize),this._animation(this._element,D.NAME_KEY,this._params.animation),this._applyAnimationEffects(),this._dismissElement(),this._addEventListeners(),this._timeout=null,this._hideTimeout=null,this._isHiding=!1}static get NAME(){return"toast"}static get NAME_KEY(){return m}static run(t,e={},i){return D.build(t,e,i)}static build(t,e,i){const s=e&&"object"==typeof e?e:{},r=Object.prototype.hasOwnProperty.call(s,"autohide");(e=(0,o._v)(k,{static:!1,autohide:!0},s)).static&&!r&&(e.autohide=!1);const l="vg-toast-"+(0,o.PR)(),h=document.createElement("div");h.classList.add("vg-toast"),h.id=l,e.theme&&h.classList.add(`vg-toast-${e.theme}`),e.placement&&e.placement.split(" ").forEach(t=>h.classList.add(t));const d=document.createElement("div");if(d.classList.add("vg-toast-wrapper"),e.type){const t=M[e.type],i=t?(0,n.z)(t):"";if(i){const t=document.createElement("div");t.classList.add("vg-toast-icon");const e=a.A.toSafeHtmlString(i),s=document.createRange().createContextualFragment(e).firstElementChild;s&&t.append(s),d.append(t)}}const c=document.createElement("div");c.classList.add("vg-toast-content");const _=document.createElement("div");if(_.classList.add("vg-toast-body"),"string"==typeof t)_.innerHTML=t,c.append(_);else if(Array.isArray(t)){if(t.length>1){const e=document.createElement("div");e.classList.add("vg-toast-header"),e.innerHTML=t[0],c.append(e)}_.innerHTML=t[1],c.append(_)}if(d.append(c),e.enableButtonClose){h.classList.add("vg-toast-has-button");const t=document.createElement("div");t.classList.add("vg-toast-button"),t.innerHTML='<button class="vg-btn-close" data-vg-dismiss="toast"></button>',d.append(t)}h.append(d),document.body.append(h);const u=D.getOrCreateInstance(h,e);return e.animation&&(u._animation(h,D.NAME_KEY,e.animation),u._applyAnimationEffects()),(0,o.g7)(i,[u]),u.show(),u}toggle(t){return this._isShown()?this.hide():this.show(t)}show(t){if((0,o.d6)(this._element))return;const e=this._element;this._clearTimeout(),this._clearHideTimeout(),this._isHiding=!1,this._disableInteractionHandlers(),this._params=this._getParams(t||{},this._params),this._route((t,i)=>{this._element===e&&r.A.trigger(e,S,{stats:t,data:i})}),r.A.trigger(e,E,{relatedTarget:t}).defaultPrevented||(e.classList.remove(f),e.classList.add(g),document.body.classList.add(p),this._setPlacement(),this._queueCallback(()=>{this._element!==e||this._isHiding||(e.classList.add(f),this._toggleInteractionHandlers(),this._syncInteractiveBounds(),this._scheduleHide(),r.A.trigger(e,A,{relatedTarget:t}))},e,!0,this._params.animation.delay))}hide(){if((0,o.d6)(this._element)||this._isHiding)return;const t=this._element;this._clearTimeout(),this._clearHideTimeout(),r.A.trigger(t,y).defaultPrevented||(this._isHiding=!0,t.classList.remove(f),this._disableInteractionHandlers(),this._hideTimeout=setTimeout(()=>{this._hideTimeout=null,this._element===t&&(t.classList.remove(g),this._params.stack.enable&&this._setPlacement(),this._queueCallback(()=>{if(this._element!==t)return;l.A.find(".vg-toast.show")||document.body.classList.remove(p);const e=!this._params.static;this._isHiding=!1,r.A.trigger(t,w),this._element===t&&e&&this.dispose()},t,!1,this._params.animation.delay))},this._params.animation.delay))}dispose(){this._element&&(this._clearTimeout(),this._clearHideTimeout(),this._disableInteractionHandlers(),this._params.static||this._element.remove(),super.dispose())}_scheduleHide(){this._clearTimeout(),this._params.autohide&&(this._timeout=setTimeout(()=>this.hide(),this._params.delay))}_isShown(){return!!this._element&&this._element.classList.contains(g)}_enableStack(){const t=this._params.placement.includes("top")?"top":"bottom",e=l.A.findAll(`.vg-toast.show.${t}`).filter(t=>{const e=D.getInstance(t);return e?._params.stack.enable});if(!this._params.stack.enable)return e.filter(t=>t!==this._element).forEach(t=>D.getInstance(t).hide()),[{el:this._element,top:0}];e.length>=this._params.stack.max&&e.slice(0,e.length-this._params.stack.max+1).forEach(t=>D.getInstance(t).hide());const i=e.filter(t=>t!==this._element).reduce((t,e)=>t+e.clientHeight,0);return e.includes(this._element)?e.map((t,i)=>({el:t,top:e.slice(0,i).reduce((t,e)=>t+e.clientHeight,0)})):[{el:this._element,top:i}]}_setPlacement(){const t=this._enableStack(),e=this._params.placement.includes("top"),i=e?"top":"bottom",s=l.A.findAll(`.vg-toast.show.${i}`).filter(t=>{const e=D.getInstance(t);return e?._params.stack.enable}),r=s.length?s:t.map(t=>t.el);let n=0;r.forEach(t=>{const i=D.getInstance(t),s=i?._params.placement||this._params.placement,r=s.includes("center"),a=s.includes("left"),o=s.includes("right"),l=t.style;l.left="",l.right="",l.top="",l.bottom="",l.transform="",l.translate="",r?(l.left="50%",l.translate="-50% 0"):a?l.left="0":o?l.right="0":(l.left="50%",l.translate="-50% 0"),e?l.top=n+"px":l.bottom=n+"px",n+=t.offsetHeight})}_toggleInteractionHandlers(){this._interactionConfig=this._resolveInteractionConfig(),this._dragHandler.setOptions(this._interactionConfig.drag),this._resizeHandler.setOptions(this._interactionConfig.resize),this._interactionConfig.drag.enable?this._dragHandler.enable():this._dragHandler.disable(),this._interactionConfig.resize.enable?this._resizeHandler.enable():this._resizeHandler.disable()}_disableInteractionHandlers(){this._dragHandler.disable(),this._resizeHandler.disable()}_syncInteractiveBounds(){this._interactionConfig.resize.enable&&this._resizeHandler.syncToViewport(),this._interactionConfig.drag.enable&&this._dragHandler.syncPosition()}_resolveInteractionConfig(){return{drag:this._normalizeInteractionParams(this._params.drag,this._interactionDefaults.drag),resize:this._normalizeInteractionParams(this._params.resize,this._interactionDefaults.resize)}}_normalizeInteractionParams(t,e){if("boolean"==typeof t)return{...e,enable:t};if(t&&"object"==typeof t){const i=Object.prototype.hasOwnProperty.call(t,"enable");return{...e,...t,enable:!i||Boolean(t.enable)}}return{...e}}_applyAnimationEffects(){const t=this._element.classList;[...t].filter(t=>t.startsWith(b)).forEach(e=>t.remove(e)),this._resolveAnimationEffectClasses(this._params.animation?.effect).forEach(e=>t.add(e))}_resolveAnimationEffectClasses(t){const e=(Array.isArray(t)?t:[t]).filter(Boolean).map(t=>this._resolveAnimationEffectClass(t)).filter(Boolean);return Array.from(new Set(e))}_resolveAnimationEffectClass(t){if("string"!=typeof t)return"";const e=t.trim().toLowerCase();return e?Object.prototype.hasOwnProperty.call(v,e)?v[e]:t.trim():""}_clearTimeout(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)}_clearHideTimeout(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_addEventListeners(){this._params.keyboard&&r.A.on(document,C,t=>{"Escape"===t.key&&this._isShown()&&this.hide()}),this._params.enableClickToast&&(this._element.classList.add("vg-toast-pointer"),r.A.on(document,x,`#${this._element.id}`,()=>{this.hide()})),r.A.on(this._element,L,()=>{this._clearTimeout()});const t=()=>{this._isShown()&&this._scheduleHide()};r.A.on(this._element,I,t),r.A.on(this._element,P,t)}}(0,n.P)(D),r.A.on(document,x,'[data-vg-toggle="toast"]',function(t){const e=l.A.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,o.d6)(this)||(this.setAttribute("aria-expanded","true"),r.A.one(e,w,()=>{this.setAttribute("aria-expanded","false")}),D.getOrCreateInstance(e).toggle(this))});const T=D},11(t,e,i){i.d(e,{A:()=>r});var s=i(381);const r=class{static _toRouteQueryParamValue(t){return Array.isArray(t)?t.map(t=>String(t||"").trim()).filter(t=>""!==t).join(","):t}static buildRouteUrl(t,e={}){const i=String(t||"").trim();if(!i)throw new Error("Request endpoint is empty");const r=(0,s.Gv)(e.baseParams)?e.baseParams:{},n=(0,s.Gv)(e.params)?e.params:{},a=new URL(i,window.location.origin),o={...r,...n};return Object.keys(o).forEach(t=>{const e=this._toRouteQueryParamValue(o[t]);null!=e&&""!==e&&a.searchParams.set(t,String(e))}),a}static async requestRoute(t={}){const e=String(t.method||"GET").toUpperCase().trim()||"GET",i=(0,s.Gv)(t.headers)?{...t.headers}:{},r=String(t.credentials||"same-origin").trim()||"same-origin",n=(0,s.Gv)(t.baseParams)?t.baseParams:{},a=(0,s.Gv)(t.params)?t.params:{},o=void 0!==t.body&&null!==t.body,l="GET"===e||"HEAD"===e,h=String(t.route||t.endpoint||"").trim(),d=this.buildRouteUrl(h,{baseParams:n,params:l?a:{}}),c={method:e,credentials:r,headers:i,signal:t.signal||void 0};if(!l&&o){const e=t.body;"undefined"!=typeof FormData&&e instanceof FormData?(delete c.headers["Content-Type"],c.body=e):"string"==typeof e?(c.headers["Content-Type"]||(c.headers["Content-Type"]="application/json"),c.body=e):(c.headers["Content-Type"]||(c.headers["Content-Type"]="application/json"),c.body=JSON.stringify(e))}const _=await fetch(d.toString(),c),u=String(_.headers.get("content-type")||"").toLowerCase(),m="json"===t.responseType||"text"!==t.responseType&&u.includes("application/json"),p=await(async()=>{if(m)try{return await _.json()}catch(t){return await _.text()}return _.text()})();if(!_.ok){const t=p&&"object"==typeof p&&p.error&&"object"==typeof p.error?p.error:{},e="string"==typeof p&&p.trim()?p:_.statusText,i=String(t.message||e||"Request failed"),s=new Error(i);throw s.status=_.status,s.code=t.code||"REQUEST_FAILED",s.details=Array.isArray(t.details)?t.details:[],s.requestId=t.request_id||_.headers.get("X-Request-Id")||"",s.response=p,s}return p}constructor(t={}){this.baseUrl=t.baseUrl||"",this.defaultHeaders={"X-Requested-With":"XMLHttpRequest",...t.headers},this.withCredentials=t.withCredentials||!1,this.csrfToken=t._token||this._getCsrfToken()}_getCsrfToken(){const t=document.querySelector('meta[name="csrf-token"]');return t?t.getAttribute("content"):(console.warn('CSRF-токен не найден в <meta name="csrf-token">'),"")}request(t,{method:e="GET",body:i=null,headers:r={},signal:n=null,onProgress:a=null,onSuccess:o=s.lQ,onError:l=s.lQ,onUploadStart:h=s.lQ,onUploadEnd:d=s.lQ}={}){const c=this.baseUrl+t,_=i instanceof FormData,u={...this.defaultHeaders,...r},m="GET"===e.toUpperCase();return m&&(i=null),m||_||!this.csrfToken||(i||(i={}),"object"!=typeof i||Array.isArray(i)||(i._token=this.csrfToken)),_||"Content-Type"in r||(u["Content-Type"]="application/json"),_||a?this._makeXHR({method:e,url:c,body:i,headers:u,signal:n,onProgress:a,onSuccess:o,onError:l,onUploadStart:h,onUploadEnd:d}):this._makeFetch({url:c,method:e,body:m?void 0:this._serializeBody(i),headers:u,signal:n,withCredentials:this.withCredentials,onSuccess:o,onError:l})}_makeFetch({url:t,method:e,body:i,headers:r,signal:n,withCredentials:a,onSuccess:o,onError:l}){const h={method:e,headers:r,signal:n,credentials:a?"include":"same-origin",...void 0!==i&&{body:i}};fetch(t,h).then(t=>{const e=t.headers.get("content-type"),i=e&&e.includes("application/json");if(!t.ok)return Promise.reject((0,s.OM)({code:t.status,response:i?t.json().catch(()=>t.text()):t.text()}));let r={code:t.status};return r.response=i?t.json():t.text(),r}).then(t=>{t&&t.response instanceof Promise?t.response.then(e=>o({...t,response:e}),()=>{}):o(t)}).catch(t=>{"AbortError"!==t.name&&(t&&t.response instanceof Promise?t.response.then(e=>{l({...t,response:e})},()=>{l({...t,response:"Request failed"})}):l(t))})}_makeXHR({method:t,url:e,body:i,headers:r,signal:n,onProgress:a,onSuccess:o,onError:l,onUploadStart:h,onUploadEnd:d}){const c=new XMLHttpRequest;return c.open(t,e,!0),c.withCredentials=this.withCredentials,Object.keys(r).forEach(t=>{"content-type"===t.toLowerCase()&&i instanceof FormData||c.setRequestHeader(t,r[t])}),a&&c.upload.addEventListener("progress",t=>{t.lengthComputable&&a(Math.round(t.loaded/t.total*100),t)}),c.onload=()=>{if(c.status>=200&&c.status<300){const t={code:c.status,response:(0,s.OM)(c.responseText)};o(t)}else{const t=(0,s.OM)({code:c.status,response:c.responseText||`HTTP ${c.status}`});l(t)}d()},c.onerror=()=>{l((0,s.OM)({code:0,response:"Network Error"})),d()},c.ontimeout=()=>{l((0,s.OM)({code:0,response:"Request Timeout"})),d()},n&&n.addEventListener("abort",()=>{c.abort()}),h(),c.send(i),c}get(t,e={}){return this.request(t,{method:"GET",...e})}post(t,e,i={}){return this.request(t,{method:"POST",body:e,...i})}put(t,e,i={}){return this.request(t,{method:"PUT",body:e,...i})}delete(t,e={}){return this.request(t,{method:"DELETE",...e})}patch(t,e,i={}){return this.request(t,{method:"PATCH",body:e,...i})}_serializeBody(t){if(t&&!(t instanceof FormData))return JSON.stringify(t)}}},667(t,e,i){i.d(e,{A:()=>a});var s=i(381),r=i(23);class n{constructor(t,e=null){this._params=this.merge(t,e)}get(){return this._params}fromElement(t){return(0,s.vq)(t)?r.p.get(t):{}}static stringToNestedObject(t,e){return t.split("-").reduceRight((t,e)=>({[e]:t}),e)}merge(t,e){let i=(0,s._v)(t,this.fromElement(e));return Object.keys(i).forEach(t=>{if("params"===t&&(i=(0,s._v)(i,i.params),delete i.params),t.includes("-")){const e=n.stringToNestedObject(t,i[t]);i=(0,s._v)(i,e),delete i[t]}}),i}}const a=n},546(t,e,i){i.d(e,{A:()=>l});const s=new Set(["svg","g","path","line","polyline","polygon","circle","ellipse","rect","defs","symbol","title","use"]),r=new Set(["xmlns","viewbox","width","height","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","opacity","transform","class","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","points","d","role","focusable","aria-hidden","href","xlink:href"]);function n(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function a(t,e=s,i=r){if(!t)return null;if(t.nodeType===Node.TEXT_NODE)return document.createTextNode(t.textContent||"");if(t.nodeType!==Node.ELEMENT_NODE)return null;const n=t.tagName.toLowerCase();if(!e.has(n))return null;const o=document.createElementNS("http://www.w3.org/2000/svg",n);return Array.from(t.attributes||[]).forEach(t=>{const e=t.name.toLowerCase(),s=t.value||"";i.has(e)&&!e.startsWith("on")&&("href"!==e&&"xlink:href"!==e||!s||s.startsWith("#"))&&o.setAttribute(e,s)}),Array.from(t.childNodes||[]).forEach(t=>{const s=a(t,e,i);s&&o.append(s)}),o}function o(t,{allowedSvgTags:e=s,allowedSvgAttrs:i=r}={}){if(null==t)return"";const o=String(t).trim();if(!o)return"";if(!o.includes("<"))return n(o);const l=document.createElement("template");return l.innerHTML=o,Array.from(l.content.childNodes).map(t=>a(t,e,i)).filter(Boolean).map(t=>t.nodeType===Node.TEXT_NODE?n(t.textContent||""):t.nodeType===Node.ELEMENT_NODE?t.outerHTML:"").join("")||n(o)}const l=class{static toSafeHtmlString(t,e){return o(t,e)}}},601(t,e,i){i.d(e,{A:()=>n});var s=i(810);class r{constructor(t="string"){this.mode=t,this.document="undefined"!=typeof document?document:null,this.tags={selfClosing:["img","input","br","hr","meta","link","area","base","col","command","embed","keygen","param","source","track","wbr"]}}setMode(t){return this.mode=t,this}element(t,e={},i=null,s={}){return"dom"===this.mode&&this.document?this._createDomElement(t,e,i,s):this._createHtmlString(t,e,i,s)}_createDomElement(t,e,i,s={}){const r=this.document.createElement(t);return this._setDomAttributes(r,e),null===i||this.tags.selfClosing.includes(t)||(Array.isArray(i)?i.forEach(t=>{"string"==typeof t?r.appendChild(this.document.createTextNode(t)):t instanceof Node&&r.appendChild(t)}):i instanceof Node?r.appendChild(i):"isHTML"in s&&s.isHTML?r.innerHTML=i:r.textContent=i),r}_setDomAttributes(t,e){e&&Object.entries(e).forEach(([e,i])=>{null!=i&&!1!==i&&(!0===i?t.setAttribute(e,""):t.setAttribute(e,String(i)))})}_createHtmlString(t,e,i,s=!1){const r=this._attributesToString(e);if(this.tags.selfClosing.includes(t))return`<${t}${r}>`;const n=null!==i?this._contentToString(i):"";return""===t?`${n}`:`<${t}${r}>${n}</${t}>`}_contentToString(t){return Array.isArray(t)?t.map(t=>t instanceof Node?this._nodeToString(t):String(t)).join(""):t instanceof Node?this._nodeToString(t):String(t)}_nodeToString(t){return t.outerHTML?t.outerHTML:String(t)}_attributesToString(t){if(!t||0===Object.keys(t).length)return"";const e=Object.entries(t).map(([t,e])=>null==e||!1===e?"":!0===e?t:`${t}="${String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}"`).filter(t=>""!==t);return e.length?" "+e.join(" "):""}div(t={},e="",i={}){return this.element("div",t,e,i)}span(t={},e="",i={}){return this.element("span",t,e,i)}i(t={},e="",i={}){return this.element("i",t,e,i)}p(t={},e="",i={}){return this.element("p",t,e,i)}a(t,e="",i={},s={}){return this.element("a",{href:t,...i},e,s)}img(t,e="",i={}){return this.element("img",{src:t,alt:e,...i})}input(t,e="text",i="",s={}){return this.element("input",{type:e,name:t,value:i,...s})}button(t="",e="button",i={},s={}){return this.element("button",{type:e,...i},t,s)}form(t="",e="post",i={},s="",r={}){return this.element("form",{action:t,method:e,...i},s,r)}label(t,e,i={},s={}){return this.element("label",{for:t,...i},e,s)}textarea(t,e="",i={}){return this.element("textarea",{name:t,...i},e)}ul(t=[],e={},i=!1){let s=[];return s=i?t:t.map(t=>this.element("li",{},t)),this.element("ul",e,s)}li(t={},e,i){return this.element("li",t,e,i)}ol(t=[],e={}){const i=t.map(t=>this.element("li",{},t));return this.element("ol",e,i)}h4(t={},e="",i={}){return this.element("h4",t,e,i)}table(t=[],e=[],i={}){const s=t.map(t=>this.element("th",{},t)),r=this.element("tr",{},s),n=this.element("thead",{},r),a=e.map(t=>{const e=t.map(t=>this.element("td",{},t));return this.element("tr",{},e)}),o=this.element("tbody",{},a);return this.element("table",i,[n,o])}csrfToken(t){return this.element("input",{type:"hidden",name:"_token",value:t})}method(t){return this.element("input",{type:"hidden",name:"_method",value:t})}withEvents(t,e={}){return t instanceof Node&&"dom"===this.mode&&Object.entries(e).forEach(([e,i])=>{t.addEventListener(e,i)}),t}addClass(t,e){if(t instanceof Node&&"dom"===this.mode)t.classList.add(e);else if("string"==typeof t){const i=t.match(/<(\w+)([^>]*)>/);if(i){const[s,r,n]=i,a=this._addClassToAttributes(n,e);return t.replace(s,`<${r}${a}>`)}}return t}_addClassToAttributes(t,e){const i=t.match(/class="([^"]*)"/);if(i){const s=i[1],r=s?`${s} ${e}`:e;return t.replace(/class="[^"]*"/,`class="${r}"`)}return`${t} class="${e}"`}component(t,e={},i={}){const r={eye:t=>{const e=t.type||"open",i=this.element("",{},(0,s.z)(`eye-${e}`));return this.span({"data-vg-toggle":"pass","data-bs-toggle":"tooltip",title:"Скрыть",class:t.class||""},[i])},alert:t=>{const e=t.type||"info";return this.div({class:`alert alert-${e}`,role:"alert"},t.content||"")},card:t=>{const e=t.header?this.div({class:"card-header"},t.header):"",i=this.div({class:"card-body"},t.body||""),s=t.footer?this.div({class:"card-footer"},t.footer):"";return this.div({class:"card"},[e,i,s])}};return r[t]?r[t](e):this.div({class:`component-${t}`},"")}}const n=function(t="string"){const e=new r(t);return new Proxy(e,{get:(t,e)=>e in t?t[e].bind(t):function(i={},s="",r={}){return t.element(e,i,s,r)}})}},647(t,e,i){i.d(e,{A:()=>v});const s=/[^.]*(?=\..*)\.|.*/,r=/\..*/,n=/::\d+$/,a={mouseenter:"mouseover",mouseleave:"mouseout"},o=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","submit","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","popstate","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]),l={};let h=1;const d=(t,e=null)=>(t.uidEvent||(t.uidEvent=e?`${e}::${h++}`:h++),t.uidEvent),c=t=>{const e=d(t);return l[e]=l[e]||{},l[e]},_=(t,e,i)=>{const s="string"==typeof e,n=s?i:e||i;let l=t.replace(r,"");return a[l]&&(l=a[l]),o.has(l)||(l=t),[s,n,l]},u=(t,e,i,r,n)=>{if("string"!=typeof e||!t)return;const[a,o,l]=_(e,i,r),h=c(t),u=h[l]||={},p=m(u,o,a?i:null);if(p)return void(p.oneOff=p.oneOff&&n);let g=a?((t,e,i,s)=>{const r=function(r){const n=Array.from(t.querySelectorAll(e));for(let a=r.target;a&&a!==t;a=a.parentNode)if(n.includes(a))return f(r,{delegateTarget:a}),s&&b.off(t,r.type,e,i),i.apply(a,[r])};return r.delegationSelector=e,r.callable=i,r.oneOff=s,r.uidEvent=null,r})(t,i,o,n):((t,e,i)=>{const s=function(s){return f(s,{delegateTarget:t}),i&&b.off(t,s.type,e),e.apply(t,[s])};return s.delegationSelector=null,s.callable=e,s.oneOff=i,s.uidEvent=null,s})(t,o,n);const v=d(g,e.replace(s,""));g.uidEvent=v,u[v]=g,t.addEventListener(l,g,a)},m=(t,e,i)=>Object.values(t).find(t=>t.callable===e&&t.delegationSelector===i),p=(t,e,i,s,r)=>{const n=m(e[i],s,r);n&&(t.removeEventListener(i,n,Boolean(r)),delete e[i][n.uidEvent])},g=(t,e,i,s)=>{const r=e[i]||{};for(const[n,a]of Object.entries(r))n.includes(s)&&p(t,e,i,a.callable,a.delegationSelector)},f=(t,e={})=>{for(const[i,s]of Object.entries(e))try{t[i]=s}catch{Object.defineProperty(t,i,{configurable:!0,get:()=>s})}return t},b={on(t,e,i,s){u(t,e,i,s,!1)},one(t,e,i,s){u(t,e,i,s,!0)},off(t,e,i,s){if("string"!=typeof e||!t)return;const[r,a,o]=_(e,i,s),l=c(t),h=e.startsWith("."),d=o!==e;if(h){for(const i of Object.keys(l))g(t,l,i,e.slice(1));return}const u=l[o]||{};if(void 0===a)for(const[i,s]of Object.entries(u)){const r=i.replace(n,"");d&&!e.includes(r)||p(t,l,o,s.callable,s.delegationSelector)}else p(t,l,o,a,r?i:null)},trigger(t,e,i){if("string"!=typeof e||!t)return null;const s=f(new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:i}),i);return t.dispatchEvent(s),s}},v=b},23(t,e,i){i.d(e,{p:()=>r,x:()=>n});var s=i(381);const r={get(t,e="data",i=!0){if(!(0,s.vq)(t))return{};if("all"===e)return Array.from(t.attributes).reduce((t,e)=>(t[e.name]=e.value,t),{});if("data"===e){const e=new Set(["data-vg-toggle","data-vg-target","data-vg-dismiss","data-vg-loaded"]),r={};return Array.from(t.attributes).filter(t=>t.name.startsWith("data-")).forEach(t=>{if(!e.has(t.name)){const e=i?t.name.slice(5):t.name;r[e]=(0,s.OM)(t.value)}}),r}return t.getAttribute(e)},has:(t,e)=>(0,s.vq)(t)&&t.hasAttribute(e),set(t,e,i){(0,s.vq)(t)&&e&&t.setAttribute(e,i)},remove(t,e){(0,s.vq)(t)&&e&&t.removeAttribute(e)},hide(t){(0,s.vq)(t)&&(t.style.display="none")},show(t,e="block"){(0,s.vq)(t)&&(t.style.display=e)}},n={remove(t,e){if(!(0,s.vq)(t)||!e)return;const i=Array.isArray(e)?e:e.split(" ").filter(Boolean);t.classList.remove(...i)},add(t,e,i=!1){if(!e)return;const r=Array.isArray(e)?e:e.split(" ").filter(Boolean);if(i)return r.join(" ");(0,s.vq)(t)&&t.classList.add(...r)},toggle(t,e,i=!0){(0,s.vq)(t)&&e&&t.classList.toggle(e,!!i)},replace(t,e,i){(0,s.vq)(t)&&e&&i&&t.classList.replace(e,i)},has:(t,e)=>(0,s.vq)(t)&&t.classList.contains(e)}},829(t,e,i){i.d(e,{A:()=>n});var s=i(381);const r=t=>{const e=t.getAttribute("data-vg-target");if(e&&"#"!==e)return e.trim();const i=t.getAttribute("href");if(!i||!i.includes("#")&&!i.startsWith("."))return null;const s=i.includes("#")&&!i.startsWith("#")?`#${i.split("#")[1]}`:i;return"#"!==s?s.trim():null},n={find(t,e=document.documentElement){if((0,s.vq)(t))return t;try{return e.querySelector(t)}catch(e){return console.warn("Invalid selector:",t,e),null}},findID(t,e=document){try{if("string"!=typeof t||""===t.trim())return null;const i=(e&&9===e.nodeType?e:e?.ownerDocument||document).getElementById(t);if(i)return e&&9!==e.nodeType?e.contains(i)?i:null:i;const s=e&&9===e.nodeType?e.documentElement:e;if(!s||"function"!=typeof s.querySelector)return null;const r=(t=>t&&window.CSS?.escape?CSS.escape(t):t.replace(/([:.#[]])/g,"\\$1"))(t);return s.querySelector(`#${r}`)}catch(e){return console.warn("Invalid ID in findID:",t,e),null}},findAll(t,e=document.documentElement){try{return Array.from(e.querySelectorAll(t))}catch(e){return console.warn("Invalid selector in findAll:",t,e),[]}},getSelectorFromElement(t){const e=r(t);return e&&this.find(e)?e:null},getElementFromSelector(t){const e=r(t);return e?this.find(e):null},getMultipleElementsFromSelector(t){const e=r(t);return e?this.findAll(e):[]},parents(t,e){const i=[];let s=t.parentElement?.closest(e);for(;s;)i.push(s),s=s.parentElement?.closest(e);return i},next(t,e){let i=t.nextElementSibling;for(;i;){if(i.matches(e))return[i];i=i.nextElementSibling}return[]},prev(t,e){let i=t.previousElementSibling;for(;i;){if(i.matches(e))return[i];i=i.previousElementSibling}return[]}}},381(t,e,i){i.d(e,{Ff:()=>v,Gv:()=>r,OM:()=>h,PR:()=>b,V6:()=>a,V8:()=>w,Xb:()=>E,_v:()=>d,d6:()=>o,dO:()=>u,g7:()=>c,iq:()=>y,lQ:()=>f,qm:()=>g,vq:()=>s,zN:()=>l,ze:()=>n});const s=t=>t?.nodeType===Node.ELEMENT_NODE,r=t=>t&&"object"==typeof t,n=t=>{if(!r(t))return!0;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0},a=t=>{if(s(t))return t;if(t?.jquery)return t[0]||null;if("string"==typeof t&&""!==t.trim())try{return document.querySelector(t)}catch(e){return console.warn("Invalid selector:",t),null}return null},o=t=>!s(t)||!!t.classList.contains("disabled")||(void 0!==t.disabled?!!t.disabled:t.hasAttribute("disabled")&&"false"!==t.getAttribute("disabled")),l=t=>{if(!s(t)||0===t.getClientRects().length)return!1;if("hidden"===getComputedStyle(t).visibility)return!1;const e=t.closest("details:not([open])");if(!e)return!0;const i=t.closest("summary");return!(!i||i.parentNode!==e)},h=t=>{if("true"===t)return!0;if("false"===t)return!1;if("null"===t)return null;if(""===t)return null;if("number"==typeof t||t===Number(t))return Number(t);if("string"!=typeof t)return t;try{return JSON.parse(decodeURIComponent(t))}catch{return t}},d=(...t)=>{const e=t=>t&&"object"==typeof t;return t.reduce((t,i)=>e(i)?(Object.keys(i).forEach(s=>{const r=t[s],n=i[s];Array.isArray(r)&&Array.isArray(n)?t[s]=r.concat(n):e(r)&&e(n)?t[s]=d(r,n):t[s]=n}),t):t,{})},c=(t,e=[],i=t)=>"function"==typeof t?t(...e):i,_="transitionend",u=(t,e,i=!0,s)=>{if(!e)return void c(t);if(!i)return void c(t);const r=s??m(e)+5;let n=!1;const a=i=>{i.target===e&&(n=!0,e.removeEventListener(_,a),c(t))};e.addEventListener(_,a),setTimeout(()=>{n||p(e)},r)},m=t=>{if(!t)return 0;const{transitionDuration:e,transitionDelay:i}=getComputedStyle(t),s=e.split(", "),r=i.split(", ");return 1e3*((Number.parseFloat(s[0])||0)+(Number.parseFloat(r[0])||0))},p=t=>{t&&t.dispatchEvent(new Event(_))},g=t=>{t.offsetHeight},f=()=>{},b=(t=7)=>{let e="";for(let i=0;i<t;i++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e},v=(t,e=!0)=>{const i="q w e r t y u i o p [ ] a s d f g h j k l ; ' z x c v b n m , .".split(" "),s="й ц у к е н г ш щ з х ъ ф ы в а п р о л д ж э я ч с м и т ь б ю".split(" "),r=e?i:s,n=e?s:i;let a=t;for(let t=0;t<r.length;t++){const e=r[t],i=n[t],s=r[t].toUpperCase(),o=n[t].toUpperCase();a=a.split(e).join(i).split(s).join(o)}return a},y=(t,e,i,s)=>{const r=t.length;let n=t.indexOf(e);return-1===n?i||!s?t[0]:t[r-1]:(n+=i?1:-1,s&&(n=(n%r+r)%r),t[Math.max(0,Math.min(n,r-1))])},w=()=>"rtl"===document.documentElement.dir;function E(){const t=navigator.userAgent,e=/Android|iPhone|iPad|iPod/i.test(t),i="ontouchstart"in window||navigator.maxTouchPoints>0,s=window.innerWidth<768,r=window.devicePixelRatio>=2;return e||i&&s&&r||function(){const t=navigator.userAgent,e=navigator.platform;if(!(/iPad/.test(t)||"MacIntel"===e&&navigator.maxTouchPoints>1))return{isiPadPro:!1};const i=window.screen.width*window.devicePixelRatio,s=window.screen.height*window.devicePixelRatio;return{isiPadPro:[{width:2048,height:2732},{width:1668,height:2388},{width:1668,height:2224}].some(t=>i===t.width&&s===t.height||i===t.height&&s===t.width),screenWidth:i,screenHeight:s,userAgent:t,platform:e}}().isiPadPro}}},e={};function i(s){var r=e[s];if(void 0!==r)return r.exports;var n=e[s]={exports:{}};return t[s](n,n.exports,i),n.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{var t=i(188),e=i(23),s=i(829),r=i(381);const n=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",a=".sticky-top",o="padding-right",l="margin-right",h=class{constructor(){}get _element(){return document.body}getWidth(){const t=document.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}isOverflowing(){return this.getWidth()>0}hide(){if(this.isOverflowing()&&!(0,r.Xb)()){const t=this.getWidth();this._disableOverflow(),this._setStyle(n,o,t,e=>e+t),this._setStyle(a,l,t,e=>e-t),this._setStyle(this._element,o,t,e=>e+t)}else(0,r.Xb)()&&this._disableOverflow()}reset(){this._resetStyle(this._element,"overflow"),this._resetStyle(this._element,o),this._resetStyle(n,o),this._resetStyle(a,l)}_disableOverflow(){this._saveInitialStyle(this._element,"overflow"),this._element.style.overflow="hidden"}_setStyle(t,e,i,s){this._applyToElements(t,t=>{if(t!==this._element&&window.innerWidth>t.clientWidth+i)return;this._saveInitialStyle(t,e);const r=getComputedStyle(t).getPropertyValue(e),n=Number.parseFloat(r)||0;t.style.setProperty(e,`${s(n)}px`)})}_resetStyle(t,i){this._applyToElements(t,t=>{const s=e.p.get(t,i);null!==s?(e.p.remove(t,i),t.style.setProperty(i,s)):t.style.removeProperty(i)})}_saveInitialStyle(t,i){if(null!==e.p.get(t,i))return;const s=t.style.getPropertyValue(i);e.p.set(t,i,s)}_applyToElements(t,e){(0,r.vq)(t)?e(t):s.A.findAll(t,this._element).forEach(e)}};var d=i(601);const c="vg-backdrop",_="fade",u="show";class m{static get _rootEl(){return document.body}static _scrollbar=new h;static _backdrop=null;static _backdrops=[];static getElement(){return this._syncBackdrops(),this._backdrop}static isActive(){return this._syncBackdrops(),this._backdrops.length>0}static show(t){const e=this._append();(0,r.g7)(t,[e])}static hide(t,e=null){this._syncBackdrops();const i=e&&e.isConnected?e:this._backdrop;i?this._destroy(i).then(r.g7.bind(null,t)):(0,r.g7)(t)}static _append(){const t=(0,d.A)("dom").div({class:c});return this._rootEl.appendChild(t),this._backdrops.push(t),this._backdrop=t,requestAnimationFrame(()=>{e.x.add(t,u),setTimeout(()=>{t.isConnected&&e.x.add(t,_)},150)}),t}static _destroy(t){return new Promise(i=>{e.x.remove(t,_),setTimeout(()=>{e.x.remove(t,u),t.remove(),this._backdrops=this._backdrops.filter(e=>e!==t&&e.isConnected),this._backdrop=this._backdrops.length?this._backdrops[this._backdrops.length-1]:null,this._backdrop||this._scrollbar.reset(),i()},150)})}static _syncBackdrops(){this._backdrops=this._backdrops.filter(t=>t&&t.isConnected),this._backdrops.length||(this._backdrops=Array.from(this._rootEl.querySelectorAll(`.${c}`))),this._backdrop=this._backdrops.length?this._backdrops[this._backdrops.length-1]:null}}const p=m;var g=i(647),f=i(810);const b={enable:!1,selector:".vg-modal-content",threshold:4,resizeEdgeSize:8,debug:!1},v=class{constructor(t,e,i={}){this._modalElement=t,this._dialogElement=e,this._options=this._normalizeOptions(i),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._dialogStartLeft=0,this._dialogStartTop=0,this._dialogWidth=0,this._dialogHeight=0,this._isEnabled=!1,this._previousUserSelect="",this._previousTransition="",this._previousWillChange="",this._initialRect=null,this._lockedIframes=[],this._debugElement=null,this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onNativeDragStart=this._onNativeDragStart.bind(this)}setOptions(t={}){this._options=this._normalizeOptions(t,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._dialogElement.addEventListener("pointerdown",this._onPointerDown),this._isEnabled=!0)}disable(){this._dialogElement&&this._isEnabled&&(this._dialogElement.removeEventListener("pointerdown",this._onPointerDown),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgModalDragging,this._setDebugVisibility(!1),this._isEnabled=!1)}syncPosition(){if(!this._isEnabled)return;if(!this._isPreparedForInteraction())return;const t=this._dialogElement.getBoundingClientRect(),e=this._dialogElement.offsetWidth||t.width,i=this._dialogElement.offsetHeight||t.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:t.left,a=Number.isFinite(r)?r:t.top,o=Math.max(0,window.innerWidth-e),l=Math.max(0,window.innerHeight-i),h=Math.min(o,Math.max(0,n)),d=Math.min(l,Math.max(0,a));this._dialogElement.style.left=`${h}px`,this._dialogElement.style.top=`${d}px`,this._updateDebugValues("synced")}_onPointerDown(t){if(0!==t.button)return;const e=this._resolveDragArea(t.target);e&&this._dialogElement.contains(e)&&(this._isPointerOnResizeEdge(t)||t.target.closest('input, textarea, select, button, a, [contenteditable="true"]')||e&&e.closest('[data-vg-dismiss="modal"]')||(this._pointerId=t.pointerId,this._dragTarget=t.target,this._isDragging=!1,t.preventDefault(),this._previousUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",this._initialRect=this._dialogElement.getBoundingClientRect(),this._dialogStartLeft=this._initialRect.left,this._dialogStartTop=this._initialRect.top,this._dialogWidth=this._initialRect.width,this._dialogHeight=this._initialRect.height,this._startX=t.clientX,this._startY=t.clientY,this._currentX=t.clientX,this._currentY=t.clientY,this._lockEmbeddedFrames(),this._modalElement.dataset.vgModalDragging="true",this._setDebugVisibility(!0),this._updateDebugValues("armed"),document.addEventListener("dragstart",this._onNativeDragStart,!0),this._dialogElement&&this._dialogElement.setPointerCapture&&this._dialogElement.setPointerCapture(t.pointerId),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)))}_onPointerMove(t){if(t.pointerId===this._pointerId){if(this._currentX=t.clientX,this._currentY=t.clientY,!this._isDragging){const e=this._currentX-this._startX,i=this._currentY-this._startY;if(Math.hypot(e,i)<this._options.threshold)return;this._isDragging=!0,this._dialogElement.style.touchAction="none",this._applyDragStyles(),this._preparePosition(this._initialRect),t.preventDefault(),this._updateDebugValues("dragging")}this._applyDragPosition()}}_onPointerUp(t){t.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),document.removeEventListener("dragstart",this._onNativeDragStart,!0),this._isDragging&&this._applyDragPosition(),this._dialogElement.style.touchAction="",document.body.style.userSelect=this._previousUserSelect,this._dialogElement&&this._dialogElement.releasePointerCapture&&this._dialogElement.releasePointerCapture(t.pointerId),this._pointerId=null,this._dragTarget=null,this._isDragging=!1,this._initialRect=null,this._unlockEmbeddedFrames(),this._restoreDragStyles(),delete this._modalElement.dataset.vgModalDragging,this._setDebugVisibility(this._options.debug),this._updateDebugValues("idle"))}_preparePosition(t=null){if(!this._dialogElement)return;const e=t||this._dialogElement.getBoundingClientRect();this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${e.left}px`,this._dialogElement.style.top=`${e.top}px`,this._dialogElement.style.width=`${e.width}px`,this._dialogElement.style.height=`${e.height}px`,this._dialogElement.style.transform="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_isPointerOnResizeEdge(t){const e=this._dialogElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,r=this._options.resizeEdgeSize,n=s>=0&&s<=r,a=s<=e.height&&s>=e.height-r,o=i>=0&&i<=r,l=i<=e.width&&i>=e.width-r;return n||a||o||l}_applyDragPosition(){if(null===this._pointerId||!this._isDragging)return;const t=this._currentX-this._startX,e=this._currentY-this._startY,i=Math.max(0,window.innerWidth-this._dialogWidth),s=Math.max(0,window.innerHeight-this._dialogHeight),r=Math.min(i,Math.max(0,this._dialogStartLeft+t)),n=Math.min(s,Math.max(0,this._dialogStartTop+e));this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._updateDebugValues("dragging")}_onNativeDragStart(t){null!==this._pointerId&&t.preventDefault()}_applyDragStyles(){this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top"}_restoreDragStyles(){this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const t=this._dialogElement.querySelectorAll("iframe");for(const e of t)this._lockedIframes.push({element:e,pointerEvents:e.style.pointerEvents}),e.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const t of this._lockedIframes)t.element.style.pointerEvents=t.pointerEvents;this._lockedIframes=[]}}_normalizeOptions(t,e=b){const i={...e,...t},s=Number(i.threshold),r=Number(i.resizeEdgeSize),n="string"==typeof i.selector&&i.selector.trim()?i.selector:b.selector;return{...i,selector:n,threshold:Number.isFinite(s)&&s>=0?s:b.threshold,resizeEdgeSize:Number.isFinite(r)&&r>0?r:b.resizeEdgeSize,debug:Boolean(i.debug)}}_resolveDragArea(t){try{return t.closest(this._options.selector)}catch(e){return t.closest(b.selector)}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="170px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="7",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues(this._isDragging?"dragging":"idle")):this._setDebugVisibility(!1)}_setDebugVisibility(t){this._debugElement&&(this._debugElement.style.display=t?"block":"none")}_updateDebugValues(t="idle"){if(!this._debugElement||!this._options.debug)return;const e=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`drag:${t} x:${Math.round(e.left)} y:${Math.round(e.top)} w:${Math.round(e.width)} h:${Math.round(e.height)}`}},y={enable:!1,minWidth:300,minHeight:160,edgeSize:8,debug:!1},w={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"},E=class{constructor(t,e,i={}){this._modalElement=t,this._dialogElement=e,this._contentElement=this._dialogElement?this._dialogElement.querySelector(".vg-modal-content"):null,this._options=this._normalizeOptions(i),this._pointerId=null,this._direction="",this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._startWidth=0,this._startHeight=0,this._startLeft=0,this._startTop=0,this._startRight=0,this._startBottom=0,this._isEnabled=!1,this._observer=null,this._syncFrameId=null,this._resizeFrameId=null,this._lockedIframes=[],this._debugElement=null,this._previousMaxWidth="",this._previousMaxHeight="",this._previousPointerEvents="",this._previousMinHeight="",this._previousOverflow="",this._previousTransition="",this._previousWillChange="",this._previousContentHeight="",this._previousContentMaxHeight="",this._previousContentOverflow="",this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerLeave=this._onPointerLeave.bind(this),this._applyResizePosition=this._applyResizePosition.bind(this)}setOptions(t={}){this._options=this._normalizeOptions(t,this._options),this._updateDebugOverlay()}enable(){this._dialogElement&&!this._isEnabled&&(this._updateDebugOverlay(),this._modalElement.addEventListener("pointermove",this._onPointerMove),this._modalElement.addEventListener("pointerdown",this._onPointerDown),this._modalElement.addEventListener("pointerleave",this._onPointerLeave),this._startObserveSizeChanges(),this._isEnabled=!0)}disable(){this._isEnabled&&(this._modalElement.removeEventListener("pointermove",this._onPointerMove),this._modalElement.removeEventListener("pointerdown",this._onPointerDown),this._modalElement.removeEventListener("pointerleave",this._onPointerLeave),document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._stopObserveSizeChanges(),this._pointerId=null,this._direction="",this._dialogElement.style.cursor="",delete this._modalElement.dataset.vgModalResizing,this._unlockEmbeddedFrames(),this._restoreResizeStyles(),this._setDebugVisibility(!1),this._isEnabled=!1)}syncToViewport(){if(this._modalElement&&"true"===this._modalElement.dataset.vgModalDragging)return;if(!this._isPreparedForInteraction())return;const t=this._dialogElement.getBoundingClientRect(),e=this._dialogElement.offsetWidth||t.width,i=this._dialogElement.offsetHeight||t.height,s=Number.parseFloat(this._dialogElement.style.left),r=Number.parseFloat(this._dialogElement.style.top),n=Number.isFinite(s)?s:t.left,a=Number.isFinite(r)?r:t.top,o=window.innerWidth,l=window.innerHeight,h=Math.max(this._options.minWidth,Math.min(e,o)),d=Math.max(this._options.minHeight,Math.min(i,l)),c=Math.max(0,window.innerWidth-h),_=Math.max(0,window.innerHeight-d),u=Math.min(c,Math.max(0,n)),m=Math.min(_,Math.max(0,a));Math.abs(e-h)>.5&&(this._dialogElement.style.width=`${h}px`),Math.abs(i-d)>.5&&(this._dialogElement.style.height=`${d}px`),this._dialogElement.style.left=`${u}px`,this._dialogElement.style.top=`${m}px`,this._updateDebugValues()}_onPointerDown(t){if(0!==t.button)return;if(t.defaultPrevented)return;const e=this._getDirectionFromPointer(t);if(!e)return;t.preventDefault(),this._pointerId=t.pointerId,this._direction=e;const i=this._dialogElement.getBoundingClientRect();this._applyResizeStyles(),this._preparePosition(i),this._startX=t.clientX,this._startY=t.clientY,this._currentX=t.clientX,this._currentY=t.clientY,this._startWidth=i.width,this._startHeight=i.height,this._startLeft=i.left,this._startTop=i.top,this._startRight=i.right,this._startBottom=i.bottom,this._lockEmbeddedFrames(),this._modalElement.dataset.vgModalResizing="true",this._setDebugVisibility(!0),this._updateDebugValues(),document.addEventListener("pointermove",this._onPointerMove),document.addEventListener("pointerup",this._onPointerUp),document.addEventListener("pointercancel",this._onPointerUp)}_onPointerMove(t){if(null===this._pointerId){const e=this._getDirectionFromPointer(t);return void(this._dialogElement.style.cursor=e?w[e]:"")}t.pointerId===this._pointerId&&(this._currentX=t.clientX,this._currentY=t.clientY,null===this._resizeFrameId&&(this._resizeFrameId=window.requestAnimationFrame(this._applyResizePosition)))}_applyResizePosition(){if(this._resizeFrameId=null,null===this._pointerId)return;const t=this._currentX-this._startX,e=this._currentY-this._startY;let i=this._startWidth,s=this._startHeight,r=this._startLeft,n=this._startTop;if(this._direction.includes("e")){const e=Math.max(this._options.minWidth,window.innerWidth-this._startLeft);i=Math.min(e,Math.max(this._options.minWidth,this._startWidth+t))}if(this._direction.includes("s")){const t=Math.max(this._options.minHeight,window.innerHeight-this._startTop);s=Math.min(t,Math.max(this._options.minHeight,this._startHeight+e))}if(this._direction.includes("w")){const e=this._startRight-this._options.minWidth;r=Math.min(e,Math.max(0,this._startLeft+t)),i=this._startRight-r}if(this._direction.includes("n")){const t=this._startBottom-this._options.minHeight;n=Math.min(t,Math.max(0,this._startTop+e)),s=this._startBottom-n}this._dialogElement.style.left=`${r}px`,this._dialogElement.style.top=`${n}px`,this._dialogElement.style.width=`${i}px`,this._dialogElement.style.height=`${s}px`,this._updateDebugValues()}_onPointerUp(t){t.pointerId===this._pointerId&&(document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._onPointerUp),document.removeEventListener("pointercancel",this._onPointerUp),this._cancelResizeFrame(),this._applyResizePosition(),this._pointerId=null,this._direction="",delete this._modalElement.dataset.vgModalResizing,this._unlockEmbeddedFrames(),this._setDebugVisibility(this._options.debug),this._updateDebugValues())}_onPointerLeave(){null===this._pointerId&&(this._dialogElement.style.cursor="")}_getDirectionFromPointer(t){const e=this._dialogElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,r=this._options.edgeSize;if(!(i>=0&&i<=e.width&&s>=0&&s<=e.height))return"";const n=s>=0&&s<=r,a=s<=e.height&&s>=e.height-r,o=i>=0&&i<=r,l=i<=e.width&&i>=e.width-r;return n&&o?"nw":n&&l?"ne":a&&o?"sw":a&&l?"se":n?"n":a?"s":o?"w":l?"e":""}_preparePosition(t){this._dialogElement.style.position="fixed",this._dialogElement.style.margin="0",this._dialogElement.style.left=`${t.left}px`,this._dialogElement.style.top=`${t.top}px`,this._dialogElement.style.width=`${t.width}px`,this._dialogElement.style.height=`${t.height}px`,this._dialogElement.style.transform="none"}_isPreparedForInteraction(){return"fixed"===this._dialogElement.style.position&&"none"===this._dialogElement.style.transform}_startObserveSizeChanges(){"undefined"==typeof ResizeObserver||this._observer||(this._observer=new ResizeObserver(()=>{null===this._pointerId&&(this._modalElement&&"true"===this._modalElement.dataset.vgModalDragging||null===this._syncFrameId&&(this._syncFrameId=window.requestAnimationFrame(()=>{this._syncFrameId=null,this.syncToViewport()})))}),this._observer.observe(this._dialogElement))}_stopObserveSizeChanges(){this._observer&&(this._observer.disconnect(),this._observer=null),null!==this._syncFrameId&&(window.cancelAnimationFrame(this._syncFrameId),this._syncFrameId=null)}_applyResizeStyles(){this._previousMaxWidth=this._dialogElement.style.maxWidth,this._previousMaxHeight=this._dialogElement.style.maxHeight,this._previousPointerEvents=this._dialogElement.style.pointerEvents,this._previousMinHeight=this._dialogElement.style.minHeight,this._previousOverflow=this._dialogElement.style.overflow,this._previousTransition=this._dialogElement.style.transition,this._previousWillChange=this._dialogElement.style.willChange,this._dialogElement.style.maxWidth="none",this._dialogElement.style.maxHeight="none",this._dialogElement.style.pointerEvents="auto",this._dialogElement.style.minHeight=`${this._options.minHeight}px`,this._dialogElement.style.overflow="hidden",this._dialogElement.style.transition="none",this._dialogElement.style.willChange="left, top, width, height",this._contentElement&&(this._previousContentHeight=this._contentElement.style.height,this._previousContentMaxHeight=this._contentElement.style.maxHeight,this._previousContentOverflow=this._contentElement.style.overflow,this._contentElement.style.height="100%",this._contentElement.style.maxHeight="100%",this._contentElement.style.overflow="auto")}_restoreResizeStyles(){this._dialogElement.style.maxWidth=this._previousMaxWidth,this._dialogElement.style.maxHeight=this._previousMaxHeight,this._dialogElement.style.pointerEvents=this._previousPointerEvents,this._dialogElement.style.minHeight=this._previousMinHeight,this._dialogElement.style.overflow=this._previousOverflow,this._dialogElement.style.transition=this._previousTransition,this._dialogElement.style.willChange=this._previousWillChange,this._contentElement&&(this._contentElement.style.height=this._previousContentHeight,this._contentElement.style.maxHeight=this._previousContentMaxHeight,this._contentElement.style.overflow=this._previousContentOverflow)}_normalizeOptions(t,e=y){const i={...e,...t},s=Number(i.minWidth),r=Number(i.minHeight),n=Number(i.edgeSize);return{...i,minWidth:Number.isFinite(s)&&s>0?s:y.minWidth,minHeight:Number.isFinite(r)&&r>0?r:y.minHeight,edgeSize:Number.isFinite(n)&&n>0?n:y.edgeSize,debug:Boolean(i.debug)}}_cancelResizeFrame(){null!==this._resizeFrameId&&(window.cancelAnimationFrame(this._resizeFrameId),this._resizeFrameId=null)}_lockEmbeddedFrames(){if(!this._dialogElement||this._lockedIframes.length)return;const t=this._dialogElement.querySelectorAll("iframe");for(const e of t)this._lockedIframes.push({element:e,pointerEvents:e.style.pointerEvents}),e.style.pointerEvents="none"}_unlockEmbeddedFrames(){if(this._lockedIframes.length){for(const t of this._lockedIframes)t.element.style.pointerEvents=t.pointerEvents;this._lockedIframes=[]}}_updateDebugOverlay(){this._options.debug?(this._debugElement||(this._debugElement=document.createElement("div"),this._debugElement.style.position="absolute",this._debugElement.style.left="8px",this._debugElement.style.bottom="8px",this._debugElement.style.zIndex="6",this._debugElement.style.padding="4px 6px",this._debugElement.style.borderRadius="4px",this._debugElement.style.background="rgba(0, 0, 0, 0.72)",this._debugElement.style.color="#fff",this._debugElement.style.fontSize="11px",this._debugElement.style.lineHeight="1.3",this._debugElement.style.pointerEvents="none",this._dialogElement.append(this._debugElement)),this._setDebugVisibility(!0),this._updateDebugValues()):this._setDebugVisibility(!1)}_setDebugVisibility(t){this._debugElement&&(this._debugElement.style.display=t?"block":"none")}_updateDebugValues(){if(!this._debugElement||!this._options.debug)return;const t=this._dialogElement.getBoundingClientRect();this._debugElement.textContent=`w:${Math.round(t.width)} h:${Math.round(t.height)} x:${Math.round(t.left)} y:${Math.round(t.top)}`}},A={enable:!1,selector:".vg-modal-content",threshold:4,resizeEdgeSize:8,debug:!1},S={enable:!1,edgeSize:8,minWidth:300,minHeight:160,debug:!1},C=class{constructor(t,e,i,s){this._modalElement=t,this._dialogElement=e,this._contentElement=i,this._getParams="function"==typeof s?s:()=>({}),this._dragHandler=new v(this._modalElement,this._dialogElement),this._resizeHandler=new E(this._modalElement,this._dialogElement),this._config=this._resolveConfig(),this._bindHandlers()}toggleHandlers(){this._config=this._resolveConfig(),this._bindHandlers(),this._config.drag.enable?this._dragHandler.enable():this._dragHandler.disable(),this._config.resize.enable?this._resizeHandler.enable():this._resizeHandler.disable()}disableHandlers(){this._dragHandler.disable(),this._resizeHandler.disable()}syncBounds(){this._config.resize.enable&&this._resizeHandler.syncToViewport(),this._config.drag.enable&&this._dragHandler.syncPosition()}saveState(){const t=this._getStateConfig(),e=this._getStateStorageKey(t);if(t.enable&&e&&"undefined"!=typeof window&&window.localStorage)try{window.localStorage.setItem(e,JSON.stringify(this._captureState()))}catch(t){}}restoreState(){const t=this._getStateConfig(),e=this._getStateStorageKey(t);if(!t.enable||!e||"undefined"==typeof window||!window.localStorage)return!1;try{const t=window.localStorage.getItem(e);if(!t)return!1;const i=JSON.parse(t);return this._applyState(i),!0}catch(t){return!1}}dispose(){this.disableHandlers()}_bindHandlers(){this._dragHandler.setOptions(this._config.drag),this._resizeHandler.setOptions(this._config.resize)}_resolveConfig(){const t=this._getParams();return{drag:this._normalizeInteractionParams(t.drag,A),resize:this._normalizeInteractionParams(t.resize,S)}}_normalizeInteractionParams(t,e){if("boolean"==typeof t)return{...e,enable:t};if(t&&"object"==typeof t){const i=Object.prototype.hasOwnProperty.call(t,"enable");return{...e,...t,enable:!i||Boolean(t.enable)}}return{...e}}_getStateConfig(){const t=this._getParams();return this._normalizeStateParams(t.state)}_normalizeStateParams(t,e={enable:!0,key:""}){if("boolean"==typeof t)return{...e,enable:t};if(t&&"object"==typeof t){const i=Object.prototype.hasOwnProperty.call(t,"enable"),s="string"==typeof t.key?t.key.trim():"";return{...e,...t,key:s,enable:!i||Boolean(t.enable)}}return{...e}}_getStateStorageKey(t=this._getStateConfig()){return t.enable?"string"==typeof t.key&&t.key.trim()?t.key.trim():this._modalElement&&this._modalElement.id?`vg.modal.state:${window.location.pathname}:${this._modalElement.id}`:"":""}_captureState(){const t=this._dialogElement?this._dialogElement.style:null,e=this._contentElement||s.A.find(".vg-modal-content",this._dialogElement),i=e?e.style:null;return{dialog:t?{position:t.position,margin:t.margin,left:t.left,top:t.top,width:t.width,height:t.height,transform:t.transform,maxWidth:t.maxWidth,maxHeight:t.maxHeight,minHeight:t.minHeight,overflow:t.overflow,pointerEvents:t.pointerEvents,transition:t.transition,willChange:t.willChange}:{},content:i?{height:i.height,maxHeight:i.maxHeight,overflow:i.overflow}:{}}}_applyState(t){if(!t||"object"!=typeof t)return;const e=t.dialog&&"object"==typeof t.dialog?t.dialog:{},i=t.content&&"object"==typeof t.content?t.content:{};this._dialogElement&&Object.keys(e).forEach(t=>{this._dialogElement.style[t]=e[t]||""});const r=this._contentElement||s.A.find(".vg-modal-content",this._dialogElement);r&&Object.keys(i).forEach(t=>{r.style[t]=i[t]||""})}},x="vg.modal",L="vg-modal-open",I="show",P="vg-modal-minimized-state",M="vg-btn-minimize",k="vg-modal-minimized-container",D="vg-modal-minimized",T=`${x}.minimize`,O=`${x}.minimized`,z=`${x}.restore`,N=`${x}.restored`;class ${constructor(t){this._modal=t,this._element=t._element,this._dialog=t._dialog,this._content=t._content,this._minimizedElement=null,this._isMinimized=!1}setup(){const t=this._getConfig();if(!t.enable||!this._content)return;if(s.A.find(`.${M}`,this._content))return;const e=document.createElement("button");e.type="button",e.className=M,e.setAttribute("aria-label",t.label||"Minimize"),e.innerHTML='<span aria-hidden="true"></span>';const i=s.A.find(".vg-btn-close",this._content);i&&i.parentNode?i.parentNode.insertBefore(e,i):this._content.prepend(e),g.A.on(e,`click.${x}.minimize`,t=>{t.preventDefault(),this.minimize(e)})}isMinimized(){return this._isMinimized}minimize(t){if(!this._getConfig().enable||!this._modal._isShown||this._isMinimized||this._modal._isTransitioning)return;if(g.A.trigger(this._element,T,{relatedTarget:t}).defaultPrevented)return;this._isMinimized=!0,this._modal._disableInteractionHandlers(),this._element.classList.remove(I),this._element.classList.add(P),this._element.style.display="none",this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),s.A.findAll('.vg-modal.show:not([data-vg-persistent="true"])').filter(t=>t!==this._element).length||document.body.classList.remove(L);const e=()=>{p.isActive()||this._modal._scrollBar.reset(),this._ensureElement(t),g.A.trigger(this._element,O,{relatedTarget:t})};this._modal._backdropElement?this._modal._hideBackdrop(e):e()}restore(t){if(!this._isMinimized||this._modal._isTransitioning)return;if(g.A.trigger(this._element,z,{relatedTarget:t}).defaultPrevented)return;const e=()=>{this.removeElement(),this._isMinimized=!1,this._element.classList.remove(P),this._element.style.display="block",this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),document.body.classList.add(L),(0,r.qm)(this._element),this._element.classList.add(I),this._modal._toggleInteractionHandlers(),this._modal._syncInteractiveBounds(),g.A.trigger(this._element,N,{relatedTarget:t})};if(this._modal._params.backdrop)return this._modal._scrollBar.hide(),void this._modal._showBackdrop(e);e()}reset(){this.removeElement(),this._isMinimized=!1,this._element.classList.remove(P)}dispose(){this.removeElement()}_getConfig(){const t=this._modal._params.minimize,e={enable:!1,title:"",text:"",label:"Minimize"};if("boolean"==typeof t)return{...e,enable:t};if(t&&"object"==typeof t){const i=Object.prototype.hasOwnProperty.call(t,"enable");return{...e,...t,enable:!i||Boolean(t.enable)}}return e}_ensureElement(t){if(this._minimizedElement&&this._minimizedElement.isConnected)return this._minimizedElement;const e=this._getConfig(),i=$.getContainer(),s=document.createElement("button");s.type="button",s.className=D,s.setAttribute("data-vg-modal-target",`#${this._element.id}`);const r=document.createElement("span");r.className=`${D}__title`,r.textContent=this._getTitle(e),s.append(r);const n=String(e.text||"").trim();if(n){const t=document.createElement("span");t.className=`${D}__text`,t.textContent=n,s.append(t)}return g.A.on(s,`click.${x}.restore`,e=>{e.preventDefault(),this.restore(s||t)}),i.append(s),this._minimizedElement=s,s}_getTitle(t){const e=String(t.title||"").trim();if(e)return e;const i=s.A.find(".vg-modal-title, .vg-modal-chat__name, [data-vg-modal-title]",this._element);return String(i?i.textContent:"").trim()||this._element.id||"Modal"}removeElement(){this._minimizedElement&&(this._minimizedElement.remove(),this._minimizedElement=null);const t=s.A.find(`.${k}`);t&&!t.children.length&&t.remove()}static getContainer(){let t=s.A.find(`.${k}`);return t||(t=document.createElement("div"),t.className=k,document.body.append(t),t)}}const H=$,F="vg.modal",R='.vg-modal.show:not([data-vg-persistent="true"])',B="data-vg-backdrop-owner",j="modal",U="vg-modal-open",q="show",V="vg-modal-static",W=`${F}.hide`,K=`${F}.hidden`,G=`${F}.show`,Y=`${F}.shown`,X=`${F}.resize`,Z=`${F}.loaded`,J=`keydown.dismiss.${F}`,Q=`hidePrevented.${F}`,tt=`click.${F}.data.api`,et=`mousedown.dismiss${F}`,it=`click.dismiss${F}`,st=`mousedown.${F}.backdrop`,rt=`DOMContentLoaded.${F}.data.api`,nt=`popstate.${F}.data.api`;class at extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({backdrop:!0,persistent:!1,focus:!0,keyboard:!0,fields:[],hash:!1,centered:!1,dismiss:!0,minimize:{enable:!1,title:"",text:""},resize:{enable:!1,edgeSize:8,minWidth:300,minHeight:160,debug:!1},state:{enable:!0,key:""},drag:{enable:!1,selector:".vg-modal-content",threshold:4,resizeEdgeSize:8,debug:!1},sizes:{width:"",height:""},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0},animation:{enable:!1,in:"animate__rollIn",out:"animate__rollOut",delay:100,duration:800},classes:{general:"vg-modal",dialog:"vg-modal-dialog",content:"vg-modal-content",header:"vg-modal-header",title:"vg-modal-title",body:"vg-modal-body",footer:"vg-modal-footer"}},e)),this._button=null,this._dialog=s.A.find(".vg-modal-dialog",this._element),this._content=s.A.find(".vg-modal-content",this._dialog),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new h,this._backdropElement=null,this._isBackdropOwner=!1,this._interaction=new C(this._element,this._dialog,this._content,()=>this._params),this._minimized=new H(this),this._addEventListeners(),this._dismissElement(),this._minimized.setup(),this._params.animation.delay=this._params.animation.enable?this._params.animation.delay:0,this._animation(this._element,at.NAME_KEY,this._params.animation),this._params.persistent?this._element.setAttribute("data-vg-persistent","true"):this._element.removeAttribute("data-vg-persistent")}static get NAME(){return"modal"}static get NAME_KEY(){return F}static init(t,e={},i){return at.build(t,e,i)}static initAll(t={}){return s.A.findAll(".vg-modal").map(e=>at.getOrCreateInstance(e,t))}static build(t,i={},s){if("string"!=typeof t)return;i&&"object"==typeof i||(i={});const n=document.getElementById(t);if(n){const t=at.getOrCreateInstance(n,i);return(0,r.g7)(s,[t]),t}let a=document.createElement("div");a.classList.add("vg-modal"),a.classList.add("fade"),a.id=t;let o=document.createElement("div");o.classList.add("vg-modal-dialog"),i.centered&&o.classList.add("vg-modal-dialog-centered");let l=document.createElement("div");if(l.classList.add("vg-modal-content"),!Object.prototype.hasOwnProperty.call(i,"dismiss")||i.dismiss){let i=document.createElement("button");e.p.set(i,"type","button"),e.p.set(i,"data-vg-dismiss","modal"),e.p.set(i,"data-vg-target","#"+t),e.p.set(i,"aria-label","close"),i.classList.add("vg-btn-close"),l.append(i)}if(i.title){let t=document.createElement("div");t.classList.add("vg-modal-header");let e=document.createElement("div");e.classList.add("vg-modal-title"),at._appendBuildContent(e,i.title,Boolean(i.html||i.titleHtml)),t.append(e),l.append(t)}let h=document.createElement("div");h.classList.add("vg-modal-body");const d=Object.prototype.hasOwnProperty.call(i,"body")?i.body:Object.prototype.hasOwnProperty.call(i,"content")?i.content:null;if(at._appendBuildContent(h,d,Boolean(i.html||i.bodyHtml||i.contentHtml)),l.append(h),Object.prototype.hasOwnProperty.call(i,"footer")){let t=document.createElement("div");t.classList.add("vg-modal-footer"),at._appendBuildContent(t,i.footer,Boolean(i.html||i.footerHtml)),l.append(t)}o.append(l),a.append(o),document.body.append(a);const c=at.getOrCreateInstance(a,i);return"animation"in i&&c._animation(a,at.NAME_KEY,i.animation),"sizes"in c._params&&c._params.sizes.width&&a.style.setProperty("--vg-modal-width",c._params.sizes.width),"sizes"in c._params&&c._params.sizes.height&&(o.style.height=c._params.sizes.height),(0,r.g7)(s,[c]),c}static _appendBuildContent(t,e,i=!1){t&&null!=e&&(Array.isArray(e)?e.forEach(e=>at._appendBuildContent(t,e,i)):e instanceof Node?t.append(e):i?t.insertAdjacentHTML("beforeend",String(e)):t.append(document.createTextNode(String(e))))}toggle(t){return this._minimized.isMinimized()?this.restore(t):this._isShown?this.hide():this.show(t)}show(t){if(!(0,r.d6)(this._element)){if(this._minimized.isMinimized())return this.restore(t);if(!this._isShown&&!this._isTransitioning){if(this._params.ajax.route&&this._params.ajax.target&&!this._params.ajax.once){const t=s.A.find(this._params.ajax.target,this._element);t&&(t.innerHTML="")}g.A.trigger(this._element,G,{relatedTarget:t}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._params.hash&&(window.location.hash!==`#${this._element.id}`&&window.history.pushState(null,"vg-modal-open","#"+this._element.id),g.A.on(window,nt,()=>{this.hide()})),this._params.backdrop&&this._scrollBar.hide(),document.body.classList.add(U),this._addFieldsInModal(t),this._adjustDialog(),this._params.backdrop?this._showBackdrop(()=>this._showElement(t)):this._showElement(t))}}}minimize(t){return this._minimized.minimize(t)}restore(t){return this._minimized.restore(t)}hide(t=[],e=!1){this._isShown&&!this._isTransitioning&&(g.A.trigger(this._element,W).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,setTimeout(()=>{this._element.classList.remove(q),this._queueCallback(()=>this._hideModal(t,e),this._element,this._isAnimatedFade())},this._params.animation.delay)))}_hideModal(t,e){if(!e){if(this._saveInteractionState(),this._disableInteractionHandlers(),this._minimized.reset(),this._element.style.display="none",this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,s.A.findAll(R).filter(t=>t!==this._element).length||t.length)return void g.A.trigger(this._element,K);if(document.body.classList.remove(U),this._params.hash&&history.pushState("",document.title,window.location.pathname+window.location.search),!this._params.backdrop)return this._resetAdjustments(),p.isActive()||this._scrollBar.reset(),void g.A.trigger(this._element,K);this._hideBackdrop(()=>{this._resetAdjustments(),p.isActive()||this._scrollBar.reset(),g.A.trigger(this._element,K)})}}dispose(){this._minimized.dispose(),this._interaction.dispose(),super.dispose()}_showElement(t){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const e=s.A.find(".vg-modal-body",this._dialog);e&&(e.scrollTop=0),(0,r.qm)(this._element),this._element.classList.add(q),this._toggleInteractionHandlers(),this._queueCallback(()=>{this._isTransitioning=!1,g.A.trigger(this._element,Y,{relatedTarget:t}),this._syncInteractiveBounds(),this._params=this._getParams(t,this._params),this._restoreInteractionState(),this._syncInteractiveBounds(),this._route((e,i)=>{g.A.trigger(this._element,Z,{stats:e,data:i,relatedTarget:t}),this._syncInteractiveBounds()})},this._dialog,this._isAnimatedFade())}_showBackdrop(t){const e=p.getElement(),i=e?e.getAttribute(B):"";if(e&&"sidebar"!==i)return i||e.setAttribute(B,j),this._backdropElement=e,this._isBackdropOwner=!0,this._bindBackdropDismiss(e),void(0,r.g7)(t);p.show(e=>{this._backdropElement=e,this._isBackdropOwner=!0,e&&e.setAttribute(B,j),this._bindBackdropDismiss(e),(0,r.g7)(t)})}_hideBackdrop(t){if(!this._backdropElement||!this._isBackdropOwner)return this._backdropElement=null,this._isBackdropOwner=!1,void(0,r.g7)(t);p.hide(()=>{this._backdropElement=null,this._isBackdropOwner=!1,(0,r.g7)(t)},this._backdropElement)}_bindBackdropDismiss(t){t&&(g.A.off(t,st),g.A.one(t,st,()=>{"static"!==this._params.backdrop?this.hide():this._triggerBackdropTransition()}))}_toggleInteractionHandlers(){this._interaction.toggleHandlers()}_disableInteractionHandlers(){this._interaction.disableHandlers()}_syncInteractiveBounds(){this._interaction.syncBounds()}_saveInteractionState(){this._interaction.saveState()}_restoreInteractionState(){return this._interaction.restoreState()}_isAnimatedFade(){return this._element.classList.contains("fade")}_adjustDialog(){const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._scrollBar.getWidth(),i=e>0;if(i&&!t){const t=(0,r.V8)()?"paddingLeft":"paddingRight";this._element.style[t]=`${e}px`}if(!i&&t){const t=(0,r.V8)()?"paddingRight":"paddingLeft";this._element.style[t]=`${e}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}_addEventListeners(){g.A.on(document,J,t=>{"Escape"===t.key&&(this._params.keyboard?this.hide():this._triggerBackdropTransition())}),g.A.on(window,X,()=>{this._isShown&&!this._isTransitioning&&(this._adjustDialog(),this._syncInteractiveBounds())}),g.A.on(this._element,et,t=>{g.A.one(this._element,it,e=>{this._element===t.target&&this._element===e.target&&("static"!==this._params.backdrop?this._params.backdrop&&this.hide():this._triggerBackdropTransition())})})}_triggerBackdropTransition(){if(g.A.trigger(this._element,Q).defaultPrevented)return;const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._element.style.overflowY;"hidden"===e||this._element.classList.contains(V)||(t||(this._element.style.overflowY="hidden"),this._element.classList.add(V),this._queueCallback(()=>{this._element.classList.remove(V),this._queueCallback(()=>{this._element.style.overflowY=e},this._dialog)},this._dialog))}_addFieldsInModal(t){this._params=this._getParams(t,this._params),this._params.fields.length&&this._params.fields.forEach(t=>{if(!1 in t&&!1 in t)return;let i=s.A.findAll("[data-"+t.name+"]",this._element);if(i.length)for(const s of i)switch(s.tagName){case"INPUT":s.value=t.value;break;case"FORM":s.action=t.value;break;case"IMG":e.p.set(s,"src",t.value);break;default:s.innerHTML=t.value}})}}(0,f.P)(at),g.A.on(document,tt,'[data-vg-toggle="modal"]',function(t){const e=s.A.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&t.preventDefault(),g.A.one(e,G,t=>{t.defaultPrevented});const i=s.A.find(R);if(i){const t=at.getInstance(i);t&&!t._params.persistent&&t.hide([i])}at.getOrCreateInstance(e).toggle(this)});const ot=()=>{let t=window.location.hash.slice(1);if(!t)return;try{t=decodeURIComponent(t)}catch(t){return}const e=s.A.findID(t);if(!e||!e.classList.contains("vg-modal")||(0,r.d6)(e))return;const i=at.getOrCreateInstance(e);i._params.hash&&!i._isShown&&i.show()};"loading"===document.readyState?g.A.on(document,rt,ot):ot(),window.addEventListener("hashchange",ot);const lt=at,ht=lt,dt=class{constructor(t){this.reference=t.reference,this.drop=t.drop,this.offset=t.offset||[0,0],this.boundary=t.boundary||"viewport",this.autoFlip=!1!==t.autoFlip,this.overflowProtection=!1!==t.overflowProtection,this.placement=t.placement||"bottom",this.fallbackPlacements=t.fallbackPlacements||[],this.clamp=!0===t.clamp,this.clampPadding=t.clampPadding??8,this.isMerge=!1!==t.isMerge}_getPlacementRect(t){return t.getBoundingClientRect()}_getViewportRect(){const t=document.documentElement;return{width:t.clientWidth,height:t.clientHeight,left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}_getOverflowConstraints(){const t=this._getPlacementRect(this.reference),e=this._getPlacementRect(this.drop),i=this._getBoundaryRect(),[s,r]=this.offset;let n=this.placement;if(this.overflowProtection){const a=this.autoFlip?Array.from(new Set([this.placement,...this.fallbackPlacements])):[this.placement];let o=null;for(const n of a){const a=this._calculatePosition(n,t,e,s,r),l=this._calculateOverflow(a,e,i);if((!o||l<o.overflow)&&(o={placement:n,position:a,overflow:l},0===l))break}n=o.placement;const l=this.clamp?this._clampPosition(o.position,e,i):o.position;this._setStyles(l)}else{const a=this._calculatePosition(n,t,e,s,r),o=this.clamp?this._clampPosition(a,e,i):a;this._setStyles(o)}this.drop.setAttribute("data-vg-placement",n)}_getBoundaryRect(){const t=this._getViewportRect();if(this.boundary instanceof Element)return this._intersectRects(t,this._getPlacementRect(this.boundary));if("string"==typeof this.boundary&&"viewport"!==this.boundary&&"clippingParents"!==this.boundary){const e=this.reference.closest(this.boundary);if(e)return this._intersectRects(t,this._getPlacementRect(e))}if("clippingParents"!==this.boundary)return t;let e=t,i=this.reference.parentElement;for(;i&&i!==document.body&&i!==document.documentElement;)this._isClippingElement(i)&&(e=this._intersectRects(e,this._getPlacementRect(i))),i=i.parentElement;return e}_isClippingElement(t){const e=window.getComputedStyle(t);return[e.overflow,e.overflowX,e.overflowY].some(t=>/(auto|scroll|hidden|clip)/.test(t||""))}_intersectRects(t,e){const i={left:Math.max(t.left,e.left),top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom)};return i.width=Math.max(0,i.right-i.left),i.height=Math.max(0,i.bottom-i.top),i}_calculatePosition(t,e,i,s=0,r=0){let n,a;switch(t){case"top":n=e.top-i.height-r,a=e.left+(e.width-i.width)/2;break;case"top-start":n=e.top-i.height-r,a=e.left+s;break;case"top-end":n=e.top-i.height-r,a=e.right-i.width-s;break;case"bottom":n=e.bottom+r,a=e.left+(e.width-i.width)/2;break;case"bottom-start":default:n=e.bottom+r,a=e.left+s;break;case"bottom-end":n=e.bottom+r,a=e.right-i.width-s;break;case"left":n=e.top+(e.height-i.height)/2,a=e.left-i.width-s;break;case"left-start":n=e.top+r,a=e.left-i.width-s;break;case"left-end":n=e.bottom-i.height-r,a=e.left-i.width-s;break;case"right":n=e.top+(e.height-i.height)/2,a=e.right+s;break;case"right-start":n=e.top+r,a=e.right+s;break;case"right-end":n=e.bottom-i.height-r,a=e.right+s}return{top:n,left:a}}_calculateOverflow(t,e,i){let s=0;return t.left<i.left&&(s+=i.left-t.left),t.top<i.top&&(s+=i.top-t.top),t.left+e.width>i.right&&(s+=t.left+e.width-i.right),t.top+e.height>i.bottom&&(s+=t.top+e.height-i.bottom),s}_clampPosition(t,e,i){const s=this.clampPadding,r=i.bottom-e.height-s,n=i.right-e.width-s;return{top:Math.min(Math.max(t.top,i.top+s),r),left:Math.min(Math.max(t.left,i.left+s),n)}}_setStyles(t){if(!t||!this.drop)return;const e=this.drop.offsetParent;let i=t.top+window.pageYOffset,s=t.left+window.pageXOffset;if(e&&e!==document.body&&e!==document.documentElement){const r=this._getPlacementRect(e);i=t.top-r.top+e.scrollTop-e.clientTop,s=t.left-r.left+e.scrollLeft-e.clientLeft}this.isMerge?(0,r._v)(this.drop.style,{position:"absolute",top:`${i}px`,left:`${s}px`,margin:"0"}):(this.drop.style.position="absolute",this.drop.style.top=`${i}px`,this.drop.style.left=`${s}px`,this.drop.style.margin="0")}_setPlacement(){this._getOverflowConstraints()}},ct="vg.dropdown",_t="show",ut="fade",mt="open",pt="vg-dropdown-content",gt='[data-vg-toggle="dropdown"]',ft=`${ct}.hide`,bt=`${ct}.hidden`,vt=`${ct}.show`,yt=`${ct}.shown`,wt=`${ct}.loaded`,Et=`keyup.${ct}.data.api`,At=`keydown.${ct}.data.api`,St=`click.${ct}.data.api`,Ct=`mouseover.${ct}.data.api`,xt=`mouseout.${ct}.data.api`;let Lt=!1;class It extends t.A{constructor(t,e){super(t,e),this._params=this._getParams(t,(0,r._v)({placement:"auto",hover:!1,ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0},animation:{fade:!0,enable:!1,in:"animate__flipInY",out:"animate__flipOutY",delay:300}},e));const i=s.A.getElementFromSelector(this._element);this._parent=this._element.parentNode,this._drop=i||s.A.find(`.${pt}`,this._parent),this._drop&&(this._isPlacement=!1,this.isFade=this._params.animation.fade,this.isAnimation=this._params.animation.enable,this._params.animation.delay=this.isAnimation?this._params.animation.delay:0,this._animation(this._drop,It.NAME_KEY,this._params.animation))}static get NAME(){return"dropdown"}static get NAME_KEY(){return ct}toggle(){return this._isShown()?this.hide():this.show()}show(){if((0,r.d6)(this._element)||this._isShown())return;const t={relatedTarget:this._element};g.A.trigger(this._drop,vt,t).defaultPrevented||("ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach(t=>{g.A.on(t,"mouseover",r.lQ)}),this._element.setAttribute("aria-expanded","true"),this._element.classList.add(_t),this._drop.classList.add(_t),this._setPlacement(),this._queueCallback(()=>{this._element&&this._drop&&this._params&&(this._route((t,e)=>{g.A.trigger(this._element,wt,{stats:t,data:e})}),this.isFade?this._drop.classList.add(ut):this.isAnimation||this._drop.classList.add(mt),g.A.trigger(this._drop,yt,t))},this._drop,this.isAnimation||this.isFade,50))}hide(){!(0,r.d6)(this._element)&&this._isShown()&&this._completeHide({relatedTarget:this._element})}dispose(){this._element&&(this._element.classList.remove(_t),this._element.setAttribute("aria-expanded","false")),this._drop&&this._drop.classList.remove(_t,ut,mt),super.dispose()}_isShown(){return this._element.classList.contains(_t)}_completeHide(t){g.A.trigger(this._drop,ft,t).defaultPrevented||("ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach(t=>{g.A.off(t,"mouseover",r.lQ)}),this._element.classList.remove(_t),this._element.setAttribute("aria-expanded","false"),this.isFade?this._drop.classList.remove(ut):this.isAnimation||this._drop.classList.remove(mt),setTimeout(()=>{this._element&&this._drop&&this._params&&this._queueCallback(()=>{this._element&&this._drop&&(this._drop.classList.remove(_t),g.A.trigger(this._drop,bt,t))},this._drop,this.isAnimation||this.isFade)},this._params.animation.delay))}_setPlacement(){if(!this._drop)return;let t="bottom-start",e=!1,i=!1;"auto"===this._params.placement?(e=!0,i=!0):t=this._params.placement,new dt({reference:this._element,drop:this._drop,placement:t,boundary:"clippingParents",autoFlip:e,overflowProtection:i,fallbackPlacements:["bottom-end","top-start","top-end","right-start","left-start","right-end","left-end"]})._setPlacement(),this._isPlacement=!0}static init(t,e={}){const i=It.getOrCreateInstance(t,e);if(i._isDataApiInitialized)return i;if(i._isDataApiInitialized=!0,i._params.hover&&!(0,r.Xb)()){let t=null;g.A.on(i._parent,Ct,e=>{if(t)return;It.hideOpenToggles(e);const s=e.target.closest(".vg-dropdown");s&&i._parent.contains(s)&&(t=s,i.show())}),g.A.on(i._parent,xt,e=>{if(!t)return;let s=e.relatedTarget;for(;s&&s!==t;)s=s.parentNode;s!==t&&(t=null,i._completeHide({relatedTarget:i._element}))})}return Lt||(g.A.on(document,Et,gt,It.keydownHandler),g.A.on(document,At,`.${pt}`,It.keydownHandler),g.A.on(document,Et,It.clearDrops),g.A.on(document,St,It.clearDrops),Lt=!0),g.A.on(t,St,t=>{t.preventDefault(),i.toggle()}),i}static initAll(t={}){return s.A.findAll(gt).map(e=>It.init(e,t))}static hideOpenToggles(t){const e=s.A.findAll(`${gt}:not(.disabled):not(:disabled).${_t}`);for(const i of e){const e=It.getInstance(i);if(!e)continue;if(t.target.closest(`.${pt}`)===e._drop)return;if((t.composedPath?.()||[]).includes(e._element))continue;const s={relatedTarget:e._element};"click"===t.type&&(s.clickEvent=t),e._completeHide(s)}}static keydownHandler(t){const e=/input|textarea/i.test(t.target.tagName),i="Escape"===t.key,r=["ArrowUp","ArrowDown"].includes(t.key);if(!r&&!i)return;if(e&&!i)return;t.preventDefault();const n=this.matches(gt)?this:s.A.find(gt,t.delegateTarget?.parentNode);if(!n)return;const a=It.getOrCreateInstance(n);r?(t.stopPropagation(),a.show()):a._isShown()&&(t.stopPropagation(),a.hide(),n.focus())}static clearDrops(t){2===t.button||"keyup"===t.type&&"Tab"!==t.key||It.hideOpenToggles(t)}}const Pt=It,Mt=JSON.parse('{"errors":{"400":"Неверный запрос","401":"Не авторизован","403":"Запрещено","404":"Не найдено","413":"Слишком большой запрос","419":"Проблемы с токеном CSRF","422":"Неверный запрос","500":"Внутренняя ошибка сервера","504":"Превышено время ожидания","went_wrong":"Что-то пошло не так, повторите позже"},"form-sender":{"bootstrap_not_found":"VGApp не удалось найти bootstrap, модалки не будут закрыты, попробуйте сделать это через коллбек afterSend."},"files":{"is-count":"Превышен лимит по количеству файлов","is-sizes":"Превышен размер файла","is-types":"Недопустимый тип файла","is-total-size":"Превышен максимально разрешённый размер для выбранных файлов","titles":"Удаление файлов","title":"Удаление файлa","descriptions":"Вы действительно хотите удалить все загруженные файлы с сервера?","description":"Вернуть будет невозможно","drop-active":"Отпустите, чтобы загрузить"},"filepreview":{"audio_title":"Аудио файл","image_title":"Просмотр изображения","image_thumbnail_alt":"Миниатюра изображения","text_title":"Просмотр текста","video_title":"Просмотр видео","pdf_title":"Просмотр PDF","office_title":"Просмотр документа","archive_title":"Просмотр архива","loading_text":"Загрузка...","loading_archive":"Загрузка архива...","loading_entry":"Загрузка файла из архива...","cannot_open_file":"Не удалось открыть файл","cannot_open_archive":"Не удалось открыть архив","cannot_preview_entry":"Не удалось открыть вложение","office_fallback":"Если встроенный превью не работает, скачайте файл.","invalid_zip":"Некорректный ZIP-файл","central_directory_not_found":"Центральный каталог не найден","archive_buffer_missing":"Буфер архива не доступен","entry_corrupted":"Файл в архиве поврежден","compression_not_supported":"Метод сжатия не поддерживается","deflate_not_supported":"Браузер не поддерживает распаковку Deflate","unknown_error":"Неизвестная ошибка","empty_file":"(пустой файл)","archive_empty_unsupported":"Архив пустой или не поддерживается.","archive_type_dir":"папка","archive_type_file":"файл","archive_table_name":"Имя","archive_table_type":"Тип","archive_table_packed":"Сжатый","archive_table_size":"Размер","archive_table_preview":"Превью","pdf_page":"Страница","pdf_zoom":"Масштаб"},"alert":{"title":"Заголовок по умолчанию","description":"Описание текущего действия","reason":"Алерт уже открыт"},"select":{"loading":"Загрузка"}}'),kt=JSON.parse('{"errors":{"title":"Ошибка","titles":"Ошибки"},"select":{"search":"Поиск..."}}'),Dt=JSON.parse('{"alert":{"agree":"Да, согласен","cancel":"Отмена"},"files":{"agree":"Да","cancel":"Нет"},"filepreview":{"open_audio":"Открыть плеер","open_image":"Открыть изображение","open_text":"Открыть текст","open_video":"Открыть видео","open_archive":"Открыть архив","open_pdf":"Открыть PDF","open_office":"Открыть документ","download":"Скачать","preview":"Превью","prev":"Назад","next":"Вперед","zoom_in":"Увеличить","zoom_out":"Уменьшить"},"loadmore":{"send":"Загружаю...","show":"Показываю...","text-ajax":"Загрузить еще","text-more":"Показать еще"},"rollup":{"less":"Свернуть","show":"Показать","more":" еще "},"select":{"load-more":"Загрузить еще"}}'),Tt=JSON.parse('{"errors":{"400":"Bad Request","401":"Unauthorized","403":"Forbidden","404":"Not Found","413":"Payload Too Large","419":"Problems with the CSRF token","422":"Unprocessable Entity","500":"Internal Server Error","504":"Gateway Timeout","went_wrong":"Something went wrong, please repeat later"},"form-sender":{"bootstrap_not_found":"VGApp could not find bootstrap, the modals will not be closed, try to do this through the afterSend callback."},"files":{"is-count":"Exceeded the limit on the number of files","is-sizes":"File size exceeded","is-types":"Invalid file type","is-total-size":"The maximum allowed size for the selected files has been exceeded","titles":"Deleting files","title":"Deleting file","descriptions":"Do you really want to delete all uploaded files from the server?","description":"It will not be possible to return it","drop-active":"Release to upload"},"filepreview":{"audio_title":"Audio file","image_title":"Image preview","image_thumbnail_alt":"Image thumbnail","text_title":"Text preview","video_title":"Video preview","pdf_title":"PDF preview","office_title":"Office preview","archive_title":"Archive preview","loading_text":"Loading...","loading_archive":"Loading archive...","loading_entry":"Loading entry...","cannot_open_file":"Cannot open file","cannot_open_archive":"Cannot open archive","cannot_preview_entry":"Cannot preview entry","office_fallback":"If embedded preview is unavailable, download the file.","invalid_zip":"Invalid ZIP file","central_directory_not_found":"Central directory not found","archive_buffer_missing":"Archive buffer is missing","entry_corrupted":"Archive entry is corrupted","compression_not_supported":"Compression method is not supported","deflate_not_supported":"Deflate decompression is not supported by the browser","unknown_error":"Unknown error","empty_file":"(empty file)","archive_empty_unsupported":"Archive is empty or unsupported.","archive_type_dir":"dir","archive_type_file":"file","archive_table_name":"Name","archive_table_type":"Type","archive_table_packed":"Packed","archive_table_size":"Size","archive_table_preview":"Preview","pdf_page":"Page","pdf_zoom":"Zoom"},"alert":{"title":"Default header","description":"Description of the current action","reason":"Alert already open"},"select":{"loading":"Loading"}}'),Ot=JSON.parse('{"errors":{"title":"Error","titles":"Errors"},"select":{"search":"Search..."}}'),zt=JSON.parse('{"alert":{"agree":"Yeah, I agree","cancel":"Cancel"},"files":{"agree":"Yeah, I agree","cancel":"Cancel"},"filepreview":{"open_audio":"Open player","open_image":"Open image","open_text":"Open text","open_video":"Open video","open_archive":"Open archive","open_pdf":"Open PDF","open_office":"Open document","download":"Download","preview":"Preview","prev":"Prev","next":"Next","zoom_in":"Zoom +","zoom_out":"Zoom -"},"loadmore":{"send":"Uploading...","show":"I\'m showing you...","text-ajax":"Upload more","text-more":"Show more"},"rollup":{"less":"Roll up","show":"Show","more":" more "},"select":{"load-more":"Upload more"}}'),Nt={ru:(0,r.OM)({messages:Mt,titles:kt,buttons:Dt}),en:(0,r.OM)({messages:Tt,titles:Ot,buttons:zt})};class $t{constructor(t="en"){this.lang=t}get(){return Nt[this.lang]||Nt.en}}function Ht(t="en",e,i){const s=new $t(t).get();return s[e]?.[i]||{}}function Ft(t,e){return Ht(t,"titles",e)}function Rt(t,e){return Ht(t,"messages",e)}function Bt(t,e){return Ht(t,"buttons",e)}var jt=i(667);const Ut="vg-alert",qt="show",Vt="fade",Wt="closing",Kt=`${Ut}-compact`,Gt="data-vg-alert-agree",Yt="data-vg-alert-cancel",Xt="alert",Zt="vg.alert";let Jt=!1;class Qt{constructor(t={},e="ru"){this.lang=e,this._defaultParams={size:"default",render:{type:"modal",dismiss:!1},dropdown:{placement:"auto",hover:!1,animation:{fade:!0,enable:!1,in:"animate__flipInY",out:"animate__flipOutY",delay:300}},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0},modal:{centered:!1,backdrop:!0,overflow:!0,keyboard:!0,dismiss:!0,animation:{enable:!1,in:"animate__rollIn",out:"animate__rollOut",delay:300,duration:700}},mode:"confirm",theme:"danger",buttons:{},message:{}},this._elementsDefault={buttons:{agree:{element:"",tag:"button",type:"button",attr:{},toggle:Gt,class:["btn"],text:Bt(this.lang,Xt).agree},cancel:{element:"",tag:"button",type:"button",attr:{},toggle:Yt,class:["btn"],text:Bt(this.lang,Xt).cancel}},message:{title:Rt(this.lang,Xt).title,description:Rt(this.lang,Xt).description},icons:{danger:(0,f.z)("danger"),warning:(0,f.z)("warning"),success:(0,f.z)("success"),info:(0,f.z)("info")}},this._params=this._setParams(t)}static get NAME(){return Xt}static get NAME_KEY(){return Zt}static boot(){return this._bindDataApi(),null}static call(t={},e="ru"){const i=new Qt(t,e);if(Jt)return Promise.reject({accepted:!1,reason:Rt(i.lang,Zt).reason});Jt=!0;const{element:n,render:a,type:o}=(()=>{if("overlay"===i._params.render.type){const t=i._buildOverlay();if(!t.element||!t.render){const t=i._buildModal();return{element:t._element,render:t,type:"modal"}}return{element:t.element,render:t.render,type:"overlay"}}if("modal"===i._params.render.type){const t=i._buildModal();return{element:t._element,render:t,type:"modal"}}if("dropdown"===i._params.render.type){const t=i._buildDropdown();if(!t.element||!t.render){const t=i._buildModal();return{element:t._element,render:t,type:"modal"}}return{element:t.element,render:t.render,type:"dropdown"}}})();"modal"===o||"dropdown"===o?a.show():"overlay"===o&&i._showOverlay(n);const l=s.A.find(`[${Gt}]`,n),h=s.A.find(`[${Yt}]`,n);return new Promise((t,e)=>{let s=!1;const d=(t=!0)=>{"modal"!==o&&"dropdown"!==o?"overlay"===o&&i._hideOverlay(n,()=>{i._params.render.dismiss&&t&&a.hide()}):a.hide()},c=e=>{e.preventDefault(),s=!0,m(),t({accepted:!0,timestamp:new Date}),d()},_=t=>{t.preventDefault(),s=!0,m(),e({accepted:!1,timestamp:new Date}),d(!1)},u=t=>{"Enter"===t.key&&l&&(t.preventDefault(),c(t)),"Escape"===t.key&&(t.preventDefault(),_(t))},m=()=>{Jt=!1,document.removeEventListener("keydown",u),document.removeEventListener("click",p),l&&l.removeEventListener("click",c),h&&h.removeEventListener("click",_)},p=t=>{if("dropdown"!==o)return;const e=i._params.relatedTarget;n.contains(t.target)||(0,r.vq)(e)&&e.contains(t.target)||_(t)};"confirm"===i._params.mode&&(l&&l.addEventListener("click",c),h&&h.addEventListener("click",_)),"info"===i._params.mode&&h&&h.addEventListener("click",_),document.addEventListener("keydown",u),"modal"===o&&n.addEventListener("vg.modal.hide",()=>{s||(s=!0,m(),e({accepted:!1,timestamp:new Date}))},{once:!0}),"dropdown"===o&&(document.addEventListener("click",p),n.addEventListener("vg.dropdown.hidden",()=>{n._vgAlertDropdownParent&&!n._vgAlertDropdownParentWasSet&&n._vgAlertDropdownParent.classList.remove("vg-dropdown"),n.remove(),s||(s=!0,m(),e({accepted:!1,timestamp:new Date}))},{once:!0})),n.focus()})}static confirm(t,e={}){let i="ru";"lang"in e&&(i=e.lang||"ru",delete e.lang);const s=new Qt(e,i);"confirm"===s._params.mode&&ae.getOrCreateInstance(t,s._params).run(Qt)}static _bindDataApi(){this._isDataApiBound||(this._isDataApiBound=!0,g.A.on(document,ee,te,function(t){t.preventDefault();const e=t.delegateTarget||this||t.target?.closest(te)||t.target;(0,r.zN)(e)&&(0,r.vq)(e)&&Qt.confirm(e,{buttons:{agree:{class:["btn-primary"]},cancel:{class:["btn-outline-primary"]}}})}))}_setParams(t){const e=(0,r._v)(this._defaultParams,t);return e.size="compact"===e.size?"compact":"default",e.buttons=(0,r._v)(this._elementsDefault.buttons,e.buttons),e.message=(0,r._v)(this._elementsDefault.message,e.message),e.icon=this._elementsDefault.icons[e.theme],e}_applySizeClass(t){return"compact"===this._params.size&&t?.classList.add(Kt),t}_buildModal(){const t=`${Ut}-${(0,r.PR)()}`;return ht.build(t,this._params.modal,t=>{t._element.classList.add(`${Ut}-modal`),this._applySizeClass(t._element),s.A.find(".vg-modal-body",t._element).append(this._buildContent())})}_buildContent(){const t=(0,d.A)("dom");let i=null;this._params.icon&&(i=t.div({class:`${Ut}-content--icon`},this._params.icon,{isHTML:!0}));const s=document.createElement("div");e.x.add(s,"vg-alert-buttons"),"confirm"===this._params.mode&&(this._createButton(s,"cancel"),this._createButton(s,"agree")),"info"===this._params.mode&&this._createButton(s,"cancel");const r="compact"===this._params.size?` ${Kt}`:"";return t.div({class:`${Ut}-wrapper ${Ut}-${this._params.theme}${r}`},[t.div({class:`${Ut}-content`},[i,t.div({class:`${Ut}-content--message`},[t.div({class:`${Ut}-content--title`},this._params.message.title),t.div({class:`${Ut}-content--description`},this._params.message.description)])]),s])}_buildOverlay(){const t=this._params.relatedTarget,e=(0,r.vq)(t)?t.closest([".vg-modal",".vg-sidebar"].join(", ")):null;if(!e)return{element:null,render:null};const i=ht.getOrCreateInstance(e),n=s.A.find(".vg-modal-content",i._element)||e,a=document.createElement("div");return a.className=`${Ut}-overlay`,this._applySizeClass(a),a.append(this._buildContent()),n.append(a),{element:a,render:i}}_showOverlay(t){t&&((0,r.qm)(t),requestAnimationFrame(()=>{t.classList.add(qt),(0,r.qm)(t),window.setTimeout(()=>{t.isConnected&&t.classList.add(Vt)},15)}))}_hideOverlay(t,e){if(!t)return void(0,r.g7)(e);const i=()=>{t.classList.remove(qt),t.classList.remove(Wt),t.remove(),(0,r.g7)(e)};t.classList.add(Wt);const n=s.A.find(`.${Ut}-wrapper`,t),a=this._getElementTransitionDuration(n);window.setTimeout(()=>{t.classList.remove(Vt);const e=this._getElementTransitionDuration(t,"::before");e?window.setTimeout(i,e):i()},a)}_getElementTransitionDuration(t,e=null){if(!t||"undefined"==typeof window)return 0;const i=window.getComputedStyle(t,e),s=i.transitionDuration.split(","),r=i.transitionDelay.split(",");return Math.max(...s.map((t,e)=>this._parseCssTime(t)+this._parseCssTime(r[e]||r[0]||"0s")))}_parseCssTime(t){const e=Number.parseFloat(t);return Number.isFinite(e)?t.trim().endsWith("ms")?e:1e3*e:0}_buildDropdown(){const t=this._params.relatedTarget;if(!(0,r.vq)(t)||!t.parentNode)return{element:null,render:null};const e=`${Ut}-dropdown-${(0,r.PR)()}`,i=t.parentNode,s=document.createElement("div"),n=document.createElement("div"),a=i.classList.contains("vg-dropdown");i.classList.add("vg-dropdown"),s.id=e,s.className=`vg-dropdown-content ${Ut}-dropdown`,this._applySizeClass(s),s.setAttribute("tabindex","-1"),s.setAttribute("role","dialog"),s._vgAlertDropdownParent=i,s._vgAlertDropdownParentWasSet=a,n.className="vg-dropdown-container",n.append(this._buildContent()),s.append(n),i.append(s);const o=Pt.getOrCreateInstance(t,(0,r._v)({placement:"bottom-start"},this._params.dropdown));return o._drop=s,o._parent=i,{element:s,render:o}}_createButton(t,e){const i=this._params.buttons[e];if(!i||i.element)return void t.insertAdjacentHTML("beforeend",i?.element||"");if(!i.tag)return;let s=null,n=[...new Set(i.class)].join(" "),a=(0,r._v)({class:n},i.attr);"button"===i.tag?s=(0,d.A)("dom").button(i.text,i.type,a):"a"===i.tag&&(s=(0,d.A)("dom").a("#",i.text,a)),s&&(s.setAttribute(i.toggle,"true"),t.appendChild(s))}}const te=`[data-vg-toggle="${Xt}"]`,ee=`click.${Zt}.data.api`,ie=`${Zt}.loaded`,se=`${Zt}.accept`,re=`${Zt}.reject`,ne=`${Zt}.finally`;class ae extends t.A{constructor(t,e={}){super(t),this._params=this._getParams(t,(0,r._v)({},e))}static get NAME(){return Xt}static get NAME_KEY(){return Zt}run(t){"confirm"===this._params.mode&&(this._params.relatedTarget=this._element,t.call(this._params).then(t=>t.accepted?this._params.ajax.route?this._ajax():t:Promise.reject(t)).then(t=>{g.A.trigger(this._element,se,{vgalert:t})}).catch(t=>{g.A.trigger(this._element,re,{vgalert:t})}).finally(()=>{g.A.trigger(this._element,ne,{vgalert:"finally"})}))}_ajax(){return new Promise(t=>{this._route((e,i)=>{g.A.trigger(this._element,ie,{stats:e,data:i}),t({status:e,data:i})})})}}Qt._isDataApiBound=!1;const oe=Qt,le="vg.collapse",he="show",de="vg-collapse",ce="vg-collapsing",_e=`:scope .${de} .${de}`,ue='[data-vg-toggle="collapse"]',me=`${le}.hide`,pe=`${le}.hidden`,ge=`${le}.show`,fe=`${le}.shown`,be=`${le}.loaded`,ve=`click.${le}.data.api`;class ye extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({toggle:!0,parent:null,ajax:{route:"",target:"",method:"get",loader:!1,once:!0,output:!0}},e)),this._params.parent=(0,r.V6)(this._params.parent)||null,this._isTransitioning=!1,this._triggerArray=[];const i=s.A.findAll(ue);for(const t of i){const e=s.A.getSelectorFromElement(t),i=s.A.findAll(e).filter(t=>t===this._element);null!==e&&i.length&&this._triggerArray.push(t)}this._initializeChildren(),this._params.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._params.toggle&&this.toggle()}static get NAME(){return"collapse"}static get NAME_KEY(){return le}toggle(t){return this._isShown()?this.hide():this.show(t)}show(){if(this._isTransitioning||this._isShown())return;let t=[];if(this._params.parent&&(t=this._getFirstLevelChildren(".vg-collapse.show, .vg-collapse.vg-collapsing").filter(t=>t!==this._element).map(t=>ye.getOrCreateInstance(t,{toggle:!1}))),t.length&&t[0]._isTransitioning)return;if(g.A.trigger(this._element,ge).defaultPrevented)return;for(const e of t)e.hide();const e=this._getDimension();this._element.classList.remove(de),this._element.classList.add(ce),this._element.style[e]="0",this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const i=`scroll${e[0].toUpperCase()+e.slice(1)}`;this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(ce),this._element.classList.add(de,he),this._element.style[e]="",this._route((t,e)=>{g.A.trigger(this._element,be,{stats:t,data:e})}),g.A.trigger(this._element,fe)},this._element,!0),this._element.style[e]=`${this._element[i]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(g.A.trigger(this._element,me).defaultPrevented)return;const t=this._getDimension();this._element.style[t]=`${this._element.getBoundingClientRect()[t]}px`,(0,r.qm)(this._element),this._element.classList.add(ce),this._element.classList.remove(de,he);for(const t of this._triggerArray){const e=s.A.getElementFromSelector(t);e&&!this._isShown(e)&&this._addAriaAndCollapsedClass([t],!1)}this._isTransitioning=!0,this._element.style[t]="",this._queueCallback(()=>{this._isTransitioning=!1,this._element.classList.remove(ce),this._element.classList.add(de),g.A.trigger(this._element,pe)},this._element,!0)}dispose(){super.dispose()}_isShown(t=this._element){return t.classList.contains(he)}_addAriaAndCollapsedClass(t,e){if(t.length)for(const i of t)this._changeStateButton(i,e)}_initializeChildren(){if(!this._params.parent)return;const t=this._getFirstLevelChildren(ue);for(const e of t){const t=s.A.getElementFromSelector(e);t&&this._addAriaAndCollapsedClass([e],this._isShown(t))}}_getFirstLevelChildren(t){const e=s.A.findAll(_e,this._params.parent);return s.A.findAll(t,this._params.parent).filter(t=>!e.includes(t))}_changeStateButton(t,i){t.classList.toggle("vg-collapsed",!i),t.setAttribute("aria-expanded",i),t.innerHTML=e.p.get(t,`data-${i?"hide":"show"}-text`)||t.innerHTML}_getDimension(){return this._element.classList.contains("vg-collapse-horizontal")?"width":"height"}}g.A.on(document,ve,ue,function(t){("A"===t.target.tagName||t.delegateTarget&&"A"===t.delegateTarget.tagName)&&t.preventDefault(),s.A.getMultipleElementsFromSelector(this).forEach(function(t){ye.getOrCreateInstance(t,{toggle:!1}).toggle()})});const we=ye,Ee=we,Ae={pathAttribute:"data-vg-filepreview",fieldsAttribute:"data-fields",validAttribute:"data-vg-filepreview-valid",errorAttribute:"data-vg-filepreview-error",errorValue:"invalid-file-path",fieldAttribute:"data-vg-filepreview-field",editableAttribute:"data-vg-filepreview-editable",editableFieldsAttribute:"data-vg-filepreview-editable-fields",missingFieldsAttribute:"data-vg-filepreview-missing-fields"},Se=class{constructor(t,e={}){this._element=t,this._options=Object.assign({},Ae,e)}getFilePath(){if(!this._element)return"";const t=this._element.getAttribute(this._options.pathAttribute);return"string"==typeof t?t.trim():""}getFields(){if(!this._element)return[];const t=this._element.getAttribute(this._options.fieldsAttribute);return"string"==typeof t&&t.trim()?t.split(",").map(t=>t.trim()).filter(t=>t&&/^[-_a-zA-Z0-9]+$/.test(t)):[]}validateFilePath(t){if(!t||"#"===t||/^javascript:/i.test(t))return{isValid:!1,fileUrl:null};try{const e=new URL(t,window.location.origin),i=e.protocol;if(!["http:","https:","blob:","data:"].includes(i))return{isValid:!1,fileUrl:null};if("data:"===i||"blob:"===i)return{isValid:!0,fileUrl:e};const s=(e.pathname||"").split("/").filter(Boolean).pop()||"";return s&&s.includes(".")?{isValid:!0,fileUrl:e}:{isValid:!1,fileUrl:null}}catch{return{isValid:!1,fileUrl:null}}}syncState(t){this._element&&(this._element.setAttribute(this._options.validAttribute,t?"true":"false"),t?this._element.removeAttribute(this._options.errorAttribute):this._element.setAttribute(this._options.errorAttribute,this._options.errorValue))}resolveEditableFields(t=[]){return this._element&&Array.isArray(t)&&t.length?t.reduce((t,e)=>(t[e]=this._element.querySelector(`.${this._escapeClassName(e)}`),t),{}):{}}syncEditableFields(t={}){if(!this._element)return;this._element.querySelectorAll(`[${this._options.fieldAttribute}]`).forEach(t=>{t.removeAttribute(this._options.fieldAttribute),t.setAttribute(this._options.editableAttribute,"false")});const e=[],i=[];Object.entries(t).forEach(([t,s])=>{s?(s.setAttribute(this._options.fieldAttribute,t),s.setAttribute(this._options.editableAttribute,"true"),e.push(t)):i.push(t)}),e.length?this._element.setAttribute(this._options.editableFieldsAttribute,e.join(",")):this._element.removeAttribute(this._options.editableFieldsAttribute),i.length?this._element.setAttribute(this._options.missingFieldsAttribute,i.join(",")):this._element.removeAttribute(this._options.missingFieldsAttribute)}_escapeClassName(t){return window.CSS&&"function"==typeof window.CSS.escape?window.CSS.escape(t):String(t).replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}getFileMeta(t){const e="string"==typeof t?t.trim():"";if(!e)return{name:"",ext:"",originalName:"",isMedia:!1,sizeBytes:null,sizeText:""};try{const t=new URL(e,window.location.origin),i=t.pathname||"",s=t.searchParams,r=this._readOriginalName(s);let n=decodeURIComponent(i.split("/").pop()||"");n&&n.includes(".")||(n=r||n);const a=n.includes(".")?`.${n.split(".").pop()||""}`:"",o=this._readSize(s),l=[".mp3",".wav",".ogg",".flac",".aac",".m4a",".mp4",".webm",".mov",".mkv",".avi"];return{name:n,ext:a.toLowerCase(),originalName:r,isMedia:l.includes(a.toLowerCase()),sizeBytes:o,sizeText:this._formatSize(o)}}catch{const t=e.split("#")[0].split("?")[0];let i=decodeURIComponent(t.split("/").pop()||"");const s=this._readOriginalName(null);i&&i.includes(".")||(i=s||i);const r=i.includes(".")?`.${i.split(".").pop()||""}`:"",n=this._readSize(null);return{name:i,ext:r.toLowerCase(),originalName:s||"",isMedia:!1,sizeBytes:n,sizeText:this._formatSize(n)}}}_readOriginalName(t){const e=this._element?.getAttribute("data-original-name")||this._element?.getAttribute("data-vg-filepreview-original-name")||"";if(e)return String(e).trim();const i=["original_name","originalName","filename","name"];for(const e of i){const i=t.get(e);if(i)return String(i).trim()}return""}_readSize(t){const e=[this._element?.getAttribute("data-size"),this._element?.getAttribute("data-vg-filepreview-size")];for(const t of e){const e=this._parseSizeValue(t);if(null!==e)return e}if(!t)return null;const i=["size","size_bytes","bytes"];for(const e of i){const i=t.get(e),s=this._parseSizeValue(i);if(null!==s)return s}return null}_parseSizeValue(t){if(null==t)return null;const e=String(t).trim().toLowerCase();if(!e)return null;const i=e.match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|tb)?$/i);if(!i)return null;const s=Number.parseFloat(i[1]);if(!Number.isFinite(s)||s<0)return null;const r=(i[2]||"b").toLowerCase();return Math.round(s*({b:1,kb:1024,mb:1048576,gb:1073741824,tb:1099511627776}[r]||1))}_formatSize(t){if(!Number.isFinite(t)||t<0)return"";const e=["B","KB","MB","GB","TB"];let i=t,s=0;for(;i>=1024&&s<e.length-1;)i/=1024,s+=1;const r=i>=100||0===s?0:2;return`${i.toFixed(r)} ${e[s]}`}},Ce=new Set(["mp3"]),xe=(t,e=0)=>(127&t[e])<<21|(127&t[e+1])<<14|(127&t[e+2])<<7|127&t[e+3],Le=(t,e,i)=>i?xe([t.getUint8(e),t.getUint8(e+1),t.getUint8(e+2),t.getUint8(e+3)],0):(t.getUint8(e)<<24|t.getUint8(e+1)<<16|t.getUint8(e+2)<<8|t.getUint8(e+3))>>>0,Ie=(t,e)=>{if(!t||!t.length)return"";try{if(0===e)return new TextDecoder("iso-8859-1").decode(t).replace(/\u0000/g,"").trim();if(1===e){if(t.length>=2){const e=t[0],i=t[1];if(255===e&&254===i)return new TextDecoder("utf-16le").decode(t.slice(2)).replace(/\u0000/g,"").trim();if(254===e&&255===i){const e=new Uint8Array(t.length-2);for(let i=2;i+1<t.length;i+=2)e[i-2]=t[i+1],e[i-1]=t[i];return new TextDecoder("utf-16le").decode(e).replace(/\u0000/g,"").trim()}}return new TextDecoder("utf-16le").decode(t).replace(/\u0000/g,"").trim()}if(2===e){const e=new Uint8Array(t.length);for(let i=0;i+1<t.length;i+=2)e[i]=t[i+1],e[i+1]=t[i];return new TextDecoder("utf-16le").decode(e).replace(/\u0000/g,"").trim()}return new TextDecoder("utf-8").decode(t).replace(/\u0000/g,"").trim()}catch{return""}},Pe=(t,e,i=1)=>{for(let s=e;s<t.length;s+=i)if(2===i){if(s+1<t.length&&0===t[s]&&0===t[s+1])return s}else if(0===t[s])return s;return-1},Me=t=>{if(!t||t.length<4)return null;const e=t[0];let i=1;const s=Pe(t,i);if(s<0)return null;const r=new TextDecoder("iso-8859-1").decode(t.slice(i,s)).trim();if(i=s+1,i>=t.length)return null;i+=1;const n=1===e||2===e,a=Pe(t,i,n?2:1);if(a>=0&&(i=a+(n?2:1)),i>=t.length)return null;const o=t.slice(i),l=r||"image/jpeg";return o.length?{mimeType:l,data:o}:null},ke=async t=>{if(!(t instanceof File))return null;const e=(t=>{const e=String(t?.name||"").toLowerCase(),i=e.lastIndexOf(".");return i<0||i>=e.length-1?"":e.slice(i+1)})(t);if(!Ce.has(e))return null;if(!t.size)return null;try{const e=t.slice(0,Math.min(t.size,2097152)),i=(t=>{const e=new Uint8Array(t);if(e.length<10)return null;if(73!==e[0]||68!==e[1]||51!==e[2])return null;const i=e[3];if(i<2||i>4)return null;const s=xe(e,6),r=Math.min(e.length,s+10),n=new DataView(t,0,r);let a=10,o="",l=null;for(;a+10<=r;){const t=String.fromCharCode(n.getUint8(a),n.getUint8(a+1),n.getUint8(a+2),n.getUint8(a+3));if(!t.trim())break;const s=Le(n,a+4,4===i);if(!s||s<1)break;const h=a+10,d=h+s;if(d>r)break;const c=e.slice(h,d);"TIT2"===t&&c.length>1&&(o=Ie(c.slice(1),c[0])||o),"APIC"!==t||l||(l=Me(c)),a=d}return{title:o,picture:l}})(await e.arrayBuffer());if(!i)return null;const s={};if(i.title&&(s.title=i.title),i.picture?.data?.length){const t=new Blob([i.picture.data],{type:i.picture.mimeType||"image/jpeg"});s.pictureBlob=t}return Object.keys(s).length?s:null}catch{return null}},De=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]);class Te{constructor(){this._modalId="vg-filepreview-image-modal"}static getInstance(){return Te._instance||(Te._instance=new Te),Te._instance}open(t={}){const e=String(t.src||"").trim();if(!e)return;if(this._ensureModal(),!this._modal||!this._image)return;const i=String(t.defaultTitle||"").trim(),s=String(t.title||"").trim();this._title.textContent=s||i,this._image.src=e,this._image.alt=s||i,this._modal.show()}close(){this._modal&&this._modal.hide()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const t={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},e=document.getElementById(this._modalId);if(e)return this._root=e,this._modal=ht.getOrCreateInstance(e,t),this._bindElements(e),void this._bindLifecycle(e);this._modal=ht.build(this._modalId,t,t=>{const e=t._element;this._root=e,e.classList.add("vg-filepreview-image-modal");const i=e.querySelector(".vg-modal-body"),s=e.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=e.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="",this._image=document.createElement("img"),this._image.className="vg-filepreview-image-modal__img",this._image.loading="eager",this._image.decoding="async",r.appendChild(this._title),i.appendChild(this._image),this._bindLifecycle(e)})}_bindElements(t){this._title=t.querySelector(".vg-filepreview-image-modal__title"),this._image=t.querySelector(".vg-filepreview-image-modal__img")}_bindLifecycle(t){t&&!t.hasAttribute("data-vg-filepreview-image-lifecycle-bind")&&(t.setAttribute("data-vg-filepreview-image-lifecycle-bind","true"),t.addEventListener("vg.modal.hidden",()=>{this._destroyModal()}))}_destroyModal(){this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._image=null}}const Oe=Te,ze=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".tif",".tiff",".heic",".heif",".avif"]),Ne=class{constructor(){this.name="image",this._modal=Oe.getInstance()}canRender(t={}){const e=String(t?.fileMeta?.ext||"").toLowerCase();return ze.has(e)}render(t={}){const e=t?.previewContainer,i=Boolean(t?.ui?.nameOnly),s=t?.i18n,r=t?.fileUrl?.href||t?.filePath||"";if(!r)return!1;const n=e=>{e&&e.preventDefault(),this._modal.open({src:r,title:t?.fileMeta?.name||s?.message("image_title")||"",defaultTitle:s?.message("image_title")||""})},a=t?.element?.querySelector(".name");a&&!a.hasAttribute("data-vg-filepreview-image-bind")&&(a.setAttribute("data-vg-filepreview-image-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n));const o=t?.element?.closest(".file")?.querySelector(".file-image .file-preview");if(o&&!o.hasAttribute("data-vg-filepreview-image-bind")&&(o.setAttribute("data-vg-filepreview-image-bind","true"),o.classList.add("is-preview-action"),o.addEventListener("click",n)),i)return Boolean(a||o);if(!e)return!1;const l=document.createElement("button");l.type="button",l.className="vg-filepreview-image-trigger",l.textContent=s?.button("open_image")||"",l.addEventListener("click",n),e.appendChild(l);const h=document.createElement("img");return h.className="vg-filepreview-image-thumb",h.src=r,h.alt=t?.fileMeta?.name||s?.message("image_thumbnail_alt")||"",h.loading="lazy",h.addEventListener("click",n),e.appendChild(h),!0}};class $e{constructor(){this._modalId="vg-filepreview-office-modal",this._labels={}}static getInstance(){return $e._instance||($e._instance=new $e),$e._instance}open(t={}){const e=String(t.src||"").trim();if(!e)return;if(this._ensureModal(),!this._modal||!this._frame)return;this._labels=t?.labels&&"object"==typeof t.labels?t.labels:{},this._src=e,this._downloadName=String(t.downloadName||"").trim();const i=String(t.defaultTitle||"").trim(),s=String(t.title||"").trim();this._title.textContent=s||i,this._fallback.textContent=this._label("fallback"),this._download.textContent=this._label("download"),this._frame.src=this._buildViewerUrl(e),this._modal.show()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){this._modal=ht.build(this._modalId,{centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},t=>{const e=t._element;this._root=e,e.classList.add("vg-filepreview-office-modal");const i=e.querySelector(".vg-modal-body"),s=e.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=e.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._frame=document.createElement("iframe"),this._frame.className="vg-filepreview-office-modal__frame",this._frame.setAttribute("title","Office preview");const n=document.createElement("div");n.className="vg-filepreview-office-modal__footer",this._fallback=document.createElement("span"),this._fallback.className="vg-filepreview-office-modal__hint",this._download=document.createElement("button"),this._download.type="button",this._download.className="vg-filepreview-office-modal__btn",this._download.addEventListener("click",()=>this._downloadFile()),n.appendChild(this._fallback),n.appendChild(this._download),r.appendChild(this._title),i.appendChild(this._frame),s.appendChild(n),this._bindLifecycle(e)})}_buildViewerUrl(t){const e=new URL(t,window.location.origin).href;return`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(e)}`}_downloadFile(){if(!this._src)return;const t=document.createElement("a");t.href=this._src,this._downloadName&&t.setAttribute("download",this._downloadName),t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)}_label(t){const e=this._labels?.[t];return String(e||"").trim()}_bindLifecycle(t){t&&!t.hasAttribute("data-vg-filepreview-office-lifecycle-bind")&&(t.setAttribute("data-vg-filepreview-office-lifecycle-bind","true"),t.addEventListener("vg.modal.hidden",()=>this._destroyModal()))}_destroyModal(){this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._frame=null,this._fallback=null,this._download=null,this._labels=null,this._src="",this._downloadName=""}}const He=$e,Fe=new Set([".doc",".docx",".xls",".xlsx",".ppt",".pptx",".odt",".ods",".odp"]),Re=class{constructor(){this.name="office",this._modal=He.getInstance()}canRender(t={}){const e=String(t?.fileMeta?.ext||"").toLowerCase();return Fe.has(e)}render(t={}){const e=t?.previewContainer,i=Boolean(t?.ui?.nameOnly),s=t?.i18n,r=t?.fileUrl?.href||t?.filePath||"";if(!r)return!1;const n=e=>{e&&e.preventDefault(),this._modal.open({src:r,title:t?.fileMeta?.name||s?.message("office_title")||"",defaultTitle:s?.message("office_title")||"",downloadName:t?.fileMeta?.originalName||t?.fileMeta?.name||"",labels:{download:s?.button("download")||"",fallback:s?.message("office_fallback")||""}})},a=t?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-office-bind")&&(a.setAttribute("data-vg-filepreview-office-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!e)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-office-trigger",o.textContent=s?.button("open_office")||"",o.addEventListener("click",n),e.appendChild(o),!0}};class Be{constructor(){this._modalId="vg-filepreview-pdf-modal",this._labels={},this._src="",this._downloadName="",this._page=1,this._zoom=100}static getInstance(){return Be._instance||(Be._instance=new Be),Be._instance}open(t={}){const e=String(t.src||"").trim();if(!e)return;if(this._ensureModal(),!this._modal||!this._frame)return;this._labels=t?.labels&&"object"==typeof t.labels?t.labels:{},this._src=e,this._downloadName=String(t.downloadName||"").trim(),this._page=1,this._zoom=100;const i=String(t.defaultTitle||"").trim(),s=String(t.title||"").trim();this._title.textContent=s||i,this._syncControls(),this._updateFrameSrc(),this._modal.show()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const t={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},e=document.getElementById(this._modalId);if(e)return this._root=e,this._modal=ht.getOrCreateInstance(e,t),this._bindElements(e),void this._bindLifecycle(e);this._modal=ht.build(this._modalId,t,t=>{const e=t._element;this._root=e,e.classList.add("vg-filepreview-pdf-modal");const i=e.querySelector(".vg-modal-body"),s=e.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-pdf-modal__body"),i.innerHTML="";let r=e.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title";const n=document.createElement("div");n.className="vg-filepreview-pdf-modal__toolbar",this._pagePrev=document.createElement("button"),this._pagePrev.type="button",this._pagePrev.className="vg-filepreview-pdf-modal__btn",this._pagePrev.setAttribute("data-role","page-prev"),this._pagePrev.addEventListener("click",()=>{this._page=Math.max(1,this._page-1),this._syncControls(),this._updateFrameSrc()}),this._pageInfo=document.createElement("span"),this._pageInfo.className="vg-filepreview-pdf-modal__meta",this._pageInfo.setAttribute("data-role","page"),this._pageNext=document.createElement("button"),this._pageNext.type="button",this._pageNext.className="vg-filepreview-pdf-modal__btn",this._pageNext.setAttribute("data-role","page-next"),this._pageNext.addEventListener("click",()=>{this._page+=1,this._syncControls(),this._updateFrameSrc()}),this._zoomOut=document.createElement("button"),this._zoomOut.type="button",this._zoomOut.className="vg-filepreview-pdf-modal__btn",this._zoomOut.setAttribute("data-role","zoom-out"),this._zoomOut.addEventListener("click",()=>{this._zoom=Math.max(50,this._zoom-10),this._syncControls(),this._updateFrameSrc()}),this._zoomIn=document.createElement("button"),this._zoomIn.type="button",this._zoomIn.className="vg-filepreview-pdf-modal__btn",this._zoomIn.setAttribute("data-role","zoom-in"),this._zoomIn.addEventListener("click",()=>{this._zoom=Math.min(300,this._zoom+10),this._syncControls(),this._updateFrameSrc()}),this._zoomInfo=document.createElement("span"),this._zoomInfo.className="vg-filepreview-pdf-modal__meta",this._zoomInfo.setAttribute("data-role","zoom"),this._download=document.createElement("button"),this._download.type="button",this._download.className="vg-filepreview-pdf-modal__btn primary",this._download.setAttribute("data-role","download"),this._download.addEventListener("click",()=>this._downloadFile()),n.appendChild(this._pagePrev),n.appendChild(this._pageInfo),n.appendChild(this._pageNext),n.appendChild(this._zoomOut),n.appendChild(this._zoomInfo),n.appendChild(this._zoomIn),n.appendChild(this._download),this._frame=document.createElement("iframe"),this._frame.className="vg-filepreview-pdf-modal__frame",this._frame.setAttribute("title","PDF preview"),r.appendChild(this._title),i.appendChild(this._frame),this._bindLifecycle(e)})}_bindElements(t){this._title=t.querySelector(".vg-filepreview-pdf-modal__title"),this._frame=t.querySelector(".vg-filepreview-pdf-modal__frame"),this._pagePrev=t.querySelector('.vg-filepreview-pdf-modal__btn[data-role="page-prev"]'),this._pageNext=t.querySelector('.vg-filepreview-pdf-modal__btn[data-role="page-next"]'),this._zoomOut=t.querySelector('.vg-filepreview-pdf-modal__btn[data-role="zoom-out"]'),this._zoomIn=t.querySelector('.vg-filepreview-pdf-modal__btn[data-role="zoom-in"]'),this._download=t.querySelector('.vg-filepreview-pdf-modal__btn[data-role="download"]'),this._pageInfo=t.querySelector('.vg-filepreview-pdf-modal__meta[data-role="page"]'),this._zoomInfo=t.querySelector('.vg-filepreview-pdf-modal__meta[data-role="zoom"]')}_bindLifecycle(t){t&&!t.hasAttribute("data-vg-filepreview-pdf-lifecycle-bind")&&(t.setAttribute("data-vg-filepreview-pdf-lifecycle-bind","true"),t.addEventListener("vg.modal.hidden",()=>this._destroyModal()))}_syncControls(){this._pageInfo&&this._zoomInfo&&(this._pagePrev.textContent=this._label("prevPage"),this._pageNext.textContent=this._label("nextPage"),this._zoomOut.textContent=this._label("zoomOut"),this._zoomIn.textContent=this._label("zoomIn"),this._download.textContent=this._label("download"),this._pageInfo.textContent=`${this._label("page")}: ${this._page}`,this._zoomInfo.textContent=`${this._label("zoom")}: ${this._zoom}%`)}_updateFrameSrc(){if(!this._frame||!this._src)return;const t=`#page=${this._page}&zoom=${this._zoom}`;this._frame.src=`${this._src}${t}`}_downloadFile(){if(!this._src)return;const t=document.createElement("a");t.href=this._src,this._downloadName&&t.setAttribute("download",this._downloadName),t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)}_label(t){const e=this._labels?.[t];return String(e||"").trim()}_destroyModal(){this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._frame=null,this._labels=null,this._src=""}}const je=Be,Ue=new Set([".pdf"]),qe=class{constructor(){this.name="pdf",this._modal=je.getInstance()}canRender(t={}){const e=String(t?.fileMeta?.ext||"").toLowerCase();return Ue.has(e)}render(t={}){const e=t?.previewContainer,i=Boolean(t?.ui?.nameOnly),s=t?.i18n,r=t?.fileUrl?.href||t?.filePath||"";if(!r)return!1;const n=e=>{e&&e.preventDefault(),this._modal.open({src:r,title:t?.fileMeta?.name||s?.message("pdf_title")||"",defaultTitle:s?.message("pdf_title")||"",labels:{page:s?.message("pdf_page")||"",zoom:s?.message("pdf_zoom")||"",zoomIn:s?.button("zoom_in")||"",zoomOut:s?.button("zoom_out")||"",prevPage:s?.button("prev")||"",nextPage:s?.button("next")||"",download:s?.button("download")||""},downloadName:t?.fileMeta?.originalName||t?.fileMeta?.name||"file.pdf"})},a=t?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-pdf-bind")&&(a.setAttribute("data-vg-filepreview-pdf-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!e)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-pdf-trigger",o.textContent=s?.button("open_pdf")||"",o.addEventListener("click",n),e.appendChild(o),!0}};class Ve{constructor(){this._modalId="vg-filepreview-text-modal",this._abortController=null,this._labels={}}static getInstance(){return Ve._instance||(Ve._instance=new Ve),Ve._instance}open(t={}){const e=String(t.src||"").trim();if(!e)return;if(this._ensureModal(),!this._modal||!this._content)return;this._labels=t?.labels&&"object"==typeof t.labels?t.labels:{};const i=String(t.defaultTitle||"").trim(),s=String(t.title||"").trim(),r=String(t.ext||"").toLowerCase();this._title.textContent=s||i,this._content.textContent=this._label("loading"),this._content.classList.remove("is-markdown"),this._modal.show(),this._loadText(e,{ext:r})}close(){this._modal&&this._modal.hide()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const t={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"600px",height:""},animation:{enable:!1}},e=document.getElementById(this._modalId);if(e)return this._root=e,this._modal=ht.getOrCreateInstance(e,t),this._bindElements(e),void this._bindLifecycle(e);this._modal=ht.build(this._modalId,t,t=>{const e=t._element;this._root=e,e.classList.add("vg-filepreview-text-modal");const i=e.querySelector(".vg-modal-body"),s=e.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-text-modal__body"),i.innerHTML="";let r=e.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="",this._content=document.createElement("pre"),this._content.className="vg-filepreview-text-modal__content",this._content.textContent="",r.appendChild(this._title),i.appendChild(this._content),this._bindLifecycle(e)})}_bindElements(t){this._title=t.querySelector(".vg-filepreview-text-modal__title"),this._content=t.querySelector(".vg-filepreview-text-modal__content")}_bindLifecycle(t){t&&!t.hasAttribute("data-vg-filepreview-text-lifecycle-bind")&&(t.setAttribute("data-vg-filepreview-text-lifecycle-bind","true"),t.addEventListener("vg.modal.hidden",()=>{this._destroyModal()}))}_loadText(t,e={}){const i=String(e.ext||"").toLowerCase(),s=`${t}|${i}`;if(Ve._cache.has(s)){const t=Ve._cache.get(s);return void this._renderLoadedText(t,i)}this._abortController&&this._abortController.abort(),this._abortController=new AbortController,fetch(t,{method:"GET",signal:this._abortController.signal}).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.text()}).then(t=>{const e=t||"";Ve._cache.set(s,e),this._renderLoadedText(e,i)}).catch(t=>{this._content&&"AbortError"!==t?.name&&(this._content.classList.remove("is-markdown"),this._content.textContent=`${this._label("cannotOpen")}: ${t?.message||this._label("unknownError")}`)})}_renderLoadedText(t,e){if(!this._content)return;const i=String(t||"");".md"===e?(this._content.classList.add("is-markdown"),this._content.innerHTML=this._renderMarkdown(i)):(this._content.classList.remove("is-markdown"),this._content.textContent=i||this._label("emptyFile"))}_destroyModal(){this._abortController&&(this._abortController.abort(),this._abortController=null),this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._content=null,this._labels=null}_label(t,e=""){const i=this._labels?.[t];return"string"==typeof i&&i.trim()?i:e}_renderMarkdown(t){const e=t=>String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),i=t=>{let i=e(t);return i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*([^*]+)\*/g,"<em>$1</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,e,i)=>`<a href="${this._sanitizeUrl(i)}" target="_blank" rel="noopener noreferrer">${e}</a>`),i},s=String(t||"").split(/\r?\n/),r=[];let n=!1,a=!1;return s.forEach(t=>{const s=t||"";if(s.trim().startsWith("```"))return void(a?(a=!1,r.push("</code></pre>")):(a=!0,r.push("<pre><code>")));if(a)return void r.push(`${e(s)}\n`);if(!s.trim())return void(n&&(n=!1,r.push("</ul>")));const o=s.match(/^(#{1,6})\s+(.+)$/);if(o){n&&(n=!1,r.push("</ul>"));const t=o[1].length;return void r.push(`<h${t}>${i(o[2])}</h${t}>`)}const l=s.match(/^[-*]\s+(.+)$/);if(l)return n||(n=!0,r.push("<ul>")),void r.push(`<li>${i(l[1])}</li>`);n&&(n=!1,r.push("</ul>")),r.push(`<p>${i(s)}</p>`)}),n&&r.push("</ul>"),a&&r.push("</code></pre>"),r.join("")||`<p>${this._escapeHtml(this._label("emptyFile"))}</p>`}_escapeHtml(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}_sanitizeUrl(t){const e=String(t||"").trim();if(!e)return"#";try{const t=new URL(e,window.location.origin);if(["http:","https:","mailto:"].includes(t.protocol))return t.href}catch{return"#"}return"#"}}Ve._cache=new Map;const We=Ve,Ke=new Set([".txt",".md",".csv",".json",".xml",".yml",".yaml",".log",".ini",".conf",".env"]),Ge=class{constructor(){this.name="text",this._modal=We.getInstance()}canRender(t={}){const e=String(t?.fileMeta?.ext||"").toLowerCase();return Ke.has(e)}render(t={}){const e=t?.previewContainer,i=Boolean(t?.ui?.nameOnly),s=t?.i18n,r=t?.fileUrl?.href||t?.filePath||"";if(!r)return!1;const n=e=>{e&&e.preventDefault(),this._modal.open({src:r,title:t?.fileMeta?.name||s?.message("text_title")||"",defaultTitle:s?.message("text_title")||"",ext:t?.fileMeta?.ext||"",labels:{loading:s?.message("loading_text")||"",cannotOpen:s?.message("cannot_open_file")||"",unknownError:s?.message("unknown_error")||"",emptyFile:s?.message("empty_file")||""}})},a=t?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-text-bind")&&(a.setAttribute("data-vg-filepreview-text-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!e)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-text-trigger",o.textContent=s?.button("open_text")||"",o.addEventListener("click",n),e.appendChild(o),!0}};class Ye{constructor(){this._modalId="vg-filepreview-video-modal",this._playlist=[],this._currentIndex=-1,this._labels={},this._onKeyDown=t=>this._handleHotkeys(t)}static getInstance(){return Ye._instance||(Ye._instance=new Ye),Ye._instance}open(t={}){const e=String(t.src||"").trim();if(!e)return;if(this._ensureModal(),!this._modal||!this._video)return;const i=t?.playlist&&"object"==typeof t.playlist?t.playlist:null;if(this._labels=t?.labels&&"object"==typeof t.labels?t.labels:{},i?.tracks?.length){this._playlist=i.tracks;const t=this._playlist.findIndex(t=>String(t.src||"").trim()===e);this._currentIndex=t>=0?t:Number(i.currentIndex||0)}else this._playlist=[{src:e,title:String(t.title||"").trim()}],this._currentIndex=0;const s=String(t.defaultTitle||"").trim(),r=String(t.title||"").trim();this._title.textContent=r||s,this._syncNavigation(),this._video.src=e,this._video.load(),this._modal.show(),this._video.play().catch(()=>{})}close(){this._modal&&(this._modal.hide(),this._stop())}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const t={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"fit-content"},animation:{enable:!1}},e=document.getElementById(this._modalId);if(e)return this._root=e,this._modal=ht.getOrCreateInstance(e,t),this._bindElements(e),void this._bindEvents(e);this._modal=ht.build(this._modalId,t,t=>{const e=t._element;this._root=e,e.classList.add("vg-filepreview-video-modal");const i=e.querySelector(".vg-modal-body"),s=e.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=e.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="";const n=document.createElement("div");n.className="vg-filepreview-video-modal__navigation",this._prevButton=document.createElement("button"),this._prevButton.type="button",this._prevButton.className="vg-filepreview-video-modal__nav-btn",this._prevButton.addEventListener("click",()=>this._goPrev()),this._nextButton=document.createElement("button"),this._nextButton.type="button",this._nextButton.className="vg-filepreview-video-modal__nav-btn",this._nextButton.addEventListener("click",()=>this._goNext()),n.appendChild(this._prevButton),n.appendChild(this._nextButton),this._video=document.createElement("video"),this._video.className="vg-filepreview-video-modal__video",this._video.controls=!0,this._video.preload="metadata",this._video.playsInline=!0,this._video.addEventListener("ended",()=>this._goNext(!0)),r.appendChild(this._title),r.appendChild(n),i.appendChild(this._video),this._bindEvents(e)})}_bindElements(t){this._title=t.querySelector(".vg-filepreview-video-modal__title"),this._video=t.querySelector(".vg-filepreview-video-modal__video")}_bindEvents(t){t&&!t.hasAttribute("data-vg-filepreview-video-bind")&&(t.setAttribute("data-vg-filepreview-video-bind","true"),document.addEventListener("keydown",this._onKeyDown),t.addEventListener("vg.modal.hidden",()=>{this._stop(),this._destroyModal()}))}_stop(){this._video&&(this._video.pause(),this._video.currentTime=0)}_destroyModal(){document.removeEventListener("keydown",this._onKeyDown),this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._prevButton=null,this._nextButton=null,this._video=null,this._playlist=[],this._currentIndex=-1,this._labels={}}_syncNavigation(){if(!this._prevButton||!this._nextButton)return;this._prevButton.textContent=this._labels.prev||"",this._nextButton.textContent=this._labels.next||"";const t=this._playlist.length>1;this._prevButton.disabled=!t,this._nextButton.disabled=!t}_goPrev(){this._playlist.length&&(this._currentIndex=this._currentIndex<=0?this._playlist.length-1:this._currentIndex-1,this._openCurrentTrack())}_goNext(t=!1){this._playlist.length&&(1!==this._playlist.length||t)&&(this._currentIndex=(this._currentIndex+1)%this._playlist.length,this._openCurrentTrack())}_openCurrentTrack(){const t=this._playlist[this._currentIndex];t?.src&&this.open({src:t.src,title:t.title||"",defaultTitle:t.title||"",playlist:{tracks:this._playlist,currentIndex:this._currentIndex},labels:this._labels})}_handleHotkeys(t){if(!this._root||!this._root.classList.contains("show"))return;const e=String(t?.target?.tagName||"").toUpperCase();["INPUT","TEXTAREA","SELECT"].includes(e)||("ArrowLeft"===t.key&&(t.preventDefault(),this._goPrev()),"ArrowRight"===t.key&&(t.preventDefault(),this._goNext()))}}const Xe=Ye,Ze=t=>{const e=t?.getAttribute("data-vg-filepreview")||"";return String(e).trim()},Je=t=>{try{return new URL(t,window.location.origin).href}catch{return""}},Qe=(t,e="")=>{const i=t?.querySelector(".name"),s=String(i?.textContent||"").trim();if(s)return s;const r=String(e).split("/").pop()||"";return decodeURIComponent(r)},ti=t=>{const e=t?.querySelector(".original_name");return String(e?.textContent||"").trim()},ei=new Set([".mp4",".webm",".mov",".mkv",".avi",".m4v"]),ii=class{constructor(){this.name="video",this._modal=Xe.getInstance()}canRender(t={}){const e=String(t?.fileMeta?.ext||"").toLowerCase();return ei.has(e)}render(t={}){const e=t?.previewContainer,i=Boolean(t?.ui?.nameOnly),s=t?.i18n,r=t?.fileUrl?.href||t?.filePath||"";if(!r)return!1;const n={prev:s?.button("prev")||"",next:s?.button("next")||""},a=e=>{e&&e.preventDefault();const i=((t,e=()=>!0)=>{const i=Array.from(document.querySelectorAll('[data-vg-filepreview][data-vg-filepreview-valid="true"]')).map(t=>{const e=Ze(t),i=Je(e),s=(t=>{if(!t)return"";const e=String(t).split("#")[0].split("?")[0].split("/").pop()||"";return e.includes(".")?`.${String(e.split(".").pop()||"").toLowerCase()}`:""})(e);return{element:t,path:e,src:i,ext:s,title:Qe(t,e),subtitle:ti(t)}}).filter(t=>t.src&&e(t.ext)),s=Je(Ze(t)),r=i.findIndex(t=>t.src===s);return{tracks:i,currentIndex:r>=0?r:0}})(t?.element,t=>ei.has(t));this._modal.open({src:r,title:t?.fileMeta?.name||s?.message("video_title")||"",defaultTitle:s?.message("video_title")||"",playlist:i,labels:n})},o=t?.element?.querySelector(".name");if(o&&!o.hasAttribute("data-vg-filepreview-video-bind")&&(o.setAttribute("data-vg-filepreview-video-bind","true"),o.classList.add("is-preview-action"),o.addEventListener("click",a)),i)return Boolean(o);if(!e)return!1;const l=document.createElement("button");return l.type="button",l.className="vg-filepreview-video-trigger",l.textContent=s?.button("open_video")||"",l.addEventListener("click",a),e.appendChild(l),!0}};class si{constructor(){this._modalId="vg-filepreview-zip-modal",this._abortController=null,this._labels={},this._entries=[],this._arrayBuffer=null}static getInstance(){return si._instance||(si._instance=new si),si._instance}open(t={}){const e=String(t.src||"").trim();if(!e)return;if(this._ensureModal(),!this._modal||!this._content)return;this._labels=t?.labels&&"object"==typeof t.labels?t.labels:{};const i=String(t.defaultTitle||"").trim(),s=String(t.title||"").trim();this._title.textContent=s||i,this._content.innerHTML=`<div class="vg-filepreview-zip-modal__loading">${this._escapeHtml(this._label("loadingArchive"))}</div>`,this._modal.show(),this._loadZipEntries(e)}close(){this._modal&&this._modal.hide()}_ensureModal(){this._modal&&this._root||this._initModal()}_initModal(){const t={centered:!0,dismiss:!0,backdrop:!0,keyboard:!0,sizes:{width:"800px"},animation:{enable:!1}},e=document.getElementById(this._modalId);if(e)return this._root=e,this._modal=ht.getOrCreateInstance(e,t),this._bindElements(e),void this._bindLifecycle(e);this._modal=ht.build(this._modalId,t,t=>{const e=t._element;this._root=e,e.classList.add("vg-filepreview-zip-modal");const i=e.querySelector(".vg-modal-body"),s=e.querySelector(".vg-modal-content");if(!i||!s)return;i.classList.add("vg-filepreview-image-modal__body"),i.innerHTML="";let r=e.querySelector(".vg-modal-header");r||(r=document.createElement("div"),r.className="vg-modal-header",s.prepend(r)),this._title=document.createElement("div"),this._title.className="vg-modal-title",this._title.textContent="",this._content=document.createElement("div"),this._content.className="vg-filepreview-zip-modal__content",r.appendChild(this._title),i.appendChild(this._content),this._bindLifecycle(e)})}_bindElements(t){this._title=t.querySelector(".vg-filepreview-zip-modal__title"),this._content=t.querySelector(".vg-filepreview-zip-modal__content")}_bindLifecycle(t){t&&!t.hasAttribute("data-vg-filepreview-zip-lifecycle-bind")&&(t.setAttribute("data-vg-filepreview-zip-lifecycle-bind","true"),t.addEventListener("vg.modal.hidden",()=>{this._destroyModal()}))}_loadZipEntries(t){this._abortController&&this._abortController.abort(),this._abortController=new AbortController;const e=si._cache.get(t);if(e?.entries&&e?.arrayBuffer)return this._entries=e.entries,this._arrayBuffer=e.arrayBuffer,void this._renderEntries(this._entries);fetch(t,{method:"GET",signal:this._abortController.signal}).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.arrayBuffer()}).then(e=>{const i=this._parseZipEntries(e);this._entries=i,this._arrayBuffer=e,si._cache.set(t,{entries:i,arrayBuffer:e}),this._renderEntries(i)}).catch(t=>{if("AbortError"!==t?.name&&this._content){const e=this._resolveErrorText(t);this._content.innerHTML=`<div class="vg-filepreview-zip-modal__error">${this._escapeHtml(this._label("cannotOpenArchive"))}: ${this._escapeHtml(e)}</div>`}})}_destroyModal(){this._abortController&&(this._abortController.abort(),this._abortController=null),this._modal&&"function"==typeof this._modal.dispose&&this._modal.dispose(),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root),this._root=null,this._modal=null,this._title=null,this._content=null,this._labels=null,this._entries=[],this._arrayBuffer=null}_parseZipEntries(t){const e=new DataView(t),i=e.byteLength;if(i<22)throw new Error("invalid_zip");const s=this._findEndOfCentralDirectory(e);if(s<0)throw new Error("central_directory_not_found");const r=e.getUint16(s+10,!0),n=e.getUint32(s+16,!0),a=new TextDecoder("utf-8",{fatal:!1}),o=[];let l=n;for(let s=0;s<r&&!(l+46>i)&&33639248===e.getUint32(l,!0);s+=1){const s=e.getUint32(l+20,!0),r=e.getUint32(l+24,!0),n=e.getUint16(l+10,!0),h=e.getUint16(l+28,!0),d=e.getUint16(l+30,!0),c=e.getUint16(l+32,!0),_=e.getUint32(l+42,!0),u=l+46,m=u+h;if(m>i)break;const p=new Uint8Array(t,u,h),g=a.decode(p);o.push({name:g,compressedSize:s,uncompressedSize:r,compressionMethod:n,localHeaderOffset:_,isDirectory:g.endsWith("/")}),l=m+d+c}return o}_findEndOfCentralDirectory(t){const e=Math.max(0,t.byteLength-65557);for(let i=t.byteLength-22;i>=e;i-=1)if(101010256===t.getUint32(i,!0))return i;return-1}_renderEntries(t){if(!this._content)return;if(!t.length)return void(this._content.innerHTML=`<div class="vg-filepreview-zip-modal__empty">${this._escapeHtml(this._label("archiveEmptyUnsupported"))}</div>`);const e=t.map((t,e)=>{const i=t.isDirectory?this._label("typeDir"):this._label("typeFile"),s=t.isDirectory?"-":this._formatSize(t.compressedSize),r=t.isDirectory?"-":this._formatSize(t.uncompressedSize),n=!t.isDirectory&&this._canPreviewEntry(t)?`<button type="button" class="vg-filepreview-zip-modal__entry-btn" data-entry-index="${e}">${this._escapeHtml(this._label("previewEntry"))}</button>`:"-";return`\n<tr>\n\t<td>${e+1}</td>\n\t<td class="name">${this._escapeHtml(t.name)}</td>\n\t<td>${i}</td>\n\t<td>${s}</td>\n\t<td>${r}</td>\n\t<td>${n}</td>\n</tr>`}).join("");this._content.innerHTML=`\n<table class="vg-filepreview-zip-modal__table">\n\t<thead>\n\t\t<tr>\n\t\t\t<th>#</th>\n\t\t\t<th>${this._escapeHtml(this._label("tableName"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tableType"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tablePacked"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tableSize"))}</th>\n\t\t\t<th>${this._escapeHtml(this._label("tablePreview"))}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t${e}\n\t</tbody>\n</table>`,this._bindEntriesPreview()}_label(t,e=""){const i=this._labels?.[t];return"string"==typeof i&&i.trim()?i:e}_resolveErrorText(t){const e=String(t?.message||"").trim();return e?"invalid_zip"===e?this._label("invalidZip"):"central_directory_not_found"===e?this._label("centralDirectoryNotFound"):e:this._label("unknownError")}_formatSize(t){if(!Number.isFinite(t)||t<0)return"-";const e=["B","KB","MB","GB"];let i=t,s=0;for(;i>=1024&&s<e.length-1;)i/=1024,s+=1;const r=i>=100||0===s?0:2;return`${i.toFixed(r)} ${e[s]}`}_escapeHtml(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}_bindEntriesPreview(){this._content&&!this._content.hasAttribute("data-vg-filepreview-zip-preview-bind")&&(this._content.setAttribute("data-vg-filepreview-zip-preview-bind","true"),this._content.addEventListener("click",t=>{const e=t.target.closest("[data-entry-index]");if(!e)return;t.preventDefault();const i=Number(e.getAttribute("data-entry-index"));!Number.isFinite(i)||i<0||i>=this._entries.length||this._previewEntry(i)}))}_canPreviewEntry(t){if(!t||t.isDirectory||!t.name)return!1;const e=this._extractExtension(t.name);return new Set([".txt",".md",".json",".xml",".yml",".yaml",".csv",".log",".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"]).has(e)}async _previewEntry(t){if(!this._content)return;const e=this._entries[t];if(!e||!this._canPreviewEntry(e))return;let i=this._content.querySelector(".vg-filepreview-zip-modal__entry-preview");i||(i=document.createElement("div"),i.className="vg-filepreview-zip-modal__entry-preview",this._content.appendChild(i)),i.innerHTML=`<div class="vg-filepreview-zip-modal__entry-preview-loading">${this._escapeHtml(this._label("loadingEntry"))}</div>`;try{const t=await this._extractEntryBytes(e),s=this._extractExtension(e.name);if(this._isImageExtension(s)){const r=new Blob([t.buffer],{type:this._mimeByExtension(s)}),n=URL.createObjectURL(r);return i.innerHTML=`\n<div class="vg-filepreview-zip-modal__entry-preview-title">${this._escapeHtml(e.name)}</div>\n<img class="vg-filepreview-zip-modal__entry-preview-image" src="${n}" alt="${this._escapeHtml(e.name)}" />`,void setTimeout(()=>URL.revokeObjectURL(n),2e3)}const r=new TextDecoder("utf-8",{fatal:!1}).decode(t),n=this._escapeHtml(r||this._label("emptyFileInArchive"));i.innerHTML=`\n<div class="vg-filepreview-zip-modal__entry-preview-title">${this._escapeHtml(e.name)}</div>\n<pre class="vg-filepreview-zip-modal__entry-preview-text">${n}</pre>`}catch(t){i.innerHTML=`<div class="vg-filepreview-zip-modal__entry-preview-error">${this._escapeHtml(this._label("cannotPreviewEntry"))}: ${this._escapeHtml(t?.message||this._label("unknownError"))}</div>`}}async _extractEntryBytes(t){if(!this._arrayBuffer)throw new Error(this._label("archiveBufferMissing"));const e=new DataView(this._arrayBuffer),i=Number(t.localHeaderOffset||0);if(i+30>e.byteLength)throw new Error(this._label("entryCorrupted"));if(67324752!==e.getUint32(i,!0))throw new Error(this._label("entryCorrupted"));const s=i+30+e.getUint16(i+26,!0)+e.getUint16(i+28,!0),r=s+Number(t.compressedSize||0);if(r>e.byteLength)throw new Error(this._label("entryCorrupted"));const n=new Uint8Array(this._arrayBuffer.slice(s,r)),a=Number(t.compressionMethod||0);if(0===a)return n;if(8===a){if("undefined"==typeof DecompressionStream)throw new Error(this._label("deflateNotSupported"));const t=new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate-raw")),e=await new Response(t).arrayBuffer();return new Uint8Array(e)}throw new Error(this._label("compressionNotSupported"))}_extractExtension(t){const e=String(t||"").toLowerCase().split("/").pop()||"";return e.includes(".")?`.${e.split(".").pop()||""}`:""}_isImageExtension(t){return new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"]).has(t)}_mimeByExtension(t){return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp"}[t]||"application/octet-stream"}}si._cache=new Map;const ri=si,ni=new Set([".zip"]),ai=class{constructor(){this.name="zip",this._modal=ri.getInstance()}canRender(t={}){const e=String(t?.fileMeta?.ext||"").toLowerCase();return ni.has(e)}render(t={}){const e=t?.previewContainer,i=Boolean(t?.ui?.nameOnly),s=t?.i18n,r=t?.fileUrl?.href||t?.filePath||"";if(!r)return!1;const n=e=>{e&&e.preventDefault(),this._modal.open({src:r,title:t?.fileMeta?.name||s?.message("archive_title")||"",defaultTitle:s?.message("archive_title")||"",labels:{loadingArchive:s?.message("loading_archive")||"",cannotOpenArchive:s?.message("cannot_open_archive")||"",unknownError:s?.message("unknown_error")||"",invalidZip:s?.message("invalid_zip")||"",centralDirectoryNotFound:s?.message("central_directory_not_found")||"",archiveEmptyUnsupported:s?.message("archive_empty_unsupported")||"",typeDir:s?.message("archive_type_dir")||"",typeFile:s?.message("archive_type_file")||"",tableName:s?.message("archive_table_name")||"",tableType:s?.message("archive_table_type")||"",tablePacked:s?.message("archive_table_packed")||"",tableSize:s?.message("archive_table_size")||"",tablePreview:s?.message("archive_table_preview")||"",previewEntry:s?.button("preview")||"",loadingEntry:s?.message("loading_entry")||"",cannotPreviewEntry:s?.message("cannot_preview_entry")||"",deflateNotSupported:s?.message("deflate_not_supported")||"",compressionNotSupported:s?.message("compression_not_supported")||"",entryCorrupted:s?.message("entry_corrupted")||"",archiveBufferMissing:s?.message("archive_buffer_missing")||"",emptyFileInArchive:s?.message("empty_file")||""}})},a=t?.element?.querySelector(".name");if(a&&!a.hasAttribute("data-vg-filepreview-zip-bind")&&(a.setAttribute("data-vg-filepreview-zip-bind","true"),a.classList.add("is-preview-action"),a.addEventListener("click",n)),i)return Boolean(a);if(!e)return!1;const o=document.createElement("button");return o.type="button",o.className="vg-filepreview-zip-trigger",o.textContent=s?.button("open_archive")||"",o.addEventListener("click",n),e.appendChild(o),!0}},oi=new Set(["ru","en"]),li=(t,e="ru")=>{const i=String(t||"").trim().toLowerCase();if(!i)return e;const s=i.split("-")[0];return oi.has(s)?s:e};class hi extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({validate:!0,lang:"ru",ui:{nameOnly:!1},preview:{audio:{enable:!0},video:{enable:!0},image:{enable:!0},archive:{enable:!0},text:{enable:!0},office:{enable:!0},pdf:{enable:!0}}},e)),this._filePath="",this._fileUrl=null,this._isValid=!1,this._fileMeta={},this._fields=[],this._editableFields={},this._helper=new Se(this._element),this._renderers=[new Ne,new ii,new qe,new Re,new ai,new Ge],this._lang=((t,e)=>{const i=li(t,"");if(i)return i;const s=li(e?.getAttribute("lang"),"");if(s)return s;const r=li(e?.closest("[lang]")?.getAttribute("lang"),"");if(r)return r;const n=li(document?.documentElement?.getAttribute("lang"),"");return n||(li(window?.navigator?.language,"")||"ru")})(this._params.lang,this._element),this._i18n=((t="ru")=>{const e=li(t,"ru"),i=Rt(e,"filepreview")||{},s=Bt(e,"filepreview")||{};return{lang:e,message:(t,e="")=>i[t]||e,button:(t,e="")=>s[t]||e}})(this._lang),this._inlineAudio=null,this._inlineAudioSrc="",this._inlineAudioButton=null,this._inlineAudioIcon=null,this._inlineAudioContainer=null,this._audioMetaPromise=null,this._audioMetaApplied=!1,this._audioCoverObjectUrl="",this._videoMetaPromise=null,this._videoMetaApplied=!1,this._videoCoverObjectUrl="",this._imageModal=null,this.init()}static get NAME(){return"filepreview"}static get NAME_KEY(){return"vg.filepreview"}get filePath(){return this._filePath}get fileUrl(){return this._fileUrl}get isValid(){return this._isValid}get fileMeta(){return this._fileMeta}get fields(){return this._fields}get editableFields(){return this._editableFields}init(){const t=this._helper.getFilePath();if(this._filePath=t,this._params.validate){const e=this._helper.validateFilePath(t);this._isValid=e.isValid,this._fileUrl=e.fileUrl}else this._isValid=!0,this._fileUrl=null;return this._helper.syncState(this._isValid),!!this._isValid&&(this._fileMeta=this._helper.getFileMeta(this._filePath),this.preview())}preview(){return this._setState("loading"),this._fields=this._helper.getFields(),this._editableFields=this._helper.resolveEditableFields(this._fields),this._helper.syncEditableFields(this._editableFields),this._renderIcon(),this._renderTextFields(),this._renderDownloadField(),this._enrichVideoMetadata(),this._renderPreview(),this._editableFields}_renderIcon(){const t=this._editableFields.icon;if(!t)return;const e=this._getImageIconSrc();if(e){t.innerHTML="";const i=document.createElement("img");return i.src=e,i.alt=this._fileMeta?.originalName||this._fileMeta?.name||"",i.className="vg-filepreview-icon-image",i.loading="lazy",i.addEventListener("error",()=>{this._renderDefaultIcon(t)}),this._isPreviewGroupEnabled("image")&&this._bindIconImageToModal(i,e),void t.appendChild(i)}this._renderDefaultIcon(t)}_renderTextFields(){const t=this._getDisplayName(),e=this._getFileName(),i=this._hasDataDrivenDisplayName(),s=this._editableFields.name;s&&(this._isAudioFile()&&this._isPreviewGroupEnabled("audio")?(this._renderAudioNameField(s),this._element.setAttribute("data-vg-filepreview-renderer","audio")):t&&(s.classList.remove("vg-filepreview-audio-inline"),s.textContent=t,this._applyNameClampStyles(s)));const r=this._editableFields.ext;r&&this._fileMeta.ext&&(r.textContent=this._fileMeta.ext);const n=this._editableFields.size;n&&this._fileMeta.sizeText&&(n.textContent=this._fileMeta.sizeText);const a=this._editableFields.original_name;if(a)return i&&e?(a.textContent=e,void this._applyNameClampStyles(a)):this._fileMeta.originalName?(a.textContent=this._fileMeta.originalName,void this._applyNameClampStyles(a)):void(this._fileMeta.isMedia&&(a.textContent=""))}_renderAudioNameField(t){const e=this._getDisplayName();if(!e)return;t.innerHTML="",t.classList.add("vg-filepreview-audio-inline");const i=document.createElement("button");i.type="button",i.className="vg-filepreview-audio-inline__toggle",i.setAttribute("aria-label","Play/Pause");const s=document.createElement("span");s.className="vg-filepreview-audio-inline__icon",i.appendChild(s);const r=document.createElement("span");r.className="vg-filepreview-audio-inline__name",r.textContent=e,this._applyNameClampStyles(r),r.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this._toggleInlineAudio()}),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this._toggleInlineAudio()}),t.appendChild(i),t.appendChild(r),this._inlineAudioButton=i,this._inlineAudioIcon=s;const n=this._element?.classList?.contains("file")?this._element:this._element?.closest?.(".file");this._inlineAudioContainer=n||this._element||t,this._setInlineAudioProgress(0);const a=hi._activeAudioOwner===this&&this._inlineAudio&&!this._inlineAudio.paused;this._syncInlineAudioIcon(a),this._enrichAudioMetadata(r)}_toggleInlineAudio(){if(!this._isPreviewGroupEnabled("audio"))return;const t=this._fileUrl?.href||this._filePath||"";t&&this._inlineAudioButton&&(hi._activeAudioOwner&&hi._activeAudioOwner!==this&&hi._activeAudioOwner._stopInlineAudio(),this._inlineAudio&&this._inlineAudioSrc===t||(this._stopInlineAudio(),this._inlineAudio=new Audio(t),this._inlineAudioSrc=t,this._inlineAudio.addEventListener("ended",()=>{this._syncInlineAudioIcon(!1),this._setInlineAudioProgress(0)}),this._inlineAudio.addEventListener("timeupdate",()=>this._syncInlineAudioProgress()),this._inlineAudio.addEventListener("loadedmetadata",()=>this._syncInlineAudioProgress())),this._inlineAudio.paused?this._inlineAudio.play().then(()=>{hi._activeAudioOwner=this,this._syncInlineAudioIcon(!0)}).catch(()=>{this._syncInlineAudioIcon(!1)}):(this._inlineAudio.pause(),this._syncInlineAudioIcon(!1),hi._activeAudioOwner===this&&(hi._activeAudioOwner=null)))}_stopInlineAudio(){if(!this._inlineAudio)return this._syncInlineAudioIcon(!1),void this._setInlineAudioProgress(0);this._inlineAudio.pause(),this._inlineAudio.currentTime=0,this._syncInlineAudioIcon(!1),this._setInlineAudioProgress(0),hi._activeAudioOwner===this&&(hi._activeAudioOwner=null)}_syncInlineAudioIcon(t){this._inlineAudioIcon&&(this._inlineAudioIcon.innerHTML=t?(0,f.z)("pause")||"":(0,f.z)("play")||"")}_syncInlineAudioProgress(){if(!this._inlineAudio)return void this._setInlineAudioProgress(0);const t=Number(this._inlineAudio.duration||0),e=Number(this._inlineAudio.currentTime||0);if(!t||!Number.isFinite(t)||t<=0)return void this._setInlineAudioProgress(0);const i=Math.max(0,Math.min(100,e/t*100));this._setInlineAudioProgress(i)}_setInlineAudioProgress(t){if(!this._inlineAudioContainer)return;const e=Math.max(0,Math.min(100,Number(t)||0));this._inlineAudioContainer.style.setProperty("--vg-filepreview-audio-inline-progress",`${e}%`)}_renderDownloadField(){const t=this._editableFields.download;if(!t)return;const e=this._i18n?.button("download")||"",i=(0,f.z)("download")||"",s=String(t.tagName||"").toUpperCase();let r=null;if("A"===s||"BUTTON"===s?r=t:(r=t.querySelector("[data-vg-filepreview-download-control]"),r||(r=document.createElement("button"),r.type="button",t.innerHTML="",t.appendChild(r))),r.classList.add("vg-filepreview-download-trigger"),r.setAttribute("data-vg-filepreview-download-control","true"),"A"===s&&r===t?(r.setAttribute("href",this._fileUrl?.href||this._filePath||"#"),this._fileMeta?.name&&r.setAttribute("download",this._fileMeta.name)):"BUTTON"===String(r.tagName||"").toUpperCase()&&r.setAttribute("type","button"),!r.hasAttribute("data-vg-filepreview-download-content-init")){if(r.setAttribute("data-vg-filepreview-download-content-init","true"),r.innerHTML="",i){const t=document.createElement("span");t.className="vg-filepreview-download-trigger__icon",t.innerHTML=i,r.appendChild(t)}if(e){const t=document.createElement("span");t.className="vg-filepreview-download-trigger__text",t.textContent=e,r.appendChild(t)}}r.hasAttribute("data-vg-filepreview-download-bind")||(r.setAttribute("data-vg-filepreview-download-bind","true"),r.addEventListener("click",t=>{t.preventDefault(),this._downloadFile()}))}_downloadFile(){const t=this._fileUrl?.href||this._filePath||"";if(!t)return;const e=this._fileMeta?.originalName||this._fileMeta?.name||"file";fetch(t,{method:"GET",credentials:"same-origin"}).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.blob()}).then(t=>{const i=URL.createObjectURL(t);this._downloadByLink(i,e),setTimeout(()=>URL.revokeObjectURL(i),1e3)}).catch(()=>{this._downloadByLink(t,e)})}_downloadByLink(t,e){const i=document.createElement("a");i.href=t,i.style.display="none",i.rel="noopener noreferrer",e&&i.setAttribute("download",e),document.body.appendChild(i),i.click(),document.body.removeChild(i)}_enrichAudioMetadata(t=null){if(this._audioMetaApplied||this._audioMetaPromise||!this._isAudioFile())return;const e=this._fileUrl?.href||this._filePath||"";e&&(this._audioMetaPromise=this._createAudioFileFromSource(e).then(t=>t?ke(t):null).then(e=>{if(!e)return!1;let i=!1;const s=String(e.title||"").trim();if(s){this._element.setAttribute("data-vg-filepreview-display-name",s),t&&(t.textContent=s,this._applyNameClampStyles(t));const e=this._editableFields?.original_name;e&&(e.textContent=this._getFileName(),this._applyNameClampStyles(e)),i=!0}if(e.pictureBlob instanceof Blob&&this._editableFields?.icon){this._audioCoverObjectUrl&&URL.revokeObjectURL(this._audioCoverObjectUrl),this._audioCoverObjectUrl=URL.createObjectURL(e.pictureBlob);const t=this._editableFields.icon;t.innerHTML="";const r=document.createElement("img");r.src=this._audioCoverObjectUrl,r.alt=s||this._fileMeta?.originalName||this._fileMeta?.name||"",r.className="vg-filepreview-icon-image",r.loading="lazy",r.addEventListener("error",()=>{this._renderDefaultIcon(t)}),this._bindIconImageToModal(r,this._audioCoverObjectUrl,s),t.appendChild(r),i=!0}return this._audioMetaApplied=!0,i}).catch(()=>!1).finally(()=>{this._audioMetaPromise=null}))}_enrichVideoMetadata(){if(!this._isPreviewGroupEnabled("video"))return;if(this._videoMetaApplied||this._videoMetaPromise||!this._isVideoFile())return;const t=this._fileUrl?.href||this._filePath||"";t&&(this._videoMetaPromise=this._createMediaFileFromSource(t,this._fileMeta?.originalName||this._fileMeta?.name||"video.mp4","video/mp4").then(t=>t?(async t=>{if(!(t instanceof File))return null;const e=(t=>{const e=String(t?.name||"").toLowerCase(),i=e.lastIndexOf(".");return i<0||i>=e.length-1?"":e.slice(i+1)})(t);if(!String(t.type||"").toLowerCase().startsWith("video/")&&!De.has(e))return null;if(!t.size)return null;let i="";try{i=URL.createObjectURL(t);const e=document.createElement("video");e.preload="metadata",e.muted=!0,e.playsInline=!0,e.crossOrigin="anonymous",e.src=i,await(s=e,r="loadedmetadata",new Promise((t,e)=>{const i=()=>{a(),t(!0)},n=()=>{a(),e(new Error(r))},a=()=>{s.removeEventListener(r,i),s.removeEventListener("error",n)};s.addEventListener(r,i,{once:!0}),s.addEventListener("error",n,{once:!0})}));const n=Number(e.videoWidth||0),a=Number(e.videoHeight||0),o=Number(e.duration||0);if(!(n&&a&&Number.isFinite(n)&&Number.isFinite(a)))return{duration:Number.isFinite(o)?o:0,width:0,height:0};const l=o>1?Math.min(1,Math.max(0,o/2)):0;await((t,e)=>new Promise((i,s)=>{const r=()=>{a(),i(!0)},n=()=>{a(),s(new Error("seek"))},a=()=>{t.removeEventListener("seeked",r),t.removeEventListener("error",n)};t.addEventListener("seeked",r,{once:!0}),t.addEventListener("error",n,{once:!0}),t.currentTime=e}))(e,l);const h=document.createElement("canvas");h.width=n,h.height=a;const d=h.getContext("2d");if(!d)return{duration:Number.isFinite(o)?o:0,width:n,height:a};d.drawImage(e,0,0,n,a);const c=await((t,e="image/jpeg",i=.92)=>new Promise(s=>{t.toBlob(t=>s(t||null),e,i)}))(h,"image/jpeg",.92);return{duration:Number.isFinite(o)?o:0,width:n,height:a,posterBlob:c||null}}catch{return null}finally{i&&URL.revokeObjectURL(i)}var s,r})(t):null).then(t=>{if(!(t&&t.posterBlob instanceof Blob&&this._editableFields?.icon))return!1;this._videoCoverObjectUrl&&URL.revokeObjectURL(this._videoCoverObjectUrl),this._videoCoverObjectUrl=URL.createObjectURL(t.posterBlob);const e=this._editableFields.icon;e.innerHTML="";const i=document.createElement("img");return i.src=this._videoCoverObjectUrl,i.alt=this._fileMeta?.originalName||this._fileMeta?.name||"",i.className="vg-filepreview-icon-image",i.loading="lazy",i.addEventListener("error",()=>{this._renderDefaultIcon(e)}),this._isPreviewGroupEnabled("video")&&this._bindIconImageToModal(i,this._videoCoverObjectUrl,i.alt),e.appendChild(i),this._videoMetaApplied=!0,!0}).catch(()=>!1).finally(()=>{this._videoMetaPromise=null}))}async _createAudioFileFromSource(t=""){const e=this._fileMeta?.originalName||this._fileMeta?.name||"audio.mp3";return this._createMediaFileFromSource(t,e,"audio/mpeg")}async _createMediaFileFromSource(t="",e="file",i="application/octet-stream"){try{const s=await fetch(t,{method:"GET",credentials:"same-origin"});if(!s.ok)return null;const r=await s.blob();return r&&r.size?new File([r],e,{type:r.type||i,lastModified:Date.now()}):null}catch{return null}}_bindIconImageToModal(t,e="",i=""){if(!t)return;const s=String(e||"").trim();if(!s)return;const r=String(i||this._fileMeta?.originalName||this._fileMeta?.name||"").trim();t.setAttribute("data-vg-filepreview-image-modal-src",s),t.setAttribute("data-vg-filepreview-image-modal-title",r),t.classList.add("is-preview-action"),t.hasAttribute("data-vg-filepreview-image-modal-bind")||(t.setAttribute("data-vg-filepreview-image-modal-bind","true"),t.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation();const i=String(t.getAttribute("data-vg-filepreview-image-modal-src")||"").trim();if(!i)return;const s=String(t.getAttribute("data-vg-filepreview-image-modal-title")||"").trim();this._imageModal||(this._imageModal=Oe.getInstance()),this._imageModal.open({src:i,title:s,defaultTitle:this._i18n?.message("image_title")||""})}))}_renderPreview(){const t=Boolean(this._params?.ui?.nameOnly)||!this._shouldRenderPreviewForCurrentFile(),e=this._resolvePreviewContainer({autoCreate:!t});if(!e&&!t)return void this._setState("error");e&&(e.innerHTML="");const i={element:this._element,filePath:this._filePath,fileUrl:this._fileUrl,fileMeta:this._fileMeta,previewContainer:e,lang:this._lang,i18n:this._i18n,ui:this._params?.ui||{}};let s=!1;if(this._renderers.forEach(t=>{if(!s&&"function"==typeof t?.canRender&&"function"==typeof t?.render&&this._isRendererEnabled(t?.name)&&t.canRender(i)){try{s=!0===t.render(i)}catch(t){s=!1}s&&this._element.setAttribute("data-vg-filepreview-renderer",t.name||"custom")}}),!s&&!t)return this._element.removeAttribute("data-vg-filepreview-renderer"),void this._setState("empty");this._setState("ready")}_resolvePreviewContainer(t={}){if(Object.prototype.hasOwnProperty.call(t,"autoCreate")&&!Boolean(t.autoCreate)){const t=this._editableFields.preview||this._element.querySelector('[data-vg-filepreview-slot="preview"]');return t&&(t.innerHTML="",t.classList.remove("preview"),t.setAttribute("hidden","hidden"),t.setAttribute("aria-hidden","true")),null}const e=this._editableFields.preview;if(e)return e.classList.add("preview"),e.removeAttribute("hidden"),e.removeAttribute("aria-hidden"),e.setAttribute("data-vg-filepreview-slot","preview"),e;const i=this._element.querySelector('[data-vg-filepreview-slot="preview"]');if(i)return i.classList.add("preview"),i.removeAttribute("hidden"),i.removeAttribute("aria-hidden"),this._editableFields.preview=i,i;const s=document.createElement("div");return s.className="preview",s.setAttribute("data-vg-filepreview-slot","preview"),this._element.appendChild(s),this._editableFields.preview=s,s}_shouldRenderPreviewForCurrentFile(){return this._isAudioFile()?this._isPreviewGroupEnabled("audio"):".pdf"===String(this._fileMeta?.ext||"").toLowerCase()?this._isPreviewGroupEnabled("pdf"):this._isVideoFile()?this._isPreviewGroupEnabled("video"):this._isImageFile()?this._isPreviewGroupEnabled("image"):this._isOfficeFile()?this._isPreviewGroupEnabled("office"):this._isArchiveFile()?this._isPreviewGroupEnabled("archive"):!!this._isTextFile()&&this._isPreviewGroupEnabled("text")}_isRendererEnabled(t=""){const e={image:"image",video:"video",pdf:"pdf",office:"office",zip:"archive",text:"text"}[String(t||"").trim()];return!e||this._isPreviewGroupEnabled(e)}_isPreviewGroupEnabled(t=""){const e=String(t||"").trim();if(!e)return!1;const i=this._params?.preview;if(!i||"object"!=typeof i||Array.isArray(i))return!1;if(!Object.prototype.hasOwnProperty.call(i,e))return!1;const s=i[e];return"boolean"==typeof s?s:!(!s||"object"!=typeof s||Array.isArray(s))&&!!Object.prototype.hasOwnProperty.call(s,"enable")&&Boolean(s.enable)}_getImageIconSrc(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".avif",".ico"].includes(t)&&(this._fileUrl?.href||this._filePath)||""}_isImageFile(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".avif",".ico",".tif",".tiff",".heic",".heif"].includes(t)}_isOfficeFile(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".doc",".docx",".xls",".xlsx",".ppt",".pptx",".odt",".ods",".odp"].includes(t)}_isArchiveFile(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".zip"].includes(t)}_isTextFile(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".txt",".md",".csv",".json",".xml",".yml",".yaml",".log",".ini",".conf",".env"].includes(t)}_renderDefaultIcon(t){const e=(0,f.z)(this._filePath);t.innerHTML=e||""}_applyNameClampStyles(t){t&&t.style&&(t.style.minWidth="60px",t.style.maxWidth="100%",t.style.overflow="hidden",t.style.textOverflow="ellipsis",t.style.whiteSpace="nowrap")}static init(t,e={}){return hi.getOrCreateInstance(t,e)}static stopActiveInlineAudio(){const t=hi._activeAudioOwner;t&&"function"==typeof t._stopInlineAudio&&t._stopInlineAudio(),hi._activeAudioOwner=null}static stopActiveInlineAudioIfDetached(t=[]){const e=hi._activeAudioOwner;e&&e._element&&Array.isArray(t)&&t.length&&t.some(t=>!(!t||"function"!=typeof t.contains)&&(t===e._element||t.contains(e._element)))&&(e._stopInlineAudio(),hi._activeAudioOwner=null)}_setState(t=""){const e=String(t||"").trim();e?this._element.setAttribute("data-vg-filepreview-state",e):this._element.removeAttribute("data-vg-filepreview-state")}_isAudioFile(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".mp3",".wav",".ogg",".flac",".aac",".m4a",".opus",".wma"].includes(t)}_isVideoFile(){const t=String(this._fileMeta?.ext||"").toLowerCase();return[".mp4",".webm",".mov",".mkv",".avi",".m4v",".ogv"].includes(t)}_getFileName(){return String(this._fileMeta?.originalName||this._fileMeta?.name||"").trim()}_getDataDisplayName(){return String(this._element?.getAttribute("data-name")||"").trim()||String(this._element?.getAttribute("data-vg-filepreview-display-name")||"").trim()}_hasDataDrivenDisplayName(){const t=this._getDataDisplayName();if(!t)return!1;const e=this._getFileName();return!e||t!==e}_getDisplayName(){return this._getDataDisplayName()||this._getFileName()}}const di=hi;class ci extends t.A{constructor(t,e={},i={}){super(t,e),this._params=this._getParams(t,(0,r._v)(i,e)),this._params.init="init"in e&&e.init||this._params.init,this._params.init?(this._isInitialized=!0,this._tpl=(0,d.A)("dom"),this._files=[],this._errors=new Set,this._validationErrorsByKey=new Map,this._fileObjectUrls=new Map,this._audioMetaPromises=new Map,this._nodes={stat:s.A.find(`.${this._getClass("stat")}`,this._element),info:s.A.find(`.${this._getClass("info")}`,this._element),drop:s.A.find(`.${this._getClass("drop")}`,this._element)},this.template='<li data-file="" class="file"><div class="file-image"></div><div class="file-info"></div><div class="file-remove"></div></li>',this._onNativeInputChange=t=>this.change(t?.target),this._init()):this._isInitialized=!1}_getClass(t){return{stat:"vg-files-stat","stat-progress":"vg-files-stat-progress",info:"vg-files-info","info-list":"vg-files-info--list",drop:"vg-files-drop","drop-list":"vg-files-drop--list","drop-message":"vg-files-drop-message",errors:"vg-files-errors"}[t]||""}_applyRenameToIncomingFiles(t){const e=this._params?.rename;return e&&Array.isArray(t)&&t.length?t.map((t,i)=>{if(!t)return t;let s=null;if("function"==typeof e?s=e(t,i):!0===e&&(s=this._generateRenamedFileName(t?.name||"file",i)),!s||"string"!=typeof s||""===s.trim())return t;if(t.name===s)return t;try{const e=new File([t],s,{type:t.type||"application/octet-stream",lastModified:t.lastModified||Date.now()});return["id","src","image"].forEach(i=>{void 0!==t[i]&&Object.defineProperty(e,i,{value:t[i],writable:!0,enumerable:!0})}),e}catch(e){return t}}):t}_generateRenamedFileName(t,e){const i=String(t||"file"),s=i.lastIndexOf("."),r=s>0&&s<i.length-1,n=r?i.slice(0,s):i,a=r?i.slice(s+1):"",o=Date.now(),l=e+1,h=n.trim()||"file";return a?`${h}_${o}_${l}.${a}`:`${h}_${o}_${l}`}_init(){this._isInitialized&&(1===Number(this._params?.limits?.count)?(this._preventOriginalInputFromSubmit(!0),this._cleanupFakeInputs()):this._preventOriginalInputFromSubmit(),this._addEventListener())}change(t=null){const e=t?.files;if(!e?.length)return;const i=this._applyRenameToIncomingFiles(Array.from(e)),s=1===Number(this._params?.limits?.count);if(Boolean(this._params?.replace)&&s)return this.clear(!1),this.append(i,!0),this._revokeUrls(),this._cleanupFakeInputs(),this._params.prepend&&this._files.reverse(),void this.build();this._params.allowed?(this.clear(),this.append(i,!0),this.build()):(this.append(i,!1),this.build())}build(){this._updateStat(),this._params.ajax?(this._render.init()?this._render.init():this._renderUI(this._files),this._renderUI(this._files)):(this._renderUI(this._files),1===Number(this._params?.limits?.count)?this._cleanupFakeInputs():this._generateHiddenInputs(this._files))}append(t,e=!0){const i=this._applyRenameToIncomingFiles(Array.from(t));let s;return s=e?i:this._mergeFilesByOrder(i,this._files,Boolean(this._params.prepend)),this._files=this._filterFiles(s),this._syncSingleInputSubmission(),this._renderErrors(),this._enrichAudioMetadata(this._files),this._files}_mergeFilesByOrder(t=[],e=[],i=!1){const s=i?[...t,...e]:[...e,...t],r=new Set,n=[];return s.forEach(t=>{const e=this._getFileKey(t);r.has(e)||(r.add(e),n.push(t))}),n}_getFileKey(t){return`${t.name}-${t.size}-${t.type}`}_getFileCustomData(t){const e=t?.customData;return!e||"object"!=typeof e||Array.isArray(e)?{}:e}_toDataAttributeKey(t){return t?String(t).replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase():""}_toDataAttributeValue(t){if(null==t||""===t)return null;if("object"==typeof t)try{return JSON.stringify(t)}catch(e){return String(t)}return t}_buildFileDataAttributes(t,e={}){const i={...e},s=this._getFileCustomData(t);return Object.entries(s).forEach(([t,e])=>{const s=this._toDataAttributeKey(t);if(!s)return;const r=`data-${s}`;if(Object.prototype.hasOwnProperty.call(i,r))return;const n=this._toDataAttributeValue(e);null!==n&&(i[r]=n)}),i}_filterFiles(t){this._errors.clear(),this._validationErrorsByKey.clear();const{count:e,sizes:i,total:s}=this._params.limits,r=1024*i*1024,n=1024*s*1024;let a=0,o=0;const l=[];for(const i of t){const t=new Set;e>0&&o>=e?this._errors.add("is-count"):(this._params.types.length&&!this._params.types.includes(i.type)&&t.add("is-types"),i.size>r&&t.add("is-sizes"),!t.size&&n>0&&a+i.size>n&&t.add("is-total-size"),l.push(i),t.size?(t.forEach(t=>this._errors.add(t)),this._validationErrorsByKey.set(this._getFileKey(i),t)):(o+=1,a+=i.size))}return l}_isFileValid(t){return!this._validationErrorsByKey.has(this._getFileKey(t))}_syncSingleInputSubmission(){if(1!==Number(this._params?.limits?.count))return;const t=this._files[0],e=!this._params.ajax&&(!t||this._isFileValid(t));this._preventOriginalInputFromSubmit(e)}_getFileValidationMessages(t){const e=this._validationErrorsByKey.get(this._getFileKey(t));if(!e?.size)return[];const i=Rt(this._params.lang,"files")||this._getFallbackErrors();return Array.from(e,t=>i[t]||t)}_getFileValidationLabel(t){const e=this._getFileValidationMessages(t);return e.length?[this._getShortValidationFileName(t?.name),e.join(". ")].filter(Boolean).join(" — "):""}_getFullFileValidationLabel(t){const e=this._getFileValidationMessages(t);return e.length?[String(t?.name||"").trim(),e.join(". ")].filter(Boolean).join(" — "):""}_getShortValidationFileName(t){const e=String(t||"").trim();if(e.length<=24)return e;const i=e.lastIndexOf("."),s=i>0&&e.length-i<=10,r=s?e.slice(0,i):e,n=s?e.slice(i):"";return`${r.slice(0,5)}...${n}`}_decorateValidationItem(t,i){return this._isFileValid(i)||(e.x.add(t,"failing"),e.x.add(t,"validation-error")),t}_forgetFileValidation(t){t&&(this._validationErrorsByKey.delete(this._getFileKey(t)),this._errors.clear(),this._validationErrorsByKey.forEach(t=>{t.forEach(t=>this._errors.add(t))}),this._renderErrors())}_getSizes(t,e=!1){const i=e?this._files.reduce((t,e)=>t+e.size,0):t,s=["byte","kilobyte","megabyte","gigabyte"],r=i>0?Math.min(Math.floor(Math.log(i)/Math.log(1024)),s.length-1):0,n=i/Math.pow(1024,r);return new Intl.NumberFormat(this._params.lang,{style:"unit",unit:s[r],unitDisplay:"short",maximumFractionDigits:2}).format(n)}_cleanupErrors(){this._errors.clear();const t=s.A.find(`.${this._getClass("errors")}`,this._element);t&&t.remove()}_renderErrors(){if(!this._errors.size){const t=s.A.find(`.${this._getClass("errors")}`,this._element);return void(t&&t.remove())}const t=Rt(this._params.lang,"files")||this._getFallbackErrors();let e=s.A.find(`.${this._getClass("errors")}`,this._element);if(e?e.innerHTML="":(e=this._tpl.div({class:this._getClass("errors")}),this._element.prepend(e)),this._validationErrorsByKey.size){const i=new Set;return this._files.forEach(t=>{const s=this._getFileValidationLabel(t);if(!s)return;const r=this._validationErrorsByKey.get(this._getFileKey(t));r?.forEach(t=>i.add(t));const n=this._getFullFileValidationLabel(t),a={class:"error-item"};n&&n!==s&&(a.title=n),e.append(this._tpl.span(a,s))}),void this._errors.forEach(s=>{if(i.has(s))return;const r=t[s]||s;e.append(this._tpl.span({class:"error-item"},r))})}this._errors.forEach(i=>{const s=t[i]||i;e.append(this._tpl.span({class:"error-item"},s))})}_getFallbackErrors(){const{count:t,sizes:e,total:i}=this._params.limits;return{"is-count":`Limit: ${t}`,"is-sizes":`Max size: ${e}MB`,"is-total-size":`Total max size: ${i}MB`,"is-types":`Allowed: ${this._params.types.join(", ")}`}}_renderUI(t){this._nodes.drop?this._renderUIDropList(t):this._nodes.info&&this._renderInfoList(t),this._renderUIStatusDropInfoAjax(this._files)}_parseTemplate(){const t=this._render,e='<li data-file="" class="file"><div class="file-image"></div><div class="file-custom"><div class="file-info"></div><div class="file-remove"></div></div></li>';let i=this.template||e;t&&t.bufferTemplate&&(i=t.bufferTemplate);const s=document.createElement("div");s.innerHTML=i;let r=s.firstElementChild;r||(s.innerHTML=e,r=s.firstElementChild);const n=r.className||"",a=n?n.split(" ").filter(t=>""!==t.trim()):[],o=r.childElementCount,l=[];for(let t=0;t<o;t++)l.push({index:t,element:r.children[t],className:r.children[t].className});return{children:l,template:i,liClasses:a,liClassName:n}}_renderUIDropList(t){if(!this._nodes.drop)return;let i=s.A.find(`.${this._getClass("drop-list")}`,this._nodes.drop);i||(i=this._tpl.ul([],{class:this._getClass("drop-list")}));const r=this._parseTemplate().children,n=this._parseTemplate().liClasses.filter(t=>"file"!==t),a=document.createDocumentFragment();t.forEach(t=>{let e=[...n];this._params.detach&&e.push("with-remove"),this._params.customButtons?.hideOnUploadState&&e.push("hide-custom-buttons-on-upload-state"),this._params.sortable.enabled&&e.push("with-sortable"),1===this._params.limits.count&&(e.push("single"),t.type.startsWith("image/")?e.push("single-image"):e.push("single-file"));let i=[];r.forEach(e=>{const s=this._renderTemplatePart(e.element,t,null,{isDrop:!0});s&&i.push(s)});const s=this._tpl.li(this._buildFileDataAttributes(t,{"data-name":t.name,"data-size":t.size??0,"data-id":t.id||"",class:"file "+e.join(" ")}),i);a.appendChild(this._decorateValidationItem(s,t))}),i.innerHTML="",i.appendChild(a);const o=s.A.find(`.${this._getClass("drop-message")}`,this._nodes.drop);o&&(t.length?e.x.add(o,"has-files"):e.x.remove(o,"has-files"),1===Number(this._params?.limits?.count)&&(t.length?e.x.remove(o,"show"):e.x.add(o,"show"))),this._nodes.drop.appendChild(i),e.x.add(this._nodes.drop,"active")}_renderInfoList(t){if(!this._nodes.info)return;let i=s.A.find(`.${this._getClass("info-list")}`,this._element);i||(i=this._tpl.ul([],{class:this._getClass("info-list")}),this._nodes.info.appendChild(i)),this._params.info||e.x.add(i,"list-row");const r=this._parseTemplate().children,n=this._parseTemplate().liClasses.filter(t=>"file"!==t),a=Array.from(i.children||[]),o=new Map;a.forEach(t=>{const e=this._getInfoNodeKey(t);e&&(t.hasAttribute("data-file-key")||t.setAttribute("data-file-key",e),o.set(e,t))});const l=[];if(t.forEach((t,e)=>{const i=this._getFileKey(t),s=this._getInfoItemSignature(t,e),a=o.get(i);if(a&&a.getAttribute("data-vg-info-signature")===s){const t=a.querySelector(".iteration");return t&&(t.textContent=`${e+1}.`),l.push(a),void o.delete(i)}a&&(di.stopActiveInlineAudioIfDetached([a]),a.remove());const h=this._createInfoListItem(t,e,r,n,i,s);l.push(h),o.delete(i)}),o.size){const t=Array.from(o.values());di.stopActiveInlineAudioIfDetached(t),t.forEach(t=>t.remove())}l.forEach(t=>{i.appendChild(t)}),this._initFilePreviewInInfo(i),t.length?e.x.add(this._nodes.info,"show"):e.x.remove(this._nodes.info,"show")}_getInfoItemSignature(t,e){const i=this._resolveDisplayName(t),s=this._resolveFilePreviewPath(t);return`${t?.id||""}|${t?.name||""}|${t?.size??0}|${t?.type||""}|${i}|${s}`}_getInfoNodeKey(t){if(!t||"function"!=typeof t.getAttribute)return"";const e=String(t.getAttribute("data-file-key")||"").trim();if(e)return e;const i=String(t.getAttribute("data-name")||"").trim(),s=String(t.getAttribute("data-size")||"").trim(),r=String(t.getAttribute("data-type")||"").trim();if(i&&s&&r)return`${i}-${s}-${r}`;const n=String(t.getAttribute("data-file")||"").trim();if(!n)return"";try{const t=JSON.parse(n),e=String(t?.name||"").trim(),i=String(t?.size??"").trim(),s=String(t?.type||"").trim();if(e&&i&&s)return`${e}-${i}-${s}`}catch{return""}return""}_createInfoListItem(t,e,i,s,r,n){let a=[...s];this._params.image&&a.push("with-image"),this._params.info&&a.push("with-info"),this._params.detach&&a.push("with-remove"),this._params.customButtons?.hideOnUploadState&&a.push("hide-custom-buttons-on-upload-state"),this._params.sortable.enabled&&a.push("with-sortable");const o=this._resolveFilePreviewPath(t),l=this._resolveDisplayName(t);let h=[];i.forEach(i=>{const s=this._renderTemplatePart(i.element,t,e);s&&h.push(s)});const d={"data-name":t.name,"data-size":t.size??0,"data-type":t.type||"","data-id":t.id||"","data-file-key":r,"data-vg-info-signature":n,class:"file "+a.join(" ")+" "};o&&(d["data-vg-filepreview"]=o,d["data-fields"]="name,size,download",d["data-original-name"]=t.name||"",d["data-vg-filepreview-display-name"]=l||t.name||"");const c=this._tpl.li(this._buildFileDataAttributes(t,d),h);return this._decorateValidationItem(c,t)}_renderTemplatePart(t,e,i=null,s={}){if(!t)return null;const{isDrop:r=!1}=s,n=t?.classList;if(n?.contains("file-image"))return this._renderUIImage(e);if(n?.contains("file-info"))return r?null:this._renderUIInfo(e,i);if(n?.contains("file-remove"))return this._wrapInFileCustom(this._renderUIDetach(e));const a=t.cloneNode(!0);return this._replaceTemplateSlot(a,".file-image",()=>this._renderUIImage(e)),this._replaceTemplateSlot(a,".file-info",()=>r?null:this._renderUIInfo(e,i)),this._replaceTemplateSlot(a,".file-remove",()=>this._renderUIDetach(e)),this._wrapInFileCustom(a)}_wrapInFileCustom(t){if(!t)return null;if(t.classList?.contains("file-custom"))return t;const e=document.createElement("div");return e.className="file-custom",e.appendChild(t),e}_replaceTemplateSlot(t,e,i){(t?.matches&&t.matches(e)?[t]:Array.from(t.querySelectorAll(e))).forEach(t=>{const e=i();e?t.replaceWith(e):t.remove()})}_renderUIDetach(t){if(this._params.detach)return this._tpl.div({class:"file-remove"},[this._setButtonElement(t)])}_renderUIInfo(t,e){if(this._params.info){const i=this._resolveDisplayName(t);return this._tpl.div({class:"file-info"},[this._tpl.span({class:"iteration"},`${e+1}.`),this._tpl.span({class:"name"},i),this._tpl.span({class:"size"},`[${this._getSizes(t.size)}]`),this._tpl.span({class:"download"},"")])}}_renderUIImage(t){const e=this._tpl.div({class:"file-image"}),i=t?.src||t?.image;if(i)return e.appendChild(this._tpl.img(i,t.name||"",{class:"file-preview"})),e;const s=this._getFileCustomData(t),r=String(s.audioCover||"").trim();if(r)return e.appendChild(this._tpl.img(r,this._resolveDisplayName(t),{class:"file-preview"})),e;if(t?.type&&t.type.startsWith("image/")){const i=this._getFileObjectUrl(t);return i?(e.appendChild(this._tpl.img(i,t.name,{class:"file-preview"})),e):e}const n=this._getIconByFileType(t);return e.appendChild(this._tpl.i({},n,{isHTML:!0})),e}_resolveDisplayName(t){const e=this._getFileCustomData(t);return String(e.audioTitle||"").trim()||String(t?.name||"").trim()}_getIconByFileType(t){return(0,f.z)(t)}_resolveFilePreviewPath(t){return String(t?.src||t?.image||"").trim()||this._getFileObjectUrl(t)}_getFileObjectUrl(t){if(!(t&&"undefined"!=typeof File&&t instanceof File))return"";const e=this._getFileKey(t);if(this._fileObjectUrls.has(e))return this._fileObjectUrls.get(e);const i=URL.createObjectURL(t);return this._fileObjectUrls.set(e,i),i}_isAudioFile(t){if(!t)return!1;if(String(t.type||"").toLowerCase().startsWith("audio/"))return!0;const e=String(t.name||"").toLowerCase();return/\.(mp3|m4a|aac|wav|ogg|flac|opus|wma)$/.test(e)}_setFileCustomDataValue(t,e,i){t&&e&&(t.customData&&"object"==typeof t.customData&&!Array.isArray(t.customData)||Object.defineProperty(t,"customData",{value:{},writable:!0,enumerable:!0}),t.customData[e]=i)}_enrichAudioMetadata(t=[]){if(!Array.isArray(t)||!t.length)return;const e=[];t.forEach(t=>{if(!this._isAudioFile(t))return;const i=this._getFileKey(t);if(this._audioMetaPromises.has(i))return;const s=this._getFileCustomData(t);if(s.audioTitle||s.audioCover)return;const r=ke(t).then(e=>{if(!e)return!1;let s=!1;if(e.title&&(this._setFileCustomDataValue(t,"audioTitle",e.title),s=!0),e.pictureBlob){const r=`cover:${i}`;let n=this._fileObjectUrls.get(r);n||(n=URL.createObjectURL(e.pictureBlob),this._fileObjectUrls.set(r,n)),this._setFileCustomDataValue(t,"audioCover",n),s=!0}return s}).catch(()=>!1).then(t=>(this._audioMetaPromises.delete(i),t));this._audioMetaPromises.set(i,r),e.push(r)}),e.length&&Promise.allSettled(e).then(t=>{t.some(t=>"fulfilled"===t.status&&!0===t.value)&&this._files.length&&this._renderUI(this._files)})}_initFilePreviewInInfo(t){if(!this._nodes.info||!t)return;const e=this._params?.lang||document.documentElement.lang||"ru";(s.A.findAll("[data-vg-filepreview]",t)||[]).forEach(t=>{di.getOrCreateInstance(t,{lang:e,ui:{nameOnly:!0}})})}_updateStat(){if(!this._nodes.stat)return;const t=this._getSizes(this._files,!0),i=s.A.find(`.${this._getClass("stat")}-count`,this._nodes.stat);i&&(i.innerHTML=this._files.length?`${this._files.length}<span>[${t}]</span>`:""),this._files.length?e.x.add(this._nodes.stat,"show"):e.x.remove(this._nodes.stat,"show")}_generateHiddenInputs(t){this._cleanupFakeInputs();const i=document.createDocumentFragment(),r=e.p.get(s.A.find("label",this._element),"for")||"",n=s.A.findID(r,this._element)?.name||s.A.findID(r,this._element)?.dataset.originalName||"files[]",a=n.endsWith("[]")?n.slice(0,-2):n;1===Number(this._params?.limits?.count)||(t.filter(t=>this._isFileValid(t)).forEach((t,s)=>{const r=document.createElement("input");r.type="file",r.name=`${a}[${s}]`,r.dataset.vgFiles="generated",e.p.hide(r);const n=new DataTransfer;n.items.add(t),r.files=n.files,i.appendChild(r)}),this._element.appendChild(i))}_cleanupFakeInputs(){s.A.findAll('[data-vg-files="generated"]',this._element).forEach(t=>t.remove())}clear(t=!0){const i=[];if(this._nodes.info){const t=s.A.find(`.${this._getClass("info-list")}`,this._element);t?.children?.length&&i.push(...Array.from(t.children))}if(this._nodes.drop){const t=s.A.find(`.${this._getClass("drop-list")}`,this._element);t?.children?.length&&i.push(...Array.from(t.children))}if(i.length&&di.stopActiveInlineAudioIfDetached(i),this._revokeUrls(),t&&this._resetFileInput(),this._cleanupFakeInputs(),this._cleanupErrors(),this._validationErrorsByKey.clear(),this._files=[],this._nodes.info){e.x.remove(this._nodes.info,"show");const t=s.A.find(`.${this._getClass("info-list")}`,this._element);t&&(t.innerHTML="")}if(this._nodes.drop){const t=s.A.find(`.${this._getClass("drop-list")}`,this._element);t&&(t.innerHTML="");const i=s.A.find(`.${this._getClass("drop-message")}`,this._element);i&&(e.x.remove(i,"has-files"),1===Number(this._params?.limits?.count)&&e.x.add(i,"show")),e.x.remove(this._nodes.drop,"active")}this._nodes.stat&&e.x.remove(this._nodes.stat,"show")}_revokeUrls(){this._fileObjectUrls.forEach(t=>{URL.revokeObjectURL(t)}),this._fileObjectUrls.clear(),this._audioMetaPromises.clear()}_resetFileInput(){s.A.findAll('[data-vg-toggle="files"]',this._element).forEach(t=>t.value="")}_preventOriginalInputFromSubmit(t=!1){const e=s.A.find('[data-vg-toggle="files"]',this._element);e&&(t||e.dataset.originalName?t&&e.dataset.originalName&&(e.name=e.dataset.originalName,delete e.dataset.originalName):(e.dataset.originalName=e.name,e.removeAttribute("name")))}_addEventListener(){s.A.findAll('[data-vg-toggle="files"]',this._element).forEach(t=>{t.removeEventListener("change",this._onNativeInputChange),t.addEventListener("change",this._onNativeInputChange)})}dispose(){this.clear(),super.dispose()}}const _i=ci;var ui=i(11);const mi=class{constructor(t={}){this.mode=t.mode||"sequential",this.maxParallel=t.maxParallel||3,this.maxConcurrent=t.maxConcurrent||1,this.retryAttempts=t.retryAttempts||3,this.retryDelay=t.retryDelay||1e3,this.uploads=new Map,this.completed=[],this.queue=[],this.waitingPromises=[],this.activeCount=0,this.isPaused=!1,this.callbacks={progress:[],complete:[],error:[],allComplete:[]},this._checkAllCompleteBound=this.checkAllComplete.bind(this)}async uploadFile(t,e,i={}){const s=this.generateId(),r={id:s,file:t,url:e,options:i,status:"pending",progress:0,attempts:0,result:null,error:null,startTime:null,endTime:null,controller:new AbortController,signal:null};return this.uploads.set(s,r),"sequential"===this.mode?this._addToSequentialQueue(r):this._startParallelUpload(r)}async uploadFiles(t,e,i={}){const s=t.map(t=>this.uploadFile(t,e,i));return(await Promise.allSettled(s)).map(t=>"fulfilled"===t.status?{file:t.value.file?.name,success:!0,result:t.value}:{file:t.reason?.file?.name||"unknown",success:!1,error:t.reason})}_addToSequentialQueue(t){return new Promise((e,i)=>{this.queue.push({uploadData:t,resolve:e,reject:i}),this._processSequentialQueue()})}async _processSequentialQueue(){if(this.isPaused||this.activeCount>=this.maxConcurrent||0===this.queue.length)return;const{uploadData:t,resolve:e,reject:i}=this.queue[0];this.activeCount++;try{e(await this._executeUpload(t))}catch(t){i(t)}finally{this.queue.shift(),this.activeCount--,await this._processSequentialQueue()}}async _startParallelUpload(t){this.activeCount>=this.maxParallel&&await new Promise(t=>this.waitingPromises.push(t)),this.activeCount++,t.startTime=Date.now();try{return await this._executeUpload(t)}finally{this.activeCount--,this._notifyWaiting()}}_notifyWaiting(){this.waitingPromises.length>0&&this.activeCount<this.maxParallel&&this.waitingPromises.shift()()}async _executeUpload(t,e=1){t.status="uploading",t.attempts=e,t.signal=t.controller.signal;try{const e=await this._performUpload(t);return this._completeUpload(t,e),e}catch(i){if("cancelled"===t.status)return;if(t.error=i,e<this.retryAttempts)return t.status="retrying",this.notifyProgress(t),await this._delay(this.retryDelay*Math.pow(2,e)),this._executeUpload(t,e+1);throw t.status="failed",t.endTime=Date.now(),this.notifyProgress(t),this.notifyError(t,i),this._checkAllCompleteBound(),i}}_performUpload(t){return new Promise((e,i)=>{const s=new ui.A,n=new FormData;n.append("file",t.file),n.append("_token",s._getCsrfToken()||""),t.options.additionalData&&Object.entries(t.options.additionalData).forEach(([t,e])=>{n.append(t,e)});const a={onProgress:(e,i)=>{t.progress=e,this.notifyProgress(t)},onSuccess:t=>{e((0,r.OM)(t))},onError:t=>{i((0,r.OM)(t))},signal:t.signal},o=s.post(t.url,n,a);t.xhr=o})}_completeUpload(t,e){t.status="completed",t.progress=100,t.result=e,t.endTime=Date.now(),this.completed.push({...t}),this.notifyComplete(t),this._checkAllCompleteBound()}cancelUpload(t){const e=this.uploads.get(t);if(!e||["completed","failed","cancelled"].includes(e.status))return!1;e.controller.abort(),e.xhr&&"function"==typeof e.xhr.abort&&e.xhr.abort(),e.status="cancelled",e.endTime=Date.now(),this.notifyProgress(e);const i=this.queue.findIndex(e=>e.uploadData.id===t);return i>-1&&this.queue.splice(i,1),!0}setMode(t,e=3){this.mode=t,this.maxParallel=e,"parallel"===t&&(this.queue=[],this._notifyWaiting())}pause(){this.isPaused=!0}resume(){this.isPaused=!1,"sequential"===this.mode?this._processSequentialQueue():this._notifyWaiting()}clear(){this.uploads.forEach((t,e)=>{this.cancelUpload(e)}),this.uploads.clear(),this.completed=[],this.queue=[],this.waitingPromises=[],this.activeCount=0}getStats(){const t=Array.from(this.uploads.values()),e=t.reduce((t,e)=>t+(e.file?.size||0),0);return{total:t.length,active:this.activeCount,pending:t.filter(t=>"pending"===t.status).length,uploading:t.filter(t=>"uploading"===t.status).length,completed:t.filter(t=>"completed"===t.status).length,failed:t.filter(t=>"failed"===t.status).length,cancelled:t.filter(t=>"cancelled"===t.status).length,mode:this.mode,isPaused:this.isPaused,queueLength:this.queue.length,totalSizeFormatted:(e/1048576).toFixed(2)+" MB"}}printDebugStats(){const t=this.getStats();console.group("--- Uploader Statistics ---"),console.table({Mode:t.mode,Status:t.isPaused?"Paused":"Running","Total Files":t.total,Uploading:t.uploading,Completed:t.completed,Failed:t.failed,Queue:t.queueLength}),console.log(`Total Size: ${t.totalSizeFormatted}`),console.groupEnd()}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_delay(t){return new Promise(e=>setTimeout(e,t))}checkAllComplete(){Array.from(this.uploads.values()).every(t=>["completed","failed","cancelled"].includes(t.status))&&this.uploads.size>0&&this.notifyAllComplete()}onProgress(t){this.callbacks.progress.push(t)}onComplete(t){this.callbacks.complete.push(t)}onError(t){this.callbacks.error.push(t)}onAllComplete(t){this.callbacks.allComplete.push(t)}notifyProgress(t){this.callbacks.progress.forEach(e=>this._safeCall(e,{...t,stats:this.getStats()}))}notifyComplete(t){this.callbacks.complete.forEach(e=>this._safeCall(e,t))}notifyError(t,e){this.callbacks.error.forEach(i=>this._safeCall(i,t,e))}notifyAllComplete(){this.callbacks.allComplete.forEach(t=>this._safeCall(t,{completed:this.completed,stats:this.getStats()}))}isIdle(){const t=this.activeCount>0,e=this.queue.length>0,i=this.waitingPromises.length>0,s=Array.from(this.uploads.values()).some(t=>["uploading","retrying","pending"].includes(t.status));return!(t||e||i||s)}offAll(){return this.callbacks.progress=[],this.callbacks.complete=[],this.callbacks.error=[],this.callbacks.allComplete=[],this}_safeCall(t,...e){try{t(...e)}catch(t){console.error("Callback error:",t)}}};var pi=i(355);const gi="vg-files-drop",fi=`${gi}--list`,bi="drop-active",vi="drop-hover",yi="vg.drop-and-drop";class wi extends t.A{constructor(t,e={}){super(t,e),this._element=t,this._params=e,this._files=null,this._input=null,this._init()}static get NAME(){return"drop-and-drop"}static get NAME_KEY(){return yi}_init(){wi._instances.add(this),this._params?.smartdrop&&(wi._smartInstances.add(this),this._bindGlobalEvents()),this._findInput(),this._setupEvents()}_findInput(){const{id:t,name:e}=this._element.dataset;t&&(this._input=document.getElementById(t)),!this._input&&e&&(this._input=s.A.find(`[name="${e}"]`)),this._input||(this._input=s.A.find('input[type="file"]',this._element)||s.A.find('input[type="file"]',this._element.parentNode))}_setupEvents(){(0,r.vq)(this._element)&&(g.A.on(this._element,`click.${yi}`,t=>{if("LABEL"!==this._element.tagName)return;const e=t.target?.closest?.(`.${fi}`);e&&this._element.contains(e)&&t.preventDefault()}),g.A.on(this._element,"dragover",t=>{if(t.preventDefault(),t.stopPropagation(),this._isSortableDrag(t))return e.x.remove(this._element,[bi,vi]),wi._setDropMessageTitleState(this._element,!1),void(t.dataTransfer.dropEffect="none");e.x.has(this._element,bi)||e.x.add(this._element,vi)}),g.A.on(this._element,"dragenter",t=>{if(t.preventDefault(),t.stopPropagation(),this._isSortableDrag(t))return e.x.remove(this._element,[bi,vi]),void wi._setDropMessageTitleState(this._element,!1);e.x.add(this._element,[bi,vi]),wi._setDropMessageTitleState(this._element,!0)}),g.A.on(this._element,"dragleave",t=>{if(t.preventDefault(),t.stopPropagation(),this._isSortableDrag(t))return e.x.remove(this._element,[bi,vi]),void wi._setDropMessageTitleState(this._element,!1);t.target!==this._element&&t.target.closest("."+gi)!==this._element||(e.x.remove(this._element,vi),setTimeout(()=>{this._element.matches(":hover")||(e.x.remove(this._element,bi),wi._setDropMessageTitleState(this._element,!1))},50))}),g.A.on(this._element,"drop",t=>{if(t.preventDefault(),t.stopPropagation(),e.x.remove(this._element,[bi,vi]),wi._setDropMessageTitleState(this._element,!1),this._isSortableDrag(t))return;const i=t.dataTransfer?.files;i&&i.length&&(this._files=i,(0,r.vq)(this._input)&&(this._input.files=i,g.A.trigger(this._input,"change")))}))}_bindGlobalEvents(){wi._isGlobalEventsBound||(wi._globalHandlers={dragenter:t=>this._updateSuggestedDrop(t),dragover:t=>this._updateSuggestedDrop(t),dragleave:t=>{this._isFileDrag(t)&&(null!==t.relatedTarget&&t.target!==document&&t.target!==document.documentElement||wi._clearSuggestedDrop())},drop:t=>{if(!this._isFileDrag(t))return void wi._clearSuggestedDrop();const e=wi._activeSuggestedDrop;if(e){const i=Array.from(wi._smartInstances).find(t=>t._element===e),s=t.dataTransfer?.files;i&&s&&s.length&&(0,r.vq)(i._input)&&(t.preventDefault(),t.stopPropagation(),i._files=s,i._input.files=s,g.A.trigger(i._input,"change"))}wi._clearSuggestedDrop()},dragend:()=>wi._clearSuggestedDrop()},g.A.on(document,"dragenter",wi._globalHandlers.dragenter),g.A.on(document,"dragover",wi._globalHandlers.dragover),g.A.on(document,"dragleave",wi._globalHandlers.dragleave),g.A.on(document,"drop",wi._globalHandlers.drop),g.A.on(document,"dragend",wi._globalHandlers.dragend),g.A.on(window,"dragenter",wi._globalHandlers.dragenter),g.A.on(window,"dragover",wi._globalHandlers.dragover),g.A.on(window,"dragleave",wi._globalHandlers.dragleave),g.A.on(window,"drop",wi._globalHandlers.drop),g.A.on(window,"dragend",wi._globalHandlers.dragend),wi._isGlobalEventsBound=!0)}_updateSuggestedDrop(t){if(!this._isFileDrag(t))return void wi._clearSuggestedDrop();const i=this._getVisibleDropZonesInViewport();if(1===i.length){const[s]=i;return wi._activeSuggestedDrop!==s&&(wi._clearSuggestedDrop(),e.x.add(s,bi),wi._setDropMessageTitleState(s,!0),wi._activeSuggestedDrop=s),t.dataTransfer&&(t.dataTransfer.dropEffect="copy"),void t.preventDefault()}wi._clearSuggestedDrop()}_isFileDrag(t){try{if(this._isSortableDrag(t))return!1;const e=t?.dataTransfer;return!!e&&(!!(e.files&&e.files.length>0)||(e.items&&e.items.length>0?Array.from(e.items).some(t=>"file"===t.kind):!!e.types&&Array.from(e.types).includes("Files")))}catch(t){return!1}}_isSortableDrag(t){if((0,pi.L)())return!0;if(document.querySelector(".dragging"))return!0;try{const e=t?.dataTransfer;return!!Array.from(e?.types||[]).includes(pi.h)||"1"===(e?.getData?.(pi.h)||"")||"vgsortable"===(e?.getData?.("text/plain")||"")}catch(t){return!1}}_getVisibleDropZonesInViewport(){return Array.from(s.A.findAll(`.${gi}`)||[]).filter(t=>this._isVisibleInViewport(t))}_isVisibleInViewport(t){if(!(0,r.vq)(t)||!t.isConnected)return!1;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility||"0"===e.opacity)return!1;const i=t.getBoundingClientRect();return!(!i.width||!i.height)&&(i.bottom>0&&i.right>0&&i.top<window.innerHeight&&i.left<window.innerWidth)}static _clearSuggestedDrop(){wi._activeSuggestedDrop&&(wi._setDropMessageTitleState(wi._activeSuggestedDrop,!1),e.x.remove(wi._activeSuggestedDrop,bi),wi._activeSuggestedDrop=null)}static _setDropMessageTitleState(t,e){if(!(0,r.vq)(t))return;const i=s.A.find(".vg-files-drop-message .title",t);if(!i)return;const n=(i.getAttribute("data-drop-original-text")||"").trim()||(i.textContent||"").trim();i.setAttribute("data-drop-original-text",n);const a=(t.getAttribute("data-drop-active-text")||"").trim();i.textContent=e&&a?a:n}static _unbindGlobalEvents(){if(!wi._isGlobalEventsBound)return;const t=wi._globalHandlers||{};g.A.off(document,"dragenter",t.dragenter),g.A.off(document,"dragover",t.dragover),g.A.off(document,"dragleave",t.dragleave),g.A.off(document,"drop",t.drop),g.A.off(document,"dragend",t.dragend),g.A.off(window,"dragenter",t.dragenter),g.A.off(window,"dragover",t.dragover),g.A.off(window,"dragleave",t.dragleave),g.A.off(window,"drop",t.drop),g.A.off(window,"dragend",t.dragend),wi._isGlobalEventsBound=!1,wi._globalHandlers=null,wi._clearSuggestedDrop()}getFiles(){return this._files}dispose(){g.A.off(this._element,`click.${yi}`),g.A.off(this._element,"dragover"),g.A.off(this._element,"dragenter"),g.A.off(this._element,"dragleave"),g.A.off(this._element,"drop"),wi._instances.delete(this),wi._smartInstances.delete(this),wi._smartInstances.size||wi._unbindGlobalEvents(),this._input=null,this._files=null}init(){return this}}wi._instances=new Set,wi._smartInstances=new Set,wi._isGlobalEventsBound=!1,wi._activeSuggestedDrop=null,wi._globalHandlers=null;const Ei=wi;var Ai=i(483);const Si=class{constructor(t,e,i={}){this.module=t,this.element=(0,r.vq)(e)?e:null,this.element?(this._params=new jt.A(i,e).get(),this._nodes={info:this.module._nodes.info,drop:this.module._nodes.drop},this.bufferTemplate="",this.parsedFiles=[]):console.error("Invalid element provided:",e)}init(){const t=this._nodes.info||this._nodes.drop;if(!t)return!1;const e=this._nodes.info?"info":"drop";return this._nativeRenderFiles(e,t)}_nativeRenderFiles(t,i){const r=s.A.find(`.vg-files-${t}--list`,i);if(!r)return!1;const n=Array.from(r.children).filter(t=>"LI"===t.tagName);return 0!==n.length&&(this._setTemplateInBuffer(n),!!this.bufferTemplate&&(this.parsedFiles=n.map(t=>{const i=e.p.get(t,"data-file");return i?this._parseDataFile(i):null}).filter(Boolean),!0))}_parseDataFile(t){const e=(0,r.OM)(t);if(!e||"object"!=typeof e||Array.isArray(e))return null;const i=this._extractBinaryMeta(e),s=this._toStringOrNull(e.name),n=this._toStringOrNull(e.id),a=this._toStringOrNull(e.src),o=this._toStringOrNull(e.type)||i.type||"application/octet-stream",l={id:n,name:s,size:this._toNumberOrNull(e.size)??i.size??0,type:o,src:a,lastModified:this._toNumberOrNull(e.lastModified??e["last-modified"])??i.lastModified??Date.now()};if(void 0!==e.image&&null!==e.image&&""!==e.image&&(l.image=e.image),!["id","name","size","type","src"].every(t=>{const e=l[t];return"size"===t?Number.isFinite(e):null!=e&&""!==e}))return null;const h={},d=new Set(["id","name","size","type","src","image","lastModified","last-modified"]);return Object.entries(e).forEach(([t,e])=>{d.has(t)||null!=e&&""!==e&&(h[t]=e)}),Object.keys(h).length&&(l.customData=h),l}_extractBinaryMeta(t){const e=t.file||t.blob||t.originFile||null;return e instanceof Blob?{size:this._toNumberOrNull(e.size)??null,type:this._toStringOrNull(e.type)||null,lastModified:(e instanceof File?this._toNumberOrNull(e.lastModified):null)??null}:{}}_toStringOrNull(t){if(null==t)return null;return String(t).trim()||null}_toNumberOrNull(t){if(null==t||""===t)return null;const e=Number(t);return Number.isFinite(e)?e:null}_setTemplateInBuffer(t){if(this.bufferTemplate||0===t.length)return;const i=t[0];e.p.has(i,"data-file")?this.bufferTemplate=i.outerHTML:(this.bufferTemplate=i.outerHTML,i.remove())}dispose(){this.bufferTemplate="",this.parsedFiles=[]}},Ci="files",xi="vg.files",Li='[data-vg-reload="file"]',Ii='[data-vg-dismiss="file"]',Pi="vg-files",Mi=`${Pi}-stat`,ki="completed",Di="pending",Ti="loading",Oi="failing",zi="loaded";class Ni extends _i{constructor(t,e={}){super(t,e,{init:!0,allowed:!1,lang:document.documentElement.lang||"ru",limits:{count:0,sizes:10,total:0},image:!1,detach:!0,info:!0,types:[],ajax:!1,prepend:!0,replace:!0,rename:!1,smartdrop:!1,customButtons:{hideOnUploadState:!0},uploads:{mode:"sequential",route:"",maxParallel:3,maxConcurrent:1,retryAttempts:1,retryDelay:1e3},removes:{buttons:null,all:{route:"",alert:!0,toast:!0,confirm:null,buttons:null},single:{route:"",alert:!0,toast:!0,confirm:null,buttons:null}},sortable:{enabled:!1,route:"",handle:".file",lists:["vg-files-info--list","vg-files-drop--list"]},callbacks:{onInit:null,onChange:null,onUploadStart:null,onUploadProgress:null,onUploadComplete:null,onUploadError:null,onUploadAllComplete:null,onRemoveFile:null,onClear:null,onReload:null}}),this._files=[],this._uploadedKeys=new Set,this._failingUploadedKeys=new Set,this._pendingUploadedKeys=new Set,this._unUploadedFiles=[],this._uploader=null,this._sortable=null,this._render=null,this.isRenderNonInit=!1,this._initExtended()}static get NAME(){return Ci}static get NAME_KEY(){return xi}_initExtended(){if(!this._isInitialized)return;if(this._render=new Si(this,this._element,this._params),this._params.ajax&&(this._params.allowed=!1),this.isRenderNonInit)return;this.isRenderNonInit=this._render.init();const t=this._render.parsedFiles;t.length&&this._addExternalFiles(t),this._params.allowed&&!this._params.ajax&&(this._params.detach=!1),this._nodes.drop&&(this._params.image=!0,this._params.detach=!0,this._setDropActiveText(),Ei.getOrCreateInstance(this._nodes.drop,this._params).init()),this._addEventListenerExtended(),this._renderStat(),this._triggerCallback("onInit",{element:this._element,files:t||[]})}_setDropActiveText(){if(!this._nodes.drop)return;const t=Rt(this._params.lang,Ci)||{},e=(this._nodes.drop.getAttribute("data-drop-active-text")||"").trim()||t["drop-active"]||"Release to upload";this._nodes.drop.setAttribute("data-drop-active-text",e);const i=s.A.find(".vg-files-drop-message .title",this._nodes.drop);if(!i)return;const r=(i.getAttribute("data-drop-original-text")||"").trim()||(i.textContent||"").trim();i.setAttribute("data-drop-original-text",r)}_addExternalFiles(t){Array.isArray(t)&&t.length&&(t.forEach(t=>{if(!t?.name)return;const e={};"string"==typeof t.type&&(e.type=t.type),Number.isFinite(t.lastModified)&&(e.lastModified=t.lastModified);const i=new File([""],t.name,e);void 0!==t.id&&null!==t.id&&""!==t.id&&Object.defineProperty(i,"id",{value:t.id,writable:!0,enumerable:!0}),Number.isFinite(t.size)&&Object.defineProperty(i,"size",{value:t.size,writable:!0,enumerable:!0}),void 0!==t.src&&null!==t.src&&""!==t.src&&Object.defineProperty(i,"src",{value:t.src,writable:!0,enumerable:!0}),void 0!==t.image&&null!==t.image&&""!==t.image&&Object.defineProperty(i,"image",{value:t.image,writable:!0,enumerable:!0}),t.customData&&"object"==typeof t.customData&&!Array.isArray(t.customData)&&Object.defineProperty(i,"customData",{value:t.customData,writable:!0,enumerable:!0});const s=this._getFileKey(i);this._uploadedKeys.add(s),this._pendingUploadedKeys.delete(s),this._failingUploadedKeys.delete(s),this._files.push(i)}),this._renderUI(this._files),this._renderStat(),this._updateStat(),this._setStatItem("completed",this._uploadedKeys.size),this._params.sortable?.enabled&&this._params.sortable.route&&!this._sortable&&(this._sortable=new pi.default(this,this._params.sortable)),this._triggerCallback("onChange",{files:this._files}),g.A.trigger(this._element,`${xi}.change`,{files:this._files}))}_addEventListenerExtended(){s.A.findAll('[data-vg-toggle="files"]',this._element).forEach(t=>{this._onNativeInputChange&&t.removeEventListener("change",this._onNativeInputChange),t.addEventListener("change",t=>this._handleChange(t))})}_handleChange(t){const e=t?.target,i=this._snapshotInputFiles(e);this.change(e),this._params.ajax&&this.uploadAll(this._files);const s={files:this._files,input:t?.target||t?.src||"",inputFiles:i};this._triggerCallback("onChange",s),this._triggerEvent("change",{files:this._files,input:s.input,inputFiles:s.inputFiles})}_snapshotInputFiles(t){const e=t?.files;return e?.length?Array.from(e):[]}async uploadAll(t){if(!this._params.ajax||!this._params.uploads.route)return;this._uploadedKeys.size||this._failingUploadedKeys.clear();const e=t.filter(t=>this._isFileValid(t)&&!this._uploadedKeys.has(this._getFileKey(t)));if(this._setStatItem("failing",this._getFailingCount()),!e.length)return;this._uploader&&!this._uploader.isIdle()||(this._uploader=new mi({mode:this._params.uploads.mode,maxConcurrent:this._params.uploads.maxConcurrent,maxParallel:this._params.uploads.maxParallel,retryAttempts:this._params.uploads.retryAttempts,retryDelay:this._params.uploads.retryDelay}),this._setupUploadEventHandlers()),e.forEach(t=>{const e=this._getFileKey(t);this._pendingUploadedKeys.add(e),this._unUploadedFiles=this._unUploadedFiles.filter(t=>this._getFileKey(t)!==e)}),this._setStatItem("pending",this._pendingUploadedKeys.size);const i={additionalData:{timestamp:(new Date).toISOString(),source:"web_uploader",prepend:this._params.prepend}};this._triggerCallback("onUploadStart",{files:e,total:e.length}),this._triggerEvent("upload.start",{files:e,total:e.length});try{await this._uploader.uploadFiles(e,this._params.uploads.route,i)}catch(t){console.error("Bulk upload failed:",t)}}async upload(t){if(!this._params.ajax||!this._params.uploads.route)return;this._uploader&&!this._uploader.isIdle()||(this._uploader=new mi({mode:this._params.uploads.mode,maxConcurrent:this._params.uploads.maxConcurrent,maxParallel:this._params.uploads.maxParallel,retryAttempts:this._params.uploads.retryAttempts,retryDelay:this._params.uploads.retryDelay}));const i=this._getFileKey(t);this._pendingUploadedKeys.has(i)||(this._pendingUploadedKeys.add(i),this._setStatItem("pending",this._pendingUploadedKeys.size)),this._unUploadedFiles=this._unUploadedFiles.filter(t=>this._getFileKey(t)!==i);const s=this._getItemElement(t);s&&(e.x.remove(s,Oi),e.x.add(s,Ti),e.x.add(s,Di)),this._setupUploadEventHandlers(t);const r={additionalData:{timestamp:(new Date).toISOString(),source:"web_uploader"}};try{await this._uploader.uploadFiles([t],this._params.uploads.route,r)}catch(t){console.error("Upload failed:",t)}}_setupUploadEventHandlers(){"function"==typeof this._uploader.offAll?this._uploader.offAll():(this._uploader.off("progress"),this._uploader.off("complete"),this._uploader.off("error"),this._uploader.off("allComplete")),this._updateStat(!0),this._uploader.onProgress(t=>{const i=t.file,n=this._getItemElement(i);if(!n)return;e.x.add(n,Ti),e.x.add(n,Di);const a=this._getButtonElement(i);if((0,r.vq)(a)){const t=a.closest("li");if(t){const e=s.A.find(".file-remove",t);e&&(e.innerHTML="",e.appendChild(this._setButtonElement(i,!0)))}}const o={file:t.file,progress:t.progress,bytesSent:t.bytesSent,totalBytes:t.totalBytes};this._triggerCallback("onUploadProgress",o),this._triggerEvent("upload.progress",o)}),this._uploader.onComplete(t=>{const i=t.file,n=this._getFileKey(i),a=this._getItemElement(i);if(!a)return;e.x.replace(a,Ti,zi),e.x.remove(a,Di);const o=this._getButtonElement(i),l=(0,r.OM)(t.result?.response?.id)||t.id||i.lastModified;if(i.id=l,(0,r.vq)(o)&&l){const t=o.closest("li");if(t){e.p.set(t,"data-id",l),this._setButtonElement(i);const r=s.A.find(".file-remove",t);r&&(r.innerHTML="",r.appendChild(this._setButtonElement(i,!0,"completed")),e.x.add(t,ki),setTimeout(()=>{r.innerHTML="",r.appendChild(this._setButtonElement(i)),e.x.remove(t,ki)},1e3))}}this._uploadedKeys.add(n),this._failingUploadedKeys.delete(n),this._pendingUploadedKeys.delete(n),this._setStatItem("completed",this._uploadedKeys.size),this._setStatItem("pending",this._pendingUploadedKeys.size);const h={file:t.file,response:t.result?.response,status:t.result?.status,id:i.id};this._triggerCallback("onUploadComplete",h),this._triggerEvent("upload.complete",h)}),this._uploader.onError(t=>{const i=t.file,n=this._getFileKey(i),a=this._getItemElement(i);if(!a)return;this._uploadedKeys.delete(n),this._failingUploadedKeys.add(n),this._pendingUploadedKeys.delete(n),this._unUploadedFiles.push(i),e.x.remove(a,Di),e.x.replace(a,Ti,Oi),this._setStatItem("failing",this._getFailingCount()),this._setStatItem("pending",this._pendingUploadedKeys.size);const o=this._getButtonElement(i);if((0,r.vq)(o)){const t=o.closest("li");if(t){this._setButtonElement(i);const r=s.A.find(".file-remove",t);r&&(r.innerHTML="",r.appendChild(this._setFailingButtons(i)),e.x.add(t,Oi))}}const l={file:t.file};this._triggerCallback("onUploadError",l),this._triggerEvent("upload.error",l)}),this._uploader.onAllComplete(()=>{this._triggerEvent("upload.allComplete"),this._updateStat(!1),this._getFailingCount()||this._params.sortable?.enabled&&this._params.sortable.route&&Promise.resolve().then(i.bind(i,355)).then(t=>{this._sortable&&"function"==typeof this._sortable.destroy&&this._sortable.destroy(),this._sortable=new t.default(this,this._params.sortable)}).catch(t=>{console.error("Ошибка загрузки VGFilesSortable:",t)});const t={uploaded:this._uploadedKeys.size,failed:this._getFailingCount(),total:this._files.length};this._triggerCallback("onUploadAllComplete",t)})}reload(t){if(!this._params.ajax||!this._params.uploads.route)return;const i=e.p.get(t,"data"),s={name:i.name,size:i.size,type:i.type,lastModified:i["last-modified"]},r=this._getFileKey(s);if(!this._failingUploadedKeys.has(r))return;const n=this._unUploadedFiles.find(t=>this._getFileKey(t)===r);if(!n)return;this._failingUploadedKeys.delete(r),this._pendingUploadedKeys.add(r),this._setStatItem("failing",this._failingUploadedKeys.size),this._setStatItem("pending",this._pendingUploadedKeys.size);const a={button:t,file:n};this._triggerCallback("onReload",a),this._triggerEvent("reload",a),this.upload(n)}_runAjaxRequest(t,e){const i=this._params.ajax;this._params.ajax=t,this._route((t,s)=>{this._params.ajax=i,e(t,s)})}_normalizeConfirmResult(t){if(!0===t)return{accepted:!0,data:null};if(!1===t||null==t)return{accepted:!1,data:null};if("object"==typeof t){if("boolean"==typeof t.accepted)return{accepted:t.accepted,data:t.data??null};if(Object.prototype.hasOwnProperty.call(t,"data"))return{accepted:!0,data:t.data??null}}return{accepted:Boolean(t),data:null}}_runDefaultRemoveConfirm(t,e){return new Promise(i=>{oe.confirm(t,{lang:e.lang,ajax:e.ajax,buttons:e.buttons,message:e.message}),g.A.one(t,"vg.alert.accept",t=>{i({accepted:!0,data:t?.vgalert?.data??null})}),g.A.one(t,"vg.alert.reject",()=>{i({accepted:!1,data:null})})})}_isPlainObject(t){return t&&"object"==typeof t&&!Array.isArray(t)}_mergeButtonConfigs(...t){return t.reduce((t,e)=>this._isPlainObject(e)?(Object.entries(e).forEach(([e,i])=>{this._isPlainObject(t[e])&&this._isPlainObject(i)?t[e]=this._mergeButtonConfigs(t[e],i):t[e]=Array.isArray(i)?i.slice():i}),t):t,{})}_getDefaultRemoveConfirmButtons(){return{agree:{text:Bt(this._params.lang,Ci).agree,class:["btn-danger"]},cancel:{text:Bt(this._params.lang,Ci).cancel,class:["btn-outline-danger"]}}}_getRemoveConfirmButtons(t){return this._mergeButtonConfigs(this._getDefaultRemoveConfirmButtons(),this._params?.removes?.buttons,this._params?.removes?.[t]?.buttons)}_confirmRemove(t,e,i,s){const r=this._getRemoveConfirmButtons(t),n={type:t,trigger:e,lang:this._params.lang,ajax:i,buttons:r,message:s},a=this._params?.removes?.[t]?.confirm;return"function"==typeof a?Promise.resolve(a(n,this)).then(t=>this._normalizeConfirmResult(t)):this._runDefaultRemoveConfirm(e,n)}removeFile(t){const i=(0,r.OM)(e.p.get(t,"data-name")),n=(0,r.OM)(e.p.get(t,"data-size")),a=(0,r.OM)(e.p.get(t,"data-id")),o=()=>{const e={button:t,name:i,size:n,id:a,remaining:this._files.length};this._triggerCallback("onRemoveFile",e),this._triggerEvent("remove",e)},l=this._files.find(t=>t.name===i&&t.size===n);if(l){const t=this._getFileKey(l);this._uploadedKeys.delete(t),this._pendingUploadedKeys.delete(t),this._failingUploadedKeys.delete(t),this._forgetFileValidation(l)}if(this._getItemElement().forEach(t=>{const i=s.A.find("button",t);if(!i)return;const n=(0,r.OM)(e.p.get(i,"data-id")),a=(0,r.OM)(e.p.get(i,"data-name")),o=(0,r.OM)(e.p.get(i,"data-size"));this._files.forEach(t=>{t.name===a&&t.size===o&&(t.id=n)}),l?.name===a&&l?.size===o&&(l.id=n)}),this._params.ajax&&this._params.removes.single.route){if(!a)return this._files=this._files.filter(t=>!(t.name===i&&t.size===n)),this._updateStatsAfterRemove(),this._files.length?this.build():this.clear(!0),o(),void this._resetFileInput();const e=this._params.removes.single.route,s=e.includes("?")?"&":"?",r={route:`${e}${s}id=${encodeURIComponent(a)}`,method:"delete"},l=t=>{this._files=this._files.filter(t=>!(t.name===i&&t.size===n)),this._updateStatsAfterRemove(),this._files.length?this._renderUI(this._files):this.clear(!0,!0),this._params.removes.single.toast&&Ai.A.run(t?.response?.message),o()};if(this._params.removes.single.alert){const e={title:Rt(this._params.lang,Ci).title,description:Rt(this._params.lang,Ci).description};this._confirmRemove("single",t,r,e).then(t=>{t.accepted&&(t.data?l(t.data):this._runAjaxRequest(r,(t,e)=>{l(e)}))}).catch(()=>{})}else this._runAjaxRequest(r,(t,e)=>{l(e)})}else this._files=this._files.filter(t=>!(t.name===i&&t.size===n)),this._updateStatsAfterRemove(),this._files.length?this.build():this.clear(!0),o();this._resetFileInput()}_updateStatsAfterRemove(){this._setStatItem("completed",this._uploadedKeys.size),this._setStatItem("pending",this._pendingUploadedKeys.size),this._setStatItem("failing",this._getFailingCount()),this._updateStat()}_getItemElement(t=null){let e=`${this._getClass("info-list")}`;return this._nodes.drop&&(e=`${this._getClass("drop-list")}`),t?s.A.find(`.${e} li[data-name="${t.name}"][data-size="${t.size}"]`,this._element):s.A.findAll(`.${e} li.loaded`,this._element)}_getButtonElement(t){return s.A.find(`button[data-name="${t.name}"][data-size="${t.size}"]`,this._element)}_setButtonElement(t,e=!1,i=""){let s=(0,f.z)("remove"),r="data-vg-dismiss";return e&&(s=(0,f.z)("spinner"),"completed"===i?s=(0,f.z)("check"):r="data-vg-reload"),this._tpl.button([this._tpl.i({},s,{isHTML:!0})],"button",this._buildFileDataAttributes(t,{type:"button",[r]:"file","data-name":t.name,"data-size":t.size??0,"data-type":t.type||"","data-last-modified":t.lastModified||"","data-id":t.id||""}))}_setFailingButtons(t){return this._tpl.div({class:"file-failing-actions"},[this._setButtonElement(t,!0,"failing"),this._setButtonElement(t)])}_renderStat(){if(!this._nodes.stat)return;if(!this._params.ajax)return;const t=s.A.find(`.${Mi}-progress`,this._nodes.stat);if(!t)return;let e=s.A.find(`.${Mi}-progress-list`,t);e||(e=this._tpl.ul([this._tpl.li({class:"stat-item pending","data-count":"0",title:Rt(this._params.lang,Ci).pending},[this._tpl.span({class:"stat-label"},(0,f.z)("cloud-dot"),{isHTML:!0}),this._tpl.span({class:"stat-value"},0)]),this._tpl.li({class:"stat-item completed","data-count":"0",title:Rt(this._params.lang,Ci).completed},[this._tpl.span({class:"stat-label"},(0,f.z)("cloud-dot"),{isHTML:!0}),this._tpl.span({class:"stat-value"},0)]),this._tpl.li({class:"stat-item failing","data-count":"0",title:Rt(this._params.lang,Ci).failing},[this._tpl.span({class:"stat-label"},(0,f.z)("cloud-dot"),{isHTML:!0}),this._tpl.span({class:"stat-value"},0)])],{class:Mi+"-progress-list"},!0),t.appendChild(e))}_setStatItem(t,i){if(!this._nodes.stat)return;const r=s.A.find(`.${Mi}-progress-list li.${t}`,this._nodes.stat);if(!r)return;e.p.set(r,"data-count",i);const n=s.A.find(".stat-value",r);n&&(n.innerHTML=i)}_renderUIStatusDropInfoAjax(t){this._params.ajax&&(t.forEach(t=>{const i=this._getItemElement(t);if(!i)return;const s=this._getFileKey(t);this._isFileValid(t)?this._uploadedKeys.has(s)?(e.x.replace(i,Di,ki),e.x.add(i,zi)):this._failingUploadedKeys.has(s)?e.x.replace(i,Di,Oi):e.x.add(i,Di):(e.x.remove(i,Di),e.x.add(i,Oi))}),this._setStatItem("failing",this._getFailingCount()))}_getFailingCount(){const t=new Set(this._failingUploadedKeys);return this._validationErrorsByKey.forEach((e,i)=>t.add(i)),t.size}_triggerCallback(t,e){const i=this._params.callbacks?.[t];if("function"==typeof i)try{i.call(this,e,this)}catch(e){console.error(`${t} callback error:`,e)}}_triggerEvent(t,e={}){g.A.trigger(this._element,`${xi}.${t}`,e)}_getUploadedIds(){return Array.from(this._uploadedKeys).map(t=>{const e=this._files.find(e=>this._getFileKey(e)===t);return e?.id||null}).filter(t=>null!==t)}dispose(){this._sortable&&"function"==typeof this._sortable.destroy&&this._sortable.destroy(),this._sortable=null,this.clear(),this._uploader&&("function"==typeof this._uploader.destroy?this._uploader.destroy():("function"==typeof this._uploader.clear&&this._uploader.clear(),"function"==typeof this._uploader.offAll&&this._uploader.offAll())),super.dispose()}}g.A.on(document,`DOMContentLoaded.${xi}.data.api`,()=>{s.A.findAll(`.${Pi}`).forEach(t=>Ni.getOrCreateInstance(t))}),g.A.on(document,`click.${xi}.data.api`,Ii,function(t){t.preventDefault(),t.stopPropagation(),"function"==typeof t.stopImmediatePropagation&&t.stopImmediatePropagation();const e=t.target.closest(`.${Pi}`);e&&Ni.getOrCreateInstance(e).removeFile(t.target.closest(Ii))}),g.A.on(document,`click.${xi}.data.api`,Li,function(t){t.preventDefault(),t.stopPropagation(),"function"==typeof t.stopImmediatePropagation&&t.stopImmediatePropagation();const e=t.target.closest(`.${Pi}`);e&&Ni.getOrCreateInstance(e).reload(t.target.closest(Li))}),g.A.on(document,`click.${xi}.data.api`,'[data-vg-dismiss="vg-files"]',function(t){const e=t.target.closest(`.${Pi}`);if(!e)return;const i=Ni.getOrCreateInstance(e);if(i._params.ajax&&i._params.removes.all.route){t.preventDefault();const e={route:i._params.removes.all.route,method:"post",data:{ids:i._getUploadedIds()}},s=()=>{i.clear(!0,!0)};if(i._params.removes.all.alert){const r={title:Rt(i._params.lang,Ci).title,description:Rt(i._params.lang,Ci).descriptions};i._confirmRemove("all",t.target,e,r).then(t=>{if(t.accepted)return t.data?(i._params.removes.all.toast&&Ai.A.run(t.data?.response?.message),void s()):void i._runAjaxRequest(e,(t,e)=>{i._params.removes.all.toast&&e?.response?.message&&Ai.A.run(e.response.message),s()})}).catch(()=>{})}else i._runAjaxRequest(e,(t,e)=>{i._params.removes.all.toast&&e?.response?.message&&Ai.A.run(e.response.message),s()})}else i.clear(!0,!0)});const $i=Ni;var Hi=i(614);const Fi="vg.hideshowpass",Ri="show",Bi=`click.${Fi}.data.api`;class ji extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({parentClass:"vg-form-sender--content-pass"},e))}static get NAME(){return"hideshowpass"}static get NAME_KEY(){return Fi}toggle(t){return this._isShown()?this.hide(t):this.show(t)}show(t){t&&(this._params=this._getParams(t,this._params)),this._element.classList.add(Ri),t.remove(),this.build(!0),e.p.set(this._element,"type","text")}hide(t){this._element.classList.remove(Ri),t.remove(),this.build(!1),e.p.set(this._element,"type","password")}_isShown(){return this._element.classList.contains(Ri)}static init(t,e){ji.getOrCreateInstance(t,e).build(!1)}build(t=!1){let e=this._params.classes.join(" "),i="";const s=(0,d.A)("string");this._element.parentElement&&this._params.parentClass&&(this._element.parentElement.classList.add(this._params.parentClass),this._element.parentElement.classList.toggle("vg-form-sender--content-pass-focus-offset",!0===this._params.focus)),i=t?s.component("eye",{class:e,type:"hide"}):s.component("eye",{class:e}),this._element.insertAdjacentHTML(this._params.insert,i)}}g.A.on(document,Bi,'[data-vg-toggle="pass"]',function(t){const e=s.A.prev(this,"input");e&&(["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,r.d6)(this)||(this.setAttribute("aria-expanded",!0),ji.getOrCreateInstance(e.shift()).toggle(this)))});const Ui=ji,qi="form-sender",Vi="vg.fs",Wi="vg-form-sender-alert",Ki=`submit.${Vi}.data.api`;class Gi extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({response:{enabled:!1,errors:!1,title:"",message:""},redirect:{error:"",success:""},validate:!1,submit:!1,fields:[],timeout:50,pass:{focus:!1,template:"pass-open",classes:["vg-form-sender--hide-show-pass"],insert:"afterend"},alert:{enabled:!0,type:"modal",errors:!0,title:!0,delay:0,modal:{closeModalsBeforeModal:!0},toast:{closeModalsBeforeToast:!0}},ajax:{route:"",target:"",method:"get",timeout:1e3,loader:!1,output:!0},classes:{general:"vg-form-sender",alertCollapse:"vg-form-sender-collapse",alertModal:"vg-form-sender-modal",validation:"needs-validation",wasValidate:"was-validated",content:"vg-form-sender--content"},callback:{afterInit:r.lQ,afterValidateError:r.lQ,afterSuccess:r.lQ,afterError:r.lQ,afterSend:r.lQ},interceptors:{beforeSend:()=>new Promise((t,e)=>t()),success:!1,error:!1},button:{enabled:!0,disabled:!0,send:"Отправляем...",initial:"Отправить",spinner:{enabled:!1,element:'<span class="spinner-border spinner-border-sm me-2"></span>'},click:r.lQ},lang:"ru"},e)),this._button=null,this._cachedElements=new Map,this._initElements()}static get NAME(){return qi}static get NAME_KEY(){return Vi}_initElements(){this._button=s.A.find('[type="submit"]',this._element)||s.A.find('[form="'+this._element.id+'"]')||null;const t=s.A.findAll("input, textarea, select",this._element);this._cachedElements.set("fields",t),this._params.ajax.route=e.p.get(this._element,"action")||this._params.ajax.route,this._params.ajax.method=e.p.get(this._element,"method")||this._params.ajax.method,this._params.isBtnText="false"!==e.p.get(this._element,"data-btn-text"),this._params.isJsonParse="false"!==e.p.get(this._element,"data-json-parse"),this._params.isShowPass="true"===e.p.get(this._element,"data-show-pass"),this._button&&(this._params=this._getParams(this._button,this._params),this._params.button.initial=this._button.innerHTML.trim()||this._params.button.initial)}build(){this._element.classList.add(this._params.classes.general);const t=this._cachedElements.get("fields");return t&&t.forEach(t=>{(0,r.zN)(t)&&t.parentElement&&t.parentElement.classList.add(this._params.classes.content)}),this._params.validate&&(e.p.set(this._element,"novalidate",""),this._element.classList.add(this._params.classes.validation)),[...s.A.findAll('input[type="password"]',this._element)].forEach(t=>{Ui.init(t,this._params.pass)}),(0,r.g7)(this._params.callback.afterInit,[this._element,this]),this}request(t,e=null){const i=this;i._alertBefore();i._params.interceptors.beforeSend().then(()=>{(()=>{let s=new FormData(i._element);i._params.ajax.data=e?((t,e)=>{const i=new Set;return e.forEach((e,s)=>{i.has(s)||(t.delete(s),i.add(s)),t.append(s,e)}),t})(e,s):s,i._route(function(e,s){(0,r.g7)(i._params.callback.afterSend,[i._element,i,e,s]),i._element.classList.remove("was-validated"),i._params.response.enabled&&(s.response=i._params.response),i._params.alert.enabled&&("string"==typeof e&&"error"===e?i._params.redirect.error?window.location.href=i._params.redirect.error:(i._params.interceptors.error||i._alertError(t,s),(0,r.g7)(i._params.callback.afterError,[i._element,i,t,s])):"string"==typeof e&&"success"===e&&(i._params.redirect.success?window.location.href=i._params.redirect.success:(i._params.interceptors.success||i._alertSuccess(t,s),(0,r.g7)(i._params.callback.afterSuccess,[i._element,i,t,s]))))})})()}).catch(t=>{console.error(t)})}_alertBefore(){const t=this;if("collapse"===t._params.alert.type){const e=t._params.classes.alertCollapse;if(!t._cachedElements.has("collapses")||document.querySelector("."+e+".show")){const i=document.getElementsByClassName(e);t._cachedElements.set("collapses",i),[...i].forEach(function(t){t.classList.contains("show")&&we.getOrCreateInstance(t,{toggle:!1}).hide()})}}t._statusButton("before"),g.A.trigger(t._element,"vg.fs.before",{vgformsender:{self:t}})}_alertError(t,e){const i=this;i._statusButton("after"),i._jsonParse(e,"error"),g.A.trigger(i._element,"vg.fs.error",{vgformsender:{event:t,self:i,data:e}})}_alertSuccess(t,e){const i=this;i._statusButton("after"),i._jsonParse(e,"success"),g.A.trigger(i._element,"vg.fs.success",{vgformsender:{event:t,self:i,data:e}})}_statusButton(t){if(this._button){if("before"===t){const t=this._button;this._params.button.initial=this._button.innerHTML.trim(),this._params.button.spinner.enabled&&this._button.insertAdjacentHTML("afterbegin",this._params.button.spinner.element),this._params.button.enabled&&(t.innerHTML=this._params.button.send),this._params.button.disabled&&e.p.set(this._button,"disabled","disabled"),(0,r.g7)(this._params.button.click,[this,this._button,"before"])}if("after"===t){if(this._params.button.enabled&&(this._button.innerHTML=this._params.button.initial),this._params.button.disabled&&e.p.remove(this._button,"disabled"),this._params.button.spinner.enabled){let t=this._button.querySelector(".spinner-border");t&&t.remove()}(0,r.g7)(this._params.button.click,[this,this._button,"after"])}}}_jsonParse(t,e){const i=this;i._params.isJsonParse?i.alert((0,r.OM)(t),e):i.alert(t,e)}_getValidationErrors(){return[...this._element.elements].filter(t=>"function"==typeof t?.checkValidity&&!t.checkValidity()).map(t=>({element:t,name:t.name||"",id:t.id||"",type:t.type||"",value:t.value,message:t.validationMessage||"",validity:{...t.validity}}))}_handleValidateError(t){return t.preventDefault(),t.stopPropagation(),this._element.classList.add(this._params.classes.wasValidate),(0,r.g7)(this._params.callback.afterValidateError,[this._element,this,t,this._getValidationErrors()]),!1}alert(t,e){if((0,r.Gv)(t))if("code"in t&&t.code&&200===t.code){if("response"in t&&t.response){let i=(0,r.OM)(t.response);"string"==typeof i?-1===i.indexOf("Parse error")&&-1===i.indexOf("syntax error")||(e="danger",t={response:{title:Ft(this._params.lang,"errors").title,message:Rt(this._params.lang,"errors").went_wrong}}):"errors"in i&&(0,r.OM)(i.errors)&&(e=(0,r.OM)(i.errors)?"danger":"success")}}else e="danger";this._params.alert.enabled&&("modal"===this._params.alert.type&&this._alertModal(t,e),"collapse"===this._params.alert.type&&this._alertCollapse(t,e),"toast"===this._params.alert.type&&this._alertToast(t,e))}_alertModal(t,e){const i=this,n=i._params.alert.modal?.closeModalsBeforeModal,a=!n&&i._hasOpenedModals();n&&i._closeOpenedModals();let o=i._params.classes.general+"-"+(0,r.PR)(),l=s.A.find("."+i._params.classes.alertModal);l&&l.remove(),setTimeout(()=>{lt.init(o,{dismiss:!0,classes:{alert:i._params.classes.alertModal}},function(r){let n=r._element;n.classList.add(i._params.classes.alertModal),a&&i._setStackedModalState(n);let o=s.A.find(".vg-modal-content",n);o&&o.classList.add(Wi,Wi+"-"+e);let l=s.A.find(".vg-modal-body",n);l&&l.append(i.setDataRelationStatus(n,e,t,"modal")),r.toggle(),i._params.alert.delay>0&&setTimeout(()=>{r.hide()},i._params.alert.delay)})},i._params.timeout)}_hasOpenedModals(){return Boolean(s.A.find(".modal.show, .vg-modal.show"))}_setStackedModalState(t){t&&(t.classList.add("vg-modal-stacked"),t.style.zIndex=this._getNextModalZIndex())}_getNextModalZIndex(){const t=s.A.findAll(".modal.show, .vg-modal.show, .ox-modal.is-open").map(t=>Number.parseInt(window.getComputedStyle(t).zIndex,10)).filter(t=>Number.isFinite(t));return String((t.length?Math.max(...t):1040)+10)}_closeOpenedModals(){[...document.getElementsByClassName("modal")].forEach(t=>{t&&t.classList.contains("show")&&("undefined"!=typeof bootstrap&&bootstrap.Modal?.getOrCreateInstance?bootstrap.Modal.getOrCreateInstance(t).hide():console.warn(Rt(this._params.lang,qi).bootstrap_not_found))}),[...document.getElementsByClassName("vg-modal")].forEach(t=>{if(t&&t.classList.contains("show")){const e=lt.getOrCreateInstance(t);e.hide([e])}}),[...document.getElementsByClassName("ox-modal")].forEach(t=>{t&&t.classList.contains("is-open")&&okaux.Modal.getOpenInstances().forEach(t=>{t.hide()})})}_alertCollapse(t,e){const i=this;let n=s.A.find("."+i._params.classes.alertCollapse);if(!n){n=document.createElement("div"),n.classList.add(i._params.classes.alertCollapse),n.classList.add("vg-collapse"),n.id=i._params.classes.general+"-"+(0,r.PR)();const s=i.setDataRelationStatus(n,e,t,"collapse");s.classList.add(Wi,Wi+"-"+e),n.append(s),i._element.prepend(n)}let a=we.getOrCreateInstance(n,{toggle:!1});a.toggle(),i._params.alert.delay>0&&setTimeout(()=>{a.hide()},i._params.alert.delay)}_alertToast(t,e){const i=this._prepareAlertResponse(e,t),s=this._getToastParams(e);this._params.alert.toast?.closeModalsBeforeToast&&this._closeOpenedModals(),i.title?Hi.A.run([i.title,i.message],s):Hi.A.run(i.message,s)}_getToastParams(t){const e="error"===t?"danger":t,i="danger"===t?"error":t,s=this._params.alert.delay>0?this._params.alert.delay:3e3,n={},{closeModalsBeforeToast:a,...o}=this._params.alert.toast||{};return["static","placement","autohide","delay","enableClickToast","enableButtonClose","keyboard","theme","drag","resize","stack","animation","ajax"].forEach(t=>{t in this._params.alert&&(n[t]=this._params.alert[t])}),(0,r._v)({theme:e||"dark",type:i||null,enableButtonClose:!0,autohide:this._params.alert.delay>0,delay:s},n,o)}setDataRelationStatus(t,e,i,r){let n=s.A.find("."+Wi+"-content",t);const a=this._prepareAlertResponse(e,i),o=(a.title?(0,d.A)("string").h4({class:Wi+"-content--title"},a.title):"")+a.message;if(n)s.A.find(".vg-modal-body",t).innerHTML=o;else{const t=(0,d.A)("dom");n=t.div({class:Wi+"-"+r},[t.div({class:Wi+"-content"},[t.i({class:Wi+"-content--icon"},(0,f.z)(e),{isHTML:!0}),t.div({class:Wi+"-content--text"},o,{isHTML:!0})])])}return n}_prepareAlertResponse(t,e){let i=(0,r.OM)(e?.response)||e;if((0,r.Gv)(e)){if((0,r.Gv)(e.response)&&"view"in e.response)return{title:"",message:e.response.view};if("string"!=typeof i){if("danger"===t){if(i.title="title"in i?i.title:Ft(this._params.lang,"errors").title,"code"in e&&200!==e.code){const t={400:Rt(this._params.lang,"errors")[400],401:Rt(this._params.lang,"errors")[401],403:Rt(this._params.lang,"errors")[403],404:Rt(this._params.lang,"errors")[404],413:Rt(this._params.lang,"errors")[413],419:Rt(this._params.lang,"errors")[419],422:Rt(this._params.lang,"errors")[422],500:Rt(this._params.lang,"errors")[500],504:Rt(this._params.lang,"errors")[504]};i.message=t[e.code]||Rt(this._params.lang,"errors").went_wrong,i.title+=" ("+e.code+")"}if("errors"in i&&this._params.alert.errors){let t=(0,r.OM)(i.errors)||null;if(i.message=[],(0,r.Gv)(t))for(const e in t)Array.isArray(t[e])?t[e].forEach(t=>i.message.push(t)):i.message.push(t[e])}}const s=(0,d.A)("string");let n="";return Array.isArray(i.message)?i.message.forEach(t=>{n+=s.div({class:Wi+"-content--message"},t)}):n=s.div({class:Wi+"-content--message"},i.message),{title:this._params.alert.title&&i.title||"",message:n}}}return{title:"",message:"string"==typeof i?i:""}}static init(t,e={}){Gi.getOrCreateInstance(t,e).build()}static buttonClick(t,e,i="before"){const n=s.A.find(t);if(n){const t=Gi.getOrCreateInstance(n);n.addEventListener("vg.fs."+i,i=>{(0,r.g7)(e,[n,t])})}}}g.A.on(document,Ki,function(t){if(!e.p.has(t.target,"data-vgformsender"))return;const i=Gi.getOrCreateInstance(t.target,{});if(i){if(i._params.validate&&!i._element.checkValidity())return i._handleValidateError(t);if(!i._params.submit){t.preventDefault();const e=function(t,e){return e.forEach(function(e){(0,r.Gv)(e)&&Object.keys(e).forEach(function(i){let s=(0,r.OM)(e[i]);Array.isArray(s)||(0,r.Gv)(s)?t.append(i,JSON.stringify(s)):t.append(i,s)})}),t};let s=new FormData(i._element),n=i._params.fields;return Array.isArray(n)&&n.length&&(s=e(s,n)),i.request(t,s)}}});const Yi=Gi;function Xi(t){return Array.prototype.slice.call(arguments,1).forEach(e=>{e&&Object.keys(e).forEach(i=>{t[i]=e[i]})}),t}const Zi=function t(e,i){function s(t,s,r){if("undefined"==typeof document)return;if("number"==typeof(r=Xi({},i,r)).expires){const t=864e5;r.expires=new Date(Date.now()+r.expires*t)}r.expires&&(r.expires=r.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);let n="";return Object.keys(r).forEach(t=>{if(r[t]&&(n+="; "+t,!0!==r[t])){const e=String(r[t]).split(";")[0];n+="="+e}}),document.cookie=t+"="+e.write(s,t)+n}return Object.create({set:s,get:function(t){if("undefined"==typeof document||arguments.length&&!t)return;const i=document.cookie?document.cookie.split("; "):[],s={};for(let r=0;r<i.length;r++){const n=i[r].split("="),a=n.slice(1).join("="),o=n[0];try{const i=decodeURIComponent(o);if(s[i]=e.read(a,i),t===i)break}catch(t){}}return t?s[t]:s},remove:function(t,e){s(t,"",Xi({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Xi({},this.attributes,e))},withConverter:function(e){return t(Xi({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(i)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),Ji="vg.lawcookie",Qi="show",ts=`${Ji}.hide`,es=`${Ji}.hidden`,is=`${Ji}.show`,ss=`${Ji}.shown`,rs=`click.${Ji}.data.api`;class ns extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({storage:"local",delay:500,cookie:{name:"lawCookie",value:"yes",attributes:{}},animation:{enable:!0,in:"animate__fadeInUp",out:"animate__fadeOutDown",delay:800},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0}},e)),this._storage=this._createStorage(),this._params.animation.delay=this._params.animation.enable?this._params.animation.delay:0,this._animation(this._element,ns.NAME_KEY,this._params.animation)}static get NAME(){return"lawcookie"}static get NAME_KEY(){return Ji}_isConsented(){return this._storage.get()===this._params.cookie.value}toggle(){return this._isConsented()?this.hide():this.show()}show(){(0,r.d6)(this._element)||this._isConsented()||g.A.trigger(this._element,is).defaultPrevented||(this._element.classList.add(Qi),this._queueCallback(()=>{g.A.trigger(this._element,ss)},this._element,!0,this._params.delay))}hide(){g.A.trigger(this._element,ts).defaultPrevented||(this._element.classList.remove(Qi),this._queueCallback(()=>{g.A.trigger(this._element,es)},this._element,!0,this._params.animation.delay))}_createStorage(){const{name:t,value:e,attributes:i}=this._params.cookie;return"cookie"===this._params.storage?{get:()=>Zi.get(t),set:()=>Zi.set(t,e,i)}:{get:()=>localStorage.getItem(t),set:()=>localStorage.setItem(t,e)}}accept(){this._storage.set()}static reset(){const{name:t}=ns.getDefaultParams().cookie;Zi.remove(t),localStorage.removeItem(t),location.reload()}static getDefaultParams(){return(0,r._v)({cookie:{name:"lawCookie"}},{})}dispose(){const{name:t}=this._params.cookie;Zi.remove(t),localStorage.removeItem(t),super.dispose()}static init(t,e={}){ns.getOrCreateInstance(t,e).toggle()}}(0,f.P)(ns),g.A.on(document,rs,'[data-vg-toggle="lawcookie"]',function(t){if(["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,r.d6)(this))return;const e=s.A.find("#vg-lawcookie");if(!e)return;const i=ns.getOrCreateInstance(e);i.accept(),i.hide()}),g.A.on(document,rs,'[data-vg-toggle="lawcookie-clear"]',function(t){if(["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,r.d6)(this))return;const e=s.A.find("#vg-lawcookie");e&&(ns.getOrCreateInstance(e).dispose(),ns.reset())});const as=ns,os="loadmore",ls="vg."+os,hs=`${ls}.loaded`,ds=`${ls}.before.load`,cs="vg-collapse",_s="show",us=`click.${ls}.data.api`;class ms extends t.A{static get NAME(){return os}static get NAME_KEY(){return ls}constructor(t,e){super(t,e),this._params=this._getParams(t,(0,r._v)({lang:document.documentElement.lang||"ru",limit:0,offset:0,output:!0,autohide:!0,animate:!1,append:"after",mode:"button",threshold:100,debug:!1,detach:!1,button:{text:"",send:"Загружаю...",show:"Показываю...",loader:!1,classes:[]},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!1,data:{}}},e)),this._observer=null,this._isScrollMode="scroll"===this._params.mode,this._isToggleElement=t.hasAttribute("data-vg-toggle"),this._params.button.send=Bt(this._params.lang,os).send,this._params.button.show=Bt(this._params.lang,os).show,this._params.button.text||(this._params.button.text=this._isToggleElement?this._element.innerHTML.trim()||Bt(this._params.lang,os)["text-ajax"]:this._params.ajax.route?Bt(this._params.lang,os)["text-ajax"]:Bt(this._params.lang,os)["text-more"]),this._isToggleElement?this._initializeAsButton():this._initializeContainer()}_initializeAsButton(){this._isScrollMode&&this._initScrollMode()}_initializeContainer(){const{elements:t,limit:e}=this._params,i=this._element,r=s.A.findAll(`.${t}`,i);!this._params.ajax.route&&(r.length<=e||this._params.offset>=r.length)||(r.forEach((t,i)=>{t.classList.toggle(_s,i<e),t.classList.toggle(cs,i>=e)}),"button"===this._params.mode?this._createAndInsertButton(i):this._isScrollMode&&this._initScrollMode(),0===this._params.offset&&(this._params.offset=e))}_createAndInsertButton(t){const i=document.createElement("button"),s=(0,r.OM)(t.dataset.buttonText)||this._params.button.text,n={limit:this._params.limit,offset:this._params.offset||this._params.limit,output:this._params.output,autohide:this._params.autohide,animate:this._params.animate,append:this._params.append,mode:this._params.mode,threshold:this._params.threshold,debug:this._params.debug,detach:this._params.detach,elements:this._params.elements,"vg-toggle":"loadmore",target:`#${t.id}`};Object.assign(n,(0,r.OM)(t.dataset.params)),Object.keys(n).forEach(t=>{e.p.set(i,`data-${t}`,n[t])}),i.textContent=s,i.classList.add(...this._params.button.classes),t.parentNode.insertBefore(i,t.nextSibling)}_initScrollMode(){this._setupIntersectionObserver(),this._observeLastVisibleItem()}_setupIntersectionObserver(){this._observer||(this._observer=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&(this._params.debug&&console.log("[VGLoadMore] Пересечение — вызов toggle"),this.toggle())})},{root:null,rootMargin:`0px 0px ${this._params.threshold}px 0px`,threshold:.1}))}_observeLastVisibleItem(){if(!this._observer)return;this._observer.disconnect();const t=this._getTargetContainer(),e=s.A.findAll(`.${this._params.elements}`,t).filter(t=>t.classList.contains(_s)),i=e[e.length-1];i instanceof Element&&this._observer.observe(i)}toggle(t){this._params.debug&&console.log("[VGLoadMore] toggle()"),g.A.trigger(this._element,ds).defaultPrevented||((this._isToggleElement||["BUTTON","A"].includes(this._element.tagName)&&!this._isScrollMode)&&(this._element.disabled=!0,this._element.innerHTML=this._params.ajax.route?this._params.button.send:this._params.button.show),this._params.ajax.route?this.ajax(t):this.staticLoad(t))}ajax(t){const e=this._params.ajax.target?.trim();let i=null;if(i=e?s.A.find(e):this._element,!i)return void console.error("[VGLoadMore] target элемент не найден:",this._params.ajax.target);const n=this._params.button.text;this._params.ajax.data=(0,r._v)(this._params.ajax.data,{limit:this._params.limit,offset:this._params.offset}),this._route((e,s,a)=>{if("error"===e||"string"!=typeof s?.response)return;this._params.output&&i.insertAdjacentHTML("after"===this._params.append?"beforeend":"afterbegin",s.response),this._params.offset+=this._params.limit,this._restoreElementState(n),this._observeLastVisibleItem();const o=!s.response.trim();this._params.autohide&&o&&this._autohideTrigger(),g.A.trigger(this._element,hs,{stats:e,data:s}),(0,r.g7)(t,[this,s,a,e])},t=>{this._restoreElementState(n),console.error("[VGLoadMore] AJAX ошибка",t)})}staticLoad(t){const e=this._getTargetContainer(),i=s.A.findAll(`.${this._params.elements}`,e),n=this._params.offset,a=n+this._params.limit,o=i.slice(n,a);if(0===o.length)return;(this._isToggleElement||["BUTTON","A"].includes(this._element.tagName)&&!this._isScrollMode)&&(this._element.disabled=!0,this._element.innerHTML=this._params.button.show),o.forEach(t=>{t.classList.replace(cs,_s),this._params.animate&&(t.style.opacity=0,requestAnimationFrame(()=>{t.style.transition="opacity 0.3s ease",t.style.opacity=1}))}),this._params.offset=a,this._observeLastVisibleItem();const l=i.slice(a);this._params.autohide&&0===l.length&&this._autohideTrigger(),this._restoreElementState(this._params.button.text),g.A.trigger(this._element,hs,{stats:"success",data:{items:o,offset:this._params.offset,remaining:l.length}}),(0,r.g7)(t,[this,this._element])}_getTargetContainer(){return s.A.find(this._params.target)||(this._isToggleElement?this._element.parentNode:this._element)}_restoreElementState(t){(this._isToggleElement||"BUTTON"===this._element.tagName)&&!this._isScrollMode&&(this._element.disabled=!1,this._element.innerHTML=t)}_autohideTrigger(){this._isScrollMode?(this._observer?.disconnect(),this._observer=null):this._params.detach&&this._element.parentNode?this._element.remove():(this._element.classList.add(cs),this._element.setAttribute("aria-hidden","true"))}dispose(){this._observer?.disconnect(),super.dispose()}}g.A.on(document,"DOMContentLoaded",()=>{s.A.findAll("[data-vgloadmore]").forEach(t=>{!t.dataset.initialized&&ms.getOrCreateInstance(t),t.dataset.initialized="true"})}),g.A.on(document,us,'[data-vg-toggle="loadmore"]',function(t){["A","AREA"].includes(this.tagName)&&t.preventDefault(),ms.getOrCreateInstance(this).toggle()});const ps=ms,gs="vg.nav",fs="show",bs="fade",vs="active",ys=`${gs}.hide`,ws=`${gs}.hidden`,Es=`${gs}.show`,As=`${gs}.shown`,Ss=`mouseover.${gs}.data.api`,Cs=`mouseout.${gs}.data.api`,xs=`click.${gs}.data.api`,Ls=`keyup.${gs}.data.api`;class Is extends t.A{constructor(t,e={}){super(t),this._params=this._getParams(t,(0,r._v)({breakpoint:"lg",placement:"horizontal",hover:!0,dropListScroll:!0,hoversmoothfirstlevel:{enable:!1,horizontalOnly:!0},animation:{enable:!0,timeout:700},toggle:'<span class="default"></span>',hamburger:{enable:!0,always:!1,title:"",body:null,target:"#sidebar-nav"},callbacks:{afterInit:r.lQ,afterClick:r.lQ}},e)),this._classes={hamburgerActive:"vg-nav-hamburger-active",hamburgerAlways:"vg-nav-hamburger-always",hamburger:"vg-nav-hamburger",container:"vg-nav-container",wrapper:"vg-nav-wrapper",dropListScroll:"vg-nav-drop-list-scroll",active:"vg-nav-active",expand:"vg-nav-expand",cloned:"vg-nav-cloned",hover:"vg-nav-hover",flip:"vg-nav-flip",XXXL:"vg-nav-xxxl",XXL:"vg-nav-xxl",XL:"vg-nav-xl",LG:"vg-nav-lg",MD:"vg-nav-md",SM:"vg-nav-sm",XS:"vg-nav-xs"},this._navigation=null,this.navigation="."+this._classes.wrapper,!1===this._params.animation.enable&&(this._params.animation.timeout=10),this._openDrops=new Map,this._pointerPosition=null,this._handleScroll=this._handleScroll.bind(this),this._handleResize=this._handleResize.bind(this)}static get NAME(){return"nav"}static get NAME_KEY(){return gs}get navigation(){return this._navigation}set navigation(t){let e=s.A.find(t,this._element);e&&(this._navigation=e)}build(){if(!this.navigation)return;let t=this._params,i=this._classes;if(this._element.classList.add(i.container),this._element.classList.add("vg-nav-"+t.placement),this._element.classList.toggle(i.dropListScroll,!!t.dropListScroll),t.hamburger.always?this._element.classList.add(i.hamburgerAlways):t.breakpoint?!1!==t.breakpoint&&this._element.classList.add("vg-nav-"+t.breakpoint):this._element.classList.add(i.expand),t.hamburger.enable&&!s.A.find("."+i.hamburger,this._element)){const s=t.hamburger.target||"#sidebar-nav";let r="",n='<span class="'+i.hamburger+'--lines"><span></span><span></span><span></span></span>';t.hamburger.title&&(r='<span class="'+i.hamburger+'--title">'+t.hamburger.title+"</span>"),null!==t.hamburger.body&&(n=t.hamburger.body);let a=document.createElement("a");a.classList.add(i.hamburger),e.p.set(a,"data-vg-toggle","sidebar"),e.p.set(a,"href",s),a.innerHTML=r+n,this._element.append(a)}if(t.toggle){let e=[...s.A.findAll(".dropdown > a",this._element)],i='<span class="toggle">'+t.toggle+"</span>";e.length&&e.forEach(function(t){t.querySelector(".toggle")||t.closest(".dots")||(t.setAttribute("aria-expanded","false"),t.insertAdjacentHTML("beforeend",i))})}"afterInit"in this._params.callbacks&&(0,r.g7)(this._params.callbacks.afterInit,[this])}show(t){let e=t.relatedTarget;if(!e||(0,r.d6)(e))return;if(e.closest(".dropdown-content")||e.classList.add("first"),g.A.trigger(e,Es,{relatedTarget:t}).defaultPrevented)return;let i=s.A.find(".dropdown-content",e),n=e.firstElementChild;n&&n.setAttribute("aria-expanded","true"),i.classList.add(fs),e.classList.add(vs);const a=new dt({reference:e,drop:i,placement:"bottom-start",fallbackPlacements:["top-start","bottom-end","top-end"],offset:[0,6],boundary:"clippingParents",autoFlip:!0,overflowProtection:!0});a._setPlacement(),this._openDrops.set(i,{reference:e,placement:a,scrollHandler:this._handleScroll,resizeHandler:this._handleResize}),window.addEventListener("scroll",this._handleScroll,{passive:!0,capture:!0}),window.addEventListener("resize",this._handleResize),this._queueCallback(()=>{i.classList.add(bs),g.A.trigger(e,As,t)},i,!0,10)}hide(t){const e=this;if("ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))g.A.off(t,"mouseover",r.lQ);let i=t.relatedTarget;if("elm"in t&&t.elm&&(i=t.elm),i){if(g.A.trigger(i,ys).defaultPrevented)return;i.classList.remove(vs),i.classList.contains("first")&&i.classList.remove("first"),[...s.A.findAll("."+fs,i)].forEach(function(i,s){i.classList.remove(bs);let r=i.closest(".dropdown");r.classList.contains(vs)&&r.classList.remove(vs);let n=i.previousElementSibling;if(n&&n.setAttribute("aria-expanded","false"),0===s){const s=()=>{i.classList.remove(fs),g.A.trigger(i,ws,t)};e._queueCallback(s,i,!0,500)}const a=e._openDrops.get(i);a&&(window.removeEventListener("scroll",a.scrollHandler,{capture:!0}),window.removeEventListener("resize",a.resizeHandler),e._openDrops.delete(i))})}}_handleScroll(){for(const[t,e]of this._openDrops.entries())if(null!==t.offsetParent){if(e.placement._setPlacement(),!this._isElementInViewport(t)){const t=e.reference;this.hide({relatedTarget:t})}}else this._cleanupDrop(t)}_handleResize(){for(const[t,e]of this._openDrops.entries())null!==t.offsetParent&&e.placement._setPlacement()}_cleanupDrop(t){const e=this._openDrops.get(t);e&&(window.removeEventListener("scroll",e.scrollHandler,{capture:!0}),window.removeEventListener("resize",e.resizeHandler),this._openDrops.delete(t))}_isElementInViewport(t){const e=t.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,r=e.top<=i&&e.top+e.height>=0,n=e.left<=s&&e.left+e.width>=0;return r&&n}_updatePointerPosition(t){t&&"number"==typeof t.clientX&&"number"==typeof t.clientY&&(this._pointerPosition={x:t.clientX,y:t.clientY})}_isHorizontalPointerMove(t){if(!this._pointerPosition||!t)return!1;const e=t.clientX-this._pointerPosition.x,i=t.clientY-this._pointerPosition.y;return Math.abs(e)>Math.abs(i)&&Math.abs(e)>0}_isFirstLevelDropdown(t){return!!t&&!t.closest(".dropdown-content")}_hasDirectDropdownContent(t){return!(!t||!t.children)&&[...t.children].some(t=>t.classList&&t.classList.contains("dropdown-content"))}_isAdjacentDropdown(t,e){return!(!t||!e||t.parentElement!==e.parentElement||t.previousElementSibling!==e&&t.nextElementSibling!==e)}_canSmoothSwitchFirstLevel(t,e,i){const s=this._params.hoversmoothfirstlevel||{};return!(!s.enable||!e||!i||e===i||!this._isFirstLevelDropdown(e)||!this._isFirstLevelDropdown(i)||!this._hasDirectDropdownContent(e)||!this._hasDirectDropdownContent(i)||!this._isAdjacentDropdown(e,i)||s.horizontalOnly&&!this._isHorizontalPointerMove(t))}static init(t,e={}){const i=Is.getOrCreateInstance(t,e);i.build();let n=s.A.findAll(".dropdown",i.navigation);i._params.hover&&!(0,r.Xb)()&&(g.A.on(i.navigation,`mousemove.${gs}.data.api`,function(t){i._updatePointerPosition(t)}),[...n].forEach(function(t){let e=null;g.A.on(t,Ss,function(t){if(e)return;let s=t.target.closest(".dropdown");if(!s)return;if(!i.navigation.contains(s))return;e=s;const r=t.relatedTarget?.closest(".dropdown"),n=i._canSmoothSwitchFirstLevel(t,s,r);n||Is.hideOpenDrops(t);let a={relatedTarget:s};i.show(a),n&&r&&r.classList.contains(vs)&&i.hide({relatedTarget:r}),i._updatePointerPosition(t)}),g.A.on(t,Cs,function(t){if(!e)return;let s=t.relatedTarget?.closest(".dropdown"),r=s,n=e;for(;r;){if(r===e)return;r=r.parentNode}if(i._canSmoothSwitchFirstLevel(t,n,s))return e=null,void i._updatePointerPosition(t);e=null,i.hide({relatedTarget:r,elm:n}),i._updatePointerPosition(t)})}));const a=document.querySelector(i._params.hamburger.target||"#sidebar-nav");let o=i._element.querySelector("."+i._classes.hamburger);a&&o&&(a.addEventListener("vg.sidebar.show",function(){o.classList.add(i._classes.hamburgerActive)}),a.addEventListener("vg.sidebar.hide",function(){o.classList.remove(i._classes.hamburgerActive)}))}static clearDrops(t){2===t.button||"keyup"===t.type&&"Tab"!==t.key||Is.hideOpenDrops(t)}static hideOpenDrops(t){[...s.A.findAll(".dropdown:not(.disabled):not(:disabled).active")].forEach(e=>{let i=t.target;if(e!==i.closest(".dropdown")){const t=e.closest(".vg-nav"),s=Is.getInstance(t);if(!s)return;let r=!!t.querySelector(".first"),n=!!i.closest(".dropdown-content");if(r&&n)return;const a={relatedTarget:e};s.hide(a)}})}}g.A.on(document,Ls,Is.clearDrops),g.A.on(document,xs,Is.clearDrops),g.A.on(document,xs,".vg-nav a",function(t){if(!e.p.has(this,"aria-expanded"))return;let i=this.closest(".vg-nav");const n=Is.getOrCreateInstance(i);if("afterClick"in n._params.callbacks&&(0,r.g7)(n._params.callbacks.afterClick,[n,t,this]),n._params.hover&&!(0,r.Xb)())return;t.preventDefault();let a=this.parentNode;if(!a)return;if((0,r.d6)(a)||!(0,r.zN)(a))return;let o=!!i.querySelector(".first");if(this.closest(".dropdown-content")&&o){if(a.classList.contains("active"))return void n.hide({relatedTarget:a})}else[...s.A.findAll(".active",i)].forEach(function(t){n.hide({relatedTarget:t})});n.show({relatedTarget:a})});const Ps=Is;var Ms=i(546);const ks="nestable",Ds="vg.nestable",Ts='[data-vg-toggle="nestable"]',Os="is-dragging",zs="vg-nestable-placeholder",Ns="vg-nestable-inner",$s="vg-nestable-handle",Hs="vg-nestable-handle-icon",Fs="vg-nestable-collapse-toggle",Rs="vg-nestable-empty",Bs="is-drop-target",js="is-drop-denied",Us="is-drop-before",qs="is-drop-attachable",Vs="is-drop-inside",Ws="is-drop-after",Ks=`${Ds}.start`,Gs=`${Ds}.change`,Ys=`${Ds}.end`,Xs=`${Ds}.save`,Zs=`${Ds}.init`,Js=`${Ds}.refresh`,Qs=`${Ds}.pointerdown`,tr=`${Ds}.move`,er=`${Ds}.drop`,ir=`${Ds}.transfer`,sr=`${Ds}.placeholdermove`,rr=`${Ds}.destroy`,nr=`${Ds}.collapse`,ar=`${Ds}.expand`;class or extends t.A{static _groups=new Map;constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({disabled:!1,disabledattribute:"data-disabled",listselector:".vg-nestable-list",itemselector:".vg-nestable-item",handleselector:".vg-nestable-handle",idattribute:"data-id",serializedata:!0,childlistclass:"vg-nestable-list",handleicon:"",emptytext:"Drop items here",indent:18,maxdepth:6,moveaxis:"default",hoverthreshold:.25,neighborchangethreshold:0,showplaceholder:!0,group:"",connect:!1,accept:null,collapse:{enabled:!0,open:!0,showtext:(0,f.z)("plus"),hidetext:(0,f.z)("minus")},callbacks:{init:null,refresh:null,pointerdown:null,start:null,move:null,placeholdermove:null,drop:null,transfer:null,change:null,collapse:null,expand:null,end:null,save:null,destroy:null},ajax:{route:"",method:"post",field:"items",data:{},loader:!1,once:!1,output:!1,timeout:0}},e)),this._rootList=this._resolveRootList(),this._draggedItem=null,this._placeholder=null,this._dragElement=null,this._dragLayer=null,this._isDragging=!1,this._startSnapshot="",this._sourceInstance=this,this._lastDropInstance=this,this._activeDropList=null,this._activeDropItem=null,this._dragBaseDepth=1,this._mouse={startX:0,startY:0,startItemX:0,grabOffsetX:0,grabOffsetY:0,x:0,y:0},this._previousBodyCursor="",this._boundOnMouseDown=this._onMouseDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._boundOnMouseUp=this._onMouseUp.bind(this),this._boundOnPointerDown=this._onPointerDown.bind(this),this._boundOnPointerMove=this._onPointerMove.bind(this),this._boundOnPointerUp=this._onPointerUp.bind(this),this._boundOnPointerCancel=this._onPointerCancel.bind(this),this._boundOnTouchStart=this._onTouchStart.bind(this),this._boundOnTouchMove=this._onTouchMove.bind(this),this._boundOnTouchEnd=this._onTouchEnd.bind(this),this._boundOnTouchCancel=this._onTouchCancel.bind(this),this._boundOnKeyDown=this._onKeyDown.bind(this),this._supportsPointerEvents="undefined"!=typeof window&&"PointerEvent"in window,this._activePointerId=null,this._activeTouchId=null,this._keyboardDraggedItem=null,this._keyboardStartSnapshot="",this._keyboardOrigin=null,this._liveRegion=null,this._rootList&&(this._registerGroup(),this.refresh(),this._ensureLiveRegion(),this._bindEvents(),this._emit("init",{payload:this.serialize()}))}static get NAME(){return ks}static get NAME_KEY(){return Ds}_getEventKey(t){switch(t){case"init":return Zs;case"refresh":return Js;case"pointerdown":return Qs;case"start":return Ks;case"move":return tr;case"placeholdermove":return sr;case"drop":return er;case"transfer":return ir;case"change":return Gs;case"end":return Ys;case"save":return Xs;case"destroy":return rr;case"collapse":return nr;case"expand":return ar;default:return`${Ds}.${t}`}}_emit(t,e={}){const i={action:t,instance:this,...e};g.A.trigger(this._element,this._getEventKey(t),i);const s=this._params?.callbacks?.[t];if("function"==typeof s)try{s(i)}catch(e){console.error(`[${ks}] callback "${t}" failed`,e)}return i}_getGroupName(){const t=this._params?.group;return null==t?"":String(t).trim()}_registerGroup(){const t=this._getGroupName();t&&(or._groups.has(t)||or._groups.set(t,new Set),or._groups.get(t).add(this))}_unregisterGroup(){const t=this._getGroupName();if(!t||!or._groups.has(t))return;const e=or._groups.get(t);e.delete(this),e.size||or._groups.delete(t)}_getConnectedInstances(){if(!this._params.connect)return[this];const t=this._getGroupName();return t&&or._groups.has(t)?Array.from(or._groups.get(t)).filter(t=>t&&t._rootList):[this]}_findOwnerInstanceByElement(t){return t&&this._getConnectedInstances().find(e=>e._rootList&&e._rootList.contains(t))||null}_canAcceptItem(t,e){if(this._isTreeDisabled())return!1;const i=this._params?.accept;if("function"!=typeof i)return!0;try{return!!i(t,e,this)}catch(t){return console.error(`[${ks}] accept() failed`,t),!1}}refresh(){const t=this._isTreeDisabled();this._element.classList.toggle("is-disabled",t),this._element.setAttribute("aria-disabled",t?"true":"false"),this._getItems().forEach(t=>{const e=this._ensureItemLayout(t),i=this._isItemDragDisabled(t);t.classList.toggle("is-drag-disabled",i),e&&(e.style.cursor=i?"not-allowed":"grab",e.style.userSelect="none",e.style.touchAction="none",e.setAttribute("aria-disabled",i?"true":"false"),["BUTTON","A","INPUT"].includes(e.tagName)||e.setAttribute("role","button"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0"),e.hasAttribute("aria-label")||e.setAttribute("aria-label","Drag item")),this._syncItemCollapse(t)}),this._syncEmptyState(),this._emit("refresh",{items:this._getItems().length})}expandItem(t){return this._setItemExpanded(t,!0)}collapseItem(t){return this._setItemExpanded(t,!1)}expandAll(){let t=0;return this._getItems().forEach(e=>{this.expandItem(e)&&(t+=1)}),t}collapseAll(){let t=0;return this._getItems().forEach(e=>{this.collapseItem(e)&&(t+=1)}),t}_setItemExpanded(t,e){const i="string"==typeof t?this._element.querySelector(t):t;if(!i||!i.matches?.(this._params.itemselector)||!this._rootList.contains(i))return!1;const s=this._getDirectChildBySelector(i,this._params.listselector);if(!s)return!1;if(s.classList.contains("show")===e)return!1;const r=we.getOrCreateInstance(s,{toggle:!1});return e?r.show():r.hide(),this._emit(e?"expand":"collapse",{item:i,list:s,expanded:e}),!0}_syncEmptyState(){if(!this._rootList)return;const t=Array.from(this._rootList.children).some(t=>t.matches(this._params.itemselector));let e=this._getDirectChildBySelector(this._rootList,`.${Rs}`);if(t)return e?.remove(),void this._rootList.classList.remove("is-empty");e||(e=document.createElement("ol"===this._rootList.tagName?.toLowerCase()?"li":"div"),e.className=Rs,e.setAttribute("aria-live","polite"),this._rootList.append(e)),e.textContent=String(this._params.emptytext||"Drop items here"),this._rootList.classList.add("is-empty")}_syncItemCollapse(t){if(!t||!this._params.collapse?.enabled)return;const e=this._getDirectChildBySelector(t,`.${Ns}`),i=e?this._getDirectChildBySelector(e,`.${$s}`):null,s=this._getDirectChildBySelector(t,this._params.listselector);let r=e?this._getDirectChildBySelector(e,`.${Fs}`):null;if(!e||!s)return void(r&&r.remove());s.id||(s.id=`vg-nestable-collapse-${Math.random().toString(36).slice(2,10)}`);const n=s.classList.contains("vg-collapse");s.classList.add("vg-collapse"),n||(this._params.collapse.open?s.classList.add("show"):s.classList.remove("show")),r?i&&r.previousElementSibling!==i&&e.insertBefore(r,i.nextSibling):(r=document.createElement("button"),r.type="button",r.className=Fs,i?e.insertBefore(r,i.nextSibling):e.insertBefore(r,e.firstChild)),r.setAttribute("data-vg-toggle","collapse"),r.setAttribute("data-vg-target",`#${s.id}`),r.setAttribute("aria-controls",s.id);const a=Ms.A.toSafeHtmlString(this._params.collapse.showtext||(0,f.z)("chevron")),o=Ms.A.toSafeHtmlString(this._params.collapse.hidetext||(0,f.z)("chevron"));r.setAttribute("data-show-text",a),r.setAttribute("data-hide-text",o);const l=s.classList.contains("show");r.setAttribute("aria-expanded",l?"true":"false"),r.innerHTML=l?o:a,we.getOrCreateInstance(s,{toggle:!1})}_ensureItemLayout(t){if(!t||!this._params.handleselector)return null;const e=this._ensureInnerLayout(t);let i=this._getDirectChildBySelector(e,this._params.handleselector);if(!i){const e=Array.from(t.querySelectorAll(this._params.handleselector)).find(e=>e.closest(this._params.itemselector)===t);e&&(i=e)}if(!i){if(this._params.handleselector!==`.${$s}`)return null;i=document.createElement("div"),i.classList.add($s)}if(i.parentElement===e&&i===e.firstElementChild||e.insertBefore(i,e.firstChild),!i.querySelector(`:scope > .${Hs}`)){const t=document.createElement("span");t.className=Hs,t.setAttribute("aria-hidden","true"),t.innerHTML=Ms.A.toSafeHtmlString(this._params.handleicon||(0,f.z)("dots-six-vertical")||":::"),i.prepend(t)}return i}_ensureInnerLayout(t){let e=this._getDirectChildBySelector(t,`.${Ns}`);const i=this._getDirectChildBySelector(t,this._params.listselector);return e||(e=document.createElement("div"),e.className=Ns,t.insertBefore(e,i||t.firstChild)),Array.from(t.childNodes).filter(t=>t!==e&&!(t.nodeType===Node.ELEMENT_NODE&&t.matches(this._params.listselector))).forEach(t=>e.append(t)),e.parentElement!==t&&t.insertBefore(e,i||t.firstChild),e}_getDirectChildBySelector(t,e){return t&&e&&Array.from(t.children).find(t=>t.matches(e))||null}serialize(){return this._rootList?this._serializeList(this._rootList):[]}save(){const t=this.serialize(),e=this._params.ajax?.route;return e?(this._emit("save",{payload:t,status:"start"}),new Promise((i,s)=>{const n=this._params.ajax||{},a=n.field||"items",o=String(n.method||"post").toLowerCase(),l=Number(n.timeout||0),h=(0,r._v)(n.data||{},{[a]:t}),d=new ui.A,c={onSuccess:e=>{this._emit("save",{payload:t,status:"success",response:e}),i(e)},onError:e=>{this._emit("save",{payload:t,status:"error",error:e}),s(e)}};setTimeout(()=>{switch(o){case"get":d.get(e,c);break;case"delete":d.delete(e,c);break;default:d.post(e,h,c)}},l)})):(this._emit("save",{payload:t,status:"skipped"}),Promise.resolve(t))}dispose(){this._rootList&&(this._supportsPointerEvents?this._rootList.removeEventListener("pointerdown",this._boundOnPointerDown):(this._rootList.removeEventListener("mousedown",this._boundOnMouseDown),this._rootList.removeEventListener("touchstart",this._boundOnTouchStart)),this._rootList.removeEventListener("keydown",this._boundOnKeyDown)),document.removeEventListener("mousemove",this._boundOnMouseMove),document.removeEventListener("mouseup",this._boundOnMouseUp),document.removeEventListener("pointermove",this._boundOnPointerMove),document.removeEventListener("pointerup",this._boundOnPointerUp),document.removeEventListener("pointercancel",this._boundOnPointerCancel),document.removeEventListener("touchmove",this._boundOnTouchMove),document.removeEventListener("touchend",this._boundOnTouchEnd),document.removeEventListener("touchcancel",this._boundOnTouchCancel),this._clearDragState(),this._clearKeyboardDragState(),this._liveRegion?.parentElement&&this._liveRegion.remove(),this._liveRegion=null,this._unregisterGroup(),this._emit("destroy"),super.dispose()}_bindEvents(){this._rootList.addEventListener("keydown",this._boundOnKeyDown),this._supportsPointerEvents?this._rootList.addEventListener("pointerdown",this._boundOnPointerDown):(this._rootList.addEventListener("mousedown",this._boundOnMouseDown),this._rootList.addEventListener("touchstart",this._boundOnTouchStart,{passive:!1}))}_resolveRootList(){return this._element?this._element.matches(this._params.listselector)?this._element:this._element.querySelector(this._params.listselector):null}_getItems(t=this._rootList){return t?Array.from(t.querySelectorAll(this._params.itemselector)):[]}_onMouseDown(t){0===t.button&&(this._startInteraction(t.target,t.clientX,t.clientY,t),this._draggedItem&&(document.addEventListener("mousemove",this._boundOnMouseMove),document.addEventListener("mouseup",this._boundOnMouseUp)))}_onMouseMove(t){this._processDragMove(t.clientX,t.clientY,t)}_onMouseUp(){document.removeEventListener("mousemove",this._boundOnMouseMove),document.removeEventListener("mouseup",this._boundOnMouseUp),this._finishDrag()}_onPointerDown(t){"mouse"===t.pointerType&&0!==t.button||(this._startInteraction(t.target,t.clientX,t.clientY,t),this._draggedItem&&(this._activePointerId=t.pointerId,document.addEventListener("pointermove",this._boundOnPointerMove),document.addEventListener("pointerup",this._boundOnPointerUp),document.addEventListener("pointercancel",this._boundOnPointerCancel)))}_onPointerMove(t){this._draggedItem&&t.pointerId===this._activePointerId&&this._processDragMove(t.clientX,t.clientY,t)}_onPointerUp(t){t.pointerId===this._activePointerId&&(this._activePointerId=null,document.removeEventListener("pointermove",this._boundOnPointerMove),document.removeEventListener("pointerup",this._boundOnPointerUp),document.removeEventListener("pointercancel",this._boundOnPointerCancel),this._finishDrag())}_onPointerCancel(t){t.pointerId===this._activePointerId&&(this._activePointerId=null,document.removeEventListener("pointermove",this._boundOnPointerMove),document.removeEventListener("pointerup",this._boundOnPointerUp),document.removeEventListener("pointercancel",this._boundOnPointerCancel),this._cancelDrag())}_onTouchStart(t){if(null!==this._activeTouchId||!t.changedTouches?.length)return;const e=t.changedTouches[0];this._startInteraction(e.target,e.clientX,e.clientY,t),this._draggedItem&&(this._activeTouchId=e.identifier,document.addEventListener("touchmove",this._boundOnTouchMove,{passive:!1}),document.addEventListener("touchend",this._boundOnTouchEnd),document.addEventListener("touchcancel",this._boundOnTouchCancel))}_onTouchMove(t){if(!this._draggedItem||null===this._activeTouchId)return;const e=this._findTouchById(t.changedTouches,this._activeTouchId)||this._findTouchById(t.touches,this._activeTouchId);e&&this._processDragMove(e.clientX,e.clientY,t)}_onTouchEnd(t){null!==this._activeTouchId&&this._findTouchById(t.changedTouches,this._activeTouchId)&&(this._activeTouchId=null,document.removeEventListener("touchmove",this._boundOnTouchMove),document.removeEventListener("touchend",this._boundOnTouchEnd),document.removeEventListener("touchcancel",this._boundOnTouchCancel),this._finishDrag())}_onTouchCancel(){null!==this._activeTouchId&&(this._activeTouchId=null,document.removeEventListener("touchmove",this._boundOnTouchMove),document.removeEventListener("touchend",this._boundOnTouchEnd),document.removeEventListener("touchcancel",this._boundOnTouchCancel),this._cancelDrag())}_onKeyDown(t){if(this._isDragging||this._draggedItem)return;const e=t.target?.closest?.(this._params.itemselector);if(!e||!this._rootList.contains(e))return;const i=t.key,s=" "===i||"Enter"===i;if(s&&!this._keyboardDraggedItem){if(!this._isKeyboardDragHandle(t.target,e))return;return t.preventDefault(),void this._startKeyboardDrag(e)}if(!this._keyboardDraggedItem)return;if(e!==this._keyboardDraggedItem&&!this._keyboardDraggedItem.contains(e))return;if(s)return t.preventDefault(),void this._finishKeyboardDrag();if("Escape"===i)return t.preventDefault(),void this._finishKeyboardDrag({cancelled:!0});let r=!1,n="";const a=this._getMoveAxis(),o="horizontal"!==a,l="vertical"!==a;if("ArrowUp"===i){if(!o)return;t.preventDefault(),r=this._moveKeyboardUp(this._keyboardDraggedItem),n="Moved up."}else if("ArrowDown"===i){if(!o)return;t.preventDefault(),r=this._moveKeyboardDown(this._keyboardDraggedItem),n="Moved down."}else if("ArrowRight"===i){if(!l)return;t.preventDefault(),r=this._indentKeyboard(this._keyboardDraggedItem),n="Nested into previous item."}else if("ArrowLeft"===i){if(!l)return;t.preventDefault(),r=this._outdentKeyboard(this._keyboardDraggedItem),n="Moved out one level."}r&&(this._cleanupEmptyLists(),this.refresh(),this._keyboardDraggedItem.focus?.(),this._emit("move",{item:this._keyboardDraggedItem,targetInstance:this,keyboard:!0,mouse:null}),n&&this._announce(n))}_isKeyboardDragHandle(t,e){if(!t||!e)return!1;const i=this._params.handleselector;if(!i)return!0;const s=t.closest(i);return!(!s||!e.contains(s))}_startKeyboardDrag(t){!t||this._keyboardDraggedItem||this._isItemDragDisabled(t)?t&&this._isItemDragDisabled(t)&&this._announce("This item cannot be moved."):(this._keyboardDraggedItem=t,this._keyboardStartSnapshot=JSON.stringify(this.serialize()),this._keyboardOrigin={parent:t.parentElement,next:t.nextSibling},t.classList.add(Os),t.setAttribute("aria-grabbed","true"),this._emit("start",{item:t,payload:this.serialize(),keyboard:!0}),this._announce(this._getKeyboardDragInstructions()))}_finishKeyboardDrag(t={}){if(!this._keyboardDraggedItem)return;const e=this._keyboardDraggedItem,i=this._keyboardStartSnapshot?JSON.parse(this._keyboardStartSnapshot):[];if(t.cancelled&&this._keyboardOrigin?.parent){const{parent:t,next:i}=this._keyboardOrigin;t.insertBefore(e,i?.parentElement===t?i:null),this._cleanupEmptyLists(),this.refresh(),e.focus?.()}const s=this.serialize(),r=this._keyboardStartSnapshot!==JSON.stringify(s);this._emit("drop",{item:e,payload:s,previousPayload:i,changed:r,targetInstance:this,keyboard:!0,cancelled:!!t.cancelled}),r&&this._emit("change",{payload:s,previousPayload:i,keyboard:!0}),this._emit("end",{payload:s,changed:r,keyboard:!0,cancelled:!!t.cancelled}),t.cancelled?this._announce("Move cancelled."):r?this._announce("Item dropped."):this._announce("Item position unchanged."),r&&this._params.ajax?.route&&this.save(),this._clearKeyboardDragState()}_clearKeyboardDragState(){this._keyboardDraggedItem&&(this._keyboardDraggedItem.classList.remove(Os),this._keyboardDraggedItem.removeAttribute("aria-grabbed")),this._keyboardDraggedItem=null,this._keyboardStartSnapshot="",this._keyboardOrigin=null}_moveKeyboardUp(t){const e=this._getPreviousItem(t);return e?(t.parentElement.insertBefore(t,e),!0):(this._announce("Cannot move up."),!1)}_moveKeyboardDown(t){const e=this._getNextItem(t);return e?(t.parentElement.insertBefore(t,e.nextSibling),!0):(this._announce("Cannot move down."),!1)}_indentKeyboard(t){const e=this._getPreviousItem(t);if(!e||e===t||t.contains(e))return this._announce("Cannot nest here."),!1;const i=this._getOrCreateChildList(e);return this._isListDisabled(i)?(this._announce("This group cannot be changed."),!1):this._isDepthExceeded(i,t)?(this._announce("Maximum nesting depth reached."),!1):(i.append(t),!0)}_outdentKeyboard(t){const e=t.parentElement,i=e?.closest(this._params.itemselector);if(!i)return this._announce("Cannot move left."),!1;const s=i.parentElement;return s?(s.insertBefore(t,i.nextSibling),!0):(this._announce("Cannot move left."),!1)}_getMoveAxis(t=this._params){const e=String(t?.moveaxis||"default").trim().toLowerCase();return"vertical"===e||"horizontal"===e?e:"default"}_getKeyboardDragInstructions(){const t=this._getMoveAxis();return"vertical"===t?"Picked up item. Use Up/Down arrows to move, Enter or Space to drop, Escape to cancel.":"horizontal"===t?"Picked up item. Use Left/Right arrows to move, Enter or Space to drop, Escape to cancel.":"Picked up item. Use arrow keys to move, Enter or Space to drop, Escape to cancel."}_startInteraction(t,e,i,s){this._keyboardDraggedItem&&this._clearKeyboardDragState();const r=t?.closest?.(this._params.itemselector);if(!r||!this._rootList.contains(r))return;if(this._isItemDragDisabled(r))return;const n=this._params.handleselector;if(n){const e=t.closest(n);if(!e||!r.contains(e))return}s.preventDefault();const a=r.getBoundingClientRect();this._draggedItem=r,this._mouse.startX=e,this._mouse.startY=i,this._mouse.startItemX=a.left,this._mouse.grabOffsetX=e-a.left,this._mouse.grabOffsetY=i-a.top,this._mouse.x=e,this._mouse.y=i,this._isDragging=!1,this._startSnapshot="",this._emit("pointerdown",{item:this._draggedItem,mouse:{x:this._mouse.x,y:this._mouse.y}})}_processDragMove(t,e,i){if(!this._draggedItem)return;if(this._mouse.x=t,this._mouse.y=e,!this._isDragging){const t=Math.abs(this._mouse.x-this._mouse.startX),e=Math.abs(this._mouse.y-this._mouse.startY);if(t<3&&e<3)return;this._startDrag()}i.preventDefault(),this._moveDragElement(this._mouse.x,this._mouse.y);const s=this._getPointerTarget(this._mouse.x,this._mouse.y);if(!s)return this._setDropListState(null),void this._setDropItemState(null);const r=s.closest(`.${zs}`);if(r){const t=this._findOwnerInstanceByElement(r)||this._currentTargetInstance||this;return void this._tryIndentFromPlaceholder(this._mouse.x,t)}const n=this._findOwnerInstanceByElement(s)||this,a=s.closest(n._params.itemselector),o=this._resolveDropList(s,a,n);if(!o||!n._rootList.contains(o))return this._setDropListState(null),void this._setDropItemState(null);const l=this._resolveMode(this._mouse.x,this._mouse.y,a,n._params);if(n._isListDisabled(o))return this._setDropListState(o,!0),void this._setDropItemState(a,l,!0);if(!n._canAcceptItem(this._draggedItem,this._sourceInstance))return this._setDropListState(o,!0),void this._setDropItemState(a,l,!0);if(this._setDropItemState(a,l),this._emit("move",{item:this._draggedItem,hoveredItem:a,mode:l,targetInstance:n,mouse:{x:this._mouse.x,y:this._mouse.y}}),"keep"!==l){if("child"===l){let t=null;if(a){if(a===this._draggedItem||this._draggedItem.contains(a))return void this._setDropListState(null);t=a}else if(this._placePlaceholderWhenExplicitlyNeeded(o,this._mouse.y,n),this._placeholder?.parentElement)for(t=n._getPreviousItem(this._placeholder);t&&(t===this._draggedItem||this._draggedItem.contains(t));)t=n._getPreviousItem(t);if(!t)return this._setDropListState(null),void this._setDropItemState(null);const e=n._getOrCreateChildList(t);return n._isDepthExceeded(e,this._draggedItem)?(this._setDropListState(e,!0),void this._setDropItemState(t,l,!0)):(this._placePlaceholder(e,null),this._setDropListState(e),this._currentTargetInstance=n,void(this._lastDropInstance=n))}if(a){if(a===this._draggedItem||this._draggedItem.contains(a))return this._setDropListState(null),void this._setDropItemState(null);const t=a.parentElement;return n._isDepthExceeded(t,this._draggedItem)?(this._setDropListState(t,!0),void this._setDropItemState(a,l,!0)):("before"===l?this._placePlaceholder(t,a):this._placePlaceholder(t,a.nextSibling),this._setDropListState(t),this._currentTargetInstance=n,void(this._lastDropInstance=n))}this._placePlaceholderWhenExplicitlyNeeded(o,this._mouse.y,n),this._setDropListState(o),this._currentTargetInstance=n,this._lastDropInstance=n}else this._setDropListState(o)}_finishDrag(){if(!this._draggedItem)return;const t=this._draggedItem,e=this._isDragging,i=this._lastDropInstance||this,s=this._startSnapshot?JSON.parse(this._startSnapshot):[];let r=this.serialize(),n=i.serialize(),a=!1;if(e){const e=this._placeholder?.parentElement||null;e&&e.insertBefore(t,this._placeholder),t.style.display="",this._cleanupEmptyLists(),i!==this&&i._cleanupEmptyLists(),this.refresh(),i!==this&&i.refresh(),r=this.serialize(),n=i.serialize(),a=this._startSnapshot!==JSON.stringify(r)||i!==this}const o=r;this._emit("drop",{item:t,payload:o,previousPayload:s,changed:a,targetInstance:i}),a&&i!==this&&(this._emit("transfer",{item:t,from:this,to:i,sourcePayload:r,targetPayload:n}),i._emit("transfer",{item:t,from:this,to:i,sourcePayload:r,targetPayload:n}),i._emit("change",{payload:n,previousPayload:[]})),this._clearDragState(),a&&this._emit("change",{payload:o,previousPayload:s}),e&&this._emit("end",{payload:o,changed:a}),a&&(this._params.ajax?.route&&this.save(),i!==this&&i._params.ajax?.route&&i.save())}_cancelDrag(){if(!this._draggedItem)return;const t=this._isDragging;this._clearDragState(),t&&this._emit("end",{payload:this.serialize(),changed:!1,cancelled:!0})}_findTouchById(t,e){if(!t||null==e)return null;for(let i=0;i<t.length;i+=1)if(t[i].identifier===e)return t[i];return null}_startDrag(){this._draggedItem&&!this._isDragging&&(this._isDragging=!0,this._startSnapshot=JSON.stringify(this.serialize()),this._sourceInstance=this,this._sourceRoot=this._rootList,this._dragBaseDepth=this._getListDepth(this._draggedItem.parentElement),this._currentTargetInstance=this,this._lastDropInstance=this,this._placeholder=this._createPlaceholder(this._draggedItem),this._params.showplaceholder||this._placeholder.classList.add("vg-nestable-placeholder-hidden"),this._draggedItem.parentElement.insertBefore(this._placeholder,this._draggedItem.nextSibling),this._dragElement=this._createDragElement(this._draggedItem),this._dragLayer=document.createElement("div"),this._dragLayer.classList.add("vg-nestable-drag-layer"),this._element?.classList&&this._element.classList.forEach(t=>this._dragLayer.classList.add(t)),this._dragLayer.style.position="fixed",this._dragLayer.style.left="0",this._dragLayer.style.top="0",this._dragLayer.style.width="0",this._dragLayer.style.height="0",this._dragLayer.style.pointerEvents="none",this._dragLayer.style.zIndex="99999",document.body.append(this._dragLayer),this._dragLayer.append(this._dragElement),"undefined"!=typeof document&&document.body&&(this._previousBodyCursor=document.body.style.cursor||"",document.body.style.cursor="grabbing"),this._moveDragElement(this._mouse.x,this._mouse.y),this._draggedItem.classList.add(Os),this._draggedItem.style.display="none",this._draggedItem.setAttribute("aria-grabbed","true"),this._emit("start",{item:this._draggedItem,payload:this.serialize()}))}_createDragElement(t){const e=t.getBoundingClientRect(),i=t.cloneNode(!0);return i.classList.add("is-drag-ghost","vg-nestable-drag-element"),i.style.position="fixed",i.style.left=`${e.left}px`,i.style.top=`${e.top}px`,i.style.width=`${e.width}px`,i.style.zIndex="99999",i.style.pointerEvents="none",i.style.margin="0",i}_moveDragElement(t,e){if(!this._dragElement)return;const i=t-(Number(this._mouse.grabOffsetX)||0),s=e-(Number(this._mouse.grabOffsetY)||0);this._dragElement.style.left=`${i}px`,this._dragElement.style.top=`${s}px`}_getPointerTarget(t,e){const i=document.elementFromPoint(t,e);return i&&this._findOwnerInstanceByElement(i)?i:null}_resolveDropList(t,e,i=this){if(e)return e.parentElement;const s=t.closest(i._params.listselector);return s&&i._rootList.contains(s)?s:i._rootList}_resolveMode(t,e,i,s=this._params){if(!i)return"append";const r=this._getItemDropRect(i),n=e-r.top,a=t-r.left,o=parseFloat(s.indent),l=Number.isFinite(o)?o:0,h=Math.max(0,Number(this._mouse.grabOffsetX)||0)+l,d=this._getMoveAxis(s),c="horizontal"!==d,_="vertical"!==d,u=Math.max(0,Math.min(49,Number(s.neighborchangethreshold||0)));if(u>0){const t=u/100,e=r.height*t,i=r.height*(1-t);return _&&a>h&&n>e&&n<i?"child":c&&n<=e?"before":c&&n>=i?"after":"keep"}const m=Math.min(.45,Math.max(.05,Number(s.hoverthreshold||.25)));return _&&a>h&&n>=r.height*(.5-m)&&n<=r.height*(.5+m)?"child":c&&n<r.height*(.5-m)?"before":c&&n>r.height*(.5+m)?"after":"keep"}_getItemDropRect(t){const e=t?.querySelector?.(`:scope > .${Ns}`);return(e||t).getBoundingClientRect()}_tryIndentFromPlaceholder(t,e=this){if(!this._placeholder||"vertical"===this._getMoveAxis(e._params))return!1;if(!e._canAcceptItem(this._draggedItem,this._sourceInstance)||e._isListDisabled(this._placeholder.parentElement))return this._setDropListState(this._placeholder.parentElement,!0),this._setDropItemState(null),!1;const i=parseFloat(e._params.indent),s=Number.isFinite(i)?Math.max(1,i):18,r=Math.max(0,t-this._mouse.startX),n=this._dragBaseDepth+Math.floor(r/s);let a=this._placeholder.parentElement,o=e._getListDepth(a),l=null;for(;o>n;){const t=a.closest(e._params.itemselector),i=t?.parentElement;if(!t||!i)break;this._placePlaceholder(i,t.nextSibling),a=i,o=e._getListDepth(a)}for(;o<n;){for(l=e._getPreviousItem(this._placeholder);l&&(l===this._draggedItem||this._draggedItem.contains(l));)l=e._getPreviousItem(l);if(!l)break;const t=e._getOrCreateChildList(l);if(e._isListDisabled(t))return this._setDropListState(t,!0),this._setDropItemState(l,"child",!0),!1;if(e._isDepthExceeded(t,this._draggedItem))return this._setDropListState(t,!0),this._setDropItemState(l,"child",!0),!1;this._placePlaceholder(t,null),a=t,o=e._getListDepth(a)}const h=a.closest(e._params.itemselector),d=e._getPreviousItem(this._placeholder),c=r%s/s;return d&&d!==this._draggedItem&&c>=.35?(this._setDropItemState(d,"attachable"),l=d):h?(this._setDropItemState(h,"child"),l=h):d&&d!==this._draggedItem?(this._setDropItemState(d,"attachable"),l=d):this._setDropItemState(null),this._setDropListState(a),this._currentTargetInstance=e,this._lastDropInstance=e,this._emit("move",{item:this._draggedItem,hoveredItem:l,mode:o>this._dragBaseDepth?"child":"keep",targetInstance:e,mouse:{x:this._mouse.x,y:this._mouse.y}}),o>this._dragBaseDepth}_hasDisabledAttribute(t){if(!t||!this._params.disabledattribute)return!1;const e=t.getAttribute(this._params.disabledattribute);return null!==e&&!0===(0,r.OM)(""===e?"true":e)}_isTreeDisabled(){return!0===(0,r.OM)(this._params.disabled)||this._hasDisabledAttribute(this._element)}_isListDisabled(t){if(this._isTreeDisabled())return!0;let e=t;for(;e&&this._rootList.contains(e);){if(e.matches(this._params.listselector)&&this._hasDisabledAttribute(e))return!0;if(e===this._rootList)break;e=e.parentElement?.closest(this._params.listselector)||null}return!1}_isItemDragDisabled(t){return this._isTreeDisabled()||this._hasDisabledAttribute(t)||this._isListDisabled(t?.parentElement)}_getPreviousItem(t){let e=t?.previousElementSibling||null;for(;e&&!e.matches(this._params.itemselector);)e=e.previousElementSibling;return e}_getNextItem(t){let e=t?.nextElementSibling||null;for(;e&&!e.matches(this._params.itemselector);)e=e.nextElementSibling;return e}_getOrCreateChildList(t){let e=t.querySelector(`:scope > ${this._params.listselector}`);return e||(e=document.createElement(this._rootList.tagName||"ol"),this._params.childlistclass&&this._params.childlistclass.split(" ").filter(Boolean).forEach(t=>e.classList.add(t)),t.append(e),e)}_isDepthExceeded(t,e=this._draggedItem){const i=this._getListDepth(t),s=Number(this._params.maxdepth||1);return i+this._getItemSubtreeDepth(e)-1>s}_getListDepth(t){if(!t)return 1;let e=1,i=t;for(;i&&i!==this._rootList;){const t=i.closest(this._params.itemselector);if(!t)break;e+=1,i=t.parentElement?.closest(this._params.listselector)}return e}_getItemSubtreeDepth(t){if(!t)return 1;const e=this._getDirectChildBySelector(t,this._params.listselector);if(!e)return 1;const i=Array.from(e.children).filter(t=>t.matches(this._params.itemselector));return i.length?i.reduce((t,e)=>Math.max(t,this._getItemSubtreeDepth(e)),1)+1:1}_cleanupEmptyLists(){this._rootList&&Array.from(this._rootList.querySelectorAll(this._params.listselector)).forEach(t=>{t!==this._rootList&&(Array.from(t.children).some(t=>t.matches(this._params.itemselector))||t.remove())})}_createPlaceholder(t){const e=t.tagName&&"li"===t.tagName.toLowerCase()?"li":"div",i=document.createElement(e);return i.className=zs,i.style.height=`${Math.max(t.getBoundingClientRect().height,24)}px`,i.setAttribute("aria-hidden","true"),i}_placePlaceholder(t,e=null){if(!t||!this._placeholder)return;if(e===this._placeholder)return;const i=this._placeholder.parentElement,s=this._placeholder.nextSibling;i===t&&s===e||(t.insertBefore(this._placeholder,e),this._emit("placeholdermove",{parent:t,beforeNode:e,item:this._draggedItem}))}_placePlaceholderWhenExplicitlyNeeded(t,e,i=this){if(!t||i._isDepthExceeded(t,this._draggedItem))return;const s=Array.from(t.children).filter(t=>t.matches(this._params.itemselector));if(!s.length)return void this._placePlaceholder(t,null);const r=s[0],n=s[s.length-1],a=r.getBoundingClientRect(),o=n.getBoundingClientRect();e<=a.top+8?this._placePlaceholder(t,r):e>=o.bottom-8&&this._placePlaceholder(t,null)}_setDropListState(t,e=!1){this._activeDropList&&this._activeDropList!==t&&this._activeDropList.classList.remove(Bs,js),t?(t.classList.add(e?js:Bs),t.classList.remove(e?Bs:js),this._activeDropList=t):this._activeDropList=null}_setDropItemState(t,e="",i=!1){const s=[Us,qs,Vs,Ws,js];if(this._activeDropItem&&this._activeDropItem!==t&&this._activeDropItem.classList.remove(...s),!t||!["before","attachable","child","after"].includes(e))return this._activeDropItem&&this._activeDropItem.classList.remove(...s),void(this._activeDropItem=null);t.classList.remove(...s);const r={before:Us,attachable:qs,child:Vs,after:Ws};t.classList.add(r[e]),i&&t.classList.add(js),this._activeDropItem=t}_clearDragState(){this._setDropListState(null),this._setDropItemState(null),this._draggedItem&&(this._draggedItem.classList.remove(Os),this._draggedItem.style.display="",this._draggedItem.removeAttribute("aria-grabbed")),this._dragElement&&this._dragElement.parentElement&&this._dragElement.remove(),this._dragLayer&&this._dragLayer.parentElement&&this._dragLayer.remove(),"undefined"!=typeof document&&document.body&&(document.body.style.cursor=this._previousBodyCursor||""),this._placeholder&&this._placeholder.parentElement&&this._placeholder.remove(),this._draggedItem=null,this._placeholder=null,this._dragElement=null,this._dragLayer=null,this._previousBodyCursor="",this._isDragging=!1,this._currentTargetInstance=this,this._lastDropInstance=this,this._activePointerId=null,this._activeTouchId=null,this._dragBaseDepth=1}_ensureLiveRegion(){if(!this._element||this._liveRegion)return;const t=document.createElement("div");t.className="vg-nestable-live",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.position="absolute",t.style.width="1px",t.style.height="1px",t.style.margin="-1px",t.style.border="0",t.style.padding="0",t.style.clip="rect(0 0 0 0)",t.style.clipPath="inset(50%)",t.style.overflow="hidden",t.style.whiteSpace="nowrap",this._element.append(t),this._liveRegion=t}_announce(t){t&&(this._ensureLiveRegion(),this._liveRegion&&(this._liveRegion.textContent="",requestAnimationFrame(()=>{this._liveRegion&&(this._liveRegion.textContent=t)})))}_serializeList(t){return Array.from(t.children).filter(t=>t.matches(this._params.itemselector)).map(t=>{const e=(0,r.OM)(t.getAttribute(this._params.idattribute)),i=t.querySelector(`:scope > ${this._params.listselector}`),s={id:e??null};if(!1!==(0,r.OM)(this._params.serializedata)&&Array.from(t.attributes).forEach(t=>{if(!t.name.startsWith("data-")||t.name===this._params.idattribute)return;const e=t.name.slice(5).replace(/-([a-z])/g,(t,e)=>e.toUpperCase());s[e]=(0,r.OM)(""===t.value?"true":t.value)}),i){const t=this._serializeList(i);t.length&&(s.children=t)}return s})}}g.A.on(document,`DOMContentLoaded.${Ds}.data.api`,()=>{s.A.findAll(Ts).forEach(t=>or.getOrCreateInstance(t))}),g.A.on(document,`click.${Ds}.data.api`,"[data-vg-nestable-action]",function(t){t.preventDefault();const e=this.getAttribute("data-vg-target"),i=e?s.A.find(e):this.closest(Ts);if(!i)return;const r=or.getOrCreateInstance(i),n=String(this.getAttribute("data-vg-nestable-action")||"").trim();["expandAll","collapseAll"].includes(n)&&r[n]()});const lr=or,hr="is-status-success",dr="is-status-warning",cr="is-status-danger",_r=[hr,dr,cr],ur=(t,e,i)=>{const s=i.max-i.min,r=s>0?(t-i.min)/s*100:0,n=Number(e?.status?.warningBelow),a=Number(e?.status?.dangerBelow),o=Number.isFinite(n)?n:60;return r<(Number.isFinite(a)?a:30)?"danger":r<o?"warning":"success"},mr=(t,e,i)=>{const s=((t,e,i)=>{if(!i.isRange)return e.from;const s="string"==typeof t?.status?.by?t.status.by.toLowerCase():"to";return"from"===s?e.from:"avg"===s?(e.from+e.to)/2:e.to})(t,e,i);return ur(s,t,e)},pr=(t,e)=>{t.classList.remove(..._r),"danger"!==e?"warning"!==e?t.classList.add(hr):t.classList.add(dr):t.classList.add(cr)},gr=(t,e)=>!Array.isArray(t?.labelWords)||t.labelWords.length<3?null:"danger"===e?t.labelWords[0]||null:"warning"===e?t.labelWords[1]||null:t.labelWords[2]||null,fr="vg.rangeslider",br="vg-range-slider",vr="is-hidden",yr=`${fr}.init`,wr=`${fr}.input`,Er=`${fr}.change`,Ar=`${fr}.update`,Sr={range:!1,min:0,max:100,step:1,start:null,connect:!0,tooltips:!0,labels:!0,separator:" - ",suffix:"",prefix:"",labelWords:null,skin:"default",ruler:{count:6,labels:!0,values:null,dimInactive:!1},status:{warningBelow:60,dangerBelow:30,by:"to"},name:{min:"",max:""},input:{min:null,max:null},output:{target:null,min:null,max:null},disabled:!1,onInit:null,onInput:null,onChange:null,onUpdate:null,formatValue:null};class Cr extends t.A{constructor(t,e={}){super(t,e),this._sourceInput=this._element.matches('input[type="range"]')?this._element:null,this._params=this._buildParams(e),this._isRange=this._resolveRangeMode(),this._listeners=[],this._handleResize=()=>this._syncUI(),this._dom={root:null,wrapper:null,fill:null,inputFrom:null,inputTo:null,tooltipFrom:null,tooltipTo:null,tooltipMerged:null,labelFrom:null,labelTo:null,labelSeparator:null,hiddenMin:null,hiddenMax:null,skin:null},this._state=this._buildState(),this._render(),this._bindEvents(),this._syncUI(),this._setDisabledState(this._params.disabled),this._emit(yr,"onInit")}static get NAME(){return"rangeslider"}static get NAME_KEY(){return fr}static init(t,e={}){return this.getOrCreateInstance(t,e)}getValue(){return this._isRange?[this._state.from,this._state.to]:this._state.from}setValue(t,e={}){const{silent:i=!1,emit:s="update"}=e;if(this._isRange){const e=Array.isArray(t)?t:[t,this._state.to],i=this._normalizeValue(e[0],this._state.min),s=this._normalizeValue(e[1],this._state.max);this._state.from=Math.min(i,s),this._state.to=Math.max(i,s)}else this._state.from=this._normalizeValue(t,this._state.min);this._syncUI(),i||this._emit("change"===s?Er:Ar,"change"===s?"onChange":"onUpdate")}enable(){this._setDisabledState(!1)}disable(){this._setDisabledState(!0)}dispose(){this._listeners.forEach(({element:t,type:e,handler:i})=>t.removeEventListener(e,i)),this._listeners=[],window.removeEventListener("resize",this._handleResize),super.dispose()}_buildParams(t){const e=this._getParams(this._element,(0,r._v)(Sr,t));return this._sourceInput&&(e.min=""!==this._sourceInput.min?(0,r.OM)(this._sourceInput.min):e.min,e.max=""!==this._sourceInput.max?(0,r.OM)(this._sourceInput.max):e.max,e.step=""!==this._sourceInput.step?(0,r.OM)(this._sourceInput.step):e.step,e.start=""!==this._sourceInput.value?(0,r.OM)(this._sourceInput.value):e.start,e.name=this._sourceInput.name||e.name,e.disabled=this._sourceInput.disabled||e.disabled),"string"==typeof e.name&&(e.name={min:e.name,max:e.name}),e.input&&"object"==typeof e.input||(e.input={min:null,max:null}),"string"==typeof e.output?e.output={target:e.output,min:null,max:null}:e.output&&"object"==typeof e.output?Object.prototype.hasOwnProperty.call(e.output,"target")||(e.output.target=null):e.output={target:null,min:null,max:null},!e.labelWords&&e.label&&"object"==typeof e.label&&Object.prototype.hasOwnProperty.call(e.label,"words")&&(e.labelWords=e.label.words),"string"==typeof e.labelWords?e.labelWords=e.labelWords.split(",").map(t=>t.trim()).filter(Boolean):Array.isArray(e.labelWords)||(e.labelWords=null),e}_buildState(){const t=Number((0,r.OM)(this._params.min)),e=Math.max(Number((0,r.OM)(this._params.max)),t),i=Number((0,r.OM)(this._params.step))||1,s=this._resolveStartValues(t,e);return{min:t,max:e>=t?e:t,step:i>0?i:1,from:s.from,to:s.to}}_resolveRangeMode(){return!this._sourceInput&&!0===(0,r.OM)(this._params.range)}_resolveStartValues(t,e){let i=t,s=e;if(this._isRange){const r=Array.isArray(this._params.start)?this._params.start:[this._params.from,this._params.to];i=this._normalizeValue(r[0],t,t,e),s=this._normalizeValue(r[1],e,t,e),i>s&&([i,s]=[s,i])}else{const r=this._params.start??this._params.value??t;i=this._normalizeValue(r,t,t,e),s=i}return{from:i,to:s}}_render(){const t=this._sourceInput?this._renderFromInput():this._renderFromContainer();this._dom.root=t,this._dom.wrapper=s.A.find(".vg-range-slider__wrapper",t),this._dom.fill=s.A.find(".vg-range-slider__fill",t),this._dom.inputFrom=s.A.find(".vg-range-slider__input--from",t),this._dom.inputTo=s.A.find(".vg-range-slider__input--to",t),this._dom.tooltipFrom=s.A.find(".vg-range-slider__tooltip--from",t),this._dom.tooltipTo=s.A.find(".vg-range-slider__tooltip--to",t),this._dom.tooltipMerged=s.A.find(".vg-range-slider__tooltip--merged",t),this._dom.labelFrom=s.A.find(".vg-range-slider__label--from",t),this._dom.labelTo=s.A.find(".vg-range-slider__label--to",t),this._dom.labelSeparator=s.A.find(".vg-range-slider__separator",t),this._dom.hiddenMin=t.querySelector('input[data-vgrangeslider-hidden="min"]'),this._dom.hiddenMax=t.querySelector('input[data-vgrangeslider-hidden="max"]'),this._dom.skin=((t,e,i,s)=>(t.classList.add("is-skin-default"),"ruler"===e.skin?(t.classList.add("is-skin-ruler"),((t,e,i,s,r)=>{const n=((t,e)=>{if(Array.isArray(t?.ruler?.values)&&t.ruler.values.length>0)return t.ruler.values.map(t=>Number(t)).filter(t=>Number.isFinite(t)).sort((t,e)=>t-e);const i=Math.max(2,Number(t?.ruler?.count)||6),s=(e.max-e.min)/(i-1),r=[];for(let t=0;t<i;t++){const n=t===i-1?e.max:e.min+s*t;r.push(Number(n.toFixed(5)))}return r})(e,i),a=document.createElement("div");a.className="vg-range-slider__ruler",!0===e?.ruler?.dimInactive&&t.classList.add("is-ruler-dim-inactive");const o=n.map(t=>{const i=document.createElement("span");i.className="vg-range-slider__ruler-item",i.style.left=`${r(t)}px`,i.dataset.value=String(t);const n=document.createElement("span");if(n.className="vg-range-slider__ruler-mark",i.appendChild(n),!1!==e?.ruler?.labels){const e=document.createElement("span");e.className="vg-range-slider__ruler-label",e.textContent=s(t),i.appendChild(e)}return a.appendChild(i),i});return t.appendChild(a),{type:"ruler",root:a,ticks:o,values:n}})(t,e,i,s.formatValue,s.toPositionPx)):"status"===e.skin?(t.classList.add("is-skin-status"),pr(t,mr(e,i,s)),{type:"status",root:t}):(e.skin,null)))(t,this._params,this._state,{formatValue:t=>this._formatValue(t),toPositionPx:t=>this._toPositionPx(t)})}_renderFromInput(){const t=this._sourceInput,e=document.createElement("div");e.className=br;const i=document.createElement("div");i.className="vg-range-slider__wrapper";const s=document.createElement("div");s.className="vg-range-slider__track";const r=document.createElement("div");r.className="vg-range-slider__fill";const n=this._params.tooltips?this._createTooltip("from"):null,a=this._params.labels?this._createLabels(!1):null;return t.insertAdjacentElement("beforebegin",e),t.classList.add("vg-range-slider__input","vg-range-slider__input--from"),t.autocomplete="off",s.appendChild(r),i.appendChild(s),i.appendChild(t),n&&i.appendChild(n),e.appendChild(i),a&&e.appendChild(a),e}_renderFromContainer(){const t=this._element;t.classList.add(br),this._isRange&&t.classList.add("is-range"),t.innerHTML="";const e=document.createElement("div");e.className="vg-range-slider__wrapper";const i=document.createElement("div");i.className="vg-range-slider__track";const s=document.createElement("div");s.className="vg-range-slider__fill",i.appendChild(s),e.appendChild(i);const r=this._createRangeInput("from");if(e.appendChild(r),this._isRange){const t=this._createRangeInput("to");e.appendChild(t)}return this._params.tooltips&&(e.appendChild(this._createTooltip("from")),this._isRange&&e.appendChild(this._createTooltip("to")),this._isRange&&e.appendChild(this._createTooltip("merged"))),t.appendChild(e),this._params.labels&&t.appendChild(this._createLabels(this._isRange)),this._isRange?(this._ensureHiddenInput(t,"min",this._params.input?.min,this._params.name?.min),this._ensureHiddenInput(t,"max",this._params.input?.max,this._params.name?.max)):this._params.name?.min&&this._ensureHiddenInput(t,"min",this._params.input?.min,this._params.name.min),t}_createRangeInput(t){const e=document.createElement("input");return e.type="range",e.className=`vg-range-slider__input vg-range-slider__input--${t}`,e.min=String(this._state.min),e.max=String(this._state.max),e.step=String(this._state.step),e.value=String("to"===t?this._state.to:this._state.from),e.autocomplete="off",e}_createTooltip(t){const e=document.createElement("span");return e.className=`vg-range-slider__tooltip vg-range-slider__tooltip--${t}`,"merged"===t&&e.classList.add(vr),e}_createLabels(t){const e=document.createElement("div");e.className="vg-range-slider__labels";const i=document.createElement("span");if(i.className="vg-range-slider__label vg-range-slider__label--from",e.appendChild(i),t){const t=document.createElement("span");t.className="vg-range-slider__separator",t.textContent=this._params.separator,e.appendChild(t);const i=document.createElement("span");i.className="vg-range-slider__label vg-range-slider__label--to",e.appendChild(i)}return e}_ensureHiddenInput(t,e,i,r){let n=i?s.A.find(i):null;n||(n=document.createElement("input"),n.type="hidden",r&&(n.name=r),t.appendChild(n)),n.setAttribute("data-vgrangeslider-hidden",e)}_bindEvents(){const t=t=>e=>{const i=this._normalizeValue(e.target.value,this._state.min);this._isRange?"from"===t?(this._state.from=Math.min(i,this._state.to),e.target.value=String(this._state.from)):(this._state.to=Math.max(i,this._state.from),e.target.value=String(this._state.to)):this._state.from=i,this._syncUI(),this._emit(wr,"onInput")},e=()=>{this._syncUI(),this._emit(Er,"onChange")};[this._dom.inputFrom,this._dom.inputTo].filter(Boolean).forEach(i=>{const s=i.classList.contains("vg-range-slider__input--to")?"to":"from",r=t(s),n=e;i.addEventListener("input",r),i.addEventListener("change",n),this._listeners.push({element:i,type:"input",handler:r}),this._listeners.push({element:i,type:"change",handler:n})}),window.addEventListener("resize",this._handleResize)}_syncUI(){this._toPercent(this._state.from),this._toPercent(this._isRange?this._state.to:this._state.from);const t=this._toPositionPx(this._state.from),e=this._toPositionPx(this._isRange?this._state.to:this._state.from);if(this._dom.inputFrom&&(this._dom.inputFrom.value=String(this._state.from)),this._dom.inputTo&&(this._dom.inputTo.value=String(this._state.to)),this._dom.fill){const i=this._isRange?t:0,s=this._isRange?e-t:e;this._dom.fill.style.left=`${Math.max(i,0)}px`,this._dom.fill.style.width=`${Math.max(s,0)}px`}this._placeTooltip(this._dom.tooltipFrom,t,this._formatValue(this._state.from)),this._placeTooltip(this._dom.tooltipTo,e,this._formatValue(this._state.to)),this._syncTooltips(t,e),this._dom.labelFrom&&(this._dom.labelFrom.textContent=this._formatValue(this._state.from)),this._dom.labelTo&&(this._dom.labelTo.textContent=this._formatValue(this._state.to)),this._dom.labelSeparator&&(this._dom.labelSeparator.hidden=!this._isRange),this._syncTargets(),((t,e,i)=>{if(!t)return;if("status"===t.type)return pr(t.root,mr(i.params,e,i)),void((t,e,i)=>{const s=i?.dom?.labelFrom,r=i?.dom?.labelTo,n=gr(t,ur(e.from,t,e)),a=gr(t,ur(e.to,t,e));s&&n&&(s.textContent=n),r&&a&&(r.textContent=a)})(i.params,e,i);if("ruler"!==t.type)return;const s=e.from!==e.to||i.isRange;t.ticks.forEach((i,r)=>{const n=t.values[r],a=s?n>=e.from&&n<=e.to:n<=e.from;i.classList.toggle("is-active",a)})})(this._dom.skin,this._state,{isRange:this._isRange,params:this._params,dom:this._dom})}_syncTargets(){const t=this.getValue(),[e,i]=Array.isArray(t)?t:[t,t];this._dom.hiddenMin&&(this._dom.hiddenMin.value=String(e)),this._dom.hiddenMax&&(this._dom.hiddenMax.value=String(i)),this._setText(this._params.output?.target,this._isRange?`${this._formatValue(e)}${this._params.separator}${this._formatValue(i)}`:this._formatValue(e)),this._setText(this._params.output?.min,this._formatValue(e)),this._setText(this._params.output?.max,this._formatValue(i))}_setDisabledState(t){this._params.disabled=!!t,this._dom.root&&this._dom.root.classList.toggle("disabled",this._params.disabled),[this._dom.inputFrom,this._dom.inputTo].filter(Boolean).forEach(t=>{t.disabled=this._params.disabled})}_placeTooltip(t,e,i){t&&(t.textContent=i,t.style.left=`${e}px`)}_syncTooltips(t,e){const i=this._dom.tooltipMerged,s=this._dom.tooltipFrom,r=this._dom.tooltipTo;return this._isRange&&i&&s&&r?e-t<=s.offsetWidth/2+r.offsetWidth/2+8?(s.classList.add(vr),r.classList.add(vr),i.classList.remove(vr),i.textContent=`${this._formatValue(this._state.from)}${this._params.separator}${this._formatValue(this._state.to)}`,void(i.style.left=(t+e)/2+"px")):(s.classList.remove(vr),r.classList.remove(vr),void i.classList.add(vr)):(s&&s.classList.remove(vr),r&&r.classList.remove(vr),void(i&&i.classList.add(vr)))}_toPercent(t){const e=this._state.max-this._state.min;return e<=0?0:(t-this._state.min)/e*100}_toPositionPx(t){const e=this._dom?.wrapper,i=this._state.max-this._state.min;if(!e||i<=0)return 0;const s=(t-this._state.min)/i,r=getComputedStyle(this._dom.root||e),n=parseFloat(r.getPropertyValue("--vg-range-slider-thumb-size"))||0,a=e.clientWidth||0;return a<=0?0:a<=n?a/2:s*(a-n)+n/2}_normalizeValue(t,e,i=this._state?.min??0,s=this._state?.max??100){const n=Number((0,r.OM)(t)),a=Number.isFinite(n)?n:e,o=Math.min(Math.max(a,i),s),l=this._state?.step||this._params.step||1,h=Math.round((o-i)/l)*l+i;return Number(h.toFixed(5))}_formatValue(t){return"function"==typeof this._params.formatValue?this._params.formatValue.call(this,t,this._element):`${null==this._params.prefix?"":String(this._params.prefix)}${t}${null==this._params.suffix?"":String(this._params.suffix)}`}_getStatusBy(){if("string"!=typeof this._params?.status?.by)return"to";const t=this._params.status.by.toLowerCase();return["from","to","avg"].includes(t)?t:"to"}_getStatusPercentByValue(t){const e=this._state.max-this._state.min;return e<=0?0:(t-this._state.min)/e*100}_getStatusToneByValue(t){const e=this._getStatusPercentByValue(t),i=Number(this._params?.status?.warningBelow),s=Number(this._params?.status?.dangerBelow),r=Number.isFinite(i)?i:60;return e<(Number.isFinite(s)?s:30)?"danger":e<r?"warning":"success"}_getStatusLabelByTone(t){return!Array.isArray(this._params?.labelWords)||this._params.labelWords.length<3?null:"danger"===t?this._params.labelWords[0]||null:"warning"===t?this._params.labelWords[1]||null:this._params.labelWords[2]||null}_getStatusDetail(){const t=this._getStatusBy(),e=this._state.from,i=this._state.to,s="from"===t?e:"avg"===t?(e+i)/2:i,r=this._getStatusToneByValue(s);return{by:t,sourceValue:s,percent:Number(this._getStatusPercentByValue(s).toFixed(5)),tone:r,label:this._getStatusLabelByTone(r),from:{value:e,percent:Number(this._getStatusPercentByValue(e).toFixed(5)),tone:this._getStatusToneByValue(e),label:this._getStatusLabelByTone(this._getStatusToneByValue(e))},to:{value:i,percent:Number(this._getStatusPercentByValue(i).toFixed(5)),tone:this._getStatusToneByValue(i),label:this._getStatusLabelByTone(this._getStatusToneByValue(i))}}}_emit(t,e){const i={value:this.getValue(),from:this._state.from,to:this._state.to,min:this._state.min,max:this._state.max,step:this._state.step,status:this._getStatusDetail(),instance:this};g.A.trigger(this._element,t,i);const s=this._params[e];"function"==typeof s&&s.call(this,this._element,i)}_setText(t,e){if(!t)return;const i=s.A.find(t);i&&(i.textContent=e)}}g.A.on(document,"DOMContentLoaded",()=>{s.A.findAll("[data-vgrangeslider]").forEach(t=>{t.dataset.vgrangesliderInitialized||(Cr.getOrCreateInstance(t),t.dataset.vgrangesliderInitialized="true")})});const xr=Cr,Lr="rollup",Ir="vg.rollup",Pr="show",Mr="vg-rollup-display--none",kr=`${Ir}.hide`,Dr=`${Ir}.show`,Tr=`click.${Ir}.data.api`;class Or extends t.A{constructor(t,i={}){super(t,i);const s={lang:document.documentElement.lang||"ru",content:"text",cnt:0,fade:!0,transition:!1,number:!1,height:0,ellipsis:{line:null},more:" еще ",button:{enabled:!0,more:"Показать",less:"Свернуть",classes:""},callbacks:{init:()=>{},expand:()=>{},collapse:()=>{}}};let n=e.p.get(t,"data-lang")||"lang"in i?i.lang:s.lang;s.button.more=Bt(n,Lr).show,s.button.less=Bt(n,Lr).less,s.more=Bt(n,Lr).more,this._params=this._getParams(t,(0,r._v)(s,i)),this.classes={container:"vg-rollup",hidden:"vg-rollup-content--hidden",fade:"vg-rollup-content--fade",ellipsis:"vg-rollup-content--ellipsis",button:"vg-rollup-content--button",transition:"vg-rollup-content--transition"},this.total=0,this.count=0,this.offset=0,this.isOffset=!1,this.build()}static get NAME(){return Lr}static get NAME_KEY(){return Ir}static toggle(t,e){const i=Or.getOrCreateInstance(t);i.isShow()?i._hide(e):i._show(e)}_show(t){e.x.add(this._element,Pr),t.innerHTML=this._params.button.less,e.p.set(t,"aria-expanded","true"),this.offset>0&&(t.innerHTML=this.isOffset?this._params.button.more:this._params.button.less,e.p.set(t,"aria-expanded",this.isOffset?"true":"false")),this.switch(this._element,!1),g.A.trigger(this._element,Dr,{relatedTarget:t})}_hide(t){let i=this._params.button.more;if(this._params.number){const t=this.total-this.count;t>0&&(i+=this._params.more+t)}e.x.remove(this._element,Pr),e.p.set(t,"aria-expanded","false"),t.textContent=i,this.switch(this._element,!0),g.A.trigger(this._element,kr,{relatedTarget:t})}build(t=null,i=!0){const s=t||this._element,n=s.clientHeight,a=this._params.height||n/2,{fade:o,transition:l,button:h,number:d,content:c,elements:_,cnt:u,ellipsis:m}=this._params,p=null!==m.line,g=h.enabled&&i;e.x.add(s,this.classes.container),i?("text"===c&&n>a?this._setupTextContent(s,a,o,l,p,m.line,g,d):"elements"===c&&this._setupElementsContent(s,_,u,o,l,p,g,d),(0,r.g7)(this._params.callbacks.init,[s,this])):this.switch(s)}_setupTextContent(t,i,s,r,n,a,o,l){e.x.add(t,this.classes.hidden),t.style.height=i+"px",n&&a?(e.x.add(t,this.classes.ellipsis),t.style.lineClamp=Number(a)):n&&console.error("Переменная [data-line] или параметр[line] не должны быть пустыми"),r&&e.x.add(t,this.classes.transition),s&&e.x.add(t,this.classes.fade),o&&this._createButton(t,"",l)}_setupElementsContent(t,i,r,n,a,o,l,h){const d=s.A.findAll("."+i,t);this.total=d.length,this.count=r,d.forEach((t,i)=>{i>=r&&e.x.add(t,Mr)});const c=l&&d.length>r;if(o&&e.x.add(t,this.classes.ellipsis),a&&e.x.add(t,this.classes.transition),n&&e.x.add(t,this.classes.fade),c){const e=this.total-this.count,i=h&&e>0?this._params.more+e:"";this._createButton(t,i,!1)}}_createButton(t,e="",i=!1){t.id||(t.id=`vg-rollup-${Math.random().toString(36).substr(2,9)}`);const s=this._params.button.more,r=`<div class="${this.classes.button}">\n <a href="#" aria-expanded="false" data-vg-toggle="rollup" class="${this._params.button.classes}" data-vg-target="#${t.id}">\n ${s}${e}\n </a>\n </div>`;t.insertAdjacentHTML("afterend",r)}switch(t,i=!1){if(i&&!this.isOffset){const{content:i}=this._params,n=t.clientHeight,a=this._params.height||n/2;if("text"===i&&n>a)e.x.add(t,this.classes.hidden),t.style.height=a+"px",this._params.ellipsis.line&&(e.x.add(t,this.classes.ellipsis),t.style.lineClamp=this._params.ellipsis.line),this._params.fade&&e.x.add(t,this.classes.fade),this._params.transition&&e.x.add(t,this.classes.transition),(0,r.g7)(this._params.callbacks.expand,[t,this]);else if("elements"===i){const i=s.A.findAll("."+this._params.elements,t);i.forEach((t,i)=>{i>=this.count&&e.x.add(t,Mr)}),(0,r.g7)(this._params.callbacks.collapse,[t,i,this])}e.x.add(t,this.classes.container)}else{const{hidden:i,ellipsis:n,fade:a}=this.classes;e.x.remove(t,[i,n,a]),e.p.remove(t,"style"),"elements"===this._params.content&&s.A.findAll("."+this._params.elements,t).forEach(t=>e.x.remove(t,Mr)),(0,r.g7)(this._params.callbacks.expand,[t,this])}}isShow(){return e.x.has(this._element,Pr)}static init(t,e={},i){const s=Or.getOrCreateInstance(t,e);(0,r.g7)(i,[s])}}g.A.on(document,Tr,'[data-vg-toggle="rollup"]',function(t){if(["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,r.d6)(this))return;const e=s.A.getElementFromSelector(this);e&&Or.toggle(e,this)});const zr=Or,Nr="vg.select",$r="vg-select",Hr="vg-select-list--option",Fr="vg-select-tag",Rr="vg-select-tag-remove",Br=`click.${Nr}.data.api`,jr=`keyup.${Nr}.data.api`,Ur=`reset.${Nr}.data.api`,qr=`keydown.${Nr}.data.api`,Vr=`${Nr}.change`,Wr=`${Nr}.search`,Kr=`${Nr}.select`,Gr=`${Nr}.deselect`,Yr='[data-vg-toggle="select"]',Xr="select",Zr="vg.select",Jr="show",Qr="active",tn="vg-select",en="vg-select-dropdown",sn="vg-select-list",rn="vg-select-list--option",nn="vg-select-current",an="vg-select-current--placeholder",on="vg-select-search",ln="vg-select-tags",hn="vg-select-tag",dn="vg-select-load-more",cn="vg-select-loading",_n="drop-up",un=`${Zr}.change`,mn=`${Zr}.hide`,pn=`${Zr}.hidden`,gn=`${Zr}.show`,fn=`${Zr}.shown`,bn=`${Zr}.init`,vn=`${Zr}.rebuild`,yn=`${Zr}.open`,wn=`${Zr}.close`,En=`${Zr}.select`,An=`${Zr}.clear`,Sn=`${Zr}.error`,Cn=`${Zr}.loadNext`,xn='[data-vg-toggle="select"]',Ln=`.${nn}`,In=`.${en}`,Pn=`.${on} input`,Mn=`.${sn}`,kn=`.${dn}`,Dn=["inited","updating","exclude"];class Tn extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({lang:document.documentElement.lang||"ru",autosearch:!0,position:"none",search:{enabled:!1,route:"",remote:!1,delay:300,minterm:1,pagination:!1,pageParam:"page",termParam:"q",perpage:20,loadMoreText:"Загрузить ещё"},close:!0,tree:!1,exclude:"data-filter-param",placeholder:"",onInit:null,onShow:null,onHide:null,onChange:null,onSelect:null,onDeselect:null,onClear:null,onLoadNext:null},e)),this._observer=null,this._observerTimeout=null,this._visibilityTransitionId=0,this._drop=s.A.find(In,this._element),this._searchTerm="",this._currentPage=1,this._totalPages=null,this._loading=!1,"object"==typeof e.search&&(this._params.search.loadMoreText=Bt(this._params.lang,Xr)["load-more"]||"Загрузить еще"),this._remoteSearchRequestId=0,this._remoteSearchAbortController=null,this._positioningScrollParent=null,this._boundUpdateDropdownPlacement=()=>this._updateDropdownPlacement(),this._initObserver(),this._syncSearch(),this._initLoadMoreButton(),this._triggerEvent(bn),this._callCallback("onInit")}static get NAME(){return Xr}static get NAME_KEY(){return Zr}static buildListOptions(t,i,r={}){let n=i.querySelector(`.${sn}`);n?n.innerHTML="":(n=document.createElement("ul"),e.x.add(n,sn),i.appendChild(n));const a=s.A.findAll("optgroup",t),o=document.createDocumentFragment(),l=this._isTreeEnabled(t,r);return a.length>0?(a.forEach(i=>{const r=document.createElement("ol");e.x.add(r,"vg-select-list--optgroup");const n=document.createElement("li");n.textContent=i.label.trim(),e.x.add(n,"vg-select-list--optgroup-title"),r.appendChild(n),Tn._createListItems(s.A.findAll("option",i),r,t,{tree:l,depth:l?1:0}),o.appendChild(r)}),n.appendChild(o)):Tn._createListItems(t.options,n,t,{tree:l,depth:0}),n}static _createListItems(t,i,s,n={}){const a=document.createDocumentFragment(),o=Number.isInteger(n.depth)?n.depth:0,l=!!n.tree;[...t].forEach(t=>{if(t.hidden)return;const i=t.getAttribute("value"),s=null==i?"":i,n=t.textContent.trim(),h=""===s&&""===n,d=document.createElement("li");if(d.textContent=n,d.dataset.index=String(t.index),d.dataset.value=s,d.classList.add(rn),e.p.set(d,"data-vg-toggle","select-option"),l){const e=t.dataset.level,i=Number.isFinite(Number(e))?parseInt(e,10):null,s=Math.max(0,null==i?o:i);d.dataset.level=String(s),d.style.paddingLeft=16+16*s+"px"}t.selected&&d.classList.add("selected"),t.disabled&&d.classList.add("disabled"),h&&(d.hidden=!0,d.style.display="none");const c=e.p.get(t);(0,r.ze)(c)||Object.keys(c).forEach(t=>{e.p.set(d,`data-${t}`,c[t])}),a.appendChild(d)}),i.appendChild(a)}static _isTreeEnabled(t,e={}){return"boolean"==typeof e.tree?e.tree:!(!t?.dataset||void 0===t.dataset.tree)&&!0===(0,r.OM)(t.dataset.tree)}static _getDataAttrCopyExclusions(t,e={}){const i=("string"==typeof e.exclude?e.exclude:t.dataset.exclude||"").split(",").map(t=>this._normalizeDataAttrKey(t)).filter(Boolean);return new Set([...Dn,...i])}static _normalizeDataAttrKey(t){return String(t||"").trim().replace(/^data-/,"").toLowerCase()}static _isSearchEnabled(t,e={}){if(!0===e.search?.enabled||!0===e.search?.remote)return!0;const i=e.autosearch;if(!1===i)return!1;const s=Number(i),r=!0!==i&&Number.isFinite(s)&&s>=0?s:7;return Array.from(t?.options||[]).filter(t=>!t.hidden&&(""!==t.value||""!==t.textContent.trim())).length>r}static isPlaceholderValue(t,e){const i=t.dataset.placeholderValue;return i?i.split(",").map(t=>t.trim()).includes(String(e)):null==e||""===String(e).trim()}static hasExplicitSelectedOption(t){return Array.from(t.options).some(t=>t.hasAttribute("selected"))}static hasSelectedValidOption(t){const e=t.selectedIndex;return-1!==e&&!this.isPlaceholderValue(t,t.options[e]?.value)}static build(t,i=!1,s={}){(i||"true"===t.dataset.inited)&&this.destroy(t);const n=document.createElement("div");n.classList.add(tn),n.style.position="relative",t.classList.length&&[...t.classList].forEach(t=>n.classList.add(t)),(0,r.d6)(t)&&n.classList.add("disabled");const a=e.p.get(t);if(!(0,r.ze)(a)){const i=this._getDataAttrCopyExclusions(t,s);Object.keys(a).forEach(t=>{i.has(t)||e.p.set(n,`data-${t}`,a[t])})}const o=t.dataset.placeholder||"",l=t.multiple,h=document.createElement("div");if(h.classList.add(nn),h.setAttribute("data-vg-toggle","select"),h.setAttribute("aria-expanded","false"),h.setAttribute("role","button"),h.tabIndex=l?-1:0,l){const t=document.createElement("div");t.classList.add(ln),h.appendChild(t);const e=document.createElement("input");e.type="text",e.className="vg-select-multiple-input",e.style.cssText="border:0;outline:none;background:transparent;padding:0;margin:0;min-width:1px;width:1px;height:1px;line-height:1;font:inherit;opacity:0;",t.appendChild(e),e.addEventListener("focus",()=>{const t=Tn.getInstance(e.closest(`.${tn}`));t&&!t._isShown()&&t.show()})}else{const e=t.selectedIndex,i=e>=0?t.options[e]:null,s=i?.textContent.trim()||"",r=o&&!this.hasSelectedValidOption(t);h.innerHTML=r?`<span class="${an}">${o}</span>`:s||"-"}n.appendChild(h);const d=document.createElement("div");return d.classList.add(en),n.appendChild(d),this.buildListOptions(t,d,s),t.insertAdjacentElement("afterend",n),t.dataset.inited="true",this.getOrCreateInstance(n,s),this.updateUI(t),n}_syncSearch(){const t=this._element.previousElementSibling;if(!t||"SELECT"!==t.tagName||!this._drop)return;const e=Tn._isSearchEnabled(t,this._params),i=this._drop.querySelector(`.${on}`);if(!e)return void i?.remove();if(i)return;const s=document.createElement("div");s.classList.add(on);const r=document.createElement("input");let n;r.name="vg-select-search",r.type="text",r.placeholder=Ft(this._params.lang,Xr).search,r.autocomplete="off",r.setAttribute("role","searchbox"),s.appendChild(r),this._drop.insertBefore(s,this._drop.firstChild),r.addEventListener("input",t=>{const e=t.target.value.trim(),i=this._params;if(this._callCallback("onSearch",{term:e}),i.search.remote&&i.search.route){if(e.length<(i.search.minterm||1))return;clearTimeout(n),n=setTimeout(()=>{this._fetchRemoteData(e)},i.search.delay||300)}else this._filterLocalOptions(e)})}toggle(t){return this._isShown()?this.hide():this.show(t)}show(t){if((0,r.d6)(this._element))return;if(g.A.trigger(this._element,gn,{relatedTarget:t}).defaultPrevented)return;const e=++this._visibilityTransitionId;this._element.classList.add(Jr),this._element.classList.add(Qr),"none"!==this._getPositionMode()?this._setupDropdownPlacement():this._teardownDropdownPlacement(),"ontouchstart"in document.documentElement&&(document.body.style.pointerEvents="none"),this._element.querySelector(xn).setAttribute("aria-expanded","true");const i=this._element.querySelector(Pn);return i&&i.focus(),this._queueCallback(()=>{e===this._visibilityTransitionId&&this._isShown()&&(this._updateDropdownPlacement(),g.A.trigger(this._element,fn,{relatedTarget:t}),this._triggerEvent(yn),this._callCallback("onShow"))},this._drop,!0,50)}hide(){!(0,r.d6)(this._element)&&this._isShown()&&this._completeHide()}_completeHide(t={}){if(g.A.trigger(this._element,mn,t).defaultPrevented)return;const e=++this._visibilityTransitionId;this._teardownDropdownPlacement(),this._element.classList.remove(Qr),this._element.querySelector(xn).setAttribute("aria-expanded","false"),this._queueCallback(()=>{e===this._visibilityTransitionId&&(this._element.classList.remove(Jr),g.A.trigger(this._element,pn,t),this._triggerEvent(wn),this._callCallback("onHide"))},this._drop,!0,10),"ontouchstart"in document.documentElement&&(document.body.style.pointerEvents="")}_isShown(){return this._element.classList.contains(Jr)}_initObserver(){this._observer&&this._observer.disconnect();const t=this._element.previousElementSibling;t&&"SELECT"===t.tagName&&(this._observer=new MutationObserver(e=>{if(console.debug("VGSelect: Mutation detected",e),t.hasAttribute("data-updating"))return;if(!e.some(t=>"attributes"===t.type?["disabled","required","style","hidden"].includes(t.attributeName):"childList"===t.type||"characterData"===t.type))return;const i=this._isShown();clearTimeout(this._observerTimeout),this._observerTimeout=setTimeout(()=>{this._element.previousElementSibling!==t||t.hasAttribute("data-updating")||(this._updateFromMutation(),i&&requestAnimationFrame(()=>{this.show()}))},100)}),this._observer.observe(t,{attributes:!0,attributeFilter:["disabled","required","style","hidden"],childList:!0,subtree:!0,characterData:!0}))}_updateFromMutation(){const t=this._element.previousElementSibling;if(!t)return;(0,r.d6)(t)?this._element.classList.add("disabled"):this._element.classList.remove("disabled");const e=this._element.querySelector(In);Tn.buildListOptions(t,e,this._params),this._syncSearch(),Tn.updateUI(t)}dispose(){this._visibilityTransitionId++,this._observer&&(this._observer.disconnect(),this._observer=null),clearTimeout(this._observerTimeout),this._observerTimeout=null,this._teardownDropdownPlacement(),super.dispose()}_setupDropdownPlacement(){"none"!==this._getPositionMode()&&(this._teardownDropdownPlacement(),this._positioningScrollParent=this._getOverflowAncestor(this._element),window.addEventListener("resize",this._boundUpdateDropdownPlacement,{passive:!0}),window.addEventListener("scroll",this._boundUpdateDropdownPlacement,{passive:!0}),this._positioningScrollParent&&this._positioningScrollParent.addEventListener("scroll",this._boundUpdateDropdownPlacement,{passive:!0}),this._updateDropdownPlacement())}_teardownDropdownPlacement(){window.removeEventListener("resize",this._boundUpdateDropdownPlacement),window.removeEventListener("scroll",this._boundUpdateDropdownPlacement),this._positioningScrollParent&&this._positioningScrollParent.removeEventListener("scroll",this._boundUpdateDropdownPlacement),this._positioningScrollParent=null,this._element.classList.remove(_n),this._element.style.removeProperty("--vg-select-list-max-height")}_getPositionMode(){const t=this._params?.position,e=null==t?"none":String(t).trim().toLowerCase();return"auto"===e||"top"===e||"bottom"===e||"none"===e?e:"none"}_getOverflowAncestor(t){let e=t?.parentElement;for(;e&&e!==document.body&&e!==document.documentElement;){const t=window.getComputedStyle(e),i=t.overflowX||t.overflow||"visible",s=t.overflowY||t.overflow||"visible";if("visible"!==i||"visible"!==s)return e;e=e.parentElement}return null}_getClipRect(){const t={top:0,left:0,right:window.innerWidth,bottom:window.innerHeight},e=this._positioningScrollParent;if(!e)return t;const i=e.getBoundingClientRect();return{top:Math.max(t.top,i.top),left:Math.max(t.left,i.left),right:Math.min(t.right,i.right),bottom:Math.min(t.bottom,i.bottom)}}_updateDropdownPlacement(){if(!this._isShown())return;const t=this._getPositionMode();if("none"===t)return;const e=this._getClipRect(),i=this._element.getBoundingClientRect(),s=e.bottom-i.bottom,r=i.top-e.top,n="top"===t||"bottom"!==t&&r>s;this._element.classList.toggle(_n,n);const a=n?r:s,o=Math.max(80,Math.floor(a-12));Number.isFinite(o)&&o>0&&this._element.style.setProperty("--vg-select-list-max-height",`${o}px`)}static destroy(t){const e=t.nextElementSibling;e&&e.classList.contains(tn)&&e.remove()}static updateUI(t){const e=t.nextElementSibling;if(!e||!e.classList.contains(tn))return;const i=e.querySelector(Ln),s=t.dataset.placeholder||"",r=t.multiple,n=Tn.getInstance(e);if(r){const e=i.querySelector(`.${ln}`),r=e.querySelector("input"),a=e.querySelectorAll(`.${hn}`).length;e.innerHTML="",e.appendChild(r);const o=Array.from(t.selectedOptions);0===o.length&&a>0&&(n?._triggerEvent(An),n?._callCallback("onClear")),0===o.length?r.placeholder=s:(r.placeholder="",o.forEach(t=>{const i=document.createElement("div");i.classList.add(hn),i.innerHTML=`<span>${t.textContent}</span><svg class="vg-select-tag-remove" data-index="${t.index}" data-value="${t.getAttribute("value")??""}" width="14" height="14" viewBox="0 0 14 14"><line x1="2" y1="2" x2="12" y2="12" stroke="currentColor"/><line x1="12" y1="2" x2="2" y2="12" stroke="currentColor"/></svg>`,e.insertBefore(i,r)}))}else{const e=t.selectedIndex,r=e>=0?t.options[e]:null,n=r?.textContent.trim()||"",a=s&&!this.hasSelectedValidOption(t),o=a?s:n||"-";i.textContent!==o&&(i.innerHTML=a?`<span class="${an}">${s}</span>`:o)}}static changeSelector(t,e,i={}){const s=t.nextElementSibling,n=s?Tn.getInstance(s):null;t.setAttribute("data-updating","true");try{const s=t.querySelector(`option[value="${CSS.escape((0,r.OM)(e))}"]`);if(!s)return void n?._triggerEvent(Sn,{error:"Option not found",value:e});const a=s.selected,o=s.textContent.trim();t.multiple?s.selected=!1!==i?.selected:([...t.options].forEach(t=>t.selected=!1),s.selected=!0,t.value=s.value),this.updateUI(t);const l=new Event("change",{bubbles:!0,cancelable:!0});t.dispatchEvent(l),a||(g.A.trigger(t,un,{data:i}),n?._triggerEvent(En,{value:e,text:o,data:i}),n?._callCallback("onSelect",{value:e,text:o,data:i}))}finally{t.removeAttribute("data-updating")}}static changeSelectorByIndex(t,e,i={}){const s=t.nextElementSibling,r=s?Tn.getInstance(s):null;t.setAttribute("data-updating","true");try{const s=Number.isInteger(e)?t.options[e]:null;if(!s)return void r?._triggerEvent(Sn,{error:"Option not found by index",index:e});const n=s.selected,a=s.textContent.trim(),o=s.value;t.multiple?s.selected=!1!==i?.selected:([...t.options].forEach(t=>t.selected=!1),s.selected=!0,t.value=s.value),this.updateUI(t);const l=new Event("change",{bubbles:!0,cancelable:!0});t.dispatchEvent(l),n||(g.A.trigger(t,un,{data:i}),r?._triggerEvent(En,{value:o,text:a,data:i}),r?._callCallback("onSelect",{value:o,text:a,data:i}))}finally{t.removeAttribute("data-updating")}}_triggerEvent(t,e={}){g.A.trigger(this._element,t,e)}_callCallback(t,e=null){const i=this._params[t];"function"==typeof i&&i.call(this,this._element,e)}static init(t,e={},i=!1){this.build(t,i,e)}static clearDrops(t){const e=s.A.find(`.${tn}.${Jr}`);if(!e)return;const i=t.target.closest(xn);if(i&&i.closest(`.${tn}`)===e)return;if(t.composedPath().some(t=>t.classList?.contains(en)))return;const r=Tn.getInstance(e);r&&r._completeHide({relatedTarget:t.target})}_initLoadMoreButton(){if(!this._params.search?.pagination||!this._params.search.remote)return;const t=this._element.querySelector(Mn);if(!t)return;const e=document.createElement("li");e.className=dn,e.style.textAlign="center",e.style.padding="8px",e.style.cursor="pointer",e.style.color="#007bff",e.style.fontSize="14px",e.style.fontWeight="500",e.textContent=this._params.search.loadMoreText,e.addEventListener("click",()=>{!this._loading&&(null===this._totalPages||this._currentPage<this._totalPages)&&this._loadNextPage()}),t.appendChild(e),this._hideLoadMoreButton(!0)}_hideLoadMoreButton(t){const e=this._element.querySelector(kn);e&&(e.style.display=t?"none":"block")}_showLoading(t){const e=this._element.querySelector(Mn);let i=e.querySelector(`.${cn}`);t&&!i?(i=document.createElement("li"),i.className=cn,i.style.textAlign="center",i.style.padding="8px",i.textContent=Rt(this._params.lang,Xr).loading,e.appendChild(i)):!t&&i&&i.remove()}async _loadNextPage(){const{route:t,pageParam:e="page",termParam:i="q",perpage:s=20}=this._params.search,r=this._currentPage+1,n=new URL(t,window.location.origin);n.searchParams.set(i,this._searchTerm),n.searchParams.set(e,r),n.searchParams.set("per_page",s),this._loading=!0,this._showLoading(!0),this._hideLoadMoreButton(!0);try{const t=await fetch(n,{headers:{"Content-Type":"application/json"}}),e=await t.json();Array.isArray(e.results)&&(Tn.addOptions(this._element.previousElementSibling,e,{preserve:!0}),this._currentPage=e.pagination?.current_page||r,this._totalPages=e.pagination?.total_pages||null,(null===this._totalPages||this._currentPage<this._totalPages)&&this._hideLoadMoreButton(!1),this._callCallback("onLoadNext",{page:this._currentPage,data:e}),this._triggerEvent(Cn,{page:this._currentPage,term:this._searchTerm}))}catch(t){console.error("VGSelect: Failed to load next page",t),this._triggerEvent(Sn,{error:"Pagination fetch failed",term:this._searchTerm}),this._hideLoadMoreButton(!1)}finally{this._showLoading(!1),this._loading=!1}}_fetchRemoteData(t){const{route:e,method:i="GET",pageParam:s="page",termParam:r="q",perpage:n=20}=this._params.search,a=new URL(e,window.location.origin);a.searchParams.set(r,t),a.searchParams.set(s,1),a.searchParams.set("per_page",n);const o=this._element.querySelector(Pn),l=this._isShown();this._searchTerm=t,this._currentPage=1,this._totalPages=null,this._remoteSearchAbortController&&this._remoteSearchAbortController.abort(),this._remoteSearchAbortController=new AbortController;const h=++this._remoteSearchRequestId,d=this._remoteSearchAbortController.signal;this._showLoading(!0),this._hideLoadMoreButton(!0),fetch(a,{method:i,headers:{"Content-Type":"application/json"},signal:d}).then(t=>t.json()).then(e=>{if(h!==this._remoteSearchRequestId)return;if((o?o.value.trim():"")!==t)return;const i=this._element.previousElementSibling;i&&([...i.querySelectorAll("option")].forEach(t=>{const e=t===i.options[0],s=""===(t.getAttribute("value")??""),r=""===(t.textContent||"").trim(),n=!0===t.hidden||t.hasAttribute("hidden"),a=t.hasAttribute("selected");e&&s&&r&&n&&a||t.hasAttribute("data-preserve")||t.closest("optgroup[data-preserve]")||t.remove()}),Tn.addOptions(i,e,{preserve:!0}),this._callCallback("onSearch",{term:t,data:e}),this._triggerEvent(vn,{term:t,data:e}),e.pagination&&(this._currentPage=e.pagination.current_page||1,this._totalPages=e.pagination.total_pages||null),(null===this._totalPages||this._currentPage<this._totalPages)&&this._hideLoadMoreButton(!1),l&&o&&(o.focus(),this._element.classList.add(Jr,Qr)))}).catch(e=>{e&&"AbortError"===e.name||(console.error("VGSelect: Remote search error",e),this._triggerEvent(Sn,{error:"Search request failed",term:t}),this._hideLoadMoreButton(!1))}).finally(()=>{h===this._remoteSearchRequestId&&this._showLoading(!1)})}static addOptions(t,e,i={}){const{preserve:s=!1}=i,r=t.nextElementSibling,n=r&&r.classList.contains(tn),a=n?Tn.getInstance(r):null;let o=e;if(e&&e.results&&Array.isArray(e.results)&&(o=e.results),!Array.isArray(o))return void a?._triggerEvent(Sn,{error:"Invalid data format: expected array"});const l=this._isTreeEnabled(t,a?._params||{});s||([...t.querySelectorAll("option")].forEach(t=>{const e=t.closest("optgroup");""!==t.value&&(t.hasAttribute("data-preserve")||e&&e.hasAttribute("data-preserve")||t.remove())}),[...t.querySelectorAll("optgroup")].forEach(t=>{0!==t.children.length||t.hasAttribute("data-preserve")||t.remove()}));const h=(t,e,i=null)=>{const s=document.createElement("option"),r=Array.isArray(t.children)&&t.children.length>0;s.value=t.id||"",s.textContent=t.text||"",t.selected&&(s.selected=!0),t.disabled&&(s.disabled=!0),l&&Number.isInteger(i)&&(s.setAttribute("data-level",String(i)),r&&!s.value&&(s.disabled=!0)),Object.keys(t).filter(t=>!["id","text","selected","disabled","children"].includes(t)).forEach(e=>{s.setAttribute(`data-${e}`,t[e])}),e.appendChild(s)},d=(t,e,i=0)=>{t.forEach(t=>{h(t,e,i),Array.isArray(t.children)&&t.children.length>0&&d(t.children,e,i+1)})};if(l?d(o,t,0):o.forEach(e=>{if(e.children&&Array.isArray(e.children)){const i=document.createElement("optgroup");i.label=e.text||"",e.disabled&&(i.disabled=!0),e.children.forEach(t=>h(t,i)),t.appendChild(i)}else h(e,t)}),n){const e=r.querySelector(`.${en}`);Tn.buildListOptions(t,e,a?._params||{}),a?._syncSearch(),a?._triggerEvent(vn)}else this.updateUI(t)}_filterLocalOptions(t){const e=this._drop.querySelector(`.${sn}`).querySelectorAll(`.${rn}`);t?(t=t.toLowerCase(),e.forEach(e=>{const i=e.textContent.toLowerCase();e.hidden=!i.includes(t)})):e.forEach(t=>t.hidden=!1)}}g.A.on(document,Br,t=>On.clearDrops(t)),g.A.on(document,Br,Yr,function(t){const e=t.target;if(e.closest(`.${Fr}`)||e.closest(`.${Rr}`))return void t.stopPropagation();const i=this.closest(`.${$r}`),r=On.getOrCreateInstance(i),n=s.A.find(`.${$r}.show`);n&&n!==i&&On.getInstance(n)?.hide(),r.toggle(this)}),g.A.on(document,Br,'[data-vg-toggle="select-option"]',function(t){const i=t.target;if(i.classList.contains("disabled"))return;const s=i.closest(`.${$r}`),r=s.previousElementSibling,n=r.multiple,a=i.dataset.index,o=Number.isFinite(Number(a))?parseInt(a,10):NaN,l=Number.isInteger(o)?r.options[o]:null;if(!l)return;const h=On.getInstance(s),d=l.selected,c=l.value;if(n)l.selected=!l.selected,i.classList.toggle("selected",l.selected),On.updateUI(r),r.dispatchEvent(new Event("change",{bubbles:!0})),g.A.trigger(r,Vr,{data:{value:c,title:i.textContent,...e.p.get(i)}}),l.selected?(h?._triggerEvent(Kr,{value:c,title:i.textContent,...e.p.get(i)}),h?._callCallback("onSelect",{value:c,title:i.textContent,...e.p.get(i)})):(h?._triggerEvent(Gr,{value:c,title:i.textContent,...e.p.get(i)}),h?._callCallback("onDeselect",{value:c,title:i.textContent,...e.p.get(i)}));else{if(d)return;s.querySelectorAll(`.${Hr}`).forEach(t=>t.classList.remove("selected")),i.classList.add("selected"),On.changeSelectorByIndex(r,o,{index:o,value:c,title:i.textContent,...e.p.get(i)}),!1!==h?._params?.close&&h?.hide()}}),g.A.on(document,jr,'[name="vg-select-search"]',function(t){const e=t.target,i=e.closest(".vg-select-dropdown"),s=i?.querySelector(".vg-select-list");if(!s)return;const n=e.closest(`.${$r}`),a=On.getInstance(n),o=s.querySelectorAll(`.${Hr}`),l=s.querySelectorAll(".vg-select-list--optgroup"),h=e.value.trim().toLowerCase(),d=[h,(0,r.Ff)(h),(0,r.Ff)(h,!0)];if(o.forEach(t=>{t.hidden=!1,t.style.display=""}),l.forEach(t=>{t.hidden=!1,t.style.display=""}),h){let t=0;l.length?l.forEach(e=>{const i=e.querySelectorAll(`.${Hr}`),s=Array.from(i).some(t=>{const e=t.textContent.toLowerCase();return d.some(t=>e.includes(t))});e.hidden=!s,e.style.display=s?"":"none",i.forEach(e=>{const i=e.textContent.toLowerCase(),s=d.some(t=>i.includes(t));e.hidden=!s,e.style.display=s?"":"none",s&&t++})}):o.forEach(e=>{const i=e.textContent.toLowerCase(),s=d.some(t=>i.includes(t));e.hidden=!s,e.style.display=s?"":"none",s&&t++}),a?._triggerEvent(Wr,{query:h,results:t}),a?._callCallback("onSearch",{query:h,results:t})}else a?._triggerEvent(Wr,{query:"",results:o.length}),a?._callCallback("onSearch",{query:"",results:o.length})}),g.A.on(document,Ur,"form",function(){s.A.findAll('select[data-inited="true"]',this).forEach(t=>On.build(t,!0))}),g.A.on(document,"keydown",Yr,function(t){const e=On.getInstance(this.closest(`.${$r}`));if(e)switch(t.key){case"Enter":case" ":t.preventDefault(),e.toggle();break;case"Escape":e._isShown()&&e.hide();break;case"ArrowDown":t.preventDefault(),e._isShown()||e.show()}}),g.A.on(document,Br,".vg-select-tags",function(t){const e=t.target.closest(`.${Rr}`);if(!e)return;t.preventDefault(),t.stopPropagation();const i=this.closest(`.${$r}`),s=i.previousElementSibling,r=e.dataset.index,n=Number.isFinite(Number(r))?parseInt(r,10):NaN,a=Number.isInteger(n)?s.options[n]:null,o=Number.isInteger(n)?i.querySelector(`.${Hr}[data-index="${n}"]`):null,l=On.getInstance(i);a&&(a.selected=!1,o&&o.classList.remove("selected"),On.updateUI(s),s.dispatchEvent(new Event("change",{bubbles:!0})),g.A.trigger(s,Vr,{data:{value:a.value}}),l?._triggerEvent(Gr,{value:a.value}),l?._callCallback("onDeselect",{value:a.value}))}),g.A.on(document,qr,".vg-select-multiple-input",function(t){if("Backspace"===t.key&&!t.target.value){const e=t.target,i=e.parentElement.querySelectorAll(`.${Fr}`);if(i.length>0){const t=i[i.length-1].querySelector("svg"),s=t?.dataset.index,r=Number.isFinite(Number(s))?parseInt(s,10):NaN,n=e.closest(`.${$r}`).previousElementSibling,a=Number.isInteger(r)?n.options[r]:null,o=Number.isInteger(r)?e.closest(`.${$r}`).querySelector(`.${Hr}[data-index="${r}"]`):null,l=On.getInstance(e.closest(`.${$r}`));a&&(a.selected=!1,o&&o.classList.remove("selected"),On.updateUI(n),n.dispatchEvent(new Event("change",{bubbles:!0})),g.A.trigger(n,Vr,{data:{value:a.value}}),l?._triggerEvent(Gr,{value:a.value}),l?._callCallback("onDeselect",{value:a.value}))}}});const On=Tn,zn=On,Nn="vg.sidebar",$n="data-vg-backdrop-owner",Hn="sidebar",Fn="show",Rn="vg-sidebar-open",Bn={HIDE:`${Nn}.hide`,HIDDEN:`${Nn}.hidden`,SHOW:`${Nn}.show`,SHOWN:`${Nn}.shown`,LOADED:`${Nn}.loaded`,KEYDOWN_DISMISS:`keydown.dismiss.${Nn}`,HIDE_PREVENTED:`hidePrevented.${Nn}`,CLICK_DATA_API:`click.${Nn}.data.api`,POPSTATE_DATA_API:`popstate.${Nn}.data.api`,DOM_LOADED_DATA_API:`DOMContentLoaded.${Nn}.data.api`};class jn extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)({backdrop:!0,overflow:!0,keyboard:!0,hash:!1,animation:{enable:!1,in:"animate__rollIn",out:"animate__rollOut",delay:800},ajax:{route:"",target:"",method:"get",loader:!1,once:!1,output:!0}},e)),this._scrollBar=new h,this._backdropElement=null,this._params.animation.delay=this._params.animation.enable?this._params.animation.delay:0,this._addEventListeners(),this._dismissElement(),this._animation(this._element,Nn,this._params.animation)}static get NAME(){return"sidebar"}static get NAME_KEY(){return Nn}static getOpenSidebars(t=null){return s.A.findAll(".vg-sidebar.show").filter(e=>e!==t)}static getBackdropElement(){const t=s.A.findAll(`.vg-backdrop[${$n}="${Hn}"]`);return t.length?t[t.length-1]:null}toggle(t){return this._isShown()?this.hide():this.show(t)}_showPopstateHandler=null;show(t){if((0,r.d6)(this._element)||this._isShown())return;if(t&&(this._params=this._getParams(t,this._params)),this._route((t,e)=>{g.A.trigger(this._element,Bn.LOADED,{stats:t,data:e})}),g.A.trigger(this._element,Bn.SHOW,{relatedTarget:t}).defaultPrevented)return;const e=jn.getOpenSidebars(this._element).length>0;let i=null;this._params.backdrop&&(e?(i=jn.getBackdropElement(),i?this._backdropElement=i:p.show(t=>{i=t,this._backdropElement=t,t.setAttribute($n,Hn)})):p.show(t=>{i=t,this._backdropElement=t,t.setAttribute($n,Hn)})),this._params.overflow&&!e&&this._scrollBar.hide(),this._params.hash&&(history.pushState(null,"",`#${this._element.id}`),this._showPopstateHandler&&g.A.off(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler),this._showPopstateHandler=()=>this.hide(),g.A.on(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler)),this._element.classList.add(Fn),document.body.classList.add(Rn),this._queueCallback(()=>{const e=this._params.backdrop?i||jn.getBackdropElement():null;e&&g.A.on(e,"mousedown.vg.backdrop",()=>this.hide()),g.A.trigger(this._element,Bn.SHOWN,{relatedTarget:t})},this._element,!0,50)}hide(t=!1){if((0,r.d6)(this._element)||!this._isShown())return;if(g.A.trigger(this._element,Bn.HIDE).defaultPrevented)return;this._element.classList.remove(Fn);const e=jn.getOpenSidebars(this._element);e.length||document.body.classList.remove(Rn),setTimeout(()=>{this._element.setAttribute("aria-expanded","false"),this._queueCallback(()=>{t||(this._params.backdrop&&!e.length?p.hide(()=>{this._backdropElement=null,this._params.overflow&&!p.isActive()&&this._scrollBar.reset()},this._backdropElement||jn.getBackdropElement()):this._params.backdrop?this._backdropElement=null:this._params.overflow&&(e.length||p.isActive()||this._scrollBar.reset()),this._params.hash&&window.location.hash===`#${this._element.id}`&&history.replaceState("",document.title,window.location.pathname+window.location.search),this._showPopstateHandler&&(g.A.off(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler),this._showPopstateHandler=null),g.A.trigger(this._element,Bn.HIDDEN))},this._element,!0)},this._params.animation.delay)}dispose(){super.dispose(),g.A.off(this._element,Bn.HIDE),this._showPopstateHandler&&g.A.off(window,Bn.POPSTATE_DATA_API,this._showPopstateHandler),this._scrollBar.reset()}_isShown(){return this._element.classList.contains(Fn)}_addEventListeners(){g.A.on(document,Bn.KEYDOWN_DISMISS,t=>{"Escape"===t.key&&(this._params.keyboard?this.hide():g.A.trigger(this._element,Bn.HIDE_PREVENTED))})}}(0,f.P)(jn),g.A.on(document,Bn.CLICK_DATA_API,'[data-vg-toggle="sidebar"]',function(t){const e=s.A.getElementFromSelector(this);e&&(["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,r.d6)(this)||(this.setAttribute("aria-expanded","true"),g.A.one(e,Bn.HIDDEN,()=>{this.setAttribute("aria-expanded","false")}),jn.getOrCreateInstance(e).toggle(this)))}),g.A.on(document,Bn.DOM_LOADED_DATA_API,function(){const t=window.location.hash.slice(1);if(!t)return;const e=s.A.find(`#${t}`);if(e&&e.classList.contains("vg-sidebar")&&!(0,r.d6)(e)){const t=jn.getOrCreateInstance(e);t._params.hash&&t.toggle()}});const Un=jn,qn="vg.spy",Vn=`.${qn}`,Wn=".data-api",Kn=`activate${Vn}`,Gn=`click${Vn}`,Yn=`load${Vn}${Wn}`,Xn="active",Zn="[href], [data-vg-target]",Jn=".nav-link",Qn=`${Jn}, .nav-item > ${Jn}, .list-group-item`;class ta extends t.A{constructor(t,e){super(t,e),this._params=this._configAfterMerge((0,r._v)({offset:null,rootMargin:"0px 0px -25%",smoothScroll:!0,target:this._element,threshold:[.1,.5,1]},e)),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement=null,this._activeTarget=null,this._observer=null,this._scrollbar=null,this._scrollbarListener=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get NAME(){return"spy"}static get NAME_KEY(){return qn}refresh(){this._initializeTargetsAndObservables(),this._updateRootElement(),this._maybeEnableSmoothScroll(),this._setupTracking()}_setupTracking(){this._updateSmoothScrollbar(),this._scrollbar?this._setupScrollbarTracking():(this._teardownScrollbarTracking(),this._rebuildObserver(),this._rootElement&&!this._isScrollableSelf(this._rootElement)&&window.Scrollbar&&setTimeout(()=>{this._scrollbar||(this._updateSmoothScrollbar(),this._scrollbar&&this._setupScrollbarTracking())},0))}_updateSmoothScrollbar(){const t=this._rootElement,e=window.Scrollbar;let i=null;t&&(i=t.scrollbar||null,!i&&e&&"function"==typeof e.get&&(i=e.get(t)||null)),i!==this._scrollbar&&(this._teardownScrollbarTracking(),this._scrollbar=i)}_setupScrollbarTracking(){this._scrollbar&&"function"==typeof this._scrollbar.addListener&&(this._observer&&this._observer.disconnect(),this._scrollbarListener&&"function"==typeof this._scrollbar.removeListener&&this._scrollbar.removeListener(this._scrollbarListener),this._scrollbarListener=t=>this._onScrollbarScroll(t),this._scrollbar.addListener(this._scrollbarListener),this._onScrollbarScroll(null))}_teardownScrollbarTracking(){this._scrollbar&&this._scrollbarListener&&"function"==typeof this._scrollbar.removeListener&&this._scrollbar.removeListener(this._scrollbarListener),this._scrollbarListener=null}_onScrollbarScroll(t){const e=t?.offset?.y??this._getParentScrollTop(),i=e>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=e;const s=this._getActivationLine(e),n=[];for(const[t,e]of this._observableSections.entries()){if(!e||!(0,r.zN)(e))continue;const i=this._targetLinks.get(t);i&&n.push({top:this._getSectionTop(e),link:i})}n.sort((t,e)=>t.top-e.top);let a=null;for(const t of n)if(t.top<=s)a=t.link;else if(!i)break;this._process(a)}_getActivationLine(t){const e=this._rootElement?this._rootElement.clientHeight:window.innerHeight||document.documentElement.clientHeight||0,i=(this._params.rootMargin||"").trim(),s=i?i.split(/\s+/):[],r=1===s.length||2===s.length?s[0]:s.length>=3?s[2]:null;if(r&&r.endsWith("%")){const i=Number.parseFloat(r);if(!Number.isNaN(i))return t+e*(1+i/100)}if(r&&r.endsWith("px")){const i=Number.parseFloat(r);if(!Number.isNaN(i))return t+e+i}return t+.75*e}_rebuildObserver(){this._observer&&this._observer.disconnect(),this._observer=this._getNewObserver();for(const t of this._observableSections.values())this._observer.observe(t)}_updateRootElement(){if(this._rootElement=this._normalizeScrollRoot(this._params.target),!this._rootElement&&this._isScrollableSelf(this._element)&&(this._rootElement=this._element),!this._rootElement){const t=this._observableSections.values().next().value||null;t&&this._isScrollable(t)?this._rootElement=t.parentElement:this._rootElement=t?this._getScrollParent(t):null}this._updateSmoothScrollbar(),this._previousScrollData.parentScrollTop=this._getParentScrollTop(),this._previousScrollData.visibleEntryTop=0}_normalizeScrollRoot(t){const e=(0,r.V6)(t);if(!e)return null;if(e===document.body||e===document.documentElement)return null;if(this._isScrollableSelf(e))return e;const i=window.Scrollbar;return e.scrollbar||i&&"function"==typeof i.get&&i.get(e)?e:null}_isScrollable(t){if(!(t instanceof HTMLElement))return!1;const e=t.parentElement;return!!e&&this._isScrollableSelf(e)}_isScrollableSelf(t){if(!(t instanceof HTMLElement))return!1;const e=getComputedStyle(t).overflowY;return!!/(auto|scroll|overlay)/.test(e)&&t.scrollHeight>t.clientHeight}_getScrollParent(t){for(let e=t.parentElement;e&&e!==document.body;e=e.parentElement)if(this._isScrollableSelf(e))return e;return null}_getSectionTop(t){if(this._rootElement){const e=this._rootElement.getBoundingClientRect(),i=t.getBoundingClientRect();return(this._scrollbar?.offset?.y??this._rootElement.scrollTop)+(i.top-e.top)}return(window.scrollY||document.documentElement.scrollTop||0)+t.getBoundingClientRect().top}_getParentScrollTop(){return this._scrollbar?this._scrollbar.offset?.y??0:this._rootElement?this._rootElement.scrollTop:window.scrollY||document.documentElement.scrollTop||0}dispose(){this._observer&&this._observer.disconnect(),this._teardownScrollbarTracking(),this._scrollbar=null,super.dispose()}_configAfterMerge(t){return t.target=(0,r.V6)(t.target)||document.body,null!=t.offset&&(t.rootMargin=`${t.offset}px 0px -30%`),"string"==typeof t.threshold&&(t.threshold=t.threshold.split(",").map(t=>Number.parseFloat(t.trim()))),t}_maybeEnableSmoothScroll(){this._params.smoothScroll&&(g.A.off(this._element,Gn),g.A.on(this._element,Gn,Zn,t=>{const e=t.delegateTarget||t.target,i=this._getTargetIdFromTrigger(e);if(!i)return;let n=this._observableSections.get(i);if(n||(n=s.A.findID(i),n&&(this._targetLinks.set(n.id,e),this._observableSections.set(n.id,n))),!n)return;if(!(0,r.zN)(n))return void setTimeout(()=>{const t=s.A.findID(i);if(!t||!(0,r.zN)(t))return;this._targetLinks.set(t.id,e),this._observableSections.set(t.id,t),this._updateRootElement(),this._setupTracking();const n=this._getSectionTop(t);this._scrollbar&&"function"==typeof this._scrollbar.scrollTo?this._scrollbar.scrollTo(0,n,600):this._rootElement?this._rootElement.scrollTo?this._rootElement.scrollTo({top:n,behavior:"smooth"}):this._rootElement.scrollTop=n:window.scrollTo?window.scrollTo({top:n,behavior:"smooth"}):document.documentElement.scrollTop=n,this._process(e)},0);t.preventDefault(),this._updateRootElement(),this._setupTracking();const a=this._getSectionTop(n),o=this._rootElement;return this._scrollbar&&"function"==typeof this._scrollbar.scrollTo?(this._scrollbar.scrollTo(0,a,600),void this._process(e)):o?(o.scrollTo?o.scrollTo({top:a,behavior:"smooth"}):o.scrollTop=a,void this._process(e)):(window.scrollTo?window.scrollTo({top:a,behavior:"smooth"}):document.documentElement.scrollTop=a,void this._process(e))}))}_getNewObserver(){const t={root:this._rootElement,rootMargin:this._params.rootMargin,threshold:this._params.threshold};return new IntersectionObserver(t=>this._observerCallback(t),t)}_observerCallback(t){const e=t=>this._targetLinks.get(t.target.id),i=this._getParentScrollTop(),s=i>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=i;for(const i of t){if(!i.isIntersecting){this._clearActiveClass(e(i));continue}const t=this._getSectionTop(i.target),r=t>=this._previousScrollData.visibleEntryTop;(s&&r||!s&&!r)&&(this._previousScrollData.visibleEntryTop=t,this._process(e(i)))}}_initializeTargetsAndObservables(){this._targetLinks.clear(),this._observableSections.clear();const t=s.A.findAll(Zn,this._element);for(const e of t){if((0,r.d6)(e))continue;const t=this._getTargetIdFromTrigger(e);if(!t)continue;const i=s.A.findID(t);i&&(this._targetLinks.set(i.id,e),this._observableSections.set(i.id,i))}}_process(t){this._activeTarget!==t&&(this._clearActiveClass(this._element),this._activeTarget=t,t&&(t.classList.add(Xn),this._activateParents(t),g.A.trigger(this._element,Kn,{relatedTarget:t})))}_activateParents(t){if(t.classList.contains("vg-dropdown-item")){const e=s.A.find('[data-vg-toggle="dropdown"]',t.closest(".vg-dropdown"));return void(e&&e.classList.add(Xn))}for(const e of s.A.parents(t,".nav, .list-group"))for(const t of s.A.prev(e,Qn))t.classList.add(Xn)}_clearActiveClass(t){if(!t)return;t.classList.remove(Xn);const e=s.A.findAll(`[href].${Xn}, [data-vg-target].${Xn}`,t);for(const t of e)t.classList.remove(Xn)}_getTargetIdFromTrigger(t){if(!t||"function"!=typeof t.getAttribute)return null;const e=(t.getAttribute("data-vg-target")||"").trim(),i=(t.getAttribute("href")||"").trim(),s=e&&"#"!==e?e:i&&(i.includes("#")||i.startsWith("#"))?i.includes("#")&&!i.startsWith("#")?`#${i.split("#")[1]}`:i:null;if(!s||"#"===s||!s.startsWith("#"))return null;const r=this._safeDecode(s);return r&&r.startsWith("#")&&r.length>1?r.slice(1):null}_safeDecode(t){try{return decodeURIComponent(t)}catch{try{return decodeURI(t)}catch{return t}}}}(()=>{let t=!1;const e=()=>{if(!t){t=!0;for(const t of s.A.findAll('[data-vg-toggle="spy"]'))ta.getOrCreateInstance(t)}};"loading"===document.readyState?g.A.on(document,`DOMContentLoaded${Vn}${Wn}`,e):e(),g.A.on(window,Yn,e)})();const ea=ta,ia="vg.tabs",sa=`${ia}.hide`,ra=`${ia}.hidden`,na=`${ia}.show`,aa=`${ia}.shown`,oa=`${ia}.loaded`,la=`keydown.${ia}`,ha=`load.${ia}`,da=`click.${ia}`,ca=`mouseover.${ia}`,_a=`mouseout.${ia}`,ua=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ma="ArrowRight",pa="ArrowDown",ga="Home",fa="End",ba="active",va="hover",ya="fade",wa="show",Ea="vg-tabs-slider",Aa='.vg-tabs-link:not([data-vg-toggle="dropdown"]), .list-group-item:not([data-vg-toggle="dropdown"]), [role="tab"]:not([data-vg-toggle="dropdown"])',Sa='[data-vg-toggle="tab"]',Ca={DROPDOWN_TOGGLE:'[data-vg-toggle="dropdown"]',DROPDOWN_MENU:".dropdown-content",TAB_CLASS:".vg-tabs",TAB_PANEL:'.list-group, .vg-tabs-panel, [role="tablist"]',OUTER:".vg-tabs-item, .list-group-item",INNER:Aa,DATA_TOGGLE:Sa,INNER_ELEM:`${Aa}, ${Sa}`,DATA_TOGGLE_ACTIVE:'.active[data-vg-toggle="tab"]'};class xa extends t.A{constructor(t,e){if(super(t,e),this._params=(0,r._v)({slide:!1,hash:!1,ajax:{route:"",target:"",method:"get",loader:!1,once:!0,output:!0}},this._params),this._parent=this._element.closest(Ca.TAB_PANEL),this._main_parent=this._parent?.closest(Ca.TAB_CLASS)||null,!this._parent)throw new TypeError(`${t.outerHTML} не имеет родителя с селектором ${Ca.INNER_ELEM}`);this._params=this._getParams(this._main_parent,this._params),this._params=this._getParams(this._element,this._params),this._setInitialAttributes(this._parent,this._getChildren()),this._setInitialSlider(),this._setTabHash(),g.A.on(this._element,la,t=>this._keydown(t))}static get NAME(){return"tabs"}static get NAME_KEY(){return ia}show(){const t=this._element;if(this._elemIsActive(t))return;const e=this._getActiveElem(),i=t,s=e?g.A.trigger(e,sa,{relatedTarget:i}):null;g.A.trigger(t,na,{relatedTarget:i}).defaultPrevented||s&&s.defaultPrevented||(this._deactivate(e,t),this._activate(t,i))}_elemIsActive(t){return t?.classList.contains(ba)||!1}_getActiveElem(){return this._getChildren().find(t=>this._elemIsActive(t))||null}_activate(t,e){if(!t)return;t.classList.add(ba);const i=s.A.getElementFromSelector(t);i&&this._activate(i,e),this._queueCallback(()=>{"tab"===t.getAttribute("role")?(this._route((t,e)=>{g.A.trigger(this._element,oa,{stats:t,data:e})}),t.removeAttribute("tabindex"),t.setAttribute("aria-selected","true"),this._toggleDropDown(t,!0),g.A.trigger(t,aa,{relatedTarget:e})):t.classList.add(wa)},t,t.classList.contains(ya))}_deactivate(t,e){if(!t)return;t.classList.remove(ba),t.blur();const i=s.A.getElementFromSelector(t);i&&this._deactivate(i,e),this._queueCallback(()=>{"tab"===t.getAttribute("role")?(t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1"),this._toggleDropDown(t,!1),g.A.trigger(t,ra,{relatedTarget:e})):t.classList.remove(wa)},t,t.classList.contains(ya))}_keydown(t){if(!ua.includes(t.key))return;t.stopPropagation(),t.preventDefault();const e=this._getChildren().filter(t=>!(0,r.d6)(t));let i;if([ga,fa].includes(t.key))i=e[t.key===ga?0:e.length-1];else{const s=[ma,pa].includes(t.key);i=(0,r.iq)(e,t.target,s,!0)}i&&(i.focus({preventScroll:!0}),xa.getOrCreateInstance(i).show())}_setTabHash(){if(!this._params.hash)return;const t=document.location.toString();if(!t.includes("#"))return;const e=t.split("#")[1],i=s.A.find(`[href="#${e}"]`,this._parent)||s.A.find(`[data-vg-target="#${e}"]`,this._element)||null;i&&xa.getOrCreateInstance(i).show()}_setInitialSlider(){if(!this._params.slide)return;let t=s.A.find(`.${Ea}`,this._main_parent);t||(t=document.createElement("span"),t.classList.add(Ea),this._main_parent.prepend(t)),this._main_parent.classList.add("vg-tabs-with-slider");const e=s.A.find(`.${ba}`,this._parent);if(!e)return;const{width:i,height:n}=window.getComputedStyle(e);e.classList.add(va),t.style.width=i,t.style.height=n,t.style.left=`${e.offsetLeft}px`,g.A.on(this._main_parent,ca,Ca.DATA_TOGGLE,e=>{const i=e.target;if(["A","AREA"].includes(i.tagName)&&e.preventDefault(),(0,r.d6)(i))return;const n=s.A.find(`.${va}`,this._parent);n&&n.classList.remove(va),i.classList.add(va);const{width:a,height:o}=window.getComputedStyle(i);t.style.width=a,t.style.height=o,t.style.left=`${i.offsetLeft}px`}),g.A.on(this._main_parent,_a,Ca.DATA_TOGGLE,()=>{const e=s.A.find(`.${ba}`,this._parent),{width:i,height:r}=window.getComputedStyle(e);s.A.findAll(`.${va}`,this._parent).forEach(t=>t.classList.remove(va)),e.classList.add(va),t.style.width=i,t.style.height=r,t.style.left=`${e.offsetLeft}px`})}_setInitialAttributes(t,e){this._setAttributeIfNotExists(t,"role","tablist"),e.forEach(t=>this._setInitialAttributesOnChild(t))}_setInitialAttributesOnChild(t){t=this._getInnerElement(t);const e=this._elemIsActive(t),i=this._getOuterElement(t);t.setAttribute("aria-selected",e),i!==t&&this._setAttributeIfNotExists(i,"role","presentation"),e||t.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(t,"role","tab"),this._setInitialAttributesOnTargetPanel(t)}_setInitialAttributesOnTargetPanel(t){const e=s.A.getElementFromSelector(t);e&&(this._setAttributeIfNotExists(e,"role","tabpanel"),t.id&&this._setAttributeIfNotExists(e,"aria-labelledby",t.id))}_setAttributeIfNotExists(t,e,i){t.hasAttribute(e)||t.setAttribute(e,i)}_getChildren(){return s.A.findAll(Ca.INNER_ELEM,this._parent)}_getInnerElement(t){return t.matches(Ca.INNER_ELEM)?t:s.A.find(Ca.INNER_ELEM,t)}_getOuterElement(t){return t.closest(Ca.OUTER)||t}_toggleDropDown(t,e){const i=this._getOuterElement(t);if(!i.classList.contains("dropdown"))return;const r=(t,r)=>{const n=s.A.find(t,i);n&&n.classList.toggle(r,e)};r(Ca.DROPDOWN_TOGGLE,ba),r(Ca.DROPDOWN_MENU,wa),i.setAttribute("aria-expanded",e)}}g.A.on(document,da,Ca.DATA_TOGGLE,function(t){["A","AREA"].includes(this.tagName)&&t.preventDefault(),(0,r.d6)(this)||xa.getOrCreateInstance(this).show()}),g.A.on(window,ha,()=>{s.A.findAll(Ca.DATA_TOGGLE_ACTIVE).forEach(t=>{xa.getOrCreateInstance(t)})});const La=xa,Ia="th",Pa='a, button, input, select, textarea, [contenteditable="true"], [data-vg-table-column-resize-handle]',Ma=class{constructor(t,e={},i=t){this._table=t,this._headerTable=i,this._options=Object.assign({hover:!1,multiple:!1,multipleWithShift:!0},e),this._headers=[],this._originalRows=new Map,this._sorts=[],this._boundClick=this._handleClick.bind(this),this._boundKeydown=this._handleKeydown.bind(this)}init(){this._headers=this._getHeaders(),this._rememberOriginalRows(),this._table.classList.toggle("vg-table-sort-hover",!0===this._options.hover),this._headerTable.classList.toggle("vg-table-sort-hover",!0===this._options.hover),this._table.classList.toggle("vg-table-sort-multiple",!0===this._options.multiple),this._headerTable.classList.toggle("vg-table-sort-multiple",!0===this._options.multiple),this._headers.forEach(t=>{this._isSortable(t)&&(t.classList.add("vg-table-sortable"),t.setAttribute("aria-sort","none"),this._decorateHeader(t),t.hasAttribute("tabindex")||(t.tabIndex=0))}),this._headerTable.addEventListener("click",this._boundClick),this._headerTable.addEventListener("keydown",this._boundKeydown)}dispose(){this._headerTable.removeEventListener("click",this._boundClick),this._headerTable.removeEventListener("keydown",this._boundKeydown),this._table.classList.remove("vg-table-sort-hover"),this._headerTable.classList.remove("vg-table-sort-hover"),this._table.classList.remove("vg-table-sort-multiple"),this._headerTable.classList.remove("vg-table-sort-multiple"),this._headers.forEach(t=>{t.classList.remove("vg-table-sortable"),t.removeAttribute("aria-sort"),t.removeAttribute("data-sort-direction"),t.removeAttribute("data-sort-priority"),t.querySelector("[data-vg-table-sort-controls]")?.remove()}),this._sorts=[],this._syncColumnHighlight(),this._headers=[],this._originalRows.clear()}setSort(t,e="asc",i=!1){const s=this._resolveColumnIndex(t);return this.setSorts([{columnIndex:s,direction:e}],i)}setSorts(t=[],e=!1){const i=this._normalizeSorts(t);return!(t.length&&!i.length||(this._sorts=!0===this._options.multiple?i:i.slice(0,1),this._applySort(),this._syncHeaders(),e&&this._emitChange(),0))}getSort(){const t=this._sorts[0];if(!t)return null;const e=this._headers[t.index];return{columnIndex:t.index,field:e?String(e.getAttribute("data-field")||"").trim():"",direction:t.direction}}getSorts(){return this._sorts.map(t=>{const e=this._headers[t.index];return{columnIndex:t.index,field:e?String(e.getAttribute("data-field")||"").trim():"",direction:t.direction}})}getSortState(){const t=this.getSort();return t?Object.assign({},t,{sorts:this.getSorts()}):null}refresh(t=!1){if(t){const t=this.getSorts();this._headers=this._getHeaders(),this._headers.forEach(t=>{this._isSortable(t)&&(t.classList.add("vg-table-sortable"),t.hasAttribute("aria-sort")||t.setAttribute("aria-sort","none"),this._decorateHeader(t),t.hasAttribute("tabindex")||(t.tabIndex=0))}),this.setSorts(t,!1)}else this._syncColumnHighlight();return this.getSort()}clearSort(t=!1){this._sorts=[],!0!==this._options.remote&&this._restoreOriginalRows(),this._syncHeaders(),t&&this._emitChange()}_getHeaders(){const t=this._headerTable.tHead||this._headerTable.querySelector("thead");return t&&t.rows.length?Array.from(t.rows[t.rows.length-1].querySelectorAll(Ia)):[]}_isSortable(t){return"false"!==String(t.getAttribute("data-sort-enabled")||"").toLowerCase()}_rememberOriginalRows(){Array.from(this._table.tBodies||[]).forEach(t=>{this._originalRows.set(t,Array.from(t.rows))})}_restoreOriginalRows(){this._originalRows.forEach((t,e)=>{t.forEach(t=>e.append(t))})}_handleClick(t){if(t.target.closest(Pa))return;const e=t.target.closest(Ia);e&&this._headers.includes(e)&&this._isSortable(e)&&this._cycleSort(this._headers.indexOf(e),this._isMultipleMode(t))}_handleKeydown(t){if("Enter"!==t.key&&" "!==t.key)return;if(t.target.closest(Pa))return;const e=t.target.closest(Ia);e&&this._headers.includes(e)&&this._isSortable(e)&&(t.preventDefault(),this._cycleSort(this._headers.indexOf(e),this._isMultipleMode(t)))}_isMultipleMode(t){return!0===this._options.multiple&&(!1===this._options.multipleWithShift||!0===t?.shiftKey)}_cycleSort(t,e=!1){const i=this._sorts.find(e=>e.index===t);if(!i)return void this._setColumnSort(t,"asc",e);if("asc"===i.direction)return void this._setColumnSort(t,"desc",e);const s=e?this._sorts.filter(e=>e.index!==t):[];this.setSorts(s,!0)}_setColumnSort(t,e,i){const s=i?this._sorts.slice():[],r=s.findIndex(e=>e.index===t),n={columnIndex:t,direction:e};r>=0?s.splice(r,1,n):s.push(n),this.setSorts(s,!0)}_applySort(){!0!==this._options.remote&&this._sorts.length&&this._originalRows.forEach((t,e)=>{const i=new Map(t.map((t,e)=>[t,e])),s=Array.from(e.rows);s.sort((t,e)=>{for(const i of this._sorts){const s=this._headers[i.index],r=String(s?.getAttribute("data-sort-type")||"auto").toLowerCase(),n=this._compareCells(t.cells[i.index],e.cells[i.index],r);if(0!==n)return"desc"===i.direction?-n:n}return(i.get(t)??0)-(i.get(e)??0)}),s.forEach(t=>e.append(t))})}_compareCells(t,e,i){const s=this._getCellValue(t),r=this._getCellValue(e);if("number"===i||"auto"===i&&this._isNumeric(s)&&this._isNumeric(r))return this._toNumber(s)-this._toNumber(r);if("date"===i){const t=Date.parse(s),e=Date.parse(r);if(!Number.isNaN(t)&&!Number.isNaN(e))return t-e}return s.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}_getCellValue(t){return t?String(t.getAttribute("data-sort-value")??t.textContent??"").trim():""}_isNumeric(t){return""!==t&&Number.isFinite(this._toNumber(t))}_toNumber(t){return Number(String(t).replace(/\s/g,"").replace(",","."))}_decorateHeader(t){if(t.querySelector("[data-vg-table-sort-controls]"))return;const e=document.createElement("span");e.className="vg-table-sort-controls",e.setAttribute("data-vg-table-sort-controls",""),e.setAttribute("aria-hidden","true"),e.innerHTML='\n\t\t\t<span class="vg-table-sort-priority" data-vg-table-sort-priority hidden></span>\n\t\t\t<span class="vg-table-sort-chevron vg-table-sort-chevron-asc"></span>\n\t\t\t<span class="vg-table-sort-chevron vg-table-sort-chevron-desc"></span>\n\t\t',t.append(e)}_syncHeaders(){this._headers.forEach((t,e)=>{const i=this._sorts.findIndex(t=>t.index===e),s=i>=0?this._sorts[i].direction:null,r=t.querySelector("[data-vg-table-sort-priority]");t.setAttribute("aria-sort","asc"===s?"ascending":"desc"===s?"descending":"none"),s?(t.setAttribute("data-sort-direction",s),t.setAttribute("data-sort-priority",String(i+1)),r&&(r.textContent=String(i+1),r.hidden=this._sorts.length<2)):(t.removeAttribute("data-sort-direction"),t.removeAttribute("data-sort-priority"),r&&(r.hidden=!0))}),this._syncColumnHighlight()}_syncColumnHighlight(){const t=[...Array.from(this._headerTable.rows||[]),...Array.from(this._table.rows||[])].filter(t=>!t.hasAttribute("data-vg-table-state-row"));t.forEach(t=>{Array.from(t.cells||[]).forEach(t=>{t.removeAttribute("data-sorted-column"),t.removeAttribute("data-sorted-priority")})}),this._sorts.forEach((e,i)=>t.forEach(t=>{const s=t.cells[e.index];s&&(s.setAttribute("data-sorted-column","1"),s.setAttribute("data-sorted-priority",String(i+1)))}))}_normalizeSorts(t){const e=[],i=new Set;return(Array.isArray(t)?t:[]).forEach(t=>{const s=t?.field??t?.columnIndex??t?.index,r=this._resolveColumnIndex(s);r<0||i.has(r)||!this._isSortable(this._headers[r])||(i.add(r),e.push({index:r,direction:"desc"===String(t?.direction??t?.dir??"asc").toLowerCase()?"desc":"asc"}))}),e}_emitChange(){g.A.trigger(this._table,"sortchange.vg.table",{sort:this.getSort(),sorts:this.getSorts()})}_resolveColumnIndex(t){if("string"==typeof t)return this._headers.findIndex(e=>String(e.getAttribute("data-field")||"").trim()===t.trim());const e=Number.parseInt(t,10);return Number.isInteger(e)?e:-1}},ka=class{constructor(t,e={}){this._scrollHost=t.closest(".vg-table-body")||t.closest(".vg-table-container")||t.closest(".vg-table-wrapper"),this._stateTarget=t.closest(".vg-table-wrapper")||this._scrollHost,this._onMove="function"==typeof e.onMove?e.onMove:null,this._active=!1,this._moved=!1,this._pointerId=null,this._startX=0,this._startScrollLeft=0,this._suppressClick=!1,this._suppressClickTimer=null,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundPointerCancel=this._handlePointerCancel.bind(this),this._boundClick=this._handleClick.bind(this)}init(){this._scrollHost&&(this._scrollHost.addEventListener("pointerdown",this._boundPointerDown),this._scrollHost.addEventListener("pointermove",this._boundPointerMove),this._scrollHost.addEventListener("pointerup",this._boundPointerUp),this._scrollHost.addEventListener("pointercancel",this._boundPointerCancel),this._scrollHost.addEventListener("click",this._boundClick,!0))}dispose(){this._scrollHost&&(this._scrollHost.removeEventListener("pointerdown",this._boundPointerDown),this._scrollHost.removeEventListener("pointermove",this._boundPointerMove),this._scrollHost.removeEventListener("pointerup",this._boundPointerUp),this._scrollHost.removeEventListener("pointercancel",this._boundPointerCancel),this._scrollHost.removeEventListener("click",this._boundClick,!0),this._scrollHost.classList.remove("is-panning"),this._stateTarget?.classList.remove("is-panning"),this._suppressClickTimer&&window.clearTimeout(this._suppressClickTimer),this._reset())}_handlePointerDown(t){t.isPrimary&&"mouse"===t.pointerType&&0===t.button&&t.shiftKey&&(this._scrollHost.scrollWidth<=this._scrollHost.clientWidth||t.target.closest('a, button, input, select, textarea, [contenteditable="true"], [role="button"]')||(this._active=!0,this._moved=!1,this._pointerId=t.pointerId,this._startX=t.clientX,this._startScrollLeft=this._scrollHost.scrollLeft,this._stateTarget.classList.add("is-panning"),t.cancelable&&t.preventDefault(),"function"==typeof this._scrollHost.setPointerCapture&&this._scrollHost.setPointerCapture(t.pointerId)))}_handlePointerMove(t){if(!this._active||t.pointerId!==this._pointerId)return;const e=t.clientX-this._startX;!this._moved&&Math.abs(e)>4&&(this._moved=!0),this._scrollHost.scrollLeft=this._startScrollLeft-e,this._onMove?.(this._scrollHost.scrollLeft),this._moved&&t.cancelable&&t.preventDefault()}_handlePointerUp(t){if(t.pointerId===this._pointerId){if("function"==typeof this._scrollHost.releasePointerCapture)try{this._scrollHost.releasePointerCapture(t.pointerId)}catch(t){}this._moved&&(this._suppressClick=!0,this._suppressClickTimer=window.setTimeout(()=>{this._suppressClick=!1,this._suppressClickTimer=null},0)),this._reset()}}_handlePointerCancel(t){t.pointerId===this._pointerId&&this._reset()}_handleClick(t){this._suppressClick&&(this._suppressClick=!1,this._suppressClickTimer&&window.clearTimeout(this._suppressClickTimer),this._suppressClickTimer=null,t.preventDefault(),t.stopImmediatePropagation())}_reset(){this._active=!1,this._moved=!1,this._pointerId=null,this._stateTarget?.classList.remove("is-panning")}},Da="tbody tr",Ta="vg-table-row-selected",Oa="data-vg-table-selected",za=class{constructor(t,e={}){this._table=t,this._options=Object.assign({click:!0,multiple:!1},e),this._boundClick=this._handleClick.bind(this)}init(){this._table.classList.toggle("vg-table-selection-click",!0===this._options.click),!0===this._options.click&&this._table.addEventListener("click",this._boundClick)}dispose(){this._table.removeEventListener("click",this._boundClick),this._table.classList.remove("vg-table-selection-click"),this.getSelectedRows().forEach(t=>this._setRowState(t,!1))}selectRow(t,e=!0,i=!0){const s=this._resolveRow(t);if(!s)return!1;const r=!0===e;return r===s.classList.contains(Ta)||(r&&!0!==this._options.multiple&&this.getSelectedRows().forEach(t=>{t!==s&&this._setRowState(t,!1)}),this._setRowState(s,r),i&&this._emitChange(s,r)),!0}toggleRow(t,e=!0){const i=this._resolveRow(t);return!!i&&this.selectRow(i,!i.classList.contains(Ta),e)}getSelectedRows(){return this._getRows().filter(t=>t.classList.contains(Ta))}clearSelection(t=!0){const e=this.getSelectedRows();return!!e.length&&(e.forEach(t=>this._setRowState(t,!1)),t&&this._emitChange(null,!1),!0)}_handleClick(t){if(t.target.closest('a, button, input, select, textarea, label, [contenteditable="true"], [role="button"], [data-vg-table-selection-ignore]'))return;const e=t.target.closest(Da);e&&this._table.contains(e)&&this.toggleRow(e)}_getRows(){return Array.from(this._table.tBodies||[]).flatMap(t=>Array.from(t.rows||[]))}_resolveRow(t){if(t instanceof Element){const e=t.matches(Da)?t:t.closest(Da);return e&&this._table.contains(e)?e:null}const e=Number.parseInt(t,10);return Number.isInteger(e)&&this._getRows()[e]||null}_setRowState(t,e){t.classList.toggle(Ta,e),e?t.setAttribute(Oa,"true"):t.removeAttribute(Oa)}_emitChange(t,e){const i=this.getSelectedRows(),s=this._getRows(),r=i.map(t=>t.getAttribute("data-row-key")||String(s.indexOf(t)));g.A.trigger(this._table,"selectionchange.vg.table",{row:t,selected:e,rows:i,keys:r})}},Na="pagechange.vg.table",$a="data-vg-table-pagination-generated",Ha=class{constructor(t,e={}){this._table=t,this._options=e,this._host=t.closest(".vg-table-wrapper")||t.parentElement,this._containers=[],this._dropdowns=[],this._page=this._positiveInt(e.page,1),this._perPage=this._clampPerPage(e.per),this._remote=!0===e.remote,this._totalRowsValue=0,this._totalPagesValue=this._remote?this._page:1,this._boundClick=this._handleClick.bind(this),this._boundChange=this._handleChange.bind(this),this._boundKeydown=this._handleKeydown.bind(this),this._boundFocusIn=this._handleFocusIn.bind(this),this._boundFocusOut=this._handleFocusOut.bind(this)}init(){this._restoreState(),this._containers=this._resolveContainers(),this._containers.forEach(t=>{t.addEventListener("click",this._boundClick),t.addEventListener("change",this._boundChange),t.addEventListener("keydown",this._boundKeydown),t.addEventListener("focusin",this._boundFocusIn),t.addEventListener("focusout",this._boundFocusOut)}),this.refresh()}dispose(){this._disposeDropdowns(),this._containers.forEach(t=>{t.removeEventListener("click",this._boundClick),t.removeEventListener("change",this._boundChange),t.removeEventListener("keydown",this._boundKeydown),t.removeEventListener("focusin",this._boundFocusIn),t.removeEventListener("focusout",this._boundFocusOut),t.hasAttribute($a)&&t.remove()}),this._rows().forEach(t=>{t.hidden="true"===t.getAttribute("data-vg-table-expand-hidden")||t.hasAttribute("data-vg-table-filter-hidden"),t.removeAttribute("data-vg-table-page-row")}),this._containers=[]}setPage(t,e=!1,i="api"){const s=this._clampPage(t);return s!==this._page&&(this._page=s,this._storeState(),this._render(),this._scroll(),e&&this._emit(Na,i),this._notify(i),!0)}setPerPage(t,e=!1,i="api"){const s=this._clampPerPage(t);return(s!==this._perPage||1!==this._page)&&(this._perPage=s,this._page=1,this._storeState(),this._render(),this._scroll(),e&&(this._emit("perpagechange.vg.table",i),this._emit(Na,i)),this._notify(i),!0)}setMeta(t={}){return this._remote?(this._totalRowsValue=this._nonNegativeInt(t.total,this._totalRowsValue),this._totalPagesValue=this._positiveInt(t.pages??t.totalPages,Math.max(1,Math.ceil(this._totalRowsValue/this._perPage))),this._perPage=this._clampPerPage(t.per_page??t.perPage??this._perPage),this._page=Math.min(this._positiveInt(t.page,this._page),this._totalPagesValue),this._storeState(),this._render(),this.getState()):this.getState()}getState(){return{page:this._page,perPage:this._perPage,totalPages:this._totalPages(),totalRows:this._remote?this._totalRowsValue:this._rows().length}}refresh(t=!1){return t&&(this._page=1),this._page=this._clampPage(this._page),this._render(),this.getState()}_render(){if(!this._remote){const t=this._rows(),e=(this._page-1)*this._perPage,i=e+this._perPage;t.forEach((t,s)=>{const r=s>=e&&s<i,n="true"===t.getAttribute("data-vg-table-expand-hidden");t.hidden=!r||n,t.setAttribute("data-vg-table-page-row",r?"visible":"hidden")})}const t=this._buildMarkup();this._disposeDropdowns(),this._containers.forEach(e=>{e.className=`vg-table-pagination vg-table-pagination--${this._positionFor(e)}`,e.innerHTML=t,this._initDropdowns(e)})}_buildMarkup(){const t=this._align(),e=this._options.size||{},i=this._options.quick||{},s=this._options.labels||{},r=this._buildPages(),n=!1===e.enabled?"":this._buildSizeMarkup(e),a=this._isQuickJumpEnabled()?`\n\t\t\t<label class="vg-table-pagination__quick">\n\t\t\t\t<span class="vg-table-pagination__sr-only">${i.label||"Перейти к странице"}</span>\n\t\t\t\t<input type="number" min="1" max="${this._totalPages()}" value="${this._page}" data-pagination-quick-input>\n\t\t\t\t<button type="button" class="vg-table-page vg-table-page--quick" data-pagination-quick-button>${i.button||"Перейти"}</button>\n\t\t\t</label>`:"";return`\n\t\t\t<div class="vg-table-pagination__inner vg-table-pagination__inner--${t}">\n\t\t\t\t${n}\n\t\t\t\t<nav class="vg-table-pagination__pages" aria-label="${s.aria||"Пагинация"}">\n\t\t\t\t\t<button type="button" class="vg-table-page vg-table-page--prev" data-pagination-page="prev" aria-label="${s.prev||"Назад"}" ${this._page<=1?"disabled":""}>${this._buildChevron("prev")}</button>\n\t\t\t\t\t${r.map(t=>this._buildPageButton(t)).join("")}\n\t\t\t\t\t<button type="button" class="vg-table-page vg-table-page--next" data-pagination-page="next" aria-label="${s.next||"Вперёд"}" ${this._page>=this._totalPages()?"disabled":""}>${this._buildChevron("next")}</button>\n\t\t\t\t</nav>\n\t\t\t\t${a}\n\t\t\t</div>`}_buildSizeMarkup(t){const e=this._sizeOptions();return`\n\t\t\t<label class="vg-table-pagination__size">\n\t\t\t\t${!1===t.label?"":`<span class="vg-table-pagination__size-heading">${t.label||"Строк на странице"}</span>`}\n\t\t\t\t<div class="vg-table-pagination__size-control vg-dropdown">\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\tmin="1"\n\t\t\t\t\t\tmax="${this._positiveInt(this._options.max,100)}"\n\t\t\t\t\t\tstep="1"\n\t\t\t\t\t\tinputmode="numeric"\n\t\t\t\t\t\tdata-pagination-per-page\n\t\t\t\t\t\tdata-vg-toggle="dropdown"\n\t\t\t\t\t\tvalue="${this._formatPerPage(this._perPage)}"\n\t\t\t\t\t\taria-label="${t.aria||t.label||"Строк на странице"}"\n\t\t\t\t\t\taria-haspopup="true"\n\t\t\t\t\t>\n\t\t\t\t\t<span class="vg-table-pagination__size-chevron" aria-hidden="true">\n\t\t\t\t\t\t<svg viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="M5 7.5L10 12.5L15 7.5" /></svg>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class="vg-dropdown-content vg-table-pagination__size-dropdown">\n\t\t\t\t\t\t<div class="vg-dropdown-container">\n\t\t\t\t\t\t\t${e.map(t=>`<button type="button" class="vg-table-pagination__size-option" data-pagination-per-page-option="${t}">${this._formatPerPage(t)}</button>`).join("")}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</label>`}_buildPageButton(t){if("object"==typeof t){const e=!1!==this._options.ellipsisHover,i=this._options.labels||{},s="prev"===t.direction?i.ellipsisPrev||"Перейти к предыдущим страницам":i.ellipsisNext||"Перейти к следующим страницам";return`<button type="button" class="vg-table-page vg-table-page--ellipsis${e?" vg-table-page--ellipsis-hover":""}" data-pagination-page="ellipsis-${t.direction}" aria-label="${s}"><span class="vg-table-page__ellipsis-dots" aria-hidden="true">…</span>${e?this._buildEllipsisChevron(t.direction):""}</button>`}const e=t===this._page;return`<button type="button" class="vg-table-page${e?" is-active":""}" data-pagination-page="${t}" ${e?'aria-current="page"':""}>${t}</button>`}_buildChevron(t){return`<svg class="vg-table-page__chevron" viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="${"prev"===t?"M12.5 4.5L7 10l5.5 5.5":"M7.5 4.5L13 10l-5.5 5.5"}" /></svg>`}_buildEllipsisChevron(t){return`<svg class="vg-table-page__ellipsis-chevron vg-table-page__ellipsis-chevron--${t}" viewBox="0 0 20 20" focusable="false" aria-hidden="true">${"prev"===t?'<path d="M10.5 5L5.5 10l5 5" /><path d="M15 5l-5 5 5 5" />':'<path d="M9.5 5l5 5-5 5" /><path d="M5 5l5 5-5 5" />'}</svg>`}_buildPages(){const t=this._totalPages(),e=Math.max(1,this._positiveInt(this._options.visible,5)),i=Math.max(1,this._positiveInt(this._options.threshold,5));if(!1===this._options.ellipsis||t<=i||t<=e+2)return this._range(1,t);let s=Math.max(2,this._page-Math.floor(e/2)),r=Math.min(t-1,s+e-1);s=Math.max(2,r-e+1);const n=[1];s>2&&n.push({direction:"prev"});for(let t=s;t<=r;t+=1)n.push(t);return r<t-1&&n.push({direction:"next"}),n.push(t),n}_handleClick(t){const e=t.target.closest("[data-pagination-per-page-option]");if(e){t.preventDefault();const i=e.getAttribute("data-pagination-per-page-option");return this.setPerPage(i,!0,"per-page"),void this._hideDropdown(e)}const i=t.target.closest("[data-pagination-quick-button]");if(i){const t=i.closest(".vg-table-pagination__quick")?.querySelector("[data-pagination-quick-input]");return void this.setPage(t?.value,!0,"quick")}const s=t.target.closest("[data-pagination-page]");if(!s||s.disabled)return;const r=s.getAttribute("data-pagination-page");"prev"!==r?"next"!==r?"ellipsis-prev"!==r?"ellipsis-next"!==r?this.setPage(r,!0,"page"):this.setPage(this._ellipsisTarget("next"),!0,"ellipsis"):this.setPage(this._ellipsisTarget("prev"),!0,"ellipsis"):this.setPage(this._page+1,!0,"next"):this.setPage(this._page-1,!0,"prev")}_handleChange(t){const e=t.target.closest("[data-pagination-per-page]");e&&this._applyPerPageInput(e)}_handleKeydown(t){const e=t.target.closest("[data-pagination-per-page]");if(e&&"Escape"===t.key)return this._hideDropdown(e),void e.blur();if(e&&"Enter"===t.key)return t.preventDefault(),void this._applyPerPageInput(e);if("Enter"!==t.key)return;const i=t.target.closest("[data-pagination-quick-input]");i&&(t.preventDefault(),this.setPage(i.value,!0,"quick"))}_handleFocusIn(t){const e=t.target.closest("[data-pagination-per-page]");e&&(e.value=String(this._perPage))}_handleFocusOut(t){const e=t.target.closest("[data-pagination-per-page]");if(!e)return;const i=t.relatedTarget instanceof Element?t.relatedTarget:null,s=e.closest(".vg-table-pagination__size-control");s&&i&&s.contains(i)||this._applyPerPageInput(e)}_applyPerPageInput(t){this.setPerPage(t.value,!0,"per-page"),t.value=this._formatPerPage(this._perPage)}_emit(t,e){g.A.trigger(this._table,t,Object.assign(this.getState(),{source:e}))}_notify(t){"function"==typeof this._options.onChange&&this._options.onChange(Object.assign(this.getState(),{source:t}))}_resolveContainers(){if(!this._host)return[];const t=this._position(),e=Array.from(this._host.querySelectorAll("[data-vg-table-pagination]"));if(e.length)return"both"===t?e:[e.find(e=>e.getAttribute("data-position")===t)||e[0]];const i="both"===t?["top","bottom"]:[t],s=this._table.closest(".vg-table-container")||this._table;return i.map(t=>{const e=document.createElement("div");return e.setAttribute($a,""),e.setAttribute("data-position",t),"top"===t?this._host.insertBefore(e,s):this._host.insertBefore(e,s.nextSibling),e})}_rows(){return Array.from(this._table.tBodies||[]).flatMap(t=>Array.from(t.rows||[])).filter(t=>!t.hasAttribute("data-vg-table-filter-hidden")&&!t.hasAttribute("data-vg-table-state-row"))}_totalPages(){return this._remote?Math.max(1,this._totalPagesValue):Math.max(1,Math.ceil(this._rows().length/this._perPage))}_clampPage(t){return Math.min(this._positiveInt(t,1),this._totalPages())}_clampPerPage(t){const e=this._positiveInt(this._options.max,100);return Math.min(this._positiveInt(t,10),e)}_sizeOptions(){const t=this._options.size||{},e=(Array.isArray(t.options)?t.options:[10,25,50,100]).map(t=>this._clampPerPage(t)).filter(t=>t>0);return e.push(this._perPage),Array.from(new Set(e)).sort((t,e)=>t-e)}_formatPerPage(t){const e=String((this._options.size||{}).suffix||"на страницу").trim();return e?`${this._positiveInt(t,this._perPage)} / ${e}`:String(this._positiveInt(t,this._perPage))}_initDropdowns(t){t.querySelectorAll('[data-pagination-per-page][data-vg-toggle="dropdown"]').forEach(t=>{const e=Pt.init(t,{placement:"auto",hover:!1,animation:{fade:!0,enable:!1,delay:120}});this._dropdowns.push({toggle:t,instance:e})})}_disposeDropdowns(){this._dropdowns.forEach(({instance:t})=>t?.dispose?.()),this._dropdowns=[]}_dropdownFor(t){const e=t.closest(".vg-table-pagination__size-control"),i=e?.querySelector("[data-pagination-per-page]");return this._dropdowns.find(t=>t.toggle===i)?.instance||null}_hideDropdown(t){this._dropdownFor(t)?.hide?.()}_position(){const t=String(this._options.position||"bottom").toLowerCase();return["top","bottom","both"].includes(t)?t:"bottom"}_positionFor(t){return t.getAttribute("data-position")||this._position().replace("both","bottom")}_align(){const t=String(this._options.align||"right").toLowerCase();return["left","center","right","between"].includes(t)?t:"right"}_isQuickJumpEnabled(){const t=(this._options.quick||{}).enabled;return"auto"===t?this._totalPages()>this._positiveInt(this._options.threshold,5):!0===t}_ellipsisTarget(t){const e=this._buildPages().filter(Number.isInteger);return"prev"===t?Math.max(1,(e[1]||2)-1):Math.min(this._totalPages(),(e[e.length-2]||this._totalPages()-1)+1)}_scroll(){const t=this._options.scroll;t&&!1!==t&&"undefined"!=typeof window&&("window"!==t?this._host?.scrollIntoView?.({block:"start",behavior:"smooth"}):window.scrollTo?.({top:0,behavior:"smooth"}))}_storageKey(){const t=String((this._options.storage||{}).key||"").trim();if(t)return t;if(this._table.id)return`vg:table:pagination:${this._table.id}`;const e="undefined"!=typeof window?window.location.pathname:"",i=Array.from(document.querySelectorAll("[data-vg-table]"));return`vg:table:pagination:${e}:${Math.max(0,i.indexOf(this._table))}`}_restoreState(){if("undefined"==typeof window||!window.localStorage)return;const t=this._options.persist||{};if(!0===t.page||!0===t.per)try{const e=JSON.parse(window.localStorage.getItem(this._storageKey())||"{}"),i=this._positiveInt(e.page,0),s=this._positiveInt(e.perPage,0);!0===t.page&&i>0&&(this._page=i),!0===t.per&&s>0&&(this._perPage=this._clampPerPage(s))}catch(t){}}_storeState(){if("undefined"==typeof window||!window.localStorage)return;const t=this._options.persist||{};if(!0!==t.page&&!0!==t.per)return;const e={};!0===t.page&&(e.page=this._page),!0===t.per&&(e.perPage=this._perPage);try{window.localStorage.setItem(this._storageKey(),JSON.stringify(e))}catch(t){}}_positiveInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>0?i:e}_nonNegativeInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>=0?i:e}_range(t,e){const i=[];for(let s=t;s<=e;s+=1)i.push(s);return i}},Fa="data-vg-table-expandable-generated",Ra="data-vg-table-expand-hidden",Ba="data-expand-depth",ja="data-vg-table-page-row",Ua=class{constructor(t,e={}){this._table=t,this._options=e,this._collapsed=new Set,this._seeded=new Set,this._rowById=new Map,this._childrenByParent=new Map,this._boundClick=this._handleClick.bind(this)}init(){return this._table.classList.add("vg-table-expandable"),this._table.addEventListener("click",this._boundClick),this.refresh()}dispose(){this._table.removeEventListener("click",this._boundClick),this._table.classList.remove("vg-table-expandable"),this._rows().forEach(t=>{t.removeAttribute(Ba),t.removeAttribute(Ra),t.style.removeProperty("--vg-table-expandable-depth"),t.hidden="hidden"===t.getAttribute(ja)||t.hasAttribute("data-vg-table-filter-hidden"),t.querySelectorAll(`[${Fa}]`).forEach(t=>t.remove());const e=this._findToggle(t);e&&(e.classList.remove("vg-table-expandable__toggle"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-label"),e.hidden=!1)}),this._collapsed.clear(),this._seeded.clear(),this._rowById.clear(),this._childrenByParent.clear()}refresh(){const t=this._rows(),e=this._idAttr(),i=this._parentAttr();this._rowById=new Map,this._childrenByParent=new Map;const s=new Map;t.forEach((t,r)=>{const n=`row-${r+1}`,a=String(t.getAttribute(e)||n).trim()||n;t.setAttribute(e,a),this._rowById.set(a,t);const o=String(t.getAttribute(i)||"").trim();s.set(a,o),o&&(this._childrenByParent.has(o)||this._childrenByParent.set(o,[]),this._childrenByParent.get(o).push(a))});const r=new Map;return this._rowById.forEach((t,e)=>{const i=this._depth(e,s,r,new Set),n=(this._childrenByParent.get(e)||[]).length>0;t.setAttribute(Ba,String(i)),t.style.setProperty("--vg-table-expandable-depth",String(i)),n&&!this._seeded.has(e)&&(this._initiallyCollapsed(t)&&this._collapsed.add(e),this._seeded.add(e)),this._syncToggle(t,e,n)}),this._rowById.forEach((t,e)=>{const i=this._hasCollapsedAncestor(e,s);i?t.setAttribute(Ra,"true"):t.removeAttribute(Ra),t.hidden=i||"hidden"===t.getAttribute(ja)||t.hasAttribute("data-vg-table-filter-hidden")}),this.getState()}toggle(t,e=null,i=!0){const s=this._resolveRow(t);if(!s)return!1;const r=String(s.getAttribute(this._idAttr())||"").trim();if(!r||!(this._childrenByParent.get(r)||[]).length)return!1;const n=null===e?this._collapsed.has(r):!0===e;return n?this._collapsed.delete(r):this._collapsed.add(r),this.refresh(),i&&this._emit(s,r,n),!0}expand(t,e=!0){return this.toggle(t,!0,e)}collapse(t,e=!0){return this.toggle(t,!1,e)}getState(){const t=Array.from(this._childrenByParent.keys()).filter(t=>this._rowById.has(t));return{expanded:t.filter(t=>!this._collapsed.has(t)),collapsed:t.filter(t=>this._collapsed.has(t))}}_handleClick(t){const e=t.target instanceof Element?t.target:t.target?.parentElement;let i=null;try{i=e?.closest(this._combinedToggleSelector())}catch(t){i=e?.closest("[data-expand-toggle]")}if(!i||!this._table.contains(i))return;t.preventDefault();const s=i.closest("tr");s&&this.toggle(s,null,!0)}_syncToggle(t,e,i){let s=this._findToggle(t);if(!s&&i){const i=t.cells?.[0];i&&(s=document.createElement("button"),s.type="button",s.setAttribute("data-expand-toggle",e),s.setAttribute(Fa,""),i.prepend(s))}if(!s)return;if(s.classList.add("vg-table-expandable__toggle"),s.hidden=!i,!i)return;const r=!this._collapsed.has(e),n=this._options.labels||{};s.setAttribute("data-expand-toggle",e),s.setAttribute("aria-expanded",String(r)),s.setAttribute("aria-label",r?n.collapse||"Свернуть дочерние строки":n.expand||"Развернуть дочерние строки")}_findToggle(t){try{return t.querySelector(this._combinedToggleSelector())}catch(e){return t.querySelector("[data-expand-toggle]")}}_combinedToggleSelector(){const t=String(this._options.toggleSelector||"[data-expand-toggle]").trim();return"[data-expand-toggle]"===t?t:`${t}, [data-expand-toggle]`}_depth(t,e,i,s){if(i.has(t))return i.get(t);if(s.has(t))return 0;s.add(t);const r=String(e.get(t)||"").trim(),n=r&&r!==t&&this._rowById.has(r)?this._depth(r,e,i,s)+1:0;return s.delete(t),i.set(t,n),n}_hasCollapsedAncestor(t,e){const i=new Set([t]);let s=String(e.get(t)||"").trim();for(;s&&!i.has(s);){if(this._collapsed.has(s))return!0;i.add(s),s=String(e.get(s)||"").trim()}return!1}_initiallyCollapsed(t){const e=t.getAttribute("data-expand-collapsed");return null===e?!0===this._options.collapsed:this._boolean(e)}_resolveRow(t){if(t instanceof Element){const e=t.matches("tbody tr")?t:t.closest("tbody tr");return e&&this._table.contains(e)?e:null}return this._rowById.get(String(t))||null}_rows(){return Array.from(this._table.tBodies||[]).flatMap(t=>Array.from(t.rows||[]))}_idAttr(){return String(this._options.idAttr||"data-expand-id").trim()||"data-expand-id"}_parentAttr(){return String(this._options.parentAttr||"data-expand-parent-id").trim()||"data-expand-parent-id"}_boolean(t){return!["false","0","off","no"].includes(String(t).toLowerCase())}_emit(t,e,i){const s={id:e,row:t,expanded:i,collapsed:!i};g.A.trigger(this._table,"rowtoggle.vg.table",s),g.A.trigger(this._table,i?"rowexpand.vg.table":"rowcollapse.vg.table",s)}},qa=["vg-table-wrapper--sticky-container","vg-table-wrapper--sticky-page"],Va=["vg-table-container--sticky-container","vg-table-container--sticky-page"],Wa=["--vg-table-sticky-top","--vg-table-sticky-max-height"],Ka="data-vg-table-sticky-generated",Ga=class{constructor(t,e,i,s={}){this._element=t,this._wrapper=e,this._container=i,this._params=s,this._head=t.tHead,this._header=null,this._headerTable=null,this._body=null,this._previousClasses=new Map,this._previousContainerClasses=new Map,this._previousStyles=new Map,this._columnWeights=new Map,this._hardColumnWidths=new Map,this._columnMinimumWidths=new Map,this._hasSourceColgroup=!1,this._resizeObserver=null,this._resizeFrame=null,this._boundScroll=this._syncScroll.bind(this),this._boundResize=this._scheduleRefresh.bind(this),this._boundPageScroll=this._syncStickyState.bind(this)}init(){if(!this._wrapper||!this._container||!this._head)return this;const t=this._measureColumns();return this._rememberColumnGeometry(t),qa.forEach(t=>this._previousClasses.set(t,this._wrapper.classList.contains(t))),Va.forEach(t=>this._previousContainerClasses.set(t,this._container.classList.contains(t))),Wa.forEach(t=>this._previousStyles.set(t,this._container.style.getPropertyValue(t))),this._wrapper.classList.add(`vg-table-wrapper--sticky-${this._params.mode}`),this._container.classList.add(`vg-table-container--sticky-${this._params.mode}`),null!==this._params.top&&""!==String(this._params.top).trim()&&this._container.style.setProperty("--vg-table-sticky-top",this._toCssLength(this._params.top,"0px")),this._container.style.setProperty("--vg-table-sticky-max-height",this._toCssLength(this._params.maxHeight,"24rem")),this._element.setAttribute("data-vg-table-sticky-header",this._params.mode),this._buildLayers(t),this._body.addEventListener("scroll",this._boundScroll,{passive:!0}),"undefined"!=typeof ResizeObserver?(this._resizeObserver=new ResizeObserver(this._boundResize),this._resizeObserver.observe(this._container),this._resizeObserver.observe(this._body)):"undefined"!=typeof window&&window.addEventListener("resize",this._boundResize),"page"===this._params.mode&&"undefined"!=typeof window&&window.addEventListener("scroll",this._boundPageScroll,{passive:!0}),this.refresh(),this}getHeaderTable(){return this._headerTable||this._element}getBody(){return this._body}syncScroll(){return this._syncScroll(),this}refresh(){if(!this._header||!this._headerTable||!this._body)return this;const t=this._resolveLayoutWidths();this._applyColgroup(this._headerTable,t),this._applyColgroup(this._element,t);const e=Math.max(0,this._body.offsetWidth-this._body.clientWidth);return this._header.style.paddingInlineEnd=`${e}px`,this._header.style.setProperty("--vg-table-sticky-scrollbar-width",`${e}px`),this._header.classList.toggle("vg-table-header--scrollbar",e>0),this._container.classList.toggle("vg-table-container--scrollbar",e>0),this._syncScroll(),this._syncStickyState(),this}dispose(){this._body&&this._body.removeEventListener("scroll",this._boundScroll),this._resizeObserver?.disconnect(),null!==this._resizeFrame&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(this._resizeFrame),this._resizeFrame=null),"undefined"!=typeof window&&(this._resizeObserver||window.removeEventListener("resize",this._boundResize),window.removeEventListener("scroll",this._boundPageScroll)),this._header?.classList.remove("is-stuck"),this._head&&this._headerTable?.contains(this._head)&&this._element.prepend(this._head),this._header?.remove(),this._container?.classList.remove("vg-table-container--scrollbar"),this._body?.contains(this._element)&&this._body.before(this._element),this._body?.remove(),this._element.querySelector(":scope > colgroup[data-vg-table-sticky-colgroup]")?.remove(),qa.forEach(t=>{this._wrapper.classList.toggle(t,!0===this._previousClasses.get(t))}),Va.forEach(t=>{this._container.classList.toggle(t,!0===this._previousContainerClasses.get(t))}),Wa.forEach(t=>{const e=this._previousStyles.get(t);e?this._container.style.setProperty(t,e):this._container.style.removeProperty(t)}),this._element.removeAttribute("data-vg-table-sticky-header")}_scheduleRefresh(){null===this._resizeFrame&&("function"==typeof requestAnimationFrame?this._resizeFrame=requestAnimationFrame(()=>{this._resizeFrame=null,this.refresh()}):this.refresh())}_buildLayers(t){this._header=this._element.ownerDocument.createElement("div"),this._header.className="vg-table-header",this._header.setAttribute(Ka,""),this._headerTable=this._element.ownerDocument.createElement("table"),this._headerTable.className=`${this._element.className} vg-table-header__table`,this._headerTable.style.cssText=this._element.style.cssText,this._headerTable.removeAttribute("data-vg-table");const e=this._element.querySelector(":scope > colgroup:not([data-vg-table-sticky-colgroup])");e?this._headerTable.append(e.cloneNode(!0)):this._applyColgroup(this._headerTable,t),this._headerTable.append(this._head),this._header.append(this._headerTable),this._body=this._element.ownerDocument.createElement("div"),this._body.className="vg-table-body",this._body.setAttribute(Ka,""),this._applyColgroup(this._element,t),this._element.before(this._header,this._body),this._body.append(this._element)}_measureColumns(){return this._measureBodyColumns()}_measureBodyColumns(){const t=this._head?.rows[this._head.rows.length-1],e=this._measureRow(t),i=Array.from(this._element.tBodies||[]).flatMap(t=>Array.from(t.rows||[]));for(const t of i){if(t.hidden||t.hasAttribute("data-vg-table-state-row")||t.hasAttribute("data-vg-table-skeleton")||t.hasAttribute("data-vg-table-skeleton-row"))continue;if(t.querySelector("[data-vg-table-state]"))continue;const i=this._measureRow(t);if(i.length===e.length&&i.some(t=>t>0))return i}return e}_measureRow(t){return t?Array.from(t.cells).flatMap(t=>{const e=Math.max(1,t.colSpan||1),i=t.getBoundingClientRect().width/e;return Array.from({length:e},()=>i)}):[]}_applyColgroup(t,e){if(!e.length)return;if(t.querySelector(":scope > colgroup:not([data-vg-table-sticky-colgroup])"))return;let i=t.querySelector(":scope > colgroup[data-vg-table-sticky-colgroup]");for(i||(i=t.ownerDocument.createElement("colgroup"),i.setAttribute("data-vg-table-sticky-colgroup",""),t.prepend(i));i.children.length<e.length;)i.append(t.ownerDocument.createElement("col"));for(;i.children.length>e.length;)i.lastElementChild.remove();const s=this._getHeaders();e.forEach((t,e)=>{const r=i.children[e];t>0?r.style.width=`${t}px`:r.style.removeProperty("width");const n=!0===s[e]?.hidden;r.hidden=n,r.toggleAttribute("data-vg-table-column-hidden",n)})}_rememberColumnGeometry(t){const e=this._getHeaders(),i=Array.from(this._element.querySelector(":scope > colgroup:not([data-vg-table-sticky-colgroup])")?.children||[]);this._hasSourceColgroup=i.length>0,e.forEach((e,s)=>{const r=this._columnKey(e,s);this._columnWeights.set(r,t[s]>0?t[s]:1),this._hasDeclaredWidth(e)||this._hasDeclaredWidth(i[s])?this._hardColumnWidths.set(r,t[s]>0?t[s]:0):this._isEmptyHeader(e)&&t[s]>0&&this._columnMinimumWidths.set(r,t[s])})}_resolveLayoutWidths(){const t=this._getHeaders(),e=this._measureBodyColumns();if(this._hasSourceColgroup||!t.length)return e;const i=Array.from(this._element.tBodies||[]).flatMap(t=>Array.from(t.rows||[])).find(t=>!t.hidden&&!t.hasAttribute("data-vg-table-state-row")),s=new Map,r=[];t.forEach((t,n)=>{const a=this._columnKey(t,n),o=i?.cells[n];if(this._hasDeclaredWidth(t)||this._hasDeclaredWidth(o)||this._hardColumnWidths.has(a)){const i=this._readDeclaredPixelWidth(t)||this._readDeclaredPixelWidth(o)||this._hardColumnWidths.get(a)||e[n]||0;this._hardColumnWidths.set(a,i),s.set(n,i)}else r.push(n)});const n=e.reduce((t,e)=>t+e,0),a=this._body?.clientWidth||this._container?.clientWidth||n,o=this._readTableMinimumWidth(),l=Math.max(a,o,0),h=Array.from(s.values()).reduce((t,e)=>t+e,0),d=Math.max(0,l-h),c=Array(t.length).fill(0);return s.forEach((t,e)=>{c[e]=t}),r.length?(this._distributeFlexibleWidths(c,r,d,t,e),c):c}_distributeFlexibleWidths(t,e,i,s,r){let n=e.slice(),a=i;if(n.reduce((t,e)=>{const i=this._columnKey(s[e],e);return t+(this._columnMinimumWidths.get(i)||0)},0)>a)n.forEach(e=>{const i=this._columnKey(s[e],e);t[e]=this._columnMinimumWidths.get(i)||0});else for(;n.length;){const e=n.map(t=>{const e=this._columnKey(s[t],t);return this._columnWeights.get(e)||r[t]||1}),i=e.reduce((t,e)=>t+e,0)||n.length,o=n.filter((t,r)=>{const n=this._columnKey(s[t],t);return(this._columnMinimumWidths.get(n)||0)>a*e[r]/i});if(!o.length){let s=0;return void n.forEach((r,o)=>{const l=o===n.length-1?Math.max(0,a-s):a*e[o]/i;t[r]=l,s+=l})}o.forEach(e=>{const i=this._columnKey(s[e],e),r=this._columnMinimumWidths.get(i)||0;t[e]=r,a-=r}),n=n.filter(t=>!o.includes(t))}}_getHeaders(){const t=Array.from(this._head?.rows||[]);return t.length?Array.from(t.at(-1).cells||[]):[]}_columnKey(t,e){return String(t?.getAttribute("data-field")||e).trim()}_isEmptyHeader(t){return Boolean(t)&&0===t.childElementCount&&""===String(t.textContent||"").trim()}_hasDeclaredWidth(t){return!!t&&(t.hasAttribute("width")||t.hasAttribute("data-column-width")||Boolean(t.style?.width||t.style?.minWidth||t.style?.maxWidth))}_readDeclaredPixelWidth(t){if(!t||!this._hasDeclaredWidth(t))return 0;const e=t.style?.minWidth&&t.style.minWidth===t.style.maxWidth?Number.parseFloat(t.style.width||t.style.minWidth):0;if(Number.isFinite(e)&&e>0)return e;const i=t.getBoundingClientRect?.().width||t.offsetWidth||0;return i>0?i:0}_readTableMinimumWidth(){if("function"!=typeof getComputedStyle)return 0;const t=Number.parseFloat(getComputedStyle(this._element).minWidth||"0");return Number.isFinite(t)?t:0}_syncScroll(){this._header&&this._body&&(this._header.scrollLeft=this._body.scrollLeft)}_syncStickyState(){if(!this._header||"page"!==this._params.mode)return;const t=this._header.getBoundingClientRect(),e=this._container.getBoundingClientRect(),i=Number.parseFloat(window.getComputedStyle(this._header).top)||0,s=Math.abs(t.top-i)<=1,r=e.top<i&&e.bottom>i+t.height;this._header.classList.toggle("is-stuck",s&&r)}_toCssLength(t,e){if("number"==typeof t&&Number.isFinite(t))return`${Math.max(0,t)}px`;const i=String(t??"").trim();return i?/^\d+(?:\.\d+)?$/.test(i)?`${i}px`:i:e}},Ya="data-vg-table-fixed-side",Xa="data-vg-table-fixed-edge",Za="--vg-table-fixed-offset",Ja=["vg-table-wrapper--fixed-columns","vg-table-wrapper--fixed-columns-stack","is-vg-table-fixed-scrolled-start","is-vg-table-fixed-scrolled-end"],Qa=class{constructor(t,e,i={},s=null){this._element=t,this._wrapper=e,this._params=i,this._stickyHeader=s,this._headerTable=s?.getHeaderTable?.()||t,this._scrollHost=s?.getBody?.()||t.closest(".vg-table-container")||e,this._columns={left:[],right:[]},this._widths=[],this._previousClasses=new Map,this._activeEdges={left:null,right:null},this._resizeObserver=null,this._boundScroll=this._syncScrollState.bind(this),this._boundResize=this.refresh.bind(this)}init(){return this._wrapper&&this._scrollHost&&this._headerTable?.tHead?(Ja.forEach(t=>{this._previousClasses.set(t,this._wrapper.classList.contains(t))}),this._wrapper.classList.add("vg-table-wrapper--fixed-columns"),this._wrapper.classList.toggle("vg-table-wrapper--fixed-columns-stack","stack"===this._params.mode),this._element.setAttribute("data-vg-table-fixed-columns",this._params.mode),this._scrollHost.addEventListener("scroll",this._boundScroll,{passive:!0}),"undefined"!=typeof ResizeObserver?(this._resizeObserver=new ResizeObserver(this._boundResize),this._resizeObserver.observe(this._scrollHost),this._resizeObserver.observe(this._element)):"undefined"!=typeof window&&window.addEventListener("resize",this._boundResize),this.refresh(),this):this}refresh(){this._headerTable=this._stickyHeader?.getHeaderTable?.()||this._element,this._scrollHost=this._stickyHeader?.getBody?.()||this._element.closest(".vg-table-container")||this._wrapper;const t=this._getHeaders();return t.length?(this._clearCells(),this._columns=this._resolveColumns(t),this._widths=t.map((t,e)=>this._measureColumn(t,e)),this._applySide("left",this._columns.left,t),this._applySide("right",[...this._columns.right].reverse(),t),this._syncScrollState(!0),this):this}getState(){return{mode:this._params.mode,left:[...this._columns.left],right:[...this._columns.right]}}syncScroll(){return this._syncScrollState(),this}dispose(){this._scrollHost?.removeEventListener("scroll",this._boundScroll),this._resizeObserver?.disconnect(),this._resizeObserver||"undefined"==typeof window||window.removeEventListener("resize",this._boundResize),this._clearCells(),Ja.forEach(t=>{this._wrapper.classList.toggle(t,!0===this._previousClasses.get(t))}),this._element.removeAttribute("data-vg-table-fixed-columns")}_getHeaders(){const t=Array.from(this._headerTable.tHead?.rows||[]);return t.length?Array.from(t[t.length-1].cells):[]}_resolveColumns(t){const e={left:[],right:[]},i=(i,s)=>{const r=this._resolveIndex(s,t);r>=0&&!e[i].includes(r)&&e[i].push(r)},s=this._params.columns;return s&&"object"==typeof s&&!Array.isArray(s)?["left","right"].forEach(t=>{(Array.isArray(s[t])?s[t]:String(s[t]||"").split(",")).forEach(e=>i(t,e))}):String(s||"").split(";").forEach(t=>{const[e,s=""]=t.split(":"),r=String(e||"").trim().toLowerCase();["left","right"].includes(r)&&s.split(",").forEach(t=>i(r,t))}),t.forEach((t,e)=>{const s=String(t.getAttribute("data-fixed")||t.getAttribute("data-fixed-column")||"").toLowerCase();["left","right"].includes(s)&&i(s,e)}),e.left.sort((t,e)=>t-e),e.right.sort((t,e)=>t-e),e}_resolveIndex(t,e){const i=String(t??"").trim();if(!i)return-1;if(/^\d+$/.test(i)){const t=Number.parseInt(i,10);return t>=0&&t<e.length?t:-1}return e.findIndex(t=>String(t.dataset.field||"").trim()===i)}_measureColumn(t,e){const i=Array.from(this._element.tBodies[0]?.rows||[]).find(t=>!t.hasAttribute("data-vg-table-state-row")),s=i?.cells[e],r=this._element.querySelector(`:scope > colgroup > col:nth-child(${e+1})`),n=s?.getBoundingClientRect?.().width||t.getBoundingClientRect?.().width||s?.offsetWidth||t.offsetWidth;if(n>0)return n;const a=Number.parseFloat(r?.style.width||r?.getAttribute("width")||"0");return Number.isFinite(a)?a:0}_applySide(t,e,i){let s=0;e.forEach(e=>{this._cellsAt(e,i).forEach(e=>{e.setAttribute(Ya,t),e.style.setProperty(Za,`${s}px`)}),s+=this._widths[e]||0,"stack"===this._params.mode&&(s+=this._params.stackGap)})}_cellsAt(t,e=this._getHeaders()){const i=[];return e[t]&&i.push(e[t]),Array.from(this._element.tBodies||[]).forEach(e=>{Array.from(e.rows||[]).forEach(e=>{e.hasAttribute("data-vg-table-state-row")||e.cells[t]&&i.push(e.cells[t])})}),Array.from(this._element.tFoot?.rows||[]).forEach(e=>{e.cells[t]&&i.push(e.cells[t])}),i}_syncScrollState(t=!1){if(!this._scrollHost)return;const e=Math.max(0,this._scrollHost.scrollWidth-this._scrollHost.clientWidth),i=Math.max(0,Math.min(e,this._scrollHost.scrollLeft));if(this._wrapper.classList.toggle("is-vg-table-fixed-scrolled-start",i>.5),this._wrapper.classList.toggle("is-vg-table-fixed-scrolled-end",i<e-.5),"stack"!==this._params.mode)return this._setEdge("left",this._columns.left.at(-1)??null,t),void this._setEdge("right",this._columns.right[0]??null,t);const s=this._columns.left.filter(t=>{const e=this._widths.slice(0,t).reduce((t,e)=>t+e,0),s=this._stackOffset("left",t);return i>=e-s-.5}),r=this._widths.reduce((t,e)=>t+e,0),n=e-i,a=this._columns.right.filter(t=>{const e=this._widths.slice(0,t+1).reduce((t,e)=>t+e,0);return n>=r-e-this._stackOffset("right",t)-.5});this._setEdge("left",s.at(-1)??null,t),this._setEdge("right",a[0]??null,t)}_stackOffset(t,e){const i="left"===t?this._columns.left:[...this._columns.right].reverse();let s=0;for(const t of i){if(t===e)return s;s+=(this._widths[t]||0)+this._params.stackGap}return s}_setEdge(t,e,i=!1){(i||this._activeEdges[t]!==e)&&(this._allManagedCells().forEach(e=>{e.getAttribute(Xa)===t&&e.removeAttribute(Xa)}),null!==e&&this._cellsAt(e).forEach(e=>e.setAttribute(Xa,t)),this._activeEdges[t]=e)}_allManagedCells(){return Array.from(this._wrapper.querySelectorAll(`[${Ya}], [${Xa}]`))}_clearCells(){this._allManagedCells().forEach(t=>{t.removeAttribute(Ya),t.removeAttribute(Xa),t.style.removeProperty(Za)}),this._activeEdges={left:null,right:null}}},to="data-vg-table-column-resize-handle",eo="[data-vg-table-column], [data-column-field]",io="columnresize.vg.table",so="columnreorder.vg.table",ro="columnvisibilitychange.vg.table",no=class{constructor(t,e,i={},s={}){this._table=t,this._wrapper=e,this._options=i,this._hooks=s,this._headerTable=t,this._controls=null,this._originalOrder=[],this._originalCellStyles=new Map,this._originalVisibility=new Map,this._widths=new Map,this._hidden=new Set,this._drag={active:!1,from:-1},this._resize={active:!1,index:-1,field:"",startX:0,startWidth:0},this._suppressClick=!1,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundKeydown=this._handleKeydown.bind(this),this._boundDragStart=this._handleDragStart.bind(this),this._boundDragOver=this._handleDragOver.bind(this),this._boundDrop=this._handleDrop.bind(this),this._boundDragEnd=this._handleDragEnd.bind(this),this._boundClickCapture=this._handleClickCapture.bind(this),this._boundControlChange=this._handleControlChange.bind(this),this._boundControlClick=this._handleControlClick.bind(this)}init(){return this._headerTable=this._hooks.getHeaderTable?.()||this._table,this._originalOrder=this.getOrder(),this._rememberOriginalState(),this._controls=this._resolveControls(),!0===this._options.reorder?.enabled&&this._restoreOrder(),!0===this._options.resize?.enabled&&this._restoreWidths(),!0===this._options.visibility?.enabled&&this._restoreVisibility(),this._decorateHeaders(),this._bind(),this.refresh(),this}refresh(){return this._headerTable=this._hooks.getHeaderTable?.()||this._table,this._decorateHeaders(),this._widths.forEach((t,e)=>this._applyWidth(e,t)),this._hidden.forEach(t=>this._applyVisibility(t,!1)),this._syncControls(),this.getState()}getState(){const t=this.getOrder();return{order:t,widths:Object.fromEntries(this._widths),visible:t.filter(t=>!this._hidden.has(t)),hidden:t.filter(t=>this._hidden.has(t))}}getOrder(){return this._getHeaders().map((t,e)=>this._field(t,e))}setWidth(t,e,i=!0){if(!0!==this._options.resize?.enabled)return!1;const s=this._resolveIndex(t),r=this._field(this._getHeaders()[s],s);if(s<0||!r||this._hidden.has(r))return!1;const n=this._clampWidth(e);return this._widths.set(r,n),this._applyWidth(r,n),this._storeWidths(),this._hooks.refreshLayout?.(!1),i&&g.A.trigger(this._table,io,{field:r,columnIndex:s,width:n,widths:Object.fromEntries(this._widths)}),!0}move(t,e,i=!0){if(!0!==this._options.reorder?.enabled)return!1;const s=this._resolveIndex(t),r=this._resolveIndex(e),n=this._getHeaders();if(s<0||r<0||s===r||this._isLocked(n[s],s)||this._isLocked(n[r],r))return!1;const a=this._field(n[s],s);return this._moveColumn(s,r),this._storeOrder(),this._decorateHeaders(),this._syncControls(),this._hooks.refreshLayout?.(!0),i&&g.A.trigger(this._table,so,{field:a,fromIndex:s,toIndex:r,order:this.getOrder()}),!0}setVisible(t,e=!0,i=!0){if(!0!==this._options.visibility?.enabled)return!1;const s=this._resolveIndex(t),r=this._getHeaders()[s],n=this._field(r,s);if(s<0||!n||this._isLocked(r,s))return!1;const a=!1!==e;return!(!a&&!this._hidden.has(n)&&this.getState().visible.length<=this._minVisible()||(a?this._hidden.delete(n):this._hidden.add(n),this._applyVisibility(n,a),this._storeVisibility(),this._syncControls(),this._hooks.refreshLayout?.(!0),i&&g.A.trigger(this._table,ro,Object.assign({field:n,visible:a},this.getState())),0))}reset(t=!0){if(this._restoreOriginalOrder(),this._restoreOriginalStyles(),this._widths.clear(),this._hidden.clear(),this._clearStorage(),this._decorateHeaders(),this._syncControls(),this._hooks.refreshLayout?.(!0),t){const t=Object.assign({reset:!0},this.getState());g.A.trigger(this._table,io,t),g.A.trigger(this._table,so,t),g.A.trigger(this._table,ro,t)}return this.getState()}dispose(){this._unbind(),this._restoreOriginalOrder(),this._restoreOriginalStyles(),this._getHeaders().forEach(t=>{t.removeAttribute("data-vg-table-column-reorder"),t.removeAttribute("data-vg-table-column-dragging"),t.removeAttribute("data-vg-table-column-drag-over"),t.removeAttribute("draggable"),t.querySelector(`[${to}]`)?.remove()}),this._wrapper?.classList.remove("vg-table-wrapper--column-resizing","vg-table-wrapper--column-dragging")}_bind(){this._headerTable.addEventListener("pointerdown",this._boundPointerDown),this._headerTable.addEventListener("keydown",this._boundKeydown),this._headerTable.addEventListener("dragstart",this._boundDragStart),this._headerTable.addEventListener("dragover",this._boundDragOver),this._headerTable.addEventListener("drop",this._boundDrop),this._headerTable.addEventListener("dragend",this._boundDragEnd),this._headerTable.addEventListener("click",this._boundClickCapture,!0),document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),this._controls?.addEventListener("change",this._boundControlChange),this._controls?.addEventListener("click",this._boundControlClick)}_unbind(){this._headerTable?.removeEventListener("pointerdown",this._boundPointerDown),this._headerTable?.removeEventListener("keydown",this._boundKeydown),this._headerTable?.removeEventListener("dragstart",this._boundDragStart),this._headerTable?.removeEventListener("dragover",this._boundDragOver),this._headerTable?.removeEventListener("drop",this._boundDrop),this._headerTable?.removeEventListener("dragend",this._boundDragEnd),this._headerTable?.removeEventListener("click",this._boundClickCapture,!0),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),this._controls?.removeEventListener("change",this._boundControlChange),this._controls?.removeEventListener("click",this._boundControlClick)}_decorateHeaders(){this._getHeaders().forEach((t,e)=>{const i=this._field(t,e),s=this._isLocked(t,e);if(!0===this._options.resize?.enabled&&!t.querySelector(`[${to}]`)){const e=t.ownerDocument.createElement("span");e.className="vg-table-column-resize-handle",e.setAttribute(to,""),e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),e.setAttribute("aria-label",this._resizeLabel(t)),e.setAttribute("aria-valuemin",String(this._options.resize.minWidth)),e.setAttribute("aria-valuemax",String(this._options.resize.maxWidth)),e.setAttribute("aria-valuenow",String(Math.round(t.getBoundingClientRect().width||t.offsetWidth||this._options.resize.minWidth))),e.tabIndex=0,t.append(e)}const r=t.querySelector(`[${to}]`);r&&r.setAttribute("aria-label",this._resizeLabel(t)),!0===this._options.reorder?.enabled&&(t.setAttribute("data-vg-table-column-reorder",s?"locked":"enabled"),t.setAttribute("draggable",String(!s))),i&&this._hidden.has(i)&&this._applyVisibility(i,!1)})}_handlePointerDown(t){const e=t.target.closest?.(`[${to}]`);if(!e||!0!==this._options.resize?.enabled)return;const i=e.closest("th"),s=this._getHeaders().indexOf(i);s<0||(t.preventDefault(),t.stopPropagation(),this._resize={active:!0,index:s,field:this._field(i,s),startX:t.clientX,startWidth:i.getBoundingClientRect().width||i.offsetWidth||this._options.resize.minWidth},this._wrapper?.classList.add("vg-table-wrapper--column-resizing"))}_handleKeydown(t){const e=t.target.closest?.(`[${to}]`);if(!e||!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;const i=e.closest("th"),s=this._getHeaders().indexOf(i);if(s<0)return;t.preventDefault(),t.stopPropagation();const r=this._field(i,s),n=this._widths.get(r)||i.getBoundingClientRect().width||i.offsetWidth||this._options.resize.minWidth,a=t.shiftKey?25:10,o="Home"===t.key?this._options.resize.minWidth:"End"===t.key?this._options.resize.maxWidth:n+("ArrowRight"===t.key?a:-a);this.setWidth(r,o,!0)}_handlePointerMove(t){if(!this._resize.active)return;t.preventDefault();const e=this._clampWidth(this._resize.startWidth+t.clientX-this._resize.startX);this._widths.set(this._resize.field,e),this._applyWidth(this._resize.field,e),this._hooks.refreshLayout?.(!1)}_handlePointerUp(){if(!this._resize.active)return;const{field:t}=this._resize,e=this._widths.get(t);this._resize={active:!1,index:-1,field:"",startX:0,startWidth:0},this._wrapper?.classList.remove("vg-table-wrapper--column-resizing"),e&&(this._storeWidths(),g.A.trigger(this._table,io,{field:t,columnIndex:this._resolveIndex(t),width:e,widths:Object.fromEntries(this._widths)}))}_handleDragStart(t){const e=t.target.closest?.('th[data-vg-table-column-reorder="enabled"]');if(!e||t.target.closest?.(`[${to}]`))return;const i=this._getHeaders().indexOf(e);if(!(i<0)&&(this._drag={active:!0,from:i},e.setAttribute("data-vg-table-column-dragging",""),this._wrapper?.classList.add("vg-table-wrapper--column-dragging"),t.dataTransfer)){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",String(i))}catch(t){}}}_handleDragOver(t){if(!this._drag.active)return;const e=t.target.closest?.('th[data-vg-table-column-reorder="enabled"]');e&&(t.preventDefault(),this._getHeaders().forEach(t=>t.toggleAttribute("data-vg-table-column-drag-over",t===e)))}_handleDrop(t){if(!this._drag.active)return;const e=t.target.closest?.('th[data-vg-table-column-reorder="enabled"]');if(!e)return;t.preventDefault();const i=this._getHeaders().indexOf(e),s=this._drag.from;this._finishDrag(),this.move(s,i,!0)}_handleDragEnd(){this._drag.active&&this._finishDrag()}_finishDrag(){this._getHeaders().forEach(t=>{t.removeAttribute("data-vg-table-column-dragging"),t.removeAttribute("data-vg-table-column-drag-over")}),this._drag={active:!1,from:-1},this._suppressClick=!0,this._wrapper?.classList.remove("vg-table-wrapper--column-dragging"),setTimeout(()=>{this._suppressClick=!1},0)}_handleClickCapture(t){(this._suppressClick||t.target.closest?.(`[${to}]`))&&(t.preventDefault(),t.stopPropagation(),this._suppressClick=!1)}_handleControlChange(t){const e=t.target.closest?.(eo);if(!e||!this._controls.contains(e))return;const i=e.getAttribute("data-vg-table-column")||e.getAttribute("data-column-field");this.setVisible(i,!1!==e.checked)||this._syncControls()}_handleControlClick(t){t.target.closest?.("[data-vg-table-columns-reset]")&&(t.preventDefault(),this.reset(!0))}_applyWidth(t,e){const i=this._resolveIndex(t);i<0||(this._cellsAt(i).forEach(t=>{this._rememberCellStyle(t),t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`}),this._colsAt(i).forEach(t=>{this._rememberCellStyle(t),t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`}),this._getHeaders()[i]?.querySelector(`[${to}]`)?.setAttribute("aria-valuenow",String(e)))}_applyVisibility(t,e){const i=this._resolveIndex(t);i<0||[...this._cellsAt(i),...this._colsAt(i)].forEach(t=>{this._originalVisibility.has(t)||this._originalVisibility.set(t,t.hidden),t.hidden=!e,t.toggleAttribute("data-vg-table-column-hidden",!e)})}_moveColumn(t,e){new Set([...Array.from(this._headerTable.rows||[]),...Array.from(this._table.tBodies||[]).flatMap(t=>Array.from(t.rows||[])),...Array.from(this._table.tFoot?.rows||[])]).forEach(i=>this._moveNode(Array.from(i.cells||[]),t,e)),this._colgroups().forEach(i=>this._moveNode(Array.from(i.children||[]),t,e))}_moveNode(t,e,i){const s=t[e],r=t[i];s&&r&&s!==r&&(e<i?r.after(s):r.before(s))}_cellsAt(t){const e=[];return new Set([...Array.from(this._headerTable.rows||[]),...Array.from(this._table.tBodies||[]).flatMap(t=>Array.from(t.rows||[])),...Array.from(this._table.tFoot?.rows||[])]).forEach(i=>{!i.hasAttribute("data-vg-table-state-row")&&i.cells[t]&&e.push(i.cells[t])}),e}_colsAt(t){return this._colgroups().map(e=>e.children[t]).filter(Boolean)}_colgroups(){return Array.from(new Set([...Array.from(this._table.querySelectorAll(":scope > colgroup")),...Array.from(this._headerTable.querySelectorAll(":scope > colgroup"))]))}_getHeaders(){const t=Array.from(this._headerTable.tHead?.rows||[]);return t.length?Array.from(t.at(-1).cells||[]):[]}_field(t,e){return String(t?.getAttribute("data-field")||e).trim()}_resolveIndex(t){const e=this._getHeaders();if("number"==typeof t||/^\d+$/.test(String(t??"").trim())){const i=Number.parseInt(t,10);return i>=0&&i<e.length?i:-1}const i=String(t||"").trim();return e.findIndex((t,e)=>this._field(t,e)===i)}_isLocked(t,e){return!0===this._hooks.isFixed?.(this._field(t,e))}_minVisible(){return Math.max(1,Number.parseInt(this._options.visibility?.minVisible,10)||1)}_clampWidth(t){const e=Math.max(40,Number.parseInt(this._options.resize?.minWidth,10)||80),i=Math.max(e,Number.parseInt(this._options.resize?.maxWidth,10)||600);return Math.min(i,Math.max(e,Math.round(Number(t)||e)))}_resizeLabel(t){const e=String(t?.textContent||"").trim();return String(this._options.resize?.label||"Изменить ширину колонки {column}").replace("{column}",e)}_resolveControls(){const t=this._options.visibility?.controls;return"undefined"!=typeof Element&&t instanceof Element?t:t?this._table.ownerDocument.querySelector(String(t)):null}_syncControls(){this._controls?.querySelectorAll(eo).forEach(t=>{const e=t.getAttribute("data-vg-table-column")||t.getAttribute("data-column-field"),i=this._resolveIndex(e);t.checked=i>=0&&!this._hidden.has(e),t.disabled=i<0||this._isLocked(this._getHeaders()[i],i)})}_rememberOriginalState(){this._getHeaders().forEach((t,e)=>{this._cellsAt(e).forEach(t=>{this._rememberCellStyle(t),this._originalVisibility.has(t)||this._originalVisibility.set(t,t.hidden)})}),this._colgroups().forEach(t=>Array.from(t.children).forEach(t=>this._rememberCellStyle(t)))}_rememberCellStyle(t){this._originalCellStyles.has(t)||this._originalCellStyles.set(t,{width:t.style.width,minWidth:t.style.minWidth,maxWidth:t.style.maxWidth})}_restoreOriginalStyles(){this._originalCellStyles.forEach((t,e)=>{e.style.width=t.width,e.style.minWidth=t.minWidth,e.style.maxWidth=t.maxWidth}),this._originalVisibility.forEach((t,e)=>{e.hidden=t,e.removeAttribute("data-vg-table-column-hidden")})}_restoreOriginalOrder(){this._originalOrder.forEach((t,e)=>{const i=this._resolveIndex(t);i>=0&&i!==e&&this._moveColumn(i,e)})}_storageKey(t,e){const i=this._options[t]||{};if(!0!==i.persist||"undefined"==typeof window)return"";return String(i.storageKey||"").trim()||(this._table.id?`vg-table:${this._table.id}:${e}`:"")}_readStorage(t,e,i){const s=this._storageKey(t,e);if(!s)return i;try{return JSON.parse(window.localStorage.getItem(s))??i}catch(t){return i}}_writeStorage(t,e,i){const s=this._storageKey(t,e);if(s)try{window.localStorage.setItem(s,JSON.stringify(i))}catch(t){}}_restoreOrder(){const t=this._readStorage("reorder","column-order",[]);Array.isArray(t)&&t.forEach((t,e)=>{const i=this._resolveIndex(t);i>=0&&i!==e&&!this._isLocked(this._getHeaders()[i],i)&&!this._isLocked(this._getHeaders()[e],e)&&this._moveColumn(i,e)})}_storeOrder(){this._writeStorage("reorder","column-order",this.getOrder())}_restoreWidths(){const t=this._readStorage("resize","column-widths",{});t&&"object"==typeof t&&!Array.isArray(t)&&Object.entries(t).forEach(([t,e])=>{this._resolveIndex(t)>=0&&this._widths.set(t,this._clampWidth(e))})}_storeWidths(){this._writeStorage("resize","column-widths",Object.fromEntries(this._widths))}_restoreVisibility(){const t=this._readStorage("visibility","hidden-columns",[]);Array.isArray(t)&&t.forEach(t=>{const e=this._resolveIndex(t);this._getHeaders().length-this._hidden.size>this._minVisible()&&e>=0&&!this._isLocked(this._getHeaders()[e],e)&&this._hidden.add(t)})}_storeVisibility(){this._writeStorage("visibility","hidden-columns",Array.from(this._hidden))}_clearStorage(){[["reorder","column-order"],["resize","column-widths"],["visibility","hidden-columns"]].forEach(([t,e])=>{const i=this._storageKey(t,e);if(i)try{window.localStorage.removeItem(i)}catch(t){}})}},ao="rowreorder.vg.table",oo="data-vg-table-row-dragging",lo="data-vg-table-row-drag-over",ho="data-vg-table-row-reorder",co='a, button, input, select, textarea, [contenteditable="true"]',_o=class{constructor(t,e,i={},s={}){this._table=t,this._wrapper=e,this._options=i,this._hooks=s,this._original=new Map,this._rowState=new WeakMap,this._handleState=new WeakMap,this._drag={row:null,fromIndex:-1,target:null,after:!1},this._boundDragStart=this._handleDragStart.bind(this),this._boundDragOver=this._handleDragOver.bind(this),this._boundDrop=this._handleDrop.bind(this),this._boundDragEnd=this._clearDrag.bind(this),this._boundKeydown=this._handleKeydown.bind(this)}init(){return Array.from(this._table.tBodies||[]).forEach(t=>this._original.set(t,this._rows(t))),this._restoreStoredOrder(),this.refresh(),this._table.addEventListener("dragstart",this._boundDragStart),this._table.addEventListener("dragover",this._boundDragOver),this._table.addEventListener("drop",this._boundDrop),this._table.addEventListener("dragend",this._boundDragEnd),this._table.addEventListener("keydown",this._boundKeydown),this}refresh(){return this._rows().forEach((t,e)=>this._decorate(t,e)),this.getState()}getState(){return{order:this._rows().map((t,e)=>this._key(t,e)),rows:this._rows()}}move(t,e,i="before",s=!0){const r=this._resolveRow(t),n=this._resolveRow(e);if(!r||!n||r===n||r.parentElement!==n.parentElement)return!1;if(this._disabled(r)||this._disabled(n))return!1;const a=this._rows(r.parentElement).indexOf(r),o="after"===String(i).toLowerCase();return!(!o&&r.nextElementSibling===n||o&&n.nextElementSibling===r||(r.parentElement.insertBefore(r,o?n.nextSibling:n),this._afterMove(r,a,s),0))}reset(t=!0){return this._original.forEach((t,e)=>t.forEach(t=>e.append(t))),this._clearStorage(),this.refresh(),this._hooks.refreshLayout?.(),t&&g.A.trigger(this._table,ao,Object.assign({reset:!0},this.getState())),this.getState()}dispose(){this._table.removeEventListener("dragstart",this._boundDragStart),this._table.removeEventListener("dragover",this._boundDragOver),this._table.removeEventListener("drop",this._boundDrop),this._table.removeEventListener("dragend",this._boundDragEnd),this._table.removeEventListener("keydown",this._boundKeydown),this._clearDrag(),this._rows().forEach(t=>this._undecorate(t)),this._original.forEach((t,e)=>t.forEach(t=>e.append(t))),this._original.clear()}_decorate(t,e){this._rowState.has(t)||this._rowState.set(t,{draggable:t.getAttribute("draggable"),tabindex:t.getAttribute("tabindex"),label:t.getAttribute("aria-label")});const i=this._disabled(t),s=this._mode();t.setAttribute(ho,i?"disabled":s),t.draggable=!i&&"row"===s,i||"row"!==s||(t.hasAttribute("tabindex")||(t.tabIndex=0),t.setAttribute("aria-label",this._handleLabel(t,e))),this._handles(t).forEach(r=>{this._handleState.has(r)||this._handleState.set(r,{draggable:r.getAttribute("draggable"),tabindex:r.getAttribute("tabindex"),role:r.getAttribute("role"),label:r.getAttribute("aria-label"),disabled:r.getAttribute("aria-disabled")}),r.draggable=!i&&"handle"===s,i||r.hasAttribute("tabindex")||(r.tabIndex=0),r.hasAttribute("role")||r.setAttribute("role","button"),r.setAttribute("aria-label",this._handleLabel(t,e)),r.toggleAttribute("aria-disabled",i)})}_undecorate(t){t.removeAttribute(ho),t.removeAttribute(oo),t.removeAttribute(lo);const e=this._rowState.get(t)||{};this._restoreAttribute(t,"draggable",e.draggable),this._restoreAttribute(t,"tabindex",e.tabindex),this._restoreAttribute(t,"aria-label",e.label),this._handles(t).forEach(t=>{const e=this._handleState.get(t)||{};this._restoreAttribute(t,"draggable",e.draggable),this._restoreAttribute(t,"tabindex",e.tabindex),this._restoreAttribute(t,"role",e.role),this._restoreAttribute(t,"aria-label",e.label),this._restoreAttribute(t,"aria-disabled",e.disabled)})}_restoreAttribute(t,e,i){null==i?t.removeAttribute(e):t.setAttribute(e,i)}_handleDragStart(t){const e=t.target.closest?.(`tr[${ho}]`);if(e&&!this._disabled(e))if("handle"!==this._mode()||t.target.closest?.(this._handleSelector())){if("row"===this._mode()&&t.target.closest?.(co))t.preventDefault();else if(this._drag={row:e,fromIndex:this._rows(e.parentElement).indexOf(e),target:null,after:!1},e.setAttribute(oo,""),this._wrapper?.classList.add("vg-table-wrapper--row-dragging"),t.dataTransfer){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",this._key(e,this._drag.fromIndex))}catch(t){}}}else t.preventDefault()}_handleDragOver(t){if(!this._drag.row)return;const e=t.target.closest?.(`tr[${ho}]`);if(!e||e===this._drag.row||e.parentElement!==this._drag.row.parentElement||this._disabled(e))return;t.preventDefault();const i=e.getBoundingClientRect(),s=t.clientY>i.top+i.height/2;this._rows().forEach(t=>t.removeAttribute(lo)),e.setAttribute(lo,s?"after":"before"),this._drag.target=e,this._drag.after=s}_handleDrop(t){if(!this._drag.row||!this._drag.target)return this._clearDrag();t.preventDefault();const{row:e,target:i,after:s,fromIndex:r}=this._drag;e.parentElement.insertBefore(e,s?i.nextSibling:i),this._clearDrag(),this._afterMove(e,r,!0)}_handleKeydown(t){if(!["ArrowUp","ArrowDown","Home","End"].includes(t.key))return;const e=t.target.closest?.(this._handleSelector()),i=e?.closest?.(`tr[${ho}]`)||("row"===this._mode()?t.target.closest?.(`tr[${ho}]`):null);if(!i||this._disabled(i))return;if(!e&&t.target!==i&&t.target.closest?.(co))return;const s=this._rows(i.parentElement).filter(t=>!this._disabled(t)),r=s.indexOf(i),n="Home"===t.key?s[0]:"End"===t.key?s.at(-1):s[r+("ArrowUp"===t.key?-1:1)];n&&n!==i&&(t.preventDefault(),this.move(i,n,"ArrowDown"===t.key||"End"===t.key?"after":"before",!0),(e||i).focus?.())}_afterMove(t,e,i){if(this.refresh(),this._storeOrder(),this._hooks.refreshLayout?.(),!i)return;const s=this._rows(t.parentElement),r=s.indexOf(t);g.A.trigger(this._table,ao,{row:t,key:this._key(t,r),fromIndex:e,toIndex:r,beforeRow:t.previousElementSibling||null,afterRow:t.nextElementSibling||null,order:s.map((t,e)=>this._key(t,e))})}_clearDrag(){this._rows().forEach(t=>{t.removeAttribute(oo),t.removeAttribute(lo)}),this._wrapper?.classList.remove("vg-table-wrapper--row-dragging"),this._drag={row:null,fromIndex:-1,target:null,after:!1}}_rows(t=null){return(t?[t]:Array.from(this._table.tBodies||[])).flatMap(t=>Array.from(t.rows||[])).filter(t=>!t.matches("[data-vg-table-state-row], [data-vg-table-skeleton-row]"))}_resolveRow(t){if("TR"===t?.tagName&&this._table.contains(t))return t;const e=this._rows();if("number"==typeof t)return e[Number.parseInt(t,10)]||null;const i=String(t||"").trim();return e.find((t,e)=>this._key(t,e)===i)||null}_key(t,e){return String(t.getAttribute(this._options.keyAttr||"data-row-key")??t.getAttribute("data-id")??e)}_disabled(t){return t.hasAttribute("data-row-reorder-disabled")}_mode(){return"row"===String(this._options.mode||"handle").toLowerCase()?"row":"handle"}_handleSelector(){return String(this._options.handleSelector||"[data-row-reorder-handle]").trim()||"[data-row-reorder-handle]"}_handles(t){return Array.from(t.querySelectorAll(this._handleSelector()))}_handleLabel(t,e){return String(this._options.labels?.handle||"Изменить позицию строки {row}").replace("{row}",this._key(t,e))}_storageKey(){return!0!==this._options.persist||"undefined"==typeof window?"":String(this._options.storageKey||"").trim()||(this._table.id?`vg-table:${this._table.id}:row-order`:"")}_storeOrder(){const t=this._storageKey();if(t)try{window.localStorage.setItem(t,JSON.stringify(this.getState().order))}catch(t){}}_restoreStoredOrder(){const t=this._storageKey();if(!t)return;let e=[];try{e=JSON.parse(window.localStorage.getItem(t))||[]}catch(t){return}Array.isArray(e)&&e.forEach((t,e)=>{const i=this._resolveRow(String(t)),s=this._rows(i?.parentElement)[e];i&&s&&i!==s&&!this._disabled(i)&&!this._disabled(s)&&s.before(i)})}_clearStorage(){const t=this._storageKey();if(t)try{window.localStorage.removeItem(t)}catch(t){}}},uo=class{constructor(t,e={},i={}){this._table=t,this._options=e,this._hooks=i,this._cache=new Map,this._controller=null,this._token=0,this._params={},this._lastMeta={},this._lastRequest=null,this._loading=!1,this._boundClick=this._handleClick.bind(this)}init(){return this._table.addEventListener("click",this._boundClick),this.load()}dispose(){this._token+=1,this._controller?.abort?.(),this._table.removeEventListener("click",this._boundClick),this._table.removeAttribute("aria-busy"),this._table.removeAttribute("data-vg-table-remote"),this._cache.clear(),this._controller=null}load(t={}){const e=this._hooks.getPagination?.()||{},i=this._positiveInt(t.page,e.page||1),s=this._positiveInt(t.perPage,e.perPage||10);return t.params&&"object"==typeof t.params&&!Array.isArray(t.params)&&this.setParams(t.params,!0===t.replaceParams),this._request(i,s,{force:!0===t.force,source:String(t.source||"api")})}reload(t={}){return this.load(Object.assign({},t,{force:!1!==t.force}))}setParams(t={},e=!1){const i=t&&"object"==typeof t&&!Array.isArray(t)?t:{};return this._params=e?Object.assign({},i):Object.assign({},this._params,i),Object.assign({},this._params)}clearCache(){this._cache.clear()}getState(){return{loading:this._loading,params:Object.assign({},this._params),meta:Object.assign({},this._lastMeta),request:this._lastRequest?Object.assign({},this._lastRequest):null}}export(t="csv",e={}){const i=String(e.route||this._options.export?.route||this._options.route||"").trim();if(!i)return"";const s=this._hooks.getPagination?.()||{},r=this._mapParams(this._buildParams(this._positiveInt(e.page,s.page||1),this._positiveInt(e.perPage,s.perPage||10)));r.format="xlsx"===String(t||"csv").toLowerCase()?"xlsx":"csv";const n=this._hooks.buildUrl(r,i,this._requestConfig(i));return!1!==e.open&&"undefined"!=typeof window&&window.open?.(n.toString(),"_blank","noopener"),n.toString()}async _request(t,e,i={}){const s=String(this._options.route||"").trim();if(!s)return null;const r=this._mapParams(this._buildParams(t,e)),n=String(this._options.method||"GET").toUpperCase(),a=this._cacheKey(s,n,r),o=i.force?null:this._readCache(a),l=Date.now(),h=++this._token,d={requestId:`vg-table-${Date.now()}-${h}`,page:t,perPage:e,params:Object.assign({},r),source:i.source,fromCache:Boolean(o)};if(this._lastRequest=d,this._controller?.abort?.(),this._controller=o||"function"!=typeof AbortController?null:new AbortController,this._loading=!0,this._table.setAttribute("data-vg-table-remote",""),this._table.setAttribute("aria-busy","true"),this._emit("beforeload.vg.table",d),!o){const t=this._hooks.renderLoading?.();t||this._renderState(this._label("loading","Загрузка…"),"loading")}try{const s=o||await this._hooks.request(this._buildRequest(r,this._controller?.signal,i.source));if(h!==this._token)return null;if(o||await this._waitMinLoadingDelay(l),h!==this._token)return null;o||this._writeCache(a,s);const n=this._applyResponse(s,t,e);return this._emit("requestsuccess.vg.table",Object.assign({},d,{response:s,meta:n.meta})),this._emit("dataloaded.vg.table",Object.assign({},d,n,{response:s})),this._emit("afterrender.vg.table",Object.assign({},d,{renderedCount:n.renderedCount,total:n.meta.total})),n}catch(t){return"AbortError"===t?.name||h!==this._token||(o||await this._waitMinLoadingDelay(l),h!==this._token||(this._hooks.renderError?.(t)||this._renderState(this._label("error","Не удалось загрузить данные"),"error"),this._emit("requesterror.vg.table",Object.assign({},d,{error:t})))),null}finally{h===this._token&&(this._loading=!1,this._table.setAttribute("aria-busy","false"),this._controller=null)}}_waitMinLoadingDelay(t){const e=this._nonNegativeInt(this._hooks.getLoadingMinDelay?.(),0)-Math.max(0,Date.now()-t);return e>0?new Promise(t=>window.setTimeout(t,e)):Promise.resolve()}_buildRequest(t,e,i="api"){const s=String(this._options.method||"GET").toUpperCase(),r="GET"===s||"HEAD"===s,n=this._requestConfig();return"retry"===i&&(n.headers["X-VGTable-Retry"]="1"),Object.assign(n,{method:s,params:r?t:{},body:r?null:t,signal:e,responseType:"json"})}_requestConfig(t=this._options.route){return{route:t,method:this._options.method,credentials:this._options.credentials,headers:Object.assign({},this._options.headers||{}),baseParams:Object.assign({},this._options.params||{})}}_buildParams(t,e){const i=Object.assign({},this._params,{page:t,per_page:e}),s=this._hooks.getSort?.(),r=Array.isArray(s?.sorts)&&s.sorts.length?s.sorts:s?.field?[s]:[];r.length&&(i.sort=r.map(t=>t.field).filter(Boolean).join(","),i.dir=r.map(t=>"desc"===t.direction?"desc":"asc").join(","));const n=this._responseMode();if(i.responsemode=n,"data"!==n){const t=String(this._options.viewparam||"").trim(),e=String(this._options.viewvalue||"").trim();t&&e&&(i[t]=e);const s=String(this._options.fieldsparam||"").trim(),r=this._fields();s&&r.length&&(i[s]=r.join(","))}return i}_mapParams(t){const e=this._options.parammap&&"object"==typeof this._options.parammap?this._options.parammap:{};return Object.keys(t).reduce((i,s)=>(i[String(Object.prototype.hasOwnProperty.call(e,s)?e[s]:s).trim()||s]=t[s],i),{})}_applyResponse(t,e,i){const s=this._extractRows(t),r=this._extractView(t),n=this._normalizeMeta(this._readPath(t,this._options.metapath),s,e,i),a=this._responseMode();let o=0;return("view"===a||"auto"===a&&"string"==typeof r&&""!==r.trim())&&"string"==typeof r&&""!==r.trim()?(this._body().innerHTML=r,o=this._body().rows.length):Array.isArray(s)&&s.length?o=this._renderRows(s):this._hooks.renderEmpty?.({rows:s,view:r,meta:n})||this._renderState(this._label("empty","Ничего не найдено"),"empty"),this._lastMeta=n,this._hooks.applyMeta?.(n),this._hooks.afterRender?.({rows:s,view:r,meta:n,renderedCount:o}),{rows:s,view:r,meta:n,renderedCount:o}}_renderRows(t){const e=this._body(),i=this._fields(),s=this._table.ownerDocument.createDocumentFragment();return t.forEach(t=>{const e=this._table.ownerDocument.createElement("tr");i.forEach(i=>{const s=this._table.ownerDocument.createElement("td"),r=this._readPath(t,i);s.textContent=null==r?"":String(r),e.append(s)}),s.append(e)}),e.replaceChildren(s),t.length}_renderState(t,e){const i=this._body(),s=this._table.ownerDocument.createElement("tr"),r=this._table.ownerDocument.createElement("td");r.colSpan=Math.max(1,this._fields().length||this._headerCells().length),r.setAttribute("data-vg-table-state",e);const n=this._table.ownerDocument.createElement("span");if(n.textContent=t,r.append(n),"error"===e){const t=this._table.ownerDocument.createElement("button");t.type="button",t.className="vg-table-state__retry",t.setAttribute("data-vg-table-retry",""),t.textContent=this._label("retry","Повторить"),r.append(t)}s.append(r),i.replaceChildren(s)}_label(t,e){return String(this._options.labels?.[t]||e||"")}_normalizeMeta(t,e,i,s){const r=t&&"object"==typeof t&&!Array.isArray(t)?t:{},n=this._positiveInt(r.page??r.current_page,i),a=this._positiveInt(r.per_page??r.perPage,s),o=this._nonNegativeInt(r.total,Array.isArray(e)?e.length:0),l=this._positiveInt(r.pages??r.last_page,Math.max(1,Math.ceil(o/a)));return Object.assign({},r,{page:Math.min(n,l),per_page:a,total:o,pages:l})}_extractRows(t){const e=this._readPath(t,this._options.datapath);return Array.isArray(e)?e:[]}_extractView(t){const e=this._readPath(t,this._options.viewpath);return"string"==typeof e?e:""}_readPath(t,e){const i=String(e||"").split(".").map(t=>t.trim()).filter(Boolean);let s=t;for(const t of i){if(!s||"object"!=typeof s||!Object.prototype.hasOwnProperty.call(s,t))return;s=s[t]}return s}_fields(){return this._headerCells().map(t=>String(t.getAttribute("data-field")||"").trim()).filter(Boolean)}_headerCells(){const t=this._hooks.getHeaderTable?.()||this._table,e=t.tHead||t.querySelector("thead");return e?.rows.length?Array.from(e.rows[e.rows.length-1].cells):[]}_body(){return this._table.tBodies[0]||this._table.createTBody()}_responseMode(){const t=String(this._options.responsemode||"data").toLowerCase();return["data","view","auto"].includes(t)?t:"data"}_cacheKey(t,e,i){return`${e}:${t}?${Object.keys(i).sort().map(t=>{const e=Array.isArray(i[t])?i[t].join(","):i[t];return`${encodeURIComponent(t)}=${encodeURIComponent(e??"")}`}).join("&")}`}_readCache(t){if(!1===this._options.cache?.enable)return null;const e=this._cache.get(t);if(!e)return null;const i=this._positiveInt(this._options.cache?.ttl,3e4);return Date.now()-e.createdAt>i?(this._cache.delete(t),null):(e.usedAt=Date.now(),e.response)}_writeCache(t,e){if(!1===this._options.cache?.enable)return;this._cache.set(t,{response:e,createdAt:Date.now(),usedAt:Date.now()});const i=this._positiveInt(this._options.cache?.max,30);if(this._cache.size<=i)return;const s=Array.from(this._cache.entries()).sort((t,e)=>t[1].usedAt-e[1].usedAt)[0];s&&this._cache.delete(s[0])}_handleClick(t){t.target.closest("[data-vg-table-retry]")&&this.reload({source:"retry"})}_emit(t,e){g.A.trigger(this._table,t,e)}_positiveInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>0?i:e}_nonNegativeInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>=0?i:e}},mo=class{constructor(t,e={},i=null){this._table=t,this._options=e,this._onChange="function"==typeof i?i:null,this._form=null,this._controls=[],this._timer=null,this._boundInput=this._handleInput.bind(this),this._boundChange=this._handleChange.bind(this),this._boundClick=this._handleClick.bind(this),this._boundSubmit=this._handleSubmit.bind(this)}init(){return this._form=this._resolveForm(),this._form?(this.refresh(),this._form.addEventListener("input",this._boundInput),this._form.addEventListener("change",this._boundChange),this._form.addEventListener("click",this._boundClick),this._form.addEventListener("submit",this._boundSubmit),this):this}dispose(){this._form&&(this._form.removeEventListener("input",this._boundInput),this._form.removeEventListener("change",this._boundChange),this._form.removeEventListener("click",this._boundClick),this._form.removeEventListener("submit",this._boundSubmit)),this._timer&&window.clearTimeout(this._timer),this._timer=null,this._controls=[],this._form=null}refresh(){return this._form?(this._controls=Array.from(this._form.querySelectorAll(`[${this._fieldAttr()}]`)).filter(t=>["INPUT","SELECT","TEXTAREA"].includes(t.tagName)),this.getState()):this.getState()}getState(){const t=new Map;this._controls.forEach(e=>{const i=String(e.getAttribute(this._fieldAttr())||"").trim();if(!i)return;t.has(i)||t.set(i,{field:i,type:String(e.getAttribute(this._typeAttr())||"text").trim()||"text",operator:String(e.getAttribute(this._operatorAttr())||this._options.defaultOperator||"eq").trim()||"eq",value:"",values:[]});const s=t.get(i),r=String(e.getAttribute(this._partAttr())||"value").toLowerCase(),n=this._readValue(e);if("operator"!==r){if("type"!==r)return Array.isArray(n)?(s.values=n,void(s.value=n.join(","))):void(("checkbox"!==e.type&&"radio"!==e.type||""!==n)&&(s.value=n));s.type=String(n||"text").trim()||"text"}else s.operator=String(n||this._options.defaultOperator||"eq").trim()||"eq"});const e={},i={};return t.forEach((t,s)=>{const r=this._normalizeItem(t);r&&(e[s]=r,i[s]=r.values.length?r.values.slice():r.value,r.operator&&(i[`${s}_op`]=r.operator))}),{filters:e,params:i,fields:Object.keys(e),meta:{count:Object.keys(e).length}}}getFields(){return this._fieldNames()}setValues(t={},e={}){const i=t&&"object"==typeof t?t:{};return this._controls.forEach(t=>{const e=String(t.getAttribute(this._fieldAttr())||"").trim();if(!e)return;const s="operator"===String(t.getAttribute(this._partAttr())||"value").toLowerCase()?`${e}_op`:e;this._writeValue(t,Object.prototype.hasOwnProperty.call(i,s)?i[s]:"")}),!0===e.emit&&this._emit(String(e.source||"api")),this.getState()}reset(t={}){return this._controls.forEach(t=>this._resetControl(t)),!1!==t.emit&&this._emit(String(t.source||"reset")),this.getState()}_handleInput(t){this._isControl(t.target)&&!this._isManual()&&(["checkbox","radio"].includes(String(t.target.type).toLowerCase())||"SELECT"===t.target.tagName?this._emit("input"):this._schedule("input"))}_handleChange(t){this._isControl(t.target)&&!this._isManual()&&(this._clearTimer(),this._emit("change"))}_handleClick(t){const e=this._options.buttons||{},i=this._closest(t.target,e.apply||"[data-filter-apply]");if(i&&this._form.contains(i))return t.preventDefault(),this._clearTimer(),void this._emit("apply");const s=this._closest(t.target,e.reset||"[data-filter-reset]");s&&this._form.contains(s)&&(t.preventDefault(),this._clearTimer(),this.reset({source:"reset"}))}_handleSubmit(t){this._isManual()&&(t.preventDefault(),this._clearTimer(),this._emit("submit"))}_emit(t){const e=Object.assign(this.getState(),{source:t});g.A.trigger(this._table,"filterschange.vg.table",e),this._onChange?.(e)}_schedule(t){this._clearTimer(),this._timer=window.setTimeout(()=>{this._timer=null,this._emit(t)},this._nonNegativeInt(this._options.debounce,300))}_clearTimer(){this._timer&&window.clearTimeout(this._timer),this._timer=null}_resolveForm(){if("undefined"!=typeof Element&&this._options.form instanceof Element)return this._options.form;const t=String(this._options.form||"").trim();if(!t)return null;try{return document.querySelector(t)}catch(t){return null}}_normalizeItem(t){let e=t.value,i=Array.isArray(t.values)?t.values.slice():[];return!1!==this._options.trim&&("string"==typeof e&&(e=e.trim()),i=i.map(t=>String(t??"").trim()).filter(Boolean)),!1===this._options.skipEmpty||i.length||null!=e&&""!==String(e)?{field:t.field,type:String(t.type||"text").toLowerCase(),operator:String(t.operator||this._options.defaultOperator||"eq").toLowerCase(),value:e??"",values:i}:null}_readValue(t){return"SELECT"===t.tagName&&t.multiple?Array.from(t.selectedOptions).map(t=>t.value).filter(Boolean):"checkbox"===t.type||"radio"===t.type?t.checked?t.getAttribute(this._valueAttr())??t.value??"1":"":t.value??""}_writeValue(t,e){if("checkbox"===t.type||"radio"===t.type){const i=Array.isArray(e)?e.map(String):[String(e??"")],s=String(t.getAttribute(this._valueAttr())??t.value??"1");return void(t.checked=i.includes(s)||"checkbox"===t.type&&["1","true","on"].includes(i[0]?.toLowerCase()))}if("SELECT"===t.tagName&&t.multiple){const i=new Set((Array.isArray(e)?e:String(e??"").split(",")).map(String));return void Array.from(t.options).forEach(t=>{t.selected=i.has(t.value)})}t.value=String(e??"")}_resetControl(t){"checkbox"===t.type||"radio"===t.type?t.checked=t.defaultChecked:"SELECT"===t.tagName?Array.from(t.options).forEach(t=>{t.selected=t.defaultSelected}):t.value=t.defaultValue||""}_fieldNames(){return Array.from(new Set(this._controls.map(t=>String(t.getAttribute(this._fieldAttr())||"").trim()).filter(Boolean)))}_isControl(t){return this._controls.includes(t)}_closest(t,e){if(!t?.closest)return null;const i=String(e||"").trim();if(!i)return null;try{return t.closest(i)}catch(t){return null}}_isManual(){return"manual"===String(this._options.apply||"auto").toLowerCase()}_fieldAttr(){return String(this._options.fieldAttr||"data-filter-field")}_partAttr(){return String(this._options.partAttr||"data-filter-part")}_typeAttr(){return String(this._options.typeAttr||"data-filter-type")}_valueAttr(){return String(this._options.valueAttr||"data-filter-value")}_operatorAttr(){return String(this._options.operatorAttr||"data-filter-operator")}_nonNegativeInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>=0?i:e}},po=class{constructor(t,e={},i=null){this._table=t,this._options=e,this._onChange="function"==typeof i?i:null,this._input=null,this._resetButtons=[],this._timer=null,this._boundInput=this._handleInput.bind(this),this._boundKeydown=this._handleKeydown.bind(this),this._boundReset=this._handleReset.bind(this)}init(){return this._input=this._resolveNode(this._options.input),this._input?(this._resetButtons=this._resolveNodes(this._options.button?.reset||"[data-search-reset]"),this._input.addEventListener("input",this._boundInput),this._input.addEventListener("keydown",this._boundKeydown),this._resetButtons.forEach(t=>t.addEventListener("click",this._boundReset)),this):this}dispose(){this._input?.removeEventListener("input",this._boundInput),this._input?.removeEventListener("keydown",this._boundKeydown),this._resetButtons.forEach(t=>t.removeEventListener("click",this._boundReset)),this._clearTimer(),this._input=null,this._resetButtons=[]}getState(){return{value:this._value(),param:String(this._options.param||"q").trim()||"q"}}setValue(t,e={}){return this._input?(this._input.value=String(t??""),this._clearTimer(),!0===e.emit&&this._emit(String(e.source||"api")),this.getState()):this.getState()}reset(t={}){return this.setValue("",{emit:!1!==t.emit,source:String(t.source||"reset")})}refresh(){return this.getState()}_handleInput(){this._schedule("input")}_handleKeydown(t){"Enter"===t.key&&(t.preventDefault(),this._clearTimer(),this._emit("enter"))}_handleReset(t){t.preventDefault(),this.reset({source:"reset"}),this._input?.focus?.()}_emit(t){const e=Object.assign(this.getState(),{source:t});g.A.trigger(this._table,"searchchange.vg.table",e),this._onChange?.(e)}_schedule(t){this._clearTimer(),this._timer=window.setTimeout(()=>{this._timer=null,this._emit(t)},this._nonNegativeInt(this._options.debounce,300))}_clearTimer(){this._timer&&window.clearTimeout(this._timer),this._timer=null}_value(){const t=String(this._input?.value??"");return!1===this._options.trim?t:t.trim()}_resolveNode(t){if("undefined"!=typeof Element&&t instanceof Element)return t;const e=String(t||"").trim();if(!e)return null;try{return document.querySelector(e)}catch(t){return null}}_resolveNodes(t){const e=String(t||"").trim();if(!e)return[];try{const t=this._input?.form||this._input?.closest?.("[data-search-controls]")||document,i=Array.from(t.querySelectorAll(e));return i.length?i:Array.from(document.querySelectorAll(e))}catch(t){return[]}}_nonNegativeInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>=0?i:e}},go="tr[data-vg-table-skeleton]",fo=class{constructor(t,e={},i={}){this._table=t,this._options=e,this._hooks=i}render(){if(!1===this._options.enabled)return 0;const t=this._body(),e=this._dataRows(),i=this._columnWidths(e[0]),s=this._hasHorizontalOverflow(),r=Math.max(1,i.length,this._headerCells().length),n=this._rowsCount(e),a=this._rowHeight(e[0]),o=this._table.ownerDocument.createDocumentFragment();for(let t=0;t<n;t+=1){const e=this._table.ownerDocument.createElement("tr");e.className="vg-table-skeleton-row",e.setAttribute("data-vg-table-skeleton",""),e.setAttribute("aria-hidden","true"),e.style.setProperty("--vg-table-skeleton-delay",`${(.08*t).toFixed(2)}s`),a>0&&e.style.setProperty("--vg-table-skeleton-row-height",`${a}px`);for(let t=0;t<r;t+=1){const r=this._table.ownerDocument.createElement("td");a>0&&(r.style.height=`${a}px`);const n=Number.isFinite(i[t])?Math.round(i[t]):0;s&&n>0&&(r.style.width=`${n}px`,r.style.minWidth=`${n}px`,r.style.maxWidth=`${n}px`);const o=this._table.ownerDocument.createElement("span");o.className="vg-table-skeleton-cell";const l=this._table.ownerDocument.createElement("span");l.className="vg-table-skeleton-line",o.append(l),r.append(o),e.append(r)}o.append(e)}return t.replaceChildren(o),this._hooks.afterRender?.(),n}dispose(){this._body().querySelectorAll(go).forEach(t=>t.remove())}_rowsCount(t){if(t.length)return t.length;const e=this._body().querySelectorAll(go).length;if(e)return e;const i=Number.parseInt(this._options.skeleton??this._options.rows,10);if(Number.isFinite(i)&&i>0)return i;const s=Number.parseInt(this._hooks.getPagination?.()?.perPage,10);return Number.isFinite(s)&&s>0?s:5}_columnWidths(t){const e=this._headerCells().map(t=>this._width(t));return e.some(t=>t>0)?e:t?Array.from(t.cells||[],t=>this._width(t)):[]}_headerCells(){const t=this._hooks.getHeaderTable?.()||this._table,e=t.tHead||t.querySelector("thead");return e?.rows.length?Array.from(e.rows[e.rows.length-1].cells):[]}_dataRows(){return Array.from(this._body().rows||[]).filter(t=>!t.matches(go)&&!t.querySelector("[data-vg-table-state]"))}_rowHeight(t){const e=t?Math.round(this._height(t)):0;if(e>0)return e;const i=this._hooks.getHeaderTable?.()||this._table,s=i.tHead||i.querySelector("thead"),r=s?.rows.length?s.rows[s.rows.length-1]:null;return r?Math.round(this._height(r)):0}_width(t){const e=t?.getBoundingClientRect?.().width;return Number.isFinite(e)&&e>0?e:0}_height(t){const e=t?.getBoundingClientRect?.().height;return Number.isFinite(e)&&e>0?e:0}_hasHorizontalOverflow(){const t=this._hooks.getScrollHost?.()||this._table.closest(".vg-table-body")||this._table.closest(".vg-table-container");return!!t&&t.scrollWidth-t.clientWidth>1}_body(){return this._table.tBodies[0]||this._table.createTBody()}},bo="statechange.vg.table",vo="data-vg-table-state-row",yo=class{constructor(t,e,i={},s={}){this._table=t,this._wrapper=e,this._options=i,this._hooks=s,this._state=null,this._boundClick=this._handleClick.bind(this)}init(){return this._table.addEventListener("click",this._boundClick),this}dispose(){this._table.removeEventListener("click",this._boundClick),this.clear(!1)}render(t,e=""){if(!1===this._options.enabled)return null;const i=["empty","filtered-empty","error"].includes(String(t))?String(t):"empty";this._removeRow();const s=this._table.ownerDocument.createElement("tr");s.setAttribute(vo,"");const r=this._table.ownerDocument.createElement("td");r.colSpan=this._columns(),r.setAttribute("data-vg-table-state",i),r.setAttribute("role","error"===i?"alert":"status");const n=this._table.ownerDocument.createElement("div");n.className="vg-table-state";const a=this._table.ownerDocument.createElement("span");a.className=`vg-table-state__icon vg-table-state__icon--${i}`,a.setAttribute("aria-hidden","true");const o=this._table.ownerDocument.createElement("span");o.className="vg-table-state__text",o.textContent=e||this._label(i),n.append(a,o);const l=this._actions(i);return l&&n.append(l),r.append(n),s.append(r),!0===this._hooks.remote?this._body().replaceChildren(s):this._body().append(s),this._state={type:i,message:o.textContent},this._wrapper?.setAttribute("data-vg-table-state",i),g.A.trigger(this._table,bo,this.getState()),this.getState()}clear(t=!0){const e=this._state;return this._removeRow(),this._state=null,this._wrapper?.removeAttribute("data-vg-table-state"),t&&e&&g.A.trigger(this._table,bo,{type:null,previous:e}),e}syncLocal(t=!1){const e=this._dataRows();if(!e.length)return this.render("empty");const i=e.filter(t=>!t.hasAttribute("data-vg-table-filter-hidden"));return t&&!i.length?this.render("filtered-empty"):(this.clear(),null)}getState(){return this._state?Object.assign({},this._state):null}_actions(t){if("error"!==t&&"filtered-empty"!==t)return null;const e=this._table.ownerDocument.createElement("span");e.className="vg-table-state__actions";const i=this._table.ownerDocument.createElement("button");return i.type="button",i.className="vg-table-state__action","error"===t?(i.setAttribute("data-vg-table-retry",""),i.textContent=this._label("retry")):(i.setAttribute("data-vg-table-state-reset",""),i.textContent=this._label("reset")),e.append(i),e}_handleClick(t){t.target.closest("[data-vg-table-state-reset]")&&(t.preventDefault(),this._hooks.reset?.())}_label(t){const e=this._options.labels||{};return String(e[t]||{empty:"Нет данных","filtered-empty":"По вашему запросу ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить",reset:"Сбросить фильтры"}[t]||"")}_columns(){const t=this._hooks.getHeaderTable?.()||this._table,e=Array.from(t.tHead?.rows||[]);return Math.max(1,e.length?e.at(-1).cells.length:1)}_dataRows(){return Array.from(this._table.tBodies||[]).flatMap(t=>Array.from(t.rows||[])).filter(t=>!t.hasAttribute(vo))}_removeRow(){this._body().querySelector(`[${vo}]`)?.remove()}_body(){return this._table.tBodies[0]||this._table.createTBody()}},wo="urlstateerror.vg.table",Eo=class{constructor(t,e={},i={}){this._table=t,this._options=e,this._hooks=i,this._state=null,this._boundPopState=this._handlePopState.bind(this)}init(){return!1!==this._options.listen&&"undefined"!=typeof window&&window.addEventListener("popstate",this._boundPopState),this}dispose(){"undefined"!=typeof window&&window.removeEventListener("popstate",this._boundPopState),this._state=null}read(t="api"){if("undefined"==typeof window)return this._emptyState();try{const e=new URLSearchParams(window.location.search||""),i=this._keys(),s=this._emptyState();if(this._include("pagination")&&(s.present.page=e.has(i.page),s.present.perPage=e.has(i.perPage),s.page=this._positiveInt(e.get(i.page),null),s.perPage=this._positiveInt(e.get(i.perPage),null)),this._include("sort")){s.present.sort=e.has(i.sort)||e.has(i.direction);const t=this._list(e.get(i.sort)),r=this._list(e.get(i.direction)),n=t.map((t,e)=>({field:t,direction:"desc"===String(r[e]||r[0]||"asc").toLowerCase()?"desc":"asc"}));s.sort=n.length?Object.assign({},n[0],{sorts:n}):null}return this._include("search")&&(s.present.search=e.has(i.search),s.search=String(e.get(i.search)||"")),this._include("filters")&&this._filterFields().forEach(t=>{const r=`${i.filterPrefix}${t}`,n=`${r}_op`,a=e.getAll(r);a.length&&(s.filters[t]=1===a.length?a[0]:a,s.present.filters=!0),e.has(n)&&(s.filters[`${t}_op`]=e.get(n),s.present.filters=!0)}),this._state=s,g.A.trigger(this._table,"urlstateread.vg.table",{source:t,state:this.getState()}),this.getState()}catch(t){return g.A.trigger(this._table,wo,{source:"read",error:t}),this._emptyState()}}write(t={}){if(!1===this._options.write||"undefined"==typeof window||!window.history)return null;try{const e=new URL(window.location.href),i=this._keys();if(this._managedKeys().forEach(t=>e.searchParams.delete(t)),this._include("pagination")&&(this._set(e,i.page,t.page||1),this._set(e,i.perPage,t.perPage||"")),this._include("sort")&&t.sort?.field){const s=Array.isArray(t.sort.sorts)&&t.sort.sorts.length?t.sort.sorts:[t.sort];this._set(e,i.sort,s.map(t=>t.field).filter(Boolean).join(",")),this._set(e,i.direction,s.map(t=>"desc"===t.direction?"desc":"asc").join(","))}this._include("search")&&this._set(e,i.search,t.search||""),this._include("filters")&&Object.entries(t.filters||{}).forEach(([t,s])=>{const r=`${i.filterPrefix}${t}`;(Array.isArray(s)?s:[s]).forEach(t=>this._append(e,r,t))});const s=`${e.pathname}${e.search}${e.hash}`;return s!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history["push"===this._options.mode?"pushState":"replaceState"]({},"",s),this._state=Object.assign({},t),g.A.trigger(this._table,"urlstatewrite.vg.table",{mode:this._options.mode,state:this.getState(),url:s}),s}catch(t){return g.A.trigger(this._table,wo,{source:"write",error:t}),null}}getState(){return this._state?JSON.parse(JSON.stringify(this._state)):null}_handlePopState(){this._hooks.apply?.(this.read("popstate"),{source:"popstate",clearMissing:!0})}_managedKeys(){const t=this._keys(),e=[];return this._include("pagination")&&e.push(t.page,t.perPage),this._include("sort")&&e.push(t.sort,t.direction),this._include("search")&&e.push(t.search),this._include("filters")&&this._filterFields().forEach(i=>e.push(`${t.filterPrefix}${i}`,`${t.filterPrefix}${i}_op`)),e.filter(Boolean)}_filterFields(){return this._hooks.getFilterFields?.()||[]}_keys(){const t=this._options.keys||{},e=String(this._options.prefix||"");return{page:`${e}${t.page||"page"}`,perPage:`${e}${t.perPage||"perPage"}`,sort:`${e}${t.sort||"sort"}`,direction:`${e}${t.direction||"dir"}`,search:`${e}${t.search||"search"}`,filterPrefix:`${e}${t.filterPrefix||"filter-"}`}}_include(t){return!1!==(this._options.include||{})[t]}_emptyState(){return{page:null,perPage:null,sort:null,search:"",filters:{},present:{page:!1,perPage:!1,sort:!1,search:!1,filters:!1}}}_set(t,e,i){null!=i&&""!==String(i)&&t.searchParams.set(e,String(i))}_append(t,e,i){null!=i&&""!==String(i)&&t.searchParams.append(e,String(i))}_positiveInt(t,e){const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>0?i:e}_list(t){return String(t||"").split(",").map(t=>t.trim()).filter(Boolean)}},Ao="ru",So={ru:{pagination:{size:{label:"Строк на странице",suffix:"на страницу"},quick:{label:"Перейти к странице",button:"Перейти"},labels:{aria:"Пагинация",prev:"Назад",next:"Вперёд",ellipsisPrev:"Перейти к предыдущим страницам",ellipsisNext:"Перейти к следующим страницам"}},expandable:{labels:{expand:"Развернуть дочерние строки",collapse:"Свернуть дочерние строки"}},state:{labels:{empty:"Нет данных","filtered-empty":"По вашему запросу ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить",reset:"Сбросить фильтры"}},columnResize:{label:"Изменить ширину колонки {column}"},rowReorder:{labels:{handle:"Изменить позицию строки {row}"}},remote:{loading:"Загрузка…",empty:"Ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить"}},en:{pagination:{size:{label:"Rows per page",suffix:"per page"},quick:{label:"Go to page",button:"Go"},labels:{aria:"Pagination",prev:"Previous",next:"Next",ellipsisPrev:"Jump to previous pages",ellipsisNext:"Jump to next pages"}},expandable:{labels:{expand:"Expand child rows",collapse:"Collapse child rows"}},state:{labels:{empty:"No data","filtered-empty":"No results found",error:"Failed to load data",retry:"Retry",reset:"Reset filters"}},columnResize:{label:"Resize column {column}"},rowReorder:{labels:{handle:"Change position of row {row}"}},remote:{loading:"Loading…",empty:"Nothing found",error:"Failed to load data",retry:"Retry"}}},Co=t=>t&&"object"==typeof t&&!Array.isArray(t),xo=(...t)=>t.reduce((t,e)=>Co(e)?(Object.entries(e).forEach(([e,i])=>{t[e]=Co(i)?xo(Co(t[e])?t[e]:{},i):i}),t):t,{}),Lo=t=>String(t||Ao).trim().toLowerCase().replace("_","-")||Ao,Io=(t,e={})=>{const i=xo({},So,e),s=i[Ao]||{},r=(t=>{const e=Lo(t),i=e.split("-")[0];return e===i?[e]:[e,i]})(t).map(t=>i[t]).find(Boolean)||s;return xo({},s,r)},Po=new Map,Mo=t=>String(t||"").trim(),ko=t=>Po.get(Mo(t))||null,Do="table",To=`vg.${Do}`,Oo=".vg-table-wrapper",zo=".vg-table-container",No={locale:"ru",i18n:{},sort:{enabled:!0,hover:!0,multiple:!1,multipleWithShift:!0},pan:{enabled:!0},stickyHeader:{enabled:!1,mode:"container",top:null,maxHeight:"24rem"},fixedColumns:{enabled:!1,columns:"",mode:"fixed",stackGap:0},columnResize:{enabled:!1,minWidth:80,maxWidth:600,persist:!1,storageKey:"",label:"Изменить ширину колонки {column}"},columnReorder:{enabled:!1,persist:!1,storageKey:""},columnVisibility:{enabled:!1,controls:"",minVisible:1,persist:!1,storageKey:""},rowReorder:{enabled:!1,mode:"handle",handleSelector:"[data-row-reorder-handle]",keyAttr:"data-row-key",persist:!1,storageKey:"",labels:{handle:"Изменить позицию строки {row}"}},selection:{enabled:!1,click:!0,multiple:!1},expandable:{enabled:!1,idAttr:"data-expand-id",parentAttr:"data-expand-parent-id",toggleSelector:"[data-expand-toggle]",collapsed:!0,labels:{expand:"Развернуть дочерние строки",collapse:"Свернуть дочерние строки"}},search:{enabled:!1,input:"",param:"q",debounce:300,resetPage:!0,trim:!0,fields:[],button:{reset:"[data-search-reset]"}},filters:{enabled:!1,form:"",debounce:300,apply:"auto",resetPage:!0,skipEmpty:!0,trim:!0,defaultOperator:"eq",fieldAttr:"data-filter-field",partAttr:"data-filter-part",typeAttr:"data-filter-type",valueAttr:"data-filter-value",operatorAttr:"data-filter-operator",buttons:{apply:"[data-filter-apply]",reset:"[data-filter-reset]"}},state:{enabled:!0,labels:{empty:"Нет данных","filtered-empty":"По вашему запросу ничего не найдено",error:"Не удалось загрузить данные",retry:"Повторить",reset:"Сбросить фильтры"}},urlState:{enabled:!1,read:!0,write:!0,listen:!0,mode:"replace",prefix:"",keys:{page:"page",perPage:"perPage",sort:"sort",direction:"dir",search:"search",filterPrefix:"filter-"},include:{pagination:!0,sort:!0,search:!0,filters:!0}},loading:{enabled:!0,minDelay:500,skeleton:5},request:{route:"",method:"GET",credentials:"same-origin",headers:{Accept:"application/json"},params:{},parammap:{},responsemode:"data",datapath:"data",metapath:"meta",viewpath:"view.tbody",viewparam:"view",viewvalue:"rows",fieldsparam:"fields",cache:{enable:!0,ttl:3e4,max:30},export:{route:""}},pagination:{enabled:!1,page:1,per:10,max:100,position:"bottom",align:"right",ellipsis:!0,ellipsisHover:!0,threshold:5,visible:5,size:{enabled:!1,options:[10,25,50,100],label:"Строк на странице",suffix:"на страницу"},quick:{enabled:!1,label:"Перейти к странице",button:"Перейти"},persist:{page:!0,per:!0},storage:{key:""},scroll:!1,labels:{aria:"Пагинация",prev:"Назад",next:"Вперёд",ellipsisPrev:"Перейти к предыдущим страницам",ellipsisNext:"Перейти к следующим страницам"}}},$o="data-vg-table-filter-hidden",Ho="not-splitter";class Fo extends t.A{constructor(t,e={}){super(t,e);const i=ko(t?.getAttribute?.("data-group-params"))||{},s=Lo(e.locale||i.locale||t?.getAttribute?.("data-locale")||No.locale),n=(0,r._v)({},i.i18n||{},e.i18n||{});this._dictionary=Io(s,n),this._params=this._getParams(t,(0,r._v)(No,this._dictionary,i,e,{locale:s,i18n:n})),this._params.locale=Lo(this._params.locale),this._normalizeSortDataOptions(),this._normalizeRequestDataOptions(),this._normalizePaginationDataOptions(),this._normalizeSearchDataOptions(),this._normalizeFiltersDataOptions(),this._normalizeStateDataOptions(),this._normalizeUrlStateDataOptions(),this._normalizeLoadingDataOptions(),this._normalizeExpandableDataOptions(),this._normalizeStickyHeaderDataOptions(),this._normalizeFixedColumnsDataOptions(),this._normalizeColumnsDataOptions(),this._normalizeRowReorderDataOptions(),this._sorting=null,this._panning=null,this._selection=null,this._expandable=null,this._pagination=null,this._filters=null,this._search=null,this._skeleton=null,this._states=null,this._urlState=null,this._applyingUrlState=!1,this._filtersState={filters:{},params:{},fields:[],meta:{count:0}},this._filterParamKeys=new Set,this._searchState={value:"",param:"q"},this._searchParamKey="",this._stickyHeader=null,this._fixedColumns=null,this._columns=null,this._rowReorder=null,this._remote=null,this._autoNotSplitterHeaders=new Set,this._emptyHeaderSortOptions=new Map,this._emptyHeaderSplittersSynced=!1,this._isRemote=Boolean(String(this._params.request.route||"").trim()),this._complex=!1,this._wrapper=null,this._ownsWrapper=!1,this._tableContainer=null,this._ownsTableContainer=!1,this._boundPaginationRefresh=this._refreshPagination.bind(this),this._boundLocalSortChange=this._handleLocalSortChange.bind(this),this._boundRemoteSortChange=this._handleRemoteSortChange.bind(this)}static get NAME(){return Do}static get NAME_KEY(){return To}static registerParamsGroup(t,e={}){return((t,e={})=>{const i=Mo(t);return!(!i||!e||"object"!=typeof e||Array.isArray(e)||(Po.set(i,e),0))})(t,e)}static unregisterParamsGroup(t){return(t=>Po.delete(Mo(t)))(t)}static getParamsGroup(t){return ko(t)}init(){if(this._ensureWrapper(),this._ensureTableContainer(),this._syncComplexState(),this._syncEmptyHeaderSplitters(),this._stickyHeader||!0!==this._params.stickyHeader.enabled||(this._stickyHeader=new Ga(this._element,this._wrapper,this._tableContainer,this._params.stickyHeader),this._stickyHeader.init()),this._complex||this._columns||!this._hasColumnsFeatures()||(this._columns=new no(this._element,this._wrapper,{resize:this._params.columnResize,reorder:this._params.columnReorder,visibility:this._params.columnVisibility},{getHeaderTable:()=>this._stickyHeader?.getHeaderTable?.()||this._element,isFixed:t=>this._isFixedColumnField(t),refreshLayout:(t=!1)=>this._refreshColumnsLayout(t)}),this._columns.init()),this._complex||this._rowReorder||!0!==this._params.rowReorder.enabled||(this._rowReorder=new _o(this._element,this._wrapper,this._params.rowReorder,{refreshLayout:()=>this._refreshRowsLayout()}),this._rowReorder.init()),this._complex||this._sorting||!0!==this._params.sort.enabled||!0===this._params.rowReorder.enabled||(this._sorting=new Ma(this._element,Object.assign({},this._params.sort,{remote:this._isRemote}),this._stickyHeader?.getHeaderTable()),this._sorting.init(),this._element.addEventListener("sortchange.vg.table",this._isRemote?this._boundRemoteSortChange:this._boundLocalSortChange)),this._complex||this._fixedColumns||!0!==this._params.fixedColumns.enabled||(this._fixedColumns=new Qa(this._element,this._wrapper,this._params.fixedColumns,this._stickyHeader),this._fixedColumns.init()),this._panning||!0!==this._params.pan.enabled||(this._panning=new ka(this._element,{onMove:()=>{this._stickyHeader?.syncScroll?.(),this._fixedColumns?.syncScroll?.()}}),this._panning.init()),this._selection||!0!==this._params.selection.enabled||(this._selection=new za(this._element,this._params.selection),this._selection.init()),this._expandable||!0!==this._params.expandable.enabled||(this._expandable=new Ua(this._element,this._params.expandable),this._expandable.init()),this._pagination||!0!==this._params.pagination.enabled||(this._pagination=new Ha(this._element,Object.assign({},this._params.pagination,{remote:this._isRemote,onChange:t=>this._handlePaginationChange(t)})),this._pagination.init()),this._filters||!0!==this._params.filters.enabled||(this._filters=new mo(this._element,this._params.filters,t=>this._handleFiltersChange(t)),this._filters.init(),this._filtersState=this._filters.getState(),this._filterParamKeys=new Set(Object.keys(this._filtersState.params||{})),this._isRemote||this._applyLocalFilters(this._filtersState)),this._search||!0!==this._params.search.enabled||(this._search=new po(this._element,this._params.search,t=>this._handleSearchChange(t)),this._search.init(),this._searchState=this._search.getState(),this._searchParamKey=this._searchState.param,this._isRemote||this._applyLocalFilters(this._filtersState)),this._states||!0!==this._params.state.enabled||(this._states=new yo(this._element,this._wrapper,this._params.state,{remote:this._isRemote,getHeaderTable:()=>this._stickyHeader?.getHeaderTable()||this._element,reset:()=>this._resetQueryControls()}),this._states.init(),this._isRemote||this._states.syncLocal(this._hasActiveQuery())),this._urlState||!0!==this._params.urlState.enabled||(this._urlState=new Eo(this._element,this._params.urlState,{getFilterFields:()=>this._filters?.getFields?.()||[],apply:(t,e)=>this._applyUrlState(t,e)}),this._urlState.init(),!1!==this._params.urlState.read&&this._applyUrlState(this._urlState.read("init"),{source:"init",clearMissing:!1})),!this._remote&&this._isRemote){this._skeleton=new fo(this._element,this._params.loading,{getPagination:()=>this._pagination?.getState()||null,getHeaderTable:()=>this._stickyHeader?.getHeaderTable()||this._element,getScrollHost:()=>this._stickyHeader?.getBody()||this._tableContainer,afterRender:()=>{this._columns?.refresh?.(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}}),this._remote=new uo(this._element,Object.assign({},this._params.request,{labels:this._dictionary.remote||{}}),{request:t=>this._route(t),buildUrl:(t,e,i)=>this._buildRouteUrl(t,e,i),getPagination:()=>this._pagination?.getState()||{page:this._params.pagination.page,perPage:this._params.pagination.per},getSort:()=>this._sorting?.getSortState?.()||this._sorting?.getSort()||null,getHeaderTable:()=>this._stickyHeader?.getHeaderTable()||this._element,applyMeta:t=>this._pagination?.setMeta(t),afterRender:t=>this._afterRemoteRender(t),renderLoading:()=>this._skeleton?.render(),renderEmpty:()=>this._states?.render(this._hasActiveQuery()?"filtered-empty":"empty"),renderError:()=>this._states?.render("error"),getLoadingMinDelay:()=>this._params.loading.minDelay});const t=Object.assign({},this._filtersState.params||{});this._searchState.value&&(t[this._searchState.param]=this._searchState.value),Object.keys(t).length&&this._remote.setParams(t),this._remote.init()}return this}isRemote(){return this._isRemote}isComplex(){return this._complex}getLocale(){return this._params.locale}setLocale(t){const e=Lo(t);this._dictionary=Io(e,this._params.i18n||{}),this._params.locale=e,this._mergeLocale(this._params,this._dictionary),this._normalizePaginationDataOptions(),this._normalizeStateDataOptions(),this._normalizeExpandableDataOptions(),this._normalizeColumnsDataOptions(),this._normalizeRowReorderDataOptions(),this._remote&&(this._remote._options.labels=this._dictionary.remote||{}),this._pagination?.refresh?.(),this._expandable?.refresh?.(),this._columns?.refresh?.(),this._rowReorder?.refresh?.();const i=this._states?.getState?.();return i&&this._states.render(i.type),g.A.trigger(this._element,"localechange.vg.table",{locale:e}),e}_mergeLocale(t,e){return t&&e&&"object"==typeof e?(Object.entries(e).forEach(([e,i])=>{i&&"object"==typeof i&&!Array.isArray(i)?(t[e]&&"object"==typeof t[e]&&!Array.isArray(t[e])||(t[e]={}),this._mergeLocale(t[e],i)):t[e]=i}),t):t}_normalizeSortDataOptions(){const t=this._params.sort,e=t=>!["false","0","off","no"].includes(String(t).toLowerCase()),i=this._element.getAttribute("data-sort-multiple")??this._element.getAttribute("data-sort-multi"),s=this._element.getAttribute("data-sort-multiple-with-shift")??this._element.getAttribute("data-sort-multi-with-shift");null!==i&&(t.multiple=e(i)),null!==s&&(t.multipleWithShift=e(s))}_normalizeColumnsDataOptions(){const t=t=>!["false","0","off","no"].includes(String(t).toLowerCase()),e=(t,e,i)=>{const s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=i?s:e};[["columnResize","column-resize"],["columnReorder","column-reorder"],["columnVisibility","column-visibility"]].forEach(([e,i])=>{const s=this._params[e];Object.prototype.hasOwnProperty.call(s,"enable")&&(s.enabled=t(s.enable));const r=this._element.getAttribute(`data-${i}-enable`)??this._element.getAttribute(`data-${i}-enabled`);null!==r&&(s.enabled=t(r));const n=this._element.getAttribute(`data-${i}-persist`);null!==n&&(s.persist=t(n));const a=this._element.getAttribute(`data-${i}-storage-key`);null!==a&&(s.storageKey=a)});const i=this._params.columnResize;i.minWidth=e(this._element.getAttribute("data-column-resize-min-width")??i.minWidth,80,40),i.maxWidth=e(this._element.getAttribute("data-column-resize-max-width")??i.maxWidth,600,i.minWidth),i.maxWidth=Math.max(i.minWidth,i.maxWidth);const s=this._params.columnVisibility,r=this._element.getAttribute("data-column-visibility-controls");null!==r&&(s.controls=r),s.minVisible=e(this._element.getAttribute("data-column-visibility-min-visible")??s.minVisible,1,1)}_normalizeRowReorderDataOptions(){const t=this._params.rowReorder,e=(t,e)=>{const i=this._element.getAttribute(`data-row-reorder-${t}`);null!==i&&e(i)},i=t=>["true","1","yes","on"].includes(String(t).toLowerCase());e("enable",e=>{t.enabled=i(e)}),e("enabled",e=>{t.enabled=i(e)}),e("mode",e=>{t.mode="row"===String(e).toLowerCase()?"row":"handle"}),e("handle-selector",e=>{t.handleSelector=String(e).trim()||t.handleSelector}),e("key-attr",e=>{t.keyAttr=String(e).trim()||t.keyAttr}),e("persist",e=>{t.persist=i(e)}),e("storage-key",e=>{t.storageKey=String(e).trim()})}_hasColumnsFeatures(){return!0===this._params.columnResize.enabled||!0===this._params.columnReorder.enabled||!0===this._params.columnVisibility.enabled}_normalizeRequestDataOptions(){this._params.request=(0,r._v)({},this._params.request,{headers:Object.assign({},this._params.request.headers),params:Object.assign({},this._params.request.params),parammap:Object.assign({},this._params.request.parammap),cache:Object.assign({},this._params.request.cache),export:Object.assign({},this._params.request.export)});const t=this._params.request,e=t=>this._element.getAttribute(`data-request-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=(t,e)=>{const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>0?i:e},n=(t,e)=>{try{const i=JSON.parse(t);return i&&"object"==typeof i&&!Array.isArray(i)?i:e}catch(t){return e}};i("route",e=>{t.route=e}),i("method",e=>{t.method=e}),i("credentials",e=>{t.credentials=e}),i("params",e=>{t.params=n(e,t.params)}),i("parammap",e=>{t.parammap=n(e,t.parammap)}),i("responsemode",e=>{t.responsemode=e}),i("datapath",e=>{t.datapath=e}),i("metapath",e=>{t.metapath=e}),i("viewpath",e=>{t.viewpath=e}),i("viewparam",e=>{t.viewparam=e}),i("viewvalue",e=>{t.viewvalue=e}),i("fieldsparam",e=>{t.fieldsparam=e}),i("cache-enable",e=>{t.cache.enable=(t=>!["false","0","off","no"].includes(String(t).toLowerCase()))(e)}),i("cache-ttl",e=>{t.cache.ttl=s(e,t.cache.ttl)}),i("cache-max",e=>{t.cache.max=s(e,t.cache.max)}),i("export-route",e=>{t.export.route=e}),t.route=String(t.route||"").trim(),t.method=String(t.method||"GET").toUpperCase(),t.credentials=String(t.credentials||"same-origin"),t.responsemode=["view","auto"].includes(String(t.responsemode).toLowerCase())?String(t.responsemode).toLowerCase():"data"}_syncComplexState(){const t=(this._isRemote?Array.from(this._element.tHead?.rows||[]):Array.from(this._element.rows||[])).some(t=>Array.from(t.cells||[]).some(t=>t.colSpan>1||t.rowSpan>1));this._complex=Boolean((this._element.tHead?.rows.length||0)>1||t),this._element.classList.toggle("vg-table-complex",this._complex),this._element.toggleAttribute("data-vg-table-complex",this._complex)}_syncEmptyHeaderSplitters(){this._emptyHeaderSplittersSynced||(Array.from(this._element.tHead?.querySelectorAll("th")||[]).forEach(t=>{0===t.childElementCount&&""===String(t.textContent||"").trim()&&(t.classList.contains(Ho)||(t.classList.add(Ho),this._autoNotSplitterHeaders.add(t)),"false"!==String(t.getAttribute("data-sort-enabled")).toLowerCase()&&(this._emptyHeaderSortOptions.set(t,t.getAttribute("data-sort-enabled")),t.setAttribute("data-sort-enabled","false")))}),this._emptyHeaderSplittersSynced=!0)}_normalizePaginationDataOptions(){this._params.pagination=(0,r._v)({},this._params.pagination,{size:Object.assign({},this._params.pagination.size),quick:Object.assign({},this._params.pagination.quick),persist:Object.assign({},this._params.pagination.persist),storage:Object.assign({},this._params.pagination.storage),labels:Object.assign({},this._params.pagination.labels)});const t=this._params.pagination,e=t=>this._element.getAttribute(`data-pagination-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase()),n=(t,e)=>{const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>0?i:e};i("enable",e=>{t.enabled=s(e)}),i("enabled",e=>{t.enabled=s(e)}),i("per-page",e=>{t.per=n(e,t.per)}),i("max-per-page",e=>{t.max=n(e,t.max)}),i("ellipsis",e=>{t.ellipsis=s(e)}),i("ellipsis-hover",e=>{t.ellipsisHover=s(e)}),i("ellipsis-after",e=>{t.threshold=n(e,t.threshold)}),i("max-visible-pages",e=>{t.visible=n(e,t.visible)}),i("show-per-page",e=>{t.size.enabled=s(e)}),i("show-per-page-label",e=>{t.size.label=!!s(e)&&"Строк на странице"}),i("per-page-label",e=>{t.size.label=e}),i("per-page-option-suffix",e=>{t.size.suffix=e}),i("per-page-options",e=>{t.size.options=(t=>String(t).replace(/^\[|\]$/g,"").split(",").map(t=>n(t.trim(),0)).filter(t=>t>0))(e)}),i("quick-jump",e=>{t.quick.enabled="auto"===e?"auto":s(e)}),i("quick-jump-button-label",e=>{t.quick.button=e}),i("persist-page",e=>{t.persist.page=s(e)}),i("persist-per-page",e=>{t.persist.per=s(e)}),i("storage-key",e=>{t.storage.key=e}),i("scroll-to-top",e=>{t.scroll=!!s(e)&&"table"}),i("scroll-to-window-top",e=>{s(e)&&(t.scroll="window")}),i("prev-label",e=>{t.labels.prev=e}),i("next-label",e=>{t.labels.next=e})}_normalizeSearchDataOptions(){this._params.search=(0,r._v)({},this._params.search,{button:Object.assign({},this._params.search.button)});const t=this._params.search,e=t=>this._element.getAttribute(`data-search-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase()),n=(t,e)=>{const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>=0?i:e},a=t=>{if(Array.isArray(t))return t.map(t=>String(t).trim()).filter(Boolean);try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(t=>String(t).trim()).filter(Boolean)}catch(t){}return String(t||"").split(",").map(t=>t.trim()).filter(Boolean)};Object.prototype.hasOwnProperty.call(t,"enable")&&(t.enabled=s(t.enable)),i("enable",e=>{t.enabled=s(e)}),i("enabled",e=>{t.enabled=s(e)}),i("input",e=>{t.input=e}),i("input-selector",e=>{t.input=e}),i("param",e=>{t.param=e}),i("debounce",e=>{t.debounce=n(e,t.debounce)}),i("debounce-ms",e=>{t.debounce=n(e,t.debounce)}),i("reset-page",e=>{t.resetPage=s(e)}),i("reset-page-on-change",e=>{t.resetPage=s(e)}),i("trim",e=>{t.trim=s(e)}),i("fields",e=>{t.fields=a(e)}),i("button-reset",e=>{t.button.reset=e}),t.fields=a(t.fields),t.param=String(t.param||"q").trim()||"q"}_normalizeFiltersDataOptions(){this._params.filters=(0,r._v)({},this._params.filters,{buttons:Object.assign({},this._params.filters.buttons)});const t=this._params.filters,e=t=>this._element.getAttribute(`data-filters-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase()),n=(t,e)=>{const i=Number.parseInt(t,10);return Number.isFinite(i)&&i>=0?i:e};Object.prototype.hasOwnProperty.call(t,"enable")&&(t.enabled=s(t.enable)),i("enable",e=>{t.enabled=s(e)}),i("enabled",e=>{t.enabled=s(e)}),i("form",e=>{t.form=e}),i("form-selector",e=>{t.form=e}),i("debounce",e=>{t.debounce=n(e,t.debounce)}),i("debounce-ms",e=>{t.debounce=n(e,t.debounce)}),i("apply",e=>{t.apply=e}),i("apply-mode",e=>{t.apply=e}),i("reset-page",e=>{t.resetPage=s(e)}),i("reset-page-on-change",e=>{t.resetPage=s(e)}),i("skip-empty",e=>{t.skipEmpty=s(e)}),i("trim",e=>{t.trim=s(e)}),i("trim-values",e=>{t.trim=s(e)}),i("default-operator",e=>{t.defaultOperator=e}),i("field-attr",e=>{t.fieldAttr=e}),i("part-attr",e=>{t.partAttr=e}),i("type-attr",e=>{t.typeAttr=e}),i("value-attr",e=>{t.valueAttr=e}),i("operator-attr",e=>{t.operatorAttr=e}),i("button-apply",e=>{t.buttons.apply=e}),i("button-reset",e=>{t.buttons.reset=e}),t.apply="manual"===String(t.apply).toLowerCase()?"manual":"auto"}_normalizeStateDataOptions(){this._params.state=(0,r._v)({},this._params.state,{labels:Object.assign({},this._params.state.labels)});const t=this._params.state,e=t=>this._element.getAttribute(`data-state-${t}`),i=e("enable")??e("enabled");null!==i&&(t.enabled=!["false","0","off","no"].includes(String(i).toLowerCase())),["empty","filtered-empty","error","retry","reset"].forEach(i=>{const s=e(`${i}-label`);null!==s&&(t.labels[i]=s)})}_normalizeUrlStateDataOptions(){this._params.urlState=(0,r._v)({},this._params.urlState,{keys:Object.assign({},this._params.urlState.keys),include:Object.assign({},this._params.urlState.include)});const t=this._params.urlState,e=t=>this._element.getAttribute(`data-url-state-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase());Object.prototype.hasOwnProperty.call(t,"enable")&&(t.enabled=s(t.enable)),i("enable",e=>{t.enabled=s(e)}),i("enabled",e=>{t.enabled=s(e)}),i("read",e=>{t.read=s(e)}),i("write",e=>{t.write=s(e)}),i("listen",e=>{t.listen=s(e)}),i("mode",e=>{t.mode=e}),i("prefix",e=>{t.prefix=e}),i("page-key",e=>{t.keys.page=e}),i("per-page-key",e=>{t.keys.perPage=e}),i("sort-key",e=>{t.keys.sort=e}),i("direction-key",e=>{t.keys.direction=e}),i("search-key",e=>{t.keys.search=e}),i("filter-prefix",e=>{t.keys.filterPrefix=e}),i("include-pagination",e=>{t.include.pagination=s(e)}),i("include-sort",e=>{t.include.sort=s(e)}),i("include-search",e=>{t.include.search=s(e)}),i("include-filters",e=>{t.include.filters=s(e)}),t.mode="push"===String(t.mode).toLowerCase()?"push":"replace"}_normalizeLoadingDataOptions(){const t=this._params.loading,e=t=>this._element.getAttribute(`data-loading-${t}`),i=(t,e,i=0)=>{const s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=i?s:e},s=e("enable")??e("enabled");null!==s&&(t.enabled=!["false","0","off","no"].includes(String(s).toLowerCase()));const r=e("min-delay");null!==r&&(t.minDelay=i(r,t.minDelay));const n=e("skeleton")??e("skeleton-rows");null!==n&&(t.skeleton=i(n,t.skeleton,1))}_normalizeExpandableDataOptions(){const t=this._params.expandable;t.labels=Object.assign({},t.labels);const e=t=>this._element.getAttribute(`data-expandable-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase());Object.prototype.hasOwnProperty.call(t,"enable")&&(t.enabled=s(t.enable)),i("enable",e=>{t.enabled=s(e)}),i("enabled",e=>{t.enabled=s(e)}),i("id-attr",e=>{t.idAttr=e}),i("parent-attr",e=>{t.parentAttr=e}),i("toggle-selector",e=>{t.toggleSelector=e}),i("collapsed",e=>{t.collapsed=s(e)}),i("expand-label",e=>{t.labels.expand=e}),i("collapse-label",e=>{t.labels.collapse=e})}_normalizeStickyHeaderDataOptions(){this._params.stickyHeader=Object.assign({},this._params.stickyHeader);const t=this._params.stickyHeader,e=t=>this._element.getAttribute(`data-sticky-header-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase());Object.prototype.hasOwnProperty.call(t,"enable")&&(t.enabled=s(t.enable)),Object.prototype.hasOwnProperty.call(t,"max")&&(t.maxHeight=t.max),i("enable",e=>{t.enabled=s(e)}),i("enabled",e=>{t.enabled=s(e)}),i("mode",e=>{t.mode=e}),i("top",e=>{t.top=e}),i("top-offset",e=>{t.top=e}),i("max",e=>{t.maxHeight=e}),i("max-height",e=>{t.maxHeight=e}),t.mode="page"===String(t.mode).toLowerCase()?"page":"container"}_normalizeFixedColumnsDataOptions(){this._params.fixedColumns=Object.assign({},this._params.fixedColumns);const t=this._params.fixedColumns,e=t=>this._element.getAttribute(`data-fixed-columns-${t}`),i=(t,i)=>{const s=e(t);null!==s&&i(s)},s=t=>!["false","0","off","no"].includes(String(t).toLowerCase()),r=(t,e)=>{const i=Number.parseFloat(t);return Number.isFinite(i)&&i>=0?i:e};let n=null;Object.prototype.hasOwnProperty.call(t,"enable")&&(t.enabled=s(t.enable));const a=this._element.getAttribute("data-fixed-columns");null!==a&&(t.columns=a),i("enable",e=>{n=s(e),t.enabled=n}),i("enabled",e=>{n=s(e),t.enabled=n}),i("mode",e=>{t.mode=e}),i("stack-gap",e=>{t.stackGap=r(e,t.stackGap)}),t.mode="stack"===String(t.mode).toLowerCase()?"stack":"fixed",t.stackGap=r(t.stackGap,0);const o=Boolean(this._element.tHead?.querySelector("[data-fixed], [data-fixed-column]"));null===n&&(null!==a||o||t.columns&&"object"==typeof t.columns)&&(t.enabled=!0)}_ensureWrapper(){const t=this._element.closest(Oo);if(t)return void(this._wrapper=t);const e=this._element.ownerDocument.createElement("div");e.className=Oo.slice(1),e.setAttribute("data-vg-table-generated-wrapper",""),this._element.before(e),e.append(this._element),this._wrapper=e,this._ownsWrapper=!0}_removeGeneratedWrapper(){this._ownsWrapper&&this._wrapper&&(this._element.parentElement===this._wrapper&&this._wrapper.before(this._element),this._wrapper.children.length||this._wrapper.remove(),this._wrapper=null,this._ownsWrapper=!1)}_ensureTableContainer(){const t=this._element.closest(zo);if(t&&t.closest(Oo)===this._wrapper)return void(this._tableContainer=t);const e=this._element.ownerDocument.createElement("div");e.className=zo.slice(1),e.setAttribute("data-vg-table-generated-container",""),this._element.before(e),e.append(this._element),this._tableContainer=e,this._ownsTableContainer=!0}_removeGeneratedTableContainer(){this._ownsTableContainer&&this._tableContainer&&(this._element.parentElement===this._tableContainer&&this._tableContainer.before(this._element),this._tableContainer.children.length||this._tableContainer.remove(),this._tableContainer=null,this._ownsTableContainer=!1)}setSort(t,e="asc"){const i=!!this._sorting&&this._sorting.setSort(t,e);return i&&(this._refreshPagination(),this._syncUrlState()),i}setSorts(t=[]){const e=!!this._sorting&&this._sorting.setSorts(t);return e&&(this._refreshPagination(),this._syncUrlState()),e}getSort(){return this._sorting?this._sorting.getSort():null}getSorts(){return this._sorting?this._sorting.getSorts():[]}clearSort(){this._sorting&&(this._sorting.clearSort(),this._refreshPagination(),this._syncUrlState())}selectRow(t,e=!0,i=!0){return!!this._selection&&this._selection.selectRow(t,e,i)}toggleRow(t,e=!0){return!!this._selection&&this._selection.toggleRow(t,e)}getSelectedRows(){return this._selection?this._selection.getSelectedRows():[]}clearSelection(t=!0){return!!this._selection&&this._selection.clearSelection(t)}toggleExpanded(t,e=null,i=!1){return!!this._expandable&&this._expandable.toggle(t,e,i)}expandRow(t,e=!1){return!!this._expandable&&this._expandable.expand(t,e)}collapseRow(t,e=!1){return!!this._expandable&&this._expandable.collapse(t,e)}getExpandable(){return this._expandable?this._expandable.getState():null}refreshExpandable(){return this._expandable?this._expandable.refresh():null}setPage(t,e=!1){return!!this._pagination&&this._pagination.setPage(t,e)}setPerPage(t,e=!1){return!!this._pagination&&this._pagination.setPerPage(t,e)}getPagination(){return this._pagination?this._pagination.getState():null}refreshPagination(t=!1){return this._pagination?this._pagination.refresh(t):null}getFilters(){return this._filters?this._filters.getState():null}setFilters(t={},e=!0){return this._filters?this._filters.setValues(t,{emit:e,source:"api"}):null}resetFilters(t=!0){return this._filters?this._filters.reset({emit:t,source:"api-reset"}):null}refreshFilters(){return this._filters?this._filters.refresh():null}getSearch(){return this._search?this._search.getState():null}setSearch(t,e=!0){return this._search?this._search.setValue(t,{emit:e,source:"api"}):null}resetSearch(t=!0){return this._search?this._search.reset({emit:t,source:"api-reset"}):null}refreshSearch(){return this._search?this._search.refresh():null}getTableState(){return this._states?.getState()||null}showTableState(t,e=""){return this._states?.render(t,e)||null}clearTableState(){return this._states?.clear()||null}getUrlState(){return this._urlState?.getState()||null}refreshUrlState(){return this._urlState?this._applyUrlState(this._urlState.read("api"),{source:"api",clearMissing:!0}):null}reload(t={}){return this._remote?this._remote.reload(t):Promise.resolve(null)}setRequestParams(t={},e=!0,i=!1){if(!this._remote)return null;const s=this._remote.setParams(t,i);return e&&this._remote.reload({page:1,source:"params"}),s}getRequestState(){return this._remote?this._remote.getState():null}clearRequestCache(){this._remote?.clearCache()}exportRemote(t="csv",e={}){return this._remote?this._remote.export(t,e):""}refreshStickyHeader(){return this._stickyHeader?this._stickyHeader.refresh():null}refreshFixedColumns(){return this._fixedColumns?this._fixedColumns.refresh():null}getFixedColumns(){return this._fixedColumns?this._fixedColumns.getState():null}getColumns(){return this._columns?this._columns.getState():null}setColumnWidth(t,e,i=!0){return!!this._columns&&this._columns.setWidth(t,e,i)}moveColumn(t,e,i=!0){return!!this._columns&&this._columns.move(t,e,i)}setColumnVisible(t,e=!0,i=!0){return!!this._columns&&this._columns.setVisible(t,e,i)}resetColumns(t=!0){return this._columns?this._columns.reset(t):null}refreshColumns(){const t=this._columns?.refresh?.()||null;return this._refreshColumnsLayout(!0),t}getRowOrder(){return this._rowReorder?this._rowReorder.getState().order:[]}moveRow(t,e,i="before",s=!0){return!!this._rowReorder&&this._rowReorder.move(t,e,i,s)}resetRows(t=!0){return this._rowReorder?this._rowReorder.reset(t):null}refreshRowReorder(){return this._rowReorder?this._rowReorder.refresh():null}_refreshPagination(){this._pagination&&this._pagination.refresh(),this._expandable&&this._expandable.refresh()}_isFixedColumnField(t){const e=String(t||"").trim();if(!e)return!1;const i=this._stickyHeader?.getHeaderTable?.()||this._element,s=Array.from(i.tHead?.querySelectorAll("th")||[]).find(t=>String(t.getAttribute("data-field")||"").trim()===e);if(["left","right"].includes(String(s?.getAttribute("data-fixed")||s?.getAttribute("data-fixed-column")||"").toLowerCase()))return!0;const r=this._params.fixedColumns.columns;return r&&"object"==typeof r&&!Array.isArray(r)?["left","right"].some(t=>(Array.isArray(r[t])?r[t]:String(r[t]||"").split(",")).map(t=>String(t).trim()).includes(e)):String(r||"").split(";").some(t=>{const[,i=""]=t.split(":");return i.split(",").map(t=>t.trim()).includes(e)})}_refreshColumnsLayout(t=!1){this._sorting?.refresh?.(t),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}_refreshRowsLayout(){this._pagination?.refresh?.(!1),this._expandable?.refresh?.(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}_handleFiltersChange(t){this._filtersState=t&&"object"==typeof t?t:{filters:{},params:{},fields:[],meta:{count:0}};const e=["reset","api-reset"].includes(String(this._filtersState.source||""));if(e&&this._search&&(this._search.reset({emit:!1,source:"filters-reset"}),this._searchState=this._search.getState()),!this._isRemote)return this._applyLocalFilters(this._filtersState),void this._syncUrlState();const i=this._filtersState.params||{},s={};this._filterParamKeys.forEach(t=>{s[t]=""}),e&&this._searchParamKey&&(s[this._searchParamKey]=""),Object.assign(s,i),this._filterParamKeys=new Set(Object.keys(i)),this._remote?.setParams(s),this._syncUrlState();const r=this._pagination?.getState();!1!==this._params.filters.resetPage&&r?.page>1?this._pagination.setPage(1,!1,"filters"):this._remote?.load({source:"filters"})}_handleSearchChange(t){if(this._searchState=t&&"object"==typeof t?t:{value:"",param:"q"},!this._isRemote)return this._applyLocalFilters(this._filtersState,!1!==this._params.search.resetPage),void this._syncUrlState();const e=String(this._searchState.param||"q").trim()||"q",i={};this._searchParamKey&&(i[this._searchParamKey]=""),this._searchState.value&&(i[e]=this._searchState.value),this._searchParamKey=e,this._remote?.setParams(i),this._syncUrlState();const s=this._pagination?.getState();!1!==this._params.search.resetPage&&s?.page>1?this._pagination.setPage(1,!1,"search"):this._remote?.load({source:"search"})}_applyLocalFilters(t,e=!1!==this._params.filters.resetPage){const i=t?.filters&&"object"==typeof t.filters?t.filters:{},s=this._stickyHeader?.getHeaderTable?.()||this._element,r=Array.from(s.tHead?.rows||[]),n=r.length?Array.from(r.at(-1).cells||[]):[],a=new Map(n.map((t,e)=>[String(t.getAttribute("data-field")||"").trim(),e]));Array.from(this._element.tBodies||[]).flatMap(t=>Array.from(t.rows||[])).filter(t=>!t.hasAttribute("data-vg-table-state-row")).forEach(t=>{const e=Object.entries(i).every(([e,i])=>{const s=String(i?.field||e||"").trim(),r=a.has(s)?a.get(s):-1;if(r<0||!t.cells[r])return!0;const n=t.cells[r],o=n.getAttribute("data-filter-value")??n.textContent??"";return this._matchesFilterValue(o,i||{})})&&this._matchesSearchRow(t,n);t.toggleAttribute($o,!e),e?this._pagination||(t.hidden="true"===t.getAttribute("data-vg-table-expand-hidden")):t.hidden=!0}),this._pagination&&this._pagination.refresh(e),this._expandable?.refresh(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.(),this._states?.syncLocal(this._hasActiveQuery())}_matchesSearchRow(t,e){const i=String(this._searchState?.value||"").toLocaleLowerCase();if(!i)return!0;const s=new Set((this._params.search.fields||[]).map(t=>String(t).trim())),r=e.reduce((t,e,i)=>{const r=String(e.getAttribute("data-field")||"").trim();return"false"===e.getAttribute("data-search-enabled")||s.size&&!s.has(r)||t.push(i),t},[]),n=t.getAttribute("data-search-value"),a=null!==n?n:r.map(e=>{const i=t.cells[e];return i?.getAttribute("data-search-value")??i?.textContent??""}).join(" ");return String(a).toLocaleLowerCase().includes(i)}_matchesFilterValue(t,e){const i=Array.isArray(e.values)&&e.values.length?e.values:e.value,s=String(e.operator||e.type||"eq").toLowerCase().trim(),r=String(t??"").trim();if("empty"===s)return""===r;if("notempty"===s)return""!==r;if(Array.isArray(i)){const t=i.map(t=>String(t??"").toLocaleLowerCase().trim()).filter(Boolean).includes(r.toLocaleLowerCase());return"notin"===s?!t:t}const n=String(i??"").trim();if(!n)return!0;const a=r.toLocaleLowerCase(),o=n.toLocaleLowerCase();if("contains"===s)return a.includes(o);if("starts"===s)return a.startsWith(o);if("ends"===s)return a.endsWith(o);const l=Number.parseFloat(r.replace(",",".")),h=Number.parseFloat(n.replace(",",".")),d=Number.isFinite(l)&&Number.isFinite(h),c="date"===e.type?Date.parse(r):NaN,_="date"===e.type?Date.parse(n):NaN,u=Number.isFinite(c)&&Number.isFinite(_)?c:l,m=Number.isFinite(c)&&Number.isFinite(_)?_:h,p=d||Number.isFinite(c)&&Number.isFinite(_);return"neq"===s?p?u!==m:a!==o:"gt"===s&&p?u>m:"gte"===s&&p?u>=m:"lt"===s&&p?u<m:"lte"===s&&p?u<=m:p?u===m:a===o}_clearLocalFilters(){Array.from(this._element.tBodies||[]).flatMap(t=>Array.from(t.rows||[])).forEach(t=>{t.removeAttribute($o),t.hidden="true"===t.getAttribute("data-vg-table-expand-hidden")||"hidden"===t.getAttribute("data-vg-table-page-row")})}_handlePaginationChange(t){this._applyingUrlState||(this._syncUrlState(),this._isRemote?this._remote?.load({page:t.page,perPage:t.perPage,source:t.source}):this._states?.syncLocal(this._hasActiveQuery()))}_handleLocalSortChange(){this._refreshPagination(),this._syncUrlState()}_hasActiveQuery(){return Boolean(this._searchState?.value||Object.keys(this._filtersState?.filters||{}).length)}_collectUrlState(){const t=this._pagination?.getState()||{};return{page:t.page||1,perPage:t.perPage||this._params.pagination.per,sort:this._sorting?.getSortState?.()||this._sorting?.getSort()||null,search:this._searchState?.value||"",filters:Object.assign({},this._filtersState?.params||{})}}_syncUrlState(){return this._applyingUrlState||!this._urlState?null:this._urlState.write(this._collectUrlState())}_applyUrlState(t={},e={}){if(!t||"object"!=typeof t)return null;const i=!0===e.clearMissing,s=t.present||{},r=new Set(this._filterParamKeys),n=this._searchParamKey;this._applyingUrlState=!0;try{if(this._filters&&(i||s.filters)&&(this._filters.setValues(t.filters||{},{emit:!1}),this._filtersState=this._filters.getState(),this._filterParamKeys=new Set(Object.keys(this._filtersState.params||{}))),this._search&&(i||s.search)&&(this._search.setValue(t.search||"",{emit:!1}),this._searchState=this._search.getState(),this._searchParamKey=this._searchState.param),this._sorting&&(i||s.sort)&&(t.sort?.sorts?.length?this._sorting.setSorts(t.sort.sorts,!1):t.sort?.field?this._sorting.setSort(t.sort.field,t.sort.direction,!1):this._sorting.clearSort(!1)),this._pagination){const e=this._pagination.getState(),r=s.perPage?t.perPage:i?this._params.pagination.per:e.perPage,n=s.page?t.page:i?this._params.pagination.page:e.page;this._isRemote?this._pagination.setMeta({page:n||1,per_page:r||e.perPage,total:e.totalRows,pages:Math.max(1,n||1)}):(r&&this._pagination.setPerPage(r,!1,"urlstate"),n&&this._pagination.setPage(n,!1,"urlstate"))}if(this._isRemote||this._applyLocalFilters(this._filtersState,!1),this._remote){const t={};r.forEach(e=>{t[e]=""}),n&&(t[n]=""),Object.assign(t,this._filtersState.params||{}),this._searchState.value&&(t[this._searchState.param]=this._searchState.value),this._remote.setParams(t)}}finally{this._applyingUrlState=!1}if(this._remote&&"init"!==e.source){const t=this._pagination?.getState()||{};this._remote.load({page:t.page,perPage:t.perPage,source:e.source||"urlstate"})}return this._collectUrlState()}_resetQueryControls(){this._applyingUrlState=!0;try{this._filters?.reset({emit:!1}),this._search?.reset({emit:!1}),this._filtersState=this._filters?.getState()||{filters:{},params:{},fields:[],meta:{count:0}},this._searchState=this._search?.getState()||{value:"",param:this._searchParamKey||"q"};const t={};this._filterParamKeys.forEach(e=>{t[e]=""}),this._searchParamKey&&(t[this._searchParamKey]=""),this._filterParamKeys=new Set,this._remote?.setParams(t),this._pagination?.getState().page>1&&this._pagination.setPage(1,!1,"state-reset"),this._isRemote||this._applyLocalFilters(this._filtersState,!0)}finally{this._applyingUrlState=!1}this._syncUrlState(),this._remote&&this._remote.load({page:1,source:"state-reset"})}_handleRemoteSortChange(){if(!this._remote)return;this._syncUrlState();const t=this._pagination?.getState();t&&1!==t.page?this._pagination.setPage(1,!1,"sort"):this._remote.reload({page:1,source:"sort"})}_afterRemoteRender(t={}){t.renderedCount>0&&this._states?.clear(),this._columns?.refresh?.(),this._sorting?.refresh?.(),this._expandable?.refresh?.(),this._rowReorder?.refresh?.(),this._stickyHeader?.refresh?.(),this._fixedColumns?.refresh?.()}dispose(){this._remote&&this._remote.dispose(),this._skeleton&&this._skeleton.dispose(),this._urlState&&this._urlState.dispose(),this._states&&this._states.dispose(),this._search&&this._search.dispose(),this._filters&&this._filters.dispose(),this._clearLocalFilters(),this._fixedColumns&&this._fixedColumns.dispose(),this._sorting&&this._sorting.dispose(),this._columns&&this._columns.dispose(),this._stickyHeader&&this._stickyHeader.dispose(),this._panning&&this._panning.dispose(),this._selection&&this._selection.dispose(),this._rowReorder&&this._rowReorder.dispose(),this._expandable&&this._expandable.dispose(),this._element.removeEventListener("sortchange.vg.table",this._boundPaginationRefresh),this._element.removeEventListener("sortchange.vg.table",this._boundLocalSortChange),this._element.removeEventListener("sortchange.vg.table",this._boundRemoteSortChange),this._pagination&&this._pagination.dispose(),this._autoNotSplitterHeaders.forEach(t=>t.classList.remove(Ho)),this._autoNotSplitterHeaders.clear(),this._emptyHeaderSortOptions.forEach((t,e)=>{null===t?e.removeAttribute("data-sort-enabled"):e.setAttribute("data-sort-enabled",t)}),this._emptyHeaderSortOptions.clear(),this._element.classList.remove("vg-table-complex"),this._element.removeAttribute("data-vg-table-complex"),this._removeGeneratedTableContainer(),this._removeGeneratedWrapper(),super.dispose()}}g.A.on(document,"DOMContentLoaded",()=>{s.A.findAll("[data-vg-table]").forEach(t=>{Fo.getOrCreateInstance(t).init()})});const Ro=Fo,Bo="vg.tooltip",jo='[data-vg-toggle="tooltip"]',Uo='[data-vg-toggle="popover"]',qo="vg-tooltip-open",Vo="show",Wo="shown",Ko=`${jo}.${Vo}, ${Uo}.${Vo}`,Go=`${Bo}.hide`,Yo=`${Bo}.hidden`,Xo=`${Bo}.show`,Zo=`${Bo}.shown`,Jo=`click.${Bo}.data.api`,Qo=`mouseenter.${Bo}`,tl=`mouseleave.${Bo}`,el=`click.dismiss.${Bo}`,il=`keydown.dismiss.${Bo}`,sl=["top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start","right-end"],rl={title:"",content:"",trigger:"hover",placement:"top",container:"body",popover:!1,html:!1,offset:[8,8],autoFlip:!0,overflowProtection:!0,fallbackPlacements:["bottom","right","left"],closeOnOutsideClick:!0,keyboard:!0,closeOther:!0,delay:{show:100,hide:100},arrow:{padding:8},custom:{class:""},animation:{enable:!0,in:"animate__backInUp",out:"animate__backOutDown",delay:300,effect:"none"}};class nl extends t.A{constructor(t,e={}){super(t,e),this._params=this._getParams(t,(0,r._v)(rl,e)),this._tooltip=null,this._isHiding=!1,this._showTimeout=null,this._hideTimeout=null,this._triggerObserver=null,this._fixTitle(),this._handleUpdate=()=>{this._element?.isConnected?this._isShown()&&this._setPlacement():this.dispose()}}static get NAME(){return"tooltip"}static get NAME_KEY(){return Bo}toggle(t){return this._isShown()?this.hide():this.show(t)}show(t){(0,r.d6)(this._element)||this._isShown()||(this._clearTimeouts(),this._showTimeout=setTimeout(()=>{this._showTimeout=null,this._element?.isConnected?g.A.trigger(this._element,Xo,{relatedTarget:t}).defaultPrevented||(this._params.closeOther&&this._hideOpenedTooltips(),this._isHiding=!1,this._createTooltip(),this._tooltip&&(this._tooltip.classList.remove(Wo),this._tooltip.classList.add(Vo),this._element.classList.add(Vo),document.body.classList.add(qo),this._addWindowListeners(),this._observeTrigger(),requestAnimationFrame(()=>{this._tooltip&&(this._setPlacement(),this._queueCallback(()=>{this._tooltip&&!this._isHiding&&(this._tooltip.classList.add(Wo),g.A.trigger(this._element,Zo,{relatedTarget:t}))},this._tooltip,!0,this._params.animation.delay))}))):this.dispose()},this._params.delay.show))}hide(){this._clearTimeouts(),this._isShown()&&!this._isHiding&&this._tooltip&&(this._disconnectTriggerObserver(),this._hideTimeout=setTimeout(()=>{this._hideTimeout=null,g.A.trigger(this._element,Go).defaultPrevented?this._observeTrigger():(this._removeWindowListeners(),this._isHiding=!0,this._tooltip.classList.remove(Wo),this._queueCallback(()=>{this._tooltip&&(this._tooltip.classList.remove(Vo),this._element.classList.remove(Vo),this._element.removeAttribute("aria-describedby"),this._tooltip.remove(),this._tooltip=null,this._isHiding=!1,s.A.find(".vg-tooltip.show")||document.body.classList.remove(qo),g.A.trigger(this._element,Yo))},this._tooltip,!1,this._params.animation.delay))},this._params.delay.hide))}dispose(){this._clearTimeouts(),this._removeWindowListeners(),this._disconnectTriggerObserver(),this._tooltip&&(this._tooltip.remove(),this._tooltip=null),this._element&&(this._element.classList.remove(Vo,Wo),this._element.removeAttribute("aria-describedby"),Object.prototype.hasOwnProperty.call(this._element.dataset,"vgOriginalTitle")&&(this._element.setAttribute("title",this._element.dataset.vgOriginalTitle),this._element.removeAttribute("data-vg-original-title"))),s.A.find(".vg-tooltip.show")||document.body.classList.remove(qo),super.dispose()}_isShown(){return!!this._element&&this._element.classList.contains(Vo)}_createTooltip(){if(this._tooltip)return;const t=this._getTitle();if(!t)return;const e=`vg-tooltip-${(0,r.PR)()}`,i=document.createElement("div");i.id=e,i.className=`vg-tooltip ${this._params.placement} ${this._params.custom.class||""}`,i.setAttribute("role",this._params.popover?"dialog":"tooltip"),this._params.popover&&i.classList.add("vg-tooltip-popover");const n=document.createElement("div");if(n.classList.add("vg-tooltip-inner"),this._params.content){const e=document.createElement("div");e.classList.add("vg-tooltip-inner--title");const i=document.createElement("div");i.classList.add("vg-tooltip-inner--content"),this._params.html?(e.innerHTML=t,i.innerHTML=this._params.content):(e.textContent=t,i.textContent=this._params.content),n.append(e),n.append(i)}else this._params.html?n.innerHTML=t:n.textContent=t;const a=document.createElement("div");a.classList.add("vg-tooltip-arrow"),n.append(a),i.append(n);const o="body"===this._params.container?document.body:s.A.find(this._params.container);o&&(o.append(i),this._element.setAttribute("aria-describedby",e),this._tooltip=i,this._animation(this._tooltip,nl.NAME_KEY,this._params.animation))}_getTitle(){return this._params.title||this._element.dataset.vgTitle||this._element.dataset.vgOriginalTitle||""}_fixTitle(){const t=this._element.getAttribute("title");null!==t&&(this._element.setAttribute("data-vg-original-title",t),this._element.removeAttribute("title"))}_setPlacement(){this._tooltip&&(new dt({reference:this._element,drop:this._tooltip,placement:this._params.placement,offset:this._params.offset,autoFlip:this._params.autoFlip,overflowProtection:this._params.overflowProtection,fallbackPlacements:this._params.fallbackPlacements,clamp:!0,isMerge:!1})._setPlacement(),this._syncPlacementClass(),this._setArrowPlacement())}_setArrowPlacement(){if(!this._tooltip)return;const t=this._tooltip.querySelector(".vg-tooltip-inner"),e=this._tooltip.querySelector(".vg-tooltip-arrow");if(!t||!e)return;const i=this._tooltip.getAttribute("data-vg-placement")||this._params.placement,s=this._element.getBoundingClientRect(),r=t.getBoundingClientRect(),n=s.left+s.width/2,a=s.top+s.height/2,o=this._params.arrow.padding;if(e.style.left="",e.style.right="",e.style.top="",e.style.bottom="",i.startsWith("top")||i.startsWith("bottom")){let t=n-r.left;t=Math.max(o,Math.min(t,r.width-o)),e.style.left=`${t}px`,e.style.transform="translateX(-50%) rotate(45deg)",i.startsWith("top")?e.style.bottom="-4px":e.style.top="-4px"}if(i.startsWith("left")||i.startsWith("right")){let t=a-r.top;t=Math.max(o,Math.min(t,r.height-o)),e.style.top=`${t}px`,e.style.transform="translateY(-50%) rotate(45deg)",i.startsWith("left")?e.style.right="-4px":e.style.left="-4px"}}_syncPlacementClass(){if(!this._tooltip)return;const t=this._tooltip.getAttribute("data-vg-placement");this._tooltip.classList.remove(...sl),t&&this._tooltip.classList.add(t)}_hideOpenedTooltips(){s.A.findAll(".vg-tooltip.show").forEach(t=>{const e=t.id,i=s.A.find(`[aria-describedby="${e}"]`);if(!i)return void t.remove();if(i===this._element)return;const r=nl.getInstance(i);r?.hide()}),s.A.find(".vg-tooltip.show")||document.body.classList.remove(qo)}_observeTrigger(){!this._triggerObserver&&this._element?.isConnected&&(this._triggerObserver=new MutationObserver(()=>{this._element?.isConnected||this.dispose()}),this._triggerObserver.observe(document.body,{childList:!0,subtree:!0}))}_disconnectTriggerObserver(){this._triggerObserver&&(this._triggerObserver.disconnect(),this._triggerObserver=null)}_addWindowListeners(){window.addEventListener("resize",this._handleUpdate),window.addEventListener("scroll",this._handleUpdate,!0)}_removeWindowListeners(){window.removeEventListener("resize",this._handleUpdate),window.removeEventListener("scroll",this._handleUpdate,!0)}_clearTimeouts(){this._showTimeout&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}}const al=()=>s.A.findAll(Ko).map(t=>nl.getInstance(t)).filter(Boolean);g.A.on(document,il,t=>{"Escape"===t.key&&al().forEach(t=>{t._params.keyboard&&t._isShown()&&t.hide()})}),g.A.on(document,el,t=>{al().forEach(e=>{e._params.closeOnOutsideClick&&(e._params.trigger.includes("click")||e._params.popover)&&e._isShown()&&(e._tooltip?.contains(t.target)||e._element.contains(t.target)||e.hide())})}),g.A.on(document,Qo,jo,function(){const t=nl.getOrCreateInstance(this);t._params.trigger.includes("hover")&&t.show(this)}),g.A.on(document,tl,jo,function(){const t=nl.getOrCreateInstance(this);t._params.trigger.includes("hover")&&t.hide()}),g.A.on(document,Jo,jo,function(t){const e=nl.getOrCreateInstance(this);e._params.popover&&(e._params.trigger="click"),e._params.trigger.includes("click")&&(t.preventDefault(),e.toggle(this))}),g.A.on(document,Jo,Uo,function(t){t.preventDefault();const e=nl.getOrCreateInstance(this);e._params.popover=!0,e._params.trigger="click",e.toggle(this)});const ol=nl,ll=[oe,Ee,Pt,$i,di,Yi,as,ps,ht,Ps,lr,xr,zr,zn,Un,ea,La,Ro,Ai.A,ol];new class{constructor(t={}){this._modules=new Map,this._excludedModules=this._normalizeModuleNameList(t.excludeModules??t.exclude??t.without),this._initializer="function"==typeof t.initializer?t.initializer:null,this._isInitialized=!1}register(t,e){const i=this._normalizeModuleName(t),s=this._resolveModuleCandidate(e);if(!i)throw new Error("VGApp.register() ожидает строковое имя модуля первым аргументом.");return this._isModuleExcluded(i)||this._modules.set(i,s),this}boot(t={}){const e=this._normalizeBootConfig(t);this.exclude(e.excludeModules),this._ensureInitialized();for(const[t,i]of this._modules){if(this._isModuleExcluded(t))continue;if("function"!=typeof i?.boot)continue;const s=this._resolveModuleConfig(t,e.modulesConfig);i.boot(s)}return this}get(t){return this._ensureInitialized(),this._modules.get(this._normalizeModuleName(t))}has(t){return this._ensureInitialized(),this._modules.has(this._normalizeModuleName(t))}exclude(t){return this._normalizeModuleNameList(t).forEach(t=>{this._excludedModules.add(t),this._isInitialized&&this._deleteModuleByExcludedName(t)}),this}include(t){return this._normalizeModuleNameList(t).forEach(t=>{this._excludedModules.delete(t)}),this}isExcluded(t){return this._isModuleExcluded(t)}getExcluded(){return Array.from(this._excludedModules)}_resolveModuleCandidate(t){const e=t?.default??t;if(!e)throw new Error("VGApp.register() ожидает валидный модуль.");return e}_resolveModuleConfig(t,e){if(e&&"object"==typeof e)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}_normalizeBootConfig(t){return t&&"object"==typeof t?{excludeModules:t.excludeModules??t.exclude??t.without??[],modulesConfig:t.modules&&"object"==typeof t.modules?t.modules:t}:{excludeModules:[],modulesConfig:{}}}_normalizeModuleNameList(t){if(!t)return new Set;const e="string"==typeof t?t.split(","):Array.from(t);return new Set(e.map(t=>this._normalizeExcludedModuleName(t)).filter(Boolean))}_normalizeModuleName(t){return String(t||"").trim()}_normalizeExcludedModuleName(t){return this._normalizeModuleName(t).toLowerCase()}_isModuleExcluded(t){return this._excludedModules.has(this._normalizeExcludedModuleName(t))}_deleteModuleByExcludedName(t){for(const e of this._modules.keys())this._normalizeExcludedModuleName(e)===t&&this._modules.delete(e)}_ensureInitialized(){this._isInitialized||"function"!=typeof this._initializer||(this._isInitialized=!0,this._initializer(this))}}({initializer:t=>{ll.forEach(e=>{t.register(e.NAME,e)})}})})(),i.r(s),s})());
3
3
  //# sourceMappingURL=vgapp.js.map