{ "version": 3, "sources": ["src/app/shared/components/block-ui/block-ui.service.ts"], "sourcesContent": ["import { DOCUMENT } from '@angular/common';\r\nimport { ApplicationRef, createComponent, EmbeddedViewRef, Inject, Injectable } from '@angular/core';\r\nimport type { BlockUiComponent } from './block-ui.component';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class BlockUiService {\r\n\r\n private blockUiComponent: BlockUiComponent;\r\n constructor(\r\n private appRef: ApplicationRef,\r\n @Inject(DOCUMENT) private document: Document,\r\n ) { }\r\n\r\n\r\n async load(): Promise {\r\n await this.ensureComponent();\r\n }\r\n\r\n async setMessage(message: string): Promise {\r\n await this.ensureComponent();\r\n this.blockUiComponent.setMessage(message);\r\n }\r\n\r\n async show(message?: string, timeout = 0): Promise {\r\n await this.ensureComponent();\r\n if(message) {\r\n this.setMessage(message);\r\n }\r\n this.blockUiComponent.show(timeout);\r\n }\r\n\r\n async hide(): Promise {\r\n await this.ensureComponent();\r\n this.blockUiComponent.hide();\r\n }\r\n\r\n private async ensureComponent(): Promise {\r\n if (!this.blockUiComponent) {\r\n const { BlockUiComponent } = await import('./block-ui.component');\r\n const componentRef = createComponent(BlockUiComponent, { environmentInjector: this.appRef.injector });\r\n this.appRef.attachView(componentRef.hostView);\r\n // 3. Get DOM element from component\r\n const domElem = (componentRef.hostView as EmbeddedViewRef)\r\n .rootNodes[0] as HTMLElement;\r\n // 4. Append DOM element to the body\r\n this.document.body.appendChild(domElem);\r\n this.blockUiComponent = componentRef.instance;\r\n }\r\n }\r\n}\r\n"], "mappings": "iJAOA,IAAaA,GAAc,IAAA,CAArB,IAAOA,EAAP,MAAOA,CAAc,CAGzBC,YACUC,EACkBC,EAAkB,CADpC,KAAAD,OAAAA,EACkB,KAAAC,SAAAA,CACxB,CAGEC,MAAI,QAAAC,EAAA,sBACR,MAAM,KAAKC,gBAAe,CAC5B,GAEMC,WAAWC,EAAe,QAAAH,EAAA,sBAC9B,MAAM,KAAKC,gBAAe,EAC1B,KAAKG,iBAAiBF,WAAWC,CAAO,CAC1C,GAEME,KAAKF,EAAkBG,EAAU,EAAC,QAAAN,EAAA,sBACtC,MAAM,KAAKC,gBAAe,EACvBE,GACD,KAAKD,WAAWC,CAAO,EAEzB,KAAKC,iBAAiBC,KAAKC,CAAO,CACpC,GAEMC,MAAI,QAAAP,EAAA,sBACR,MAAM,KAAKC,gBAAe,EAC1B,KAAKG,iBAAiBG,KAAI,CAC5B,GAEcN,iBAAe,QAAAD,EAAA,sBAC3B,GAAI,CAAC,KAAKI,iBAAkB,CAC1B,GAAM,CAAEI,iBAAAA,CAAgB,EAAK,KAAM,QAAO,qBAAsB,EAC1DC,EAAeC,EAAgBF,EAAkB,CAAEG,oBAAqB,KAAKd,OAAOe,QAAQ,CAAE,EACpG,KAAKf,OAAOgB,WAAWJ,EAAaK,QAAQ,EAE5C,IAAMC,EAAWN,EAAaK,SAC7BE,UAAU,CAAC,EAEZ,KAAKlB,SAASmB,KAAKC,YAAYH,CAAO,EACtC,KAAKX,iBAAmBK,EAAaU,QACvC,CACF,2CA3CWxB,GAAcyB,EAAAC,CAAA,EAAAD,EAKfE,CAAQ,CAAA,CAAA,wBALP3B,EAAc4B,QAAd5B,EAAc6B,UAAAC,WAFb,MAAM,CAAA,EAEd,IAAO9B,EAAP+B,SAAO/B,CAAc,GAAA", "names": ["BlockUiService", "constructor", "appRef", "document", "load", "__async", "ensureComponent", "setMessage", "message", "blockUiComponent", "show", "timeout", "hide", "BlockUiComponent", "componentRef", "createComponent", "environmentInjector", "injector", "attachView", "hostView", "domElem", "rootNodes", "body", "appendChild", "instance", "\u0275\u0275inject", "ApplicationRef", "DOCUMENT", "factory", "\u0275fac", "providedIn", "_BlockUiService"] }