!function(){"use strict";!function(){let e=localStorage.getItem("aipkit_guest_uuid");e||(e="10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),localStorage.setItem("aipkit_guest_uuid",e)),window.aipkit_guest_uuid=e}()}(),function(){"use strict";window.aipkit_frontendApiRequest=function(e,t={},i={}){return new Promise((n,a)=>{if(!i.ajaxUrl)return a(new Error("AIPKit Frontend AJAX: ajaxUrl missing in config."));let o=new FormData;o.append("action",e),i.nonce&&o.append("_ajax_nonce",i.nonce),i.botId&&o.append("bot_id",i.botId),window.aipkit_guest_uuid&&o.append("session_id",window.aipkit_guest_uuid),window.aipkit_current_conversation_uuid&&o.append("conversation_uuid",window.aipkit_current_conversation_uuid),window.aipkit_current_post_id&&o.append("post_id",window.aipkit_current_post_id),"OpenAI"===i.provider&&i.enableOpenAIConversationState&&window.aipkit_current_openai_response_id&&o.append("previous_openai_response_id",window.aipkit_current_openai_response_id),!0===t.frontend_web_search_active&&o.append("frontend_web_search_active","true"),!0===t.frontend_google_search_grounding_active&&o.append("frontend_google_search_grounding_active","true"),i.activeFileContext&&("OpenAI"===i.activeFileContext.provider&&i.activeFileContext.vector_store_id&&o.append("active_openai_vs_id",i.activeFileContext.vector_store_id),"Pinecone"===i.activeFileContext.provider&&i.activeFileContext.index_name&&i.activeFileContext.namespace&&(o.append("active_pinecone_index_name",i.activeFileContext.index_name),o.append("active_pinecone_namespace",i.activeFileContext.namespace)),"Qdrant"===i.activeFileContext.provider&&i.activeFileContext.collection_name&&i.activeFileContext.file_upload_context_id&&(o.append("active_qdrant_collection_name",i.activeFileContext.collection_name),o.append("active_qdrant_file_upload_context_id",i.activeFileContext.file_upload_context_id)),"Chroma"===i.activeFileContext.provider&&i.activeFileContext.collection_name&&i.activeFileContext.file_upload_context_id&&(o.append("active_chroma_collection_name",i.activeFileContext.collection_name),o.append("active_chroma_file_upload_context_id",i.activeFileContext.file_upload_context_id)),"Claude"===i.activeFileContext.provider&&i.activeFileContext.file_id&&o.append("active_claude_file_id",i.activeFileContext.file_id));for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&"frontend_web_search_active"!==e&&"frontend_google_search_grounding_active"!==e&&"active_openai_vs_id"!==e&&"active_pinecone_index_name"!==e&&"active_pinecone_namespace"!==e&&"active_qdrant_collection_name"!==e&&"active_qdrant_file_upload_context_id"!==e&&"active_chroma_collection_name"!==e&&"active_chroma_file_upload_context_id"!==e&&"active_claude_file_id"!==e&&("audio_file"===e&&t[e]instanceof Blob?o.append(e,t[e],"speech."+(t.audio_format||"webm")):o.append(e,t[e]));fetch(i.ajaxUrl,{method:"POST",body:o,credentials:"same-origin"}).then(e=>e.json()).then(e=>{if(e.success)n(e.data);else{let t=e.data&&"object"==typeof e.data&&e.data.message?e.data.message:"Unknown frontend API error (data or data.message missing/invalid)";a(new Error(t))}}).catch(e=>{a(e)})})}}(),function(){"use strict";function e(e){e.preventDefault();let t=e.target,i=t.querySelector(".aipkit_semantic_search_input"),n=t.querySelector(".aipkit_semantic_search_button"),a=t.closest(".aipkit_semantic_search_wrapper"),o=a.querySelector(".aipkit_semantic_search_results");if(!(i&&n&&a&&o))return;let c=i.value.trim();if(!c)return;let _=window.aipkit_semantic_search_config||{},r=_.text||{};n.disabled=!0;let d=n.querySelector(".aipkit_spinner");d&&(d.style.display="inline-block"),o.innerHTML='<div class="aipkit-search-loading"><span class="aipkit_spinner"></span></div>';let p={query:c};window.aipkit_frontendApiRequest("aipkit_perform_semantic_search",p,_).then(e=>{o.innerHTML=e.html||`<p>${_.settings.no_results_text||"No results found."}</p>`}).catch(e=>{o.innerHTML=`<p class="aipkit-search-error">${r.error||"An error occurred while searching."}</p>`}).finally(()=>{n.disabled=!1,d&&(d.style.display="none")})}function t(){document.querySelectorAll(".aipkit_semantic_search_form").forEach(t=>{"true"!==t.dataset.listenerAttached&&(t.addEventListener("submit",e),t.dataset.listenerAttached="true")})}document.addEventListener("DOMContentLoaded",t),document.addEventListener("aipkit:contentLoaded",t)}();