{"version":3,"sources":["webpack://CoveoForSitecore/./src/ui/analytics/ValidateAnalyticsIncluded.ts"],"names":["coveo_search_ui_1","__webpack_require__","ContextEvents_1","defaultErrorMessage","ValidateAnalyticsIncluded","_super","element","options","bindings","_this","call","this","ID","ComponentOptions","initComponentOptions","bind","onRootElement","SitecoreContextEvents","onSitecoreContextInitialization","__extends","prototype","sitecoreContextArgs","shouldHaveAnalyticsComponent","searchInterfaceHasNoBoundAnalyticsComponent","console","warn","isInExperienceEditor","appendChild","createErrorMessageElement","searchInterface","getComponents","length","errorMessage","errorSpan","document","createElement","classList","add","textContent","Component","exports","Initialization","registerAutoCreateComponent"],"mappings":"2fAAA,IAAAA,EAAAC,EAAA,GAMAC,EAAAD,EAAA,GAKME,EAAsB,uJAE5BC,EAAA,SAAAC,GAKI,SAAAD,EAAmBE,EAA6BC,EAA4CC,GAA5F,IAAAC,EACIJ,EAAAK,KAAAC,KAAML,EAASF,EAA0BQ,GAAIJ,IAASG,YADvCF,EAAAH,UAA6BG,EAAAF,UAA4CE,EAAAD,WAGxFC,EAAKF,QAAUP,EAAAa,iBAAiBC,qBAAqBR,EAASF,EAA2BG,GAEzFE,EAAKM,KAAKC,cAAcd,EAAAe,sBAAsBC,gCAAiCT,EAAKS,mCAyB5F,OAnC+CC,EAAAf,EAAAC,GAanCD,EAAAgB,UAAAF,gCAAR,SAAwCG,GAChCA,EAAoBC,8BAAgCX,KAAKY,gDACzDC,QAAQC,KAAKtB,GACVkB,EAAoBK,sBACnBf,KAAKL,QAAQqB,YAAYhB,KAAKiB,0BAA0BzB,MAK5DC,EAAAgB,UAAAG,4CAAR,WACI,OAAkE,IAA3DZ,KAAKkB,gBAAgBC,cAAc,aAAaC,QACsB,IAAtEpB,KAAKkB,gBAAgBC,cAAc,wBAAwBC,QAG9D3B,EAAAgB,UAAAQ,0BAAR,SAAkCI,GAC9B,IAAMC,EAAYC,SAASC,cAAc,QAKzC,OAHAF,EAAUG,UAAUC,IAAI,gBACxBJ,EAAUK,YAAcN,EAEjBC,GAhCJ7B,EAAAQ,GAAK,4BAELR,EAAAG,QAAsC,GAgCjDH,EAnCA,CAA+CJ,EAAAuC,WAAlCC,EAAApC,4BAqCbJ,EAAAyC,eAAeC,4BAA4BtC","file":"ValidateAnalyticsIncluded.min.js","sourcesContent":["import {\r\n Component,\r\n ComponentOptions,\r\n IComponentBindings,\r\n Initialization\r\n} from \"coveo-search-ui\";\r\nimport { SitecoreContextEvents, ISitecoreContextInitializationEventArgs } from \"../../events/ContextEvents\";\r\n\r\nexport interface IValidateAnalyticsIncluded {\r\n}\r\n\r\nconst defaultErrorMessage = \"The Coveo Analytics are not enabled for this Search Interface. Insert a Coveo For Sitecore Analytics component to record Coveo Usage Analytics data.\";\r\n\r\nexport class ValidateAnalyticsIncluded extends Component {\r\n static ID = \"ValidateAnalyticsIncluded\";\r\n\r\n static options: IValidateAnalyticsIncluded = {};\r\n\r\n constructor(public element: HTMLElement, public options: IValidateAnalyticsIncluded, public bindings: IComponentBindings) {\r\n super(element, ValidateAnalyticsIncluded.ID, bindings);\r\n\r\n this.options = ComponentOptions.initComponentOptions(element, ValidateAnalyticsIncluded, options);\r\n\r\n this.bind.onRootElement(SitecoreContextEvents.onSitecoreContextInitialization, this.onSitecoreContextInitialization)\r\n }\r\n\r\n private onSitecoreContextInitialization(sitecoreContextArgs: ISitecoreContextInitializationEventArgs): void {\r\n if (sitecoreContextArgs.shouldHaveAnalyticsComponent && this.searchInterfaceHasNoBoundAnalyticsComponent()) {\r\n console.warn(defaultErrorMessage);\r\n if(sitecoreContextArgs.isInExperienceEditor) {\r\n this.element.appendChild(this.createErrorMessageElement(defaultErrorMessage));\r\n }\r\n }\r\n }\r\n\r\n private searchInterfaceHasNoBoundAnalyticsComponent(): boolean {\r\n return this.searchInterface.getComponents(\"Analytics\").length === 0 &&\r\n this.searchInterface.getComponents(\"ForSitecoreAnalytics\").length === 0;\r\n }\r\n\r\n private createErrorMessageElement(errorMessage: string): HTMLElement {\r\n const errorSpan = document.createElement(\"span\");\r\n\r\n errorSpan.classList.add(\"errorMessage\");\r\n errorSpan.textContent = errorMessage;\r\n\r\n return errorSpan;\r\n }\r\n}\r\n\r\nInitialization.registerAutoCreateComponent(ValidateAnalyticsIncluded);\r\n"],"sourceRoot":""}