PageSourceSearch

https://www.cfainstitute.org/modules/custom/ep_search_api_coveo/js…tomic-search-box-instant-resultsBhxtBj8t.js

js cfainstitute.org collected 2026-09-24 07:46:46 UTC 5,951 bytes, 134 lines download raw bytes

1import { t as e } from "./result-templates-managerBgn3QZxU.js";
2import { T as t, w as n } from "./esmDc86wdRn.js";
3import { a as r, i, n as a, o, r as s, s as c, u as l } from "./decoratorsDgvFPsqQ.js";
4import { t as u } from "./keyedBPCVJzoF.js";
5import { t as d } from "./error-guardDZkUaSL0.js";
6import { t as f } from "./string-utilsCDSkQy2q.js";
7import { t as p } from "./template-providerBSuNqaIN.js";
8import { n as m, r as h, t as g } from "./instant-itemBzf9P2tc.js";
9import { t as _ } from "./suggestions-eventsDrxC_N55.js";
10//#region node_modules/@coveo/atomic/dist/atomic/components/components/common/item-list/result-template-provider.js
11var v = class extends p {
12	constructor(t, n) {
13		super(t, () => e(t.bindings.engine)), this.gridCellLinkTarget = n;
14	}
15	makeDefaultTemplate() {
16		let e = document.createDocumentFragment(), t = document.createElement("atomic-result-link");
17		e.appendChild(t);
18		let n = document.createDocumentFragment(), r = `
19      <atomic-result-link>
20      ${this.gridCellLinkTarget ? `<a slot="attributes" target="${this.gridCellLinkTarget}"></a>` : ""}
21      </atomic-result-link>
22    `, i = document.createElement("template");
23		return i.innerHTML = r.trim(), n.appendChild(i.content), {
24			content: e,
25			linkContent: n,
26			conditions: []
27		};
28	}
29}, y = function(e, t, n, r) {
30	var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
31	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
32	else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
33	return i > 3 && a && Object.defineProperty(t, n, a), a;
34}, b = class extends r {
35	constructor() {
36		super(...arguments), this.results = [], this.display = "list", this.templateHasError = !1, this.maxResultsPerQuery = 4, this.density = "normal", this.imageSize = "icon";
37	}
38	async setRenderFunction(e) {
39		this.itemRenderingFunction = e;
40	}
41	connectedCallback() {
42		super.connectedCallback();
43		try {
44			_((e) => (this.bindings = e, this.initialize()), this, ["atomic-search-box"]);
45		} catch (e) {
46			this.error = e;
47		}
48	}
49	getLink(e) {
50		return (e.tagName === "ATOMIC-RESULT" ? e : e?.querySelector("atomic-result"))?.shadowRoot?.querySelector("atomic-result-link a:not([slot])") || null;
51	}
52	handleLinkClick(e, t) {
53		let n = (t) => e.setAttribute("target", t), r = e.getAttribute("target");
54		t && n("_blank"), e.click(), t && n(r || "");
55	}
56	renderItems() {
57		if (!this.bindings.suggestedQuery() || this.bindings.store.isMobile()) return [];
58		let e = (this.instantResults.state.results.length ? this.instantResults.state.results : this.results).map((e) => {
59			let n = g(this.bindings.i18n, "instant-results-suggestion-label", this.ariaLabelGenerator?.(this.bindings, e) || e.title, e.uniqueId), r = l`${u(`instant-result-${f(e.uniqueId)}`, l`<atomic-result
60            part="outline"
61            .result=${e}
62            .interactiveResult=${t(this.bindings.engine, { options: { result: e } })}
63            .display=${this.display}
64            .density=${this.density}
65            .imageSize=${this.imageSize}
66            .content=${this.itemTemplateProvider.getTemplateContent(e)}
67            .renderingFunction=${this.itemRenderingFunction}
68          ></atomic-result>`)}`, i = document.createElement("div");
69			c(r, i);
70			let a = i.firstElementChild;
71			return {
72				...n,
73				content: a,
74				onSelect: (e) => {
75					let t = this.getLink(e.target);
76					t && this.handleLinkClick(t, e.ctrlKey || e.metaKey);
77				}
78			};
79		});
80		if (e.length) {
81			let t = m(this.bindings.i18n, "show-all-results");
82			e.push({
83				...t,
84				content: h({
85					i18n: this.bindings.i18n,
86					i18nKey: "show-all-results"
87				}),
88				onSelect: () => {
89					this.bindings.clearSuggestions(), this.bindings.searchBoxController.updateText(this.instantResults.state.q), this.bindings.searchBoxController.submit();
90				}
91			});
92		}
93		return e;
94	}
95	initialize() {
96		return this.instantResults = n(this.bindings.engine, { options: { maxResultsPerQuery: this.maxResultsPerQuery } }), this.itemTemplateProvider = new v({
97			includeDefaultTemplate: !0,
98			templateElements: Array.from(this.querySelectorAll("atomic-result-template")),
99			getResultTemplateRegistered: () => !0,
100			setResultTemplateRegistered: () => {},
101			getTemplateHasError: () => this.templateHasError,
102			setTemplateHasError: (e) => {
103				this.templateHasError = e;
104			},
105			bindings: this.bindings
106		}), {
107			position: Array.from(this.parentNode.children).indexOf(this),
108			panel: "right",
109			onSuggestedQueryChange: (e) => (this.instantResults.updateQuery(e), this.onSuggestedQueryChange()),
110			renderItems: () => this.renderItems()
111		};
112	}
113	onSuggestedQueryChange() {
114		return !this.bindings.getSuggestionElements().length && !this.bindings.searchBoxController.state.value && console.warn("There doesn't seem to be any query suggestions configured. Make sure to include either an atomic-search-box-query-suggestions or atomic-search-box-recent-queries in your search box in order to see some instant results."), new Promise((e) => {
115			let t = this.instantResults.subscribe(() => {
116				let n = this.instantResults.state;
117				n.isLoading || (n.results.length && (this.results = n.results), t(), e());
118			});
119		});
120	}
121	render() {
122		return l`${o}`;
123	}
124};
125y([a()], b.prototype, "error", void 0), y([a()], b.prototype, "templateHasError", void 0), y([s({
126	attribute: "max-results-per-query",
127	reflect: !0,
128	type: Number
129})], b.prototype, "maxResultsPerQuery", void 0), y([s({ reflect: !0 })], b.prototype, "density", void 0), y([s({
130	attribute: "image-size",
131	reflect: !0
132})], b.prototype, "imageSize", void 0), y([s({ attribute: "aria-label-generator" })], b.prototype, "ariaLabelGenerator", void 0), y([d()], b.prototype, "render", null), b = y([i("atomic-search-box-instant-results")], b);
133//#endregion
134export { b as AtomicSearchBoxInstantResults };

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.