Sid Gifari File Manager
🏠 Root
/
home
/
genremedia08
/
thepassage.overlookedtracks.com
/
wp-content9
/
plugins
/
echo-knowledge-base
/
js
/
ai
/
Editing: admin-ai-chat.min.js
(function(){"use strict";const{useState:e,useEffect:a,useCallback:t,useRef:s,createElement:n}=wp.element;const{__:i,sprintf:o}=wp.i18n;const{showError:c,showSuccess:l,makeApiRequest:r,showLoadingDialog:d,useTableSearch:p,formatServerDateTime:u,TutorialButton:b,isAuthError:h,SetupStepsGuide:_}=window.EPKB_AI_Util_React||{};const{logError:f,parseMessageFormatting:g}=window.EPKBChatUtils||{};const m=e=>{const a=document.createElement("div");a.className="epkb-ai-dialog epkb-ai-loading-dialog";a.style.cssText=`\n\t\t\tposition: fixed;\n\t\t\ttop: 50%;\n\t\t\tleft: 50%;\n\t\t\ttransform: translate(-50%, -50%);\n\t\t\tbackground: white;\n\t\t\tborder-radius: 8px;\n\t\t\tpadding: 24px;\n\t\t\tmax-width: 350px;\n\t\t\tbox-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n\t\t\tz-index: 999999;\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tgap: 16px;\n\t\t\tborder: 1px solid #ddd;\n\t\t`;const t=document.createElement("div");t.className="epkb-loading-spinner";t.style.cssText="width: 24px; height: 24px; flex-shrink: 0;";const s=document.createElement("p");s.style.cssText="margin: 0; color: #555; font-size: 14px; line-height: 1.5; font-weight: 500;";s.textContent=e;a.appendChild(t);a.appendChild(s);document.body.appendChild(a);a.offsetHeight;return{close:()=>{a.style.transition="opacity 0.3s ease-out";a.style.opacity="0";setTimeout((()=>a.remove()),300)}}};const k=e=>e?u?u(e,""):e:"";const w=e=>{if(!e||typeof e!=="object"){return[]}const a=Array.isArray(e.ratings)?e.ratings:[];let t=0;let s=0;a.forEach((e=>{if(e.vote==="up"){t+=1}else if(e.vote==="down"){s+=1}}));const n=[];if(t>0){n.push(t>1?o(i("Thumbs up (%d)","echo-knowledge-base"),t):i("Thumbs up","echo-knowledge-base"))}if(s>0){n.push(s>1?o(i("Thumbs down (%d)","echo-knowledge-base"),s):i("Thumbs down","echo-knowledge-base"))}return n};const v=e=>{if(!e||typeof e!=="object"){return[]}const a=Array.isArray(e.ratings)?e.ratings:[];const t=a.map((e=>{const a=e.vote==="up"?i("Thumbs up","echo-knowledge-base"):i("Thumbs down","echo-knowledge-base");const t=k(e.submitted_at);return t?`${a} (${t})`:a}));return t};const y=e=>{if(!e||typeof e!=="object"){return[]}const a=[];const t=Array.isArray(e.handoff_clicks)?e.handoff_clicks:[];t.forEach((e=>{const t=k(e.submitted_at);const s=i("Contact an Agent clicked","echo-knowledge-base");a.push(t?`${s} (${t})`:s)}));if(e.handoff_submission){const t=k(e.handoff_submission.submitted_at);const s=i("Agent handover request submitted","echo-knowledge-base");a.push(t?`${s} (${t})`:s)}return a};const N=({conversations:o,selectedId:c,onSelect:r,onDelete:d,onArchive:b,onUnarchive:h,viewFilter:_,onViewFilterChange:f,isLoading:g,onRefresh:k,onSearch:v,allConversations:y,currentPage:N,totalPages:x,onPageChange:C,autoSelectTopRowSignal:S,showAgentHandover:A,deletedConversationIds:T})=>{const[P,R]=e([]);const[$,E]=e(false);const[I,D]=e("desc");const[L,U]=e((()=>new Set));const[F,j]=e((()=>{const e="epkb_viewed_chat_conversations";try{const a=localStorage.getItem(e);return a?new Set(JSON.parse(a)):new Set}catch(e){return new Set}}));const O=t((e=>{j((a=>{const t=new Set(a);t.add(e);const s="epkb_viewed_chat_conversations";try{localStorage.setItem(s,JSON.stringify([...t]))}catch(e){}return t}))}),[]);const{searchTerm:B,displayedData:M,isSearching:G,searchMessage:z,handleSearchChange:q,clearSearch:H}=p({data:o,allData:y,onServerSearch:v,searchFields:["first_message","conversation","user_name","user"]});const K=[...M].sort(((e,a)=>{const t=new Date(e.time||e.created_at||0);const s=new Date(a.time||a.created_at||0);if(I==="asc"){return t-s}else{return s-t}}));const J=s(S);a((()=>{if(S===J.current){return}if(c!==null){J.current=S;return}if(K.length===0){return}const e=K[0].id;O(e);r(e);J.current=S}),[S,c,K,O,r]);a((()=>{if(!Array.isArray(T)||T.length===0){return}R((e=>e.filter((e=>!T.includes(e)))))}),[T]);const V=e=>{if(e){R(K.map((e=>e.id)))}else{R([])}};const Y=()=>{D(I==="asc"?"desc":"asc")};const Q=(e,a)=>{if(a){R([...P,e])}else{R(P.filter((a=>a!==e)))}};const W=async(e,a)=>{e.stopPropagation();if(L.has(a)){return}U((e=>{const t=new Set(e);t.add(a);return t}));try{await d([a])}catch(e){}finally{U((e=>{const t=new Set(e);t.delete(a);return t}))}};const X=async()=>{if(P.length===0)return;const{showConfirmDialog:e}=window.EPKB_AI_Util_React||{};if(!e){if(!confirm(i("Are you sure you want to delete the selected conversations?","echo-knowledge-base"))){return}}else{const a=await e({title:i("Delete Conversations","echo-knowledge-base"),message:i("Are you sure you want to delete the selected conversations?","echo-knowledge-base"),confirmText:i("Delete","echo-knowledge-base"),cancelText:i("Cancel","echo-knowledge-base"),confirmButtonClass:"epkb-ai-button-destructive"});if(!a){return}}const a=m(i("Deleting conversations...","echo-knowledge-base"));P.forEach((e=>{const a=document.getElementById(`chat-row-${e}`);if(a){a.style.opacity="0.5";a.style.transition="opacity 0.3s ease"}}));try{await d(P);R([])}catch(e){P.forEach((e=>{const a=document.getElementById(`chat-row-${e}`);if(a){a.style.opacity="1"}}));throw e}finally{if(a){a.close()}}};const Z=async()=>{E(true);await k();E(false);l(i("Conversations refreshed successfully","echo-knowledge-base"))};const ee=async()=>{if(P.length===0||!b)return;const{showConfirmDialog:e}=window.EPKB_AI_Util_React||{};if(e){const a=await e({title:i("Archive Conversations","echo-knowledge-base"),message:i("Are you sure you want to archive the selected conversations?","echo-knowledge-base"),confirmText:i("Archive","echo-knowledge-base"),cancelText:i("Cancel","echo-knowledge-base")});if(!a)return}const a=m(i("Archiving conversations...","echo-knowledge-base"));try{await b(P);R([])}finally{if(a)a.close()}};const ae=async()=>{if(P.length===0||!h)return;const{showConfirmDialog:e}=window.EPKB_AI_Util_React||{};if(e){const a=await e({title:i("Restore Conversations","echo-knowledge-base"),message:i("Are you sure you want to restore the selected conversations?","echo-knowledge-base"),confirmText:i("Restore","echo-knowledge-base"),cancelText:i("Cancel","echo-knowledge-base")});if(!a)return}const a=m(i("Restoring conversations...","echo-knowledge-base"));try{await h(P);R([])}finally{if(a)a.close()}};const te=e=>{if(!e||typeof e!=="object"){return""}const a=[];if(e.handoff_submission){a.push(i("Agent handover request","echo-knowledge-base"))}a.push(...w(e));return a.join(", ")};return n("div",{className:"epkb-ai-data-source-table"},n("div",{className:"epkb-ai-table-content"},n("div",{className:"epkb-submissions-table-container"},n("div",{className:"epkb-table-filter-container"},f&&n("div",{className:"epkb-ai-view-filter-tabs",style:{display:"flex",gap:"2px",marginRight:"15px"}},n("button",{className:"epkb-ai-filter-tab",onClick:()=>f("active"),style:{padding:"6px 12px",fontSize:"13px",border:"1px solid #ccc",borderRadius:"3px 0 0 3px",background:_==="active"?"#0073aa":"#fff",color:_==="active"?"#fff":"#333",cursor:"pointer"}},i("Active","echo-knowledge-base")),n("button",{className:"epkb-ai-filter-tab",onClick:()=>f("archived"),style:{padding:"6px 12px",fontSize:"13px",border:"1px solid #ccc",borderLeft:"none",background:_==="archived"?"#0073aa":"#fff",color:_==="archived"?"#fff":"#333",cursor:"pointer"}},i("Archived","echo-knowledge-base")),n("button",{className:"epkb-ai-filter-tab",onClick:()=>f("all"),style:{padding:"6px 12px",fontSize:"13px",border:"1px solid #ccc",borderLeft:"none",borderRadius:"0 3px 3px 0",background:_==="all"?"#0073aa":"#fff",color:_==="all"?"#fff":"#333",cursor:"pointer"}},i("All","echo-knowledge-base"))),n("div",{className:"epkb-ai-search-input"},n("input",{type:"text",placeholder:i("Search conversations...","echo-knowledge-base"),value:B,onChange:e=>q(e.target.value)}),n("span",{className:"epkb-ai-search-icon epkbfa epkbfa-search"})),n("button",{className:"epkb-ai-button epkb-ai-button-success",onClick:Z,disabled:g||$,style:{backgroundColor:"#46b450",borderColor:"#46b450",color:"#fff",padding:"6px 12px",fontSize:"14px",marginRight:P.length>0?"10px":"0"}},$?i("Refreshing...","echo-knowledge-base"):n("span",null,n("span",{className:"epkbfa epkbfa-refresh",style:{marginRight:"5px"}}),i("Refresh","echo-knowledge-base"))),P.length>0&&_==="active"&&b&&n("button",{className:"epkb-ai-button epkb-ai-button-secondary",onClick:ee,style:{marginRight:"5px"}},i("Archive Selected","echo-knowledge-base")),P.length>0&&_==="archived"&&h&&n("button",{className:"epkb-ai-button epkb-ai-button-secondary",onClick:ae,style:{marginRight:"5px"}},i("Restore Selected","echo-knowledge-base")),P.length>0&&n("button",{className:"epkb-ai-button epkb-ai-button-destructive",onClick:X},i("Delete Selected","echo-knowledge-base"))),g?n("div",{className:"epkb-ai-loading"},n("div",{className:"epkb-loading-spinner"}),n("p",null,i("Loading conversations...","echo-knowledge-base"))):K.length===0&&!B?n("div",{className:"epkb-ai-no-data"},n("p",null,i("No conversations found","echo-knowledge-base"))):n("table",{id:"epkb-chat-conversations-table"},n("thead",null,n("tr",null,n("th",null,n("input",{type:"checkbox",checked:P.length===K.length&&K.length>0,onChange:e=>V(e.target.checked)})),n("th",{"data-column":"time",style:{cursor:"pointer",userSelect:"none"},onClick:Y},n("span",null,i("Time","echo-knowledge-base")," ",I==="asc"?"↑":"↓")),n("th",{"data-column":"user"},i("User","echo-knowledge-base")),n("th",{"data-column":"conversation"},i("Conversation","echo-knowledge-base")),n("th",{"data-column":"message_count"},i("Message Count","echo-knowledge-base")),A&&n("th",{"data-column":"agent_handover"},i("Agent Handover","echo-knowledge-base")))),n("tbody",null,K.map((e=>{const a=c===e.id;const t=L.has(e.id);return n("tr",{key:e.id,id:`chat-row-${e.id}`,className:`${a?"selected":""} ${!F.has(e.id)?"epkb-ai-unviewed-record":""}`.trim(),onClick:()=>{O(e.id);r(e.id)}},n("td",null,n("input",{type:"checkbox",checked:P.includes(e.id),onChange:a=>Q(e.id,a.target.checked),onClick:e=>e.stopPropagation()})),n("td",null,a?n("div",{style:{display:"flex",gap:"12px",alignItems:"center"}},(()=>{const a=e.archived||e.metadata&&e.metadata.archived;if(!a&&b){return n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-secondary epkb-ai-button-small",onClick:a=>{a.stopPropagation();b([e.id])},"aria-label":i("Archive","echo-knowledge-base"),title:i("Archive","echo-knowledge-base"),style:{padding:"6px 10px"}},n("span",{className:"epkbfa epkbfa-archive",style:{fontSize:"16px"},"aria-hidden":"true"}))}else if(a&&h){return n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-secondary epkb-ai-button-small",onClick:a=>{a.stopPropagation();h([e.id])},"aria-label":i("Restore","echo-knowledge-base"),title:i("Restore","echo-knowledge-base"),style:{padding:"6px 10px"}},n("span",{className:"epkbfa epkbfa-undo",style:{fontSize:"16px"},"aria-hidden":"true"}))}return null})(),n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-destructive epkb-ai-button-small",onClick:a=>W(a,e.id),"aria-label":i("Delete","echo-knowledge-base"),title:i("Delete","echo-knowledge-base"),disabled:t,style:{padding:"6px 10px"}},t?n("span",{className:"epkb-ai-spinner","aria-hidden":"true"}):n("span",{className:"epkbfa epkbfa-trash",style:{fontSize:"16px"},"aria-hidden":"true"}))):u?u(e.time||e.created_at,"-"):e.time||e.created_at||"-"),n("td",null,e.user_id&&e.user_id>0?n("a",{href:`user-edit.php?user_id=${e.user_id}`,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"}},e.user||e.user_name):e.user||e.user_name),n("td",null,e.conversation||e.first_message||""),(()=>{const a=typeof e.message_count==="number"?e.message_count:parseInt(e.message_count,10);const t=Number.isFinite(a)?a:(e.messages||[]).length;return n("td",{"data-column":"message_count"},t>0?n("span",{className:"epkb-ai-question-count",title:i("Number of messages","echo-knowledge-base")},t):"-")})(),A&&n("td",{"data-column":"agent_handover"},te(e.metadata)||"-"))})))),(z||G)&&n("div",{className:"epkb-ai-search-message",style:{textAlign:"center",padding:"10px",color:"#666",fontStyle:"italic"}},G?i("Searching server for more results...","echo-knowledge-base"):z),(()=>{if(x<=1){return null}return n("div",{className:"epkb-ai-pagination"},n("button",{disabled:N===1,onClick:()=>C(N-1),className:"epkb-ai-button epkb-ai-button-secondary"},i("Previous","echo-knowledge-base")),n("span",{className:"epkb-ai-page-info"},`${i("Page","echo-knowledge-base")} ${N} ${i("of","echo-knowledge-base")} ${x}`),n("button",{disabled:N===x,onClick:()=>C(N+1),className:"epkb-ai-button epkb-ai-button-secondary"},i("Next","echo-knowledge-base")))})())))};const x=({conversation:e,onDelete:a,onArchive:t,onUnarchive:s,viewFilter:c})=>{const l=async()=>{if(!e||!a){return}const t=m(i("Deleting conversation...","echo-knowledge-base"));const s=document.getElementById(`chat-row-${e.id}`);if(s){s.style.opacity="0.5";s.style.transition="opacity 0.3s ease"}try{await a([e.id],{showSuccessMessage:false})}catch(e){if(s){s.style.opacity="1"}}finally{if(t){t.close()}}};const r=async()=>{if(!e||!t)return;const a=m(i("Archiving conversation...","echo-knowledge-base"));try{await t([e.id])}finally{if(a)a.close()}};const d=async()=>{if(!e||!s)return;const a=m(i("Restoring conversation...","echo-knowledge-base"));try{await s([e.id])}finally{if(a)a.close()}};const p=e?.archived||e?.metadata&&e.metadata.archived;if(!e){return n("div",{className:"epkb-ai-data-source-settings"},n("div",{className:"epkb-ai-data-source-heading-wrapper"},n("h3",{className:"epkb-ai-data-source-heading"},i("Conversation Details","echo-knowledge-base"))),n("div",{className:"epkb-ai-action-content"},n("div",{className:"epkb-ai-no-selection"},n("p",null,i("Select a conversation to view details","echo-knowledge-base")))))}const b=e.metadata&&typeof e.metadata==="object"?e.metadata:{};const h=b.page_url||b.handoff_submission&&b.handoff_submission.page_url||"";const _=b.page_title||"";const f=v(b);const k=y(b);const w=h||f.length>0||k.length>0;const N={};if(Array.isArray(b.ratings)){b.ratings.forEach((e=>{if(!e.message_id){return}const a=String(e.message_id);if(!N[a]){N[a]={up:0,down:0}}if(e.vote==="up"){N[a].up+=1}else if(e.vote==="down"){N[a].down+=1}}))}const x=a=>a.length>0?n("ul",{className:"epkb-ai-meta-list"},a.map(((a,t)=>n("li",{key:`meta-${e.id}-${t}`,className:"epkb-ai-meta-list-item"},a)))):n("span",{className:"epkb-ai-meta-empty"},"-");return n("div",{className:"epkb-ai-data-source-settings"},n("div",{className:"epkb-ai-data-source-heading-wrapper"},n("h3",{className:"epkb-ai-data-source-heading"},i("Conversation Details","echo-knowledge-base")),n("div",{style:{display:"flex",gap:"8px"}},!p&&t&&n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-secondary",onClick:r},i("Archive","echo-knowledge-base")),p&&s&&n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-secondary",onClick:d},i("Restore","echo-knowledge-base")),n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-destructive",onClick:l},i("Delete","echo-knowledge-base")))),n("div",{className:"epkb-ai-discussion-details-content"},w&&n("div",{className:"epkb-ai-conversation-meta"},n("h4",null,i("Conversation Summary","echo-knowledge-base")),h&&n("div",{className:"epkb-ai-meta-item"},n("span",{className:"epkb-ai-meta-label"},i("Page","echo-knowledge-base")),n("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"epkb-ai-meta-value epkb-ai-meta-link"},_||h)),f.length>0&&n("div",{className:"epkb-ai-meta-item epkb-ai-meta-item--stacked"},n("span",{className:"epkb-ai-meta-label"},i("Feedback","echo-knowledge-base")),n("div",{className:"epkb-ai-meta-value"},x(f))),k.length>0&&n("div",{className:"epkb-ai-meta-item epkb-ai-meta-item--stacked"},n("span",{className:"epkb-ai-meta-label"},i("Agent Handover","echo-knowledge-base")),n("div",{className:"epkb-ai-meta-value"},x(k)))),n("div",{className:"epkb-ai-conversation-messages"},n("div",{className:"epkb-ai-conversation-thread"},n("h4",null,i("Full Conversation","echo-knowledge-base")),e.messages&&e.messages.length>0?n("div",{className:"epkb-ai-messages-list"},e.messages.map(((a,t)=>{const s=a.id?String(a.id):"";const c=s&&N[s]?N[s]:null;const l=c&&(c.up>0||c.down>0);const r=typeof a.content==="string"?a.content:a.content?String(a.content):"";const d=a.role==="assistant"&&typeof g==="function";const p=d?g(r):r;const b=c&&c.up>1?o(i("Thumbs up (%d)","echo-knowledge-base"),c.up):i("Thumbs up","echo-knowledge-base");const h=c&&c.down>1?o(i("Thumbs down (%d)","echo-knowledge-base"),c.down):i("Thumbs down","echo-knowledge-base");return n("div",{key:`${e.id}-${t}`,className:`epkb-ai-message epkb-ai-message-${a.role}`},n("div",{className:"epkb-ai-message-header"},n("span",{className:"epkb-ai-message-role"},a.role==="user"?i("User","echo-knowledge-base"):i("AI Assistant","echo-knowledge-base")),a.timestamp&&n("span",{className:"epkb-ai-message-time"},u?u(a.timestamp,""):a.timestamp)),l&&n("div",{className:"epkb-ai-message-feedback"},c.up>0&&n("span",{className:"epkb-ai-message-feedback-item epkb-ai-message-feedback-item--up",title:b},n("span",{className:"epkbfa epkbfa-thumbs-up","aria-hidden":"true"}),n("span",{className:"epkb-ai-message-feedback-text"},b)),c.down>0&&n("span",{className:"epkb-ai-message-feedback-item epkb-ai-message-feedback-item--down",title:h},n("span",{className:"epkbfa epkbfa-thumbs-down","aria-hidden":"true"}),n("span",{className:"epkb-ai-message-feedback-text"},h))),n("div",{className:"epkb-ai-message-bubble"},n("div",{className:"epkb-ai-message-content",...d?{dangerouslySetInnerHTML:{__html:p}}:{}},d?null:r)))}))):n("div",{className:"epkb-ai-no-messages"},n("p",null,i("No messages in this conversation.","echo-knowledge-base")))))))};const C=({field:t,fieldName:s,value:i,onChange:o,onPresetChange:c})=>{const[l,r]=e(false);a((()=>{const e=e=>{if(!e.target.closest(".epkb-ai-custom-dropdown")){r(false)}};const a=document.querySelector(".epkb-ai-behavior-preset-select");const t=a?a.closest(".epkb-ai-settings-section"):null;if(t){if(l){t.classList.add("epkb-has-dropdown-open")}else{t.classList.remove("epkb-has-dropdown-open")}}if(l){document.addEventListener("click",e);return()=>{document.removeEventListener("click",e);if(t){t.classList.remove("epkb-has-dropdown-open")}}}}),[l]);const d=e=>{const a=e.split(" - ");if(a.length===2){return{name:a[0].trim(),description:a[1].trim()}}return{name:e,description:""}};const p=t.options[i]||"";const u=d(p);return n("div",{className:"epkb-ai-field epkb-ai-field-select epkb-ai-behavior-preset-select"},n("label",{className:"epkb-ai-field-label"},t.label),n("div",{className:"epkb-ai-custom-dropdown"},n("div",{className:"epkb-ai-dropdown-trigger",onClick:()=>r(!l)},n("span",{className:"epkb-ai-dropdown-value"},u.name),n("span",{className:"epkb-ai-dropdown-arrow"},l?"▲":"▼")),l&&n("div",{className:"epkb-ai-dropdown-menu"},Object.entries(t.options).map((([e,a])=>{const t=d(a);return n("div",{key:e,className:"epkb-ai-dropdown-option"+(i===e?" selected":""),onClick:()=>{o(s,e);if(c){c(e)}r(false)}},n("div",{className:"epkb-ai-option-name"},t.name),t.description&&n("div",{className:"epkb-ai-option-description"},t.description))})))),t.description&&n("p",{className:"epkb-ai-field-description"},t.description))};const S=({settings:a,onChange:t,onSave:s,isSaving:o,onPresetChange:c,collectionIssues:l=[]})=>{const[r,d]=e("location-1");const p=Array.isArray(l)&&l.length>0;const u=e=>{const a=e.collection_name||(e.collection_id?`${i("Collection","echo-knowledge-base")} ${e.collection_id}`:"");if(a){return`${a}: ${e.message||""}`}return e.message||""};const b=(e,s)=>{const o=a.hasOwnProperty(e)?a[e]:s.value||"";switch(s.type){case"toggle":return n("div",{className:"epkb-ai-field epkb-ai-field-toggle"},n("label",{className:"epkb-ai-toggle-label"},n("input",{type:"checkbox",checked:o==="on",onChange:a=>t(e,a.target.checked?"on":"off")}),n("span",{className:"epkb-ai-toggle-text"},s.label)),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"radio":return n("div",{className:"epkb-ai-field epkb-ai-field-radio"+(s.field_class?" "+s.field_class:"")},n("div",{className:"epkb-ai-field-label"},s.label),n("div",{className:"epkb-ai-radio-group"},Object.entries(s.options).map((([a,s])=>n("label",{key:a,className:"epkb-ai-radio-label"},n("input",{type:"radio",name:e,value:a,checked:o===a,onChange:a=>t(e,a.target.value)}),n("span",{className:"epkb-ai-radio-text"},s))))),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"password":return n("div",{className:"epkb-ai-field epkb-ai-field-password"},n("label",{className:"epkb-ai-field-label"},s.label),n("input",{type:"password",className:"epkb-ai-input",value:o||"",onChange:a=>t(e,a.target.value),placeholder:s.placeholder}),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"text":return n("div",{className:"epkb-ai-field epkb-ai-field-text"},n("label",{className:"epkb-ai-field-label"},s.label),n("input",{type:"text",className:"epkb-ai-input",value:o||"",onChange:a=>t(e,a.target.value),placeholder:s.placeholder}),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"textarea":const l=e==="ai_chat_instructions"?"epkb-ai-field-description-red":"";return n("div",{className:"epkb-ai-textarea-field"},n("div",{className:"epkb-ai-textarea-header"},n("label",null,s.label),s.show_reset&&n("button",{type:"button",className:"epkb-ai-reset-button",onClick:async()=>{if(s.default){const{showConfirmDialog:a}=window.EPKB_AI_Util_React||{};if(!a){if(confirm(i("Are you sure you want to reset to default instructions?","echo-knowledge-base"))){t(e,s.default)}}else{const n=await a({title:i("Reset Instructions","echo-knowledge-base"),message:i("Are you sure you want to reset to default instructions? Your custom instructions will be lost.","echo-knowledge-base"),confirmText:i("Reset","echo-knowledge-base"),cancelText:i("Cancel","echo-knowledge-base"),confirmButtonClass:"epkb-ai-button-destructive"});if(n){t(e,s.default)}}}}},i("Reset to Default","echo-knowledge-base"))),n("textarea",{value:o,onChange:a=>t(e,a.target.value),rows:s.rows||3,placeholder:s.placeholder}),s.description&&n("p",{className:l},s.description));case"number":return n("div",{className:"epkb-ai-field epkb-ai-field-number"},n("label",{className:"epkb-ai-field-label"},s.label),n("input",{type:"number",className:"epkb-ai-input",value:o,onChange:a=>t(e,a.target.value),min:s.min,max:s.max,step:s.step}),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"color":return n("div",{className:"epkb-ai-field epkb-ai-field-color"},n("label",{className:"epkb-ai-field-label"},s.label),n("input",{type:"color",className:"epkb-ai-color-input",value:o||s.value||"#0073aa",onChange:a=>t(e,a.target.value)}),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"select":if(s.field_class&&s.field_class.includes("epkb-ai-behavior-preset-select")){return n(C,{field:s,fieldName:e,value:o,onChange:t,onPresetChange:c})}const r=e=>{const a=typeof e==="string"&&e.indexOf("gpt-5")===0;if(a){return{type:"gpt5",defaults:{verbosity:"medium",reasoning:"medium",max_output_tokens:5e3}}}return{type:"gpt4",defaults:{temperature:.2,top_p:1,max_output_tokens:5e3}}};return n("div",{className:"epkb-ai-field epkb-ai-field-select"+(s.field_class?" "+s.field_class:"")},n("label",{className:"epkb-ai-field-label"},s.label),n("select",{className:"epkb-ai-select",value:o,onChange:s=>{const n=s.target.value;t(e,n);const i=a.chat_model_field||"ai_chatgpt_chat_model";if(e===i){const e=a.ai_chat_preset!==undefined?a.ai_chat_preset:a.sections&&a.sections.chat_settings&&a.sections.chat_settings.fields&&a.sections.chat_settings.fields.ai_chat_preset?a.sections.chat_settings.fields.ai_chat_preset.value:"custom";if(e==="custom"){const e=r(n);if(e.type==="gpt5"){if(e.defaults.verbosity!==undefined)t("ai_chat_verbosity",e.defaults.verbosity);if(e.defaults.reasoning!==undefined)t("ai_chat_reasoning",e.defaults.reasoning)}else{if(e.defaults.temperature!==undefined)t("ai_chat_temperature",e.defaults.temperature);if(e.defaults.top_p!==undefined)t("ai_chat_top_p",e.defaults.top_p)}if(e.defaults.max_output_tokens!==undefined)t("ai_chat_max_output_tokens",e.defaults.max_output_tokens)}}}},Object.entries(s.options).map((([e,a])=>n("option",{key:e,value:e},a)))),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"section_header":return n("div",{className:"epkb-ai-section-divider"},n("h4",{className:"epkb-ai-section-subtitle"},s.label),s.description&&n("p",{className:"epkb-ai-section-description"},s.description));case"checkboxes":return n("div",{className:"epkb-ai-field epkb-ai-field-checkboxes"+(s.field_class?" "+s.field_class:"")},s.label&&n("label",{className:"epkb-ai-field-label"},s.label),n("div",{className:"epkb-field-checkboxes"},Object.entries(s.options||{}).map((([a,s])=>n("label",{key:a,className:"epkb-checkbox-label"},n("input",{type:"checkbox",value:a,checked:Array.isArray(o)?o.includes(a):false,onChange:s=>{const n=Array.isArray(o)?o:[];const i=s.target.checked?[...n,a]:n.filter((e=>e!==a));t(e,i)}}),n("span",null,s))))),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"checkbox":return n("div",{className:"epkb-ai-field epkb-ai-field-checkbox"+(s.field_class?" "+s.field_class:"")},n("label",{className:"epkb-ai-checkbox-label"},n("input",{type:"checkbox",checked:o==="on",onChange:a=>t(e,a.target.checked?"on":"off")}),n("span",{className:"epkb-ai-checkbox-text"},s.label)),s.description&&n("p",{className:"epkb-ai-field-description"},s.description));case"notice":return n("div",{className:"epkb-ai-notice epkb-ai-notice-"+(s.notice_type||"info")},s.message);case"action_button":return null;case"html":return n("div",{className:"epkb-ai-field-html",dangerouslySetInnerHTML:{__html:s.html}});case"section_header":return n("div",{className:"epkb-ai-section-header-field"},n("h4",null,s.label),s.description&&n("p",null,s.description));default:return null}};return n("div",{className:"epkb-ai-settings"},p&&n("div",{className:"epkb-ai-notice epkb-ai-notice-error",style:{marginBottom:"16px"}},n("h4",{style:{margin:"0 0 6px"}},i("Training data issues detected","echo-knowledge-base")),n("p",{style:{margin:"0 0 8px"}},i("AI Chat cannot use the selected collection until these issues are fixed in Training Data.","echo-knowledge-base")),n("ul",{className:"epkb-ai-issue-list",style:{margin:0,paddingLeft:"18px"}},l.map(((e,a)=>n("li",{key:e.collection_id||a},u(e)))))),n("div",{className:"epkb-ai-settings-sections-wrapper"},Object.entries(a.sections||{}).map((([e,t])=>n("div",{key:e,className:"epkb-ai-settings-section"},n("div",{className:"epkb-ai-section-header"},t.icon&&n("span",{className:t.icon}),n("div",{className:"epkb-ai-header-text"},n("h3",null,t.title))),n("div",{className:"epkb-ai-section-content"},(()=>{const s=Object.entries(t.fields||{});if(e==="chat_settings"){const e=a.ai_chat_preset;const t=a.sections&&a.sections.chat_settings&&a.sections.chat_settings.fields&&a.sections.chat_settings.fields.ai_chat_preset?a.sections.chat_settings.fields.ai_chat_preset.value:undefined;const i=(e?e:t)==="custom";const o=a.chat_model_field||"ai_chatgpt_chat_model";const c=a[o]||"";const l=c.indexOf("gpt-5")===0;const r=new Set(["ai_chat_verbosity","ai_chat_reasoning"]);const d=new Set(["ai_chat_temperature","ai_chat_top_p"]);const p=new Set(["ai_chat_enabled","ai_chat_instructions","ai_chat_preset","ai_show_sources"]);const u=new Set([o,"ai_chat_max_output_tokens"]);return s.filter((([e])=>{if(p.has(e))return true;if(!i)return false;if(u.has(e))return true;if(l){return r.has(e)}else{return d.has(e)}})).map((([e,a])=>n("div",{key:e,className:"epkb-ai-field-row"},b(e,a))))}if(e==="display_settings"){const e=a.ai_chat_display_mode||"all_pages";const i=t.location_tabs||{};const o=Object.keys(i).length>0;const c=s.filter((([a,t])=>{if(a==="collection_tabs_description"&&e==="all_pages"){return false}return true})).map((([a,t])=>{const s=a==="ai_chat_display_collection"&&e!=="all_pages";return n("div",{key:a,className:"epkb-ai-field-row"+(s?" epkb-ai-field-hidden":""),"data-field-name":a},b(a,t))}));if(e==="all_pages"||!o){return c}return[...c,n("div",{key:"location-tabs-container",className:"epkb-ai-location-tabs-container"},n("div",{className:"epkb-ai-location-tabs-nav"},Object.entries(i).map((([e,a])=>n("button",{key:e,type:"button",className:`epkb-ai-location-tab-button ${r===e?"active":""}`,onClick:()=>d(e)},a.icon&&n("span",{className:a.icon}),n("span",null,a.title))))),n("div",{className:"epkb-ai-location-tab-content"},(()=>{const e=i[r];if(!e||!e.fields)return null;return Object.entries(e.fields).map((([e,a])=>n("div",{key:e,className:"epkb-ai-field-row"},b(e,a))))})()))]}return s.map((([e,a])=>n("div",{key:e,className:"epkb-ai-field-row"},b(e,a))))})()))))),n("div",{className:"epkb-ai-settings-actions"},n("button",{className:"epkb-ai-button epkb-ai-button-primary",onClick:s,disabled:o},o?i("Saving...","echo-knowledge-base"):i("Save Settings","echo-knowledge-base"))))};const A=({settings:o,tabData:c,isLoading:l,onDataChange:r,makeApiRequest:d,showError:p,showSuccess:u,onTabSwitch:g})=>{const m=10;const[k,w]=e((()=>{const e=new URL(window.location);return e.searchParams.get("active_sub_tab")||c?.active_sub_tab||"chat-history"}));const[v,y]=e(null);const C=s(v);const[A,T]=e([]);const[P,R]=e(null);const[$,E]=e(false);const[I,D]=e(false);const[L,U]=e(c?.ai_config||{});const[F,j]=e(c?.widget_config||{});const[O,B]=e(false);const[M,G]=e(false);const[z,q]=e(1);const[H,K]=e(1);const[J,V]=e(0);const[Y,Q]=e(0);const[W,X]=e([]);const[Z,ee]=e("active");const ae=s(false);const te=s(z);a((()=>{te.current=z}),[z]);a((()=>{C.current=v}),[v]);const[se,ne]=e({ai_chat_enabled:c?.ai_config?.ai_chat_enabled||"off",ai_search_enabled:c?.ai_config?.ai_search_enabled||"off"});a((()=>{if(c){T([]);if(c.ai_config){U(c.ai_config);ne({ai_chat_enabled:c.ai_config.ai_chat_enabled||"off",ai_search_enabled:c.ai_config.ai_search_enabled||"off"})}if(c.widget_config){j(c.widget_config)}}}),[c]);const ie=t((async()=>{G(true);try{const e=await d("ai-chat/conversations",{method:"GET",params:{kb_id:o?.kb_id||1,per_page:100}});if(e&&e.conversations){let a=[...e.conversations];const t=e.pagination?.total_pages||1;for(let e=2;e<=t;e++){const t=await d("ai-chat/conversations",{method:"GET",params:{kb_id:o?.kb_id||1,page:e,per_page:100}});if(t&&t.conversations){a=[...a,...t.conversations]}}R(a);return a}}catch(e){f("AI Chat Admin","Failed to fetch all conversations for filtering",{message:e.message||"Unknown error"});throw e}finally{G(false)}return[]}),[d,o?.kb_id]);const oe=t((async e=>{if(!e)return null;q(1);if(M)return null;if(P&&P.length>0){return P}try{const e=await ie();return e}catch(e){f("AI Chat Admin","Server search failed",{message:e.message||"Unknown error",searchTerm:searchTerm});return null}}),[ie,M,P]);const ce=async(e=1,a=Z)=>{if(!d){return Promise.resolve([])}if(L.ai_chat_enabled==="off"){T([]);R(null);B(true);K(1);V(0);return Promise.resolve([])}E(true);const t=a==="archived"?"true":a==="all"?"all":"false";try{const a=await d("ai-chat/conversations",{method:"GET",params:{kb_id:o?.kb_id||1,per_page:m,page:e,archived:t}});if(a&&a.conversations){T(a.conversations);B(true);K(a.pages||1);V(a.total||0);R(null);if(ae.current){ae.current=false;if(C.current===null){Q((e=>e+1))}}return a.conversations}else{f("AI Chat Admin","No conversations found in response",{response:a});T([]);B(true);R(null);K(1);V(0);ae.current=false;return[]}}catch(e){p(e.message||i("Failed to load conversations","echo-knowledge-base"));throw e}finally{E(false)}};a((()=>{if(k==="chat-history"&&!O){ce(z)}}),[k,O,o?.kb_id,d]);a((()=>{if(k==="chat-history"&&O){ce(z)}}),[z]);a((()=>()=>{B(false);T([]);R(null);y(null)}),[]);const le=c?.ai_config?.ai_disclaimer_accepted==="on";const re=(e,a)=>{const t=["widget_header_title","input_placeholder_text","welcome_message","launcher_background_color","widget_header_background_color","send_button_background_color","new_button_background_color","user_message_background_color","ai_message_background_color"];if(e==="ai_chat_display_mode"){setTimeout((()=>{const e=document.querySelector('[data-field-name="ai_chat_display_collection"]');if(e){if(a==="all_pages"){e.classList.remove("epkb-ai-field-hidden")}else{e.classList.add("epkb-ai-field-hidden")}}}),0)}if(t.includes(e)){j((t=>({...t,[e]:a})))}else{U((t=>({...t,[e]:a})))}};const de=e=>{const a=window.epkb_ai_api?.presets?.chat||{};const t=L.chat_model_field||"ai_chatgpt_chat_model";if(e!=="custom"&&a[e]){const s=a[e];U((a=>{const n={...a,ai_chat_preset:e};if(s.model!==undefined)n[t]=s.model;if(s.verbosity!==undefined)n.ai_chat_verbosity=s.verbosity;if(s.reasoning!==undefined)n.ai_chat_reasoning=s.reasoning;if(s.temperature!==undefined)n.ai_chat_temperature=s.temperature;if(s.max_output_tokens!==undefined)n.ai_chat_max_output_tokens=s.max_output_tokens;if(s.top_p!==undefined)n.ai_chat_top_p=s.top_p;return n}))}else{U((a=>({...a,ai_chat_preset:e})))}};const pe=async()=>{D(true);const e=L.chat_model_field||"ai_chatgpt_chat_model";try{const a={ai_chat_enabled:L.ai_chat_enabled,ai_chat_preset:L.ai_chat_preset,ai_show_sources:L.ai_show_sources,[e]:L[e],ai_chat_instructions:L.ai_chat_instructions,ai_chat_verbosity:L.ai_chat_verbosity,ai_chat_reasoning:L.ai_chat_reasoning,ai_chat_temperature:L.ai_chat_temperature,ai_chat_max_output_tokens:L.ai_chat_max_output_tokens,ai_chat_top_p:L.ai_chat_top_p,ai_chat_display_mode:L.ai_chat_display_mode,ai_chat_display_page_rules:L.ai_chat_display_page_rules,ai_chat_display_other_post_types:L.ai_chat_display_other_post_types,ai_chat_display_url_patterns:L.ai_chat_display_url_patterns?L.ai_chat_display_url_patterns.split("\n").filter((e=>e.trim())).join(","):"",ai_chat_handoff_enabled:L.ai_chat_handoff_enabled,ai_chat_feedback_enabled:L.ai_chat_feedback_enabled,ai_chat_feedback_with_handoff:L.ai_chat_feedback_with_handoff,ai_chat_handoff_method:L.ai_chat_handoff_method,ai_chat_handoff_button_display:L.ai_chat_handoff_button_display,ai_chat_handoff_button_text:L.ai_chat_handoff_button_text,ai_chat_handoff_heading:L.ai_chat_handoff_heading,ai_chat_handoff_keywords:L.ai_chat_handoff_keywords?L.ai_chat_handoff_keywords.split("\n").filter((e=>e.trim())).join(","):"",ai_chat_handoff_destination_email:L.ai_chat_handoff_destination_email,ai_chat_handoff_consent_text:L.ai_chat_handoff_consent_text};if(L.ai_chat_display_mode==="all_pages"){a.ai_chat_display_collection=L.ai_chat_display_collection}else{a.ai_chat_display_collection=L.ai_chat_display_collection;for(let e=2;e<=5;e++){const t=`_${e}`;a[`ai_chat_display_collection${t}`]=L[`ai_chat_display_collection${t}`];a[`ai_chat_display_page_rules${t}`]=L[`ai_chat_display_page_rules${t}`];a[`ai_chat_display_other_post_types${t}`]=L[`ai_chat_display_other_post_types${t}`];a[`ai_chat_display_url_patterns${t}`]=L[`ai_chat_display_url_patterns${t}`]?L[`ai_chat_display_url_patterns${t}`].split("\n").filter((e=>e.trim())).join(","):""}}const t={settings:a};if(F){t.widget_settings=F;t.widget_id=1}const s=await d("ai/settings",{method:"POST",data:t});if(s.success){u(i("Settings saved successfully","echo-knowledge-base"));const e={ai_config:L};if(s.widget_config){e.widget_config=s.widget_config}else{e.widget_config=F}r(e);const a=se.ai_chat_enabled!==L.ai_chat_enabled;const t=se.ai_search_enabled!==L.ai_search_enabled;if(a||t){setTimeout((()=>{const e=new URL(window.location.href);e.searchParams.set("active_tab","chat");window.location.href=e.toString()}),1e3)}else{ne({ai_chat_enabled:L.ai_chat_enabled,ai_search_enabled:L.ai_search_enabled||se.ai_search_enabled})}}}catch(e){if(!h(e)){p(e.message||i("Failed to save settings","echo-knowledge-base"))}}finally{D(false)}};const ue=async(e,a={})=>{const{showSuccessMessage:t=true}=a;try{const a=await d("ai-chat/conversations/bulk",{method:"DELETE",data:{ids:e}});const s=a.success||a===true||typeof a==="string"&&a.includes("deleted successfully")||a.message&&a.message.includes("deleted successfully");if(s){if(t){const e=typeof a==="string"?a:a.message||i("Conversations deleted successfully","echo-knowledge-base");u(e)}const s=a&&Number.isInteger(a.deleted)?a.deleted:e.length;const n=Math.max(0,J-s);const c=Math.max(1,Math.ceil(n/m));V(n);K(c);R(null);X([...e]);const l=C.current!==null&&e.includes(C.current);if(l){ae.current=true;y(null);C.current=null}const r=new Set(e);const p=A.filter((e=>!r.has(e.id)));const b=A.length-p.length;T(p);const h=te.current;if(h>c){q(c);return}const _=()=>{if(!ae.current){return}ae.current=false;if(C.current===null){Q((e=>e+1))}};if(b>0){const e=(h-1)*m+p.length;try{const a=await d("ai-chat/conversations",{method:"GET",params:{kb_id:o?.kb_id||1,per_page:b,offset:e}});if(a&&a.conversations&&te.current===h){T((e=>{const t=new Set(e.map((e=>e.id)));const s=a.conversations.filter((e=>!t.has(e.id)));return s.length?[...e,...s]:e}))}}catch(a){f("AI Chat Admin","Failed to fetch replacement conversations",{message:a.message||"Unknown error",offset:e,count:b})}finally{if(te.current===h){_()}}}else{_()}}else{throw new Error(a.message||a||i("Failed to delete conversations","echo-knowledge-base"))}}catch(e){p(e.message||i("Failed to delete conversations","echo-knowledge-base"));throw e}};const be=async e=>{try{const a=await d("ai-chat/conversations/archive",{method:"POST",data:{ids:e}});if(a.success||a.archived!==undefined){u(a.message||i("Conversations archived successfully","echo-knowledge-base"));R(null);await ce(z)}else{throw new Error(a.message||i("Failed to archive conversations","echo-knowledge-base"))}}catch(e){p(e.message||i("Failed to archive conversations","echo-knowledge-base"));throw e}};const he=async e=>{try{const a=await d("ai-chat/conversations/unarchive",{method:"POST",data:{ids:e}});if(a.success||a.unarchived!==undefined){u(a.message||i("Conversations restored successfully","echo-knowledge-base"));R(null);await ce(z)}else{throw new Error(a.message||i("Failed to restore conversations","echo-knowledge-base"))}}catch(e){p(e.message||i("Failed to restore conversations","echo-knowledge-base"));throw e}};const _e=e=>{ee(e);q(1);y(null);R(null);ce(1,e)};const fe=A.find((e=>e.id===v));const ge=[{id:"chat-history",title:i("Chat History","echo-knowledge-base")},{id:"chat-settings",title:i("Settings","echo-knowledge-base")}];const me=c?.sub_tabs?Object.values(c.sub_tabs):ge;if(!le){const{DisclaimerRequiredMessage:e}=window.EPKB_AI_Util_React||{};if(e){return n(e,{i18n:o?.i18n||{},onAccept:()=>{if(g){g("general-settings")}else{const e=new URL(window.location.href);if(e.searchParams.has("page")){e.searchParams.set("active_tab","general-settings");window.location.href=e.toString()}}}})}}const ke=c?.ai_config?.ai_provider||"gemini";const we=ke==="gemini"?"ai_gemini_key":"ai_chatgpt_key";const ve=c?.ai_config?.[we]&&c.ai_config[we].length>0;const ye=!le||!ve;const Ne=c?.is_ai_features_pro_enabled===true;const xe=()=>{switch(k){case"chat-history":if(L.ai_chat_enabled==="off"){return n("div",{className:"epkb-ai-disabled-message"},n("div",{className:"epkb-ai-notice epkb-ai-notice-warning"},n("h3",null,i("AI Chat is Disabled","echo-knowledge-base")),n("p",null,i("To view chat history, please enable AI Chat in the Settings tab.","echo-knowledge-base")),n("button",{className:"epkb-ai-button epkb-ai-button-primary",onClick:()=>{w("chat-settings");const e=new URL(window.location);e.searchParams.set("active_sub_tab","chat-settings");window.history.pushState({},"",e)}},i("Go to Settings","echo-knowledge-base"))))}return n("div",{className:"epkb-ai-chat-history-wrapper"},ye&&n("div",{className:"epkb-ai-notice epkb-ai-notice-warning",style:{marginBottom:"20px"}},n("p",null,!ve?i("API key is not configured. Please configure it in General Settings to use AI Chat features.","echo-knowledge-base"):i("Please accept the data privacy agreement in General Settings to use AI Chat features.","echo-knowledge-base")),n("a",{href:"#",className:"epkb-ai-button epkb-ai-button-small",onClick:e=>{e.preventDefault();const a=new URL(window.location.href);a.searchParams.set("active_tab","general-settings");window.location.href=a.toString()}},i("Go to General Settings","echo-knowledge-base"))),n("div",{className:"epkb-ai-data-source-layout"},n(N,{conversations:A,allConversations:P,selectedId:v,onSelect:y,onDelete:ue,onArchive:be,onUnarchive:he,viewFilter:Z,onViewFilterChange:_e,isLoading:$,onRefresh:()=>ce(z),onSearch:oe,currentPage:z,totalPages:H,onPageChange:q,autoSelectTopRowSignal:Y,showAgentHandover:Ne,deletedConversationIds:W}),n(x,{key:v,conversation:fe,onDelete:ue,onArchive:be,onUnarchive:he,viewFilter:Z})));case"chat-settings":return n(S,{settings:{...L,...F,sections:c?.settings_sections||{api_config:{title:i("API Configuration","echo-knowledge-base"),icon:"epkbfa epkbfa-cog",fields:{}}}},collectionIssues:c?.collection_issues||[],onChange:re,onSave:pe,isSaving:I,onPresetChange:de});default:return null}};return n("div",{className:"epkb-ai-chat-container"},_&&n(_,{setupSteps:c?.setup_steps,onTabSwitch:g}),me.length>0&&n("div",{className:"epkb-ai-sub-tabs"},n("div",{className:"epkb-ai-sub-tabs-header"},n("div",{className:"epkb-ai-sub-tabs-nav"},me.map((e=>n("button",{key:e.id,className:`epkb-ai-sub-tab-button epkb-ai-sub-tab-${e.id} ${k===e.id?"active":""}`,onClick:()=>{w(e.id);const a=new URL(window.location);a.searchParams.set("active_sub_tab",e.id);window.history.pushState({},"",a)}},e.title)))),b&&n(b),k==="chat-settings"&&n("button",{type:"button",className:"epkb-ai-button epkb-ai-button-primary epkb-ai-sub-tabs-save-button",onClick:pe,disabled:I},I?i("Saving...","echo-knowledge-base"):i("Save Settings","echo-knowledge-base")))),xe())};window.EPKB_AI_Chat={AIAdminChat:A}})();
Save
Cancel