import{g as e}from"./p-8b5d3a52.js";import{a as o}from"./p-2ade684f.js";import{L as t}from"./p-dcc98162.js";import{I as a,c as r}from"./p-3a41fc0a.js";import"./p-9ec80349.js";const c=[{payloadKey:"IS_LOAD_METHOD_CALLED",payloadDescription:"Indicate if the method load of public API VegaLoaderController is called",canAccept:(e,o)=>"VegaLoaderController"===e&&"load"===o,payloadValue:()=>!0},{payloadKey:"IS_CLOSE_METHOD_CALLED",payloadDescription:"Indicate if the method close of public API VegaLoaderController is called",canAccept:(e,o)=>"VegaLoaderController"===e&&"close"===o,payloadValue:()=>!0}];class l{constructor(){this.vegaPublicAPIRuntimeMetricsSlimmer=r(l,["load","close"],c)}load(e={}){let o=e.containerSelector||"body",a=document.querySelector(o);if(a&&l.SPECIAL_ELEMENT_TO_WRAP_FULL_BODY.includes(a.tagName)&&(o="body",a=document.querySelector("body")),!a)return t.error("Container is not found by selector: ",o),null;const r=this.createLoadingIndicator(e.indicatorOptions),c=this.createLoader(o);return c.append(r),this.appendLoader(c,a)}close(e){const o=this.findLoader(e);if(o){if(o.dataset.container){const e=document.querySelector(o.dataset.container);e&&e.dataset.vegaLoaderOriginPosition&&(e.style.position=e.dataset.vegaLoaderOriginPosition)}o.remove()}}findLoader(e){var o,t;let a;if(e.includes(">>>")){const[r,c]=e.split(">>>");a=null===(t=null===(o=document.querySelector(r))||void 0===o?void 0:o.shadowRoot)||void 0===t?void 0:t.getElementById(c)}else a=document.getElementById(e);return a}createLoader(t){const a=document.createElement("vega-loader-wrapper");return a.className=o(["body"===t?"fixed-wrapper":"absolute-wrapper"]),a.dataset.container=t,a.id=`vega-loader-${e()}`,a}createLoadingIndicator(e={}){const o=document.createElement("vega-loading-indicator");return Object.assign(o,e),o}appendLoader(e,o){return o.dataset.vegaLoaderOriginPosition=o.style.position,o.style.position="relative",o.shadowRoot?(o.shadowRoot.append(e),`${e.dataset.container}>>>${e.id}`):(o.append(e),e.id)}}l.SPECIAL_ELEMENT_TO_WRAP_FULL_BODY=["VEGA-MODAL"],function(e,o,t,a){var r,c=arguments.length,l=c<3?o:null===a?a=Object.getOwnPropertyDescriptor(o,t):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,o,t,a);else for(var d=e.length-1;d>=0;d--)(r=e[d])&&(l=(c<3?r(l):c>3?r(o,t,l):r(o,t))||l);c>3&&l&&Object.defineProperty(o,t,l)}([a()],l.prototype,"vegaPublicAPIRuntimeMetricsSlimmer",void 0);const d=new l;export{d as VegaLoader}