vendor: 9,140 bytes, line 1
1!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ModernQuery=t():e.ModernQuery=t()}(this,(()=>(()=>{var e={957:function(e){var t;t=function(){"use strict";function e(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function t(t){for(var s=1;s<arguments.length;s++){var r=null!=arguments[s]?arguments[s]:{};s%2?e(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function n(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){if(e){if("string"==typeof e)return o(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s<t;s++)n[s]=e[s];return n}var a=function(e){return"string"==typeof e?document.querySelector(e):e()},l=function(e,t){var s="string"==typeof e?document.createElement(e):e;for(var n in t){var r=t[n];if("inside"===n)r.append(s);else if("dest"===n)a(r[0]).insertAdjacentElement(r[1],s);else if("around"===n){var i=r;i.parentNode.insertBefore(s,i),s.append(i),null!=i.getAttribute("autofocus")&&i.focus()}else n in s?s[n]=r:s.setAttribute(n,r)}return s},c=function(e,t){return e=String(e).toLowerCase(),t?e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC"):e},u=function(e,s){return l("mark",t({innerHTML:e},"string"==typeof s&&{class:s})).outerHTML},h=function(e,t){t.input.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t.feedback,cancelable:!0}))},d=function(e,t,s){var n=s||{},r=n.mode,i=n.diacritics,o=n.highlight,a=c(t,i);if(t=String(t),e=c(e,i),"loose"===r){var l=(e=e.replace(/ /g,"")).length,h=0,d=Array.from(t).map((function(t,s){return h<l&&a[s]===e[h]&&(t=o?u(t,o):t,h++),t})).join("");if(h===l)return d}else{var p=a.indexOf(e);if(~p)return e=t.substring(p,p+e.length),o?t.replace(e,u(e,o)):t}},p=function(e,t){return new Promise((function(s,n){var r;return(r=e.data).cache&&r.store?s():new Promise((function(e,s){return"function"==typeof r.src?r.src(t).then(e,s):e(r.src)})).then((function(t){try{return e.feedback=r.store=t,h("response",e),s()}catch(e){return n(e)}}),n)}))},m=function(e,t){var s=t.data,n=t.searchEngine,r=[];s.store.forEach((function(o,a){var l=function(s){var i=s?o[s]:o,a="function"==typeof n?n(e,i):d(e,i,{mode:n,diacritics:t.diacritics,highlight:t.resultItem.highlight});if(a){var l={match:a,value:o};s&&(l.key=s),r.push(l)}};if(s.keys){var c,u=function(e,t){var s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!s){if(Array.isArray(e)||(s=i(e))){s&&(e=s);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){s=s.call(e)},n:function(){var e=s.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==s.return||s.return()}finally{if(l)throw o}}}}(s.keys);try{for(u.s();!(c=u.n()).done;)l(c.value)}catch(e){u.e(e)}finally{u.f()}}else l()})),s.filter&&(r=s.filter(r));var o=r.slice(0,t.resultsList.maxResults);t.feedback={query:e,matches:r,results:o},h("results",t)},_="aria-expanded",g="aria-activedescendant",f="aria-selected",y=function(e,s){e.feedback.selection=t({index:s},e.feedback.results[s])},v=function(e){e.isOpen||((e.wrapper||e.input).setAttribute(_,!0),e.list.removeAttribute("hidden"),e.isOpen=!0,h("open",e))},b=function(e){e.isOpen&&((e.wrapper||e.input).setAttribute(_,!1),e.input.setAttribute(g,""),e.list.setAttribute("hidden",""),e.isOpen=!1,h("close",e))},M=function(e,t){var s=t.resultItem,n=t.list.getElementsByTagName(s.tag),i=!!s.selected&&s.selected.split(" ");if(t.isOpen&&n.length){var o,a,l=t.cursor;e>=n.length&&(e=0),e<0&&(e=n.length-1),t.cursor=e,l>-1&&(n[l].removeAttribute(f),i&&(a=n[l].classList).remove.apply(a,r(i))),n[e].setAttribute(f,!0),i&&(o=n[e].classList).add.apply(o,r(i)),t.input.setAttribute(g,n[t.cursor].id),t.list.scrollTop=n[e].offsetTop-t.list.clientHeight+n[e].clientHeight+5,t.feedback.cursor=t.cursor,y(t,e),h("navigate",t)}},Q=function(e){M(e.cursor+1,e)},E=function(e){M(e.cursor-1,e)},w=function(e,t,s){(s=s>=0?s:e.cursor)<0||(e.feedback.event=t,y(e,s),h("selection",e),b(e))};function O(e,s){var n=this;return new Promise((function(r,i){var o,a;return o=s||((a=e.input)instanceof HTMLInputElement||a instanceof HTMLTextAreaElement?a.value:a.innerHTML),function(e,t,s){return t?t(e):e.length>=s}(o=e.query?e.query(o):o,e.trigger,e.threshold)?p(e,o).then((function(s){try{return e.feedback instanceof Error?r():(m(o,e),e.resultsList&&function(e){var s=e.resultsList,n=e.list,r=e.resultItem,i=e.feedback,o=i.matches,a=i.results;if(e.cursor=-1,n.innerHTML="",o.length||s.noResults){var c=new DocumentFragment;a.forEach((function(e,s){var n=l(r.tag,t({id:"".concat(r.id,"_").concat(s),role:"option",innerHTML:e.match,inside:c},r.class&&{class:r.class}));r.element&&r.element(n,e)})),n.append(c),s.element&&s.element(n,i),v(e)}else b(e)}(e),c.call(n))}catch(e){return i(e)}}),i):(b(e),c.call(n));function c(){return r()}}))}var T=function(e,t){for(var s in e)for(var n in e[s])t(s,n)},x=function(e){var s,n,r,i=e.events,o=(s=function(){return O(e)},n=e.debounce,function(){clearTimeout(r),r=setTimeout((function(){return s()}),n)}),a=e.events=t({input:t({},i&&i.input)},e.resultsList&&{list:i?t({},i.list):{}}),l={input:{input:function(){o()},keydown:function(t){!function(e,t){switch(e.keyCode){case 40:case 38:e.preventDefault(),40===e.keyCode?Q(t):E(t);break;case 13:t.submit||e.preventDefault(),t.cursor>=0&&w(t,e);break;case 9:t.resultsList.tabSelect&&t.cursor>=0&&w(t,e);break;case 27:t.input.value="",b(t)}}(t,e)},blur:function(){b(e)}},list:{mousedown:function(e){e.preventDefault()},click:function(t){!function(e,t){var s=t.resultItem.tag.toUpperCase(),n=Array.from(t.list.querySelectorAll(s)),r=e.target.closest(s);r&&r.nodeName===s&&w(t,e,n.indexOf(r))}(t,e)}}};T(l,(function(t,s){(e.resultsList||"input"===s)&&(a[t][s]||(a[t][s]=l[t][s]))})),T(a,(function(t,s){e[t].addEventListener(s,a[t][s])}))};function q(e){var s=this;return new Promise((function(n,r){var i,o,a;if(i=e.placeHolder,a={role:"combobox","aria-owns":(o=e.resultsList).id,"aria-haspopup":!0,"aria-expanded":!1},l(e.input,t(t({"aria-controls":o.id,"aria-autocomplete":"both"},i&&{placeholder:i}),!e.wrapper&&t({},a))),e.wrapper&&(e.wrapper=l("div",t({around:e.input,class:e.name+"_wrapper"},a))),o&&(e.list=l(o.tag,t({dest:[o.destination,o.position],id:o.id,role:"listbox",hidden:"hidden"},o.class&&{class:o.class}))),x(e),e.data.cache)return p(e).then((function(e){try{return c.call(s)}catch(e){return r(e)}}),r);function c(){return h("init",e),n()}return c.call(s)}))}function A(e){var t=e.prototype;t.init=function(){q(this)},t.start=function(e){O(this,e)},t.unInit=function(){if(this.wrapper){var e=this.wrapper.parentNode;e.insertBefore(this.input,this.wrapper),e.removeChild(this.wrapper)}var t;T((t=this).events,(function(e,s){t[e].removeEventListener(s,t.events[e][s])}))},t.open=function(){v(this)},t.close=function(){b(this)},t.goTo=function(e){M(e,this)},t.next=function(){Q(this)},t.previous=function(){E(this)},t.select=function(e){w(this,null,e)},t.search=function(e,t,s){return d(e,t,s)}}return function e(t){this.options=t,this.id=e.instances=(e.instances||0)+1,this.name="autoComplete",this.wrapper=1,this.threshold=1,this.debounce=0,this.resultsList={position:"afterend",tag:"ul",maxResults:5},this.resultItem={tag:"li"},function(e){var t=e.name,n=e.options,r=e.resultsList,i=e.resultItem;for(var o in n)if("object"===s(n[o]))for(var l in e[o]||(e[o]={}),n[o])e[o][l]=n[o][l];else e[o]=n[o];e.selector=e.selector||"#"+t,r.destination=r.destination||e.selector,r.id=r.id||t+"_list_"+e.id,i.id=i.id||t+"_result",e.input=a(e.selector)}(this),A.call(this,e),q(this)}},e.exports=t()}},t={};function s(n){var r=t[n];
1if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,s),i.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};return(()=>{"use strict";s.d(n,{ModernQuery:()=>J,vs:()=>e});class e{static parseTitle(e,t){if(t.title_parse)if("string"==typeof t.title_parse)if(t.title_parse_regex){const s=new RegExp(t.title_parse);e=e.replace(s,"")}else e=e.replace(t.title_parse,"");else"function"==typeof t.title_parse&&(e=t.title_parse.call(this,e,t));return e}static extractMetaTagValue(e,t){let s=t;if(Array.isArray(s)||(s=[s]),void 0!==e.fields.meta&&e.fields.meta.length>0)for(const t of s)for(const s of e.fields.meta)if(s.key.toLowerCase()==t.toLowerCase()){let e=s.value;if(e&&s.key.toLowerCase().endsWith("_encoded")&&(e=atob(e)),e)return e}return null}static extractMetaDescriptionValue(t,s){const n=e.extractMetaTagValue(t,s);
1return n?n.replace(/\\n/g,""):null}static highlightStringsToSnippet(t,s){let n="";if(t){const e=Object.keys(t);e.length>0&&e.forEach((e=>{if(s.snippet_fields.includes(e)){const s=t[e].filter(((e,t,s)=>s.indexOf(e)===t));n+=s.reduce(((e,t)=>null!==RegExp(/\s+/).exec(t)?e+t+"...":e),"")}}))}return s.snippet_max_length>0&&n.length>s.snippet_max_length&&(n=n.substring(0,s.snippet_max_length)+"..."),e.finalizeSnippetHtml(n)}static finalizeSnippetHtml(t){return e.closeHtmlTags(t)}static closeHtmlTags(e){const t=/<\/?([a-zA-Z]+)[^>]*>/g;let s;const n=[];for(;s=t.exec(e);){const e=s[1];"/"===s[0][1]?n.length>0&&n[n.length-1]===e&&n.pop():n.push(e)}for(;n.length;)e+=`</${n.pop()}>`;return e}static metaKeyToClassSuffix(e){return(e.includes(":")?e.slice(e.indexOf(":")+1):e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}static generateRefId(){return"mq-"+Math.floor(1e4*Math.random()).toString()}static getRefSelector(e,t){if(e){const s=t.match(/([^ >+~]+)(?=[^ >+~]*$)/);if(!s)return t;const n=`${s[1]}[data-mq-ref="${e}"]`;return t.replace(/([^ >+~]+)(?=[^ >+~]*$)/,n)}return t}}class t{constructor(e){this.MQ=e}setElementStyle(e,t,s){document.querySelectorAll(e).forEach((e=>{var n;if(e instanceof HTMLElement){const r=(null===(n=this.renderer)||void 0===n?void 0:n.refId)?e:null==e?void 0:e.parentElement;r&&(r.style[t]=s)}}))}}class r{static getOptionByKeys(e,t){if(!e||"string"!=typeof t)return null;const s=t.split(".");let n=e;for(const e of s){if(!n||"object"!=typeof n||!(e in n))return null;n=n[e]}return n}static setOptionByKeys(e,t,s){if(!e||"string"!=typeof t)return;const n=t.split(".");let r=e;for(let e=0;e<n.length;e++){const t=n[e];e===n.length-1?r[t]=s:(t in r&&"object"==typeof r[t]&&null!==r[t]||(r[t]={}),r=r[t])}return e}}class i{set refId(e){this._refId=e}get refId(){return this._refId}set container(e){this._container=e}get container(){return this._container}get className(){return this._className}constructor(e,{data:t,container:s,selector:n,position:r}={data:null,container:null,selector:null,position:null}){this._refId="",this._selectorOptionKey="",this._classOptionKey="",this._className="",this._elementType="div",this._innerElementType="div",this._position="after",this._hasInnerElement=!1,this.elementSelector="",this.options={},this.data={},this.MQ=e,this.setOptions(this.MQ.options),this.refId=this.MQ.refId,t&&(this.data=t),s&&(this.container=s),r&&(this._position=r),n&&(this.elementSelector=n)}setOption(e,t){this.options=r.setOptionByKeys(this.options,e,t)}getOption(e){return r.getOptionByKeys(this.options,e)}setOptions(e){this.options=e}getOptions(){return this.options}applyOptions(e){this.options={...this.options,...e}}get element(){return this._element||this.findOrGenerateElement(),this._element}set element(e){this._element=e}get innerElement(){return this._innerElement||(this._element?this.findOrGenerateInnerElement():this.findOrGenerateElement()),this._innerElement}set selector(e){this.elementSelector=e}get selector(){return this.elementSelector||this._selectorOptionKey&&(this.elementSelector=e.getRefSelector(this.refId,this.getOption(this._selectorOptionKey))),this.elementSelector}generateElement(){return this._element=document.createElement(this._elementType),this._hasInnerElement&&(console.log(`${this.constructor.name} has inner element}`),this.generateInnerElement(),this._element.appendChild(this._innerElement)),this.applyElementAttributes(),console.log("calling from generate"),this.applyElementContents(),this._element}applyElementContents(){const e=this.generateElementContents(),t=this._hasInnerElement?this._innerElement:this._element;console.log("elementforcontents",t),e&&("before"===this._position?(console.log("position before for existing",this._element),t.innerHTML=e+this._element.innerHTML):t.innerHTML=e)}findElement(){if(!this.selector)throw new Error("No element selector specified");return console.log("trying to find",this.selector),document.querySelector(this.selector)}findOrGenerateElement(){const e=this.findElement();return e?this._element=e:(console.log("generating element",this.elementSelector),this.generateElement()),this._element}generateInnerElement(){return this._innerElement=document.createElement(this._innerElementType),this.applyInnerElementAttributes(),this._innerElement}applyInnerElementAttributes(){this._innerElement&&(this._innerElement.classList.add("mq-inner"),this._innerElement.setAttribute("data-mq-ref",this.refId))}findOrGenerateInnerElement(){const e=this.findInnerElement();e?this._innerElement=e:this.generateInnerElement()}generateElementContents(){return""}reset(){this.resetElementOutput(),this.render()}resetElementOutput(){this._element=null,this._innerElement=null;const e=this.findElement();if(e){for(e.innerHTML="";e.attributes.length>0;)e.removeAttribute(e.attributes[0].name);this.initializeExistingElement(e)}}render(e){var t;if(console.log(`Render called in ${this.constructor.name}`),!this.container)return void console.error("No container found in",null===(t=null==this?void 0:this.constructor)||void 0===t?void 0:t.name);const s=this.findElement();if(s){if(this.initializeExistingElement(s),this._hasInnerElement){const e=this.findInnerElement();e?this.initializeExistingInnerElement(e):(console.log(`Generating new inner element ${this.constructor.name}`),this.generateInnerElement(),s.appendChild(this._innerElement))}console.log("calling from render"),this.applyElementContents()}else console.log(`Generating element in ${this.constructor.name}`),this.generateElement(),"before"===this._position?this.container.insertBefore(this.element,this.container.firstChild):(console.log("appending",this.element,this.container),this.container.appendChild(this.element)),this._hasInnerElement&&this.renderInnerElement();this.applyEvents()}renderInnerElement(){if(!this._element)throw new Error("Element must be created before inner element rendered");this.findOrGenerateInnerElement(),this._element.appendChild(this._innerElement)}initializeExistingElement(e){this._element=e,this.applyElementAttributes()}initializeExistingInnerElement(e){this._innerElement=e,this.applyInnerElementAttributes()}applyEvents(){}getOutput(e){return this.element.outerHTML}applyElementAttributes(){if(console.log(`Applying element attributes in ${this.constructor.name}`,this._element),!this._element)throw new Error("Element must be created before attributes are applied");this._element&&this._element.setAttribute("data-mq-ref",this.refId),this._classOptionKey&&(console.log("class name from option",this.getOption(this._classOptionKey)),this._element.classList.add(this.getOption(this._classOptionKey))),this._className&&(console.log("rendererd class name",this._className),this._element.classList.add(this._className))}findInnerElement(){var e;return null===(e=this.element)||void 0===e?void 0:e.querySelector(":scope > .mq-inner")}}class o extends i{render(){const e=this.MQ.options.selectors.chat_form_container,t=document.querySelector(e);t&&void 0!==t.innerHTML&&""==t.innerHTML.trim()&&(t.innerHTML=this.getOutput())}getOutput(){if(this.MQ.options.callbacks.chat_form_render.template&&"function"==typeof this.MQ.options.callbacks.chat_form_render.template)return this.MQ.options.callbacks.chat_form_render.template.call(this,this.MQ);const e=this.refId;return`<form data-mq-ref="${e}" data-mq-id="chat-form-${e}">\n <div class="${this.MQ.options.classes.input_chat_prompt}-container">\n <label for="chat-input-${e}" class="mq-visually-hidden">${this.MQ.options.labels.chat_input_label}</label>\n <input id="chat-input-${e}" data-mq-ref="${e}" data-mq-id="chat-input-${e}" class="${this.MQ.options.classes.input_chat_prompt}" type="text" placeholder="Type a question here">\n </div>\n <div class="${this.MQ.options.classes.button_chat_submit}-container">\n <button data-mq-ref="${e}" data-mq-id="form-submit-${e}" class="${this.MQ.options.classes.button_chat_submit}" type="submit">${this.MQ.options.labels.chat_button_submit}</button>\n </div>\n </form>`}}class a extends i{constructor(){super(...arguments),this._selectorOptionKey="selectors.chat_result_container",this._classOptionKey="classes.chat_result_container"}render(){let e;(e=this.MQ.options.callbacks.chat_text_render.before)&&e.call(this,this.MQ,this.data),super.render(),(e=this.MQ.options.callbacks.chat_text_render.after)&&e.call(this,this.MQ,this.data)}generateInnerElement(){let e=this.data.text;e=e.trim(),e=e.replace(/\n/g,"<br>");const t=document.createElement("span");return t.innerHTML=e,t}generateElementContents(){var e;return null===(e=this.generateInnerElement())||void 0===e?void 0:e.outerHTML}getOutput(){return this.element.outerHTML}}class l{constructor(){this._params={},this.endpointBaseUrl="https://api.modernquery.io/"}static convertParamsToQueryString(e){return Object.keys(e).reduce(((t,s)=>{const n=e[s]?encodeURIComponent(e[s]):"";return t+"&"+encodeURIComponent(s).toString()+"="+n}),"")}get params(){return this._params}updateParams(e){this._params={...this._params,...e}}setParams(e){this._params=e}
1async makeRequest(e,t={}){let s="https://api.modernquery.io/";const n={};(null==t?void 0:t.method)&&(n.method=t.method),s=void 0!==t.baseUrl&&t.baseUrl?t.baseUrl:"https://api.modernquery.io/",console.log("endpoint base",s),s.endsWith("/")||(s+="/");let r=s+e.replace(/^\/?/,"");console.log("service options",t),console.log("service method",t.method),void 0!==t.params&&("PUT"==n.method||"POST"==n.method?(n.body=JSON.stringify(t.params),n.headers={...n.headers,Accept:"application/json, text/plain, */*","Content-Type":"application/json"}):r+="?"+l.convertParamsToQueryString(t.params)),(null==t?void 0:t.signal)&&(n.signal=t.signal);const i=await fetch(r,n).catch((e=>{throw e}));console.log("response from service",i);const o=i.json();return void 0!==t.expectFields&&this.confirmExpectedFields(o,t.expectFields),o}confirmExpectedFields(e,t){return console.log("expected fields data",e),console.log("expectedfields",t),!0}}const c=class extends l{async askQuestion(e){return await this.makeRequest("/document/chat",{params:e})}async getRecommendations(e){return e.relevant_docs=!0,await this.makeRequest("/document/chat",{params:e})}};class u extends i{constructor(){super(...arguments),this._imageAsTag=!1,this.optionKeys={results:"results",show_snippet:"results.show_snippet",show_url:"results.show_url",show_images:"results.show_images",meta_description_as_snippet:"results.meta_description_as_snippet",meta_description_order:"results.meta_description_order",default_image_hide:"results.default_image_hide",default_image:"results.default_image",meta_fields_display:"results.meta_fields_display"}}getOutput(t){const s={url:"",tag:""};let n=t.fields.title,r=t.highlight;if(n=e.parseTitle(n,this.getOption(this.optionKeys.results)),this.getOption(this.optionKeys.meta_description_as_snippet)){const s=this.getOption(this.optionKeys.meta_description_order);if(Array.isArray(s)){let n;for(const r of s)n||(n=e.extractMetaDescriptionValue(t,r));r=n||r}}if(this.getOption(this.optionKeys.show_images)){const e=this.getResultImageValue(t);if(e){if(this._imageAsTag){const t=e.match(/src\s*=\s*"(.*?)"/);t&&t[1]&&(s.url=t[1]),s.tag=e}else s.url=e;s.url&&(s.url=s.url.trim(),this.getOption(this.optionKeys.default_image)==s.url&&this.getOption(this.optionKeys.default_image_hide)&&(s.url=""))}}let i=this.MQ.options.classes.results_item;s.url&&(i+=" "+this.MQ.options.classes.has_image);const o=this.getMetaFieldsToDisplay(t),a={title:n,snippet:r,created_time:this.getCreatedTime(t),modified_time:this.getModifiedTime(t),image:s,meta_fields:o};if(this.MQ.options.callbacks.search_result_render.markup&&"function"==typeof this.MQ.options.callbacks.search_result_render.markup)return this.MQ.options.callbacks.search_result_render.markup.call(this,this.MQ,t,a);let l=`<${this.MQ.options.elements.results_item} class="${i}">`;s.url&&(l+=`<${this.MQ.options.elements.results_item_image_container} class="${this.MQ.options.classes.results_item_image_container}">\n <img src="${s.url}" onerror="try { this.style.display='none'; this.parentElement.style.display = 'none'; this?.parentElement?.parentElement?.classList?.remove('${this.MQ.options.classes.has_image}'); } catch(e) { console.log('e'); }" role="presentation">\n </${this.MQ.options.elements.results_item_image_container}>`),l+=`<${this.MQ.options.elements.results_item_content} class="${this.MQ.options.classes.results_item_content}">`,l+=`<${this.MQ.options.elements.results_item_title} class="${this.MQ.options.classes.results_item_title}" href="${t.fields.url}">${n}</${this.MQ.options.elements.results_item_title}>`,this.getOption(this.optionKeys.show_url)&&(l+=`<${this.MQ.options.elements.results_item_url} class="${this.MQ.options.classes.results_item_url}" href="${t.fields.url}">${t.fields.url}</${this.MQ.options.elements.results_item_url}>`);for(const t of o){const s=this.MQ.options.classes.results_item_meta_field;l+=`<span class="${s} ${s}-${e.metaKeyToClassSuffix(t.key)}">${t.label?`<span class="${s}__label">${t.label}</span>`:""}${t.formatted_value}</span>`}return this.getOption(this.optionKeys.show_snippet)&&(l+=`<${this.MQ.options.elements.results_item_snippet} class="${this.MQ.options.classes.results_item_snippet}">${r}</${this.MQ.options.elements.results_item_snippet}>`),l+=`</${this.MQ.options.elements.results_item}>\n </${this.MQ.options.elements.results_item_content}>`,l}getResultImageValue(t){const s=e.extractMetaTagValue(t,"mq:image_tag_encoded"),n=e.extractMetaTagValue(t,this.MQ.options.results.image_tag_order);return s&&n==s&&(this._imageAsTag=!0),n}getMetaFieldsToDisplay(t){var s,n;const r=this.getOption(this.optionKeys.meta_fields_display);if(!Array.isArray(r)||0===r.length)return[];const i=null!==(s=t.fields.page_type)&&void 0!==s?s:null,o=[];for(const s of r){if(s.page_types&&!s.page_types.includes(i))continue;const r=e.extractMetaTagValue(t,s.meta_key);r&&o.push({key:s.meta_key,label:null!==(n=s.label)&&void 0!==n?n:null,value:r,formatted_value:this.formatMetaFieldValue(r,s.format)})}return o}formatMetaFieldValue(e,t="string"){if("date"===t){const t=new Date(e);if(!isNaN(t.getTime()))return t.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"})}return e}getCreatedTime(t){return e.extractMetaTagValue(t,["mq:created_time","mq:published_time","article:published_time"])}getModifiedTime(t){return e.extractMetaTagValue(t,["mq:modified_time","article:modified_time"])}}class h extends i{render(t){console.log("results",t);const s=e.getRefSelector(this.refId,this.MQ.options.selectors.results_container),n=document.querySelector(s);n?this.getOption("output_append")?n.innerHTML+=this.getOutput(t):n.innerHTML=this.getOutput(t):console.error(`Could not find element matching selector ${s} for search results rendering`)}getOutput(e){const t=new u(this.MQ);return e.reduce(((e,s)=>e+t.getOutput(s)),"")}}class d extends i{render(e){let t;console.log("data in renderer",e);const s=new h(this.MQ);s.setOptions(this.getOptions()),s.refId=this.refId;const n=d.extractItems(e,this.MQ);(t=this.MQ.options.callbacks.search_results_render.before)&&t.call(this,this.MQ,e),s.render(n),(t=this.MQ.options.callbacks.search_results_render.after)&&t.call(this,this.MQ,e)}static extractItems(t,s){var n,r,i;return(null===(n=null==t?void 0:t.hits)||void 0===n?void 0:n.hits)?null===(i=null===(r=t.hits)||void 0===r?void 0:r.hits)||void 0===i?void 0:i.map((t=>{var n,r,i,o,a,l,c;return{fields:{id:null===(n=t._source)||void 0===n?void 0:n.id,source_id:null===(r=t._source)||void 0===r?void 0:r.source_id,meta:null===(i=t._source)||void 0===i?void 0:i.meta,title:null===(o=t._source)||void 0===o?void 0:o.title,url:null===(a=t._source)||void 0===a?void 0:a.url,page_section:null===(l=t._source)||void 0===l?void 0:l.page_section,page_type:null===(c=t._source)||void 0===c?void 0:c.page_type},highlight:e.highlightStringsToSnippet(t.highlight,s.options.results)}})):[]}}class p extends u{constructor(){super(...arguments),this.optionKeys={results:"chat.recommendations.results",show_snippet:"chat.recommendations.results.show_snippet",show_url:"chat.recommendations.results.show_url",show_images:"chat.recommendations.results.show_images",meta_description_as_snippet:"chat.recommendations.results.meta_description_as_snippet",meta_description_order:"chat.recommendations.results.meta_description_order",default_image_hide:"chat.recommendations.results.default_image_hide",default_image:"chat.recommendations.results.default_image",meta_fields_display:"chat.recommendations.results.meta_fields_display"}}}class m extends h{getOutput(e){const t=new p(this.MQ);return e.reduce(((e,s)=>e+t.getOutput(s)),"")}}class _ extends i{render(e){let t;console.log("data in chat renderer",e),(t=this.MQ.options.callbacks.chat_recommendations_render.before)&&t.call(this,this.MQ,e),this.data=e,super.render(),(t=this.MQ.options.callbacks.chat_recommendations_render.after)&&t.call(this,this.MQ,e)}getOutput(){var e,t,s,n;let r=`\n <div class="chat-recommendation-heading">\n ${this.MQ.options.labels.chat_recommendations_heading}\n </div>\n `;const i=this.data;if(i.search_results&&(null===(t=null===(e=i.search_results.hits)||void 0===e?void 0:e.hits)||void 0===t?void 0:t.length)>0){const e=null===(n=null===(s=i.search_results.hits)||void 0===s?void 0:s.hits)||void 0===n?void 0:n.filter((e=>{var t,s,n,r;const o=null===(s=null===(t=i.search_results.hits)||void 0===t?void 0:t.hits)||void 0===s?void 0:s.findIndex((t=>{var s,n;return(null===(s=t._source)||void 0===s?void 0:s.url)==(null===(n=e._source)||void 0===n?void 0:n.url)}));return(null===(r=null===(n=i.search_results.hits)||void 0===n?void 0:n.hits)||void 0===r?void 0:r.indexOf(e))===o}));i.search_results.hits.hits=e;const t=new m(this.MQ);t.applyOptions(this.MQ.options.chat.recommendations.results);const o=d.extractItems(i.search_results,this.MQ);r+=t.getOutput(o)}return r}}class g extends i{getOutput(t){let s=t.metadata.title;s=e.parseTitle(s,this.MQ.options.results);const n=this.MQ.options.classes.results_item;let r=`<${this.MQ.options.elements.results_item} class="mq-chat-source-doc ${n}">`;return r+=`<${this.MQ.options.elements.results_item_content}>`,r+=`<${this.MQ.options.elements.results_item_title} class="${this.MQ.options.classes.results_item_title}" href="${t.metadata.url}">${s}</${this.MQ.options.elements.results_item_title}>`,r+=`</${this.MQ.options.elements.results_item_content}>\n </${this.MQ.options.elements.results_item}>`,r}}class f extends i{constructor(){super(...arguments),this._selectorOptionKey="selectors.chat_recommendations_container",this._classOptionKey="classes.chat_recommendations_container",this._hasInnerElement=!0}render(){let e;(e=this.MQ.options.callbacks.chat_recommendations_render.before)&&e.call(this,this.MQ,this.data),super.render(),(e=this.MQ.options.callbacks.chat_recommendations_render.after)&&e.call(this,this.MQ,this.data)}generateElementContents(){const e=new g(this.MQ);let t=this.data;return t&&Array.isArray(t)?(t=t.slice(0,this.MQ.options.chat.recommendations.results.number_per_page),t.reduce(((t,s)=>t+e.getOutput(s)),"")):""}}class y{constructor(e){this.MQ=e}}class v extends y{handleEvent(e){return!0}applyToElement(e){const t=e=>{const t=e.scrollHeight>e.clientHeight;console.log("isoverflow",t,e),t?e.classList.add("mq-content-overflow"):e.classList.remove("mq-content-overflow")},s=new ResizeObserver((()=>{console.log("resize observer triggered"),t(e)}));new MutationObserver((()=>{t(e)})).observe(e,{childList:!0,subtree:!0,characterData:!0}
1),s.observe(e),t(e)}}class b extends i{constructor(){super(...arguments),this._selectorOptionKey="selectors.chat_result_recommendations_container",this._classOptionKey="classes.chat_result_recommendations_container",this._hasInnerElement=!0}applyEvents(){console.log("applying events in RenderChatTextAndRecommendationsContainer"),new v(this.MQ).applyToElement(this.innerElement)}render(){console.log("render called in RenderChatTextAndRecommendationsContainer"),super.render(),console.log("checking for height constraint in RenderChatTextandRecommendationsContainer"),this.getOption("ui.chat_result_constrain_height")&&(console.log("inner element",this._innerElement),this._innerElement.classList.add(this.getOption("classes.constrain_height")))}}class M extends i{constructor(){super(...arguments),this._selectorOptionKey="selectors.content_fade_out"}render(){const e=this.container;e?e.innerHTML+=this.getOutput():console.error("No container found for ContentFadeOut")}generateElement(){const e=this.refId;this._element=document.createElement("div"),this._element.setAttribute("data-mq-ref",e);const t=this.getOption("classes.content_fade_out");return this._element.classList.add(t),this._element}getOutput(){return this.element.outerHTML}}class Q extends y{handleEvent(e){console.log("handling show more event"),e.preventDefault();const t=e.target.closest("."+this.MQ.options.classes.constrain_height);return!!t&&(t.classList.add(this.MQ.options.classes.expanded),!0)}applyToElement(e){console.log("applying show more event to element",e),e.addEventListener("click",(e=>(console.log("clicked show more"),this.handleEvent(e))))}}class E extends i{constructor(){super(...arguments),this._selectorOptionKey="selectors.show_more_button"}applyEvents(){console.log("applying events in rendershowmorebutton"),new Q(this.MQ).applyToElement(this.element)}generateElement(){return this._element=document.createElement("button"),this.applyElementAttributes(),this._element.innerHTML=this.generateElementContents(),this._element.classList.add(this.getOption("classes.show_more_button")),this._element.addEventListener("click",(function(e){console.log("TEST CLICK")})),this._element}generateElementContents(){var e;return`<span>${null!==(e=this.getOption("labels.chat_result_expand"))&&void 0!==e?e:"Show More"}</span>`}getOutput(){return this.element.outerHTML}}class w extends i{constructor(){super(...arguments),this._elementType="h2"}generateElementContents(){var e;return`<span>${null===(e=this.data)||void 0===e?void 0:e.text}</span>`}}class O extends w{constructor(){super(...arguments),this._classOptionKey="classes.chat_recommendations_heading",this._selectorOptionKey="selectors.chat_recommendations_heading"}}class T extends t{constructor(e){super(e),this._chatService=new c}renderForm(){new o(this.MQ).render()}renderResult(e){new a(this.MQ,{data:e}).render()}renderTextAndRecommendationsContainer(t){var s;const n=document.querySelector(e.getRefSelector(t,this.MQ.options.selectors.chat_container));console.log("parentcontainer",n,e.getRefSelector(t,this.MQ.options.selectors.chat_container));const r=new b(this.MQ,{container:n});return r.refId=t,null===(s=r.element)||void 0===s||s.classList.remove(this.MQ.options.classes.expanded),console.log("rendertextandrecs called"),r.render(),r}renderTextAndRecommendations(e,t,s,n){console.log("containerelement",e);const r=new a(this.MQ,{data:t,container:e}),i=new f(this.MQ,{data:s,container:e});if(r.render(),console.log("recomendations element",i.element),console.log("selector",i.selector+" h2"),i.render(),this.MQ.options.labels.chat_recommendations_heading){const e=i.innerElement||i.container;new O(this.MQ,{data:{text:this.MQ.options.labels.chat_recommendations_heading},container:e,position:"before"}).render()}if(console.log("checking for height constraint in chat controller",this.MQ.options.ui.chat_result_constrain_height),this.MQ.options.ui.chat_result_constrain_height){console.log("rendering fadeout and chose more");const t=new M(this.MQ,{container:e}),s=new E(this.MQ,{container:e});t.render(),s.render()}}renderRecommendations(e){new _(this.MQ,{data:e}).render(e)}renderSourceDocs(e){new f(this.MQ,{data:e}).render()}async getResultData(e){return console.log("mq domain name",this.MQ.domainName),await this._chatService.askQuestion({domain:this.MQ.domainName,property_id:this.MQ.propertyId,group_id:this.MQ.groupId,org_name:this.MQ.orgName,prompt:e})}async getRecommendations(e){return await this._chatService.getRecommendations({domain:this.MQ.domainName,property_id:this.MQ.propertyId,group_id:this.MQ.groupId,prompt:e})}}const x=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1},q=(...e)=>e.reduce(((e,t)=>{if(Array.isArray(t))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(t).forEach((s=>{["__proto__","constructor","prototype"].includes(s)||(Array.isArray(e[s])&&Array.isArray(t[s])?e[s]=q.options.mergeArrays?q.options.uniqueArrayItems?Array.from(new Set(e[s].c
1oncat(t[s]))):[...e[s],...t[s]]:t[s]:x(e[s])&&x(t[s])?e[s]=q(e[s],t[s]):e[s]=void 0===t[s]?q.options.allowUndefinedOverrides?t[s]:e[s]:t[s])})),e}),{}),A={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};q.options=A,q.withOptions=(e,...t)=>{q.options=Object.assign(Object.assign({},A),e);const s=q(...t);return q.options=A,s};const $=q;var I=s(957),S=s.n(I);class k{constructor(e){this.MQ=e}apply(){const e=document.querySelectorAll(this.MQ.options.selectors.input_search_keywords);e.length>0&&(e.forEach((function(e){e.setAttribute("autocomplete","off")})),this.applyAutocomplete())}applyAutocomplete(){console.log("applying autocomplete to",this.MQ.options.selectors.input_search_keywords);const t=this.MQ;this.MQ.state.scripts.autocomplete=new(S())({name:"mq-autocomplete",submit:!0,selector:this.MQ.options.selectors.input_search_keywords,placeHolder:this.MQ.options.labels.search_input_placeholder,data:{src:async e=>{try{const t=await this.MQ.search.service.autoComplete({params:{keywords:e,domain:this.MQ.domainName,group_id:this.MQ.groupId,property_id:this.MQ.propertyId,page:1}});return console.log("data returned from autocomplete",t),t.suggestions}catch(e){return e}},filter:t=>t.map((t=>(void 0!==t.value&&(t.value.title,t.value.title=e.parseTitle(t.value.title,this.MQ.options.results)),void 0!==t.match&&(t.match=e.parseTitle(t.match,this.MQ.options.results),t.match=t.match.replace("Ã","")),t))),keys:["title"]},events:{input:{focus(){t.state.scripts.autocomplete.input.value.length&&t.state.scripts.autocomplete.start()},selection(e){const t=e.detail;console.log(t);const s=t.selection.value;void 0!==s.url?window.location.href=s.url:(this.MQ.state.scripts.autocomplete.input.value=s,this.MQ.state.scripts.autocomplete.input.closest("form").submit())}}},resultItem:{highlight:!0}})}}class L{constructor(e){this.MQ=e}handleEvent(e){e.preventDefault();const t=this.MQ.options.search.tags||[];this.MQ.state.scripts.autocomplete&&this.MQ.state.scripts.autocomplete.close();const s=e.target.getAttribute("data-mq-ref"),n="search-input-"+s.toString(),r=document.querySelector(`[data-mq-id="${n}"]`);if(!r)return console.error(`Could not find keyword input matching submit button ${s}`),!1;const i="search-tags-"+s.toString(),o=document.querySelectorAll(`[data-mq-id="${i}"]`);o&&(null==o?void 0:o.length)>0&&o.forEach((e=>{(null==e?void 0:e.name)&&(null==e?void 0:e.value)&&t.push({name:e.name,value:e.value})}));const a=r.value;console.log("keywords",a);try{this.MQ.search.getResultsData(a,{tags:t,signal:null}).then((e=>{this.MQ.search.renderResults(e,s)}))}catch(e){if("AbortError"!==(null==e?void 0:e.name))throw e}return!1}applyToElement(e){e.addEventListener("click",(e=>(this.MQ.state.page=1,this.handleEvent(e))))}}class C{constructor(e){this.MQ=e}apply(){const e=document.querySelectorAll(this.MQ.options.selectors.button_search_submit);e.length>0&&e.forEach((e=>{new L(this.MQ).applyToElement(e)}))}}class R{static isActionableKeyPressEvent(e){return!!(null==e?void 0:e.key)&&R.isActionableKeyValue(e.key)}static isActionableKeyValue(e){return R.isLetter(e)||R.isNumber(e)||R.isSpecialCharacter(e)||R.isBackspace(e)}static isLetter(e){return/^[a-zA-Z]$/.test(e)}static isNumber(e){return/^[0-9]$/.test(e)}static isSpecialCharacter(e){return/^[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?`~]$/.test(e)}static isBackspace(e){return"Backspace"===e}}class H{constructor(e){this.keyTimeoutMs=300,this.keyTimers=[],this.MQ=e}apply(){this.MQ;const e=document.querySelectorAll(this.MQ.options.selectors.input_search_keywords);e.length>0&&e.forEach((e=>{e.setAttribute("autocomplete","off"),e.addEventListener("keyup",(t=>{if(t.preventDefault(),R.isActionableKeyPressEvent(t)){if(this.keyTimers.length>0){const e=this.keyTimers.pop();e&&clearTimeout(e)}return this.keyTimers.push(setTimeout((()=>{this.MQ.state.page=1,"load_more"==this.MQ.options.ui.pager_style&&this.MQ.pager.hidePager(),this.MQ.resultCounter.hideResultCount(),this.cancelLastFetchForElement(e),this.handleInputTrigger(e,t)}),this.keyTimeoutMs)),!1}}))}))}cancelLastFetchForElement(e){const t=e.getAttribute("data-mq-id");return void 0!==H.abortControllers[t]&&(H.abortControllers[t].abort(),!0)}handleInputTrigger(e,t){var s;const n=this.MQ.options.search.tags||[];if((null===(s=null==e?void 0:e.value)||void 0===s?void 0:s.length)>
1=this.MQ.options.ui.search_as_you_type_min_letters){const t=e.getAttribute("data-mq-id"),s=e.getAttribute("data-mq-ref"),r=s?"search-tags-"+s.toString():"search-tags",i=document.querySelectorAll(`[data-mq-id="${r}"]`);i&&(null==i?void 0:i.length)>0&&i.forEach((e=>{(null==e?void 0:e.name)&&(null==e?void 0:e.value)&&n.push({name:e.name,value:e.value})}));const o=e.value;console.log("keywords",o),H.abortControllers[t]=new AbortController;const a=H.abortControllers[t].signal;try{this.MQ.search.getResultsData(o,{tags:n,signal:a}).then((e=>{this.MQ.search.renderResults(e,s)})).catch((e=>{if("AbortError"!=(null==e?void 0:e.name))throw e}))}catch(e){if("AbortError"!==(null==e?void 0:e.name))throw e}}}}H.abortControllers={};class K extends i{constructor(){super(...arguments),this._selectorOptionKey="selectors.chat_result_loading_indicator",this._classOptionKey="classes.chat_result_loading_indicator"}}class j{constructor(e){this.MQ=e}apply(){const t=document.querySelectorAll(e.getRefSelector(this.MQ.refId,this.MQ.options.selectors.button_chat_submit)),s=this.MQ;t.length>0&&t.forEach((function(t){t.addEventListener("click",(t=>{var n;t.preventDefault(),console.log("clicked");const r=t.target,i=r.getAttribute("data-mq-id"),o=i.substring(i.lastIndexOf("-")+1),a=null!==(n=r.getAttribute("data-mq-ref"))&&void 0!==n?n:s.refId;console.log("id is",i),console.log("id number is",o);const l="chat-form-"+a.toString(),c="chat-input-"+a.toString(),u=document.querySelector(`[data-mq-id="${l}"]`),h=document.querySelector(`[data-mq-id="${c}"]`);console.log("prompt id is",c),console.log("promptInput is",h);const d=document.querySelector("body");if(!h)return console.error(`Could not find chat input matching submit button ${i}`),!1;const p=h.value;d.classList.add(s.options.classes.chat_result_loading),d.classList.remove(s.options.classes.chat_result_loaded);const m=s.chat.renderTextAndRecommendationsContainer(a);m.reset(),new K(s,{container:m.innerElement}).render(),console.log("resultrecrenderer",m.element);const _=document.querySelector(e.getRefSelector(a,s.options.selectors.chat_result_container));return _&&(_.innerHTML=""),console.log("prompt",p),u&&u.classList.add("loading"),s.options.labels.chat_button_loading&&(r.innerHTML=s.options.labels.chat_button_loading),s.chat.getResultData(p).then((e=>{s.chat.renderTextAndRecommendations(m.innerElement,e,null==e?void 0:e.sourceDocuments,a),console.log("rendering source docs"),d.classList.add(s.options.classes.chat_result_loaded),u&&u.classList.remove("loading"),s.options.labels.chat_button_loading&&(r.innerHTML=s.options.labels.chat_button_submit),d.classList.remove(s.options.classes.chat_result_loading)})),s.options.ui.chat_search_combined&&(console.log("combined chat search",p),s.state.page=1,s.search.getResultsData(p,{params:{is_chat_prompt:!0}}).then((e=>{console.log("rendering search results"),s.search.renderResults(e,a)}))),!1}))}))}}class P extends i{render(t){const s=e.getRefSelector(this.MQ.refId,this.MQ.options.selectors.results_pager_container),n=document.querySelector(s);n&&(n.innerHTML=this.getOutput())}getOutput(){if("load_more"==this.MQ.options.ui.pager_style)return this.getLoadMoreOutput()}getLoadMoreOutput(){const e=this.refId;return`<form data-mq-ref="${e}" class="search-results-pager" data-mq-element="search-results-pager" data-mq-id="search-results-pager-${e}">\n <button data-mq-ref="${e}" data-mq-id="search-results-load-more-${e}" class="${this.MQ.options.classes.button_results_load_more}" type="button">${this.MQ.options.labels.button_results_load_more}</button>\n </form>`}}class N{constructor(e){this.MQ=e}handleEvent(e){return e.preventDefault(),console.log("handling load more event"),this.MQ.state.page=this.MQ.state.page+1,new L(this.MQ).handleEvent(e),!1}applyToElement(e){e.addEventListener("click",(e=>this.handleEvent(e)))}}class D{constructor(e){this.MQ=e}apply(){const e=document.querySelectorAll(this.MQ.options.selectors.button_results_load_more);e.length>0&&e.forEach((e=>{new N(this.MQ).applyToElement(e)}))}}class F extends t{constructor(e){super(e),this.renderer=new P(this.MQ)}renderPager(e){this.renderer.render(e)}
1applyPagerEvents(){new D(this.MQ).apply()}setPagerStyle(e,t){const s=this.MQ.options.selectors.results_pager_container;document.querySelectorAll(s).forEach((s=>{if(s instanceof HTMLElement){const n=this.renderer.refId?s:null==s?void 0:s.parentElement;n&&(n.style[e]=t)}}))}hidePager(){this.setPagerStyle("display","none")}showPager(){this.setPagerStyle("display","")}}class V extends i{render(t){const s=e.getRefSelector(this.MQ.refId,this.MQ.options.selectors.results_meta_total_count),n=document.querySelector(s);n&&(n.innerHTML=this.getOutput(t))}getOutput(e){var t,s;const n=(null===(s=null===(t=null==e?void 0:e.hits)||void 0===t?void 0:t.total)||void 0===s?void 0:s.value)||0;if(this.MQ.options.ui.replace_total_count_on_no_results&&n<=0)return"<span>"+this.MQ.options.labels.results_none+"</span>";const r=this.MQ.options.labels.results_total_count;return-1!==r.indexOf("%count%")?`<span>${r.replace("%count%",`<span>${n}</span>`)}</span>`:"<span>"+this.MQ.options.labels.results_total_count+"</span><span>"+n+"</span>"}}class z extends t{constructor(e){super(e),this.renderer=new V(this.MQ)}renderResultCount(e){this.renderer.render(e)}setResultCountStyle(e,t){const s=this.MQ.options.selectors.results_meta_total_count;document.querySelectorAll(s).forEach((s=>{if(s instanceof HTMLElement){const n=this.renderer.refId?s:null==s?void 0:s.parentElement;n&&(n.style[e]=t)}}))}hideResultCount(){this.setResultCountStyle("visibility","hidden")}showResultCount(){this.setResultCountStyle("visibility","visible")}}const B=class extends l{async searchKeywords(e={}){var t;return console.log("params in searchkeywords",e.params),e.method=(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t.search_tags)?"POST":"GET",await this.makeRequest("/document/search",e)}async autoComplete(e={}){var t;return e.method=(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t.search_tags)?"POST":"GET",await this.makeRequest("/document/autocomplete",e)}};class G extends i{render(){const e=this.MQ.options.selectors.search_form_container,t=document.querySelector(e);t&&(t.innerHTML=this.getOutput(),this.applyHTMLAttributes(t))}getOutput(){const e=this.refId;return`<form data-mq-element="search-form" data-mq-ref="${e}" data-mq-id="search-form-${e}" class="${this.MQ.options.classes.search_form}">\n <label for="search-input-${e}" class="mq-visually-hidden">${this.MQ.options.labels.search_input_label}</label>\n <input id="search-input-${e}" data-mq-ref="${e}" data-mq-element="search-input" data-mq-id="search-input-${e}" class="${this.MQ.options.classes.input_search_keywords}" type="text" placeholder="${this.MQ.options.labels.search_input_placeholder}" autocomplete="off">\n <button data-mq-ref="${e}" data-mq-id="form-submit-${e}" class="${this.MQ.options.classes.button_search_submit}" type="submit">${this.MQ.options.labels.search_button_submit}</button>\n </form>`}applyHTMLAttributes(e){const t=this.refId,s=e.querySelector(this.MQ.options.selectors.input_search_keywords),n=e.querySelector(this.MQ.options.classes.button_search_submit);s&&(s.setAttribute("data-mq-ref",t),s.setAttribute("data-mq-element","search-input"),s.setAttribute("data-mq-id",`search-input-${t}`),s.classList.add(this.MQ.options.classes.input_search_keywords)),n&&(n.setAttribute("data-mq-ref",t),n.setAttribute("data-mq-element","search-submit"),n.setAttribute("data-mq-id",`search-submit-${t}`),n.classList.add(this.MQ.options.classes.button_search_submit))}}class U extends t{constructor(e){super(e),this._searchService=new B}get service(){return this._searchService}renderForm(){new G(this.MQ).render()}renderResults(e,t=null){var s,n,r,i,o,a;const l=new d(this.MQ);t&&(l.refId=t,this.MQ.pager.renderer.refId=t,this.MQ.resultCounter.renderer.refId=t),"load_more"==this.MQ.options.ui.pager_style&&(this.MQ.state.page<=1?this.MQ.pager.hidePager():l.setOption("output_append",!0)),((null===(s=null==e?void 0:e.hits)||void 0===s?void 0:s.hits.length)<=0||(null===(r=null===(n=null==e?void 0:e.hits)||void 0===n?void 0:n.total)||void 0===r?void 0:r.value)<=this.MQ.options.results.number_per_page)&&this.MQ.pager.hidePager(),l.render(e),this.MQ.resultCounter.renderer.render(e),this.MQ.resultCounter.showResultCount(),(null===(i=null==e?void 0:e.hits)||void 0===i?void 0:i.hits.length)>0&&(null===(a=null===(o=null==e?void 0:e.hits)||void 0===o?void 0:o.total)||void 0===a?void 0:a.value)>this.MQ.options.results.number_per_page&&(this.MQ.pager.renderPager(e),this.MQ.pager.applyPagerEvents(),this.MQ.pager.showPager());const c=document.querySelector("body");c&&c.classList.add(this.MQ.options.classes.results_loaded)}async getResultsData(e,{tags:t,signal:s,params:n}={}){var r,i;const o=document.querySelector("body");o&&o.classList.add(this.MQ.options.classes.results_loading);try{let o={domain:this.MQ.domainName,property_id:this.MQ.propertyId,group_id:this.MQ.groupId,keywords:e,results_per_page:null!==(r=this.MQ.options.results.number_per_page)&&void 0!==r?r:20,page:null!==(i=this.MQ.state.page)&&void 0!==i?i:1};o={...o,...n},t&&(null==t?void 0:t.length)>0&&(o.search_tags=t);const a={params:o};return s&&(a.signal=s),console.log("mq domain name",this.MQ.domainName),await this.service.searchKeywords(a)}catch(e){throw"AbortError"==(null==e?void 0:e.name)&&console.log("Fetch aborted due to explicit abort. This is probably ok."),e}finally{o&&o.classList.remove(this.MQ.options.classes.results_loading)}}}const Z={chat_container:"mq-chat-container",search_container:"mq-search-container",results_container:"search-results-container",results_pager_container:"search-results-pager-container",results_meta_total_count:"search-results-total",results_item:"search-result",results_item_title:"search-result-title",results_item_url:"search-result-url",results_item_snippet:"search-result-snippet",results_item_image_container:"search-result-image",results_loaded:"search-results-loaded",results_loading:"search-results-loading",input_chat_prompt:"search-ch
1at-prompt",input_search_keywords:"search-keywords",button_search_submit:"search-submit",button_chat_submit:"search-chat-submit",button_results_load_more:"search-results-load-more",chat_result_loading:"chat-results-loading",chat_result_loaded:"chat-results-loaded",chat_result_loading_indicator:"mq-chat-result-loading-indicator",has_image:"has-image",results_item_content:"search-result-content",search_form:"search-form",chat_recommendations_container:"chat-recommendations-container",chat_result_recommendations_container:"chat-result-recommendations-container",chat_recommendations_heading:"chat-recommendations-heading",chat_result_container:"chat-result-container",constrain_height:"mq-constrain-height",content_fade_out:"mq-content-fade-out",show_more_button:"mq-show-more-button",expanded:"mq-content-expanded",results_item_meta_field:"mq-search-result-meta-field"},W={classes:Z,selectors:{chat_container:"."+Z.chat_container,search_container:"."+Z.search_container,results_container:"."+Z.results_container,results_pager_container:"."+Z.results_pager_container,results_meta_total_count:"."+Z.results_meta_total_count,results_item:"."+Z.results_item,results_item_title:"."+Z.results_item_title,results_item_url:"."+Z.results_item_url,results_item_snippet:"."+Z.results_item_snippet,input_chat_prompt:".search-chat-prompt",input_search_keywords:".search-keywords",button_search_submit:".search-submit",button_chat_submit:".search-chat-submit",button_results_load_more:"."+Z.button_results_load_more,search_form_container:".search-form-container",chat_form_container:".chat-form-container",chat_result_container:".chat-result-container",chat_result_loading:"."+Z.chat_result_loading,chat_result_loading_indicator:"."+Z.chat_result_loading_indicator,chat_recommendations_container:"."+Z.chat_recommendations_container,chat_recommendations_heading:"."+Z.chat_recommendations_heading,results_loading_container:".search-results-loading",chat_result_recommendations_container:"."+Z.chat_result_recommendations_container,content_fade_out:"."+Z.content_fade_out,show_more_button:"."+Z.show_more_button,constrain_height:"."+Z.constrain_height},labels:{results_total_count:"Total Results: ",search_input_placeholder:"Enter Keywords",search_input_label:"Enter Search Terms",chat_input_label:"Ask a Question",chat_button_loading:"Loading...",chat_button_submit:"Go",search_button_submit:"Search",chat_recommendations_heading:"Explore more about this topic",button_results_load_more:"Load More",results_none:"No results found. Please try a different search."},elements:{results_container:"div",results_item_title:"a",results_item_url:"a",results_item:"div",results_item_snippet:"div",results_item_image_container:"div",results_item_content:"div"},results:{snippet_fields:["content"],show_url:!0,show_snippet:!0,title_parse:"",show_images:!0,image_tag_order:["mq:image","mq:image_tag_encoded","og:image"],meta_description_as_snippet:!1,meta_description_order:["mq:description","description","og:description"],snippet_max_length:200,default_image:null,default_image_hide:!0,number_per_page:20},ui:{chat_search_combined:!1,search_as_you_type_enabled:!1,search_as_you_type_min_letters:3,autocomplete_enabled:!0,autocomplete_min_letters:3,pager_style:"load_more",replace_total_count_on_no_results:!1,chat_result_constrain_height:!0},search:{tags:null},chat:{recommendations:{results:{show_url:!1,show_snippet:!1,snippet_fields:["content"],title_parse:"",show_images:!1,image_tag_order:["mq:image","mq:image_tag_encoded","og:image"],meta_description_as_snippet:!1,meta_description_order:["mq:description","description","og:description"],snippet_max_length:200,default_image:null,default_image_hide:!0,number_per_page:5}}},callbacks:{chat_form_render:{before:null,template:null,after:null},chat_recommendations_render:{before:null,after:null},chat_text_render:{before:null,after:null},search_results_render:{before:null,after:null},search_result_render:{before:null,after:null,markup:null}}};class J{constructor(t){this.options=W,t&&this.optionsApply(t),this.search=new U(this),this.events=new Y(this),this.chat=new T(this),this.state=new X(this),this.pager=new F(this),this.resultCounter=new z(this),this._refId=e.generateRefId()}optionsApply(e){this.options=$.withOptions({mergeArrays:!1},W,this.options,e)}setDomainName(e){this.domainName=e}setPropertyId(e){this.propertyId=e}setGroupId(e){this.groupId=e}setOrgName(e){this.orgName=e}set refId(e){this._refId=e}get refId(){return this._refId||(this._refId=e.generateRefId()),this._refId}}class X{constructor(e){this.scripts={autocomplete:null},this.page=10,this.MQ=e}}class Y{constructor(e){this.MQ=e}apply(){this.MQ.options.ui.autocomplete_enabled&&new k(this.MQ).apply(),this.MQ.options.ui.search_as_you_t
1ype_enabled&&new H(this.MQ).apply(),new C(this.MQ).apply(),new j(this.MQ).apply()}}})(),n.ModernQuery})()))
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.