@cloudflare/ai-search-snippet 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +231 -11
- package/dist/search-snippet.es.js +650 -325
- package/dist/search-snippet.es.js.map +1 -1
- package/dist/search-snippet.umd.js +117 -125
- package/dist/search-snippet.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(p,
|
|
1
|
+
(function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p.SearchSnippet={}))})(this,(function(p){"use strict";var oe=Object.defineProperty;var le=(p,u,d)=>u in p?oe(p,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):p[u]=d;var a=(p,u,d)=>le(p,typeof u!="symbol"?u+"":u,d);const u={loadingAriaLabel:"Loading",errorPrefix:"Error:",missingApiUrlError:"The api-url attribute is required. Please provide a valid API URL.",poweredBy:"Powered by",poweredByLinkLabel:"Cloudflare AI Search",placeholder:"Search...",searchButtonLabel:"Search",searchInputAriaLabel:"Search input",searchResultsAriaLabel:"Search results",emptyStateTitle:"Start Searching",emptyStateDescription:"Enter a query to search for results",modalEmptyStateDescription:"Start typing to search",noResultsTitle:"No Results Found",noResultsDescription:'No results found for "{query}"',modalNoResultsTitle:"No results found",modalNoResultsDescription:'No results for "{query}"',resultsCount:"Found {n} result",resultsCountPlural:"Found {n} results",resultsCountOverflow:"Showing {n} of {total} results",modalResultsCount:"{n} result",modalResultsCountPlural:"{n} results",modalResultsCountZero:"0 results",modalResultsCountError:"Error",seeMoreResults:"See more results",navigateHint:"Navigate",selectHint:"Select",closeHint:"Close",chatTitle:"Chat",chatPlaceholder:"Type a message...",chatInputAriaLabel:"Chat message input",sendButtonLabel:"Send",sendButtonAriaLabel:"Send message",chatEmptyTitle:"Start a Conversation",chatEmptyDescription:"Send a message to begin chatting",userAvatar:"U",assistantAvatar:"AI",unknownError:"Unknown error",openChatAriaLabel:"Open chat",clearHistoryAriaLabel:"Clear history",minimizeAriaLabel:"Minimize",closeAriaLabel:"Close",historyTitle:"History",newChatButton:"New Chat",clearChatButton:"Clear Chat",toggleSidebarTitle:"Toggle sidebar",deleteChatTitle:"Delete chat",noChatsYet:"No chats yet",yesterday:"Yesterday",justNow:"Just now",minuteAgo:"{n} minute ago",minutesAgo:"{n} minutes ago",hourAgo:"{n} hour ago",hoursAgo:"{n} hours ago",loadingMessages:["Searching...","Digging through results...","Scanning the knowledge base...","Finding the best matches...","Sifting through the data...","Almost there...","Looking far and wide...","Connecting the dots...","Rummaging through pages...","Hunting down answers..."]};function d(l){if(!l||typeof l!="object")return u;const i={...u};for(const e of Object.keys(l)){const t=l[e];if(t!=null){if(e==="loadingMessages"){Array.isArray(t)&&t.length>0&&(i.loadingMessages=t.filter(s=>typeof s=="string"),i.loadingMessages.length===0&&(i.loadingMessages=u.loadingMessages));continue}typeof t=="string"&&(i[e]=t)}}return i}function w(l,i={}){return l.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(i,t)?String(i[t]):e)}function E(l,i){if(!l)return null;try{const e=JSON.parse(l);if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("translations must be a JSON object");return e}catch(e){return console.error(`${i}: invalid translations attribute`,e),null}}const A=2500;function z(l,i){let e;function t(...s){clearTimeout(e),e=setTimeout(()=>{l(...s)},i)}return t.cancel=()=>clearTimeout(e),t}function o(l){const i=document.createElement("div");return i.textContent=l,i.innerHTML}function $(l){try{return decodeURI(l)}catch{return l}}function R(l){return new DOMParser().parseFromString(l,"text/html").documentElement.textContent||""}function X(l,i){const e=d(i),t=new Date(l),r=new Date().getTime()-t.getTime();if(r<6e4)return e.justNow;if(r<36e5){const n=Math.floor(r/6e4),c=n===1?e.minuteAgo:e.minutesAgo;return w(c,{n})}if(r<864e5){const n=Math.floor(r/36e5),c=n===1?e.hourAgo:e.hoursAgo;return w(c,{n})}return t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function q(l){return new Date(l).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function B(l="id"){return`${l}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function g(l,i){return l!==null?l:i}function b(l,i){return l===null?i:l==="true"||l===""}function C(l,i){if(l===null)return i;const e=Number.parseInt(l,10);return Number.isNaN(e)?i:e}function f(l,i){return new CustomEvent(l,{detail:i,bubbles:!0,composed:!0,cancelable:!0})}function M(l){if(!l)throw new Error("API URL is required");return new O(l)}function k(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)}function H(...l){const i={};for(const e of l)if(e)for(const[t,s]of Object.entries(e)){const r=i[t];k(r)&&k(s)?i[t]=H(r,s):i[t]=s}return i}function Q(l,i){if(!k(i))return l;const e=new URLSearchParams;for(const[h,m]of Object.entries(i))m!=null&&e.append(h,String(m));const t=e.toString();if(!t)return l;const s=l.indexOf("#"),r=s===-1?l:l.slice(0,s),n=s===-1?"":l.slice(s),c=r.includes("?")?"&":"?";return`${r}${c}${t}${n}`}function ee(l){if(!k(l))return{};const i={};for(const[e,t]of Object.entries(l))t!=null&&(i[e]=String(t));return i}function te(l){return k(l)?l:void 0}class O{constructor(i){a(this,"activeRequests",new Map);a(this,"baseUrl");this.baseUrl=i.replace(/\/$/,"")}request(i,e,t,s){const r=e==="search"?"snippet-search":"snippet-chat-completions",n=Q(`${this.baseUrl}/${e}`,s?.queryParams);return fetch(n,{method:"POST",body:JSON.stringify(H(te(s?.body),i)),headers:{...ee(s?.headers),"Content-Type":"application/json",Accept:i.stream?"text/event-stream":"application/json","cf-ai-search-source":r},signal:t})}async search(i,e={}){const t=this.generateRequestId(),s=new AbortController,r=e.signal||s.signal;this.registerRequest(t,s);try{const n=await this.request({messages:[{role:"user",content:i}],stream:!1,ai_search_options:{retrieval:{metadata_only:!0,max_num_results:e.maxResults??30}}},"search",r,e.request);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);if(!n.body)throw new Error("Response body is empty");const c=await n.json();if(c.success&&c.result)return c.result.chunks.map(h=>({type:"result",id:h.id,title:R(h.item.metadata?.title),description:h.item.metadata?.description?R(h.item.metadata?.description):"",timestamp:h.item.timestamp??void 0,url:h.item.key,image:h.item.metadata?.image||void 0,metadata:{...h.item.metadata,instance_id:h.instance_id}}));throw c.success===!1?new Error(c.error):new Error("Unknown error")}finally{this.unregisterRequest(t)}}async*searchStream(i,e={}){const t=this.generateRequestId(),s=new AbortController,r=e.signal||s.signal;this.registerRequest(t,s);const n=await this.request({messages:[{role:"user",content:i}],stream:!0,...e.maxResults!==void 0&&{max_num_results:e.maxResults}},"ai-search",r,e.request);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);if(!n.body)throw new Error("Response body is empty");let c="";const h=n.body.getReader(),m=new TextDecoder;for(;;){const{done:v,value:x}=await h.read();if(v)break;const ne=m.decode(x,{stream:!0});c+=ne}yield{type:"result",id:"",title:"",description:c.replaceAll("data: ","").trim().split(`
|
|
2
2
|
|
|
3
|
-
`).map(
|
|
3
|
+
`).map(v=>JSON.parse(v)).map(v=>v.response).join(""),url:"",metadata:{}}}async*chat(i,e){const t=new AbortController,s=e?.signal||t.signal,r=await this.request({messages:[{role:"user",content:i}],stream:!1},"chat/completions",s);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);if(!r.body)throw new Error("Response body is empty");yield{type:"text",message:(await r.json()).choices.map(c=>c.message.content).join("")}}cancelRequest(i){const e=this.activeRequests.get(i);e&&(e.controller.abort(),this.unregisterRequest(i))}cancelAllRequests(){for(const[i]of this.activeRequests)this.cancelRequest(i)}registerRequest(i,e){this.activeRequests.set(i,{id:i,controller:e,timestamp:Date.now()})}unregisterRequest(i){this.activeRequests.delete(i)}generateRequestId(){return`req-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}const L=`Powered by <a href="https://workers.cloudflare.com/product/ai-search" target="_blank" rel="noopener noreferrer">Cloudflare AI Search <svg width="32" height="10" viewBox="0 0 412 186" xmlns="http://www.w3.org/2000/svg" aria-label="Cloudflare" role="img">
|
|
4
4
|
<path fill="#f38020" d="m280.8395,183.31456c11,-26 -4,-38 -19,-38l-148,-2c-4,0 -4,-6 1,-7l150,-2c17,-1 37,-15 43,-33c0,0 10,-21 9,-24a97,97 0 0 0 -187,-11c-38,-25 -78,9 -69,46c-48,3 -65,46 -60,72c0,1 1,2 3,2l274,0c1,0 3,-1 3,-3z"/>
|
|
5
5
|
<path fill="#faae40" d="m330.8395,81.31456c-4,0 -6,-1 -7,1l-5,21c-5,16 3,30 20,31l32,2c4,0 4,6 -1,7l-33,1c-36,4 -46,39 -46,39c0,2 0,3 2,3l113,0l3,-2a81,81 0 0 0 -78,-103"/>
|
|
6
|
-
</svg></a>`,
|
|
6
|
+
</svg></a>`,D=`
|
|
7
7
|
/* Chat container */
|
|
8
8
|
.chat-container {
|
|
9
9
|
display: flex;
|
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
.chat-message-bubble a:hover {
|
|
321
321
|
text-decoration: none;
|
|
322
322
|
}
|
|
323
|
-
`,
|
|
323
|
+
`,T=`
|
|
324
324
|
:host {
|
|
325
325
|
/* Colors - Light Mode */
|
|
326
326
|
--search-snippet-primary-color: #2563eb;
|
|
@@ -754,61 +754,53 @@
|
|
|
754
754
|
padding: var(--search-snippet-spacing-xs) 0;
|
|
755
755
|
text-align: center;
|
|
756
756
|
}
|
|
757
|
-
`;function
|
|
758
|
-
`),t=[];let s=!1,r="";for(let
|
|
759
|
-
`)}function
|
|
757
|
+
`;function se(l){let i=l;i=ie(i),i=i.replace(/```([\s\S]*?)```/g,(n,c)=>`<pre><code>${c.trim()}</code></pre>`);const e=i.split(`
|
|
758
|
+
`),t=[];let s=!1,r="";for(let n=0;n<e.length;n++){const c=e[n],h=c.match(/^(#{1,6})\s+(.+)$/);if(h){const v=h[1].length,x=h[2];t.push(`<h${v}>${S(x)}</h${v}>`);continue}if(c.match(/^---+$/)){t.push("<hr />");continue}if(c.match(/^>\s+/)){const v=c.replace(/^>\s+/,"");t.push(`<blockquote>${S(v)}</blockquote>`);continue}const m=c.match(/^[-*]\s+(.+)$/);if(m){(!s||r!=="ul")&&(s&&t.push(`</${r}>`),t.push("<ul>"),s=!0,r="ul"),t.push(`<li>${S(m[1])}</li>`);continue}const y=c.match(/^\d+\.\s+(.+)$/);if(y){(!s||r!=="ol")&&(s&&t.push(`</${r}>`),t.push("<ol>"),s=!0,r="ol"),t.push(`<li>${S(y[1])}</li>`);continue}if(s&&(t.push(`</${r}>`),s=!1,r=""),c.trim()===""){t.push("<br />");continue}t.push(`<p>${S(c)}</p>`)}return s&&t.push(`</${r}>`),t.join(`
|
|
759
|
+
`)}function S(l){let i=l;return i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),i=i.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/__(.+?)__/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/_(.+?)_/g,"<em>$1</em>"),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),i}function ie(l){const i={"&":"&","<":"<",">":">",'"':""","'":"'"};return l.replace(/[&<>"']/g,e=>i[e]||e)}class N{constructor(i,e,t){a(this,"container");a(this,"client");a(this,"props");a(this,"translations");a(this,"inputElement",null);a(this,"messagesContainer",null);a(this,"sendButton",null);a(this,"messages",[]);a(this,"isStreaming",!1);a(this,"currentStreamingMessageId",null);a(this,"loadingMessageInterval",null);a(this,"loadingMessageIndex",0);a(this,"handleInputResize",null);a(this,"handleInputKeydown",null);a(this,"handleSendClick",null);this.container=i,this.client=e,this.props=t,this.translations=d(t.translations),this.render(),this.attachEventListeners()}render(){const i=this.translations;this.container.innerHTML=`
|
|
760
760
|
<div class="chat-container">
|
|
761
761
|
<div class="chat-messages">
|
|
762
|
-
|
|
763
|
-
<svg class="chat-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
764
|
-
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
765
|
-
</svg>
|
|
766
|
-
<div class="chat-empty-title">Start a Conversation</div>
|
|
767
|
-
<div class="chat-empty-description">
|
|
768
|
-
Send a message to begin chatting
|
|
769
|
-
</div>
|
|
770
|
-
</div>
|
|
762
|
+
${this.renderEmptyStateHTML()}
|
|
771
763
|
</div>
|
|
772
764
|
<div class="chat-input-area">
|
|
773
765
|
<div class="chat-input-wrapper">
|
|
774
766
|
<textarea
|
|
775
767
|
class="chat-input"
|
|
776
|
-
placeholder="${
|
|
777
|
-
aria-label="
|
|
768
|
+
placeholder="${o(this.props.placeholder||i.chatPlaceholder)}"
|
|
769
|
+
aria-label="${o(i.chatInputAriaLabel)}"
|
|
778
770
|
style="height: 40px;"
|
|
779
771
|
rows="1"
|
|
780
772
|
></textarea>
|
|
781
|
-
<button class="button chat-send-button" aria-label="
|
|
782
|
-
<span
|
|
773
|
+
<button class="button chat-send-button" aria-label="${o(i.sendButtonAriaLabel)}">
|
|
774
|
+
<span>${o(i.sendButtonLabel)}</span>
|
|
783
775
|
</button>
|
|
784
776
|
</div>
|
|
785
777
|
</div>
|
|
786
778
|
</div>
|
|
787
|
-
`,this.messagesContainer=this.container.querySelector(".chat-messages"),this.inputElement=this.container.querySelector(".chat-input"),this.sendButton=this.container.querySelector(".chat-send-button")}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
</div>
|
|
779
|
+
`,this.messagesContainer=this.container.querySelector(".chat-messages"),this.inputElement=this.container.querySelector(".chat-input"),this.sendButton=this.container.querySelector(".chat-send-button")}renderEmptyStateHTML(){const i=this.translations;return`
|
|
780
|
+
<div class="chat-empty">
|
|
781
|
+
<svg class="chat-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
782
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
783
|
+
</svg>
|
|
784
|
+
<div class="chat-empty-title">${o(i.chatEmptyTitle)}</div>
|
|
785
|
+
<div class="chat-empty-description">
|
|
786
|
+
${o(i.chatEmptyDescription)}
|
|
796
787
|
</div>
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
788
|
+
</div>
|
|
789
|
+
`}attachEventListeners(){!this.inputElement||!this.sendButton||(this.handleInputResize=i=>{const e=i.target;e.style.height="auto",e.style.height=`${e.scrollHeight}px`},this.inputElement.addEventListener("input",this.handleInputResize),this.handleInputKeydown=i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),this.handleSendMessage())},this.inputElement.addEventListener("keydown",this.handleInputKeydown),this.handleSendClick=()=>{this.handleSendMessage()},this.sendButton.addEventListener("click",this.handleSendClick))}async handleSendMessage(){if(!this.inputElement||this.isStreaming)return;const i=this.inputElement.value.trim();i.length!==0&&(this.inputElement.value="",this.inputElement.style.height="auto",await this.sendMessage(i))}async sendMessage(i){const e={id:B("msg"),role:"user",content:i,timestamp:Date.now()};this.addMessage(e),this.renderMessages(!0),this.setStreamingState(!0);const t=B("msg"),s={id:t,role:"assistant",content:"",timestamp:Date.now()};this.addMessage(s),this.currentStreamingMessageId=t,this.renderMessages(!0);try{const r=this.client.chat(i);let n="";for await(const h of r)if(h.type==="text"&&h.message)n+=h.message,this.updateStreamingMessage(t,n);else if(h.type==="error"){this.showErrorInMessage(t,h.message||this.translations.unknownError);break}const c=this.messages.findIndex(h=>h.id===t);c!==-1&&(this.messages[c].content=n),this.container.dispatchEvent(f("message",{message:s}))}catch(r){this.showErrorInMessage(t,r.message),this.container.dispatchEvent(f("error",{error:{message:r.message,code:"CHAT_ERROR"}}))}finally{this.setStreamingState(!1),this.renderMessages(),this.currentStreamingMessageId=null}}addMessage(i){this.messages.push(i),this.renderMessages()}updateStreamingMessage(i,e){const t=this.messages.findIndex(s=>s.id===i);t!==-1&&(this.messages[t].content=e,this.renderMessages(!0))}showErrorInMessage(i,e){const t=this.messages.findIndex(s=>s.id===i);t!==-1&&(this.messages[t].content=`${this.translations.errorPrefix} ${e}`,this.renderMessages())}renderMessages(i=!1){if(!this.messagesContainer)return;if(this.messages.length===0){this.messagesContainer.innerHTML=this.renderEmptyStateHTML();return}const e=this.messages.map(t=>this.renderMessage(t,i&&t.id===this.currentStreamingMessageId)).join("");this.messagesContainer.innerHTML=e,this.scrollToBottom()}renderMessage(i,e=!1){const t=this.translations,s=`chat-message-${i.role}`,r=i.role==="user"?t.userAvatar:t.assistantAvatar,n=t.loadingMessages[this.loadingMessageIndex]??"";return`
|
|
790
|
+
<div class="chat-message ${s}">
|
|
791
|
+
<div class="chat-message-avatar">${o(r)}</div>
|
|
800
792
|
<div class="chat-message-content">
|
|
801
793
|
<div class="chat-message-bubble">
|
|
802
|
-
${i.content?`<div class="chat-message-text">${
|
|
803
|
-
${e?`<div class="chat-streaming"><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="loading-text">${
|
|
794
|
+
${i.content?`<div class="chat-message-text">${se(i.content)}</div>`:""}
|
|
795
|
+
${e?`<div class="chat-streaming"><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="loading-text">${o(n)}</span></div>`:""}
|
|
804
796
|
</div>
|
|
805
797
|
<div class="chat-message-metadata">
|
|
806
|
-
<span class="chat-message-time">${
|
|
798
|
+
<span class="chat-message-time">${o(X(i.timestamp,this.translations))}</span>
|
|
807
799
|
</div>
|
|
808
800
|
</div>
|
|
809
801
|
</div>
|
|
810
|
-
`}scrollToBottom(){this.messagesContainer&&requestAnimationFrame(()=>{this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)})}setStreamingState(i){this.isStreaming=i,this.inputElement&&(this.inputElement.disabled=i),this.sendButton&&(this.sendButton.disabled=i,this.sendButton.innerHTML=i?'<div class="loading"></div>'
|
|
811
|
-
${
|
|
802
|
+
`}scrollToBottom(){this.messagesContainer&&requestAnimationFrame(()=>{this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)})}setStreamingState(i){this.isStreaming=i,this.inputElement&&(this.inputElement.disabled=i),this.sendButton&&(this.sendButton.disabled=i,this.sendButton.innerHTML=i?'<div class="loading"></div>':`<span>${o(this.translations.sendButtonLabel)}</span>`),i?this.startLoadingMessages():this.clearLoadingMessages()}startLoadingMessages(){this.clearLoadingMessages();const i=this.translations.loadingMessages;this.loadingMessageIndex=Math.floor(Math.random()*i.length),this.loadingMessageInterval=setInterval(()=>{const e=this.translations.loadingMessages;this.loadingMessageIndex=(this.loadingMessageIndex+1)%e.length,this.isStreaming&&this.renderMessages(!0)},A)}clearLoadingMessages(){this.loadingMessageInterval&&(clearInterval(this.loadingMessageInterval),this.loadingMessageInterval=null)}getMessages(){return[...this.messages]}clearMessages(){this.messages=[],this.renderMessages()}setMessages(i){this.messages=[...i],this.renderMessages()}setProps(i){this.props=i,this.translations=d(i.translations),this.detachEventListeners(),this.render(),this.attachEventListeners(),this.renderMessages(this.isStreaming),this.isStreaming&&this.setStreamingState(!0)}detachEventListeners(){this.inputElement&&(this.handleInputResize&&this.inputElement.removeEventListener("input",this.handleInputResize),this.handleInputKeydown&&this.inputElement.removeEventListener("keydown",this.handleInputKeydown)),this.sendButton&&this.handleSendClick&&this.sendButton.removeEventListener("click",this.handleSendClick),this.handleInputResize=null,this.handleInputKeydown=null,this.handleSendClick=null}destroy(){this.clearLoadingMessages(),this.isStreaming&&this.client.cancelAllRequests(),this.inputElement&&(this.handleInputResize&&this.inputElement.removeEventListener("input",this.handleInputResize),this.handleInputKeydown&&this.inputElement.removeEventListener("keydown",this.handleInputKeydown)),this.sendButton&&this.handleSendClick&&this.sendButton.removeEventListener("click",this.handleSendClick),this.handleInputResize=null,this.handleInputKeydown=null,this.handleSendClick=null}}const P="chat-bubble-snippet";class U extends HTMLElement{constructor(){super();a(this,"shadow");a(this,"client",null);a(this,"chatView",null);a(this,"container",null);a(this,"isExpanded",!1);a(this,"isMinimized",!1);a(this,"translationsOverride",null);a(this,"resolvedTranslations",d(null));a(this,"handleBubbleClick",null);a(this,"handleCloseClick",null);a(this,"handleMinimizeClick",null);a(this,"handleClearClick",null);this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["api-url","placeholder","theme","hide-branding","translations"]}connectedCallback(){this.syncTranslationsFromAttribute(),this.render(),this.initializeClient(),this.dispatchEvent(f("ready",void 0))}disconnectedCallback(){this.cleanup()}attributeChangedCallback(e,t,s){t!==s&&(e==="api-url"?this.initializeClient():e==="theme"?this.updateTheme(s):e==="translations"&&(this.syncTranslationsFromAttribute(),this.isConnected&&this.rerenderAfterTranslationsChange()))}get translations(){return this.translationsOverride}set translations(e){this.translationsOverride=e??null,this.resolvedTranslations=d(this.translationsOverride),this.isConnected&&this.rerenderAfterTranslationsChange()}syncTranslationsFromAttribute(){if(this.translationsOverride){this.resolvedTranslations=d(this.translationsOverride);return}const e=E(this.getAttribute("translations"),"ChatBubbleSnippet");this.resolvedTranslations=d(e)}rerenderAfterTranslationsChange(){const e=this.isExpanded,t=this.isMinimized;this.removeEventListeners();const s=this.chatView?this.shadow.querySelector(".chat-content"):null;s?.parentNode&&s.parentNode.removeChild(s),this.render(),e&&(this.shadow.querySelector(".bubble-button")?.classList.add("hidden"),this.shadow.querySelector(".chat-window")?.classList.add("expanded"),t&&this.shadow.querySelector(".chat-window")?.classList.add("minimized"));const r=this.shadow.querySelector(".chat-window");if(this.chatView&&s&&r){const n=r.querySelector(".chat-content");n?r.replaceChild(s,n):r.appendChild(s),this.chatView.setProps(this.getProps())}else e&&this.initializeChatView()}getProps(){const e=this.resolvedTranslations;return{apiUrl:g(this.getAttribute("api-url"),""),placeholder:g(this.getAttribute("placeholder"),e.chatPlaceholder),theme:g(this.getAttribute("theme"),"auto"),hideBranding:b(this.getAttribute("hide-branding"),!1),translations:this.translationsOverride??void 0}}initializeClient(){const e=this.getProps();if(!e.apiUrl){console.error("ChatBubbleSnippet: api-url attribute is required"),this.client=null;return}try{this.client=M(e.apiUrl)}catch(t){console.error("ChatBubbleSnippet:",t)}}render(){const e=document.createElement("style");e.textContent=`${T}
|
|
803
|
+
${D}
|
|
812
804
|
${this.getBubbleStyles()}`,this.container=document.createElement("div"),this.container.className="chat-bubble-widget",this.container.innerHTML=this.getBaseHTML(),this.shadow.innerHTML="",this.shadow.appendChild(e),this.shadow.appendChild(this.container),this.attachEventListeners()}getBubbleStyles(){return`
|
|
813
805
|
.chat-bubble-widget {
|
|
814
806
|
position: var(--chat-bubble-position);
|
|
@@ -947,8 +939,8 @@ ${this.getBubbleStyles()}`,this.container=document.createElement("div"),this.con
|
|
|
947
939
|
max-width: 400px;
|
|
948
940
|
}
|
|
949
941
|
}
|
|
950
|
-
`}getBaseHTML(){return`
|
|
951
|
-
<button class="bubble-button" aria-label="
|
|
942
|
+
`}getBaseHTML(){const e=this.getProps(),t=this.resolvedTranslations,s=e.hideBranding?"":`<div class="powered-by">${L}</div>`;return`
|
|
943
|
+
<button class="bubble-button" aria-label="${o(t.openChatAriaLabel)}">
|
|
952
944
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
953
945
|
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
954
946
|
</svg>
|
|
@@ -959,21 +951,21 @@ ${this.getBubbleStyles()}`,this.container=document.createElement("div"),this.con
|
|
|
959
951
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
960
952
|
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
961
953
|
</svg>
|
|
962
|
-
<span
|
|
954
|
+
<span>${o(t.chatTitle)}</span>
|
|
963
955
|
</div>
|
|
964
956
|
<div class="chat-header-actions">
|
|
965
|
-
<button class="icon-button clear-button" aria-label="
|
|
957
|
+
<button class="icon-button clear-button" aria-label="${o(t.clearHistoryAriaLabel)}">
|
|
966
958
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
967
959
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
968
960
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
969
961
|
</svg>
|
|
970
962
|
</button>
|
|
971
|
-
<button class="icon-button minimize-button" aria-label="
|
|
963
|
+
<button class="icon-button minimize-button" aria-label="${o(t.minimizeAriaLabel)}">
|
|
972
964
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
973
965
|
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
974
966
|
</svg>
|
|
975
967
|
</button>
|
|
976
|
-
<button class="icon-button close-button" aria-label="
|
|
968
|
+
<button class="icon-button close-button" aria-label="${o(t.closeAriaLabel)}">
|
|
977
969
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
978
970
|
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
979
971
|
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
@@ -982,14 +974,14 @@ ${this.getBubbleStyles()}`,this.container=document.createElement("div"),this.con
|
|
|
982
974
|
</div>
|
|
983
975
|
</div>
|
|
984
976
|
<div class="chat-content"></div>
|
|
985
|
-
${
|
|
977
|
+
${s}
|
|
986
978
|
</div>
|
|
987
|
-
`}attachEventListeners(){const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".close-button"),s=this.shadow.querySelector(".minimize-button"),r=this.shadow.querySelector(".clear-button");this.handleBubbleClick=()=>this.toggleChat(),this.handleCloseClick=()=>this.closeChat(),this.handleMinimizeClick=()=>this.toggleMinimize(),this.handleClearClick=()=>this.clearChat(),e?.addEventListener("click",this.handleBubbleClick),t?.addEventListener("click",this.handleCloseClick),s?.addEventListener("click",this.handleMinimizeClick),r?.addEventListener("click",this.handleClearClick)}removeEventListeners(){const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".close-button"),s=this.shadow.querySelector(".minimize-button"),r=this.shadow.querySelector(".clear-button");this.handleBubbleClick&&e?.removeEventListener("click",this.handleBubbleClick),this.handleCloseClick&&t?.removeEventListener("click",this.handleCloseClick),this.handleMinimizeClick&&s?.removeEventListener("click",this.handleMinimizeClick),this.handleClearClick&&r?.removeEventListener("click",this.handleClearClick),this.handleBubbleClick=null,this.handleCloseClick=null,this.handleMinimizeClick=null,this.handleClearClick=null}toggleChat(){this.isExpanded=!this.isExpanded;const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".chat-window");this.isExpanded?(e?.classList.add("hidden"),t?.classList.add("expanded"),this.initializeChatView()):(e?.classList.remove("hidden"),t?.classList.remove("expanded"))}closeChat(){this.isExpanded=!1,this.isMinimized=!1;const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".chat-window");e?.classList.remove("hidden"),t?.classList.remove("expanded","minimized")}toggleMinimize(){this.isMinimized=!this.isMinimized;const e=this.shadow.querySelector(".chat-window");this.isMinimized?e?.classList.add("minimized"):e?.classList.remove("minimized")}initializeChatView(){if(this.chatView)return;const e=this.shadow.querySelector(".chat-content");if(!e)return;if(!this.client){e.innerHTML=`
|
|
979
|
+
`}attachEventListeners(){const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".close-button"),s=this.shadow.querySelector(".minimize-button"),r=this.shadow.querySelector(".clear-button");this.handleBubbleClick=()=>this.toggleChat(),this.handleCloseClick=()=>this.closeChat(),this.handleMinimizeClick=()=>this.toggleMinimize(),this.handleClearClick=()=>this.clearChat(),e?.addEventListener("click",this.handleBubbleClick),t?.addEventListener("click",this.handleCloseClick),s?.addEventListener("click",this.handleMinimizeClick),r?.addEventListener("click",this.handleClearClick)}removeEventListeners(){const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".close-button"),s=this.shadow.querySelector(".minimize-button"),r=this.shadow.querySelector(".clear-button");this.handleBubbleClick&&e?.removeEventListener("click",this.handleBubbleClick),this.handleCloseClick&&t?.removeEventListener("click",this.handleCloseClick),this.handleMinimizeClick&&s?.removeEventListener("click",this.handleMinimizeClick),this.handleClearClick&&r?.removeEventListener("click",this.handleClearClick),this.handleBubbleClick=null,this.handleCloseClick=null,this.handleMinimizeClick=null,this.handleClearClick=null}toggleChat(){this.isExpanded=!this.isExpanded;const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".chat-window");this.isExpanded?(e?.classList.add("hidden"),t?.classList.add("expanded"),this.initializeChatView()):(e?.classList.remove("hidden"),t?.classList.remove("expanded"))}closeChat(){this.isExpanded=!1,this.isMinimized=!1;const e=this.shadow.querySelector(".bubble-button"),t=this.shadow.querySelector(".chat-window");e?.classList.remove("hidden"),t?.classList.remove("expanded","minimized")}toggleMinimize(){this.isMinimized=!this.isMinimized;const e=this.shadow.querySelector(".chat-window");this.isMinimized?e?.classList.add("minimized"):e?.classList.remove("minimized")}initializeChatView(){if(this.chatView)return;const e=this.shadow.querySelector(".chat-content");if(!e)return;if(!this.client){const s=this.resolvedTranslations;e.innerHTML=`
|
|
988
980
|
<div style="padding: 16px; color: var(--search-snippet-error-color, #ef4444); font-family: var(--search-snippet-font-family, sans-serif); font-size: var(--search-snippet-font-size-base, 14px);">
|
|
989
|
-
<strong
|
|
981
|
+
<strong>${o(s.errorPrefix)}</strong> ${o(s.missingApiUrlError)}
|
|
990
982
|
</div>
|
|
991
|
-
`;return}const t=this.getProps();this.chatView=new
|
|
992
|
-
${
|
|
983
|
+
`;return}const t=this.getProps();this.chatView=new N(e,this.client,t)}updateTheme(e){(e==="light"||e==="dark"?e:null)===null&&this.hasAttribute("theme")&&this.getAttribute("theme")!=="auto"&&this.removeAttribute("theme")}cleanup(){this.removeEventListeners(),this.client&&this.client.cancelAllRequests(),this.chatView&&this.chatView.destroy()}clearChat(){this.chatView?.clearMessages()}async sendMessage(e){this.chatView&&await this.chatView.sendMessage(e)}getMessages(){return this.chatView?.getMessages()||[]}}customElements.get(P)||customElements.define(P,U);const j="chat-page-snippet",_="chat-page-sessions";class V extends HTMLElement{constructor(){super();a(this,"shadow");a(this,"client",null);a(this,"chatView",null);a(this,"container",null);a(this,"sessions",[]);a(this,"currentSessionId",null);a(this,"sidebarCollapsed",!1);a(this,"translationsOverride",null);a(this,"resolvedTranslations",d(null));a(this,"handleClearClick",null);a(this,"handleNewChatClick",null);a(this,"handleToggleSidebarClick",null);a(this,"handleChatListClick",null);a(this,"handleMessageEvent",null);this.shadow=this.attachShadow({mode:"open"}),this.loadSessions()}static get observedAttributes(){return["api-url","placeholder","theme","hide-branding","translations"]}connectedCallback(){this.syncTranslationsFromAttribute(),this.render(),this.initializeClient(),this.setupView(),this.dispatchEvent(f("ready",void 0))}disconnectedCallback(){this.saveCurrentSession(),this.cleanup()}attributeChangedCallback(e,t,s){t!==s&&(e==="api-url"?(this.initializeClient(),this.setupView()):e==="theme"?this.updateTheme(s):e==="translations"&&(this.syncTranslationsFromAttribute(),this.isConnected&&this.rerenderAfterTranslationsChange()))}get translations(){return this.translationsOverride}set translations(e){this.translationsOverride=e??null,this.resolvedTranslations=d(this.translationsOverride),this.refreshDefaultSessionTitles(),this.isConnected&&this.rerenderAfterTranslationsChange()}syncTranslationsFromAttribute(){if(this.translationsOverride){this.resolvedTranslations=d(this.translationsOverride),this.refreshDefaultSessionTitles();return}const e=E(this.getAttribute("translations"),"ChatPageSnippet");this.resolvedTranslations=d(e),this.refreshDefaultSessionTitles()}refreshDefaultSessionTitles(){if(this.sessions.length===0)return;const e=this.resolvedTranslations.newChatButton;let t=!1;for(const s of this.sessions)s.titleIsDefault&&s.title!==e&&(s.title=e,t=!0);t&&this.saveSessions()}rerenderAfterTranslationsChange(){this.removeEventListeners();const e=this.chatView?this.shadow.querySelector(".container"):null;e?.parentNode&&e.parentNode.removeChild(e),this.render(),this.attachEventListeners(),this.renderChatList();const t=this.shadow.querySelector(".chat-page-content");if(this.chatView&&e&&t){const s=t.querySelector(".container");s?t.replaceChild(e,s):t.appendChild(e),this.chatView.setProps(this.getProps()),this.handleMessageEvent=()=>{this.saveCurrentSession(),this.updateSessionTitle(),this.renderChatList()},e.addEventListener("message",this.handleMessageEvent)}}getProps(){const e=this.resolvedTranslations;return{apiUrl:g(this.getAttribute("api-url"),""),placeholder:g(this.getAttribute("placeholder"),e.chatPlaceholder),theme:g(this.getAttribute("theme"),"auto"),hideBranding:b(this.getAttribute("hide-branding"),!1),translations:this.translationsOverride??void 0}}initializeClient(){const e=this.getProps();if(!e.apiUrl){console.error("ChatPageSnippet: api-url attribute is required"),this.client=null;return}try{this.client=M(e.apiUrl)}catch(t){console.error("ChatPageSnippet:",t)}}render(){const e=document.createElement("style");e.textContent=`${T}
|
|
984
|
+
${D}
|
|
993
985
|
${this.getPageStyles()}`,this.container=document.createElement("div"),this.container.className="chat-page-container",this.container.innerHTML=this.getBaseHTML(),this.shadow.innerHTML="",this.shadow.appendChild(e),this.shadow.appendChild(this.container),this.attachEventListeners()}getPageStyles(){return`
|
|
994
986
|
:host {
|
|
995
987
|
display: block;
|
|
@@ -1263,24 +1255,24 @@ ${this.getPageStyles()}`,this.container=document.createElement("div"),this.conta
|
|
|
1263
1255
|
background: var(--search-snippet-background);
|
|
1264
1256
|
border-radius: 0;
|
|
1265
1257
|
}
|
|
1266
|
-
`}getBaseHTML(){return`
|
|
1258
|
+
`}getBaseHTML(){const e=this.getProps(),t=this.resolvedTranslations,s=e.hideBranding?"":`<div class="powered-by">${L}</div>`;return`
|
|
1267
1259
|
<div class="chat-sidebar">
|
|
1268
1260
|
<div class="sidebar-header">
|
|
1269
|
-
<span class="sidebar-title"
|
|
1261
|
+
<span class="sidebar-title">${o(t.historyTitle)}</span>
|
|
1270
1262
|
</div>
|
|
1271
1263
|
<button class="new-chat-button">
|
|
1272
1264
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1273
1265
|
<path d="M12 5v14M5 12h14"></path>
|
|
1274
1266
|
</svg>
|
|
1275
|
-
|
|
1267
|
+
${o(t.newChatButton)}
|
|
1276
1268
|
</button>
|
|
1277
1269
|
<div class="chat-list"></div>
|
|
1278
|
-
${
|
|
1270
|
+
${s}
|
|
1279
1271
|
</div>
|
|
1280
1272
|
<div class="chat-main">
|
|
1281
1273
|
<div class="chat-page-header">
|
|
1282
1274
|
<div class="chat-page-header-left">
|
|
1283
|
-
<button class="toggle-sidebar-button" title="
|
|
1275
|
+
<button class="toggle-sidebar-button" title="${o(t.toggleSidebarTitle)}">
|
|
1284
1276
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1285
1277
|
<path d="M3 12h18M3 6h18M3 18h18"></path>
|
|
1286
1278
|
</svg>
|
|
@@ -1289,7 +1281,7 @@ ${this.getPageStyles()}`,this.container=document.createElement("div"),this.conta
|
|
|
1289
1281
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1290
1282
|
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
1291
1283
|
</svg>
|
|
1292
|
-
<span
|
|
1284
|
+
<span>${o(t.chatTitle)}</span>
|
|
1293
1285
|
</div>
|
|
1294
1286
|
</div>
|
|
1295
1287
|
<div class="chat-page-header-actions">
|
|
@@ -1297,7 +1289,7 @@ ${this.getPageStyles()}`,this.container=document.createElement("div"),this.conta
|
|
|
1297
1289
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1298
1290
|
<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1299
1291
|
</svg>
|
|
1300
|
-
|
|
1292
|
+
${o(t.clearChatButton)}
|
|
1301
1293
|
</button>
|
|
1302
1294
|
</div>
|
|
1303
1295
|
</div>
|
|
@@ -1305,23 +1297,23 @@ ${this.getPageStyles()}`,this.container=document.createElement("div"),this.conta
|
|
|
1305
1297
|
<div class="container"></div>
|
|
1306
1298
|
</div>
|
|
1307
1299
|
</div>
|
|
1308
|
-
`}attachEventListeners(){const e=this.shadow.querySelector(".clear-button"),t=this.shadow.querySelector(".new-chat-button"),s=this.shadow.querySelector(".toggle-sidebar-button"),r=this.shadow.querySelector(".chat-list");this.handleClearClick=()=>this.clearCurrentChat(),this.handleNewChatClick=()=>this.createNewChat(),this.handleToggleSidebarClick=()=>this.toggleSidebar(),this.handleChatListClick=
|
|
1300
|
+
`}attachEventListeners(){const e=this.shadow.querySelector(".clear-button"),t=this.shadow.querySelector(".new-chat-button"),s=this.shadow.querySelector(".toggle-sidebar-button"),r=this.shadow.querySelector(".chat-list");this.handleClearClick=()=>this.clearCurrentChat(),this.handleNewChatClick=()=>this.createNewChat(),this.handleToggleSidebarClick=()=>this.toggleSidebar(),this.handleChatListClick=n=>this.onChatListClick(n),e?.addEventListener("click",this.handleClearClick),t?.addEventListener("click",this.handleNewChatClick),s?.addEventListener("click",this.handleToggleSidebarClick),r?.addEventListener("click",this.handleChatListClick)}removeEventListeners(){const e=this.shadow.querySelector(".clear-button"),t=this.shadow.querySelector(".new-chat-button"),s=this.shadow.querySelector(".toggle-sidebar-button"),r=this.shadow.querySelector(".chat-list"),n=this.shadow.querySelector(".container");this.handleClearClick&&e?.removeEventListener("click",this.handleClearClick),this.handleNewChatClick&&t?.removeEventListener("click",this.handleNewChatClick),this.handleToggleSidebarClick&&s?.removeEventListener("click",this.handleToggleSidebarClick),this.handleChatListClick&&r?.removeEventListener("click",this.handleChatListClick),this.handleMessageEvent&&n&&n.removeEventListener("message",this.handleMessageEvent),this.handleClearClick=null,this.handleNewChatClick=null,this.handleToggleSidebarClick=null,this.handleChatListClick=null,this.handleMessageEvent=null}setupView(){const e=this.shadow.querySelector(".container");if(!this.client){if(e){const s=this.resolvedTranslations;e.innerHTML=`
|
|
1309
1301
|
<div style="padding: 16px; color: var(--search-snippet-error-color, #ef4444); font-family: var(--search-snippet-font-family, sans-serif); font-size: var(--search-snippet-font-size-base, 14px);">
|
|
1310
|
-
<strong
|
|
1302
|
+
<strong>${o(s.errorPrefix)}</strong> ${o(s.missingApiUrlError)}
|
|
1311
1303
|
</div>
|
|
1312
|
-
`
|
|
1304
|
+
`}return}if(!e)return;const t=this.getProps();if(this.chatView=new N(e,this.client,t),this.sessions.length===0)this.createNewChat();else{const s=this.sessions[0];this.switchToSession(s.id)}this.handleMessageEvent=()=>{this.saveCurrentSession(),this.updateSessionTitle(),this.renderChatList()},e.addEventListener("message",this.handleMessageEvent),this.renderChatList()}generateSessionId(){return`session_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}loadSessions(){try{const e=localStorage.getItem(_);e&&(this.sessions=JSON.parse(e),this.sessions.sort((t,s)=>s.updatedAt-t.updatedAt))}catch(e){console.error("Failed to load chat sessions:",e)}}saveSessions(){try{localStorage.setItem(_,JSON.stringify(this.sessions))}catch(e){console.error("Failed to save chat sessions:",e)}}saveCurrentSession(){if(!this.currentSessionId||!this.chatView)return;const e=this.sessions.findIndex(t=>t.id===this.currentSessionId);e!==-1&&(this.sessions[e].messages=this.chatView.getMessages(),this.sessions[e].updatedAt=Date.now(),this.saveSessions())}updateSessionTitle(){if(!this.currentSessionId)return;const e=this.sessions.find(r=>r.id===this.currentSessionId);if(!e||e.messages.length===0||!(e.titleIsDefault??e.title===this.resolvedTranslations.newChatButton))return;const s=e.messages.find(r=>r.role==="user");s&&(e.title=s.content.slice(0,50)+(s.content.length>50?"...":""),e.titleIsDefault=!1,this.saveSessions())}createNewChat(){this.saveCurrentSession();const e={id:this.generateSessionId(),title:this.resolvedTranslations.newChatButton,messages:[],createdAt:Date.now(),updatedAt:Date.now(),titleIsDefault:!0};this.sessions.unshift(e),this.currentSessionId=e.id,this.saveSessions(),this.chatView?.clearMessages(),this.renderChatList()}switchToSession(e){if(e===this.currentSessionId)return;this.saveCurrentSession();const t=this.sessions.find(s=>s.id===e);t&&this.chatView&&(this.currentSessionId=e,this.chatView.setMessages(t.messages),this.renderChatList())}deleteSession(e){const t=this.sessions.findIndex(s=>s.id===e);t!==-1&&(this.sessions.splice(t,1),this.saveSessions(),e===this.currentSessionId&&(this.sessions.length>0?this.switchToSession(this.sessions[0].id):this.createNewChat()),this.renderChatList())}clearCurrentChat(){if(!this.currentSessionId)return;const e=this.sessions.find(t=>t.id===this.currentSessionId);e&&(e.messages=[],e.title=this.resolvedTranslations.newChatButton,e.titleIsDefault=!0,e.updatedAt=Date.now(),this.saveSessions()),this.chatView?.clearMessages(),this.renderChatList()}toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed,this.shadow.querySelector(".chat-sidebar")?.classList.toggle("collapsed",this.sidebarCollapsed)}onChatListClick(e){const t=e.target,s=t.closest(".chat-list-item-delete");if(s){e.stopPropagation();const n=s.getAttribute("data-session-id");n&&this.deleteSession(n);return}const r=t.closest(".chat-list-item");if(r){const n=r.getAttribute("data-session-id");n&&this.switchToSession(n)}}renderChatList(){const e=this.shadow.querySelector(".chat-list");if(!e)return;const t=this.resolvedTranslations;if(this.sessions.length===0){e.innerHTML=`<div class="chat-list-empty">${this.escapeHTML(t.noChatsYet)}</div>`;return}e.innerHTML=this.sessions.map(s=>this.renderChatListItem(s)).join("")}renderChatListItem(e){const t=e.id===this.currentSessionId,s=this.formatDate(e.updatedAt),r=this.resolvedTranslations.deleteChatTitle;return`
|
|
1313
1305
|
<div class="chat-list-item ${t?"active":""}" data-session-id="${e.id}">
|
|
1314
1306
|
<div class="chat-list-item-content">
|
|
1315
1307
|
<div class="chat-list-item-title">${this.escapeHTML(e.title)}</div>
|
|
1316
1308
|
<div class="chat-list-item-date">${s}</div>
|
|
1317
1309
|
</div>
|
|
1318
|
-
<button class="chat-list-item-delete" data-session-id="${e.id}" title="
|
|
1310
|
+
<button class="chat-list-item-delete" data-session-id="${e.id}" title="${this.escapeHTML(r)}">
|
|
1319
1311
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1320
1312
|
<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1321
1313
|
</svg>
|
|
1322
1314
|
</button>
|
|
1323
1315
|
</div>
|
|
1324
|
-
`}formatDate(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),
|
|
1316
|
+
`}formatDate(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),n=Math.floor(r/(1e3*60*60*24));return n===0?t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n===1?this.resolvedTranslations.yesterday:n<7?t.toLocaleDateString(void 0,{weekday:"long"}):t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}escapeHTML(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}updateTheme(e){(e==="light"||e==="dark"?e:null)===null&&this.hasAttribute("theme")&&this.getAttribute("theme")!=="auto"&&this.removeAttribute("theme")}cleanup(){this.removeEventListeners(),this.client&&this.client.cancelAllRequests(),this.chatView&&this.chatView.destroy()}clearChat(){this.clearCurrentChat()}async sendMessage(e){this.chatView&&(await this.chatView.sendMessage(e),this.saveCurrentSession())}getMessages(){return this.chatView?.getMessages()||[]}getSessions(){return[...this.sessions]}getCurrentSession(){return this.sessions.find(e=>e.id===this.currentSessionId)||null}}customElements.get(j)||customElements.define(j,V);const re=`
|
|
1325
1317
|
/* Search view states */
|
|
1326
1318
|
.search-view {
|
|
1327
1319
|
transition: var(--search-snippet-transition-slow);
|
|
@@ -1691,8 +1683,8 @@ a.search-result-item:focus-visible {
|
|
|
1691
1683
|
border-radius: 2px;
|
|
1692
1684
|
font-weight: var(--search-snippet-font-weight-medium);
|
|
1693
1685
|
}
|
|
1694
|
-
`,
|
|
1695
|
-
${
|
|
1686
|
+
`,K="search-bar-snippet",F=10,G=50;class I extends HTMLElement{constructor(){super();a(this,"shadow");a(this,"client",null);a(this,"container",null);a(this,"inputElement",null);a(this,"resultsContainer",null);a(this,"searchButton",null);a(this,"debouncedSearch",null);a(this,"currentSearchController",null);a(this,"loadingMessageInterval",null);a(this,"loadingMessageIndex",0);a(this,"translationsOverride",null);a(this,"resolvedTranslations",d(null));a(this,"handleInputChange",null);a(this,"handleInputKeydownEnter",null);a(this,"handleInputKeydownEscape",null);a(this,"handleSearchButtonClick",null);this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["api-url","placeholder","max-results","max-render-results","debounce-ms","theme","hide-branding","show-url","show-date","hide-thumbnails","see-more","request-options","translations"]}connectedCallback(){this.syncTranslationsFromAttribute(),this.initializeClient(),this.render(),this.dispatchEvent(f("ready",void 0))}disconnectedCallback(){this.cleanup()}attributeChangedCallback(e,t,s){t!==s&&(e==="api-url"?this.initializeClient():e==="theme"?this.updateTheme(s):e==="translations"&&(this.syncTranslationsFromAttribute(),this.isConnected&&this.rerender()))}get translations(){return this.translationsOverride}set translations(e){this.translationsOverride=e??null,this.resolvedTranslations=d(this.translationsOverride),this.isConnected&&this.rerender()}rerender(){const e=this.inputElement?.value??"";this.render(),e&&this.inputElement&&(this.inputElement.value=e,e.trim().length>0&&this.performSearch(e.trim()))}syncTranslationsFromAttribute(){if(this.translationsOverride){this.resolvedTranslations=d(this.translationsOverride);return}const e=E(this.getAttribute("translations"),"SearchBarSnippet");this.resolvedTranslations=d(e)}getProps(){const e=this.resolvedTranslations;return{apiUrl:g(this.getAttribute("api-url"),""),placeholder:g(this.getAttribute("placeholder"),e.placeholder),maxResults:C(this.getAttribute("max-results"),G),maxRenderResults:C(this.getAttribute("max-render-results"),F),debounceMs:C(this.getAttribute("debounce-ms"),300),theme:g(this.getAttribute("theme"),"auto"),hideBranding:b(this.getAttribute("hide-branding"),!1),showUrl:b(this.getAttribute("show-url"),!1),showDate:b(this.getAttribute("show-date"),!1),hideThumbnails:b(this.getAttribute("hide-thumbnails"),!1),seeMore:g(this.getAttribute("see-more"),""),translations:this.translationsOverride??void 0}}getRequestOptions(){const e=this.getAttribute("request-options");if(e)try{const t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))throw new Error("request-options must be a JSON object");return t}catch(t){console.error("SearchBarSnippet: invalid request-options attribute",t);return}}initializeClient(){const e=this.getProps();if(!e.apiUrl){console.error("SearchBarSnippet: api-url attribute is required"),this.client=null,this.showMissingApiUrlError();return}try{this.client=M(e.apiUrl)}catch(t){console.error("SearchBarSnippet:",t)}}render(){const e=this.getProps(),t=this.resolvedTranslations,s=n=>this.performSearch(n);this.debouncedSearch=z(s,e.debounceMs||400);const r=document.createElement("style");r.textContent=`${T}
|
|
1687
|
+
${re}`,this.container=document.createElement("div"),this.container.className="container",this.container.innerHTML=`
|
|
1696
1688
|
<div class="search-view">
|
|
1697
1689
|
<div class="search-input-wrapper">
|
|
1698
1690
|
<svg xmlns="http://www.w3.org/2000/svg" class="search-icon" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
|
|
@@ -1700,12 +1692,12 @@ ${X}`,this.container=document.createElement("div"),this.container.className="con
|
|
|
1700
1692
|
type="text"
|
|
1701
1693
|
name="search-input"
|
|
1702
1694
|
class="search-input"
|
|
1703
|
-
placeholder="${
|
|
1704
|
-
aria-label="
|
|
1695
|
+
placeholder="${o(e.placeholder||t.placeholder)}"
|
|
1696
|
+
aria-label="${o(t.searchInputAriaLabel)}"
|
|
1705
1697
|
autocomplete="off"
|
|
1706
1698
|
/>
|
|
1707
|
-
<button class="button search-submit-button" aria-label="
|
|
1708
|
-
<span
|
|
1699
|
+
<button class="button search-submit-button" aria-label="${o(t.searchButtonLabel)}">
|
|
1700
|
+
<span>${o(t.searchButtonLabel)}</span>
|
|
1709
1701
|
</button>
|
|
1710
1702
|
</div>
|
|
1711
1703
|
<div class="search-content">
|
|
@@ -1714,32 +1706,32 @@ ${X}`,this.container=document.createElement("div"),this.container.className="con
|
|
|
1714
1706
|
</div>
|
|
1715
1707
|
</div>
|
|
1716
1708
|
</div>
|
|
1717
|
-
`,this.shadow.innerHTML="",this.shadow.appendChild(
|
|
1718
|
-
<a href="${
|
|
1719
|
-
<span
|
|
1709
|
+
`,this.shadow.innerHTML="",this.shadow.appendChild(r),this.shadow.appendChild(this.container),this.inputElement=this.container.querySelector(".search-input"),this.resultsContainer=this.container.querySelector(".search-results-wrapper"),this.searchButton=this.container.querySelector(".search-submit-button"),this.attachEventListeners(),this.client||this.showMissingApiUrlError()}attachEventListeners(){this.inputElement&&(this.handleInputChange=e=>{const s=e.target.value.trim();s.length>0&&this.debouncedSearch?this.debouncedSearch(s):this.showEmptyState()},this.inputElement.addEventListener("input",this.handleInputChange),this.handleInputKeydownEnter=e=>{if(e.key==="Enter"){const t=e.target.value.trim();t.length>0&&this.performSearch(t)}},this.inputElement.addEventListener("keydown",this.handleInputKeydownEnter),this.handleInputKeydownEscape=e=>{e.key==="Escape"&&this.inputElement&&(this.inputElement.value="")},window.addEventListener("keydown",this.handleInputKeydownEscape),this.searchButton&&(this.handleSearchButtonClick=()=>{const e=this.inputElement?.value.trim()||"";e.length>0&&this.performSearch(e)},this.searchButton.addEventListener("click",this.handleSearchButtonClick)))}async performSearch(e){if(!this.client){this.showMissingApiUrlError();return}this.currentSearchController&&(this.currentSearchController.abort(),this.currentSearchController=null),this.currentSearchController=new AbortController,this.showLoadingState();try{const t=this.getProps(),s=await this.client.search(e,{signal:this.currentSearchController.signal,maxResults:t.maxResults||G,request:this.getRequestOptions()}),r=s.slice(0,t.maxRenderResults||F);this.displayResults(r,e,s.length)}catch(t){if(t.name==="AbortError")return;this.showErrorState(t.message)}finally{this.currentSearchController=null}}displayResults(e,t,s=e.length){if(this.clearLoadingInterval(),!this.resultsContainer)return;if(e.length===0){this.showNoResultsState(t);return}const r=this.getProps(),n=this.resolvedTranslations,c=r.hideBranding?"":`<div class="powered-by-inline">${L}</div>`,h=s>e.length,m=h?w(n.resultsCountOverflow,{n:e.length,total:s}):w(s===1?n.resultsCount:n.resultsCountPlural,{n:s}),y=r.seeMore&&h?`<div class="search-footer">
|
|
1710
|
+
<a href="${o(r.seeMore+encodeURIComponent(t))}" class="search-see-more">
|
|
1711
|
+
<span>${o(n.seeMoreResults)}</span>
|
|
1720
1712
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
|
|
1721
1713
|
</a>
|
|
1722
|
-
</div>`:"",
|
|
1714
|
+
</div>`:"",v=`
|
|
1723
1715
|
<div class="search-header">
|
|
1724
1716
|
<div class="search-count">
|
|
1725
|
-
${
|
|
1717
|
+
${o(m)}
|
|
1726
1718
|
</div>
|
|
1727
|
-
${
|
|
1719
|
+
${c}
|
|
1728
1720
|
</div>
|
|
1729
1721
|
<div class="search-results">
|
|
1730
|
-
${e.map(
|
|
1722
|
+
${e.map(x=>this.renderResult(x)).join("")}
|
|
1731
1723
|
</div>
|
|
1732
|
-
${
|
|
1733
|
-
`;this.resultsContainer.innerHTML=
|
|
1734
|
-
${t.showUrl&&e.url?`<span class="search-result-url">${
|
|
1724
|
+
${y}
|
|
1725
|
+
`;this.resultsContainer.innerHTML=v,this.attachResultHandlers()}renderResult(e){const t=this.getProps(),s=t.hideThumbnails?"":this.renderResultImage(e.image,e.title),r=e.url?o(e.url):"#",n=e.url?o($(e.url)):"",c=t.showDate&&e.timestamp!==void 0?`<div class="search-result-date">${o(q(e.timestamp))}</div>`:"",h=t.showUrl&&e.url||c?`<div class="search-result-metadata">
|
|
1726
|
+
${t.showUrl&&e.url?`<span class="search-result-url">${n}</span>`:'<span class="search-result-url search-result-url-empty"></span>'}
|
|
1735
1727
|
${c}
|
|
1736
1728
|
</div>`:"";return`
|
|
1737
|
-
<a href="${r}" class="search-result-item" data-result-id="${
|
|
1729
|
+
<a href="${r}" class="search-result-item" data-result-id="${o(e.url||"")}">
|
|
1738
1730
|
${s}
|
|
1739
1731
|
<div class="search-result-content">
|
|
1740
|
-
<div class="search-result-title">${
|
|
1741
|
-
<div class="search-result-snippet">${
|
|
1742
|
-
${
|
|
1732
|
+
<div class="search-result-title">${o(e.title||"")}</div>
|
|
1733
|
+
<div class="search-result-snippet">${o(e.description||"")}</div>
|
|
1734
|
+
${h}
|
|
1743
1735
|
</div>
|
|
1744
1736
|
</a>
|
|
1745
1737
|
`}renderResultImage(e,t){const s='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>';return e?`
|
|
@@ -1748,8 +1740,8 @@ ${X}`,this.container=document.createElement("div"),this.container.className="con
|
|
|
1748
1740
|
<div class="search-result-image-placeholder" style="display: none;">${s}</div>
|
|
1749
1741
|
<img
|
|
1750
1742
|
class="search-result-image"
|
|
1751
|
-
src="${
|
|
1752
|
-
alt="${
|
|
1743
|
+
src="${o(e)}"
|
|
1744
|
+
alt="${o(t)}"
|
|
1753
1745
|
loading="lazy"
|
|
1754
1746
|
/>
|
|
1755
1747
|
</div>
|
|
@@ -1757,38 +1749,38 @@ ${X}`,this.container=document.createElement("div"),this.container.className="con
|
|
|
1757
1749
|
<div class="search-result-image-container">
|
|
1758
1750
|
<div class="search-result-image-placeholder">${s}</div>
|
|
1759
1751
|
</div>
|
|
1760
|
-
`}attachResultHandlers(){const e=this.container?.querySelectorAll(".search-result-item");if(!e)return;for(const s of e)s.getAttribute("href")==="#"&&s.addEventListener("click",
|
|
1752
|
+
`}attachResultHandlers(){const e=this.container?.querySelectorAll(".search-result-item");if(!e)return;for(const s of e)s.getAttribute("href")==="#"&&s.addEventListener("click",n=>{n.preventDefault()});this.container?.querySelectorAll(".search-result-image")?.forEach(s=>{s.addEventListener("load",()=>{s.classList.add("loaded"),s.closest(".search-result-image-container")?.querySelector(".search-result-image-loading")?.remove()}),s.addEventListener("error",()=>{const r=s.closest(".search-result-image-container");r?.querySelector(".search-result-image-loading")?.remove();const n=r?.querySelector(".search-result-image-placeholder");n&&(n.style.display="flex"),s.style.display="none"})})}showLoadingState(){if(!this.resultsContainer)return;this.clearLoadingInterval();const e=this.resolvedTranslations.loadingMessages;this.loadingMessageIndex=Math.floor(Math.random()*e.length);const t=this.resolvedTranslations;this.resultsContainer.innerHTML=`
|
|
1761
1753
|
<div class="search-loading">
|
|
1762
|
-
<div class="loading" aria-label="
|
|
1763
|
-
<div class="loading-text loading-text-animate">${
|
|
1754
|
+
<div class="loading" aria-label="${o(t.loadingAriaLabel)}"></div>
|
|
1755
|
+
<div class="loading-text loading-text-animate">${o(e[this.loadingMessageIndex])}</div>
|
|
1764
1756
|
</div>
|
|
1765
|
-
`,this.startLoadingInterval()
|
|
1757
|
+
`,this.startLoadingInterval()}startLoadingInterval(){this.loadingMessageInterval=setInterval(()=>{const e=this.resolvedTranslations.loadingMessages;this.loadingMessageIndex=(this.loadingMessageIndex+1)%e.length;const t=this.resultsContainer?.querySelector(".loading-text");t&&(t.classList.remove("loading-text-animate"),t.offsetWidth,t.textContent=e[this.loadingMessageIndex],t.classList.add("loading-text-animate"))},A)}clearLoadingInterval(){this.loadingMessageInterval&&(clearInterval(this.loadingMessageInterval),this.loadingMessageInterval=null)}showEmptyState(){if(this.clearLoadingInterval(),!this.resultsContainer)return;const e=this.resolvedTranslations;this.resultsContainer.innerHTML=`
|
|
1766
1758
|
<div class="search-empty">
|
|
1767
1759
|
<svg class="search-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1768
1760
|
<circle cx="11" cy="11" r="8"></circle>
|
|
1769
1761
|
<path d="m21 21-4.35-4.35"></path>
|
|
1770
1762
|
</svg>
|
|
1771
|
-
<div class="search-empty-title"
|
|
1763
|
+
<div class="search-empty-title">${o(e.emptyStateTitle)}</div>
|
|
1772
1764
|
<div class="search-empty-description">
|
|
1773
|
-
|
|
1765
|
+
${o(e.emptyStateDescription)}
|
|
1774
1766
|
</div>
|
|
1775
1767
|
</div>
|
|
1776
|
-
`
|
|
1768
|
+
`}showNoResultsState(e){if(this.clearLoadingInterval(),!this.resultsContainer)return;const t=this.resolvedTranslations;this.resultsContainer.innerHTML=`
|
|
1777
1769
|
<div class="search-empty">
|
|
1778
1770
|
<svg class="search-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1779
1771
|
<circle cx="11" cy="11" r="8"></circle>
|
|
1780
1772
|
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1781
1773
|
</svg>
|
|
1782
|
-
<div class="search-empty-title"
|
|
1774
|
+
<div class="search-empty-title">${o(t.noResultsTitle)}</div>
|
|
1783
1775
|
<div class="search-empty-description">
|
|
1784
|
-
|
|
1776
|
+
${o(w(t.noResultsDescription,{query:e}))}
|
|
1785
1777
|
</div>
|
|
1786
1778
|
</div>
|
|
1787
|
-
`
|
|
1779
|
+
`}showErrorState(e){if(this.clearLoadingInterval(),!this.resultsContainer)return;const t=this.resolvedTranslations;this.resultsContainer.innerHTML=`
|
|
1788
1780
|
<div class="error">
|
|
1789
|
-
<strong
|
|
1781
|
+
<strong>${o(t.errorPrefix)}</strong> ${o(e)}
|
|
1790
1782
|
</div>
|
|
1791
|
-
`
|
|
1783
|
+
`}showMissingApiUrlError(){this.resultsContainer&&this.showErrorState(this.resolvedTranslations.missingApiUrlError)}updateTheme(e){const t=e==="light"||e==="dark"||e==="auto"?e:"auto";t==="auto"?this.removeAttribute("theme"):this.setAttribute("theme",t)}cleanup(){this.clearLoadingInterval(),this.currentSearchController&&(this.currentSearchController.abort(),this.currentSearchController=null),this.client&&this.client.cancelAllRequests(),this.inputElement&&(this.handleInputChange&&this.inputElement.removeEventListener("input",this.handleInputChange),this.handleInputKeydownEnter&&this.inputElement.removeEventListener("keydown",this.handleInputKeydownEnter),this.handleInputKeydownEscape&&window.removeEventListener("keydown",this.handleInputKeydownEscape)),this.searchButton&&this.handleSearchButtonClick&&this.searchButton.removeEventListener("click",this.handleSearchButtonClick),this.handleInputChange=null,this.handleInputKeydownEnter=null,this.handleInputKeydownEscape=null,this.handleSearchButtonClick=null}async search(e){await this.performSearch(e)}}customElements.get(K)||customElements.define(K,I);const ae=`
|
|
1792
1784
|
/* Modal backdrop */
|
|
1793
1785
|
.modal-backdrop {
|
|
1794
1786
|
position: fixed;
|
|
@@ -2225,8 +2217,8 @@ a.modal-result-item:focus-visible {
|
|
|
2225
2217
|
.modal-container.open {
|
|
2226
2218
|
animation: modal-slide-in var(--search-snippet-transition) ease-out;
|
|
2227
2219
|
}
|
|
2228
|
-
`,
|
|
2229
|
-
${
|
|
2220
|
+
`,Y="search-modal-snippet",J=10,W=50;class Z extends HTMLElement{constructor(){super();a(this,"shadow");a(this,"client",null);a(this,"backdrop",null);a(this,"modal",null);a(this,"inputElement",null);a(this,"resultsContainer",null);a(this,"footerCount",null);a(this,"isOpen",!1);a(this,"results",[]);a(this,"activeIndex",-1);a(this,"debouncedSearch",null);a(this,"currentSearchController",null);a(this,"loadingMessageInterval",null);a(this,"loadingMessageIndex",0);a(this,"translationsOverride",null);a(this,"resolvedTranslations",d(null));a(this,"handleGlobalKeydown",null);a(this,"handleInputChange",null);a(this,"handleInputKeydown",null);a(this,"handleBackdropClick",null);a(this,"savedBodyStyles",null);a(this,"savedHtmlOverflow",null);this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["api-url","placeholder","max-results","max-render-results","theme","shortcut","use-meta-key","debounce-ms","hide-branding","show-url","show-date","hide-thumbnails","see-more","request-options","translations"]}connectedCallback(){this.syncTranslationsFromAttribute(),this.initializeClient(),this.render(),this.attachGlobalKeyboardShortcut(),this.dispatchEvent(f("ready",void 0))}disconnectedCallback(){this.cleanup()}attributeChangedCallback(e,t,s){t!==s&&(e==="api-url"?this.initializeClient():e==="theme"?this.updateTheme(s):e==="translations"&&(this.syncTranslationsFromAttribute(),this.isConnected&&this.rerender()))}get translations(){return this.translationsOverride}set translations(e){this.translationsOverride=e??null,this.resolvedTranslations=d(this.translationsOverride),this.isConnected&&this.rerender()}rerender(){const e=this.isOpen,t=this.inputElement?.value??"";this.isOpen=!1,this.render(),e&&(this.isOpen=!0,this.backdrop?.classList.add("open"),this.modal?.classList.add("open"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.inputElement?.focus()})})),t&&this.inputElement&&(this.inputElement.value=t,t.trim().length>0&&this.performSearch(t.trim()))}syncTranslationsFromAttribute(){if(this.translationsOverride){this.resolvedTranslations=d(this.translationsOverride);return}const e=E(this.getAttribute("translations"),"SearchModalSnippet");this.resolvedTranslations=d(e)}getProps(){const e=this.resolvedTranslations;return{apiUrl:g(this.getAttribute("api-url"),""),placeholder:g(this.getAttribute("placeholder"),e.placeholder),maxResults:C(this.getAttribute("max-results"),W),maxRenderResults:C(this.getAttribute("max-render-results"),J),debounceMs:C(this.getAttribute("debounce-ms"),300),theme:g(this.getAttribute("theme"),"auto"),shortcut:g(this.getAttribute("shortcut"),"k"),useMetaKey:this.getAttribute("use-meta-key")!=="false",hideBranding:b(this.getAttribute("hide-branding"),!1),showUrl:b(this.getAttribute("show-url"),!1),showDate:b(this.getAttribute("show-date"),!1),hideThumbnails:b(this.getAttribute("hide-thumbnails"),!1),seeMore:g(this.getAttribute("see-more"),""),translations:this.translationsOverride??void 0}}getRequestOptions(){const e=this.getAttribute("request-options");if(e)try{const t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))throw new Error("request-options must be a JSON object");return t}catch(t){console.error("SearchModalSnippet: invalid request-options attribute",t);return}}initializeClient(){const e=this.getProps();if(!e.apiUrl){console.error("SearchModalSnippet: api-url attribute is required"),this.client=null,this.showMissingApiUrlError();return}try{this.client=M(e.apiUrl)}catch(t){console.error("SearchModalSnippet:",t)}}render(){const e=this.getProps(),t=this.resolvedTranslations,s=h=>this.performSearch(h);this.debouncedSearch=z(s,e.debounceMs||300);const r=document.createElement("style");r.textContent=`${T}
|
|
2221
|
+
${ae}`;const n=e.hideBranding?"":`<div class="powered-by-inline">${L}</div>`,c=document.createElement("div");c.innerHTML=`
|
|
2230
2222
|
<div class="modal-backdrop" role="presentation"></div>
|
|
2231
2223
|
<div class="modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
2232
2224
|
<div class="modal-header">
|
|
@@ -2236,8 +2228,8 @@ ${ee}`;const r=e.hideBranding?"":`<div class="powered-by-inline">${S}</div>`,o=d
|
|
|
2236
2228
|
<input
|
|
2237
2229
|
type="text"
|
|
2238
2230
|
class="modal-search-input"
|
|
2239
|
-
placeholder="${
|
|
2240
|
-
aria-label="
|
|
2231
|
+
placeholder="${o(e.placeholder||t.placeholder)}"
|
|
2232
|
+
aria-label="${o(t.searchButtonLabel)}"
|
|
2241
2233
|
aria-autocomplete="list"
|
|
2242
2234
|
aria-controls="modal-results-list"
|
|
2243
2235
|
aria-expanded="false"
|
|
@@ -2246,7 +2238,7 @@ ${ee}`;const r=e.hideBranding?"":`<div class="powered-by-inline">${S}</div>`,o=d
|
|
|
2246
2238
|
/>
|
|
2247
2239
|
</div>
|
|
2248
2240
|
<div class="modal-content">
|
|
2249
|
-
<div class="modal-results" id="modal-results-list" role="listbox" aria-label="
|
|
2241
|
+
<div class="modal-results" id="modal-results-list" role="listbox" aria-label="${o(t.searchResultsAriaLabel)}">
|
|
2250
2242
|
${this.renderEmptyState()}
|
|
2251
2243
|
</div>
|
|
2252
2244
|
</div>
|
|
@@ -2255,42 +2247,42 @@ ${ee}`;const r=e.hideBranding?"":`<div class="powered-by-inline">${S}</div>`,o=d
|
|
|
2255
2247
|
<div class="modal-footer-hint">
|
|
2256
2248
|
<kbd class="modal-kbd">↑</kbd>
|
|
2257
2249
|
<kbd class="modal-kbd">↓</kbd>
|
|
2258
|
-
<span
|
|
2250
|
+
<span>${o(t.navigateHint)}</span>
|
|
2259
2251
|
</div>
|
|
2260
2252
|
<div class="modal-footer-hint">
|
|
2261
2253
|
<kbd class="modal-kbd">↵</kbd>
|
|
2262
|
-
<span
|
|
2254
|
+
<span>${o(t.selectHint)}</span>
|
|
2263
2255
|
</div>
|
|
2264
2256
|
<div class="modal-footer-hint">
|
|
2265
2257
|
<kbd class="modal-kbd">Esc</kbd>
|
|
2266
|
-
<span
|
|
2258
|
+
<span>${o(t.closeHint)}</span>
|
|
2267
2259
|
</div>
|
|
2268
2260
|
</div>
|
|
2269
|
-
${
|
|
2261
|
+
${n}
|
|
2270
2262
|
</div>
|
|
2271
2263
|
</div>
|
|
2272
|
-
`,this.shadow.innerHTML="",this.shadow.appendChild(
|
|
2273
|
-
<span
|
|
2264
|
+
`,this.shadow.innerHTML="",this.shadow.appendChild(r),this.shadow.appendChild(c),this.backdrop=this.shadow.querySelector(".modal-backdrop"),this.modal=this.shadow.querySelector(".modal-container"),this.inputElement=this.shadow.querySelector(".modal-search-input"),this.resultsContainer=this.shadow.querySelector(".modal-results"),this.footerCount=this.shadow.querySelector(".modal-results-count"),this.attachEventListeners(),this.client||this.showMissingApiUrlError()}attachGlobalKeyboardShortcut(){const e=this.getProps(),t=e.shortcut?.toLowerCase()||"k";this.handleGlobalKeydown=s=>{(e.useMetaKey&&s.metaKey||s.ctrlKey)&&s.key.toLowerCase()===t&&!this.isOpen&&(s.preventDefault(),this.open())},document.addEventListener("keydown",this.handleGlobalKeydown)}attachEventListeners(){!this.inputElement||!this.backdrop||(this.handleInputChange=e=>{const s=e.target.value.trim();s.length>0&&this.debouncedSearch?this.debouncedSearch(s):(this.debouncedSearch?.cancel(),this.currentSearchController?.abort(),this.results=[],this.activeIndex=-1,this.showEmptyState())},this.inputElement.addEventListener("input",this.handleInputChange),this.handleInputKeydown=e=>{switch(e.key){case"ArrowDown":e.preventDefault(),this.navigateResults(1);break;case"ArrowUp":e.preventDefault(),this.navigateResults(-1);break;case"Enter":e.preventDefault(),this.selectActiveResult();break;case"Escape":e.preventDefault(),this.close();break}},this.inputElement.addEventListener("keydown",this.handleInputKeydown),this.handleBackdropClick=e=>{e.target===this.backdrop&&this.close()},this.backdrop.addEventListener("click",this.handleBackdropClick))}navigateResults(e){if(this.results.length===0)return;const t=this.activeIndex+e;t<0?this.activeIndex=this.results.length-1:t>=this.results.length?this.activeIndex=0:this.activeIndex=t,this.updateActiveResult()}updateActiveResult(){const e=this.resultsContainer?.querySelectorAll(".modal-result-item");e&&(e.forEach((t,s)=>{s===this.activeIndex?(t.classList.add("active"),t.setAttribute("aria-selected","true"),t.scrollIntoView({block:"nearest"})):(t.classList.remove("active"),t.setAttribute("aria-selected","false"))}),this.inputElement&&this.activeIndex>=0?this.inputElement.setAttribute("aria-activedescendant",`result-${this.activeIndex}`):this.inputElement&&this.inputElement.removeAttribute("aria-activedescendant"))}selectActiveResult(){if(this.activeIndex<0||this.activeIndex>=this.results.length){const s=this.inputElement?.value.trim();s&&s.length>0&&this.performSearch(s);return}const e=this.results[this.activeIndex];this.dispatchEvent(f("result-select",{result:e,index:this.activeIndex}));const t=this.resultsContainer?.querySelector(`.modal-result-item[data-index="${this.activeIndex}"]`);t&&e.url&&t.click(),this.close()}async performSearch(e){if(!this.client){this.showMissingApiUrlError();return}this.currentSearchController&&(this.currentSearchController.abort(),this.currentSearchController=null),this.currentSearchController=new AbortController,this.showLoadingState();try{const t=this.getProps(),s=await this.client.search(e,{signal:this.currentSearchController.signal,maxResults:t.maxResults||W,request:this.getRequestOptions()});this.results=s.slice(0,t.maxRenderResults||J),this.activeIndex=this.results.length>0?0:-1,this.displayResults(this.results,e,s.length)}catch(t){if(t.name==="AbortError")return;this.showErrorState(t.message)}finally{this.currentSearchController=null}}displayResults(e,t,s=e.length){if(this.clearLoadingInterval(),!this.resultsContainer)return;if(e.length===0){this.showNoResultsState(t);return}const r=this.getProps(),n=this.resolvedTranslations,c=e.map((v,x)=>this.renderResult(v,x)).join(""),h=s>e.length,m=h?w(n.resultsCountOverflow,{n:e.length,total:s}):w(s===1?n.modalResultsCount:n.modalResultsCountPlural,{n:s}),y=r.seeMore&&h?`<a href="${o(r.seeMore+encodeURIComponent(t))}" class="modal-see-more">
|
|
2265
|
+
<span>${o(n.seeMoreResults)}</span>
|
|
2274
2266
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
|
|
2275
|
-
</a>`:"";this.resultsContainer.innerHTML=
|
|
2267
|
+
</a>`:"";this.resultsContainer.innerHTML=c+y,this.footerCount&&(this.footerCount.textContent=m),this.inputElement&&this.inputElement.setAttribute("aria-expanded","true"),this.attachResultHandlers(),this.updateActiveResult()}renderResult(e,t){const s=this.getProps(),r=s.hideThumbnails?"":this.renderResultImage(e.image,e.title),n=e.url?o(e.url):"#",c=e.url?o($(e.url)):"",h=s.showDate&&e.timestamp!==void 0?`<div class="modal-result-date">${o(q(e.timestamp))}</div>`:"",m=s.showUrl&&e.url||h?`<div class="modal-result-metadata">
|
|
2276
2268
|
${s.showUrl&&e.url?`<span class="modal-result-url">${c}</span>`:'<span class="modal-result-url modal-result-url-empty"></span>'}
|
|
2277
|
-
${
|
|
2269
|
+
${h}
|
|
2278
2270
|
</div>`:"";return`
|
|
2279
2271
|
<a
|
|
2280
|
-
href="${
|
|
2272
|
+
href="${n}"
|
|
2281
2273
|
class="modal-result-item${t===this.activeIndex?" active":""}"
|
|
2282
2274
|
role="option"
|
|
2283
2275
|
id="result-${t}"
|
|
2284
2276
|
aria-selected="${t===this.activeIndex}"
|
|
2285
2277
|
tabindex="-1"
|
|
2286
2278
|
data-index="${t}"
|
|
2287
|
-
data-url="${
|
|
2279
|
+
data-url="${o(e.url||"")}"
|
|
2288
2280
|
>
|
|
2289
2281
|
${r}
|
|
2290
2282
|
<div class="modal-result-content">
|
|
2291
|
-
<div class="modal-result-title">${
|
|
2292
|
-
${e.description?`<div class="modal-result-description">${
|
|
2293
|
-
${
|
|
2283
|
+
<div class="modal-result-title">${o(e.title||"")}</div>
|
|
2284
|
+
${e.description?`<div class="modal-result-description">${o(e.description)}</div>`:""}
|
|
2285
|
+
${m}
|
|
2294
2286
|
</div>
|
|
2295
2287
|
</a>
|
|
2296
2288
|
`}renderResultImage(e,t){const s='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>';return e?`
|
|
@@ -2299,8 +2291,8 @@ ${ee}`;const r=e.hideBranding?"":`<div class="powered-by-inline">${S}</div>`,o=d
|
|
|
2299
2291
|
<div class="modal-result-image-placeholder" style="display: none;">${s}</div>
|
|
2300
2292
|
<img
|
|
2301
2293
|
class="modal-result-image"
|
|
2302
|
-
src="${
|
|
2303
|
-
alt="${
|
|
2294
|
+
src="${o(e)}"
|
|
2295
|
+
alt="${o(t)}"
|
|
2304
2296
|
loading="lazy"
|
|
2305
2297
|
/>
|
|
2306
2298
|
</div>
|
|
@@ -2308,31 +2300,31 @@ ${ee}`;const r=e.hideBranding?"":`<div class="powered-by-inline">${S}</div>`,o=d
|
|
|
2308
2300
|
<div class="modal-result-image-container">
|
|
2309
2301
|
<div class="modal-result-image-placeholder">${s}</div>
|
|
2310
2302
|
</div>
|
|
2311
|
-
`}attachResultHandlers(){const e=this.resultsContainer?.querySelectorAll(".modal-result-item");if(!e)return;e.forEach((s,r)=>{s.getAttribute("href")==="#"&&s.addEventListener("click",c=>{c.preventDefault()}),s.addEventListener("mouseenter",()=>{this.activeIndex=r,this.updateActiveResult()})}),this.resultsContainer?.querySelectorAll(".modal-result-image")?.forEach(s=>{s.addEventListener("load",()=>{s.classList.add("loaded"),s.closest(".modal-result-image-container")?.querySelector(".modal-result-image-loading")?.remove()}),s.addEventListener("error",()=>{const r=s.closest(".modal-result-image-container");r?.querySelector(".modal-result-image-loading")?.remove();const
|
|
2303
|
+
`}attachResultHandlers(){const e=this.resultsContainer?.querySelectorAll(".modal-result-item");if(!e)return;e.forEach((s,r)=>{s.getAttribute("href")==="#"&&s.addEventListener("click",c=>{c.preventDefault()}),s.addEventListener("mouseenter",()=>{this.activeIndex=r,this.updateActiveResult()})}),this.resultsContainer?.querySelectorAll(".modal-result-image")?.forEach(s=>{s.addEventListener("load",()=>{s.classList.add("loaded"),s.closest(".modal-result-image-container")?.querySelector(".modal-result-image-loading")?.remove()}),s.addEventListener("error",()=>{const r=s.closest(".modal-result-image-container");r?.querySelector(".modal-result-image-loading")?.remove();const n=r?.querySelector(".modal-result-image-placeholder");n&&(n.style.display="flex"),s.style.display="none"})})}renderEmptyState(){const e=this.resolvedTranslations;return`
|
|
2312
2304
|
<div class="modal-empty">
|
|
2313
2305
|
<svg class="modal-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
2314
2306
|
<circle cx="11" cy="11" r="8"></circle>
|
|
2315
2307
|
<path d="m21 21-4.35-4.35"></path>
|
|
2316
2308
|
</svg>
|
|
2317
|
-
<div class="modal-empty-description"
|
|
2309
|
+
<div class="modal-empty-description">${o(e.modalEmptyStateDescription)}</div>
|
|
2318
2310
|
</div>
|
|
2319
|
-
`}showEmptyState(){this.clearLoadingInterval(),this.resultsContainer&&(this.resultsContainer.innerHTML=this.renderEmptyState(),this.footerCount&&(this.footerCount.textContent=""),this.inputElement&&this.inputElement.setAttribute("aria-expanded","false"))}showLoadingState(){this.resultsContainer
|
|
2311
|
+
`}showEmptyState(){this.clearLoadingInterval(),this.resultsContainer&&(this.resultsContainer.innerHTML=this.renderEmptyState(),this.footerCount&&(this.footerCount.textContent=""),this.inputElement&&this.inputElement.setAttribute("aria-expanded","false"))}showLoadingState(){if(!this.resultsContainer)return;this.clearLoadingInterval();const e=this.resolvedTranslations.loadingMessages,t=this.resolvedTranslations;this.loadingMessageIndex=Math.floor(Math.random()*e.length),this.resultsContainer.innerHTML=`
|
|
2320
2312
|
<div class="modal-loading">
|
|
2321
|
-
<div class="loading" aria-label="
|
|
2322
|
-
<div class="loading-text loading-text-animate">${
|
|
2313
|
+
<div class="loading" aria-label="${o(t.loadingAriaLabel)}"></div>
|
|
2314
|
+
<div class="loading-text loading-text-animate">${o(e[this.loadingMessageIndex])}</div>
|
|
2323
2315
|
</div>
|
|
2324
|
-
`,this.footerCount&&(this.footerCount.textContent=
|
|
2316
|
+
`,this.footerCount&&(this.footerCount.textContent=e[this.loadingMessageIndex]),this.startLoadingInterval()}startLoadingInterval(){this.loadingMessageInterval=setInterval(()=>{const e=this.resolvedTranslations.loadingMessages;this.loadingMessageIndex=(this.loadingMessageIndex+1)%e.length;const t=this.resultsContainer?.querySelector(".loading-text");t&&(t.classList.remove("loading-text-animate"),t.offsetWidth,t.textContent=e[this.loadingMessageIndex],t.classList.add("loading-text-animate")),this.footerCount&&(this.footerCount.textContent=e[this.loadingMessageIndex])},A)}clearLoadingInterval(){this.loadingMessageInterval&&(clearInterval(this.loadingMessageInterval),this.loadingMessageInterval=null)}showNoResultsState(e){if(this.clearLoadingInterval(),!this.resultsContainer)return;const t=this.resolvedTranslations;this.resultsContainer.innerHTML=`
|
|
2325
2317
|
<div class="modal-empty">
|
|
2326
2318
|
<svg class="modal-empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
2327
2319
|
<circle cx="11" cy="11" r="8"></circle>
|
|
2328
2320
|
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
2329
2321
|
</svg>
|
|
2330
|
-
<div class="modal-empty-title"
|
|
2331
|
-
<div class="modal-empty-description"
|
|
2322
|
+
<div class="modal-empty-title">${o(t.modalNoResultsTitle)}</div>
|
|
2323
|
+
<div class="modal-empty-description">${o(w(t.modalNoResultsDescription,{query:e}))}</div>
|
|
2332
2324
|
</div>
|
|
2333
|
-
`,this.footerCount&&(this.footerCount.textContent=
|
|
2325
|
+
`,this.footerCount&&(this.footerCount.textContent=t.modalResultsCountZero),this.inputElement&&this.inputElement.setAttribute("aria-expanded","false")}showErrorState(e){if(this.clearLoadingInterval(),!this.resultsContainer)return;const t=this.resolvedTranslations;this.resultsContainer.innerHTML=`
|
|
2334
2326
|
<div class="error">
|
|
2335
|
-
<strong
|
|
2327
|
+
<strong>${o(t.errorPrefix)}</strong> ${o(e)}
|
|
2336
2328
|
</div>
|
|
2337
|
-
`,this.footerCount&&(this.footerCount.textContent=
|
|
2329
|
+
`,this.footerCount&&(this.footerCount.textContent=t.modalResultsCountError)}showMissingApiUrlError(){this.resultsContainer&&this.showErrorState(this.resolvedTranslations.missingApiUrlError)}updateTheme(e){const t=e==="light"||e==="dark"||e==="auto"?e:"auto";t==="auto"?this.removeAttribute("theme"):this.setAttribute("theme",t)}lockBodyScroll(){const e=window.scrollY;this.savedBodyStyles={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,width:document.body.style.width,scrollbarGutter:document.body.style.scrollbarGutter},this.savedHtmlOverflow=document.documentElement.style.overflow,document.body.style.scrollbarGutter="stable",document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%"}unlockBodyScroll(){if(!this.savedBodyStyles)return;const e=Math.abs(Number.parseInt(document.body.style.top||"0",10));document.documentElement.style.overflow=this.savedHtmlOverflow||"",document.body.style.overflow=this.savedBodyStyles.overflow,document.body.style.position=this.savedBodyStyles.position,document.body.style.top=this.savedBodyStyles.top,document.body.style.width=this.savedBodyStyles.width,document.body.style.scrollbarGutter=this.savedBodyStyles.scrollbarGutter||"",window.scrollTo(0,e),this.savedBodyStyles=null,this.savedHtmlOverflow=null}cleanup(){this.clearLoadingInterval(),this.currentSearchController&&(this.currentSearchController.abort(),this.currentSearchController=null),this.handleGlobalKeydown&&(document.removeEventListener("keydown",this.handleGlobalKeydown),this.handleGlobalKeydown=null),this.inputElement&&(this.handleInputChange&&this.inputElement.removeEventListener("input",this.handleInputChange),this.handleInputKeydown&&this.inputElement.removeEventListener("keydown",this.handleInputKeydown)),this.backdrop&&this.handleBackdropClick&&this.backdrop.removeEventListener("click",this.handleBackdropClick),this.handleInputChange=null,this.handleInputKeydown=null,this.handleBackdropClick=null,this.client&&this.client.cancelAllRequests()}open(){this.isOpen||(this.isOpen=!0,this.backdrop?.classList.add("open"),this.modal?.classList.add("open"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.inputElement?.focus()})}),this.lockBodyScroll(),this.dispatchEvent(f("open",void 0)))}close(){this.isOpen&&(this.isOpen=!1,this.backdrop?.classList.remove("open"),this.modal?.classList.remove("open"),this.inputElement&&(this.inputElement.value=""),this.results=[],this.activeIndex=-1,this.showEmptyState(),this.unlockBodyScroll(),this.dispatchEvent(f("close",void 0)))}toggle(){this.isOpen?this.close():this.open()}async search(e){this.isOpen||this.open(),this.inputElement&&(this.inputElement.value=e),await this.performSearch(e)}getResults(){return[...this.results]}isModalOpen(){return this.isOpen}}customElements.get(Y)||customElements.define(Y,Z),p.AISearchClient=O,p.ChatBubbleSnippet=U,p.ChatPageSnippet=V,p.DEFAULT_TRANSLATIONS=u,p.SearchBarSnippet=I,p.SearchModalSnippet=Z,p.default=I,p.mergeTranslations=d,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
2338
2330
|
//# sourceMappingURL=search-snippet.umd.js.map
|