Current File : /home/kelaby89/public_html/wp/wp-content/plugins/ai-engine/app/index.js |
(()=>{"use strict";var __webpack_modules__={1469:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{G:()=>ChatbotContextProvider,o:()=>useChatbotContext});var _app_chatbot_helpers__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6966),_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(1137),_app_helpers__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(7678);const{useContext,createContext,useState,useMemo,useEffect,useCallback,useRef}=wp.element,rawAiName="AI: ",rawUserName="User: ",ChatbotContext=createContext(),useChatbotContext=()=>{const e=useContext(ChatbotContext);if(!e)throw new Error("useChatbotContext must be used within a ChatbotContextProvider");return e},ChatbotContextProvider=({children,...rest})=>{var _params$startSentence;const{params,system,theme,atts}=rest,{timeElapsed,startChrono,stopChrono}=(0,_app_chatbot_helpers__WEBPACK_IMPORTED_MODULE_0__.dh)(),shortcodeStyles=useMemo((()=>(null==theme?void 0:theme.settings)||{}),[theme]),[restNonce,setRestNonce]=useState(system.restNonce),[messages,setMessages]=useState([]),[shortcuts,setShortcuts]=useState([]),[blocks,setBlocks]=useState([]),[locked,setLocked]=useState(!1),[chatId,setChatId]=useState((0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)()),[inputText,setInputText]=useState(""),[chatbotTriggered,setChatbotTriggered]=useState(!1),[showIconMessage,setShowIconMessage]=useState(!1),[uploadedFile,setUploadedFile]=useState({localFile:null,uploadedId:null,uploadedUrl:null,uploadProgress:null}),[windowed,setWindowed]=useState(!0),[open,setOpen]=useState(!1),[error,setError]=useState(null),[busy,setBusy]=useState(!1),[busyNonce,setBusyNonce]=useState(!1),[serverReply,setServerReply]=useState(),chatbotInputRef=useRef(),conversationRef=useRef(),hasFocusRef=useRef(!1),{isListening,setIsListening,speechRecognitionAvailable}=(0,_app_chatbot_helpers__WEBPACK_IMPORTED_MODULE_0__.Vw)((e=>{setInputText(e)})),stream=system.stream||!1,internalId=useMemo((()=>(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)()),[]),botId=system.botId,customId=system.customId,userData=system.userData,sessionId=system.sessionId,contextId=system.contextId,pluginUrl=system.pluginUrl,restUrl=system.restUrl,debugMode=system.debugMode,virtualKeyboardFix=system.virtual_keyboard_fix,typewriter=(null==system?void 0:system.typewriter)??!1,speechRecognition=(null==system?void 0:system.speech_recognition)??!1,speechSynthesis=(null==system?void 0:system.speech_synthesis)??!1,startSentence=(0,_app_chatbot_helpers__WEBPACK_IMPORTED_MODULE_0__.Mc)((null===(_params$startSentence=params.startSentence)||void 0===_params$startSentence?void 0:_params$startSentence.trim())??"",userData),initialActions=system.actions||[],initialShortcuts=system.shortcuts||[],initialBlocks=system.blocks||[],isMobile=document.innerWidth<=768,processedParams=(0,_app_chatbot_helpers__WEBPACK_IMPORTED_MODULE_0__._$)(params,userData),{aiName,userName,guestName,aiAvatar,userAvatar,guestAvatar}=processedParams,{textSend,textClear,textInputMaxLength,textInputPlaceholder,textCompliance,window:isWindow,copyButton,headerSubtitle,fullscreen,localMemory:localMemoryParam,icon,iconText,iconTextDelay,iconAlt,iconPosition,iconBubble,imageUpload,fileUpload,fileSearch}=processedParams,isRealtime="realtime"===processedParams.mode,localMemory=localMemoryParam&&(!!customId||!!botId),localStorageKey=localMemory?`mwai-chat-${customId||botId}`:null,{cssVariables,iconUrl,aiAvatarUrl,userAvatarUrl,guestAvatarUrl}=useMemo((()=>{const e=e=>e?(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.Ve)(e)||(0,_app_chatbot_helpers__WEBPACK_IMPORTED_MODULE_0__.mv)(e)?e:`${pluginUrl}/images/${e}`:null,t=icon?e(icon):`${pluginUrl}/images/chat-traditional-1.svg`,a=e(processedParams.aiAvatarUrl),n=e(processedParams.userAvatarUrl),l=e(processedParams.guestAvatarUrl);return{cssVariables:Object.keys(shortcodeStyles).reduce(((e,t)=>(e[`--mwai-${t}`]=shortcodeStyles[t],e)),{}),iconUrl:t,aiAvatarUrl:a,userAvatarUrl:n,guestAvatarUrl:l}}),[icon,pluginUrl,shortcodeStyles,processedParams]),[draggingType,setDraggingType]=useState(!1),[isBlocked,setIsBlocked]=useState(!1),uploadIconPosition=useMemo((()=>"timeless"===(null==theme?void 0:theme.themeId)?"mwai-tools":"mwai-input"),[null==theme?void 0:theme.themeId]),submitButtonConf=useMemo((()=>({text:textSend,textSend,textClear,imageSend:"timeless"===(null==theme?void 0:theme.themeId)?pluginUrl+"/images/action-submit-blue.svg":null,imageClear:"timeless"===(null==theme?void 0:theme.themeId)?pluginUrl+"/images/action-clear-blue.svg":null})),[pluginUrl,textClear,textSend,null==theme?void 0:theme.themeId]),resetMessages=()=>{if(resetUploadedFile(),startSentence){const e=[{id:(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)(),role:"assistant",content:startSentence,who:rawAiName,timestamp:(new Date).getTime()}];setMessages(e)}else setMessages([])},refreshRestNonce=useCallback((async(e=!1)=>{try{if(!e&&restNonce)return restNonce;setBusyNonce(!0);const t=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.ti)(`${restUrl}/mwai/v1/start_session`),a=await t.json();return setRestNonce(a.restNonce),a.restNonce}catch(e){console.error("Error while fetching the restNonce.",e)}finally{setBusyNonce(!1)}}),[restNonce,setRestNonce,restUrl]);useEffect((()=>{initialActions.length>0&&handleActions(initialActions),initialShortcuts.length>0&&handleShortcuts(initialShortcuts),initialBlocks.length>0&&handleBlocks(initialBlocks)}),[]),useEffect((()=>{chatbotTriggered&&!restNonce&&refreshRestNonce()}),[chatbotTriggered]),useEffect((()=>{inputText.length>0&&!chatbotTriggered&&setChatbotTriggered(!0)}),[chatbotTriggered,inputText]),useEffect((()=>{resetMessages()}),[startSentence]),useEffect((()=>{if(customId||botId){const e=_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__.HX.chatbots.findIndex((e=>e.internalId===internalId)),t={internalId,botId,chatId,customId,open:()=>{setTasks((e=>[...e,{action:"open"}]))},close:()=>{setTasks((e=>[...e,{action:"close"}]))},clear:e=>{const{chatId:t=null}=e||{};setTasks((e=>[...e,{action:"clear",data:{chatId:t}}]))},toggle:()=>{setTasks((e=>[...e,{action:"toggle"}]))},ask:(e,t=!1)=>{setTasks((a=>[...a,{action:"ask",data:{text:e,submit:t}}]))},lock:()=>{setLocked(!0)},unlock:()=>{setLocked(!1)},setShortcuts:e=>{setTasks((t=>[...t,{action:"setShortcuts",data:e}]))},setBlocks:e=>{setTasks((t=>[...t,{action:"setBlocks",data:e}]))},addBlock:e=>{setTasks((t=>[...t,{action:"addBlock",data:e}]))},removeBlockById:e=>{setTasks((t=>[...t,{action:"removeBlockById",data:e}]))},getBlocks:()=>blocks,setContext:({chatId:e,messages:t})=>{setTasks((a=>[...a,{action:"setContext",data:{chatId:e,messages:t}}]))}};-1!==e?_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__.HX.chatbots[e]=t:_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__.HX.chatbots.push(t)}}),[botId,chatId,customId,internalId]),useEffect((()=>{busy?startChrono():(!isMobile&&hasFocusRef.current&&chatbotInputRef.current.focusInput(),stopChrono())}),[busy,startChrono,stopChrono,isMobile]);const saveMessages=useCallback((e=>{localStorageKey&&localStorage.setItem(localStorageKey,(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.F1)({chatId,messages:e}))}),[localStorageKey,chatId]),resetError=()=>{setError(null)};useEffect((()=>{let e=[];if(localStorageKey&&(e=localStorage.getItem(localStorageKey),e))return e=JSON.parse(e),setMessages(e.messages),void setChatId(e.chatId);resetMessages()}),[botId]);const handleActions=useCallback(((actions,lastMessage)=>{actions=actions||[];let callsCount=0;for(const action of actions)if("function"===action.type){const data=action.data||{},{name=null,args=[]}=data,finalArgs=args?Object.values(args).map((e=>JSON.stringify(e))):[];try{debugMode&&console.log(`[CHATBOT] CALL ${name}(${finalArgs.join(", ")})`),eval(`${name}(${finalArgs.join(", ")})`),callsCount++}catch(e){console.error("Error while executing an action.",e)}}!lastMessage.content&&callsCount>0&&(lastMessage.content="*Done!*")}),[debugMode]),handleShortcuts=useCallback((e=>{setShortcuts(e||[])}),[]),handleBlocks=useCallback((e=>{setBlocks(e||[])}),[]);useEffect((()=>{if(!serverReply)return;setBusy(!1);const e=[...messages],t=e.length>0?e[e.length-1]:null;if(!serverReply.success)return"assistant"===t.role&&t.isQuerying&&e.pop(),e.pop(),e.push({id:(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)(),role:"system",content:serverReply.message,who:rawAiName,timestamp:(new Date).getTime()}),setMessages(e),void saveMessages(e);if("assistant"===t.role&&t.isQuerying)t.content=(0,_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__.W5)("ai.reply",serverReply.reply,{chatId,botId}),serverReply.images&&(t.images=serverReply.images),t.timestamp=(new Date).getTime(),delete t.isQuerying,handleActions(null==serverReply?void 0:serverReply.actions,t),handleBlocks(null==serverReply?void 0:serverReply.blocks),handleShortcuts(null==serverReply?void 0:serverReply.shortcuts);else if("assistant"===t.role&&t.isStreaming)t.content=(0,_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__.W5)("ai.reply",serverReply.reply,{chatId,botId}),serverReply.images&&(t.images=serverReply.images),t.timestamp=(new Date).getTime(),delete t.isStreaming,handleActions(null==serverReply?void 0:serverReply.actions,t),handleBlocks(null==serverReply?void 0:serverReply.blocks),handleShortcuts(null==serverReply?void 0:serverReply.shortcuts);else{const t={id:(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)(),role:"assistant",content:(0,_app_chatbot_MwaiAPI__WEBPACK_IMPORTED_MODULE_2__.W5)("ai.reply",serverReply.reply,{botId,chatId,customId}),who:rawAiName,timestamp:(new Date).getTime()};serverReply.images&&(t.images=serverReply.images),handleActions(null==serverReply?void 0:serverReply.actions,t),handleBlocks(null==serverReply?void 0:serverReply.blocks),handleShortcuts(null==serverReply?void 0:serverReply.shortcuts),e.push(t)}setMessages(e),saveMessages(e)}),[serverReply]);const onClear=useCallback((async({chatId:e=null}={})=>{e||(e=(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)()),await setChatId(e),localStorageKey&&localStorage.removeItem(localStorageKey),resetMessages(),setInputText(""),setShortcuts([]),setBlocks([])}),[botId]),onStartRealtimeSession=useCallback((async()=>{const e={botId,customId,contextId,chatId},t=restNonce??await refreshRestNonce(),a=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.ti)(`${restUrl}/mwai-ui/v1/openai/realtime/start`,e,t);return await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.Pn)(a)}),[botId,customId,contextId,chatId,restNonce,refreshRestNonce,restUrl]),onCommitStats=useCallback((async(e,t=null)=>{try{const a=restNonce??await refreshRestNonce(),n=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.ti)(`${restUrl}/mwai-ui/v1/openai/realtime/stats`,{botId,session:sessionId,refId:t||chatId,stats:e},a),l=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.Pn)(n);return{success:l.success,message:l.message}}catch(e){return console.error("Error while committing stats.",e),{success:!1,message:"An error occurred while committing the stats."}}}),[botId,restNonce,refreshRestNonce,restUrl,sessionId,chatId]),onCommitDiscussions=useCallback((async(e=[])=>{try{const t=restNonce??await refreshRestNonce(),a={botId,session:sessionId,chatId,messages:e??[]},n=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.ti)(`${restUrl}/mwai-ui/v1/openai/realtime/discussions`,a,t),l=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.Pn)(n);return{success:l.success,message:l.message}}catch(e){return console.error("Error while committing discussion.",e),{success:!1,message:"An error occurred while committing the discussion."}}}),[botId,chatId,restNonce,refreshRestNonce,restUrl,sessionId]),onRealtimeFunctionCallback=useCallback((async(functionId,functionType,functionName,functionTarget,args)=>{const body={functionId,functionType,functionName,functionTarget,arguments:args};if("js"!==functionTarget){const e=restNonce??await refreshRestNonce(),t=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.ti)(`${restUrl}/mwai-ui/v1/openai/realtime/call`,body,e),a=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.Pn)(t);return a}{const finalArgs=args?Object.values(args).map((e=>JSON.stringify(e))):[];try{return debugMode&&console.log(`[CHATBOT] CALL ${functionName}(${finalArgs.join(", ")})`),eval(`${functionName}(${finalArgs.join(", ")})`),{success:!0,message:"The function was executed",data:null}}catch(e){return console.error("Error while executing an action.",e),{success:!1,message:"An error occurred while executing the function.",data:null}}}return null}),[restNonce,refreshRestNonce,restUrl,debugMode]),onSubmit=useCallback((async e=>{var t;if(busy)return void console.error("AI Engine: There is already a query in progress.");"string"!=typeof e&&(e=inputText);const a=uploadedFile,n=null==uploadedFile?void 0:uploadedFile.uploadedUrl,l=null==uploadedFile||null===(t=uploadedFile.localFile)||void 0===t?void 0:t.type,r=!!l&&l.startsWith("image");let o=e;n&&(o=r?`\n${e}`:`[Uploaded File](${n})\n${e}`),setBusy(!0),setInputText(""),setShortcuts([]),setBlocks([]),resetUploadedFile();const c=[...messages,{id:(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)(),role:"user",content:o,who:rawUserName,timestamp:(new Date).getTime()}];saveMessages(c);const i=(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.vx)(),s=[...c,{id:i,role:"assistant",content:null,who:rawAiName,timestamp:null,isQuerying:!stream,isStreaming:!!stream}];setMessages(s);const m={botId,customId,session:sessionId,chatId,contextId,messages,newMessage:e,newFileId:null==a?void 0:a.uploadedId,stream,...atts};try{debugMode&&console.log("[CHATBOT] OUT: ",m);const e=stream?e=>{setMessages((t=>{const a=[...t],n=a.length>0?a[a.length-1]:null;return n&&n.id===i&&(n.content=e,n.timestamp=(new Date).getTime()),a}))}:null,t=restNonce??await refreshRestNonce(),a=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.ti)(`${restUrl}/mwai-ui/v1/chats/submit`,m,t,stream),n=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.Pn)(a,e,debugMode?"CHATBOT":null);if(!n.success&&n.message){setError(n.message);const e=[...s];return e.pop(),e.pop(),setMessages(e),saveMessages(e),void setBusy(!1)}setServerReply(n)}catch(e){console.error("An error happened in the handling of the chatbot response.",{err:e}),setBusy(!1)}}),[busy,uploadedFile,messages,saveMessages,stream,botId,customId,sessionId,chatId,contextId,atts,inputText,debugMode,restNonce,refreshRestNonce,restUrl]),onSubmitAction=useCallback(((e=null)=>{const t=!(null==uploadedFile||!uploadedFile.uploadedId);hasFocusRef.current=document.activeElement===chatbotInputRef.current.currentElement(),e?onSubmit(e):(t||inputText.length>0)&&onSubmit(inputText)}),[inputText,onSubmit,null==uploadedFile?void 0:uploadedFile.uploadedId]),onFileUpload=async(e,t="N/A",a="N/A")=>{try{if(null===e)return void resetUploadedFile();const n={type:t,purpose:a},l=`${restUrl}/mwai-ui/v1/files/upload`,r=restNonce??await refreshRestNonce(),o=await(0,_app_helpers__WEBPACK_IMPORTED_MODULE_1__.uE)(l,e,r,(t=>{setUploadedFile({localFile:e,uploadedId:null,uploadedUrl:null,uploadProgress:t})}),n);setUploadedFile({localFile:e,uploadedId:o.data.id,uploadedUrl:o.data.url,uploadProgress:null})}catch(e){console.error("onFileUpload Error",e),setError(e.message||"An unknown error occurred"),resetUploadedFile()}},onUploadFile=async e=>(error&&resetError(),onFileUpload(e)),resetUploadedFile=()=>{setUploadedFile({localFile:null,uploadedId:null,uploadedUrl:null,uploadProgress:null})},runTimer=useCallback((()=>{const e=setTimeout((()=>{setOpen((e=>(e||setShowIconMessage(!0),e)))}),1e3*iconTextDelay);return()=>clearTimeout(e)}),[iconText,iconTextDelay]);useEffect((()=>{if(iconText&&!iconTextDelay)setShowIconMessage(!0);else if(iconText&&iconTextDelay)return runTimer()}),[iconText]);const[tasks,setTasks]=useState([]),runTasks=useCallback((async()=>{if(tasks.length>0){const e=tasks[0];if("ask"===e.action){const{text:t,submit:a}=e.data;a?onSubmit(t):setInputText(t)}else if("toggle"===e.action)setOpen((e=>!e));else if("open"===e.action)setOpen(!0);else if("close"===e.action)setOpen(!1);else if("clear"===e.action){const{chatId:t}=e.data;onClear({chatId:t})}else if("setContext"===e.action){const{chatId:t,messages:a}=e.data;setChatId(t),setMessages(a)}else if("setShortcuts"===e.action){const t=e.data;handleShortcuts(t)}else if("setBlocks"===e.action){const t=e.data;handleBlocks(t)}else if("addBlock"===e.action){const t=e.data;setBlocks((e=>[...e,t]))}else if("removeBlockById"===e.action){const t=e.data;setBlocks((e=>e.filter((e=>e.id!==t))))}setTasks((e=>e.slice(1)))}}),[tasks,onClear,onSubmit,setChatId,setInputText,setMessages,setOpen,handleShortcuts,handleBlocks]);useEffect((()=>{runTasks()}),[runTasks]);const actions={setInputText,saveMessages,setMessages,resetMessages,resetError,onClear,onSubmit,onSubmitAction,onFileUpload,onUploadFile,setOpen,setWindowed,setShowIconMessage,setIsListening,setDraggingType,setIsBlocked,onStartRealtimeSession,onRealtimeFunctionCallback,onCommitStats,onCommitDiscussions},state={theme,botId,customId,userData,pluginUrl,inputText,messages,shortcuts,blocks,busy,error,setBusy,typewriter,speechRecognition,speechSynthesis,virtualKeyboardFix,localMemory,isRealtime,imageUpload,fileUpload,uploadedFile,fileSearch,textSend,textClear,textInputMaxLength,textInputPlaceholder,textCompliance,aiName,userName,guestName,aiAvatar,userAvatar,guestAvatar,aiAvatarUrl,userAvatarUrl,guestAvatarUrl,isWindow,copyButton,headerSubtitle,fullscreen,icon,iconText,iconAlt,iconPosition,iconBubble,cssVariables,iconUrl,chatbotInputRef,conversationRef,isMobile,open,locked,windowed,showIconMessage,timeElapsed,isListening,speechRecognitionAvailable,uploadIconPosition,submitButtonConf,draggingType,isBlocked,busyNonce};return React.createElement(ChatbotContext.Provider,{value:{state,actions}},children)}},1137:(e,t,a)=>{a.d(t,{HX:()=>l,W5:()=>r});class n{constructor(){if("undefined"!=typeof window&&window.MwaiAPI)return window.MwaiAPI;this.chatbots=[],this.forms=[],this.filters={},this.actions={},"undefined"!=typeof window&&(window.MwaiAPI=this)}getChatbot(e=null){return e?this.chatbots.find((t=>t.botId===e||t.customId===e)):this.chatbots[0]}getForm(e=null){return e?this.forms.find((t=>t.formId===e)):this.forms[0]}addFilter(e,t,a=10){this.filters[e]||(this.filters[e]=[]),this.filters[e].push({callback:t,priority:a}),this.filters[e].sort(((e,t)=>e.priority-t.priority))}applyFilters(e,t,...a){return this.filters[e]?this.filters[e].reduce(((e,t)=>t.callback(e,...a)),t):t}addAction(e,t,a=10){this.actions[e]||(this.actions[e]=[]),this.actions[e].push({callback:t,priority:a}),this.actions[e].sort(((e,t)=>e.priority-t.priority))}doAction(e,...t){this.actions[e]&&this.actions[e].forEach((e=>{e.callback(...t)}))}}const l=(()=>{if("undefined"!=typeof window&&window.MwaiAPI)return window.MwaiAPI;const e=new n;return"undefined"!=typeof window&&(window.MwaiAPI=e),e})(),r=(e,t,...a)=>l.applyFilters(e,t,...a)},6966:(e,t,a)=>{a.d(t,{Mc:()=>p,Vw:()=>R,_$:()=>g,bE:()=>h,dh:()=>E,gR:()=>d,kW:()=>y,mv:()=>u,tm:()=>m});var n=a(8614);function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},l.apply(this,arguments)}const{useState:r,useMemo:o,useEffect:c,useRef:i,useCallback:s}=wp.element,m=({active:e,disabled:t,...a})=>React.createElement("div",l({active:e?"true":"false",disabled:t},a),React.createElement(n.A,{size:"24"})),d=()=>o((()=>(e,t)=>(Array.isArray(e)||(e=[e]),t&&Object.entries(t).forEach((([t,a])=>{a&&e.push(t)})),e.join(" "))),[]);function u(e){return!(!e||"string"!=typeof e)&&0===e.indexOf("http")}function E(){const[e,t]=r(null),a=i(null);return c((()=>()=>{clearInterval(a.current)}),[]),{timeElapsed:e,startChrono:function(){if(null!==a.current)return;const e=Date.now();a.current=setInterval((()=>{const a=Math.floor((Date.now()-e)/1e3);var n;t((n=a,`${Math.floor(n/60)}:${(n%60).toString().padStart(2,"0")}`))}),500)},stopChrono:function(){clearInterval(a.current),a.current=null,t(null)}}}const p=(e,t)=>"string"==typeof e&&t?(Object.entries(t).forEach((([t,a])=>{e=e.replace(new RegExp(`{${t}}`,"g"),a)})),e):e,g=(e,t=[])=>{var a,n,l,r,o,c,i,s,m,d,u,E,g,R,h;const y=(null===(a=e.guestName)||void 0===a?void 0:a.trim())??"",b=(null===(n=e.textSend)||void 0===n?void 0:n.trim())??"",v=(null===(l=e.textClear)||void 0===l?void 0:l.trim())??"",f=parseInt(e.textInputMaxLength),_=(null===(r=e.textInputPlaceholder)||void 0===r?void 0:r.trim())??"";let w=(null===(o=e.textCompliance)||void 0===o?void 0:o.trim())??"",C="";const O=Boolean(e.window),T=Boolean(e.copyButton),N=Boolean(e.fullscreen),I=(null===(c=e.icon)||void 0===c?void 0:c.trim())??"";let M=(null===(i=e.iconText)||void 0===i?void 0:i.trim())??"";const S=parseInt(e.iconTextDelay||1),A=(null===(s=e.iconAlt)||void 0===s?void 0:s.trim())??"",k=(null===(m=e.iconPosition)||void 0===m?void 0:m.trim())??"",x=Boolean(e.iconBubble),P=(null===(d=e.aiName)||void 0===d?void 0:d.trim())??"",L=(null===(u=e.userName)||void 0===u?void 0:u.trim())??"",D=Boolean(null==e?void 0:e.aiAvatar),F=Boolean(null==e?void 0:e.userAvatar),U=Boolean(null==e?void 0:e.guestAvatar),B=D?(null==e||null===(E=e.aiAvatarUrl)||void 0===E?void 0:E.trim())??"":null,G=F?(null==e||null===(g=e.userAvatarUrl)||void 0===g?void 0:g.trim())??"":null,H=U?(null==e||null===(R=e.guestAvatarUrl)||void 0===R?void 0:R.trim())??"":null,j=Boolean(e.localMemory),$=Boolean(e.imageUpload),Y=Boolean(e.fileUpload),W=Boolean(e.fileSearch),z=(null===(h=e.mode)||void 0===h?void 0:h.trim())??"chat";var V;return C=null===e.headerSubtitle||void 0===e.headerSubtitle?"Discuss with":(null===(V=e.headerSubtitle)||void 0===V?void 0:V.trim())??"",t&&(w=p(w,t),M=p(M,t)),{textSend:b,textClear:v,textInputMaxLength:f,textInputPlaceholder:_,textCompliance:w,mode:z,window:O,copyButton:T,fullscreen:N,localMemory:j,imageUpload:$,fileUpload:Y,fileSearch:W,icon:I,iconText:M,iconTextDelay:S,iconAlt:A,iconPosition:k,iconBubble:x,headerSubtitle:C,aiName:P,userName:L,guestName:y,aiAvatar:D,userAvatar:F,guestAvatar:U,aiAvatarUrl:B,userAvatarUrl:G,guestAvatarUrl:H}},R=e=>{const[t,a]=r(!1),[n,l]=r(!1);return c((()=>{"undefined"!=typeof window&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)&&l(!0)}),[]),c((()=>{if(!n)return;const l=new(window.SpeechRecognition||window.webkitSpeechRecognition);let r=null;return navigator.userAgent.toLowerCase().indexOf("android")>-1?(l.interimResults=!1,l.continuous=!1,r=t=>{const n=Array.from(t.results).filter((e=>e.isFinal)).map((e=>e[0].transcript)).join("");e(n),a(!1)}):(l.interimResults=!0,l.continuous=!0,r=t=>{const a=Array.from(t.results).map((e=>e[0])).map((e=>e.transcript)).join("");e(a)}),t?(l.addEventListener("result",r),l.start()):(l.removeEventListener("result",r),l.abort()),()=>{l.abort()}}),[t,n]),{isListening:t,setIsListening:a,speechRecognitionAvailable:n}},h=({if:e,className:t,disableTransition:a=!1,children:n,...o})=>{const[i,s]=r(!1),[m,d]=r("mwai-transition");return c((()=>{a?s(e):e?(s(!0),setTimeout((()=>{d("mwai-transition mwai-transition-visible")}),150)):d("mwai-transition")}),[e,a]),i?React.createElement("div",l({className:`${t} ${a?"":m}`,onTransitionEnd:()=>{"mwai-transition"!==m||a||s(!1)}},o),n):null},y=()=>{const[e,t]=r(window.visualViewport.height),a=o((()=>/Android/.test(navigator.userAgent)),[]),n=o((()=>/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream),[]),l=i(window.visualViewport),m=s((()=>{t(l.current.height)}),[]);return c((()=>{const e=l.current;return e.addEventListener("resize",m),n?(window.addEventListener("resize",m),document.addEventListener("focusin",m)):e.addEventListener("scroll",m),()=>{e.removeEventListener("resize",m),n?(window.removeEventListener("resize",m),document.removeEventListener("focusin",m)):e.removeEventListener("scroll",m)}}),[m,n]),{viewportHeight:e,isIOS:n,isAndroid:a}}},7678:(e,t,a)=>{a.d(t,{CI:()=>E,F1:()=>c,Pn:()=>i,Ve:()=>g,rn:()=>u,ti:()=>s,uE:()=>m,vx:()=>d});var n=a(6841);const{useMemo:l,useEffect:r,useState:o}=wp.element;function c(e,t=null,a=!0){const n=[];return JSON.stringify(e,((e,t)=>{if("object"==typeof t&&null!==t){if(n.includes(t)){if(!a)throw console.warn("Circular reference found.",{key:e,value:t,cache:n,cacheIndex:n.indexOf(t)}),new Error("Circular reference found. Cancelled.");return}n.push(t)}return t}),t)}async function i(e,t,a=null){if(!t)try{const t=await e.json();return a&&console.log(`[${a}] IN: `,t),t}catch(e){return console.error("Could not parse the regular response.",{err:e,data}),{success:!1,message:"Could not parse the regular response."}}const n=e.body.getReader(),l=new TextDecoder("utf-8");let r="",o="";for(;;){const{value:e,done:c}=await n.read();if(r+=l.decode(e,{stream:!0}),c)break;const i=r.split("\n");for(let e=0;e<i.length-1;e++){if(0!==i[e].indexOf("data: "))continue;const n=JSON.parse(i[e].replace("data: ",""));if("live"===n.type)a&&console.log(`[${a} STREAM] LIVE: `,n),o+=n.data,t&&t(o,n.data);else if("error"===n.type)try{return a&&console.error(`[${a} STREAM] ERROR: `,n.data),{success:!1,message:n.data}}catch(e){return console.error("Could not parse the 'error' stream.",{err:e,data:n}),{success:!1,message:"Could not parse the 'error' stream."}}else if("end"===n.type)try{const e=JSON.parse(n.data);return a&&console.log(`[${a} STREAM] END: `,e),e}catch(e){return console.error("Could not parse the 'end' stream.",{err:e,data:n}),{success:!1,message:"Could not parse the 'end' stream."}}}r=i[i.length-1]}try{const e=JSON.parse(r);return a&&console.log(`[${a} STREAM] IN: `,e),e}catch(e){return console.error("Could not parse the buffer.",{err:e,buffer:r}),{success:!1,message:"Could not parse the buffer."}}}async function s(e,t,a,n){const l={"Content-Type":"application/json"};return a&&(l["X-WP-Nonce"]=a),n&&(l.Accept="text/event-stream"),await fetch(`${e}`,{method:"POST",headers:l,body:c(t)})}async function m(e,t,a,n,l={}){return new Promise(((r,o)=>{const c=new FormData;c.append("file",t);for(const[e,t]of Object.entries(l))c.append(e,t);const i=new XMLHttpRequest;i.open("POST",e,!0),a&&i.setRequestHeader("X-WP-Nonce",a),i.upload.onprogress=function(e){if(e.lengthComputable&&n){const t=e.loaded/e.total*100;n(t)}},i.onload=function(){if(i.status>=200&&i.status<300)try{const e=JSON.parse(i.responseText);r(e)}catch(e){o({status:i.status,statusText:i.statusText,error:"The server response is not valid JSON"})}else{try{const e=JSON.parse(i.responseText);return void o({status:i.status,message:e.message})}catch(e){}o({status:i.status,statusText:i.statusText})}},i.onerror=function(){o({status:i.status,statusText:i.statusText})},i.send(c)}))}function d(){return Math.random().toString(36).substring(2)}const u=()=>{const[e,t]=o(!0);r((()=>{const e=setTimeout((()=>{const e=setInterval((()=>{t((e=>!e))}),500);return()=>clearInterval(e)}),200);return()=>clearTimeout(e)}),[]);const a={opacity:e?1:0,width:"1px",height:"1em",borderLeft:"8px solid",marginLeft:"2px"};return React.createElement("span",{style:a})},E=e=>{const{content:t,error:a,isStreaming:r,baseClass:o="mwai-output-handler"}=e;let c=(a||t)??"";(c.match(/```/g)||[]).length%2!=0?c+="\n```":r&&(c+="<BlinkingCursor />");const i=l((()=>{const e=[o];return a&&e.push("mwai-error"),e}),[a]),s=l((()=>({wrapper:"div",forceWrapper:!0,overrides:{BlinkingCursor:{component:u},a:{props:{target:"_blank"}}}})),[]);return React.createElement(n.Ay,{options:s,className:i.join(" "),children:c})},p=/([\u2700-\u27BF]|[\uE000-\uF8FF]|[\uD800-\uDFFF]|[\uFE00-\uFE0F]|[\u1F100-\u1F1FF]|[\u1F200-\u1F2FF]|[\u1F300-\u1F5FF]|[\u1F600-\u1F64F]|[\u1F680-\u1F6FF]|[\u1F700-\u1F77F]|[\u1F780-\u1F7FF]|[\u1F800-\u1F8FF]|[\u1F900-\u1F9FF]|[\u1FA00-\u1FA6F])/;function g(e){return e&&2===e.length&&p.test(e)}},1615:(e,t,a)=>{var n=a(5323),l=a(7665),r=a(2564),o=a(9270),c=a(7097),i=a(4977),s=a(7039),m=a(4536),d=a(5263),u=a(6913),E=a(1829),p=a(4547),g=a(3676),R=a(9296),h=a(4461),y=a(8135);const b=mwai.prefix,v=mwai.domain,f=mwai.rest_url.replace(/\/+$/,""),_=mwai.api_url.replace(/\/+$/,""),w=mwai.plugin_url.replace(/\/+$/,""),C=mwai.user_data,O="1"===mwai.is_pro,T=O&&"1"===mwai.is_registered,N=mwai.rest_nonce,I=mwai.options,M=mwai.session,S=mwai.themes,A=!!mwai.stream,k=mwai.chatbots;var x=a(197),P=a(3185);const L=P.Ay.div`
color: white;
padding: 15px;
margin-bottom: -15px;
a {
color: #7dedff;
text-decoration: none;
}
p {
font-size: 15px;
}
`,D=(0,P.Ay)(h.z)`
.neko-block-title {
display: none;
}
.plugin-desc {
display: flex;
flex-direction: column;
margin-left: 15px;
}
.neko-block-content {
display: flex;
padding: 15px;
h2 {
font-size: 18px;
margin: 0;
a {
text-decoration: none;
}
}
p {
margin: 0px;
margin-top: 10px;
font-size: 13px;
line-height: 1.5;
}
.plugin-actual-desc {
font-size: 13px;
font-weight: 500;
}
}
`,F=P.Ay.img`
height: 125px;
width: auto;
border-radius: 10px;
background: lightgray;
`,U=P.Ay.div`
margin: 15px;
.center {
background: white;
color: black;
border-radius: 10px;
padding: 10px;
max-width: 100%
overflow: none;
h2 {
font-size: 26px;
}
table {
width: 100%;
tr td:first-child {
width: 220px;
font-weight: bold;
color: #1e7cba;
}
* {
overflow-wrap: anywhere;
}
}
}
hr {
border-color: #1e7cba;
}
`,B=P.Ay.ul`
margin-top: 10px;
background: rgb(0, 72, 88);
padding: 10px;
color: rgb(58, 212, 58);
max-height: 600px;
min-height: 200px;
display: block;
font-family: monospace;
font-size: 12px;
white-space: pre;
overflow-x: auto;
width: calc(100vw - 276px);
color: white;
.log-date {
color: var(--neko-yellow);
margin-left: 8px;
}
.log-type {
background: #0000004d;
padding: 2px 5px;
border-radius: 8px;
text-transform: uppercase;
}
.log-content {
display: block;
}
.log-warning .log-type {
background: var(--neko-yellow);
color: white;
}
.log-fatal .log-type {
background: var(--neko-red);
color: white;
}
`,{useState:G,useEffect:H}=wp.element,j=`${f}/meow-common/v1`,$=({request:e,title:t,max:a})=>{const[n,l]=G(!1),[r,o]=G([]),c=r.length>0?r.reduce((function(e,t){return e+t})):0,s=r.length>0?Math.ceil(c/r.length):0,m=!r.length&&n;return H((()=>{n&&setTimeout((async()=>{const t=(new Date).getTime();await(0,y.IU)(`${j}/${e}`,{method:"POST",nonce:N});const a=(new Date).getTime()-t;o((e=>[...e,a]))}),1e3)}),[r]),React.createElement(L,{style:{width:200,textAlign:"center"}},React.createElement(i.s,{h2:!0,style:{color:"white"}},t),React.createElement(x.X,{size:200,value:m?a:s,max:a},React.createElement("span",{style:{fontSize:20}},m?"START":s+" ms"),React.createElement("span",{style:{fontSize:12}},m?"YOUR ENGINE":r.length+" requests")),React.createElement(R.M,{style:{width:"100%",marginTop:10},color:n?"#cc3627":"#ccb027",onClick:()=>{n||o([]),l(!n)}},n?"Stop":"Start"))},{useState:Y,useEffect:W}=wp.element;_&&f&&w||console.error("[@common/dashboard] apiUrl, restUrl and pluginUrl are mandatory.");const z=`${f}/meow-common/v1`,V=React.createElement(L,null,React.createElement(i.s,{p:!0,style:{lineHeight:"1.5",margin:"0 0 15px 0"}},"Hi! ☀️ Meow Apps isn't your typical plugin suite—it's a passion project led by me, ",React.createElement("a",{target:"_blank",href:"https://jordymeow.com"},"Jordy Meow"),", and a stellar team! 💕 Based in ",React.createElement("a",{target:"_blank",href:"https://offbeatjapan.org"},"Japan"),", we're all about making your WordPress experience smoother and speedier. Our plugins are all about boosting your site's performance and user-friendliness. Ready to level up your WordPress game? Check out ",React.createElement("a",{href:"http://meowapps.com",target:"_blank"},"Meow Apps")," and let's make magic happen! 🌴🙀")),K=React.createElement(L,null,React.createElement(i.s,{p:!0},"The ",React.createElement("b",null,"Empty Request Time")," measures your installation's basic performance by showing the average time needed to process an empty request on your server. To see how disabling plugins affects the results, turn some off and run the test again. Aim for a time under 2,000 ms, but ideally, keep it below 500 ms. The ",React.createElement("b",null,"File Operation Time")," creates a temporary 10MB file each time it runs. ",React.createElement("b",null,"The SQL Request Time")," calculates the total number of posts. This process should be quick and have a similar duration to the Empty Request Time.")),q=React.createElement(L,null,React.createElement(i.s,{p:!0},"Maintain a streamlined WordPress setup by using essential plugins and a dependable hosting provider. Refrain from self-hosting unless you're an expert. Go further by reading our tutorials:",React.createElement("ul",null,React.createElement("li",null,"⭐️ ",React.createElement("a",{href:"https://meowapps.com/tutorial-improve-seo-wordpress/",target:"_blank"},"SEO Checklist & Optimization")),React.createElement("li",null,"⭐️ ",React.createElement("a",{href:"https://meowapps.com/tutorial-faster-wordpress-optimize/",target:"_blank"},"Optimize your WordPress Speed")),React.createElement("li",null,"⭐️ ",React.createElement("a",{href:"https://meowapps.com/tutorial-optimize-images-wordpress/",target:"_blank"},"Optimize Images (CDN, and so on)")),React.createElement("li",null,"⭐️ ",React.createElement("a",{href:"https://meowapps.com/tutorial-hosting-service-wordpress/",target:"_blank"},"The Best Hosting Services for WordPress"))))),X=async()=>(await(0,y.IU)(`${z}/all_settings/`,{method:"POST",nonce:N})).data,Q=async({value:e,id:t})=>await(0,y.IU)(`${z}/update_option`,{method:"POST",nonce:N,json:{name:t,value:e}}),J=async()=>(await(0,y.IU)(`${z}/error_logs`,{method:"POST",nonce:N})).data.reverse(),Z=()=>{const e=(0,l.jE)(),[t,a]=Y(!1),[n,r]=Y(!1),[y,b]=Y(""),{data:v,error:f,isLoading:_}=(0,o.I)({queryKey:["all_settings"],queryFn:X}),{mutate:w}=(0,c.n)({mutationFn:Q,onSuccess:()=>{e.invalidateQueries(["all_settings"])}}),{mutate:C,data:O=[]}=(0,c.n)({mutationFn:J}),T=null==v?void 0:v.meowapps_hide_meowapps,N=null==v?void 0:v.force_sslverify;W((()=>{f&&!t&&(a(!0),console.error("Error from useQuery",f.message))}),[f]),W((()=>{let e=document.getElementById("meow-common-phpinfo");b(e.innerHTML)}),[]);const I=(e,t)=>{w({value:e,id:t})},M=React.createElement(s.d,{title:"Main Menu"},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"meowapps_hide_meowapps",label:"Hide (Not Recommended)",description:React.createElement(i.s,{p:!0},"This will hide the Meow Apps Menu (on the left side) and everything it contains. You can re-enable it through though an option that will be added in Settings → General."),value:"1",disabled:n,checked:T,onChange:I}))),S=React.createElement(s.d,{title:"SSL Verify"},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"force_sslverify",label:"Force (Not Recommended)",description:React.createElement(i.s,{p:!0},"This will enforce the usage of SSL when checking the license or updating the plugin."),value:"1",disabled:n,checked:N,onChange:I})));return React.createElement(u.z,{showRestError:t},React.createElement(E.n,{title:"The Dashboard"}),React.createElement(p.N,null,React.createElement(p.Y,{full:!0},React.createElement(g._,{keepTabOnReload:!0},React.createElement(g.V,{title:"Meow Apps"},V,React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0},React.createElement(D,{title:"AI Engine",className:"primary"},React.createElement(F,{src:"https://ps.w.org/ai-engine/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/ai-engine/"},"AI Engine")),React.createElement("p",{className:"plugin-actual-desc"},"This is the ultimate AI plugin for WordPress. From a chatbot adapted to your needs to an AI that can write your content for you, API, REST, and more."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/ai-engine/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/ai-engine/"},"Meow Apps"))))),React.createElement(D,{title:"Media Cleaner",className:"primary"},React.createElement(F,{src:"https://ps.w.org/media-cleaner/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-cleaner/"},"Media Cleaner")),React.createElement("p",{className:"plugin-actual-desc"},"Is your Media Library bloated, your database heavy, and your website running slow? Media Cleaner will clean your Media Library from the media entries (and files) which aren't used in your website, as well as broken entries."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-cleaner/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/media-cleaner/"},"Meow Apps"))))),React.createElement(D,{title:"Database Cleaner",className:"primary"},React.createElement(F,{src:"https://ps.w.org/database-cleaner/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/database-cleaner/"},"Database Cleaner")),React.createElement("p",{className:"plugin-actual-desc"},"Not only does Database Cleaner have a user-friendly UI, but it's also equipped to handle large DBs, giving it an edge over other plugins. It's a must-have for any WordPress site."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/database-cleaner/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/database-cleaner/"},"Meow Apps"))))),React.createElement(D,{title:"Media File Renamer",className:"primary"},React.createElement(F,{src:"https://ps.w.org/media-file-renamer/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-file-renamer/"},"Media File Renamer")),React.createElement("p",{className:"plugin-actual-desc"},"Rename and move files directly from the dashboard, manually, automatically or via AI, either individually or in bulk. It's the best way to rename your files."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-file-renamer/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/media-file-renamer/"},"Meow Apps"))))),React.createElement(D,{title:"Social Engine",className:"primary"},React.createElement(F,{src:"https://ps.w.org/social-engine/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/social-engine/"},"Social Engine")),React.createElement("p",{className:"plugin-actual-desc"},'Effortlessly schedule and automate the perfect posts for all your networks. Unlimited capabilities and infinite className="plugin-actual-desc" extensibility, for free!'),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/social-engine/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/social-engine/"},"Meow Apps"))))),React.createElement(D,{title:"Meow Analytics",className:"primary"},React.createElement(F,{src:"https://ps.w.org/meow-analytics/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-analytics/"},"Meow Analytics")),React.createElement("p",{className:"plugin-actual-desc"},"Google Analytics for your website. Simple and fast."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-analytics/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/meow-analytics/"},"Meow Apps")))))),React.createElement(p.Y,{minimal:!0},React.createElement(D,{title:"Contact Form Block",className:"primary"},React.createElement(F,{src:"https://ps.w.org/seo-engine/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/seo-engine/"},"SEO Engine")),React.createElement("p",{className:"plugin-actual-desc"},"Optimize your content for SEO and for the AI world, with AI assistants... while keeping everything simple and fast, as it should be! ✌️"),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/seo-engine/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/seo-engine/"},"Meow Apps"))))),React.createElement(D,{title:"Meow Gallery",className:"primary"},React.createElement(F,{src:"https://ps.w.org/meow-gallery/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-gallery/"},"Meow Gallery")),React.createElement("p",{className:"plugin-actual-desc"},"Fast and beautiful galleries with many layouts. Forget the heavy and slow plugins, use the Meow Gallery for a better experience! 💕"),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-gallery/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/meow-gallery/"},"Meow Apps"))))),React.createElement(D,{title:"Meow Lightbox",className:"primary"},React.createElement(F,{src:"https://ps.w.org/meow-lightbox/assets/icon-256x256.gif"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-lightbox/"},"Meow Lightbox")),React.createElement("p",{className:"plugin-actual-desc"},"Sleek and performant lightbox with EXIF support."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-lightbox/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/meow-lightbox/"},"Meow Apps"))))),React.createElement(D,{title:"Perfect Images (Retina)",className:"primary"},React.createElement(F,{src:"https://ps.w.org/wp-retina-2x/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wp-retina-2x/"},"Perfect Images")),React.createElement("p",{className:"plugin-actual-desc"},"Manage, Optimize, Replace your images with Perfect Images."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wp-retina-2x/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/wp-retina-2x/"},"Meow Apps"))))),React.createElement(D,{title:"Photo Engine",className:"primary"},React.createElement(F,{src:"https://ps.w.org/wplr-sync/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wplr-sync/"},"Photo Engine")),React.createElement("p",{className:"plugin-actual-desc"},"Organize your photos in folders and collections. Synchronize with Lightroom. Simplify and speed up your workflow."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wplr-sync/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/wplr-sync/"},"Meow Apps"))))),React.createElement(D,{title:"Contact Form Block",className:"primary"},React.createElement(F,{src:"https://ps.w.org/contact-form-block/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/contact-form-block/"},"Contact Form Block")),React.createElement("p",{className:"plugin-actual-desc"},"Need a very simple but straightforward contact form? This is the one you need. It's fast, simple, and efficient."),React.createElement("p",null,React.createElement("div",null,"Free Version: ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/contact-form-block/"},"WordPress.org")),React.createElement("div",null,"Pro Version: ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/contact-form-block/"},"Meow Apps")))))))),React.createElement(g.V,{title:"Performance"},K,React.createElement("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:25}},React.createElement($,{title:"Empty Request Time",request:"empty_request",max:2500}),React.createElement($,{title:"File Operation Time",request:"file_operation",max:2600}),React.createElement($,{title:"SQL Request Time",request:"sql_request",max:2800})),q),React.createElement(g.V,{title:"PHP Info"},React.createElement(U,{dangerouslySetInnerHTML:{__html:y}})),React.createElement(g.V,{title:"PHP Error Logs"},React.createElement(L,null,React.createElement(R.M,{style:{marginBottom:10},color:"#ccb027",onClick:()=>{C()},disabled:n,isBusy:"isLoadingErrorLogs"===n},"Load PHP Error Logs"),React.createElement(B,null,O.map((e=>React.createElement("li",{class:`log-${e.type}`},React.createElement("span",{class:"log-type"},e.type),React.createElement("span",{class:"log-date"},e.date),React.createElement("span",{class:"log-content"},e.content))))),React.createElement(i.s,{p:!0},"If you don't see any errors, your host might not allow remote access to PHP error logs. Contact them for assistance, or look in your hosting control panel."))),React.createElement(g.V,{title:"Settings"},React.createElement(h.z,{title:"Settings",className:"primary"},M,S))))))};var ee=a(4677),te=a(8696),ae=a(6734),ne=a(1543),le=a(8668),re=a(9794),oe=a(7213);const{useState:ce,useEffect:ie}=wp.element,se=`${f}/meow-licenser/${b}/v1`,me=()=>{const[e,t]=ce(!1),[a,n]=ce(!1),[l,r]=ce(null),[o,c]=ce(null),[s,m]=ce(""),d=T&&(!o||"valid"!==o.license),u=async()=>{if("MEOW_OVERRIDE"===s)return n(!0),c(null),void m("");t(!0);try{const e=await(0,y.IU)(`${se}/set_license`,{method:"POST",nonce:N,json:{serialKey:s}});e.success&&(c(e.data),e.data&&!e.data.issue&&r("licenseAdded"))}catch(e){alert("Error while validating the license. Check your console for more information."),console.error(e)}t(!1)};ie((()=>{(async()=>{if(O){t(!0);try{const e=await(0,y.IU)(`${se}/get_license`,{method:"POST",nonce:N});c(e.data),e.data.key&&m(e.data.key)}catch(e){alert("Error while checking the license. Check your console for more information."),console.error(e)}t(!1)}})()}),[]);const E=d?"Forced License":T?"Enabled":"Disabled",p=d||o&&"valid"===o.license;let g="Your license is active. Thanks a lot for your support :)";d&&(g="This license has been force-enabled for you.",o&&o.check_url&&(g=React.createElement(React.Fragment,null,React.createElement("span",null,g),React.createElement("br",null),React.createElement("small",null,"To check your license status, please click ",React.createElement("a",{target:"_blank",href:o.check_url+"&cache="+642e3*Math.random(),rel:"noreferrer"},"here"),".")))),p||(o?"no_activations_left"===o.issue?g=React.createElement("span",null,"There are no activations left for this license. You can visit your account at ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"Meow Apps"),", unregister a site, and click on ",React.createElement("i",null,"Retry to validate"),"."):"expired"===o.issue?g=React.createElement("span",null,"Your license has expired. You can get another license or renew the current one by visiting your account at ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"Meow Apps"),"."):"missing"===o.issue?g="This license does not exist.":"disabled"===o.issue?g="This license has been disabled.":"item_name_mismatch"===o.issue?g="This license seems to be for a different plugin... isn't it? :)":"forced"===o.issue?g="ABC":(g=React.createElement("span",null,"There is an unknown error related to the system or this serial key. Really sorry about this! Make sure your security plugins and systems are off temporarily. If you are still experiencing an issue, please ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com/contact/"},"contact us"),"."),console.error({license:o})):g="Unknown error :(");const b=React.createElement(h.z,{title:"Pro Version (Not Installed)",className:"primary"},"You will find more information about the Pro Version ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"here"),". If you actually bought the Pro Version already, please remove the current plugin and download the Pro Version from your account at ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com/"},"Meow Apps"),"."),v=React.createElement(h.z,{title:`Pro Version (${E})`,busy:e,className:"primary"},!d&&!(o&&o.key===s)&&React.createElement(React.Fragment,null,React.createElement("div",{style:{marginBottom:10}},"License Key:"),React.createElement(te.A,{id:"mfrh_pro_serial",name:"mfrh_pro_serial",disabled:e,value:s,onChange:e=>m(e),placeholder:"Type your license key..."}),React.createElement(i.s,{p:!0},"Insert your serial key above. If you don't have one yet, you can get one ",React.createElement("a",{href:"https://meowapps.com"},"here"),". If there was an error during the validation, try the ",React.createElement("i",null,"Retry")," to ",React.createElement("i",null,"validate")," button.")),o&&!p&&React.createElement(oe.X,{variant:"danger"},g),(d||o)&&p&&React.createElement(oe.X,{variant:"success"},g),React.createElement("div",{style:{marginTop:15,display:"flex",justifyContent:"end"}},o&&!p&&React.createElement(R.M,{className:"secondary",disabled:e||!s,onClick:u},"Retry to validate"),o&&o.key===s&&React.createElement(R.M,{className:"secondary",disabled:e||!s,onClick:async()=>{t(!0);try{(await(0,y.IU)(`${se}/set_license`,{method:"POST",nonce:N,json:{serialKey:null}})).success&&(m(""),c(null),r("licenseRemoved"))}catch(e){alert("Error while removing the license. Check your console for more information."),console.error(e)}t(!1)}},"Remove License"),React.createElement(R.M,{disabled:e||!s||o&&o.key===s,onClick:u},"Validate License"),a&&!p&&React.createElement(R.M,{disabled:e||!s||o&&o.key===s,onClick:async()=>{t(!0);try{const e=await(0,y.IU)(`${se}/set_license`,{method:"POST",nonce:N,json:{serialKey:s,override:!0}});e.success&&(c(e.data),e.data&&!e.data.issue&&r("licenseAdded"))}catch(e){alert("Error while forcing the license. Check your console for more information."),console.error(e)}t(!1)},className:"danger"},"Force License")),React.createElement(re.n,{isOpen:"licenseAdded"===l,title:"Thank you :)",content:"The Pro features have been enabled. This page should be now reloaded.",okButton:{label:"Reload",onClick:()=>location.reload()}}),React.createElement(re.n,{isOpen:"licenseRemoved"===l,title:"Goodbye :(",content:"The Pro features have been disabled. This page should be now reloaded.",okButton:{label:"Reload",onClick:()=>location.reload()}}));return O?v:b},{__:de}=wp.i18n,ue={};ue.COMMON={GENERAL:de("General","ai-engine"),MODULES:de("Modules","ai-engine"),CLIENT_MODULES:de("Client Modules","ai-engine"),BACKEND_MODULES:de("Admin Modules","ai-engine"),SERVER_MODULES:de("Server Modules","ai-engine"),ADVISOR:de("Advisor","ai-engine"),SETTINGS:de("Settings","ai-engine"),CHATBOT:de("Chatbot","ai-engine"),CHATBOTS:de("Chatbots","ai-engine"),CHATBOT_HELP:de("Highly customizable chatbot.","ai-engine"),STATISTICS:de("Statistics","ai-engine"),STYLE:de("Style","ai-engine"),ENABLE:de("Enable","ai-engine"),NAME:de("Name","ai-engine"),SUBMIT:de("Submit","ai-engine"),MODEL:de("Model","ai-engine"),AI_MODEL:de("AI Model","ai-engine"),TEMPERATURE:de("Temperature","ai-engine"),MAX_TOKENS:de("Max Tokens","ai-engine"),CONTEXT_MAX_LENGTH:de("Context Max Length","ai-engine"),STOP_SEQUENCE:de("Stop Sequence","ai-engine"),MODE:de("Mode","ai-engine"),CONTEXT:de("Context","ai-engine"),IMAGES_NUMBER:de("Number of Images","ai-engine"),AVATAR:de("Avatar","ai-engine"),AI_NAME:de("AI Name","ai-engine"),GUEST_NAME:de("Guest Name","ai-engine"),USER_NAME:de("User Name","ai-engine"),PLACEHOLDER:de("Placeholder","ai-engine"),START_SENTENCE:de("Start Sentence","ai-engine"),SEND:de("Send","ai-engine"),CLEAR:de("Clear","ai-engine"),SYSTEM_NAME:de("System Name","ai-engine"),ID:de("ID","ai-engine"),SCOPE:de("Scope","ai-engine"),POPUP:de("Popup","ai-engine"),POSITION:de("Position","ai-engine"),VOICE:de("Voice","ai-engine"),ICON:de("Icon","ai-engine"),ICON_TEXT:de("Icon Text","ai-engine"),ICON_TEXT_DELAY:de("Icon Text Delay","ai-engine"),FULL_SCREEN:de("Full Screen","ai-engine"),CASUALLY_FINE_TUNED:de("Casually Fine-Tuned","ai-engine"),CONTENT_AWARE:de("Content Aware","ai-engine"),SPACING:de("Spacing","ai-engine"),BORDER_RADIUS:de("Border Radius","ai-engine"),FONT_SIZE:de("Font Size","ai-engine"),FONT_COLOR:de("Font Color","ai-engine"),BACK_PRIMARY_COLOR:de("Back Primary Color","ai-engine"),BACK_SECONDARY_COLOR:de("Back 2nd Color","ai-engine"),HEADER_BUTTONS_COLOR:de("Header Buttons Color","ai-engine"),HEADER_BACKGROUND_COLOR:de("Header Back Color","ai-engine"),HEADER_SUBTITLE:de("Header Subtitle","ai-engine"),BUBBLE_COLOR:de("Bubble Color","ai-engine"),BACK_USER_COLOR:de("Back User Color","ai-engine"),BACK_AI_COLOR:de("Back AI Color","ai-engine"),BACK_AI_SECONDARY_COLOR:de("Back AI 2nd Color","ai-engine"),AVATAR_MESSAGE_BACKGROUND_COLOR:de("Message Background","ai-engine"),AVATAR_MESSAGE_FONT_COLOR:de("Message Color","ai-engine"),POPUP_ICON:de("Popup Icon","ai-engine"),CUSTOM_ICON:de("Custom Icon (URL or Emoticon)","ai-engine"),FEATURES:de("Features","ai-engine"),TIMEFRAME:de("Timeframe","ai-engine"),ABSOLUTE:de("Absolute","ai-engine"),NONE:de("None","ai-engine"),EDITORS_ADMINS:de("Editors & Admins","ai-engine"),ADMINS_ONLY:de("Admins Only","ai-engine"),CREDITS:de("Credits","ai-engine"),TYPE:de("Type","ai-engine"),USERS:de("Users","ai-engine"),USER:de("User","ai-engine"),GUESTS:de("Guests","ai-engine"),GUEST:de("Guest","ai-engine"),OPENAI:de("Open AI","ai-engine"),LICENSE_TAB:de("License","ai-engine"),FINETUNES:de("Finetunes","ai-engine"),MODELS:de("Models","ai-engine"),FILES:de("Files","ai-engine"),ASSISTANT:de("Assistant","ai-engine"),ASSISTANTS:de("Assistants","ai-engine"),UTILITIES:de("Utilities","ai-engine"),POSTS_SUGGESTIONS:de("AI Copilot, AI Suggestions, Magic Wands","ai-engine"),POSTS_SUGGESTIONS_HELP:de("Tools to brainstorm/write faster and better.","ai-engine"),GENERATORS:de("Generators","ai-engine"),CONTENT_GENERATOR:de("Content Generator","ai-engine"),CONTENT_GENERATOR_HELP:de("Generate articles. Support templates.","ai-engine"),IMAGES_GENERATOR:de("Images Generator","ai-engine"),IMAGES_GENERATOR_HELP:de("Generate images. Support templates.","ai-engine"),PLAYGROUND:de("Playground","ai-engine"),PLAYGROUND_HELP:de("Play with AI or let it perform various tasks for you. Support templates.","ai-engine"),FORMS:de("Forms","ai-engine"),FORMS_HELP:de("Build AI forms. Based on fields, users will be given answers or suggestions.","ai-engine"),STATISTICS_HELP:de("Track AI interactions, check statistics, set limits, and more!","ai-engine"),CLIENT_DEBUG:de("Client Debug","ai-engine"),CLIENT_DEBUG_HELP:de("Debugging information will be displayed in the console.","ai-engine"),SERVER_DEBUG:de("Server Debug","ai-engine"),SERVER_DEBUG_HELP:de("Debugging information from your server will be displayed in a console on this tab.","ai-engine"),CLEAR_LOGS:de("Clear Logs","ai-engine"),REFRESH_LOGS:de("Refresh Logs","ai-engine"),API_KEY:de("API Key","ai-engine"),USAGE_HELP:de('Those values are for information only. They are not accurate and should not be used for billing purposes. The calculation of the number of tokens and the cost is very different from one service to another, and AI Engine does its best to estimate it. For the exact amounts, please check your accounts at the respective services. For OpenAI, you can check your <a href="https://platform.openai.com/usage" target="_blank">OpenAI account</a>.',"ai-engine"),RESET_USAGE_SURE:de("Are you sure you want to reset the usage data?","ai-engine"),USAGE_PRO_HELP:de('If you would like to have better control on the amounts, add conditions or set limits to the usage of the AI, consider <a href="https://meowapps.com/ai-engine/" target="_blank">AI Engine Pro</a>.',"ai-engine"),LANGUAGE:de("Language","ai-engine"),HIDE:de("Hide","ai-engine"),SHOW:de("Show","ai-engine"),CONTENT:de("Content","ai-engine"),IMAGES:de("Images","ai-engine"),IMAGES_AND_FILES:de("Images & Files","ai-engine"),EXCERPT:de("Excerpt","ai-engine"),GENERATE:de("Generate","ai-engine"),MODEL_PARAMS:de("Model Params","ai-engine"),CONTEXT_PARAMS:de("Context Params","ai-engine"),PROMPT:de("Prompt","ai-engine"),PROMPTS:de("Prompts","ai-engine"),LABEL:de("Label","ai-engine"),SYSTEM:de("System","ai-engine"),SHORTCODE:de("Shortcode","ai-engine"),SHORTCODES:de("Shortcodes","ai-engine"),RESOLVE:de("Resolve","ai-engine"),MAX_MESSAGES:de("Max Messages","ai-engine"),INPUT_MAX_LENGTH:de("Input Max Length","ai-engine"),COMPLIANCE_TEXT:de("Compliance Text","ai-engine"),MODERATION:de("Moderation","ai-engine"),MODERATION_HELP:de("Moderation features with AI.","ai-engine"),FORMATTING:de("Formatting","ai-engine"),FORMATTING_HELP:de("Format the reply from AI into HTML. This is already done automatically if Markdown is detected in the reply.","ai-engine"),LOGS:de("Logs","ai-engine"),CODE:de("Code","ai-engine"),EMBEDDINGS:de("Embeddings","ai-engine"),EMBEDDINGS_HELP:de("Create searchable data that can be reused to feed the chatbot and other AI or UI elements.","ai-engine"),OTHERS:de("Others","ai-engine"),PINECONE_APIKEY_HELP:de('You can get your API Keys in your <a href="https://app.pinecone.io/organizations/keys" target="_blank">Pinecone Account</a>.',"ai-engine"),QDRANT_APIKEY_HELP:de('You can get your API Keys in your <a href="https://cloud.qdrant.io/accounts/" target="_blank">Qdrant Account</a>.',"ai-engine"),SERVER:de("Server","ai-engine"),PINECONE_SERVER_HELP:de("The URL of your host (check your Indexes).","ai-engine"),PINECONE_NAMESPACE_HELP:de("The namespace is used to separate the data from other data. This allows you to use the same server/index on more than one website. This is optional.","ai-engine"),QDRANT_SERVER_HELP:de("The URL of your cluster (known as Cluster URL).","ai-engine"),QDRANT_COLLECTION_HELP:de("The collection keeps data apart so you can use one cluster for many websites. If there's no collection, Qdrant makes one with 1536 dimensions and uses cosine similarity.","ai-engine"),COST:de("Cost","ai-engine"),USAGE:de("Usage","ai-engine"),TRANSCRIPTION:de("Transcription","ai-engine"),TRANSCRIPTION_HELP:de("Introduces a 'Transcribe' tab to easily transform audio/images into text and get AI answers in JSON format.","ai-engine"),AUDIO_TRANSCRIPTION:de("Audio-to-Text","ai-engine"),IMAGE_TRANSCRIPTION:de("Image-to-Text","ai-engine"),AUDIO_TO_TEXT:de("Audio ➡ Text","ai-engine"),IMAGE_TO_TEXT:de("Image ➡ Text","ai-engine"),EMBEDDINGS_ENV:de("Environment","ai-engine"),EMBEDDINGS_INDEX:de("Index","ai-engine"),NAMESPACE:de("Namespace","ai-engine"),NAMESPACES:de("Namespaces","ai-engine"),NAMESPACE_HELP:de("The namespace is used to separate the data from other data. This allows you to use the same index on more than one website.","ai-engine"),NAMESPACES_HELP:de("Enter the namespaces you would like to use on this site, separated by commas.","ai-engine"),ERROR:de("Error","ai-engine"),RETRY:de("Retry","ai-engine"),AUTO_RETRY:de("Auto Retry","ai-engine"),SKIP:de("Skip","ai-engine"),AUTO_SKIP:de("Auto Skip","ai-engine"),STOP:de("Stop","ai-engine"),AUTO_RETRY_DESCRIPTION:de("Auto Retry retries actions up to 10 times with increasing delay to avoid timeouts.","ai-engine"),WIDTH:de("Width","ai-engine"),MAX_HEIGHT:de("Max Height","ai-engine"),APPEARANCE:de("Appearance","ai-engine"),THRESHOLDS:de("Thresholds","ai-engine"),DASHBOARD:de("Dashboard","ai-engine"),ADVANCED:de("Advanced","ai-engine"),DISCUSSIONS:de("Discussions","ai-engine"),DISCUSSION_TITLES:de("Discussion Titles","ai-engine"),ROWS:de("Rows","ai-engine"),POST_TYPE:de("Post Type","ai-engine"),GENERATE_CONTENT:de("Generate Content","ai-engine"),GENERATE_IMAGES:de("Generate Images","ai-engine"),ADMIN_BAR:de("Admin Bar","ai-engine"),ADMIN_TOOLS:de("Admin Tools","ai-engine"),REFRESH:de("Refresh","ai-engine"),DELETE:de("Delete","ai-engine"),DELETE_ALL:de("Delete All","ai-engine"),DELETE_SELECTED:de("Delete Selected","ai-engine"),OPENAI_ORGANIZATION_ID:de("Organization ID","ai-engine"),OPENAI_AZURE_API_KEY:de("API Key","ai-engine"),OPENAI_AZURE_DEPLOYMENT_NAME:de("Deployment Name","ai-engine"),OPENAI_AZURE_DEPLOYMENTS:de("Deployments","ai-engine"),ENDPOINT:de("Endpoint","ai-engine"),HUGGINGFACE_MODELS:de("Models","ai-engine"),HUGGINGFACE_MODEL_NAME:de("Name","ai-engine"),HUGGINGFACE_MODEL_URL:de("API URL","ai-engine"),THEME:de("Theme","ai-engine"),THEMES:de("Themes","ai-engine"),BANNED_WORDS:de("Banned Words","ai-engine"),WORD_BOUNDARIES:de("Word Boundaries","ai-engine"),IGNORE:de("Ignore","ai-engine"),BANNED_IPS:de("Banned IPs","ai-engine"),SECURITY:de("Security","ai-engine"),POST_TYPES:de("Post Types","ai-engine"),COPY_BUTTON:de("Copy Button","ai-engine"),AI_AVATAR:de("AI Avatar","ai-engine"),GUEST_AVATAR:de("Guest Avatar","ai-engine"),SITE_WIDE_CHATBOT:de("Site-Wide Chatbot","ai-engine"),QUERIES_DATA:de("Queries Data","ai-engine"),QUERIES_FORMS_DATA:de("Queries Form Data","ai-engine"),WEBSPEECH_API:de("Web Speech API","ai-engine"),VIRTUAL_KEYBOARD:de("Virtual Keyboard","ai-engine"),GDPR_CONSENT:de("GDPR Consent","ai-engine"),GDPR_TEXT:de("GDPR Text","ai-engine"),GDPR_BUTTON:de("GDPR Button","ai-engine"),FIX:de("Fix","ai-engine"),SPEECH_RECOGNITION:de("Speech Recognition","ai-engine"),SPEECH_SYNTHESIS:de("Speech Synthesis","ai-engine"),QUERY:de("Query","ai-engine"),QUERIES:de("Queries","ai-engine"),LOCAL_MEMORY:de("Local Memory","ai-engine"),ACTIONS:de("Actions","ai-engine"),RESET:de("Reset","ai-engine"),INCIDENTS_OPENAI:de("Incidents (OpenAI)","ai-engine"),PREVIEW:de("Preview","ai-engine"),LEGACY_FORMS:de("Legacy Forms","ai-engine"),LEGACY_FEATURES:de("Legacy Features","ai-engine"),DUPLICATE:de("Duplicate","ai-engine"),CHATBOT_EDITOR:de("Chatbot Editor","ai-engine"),THEME_EDITOR:de("Theme Editor","ai-engine"),STREAMING:de("Streaming","ai-engine"),SYNTAX_HIGHLIGHT:de("Syntax Highlight","ai-engine"),PRIVACY_FIRST:de("Privacy First","ai-engine"),DATA_NOT_AVAILABLE:de("Data not available.","ai-engine"),EXPORT:de("Export","ai-engine"),IMPORT:de("Import","ai-engine"),MODIFY_EMBEDDING:de("Modify Embedding","ai-engine"),ADD_EMBEDDING:de("Add Embedding","ai-engine"),DEV_TOOLS:de("Dev Tools","ai-engine"),SINGLE_GENERATE:de("Single Generate","ai-engine"),PUBLIC_API:de("Public API","ai-engine"),USER_INTERFACE:de("User Interface","ai-engine"),INTRO_MESSAGE:de("Intro Message","ai-engine"),ADDONS:de("Add-ons","ai-engine"),AI_ENVIRONMENT_DEFAULTS:de("Default Environments for AI","ai-engine"),ENVIRONMENTS_FOR_AI:de("Environments for AI","ai-engine"),ENVIRONMENT_ID:de("Environment ID","ai-engine"),EMBEDDINGS_ENVIRONMENT_DEFAULT:de("Default Embeddings Environment","ai-engine"),ENVIRONMENT:de("Environment","ai-engine"),PLUGIN_DATA:de("Plugin Data","ai-engine"),PLUGIN_DATA_DESCRIPTION:de("The database and all the options of the plugin will be removed on uninstall.","ai-engine"),RESET_LIMITS:de("Reset Limits","ai-engine"),VISION:de("Vision","ai-engine"),FILE_SEARCH:de("File Search","ai-engine"),PROMPT_TO_JSON:de("Prompt ➡ JSON","ai-engine"),RESOLUTION:de("Resolution","ai-engine"),DEFAULT:de("Default","ai-engine"),REFRESH_MODELS:de("Refresh Models","ai-engine"),AUDIO:de("Audio","ai-engine"),JSON:de("JSON","ai-engine"),AI_ENVIRONMENT:de("AI Environment","ai-engine"),OVERRIDE_DEFAULTS:de("Override Defaults","ai-engine"),REGION:de("Region","ai-engine"),PROJECT_ID:de("Project ID","ai-engine"),BEARER_TOKEN:de("Bearer Token","ai-engine"),DIMENSIONS:de("Dimensions","ai-engine"),MIN_SCORE:de("Min Score","ai-engine"),MAX_SELECT:de("Max Results","ai-engine"),QDRANT_COLLECTION:de("Collection","ai-engine"),INSTRUCTIONS:de("Instructions","ai-engine"),FUNCTIONS:de("Functions","ai-engine"),BUBBLE:de("Bubble","ai-engine"),TABS:de("Tabs","ai-engine"),DROPDOWN:de("Dropdown","ai-engine"),CHATBOT_SELECT:de("Chatbot Select","ai-engine")},ue.FORMS={PROMPT_INFO:de("The template of your prompt. To re-use the data entered by the user, use the name of that field between curly braces. Example: Recommend me {MUSIC_TYPE} artists. You can also use an ID as an input, like this: ${#myfield}. Finally, if you wish the output to be formatted, add: 'Use Markdown.'.\"","ai-engine"),OUTPUT:de("Output","ai-engine"),OUTPUT_ELEMENT:de("Output Element","ai-engine"),OUTPUT_ELEMENT_INFO:de("The result will be written to this element. If you wish to simply display the result in an Output Block, use its ID. For instance, if its ID is mwai-666, use '#mwai-666'.","ai-engine")},ue.HELP={TEMPERATURE:de("Between 0 and 1. Higher values means the model will take more risks.","ai-engine"),MAX_TOKENS:de("The maximum number of tokens to generate. The model will stop generating once it hits this limit.","ai-engine"),STOP_SEQUENCE:de("The sequence of tokens that will cause the model to stop generating text. You absolutely need this with fine-tuned models.","ai-engine"),COST:de("Keeps track of the current costs.","ai-engine"),RESOLVE_SHORTCODE:de("Will resolve the shortcode in your content when needed (Content-Aware will use this, for instance).","ai-engine"),FINETUNES:de("Train your own AI models.","ai-engine"),DISCUSSIONS:de("Keep the conversations and enable browsing them via the Conversations tab.","ai-engine"),DISCUSSION_TITLES:de("Generate titles for the discussions automatically with AI.","ai-engine"),AZURE_DEPLOYMENTS:de("Add your deployments below and define what kind of model they are.","ai-engine"),BANNED_WORDS:de("Reject queries containing these words; separate with commas.","ai-engine"),WORD_BOUNDARIES:de("Ignore standard word separation (space) and match banned words anywhere in the text.","ai-engine"),BANNED_IPS:de("Block access from specified IP addresses or ranges using CIDR notation; separate with commas.","ai-engine"),VIRTUAL_KEYBOARD:de("Prevent the virtual keyboard from pushing the chatbot up on mobile devices. This is experimental and might cause issues.","ai-engine"),GDPR_CONSENT:de("If enabled, the user will have to accept the conditions before using the chatbot.","ai-engine"),POST_TYPES:de("Enable for these post types; separate with commas.","ai-engine"),POST_STATUS:de("Enable for these post statuses (publish, draft, future, private, etc); separate with commas.","ai-engine"),POST_CATEGORIES:de("Enable for these categories (slugs); separate with commas. If none, it will be enabled for all.","ai-engine"),CONTEXT_MAX_LENGTH:de("Truncate the context (Content-Aware, Embeddings, etc) to make sure it is below this number of characters.","ai-engine"),MAX_MESSAGES:de("Maximum number of historical messages that is sent to the AI model.","ai-engine"),INPUT_MAX_LENGTH:de("Maximum number of characters that can be input by the user.","ai-engine"),STATISTICS:de(" In the Queries tab, you can browse through all your users' activity. Contextual data is excluded unless you activate the options below. Make sure your users are aware of this.","ai-engine"),QUERIES_DATA:de("Record the queries and their replies.","ai-engine"),QUERIES_FORMS_DATA:de("Capture form data neatly for simple reuse.","ai-engine"),SPEECH_RECOGNITION:de("Enable speech-to-text. Depends on the browser and OS used by the user.","ai-engine"),SPEECH_SYNTHESIS:de("Enable text-to-speech.","ai-engine"),CUSTOM_SHORTCODE:de("Prefer the above version. If you need many chatbots, you can custom shortcodes, like the one below. Custom shortcodes are based on the default chatbot, and their attributes override the default ones.","ai-engine"),USER_FILTER:de("Type an User ID, or an IP.","ai-engine"),STREAMING:de("The AI's response will appear as it's being created. Be cautious: this feature's ability to manage statistics, limits, and filters is still in its beta phase.","ai-engine"),SYNTAX_HIGHLIGHT:de("Enable syntax highlighting for the code blocks.","ai-engine"),PRIVACY_FIRST:de("Only essential data is stored. IPs, conversations, and other private details are minimized and kept as anonymous as possible.","ai-engine"),DEV_TOOLS:de("Enable a new tab with debugging tools. For developers only.","ai-engine"),PUBLIC_API:de("Enable the Public REST API.","ai-engine"),INTRO_MESSAGE:de("Enable the introduction text at the top of this page.","ai-engine"),ADDONS:de("Enable the AI Addons section under the Meow Apps menu.","ai-engine"),OPENAI_API_KEY:de('You can get your API Keys in your <a href="https://platform.openai.com/api-keys" target="_blank">OpenAI Account</a>.',"ai-engine"),OPENAI_ORGANIZATION_ID:de('You can link this environment to an <a href="https://platform.openai.com/account/organization" target="_blank">Organization</a>. This is optional.',"ai-engine"),AZURE_API_KEY:de('You can get your API Keys in your <a href="https://oai.azure.com/portal" target="_blank">Azure Account</a>.',"ai-engine"),ANTHROPIC_API_KEY:de('You can get your API Keys in your <a href="https://console.anthropic.com/settings/keys" target="_blank">Anthropic Account</a>.',"ai-engine"),OPENROUTER_API_KEY:de('You can get your API Keys in your <a href="https://openrouter.ai/keys" target="_blank">OpenRouter Account</a>.',"ai-engine"),QDRANT:de('Use the code <b>#AIENGINE5</b> when you <a href="https://qdrant.to/cloud" target="_blank">Create a Qdrant Account</a>. You will get 5% off.',"ai-engine"),ASSISTANTS:de("The Assistants API is designed to help developers build powerful AI assistants capable of performing a variety of tasks.","ai-engine"),ASSISTANTS_INTRO:de('The Assistants API is designed to help developers build powerful AI assistants capable of performing a variety of tasks. To create them, head to the <a href="https://beta.openai.com/assistants" target="_blank">OpenAI Assistants</a> dashboard, then <b>Refresh Assistants</b> here. You can use an assistant in your chatbots by switching the <b>Mode</b> to <b>Assistant</b>.',"ai-engine"),ASSISTANTS_WARNINGS:de('Assistants are also <a href="https://platform.openai.com/docs/api-reference/assistants" target="_blank">in beta</a>, both for OpenAI and AI Engine. OpenAI did not add streaming support for them yet. Pricing is still quite unclear and <a href="https://openai.com/pricing" target="_blank">tricky</a>. AI Engine can only perform an estimation. If you want to discuss assistants with other users, visit the <a href="https://discord.gg/bHDGh38" target="_blank">Meow Apps Discord Server</a>.',"ai-engine"),BEARER_TOKEN:de('The Public API will be usable by using this Bearer Token. If not set, you will need to <a href="https://meowapps.com/ai-engine/api/#public-rest-api" target="_blank">build your own authentication</a> by using the <i>mwai_allow_public_api</i> filter.',"ai-engine"),MCP_BEARER_TOKEN:de("MCP will be usable by using this Bearer Token. If not set, you will need to build your own authentication by using the <i>mwai_allow_mcp</i> filter.","ai-engine"),NO_EMBEDDINGS_RESULTS:de("No results for this search. Make sure the Minimum Score is not too high.","ai-engine"),NO_EMBEDDINGS_ROWS:de("No embeddings yet in this environment.","ai-engine"),MIN_SCORE:de("The minimum score the embeddings need to have to be returned. Between 0 and 100 and defaults to 35.","ai-engine"),MAX_SELECT:de("The maximum number of embeddings to return and to use as context. Between 1 and 100 and defaults to 10.","ai-engine"),FUNCTIONS:de("Select the functions to make available for the AI model's choice. It will use them to enhance responses and perform specific actions. This feature is known as Function Calling or Tools.","ai-engine"),FUNCTIONS_UNAVAILABLE:de('There are no functions available. Please use <a href="https://wordpress.org/plugins/code-engine/" target="_blank">Code Engine</a> to add some. The Pro Version of AI Engine is also required for this feature.',"ai-engine"),ADVISOR:de("In your Dashboard will be displayed daily recommendations tailored to your WordPress setup. Admins only.","ai-engine"),BUBBLE:de("The popup will be displayed as a bubble.","ai-engine"),ICON_TEXT:de("If set, this text will appear next to the icon/bubble.","ai-engine"),ICON_TEXT_DELAY:de("The delay before the text appears.","ai-engine"),CHATBOT_SELECT:de("Choose how you want to select the chatbot. By default, tabs are used, but you can also use a filterable dropdown if you have many chatbots.","ai-engine")},ue.SETTINGS={AI_ENV_SETUP:de('To leverage the functionalities of AI Engine, it needs to be connected directly to AI services. We recommend starting with OpenAI. Create an account and generate an API Key by visiting the <a href="https://platform.openai.com/api-keys" target="_blank">OpenAI</a> website. Once obtained, navigate to the <b>Settings</b> tab and input your OpenAI API Key in the "Environments for AI" section.',"ai-engine"),PINECONE_SETUP:de('You choose to use Embeddings. To use them, you need to a Pinecone account. Visit the <a href="https://app.pinecone.io" target="_blank">Pinecone</a> website to create an account, then insert your Pinecone API Key in the <b>Settings</b> tab.',"ai-engine"),INTRO:de('Boost your WordPress with AI, now! Please start with our <a href="https://meowapps.com/ai-engine/tutorial/" target="_blank">tutorial</a>. Then move to our <a href="https://docs.meowapps.com/" target="_blank">documentation</a>. Have a look at our <a href="https://meowapps.com/products/category/ai-add-ons/" target="_blank">add-ons</a>. And make sure you read the <a href="https://meowapps.com/ai-engine/disclaimer/" target="_blank">disclaimer</a>. Have fun! 🎵',"ai-engine"),MODULES_INTRO:de("To avoid cluttering the UI and your WP, only enable the features you need.","ai-engine"),ALERT_INJECT_BUT_NO_POPUP:de("You choose to inject the chatbot in your website. You probably also want to use the chatbot in a Popup.","ai-engine"),ALERT_CASUALLY_BUT_NO_FINETUNE:de("Normally, you should not check the Casually Fine Tuned option with a non-finetuned model. Make sure that's what you want.","ai-engine"),ALERT_CONTENTAWARE_BUT_NO_CONTENT:de('Content Aware requires your Context to use the {CONTENT} placeholder. It will be replaced by the content of page the chatbot is on. More info <a href="https://meowapps.com/ai-engine/tutorial/#contextualization" target="_blank">here</a>.',"ai-engine"),SET_AS_DEFAULT_PARAMETERS:de("Set as Default Parameters","ai-engine"),SET_AS_DEFAULT_PARAMETERS_HELP:de("Set the parameters above as the default parameters for the chatbot. You can then use the shortcode [mwai_chat] anywhere on your website.","ai-engine"),INJECT_DEFAULT_CHATBOT:de("Inject Default Chatbot in Entire Website","ai-engine"),INJECT_DEFAULT_CHATBOT_HELP:de("Inject the chatbot [mwai_chat] in the entire website.","ai-engine"),CHATGPT_STYLE_INTRO:de('Keep in mind that you can also style the chatbot (or a specific chatbot, if you use many) by injecting CSS. Have a look <a target="_blank" href="https://meowapps.com/ai-engine/tutorial/#apply-custom-style-to-the-chatbot">here</a>. More information in the <a target="_blank" href="https://meowapps.com/ai-engine/faq">FAQ</a>.',"ai-engine"),TYPEWRITER_EFFECT:de("Typewriter Effect","ai-engine"),TYPEWRITER_EFFECT_HELP:de("The reply from AI will be typewrited. This delays the final output! Absolutely not recommended. Please use <b>Streaming</b> instead.","ai-engine"),CHATBOT_MODERATION_HELP:de("If the conversation seems offensive, the chatbot will reject it.","ai-engine"),CUSTOM_URL:de("Custom URL","ai-engine"),ASSISTANT_NO_FILE_SEARCH:de('This assistant does not support File Search. You can activate it on the <a href="https://platform.openai.com/assistants" target="_blank">OpenAI Assistants</a> dashboard. Then, use the Refresh button in the Assistants tab.',"ai-engine"),ASSISTANT_FILE_SEARCH:de("File Search will be used when the users upload documents. If the user uploads images, those will be handled by AI Vision if the model supports it and if it is enabled.","ai-engine")},ue.CHATBOT={CHATBOT_BUILDER:de("Chatbot Builder","ai-engine"),RESET_PARAMS:de("Reset Parameters","ai-engine")},ue.STATISTICS={ABSOLUTE_HELP:de("Using Absolute, Day represents <i>today</i>. Otherwise, the <i>past 24 hours</i>. Same logic applies to the other timeframes.","ai-engine"),NO_CREDITS_MESSAGE:de("Message for No Credits","ai-engine"),FULL_ACCESS_USERS:de("Full-Access Users","ai-engine"),ENABLE_LIMITS:de("Enable Limits","ai-engine")},ue.CONTENT_GENERATOR={INTRO:de("The Content Generator is a powerful tool that can generate content for you. It can be used to generate articles, emails, or even code. It can also be used to generate content for your chatbot. <b>Let me know if there are any new features you would like to see!</b> Have fun 🥳","ai-engine"),TITLE_MISSING:de("Title is missing!","ai-engine"),SECTIONS_MISSING:de("Sections are missing!","ai-engine"),SINGLE_GENERATE:de("Single Generate","ai-engine"),BULK_GENERATE:de("Bulk Generate","ai-engine"),CONTENT_PARAMS:de("Content Params","ai-engine"),POST_PARAMS:de("Post Params","ai-engine"),CONTENT_PARAMS_INTRO:de("Input fields are displayed for certain placeholders used in prompts, such as {LANGUAGE} or {WRITING_TONE}","ai-engine"),CUSTOM_LANGUAGE:de("Custom Language","ai-engine"),WRITING_STYLE:de("Writing Style","ai-engine"),WRITING_TONE:de("Writing Tone","ai-engine"),CUSTOM_LANGUAGE_HELP:de('All the languages are <i>somehow</i> supported by AI. <a href="https://meowapps.com/ai-engine/faq/#languages" target="_blank">Learn more</a>.',"ai-engine"),MODEL_HELP:de("It is recommended to use Turbo or GPT-4 to write texts.","ai-engine"),PROMPTS_INTRO:de("Prompts represent the exact request sent to the AI. The variables between curly braces will be replaced by the content of the corresponding field. Prompts are saved in your templates.","ai-engine"),PROMPT_TITLE:de("Prompt for <b>Title</b>","ai-engine"),PROMPT_SECTIONS:de("Prompt for <b>Sections</b>","ai-engine"),PROMPT_CONTENT:de("Prompt for <b>Content</b>","ai-engine"),PROMPT_EXCERPT:de("Prompt for <b>Excerpt</b>","ai-engine"),POST_CREATED:de("Post Created","ai-engine"),POST_CREATED_AS_DRAFT:de("The post was created as a draft.","ai-engine"),CONTENT_HELP:de('You can modify the content before using "Create Post". Markdown is supported, and will be converted to HTML when the post is created.',"ai-engine"),SECTIONS_HELP:de('Add, rewrite, remove, or reorganize those sections as you wish before (re)clicking on "Generate Content". Markdown format is recommended.',"ai-engine"),GENERATE_EXCERPT:de("Generate Excerpt","ai-engine"),GENERATE_CONTENT:de("Generate Content","ai-engine"),GENERATE_SECTIONS:de("Generate Sections","ai-engine"),PARAGRAPHS_PER_SECTION:de("# of Paragraphs per Section","ai-engine"),SECTIONS:de("Sections","ai-engine"),TOPICS_HELP:de("Write or paste your topics below. Each line will be used as a topic. The same <b>Params</b> and <b>Prompts</b> will be used as with the <b>Single Generate</b>, so make sure you get satisfying results with it first. This <b>takes time</b>, so relax and enjoy some coffee ☕️ and tea 🍵 :)","ai-engine"),GENERATED_POSTS:de("Generated Posts","ai-engine"),GENERATE_ALL:de("Generate All","ai-engine"),EDIT_POST:de("Edit Post","ai-engine"),CREATE_POST:de("Create Post","ai-engine"),TITLE_TOO_SHORT:de("The title is too short. It should be at least 3 words.","ai-engine"),TITLE_TOO_SHORT_2:de("The title is too short. It should be at least 40 characters.","ai-engine"),TITLE_TOO_LONG:de("The title is too long. It should be less than 8 words.","ai-engine"),TITLE_TOO_LONG_2:de("The title is too long. It should be less than 70 characters.","ai-engine")},ue.TEMPLATES={TEMPLATE:de("Template","ai-engine"),TEMPLATES:de("Templates","ai-engine"),DELETE_CONFIRM:de("Are you sure you want to delete this template?","ai-engine"),DELETE_ALL_CONFIRM:de("Are you sure you want to delete all the templates?","ai-engine"),NEW_TEMPLATE_NAME:de("New Template","ai-engine"),EDIT:de("EDIT","ai-engine")},ue.PLAYGROUND={INTRO:de("Welcome to the AI Playground! Here, you can play with different AI models and ask the UI to perform various tasks for you. You can ask it to write, rewrite, or translate an article, categorize words or elements into groups, write an email, etc. <b>Let me know if there are any new features you would like to see!</b> Have fun 🥳","ai-engine"),PROMPT:de("Query / Prompt","ai-engine"),REPLY:de("Reply","ai-engine")},ue.ALERTS={FINETUNING_STARTED:de("Fine-tuning started! Check its progress in the Models section. Depending on your dataset size, it may take a while (from a few minutes to days).","ai-engine"),RESET_BUILDER:de("This will delete all the rows in the builder. Are you sure?","ai-engine"),DELETE_FINETUNE:de("You are going to delete this fine-tune. Are you sure?\n\nPlease note that it will take a while before it is actually deleted. This might be a temporary issue of OpenAI.","ai-engine"),FINETUNE_ALREADY_DELETED:de("This fine-tune was already deleted. It will be removed from the list.","ai-engine"),CHECK_CONSOLE:de("Error! Check your console for more details.","ai-engine"),DATASET_UPLOADED:de("Uploaded successfully! You can now train a model based on this dataset.","ai-engine"),ONLY_SUPPORTS_FILES:de("This only supports JSON, JSONL, and CSV files. Check the Instructions section below.","ai-engine"),EMPTY_LINES_DATASET:de("Some lines were empty. Make sure the CSV has a header row and that the columns are named 'prompt' and 'completion'. For debugging, an empty line was logged to the console.","ai-engine"),EMPTY_LINES_EMBEDDINGS:de("Some lines were empty. Make sure the CSV has a header row and that the columns are named 'title' and 'content'. For debugging, an empty line was logged to the console.","ai-engine"),ARE_YOU_SURE:de("Are you sure?","ai-engine")},ue.FINETUNING={MODELS_INTRO:de("The AI models you have fine-tuned. To create more, visit <b>Files</b>.","ai-engine"),LEGACY_MODELS_INTRO:de('The AI models you have fine-tuned. <b>Do not use legacy fine-tuning anymore (based on models prior to GPT 3.5). Their deprecation has been <a href="https://platform.openai.com/docs/guides/legacy-fine-tuning" target="_blank">announced by OpenAI</a> for January 4th, 2024.</b><br />',"ai-engine"),FILES_INTRO:de("The files you have uploaded to OpenAI. To create a new dataset file, switch from <b>Model & Files</b> to <b>Dataset Editor</b>. To train a new model, click on the <i>magic wand</i>.","ai-engine"),MODEL_FINETUNE:de("Model Finetune","ai-engine"),MODELS_FILES:de("Models & Files","ai-engine"),DATASET_EDITOR:de("Dataset Editor","ai-engine"),EDITOR:de("Editor","ai-engine"),GENERATOR:de("Generator","ai-engine"),HUGE_DATASET_WARNING:de("Caution: The data is too large to be saved in your browser's local storage.","ai-engine"),NO_FINETUNES_YET:de("No fine-tunes found. Refresh the list, or create a new one (via a dataset).","ai-engine"),CLEAN_MODELS_LIST:de("Clean Models List","ai-engine"),DELETED_FINETUNE_ISSUE:de("For some reason, OpenAI still return the models even after you deleted them. Don't worry, AI Engine will do the cleanup for you! You can force the cleanup by using this button. It takes a bit of time depending on the total of models you have.","ai-engine")},ue.EMBEDDINGS={EDIT:de("EDIT","ai-engine"),AI_SEARCH:de("AI SEARCH","ai-engine"),SYNC_POSTS:de("Sync Posts","ai-engine"),AUTO_SYNC_POSTS:de("Auto-Sync Posts","ai-engine"),AUTO_SYNC_POSTS_DESCRIPTION:de("Embeddings will be created, updated or removed based on the activity related to your posts.","ai-engine"),REWRITE_CONTENT:de("Rewrite Content","ai-engine"),REWRITE_CONTENT_DESCRIPTION:de("Shorten and improve the content for your embedding using the default model.","ai-engine"),FORCE_RECREATE:de("Force Recreate","ai-engine"),FORCE_RECREATE_DESCRIPTION:de("Recreate embeddings on sync even if the content has not changed.","ai-engine"),REWRITE_PROMPT_DESCRIPTION:de("Prompt for the rewrite. Supports {CONTENT}, {TITLE}, {URL}, {EXCERPT}, {LANGUAGE}, {ID}.","ai-engine"),SYNC_ALL:de("Sync All","ai-engine"),SYNC_ONE:de("Sync One","ai-engine"),ADD_INDEX:de("Add Index","ai-engine"),ADD_INDEX_DESCRIPTION:de("An index is like a database, and contains embeddings. You can have many indexes and switch between them. The indexes are hosted on Pinecone.","ai-engine"),NO_NAMESPACE_SUPPORT:de("Note: This server does not support namespaces.","ai-engine")},ue.ERROR={UPDATING_OPTIONS:de("An error occured while updating the options."),GETTING_OPTIONS:de("An error occured while getting the options."),CHECK_YOUR_CONSOLE:de('For more information, check <a target="_blank" href="https://meowapps.com/tutorial-network-activity-dev-tools/">your console</a>. You might also want to check your <a target="_blank" href="https://meowapps.com/tutorial-php-error-logs/">PHP Error Logs</a>.',"ai-engine")};const Ee=ue;function pe(){return pe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},pe.apply(this,arguments)}const{useMemo:ge,useState:Re,useEffect:he}=wp.element,ye={title:"",content:"",refId:null,type:"manual",behavior:"context"},be=({options:e})=>{const{ai_envs:t}=e,a=t.find((e=>e.apikey&&e.apikey.length>0)),n=!(null!=e&&e.module_embeddings)||(null==e?void 0:e.embeddings_envs)&&(null==e?void 0:e.embeddings_envs.length)>0;return React.createElement(React.Fragment,null,!a&&React.createElement(oe.X,{variant:"danger",style:{marginTop:0,marginBottom:25}},(0,y.FE)(Ee.SETTINGS.AI_ENV_SETUP)),!n&&React.createElement(oe.X,{variant:"danger",style:{marginTop:0,marginBottom:25}},(0,y.FE)(Ee.SETTINGS.PINECONE_SETUP)))},ve=(e,t,a=!1)=>{const[n,l]=Re(null==e?void 0:e.ai_default_model),r=t||(null==e?void 0:e.ai_default_env),o=(null==e?void 0:e.ai_envs)??[],c=ge((()=>{if(a&&null!=e&&e.ai_envs){const e={fake:!0,finetunes:[],legacy_finetunes:[],legacy_finetunes_deleted:[],finetunes_deleted:[],deployments:[]};return o.forEach((t=>{t.finetunes&&e.finetunes.push(...t.finetunes),t.legacy_finetunes&&e.legacy_finetunes.push(...t.legacy_finetunes),t.legacy_finetunes_deleted&&e.legacy_finetunes_deleted.push(...t.legacy_finetunes_deleted),t.finetunes_deleted&&e.finetunes_deleted.push(...t.finetunes_deleted),t.deployments&&e.deployments.push(...t.deployments)})),e}return null}),[o,a]),i=ge((()=>{var t;if(a)return c;if(!r)return console.warn("useModels: Environment ID is null. Please provide a valid envId."),null;return(null==e||null===(t=e.ai_envs)||void 0===t?void 0:t.find((e=>e.id===r)))||(console.warn(`useModels: Environment with ID ${r} could not be resolved.`,{envs:o,envId:r}),null)}),[o,r,a,c]),s=ge((()=>{let e=(null==i?void 0:i.finetunes_deleted)||[];return Array.isArray(null==i?void 0:i.legacy_finetunes_deleted)&&(e=[...e,...i.legacy_finetunes_deleted]),e}),[i]),m=e=>({background:{deprecated:"var(--neko-red)",tuned:"var(--neko-green)",preview:"var(--neko-orange)"}[e],color:"white",padding:"3px 4px",margin:"1px 0px 0px 3px",borderRadius:4,fontSize:9,lineHeight:"100%"}),d={deprecated:"DEPRECATED",tuned:"TUNED",preview:"PREVIEW"},u=(e,t)=>{var a;const n=(null===(a=e.tags)||void 0===a?void 0:a.find((e=>["deprecated","preview"].includes(e))))||(t?"tuned":"");return React.createElement(React.Fragment,null,e.name??e.suffix??e.model,n&&React.createElement("small",{style:m(n)},d[n]))},E=ge((()=>{let t=[];if(!0===(null==i?void 0:i.fake))for(const a of e.ai_engines)Array.isArray(a.models)&&(t=[...t,...a.models]);else if("azure"===(null==i?void 0:i.type)){const a=e.ai_engines.find((e=>"openai"===e.type)),n=(null==a?void 0:a.models)??[];t=(null==n?void 0:n.filter((e=>{var t;return null===(t=i.deployments)||void 0===t?void 0:t.find((t=>t.model===e.model))})))??[]}else if("huggingface"===(null==i?void 0:i.type)){var a;t=(null==i||null===(a=i.customModels)||void 0===a?void 0:a.map((e=>{const t=e.tags?[...new Set([...e.tags,"core","chat"])]:["core","chat"],a=t.includes("image")?"text-to-image":"completion";return{model:e.name,name:e.name,features:a,tags:t,options:[]}})))??[]}else{const a=e.ai_engines.find((e=>e.type===(null==i?void 0:i.type)));t=(null==a?void 0:a.models)??[]}let n=(null==i?void 0:i.finetunes)??[];return Array.isArray(null==i?void 0:i.legacy_finetunes)&&(n=[...n,...i.legacy_finetunes]),n=n.filter((e=>"succeeded"===e.status&&e.model)),t=t.map((e=>({...e,name:u(e),rawName:e.name}))),n.length&&(t=[...t,...n.map((e=>{const t=e.model.split(":")[0];return{model:e.model,name:u(e,!0),rawName:e.suffix,suffix:e.suffix,features:["completion"],family:t,description:"finetuned",finetuned:!0,tags:["chat","finetune"]}}))]),t}),[e,i]),p=ge((()=>E.filter((e=>!s.includes(e.model)))),[E,s]),g=ge((()=>E.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("core")}))),[E]),R=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("image")}))),[p]),h=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("embedding")}))),[p]),y=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("vision")}))),[p]),b=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("chat")}))),[p]),v=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("audio")}))),[p]),f=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("json")}))),[p]),_=ge((()=>p.filter((e=>{var t;return null==e||null===(t=e.tags)||void 0===t?void 0:t.includes("realtime")}))),[p]),w=t=>{if(!t)return null;let a=E.find((e=>e.model===t));return a||(t.startsWith("gpt-3.5-turbo-")||t.startsWith("gpt-35-turbo")?t="gpt-3.5-turbo":t.startsWith("gpt-4o-mini")?t="gpt-4o-mini":t.startsWith("gpt-4o")?t="gpt-4o":t.startsWith("gpt-4")?t="gpt-4":t.startsWith("o1-preview")?t="o1-preview":t.startsWith("o1-mini")?t="o1-mini":t.startsWith("o1-")&&(t="o1"),a=E.find((e=>e.model===t)),a||console.warn(`Model ${t} not found.`,{allModels:E,options:e}),a)},C=e=>{const t=w(e);return g.find((e=>(null==e?void 0:e.family)===(null==t?void 0:t.family)))||null},O=(e,t="1024x1024")=>{const a=C(e);if("image"===(null==a?void 0:a.type)&&null!=a&&a.resolutions){const e=a.resolutions.find((e=>e.name===t));return(null==e?void 0:e.price)||null}return(null==a?void 0:a.price)||null};return{allModels:E,model:n,models:p,completionModels:b,imageModels:R,visionModels:y,coreModels:g,embeddingsModels:h,audioModels:v,jsonModels:f,realtimeModels:_,setModel:l,isFineTunedModel:e=>{const t=w(e);return(null==t?void 0:t.finetuned)||!1},getModelName:(e,t=!1)=>{const a=w(e);return a?t&&a?a.rawName:(null==a?void 0:a.name)||(null==a?void 0:a.model)||e:e},getFamilyName:e=>{const t=w(e);return(null==t?void 0:t.family)||null},getPrice:O,getModel:w,calculatePrice:(e,t,a,n="1024x1024")=>{const l=C(e),r=O(e,n);let o=r,c=r;return"object"==typeof r&&null!==r&&(o=r.in,c=r.out),o&&c?o*t*l.unit+c*a*l.unit:0}}},fe=async e=>{const t=await(0,y.IU)(`${_}/vectors/remote_list`,{nonce:N,method:"POST",json:e});return t?{total:t.total,vectors:t.vectors}:{total:0,vectors:[]}},_e=async e=>{e.offset=(e.page-1)*e.limit;const t=await(0,y.IU)(`${_}/discussions/list`,{nonce:N,method:"POST",json:e});return t?{total:t.total,chats:t.chats}:{total:0,chats:[]}},we=async e=>{var t,a,n;const l=null!==(null==e||null===(t=e.filters)||void 0===t?void 0:t.search);if(""===(null==e||null===(a=e.filters)||void 0===a?void 0:a.search))return[];if(!e.filters.envId)return{total:0,vectors:[]};const r=await(0,y.IU)(`${_}/vectors/list`,{nonce:N,method:"POST",json:e});if(l&&null!=r&&null!==(n=r.vectors)&&void 0!==n&&n.length){const t=r.vectors.sort(((t,a)=>{var n;return"asc"===(null==e||null===(n=e.sort)||void 0===n?void 0:n.by)?t.score-a.score:a.score-t.score}));r.vectors=t}return r?{total:r.total,vectors:r.vectors}:{total:0,vectors:[]}};function Ce(e){let t=new Date(e);t=new Date(t.getTime()-60*t.getTimezoneOffset()*1e3);const a=t.toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"}),n=t.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit",second:"2-digit"});return React.createElement(React.Fragment,null,a,React.createElement("br",null),React.createElement("small",null,n))}function Oe(e,t){const a=t?(()=>{let e=t.substring(0,16);return e.length<t.length?(e.endsWith(".")&&(e=e.slice(0,-1)),e+"~"):e})():"";return React.createElement(React.Fragment,null,!e&&React.createElement(React.Fragment,null,Ee.COMMON.GUEST),e&&React.createElement(React.Fragment,null,React.createElement("a",{target:"_blank",href:`/wp-admin/user-edit.php?user_id=${e}`,rel:"noreferrer"},Ee.COMMON.USER," #",e)),React.createElement("br",null),React.createElement("small",null,a))}const Te=(e=6)=>{let t="";for(let a=0;a<e;a++)t+="abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())];return t},Ne=({size:e=14,disabled:t=!1,style:a,...n})=>{const l={position:"relative",top:2,borderRadius:2,filter:t?"grayscale(100%)":"none",...a};return React.createElement("img",pe({width:e,height:e},n,{style:l,alt:"OpenAI",src:w+"/images/chat-openai.svg"}))},Ie=({size:e=14,disabled:t=!1,style:a,...n})=>{const l={position:"relative",top:2,borderRadius:2,filter:t?"grayscale(100%)":"none",...a};return React.createElement("img",pe({width:e,height:e},n,{style:l,alt:"Anthropic",src:w+"/images/chat-anthropic.svg"}))},Me=({size:e=14,disabled:t=!1,style:a,...n})=>{const l={position:"relative",top:2,borderRadius:2,filter:t?"grayscale(100%)":"none",...a};return React.createElement("img",pe({width:e,height:e},n,{style:l,alt:"JavaScript",src:w+"/images/code-js.svg"}))},Se=({size:e=14,disabled:t=!1,style:a,...n})=>{const l={position:"relative",top:2,borderRadius:2,filter:t?"grayscale(100%)":"none",...a};return React.createElement("img",pe({width:e,height:e},n,{style:l,alt:"PHP",src:w+"/images/code-php.svg"}))},Ae=(e=null)=>{const{getBlocks:t,getSelectedBlockClientId:a}=wp.data.select("core/block-editor"),{getEditedPostAttribute:n}=wp.data.select("core/editor"),l=t(),r=n("title"),o=a();let c=r+"\n\n";return l.forEach(((t,a)=>{e&&t.clientId===o?c+=e+"\n\n":c+=(t.attributes.content||"")+"\n\n"})),c.trim()},{useState:ke,useEffect:xe,useMemo:Pe}=wp.element,Le=React.createElement("g",null,React.createElement("g",null,React.createElement("path",{d:"m391 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m331 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m271 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m211 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m151 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m91 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m406 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("path",{d:"m346 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("path",{d:"m286 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("g",{fill:"#5f55af"},React.createElement("path",{d:"m226 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m166 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m106 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 121h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 181h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 241h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 301h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 361h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 421h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"})),React.createElement("path",{d:"m431 91v30h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15z",fill:"#39326c"}),React.createElement("path",{d:"m431 181h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 241h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 301h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 361h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 421h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"})),React.createElement("g",null,React.createElement("path",{d:"m446 51h-380c-8.284 0-15 6.716-15 15v380c0 8.284 6.716 15 15 15h380c8.284 0 15-6.716 15-15v-380c0-8.284-6.716-15-15-15z",fill:"#aed0ff"}),React.createElement("g",null,React.createElement("path",{d:"m461 446v-380c0-8.284-6.716-15-15-15h-190v410h190c8.284 0 15-6.716 15-15z",fill:"#7c84e8"})),React.createElement("path",{d:"m386 111h-260c-8.284 0-15 6.716-15 15v260c0 8.284 6.716 15 15 15h260c8.284 0 15-6.716 15-15v-260c0-8.284-6.716-15-15-15z",fill:"#5f55af"}),React.createElement("g",null,React.createElement("path",{d:"m401 386v-260c0-8.284-6.716-15-15-15h-130v290h130c8.284 0 15-6.716 15-15z",fill:"#39326c"}))),React.createElement("g",null,React.createElement("path",{d:"m247.626 192.389c-.052-.138-.106-.274-.162-.411-2.744-6.671-9.175-10.978-16.387-10.978-.006 0-.012 0-.018 0-7.219.007-13.65 4.329-16.383 11.01-.046.113-.091.227-.134.341l-45.06 118.31c-2.949 7.742.937 16.408 8.679 19.356 7.742 2.95 16.408-.937 19.356-8.679l7.543-19.804h51.691l7.458 19.762c2.267 6.007 7.974 9.708 14.036 9.708 1.76 0 3.55-.312 5.294-.97 7.75-2.925 11.663-11.579 8.737-19.33zm-31.14 79.146 14.538-38.171 14.406 38.171z",fill:"#f9f9f9"}),React.createElement("g",{fill:"#e2dff4"},React.createElement("path",{d:"m264.209 321.296c2.267 6.007 7.974 9.708 14.036 9.708 1.76 0 3.55-.312 5.294-.97 7.75-2.925 11.663-11.579 8.737-19.33l-36.276-96.126v86.956h.751z"}),React.createElement("path",{d:"m328.5 181c-8.284 0-15 6.716-15 15v120c0 8.284 6.716 15 15 15s15-6.716 15-15v-120c0-8.284-6.716-15-15-15z"})))),De=React.createElement("g",null,React.createElement("path",{d:"m213.46 341.461-139.26 156.08c-16.17 18.48-44.53 19.33-61.8 2.06-17.32-17.32-16.37-45.67 2.06-61.8l156.08-139.26s13.46-2.54 29.46 13.46 13.46 29.46 13.46 29.46z",fill:"#0052be"}),React.createElement("path",{d:"m213.46 341.461-139.26 156.08c-16.17 18.48-44.53 19.33-61.8 2.06l187.6-187.6c16 16 13.46 29.46 13.46 29.46z",fill:"#00429b"}),React.createElement("path",{d:"m304 240.001-90.54 101.46c-14.997-14.997-27.922-27.922-42.92-42.92l101.46-90.54z",fill:"#00429b"}),React.createElement("path",{d:"m304 240.001-90.54 101.46-21.46-21.46 96-96z",fill:"#00337a"}),React.createElement("path",{d:"m400 279.001h-64.4l-42.47 57.87c-7.88 10.735-24.824 6.606-26.91-6.52l-11.56-73.01-73.01-11.56c-13.139-2.087-17.244-19.042-6.52-26.91l57.87-42.47v-64.4c0-12.176 13.797-19.289 23.72-12.21l50.15 35.83 70.92-19.9c11.25-3.168 21.656 7.245 18.49 18.49l-19.9 70.92 35.83 50.15c7.071 9.913-.02 23.72-12.21 23.72z",fill:"#ffdd54"}),React.createElement("path",{d:"m412.21 255.281c7.071 9.913-.02 23.72-12.21 23.72h-64.4l-42.47 57.87c-7.875 10.728-24.823 6.616-26.91-6.52l-11.56-73.01 137.79-137.79c3.83 3.84 5.3 9.44 3.83 14.66l-19.9 70.92z",fill:"#ffb454"}),React.createElement("path",{d:"m512 39.001c0 8.28-6.72 15-15 15h-9v9c0 8.28-6.72 15-15 15s-15-6.72-15-15v-9h-9c-8.28 0-15-6.72-15-15s6.72-15 15-15h9v-9c0-8.28 6.72-15 15-15s15 6.72 15 15v9h9c8.28 0 15 6.719 15 15z",fill:"#bee75e"}),React.createElement("path",{d:"m512 39.001c0 8.28-6.72 15-15 15h-9v9c0 8.28-6.72 15-15 15s-15-6.72-15-15v-9l30-30h9c8.28 0 15 6.719 15 15z",fill:"#00cb75"}),React.createElement("path",{d:"m336 41.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#f6f9f9"}),React.createElement("path",{d:"m441 224.001c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9z",fill:"#e2dff4"}),React.createElement("path",{d:"m497 329.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#ff4a4a"}),React.createElement("path",{d:"m192 24.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#ff8659"}),React.createElement("path",{d:"m159.442 122.977-56-32c-7.191-4.109-16.355-1.611-20.466 5.581-4.11 7.193-1.611 16.355 5.581 20.466l56 32c7.16 4.093 16.337 1.644 20.466-5.581 4.111-7.193 1.612-16.355-5.581-20.466z",fill:"#f6f9f9"}),React.createElement("path",{d:"m118.14 169.117-64 8c-8.221 1.027-14.052 8.524-13.023 16.744 1.027 8.218 8.523 14.054 16.744 13.023l64-8c8.221-1.027 14.052-8.524 13.023-16.744-1.028-8.22-8.527-14.062-16.744-13.023z",fill:"#acceff"}),React.createElement("path",{d:"m389.023 352.558c-4.111-7.193-13.274-9.693-20.466-5.581-7.192 4.11-9.691 13.272-5.581 20.466l32 56c2.769 4.845 7.83 7.561 13.037 7.561 11.319 0 18.784-12.341 13.01-22.445z",fill:"#e2dff4"}),React.createElement("path",{d:"m329.86 377.117c-8.222-1.031-15.717 4.804-16.744 13.023l-8 64c-1.117 8.925 5.834 16.862 14.902 16.862 7.455 0 13.917-5.553 14.865-13.142l8-64c1.029-8.219-4.802-15.716-13.023-16.743z",fill:"#6ba7ff"})),Fe=({icon:e="ai",size:t=20,style:a={}}={})=>{const n=Pe((()=>{switch(e){case"ai":default:return Le;case"wand":return De}}),[e]);return React.createElement("svg",{style:{width:t,height:t,marginRight:5,...a},"enable-background":"new 0 0 512 512",height:"512",viewBox:"0 0 512 512",width:"512",xmlns:"http://www.w3.org/2000/svg"},n)},Ue=({title:e=Ee.COMMON.SETTINGS,options:t=I})=>{const a=null==t?void 0:t.module_playground,n=null==t?void 0:t.module_generator_content,l=null==t?void 0:t.module_generator_images;return React.createElement(E.n,{title:`AI Engine | ${e}`},React.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},n&&React.createElement(R.M,{className:"header",onClick:()=>location.href="edit.php?page=mwai_content_generator"},React.createElement(Fe,{icon:"wand",style:{marginRight:8}}),Ee.COMMON.CONTENT),l&&React.createElement(R.M,{className:"header",icon:"",onClick:()=>location.href="edit.php?page=mwai_images_generator"},React.createElement(Fe,{icon:"wand",style:{marginRight:8}}),Ee.COMMON.IMAGES),a&&React.createElement(R.M,{className:"header",icon:"",onClick:()=>location.href="tools.php?page=mwai_dashboard"},React.createElement(Fe,{icon:"wand",style:{marginRight:8}}),Ee.COMMON.PLAYGROUND),React.createElement(R.M,{className:"header",icon:"tools",onClick:()=>location.href="admin.php?page=mwai_settings"})))},Be=((0,P.Ay)(R.M)`
`,P.Ay.div`
display: flex;
justify-content: unset;
align-items: center;
justify-content: space-between;
padding: 0 0 2px 0;
h2 {
margin: 7px 0 0 0;
padding: 0;
}
`),Ge=P.Ay.div`
display: grid;
grid-template-columns: repeat(auto-fit, minmax(30%, 1fr));
grid-template-rows: repeat(auto-fit, minmax(30%, 1fr));
grid-gap: 10px;
margin-top: 20px;
img, div {
width: 100%;
cursor: pointer;
}
.empty-image {
width: 100%;
padding-bottom: 100%;
background-color: #f5f5f5;
}
`;var He=a(4809),je=a.n(He),$e=a(8922),Ye=a(3896),We=a(1843),ze=a(5900),Ve=a(7494),Ke=a(8482),qe=a(209),Xe=a(520),Qe=a(851),Je=a(6897);const Ze=async()=>{const e=await(0,y.IU)(`${_}/helpers/post_types`,{nonce:N});if(!e.success)throw new Error(e.message);return e.postTypes},et=async(e=null,t=!1)=>{const a=await(0,y.IU)(`${_}/openai/finetunes/list_deleted?envId=${e}&legacy=${t}`,{nonce:N});if(!a.success)throw new Error(a.message);return null==a?void 0:a.finetunes},tt=async()=>{const e=await(0,y.IU)(`${_}/settings/themes`,{method:"GET",nonce:N});return null==e?void 0:e.themes},at=async e=>{const t=[];for(let a=0;a<e.length;a++){let n=e[a].themeId;if(t.includes(n)){let e=1;for(;t.includes(n+"-"+e);)e++;n=n+"-"+e}t.push(n),e[a].themeId=n}const a=await(0,y.IU)(`${_}/settings/themes`,{method:"POST",nonce:N,json:{themes:e}});return null==a?void 0:a.themes},nt=async()=>{const e=await(0,y.IU)(`${_}/settings/chatbots`,{method:"GET",nonce:N});if(!e.success)throw new Error(null==e?void 0:e.message);return null==e?void 0:e.chatbots},lt=async e=>{const t=await(0,y.IU)(`${_}/settings/chatbots`,{method:"POST",nonce:N,json:{chatbots:e}});if(!t.success)throw new Error(null==t?void 0:t.message);return null==t?void 0:t.chatbots},rt=async()=>{const e=await(0,y.IU)(`${_}/settings/options`,{method:"GET",nonce:N});return null==e?void 0:e.options},ot=async()=>{try{return(await(0,y.IU)(`${_}/get_logs`,{nonce:N,method:"GET"})).data}catch(e){throw new Error(e.message)}},ct=async()=>{try{await(0,y.IU)(`${_}/clear_logs`,{nonce:N})}catch(e){throw new Error(e.message)}},{useState:it}=wp.element,st=({instructions:e,setMessages:t})=>{const[a,n]=it("post"),[l,r]=it(0),[c,i]=it(!1),[s,m]=it("Generate 30 questions and answers from this text. Questions use a neutral tone. Answers use the same tone as the text."),{isLoading:d,data:u}=(0,o.I)({queryKey:["postTypes"],queryFn:Ze}),{isLoading:E,data:p}=(0,o.I)({queryKey:["postsCount-"+a],queryFn:()=>(async e=>{const t=await(0,y.IU)(`${_}/helpers/count_posts?postType=${e}`,{nonce:N});return null!=t&&t.count?parseInt(null==t?void 0:t.count):null})(a)}),g=(0,Je.XS)({i18n:Ee,onStop:()=>{i(),g.reset()}}),h=c||g.busy||E||d,b=async(t=0,n=void 0,l=void 0)=>{let o=s+"\n\nUse this format:\n\nQ: Question?\nA: Answer.\n\nQ: Question?\nA: Answer.\nText:\n\n{CONTENT}";const c=await(async(e,t=0,a=0)=>await(0,y.IU)(`${_}/helpers/post_content?postType=${e}&offset=${t}&postId=${a}`,{nonce:N}))(a,t,n||void 0);let i=null,m=null;const d=null==c?void 0:c.content,u=null==c?void 0:c.url,E=null==c?void 0:c.title;let p=0;if(c.success)if(d.length<64)console.log("Issue: Content is too short! Skipped.",{content:d});else{var g;o=o.replace("{CONTENT}",d),o=o.replace("{URL}",u),o=o.replace("{TITLE}",E);const e=await(0,y.IU)(`${_}/ai/completions`,{method:"POST",json:{scope:"admin-tools",session:M,message:o},signal:l,nonce:N});if(!e.success){var R;if(null!==(R=e.error)&&void 0!==R&&R.cancelledByUser)return null;throw console.error(e),new Error(e.message??"Unknown error, check your console logs.")}m=null==e?void 0:e.data,null!=e&&null!==(g=e.usage)&&void 0!==g&&g.total_tokens&&(p=e.usage.total_tokens,r((t=>t+e.usage.total_tokens)))}else alert(c.message),i=c.message;null!=l&&l.aborted&&v();const h=(t=>{if(!t)return[];const a=t.split("\n").filter((e=>""!==e.trim())),n=[];let l=[];for(let t=0;t<a.length;t++)a[t].startsWith("Q:")?(l.length&&(n.push({messages:[...l]}),l=[]),l.push({role:"system",content:e}),l.push({role:"user",content:a[t].slice(2).trim()})):a[t].startsWith("A:")&&(l.push({role:"assistant",content:a[t].slice(2).trim()}),n.push({messages:[...l]}),l=[]);return l.length&&n.push({messages:l}),n})(m),b={content:d,prompt:o,rawData:m,entries:h,error:i,tokens:p};return console.log("Result:",b),b},v=()=>{console.log("User aborted."),setBusy(!1),g.reset()};return React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex",width:"100%"}},React.createElement(R.M,{disabled:h,onClick:async()=>{try{r(0);const e=prompt("Enter the ID of a post (leave blank to use the very first one).");if(null===e)return;i("singleGenerate");const a=await b(0,e);a.entries.length?confirm(`Got ${a.entries.length} entries! Do you want to add them to your data? If not, they will be displayed in your console.`)&&t((e=>[...e,...a.entries])):alert("No entries were generated. Check the console for more information.")}catch(e){console.error(e),alert(e.message)}finally{i(!1)}},isBusy:"singleGenerate"===c},Ee.COMMON.SINGLE_GENERATE),React.createElement("span",{style:{color:"#d1e8f2",fontSize:"22px",padding:5}},"|"),React.createElement(R.M,{disabled:h,onClick:()=>(async()=>{r(0);const e=Array.from(Array(p).keys()),a=prompt("There are "+e.length+" entries. If you want to start from a certain entry offset, type it here. Otherwise, just press OK, and everything will be processed."),n=e.map((e=>async n=>{var l;if(console.log("Task "+e),a&&e<a)return{success:!0};const r=await b(e,null,n);return(null==r||null===(l=r.entries)||void 0===l?void 0:l.length)>0&&t((e=>[...e,...r.entries])),{success:!0}}));await g.start(n),i(!1),alert("All done!"),g.reset()})()},"Bulk Generate"),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:10}},"Based on ",E&&"...",!E&&p),React.createElement(ee.u,{id:"postType",scrolldown:!0,disabled:h,name:"postType",style:{width:100,marginLeft:10},onChange:n,value:a},null==u?void 0:u.map((e=>React.createElement(ee.j,{key:e.type,value:e.type,label:e.name})))),React.createElement(Qe.j,{busy:g.busy,style:{marginLeft:10,flex:"auto"},value:g.value,max:g.max,onStopClick:g.stop}),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:10}},"Tokens: ",l)),React.createElement("div",{style:{width:"100%"}},React.createElement(Ye.m,{id:"generatePrompt",name:"generatePrompt",rows:2,style:{marginTop:10,marginBottom:5},value:s,onBlur:m,disabled:h})),g.TasksErrorModal)},{useState:mt,useMemo:dt,useRef:ut,useEffect:Et}=wp.element,pt=({createdOn:e,estimatedOn:t})=>{if(!e||!t)return null;const a=new Date;e=new Date(e),t=new Date(t);const n=e=>new Date(e).toLocaleString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"});return React.createElement("div",null,"Start: ",n(e),".",React.createElement("br",null),"Finish: ",n(t),".",React.createElement("br",null),"Time Left: ",React.createElement("b",null,((e,t)=>{const a=t-e,n=Math.floor(a/6e4),l=Math.floor(n/60);return l>0?`${l} hour${l>1?"s":""} and ${n%60} minute${n%60!=1?"s":""}`:`${n} minute${1!==n?"s":""}`})(a,t)),".",React.createElement("br",null),React.createElement("br",null),React.createElement("small",null,"Use Refresh Models to update the status."))},gt=[{accessor:"row",title:"#",width:25,verticalAlign:"top"},{accessor:"question",title:"Question",verticalAlign:"top"},{accessor:"answer",title:"Answer",verticalAlign:"top"},{accessor:"actions",title:"",width:36,align:"center"}],Rt=[{accessor:"row",title:"#",width:25,verticalAlign:"top"},{accessor:"messages",title:"Messages",verticalAlign:"top"},{accessor:"actions",title:"",width:68,align:"top"}],ht=[{accessor:"status",title:"Status",sortable:!0,width:"120px"},{accessor:"id",title:"ID",width:"120px"},{accessor:"filename",title:"File"},{accessor:"purpose",title:"Purpose"},{accessor:"filesize",title:"Size",sortable:!0},{accessor:"createdOn",title:"Date",sortable:!0,width:"80px"},{accessor:"actions",title:"",width:"190px"}],yt=[{accessor:"status",title:"Status",sortable:!0,width:"120px"},{accessor:"id",title:"ID",width:"120px"},{accessor:"suffix",title:"Suffix"},{accessor:"model",title:"Model"},{accessor:"base_model",title:"Based On",width:"200px"},{accessor:"createdOn",title:"Date",sortable:!0,width:"80px"},{accessor:"actions",title:""}],bt=({status:e,includeText:t=!1})=>{const{colors:a}=(0,r.z)(),n=a.orange,l=a.green,o=a.red;let c=null;switch(e){case"pending":case"running":c=React.createElement($e.z,{title:e,icon:"replay",spinning:!0,width:24,color:n});break;case"succeeded":case"processed":c=React.createElement($e.z,{title:e,icon:"check-circle",width:24,color:l});break;case"failed":c=React.createElement($e.z,{title:e,icon:"close",width:24,color:o});break;case"cancelled":c=React.createElement($e.z,{title:e,icon:"close",width:24,color:n});break;default:c=React.createElement($e.z,{title:e,icon:"alert",width:24,color:n})}return t?React.createElement("div",{style:{display:"flex",alignItems:"center"}},c,React.createElement("span",{style:{textTransform:"uppercase",fontSize:9,marginLeft:3}},e)):c},vt=({children:e,data:t,onChange:a=(()=>{})})=>{const[n,l]=mt(!1),r=e=>{l(!1),e!==t&&a(e)};return n?React.createElement("div",{onKeyUp:e=>{"Escape"===e.key&&r(t)},style:{height:"100%",display:"flex",flexDirection:"column",width:"100%"}},React.createElement(Ye.m,{onBlurForce:!0,autoFocus:!0,fullHeight:!0,rows:3,style:{height:"100%",width:"100%"},onEnter:r,onBlur:r,value:t}),React.createElement(R.M,{onClick:r,fullWidth:!0,style:{marginTop:2,height:35}},"Save")):React.createElement("pre",{style:{width:"100%",height:"100%",whiteSpace:"break-spaces",margin:0,padding:0,fontSize:13,fontFamily:"inherit"},onClick:()=>l(!0)},e)},ft=({options:e,updateOption:t,refreshOptions:a})=>{var n;const{colors:c}=(0,r.z)(),i=(0,l.jE)(),[s,m]=mt(!1),[u,E]=mt(),[h,b]=mt(!1),[v,f]=mt("finetunes"),[w,C]=mt("current"),[O,T]=mt("fine-tune"),[I,M]=mt("meow"),[S,A]=mt(!1),[k,x]=mt(4),[P,L]=mt(4),[D,F]=mt(.1),[U,B]=mt(.01),[G,H]=mt(!1),[j,$]=mt(null==e||null===(n=e.ai_envs)||void 0===n||null===(n=n[0])||void 0===n?void 0:n.id),Y=dt((()=>(null==e?void 0:e.ai_envs)||[]),[e]),W=dt((()=>null==Y?void 0:Y.find((e=>e.id===j))),[j,Y]),z=(null==W?void 0:W.finetunes_deleted)||[],V=(null==W?void 0:W.finetunes)||[],{isFetching:K,error:q,data:X}=(0,o.I)({queryKey:["datasets-"+j+"-"+O],enabled:G,queryFn:()=>(async(e=null,t=null)=>{var a;let n=`${_}/openai/files/list?envId=${e}`;t&&(n+=`&purpose=${t}`);const l=await(0,y.IU)(n,{nonce:N});if(!l.success)throw new Error(l.message);return null==l||null===(a=l.files)||void 0===a?void 0:a.data})(j,O)}),[Q,J]=mt("gpt-4o-mini-2024-07-18"),Z=async(e,a)=>{const n=Y.map((t=>t.id===j?{...t,[e]:a}:t));return t(n,"ai_envs")};Et((()=>{"files"!==v||G||H(!0)}),[v]),Et((()=>{q&&!s&&m(q)}),[q]);const ce=10,[ie,se]=mt(!0),[me,de]=mt(1),[ue,pe]=mt([]),[ge,Re]=mt(!1),[he,ye]=mt("You are Chihiro, an AI Assistant. Your primary objective is to assist website visitors by directing them to the appropriate page or succinctly answering their questions with precision."),[be,ve]=mt(""),[fe,_e]=mt(!1),[we,Ce]=mt([]),Oe=dt((()=>ue.length),[ue]);Et((()=>{if(0===ue.length)return void _e(!1);const e=ue.map(((e,t)=>{if(!e.messages||e.messages.length<3)return t+1;if("system"!==e.messages[0].role||"user"!==e.messages[1].role||"assistant"!==e.messages[2].role)return t+1;for(let a=3;a<e.messages.length;a++)if(e.messages[a].role===e.messages[a-1].role)return t+1;return null})).filter((e=>null!==e));Ce(e),_e(0===e.length)}),[ue]);const Te=({messages:e,currentRow:t,onUpdateDataRow:a,onDeleteDataRow:n})=>React.createElement(React.Fragment,null,e.map(((e,l)=>React.createElement("div",{key:l,style:{display:"flex"}},React.createElement(R.M,{rounded:!0,icon:"trash",onClick:()=>n(t,l+1)}),React.createElement("div",{style:{width:120,paddingLeft:5,paddingTop:0,paddingBottom:4,marginRight:10}},React.createElement(ee.u,{scrolldown:!0,name:"role",value:e.role,style:{width:120},onChange:n=>a(t,n,e.content,l+1)},React.createElement(ee.j,{value:"assistant",label:"Assistant"}),React.createElement(ee.j,{value:"user",label:"User"}),React.createElement(ee.j,{value:"system",label:"System"}))),React.createElement(vt,{data:e.content,style:{flex:"auto"},onChange:n=>a(t,e.role,n,l+1)},e.content))))),Ne=async()=>{await i.invalidateQueries("datasets")},Ie=async()=>{b("finetunes"),V.length?await(async(e=null,t=!1)=>{const a=await(0,y.IU)(`${_}/openai/finetunes/list?envId=${e}&legacy=${t}`,{nonce:N});if(!a.success)throw new Error(a.message);return null==a?void 0:a.finetunes})(j):await et(j),await a(),b(!1)},Me=(e=!0)=>{e&&!confirm(Ee.ALERTS.RESET_BUILDER)||(pe([]),ke({instructions:he,entries:[]}))};Et((()=>{if(!ue||0===ue.length){const e=localStorage.getItem("mwai_builder_data_v2");if(e){const t=JSON.parse(e);pe(t.entries),t.instructions&&ye(t.instructions)}}}),[]);const Se=e=>{let t=!1,a=!1;for(let n=0;n<ue.length;n++){const l=ue[n].messages;if(l&&l.length>0)if("system"===l[0].role){if(l[0].content!==e){if(!t){if(!confirm("The instructions in your data do not match the ones in your entries. Do you want to replace it for every entry?"))return;t=!0}const a=[...ue];a[n].messages[0].content=e,pe((()=>a))}}else{if(!a){if(!confirm("Some entries are missing the system role as the first message. Do you want to add it for every entry where it's missing?"))return;a=!0}const t=[...ue];t[n].messages.unshift({role:"system",content:e}),pe((()=>t))}else{if(!a){if(!confirm("Some entries are missing the system role as the first message. Do you want to add it for every entry where it's missing?"))return;a=!0}const t=[...ue];t[n].messages=[{role:"system",content:e},...l],pe((()=>t))}}},Ae=e=>{ye(e),ge||Se(e)},ke=e=>{(()=>{const e=new Date;let t=e.toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"});t=t.replace(/\//g,"."),t+="-"+e.getHours().toString().padStart(2,"0")+"."+e.getMinutes().toString().padStart(2,"0"),ve(`MEOW-${t}.jsonl`)})();try{e?localStorage.setItem("mwai_builder_data_v2",(0,y.F1)(e)):localStorage.removeItem("mwai_builder_data_v2"),se(!0)}catch(e){localStorage.removeItem("mwai_builder_data_v2"),se(!1)}};Et((()=>{ue&&(null==ue?void 0:ue.length)>0&&ke({instructions:he,entries:ue})}),[ue]),Et((()=>{he&&(null==he?void 0:he.length)>0&&ke({instructions:he,entries:ue})}),[he]);const xe=(e,t)=>{const a=[...ue];a[e-1].messages.splice(t-1,1),pe(a)},Pe=(e,t,a,n=null)=>{const l=ue.map(((l,r)=>{if(r===e-1){if(n)return{...l,messages:l.messages.map(((e,l)=>l===n-1?{...e,role:t,content:a}:e))};if("assistant"===t)return{...l,messages:l.messages.map((e=>"assistant"===e.role?{...e,content:a}:e))};if("user"===t)return{...l,messages:l.messages.map((e=>"user"===e.role?{...e,content:a}:e))}}return l}));pe(l)},Le=dt((()=>{let e=(me-1)*ce;const t=null==ue?void 0:ue.slice((me-1)*ce,(me-1)*ce+ce);return null==t?void 0:t.map((t=>{const a=++e;let n="",l="",r=[];if(ge)r=t.messages;else{const e=t.messages.find((e=>"user"===e.role));e&&(n=e.content);const a=t.messages.find((e=>"assistant"===e.role));a&&(l=a.content)}return{row:a,messages:React.createElement(Te,{entries:ue,messages:r,currentRow:a,onUpdateDataRow:Pe,onDeleteDataRow:xe}),question:React.createElement(vt,{data:n,onChange:e=>Pe(a,"user",e)},n),answer:React.createElement(vt,{data:l,onChange:e=>Pe(a,"assistant",e)},l),actions:React.createElement(React.Fragment,null,ge&&React.createElement(R.M,{rounded:!0,icon:"plus",onClick:()=>Je(a)}),React.createElement(R.M,{rounded:!0,icon:"trash",onClick:()=>(e=>{const t=ue.filter(((t,a)=>a!==e-1));pe(t),0===t.length&&ke({instructions:he,entries:[]})})(a)}))}}))}),[ue,me,ce,ge,Pe,xe]),De=async e=>{if(confirm(Ee.ALERTS.DELETE_FINETUNE)){b(!0);try{await Z("finetunes_deleted",[...z,e])}catch(e){console.error(e),alert(Ee.ALERTS.CHECK_CONSOLE)}b(!1)}},Fe=dt((()=>null==X?void 0:X.sort(((e,t)=>t.created_at-e.created_at)).map((e=>{const t=e.id,a=e.filename,n=new Date(1e3*e.created_at),l="fine-tune"===e.purpose;return{status:React.createElement(bt,{status:e.status,includeText:!0}),id:t,filename:a,purpose:e.purpose,filesize:(0,y.z3)(e.bytes),createdOn:React.createElement(React.Fragment,null,n.toLocaleDateString(),React.createElement("br",null),n.toLocaleTimeString()),actions:React.createElement(React.Fragment,null,React.createElement(R.M,{disabled:!l,icon:"wand",onClick:()=>E(t)},"Train Model"),React.createElement(R.M,{rounded:!0,icon:"arrow-down",onClick:()=>(async(e,t)=>{b(!0);try{const a=await(0,y.IU)(`${_}/openai/files/download`,{method:"POST",nonce:N,json:{envId:j,fileId:e}});if(a.success){const e=new Blob([a.data],{type:"text/plain"}),n=window.URL.createObjectURL(e),l=document.createElement("a");l.setAttribute("href",n),l.setAttribute("download",`${t}`),document.body.appendChild(l),l.click(),l.remove()}else alert(a.message)}catch(e){console.error(e),alert(Ee.ALERTS.CHECK_CONSOLE)}b(!1)})(t,a)}),React.createElement(R.M,{className:"danger",rounded:!0,icon:"trash",onClick:()=>(async e=>{b(!0);try{const t=await(0,y.IU)(`${_}/openai/files/delete`,{method:"POST",nonce:N,json:{envId:j,fileId:e}});t.success?await Ne():alert(t.message)}catch(e){console.error(e),alert(Ee.ALERTS.CHECK_CONSOLE)}b(!1)})(t)}))}}))),[X]),Ue=e=>z.includes(e.model)||z.includes(e.id),Be=e=>"failed"===e.status||"cancelled"===e.status,Ge=e=>!Be(e)&&!Ue(e),He=dt((()=>{if(!V)return[];let e=V;return"current"===w?e=e.filter(Ge):"deleted"===w?e=e.filter(Ue):"failed"===w&&(e=e.filter(Be)),e.map((e=>{const t=new Date(e.createdOn);return{...e,model:e.model?e.model:React.createElement(pt,{createdOn:e.createdOn,estimatedOn:e.estimatedOn}),status:React.createElement(bt,{status:e.status,includeText:!0}),createdOn:React.createElement(React.Fragment,null,t.toLocaleDateString(),React.createElement("br",null),t.toLocaleTimeString()),actions:React.createElement(React.Fragment,null,"succeeded"===e.status&&React.createElement(R.M,{className:"danger",rounded:!0,icon:"trash",onClick:()=>(async e=>{if(confirm(Ee.ALERTS.DELETE_FINETUNE)){b(!0);try{const t=await(0,y.IU)(`${_}/openai/finetunes/delete`,{method:"POST",nonce:N,json:{envId:j,modelId:e}});t.success?await Z("finetunes_deleted",[...z,e]):t.message.indexOf("does not exist")>-1?(alert(Ee.ALERTS.FINETUNE_ALREADY_DELETED),await Z("finetunes_deleted",[...z,e])):alert(t.message)}catch(e){console.error(e),alert(Ee.ALERTS.CHECK_CONSOLE)}b(!1)}})(e.model)}),"cancelled"===e.status&&React.createElement(R.M,{className:"danger",rounded:!0,icon:"trash",onClick:()=>De(e.id)}),"failed"===e.status&&React.createElement(R.M,{className:"danger",rounded:!0,icon:"trash",onClick:()=>De(e.id)}),"pending"===e.status&&React.createElement(R.M,{className:"danger",rounded:!0,icon:"close",onClick:()=>(async e=>{b(!0);try{const t=await(0,y.IU)(`${_}/openai/finetunes/cancel`,{method:"POST",nonce:N,json:{envId:j,finetuneId:e}});t.success?Ie():alert(t.message)}catch(e){console.error(e),alert(Ee.ALERTS.CHECK_CONSOLE)}b(!1)})(e.id)}))}}))}),[w,z,V]),$e=K||h,Qe=dt((()=>{const e=new Date,t=e.getFullYear(),a=e.getMonth()+1,n=e.getDate(),l=e.getHours(),r=e.getMinutes(),o=e.getSeconds();return`${Q}:ft-your-org:${I}-${t}-${a<10?"0"+a:a}-${n<10?"0"+n:n}-${l<10?"0"+l:l}-${r<10?"0"+r:r}-${o<10?"0"+o:o}`}),[I,Q]),Je=(e,t="user",a="Hello!")=>{const n=ue.map(((n,l)=>l===e-1?{...n,messages:[...n.messages,{role:t,content:a}]}:n));pe(n)},Ze=ut(null),tt=null==V?void 0:V.filter(Ge).length,at=null==V?void 0:V.filter(Be).length,nt=null==V?void 0:V.filter(Ue).length,lt=dt((()=>React.createElement(ee.u,{scrolldown:!0,value:j,onChange:$,style:{marginLeft:5}},Y.filter((e=>"openai"===e.type)).map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))))),[j,Y]),rt=dt((()=>{if(0===we.length)return null;const e=we.slice(0,10).map(((e,t)=>React.createElement("span",{key:e,style:{cursor:"pointer",textDecoration:"underline"},onClick:()=>(e=>{const t=Math.floor(e/ce);de(t+1)})(e)},e,t<we.slice(0,10).length-1?", ":"")));return we.length>10?React.createElement(React.Fragment,null,"Some entries are invalid, for example those ones: ",e,", and ",we.length-10," more."):React.createElement(React.Fragment,null,"Some entries are invalid, for example those ones: ",e)}),[we,ce]);return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0,minimal:!0,style:{margin:8}},React.createElement(g._,{inversed:!0,currentTab:v,onChange:(e,t)=>{f(t.key)},action:React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),"finetunes"===v&&React.createElement(React.Fragment,null,React.createElement(R.M,{disabled:h,busy:"finetunes"===h,onClick:Ie,className:"secondary"},Ee.COMMON.REFRESH_MODELS),lt),"files"===v&&React.createElement(React.Fragment,null,React.createElement(R.M,{disabled:h,onClick:async()=>{b(!0),await Ne(),b(!1)},className:"secondary"},"Refresh Files"),lt),"editor"===v&&React.createElement(React.Fragment,null,React.createElement("label",{style:{marginRight:10}},"Filename:"),React.createElement(te.A,{disabled:!Oe||h,value:Oe?be:"",onChange:ve,style:{width:220,marginRight:5}}),React.createElement(R.M,{className:"secondary",disabled:!fe||h,icon:"upload",onClick:async()=>{b(!0);try{const e=ue.map((e=>(0,y.F1)(e))).join("\n"),t=await(0,y.IU)(`${_}/openai/files/upload`,{method:"POST",nonce:N,json:{envId:j,filename:be,data:e}});await Ne(),t.success?(Me(!1),alert(Ee.ALERTS.DATASET_UPLOADED),f("files")):alert(t.message)}catch(e){console.error(e),alert(Ee.ALERTS.CHECK_CONSOLE)}b(!1)}},"Upload to OpenAI"),lt))},React.createElement(g.V,{title:Ee.COMMON.MODELS,key:"finetunes"},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},React.createElement("div",null,(0,y.FE)(Ee.FINETUNING.MODELS_INTRO)),React.createElement(We.o,{value:w,onChange:e=>{C(e)}},React.createElement(We.K,{title:"Current",value:"current",count:tt??"-"}),React.createElement(We.K,{title:"Failed",value:"failed",count:at??"-"}),React.createElement(We.K,{title:"Deleted",value:"deleted",count:nt??"-"}))),React.createElement(ae.g,null),React.createElement(ze.o,{busy:$e,data:He,columns:yt,emptyMessage:Ee.FINETUNING.NO_FINETUNES_YET}),React.createElement("div",{style:{marginTop:5,display:"flex",justifyContent:"end",lineHeight:"12px",alignItems:"center"}},React.createElement(R.M,{small:!0,disabled:h,busy:"clean"===h,onClick:async()=>{b("clean"),await et(j),await a(),b(!1)},className:"primary"},Ee.FINETUNING.CLEAN_MODELS_LIST),React.createElement("small",{style:{marginLeft:5}},Ee.FINETUNING.DELETED_FINETUNE_ISSUE))),React.createElement(g.V,{title:Ee.COMMON.FILES,key:"files"},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},React.createElement("div",null,(0,y.FE)(Ee.FINETUNING.FILES_INTRO)),React.createElement(We.o,{value:O,onChange:e=>{T(e)}},React.createElement(We.K,{title:"Datasets",value:"fine-tune"}),React.createElement(We.K,{title:"All",value:null}))),React.createElement(ae.g,null),React.createElement(ze.o,{busy:$e,data:Fe,columns:ht,emptyMessage:React.createElement(React.Fragment,null,"You do not have any dataset files yet.")})),React.createElement(g.V,{title:Ee.FINETUNING.DATASET_EDITOR,key:"editor"},!ie&&React.createElement("p",{style:{color:"red"}},Ee.FINETUNING.HUGE_DATASET_WARNING),React.createElement(Ve.V,{style:{display:"flex"}},React.createElement(R.M,{icon:"plus",onClick:()=>((e="Question?",t="Answer.")=>{pe([...ue,{messages:[{role:"system",content:he},{role:"user",content:e},{role:"assistant",content:t}]}])})(),disabled:h},"Add Entry"),ge&&React.createElement(R.M,{onClick:()=>Se(he),disabled:h},"Rewrite Instructions"),React.createElement("div",{style:{flex:"auto"}}),React.createElement(Ke.S,{style:{marginLeft:5},onLabel:"Expert",offLabel:"Easy",width:90,onBackgroundColor:c.purple,offBackgroundColor:c.green,onChange:Re,checked:ge}),React.createElement(qe.Z,{ref:Ze,onSelectFiles:async e=>{for(let t=0;t<e.length;t++){const a=e[t],n=new FileReader,l=a.name.endsWith(".json"),r=a.name.endsWith(".jsonl"),o=a.name.endsWith(".csv");let c=!1;l||r||o?(n.onload=async e=>{const t=e.target.result;let a=[];if(l)try{a=JSON.parse(t)}catch(e){return console.error(e),void alert(Ee.ALERTS.ONLY_SUPPORTS_FILES)}else r?(a=t.split("\n").map((e=>{e=e.trim();try{return JSON.parse(e)}catch(t){return console.error(t,e),null}})),a.every((e=>e.messages))||(c=!0)):o&&(a=je().parse(t,{header:!0,skipEmptyLines:!0}).data,console.log("The CSV was loaded!",a),c=!0);c&&(a=a.map((e=>{const t=Object.keys(e).reduce(((t,a)=>(t[a.toLowerCase()]=e[a],t)),{});c=!0;const a=["prompt","question","q"].find((e=>t[e])),n=["completion","reply","a"].find((e=>t[e])),l=t[a],r=t[n],o=null==r?void 0:r.replace(/\n\n$/g,""),i=null==l?void 0:l.replace(/\n\n###\n\n$/g,"");return l&&r?{messages:[{role:"system",content:he},{role:"user",content:i.trim()},{role:"assistant",content:o.trim()}]}:null}))),a=a.filter((e=>e)),a.every((e=>null==e?void 0:e.messages))?pe(a):alert(Ee.ALERTS.ONLY_SUPPORTS_FILES)},n.readAsText(a)):(alert(Ee.ALERTS.ONLY_SUPPORTS_FILES),console.warn(a))}},accept:"",style:{paddingLeft:5}},React.createElement(R.M,{className:"secondary",onClick:()=>Ze.current.click()},"Import")),React.createElement(R.M,{disabled:!Oe,onClick:Me,className:"secondary"},"Clear")),React.createElement(ae.g,null),ue.length>0&&(null==we?void 0:we.length)>0&&React.createElement(React.Fragment,null,React.createElement(oe.X,{variant:"danger"},rt),React.createElement(ae.g,null)),React.createElement(le.a,{keepState:"datasetEditor"},React.createElement(le.Y,{title:"Dataset"},React.createElement(ae.g,{tiny:!0}),React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:"auto"}}),React.createElement(Xe.Q,{currentPage:me,limit:ce,total:Oe,onCurrentPageChanged:de,onClick:de})),React.createElement(ae.g,{tiny:!0}),React.createElement(ze.o,{busy:h,data:Le,columns:ge?Rt:gt,emptyMessage:React.createElement(React.Fragment,null,"You can import a file, or create manually each entry by clicking ",React.createElement("b",null,"Add"),".")}),React.createElement(ae.g,{tiny:!0}),React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:"auto"}}),React.createElement(Xe.Q,{currentPage:me,limit:ce,total:Oe,onCurrentPageChanged:de,onClick:de}),React.createElement(R.M,{disabled:!Oe,style:{marginLeft:5},onClick:()=>{const e=(0,y.F1)(ue,2),t=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(t),n=document.createElement("a");n.href=a;const l=new Date,r=`${l.getFullYear()}-${l.getMonth()+1}-${l.getDate()}-WP.json`;n.download=r,document.body.appendChild(n),n.click(),document.body.removeChild(n)}},"Export as JSON"))),React.createElement(le.Y,{title:Ee.COMMON.CONTEXT},React.createElement(ae.g,null),React.createElement("span",null,"The instructions are the same for all entries. It is used as the ",React.createElement("i",null,"system")," (and first) message in each conversation. More information ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset",target:"_blank",rel:"noreferrer"},"here"),"."),React.createElement(ae.g,null),React.createElement(Ye.m,{id:"instructions",name:"instructions",rows:2,value:he,onBlur:Ae,onEnter:Ae})),React.createElement(le.Y,{title:"Generator"},React.createElement(ae.g,null),React.createElement(st,{options:e,instructions:he,setMessages:pe}),React.createElement(oe.X,{variant:"danger"},"Use this feature with caution. The AI will generate questions and answers for each of your post based on the given prompt, and they will be added to your dataset. Keep in mind that this process may be ",React.createElement("u",null,"extremely slow")," and require a ",React.createElement("u",null,"significant number of API calls"),", resulting in a ",React.createElement("u",null,"high cost"),".")),React.createElement(le.Y,{title:"Instructions"},React.createElement("p",null,"You can create your dataset by importing a file (two columns, in the CSV, JSON or JSONL format) or manually by clicking ",React.createElement("b",null,"Add Entry"),". For the format, check this ",React.createElement("a",{rel:"noreferrer",target:"_blank",href:"https://gist.github.com/jordymeow/a855df4a1f644bb3df8c78ea87c1a2ca"},"JSON Example")," (more complex) or this ",React.createElement("a",{rel:"noreferrer",target:"_blank",href:"https://gist.github.com/jordymeow/e0c80ebeefe4d4d07ae39995c561ba4a"},"CSV Example")," (simpler). ",React.createElement("b",null,"Writing datasets is actually complex.")," Please have a look at OpenAI's ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/fine-tuning/conditional-generation",target:"_blank",rel:"noreferrer"},"tutorials"),". And here is Meow Apps' ",React.createElement("a",{href:"https://meowapps.com/wordpress-chatbot-finetuned-model-ai/",target:"_blank",rel:"noreferrer"},"simplified tutorial"),". Is your dataset ready? Modify the filename to your liking and click ",React.createElement("b",null,"Upload to OpenAI"),"."),React.createElement("p",null,"To avoid losing your work, this data is kept in your browser's local storage."))))))),React.createElement(ne.L,{style:{margin:10}},React.createElement(re.n,{isOpen:s,title:"Error",onRequestClose:()=>m(),okButton:{label:"Ok",onClick:()=>m()},content:React.createElement(React.Fragment,null,React.createElement("p",null,null==s?void 0:s.message))}),React.createElement(re.n,{isOpen:u,title:"Train a new model",onRequestClose:()=>E(),okButton:{label:"Start",disabled:h,onClick:async()=>{const e=u,t=I;b(!0);let a={envId:j,fileId:e,model:Q,suffix:t};S&&(a={...a,nEpochs:k,batchSize:P,learningRateMultiplier:D,promptLossWeight:U});try{const e=await(0,y.IU)(`${_}/openai/files/finetune`,{method:"POST",nonce:N,json:a});e.success?(Ie(),alert(Ee.ALERTS.FINETUNING_STARTED),f("finetunes"),E()):alert(e.message)}catch(e){console.log(e.message),alert(e.message)}b(!1)}},cancelButton:{label:"Close",disabled:h,onClick:()=>E()},content:React.createElement(React.Fragment,null,React.createElement("p",null,"Exciting! 🎵 You are about to create your own new model, based on your dataset. You simply need to select a base model, and optionally, to modify the ",React.createElement("a",{href:"https://beta.openai.com/docs/guides/fine-tuning/hyperparameters",target:"_blank",rel:"noreferrer"},"hyperparameters"),". Before starting the process, make sure that:"),React.createElement("ul",null,React.createElement("li",null,"✅ The dataset is well-defined."),React.createElement("li",null,"✅ You understand ",React.createElement("a",{href:"https://openai.com/api/pricing/#faq-fine-tuning-pricing-calculation",target:"_blank",rel:"noreferrer"},"OpenAI pricing")," about fine-tuning.")),React.createElement("label",null,"Base model:"),React.createElement(ae.g,{height:5}),React.createElement(te.A,{value:Q,onChange:J,description:React.createElement(React.Fragment,null,"As of August 2024, you can use ",React.createElement("a",{href:"#",onClick:()=>J("gpt-4o-mini-2024-07-18")},"gpt-4o-mini-2024-07-18"),", ",React.createElement("a",{href:"#",onClick:()=>J("gpt-3.5-turbo-0125")},"gpt-3.5-turbo-0125"),", or any of your previously fine-tuned models. Check all the available models ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/fine-tuning/which-models-can-be-fine-tuned",target:"_blank",rel:"noreferrer"},"here"),".")}),React.createElement(ae.g,{height:10}),React.createElement("label",null,"Suffix (for new model name):"),React.createElement(ae.g,{height:5}),React.createElement(te.A,{value:I,onChange:M}),React.createElement(ae.g,{height:5}),React.createElement("small",null,"The name of the new model name will be decided by OpenAI. You can customize it a bit with a ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/fine-tuning/create-a-fine-tuned-model",target:"_blank",rel:"noreferrer"},"suffix"),". Preview: ",React.createElement("b",null,Qe),"."),React.createElement(ae.g,{line:!0,height:20}),React.createElement(d.R,{label:"Enable HyperParams",checked:S,onChange:A}),S&&React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"}},React.createElement("label",{style:{marginRight:5}},"Number of Epochs:"),React.createElement(te.A,{style:{marginRight:5},value:k,onChange:x,type:"number"}),React.createElement("label",{style:{marginRight:5}},"Batch Size:"),React.createElement(te.A,{value:P,onChange:L,type:"number"})),React.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"}},React.createElement("label",{style:{marginRight:5}},"Learning Rate Multiplier:"),React.createElement(te.A,{style:{marginRight:5},value:D,onChange:F,type:"number"}),React.createElement("label",{style:{marginRight:5}},"Prompt Loss Weight:"),React.createElement(te.A,{value:U,onChange:B,type:"number"}))))})))},{useState:_t}=wp.element,wt=({options:e,updateOption:t,busy:a})=>{const[n,l]=_t("I would love to live on a tropical island with beautiful and sexy felines, where we could bask in the sun on the sandy beaches, sip on refreshing coconut milk, and enjoy each other's company. While we might occasionally fight in the trees, our days would mostly be spent in peaceful slumber. However, I am not sure of how we would handle any potential disruptions to our idyllic existence if human were to come..."),[r,o]=_t([]),[c,i]=_t(""),[m,u]=_t(!1),E=null==e?void 0:e.chatbot_moderation,g=m||a,b=React.createElement(s.d,{title:Ee.COMMON.CHATBOT},React.createElement(d.R,{name:"chatbot_moderation",label:Ee.COMMON.ENABLE,value:"1",checked:E,description:Ee.SETTINGS.CHATBOT_MODERATION_HELP,onChange:t}));return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{busy:g,title:Ee.COMMON.SETTINGS,className:"primary"},React.createElement("p",null,"You can enable moderation various parts of WordPress. It will slow down the processing a little."),b)),React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{busy:g,title:"AI Moderation Tester",className:"primary"},React.createElement("p",null,"Paste a text below, and check if it is safe for your website. ",React.createElement("b",null,"OpenAI Moderation Model is free!")," Learn more about it ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/moderation/overview",target:"_blank"},"here"),"."),React.createElement(Ye.m,{name:"context",rows:8,value:n,onChange:l}),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,onClick:async()=>{u(!0);const e=await(0,y.IU)(`${_}/ai/moderate`,{method:"POST",nonce:N,json:{text:n}});if(e.success){let t=e.results;o(null==t?void 0:t.results)}else i(e.message);u(!1)}},"Moderation Check"),React.createElement(ae.g,null),React.createElement("label",null,"Results:"),React.createElement("pre",null,(0,y.F1)(r,2))))))},{useState:Ct,useEffect:Ot,useMemo:Tt}=wp.element,Nt=({modal:e,busy:t,setModal:a,onAddEmbedding:n,onModifyEmbedding:l})=>{const[r,o]=Ct(!1),c=t;Ot((()=>{"edit"!==(null==e?void 0:e.type)&&"add"!==(null==e?void 0:e.type)||o((null==e?void 0:e.data)||{})}),[e]);const i=Tt((()=>{var t,a,n,l,o;return null==e||!e.data||(null==e||null===(t=e.data)||void 0===t?void 0:t.title)!==(null==r?void 0:r.title)||(null==e||null===(a=e.data)||void 0===a?void 0:a.content)!==(null==r?void 0:r.content)||(null==e||null===(n=e.data)||void 0===n?void 0:n.behavior)!==(null==r?void 0:r.behavior)||(null==e||null===(l=e.data)||void 0===l?void 0:l.type)!==(null==r?void 0:r.type)||(null==e||null===(o=e.data)||void 0===o?void 0:o.refId)!==(null==r?void 0:r.refId)}),[e,r]);return React.createElement(React.Fragment,null,React.createElement(re.n,{isOpen:"edit"===(null==e?void 0:e.type)||"add"===(null==e?void 0:e.type),title:"edit"===(null==e?void 0:e.type)?Ee.COMMON.MODIFY_EMBEDDING:Ee.COMMON.ADD_EMBEDDING,okButton:{label:"edit"===(null==e?void 0:e.type)?Ee.COMMON.MODIFY_EMBEDDING:Ee.COMMON.ADD_EMBEDDING,disabled:!i||t,isBusy:"addEmbedding"===t,onClick:()=>{"edit"===e.type?(async()=>{try{await l(r),a(null)}catch(e){alert(e.message)}})():(async()=>{try{await n(r),a(null)}catch(e){alert(e.message)}})()}},cancelButton:{disabled:t,onClick:()=>a(null)},onRequestClose:()=>a(null),content:React.createElement(React.Fragment,null,React.createElement("p",null,"A custom embedding can be a sentence, a paragraph or a whole article. When an user input is made, the AI will search for the best embedding that matches the user input and will be able to reply with more accuracy."),React.createElement(ae.g,null),React.createElement("label",null,"Title:"),React.createElement(ae.g,{tiny:!0}),React.createElement(te.A,{value:null==r?void 0:r.title,placeholder:'Title, like "My Website Information"',description:"This is for your convenience only, it's not used anywhere.",onChange:e=>o({...r,title:e})}),React.createElement(ae.g,null),React.createElement("label",null,"Content:"),React.createElement(ae.g,{tiny:!0}),React.createElement(Ye.m,{countable:"chars",maxLength:64e3,description:"The content of your embeddings that will be used by the AI if it matches the user input.",value:null==r?void 0:r.content,onChange:e=>o({...r,content:e})}),React.createElement(ae.g,null),React.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},React.createElement("div",{style:{flex:3}},React.createElement("label",null,"Behavior:"),React.createElement(ae.g,{tiny:!0}),React.createElement(ee.u,{scrolldown:!0,name:"behavior",disabled:c||!0,value:null==r?void 0:r.behavior,onChange:e=>{o({...r,behavior:e})}},React.createElement(ee.j,{value:"context",label:"Context"}),React.createElement(ee.j,{value:"reply",label:"Reply"}))),React.createElement("div",{style:{flex:3,marginLeft:5}},React.createElement("label",null,"Type:"),React.createElement(ae.g,{tiny:!0}),React.createElement(ee.u,{scrolldown:!0,name:"type",disabled:c||!0,value:null==r?void 0:r.type,onChange:e=>{o({...r,type:e})}},React.createElement(ee.j,{value:"manual",label:"Manual"}),React.createElement(ee.j,{value:"postId",label:"Related to Post"}))),"postId"===(null==r?void 0:r.type)&&React.createElement("div",{style:{flex:1,marginLeft:5}},React.createElement("label",null,"Post ID:"),React.createElement(ae.g,{tiny:!0}),React.createElement(te.A,{value:null==r?void 0:r.refId,disabled:!0,onChange:e=>o({...r,refId:e})}))))}))},{useState:It}=wp.element;function Mt(e,t){const a=new Blob([e],{type:"text/plain;charset=utf-8;"}),n=document.createElement("a");n.href=URL.createObjectURL(a),n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}const St=({modal:e,setModal:t})=>{const[a,n]=It(!1),[l,r]=It(0),[o,c]=It(0),i=null==e?void 0:e.data,s=async()=>{let e=!1;const t={page:1,limit:20,filters:{envId:i.envId,dbIndex:i.dbIndex,dbNS:i.dbNS}};let a=[];for(;!e;){const n=await we(t);n.vectors.length<2&&(e=!0),r((()=>n.total)),a=a.concat(n.vectors),c((()=>a.length)),t.page++}return a};return React.createElement(React.Fragment,null,React.createElement(re.n,{isOpen:"export"===(null==e?void 0:e.type),title:"Export Embeddings",onRequestClose:()=>t(null),okButton:{label:"Close",disabled:a,onClick:()=>t(null)},customButtons:React.createElement(React.Fragment,null,React.createElement(R.M,{onClick:async()=>{try{n(!0);const e=await s(),t=je().unparse(e),a=new Date,l=a.getFullYear();Mt(t,`vectors-${l}-${a.getMonth()+1}-${a.getDate()}.csv`),setTimeout((()=>{r(0)}),1e3)}catch(e){console.error(e),alert("An error occured while exporting vectors. Check your console.")}finally{n(!1)}},disabled:a},"Export CSV"),React.createElement(R.M,{onClick:async()=>{try{n(!0);const e=await s(),t=(0,y.F1)(e,2),a=new Date,l=a.getFullYear();Mt(t,`vectors-${l}-${a.getMonth()+1}-${a.getDate()}.json`),setTimeout((()=>{r(0)}),1e3)}catch(e){console.error(e),alert("An error occured while exporting vectors. Check your console.")}finally{n(!1)}},disabled:a},"Export JSON")),content:React.createElement(React.Fragment,null,React.createElement(Qe.j,{busy:a,style:{flex:"auto"},value:o,max:l}))}))},{useState:At}=wp.element,kt=({modal:e,setModal:t,onAddEmbedding:a,onModifyEmbedding:n})=>{var l;const[r,o]=At(!1),[c,i]=At(0),[s,m]=At(0),[u,E]=At({add:[],modify:[],same:[],total:0,isReady:!1}),p=(null==e||null===(l=e.data)||void 0===l?void 0:l.importVectors)??[],[g,h]=At({envId:!1,dbId:!1,dbIndex:!1,dbNS:!1,title:!0,refId:!0}),y=null==e?void 0:e.data,b=e=>({id:e.id??null,type:e.type??"manual",title:e.title??"N/A",behavior:e.behavior??"context",envId:(null==y?void 0:y.envId)??null,dbId:e.dbId??null,dbIndex:y.dbIndex??null,dbNS:y.dbNS??null,content:e.content??"",refId:e.refId??null}),v=(e,t,a)=>Object.keys(a).every((n=>!a[n]||e[n]===t[n])),f=()=>{t(null),o(!1),i(0),m(0),E({add:[],modify:[],same:[],total:0,isReady:!1})};return React.createElement(React.Fragment,null,React.createElement(re.n,{isOpen:"import"===(null==e?void 0:e.type),title:"Import Embeddings",onRequestClose:f,okButton:{label:"Close",onClick:f,disabled:r},customButtons:React.createElement(React.Fragment,null,React.createElement(R.M,{onClick:async()=>{try{let e=!1;const t={page:1,limit:20,filters:{envId:y.envId,dbIndex:y.dbIndex,dbNS:y.dbNS}};let a=[];for(o("stepOne");!e;){const n=await we(t);n.vectors.length<2&&(e=!0),i((()=>n.total)),a=a.concat(n.vectors),m((()=>a.length)),t.page++}(async(e,t)=>{const a=[],n=[],l=[];console.log("Calculate Diff",{currentVectors:e,importVectors:t});for(const r of t){const t=b(r),o=e.find((e=>v(e,t,g)));console.log("Matched Vector",{cleanVector:{...t},matchedVector:{...o}}),o?t.id=o.id:delete t.id;const c=e.find((e=>e.id===t.id));c&&t.content===c.content&&t.title===c.title?l.push(t):t.id?n.push(t):a.push(t)}const r=a.length+n.length;E({add:a,modify:n,same:l,total:r,isReady:!0}),console.log("Embeddings Diff",{add:a,modify:n,same:l,total:r})})(a,p)}catch(e){console.error(e),alert("An error occured while retrieving your current embeddings. Check your console.")}finally{o(!1)}},disabled:r},"Check Differences"),React.createElement(R.M,{onClick:async()=>{try{i(u.add.length+u.modify.length),m(0),o("stepTwo");for(const e of u.add)await a(e,!0),m((e=>e+1));for(const e of u.modify)await n(e,!0),m((e=>e+1));alert("All embeddings have been updated."),E({add:[],modify:[],same:[],total:0,isReady:!1}),f()}catch(e){console.error(e),alert("An error occured while updating embeddings. Check your console.")}finally{o(!1)}},disabled:r||0===u.total},"Apply Changes")),content:React.createElement(React.Fragment,null,React.createElement("p",null,"There are ",React.createElement("b",null,p.length," embeddings")," in the file."),React.createElement(ae.g,null),React.createElement(le.Y,{title:"1 - Check Differences"}),React.createElement("p",null,"Calculates the differences between the embeddings in your file and the ones currently registered in AI Engine. Based on that, a list of changes will be created. Please note that the environment, index and namespace that might be set in the file will be ignored."),React.createElement("p",{style:{marginTop:10}},"An embedding will be considered the same entry based on:"),React.createElement(ae.g,null),React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{marginLeft:15}},React.createElement(d.R,{small:!0,label:"DB ID",disabled:!1,checked:g.dbId,onChange:()=>h({...g,dbId:!g.dbId})})),React.createElement("div",{style:{marginLeft:15}},React.createElement(d.R,{small:!0,label:"Title",disabled:!1,checked:g.title,onChange:()=>h({...g,title:!g.title})})),React.createElement("div",{style:{marginLeft:15}},React.createElement(d.R,{small:!0,label:"Ref (Post ID)",disabled:!1,checked:g.refId,onChange:()=>h({...g,refId:!g.refId})}))),"stepOne"===r&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(Qe.j,{busy:r,style:{flex:"auto"},value:s,max:c})),React.createElement(ae.g,null),React.createElement(le.Y,{title:"2 - Apply Changes"}),!u.isReady&&React.createElement("i",null,"Waiting for diff..."),u.isReady&&React.createElement(React.Fragment,null,React.createElement("p",null,"There are ",u.same.length>=1&&React.createElement("span",null,React.createElement("b",null,u.same.length," identical embeddings")," (with the same title and content). They will be ignored. "),React.createElement("span",null,"Changes to apply:")),React.createElement("ul",null,React.createElement("li",null,"👉 Add: ",React.createElement("b",null,u.add.length)),React.createElement("li",null,"👉 Modify: ",React.createElement("b",null,u.modify.length)))),"stepTwo"===r&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(Qe.j,{busy:r,style:{flex:"auto"},value:s,max:c})),React.createElement(ae.g,null))}))},{useState:xt,useMemo:Pt,useEffect:Lt,useRef:Dt}=wp.element,Ft=[{accessor:"status",title:"Status",width:"80px"},{accessor:"title",title:"Title / Model",sortable:!1},{accessor:"type",title:"Ref",sortable:!1,width:"75px"},{accessor:"score",title:"Score",sortable:!0,width:"65px"},{accessor:"updated",title:"Updated",sortable:!1,width:"80px"},{accessor:"actions",title:"",width:"100px"}],Ut=[{accessor:"status",title:"Status",sortable:!0,width:"80px"},{accessor:"title",title:"Title / Model",sortable:!1},{accessor:"type",title:"Ref",sortable:!0,width:"75px"},{accessor:"updated",title:"Updated",sortable:!0,width:"80px"},{accessor:"actions",title:"",width:"100px"}],Bt=({embedding:e,envName:t})=>{const{colors:a}=(0,r.z)(),{status:n,content:l,error:o}=e,c=Pt((()=>{if("ok"===n){if(!t)return"env_issue";if(!l)return"empty"}return n}),[n,t,l]),i=Pt((()=>"orphan"===c?"This embedding was retrieved from the Vector DB, but it has no content. Add some, or delete it.":"env_issue"===c?"This embedding is not related to any Embeddings Environment. Make sure you have an Embeddings Environment selected, and Sync/Refresh it; it will be linked to the current environment. You can also delete it.":"empty"===c?"This embedding has no content.":o||null),[c,o]),{icon:s,color:m}=Pt((()=>{const e={outdated:{icon:"alert",color:a.orange},ok:{icon:"check-circle",color:a.green},error:{icon:"alert",color:a.red},orphan:{icon:"pencil",color:a.orange},env_issue:{icon:"database",color:a.red},empty:{icon:"alert",color:a.orange},default:{icon:"alert",color:a.orange}};return e[c]||e.default}),[c,a]);return React.createElement("div",{style:{display:"flex",alignItems:"center"},title:i},React.createElement($e.z,{icon:s,width:24,color:m,title:i}),React.createElement("span",{style:{textTransform:"uppercase",fontSize:9,marginLeft:3}},c))},Gt=({options:e,updateOption:t})=>{const a=(0,l.jE)(),{colors:n}=(0,r.z)(),[c,s]=xt("post"),[m,u]=xt(!1),[E,b]=xt("edit"),[v,f]=xt(null),[w,C]=xt(!1),[O,T]=xt([]),[I,M]=xt({type:null,data:null}),[S,A]=xt(null),k=e.embeddings||{},x=Dt(null),P=ve(e,!1,!0),L=e.embeddings_envs||[],[D,F]=xt((()=>{const e=localStorage.getItem("mwai-admin-embeddings");try{const t=JSON.parse(e);return{environmentId:(null==t?void 0:t.environmentId)||null}}catch(e){return{environmentId:null}}})().environmentId),U=Pt((()=>L.find((e=>e.id===D))||null),[L,D]),B=(null==U?void 0:U.min_score)>=0?U.min_score:35,G=(null==U?void 0:U.max_select)>=0?U.max_select:10,H=Pt((()=>null!=U&&U.ai_embeddings_override&&null!=U&&U.ai_embeddings_env&&null!=U&&U.ai_embeddings_model?P.getModel(U.ai_embeddings_model):P.getModel(e.ai_embeddings_default_model)),[U,k.model]),{isLoading:j,data:$}=(0,o.I)({queryKey:["postTypes"],queryFn:Ze}),{isLoading:Y,data:W}=(0,o.I)({queryKey:["postsCount-"+c+"-"+(null==k?void 0:k.syncPostStatus)??"publish"],queryFn:()=>(async(e,t="publish")=>{const a=await(0,y.IU)(`${_}/helpers/count_posts?postType=${e}&postStatus=${t}`,{nonce:N});return null!=a&&a.count?parseInt(null==a?void 0:a.count):null})(c,(null==k?void 0:k.syncPostStatus)??"publish")}),[z,V]=xt({filters:{envId:D,search:v,debugMode:!1},sort:{accessor:"updated",by:"desc"},page:1,limit:20}),{isFetching:K,data:q,error:X}=(0,o.I)({queryKey:["vectors",z],queryFn:()=>we(z)}),Q=K||"searchVectors"===m,J="search"===E?Ft:Ut,Z=(0,Je.XS)({i18n:Ee,onStop:()=>{u(),Z.reset()}}),ne=m||Q||Z.isBusy||j,le=async e=>{u("updateSettings"),await t({...e},"embeddings"),u(null)},re=Pt((()=>k.syncPosts&&(null==k?void 0:k.syncPostsEnvId)!==D),[D,k]);Lt((()=>{!k.syncPosts&&k.syncPostsEnvId&&le({...k,syncPostsEnvId:null})}),[k.syncPosts]);const ce=Pt((()=>L.find((e=>e.id===k.syncPostsEnvId))||null),[k.syncPostsEnvId]);Lt((()=>{V({...z,filters:{envId:D,search:v,debugMode:S}}),(({environmentId:e})=>{const t={environmentId:e||null};localStorage.setItem("mwai-admin-embeddings",(0,y.F1)(t))})({environmentId:D})}),[D,S]),Lt((()=>{const e="edit"===E?null:"";f("edit"===E?null:""),V({...z,filters:{...z.filters,search:e},sort:{accessor:"edit"===E?"created":"score",by:"desc"},page:1,limit:20})}),[E]),Lt((()=>{var e,t;null!=k&&null!==(e=k.syncPostTypes)&&void 0!==e&&e.length&&null!=k&&null!==(t=k.syncPostStatus)&&void 0!==t&&t.length||le({...k,syncPostTypes:["post","page","product"],syncPostStatus:["publish"]})}),[k.syncPostTypes]);const ie=Pt((()=>{const e={padding:"8px 15px",textAlign:"center"};return k.syncPosts&&!ce?React.createElement(oe.X,{variant:"danger",style:e},"Pick a valid environment for the sync."):k.syncPosts?React.createElement(oe.X,{variant:"special",style:e},"Enabled on ",React.createElement("b",null,null==ce?void 0:ce.name)):React.createElement(oe.X,{variant:"info",style:e},"Disabled")}),[k]),se=async()=>{v!==z.filters.search?V({...z,filters:{...z.filters,search:v}}):a.invalidateQueries({queryKey:["vectors"]})},me=async(e=w,t=!1)=>{t||u("addEmbedding");try{const t={...e};t.envId||(t.envId=U.id);const a=await(0,y.IU)(`${_}/vectors/add`,{nonce:N,method:"POST",json:{vector:t}});he(null==a?void 0:a.vector,!0),C(!1),console.log("Embedding Added",e)}catch(e){throw console.error(e),new Error(e.message??"Unknown error, check your console logs.")}finally{t||u(!1)}return!0},de=async(e=w,t)=>{t||u("addEmbedding");try{const t={...e};t.envId=U.id;const a=await(0,y.IU)(`${_}/vectors/update`,{nonce:N,method:"POST",json:{vector:t}});he(null==a?void 0:a.vector),C(!1),console.log("Embeddings updated.",a)}catch(e){throw console.error(e),new Error(e.message??"Unknown error, check your console logs.")}finally{t||u(!1)}return!0},ue=async(e,t)=>{t||u("deleteEmbedding");try{await(0,y.IU)(`${_}/vectors/delete`,{nonce:N,method:"POST",json:{envId:U.id,ids:e}})}catch(t){if(console.error(t),!confirm(`Got an error from the vector database:\n\n${t.message}\n\nDo you want to force the deletion locally?`))throw new Error(t.message??"Unknown error, check your console logs.");await(0,y.IU)(`${_}/vectors/delete`,{nonce:N,method:"POST",json:{envId:U.id,ids:e,force:!0}})}finally{t||u(!1)}console.log("Embeddings deleted.",{ids:e}),a.invalidateQueries({queryKey:["vectors"]}),"search"===E&&console.error("We should update the vectors data with the deleted embeddings.")},pe=Pt((()=>(null==q?void 0:q.total)||0),[q]),ge=Pt((()=>{const e=q;return null!=e&&e.vectors?null==e?void 0:e.vectors.map((e=>{var t,a;let l=new Date(e.updated);l=new Date(l.getTime()-60*l.getTimezoneOffset()*1e3);const r=l.toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"}),o=l.toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit",second:"2-digit"}),c=React.createElement("span",null,r,React.createElement("br",null),o);let i=new Date(e.created);i=new Date(i.getTime()-60*i.getTimezoneOffset()*1e3);const s=i.toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),m=e.score?React.createElement("span",{style:{color:e.score>B/100?"var(--neko-green)":"inherit"}},(100*e.score.toFixed(4)).toFixed(2)):"-";let d=null;e.subType&&"string"==typeof e.subType&&(d=e.subType.toUpperCase());const u=(null===(t=P.getModel(e.model))||void 0===t?void 0:t.name)??e.model,E=e.model&&e.model!==(null==H?void 0:H.model),p=e.envId!==D,g=null===(a=L.find((t=>t.id===e.envId)))||void 0===a?void 0:a.name,h="ok"!==e.status||E||p;let y=null;return E&&(y=React.createElement("b",{style:{color:n.red}},"[MODEL MISMATCH] "),console.error(`Embeddings Model Mismatch for #${e.id}: "${e.title}". Should be "${null==H?void 0:H.model}" but "${e.model}" was found. Sync will fix this.`)),p&&g&&(y=React.createElement("b",{style:{color:n.green}},"[ENV: ",g,"] ")),{id:e.id,type:React.createElement("small",null,e.refId?React.createElement(React.Fragment,null,"ID ",React.createElement("a",{href:`/wp-admin/post.php?post=${e.refId}&action=edit`,target:"_blank",rel:"noreferrer"},"#",e.refId),React.createElement("br",null),React.createElement("div",{style:{fontSize:"80%",marginTop:-5}},d)):"MANUAL"),score:m,title:React.createElement(React.Fragment,null,React.createElement("span",null,e.title),React.createElement("br",null),React.createElement("small",{style:{color:E?n.red:"inherit"}},y,u," ",e.dimensions&&React.createElement(React.Fragment,null," (",e.dimensions,")"))),status:React.createElement(Bt,{embedding:e,envName:g}),updated:c,created:s,actions:React.createElement(React.Fragment,null,React.createElement(R.M,{className:"primary",rounded:!0,icon:"pencil",disabled:ne,onClick:()=>M({type:"edit",data:e})}),React.createElement(R.M,{className:"primary",rounded:!0,icon:"replay",disabled:ne||!h,onClick:()=>Re(e.id)}),React.createElement(R.M,{className:"danger",rounded:!0,icon:"trash",disabled:ne,onClick:()=>ue([e.id])}))}})):[]}),[E,q,ne]),Re=async e=>{u("syncEmbedding");try{await be(e)}catch(e){console.error(e),alert((null==e?void 0:e.message)??e)}u(!1)},he=(e,t=!1)=>{a.invalidateQueries({queryKey:["vectors"]})},be=async(e=null,t=null,a=void 0)=>{const n=await(async({vectorId:e,postId:t,envId:a},n=null)=>await(0,y.IU)(`${_}/vectors/sync`,{nonce:N,method:"POST",json:{vectorId:e,postId:t,envId:a},signal:n}))({vectorId:e,postId:t,envId:D},a);n.success&&he(n.vector)},_e=async(e=!1)=>{u("bulkPushAll");let t=[];if(e||0===O.length){const e=await(async(e,t="publish")=>{const a=await(0,y.IU)(`${_}/helpers/posts_ids?postType=${e}&postStatus=${t}`,{nonce:N});return null!=a&&a.postIds?a.postIds:[]})(c,k.syncPostStatus);t=e.map((e=>async t=>(await be(null,e,t),{success:!0})))}else t=q.vectors.filter((e=>O.includes(e.id))).map((e=>async t=>("postId"===e.type?await be(e.id,null,t):"manual"===e.type&&await de(e,t),{success:!0})));await Z.start(t),u(!1),alert("All done! For more information, check the console (Chrome Developer Tools). Posts with very short content (or content that could not be retrieved) are skipped."),Z.reset()},Ce=Pt((()=>React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex"}},React.createElement(ee.u,{scrolldown:!0,name:"environment",style:{flex:1,marginBottom:5},disabled:ne,value:(null==U?void 0:U.id)??null,onChange:e=>{F(e)}},L.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))),!(null!=L&&L.length)&&React.createElement(ee.j,{value:null,label:"None"}))))),[U,L,ne]),Oe=Pt((()=>null!=X&&X.message?React.createElement(oe.X,{variant:"danger",style:{margin:"5px 5px"}},React.createElement("b",null,X.message),React.createElement("br",null),React.createElement("small",null,"Check your Console Logs and PHP Error Logs for more information.")):"search"===E?Ee.HELP.NO_EMBEDDINGS_RESULTS:Ee.HELP.NO_EMBEDDINGS_ROWS),[E,X]);return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0,minimal:!0,style:{margin:10}},React.createElement("div",{style:{display:"flex"}},React.createElement(Ve.V,{style:{flex:1,marginRight:15}},React.createElement(Ke.S,{style:{marginRight:10},disabled:ne,onLabel:Ee.EMBEDDINGS.AI_SEARCH,offLabel:Ee.EMBEDDINGS.EDIT,width:110,onValue:"search",offValue:"edit",checked:"search"===E,onChange:b,onBackgroundColor:n.purple,offBackgroundColor:n.green}),"edit"===E&&React.createElement(React.Fragment,null,React.createElement(R.M,{className:"primary",disabled:!U||ne,onClick:()=>M({type:"add",data:ye})},"Add"))),React.createElement(Ve.V,{style:{flex:"auto"}},"edit"===E&&React.createElement(React.Fragment,null,O.length>0&&React.createElement(React.Fragment,null,React.createElement(R.M,{className:"primary",disabled:ne,isBusy:"bulkPushAll"===m,onClick:()=>_e(!1)},"Sync Selected"),React.createElement(R.M,{className:"danger",disabled:ne,onClick:async()=>{confirm("Are you sure you want to delete the selected embeddings?")&&(u("deleteEmbeddings"),await ue(O),T([]),u(!1))}},Ee.COMMON.DELETE_SELECTED)),O.length>0&&React.createElement("div",{style:{display:"flex",alignItems:"center",marginLeft:10,marginRight:10}},O.length," selected"),React.createElement(Qe.j,{busy:Z.busy,style:{flex:"auto"},value:Z.value,max:Z.max,onStopClick:Z.stop})),"search"===E&&React.createElement("div",{style:{flex:"auto",display:"flex"}},React.createElement(te.A,{style:{flex:"auto",marginRight:5},placeholder:"Search",disabled:!U||ne,value:v,onChange:f,onEnter:se,onReset:async()=>{f(""),V({...z,filters:{...z.filters,search:""}})}}),React.createElement(R.M,{className:"primary",onClick:se,disabled:!U||ne||!v,isBusy:"searchVectors"===m},"Search"))))),React.createElement(p.Y,{minimal:!0,style:{flex:3}},React.createElement(h.z,{className:"primary",title:"Embeddings",action:React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(ee.u,{scrolldown:!0,name:"debugMode",style:{width:180},disabled:ne,value:S||null,onChange:A},React.createElement(ee.j,{value:null,label:"Current Environment"}),React.createElement(ee.j,{value:"includeOrphans",label:"With Orphans"}),React.createElement(ee.j,{value:"includeAll",label:"All Envs & Orphans"})),React.createElement(R.M,{className:"secondary",style:{marginLeft:5},disabled:!U||Q,onClick:()=>{a.invalidateQueries({queryKey:["vectors"]})}},Ee.COMMON.REFRESH)))},React.createElement(ze.o,{busy:ne,sort:z.sort,onSortChange:(e,t)=>{V({...z,sort:{accessor:e,by:t}})},emptyMessage:Oe,data:ge,columns:J,onSelectRow:e=>{1===O.length&&O[0]===e&&T([]),T([e])},onSelect:e=>{T([...O,...e])},onUnselect:e=>{T([...O.filter((t=>!e.includes(t)))])},selectedItems:O}),React.createElement(ae.g,null),"search"!==E&&React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:"auto"}}),React.createElement(Xe.Q,{currentPage:z.page,limit:z.limit,onCurrentPageChanged:e=>V({...z,page:e}),total:pe,onClick:e=>{V({...z,page:e})}}),React.createElement(R.M,{className:"primary",style:{marginLeft:5},disabled:!U,onClick:()=>{M({type:"export",data:{envId:D}})}},Ee.COMMON.EXPORT))),React.createElement(h.z,{className:"primary",title:"Information"},React.createElement("p",null,React.createElement("b",null,"If want to discuss embeddings with other users, visit the ",React.createElement("a",{href:"https://discord.gg/bHDGh38",target:"_blank",rel:"noreferrer"},"Meow Apps Discord Server"),".")),React.createElement("p",null,"An embedding is a textual piece of data (sentence, paragraph, a whole article) that has been converted by OpenAI into a vector. Vectors can then be used to find the most relevant data for a given query. In this dashboard, you can create embeddings, and they will be synchronized with ",React.createElement("a",{target:"_blank",href:"https://www.pinecone.io/",rel:"noreferrer"},"Pinecone"),", a very fast and affordable vector database."),React.createElement("p",null,"You can switch from EDIT to AI SEARCH and you will be able to query the database, and get your content, with a score. You can edit the content and it will be synchronized with Pinecone. Then make your content perfect so that the results are satisfying! You can use Sync and Sync One, it will go through your posts and create the embeddings if they don't exist yet, or update them if they do."),React.createElement("p",null,"Both the chatbots and the AI Forms can use embeddings to enrich their answers."))),React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{className:"primary"},Ce,React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:1,marginRight:5}},React.createElement("label",null,"Minimum Score:"),React.createElement("br",null),React.createElement("span",{style:{color:"var(--neko-green)"}},B,"%")),React.createElement("div",{style:{flex:1,marginLeft:5}},React.createElement("label",null,"Max Embedding(s):"),React.createElement("br",null),React.createElement("span",{style:{color:"var(--neko-green)"}},G))),React.createElement("p",null,"The best ",G," embedding(s) with a score of ",B," or more will provide additional context.")),"search"!==E&&React.createElement("div",{style:{margin:8}},React.createElement(i.s,{h2:!0,style:{color:"white",marginBottom:10}},Ee.EMBEDDINGS.SYNC_POSTS),React.createElement(g._,{inversed:!0},React.createElement(g.V,{title:"Push",inversed:!0},React.createElement(qe.Z,{ref:x,onSelectFiles:async e=>{for(let t=0;t<e.length;t++){const a=e[t],n=new FileReader,l=a.name.endsWith(".json"),r=a.name.endsWith(".jsonl"),o=a.name.endsWith(".csv");l||r||o?(n.onload=async e=>{const t=e.target.result;let a=[];l?a=JSON.parse(t):r?a=t.split("\n").map((e=>{e=e.trim();try{return JSON.parse(e)}catch(e){return console.error(e),null}})):o&&(a=je().parse(t,{header:!0,skipEmptyLines:!0}).data,console.log("The CSV for Embeddings Import was loaded.",a));const n=a,c=n.filter((e=>e.title&&e.content));if(n.length!==c.length){alert(Ee.ALERTS.EMPTY_LINES_EMBEDDINGS);const e=n.find((e=>!e.prompt||!e.completion));console.warn("Empty line: ",e)}M({type:"import",data:{importVectors:c,envId:D}})},n.readAsText(a)):alert(Ee.ALERTS.ONLY_SUPPORTS_FILES)}},accept:""},React.createElement(R.M,{fullWidth:!0,className:"secondary",disabled:!U||ne,onClick:()=>x.current.click()},"Import CSV or JSON")),React.createElement(ae.g,{line:!0}),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(ee.u,{id:"postType",scrolldown:!0,disabled:ne,name:"postType",style:{width:100},onChange:s,value:c},null==$?void 0:$.map((e=>React.createElement(ee.j,{key:e.type,value:e.type,label:e.name})))),React.createElement(R.M,{fullWidth:!0,className:"primary",style:{marginLeft:10},disabled:!U||ne,isBusy:"bulkPushAll"===m,onClick:()=>_e(!0)},Ee.EMBEDDINGS.SYNC_ALL," ",!Y&&React.createElement(React.Fragment,null,"(",`${W}`,")"))),React.createElement(ae.g,{tiny:!0}),React.createElement(R.M,{fullWidth:!0,className:"primary",disabled:!U||ne,isBusy:"singleRun"===m,onClick:async()=>{const e=prompt("Enter the Post ID to synchronize with:");if(e){u("singleRun");try{await be(null,e)}catch(e){console.error(e),alert((null==e?void 0:e.message)??e)}u(!1)}}},Ee.EMBEDDINGS.SYNC_ONE)),React.createElement(g.V,{title:"Pull",inversed:!0},React.createElement(R.M,{fullWidth:!0,className:"primary",disabled:!U||ne,isBusy:"bulkPullAll"===m,onClick:()=>(async()=>{u("bulkPullAll");const e={page:1,limit:1e4,filters:{envId:D}};let t=[],n=[],l=!1;for(;!l;)try{const a=await fe(e);a.vectors.length<e.limit&&(l=!0),t=t.concat(a.vectors),e.page++}catch(e){return console.error(e),alert((null==e?void 0:e.message)??e),void u(!1)}for(console.log("Remote vectors retrieved.",{remoteVectors:t}),l=!1,e.limit=20,e.page=0;!l;){const t=await we(e);t.vectors.length<e.limit&&(l=!0),n=n.concat(t.vectors),e.page++}n=n.map((e=>e.dbId)),console.log("Local vectors retrieved.",{vectors:n});const r=t.filter((e=>!n.includes(e)));if(console.log("Vectors to pull from Vector DB to AI Engine.",{vectorsToPull:r}),!r.length)return u(!1),void alert(`${t.length} vectors were pulled from the remote database. They are already synchronized with the local database.`);const o=r.map((e=>async t=>(await(async(e,t)=>await(0,y.IU)(`${_}/vectors/add_from_remote`,{nonce:N,method:"POST",json:e,signal:t}))({envId:D,dbId:e},t),await a.invalidateQueries({queryKey:["vectors"]}),{success:!0})));await Z.start(o),u(!1),alert("All done! For more information, check the console (Chrome Developer Tools)."),Z.reset()})()},Ee.EMBEDDINGS.SYNC_ALL)),React.createElement(g.V,{title:"Settings",inversed:!0},React.createElement(d.R,{label:Ee.EMBEDDINGS.REWRITE_CONTENT,disabled:m,checked:k.rewriteContent,onChange:e=>{le({...k,rewriteContent:e})},description:Ee.EMBEDDINGS.REWRITE_CONTENT_DESCRIPTION}),k.rewriteContent&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(Ye.m,{value:k.rewritePrompt,rows:5,disabled:m,onBlur:e=>{le({...k,rewritePrompt:e})},description:Ee.EMBEDDINGS.REWRITE_PROMPT_DESCRIPTION}),React.createElement(ae.g,null)),React.createElement(d.R,{label:Ee.EMBEDDINGS.FORCE_RECREATE,checked:k.forceRecreate,disabled:m,onChange:e=>{le({...k,forceRecreate:e})},description:Ee.EMBEDDINGS.FORCE_RECREATE_DESCRIPTION})))),"search"!==E&&React.createElement("div",{style:{margin:"20px 8px 8px 8px"}},React.createElement(i.s,{h2:!0,style:{color:"white",marginBottom:10}},Ee.EMBEDDINGS.AUTO_SYNC_POSTS),React.createElement(g._,{inversed:!0},React.createElement(g.V,{title:"Status",inversed:!0},ie),React.createElement(g.V,{title:"Settings",inversed:!0},ie,U&&re&&React.createElement(React.Fragment,null,React.createElement(ae.g,{tiny:!0}),React.createElement(oe.X,{variant:"danger",style:{padding:"10px 20px",marginBottom:5}},"The currently selected environment is not used for Auto-Sync. Do you want to use this one?"),React.createElement(R.M,{fullWidth:!0,className:"primary",disabled:ne,onClick:()=>le({...k,syncPostsEnvId:D}),style:{flex:1}},"Use Current Environment"),React.createElement(ae.g,{tiny:!0})),React.createElement(ae.g,{tiny:!0}),React.createElement(d.R,{label:Ee.EMBEDDINGS.AUTO_SYNC_POSTS,checked:k.syncPosts,disabled:m,onChange:e=>{le({...k,syncPosts:e})},description:Ee.EMBEDDINGS.AUTO_SYNC_POSTS_DESCRIPTION}),k.syncPosts&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(te.A,{name:"syncPostTypes",value:k.syncPostTypes,isCommaSeparatedArray:!0,description:Ee.HELP.POST_TYPES,onBlur:e=>{le({...k,syncPostTypes:e})}}),React.createElement(ae.g,null),React.createElement(te.A,{name:"syncPostStatus",value:k.syncPostStatus||"publish",isCommaSeparatedArray:!0,description:Ee.HELP.POST_STATUS,onBlur:e=>{le({...k,syncPostStatus:e})}}),React.createElement(ae.g,null),React.createElement(te.A,{name:"syncPostCategories",value:k.syncPostCategories||"publish",isCommaSeparatedArray:!0,description:Ee.HELP.POST_CATEGORIES,onBlur:e=>{le({...k,syncPostCategories:e})}}))))))),React.createElement(Nt,{modal:I,setModal:M,busy:m,onAddEmbedding:me,onModifyEmbedding:de}),React.createElement(St,{modal:I,setModal:M,busy:m}),React.createElement(kt,{modal:I,setModal:M,busy:m,onAddEmbedding:me,onModifyEmbedding:de}),Z.TasksErrorModal)};var Ht=a(2262),jt=a(4731);const{useState:$t,useMemo:Yt}=wp.element;Ht.t1.register(Ht.PP,Ht.kc,Ht.E8,Ht.m_,Ht.s$);const Wt=({month:e,usageData:t})=>0===t[e].length?React.createElement("div",{style:{width:"calc(100% - 36px)",margin:"5px 18px 0px 18px",fontStyle:"italic"}},"No data available."):React.createElement("table",{style:{width:"calc(100% - 36px)",margin:"5px 18px 0px 18px",borderCollapse:"collapse"}},React.createElement("tbody",null,t[e].map(((e,t)=>{const a=e.isImage?"images":e.isAudio?"seconds":"tokens",n=e.units.toLocaleString();return React.createElement("tr",{key:t},React.createElement("td",{style:{paddingRight:10}},"Unknown Model"===e.name?`⚠️ ${e.rawName}`:e.name),React.createElement("td",{style:{textAlign:"right",paddingRight:10}},n),React.createElement("td",{style:{paddingRight:10}},a),React.createElement("td",{style:{textAlign:"right"}},e.price>0?`${e.price.toFixed(4)}$`:"-"))})))),zt=({options:e})=>{const{models:t,getModel:a,calculatePrice:n}=ve(e,null,!0),l=null==e?void 0:e.ai_models_usage,{colors:o}=(0,r.z)(),[c,i]=$t("model"),[s,m]=$t("tokens"),d=Yt((()=>{const e={};return Object.keys(l).forEach((t=>{const r=l[t];e[t]||(e[t]=[]);const o={};Object.keys(r).forEach((e=>{const t=r[e],l=a(e);let c=null,i=null,s=!1,m=!1;l?"image"===l.type?(i=(null==t?void 0:t.images)||0,m=!0):"second"===l.type?(i=(null==t?void 0:t.seconds)||0,s=!0):(c=(null==t?void 0:t.prompt_tokens)||0,i=(null==t?void 0:t.completion_tokens)||0):(c=(null==t?void 0:t.prompt_tokens)||0,i=(null==t?void 0:t.completion_tokens)||0);const d=l?n(e,c,i):0,u=l?l.rawName:"Unknown Model",E=e;o[u]||(o[u]={name:u,rawName:E,units:0,price:0,isImage:m,isAudio:s,family:l?l.family:null}),o[u].units+=m?i:c+i,o[u].price+=d})),e[t]=Object.values(o),e[t].sort(((e,t)=>t.price-e.price))})),e}),[l,t]),u=Yt((()=>{const e=Object.keys(d),a=[],n=[o.blue,o.green,o.yellow,o.orange,o.red,o.purple];if("model"===c){t.forEach(((t,l)=>{const r=t.rawName,o=e.map((e=>{var t;const a=null===(t=d[e])||void 0===t?void 0:t.find((e=>e.name===r||e.rawName===r));return"tokens"===s?a?Math.max(a.units,1):0:a?Math.max(a.price,.01):0}));o.some((e=>e>0))&&a.push({label:r,data:o,backgroundColor:n[l%n.length]})}));const l=e.map((e=>{var t;return(null===(t=d[e])||void 0===t?void 0:t.filter((e=>"Unknown Model"===e.name))).reduce(((e,t)=>e+("tokens"===s?Math.max(t.units,1):Math.max(t.price,.01))),0)}));l.some((e=>e>0))&&a.push({label:"Unknown Model",data:l,backgroundColor:"rgba(128, 128, 128, 0.5)"})}else if("family"===c){const t={};e.forEach((a=>{d[a].forEach((n=>{const l=n.family;if(l){t[l]||(t[l]=Array(e.length).fill(0));const r="tokens"===s?Math.max(n.units,1):Math.max(n.price,.01),o=e.indexOf(a);t[l][o]+=r}}))})),Object.keys(t).forEach(((e,l)=>{a.push({label:e,data:t[e],backgroundColor:n[l%n.length]})}))}return{labels:e,datasets:a}}),[d,t,c,s,o]),E=Yt((()=>{const e={};u.datasets.forEach((t=>{const a=t.label;e[a]||(e[a]=0),t.data.forEach((t=>{e[a]+=t}))}));const t=Object.entries(e).sort((([,e],[,t])=>t-e)).slice(0,8).map((([e])=>e));return u.datasets.filter((e=>t.includes(e.label)))}),[u]),p={plugins:{legend:{position:"bottom",labels:{filter:e=>E.some((t=>t.label===e.text))}}},responsive:!0,scales:{x:{stacked:!0},y:{stacked:!0}}};return React.createElement(React.Fragment,null,l&&0===Object.keys(l).length&&React.createElement("div",{style:{fontStyle:"italic"}},"No data available."),l&&Object.keys(l).length>0&&React.createElement(React.Fragment,null,React.createElement(We.o,{name:"groupBy",value:`${c}-${s}`,onChange:e=>{const[t,a]=e.split("-");i(t),m(a)}},React.createElement(We.K,{title:"Units by Model",value:"model-tokens"}),React.createElement(We.K,{title:"Price by Model",value:"model-price"}),React.createElement(We.K,{title:"Units by Family",value:"family-tokens"}),React.createElement(We.K,{title:"Price by Family",value:"family-price"})),React.createElement(ae.g,{size:"medium"}),React.createElement(jt.yP,{options:p,data:u}),React.createElement(ae.g,{size:"medium"}),React.createElement(le.a,{keepState:"monthlyUsageCategories"},Object.keys(d).reverse().map(((e,t)=>React.createElement(le.Y,{key:t,title:`🗓️ ${e} (${d[e].reduce(((e,t)=>e+t.price),0).toFixed(2)}$)`},React.createElement(Wt,{month:e,usageData:d})))))))};var Vt=a(6841);const{useState:Kt}=wp.element;const qt=({modal:e,setModal:t})=>{const[a,n]=Kt(!1),[l,r]=Kt(0),[o,c]=Kt(0);return React.createElement(React.Fragment,null,React.createElement(re.n,{isOpen:"export"===(null==e?void 0:e.type),title:"Export Discussions",onRequestClose:()=>t(null),okButton:{label:"Close",disabled:a,onClick:()=>t(null)},customButtons:React.createElement(React.Fragment,null,React.createElement(R.M,{onClick:async()=>{try{n(!0);const e=await(async()=>{let e=!1;const t={page:1,limit:20,filters:{}};let a=[];for(;!e;){const n=await _e(t);n.chats.length<2&&(e=!0),r((()=>n.total)),n.chats.forEach((e=>{e.messages=JSON.parse(e.messages),e.extra=JSON.parse(e.extra)})),a=a.concat(n.chats),c((()=>a.length)),t.page++}return a})(),t=(0,y.F1)(e,2),a=new Date,l=a.getFullYear();(function(e,t){const a=new Blob([e],{type:"text/plain;charset=utf-8;"}),n=document.createElement("a");n.href=URL.createObjectURL(a),n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)})(t,`discussions-${l}-${a.getMonth()+1}-${a.getDate()}.json`),setTimeout((()=>{r(0)}),1e3)}catch(e){console.error(e),alert("An error occured while exporting discussions. Check your console.")}finally{n(!1)}},disabled:a},"Export JSON")),content:React.createElement(React.Fragment,null,React.createElement(Qe.j,{busy:a,style:{flex:"auto"},value:o,max:l}))}))},{useMemo:Xt,useState:Qt,useEffect:Jt,useCallback:Zt}=wp.element,ea=P.Ay.div`
font-size: 12px;
border-bottom: 1px solid black;
`,ta=P.Ay.span`
font-weight: bold;
text-transform: uppercase;
`,aa=P.Ay.div`
font-size: 12px;
color: #bdb8b8;
background: #eeeeee;
padding: 2px 8px;
`,na=P.Ay.div`
font-size: 14px;
padding: 10px;
border: 1px solid #eaeaea;
background: #f5f5f5;
color: #333333;
word-break: break-word;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
img {
max-width: 100%;
height: auto;
}
a {
color: #333333;
text-decoration: underline;
}
a:hover {
color: #333333;
text-decoration: none;
}
blockquote {
border-left: 4px solid #dddddd;
padding-left: 10px;
margin-left: 0;
font-style: italic;
}
pre {
background: #eeeeee;
padding: 10px;
border-radius: 5px;
overflow-x: auto;
text-wrap: pretty;
}
code {
background: #eeeeee;
padding: 2px 5px;
border-radius: 5px;
}
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 10px;
}
table td, table th {
border: 1px solid #dddddd;
text-align: left;
padding: 5px;
}
table tr:nth-child(even) {
background-color: #dddddd;
}
.mwai-dead-image {
color: #ab5252;
background: #ffd2d2;
padding: 8px 8px;
text-align: center;
}
`,la={overrides:{object:{component:({children:e,...t})=>`<object ${Object.keys(t).map((e=>`${e}="${t[e]}"`)).join(" ")}>${e}</object>`},script:{component:({children:e,...t})=>`<script ${Object.keys(t).map((e=>`${e}="${t[e]}"`)).join(" ")}>${e}<\/script>`},iframe:{component:({children:e,...t})=>`<iframe ${Object.keys(t).map((e=>`${e}="${t[e]}"`)).join(" ")}>${e}</iframe>`}}},ra=({content:e})=>{const[t,a]=Qt(e||""),n=e=>new Promise((t=>{const a=new Image;a.onload=()=>t(!0),a.onerror=()=>t(!1),a.src=e}));Jt((()=>{e&&(async e=>{const t=/!\[.*?\]\((.*?)\)/g;let l,r=e;for(;null!==(l=t.exec(e));){const e=l[1];if(!await n(e)){const e='<div class="mwai-dead-image">Image not available</div>';r=r.replace(l[0],e)}}a(r)})(e)}),[e]);const l=Xt((()=>{let e="";try{e=(0,Vt.cx)(t,la)}catch(a){console.error("Crash in markdown-to-jsx! Reverting to plain text.",{e:a,processedContent:t}),e=t}return e}),[t]);return React.createElement(na,null,l)},oa=({message:e})=>{var t,a,n,l;const r=null!=e&&null!==(t=e.extra)&&void 0!==t&&t.embeddings?null==e||null===(a=e.extra)||void 0===a?void 0:a.embeddings:null!=e&&null!==(n=e.extra)&&void 0!==n&&n.embedding?[null==e||null===(l=e.extra)||void 0===l?void 0:l.embedding]:[];return React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement(ea,null,React.createElement(ta,null,e.role||e.type)),(null==r?void 0:r.length)>0&&React.createElement(aa,null,r.map((e=>React.createElement("div",{key:r.id},React.createElement("span",null,e.title)," (",React.createElement("span",null,(100*e.score.toFixed(4)).toFixed(2)),")")))),React.createElement(ra,{content:e.content||e.text}))},ca=async(e=[])=>await(0,y.IU)(`${_}/discussions/delete`,{nonce:N,method:"POST",json:{chatIds:e}}),ia=()=>{var e,t,a,n,r,c,i,s,m,u,E;const g=(0,l.jE)(),[y,b]=Qt({type:null,data:null}),[v,f]=Qt(!1),[_,w]=Qt(!1),{data:C}=(0,o.I)({queryKey:["chatbots"],queryFn:nt,initialData:k}),O=Xt((()=>[{accessor:"updated",title:"Time",width:"80px",sortable:!0},{accessor:"user",title:"User",width:"85px",filters:{type:"text",description:Ee.HELP.USER_FILTER}},{accessor:"botId",title:"Chatbot",width:"85px",filters:{type:"select",options:C.map((e=>({value:e.botId,label:e.name})))}},{accessor:"preview",title:Ee.COMMON.PREVIEW,filters:{type:"text"}},{accessor:"messages",title:"#",width:"45px"}]),[C]),[T,N]=Qt((()=>O.filter((e=>e.filters)).map((e=>({accessor:e.accessor,value:null}))))),[I,M]=Qt([]),[S,A]=Qt({filters:T,sort:{accessor:"created",by:"desc"},page:1,limit:10}),x=Zt((async()=>document.hidden?new Promise((()=>{})):await _e(S)),[S]),{isFetching:P,data:L,error:D}=(0,o.I)({queryKey:["chats",S],queryFn:x,refetchInterval:_?5e3:null});Jt((()=>{A({...S,filters:T})}),[T]);const F=Xt((()=>(null==L?void 0:L.total)||0),[L]),U=Xt((()=>null!=L&&L.chats?L.chats.sort(((e,t)=>t.created_at-e.created_at)).map((e=>{const t=JSON.parse(e.messages),a=JSON.parse(e.extra),n=Ce(e.created),l=Ce(e.updated),r=Oe(e.userId??(null==a?void 0:a.userId),e.ip??(null==a?void 0:a.ip)),o=null==t?void 0:t.filter((e=>"user"===e.role||"user"===e.type)),c=null!=o&&o.length?o[0].content||o[0].text:"",i=null!=o&&o.length?o[o.length-1].content||o[o.length-1].text:"",s=C.find((t=>t.botId===e.botId)),m=null==a?void 0:a.parentBotId,d=m?C.find((e=>e.botId===m)):null;let u,E=null;s?u=s.name:d?(u=d.name,E=React.createElement($e.z,{icon:"tools",height:"14",style:{position:"relative",top:2,marginRight:2},tooltip:"Overriden Bot"})):u=React.createElement(React.Fragment,null,React.createElement($e.z,{icon:"cog",height:"14",style:{position:"relative",top:2,marginRight:2},tooltip:"Custom Bot"}),"Custom");const p=e.title?React.createElement(React.Fragment,null,React.createElement("div",null,e.title),React.createElement("small",null,React.createElement("i",null,c))):React.createElement(React.Fragment,null,React.createElement("div",null,c),React.createElement("small",null,i));return{id:e.id,botId:React.createElement(React.Fragment,null,React.createElement("div",null,E,u),React.createElement("div",null,React.createElement("small",null,e.botId))),user:r,messages:(null==t?void 0:t.length)??0,preview:p,extra:a.model,created:React.createElement("div",{style:{textAlign:"right"}},n),updated:React.createElement("div",{style:{textAlign:"right"}},l)}})):[]),[L,C]),B=Xt((()=>{if(1!==(null==I?void 0:I.length))return null;const e=null==L?void 0:L.chats.find((e=>e.id===I[0]));if(!e)return null;let t=[],a={};try{t=JSON.parse(e.messages),a=JSON.parse(e.extra)}catch(t){console.error("Could not parse discussion messages or extra.",{e:t,currentDiscussion:e})}return{id:e.id,chatId:e.chatId,botId:e.botId,messages:t,extra:a,created:e.created,updated:e.updated}}),[I,L]),G=async()=>{if(f(!0),I.length){const e=(null==L?void 0:L.chats.filter((e=>I.includes(e.id)))).map((e=>e.chatId));await ca(e),M([])}else{if(!window.confirm(Ee.ALERTS.ARE_YOU_SURE))return void f(!1);await ca()}await g.invalidateQueries({queryKey:["chats"]}),g.refetchQueries({queryKey:["chats"]}),f(!1)},H=Xt((()=>React.createElement("div",null,React.createElement("div",{style:{display:"flex",flexDirection:"row"}},React.createElement(Xe.Q,{currentPage:S.page,limit:S.limit,onCurrentPageChanged:e=>A({...S,page:e}),total:F,onClick:e=>{A({...S,page:e})}}),React.createElement(R.M,{className:"primary",style:{marginLeft:5},onClick:()=>{b({type:"export",data:{}})}},Ee.COMMON.EXPORT)))),[S,F]),j=Xt((()=>null!=D&&D.message?React.createElement(oe.X,{variant:"danger",style:{margin:"5px 5px"}},React.createElement("b",null,D.message),React.createElement("br",null),React.createElement("small",null,"Check your Console Logs and PHP Error Logs for more information.")):null),[D]),$=Ce(null==B?void 0:B.created),Y=Ce(null==B?void 0:B.updated);return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0,style:{flex:2}},React.createElement(h.z,{className:"primary",title:Ee.COMMON.DISCUSSIONS,action:React.createElement(React.Fragment,null,React.createElement("div",null,!_&&React.createElement(R.M,{className:"secondary",style:{marginLeft:5},disabled:P,onClick:async()=>{await g.invalidateQueries({queryKey:["chats"]}),g.refetchQueries({queryKey:["chats"]})}},Ee.COMMON.REFRESH),I.length>0&&React.createElement(React.Fragment,null,React.createElement(R.M,{className:"danger",disabled:!1,onClick:G},Ee.COMMON.DELETE))))},React.createElement(ze.o,{busy:!_&&P||v,sort:S.sort,onSortChange:(e,t)=>{A({...S,sort:{accessor:e,by:t}})},emptyMessage:j,filters:T,onFilterChange:(e,t)=>{const a=[...T.filter((t=>t.accessor!==e)),{accessor:e,value:t}];N(a)},data:U,columns:O,selectedItems:I,onSelectRow:e=>{1!==I.length||I[0]!==e?M([e]):M([])},onSelect:e=>{M([...I,...e])},onUnselect:e=>{M([...I.filter((t=>!e.includes(t)))])}}),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginTop:10}},React.createElement(R.M,{className:"danger",disabled:I.length,style:{marginRight:10},onClick:G},Ee.COMMON.DELETE_ALL),React.createElement(d.R,{name:"auto-refresh",label:"Auto Refresh",value:"1",checked:_,style:{width:180},onChange:()=>w(!_)}),React.createElement("div",{style:{flex:"auto"}}),H))),React.createElement(p.Y,{minimal:!0,style:{flex:1}},React.createElement(h.z,{className:"primary",title:"Selected Discussion",action:React.createElement(React.Fragment,null)},!B&&React.createElement("div",{style:{textAlign:"center",padding:10}},"No discussion selected."),null==B||null===(e=B.messages)||void 0===e?void 0:e.map(((e,t)=>React.createElement(oa,{key:t,message:e})))),!!B&&React.createElement(h.z,{className:"primary",title:"Information"},React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Model"),React.createElement("div",null,null==B||null===(t=B.extra)||void 0===t?void 0:t.model)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Bot ID (or Custom ID)"),React.createElement("div",null,null==B?void 0:B.botId)),(null==B||null===(a=B.extra)||void 0===a?void 0:a.parentBotId)&&React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Parent Bot ID"),React.createElement("div",null,null==B||null===(n=B.extra)||void 0===n?void 0:n.parentBotId)),(null==B||null===(r=B.extra)||void 0===r?void 0:r.context)&&React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Context"),React.createElement("div",null,null==B||null===(c=B.extra)||void 0===c?void 0:c.context)),(null==B||null===(i=B.extra)||void 0===i?void 0:i.assistantId)&&React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Assistant ID"),React.createElement("div",null,null==B||null===(s=B.extra)||void 0===s?void 0:s.assistantId)),(null==B||null===(m=B.extra)||void 0===m?void 0:m.threadId)&&React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Thread ID"),React.createElement("div",null,null==B||null===(u=B.extra)||void 0===u?void 0:u.threadId)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Chat ID"),React.createElement("div",null,null==B?void 0:B.chatId)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Session"),React.createElement("div",null,null==B||null===(E=B.extra)||void 0===E?void 0:E.session)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Created"),React.createElement("div",null,$)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{fontWeight:"bold"}},"Updated"),React.createElement("div",null,Y))))),React.createElement(qt,{modal:y,setModal:b,busy:v}))},sa=P.Ay.div`
background: white;
padding: 15px;
border-radius: 5px;
h2 {
margin-bottom: 8px;
}
h2:first-child, h3:first-child {
margin-top: 0;
}
label {
display: block;
margin-bottom: 5px;
}
label {
margin-top: 10px;
}
ul {
margin: 20px 0 0 0;
}
li {
margin-bottom: 5px;
border: 1px solid #e5e5e5;
padding: 8px;
background: #f5f5f5;
border-radius: 5px;
cursor: pointer;
position: relative;
&:last-child {
margin-bottom: 0;
}
&:hover {
background: #e5e5e5;
}
&.active {
background: #007cba;
color: white;
border-color: #007cba;
&.modified {
background: #ff8c00;
border-color: #ff8c00;
}
}
}
.information {
color: #a3a3a3;
margin-top: 5px;
font-size: 12px;
line-height: 100%;
}
`,ma=(0,P.Ay)(te.A)`
flex: auto !important;
input {
height: 50px !important;
font-size: 13px !important;
font-family: monospace !important;
padding: 20px !important;
border-color: #333d4e !important;
background: #333d4e !important;
color: white !important;
}
`,da=P.Ay.div`
display: flex;
flex-direction: column;
label {
margin-bottom: 3px;
}
.mwai-builder-row {
margin-top: 10px;
display: flex;
flex-direction: row;
.neko-color-picker {
margin-left: 5px;
}
}
.mwai-builder-col {
flex: 1;
display: flex;
flex-direction: column;
margin-right: 5px;
}
.mwai-builder-col:last-child {
margin-right: 0;
}
pre {
white-space: pre-wrap;
background: #d4f0ff;
color: #037cba;
padding: 10px;
font-size: 13px;
font-weight: bold;
margin: 10px 0 10px 0;
}
.neko-spacer {
margin-bottom: 0 !important;
}
.neko-input {
}
.nui-select-option {
}
`,{useMemo:ua}=wp.element,Ea=({model:e,maxTokens:t,onRecommendedClick:a,...n})=>{const l=null==e?void 0:e.maxContextualTokens,r=null==e?void 0:e.maxCompletionTokens,o=null==e?void 0:e.maxTokens,c=!!a;t=Math.floor(parseInt(t),0);const i=ua((()=>e?r||(l?Math.floor(l/2):o?Math.floor(o/2):null):null),[r,l,o]),s=ua((()=>e?i===t?"var(--neko-green)":t>r?"var(--neko-red)":"var(--neko-yellow)":null),[r,t,i]);return React.createElement("span",n,!(null==e||!e.maxContextualTokens)&&React.createElement(React.Fragment,null,"Contextual: ",null==e?void 0:e.maxContextualTokens,React.createElement("br",null)),!(null==e||!e.maxCompletionTokens)&&React.createElement(React.Fragment,null,"Completion: ",null==e?void 0:e.maxCompletionTokens,React.createElement("br",null)),!(null!=e&&e.maxCompletionTokens)&&!(null==e||!e.maxTokens)&&React.createElement(React.Fragment,null,"Total Max Tokens: ",null==e?void 0:e.maxTokens,React.createElement("br",null)),!!i&&React.createElement(React.Fragment,null,"Recommended: ",React.createElement("b",{onClick:c?()=>a(i):null,style:{color:s,cursor:c?"pointer":"inherit"}},i,t>r&&React.createElement(React.Fragment,null,"❗️")),React.createElement("br",null)))},{useState:pa,useMemo:ga}=wp.element,Ra=P.Ay.div`
pre {
display: flex;
align-items: center;
background: #f8fcff;
color: #779bb8;
margin: 0px;
padding: 3px 8px;
font-size: 13px;
border: 2px solid rgb(210 228 243);
border-radius: 5px;
font-family: system-ui;
cursor: pointer;
font-weight: 500;
}
.mwai-name {
font-style: italic;
}
.mwai-value {
color: var(--neko-green);
}
.skipped-params {
margin-top: 10px;
color: #ff4d4f;
}
`,ha=e=>"string"!=typeof e?e:e.replace(/"/g,""").replace(/'/g,"'").replace(/\n/g,"\\n").replace(/\[/g,"[").replace(/\]/g,"]"),ya=({currentChatbot:e,isCustom:t=!1,defaultChatbot:a,...n})=>{const[l,r]=pa(null),o=ga((()=>{if(!e)return{shortcodeHtml:null,shortcodeText:null,skipped:[]};let n;const l=[],r=[];if(t){for(const t in e){const n=e[t];if(null==n||"botId"===t||"name"===t||""===n||a&&a[t]===n||"object"==typeof n||Array.isArray(n)&&0===n.length){"object"==typeof n&&Array.isArray(n)&&0!==n.length&&r.push(t);continue}const o=ha(n),c=t.replace(/([A-Z])/g,(e=>`_${e.toLowerCase()}`));l.push(`${c}="${o}"`)}n="[mwai_chatbot"+(l.length?` ${l.join(" ")}`:"")+"]"}else{const t=e.botId??"default";l.push(`id="${t}"`),n=`[mwai_chatbot id="${t}"]`}return{shortcodeHtml:React.createElement("span",null,"[mwai_chatbot"," ",l.map(((e,t)=>{const[a,n]=e.split("=");return React.createElement("span",{key:t},React.createElement("span",{className:"mwai-name"},a),"=",React.createElement("span",{className:"mwai-value"},n),t<l.length-1?" ":"")})),"]"),shortcodeText:n,skipped:r}}),[e,t,a]),c=(null==o?void 0:o.skipped)??[];return e?React.createElement(Ra,n,React.createElement("pre",{onClick:async()=>{navigator.clipboard?(await navigator.clipboard.writeText(o.shortcodeText),r("Copied!"),setTimeout((()=>{r(null)}),2e3)):alert("Clipboard is not enabled (only works with https).")}},!l&&o.shortcodeHtml,l&&React.createElement("span",null,l)),c.length>0&&React.createElement("div",{className:"skipped-params"},"Skipped parameters: ",c.join(", "))):null};var ba=a(7678);function va(){return va=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},va.apply(this,arguments)}const{useMemo:fa,useState:_a,useEffect:wa}=wp.element,Ca="drop-shadow(0 0 5px rgba(0,0,0,0.1))",Oa=["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],Ta=["chat-openai.svg","chat-robot-1.svg","chat-robot-2.svg","chat-nyao-1.svg","chat-nyao-2.svg","chat-nyao-3.svg","chat-color-blue.svg","chat-color-green.svg","chat-color-red.svg","chat-traditional-1.svg","chat-traditional-2.svg","avatar-user.svg","avatar-woman-blond.svg","avatar-woman-indian.svg","avatar-woman-asian.svg","avatar-woman-doctor.svg","avatar-man-blond.svg","avatar-man-black.svg","avatar-man-sunglasses.svg","avatar-man-pirate.svg"],Na=({label:e,valueName:t,updateShortcodeParams:a,icon:n})=>{const l=n||"chat-color-green.svg",r=(0,ba.Ve)(l),o=r||(null==l?void 0:l.startsWith("https://"))||(null==l?void 0:l.startsWith("http://")),c=o?l:`${w}/images/${l}`;return React.createElement(React.Fragment,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("label",null,e,":")),React.createElement("div",{style:{marginTop:0,border:"1.5px solid #d2e4f3",borderRadius:5,padding:"10px 10px 10px 10px",background:"#f5fcff"}},React.createElement("div",{className:"mwai-builder-row",style:{marginTop:0}},React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center"}},Ta.map((e=>React.createElement("img",{key:e,style:{marginRight:2,marginBottom:2,cursor:"pointer",filter:Ca},width:24,height:24,src:`${w}/images/${e}`,onClick:()=>{a(e,t)}}))),React.createElement("div",{style:{width:24,height:24,border:"1px solid #d2e4f3",background:"#f5fcff",borderRadius:5,cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{a(`${w}/images/chat-traditional-1.svg`,t)}},"..."))),React.createElement("div",{className:"mwai-builder-col",style:{width:48,display:"flex",alignItems:"end"}},r?React.createElement("div",{style:{fontSize:48,lineHeight:"48px",marginRight:0,paddingTop:0}},l):React.createElement("img",{style:{marginRight:0,paddingTop:0,filter:Ca},width:48,height:48,src:`${c}`}))),o&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.CUSTOM_ICON,":"),React.createElement(te.A,{name:"icon",value:l,onBlur:e=>a(e,t),onEnter:e=>a(e,t)})))))},Ia=e=>{const{themes:t,shortcodeParams:a,updateShortcodeParams:n,defaultChatbot:l,blockMode:r,deleteCurrentChatbot:o,resetCurrentChatbot:c,duplicateCurrentChatbot:i,options:s,...m}=e,{completionModels:u,imageModels:E,realtimeModels:g,getModel:h}=ve(s,a.envId||null),b="chat"===a.mode??"chat",v="assistant"===a.mode??!1,f="images"===a.mode??!1,w="realtime"===a.mode??!1,C=a.contentAware,O=fa((()=>(null==s?void 0:s.ai_envs)||[]),[s.ai_envs]),I=null==s?void 0:s.module_embeddings,M=(null==s?void 0:s.functions)||[],S=a.functions||[],[A,k]=_a(!1),x=fa((()=>a.instructions&&a.instructions.includes("{CONTENT}")),[a.instructions]),P=fa((()=>O.find((e=>e.id===a.envId))||null),[O,a.envId]),L=fa((()=>(null==P?void 0:P.assistants)||[]),[P]),D=fa((()=>L.find((e=>e.id===a.assistantId))||null),[L,a.assistantId]),F=h(D?D.model:a.model),U=s.embeddings_envs||[],B=fa((()=>{var e;return null==F||null===(e=F.tags)||void 0===e?void 0:e.includes("functions")}),[F]),G=fa((()=>{var e;return null==F||null===(e=F.tags)||void 0===e?void 0:e.includes("vision")}),[F]),H=fa((()=>{var e;return null==F||null===(e=F.tags)||void 0===e?void 0:e.includes("files")}),[F]),j=fa((()=>{var e;return null==F||null===(e=F.tags)||void 0===e?void 0:e.includes("image")}),[F]);wa((()=>{const e=S.filter((e=>M.some((t=>t.id===e.id))));if(e.length!==S.length)console.warn("Update Params: Functions has been updated."),n(e,"functions");else if(j&&!a.resolution){if(console.warn("Update Params: Resolution has been set."),null!=F&&F.resolutions){const e=F.resolutions.map((e=>e.name)),t=e.includes("1024x1024")?"1024x1024":e[0];n(t,"resolution")}}else!j&&a.resolution?(console.warn("Update Params: Resolution has been removed."),n(null,"resolution")):j&&b||v&&a.model?(console.warn("Update Params: Model has been removed."),n(null,"model")):!v&&a.assistantId?(console.warn("Update Params: Assistant has been removed."),n(null,"assistantId")):a.imageUpload&&!G?(console.warn("Update Params: Vision has been removed."),n(null,"imageUpload")):a.fileSearch&&!v?(console.warn("Update Params: File search has been removed."),n(null,"fileSearch")):a.model&&!a.envId?(console.warn("Update Params: Model has been removed."),n(null,"model")):a.envId&&!P?(console.warn("Update Params: Environment has been removed."),n(null,"envId")):!I&&a.embeddingsEnvId?(console.warn("Update Params: Embeddings environment has been removed."),n(null,"embeddingsEnvId")):!B&&S.length?(console.warn("Update Params: Functions have been removed."),n([],"functions")):!v||!a.fileSearch||null!=D&&D.has_file_search?a.aiAvatar||a.aiName?a.userAvatar||a.userName?a.guestAvatar||a.guestName||(console.warn("Update Params: Guest avatar has been set to true."),n(!0,"guestAvatar")):(console.warn("Update Params: User avatar has been set to true."),n(!0,"userAvatar")):(console.warn("Update Params: AI avatar has been set to true."),n(!0,"aiAvatar")):(console.warn("Update Params: File search has been removed."),n(null,"fileSearch"))}),[a]);const $=fa((()=>j&&F?F.resolutions?null==F?void 0:F.resolutions:(console.error("This image model does not have resolutions.",F),[]):[]),[F,j]),Y=fa((()=>{const e=[b?"Chat":v?"Assistant":f?"Images":w?"Realtime":null,(null==a?void 0:a.botId)||(null==l?void 0:l.id)||"default"].filter(Boolean).join(", ");return React.createElement("div",null,Ee.COMMON.CHATBOT,React.createElement("small",{style:{opacity:.5}}," ",e))}),[b,v,null==a?void 0:a.botId,null==l?void 0:l.id]),W=fa((()=>{const e=(e,t)=>{const a=O.find((t=>t.id===e));if(!a)return null;const n=h(t);return[a.name,null==n?void 0:n.rawName].filter(Boolean).join(", ")};if(a.envId){const t=e(a.envId,a.model);if(t)return React.createElement("div",null,Ee.COMMON.AI_MODEL,React.createElement("small",{style:{opacity:.5}}," ",t))}else{const t=e(null==s?void 0:s.ai_default_env,null==s?void 0:s.ai_default_model);if(t)return React.createElement("div",null,Ee.COMMON.AI_MODEL,React.createElement("small",{style:{opacity:.5}}," ",t))}return Ee.COMMON.AI_MODEL}),[a.envId,a.model,O,h,null==s?void 0:s.ai_default_env,null==s?void 0:s.ai_default_model]),z=fa((()=>{if(a.embeddingsEnvId){const e=U.find((e=>e.id===a.embeddingsEnvId));if(e){const t=[e.name,C?"Content Aware":null].filter(Boolean).join(", ");return React.createElement("div",null,Ee.COMMON.CONTEXT,React.createElement("small",{style:{opacity:.5}}," ",t))}}return Ee.COMMON.CONTEXT}),[a.embeddingsEnvId,U,C]),V=fa((()=>{if(!S.length)return Ee.COMMON.FUNCTIONS;const e=`Enabled: ${S.length}, Total: ${M.length}`;return React.createElement("div",null,Ee.COMMON.FUNCTIONS,React.createElement("small",{style:{opacity:.5}}," ",e))}),[S,M]),K=fa((()=>{const e=a.contextMaxLength||(null==s?void 0:s.context_max_length),t=[a.maxMessages?`Messages: ${a.maxMessages}`:null,e?`Context: ${e}`:null].filter(Boolean).join(", ");return React.createElement("div",null,Ee.COMMON.THRESHOLDS,React.createElement("small",{style:{opacity:.5}}," ",t))}),[a.contextMaxLength,a.maxMessages,null==s?void 0:s.context_max_length]),q=fa((()=>{const e=null==t?void 0:t.find((e=>e.themeId===a.themeId)),n=[(null==e?void 0:e.name)||a.themeId,a.window?"Popup":null].filter(Boolean).join(", ");return React.createElement("div",null,Ee.COMMON.APPEARANCE,React.createElement("small",{style:{opacity:.5}}," ",n))}),[a.themeId,a.window,t]),X=fa((()=>f?E:(w?g:u)??[]),[f,w,u,E,g]);return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,va({minimal:!0},m),React.createElement(da,null,React.createElement(le.a,{keepState:"chatbotParams"},React.createElement(le.Y,{title:Y},React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.NAME,":"),React.createElement(te.A,{name:"name","data-form-type":"other",disabled:"default"===a.botId,value:a.name,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("div",null,React.createElement("label",{style:{display:"block"}},Ee.COMMON.ID,":"),React.createElement(te.A,{name:"botId",type:"text",placeholder:"Optional",disabled:"default"===a.botId,value:a.botId,onBlur:n,onEnter:n}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("div",null,React.createElement("label",{style:{display:"block"}},Ee.COMMON.SCOPE,":"),React.createElement(te.A,{name:"scope",type:"text",placeholder:"Scope",value:a.scope,onBlur:n,onEnter:n}))),!w&&React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.LOCAL_MEMORY,":"),React.createElement(d.R,{name:"localMemory",label:"Yes",checked:a.localMemory,value:"1",onChange:n}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{height:"chat"===a.mode?76:"inherit"}},React.createElement("label",null,Ee.COMMON.MODE,":"),React.createElement(ee.u,{scrolldown:!0,id:"mode",name:"mode",value:a.mode,onChange:n},React.createElement(ee.j,{value:"chat",label:"Chat"}),React.createElement(ee.j,{value:"images",label:"Images"}),React.createElement(ee.j,{value:"assistant",label:"Assistant",isPro:!0,requirePro:!T}),React.createElement(ee.j,{value:"realtime",label:"Realtime",isPro:!0,requirePro:!T}))),(b||v||w)&&React.createElement("div",{className:"mwai-builder-col",style:{flex:5}},React.createElement("label",null,Ee.COMMON.INSTRUCTIONS,":"),React.createElement(Ye.m,{name:"instructions",rows:10,textAreaStyle:{resize:"none"},value:a.instructions,onBlur:n,onEnter:n})))),React.createElement(le.Y,{title:W},React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.ENVIRONMENT,":"),React.createElement(ee.u,{scrolldown:!0,name:"envId",value:a.envId??"",onChange:n},O.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(ee.j,{value:"",label:"Default"}))),(b||f||w)&&React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ee.COMMON.MODEL,":"),React.createElement(ee.u,{scrolldown:!0,textFiltering:X.length>16,name:"model",disabled:!a.envId,value:a.model,onChange:n},React.createElement(ee.j,{value:"",label:"Default"}),X.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),v&&React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ee.COMMON.ASSISTANT,":"),React.createElement(ee.u,{scrolldown:!0,name:"assistantId",value:a.assistantId,onChange:n},React.createElement(ee.j,{value:"",label:"None"}),L.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))))),j&&React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.RESOLUTION,":"),React.createElement(ee.u,{scrolldown:!0,name:"resolution",value:a.resolution,onChange:n},$.map((e=>React.createElement(ee.j,{key:e.name,value:e.name,label:e.label}))))),G&&React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.VISION,":"),React.createElement(d.R,{name:"imageUpload",label:Ee.COMMON.ENABLE,checked:a.imageUpload,value:"1",onChange:n})),H&&React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.FILES,":"),React.createElement(d.R,{name:"fileUpload",label:Ee.COMMON.ENABLE,checked:a.fileUpload,value:"1",onChange:n}))),(b||w)&&React.createElement("div",{className:"mwai-builder-row"},w&&React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.VOICE,":"),React.createElement(ee.u,{scrolldown:!0,name:"voice",value:a.voice,onChange:n},React.createElement(ee.j,{value:"",label:"Default"}),Oa.map((e=>React.createElement(ee.j,{key:e,value:e,label:e}))))),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.TEMPERATURE,":"),React.createElement(te.A,{name:"temperature",type:"number",step:"0.1",min:"0",max:"1",value:a.temperature,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.MAX_TOKENS,":"),React.createElement(te.A,{name:"maxTokens",type:"number",description:React.createElement(Ea,{model:F,maxTokens:a.maxTokens,onRecommendedClick:e=>{n(e,"maxTokens")},style:{fontSize:11,lineHeight:"8px"}}),value:a.maxTokens,onBlur:n,onEnter:n})))),v&&React.createElement(le.Y,{title:Ee.COMMON.ASSISTANT},React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.FILE_SEARCH,":"),React.createElement(ee.u,{scrolldown:!0,name:"fileSearch",disabled:!(null!=D&&D.has_file_search),description:(0,y.FE)(null!=D&&D.has_file_search?Ee.SETTINGS.ASSISTANT_FILE_SEARCH:Ee.SETTINGS.ASSISTANT_NO_FILE_SEARCH),value:a.fileSearch,onChange:n},React.createElement(ee.j,{value:"",label:"None"}),React.createElement(ee.j,{value:"discussion",label:"For Discussion"}))))),(b||v)&&React.createElement(le.Y,{title:z},React.createElement("div",{style:{marginTop:15,fontWeight:"bold"}},Ee.COMMON.EMBEDDINGS),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.EMBEDDINGS_ENV,":"),React.createElement(ee.u,{scrolldown:!0,name:"embeddingsEnvId",requirePro:!0,isPro:T,disabled:!I||!(null!=U&&U.length),value:a.embeddingsEnvId,onChange:n},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(ee.j,{value:"",label:"None"})))),React.createElement("div",{style:{marginTop:15,fontWeight:"bold"}},Ee.COMMON.OTHERS),b&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.CONTENT_AWARE,":"),React.createElement(d.R,{name:"contentAware",label:"Yes",requirePro:!0,isPro:T,checked:a.contentAware,value:"1",onChange:n}))),C&&!x&&React.createElement(oe.X,{variant:"danger",style:{marginTop:15,padding:"10px 15px"}},React.createElement("p",null,(0,y.FE)(Ee.SETTINGS.ALERT_CONTENTAWARE_BUT_NO_CONTENT)))),B&&!r&&React.createElement(le.Y,{title:V},React.createElement("p",null,React.createElement(Ne,{style:{marginRight:3}}),React.createElement(Ie,{style:{marginRight:5}}),(0,y.FE)(Ee.HELP.FUNCTIONS)),!(null!=M&&M.length)&&React.createElement(oe.X,{variant:"danger"},(0,y.FE)(Ee.HELP.FUNCTIONS_UNAVAILABLE)),!(null==M||!M.length)&&React.createElement("div",{style:{maxHeight:200,overflowY:"auto",border:"1px solid #d1e3f2",marginTop:10,padding:"5px 6px",borderRadius:5}},null==M?void 0:M.map((e=>React.createElement(d.R,{key:e.id,name:"functions",label:React.createElement(React.Fragment,null,"js"===e.target&&React.createElement(Me,{style:{marginRight:5}}),"js"!==e.target&&React.createElement(Se,{style:{marginRight:5}}),React.createElement("span",null,e.name)),description:e.desc,checked:S.some((t=>t.id===e.id)),value:e.id,onChange:t=>{const a=S.filter((t=>t.id!==e.id));t&&a.push({type:e.type,id:e.id}),n(a,"functions")}})))),v&&React.createElement(React.Fragment,null,React.createElement("p",null,"Assistant needs to be updated with the set of functions every time you modify them (including their names, arguments, descriptions, etc)."),React.createElement(R.M,{className:"primary",fullWidth:!0,onClick:async()=>{k(!0);try{await(async(e,t,a)=>{const n=await(0,y.IU)(`${_}/openai/assistants/set_functions`,{method:"POST",nonce:N,json:{envId:e,assistantId:t,functions:a}});if(!n.success)throw new Error(n.message);return n})(a.envId,a.assistantId,S),alert("Functions have been set on the assistant.")}catch(e){alert(e.message)}k(!1)},isBusy:A},"Set Functions on Assistant"))),React.createElement(le.Y,{title:K},React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.INPUT_MAX_LENGTH,":"),React.createElement(te.A,{name:"textInputMaxLength",type:"number",description:Ee.HELP.INPUT_MAX_LENGTH,step:"1",min:"8",value:a.textInputMaxLength,onBlur:n,onEnter:n})),!w&&React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.MAX_MESSAGES,":"),React.createElement(te.A,{name:"maxMessages",type:"number",description:Ee.HELP.MAX_MESSAGES,step:"1",min:"1",max:"1024",value:a.maxMessages,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.CONTEXT_MAX_LENGTH,":"),React.createElement(te.A,{name:"contextMaxLength",type:"number",step:"1",description:Ee.HELP.CONTEXT_MAX_LENGTH,value:a.contextMaxLength||(null==s?void 0:s.context_max_length),onBlur:n,onEnter:n})))),React.createElement(le.Y,{title:q},React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ee.COMMON.THEME,":"),React.createElement(ee.u,{scrolldown:!0,name:"themeId",value:a.themeId,description:"",onChange:n},React.createElement(ee.j,{value:"none",label:"None"}),React.createElement(ee.j,{value:"chatgpt",label:"ChatGPT"}),React.createElement(ee.j,{value:"timeless",label:"Timeless"}),React.createElement(ee.j,{value:"messages",label:"Messages"}),null==t?void 0:t.filter((e=>"css"===e.type)).map((e=>React.createElement(ee.j,{key:e.themeId,value:e.themeId,label:e.name}))))),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.POPUP,":"),React.createElement(d.R,{name:"window",label:"Yes",checked:a.window,value:"1",onChange:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.FULL_SCREEN,":"),React.createElement(d.R,{name:"fullscreen",label:"Yes",checked:a.fullscreen,value:"1",onChange:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.COPY_BUTTON,":"),React.createElement(d.R,{name:"copyButton",label:"Yes",checked:a.copyButton,value:"1",onChange:n}))),"timeless"===a.themeId&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.HEADER_SUBTITLE,":"),React.createElement(te.A,{name:"headerSubtitle","data-form-type":"other",value:a.headerSubtitle,onBlur:n,onEnter:n}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.AVATAR,":"),React.createElement(d.R,{name:"aiAvatar",label:"Yes",checked:a.aiAvatar,value:"1",onChange:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ee.COMMON.AI_NAME,":"),React.createElement(te.A,{name:"aiName","data-form-type":"other",value:a.aiName,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:7}},React.createElement("label",null,Ee.COMMON.START_SENTENCE,":"),React.createElement(Ye.m,{name:"startSentence",rows:1,value:a.startSentence,onBlur:n,onEnter:n}))),a.aiAvatar&&React.createElement(Na,{label:Ee.COMMON.AI_AVATAR,updateShortcodeParams:n,valueName:"aiAvatarUrl",icon:a.aiAvatarUrl}),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.AVATAR,":"),React.createElement(d.R,{name:"userAvatar",label:"Yes",checked:a.userAvatar,value:"1",onChange:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ee.COMMON.USER_NAME,":"),React.createElement(te.A,{name:"userName","data-form-type":"other",value:a.userName,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ee.COMMON.PLACEHOLDER,":"),React.createElement(te.A,{name:"textInputPlaceholder",value:a.textInputPlaceholder,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ee.COMMON.SEND,":"),React.createElement(te.A,{name:"textSend",value:a.textSend,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ee.COMMON.CLEAR,":"),React.createElement(te.A,{name:"textClear",value:a.textClear,onBlur:n,onEnter:n}))),a.userAvatar&&React.createElement("p",null,React.createElement("i",null,"The ",React.createElement("a",{href:"https://gravatar.com/",target:"_blank",rel:"noreferrer"},"gravatar")," of this user will be used as the avatar.")),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.AVATAR,":"),React.createElement(d.R,{name:"guestAvatar",label:"Yes",checked:a.guestAvatar,value:"1",onChange:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ee.COMMON.GUEST_NAME,":"),React.createElement(te.A,{name:"guestName",value:a.guestName,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:7}},React.createElement("label",null,Ee.COMMON.COMPLIANCE_TEXT,":"),React.createElement(te.A,{name:"textCompliance",value:a.textCompliance,onBlur:n,onEnter:n}))),a.guestAvatar&&React.createElement(Na,{label:Ee.COMMON.GUEST_AVATAR,updateShortcodeParams:n,valueName:"guestAvatarUrl",icon:a.guestAvatarUrl})),React.createElement(le.Y,{title:Ee.COMMON.POPUP,hide:!a.window},React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:4}},React.createElement("label",null,Ee.COMMON.POSITION,":"),React.createElement(ee.u,{scrolldown:!0,name:"iconPosition",value:a.iconPosition,onChange:n},React.createElement(ee.j,{value:"bottom-right",label:"Bottom Right"}),React.createElement(ee.j,{value:"bottom-left",label:"Bottom Left"}),React.createElement(ee.j,{value:"top-right",label:"Top Right"}),React.createElement(ee.j,{value:"top-left",label:"Top Left"}))),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.BUBBLE,":"),React.createElement(d.R,{name:"iconBubble",label:"Yes",checked:a.iconBubble,value:"1",onChange:n}))),React.createElement(Na,{label:Ee.COMMON.ICON,updateShortcodeParams:n,valueName:"icon",icon:a.icon}),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:4}},React.createElement("label",null,Ee.COMMON.ICON_TEXT,":"),React.createElement(te.A,{name:"iconText",description:Ee.HELP.ICON_TEXT,value:a.iconText,onBlur:n,onEnter:n})),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ee.COMMON.ICON_TEXT_DELAY,":"),React.createElement(te.A,{name:"iconTextDelay",type:"number",description:Ee.HELP.ICON_TEXT_DELAY??1,value:a.iconTextDelay,onBlur:n,onEnter:n})))),!r&&React.createElement(le.Y,{title:Ee.COMMON.SHORTCODES},React.createElement(ya,{currentChatbot:a,style:{marginTop:10}}),"default"!==a.botId&&React.createElement(React.Fragment,null,React.createElement("p",null,Ee.HELP.CUSTOM_SHORTCODE),React.createElement(ya,{currentChatbot:a,isCustom:!0,defaultChatbot:l,style:{marginTop:10}}))),!r&&React.createElement(le.Y,{title:Ee.COMMON.ACTIONS},React.createElement("div",{style:{display:"flex",marginTop:10}},React.createElement(R.M,{className:"primary",onClick:i},Ee.COMMON.DUPLICATE),React.createElement(R.M,{className:"secondary",onClick:c},Ee.COMMON.RESET),React.createElement("div",{style:{flex:"auto"}}),React.createElement(R.M,{className:"danger",disabled:"Default"===a.name,onClick:o},Ee.COMMON.DELETE))))))))};var Ma=a(7612);const{useState:Sa,useEffect:Aa,useRef:ka,useCallback:xa}=wp.element,Pa=P.Ay.div`
position: relative;
.swatch {
width: 24px;
height: 24px;
border: 3px solid #fff;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
cursor: pointer;
}
.popover {
position: absolute;
top: -210px;
left: -80px;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
z-index: 9999;
border-radius: 8px;
}
`,La=({name:e,value:t,onChange:a})=>{const n=ka(),[l,r]=Sa(!1),[o,c]=Sa(t);Aa((()=>{c(t)}),[t]);const i=xa((()=>{o!==t&&a(o,e),r(!1)}),[o,t]);var s,m;return Aa((()=>{let e=!1,t=!1;const a=a=>{!e&&t&&s.current&&!s.current.contains(a.target)&&m(a)},n=a=>{t=s.current,e=s.current&&s.current.contains(a.target)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),document.addEventListener("click",a),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("click",a)}}),[s=n,m=i]),React.createElement(Pa,{className:"neko-color-picker"},React.createElement("div",{className:"swatch",style:{backgroundColor:o},onClick:()=>r(!0)}),l&&React.createElement("div",{className:"popover",ref:n,style:{background:"white"}},React.createElement(Ma.jI,{color:o,onChange:c}),React.createElement("div",{style:{display:"flex",padding:5}},React.createElement(R.M,{style:{flex:1},onClick:()=>a(o,e)},"Apply"))))},Da=e=>{const{settings:t,onUpdateSettings:a}=e;return React.createElement(React.Fragment,null,React.createElement(da,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.SPACING,":"),React.createElement(te.A,{id:"spacing",name:"spacing",value:(null==t?void 0:t.spacing)??"15px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.BORDER_RADIUS,":"),React.createElement(te.A,{id:"borderRadius",name:"borderRadius",value:(null==t?void 0:t.borderRadius)??"10px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.FONT_SIZE,":"),React.createElement(te.A,{id:"fontSize",name:"fontSize",value:(null==t?void 0:t.fontSize)??"15px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"fontColor",name:"fontColor",value:(null==t?void 0:t.fontColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"fontColor",name:"fontColor",value:(null==t?void 0:t.fontColor)??"#FFFFFF",onChange:a})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_PRIMARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",style:{flex:1},value:(null==t?void 0:t.backgroundPrimaryColor)??"#454654",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:(null==t?void 0:t.backgroundPrimaryColor)??"#454654",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_SECONDARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundSecondaryColor",name:"backgroundSecondaryColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#343541",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundSecondaryColor",name:"backgroundSecondaryColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#343541",onChange:a,onEnter:a})))),React.createElement(ae.g,null),React.createElement(le.Y,{title:Ee.COMMON.POPUP,isCollapsed:!1}),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.75}},React.createElement("label",null,Ee.COMMON.WIDTH,":"),React.createElement(te.A,{id:"width",name:"width",value:(null==t?void 0:t.width)??"460px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.75}},React.createElement("label",null,Ee.COMMON.MAX_HEIGHT,":"),React.createElement(te.A,{id:"maxHeight",name:"maxHeight",value:(null==t?void 0:t.maxHeight)??"40vh",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.AVATAR_MESSAGE_BACKGROUND_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"iconTextBackgroundColor",name:"iconTextBackgroundColor",value:(null==t?void 0:t.iconTextBackgroundColor)??"#343541",onBlur:a,onEnter:a}),React.createElement(La,{id:"iconTextBackgroundColor",name:"iconTextBackgroundColor",value:(null==t?void 0:t.iconTextBackgroundColor)??"#343541",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.AVATAR_MESSAGE_FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"iconTextColor",name:"iconTextColor",value:(null==t?void 0:t.iconTextColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"iconTextColor",name:"iconTextColor",value:(null==t?void 0:t.iconTextColor)??"#FFFFFF",onChange:a,onEnter:a})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BUBBLE_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"bubbleColor",name:"bubbleColor",style:{flex:1},value:(null==t?void 0:t.bubbleColor)??"#343541",onBlur:a,onEnter:a}),React.createElement(La,{id:"bubbleColor",name:"bubbleColor",value:(null==t?void 0:t.bubbleColor)??"#343541",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.HEADER_BACKGROUND_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundHeaderColor",name:"backgroundHeaderColor",style:{flex:1},value:(null==t?void 0:t.backgroundHeaderColor)??"#343541",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundHeaderColor",name:"backgroundHeaderColor",value:(null==t?void 0:t.backgroundHeaderColor)??"#343541",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.HEADER_BUTTONS_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"headerButtonsColor",name:"headerButtonsColor",style:{flex:1},value:(null==t?void 0:t.headerButtonsColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"headerButtonsColor",name:"headerButtonsColor",value:(null==t?void 0:t.headerButtonsColor)??"#FFFFFF",onChange:a,onEnter:a}))))))},{useMemo:Fa,useState:Ua,useEffect:Ba}=wp.element,Ga=e=>{const{theme:t,onUpdateTheme:a}=e,[n,l]=Ua("");Ba((()=>{l(t.style)}),[t]);const r=Fa((()=>n!==t.style),[n,t]);return React.createElement(da,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.NAME,":"),React.createElement(te.A,{name:"name","data-form-type":"other",value:t.name,onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("div",null,React.createElement("label",{style:{display:"block"}},Ee.COMMON.ID,":"),React.createElement(te.A,{name:"themeId",type:"text",placeholder:"Optional",value:t.themeId,onBlur:a,onEnter:a})))),React.createElement(ae.g,null),React.createElement("label",null,"Custom CSS:"),React.createElement(Ye.m,{name:"css",value:n,onChange:l,rows:16,tabToSpaces:2}),React.createElement("div",{style:{display:"flex"}},React.createElement(R.M,{fullWidth:!0,onClick:()=>{const e=".mwai-THEME_ID-theme {\n --mwai-spacing: 10px;\n --mwai-fontSize: 14px;\n --mwai-fontColor: #000;\n --mwai-bgPrimary: #fff;\n --mwai-primary: #0084ff;\n --mwai-secondary: #f0f0f0;\n --mwai-width: 300px;\n --mwai-borderRadius: 5px;\n}\n\n.mwai-THEME_ID-theme .mwai-content {\n background: var(--mwai-bgPrimary);\n padding: var(--mwai-spacing);\n font-size: var(--mwai-fontSize);\n color: var(--mwai-fontColor);\n}\n\n.mwai-THEME_ID-theme .mwai-conversation {\n display: flex;\n flex-direction: column;\n}\n\n.mwai-THEME_ID-theme .mwai-reply {\n margin-bottom: var(--mwai-spacing);\n padding: var(--mwai-spacing);\n display: flex;\n}\n\n.mwai-THEME_ID-theme .mwai-reply.mwai-ai {\n background: var(--mwai-secondary);\n}\n\n.mwai-THEME_ID-theme .mwai-reply.mwai-user {\n background: var(--mwai-primary);\n color: #fff;\n}\n\n.mwai-THEME_ID-theme .mwai-name {\n margin-right: var(--mwai-spacing);\n}\n\n.mwai-THEME_ID-theme .mwai-input {\n display: flex;\n align-items: center;\n gap: 5px;\n}\n\n.mwai-THEME_ID-theme .mwai-input-text {\n display: flex;\n align-items: center;\n flex: 1;\n}\n\n.mwai-THEME_ID-theme .mwai-input-text textarea {\n flex: 1;\n}\n\n.mwai-THEME_ID-theme .mwai-input-text .mwai-microphone {\n flex: 1;\n}\n\n.mwai-THEME_ID-theme .mwai-input-text .mwai-file-upload-icon {\n flex: 1;\n}\n\n.mwai-THEME_ID-theme .mwai-trigger {\n position: absolute;\n right: 0;\n bottom: 0;\n transition: all 0.2s ease-out;\n z-index: 9999;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n}\n\n.mwai-THEME_ID-theme .mwai-trigger .mwai-icon-text-container {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n}\n\n.mwai-THEME_ID-theme .mwai-trigger .mwai-icon-text {\n background: var(--mwai-iconTextBackgroundColor);\n color: var(--mwai-iconTextColor);\n box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);\n max-width: 200px;\n font-size: 13px;\n margin-bottom: 15px;\n padding: 10px 15px;\n border-radius: 8px;\n}\n\n.mwai-THEME_ID-theme .mwai-reply-actions .mwai-copy-button {\n fill: var(--mwai-fontColor);\n padding: 3px 5px;\n width: 24px;\n height: 24px;\n background: var(--mwai-bgPrimary);\n cursor: pointer;\n border-radius: var(--mwai-borderRadius);\n display: none;\n}\n\n.mwai-THEME_ID-theme .mwai-reply-actions:not(.mwai-hidden) .mwai-copy-button {\n display: block;\n}\n\n.mwai-THEME_ID-theme.mwai-window {\n position: fixed;\n right: 30px;\n bottom: 30px;\n width: var(--mwai-width);\n z-index: 9999;\n}\n\n.mwai-THEME_ID-theme.mwai-window .mwai-content {\n display: none;\n opacity: 0;\n max-height: var(--mwai-maxHeight);\n border-radius: 0 0 var(--mwai-borderRadius) var(--mwai-borderRadius);\n}\n\n.mwai-THEME_ID-theme.mwai-window.mwai-bottom-left,\n.mwai-THEME_ID-theme.mwai-window.mwai-top-left {\n right: auto;\n left: 30px;\n}\n\n.mwai-THEME_ID-theme.mwai-window.mwai-top-right,\n.mwai-THEME_ID-theme.mwai-window.mwai-top-left {\n top: 30px;\n bottom: auto;\n}\n\n.mwai-THEME_ID-theme.mwai-window.mwai-open .mwai-trigger {\n display: none;\n}\n\n.mwai-THEME_ID-theme.mwai-window.mwai-open .mwai-content {\n display: flex;\n flex-direction: column;\n transition: opacity 200ms ease-in-out;\n opacity: 1;\n}\n\n.mwai-THEME_ID-theme.mwai-window .mwai-header {\n display: none;\n justify-content: flex-end;\n height: 22px;\n}\n\n.mwai-THEME_ID-theme.mwai-window.mwai-open .mwai-header {\n display: flex;\n}\n\n.mwai-THEME_ID-theme.mwai-window .mwai-header .mwai-buttons .mwai-close-button:after {\n content: '╳';\n cursor: pointer;\n}\n".replace(/THEME_ID/g,t.themeId);l(e)}},"Default CSS"),React.createElement(R.M,{fullWidth:!0,onClick:()=>{a(n,"style")},disabled:!r},"Apply CSS")))},Ha=e=>{const{settings:t,onUpdateSettings:a}=e;return React.createElement(React.Fragment,null,React.createElement(da,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.SPACING,":"),React.createElement(te.A,{id:"spacing",name:"spacing",value:(null==t?void 0:t.spacing)??"15px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.BORDER_RADIUS,":"),React.createElement(te.A,{id:"borderRadius",name:"borderRadius",value:(null==t?void 0:t.borderRadius)??"10px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.FONT_SIZE,":"),React.createElement(te.A,{id:"fontSize",name:"fontSize",value:(null==t?void 0:t.fontSize)??"15px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"fontColor",name:"fontColor",value:(null==t?void 0:t.fontColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"fontColor",name:"fontColor",value:(null==t?void 0:t.fontColor)??"#FFFFFF",onChange:a})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_PRIMARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",style:{flex:1},value:(null==t?void 0:t.backgroundPrimaryColor)??"#fafafa",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:(null==t?void 0:t.backgroundPrimaryColor)??"#fafafa",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_USER_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundUserColor",name:"backgroundUserColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#0084ff",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundUserColor",name:"backgroundUserColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#0084ff",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_AI_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundAiColor",name:"backgroundAiColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#eee",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundAiColor",name:"backgroundAiColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#eee",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_AI_SECONDARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundAiSecondaryColor",name:"backgroundAiSecondaryColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#ddd",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundAiSecondaryColor",name:"backgroundAiSecondaryColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#ddd",onChange:a,onEnter:a})))),React.createElement(ae.g,null),React.createElement(le.Y,{title:Ee.COMMON.POPUP,isCollapsed:!1}),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.75}},React.createElement("label",null,Ee.COMMON.WIDTH,":"),React.createElement(te.A,{id:"width",name:"width",value:(null==t?void 0:t.width)??"460px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.75}},React.createElement("label",null,Ee.COMMON.MAX_HEIGHT,":"),React.createElement(te.A,{id:"maxHeight",name:"maxHeight",value:(null==t?void 0:t.maxHeight)??"40vh",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.AVATAR_MESSAGE_BACKGROUND_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"iconTextBackgroundColor",name:"iconTextBackgroundColor",value:(null==t?void 0:t.iconTextBackgroundColor)??"#0084ff",onBlur:a,onEnter:a}),React.createElement(La,{id:"iconTextBackgroundColor",name:"iconTextBackgroundColor",value:(null==t?void 0:t.iconTextBackgroundColor)??"#0084ff",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.AVATAR_MESSAGE_FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"iconTextColor",name:"iconTextColor",value:(null==t?void 0:t.iconTextColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"iconTextColor",name:"iconTextColor",value:(null==t?void 0:t.iconTextColor)??"#FFFFFF",onChange:a,onEnter:a})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BUBBLE_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"bubbleColor",name:"bubbleColor",style:{flex:1},value:(null==t?void 0:t.bubbleColor)??"#0084ff",onBlur:a,onEnter:a}),React.createElement(La,{id:"bubbleColor",name:"bubbleColor",value:(null==t?void 0:t.bubbleColor)??"#0084ff",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.HEADER_BACKGROUND_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundHeaderColor",name:"backgroundHeaderColor",style:{flex:1},value:(null==t?void 0:t.backgroundHeaderColor)??"#0084ff",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundHeaderColor",name:"backgroundHeaderColor",value:(null==t?void 0:t.backgroundHeaderColor)??"#0084ff",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.HEADER_BUTTONS_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"headerButtonsColor",name:"headerButtonsColor",style:{flex:1},value:(null==t?void 0:t.headerButtonsColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"headerButtonsColor",name:"headerButtonsColor",value:(null==t?void 0:t.headerButtonsColor)??"#FFFFFF",onChange:a,onEnter:a}))))))},ja=e=>{const{settings:t,onUpdateSettings:a}=e;return React.createElement(React.Fragment,null,React.createElement(oe.X,{variant:"danger"},"This theme is ",React.createElement("b",null,"still in development"),". The related settings will be available soon."),React.createElement(da,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.SPACING,":"),React.createElement(te.A,{id:"spacing",name:"spacing",value:(null==t?void 0:t.spacing)??"15px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.BORDER_RADIUS,":"),React.createElement(te.A,{id:"borderRadius",name:"borderRadius",value:(null==t?void 0:t.borderRadius)??"10px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ee.COMMON.FONT_SIZE,":"),React.createElement(te.A,{id:"fontSize",name:"fontSize",value:(null==t?void 0:t.fontSize)??"13px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ee.COMMON.FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"fontColor",name:"fontColor",value:(null==t?void 0:t.fontColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"fontColor",name:"fontColor",value:(null==t?void 0:t.fontColor)??"#FFFFFF",onChange:a})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_PRIMARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",style:{flex:1},value:(null==t?void 0:t.backgroundPrimaryColor)??"#fafafa",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:(null==t?void 0:t.backgroundPrimaryColor)??"#fafafa",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_USER_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundUserColor",name:"backgroundUserColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#434cc5",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundUserColor",name:"backgroundUserColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#434cc5",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_AI_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundAiColor",name:"backgroundAiColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#F1F3F7",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundAiColor",name:"backgroundAiColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#eee",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BACK_AI_SECONDARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundAiSecondaryColor",name:"backgroundAiSecondaryColor",style:{flex:1},value:(null==t?void 0:t.backgroundSecondaryColor)??"#ddd",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundAiSecondaryColor",name:"backgroundAiSecondaryColor",value:(null==t?void 0:t.backgroundSecondaryColor)??"#ddd",onChange:a,onEnter:a})))),React.createElement(ae.g,null),React.createElement(le.Y,{title:Ee.COMMON.POPUP,isCollapsed:!1}),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.75}},React.createElement("label",null,Ee.COMMON.WIDTH,":"),React.createElement(te.A,{id:"width",name:"width",value:(null==t?void 0:t.width)??"360px",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.75}},React.createElement("label",null,Ee.COMMON.MAX_HEIGHT,":"),React.createElement(te.A,{id:"maxHeight",name:"maxHeight",value:(null==t?void 0:t.maxHeight)??"40vh",onBlur:a,onEnter:a})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.AVATAR_MESSAGE_BACKGROUND_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"iconTextBackgroundColor",name:"iconTextBackgroundColor",value:(null==t?void 0:t.iconTextBackgroundColor)??"#343541",onBlur:a,onEnter:a}),React.createElement(La,{id:"iconTextBackgroundColor",name:"iconTextBackgroundColor",value:(null==t?void 0:t.iconTextBackgroundColor)??"#343541",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.AVATAR_MESSAGE_FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"iconTextColor",name:"iconTextColor",value:(null==t?void 0:t.iconTextColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"iconTextColor",name:"iconTextColor",value:(null==t?void 0:t.iconTextColor)??"#FFFFFF",onChange:a,onEnter:a})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.BUBBLE_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"bubbleColor",name:"bubbleColor",style:{flex:1},value:(null==t?void 0:t.bubbleColor)??"#434cc5",onBlur:a,onEnter:a}),React.createElement(La,{id:"bubbleColor",name:"bubbleColor",value:(null==t?void 0:t.bubbleColor)??"#434cc5",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.HEADER_BACKGROUND_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"backgroundHeaderColor",name:"backgroundHeaderColor",style:{flex:1},value:(null==t?void 0:t.backgroundHeaderColor)??"#434cc5",onBlur:a,onEnter:a}),React.createElement(La,{id:"backgroundHeaderColor",name:"backgroundHeaderColor",value:(null==t?void 0:t.backgroundHeaderColor)??"#434cc5",onChange:a,onEnter:a}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.HEADER_BUTTONS_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(te.A,{id:"headerButtonsColor",name:"headerButtonsColor",style:{flex:1},value:(null==t?void 0:t.headerButtonsColor)??"#FFFFFF",onBlur:a,onEnter:a}),React.createElement(La,{id:"headerButtonsColor",name:"headerButtonsColor",value:(null==t?void 0:t.headerButtonsColor)??"#FFFFFF",onChange:a,onEnter:a}))))))},$a=e=>{const{theme:t,updateTheme:a,resetTheme:n,deleteTheme:l}=e,r=(e,n)=>{const l={...t.settings,[n]:e};a(l,"settings")};return React.createElement(React.Fragment,null,"internal"===t.type&&"chatgpt"===t.themeId&&React.createElement(Da,{settings:t.settings??[],onUpdateSettings:r}),"internal"===t.type&&"messages"===t.themeId&&React.createElement(Ha,{settings:t.settings??[],onUpdateSettings:r}),"internal"===t.type&&"timeless"===t.themeId&&React.createElement(ja,{settings:t.settings??[],onUpdateSettings:r}),"internal"!==t.type&&React.createElement(Ga,{theme:t,onUpdateTheme:a}),React.createElement(ae.g,null),React.createElement(le.Y,{title:Ee.COMMON.ACTIONS}),React.createElement("div",{style:{display:"flex",marginTop:10}},React.createElement(R.M,{className:"secondary",onClick:()=>{n()}},Ee.COMMON.RESET),React.createElement("div",{style:{flex:"auto"}}),React.createElement(R.M,{className:"danger",disabled:"internal"===t.type,onClick:l},Ee.COMMON.DELETE)))},{useState:Ya}=wp.element,Wa=e=>{const t=(0,l.jE)(),{onSwitchTheme:a=(()=>{})}=e,[n,r]=Ya(!1),{data:c}=(0,o.I)({queryKey:["themes"],queryFn:tt,initialData:S}),i=e.currentTheme,s=async(e,a)=>{try{r(!0);const n={...i,[a]:e};let l=[...c];const o=l.findIndex((e=>e.themeId===i.themeId));l[o]=n,l=await at(l),t.setQueryData(["themes"],l)}catch(e){console.error(e)}r(!1)},m=async()=>{r(!0);const e=[...c.filter((e=>e.themeId!==i.themeId))];a(e[0].themeId),await at(e),await t.setQueryData(["themes"],e),r(!1)},d=async()=>{r(!0);const e=[...c],a=e.findIndex((e=>e.themeId===i.themeId));e[a]={type:e[a].type,name:e[a].name,themeId:e[a].themeId,settings:[],style:""},await at(e),await t.setQueryData(["themes"],e),r(!1)};return React.createElement(React.Fragment,null,React.createElement(g._,{inversed:!0,onChange:(e,t)=>{const n=c.find((e=>e.themeId===t.key));n&&a(n.themeId)},currentTab:null==i?void 0:i.themeId,action:React.createElement(React.Fragment,null,React.createElement(R.M,{rounded:!0,className:"secondary",icon:"plus",onClick:async()=>{r(!0);try{const e=await at([...c,{type:"css",name:"New Theme",themeId:"theme-"+Te(),settings:[],style:""}]);t.setQueryData(["themes"],e)}catch(e){console.error(e)}r(!1)}}))},null==c?void 0:c.map((e=>React.createElement(g.V,{key:e.themeId,title:e.name,busy:n},React.createElement($a,{theme:e,updateTheme:s,resetTheme:d,deleteTheme:m}))))))};var za=a(1469),Va=a(6966);const Ka=()=>{const e={width:9,height:9,margin:"5px 0px 0px 5px",borderRadius:"50%",backgroundColor:"#a3a1a1",opacity:1,animation:"bouncing-loader 0.4s infinite alternate"};return React.createElement(React.Fragment,null,React.createElement("style",null,"\n @keyframes bouncing-loader {\n to {\n opacity: 0.6;\n transform: translateY(-10px);\n }\n }\n "),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:26}},["0.1s","0.2s","0.3s"].map(((t,a)=>React.createElement("div",{key:a,style:{...e,animationDelay:t}})))))};function qa(){return qa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},qa.apply(this,arguments)}const{useState:Xa,useEffect:Qa,useRef:Ja,useCallback:Za}=wp.element,en=({enabled:e,content:t,children:a,className:n,...l})=>{const r=(0,Va.gR)(),[o,c]=Xa("idle"),[i,s]=Xa(!0),m=Ja(null),d=Ja(!1),u=Za((()=>{d.current||(d.current=!0,m.current=setTimeout((()=>{s(!1)}),500))}),[]),E=Za((()=>{m.current&&clearTimeout(m.current),s(!0),d.current=!1}),[]);Qa((()=>()=>{m.current&&clearTimeout(m.current)}),[]);const p="success"===o?'<path d="M10.7673 18C10.3106 18 9.86749 17.8046 9.54432 17.4555L5.50694 13.1222C4.83102 12.3968 4.83102 11.2208 5.50694 10.4954C6.18287 9.76997 7.27871 9.76997 7.95505 10.4954L10.6794 13.4196L16.9621 5.63976C17.5874 4.86495 18.6832 4.78289 19.4031 5.45388C20.125 6.12487 20.2036 7.29638 19.5759 8.07391L12.0778 17.3589C11.7639 17.7475 11.3119 17.9801 10.8319 18C10.8087 18 10.788 18 10.7673 18Z" />':"error"===o?'<path d="M17.7623 17.7626C17.0831 18.4418 15.9549 18.416 15.244 17.705L5.79906 8.26012C5.08811 7.54917 5.0623 6.42098 5.74145 5.74183C6.4206 5.06267 7.54879 5.08849 8.25975 5.79944L17.7047 15.2443C18.4156 15.9553 18.4414 17.0835 17.7623 17.7626Z" /><path d="M17.5508 8.52848L8.52842 17.5509C7.84927 18.23 6.72108 18.2042 6.01012 17.4933C5.29917 16.7823 5.27336 15.6541 5.95251 14.975L14.9749 5.95257C15.6541 5.27342 16.7823 5.29923 17.4932 6.01019C18.2042 6.72114 18.23 7.84933 17.5508 8.52848Z" />':'<path d="M7 5a3 3 0 0 1 3-3h9a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-2v2a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3v-9a3 3 0 0 1 3-3h2zm2 2h5a3 3 0 0 1 3 3v5h2a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-9a1 1 0 0 0-1 1zM5 9a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1v-9a1 1 0 0 0-1-1z" />';return React.createElement("div",qa({},l,{onMouseLeave:E,onMouseEnter:u,onMouseOver:u}),React.createElement("span",{className:n},a),React.createElement("div",{className:r("mwai-reply-actions",{"mwai-hidden":i})},e&&React.createElement("div",{className:"mwai-copy-button",onClick:()=>{try{navigator.clipboard.writeText(t),c("success")}catch(e){c("error"),console.warn("Not allowed to copy to clipboard. Make sure your website uses HTTPS.",{content:t})}finally{setTimeout((()=>{c("idle")}),2e3)}}},React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",dangerouslySetInnerHTML:{__html:p}}))))},{useMemo:tn}=wp.element,an=({role:e="user"})=>{const{state:t}=(0,za.o)(),{pluginUrl:a,iconUrl:n,userData:l,userName:r,aiName:o,guestName:c,userAvatar:i,aiAvatar:s,guestAvatar:m,userAvatarUrl:d,aiAvatarUrl:u,guestAvatarUrl:E}=t,p=tn((()=>{const t="assistant"===e,p=!l&&!t,g=e=>React.createElement("div",{className:"mwai-name-text"},e),R=(e,t,n,l,r=!1)=>{if(!e)return null;if((0,ba.Ve)(t))return o=t,React.createElement("div",{className:"mwai-avatar mwai-emoji",style:{fontSize:"32px",lineHeight:"32px"}},o);var o;const c=((e,t=!1)=>(0,Va.mv)(e)?e:e&&!(0,ba.Ve)(e)?t?e:`${a}/images/${e}`:(t||(0,ba.Ve)(e)||console.warn("Invalid URL for avatar:",e),null))(t,r)||n;return c?((e,t)=>React.createElement("div",{className:"mwai-avatar"},React.createElement("img",{width:"32",height:"32",src:e,alt:t})))(c,l):null};if(t){const e=R(s,u,n,"AI Avatar");return e?(null===u&&n&&console.warn("Using iconUrl as a temporary fallback for AI avatar. Please set aiAvatarUrl."),e):g(o)}if(!p){return R(i,d,null==l?void 0:l.AVATAR_URL,"User Avatar",!0)||g(function(e,t,a){return a&&0!==Object.keys(a).length?Object.entries(a).reduce(((e,[t,a])=>{const n=`{${t}}`;return e.includes(n)?e.replace(n,a):e}),e):t||e||"Guest"}(r,c,l))}if(p){return R(m,E,null,"Guest Avatar")||g(c||"Guest")}}),[e,o,r,c,l,n,s,i,m,u,d,E,a]);return React.createElement("span",{className:"mwai-name"},p)},{useState:nn,useMemo:ln,useEffect:rn,useRef:on}=wp.element,cn=({href:e,children:t})=>{if(!e)return React.createElement("span",null,t);const a="_blank";if("Uploaded File"===String(t)){const t=e.split("/").pop();return React.createElement("a",{href:e,target:a,rel:"noopener noreferrer",className:"mwai-filename"},React.createElement("span",null,"✓ ",t))}return React.createElement("a",{href:e,target:a,rel:"noopener noreferrer"},t)},sn=({message:e,onRendered:t=(()=>{})})=>{const{state:a}=(0,za.o)(),{copyButton:n}=a,[l]=nn(e.isQuerying||e.isStreaming),r=e.isQuerying,o=e.isStreaming;let c=e.content??"";(c.match(/```/g)||[]).length%2!=0?c+="\n```":e.isStreaming&&(c+="<BlinkingCursor />"),rn((()=>{l&&(!l||r||o)||t()}),[l,r,o]);const i=ln((()=>({overrides:{BlinkingCursor:{component:ba.rn},a:{component:cn},img:{props:{onError:e=>{null!==e.target.src.match(/\.(jpeg|jpg|gif|png)$/)&&(e.target.src="https://placehold.co/600x200?text=Expired+Image")},className:"mwai-image"}}}})),[]),s=ln((()=>{let e="";try{e=(0,Vt.cx)(c,i)}catch(t){console.error("Crash in markdown-to-jsx! Reverting to plain text.",{e:t,content:c}),e=c}return e}),[c,i]);return r||o&&!c?React.createElement(Ka,null):React.createElement(React.Fragment,null,React.createElement(an,{role:e.role}),React.createElement(en,{content:e.content,enabled:n,className:"mwai-text"},s))},mn=({message:e,onRendered:t=(()=>{})})=>{const[a,n]=nn(null==e?void 0:e.images);return rn((()=>{t()})),e.isQuerying?React.createElement(Ka,null):React.createElement(React.Fragment,null,React.createElement(an,{role:e.role}),React.createElement("span",{className:"mwai-text"},React.createElement("div",{className:"mwai-gallery"},null==a?void 0:a.map(((e,t)=>React.createElement("a",{key:t,href:e,target:"_blank",rel:"noopener noreferrer"},React.createElement("img",{key:t,src:e,onError:()=>(e=>{n((t=>t.map(((t,a)=>a===e?"https://placehold.co/600x200?text=Expired+Image":t))))})(t)})))))))},dn=({message:e,conversationRef:t})=>{var a;const{state:n}=(0,za.o)(),{typewriter:l}=n,r=(0,Va.gR)(),o=on(),c=r("mwai-reply",{"mwai-ai":"assistant"===e.role,"mwai-user":"user"===e.role,"mwai-system":"system"===e.role}),i=(null==e||null===(a=e.images)||void 0===a?void 0:a.length)>0,s=()=>{!o.current||e.isQuerying||o.current.classList.contains("mwai-rendered")||"undefined"==typeof hljs||(o.current.classList.add("mwai-rendered"),o.current.querySelectorAll("pre code").forEach((e=>{hljs.highlightElement(e)})))};return ln((()=>"user"===e.role?React.createElement("div",{ref:o,className:c},React.createElement(sn,{message:e})):"assistant"===e.role?i?React.createElement("div",{ref:o,className:c},React.createElement(mn,{message:e,conversationRef:t,onRendered:s})):React.createElement("div",{ref:o,className:c},React.createElement(sn,{message:e,conversationRef:t,onRendered:s})):"system"===e.role?React.createElement("div",{ref:o,className:c},React.createElement(sn,{message:e,conversationRef:t,onRendered:s})):React.createElement("div",null,React.createElement("i",null,"Unhandled role."))),[e,t,i,l])};var un=a(2192);const{useState:En,useMemo:pn,useRef:gn}=wp.element,Rn=()=>{const e=(0,Va.gR)(),{state:t,actions:a}=(0,za.o)(),{uploadedFile:n,busy:l,imageUpload:r,fileUpload:o,fileSearch:c,draggingType:i}=t,{onUploadFile:s}=a,[m,d]=En(!1),u=gn(),E=null==n?void 0:n.uploadedId,p=r||c||o,g=n,R=pn((()=>null!=g&&g.localFile?g.localFile.type.startsWith("image/")?"image":"document":i),[g,i]),h=pn((()=>{let e="idle";return null!=g&&g.uploadProgress?e="up":i?e="add":m&&E?e="del":E?e="ok":m&&!E&&(e="add"),`mwai-file-upload-icon mwai-${R?R.toLowerCase():"idle"}-${e}`}),[R,g,i,m,E]),y=pn((()=>null!=g&&g.uploadProgress?g.uploadProgress>99?99:Math.round(g.uploadProgress):""),[g]);return p?React.createElement("div",{disabled:l,onClick:()=>{null!=n&&n.localFile?s(null):l||u.current.click()},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:e("mwai-file-upload",{"mwai-enabled":null==n?void 0:n.uploadedId,"mwai-busy":(null==n?void 0:n.localFile)&&!(null!=n&&n.uploadedId)}),style:{cursor:l?"default":"pointer"}},React.createElement("div",{className:h},React.createElement("span",{className:"mwai-file-upload-progress"},y)),React.createElement("input",{type:"file",ref:u,onChange:e=>{const t=e.target.files[0];t&&s(t)},style:{display:"none"}})):null},{useRef:hn,useState:yn,useEffect:bn,useImperativeHandle:vn}=wp.element,fn=()=>{const e=(0,Va.gR)(),{state:t,actions:a}=(0,za.o)(),{inputText:n,textInputMaxLength:l,textInputPlaceholder:r,error:o,speechRecognitionAvailable:c,isMobile:i,conversationRef:s,open:m,uploadIconPosition:d,locked:u,isListening:E,busy:p,speechRecognition:g,chatbotInputRef:R}=t,{onSubmitAction:h,setIsListening:y,resetError:b,setInputText:v}=a,[f,_]=yn(!1),w=hn();vn(R,(()=>({focusInput:()=>{var e;null===(e=w.current)||void 0===e||e.focus()},currentElement:()=>w.current}))),bn((()=>{!i&&m&&w.current.focus(),s.current&&(s.current.scrollTop=s.current.scrollHeight)}),[m,i,s]);const C=e("mwai-input-text",{});return React.createElement("div",{ref:R,className:C},"mwai-input"===d&&React.createElement(Rn,null),React.createElement(un.A,{ref:w,disabled:p||u,placeholder:r,value:n,maxLength:l,onCompositionStart:()=>_(!0),onCompositionEnd:()=>_(!1),onKeyDown:e=>{f||"Enter"!==e.code||e.shiftKey||(e.preventDefault(),h())},onChange:e=>{return t=e.target.value,E&&y(!1),o&&b(),void v(t);var t}}),g&&React.createElement(Va.tm,{active:E,disabled:!c||p,className:"mwai-microphone",onClick:()=>y(!E)}))};var _n=a(7775),wn=a(1585);const{useMemo:Cn,useCallback:On}=wp.element,Tn=()=>{const{state:e,actions:t}=(0,za.o)(),{onClear:a,onSubmitAction:n,setIsListening:l}=t,{textClear:r,textSend:o,uploadedFile:c,inputText:i,messages:s,isListening:m,timeElapsed:d,busy:u,submitButtonConf:E,locked:p}=e,g=!(null==c||!c.uploadProgress),R=!(null!=c&&c.uploadedId)&&i.length<1&&(null==s?void 0:s.length)>1,h=Cn((()=>u?d?React.createElement("div",{className:"mwai-timer"},d):null:null!=E&&E.imageSend&&null!=E&&E.imageClear?React.createElement("img",{src:R?E.imageClear:E.imageSend,alt:R?r:o}):R||o?R&&!r?React.createElement(wn.A,{size:"20"}):React.createElement("span",null,R?r:o):React.createElement(_n.A,{size:"20",style:{marginLeft:10}})),[u,d,R,r,o,E]),y=Cn((()=>"mwai-input-submit "+(u?"mwai-busy":"")),[u]),b=On((()=>{m&&l(!1),R?a():n()}),[R,m,a,n,l]),v=On((()=>{u||b()}),[u,b]);return React.createElement("button",{className:y,disabled:u||g||p,onClick:v},h)},{useMemo:Nn}=wp.element;const In=()=>{const{state:e,actions:t}=(0,za.o)(),{theme:a,isWindow:n,fullscreen:l,aiName:r,pluginUrl:o,open:c,iconUrl:i,aiAvatarUrl:s,windowed:m,headerSubtitle:d}=e,{setOpen:u,setWindowed:E}=t,p=Nn((()=>{if(!n)return null;const e="timeless"===(null==a?void 0:a.themeId),t=e?function(e,t,a,n){if((0,ba.Ve)(n||a))return l=n||a,React.createElement("div",{className:"mwai-avatar mwai-emoji",style:{fontSize:"48px",lineHeight:"48px"}},l);var l;const r=(o=n,((0,Va.mv)(o)?o:o?`${t}/images/${o}`:null)||a||`${t}/images/chat-openai.svg`);var o,c;return r?(c=r,React.createElement("div",{className:"mwai-avatar"},React.createElement("img",{alt:"AI Engine",src:c}))):React.createElement("div",{className:"mwai-name-text"},e)}(r,o,i,s):null,p=null==d?"Discuss with":d;return React.createElement(React.Fragment,null,e&&React.createElement(React.Fragment,null,t,React.createElement("div",{className:"mwai-name"},p&&React.createElement("small",{className:"mwai-subtitle"},p),React.createElement("div",null,r)),React.createElement("div",{style:{flex:"auto"}})),React.createElement("div",{className:"mwai-buttons"},l&&React.createElement("div",{className:"mwai-resize-button",onClick:()=>E(!m)}),React.createElement("div",{className:"mwai-close-button",onClick:()=>u(!c)})))}),[n,null==a?void 0:a.themeId,r,o,i,s,l,E,m,u,c,d]);return React.createElement("div",{className:"mwai-header"},p)},{useMemo:Mn,useEffect:Sn}=wp.element,An=()=>{const{state:e,actions:t}=(0,za.o)(),{isWindow:a,iconText:n,showIconMessage:l,iconAlt:r,iconUrl:o,open:c}=e,{setShowIconMessage:i,setOpen:s}=t;Sn((()=>{c&&l&&i(!1)}),[c,i,l]);const m=Mn((()=>a?React.createElement("div",{className:"mwai-trigger mwai-open-button"},React.createElement(Va.bE,{className:"mwai-icon-text-container",if:n&&l},React.createElement("div",{className:"mwai-icon-text-close",onClick:()=>i(!1)},"✕"),React.createElement("div",{className:"mwai-icon-text",onClick:()=>s(!0)},n)),React.createElement("div",{className:"mwai-icon-container",onClick:()=>s(!0)},(0,ba.Ve)(o)?React.createElement("div",{className:"mwai-icon mwai-emoji",style:{fontSize:"48px",lineHeight:"64px",width:"64px",height:"64px",display:"flex",justifyContent:"center",alignItems:"center"}},o):React.createElement("img",{className:"mwai-icon",width:"64",height:"64",alt:r,src:o}))):null),[a,n,l,r,o,i,s]);return React.createElement(React.Fragment,null,m)};var kn=a(5731),xn=a(9798),Pn=a(8834),Ln=a(7611),Dn=a(3893),Fn=a(718),Un=a(215);const{useState:Bn,useRef:Gn,useEffect:Hn}=wp.element;function jn(e,t){e.getByteTimeDomainData(t);let a=0;for(let e=0;e<t.length;e++){const n=t[e]-128;a+=n*n}return Math.sqrt(a/t.length)}function $n({assistantStream:e=null,userStream:t=null,assistantColor:a=null,userColor:n=null,userUI:l={emoji:null,text:null,image:null,use:"text"},assistantUI:r={emoji:null,text:null,image:null,use:"text"},attackSpeed:o=.3,releaseSpeed:c=.05,circleSize:i=50,pulseMaxSize:s=30}){const[m,d]=Bn(0),[u,E]=Bn(0),p=Gn(0),g=Gn(0),R=Gn(null),h=Gn(null),y=Gn(null),b=Gn(null),v=Gn(null);Hn((()=>{if(!e&&!t)return;R.current||(R.current=new AudioContext);const a=R.current;let n,l,r;e&&(n=a.createMediaStreamSource(e),h.current=a.createAnalyser(),h.current.fftSize=1024,y.current=new Uint8Array(h.current.frequencyBinCount),n.connect(h.current)),t&&(l=a.createMediaStreamSource(t),b.current=a.createAnalyser(),b.current.fftSize=1024,v.current=new Uint8Array(b.current.frequencyBinCount),l.connect(b.current));const i=()=>{let e=0;h.current&&y.current&&(e=jn(h.current,y.current));let t=0;b.current&&v.current&&(t=jn(b.current,v.current)),e>p.current?p.current=p.current*(1-o)+e*o:p.current=p.current*(1-c)+e*c,t>g.current?g.current=g.current*(1-o)+t*o:g.current=g.current*(1-c)+t*c,d(p.current),E(g.current),r=requestAnimationFrame(i)};return i(),()=>{n&&n.disconnect(),h.current&&h.current.disconnect(),l&&l.disconnect(),b.current&&b.current.disconnect(),r&&cancelAnimationFrame(r)}}),[e,t,o,c]);const f=i+Math.min(m/20,1)*s,_=i+Math.min(u/20,1)*s,w=i+s,C={width:_,height:_,borderRadius:"50%",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",opacity:.5};n&&(C.backgroundColor=n);const O={width:f,height:f,borderRadius:"50%",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",opacity:.5};a&&(O.backgroundColor=a);const T={width:i,height:i,borderRadius:"50%",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",color:"#fff"};n&&(T.backgroundColor=n);const N={width:i,height:i,borderRadius:"50%",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",color:"#fff"};a&&(N.backgroundColor=a);let I="mwai-visualizer";u>m?I+=" mwai-user-talking":m>u&&(I+=" mwai-assistant-talking");const M=e=>{if(!e)return null;const{emoji:t,text:a,image:n,use:l}=e;switch(l){case"emoji":return t?React.createElement("span",null,t):a?React.createElement("span",null,a.slice(0,1)):null;case"image":return n?React.createElement("img",{src:n,alt:"",style:{width:"100%",height:"100%",borderRadius:"50%"}}):t?React.createElement("span",null,t):a?React.createElement("span",null,a.slice(0,1)):null;default:return a?React.createElement("span",null,a.slice(0,1)):t?React.createElement("span",null,t):null}};return React.createElement("div",{className:I},React.createElement("div",{className:"mwai-visualizer-user",style:{position:"relative",width:w,height:w,overflow:"visible"}},React.createElement("div",{className:"mwai-animation",style:C}),React.createElement("div",{style:T},M(l))),React.createElement("hr",{className:"mwai-visualizer-line"}),React.createElement("div",{className:"mwai-visualizer-assistant",style:{position:"relative",width:w,height:w,overflow:"visible"}},React.createElement("div",{className:"mwai-animation",style:O}),React.createElement("div",{style:N},M(r))))}const{useState:Yn,useRef:Wn,useCallback:zn,useMemo:Vn,useEffect:Kn}=wp.element;function qn(e,...t){1>=e&&console.log(...t)}function Xn(e,t="user"){const{pluginUrl:a,iconUrl:n,userData:l,userName:r,aiName:o,guestName:c,userAvatar:i,aiAvatar:s,guestAvatar:m,userAvatarUrl:d,aiAvatarUrl:u,guestAvatarUrl:E}=e,p=(e,t,n,l,r=!1)=>{if(t){const e=((e,t=!1)=>(0,Va.mv)(e)?e:e&&!(0,ba.Ve)(e)?t?e:`${a}/images/${e}`:null)(n,r)||l;if(e)return{emoji:null,text:null,image:e,use:"image"}}return(0,ba.Ve)(e)?{emoji:e,text:null,image:null,use:"emoji"}:{emoji:null,text:e,image:null,use:"text"}};if("assistant"===t)return p(o,s,u,n);if(l){const e=function(e,t,a){return a&&0!==Object.keys(a).length?Object.entries(a).reduce(((e,[t,a])=>{const n=`{${t}}`;return e.includes(n)?e.replace(n,a):e}),e):t||e||"Guest"}(r,c,l);return p(e,i,d,null==l?void 0:l.AVATAR_URL,!0)}return l||"user"!==t?{emoji:null,text:"Unknown",image:null,use:"text"}:p(c||"Guest",m,E,null)}const Qn=()=>{const{state:e,actions:t}=(0,za.o)(),{busy:a,locked:n,open:l,popup:r}=e,{onStartRealtimeSession:o,onRealtimeFunctionCallback:c,onCommitStats:i,onCommitDiscussions:s}=t,[m,d]=Yn(!1),[u,E]=Yn(!1),[p,g]=Yn(!1),[R,h]=Yn(null),[y,b]=Yn(null),[v,f]=Yn({text_input_tokens:0,audio_input_tokens:0,text_output_tokens:0,audio_output_tokens:0,text_cached_tokens:0,audio_cached_tokens:0}),[_,w]=Yn([]),C=Wn(new Set),O=Wn(null),T=Wn(null),N=Wn(null),[I,M]=Yn(!0),[S,A]=Yn(!0),[k,x]=Yn(!1),[P,L]=Yn(!1),[D,F]=Yn(null),U=Wn([]),B=Vn((()=>Xn(e,"user")),[e]),G=Vn((()=>Xn(e,"assistant")),[e]);Kn((()=>{!l&&u&&r&&W()}),[l,r,u]);const H=zn((async e=>{await i(e)}),[i]),j=zn((()=>{T.current&&"open"===T.current.readyState?(T.current.send(JSON.stringify({type:"session.update",session:{input_audio_transcription:{model:"whisper-1"}}})),qn(1,"Sent session.update to enable Whisper.")):console.error("Data channel is not open yet; cannot enable transcription.")}),[]),$=zn((async(e,t,a)=>{let n={};try{n=JSON.parse(a||"{}")}catch(e){console.error("Could not parse function arguments.",a)}const l=U.current.find((e=>e.name===t));if(l)try{var r;const t=await c(l.id,l.type,l.name,l.target,n);if(null==t||!t.success)return void console.error("Callback failed.",null==t?void 0:t.message);const a=t.data;"open"===(null===(r=T.current)||void 0===r?void 0:r.readyState)&&(qn(1,"Send callback value:",a),T.current.send(JSON.stringify({type:"conversation.item.create",item:{type:"function_call_output",call_id:e,output:JSON.stringify(a)}})),T.current.send(JSON.stringify({type:"response.create",response:{instructions:"Reply based on the function's output."}})))}catch(e){console.error("Error in handleFunctionCall.",e)}else console.error(`No match for callback: '${t}'.`)}),[c]),Y=zn((async(e,t)=>{d(!0);const a=new RTCPeerConnection;let n;O.current=a;try{n=await navigator.mediaDevices.getUserMedia({audio:!0}),N.current=n,n.getTracks().forEach((e=>a.addTrack(e,n)))}catch(e){return console.error("Error accessing microphone.",e),void d(!1)}a.ontrack=e=>{const t=document.getElementById("mwai-audio");t&&(t.srcObject=e.streams[0]),F(e.streams[0])};const l=a.createDataChannel("oai-events");T.current=l,l.addEventListener("open",(()=>{qn(1,"Data channel open."),j()})),l.addEventListener("message",(e=>{let t;try{t=JSON.parse(e.data)}catch(t){return void console.error("Could not parse Realtime message.",e.data)}var a;switch(((null===(a=t.type)||void 0===a?void 0:a.endsWith(".done"))||"input_audio_buffer.committed"===t.type||"conversation.item.input_audio_transcription.completed"===t.type||"response.done"===t.type)&&console.log("Key event from Realtime API.",t),t.type){case"input_audio_buffer.committed":{const e=t.item_id;C.current.has(e)||(C.current.add(e),w((t=>[...t,{id:e,role:"user",content:"[Audio]"}]))),b("user");break}case"conversation.item.input_audio_transcription.completed":{const e=t.item_id,a=(t.transcript||"[Audio]").trim();w((t=>t.map((t=>t.id===e&&"user"===t.role?{...t,content:a}:t))));break}case"response.audio_transcript.done":{const e=t.item_id,a=(t.transcript||"[Audio]").trim();b("assistant"),C.current.has(e)||(C.current.add(e),w((t=>[...t,{id:e,role:"assistant",content:a}])));break}case"response.function_call_arguments.done":{const{call_id:e,name:a,arguments:n}=t;qn(1,"Function call requested.",e,a),$(e,a,n);break}case"response.done":{const e=t.response;if(null!=e&&e.usage){const t=function(e){if(!e)return null;const{input_token_details:{text_tokens:t=0,audio_tokens:a=0,cached_tokens_details:{text_tokens:n=0,audio_tokens:l=0}={}}={},output_token_details:{text_tokens:r=0,audio_tokens:o=0}={}}=e;return{text_input_tokens:t,audio_input_tokens:a,text_output_tokens:r,audio_output_tokens:o,text_cached_tokens:n,audio_cached_tokens:l}}(e.usage);t&&f((e=>{const a={text_input_tokens:(e.text_input_tokens||0)+t.text_input_tokens,audio_input_tokens:(e.audio_input_tokens||0)+t.audio_input_tokens,text_output_tokens:(e.text_output_tokens||0)+t.text_output_tokens,audio_output_tokens:(e.audio_output_tokens||0)+t.audio_output_tokens,text_cached_tokens:(e.text_cached_tokens||0)+t.text_cached_tokens,audio_cached_tokens:(e.audio_cached_tokens||0)+t.audio_cached_tokens};return H(a),a}))}b("user");break}}}));const r=await a.createOffer();await a.setLocalDescription(r);const o=t||"gpt-4o-preview-2024-12-17",c=await fetch(`https://api.openai.com/v1/realtime?model=${o}`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"},body:r.sdp});if(!c.ok)return console.error("SDP exchange failed.",c),void d(!1);const i=await c.text();await a.setRemoteDescription({type:"answer",sdp:i}),qn(1,"Realtime connection established."),d(!1),E(!0),g(!1),b("user")}),[j,$,H]),W=zn((()=>{try{O.current&&(O.current.close(),O.current=null),N.current&&(N.current.getTracks().forEach((e=>e.stop())),N.current=null),T.current=null,d(!1),E(!1),g(!1),b(null),console.log("Messages:",_),console.log("Statistics:",v),s(_),w([]),f({text_input_tokens:0,audio_input_tokens:0,text_output_tokens:0,audio_output_tokens:0,text_cached_tokens:0,audio_cached_tokens:0}),qn(1,"Stopped Realtime connection.")}catch(e){console.error("Error stopping connection.",e)}}),[_,v,s]),z=zn((()=>{if(!N.current)return;const e=N.current.getAudioTracks();e.length&&(p?(e.forEach((e=>{e.enabled=!0})),qn(1,"Resumed microphone."),g(!1)):(e.forEach((e=>{e.enabled=!1})),qn(1,"Paused microphone."),g(!0)))}),[p]),V=zn((async()=>{d(!0);try{const e=await o();if(null==e||!e.success)return console.error("Could not start realtime session.",e),void d(!1);U.current=e.function_callbacks||[],h(e.session_id),await Y(e.client_secret,e.model)}catch(e){console.error("Error in handlePlay.",e),d(!1)}}),[o,Y]),K=zn((()=>W()),[W]),q=zn((()=>A((e=>!e))),[]),X=zn((()=>L((e=>!e))),[]),Q=zn((()=>x((e=>!e))),[]),J=Vn((()=>p?"mwai-pause mwai-active":"mwai-pause"),[p]),Z=Vn((()=>{const e=[..._].reverse().find((e=>"assistant"===e.role));return e?e.content.length>256?`${e.content.slice(0,256)}...`:e.content:"..."}),[_]),ee=Vn((()=>S?"mwai-option mwai-option-users mwai-active":"mwai-option mwai-option-users"),[S]),te=Vn((()=>k?"mwai-option mwai-option-captions mwai-active":"mwai-option mwai-option-captions"),[k]),ae=Vn((()=>P?"mwai-option mwai-option-statistics mwai-active":"mwai-option mwai-option-statistics"),[P]);return React.createElement("div",null,React.createElement("audio",{id:"mwai-audio",autoPlay:!0}),S&&React.createElement("div",{style:{display:"flex",justifyContent:"center"}},React.createElement($n,{assistantStream:D,userUI:B,assistantUI:G,userStream:N.current})),React.createElement("div",{className:"mwai-controls"},!u&&!m&&React.createElement("button",{onClick:V,className:"mwai-play",disabled:a||n,"aria-label":"Play"},React.createElement(kn.A,{size:16})),m&&React.createElement("button",{className:"mwai-play",disabled:!0},React.createElement(xn.A,{size:16,style:{animation:"spin 0.8s linear infinite"}})),u&&!m&&React.createElement(React.Fragment,null,React.createElement("button",{onClick:K,className:"mwai-stop",disabled:a||n,"aria-label":"Stop"},React.createElement(Pn.A,{size:16})),React.createElement("button",{onClick:z,className:J,disabled:a||n,"aria-label":"Pause"},React.createElement(Ln.A,{size:16})))),k&&Z&&Z.length>0&&React.createElement("div",{className:"mwai-last-transcript"},Z),P&&React.createElement("div",{className:"mwai-statistics"},React.createElement("div",null,React.createElement("label",null,"Text In"),React.createElement("span",null,v.text_input_tokens)),React.createElement("div",null,React.createElement("label",null,"Text Out"),React.createElement("span",null,v.text_output_tokens)),React.createElement("div",null,React.createElement("label",null,"Text Cached"),React.createElement("span",null,v.text_cached_tokens)),React.createElement("div",null,React.createElement("label",null,"Audio In"),React.createElement("span",null,v.audio_input_tokens)),React.createElement("div",null,React.createElement("label",null,"Audio Out"),React.createElement("span",null,v.audio_output_tokens)),React.createElement("div",null,React.createElement("label",null,"Audio Cached"),React.createElement("span",null,v.audio_cached_tokens))),I&&React.createElement("div",{className:"mwai-options"},React.createElement(Dn.A,{size:13,title:"Show Users",className:ee,onClick:q}),React.createElement(Fn.A,{size:18,title:"Show Captions",className:te,onClick:Q}),React.createElement(Un.A,{size:14,title:"Show Statistics",className:ae,onClick:X})))},{useState:Jn,useMemo:Zn,useLayoutEffect:el,useCallback:tl,useEffect:al,useRef:nl}=wp.element,ll={overrides:{a:{props:{target:"_blank"}}}},rl=e=>{const t=(0,Va.gR)(),{style:a}=e,[n,l]=Jn(!0),{state:r,actions:o}=(0,za.o)(),{theme:c,botId:i,customId:s,messages:m,textCompliance:d,isWindow:u,fullscreen:E,iconPosition:p,iconBubble:g,shortcuts:R,blocks:h,imageUpload:y,fileSearch:b,fileUpload:v,draggingType:f,isBlocked:_,virtualKeyboardFix:w,isRealtime:C,windowed:O,cssVariables:T,error:N,conversationRef:I,open:M,busy:S,uploadIconPosition:A,chatbotInputRef:k}=r,{resetError:x,onSubmit:P,setIsBlocked:L,setDraggingType:D,onUploadFile:F}=o,U=Zn((()=>"css"===(null==c?void 0:c.type)?null==c?void 0:c.style:null),[c]),B=y||b||v,G=B||d,H=nl(null),{viewportHeight:j,isIOS:$,isAndroid:Y}=(0,Va.kW)();al((()=>{if(!w)return;if(!$&&!Y)return;if(!u)return;const e=document.querySelector(".mwai-window");e&&(M?(e.style.height=`${j}px`,$&&(()=>{if("INPUT"===document.activeElement.tagName||"TEXTAREA"===document.activeElement.tagName){window.scrollTo({top:0});const e=setInterval((()=>{window.scrollTo({top:0})}),100);setTimeout((()=>{clearInterval(e)}),1e3)}})()):e.style.height="")}),[E,Y,$,u,O,M,j,w]);const W=t("mwai-chatbot",{[`mwai-${null==c?void 0:c.themeId}-theme`]:!0,"mwai-window":u,"mwai-bubble":g,"mwai-open":M,"mwai-fullscreen":!O||!u&&E,"mwai-bottom-left":"bottom-left"===p,"mwai-top-right":"top-right"===p,"mwai-top-left":"top-left"===p});el((()=>{n&&I.current&&(I.current.scrollTop=I.current.scrollHeight)}),[m,n,I,S]);const z=nl(new Set);al((()=>{h&&h.length>0&&h.forEach((e=>{const{type:t,data:a}=e;"content"===t&&a.script&&(e=>{const t=(e=>{let t,a,n=0;if(0===e.length)return n;for(t=0;t<e.length;t++)a=e.charCodeAt(t),n=(n<<5)-n+a,n|=0;return n})(e);if(!z.current.has(t)){const a=document.createElement("script");a.type="text/javascript",a.textContent=e,document.body.appendChild(a),z.current.add(t)}})(a.script)}))}),[h]);const V=Zn((()=>null==m?void 0:m.map((e=>React.createElement(dn,{key:e.id,message:e})))),[m]),K=Zn((()=>R&&0!==R.length?React.createElement("div",{className:"mwai-shortcuts"},R.map(((e,a)=>{const{type:n,data:l}=e,{label:r,variant:o,icon:c,className:s}=l??{};let m=t("mwai-shortcut",{"mwai-success":"success"===o,"mwai-danger":"danger"===o,"mwai-warning":"warning"===o,"mwai-info":"info"===o});s&&(m+=` ${s}`);const d=c&&c.startsWith("http"),u=c&&!d&&c.length>=1&&c.length<=2;switch(n){case"message":{const{message:e}=l,t=()=>{P(e)};return React.createElement("button",{className:m,key:a,onClick:t},(d||u)&&React.createElement(React.Fragment,null,React.createElement("div",{className:"mwai-icon"},d&&React.createElement("img",{src:c,alt:r||"AI Shortcut"}),u&&React.createElement("span",{role:"img","aria-label":"AI Shortcut"},c)),React.createElement("div",{style:{flex:"auto"}})),React.createElement("div",{className:"mwai-label"},r||"N/A"))}case"callback":{const{onClick:e}=l,t=()=>{if("function"==typeof e)e();else if("string"==typeof e){const t=e.replace(/{CHATBOT_ID}/g,i),a=new Function(`return (${t});`)();l.onClick=a,a()}else console.warn("No valid callback function provided in data.onClick.")};return React.createElement("button",{className:m,key:a,onClick:t},(d||u)&&React.createElement(React.Fragment,null,React.createElement("div",{className:"mwai-icon"},d&&React.createElement("img",{src:c,alt:r||"AI Shortcut"}),u&&React.createElement("span",{role:"img","aria-label":"AI Shortcut"},c)),React.createElement("div",{style:{flex:"auto"}})),React.createElement("div",{className:"mwai-label"},r||"N/A"))}default:return console.warn(`This shortcut type is not supported: ${n}.`),null}}))):null),[t,P,R]),q=Zn((()=>h&&0!==h.length?React.createElement("div",{className:"mwai-blocks"},h.map(((e,a)=>{const{type:n,data:l}=e;if("content"!==n)return console.warn(`Block type ${n} is not supported.`),null;const{html:r,variant:o}=l,c=t("mwai-block",{"mwai-success":"success"===o,"mwai-danger":"danger"===o,"mwai-warning":"warning"===o,"mwai-info":"info"===o});return React.createElement("div",{className:c,key:a,dangerouslySetInnerHTML:{__html:r}})}))):null),[t,h]),X=tl(((e,t)=>{e.preventDefault(),e.stopPropagation();const a=e.dataTransfer.items[0];t?(H.current&&(clearTimeout(H.current),H.current=null),y&&(e=>e.type.startsWith("image/"))(a)?(D("image"),L(!1)):(b||v)&&(e=>["text/x-c","text/x-csharp","text/x-c++","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","text/javascript","application/x-sh","application/typescript"].includes(e.type))(a)?(D("document"),L(!1)):(D(!1),L(!0))):H.current||(H.current=setTimeout((()=>{D(!1),L(!1),H.current=null}),100))}),[y,b,v]),Q=tl((e=>{if(e.preventDefault(),X(e,!1),S)return;const t=e.dataTransfer.files[0];t&&("image"===f&&y||"document"===f&&(b||v)?F(t):(L(!0),setTimeout((()=>L(!1)),2e3)))}),[S,f,y,v,b,F]),J=t("mwai-input",{"mwai-dragging":f,"mwai-blocked":_});return React.createElement(Va.bE,{dir:"auto",id:`mwai-chatbot-${s||i}`,className:W,style:{...T,...a},if:!0,disableTransition:!u},U&&React.createElement("style",null,U),React.createElement(An,null),React.createElement(In,null),React.createElement("div",{className:"mwai-content"},!C&&React.createElement(React.Fragment,null,React.createElement("div",{ref:I,className:"mwai-conversation",onScroll:()=>{if(I.current){const{scrollTop:e,scrollHeight:t,clientHeight:a}=I.current;l(t-e<=a+1)}}},V,K),N&&React.createElement("div",{className:"mwai-error",onClick:()=>x()},React.createElement(Vt.Ay,{options:ll},N)),q,React.createElement("div",{className:J,onClick:()=>{var e;return null===(e=k.current)||void 0===e?void 0:e.focusInput()},onDrop:Q,onDragEnter:e=>X(e,!0),onDragLeave:e=>X(e,!1),onDragOver:e=>X(e,!0)},React.createElement(fn,null),React.createElement(Tn,null))),C&&React.createElement("div",{className:"mwai-realtime"},React.createElement(Qn,null)),G&&React.createElement("div",{className:"mwai-footer"},B&&React.createElement("div",{className:"mwai-tools"},"mwai-tools"===A&&React.createElement(Rn,null)),d&&React.createElement("div",{className:"mwai-compliance",dangerouslySetInnerHTML:{__html:d}}))))},ol=e=>React.createElement(za.G,e,React.createElement(rl,e)),{useMemo:cl,useState:il,useEffect:sl}=wp.element,ml=e=>{e?localStorage.setItem("mwai-admin-chatbotKey",e):localStorage.removeItem("mwai-admin-chatbotKey")},dl=e=>{const t=(0,l.jE)(),{options:a,updateOption:n,busy:c}=e,[i,s]=il("chatbots"),[m,d]=il(!1),[u,E]=il((()=>localStorage.getItem("mwai-admin-chatbotKey")||"chatbot-key-0")),h=null==a?void 0:a.chatbot_defaults,{colors:y}=(0,r.z)(),{data:b}=(0,o.I)({queryKey:["chatbots"],queryFn:nt,initialData:k}),{data:v}=(0,o.I)({queryKey:["themes"],queryFn:tt,initialData:S}),_=(null==a?void 0:a.botId)??"none",O=(null==a?void 0:a.chatbot_select)??"tabs",T=c||m,[I,x]=il({});sl((()=>{if(b){const e={};if(b.forEach(((t,a)=>{e[`chatbot-key-${a}`]=t.botId})),x(e),!u||!(u in e)){const t=Object.keys(e)[0];E(t),ml(t)}}}),[b,u]);const P=cl((()=>{if(b)return b.find((e=>"default"===e.botId))}),[b]),L=cl((()=>{if(b&&u&&I[u]){const e=I[u];return b.find((t=>t.botId===e))}return null}),[b,u,I]),D=cl((()=>v&&L?v.find((e=>e.themeId===(null==L?void 0:L.themeId))):v.find((e=>"chatgpt"===e.themeId))),[L,v]),F=async(e,a)=>{if("botId"===a&&"default"===e)return void alert("You cannot name a chatbot 'default'. Please choose another name.");if("botId"===a&&""===e)return void alert("Your chatbot must have an ID.");if("botId"===a&&b.find((t=>t.botId===e)))return void alert("This chatbot ID is already in use. Please choose another ID.");d(!0);const n={...L,[a]:e};let l=[...b];if(L){const r=l.findIndex((e=>e.botId===L.botId));-1!==r&&(l[r]=n,l=await lt(l),t.setQueryData(["chatbots"],l),"botId"===a&&x((t=>({...t,[u]:e}))))}d(!1)},U=async(e=h)=>{d(!0);const a="chatbot-"+Te(),n={...e,botId:a,name:"New Chatbot"};delete n.functions;const l=await lt([...b,n]);t.setQueryData(["chatbots"],l);const r=`chatbot-key-${Object.keys(I).length}`;x((e=>({...e,[r]:a}))),E(r),ml(r),d(!1)},B=async()=>{d(!0);const e=I[u],a=Object.keys(I),n=a.indexOf(u);let l;l=n>0?a[n-1]:a.length>1?a[n+1]:null,E(l),ml(l);let r=b.filter((t=>t.botId!==e));r=await lt(r),t.setQueryData(["chatbots"],r);const o={...I};delete o[u],x(o),d(!1)},G=async()=>{d(!0);let e=[...b];const a=e.findIndex((e=>e.botId===L.botId));e[a]={...h,botId:L.botId,name:L.name},e=await lt(e),t.setQueryData(["chatbots"],e),d(!1)},H=async()=>{U(L)};return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0,fullWidth:!0,style:{margin:10}},React.createElement(Ve.V,null,React.createElement(ya,{currentChatbot:L}),React.createElement("label",{style:{marginLeft:5}},Ee.COMMON.CHATBOTS),React.createElement(Ke.S,{style:{marginLeft:5},disabled:T,onLabel:"",offLabel:"",width:42,offValue:"chatbots",onValue:"themes",offBackgroundColor:y.blue,onBackgroundColor:y.purple,checked:"themes"===i,onChange:s}),React.createElement("label",{style:{marginLeft:5}},Ee.COMMON.THEMES),React.createElement("div",{style:{flex:"auto"}}),React.createElement("label",null,Ee.COMMON.SITE_WIDE_CHATBOT,":"),React.createElement(ee.u,{scrolldown:!0,name:"botId",disabled:T,style:{minWidth:160},value:_,onChange:n},React.createElement(ee.j,{value:"none",label:"None"}),null==b?void 0:b.map((e=>React.createElement(ee.j,{key:e.botId,value:e.botId,label:e.name})))))),React.createElement(p.Y,{minimal:!0,style:{margin:10,maxWidth:"50%"}},"chatbots"===i&&React.createElement(React.Fragment,null,"dropdown"===O&&React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex",alignItems:"center",marginBottom:10}},React.createElement(ee.u,{scrolldown:!0,textFiltering:!0,name:"botId",disabled:T,style:{flex:"auto",marginRight:10},value:u,onChange:E},null==b?void 0:b.map(((e,t)=>React.createElement(ee.j,{key:e.botId,value:`chatbot-key-${t}`,label:e.name})))),React.createElement(R.M,{rounded:!0,className:"secondary",icon:"plus",disabled:T,onClick:()=>U()})),L&&React.createElement(ne.L,{style:{borderRadius:10}},React.createElement(Ia,{style:{margin:"-10px -10px"},options:a,themes:v,defaultChatbot:P,deleteCurrentChatbot:B,resetCurrentChatbot:G,duplicateCurrentChatbot:H,shortcodeParams:L,updateShortcodeParams:F}))),"tabs"===O&&React.createElement(React.Fragment,null,React.createElement(g._,{inversed:!0,onChange:(e,t)=>{E(t.key),ml(t.key)},currentTab:u,action:React.createElement(R.M,{rounded:!0,className:"secondary",icon:"plus",disabled:T,onClick:()=>U()})},Object.entries(I).map((([e,t])=>{const n=b.find((e=>e.botId===t));return React.createElement(g.V,{key:e,title:n.name,busy:m},React.createElement(Ia,{options:a,themes:v,defaultChatbot:P,deleteCurrentChatbot:B,resetCurrentChatbot:G,duplicateCurrentChatbot:H,shortcodeParams:n,updateShortcodeParams:F}))}))))),"themes"===i&&React.createElement(Wa,{themes:v,options:a,updateOption:n,currentTheme:D,onSwitchTheme:e=>{F(e,"themeId")}})),React.createElement(p.Y,{minimal:!0,style:{maxWidth:"50%"}},React.createElement("small",{style:{marginLeft:15,marginBottom:-20}},"Chatbot: ",React.createElement("b",null,null==L?void 0:L.name)," - Theme: ",React.createElement("b",null,null==D?void 0:D.name)),React.createElement("div",{style:{position:"relative",margin:"5px 10px 10px 10px",minHeight:480,borderRadius:5,padding:10,border:"2px dashed rgb(0 0 0 / 20%)",background:"rgb(0 0 0 / 5%)"}},!!L&&React.createElement(ol,{system:{botId:L.botId,userData:C,sessionId:M,restNonce:N,pluginUrl:w,restUrl:f,stream:A,debugMode:null==a?void 0:a.debug_mode,typewriter:null==a?void 0:a.chatbot_typewriter,speech_recognition:null==a?void 0:a.shortcode_chat_speech_recognition,speech_synthesis:null==a?void 0:a.shortcode_chat_speech_synthesis},params:L,theme:D,style:L.window||L.fullscreen?{position:"absolute"}:{}})),React.createElement("div",{style:{marginLeft:10,fontSize:11,lineHeight:"140%",opacity:.5}},"This is the actual chatbot, but there might be some differences when run on your front-end, depending on your theme and the other plugins you use."))))};var ul=a(421);const{useMemo:El,useState:pl,useEffect:gl}=wp.element,Rl=[{accessor:"id",visible:!1},{accessor:"time",title:"Time",width:"80px",sortable:!0},{accessor:"user",title:"User",width:"85px",filters:{type:"text",description:"Type a User ID, or an IP."}},{accessor:"scope",title:"Scope",width:"90px",filters:{type:"checkbox",options:[{value:"chatbot",label:"Chatbot"},{value:"form",label:"Form"},{value:"playground",label:"Playground"}]}},{accessor:"model",title:"Model"},{accessor:"units",title:"Units",width:"65px",align:"right",sortable:!0},{accessor:"price",title:"Price",width:"85px",align:"right",sortable:!0}],hl=async(e=[])=>await(0,y.IU)(`${_}/system/logs/delete`,{nonce:N,method:"POST",json:{logIds:e}}),yl=({selectedLogIds:e,setSelectedLogIds:t,onDataFetched:a})=>{const n=(0,l.jE)(),[r,c]=pl(!1),{getModelName:i}=ve(I,null,!0),[s,m]=pl((()=>Rl.filter((e=>e.filters)).map((e=>({accessor:e.accessor,value:[]}))))),[d,u]=pl({filters:s,sort:{accessor:"time",by:"desc"},page:1,limit:20}),{isFetching:E,data:p,error:g}=(0,o.I)({queryKey:["logs",d],queryFn:()=>(async e=>{e.offset=(e.page-1)*e.limit;const t=await(0,y.IU)(`${_}/system/logs/list`,{nonce:N,method:"POST",json:e});return t?{total:t.total,logs:t.logs}:{total:0,logs:[]}})(d)});gl((()=>{u({...d,filters:s})}),[s]),gl((()=>{null!=p&&p.logs&&a&&a(p.logs)}),[null==p?void 0:p.logs,a]);const b=El((()=>(null==p?void 0:p.total)||0),[p]),v=El((()=>null!=p&&p.logs?p.logs.sort(((e,t)=>t.created_at-e.created_at)).map((e=>{var t;const a=Ce(e.time),n=Oe(e.userId,e.ip),l=Math.round(1e3*e.price)/1e3;let r=React.createElement(React.Fragment,null,"∞");e.price>=.001&&(r=React.createElement("b",null,"$",l.toFixed(3))),e.price>=.01&&(r=React.createElement("b",null,"$",l.toFixed(2))),e.price>=.1&&(r=React.createElement("b",{style:{color:"red"}},"$",l.toFixed(2)));const o=(null==I||null===(t=I.ai_envs)||void 0===t||null===(t=t.find((t=>t.id===e.envId)))||void 0===t?void 0:t.name)||e.envId,c=React.createElement("div",null,React.createElement("span",{title:e.model},i(e.model),"assistant"===e.mode&&React.createElement("i",null," (Assistant)")),React.createElement("br",null),React.createElement("small",null,o));return{id:e.id,scope:React.createElement("div",null,e.scope,React.createElement("br",null),React.createElement("small",null,e.session)),user:n,model:c,units:React.createElement("div",{style:{textAlign:"right"}},e.units,React.createElement("br",null),React.createElement("small",null,e.type)),price:React.createElement(React.Fragment,null,r,React.createElement("br",null),React.createElement("small",null,"$",e.price)),time:React.createElement("div",{style:{textAlign:"right"}},a)}})):[]),[p]),f=async()=>{if(c(!0),e.length)await hl(e),t([]);else{if(!window.confirm(Ee.ALERTS.ARE_YOU_SURE))return void c(!1);await hl()}await n.invalidateQueries({queryKey:["logs"]}),await n.refetchQueries({queryKey:["logs"]}),c(!1)},w=El((()=>null!=g&&g.message?React.createElement(oe.X,{variant:"danger",style:{margin:"5px 5px"}},React.createElement("b",null,g.message),React.createElement("br",null),React.createElement("small",null,"Check your Console Logs and PHP Error Logs for more information.")):null),[g]);return React.createElement(React.Fragment,null,React.createElement(h.z,{className:"primary",title:Ee.COMMON.QUERIES,action:React.createElement("div",null,React.createElement(R.M,{className:"secondary",style:{marginLeft:5},disabled:E,onClick:async()=>{await n.invalidateQueries({queryKey:["logs"]}),n.refetchQueries({queryKey:["logs"]})}},Ee.COMMON.REFRESH),e.length>0&&React.createElement(R.M,{className:"danger",onClick:f},Ee.COMMON.DELETE))},React.createElement(ze.o,{busy:E||r,onSelectRow:a=>{1===e.length&&e[0]===a?t([]):t([a])},onSelect:a=>{t([...e,...a])},onUnselect:a=>{t(e.filter((e=>!a.includes(e))))},selectedItems:e,sort:d.sort,onSortChange:(e,t)=>{u({...d,sort:{accessor:e,by:t}})},emptyMessage:w,filters:s,onFilterChange:(e,t)=>{const a=[...s.filter((t=>t.accessor!==e)),{accessor:e,value:t}];m(a)},data:v,columns:Rl}),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginTop:10,marginBottom:-5}},React.createElement(R.M,{className:"danger",disabled:e.length>0,onClick:f},Ee.COMMON.DELETE_ALL),React.createElement("div",{style:{flex:"auto"}}),React.createElement(Xe.Q,{currentPage:d.page,limit:d.limit,onCurrentPageChanged:e=>u({...d,page:e}),total:b,onClick:e=>u({...d,page:e})}))),React.createElement(h.z,{className:"primary",title:"Information"},React.createElement("p",null,React.createElement("b",null,"Prices and tokens counts aren't accurate in many cases.")),React.createElement("p",null,"For more information, check this:"," ",React.createElement("a",{href:"https://www.notion.so/meowarts/Cost-Usage-Calculation-d5ce4917d77f4939b232b20d0082368a?pvs=4",target:"_blank",rel:"noreferrer"},"Cost & Usage Calculation"),". You are also always welcome to discuss about it in the"," ",React.createElement("a",{href:"https://discord.gg/bHDGh38",target:"_blank",rel:"noreferrer"},"Discord Server"),".")))},{useMemo:bl,useState:vl}=wp.element,fl=({options:e,updateOption:t,busy:a})=>{var n;const[l,r]=vl([]),[c,i]=vl([]),[s,m]=vl("users"),u=null==e?void 0:e.limits,E=null==e?void 0:e.default_limits,b=bl((()=>1===c.length?c[0]:null),[c]),v=bl((()=>{const e=l.find((e=>e.id===b));if(e&&e.stats&&"string"==typeof e.stats)try{e.stats=JSON.parse(e.stats)}catch(t){e.stats={}}return e}),[l,b]),{isFetching:f,data:w}=(0,o.I)({queryKey:["logsMeta",b],queryFn:()=>(async e=>e?(await(0,y.IU)(`${_}/system/logs/meta`,{nonce:N,method:"POST",json:{logId:e,metaKeys:["query","reply","fields"]}})).data:null)(b),enabled:!!b,staleTime:864e5}),C=bl((()=>null!=u&&u[s]?u[s]:{credits:1,creditType:"price",timeFrame:"month",isAbsolute:!1,overLimitMessage:"You have reached the limit.",ignoredUsers:""}),[u,s]),O=async(e,a)=>{"credits"===a&&(e=Math.max(0,e));const n={...C,[a]:e},l={...u,[s]:n};await t(l,"limits")},T=bl((()=>Array.isArray(w)?null:w),[w]);return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0,style:{flex:2.5}},React.createElement(yl,{selectedLogIds:c,setSelectedLogIds:i,onDataFetched:r})),React.createElement(p.Y,{minimal:!0},b&&React.createElement(React.Fragment,null,React.createElement(ae.g,{large:!0}),React.createElement(g._,{inversed:!0,style:{marginRight:10,marginLeft:10}},React.createElement(g.V,{title:"Query"},React.createElement("div",{style:{height:380,overflow:"auto",maxHeight:380}},f&&React.createElement("i",{style:{color:"gray"}},"Loading..."),!f&&!T&&React.createElement("i",{style:{color:"gray"}},Ee.COMMON.DATA_NOT_AVAILABLE),!f&&T&&React.createElement(ul.p2,{value:T.query,rootName:"query",indentWidth:2,displayDataTypes:!1,displayObjectSize:!1,displayArrayKey:!1,enableClipboard:!1,style:{fontSize:12}}))),React.createElement(g.V,{title:"Reply"},React.createElement("div",{style:{height:380,overflow:"auto",maxHeight:380}},f&&React.createElement("i",{style:{color:"gray"}},"Loading..."),!f&&!T&&React.createElement("i",{style:{color:"gray"}},Ee.COMMON.DATA_NOT_AVAILABLE),!f&&T&&React.createElement(ul.p2,{value:T.reply,rootName:"reply",indentWidth:2,displayDataTypes:!1,displayObjectSize:!1,displayArrayKey:!1,enableClipboard:!1,style:{fontSize:12}}))),T&&T.fields&&React.createElement(g.V,{title:"Fields"},React.createElement("div",{style:{height:380,overflow:"auto",maxHeight:380}},f&&React.createElement("i",{style:{color:"gray"}},"Loading..."),!f&&!T&&React.createElement("i",{style:{color:"gray"}},Ee.COMMON.DATA_NOT_AVAILABLE),!f&&T&&React.createElement(ul.p2,{value:T.fields,rootName:"fields",indentWidth:2,displayDataTypes:!1,displayObjectSize:!1,displayArrayKey:!1,enableClipboard:!1,style:{fontSize:12}}))),(null==v?void 0:v.stats)&&React.createElement(g.V,{title:"Stats"},React.createElement("div",{style:{height:380,overflow:"auto",maxHeight:380}},React.createElement(ul.p2,{value:v.stats,rootName:"stats",indentWidth:2,displayDataTypes:!1,displayObjectSize:!1,displayArrayKey:!1,enableClipboard:!1,style:{fontSize:12}}))))),React.createElement(da,null,React.createElement(h.z,{className:"primary",busy:a,title:"Limits",style:{flex:1}},React.createElement(d.R,{name:"enabled",label:Ee.STATISTICS.ENABLE_LIMITS,checked:null==u?void 0:u.enabled,value:"1",onChange:async(e,a)=>{const n={...u,[a]:e};await t(n,"limits")}}),(null==u?void 0:u.enabled)&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(We.o,{value:s,busy:a,onChange:e=>m(e)},React.createElement(We.K,{title:Ee.COMMON.USERS,value:"users",disabled:!(null!=u&&u.enabled)}),React.createElement(We.K,{title:Ee.COMMON.GUESTS,value:"guests"}),React.createElement(We.K,{title:Ee.COMMON.SYSTEM,value:"system"})),"userId"===(null==u?void 0:u.target)&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Message for Guests:"),React.createElement(te.A,{id:"guestMessage",name:"guestMessage",disabled:!(null!=u&&u.enabled),value:null==u?void 0:u.guestMessage,onEnter:O,onBlur:O}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.CREDITS,":"),React.createElement(te.A,{id:"credits",name:"credits",type:"number",min:"0",max:"1000000",disabled:!(null!=u&&u.enabled),value:C.credits,onEnter:O,onBlur:O})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.TYPE,":"),React.createElement(ee.u,{scrolldown:!0,id:"creditType",name:"creditType",disabled:!(null!=u&&u.enabled),value:C.creditType,onChange:O},React.createElement(ee.j,{key:"queries",id:"queries",value:"queries",label:"Queries"}),React.createElement(ee.j,{key:"units",id:"units",value:"units",label:"Tokens"}),React.createElement(ee.j,{key:"price",id:"price",value:"price",label:"Dollars"})))),0!==C.credits&&React.createElement("p",null,"If you want to apply variable amount of credits,"," ",React.createElement("a",{href:"https://meowapps.com/ai-engine/faq/#limits",target:"_blank",rel:"noreferrer"},"click here"),"."),0!==C.credits&&"price"===C.creditType&&React.createElement("p",null,"The dollars represent the budget you spent through OpenAI."),0===C.credits&&React.createElement("p",null,"Since there are no credits, the Message for No Credits Message will be displayed."),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.TIMEFRAME,":"),React.createElement(ee.u,{scrolldown:!0,id:"timeFrame",name:"timeFrame",disabled:!(null!=u&&u.enabled),value:C.timeFrame,onChange:O},React.createElement(ee.j,{key:"second",id:"second",value:"second",label:"Second"}),React.createElement(ee.j,{key:"minute",id:"minute",value:"minute",label:"Minute"}),React.createElement(ee.j,{key:"hour",id:"hour",value:"hour",label:"Hour"}),React.createElement(ee.j,{key:"day",id:"day",value:"day",label:"Day"}),React.createElement(ee.j,{key:"week",id:"week",value:"week",label:"Week"}),React.createElement(ee.j,{key:"month",id:"month",value:"month",label:"Month"}),React.createElement(ee.j,{key:"year",id:"year",value:"year",label:"Year"}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.COMMON.ABSOLUTE,":"),React.createElement(d.R,{name:"isAbsolute",label:"Yes",disabled:!(null!=u&&u.enabled),checked:C.isAbsolute,value:"1",onChange:O}))),C.isAbsolute&&React.createElement("p",null,(0,y.FE)(Ee.STATISTICS.ABSOLUTE_HELP)),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.STATISTICS.NO_CREDITS_MESSAGE,":"),React.createElement(te.A,{id:"overLimitMessage",name:"overLimitMessage",disabled:!(null!=u&&u.enabled),value:C.overLimitMessage,onEnter:O,onBlur:O}))),"users"===s&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ee.STATISTICS.FULL_ACCESS_USERS,":"),React.createElement(ee.u,{scrolldown:!0,id:"ignoredUsers",name:"ignoredUsers",disabled:!(null!=u&&u.enabled),value:null==u||null===(n=u.users)||void 0===n?void 0:n.ignoredUsers,description:"",onChange:O},React.createElement(ee.j,{key:"none",id:"none",value:"",label:Ee.COMMON.NONE}),React.createElement(ee.j,{key:"editor",id:"editor",value:"administrator,editor",label:Ee.COMMON.EDITORS_ADMINS}),React.createElement(ee.j,{key:"admin",id:"admin",value:"administrator",label:Ee.COMMON.ADMINS_ONLY})))),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,className:"danger",onClick:async()=>{confirm(Ee.ALERTS.ARE_YOU_SURE)&&await t(E,"limits")}},Ee.COMMON.RESET_LIMITS)))))))};var _l=a(7392);const wl=({options:e,updateOption:t,setOptions:a})=>{const n=null==e?void 0:e.debug_mode,l=null==e?void 0:e.module_mcp,r=null==e?void 0:e.server_debug_mode,o=React.createElement(s.d,{title:Ee.COMMON.CLIENT_DEBUG},React.createElement(d.R,{name:"debug_mode",label:Ee.COMMON.ENABLE,value:"1",checked:n,description:Ee.COMMON.CLIENT_DEBUG_HELP,onChange:t})),c=React.createElement(s.d,{title:Ee.COMMON.SERVER_DEBUG},React.createElement(d.R,{name:"server_debug_mode",label:Ee.COMMON.ENABLE,value:"1",checked:r,description:Ee.COMMON.SERVER_DEBUG_HELP,onChange:t})),i=React.createElement(s.d,{title:"SSE Endpoint"},React.createElement(d.R,{name:"module_mcp",label:Ee.COMMON.ENABLE,value:"1",checked:l,description:"Enable the /wp-json/mcp/v1/sse endpoint. Check the labs/mcp.md for more information.",onChange:t})),m=React.createElement(s.d,{title:Ee.COMMON.BEARER_TOKEN},React.createElement(te.A,{name:"mcp_bearer_token",value:null==e?void 0:e.mcp_bearer_token,description:(0,y.FE)(Ee.HELP.MCP_BEARER_TOKEN),onBlur:t}));return React.createElement(React.Fragment,null,React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{title:"Debugging",className:"primary"},React.createElement(R.M,{onClick:async()=>{const e=prompt("Enter the Post ID you want to retrieve the content from.");if(!e)return;const t=await(async(e,t=0,a=0,n="publish")=>await(0,y.IU)(`${_}/helpers/post_content?postType=${e}&postStatus=${n}&offset=${t}&postId=${a}`,{nonce:N}))(null,null,e);if(console.log(`Data for Post ID ${e}`,t),null!=t&&t.content){const e=t.content.trim().replace(/<[^>]*>?/gm,""),a=e.split(" ")[0],n=e.split(" ").pop();console.log(`Content First Word: ${a}`),console.log(`Content Last Word: ${n}`)}}},"Get Content"),React.createElement("p",null,"This button will display the content of the post, as seen by AI Engine, in your Developer Tools Console. That allows you to check what AI Engine uses when using Content Aware, Embeddings Sync, etc."),React.createElement(R.M,{onClick:async()=>{await(async()=>await(0,y.IU)(`${_}/helpers/run_tasks`,{nonce:N,method:"POST"}))()}},"Run Tasks"),React.createElement("p",null,"This button will force the AI Engine to run the tasks. Normally, the AI Engine runs the tasks every 10 minutes. This button will force the AI Engine to run the tasks immediately.")),React.createElement(h.z,{title:"Model Context Protocol (MCP)",className:"primary"},React.createElement("p",null,"Check the tutorial ",React.createElement("a",{href:"https://meowapps.com/claude-wordpress-mcp/",target:"_blank",rel:"noopener noreferrer"},"here")," for more information about MCP and how to use it with AI Engine. The Pro version of AI Engine adds theme support, allowing Claude (or other agents) to fork, create, and modify WordPress themes directly."),i,m)),React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{title:"Settings",className:"primary"},o,c),r&&React.createElement(_l.k,{refreshQuery:ot,clearQuery:ct,i18n:Ee}))))},{useMemo:Cl}=wp.element,Ol=({env:e,updateEnvironment:t,deleteEnvironment:a,ai_envs:n,options:l})=>{const{embeddingsModels:r}=ve(l,null==e?void 0:e.ai_embeddings_env),o=Cl((()=>r.find((t=>t.model===e.ai_embeddings_model))),[r,e.ai_embeddings_model]),c=Cl((()=>(o&&!o.dimensions&&console.error("This embeddings model does not have dimensions:",o),(null==o?void 0:o.dimensions)||[])),[o]);return React.createElement(React.Fragment,null,React.createElement(s.d,{title:Ee.COMMON.NAME},React.createElement(te.A,{name:"name",value:e.name,onFinalChange:a=>t(e.id,{name:a})})),React.createElement(s.d,{title:Ee.COMMON.TYPE},React.createElement(ee.u,{scrolldown:!0,name:"type",value:e.type,description:"qdrant"===e.type?(0,y.FE)(Ee.HELP.QDRANT):null,onChange:a=>t(e.id,{type:a})},React.createElement(ee.j,{value:"pinecone",label:"Pinecone"}),React.createElement(ee.j,{value:"qdrant",label:"Qdrant"}))),React.createElement(s.d,{title:Ee.COMMON.API_KEY},React.createElement(te.A,{name:"apikey",value:e.apikey,description:(0,y.FE)("pinecone"===e.type?Ee.COMMON.PINECONE_APIKEY_HELP:Ee.COMMON.QDRANT_APIKEY_HELP),onFinalChange:a=>t(e.id,{apikey:a})})),React.createElement(s.d,{title:Ee.COMMON.SERVER},React.createElement(te.A,{name:"server",value:e.server,description:(0,y.FE)("qdrant"===e.type?Ee.COMMON.QDRANT_SERVER_HELP:Ee.COMMON.PINECONE_SERVER_HELP),onFinalChange:a=>t(e.id,{server:a})})),"pinecone"===e.type&&React.createElement(React.Fragment,null,React.createElement(s.d,{title:Ee.COMMON.NAMESPACE},React.createElement(te.A,{name:"namespace",value:e.namespace,description:(0,y.FE)(Ee.COMMON.PINECONE_NAMESPACE_HELP),onFinalChange:a=>t(e.id,{namespace:a})}))),"qdrant"===e.type&&React.createElement(React.Fragment,null,React.createElement(s.d,{title:Ee.COMMON.QDRANT_COLLECTION},React.createElement(te.A,{name:"collection",value:e.collection,description:(0,y.FE)(Ee.COMMON.QDRANT_COLLECTION_HELP),onFinalChange:a=>t(e.id,{collection:a})}))),React.createElement(s.d,{title:Ee.COMMON.MIN_SCORE},React.createElement(te.A,{name:"min_score",value:e.min_score||35,type:"number",min:"0",max:"100",step:"1",description:(0,y.FE)(Ee.HELP.MIN_SCORE),onFinalChange:a=>t(e.id,{min_score:a})})),React.createElement(s.d,{title:Ee.COMMON.MAX_SELECT},React.createElement(te.A,{name:"max_select",value:e.max_select||10,type:"number",min:"1",max:"100",step:"1",description:(0,y.FE)(Ee.HELP.MAX_SELECT),onFinalChange:a=>t(e.id,{max_select:a})})),React.createElement(le.a,{keepState:"embeddingsEnvs"},React.createElement(le.Y,{title:Ee.COMMON.AI_ENVIRONMENT},React.createElement("div",{style:{marginTop:10}},React.createElement(s.d,{title:Ee.COMMON.OVERRIDE_DEFAULTS},React.createElement(d.R,{label:Ee.COMMON.ENABLE,value:"1",checked:null==e?void 0:e.ai_embeddings_override,onChange:a=>t(e.id,{ai_embeddings_override:a})})),(null==e?void 0:e.ai_embeddings_override)&&React.createElement(React.Fragment,null,React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_embeddings_env",value:null==e?void 0:e.ai_embeddings_env,onChange:a=>t(e.id,{ai_embeddings_env:a})},n.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))))),React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_embeddings_model",value:e.ai_embeddings_model,onChange:a=>t(e.id,{ai_embeddings_model:a})},r.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),React.createElement(s.d,{title:Ee.COMMON.DIMENSIONS},React.createElement(ee.u,{scrolldown:!0,name:"ai_embeddings_dimensions",value:e.ai_embeddings_dimensions||null,onChange:a=>t(e.id,{ai_embeddings_dimensions:a})},c.map(((e,t)=>React.createElement(ee.j,{key:e,value:e,label:t===c.length-1?`${e} (Default)`:e}))),React.createElement(ee.j,{key:null,value:null,label:"Not Set"})))))),React.createElement(le.Y,{title:Ee.COMMON.ACTIONS},React.createElement("div",{style:{display:"flex",marginTop:10}},React.createElement("div",{style:{flex:"auto"}}),React.createElement(R.M,{className:"danger",onClick:()=>a(e.id)},Ee.COMMON.DELETE)))))},Tl=function({environments:e,updateEnvironment:t,updateOption:a,options:n,busy:l}){const r=t=>{if(1===e.length)return void alert("You can't delete the last environment.");const n=e.filter((e=>e.id!==t));a(n,"embeddings_envs")};return React.createElement("div",{style:{padding:"0px 10px 20px 10px",marginTop:-5}},React.createElement(i.s,{h2:!0,style:{color:"white"}},"Environments for Embeddings"),React.createElement(g._,{inversed:!0,keepTabOnReload:!0,style:{marginTop:-5},action:React.createElement(R.M,{rounded:!0,className:"secondary",icon:"plus",onClick:()=>{const t=[...e,{name:"New Environment",type:"pinecone",apikey:"",server:"",indexes:[],namespaces:[]}];a(t,"embeddings_envs")}})},e.map((e=>React.createElement(g.V,{key:e.id,title:e.name,busy:l},React.createElement(Ol,{env:e,updateEnvironment:t,deleteEnvironment:r,ai_envs:(null==n?void 0:n.ai_envs)||[],options:n}))))))},{useCallback:Nl,useMemo:Il,useState:Ml}=wp.element,Sl=({updateEnvironment:e,environmentId:t,deployments:a,options:n})=>{const l=(n,l,r)=>{const o=JSON.parse((0,y.F1)(a));o[n][l]=r,e(t,{deployments:o})},r=Il((()=>{var e;const t=null==n||null===(e=n.ai_engines)||void 0===e?void 0:e.find((e=>"openai"===e.type));return(null==t?void 0:t.models)??[]}),[n]);return React.createElement(s.d,{title:Ee.COMMON.OPENAI_AZURE_DEPLOYMENTS,style:{marginTop:10}},a.map(((n,o)=>React.createElement("div",{key:o,style:{display:"flex",marginBottom:10}},React.createElement(te.A,{style:{flex:1},value:n.name,placeholder:Ee.COMMON.OPENAI_AZURE_DEPLOYMENT_NAME,onBlur:e=>l(o,"name",e),onEnter:e=>l(o,"name",e)}),React.createElement(ee.u,{style:{flex:1,marginLeft:10},scrolldown:!0,id:"model",name:"model",value:n.model,onChange:e=>l(o,"model",e)},r.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name})))),React.createElement(R.M,{rounded:!0,isSmall:!0,style:{marginLeft:10,height:30},icon:"trash",onClick:()=>(n=>{const l=[...a];l.splice(n,1),e(t,{deployments:l})})(o)})))),React.createElement(R.M,{fullWidth:!0,icon:"plus",onClick:()=>{const n=[...a,{name:"",model:""}];e(t,{deployments:n})}}))},Al=({updateEnvironment:e,environmentId:t,customModels:a})=>{const n=(n,l,r)=>{const o=JSON.parse((0,y.F1)(a));o[n][l]=r,e(t,{customModels:o})};return React.createElement(s.d,{title:Ee.COMMON.HUGGINGFACE_MODELS,style:{marginTop:10}},a.map(((l,r)=>{var o,c;return React.createElement("div",{key:r,style:{display:"flex",flexDirection:"column",marginBottom:10}},React.createElement("div",{key:r,style:{display:"flex",marginBottom:2}},React.createElement(te.A,{style:{flex:1},value:l.name,placeholder:Ee.COMMON.HUGGINGFACE_MODEL_NAME,onBlur:e=>n(r,"name",e),onEnter:e=>n(r,"name",e)}),React.createElement(te.A,{style:{flex:2,marginLeft:5},value:l.apiUrl,placeholder:Ee.COMMON.HUGGINGFACE_MODEL_URL,onBlur:e=>n(r,"apiUrl",e),onEnter:e=>n(r,"apiUrl",e)}),React.createElement(R.M,{rounded:!0,isSmall:!0,style:{marginLeft:5,height:30},icon:"trash",onClick:()=>(n=>{const l=[...a];l.splice(n,1),e(t,{customModels:l})})(r)})),React.createElement("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"}},React.createElement("span",{style:{marginRight:5}},"Image Model"),React.createElement(d.R,{style:{marginTop:r?0:5,marginRight:10},disabled:!0,checked:null===(o=l.tags)||void 0===o?void 0:o.includes("image"),onChange:n=>{const l=JSON.parse((0,y.F1)(a));l[r].tags||(l[r].tags=["core","chat"]),n?l[r].tags.push("image"):l[r].tags=l[r].tags.filter((e=>"image"!==e)),e(t,{customModels:l})}}),React.createElement("span",{style:{marginRight:5}},"Vision Model"),React.createElement(d.R,{style:{marginTop:r?0:5,marginRight:33},disabled:!0,checked:null===(c=l.tags)||void 0===c?void 0:c.includes("vision"),onChange:n=>{const l=JSON.parse((0,y.F1)(a));l[r].tags||(l[r].tags=["core","chat"]),n?l[r].tags.push("vision"):l[r].tags=l[r].tags.filter((e=>"vision"!==e)),e(t,{customModels:l})}})))})),React.createElement(R.M,{fullWidth:!0,icon:"plus",onClick:()=>{const n=[...a,{name:"",apiUrl:"",tags:["core","chat"]}];e(t,{customModels:n})}}))},kl=function({options:e,environments:t,updateEnvironment:a,updateOption:n,busy:l}){const[r,o]=Ml(!1),c=(null==e?void 0:e.ai_engines)??[],m=Nl((e=>{switch(e.type){case"openai":return(0,y.FE)(Ee.HELP.OPENAI_API_KEY);case"azure":return(0,y.FE)(Ee.HELP.AZURE_API_KEY);case"openrouter":return(0,y.FE)(Ee.HELP.OPENROUTER_API_KEY);case"anthropic":return(0,y.FE)(Ee.HELP.ANTHROPIC_API_KEY);default:return""}}),[]),d=Nl((async(t,a)=>{try{o(!0);const l=await(0,y.IU)(`${_}/ai/models`,{method:"POST",nonce:N,json:{envId:t}});o(!1);let r=null==l?void 0:l.models;if(!r)throw new Error("Could not fetch models.");r=r.map((e=>({...e,envId:t,type:a})));let c=(null==e?void 0:e.ai_models)??[];c=c.filter((e=>!(e.type===a&&(!e.envId||e.envId===t)))),c.push(...r),n(c,"ai_models")}catch(e){alert(e.message),console.log(e),o(!1)}}),[n]);return React.createElement("div",{style:{padding:"0px 10px 5px 10px",marginTop:13,marginBottom:5}},React.createElement(i.s,{h2:!0,style:{color:"white",marginBottom:15}},Ee.COMMON.ENVIRONMENTS_FOR_AI),React.createElement(g._,{inversed:!0,style:{marginTop:-5},action:React.createElement(R.M,{rounded:!0,className:"secondary",icon:"plus",onClick:()=>{const e=[...t,{name:"New Environment",type:"openai",apikey:""}];n(e,"ai_envs")}})},t.map((o=>{var i;let u=0;const E=c.find((e=>e.type===o.type))||{},p=null===(i=E.inputs)||void 0===i?void 0:i.includes("dynamicModels");return Array.isArray(E.models)&&(u=E.models.length),React.createElement(g.V,{key:o.id,title:o.name,busy:l},React.createElement(s.d,{title:Ee.COMMON.NAME},React.createElement(te.A,{name:"name",value:o.name,onFinalChange:e=>a(o.id,{name:e})})),React.createElement(s.d,{title:Ee.COMMON.TYPE},React.createElement(ee.u,{scrolldown:!0,name:"type",value:o.type,onChange:e=>a(o.id,{type:e})},c.map((e=>React.createElement(ee.j,{key:e.type,value:e.type,label:e.name}))))),(e=>{const t=(c.find((t=>t.type===e.type))||{}).inputs||[];return React.createElement(React.Fragment,null,t.includes("apikey")&&React.createElement(s.d,{title:Ee.COMMON.API_KEY},React.createElement(te.A,{name:"apikey",value:e.apikey,description:m(e),onFinalChange:t=>a(e.id,{apikey:t})})),t.includes("organizationId")&&React.createElement(s.d,{title:Ee.COMMON.OPENAI_ORGANIZATION_ID},React.createElement(te.A,{name:"organizationId",value:e.organizationId,description:(0,y.FE)(Ee.HELP.OPENAI_ORGANIZATION_ID),onFinalChange:t=>a(e.id,{organizationId:t})})),t.includes("endpoint")&&React.createElement(s.d,{title:Ee.COMMON.ENDPOINT},React.createElement(te.A,{name:"endpoint",value:e.endpoint,onFinalChange:t=>a(e.id,{endpoint:t})})),t.includes("region")&&React.createElement(s.d,{title:Ee.COMMON.REGION},React.createElement(te.A,{name:"region",value:e.region,onFinalChange:t=>a(e.id,{region:t})})),t.includes("projectId")&&React.createElement(s.d,{title:Ee.COMMON.PROJECT_ID},React.createElement(te.A,{name:"projectId",value:e.projectId,onFinalChange:t=>a(e.id,{projectId:t})})))})(o),"google"===o.type&&React.createElement(React.Fragment,null,React.createElement(oe.X,{variant:"danger"},"Click ",React.createElement("a",{href:"https://aistudio.google.com/app/apikey",target:"_blank",rel:"noreferrer"},"here")," to access your Google AI. As of 2025, Gemini is still unstable, so if you encounter issues, let's discuss them on ",React.createElement("a",{href:"https://discord.gg/bHDGh38",target:"_blank",rel:"noreferrer"},"Discord"),". Sorry, we will not be able to provide 1-1 support for this."),React.createElement(ae.g,null)),"huggingface"===o.type&&React.createElement(React.Fragment,null,React.createElement(oe.X,{variant:"danger"},"Support for Hugging Face is experimental and may not work as expected. Also, AI Engine is ready for Image and Vision but Hugging Face is not (hence the disabled checkboxes). Let's discuss about Hugging Face on ",React.createElement("a",{href:"https://discord.gg/bHDGh38",target:"_blank",rel:"noreferrer"},"Discord"),"."),React.createElement(ae.g,null)),"perplexity"===o.type&&(""===o.apikey||!o.apikey)&&React.createElement(React.Fragment,null,React.createElement(oe.X,{variant:"warning"},"Perplexity.ai is a paid service. Click ",React.createElement("a",{href:"https://perplexity.ai/pro?referral_code=A1R94DGZ",target:"_blank",rel:"noreferrer"},"here")," to create an account with 10$ free credit."),React.createElement(ae.g,null)),React.createElement(le.a,{keepState:"environmentCategories"},p&&React.createElement(le.Y,{title:Ee.COMMON.MODELS},"openrouter"===o.type&&React.createElement("p",null,"There are currently ",React.createElement("b",null,u)," models available. OpenRouter models need to be refresh regularly. This button will fetch the latest models and their prices."),"google"===o.type&&React.createElement("p",null,"There are currently ",React.createElement("b",null,u)," models available. Google models need to be refresh regularly. This button will fetch the latest models and their prices."),"openrouter"!==o.type&&"google"!==o.type&&React.createElement("p",null,"There are currently ",React.createElement("b",null,u)," models available. This button will fetch the latest models."),React.createElement(R.M,{fullWidth:!0,className:"primary",isBusy:r,onClick:()=>d(o.id,o.type)},Ee.COMMON.REFRESH_MODELS)),"azure"===o.type&&React.createElement(React.Fragment,null,React.createElement("p",null,Ee.HELP.AZURE_DEPLOYMENTS),React.createElement(le.Y,{title:Ee.COMMON.OPENAI_AZURE_DEPLOYMENTS},React.createElement(Sl,{deployments:o.deployments??[],environmentId:o.id,updateEnvironment:a,options:e}))),"huggingface"===o.type&&React.createElement(le.Y,{title:Ee.COMMON.HUGGINGFACE_MODELS},React.createElement("p",null,"Browse the ",React.createElement("a",{href:"https://huggingface.co/models",target:"_blank",rel:"noreferrer"},"Models on Hugging Face"),". Use the Deploy button (Inference API Serverless) in order to get the API URL. Paste it below with the name of your choice and you're done!"),React.createElement(Al,{customModels:o.customModels??[],environmentId:o.id,updateEnvironment:a,options:e})),React.createElement(le.Y,{title:Ee.COMMON.ENVIRONMENT_ID},React.createElement("p",null,'The EnvID is "',React.createElement("b",null,o.id),'".')),React.createElement(le.Y,{title:Ee.COMMON.ACTIONS},React.createElement("div",{style:{display:"flex",marginTop:10}},React.createElement("div",{style:{flex:"auto"}}),React.createElement(R.M,{className:"danger",onClick:()=>(e=>{if(1===t.length)return void alert("You can't delete the last environment.");const a=t.filter((t=>t.id!==e));n(a,"ai_envs")})(o.id)},Ee.COMMON.DELETE)))))}))))},{useState:xl,useEffect:Pl}=wp.element,Ll=()=>{const[e,t]=xl(""),[a,n]=xl(""),[l,r]=xl(""),[o,c]=xl(!1),[i,s]=xl("imageToText"),[m,d]=xl(null);Pl((()=>{t(""),n(""),r("")}),[i]);const u=async(t="imageToText")=>{let a="";if("textToJSON"===t)a=`${_}/ai/json`;else if("imageToText"===t)a=`${_}/ai/transcribe_image`;else{if("audioToText"!==t)return void alert(`Unknown transcription type: ${t}`);a=`${_}/ai/transcribe_audio`}c(t),d(Date.now());try{var r;let t=(await(0,y.IU)(a,{method:"POST",nonce:N,json:{url:e,message:l}})).data;null!=t&&null!==(r=t.error)&&void 0!==r&&r.message?alert(t.error.message):n(t)}catch(e){alert(e.message)}finally{c(!1),d(null)}};return React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{title:"Features",className:"raw"},React.createElement(g._,{inversed:!0,onChange:(e,t)=>{s(t.key)}},React.createElement(g.V,{title:Ee.COMMON.IMAGE_TO_TEXT,key:"imageToText"},React.createElement("label",null,"Image URL:"),React.createElement(ae.g,{tiny:!0}),React.createElement(Ye.m,{name:"url",rows:2,value:e,onChange:t}),React.createElement(ae.g,null),React.createElement("label",null,"Prompt:"),React.createElement(ae.g,{tiny:!0}),React.createElement(Ye.m,{rows:2,value:l,onChange:r}),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,style:{height:40},disabled:o,isBusy:"imageToText"===o,startTime:m,onClick:()=>{u("imageToText")}},"Transcribe Image"),React.createElement(ae.g,{tiny:!0}),React.createElement("p",null,"If you are looking for beautiful images to play with this, here are some URLs: ",React.createElement("a",{target:"_blank",href:"https://offbeatjapan.org"},"Offbeat Japan"),", ",React.createElement("a",{target:"_blank",href:"https://unsplash.com"},"Unsplash"),", ",React.createElement("a",{target:"_blank",href:"https://www.pexels.com"},"Pexels"),".")),React.createElement(g.V,{title:Ee.COMMON.AUDIO_TO_TEXT,key:"audioToText"},React.createElement("label",null,"Audio URL:"),React.createElement(ae.g,{tiny:!0}),React.createElement(Ye.m,{name:"url",rows:2,value:e,onChange:t}),React.createElement(ae.g,null),React.createElement("label",null,"Prompt:"),React.createElement(ae.g,{tiny:!0}),React.createElement(Ye.m,{rows:2,value:l,onChange:r}),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,style:{height:40},disabled:o,isBusy:"audioToText"===o,startTime:m,onClick:()=>{u("audioToText")}},"Transcribe Audio")),React.createElement(g.V,{title:Ee.COMMON.PROMPT_TO_JSON,key:"textToJSON"},React.createElement("label",null,"Prompt:"),React.createElement(ae.g,{tiny:!0}),React.createElement(Ye.m,{rows:2,value:l,onChange:r}),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,style:{height:40},disabled:o,isBusy:"textToJSON"===o,startTime:m,onClick:()=>{u("textToJSON")}},"Query AI"),React.createElement(ae.g,null),React.createElement("label",null,"Examples:"),React.createElement("ul",null,React.createElement("li",null,"👽 List the best science fiction books. Include the title, author, publication year, and a short synopsis."),React.createElement("li",null,"🎋 Identify the most beautiful gardens in Japan. Provide the garden name, location (gps: [lng, lat]), best visiting season, and features."),React.createElement("li",null,"💰 Identify the current top 10 richest individuals globally. For each person, include their name, estimated net worth, source of wealth, country of residence, and key tags (such as 'technology', 'retail', 'investor', etc.). Additionally, provide a brief description of their most notable business ventures or achievements."),React.createElement("li",null,"🦁 Compile a list of significant archaeological discoveries in the last decade. Include the discovery, location, date, and significance.")),React.createElement(ae.g,null))))),React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{title:"Transcription",className:"primary"},React.createElement(ae.g,{tiny:!0}),"textToJSON"===i&&React.createElement(ul.p2,{value:a,indentWidth:2,displayDataTypes:!1,displayObjectSize:!1,displayArrayKey:!1,enableClipboard:!1,style:{fontSize:12}}),"textToJSON"!==i&&React.createElement(Ye.m,{name:"context",rows:21,value:a,disabled:!a}))))},{useState:Dl,useMemo:Fl,useEffect:Ul}=wp.element,Bl=[{accessor:"name",title:"Name",verticalAlign:"top"},{accessor:"instructions",title:"Instructions",width:220,verticalAlign:"top"},{accessor:"parameters",title:"Parameters",verticalAlign:"top"},{accessor:"createdOn",title:"Created On",verticalAlign:"top"}],Gl=[{accessor:"file",title:"File",verticalAlign:"top"},{accessor:"metadata",title:"Metadata",verticalAlign:"top"},{accessor:"userId",title:"User ID",verticalAlign:"top"},{accessor:"purpose",title:"Purpose",verticalAlign:"top"},{accessor:"created",title:"Created On",verticalAlign:"top"},{accessor:"actions",title:"Actions",verticalAlign:"top"}],Hl=({options:e,refreshOptions:t})=>{var a;const n=(0,l.jE)(),[c,s]=Dl(null),[m,d]=Dl(!1),[u,E]=Dl(null==e||null===(a=e.ai_envs)||void 0===a||null===(a=a[0])||void 0===a?void 0:a.id),[b,v]=Dl("assistants"),[w,C]=Dl([]),{colors:O}=(0,r.z)(),T=Fl((()=>{var t;return(null==e||null===(t=e.ai_envs)||void 0===t?void 0:t.filter((e=>"openai"===e.type||"azure"===e.type)))||[]}),[e]),I=Fl((()=>T.find((e=>e.id===u))),[u,T]),M=Fl((()=>(null==I?void 0:I.assistants)||[]),[I]),[S,A]=Dl({userId:null,purpose:["assistant-in","assistant-out"],metadata:null,envId:u,page:1,limit:10}),k=(0,y.F1)(S);Ul((()=>{const e=(()=>{const e=localStorage.getItem("mwai-admin-assistants");try{return JSON.parse(e)}catch(e){return{}}})(),t=(null==e?void 0:e.envId)??null;t&&E(t)}),[]),Ul((()=>{(({envId:e})=>{const t={envId:e||null};localStorage.setItem("mwai-admin-assistants",(0,y.F1)(t))})({envId:u})}),[u]),Ul((()=>{A({...S,envId:u})}),[u]);const{isFetching:x,data:P}=(0,o.I)({queryKey:["assistants-files",k],enabled:"files"===b,staleTime:3e5,queryFn:()=>(async({userId:e=null,purpose:t=null,metadata:a=null,envId:n=null,limit:l=10,page:r=0})=>{const o=await(0,y.IU)(`${f}/mwai-ui/v1/files/list`,{nonce:N,method:"POST",json:{userId:e,purpose:t,metadata:a,envId:n,limit:l,page:r}});if(!o.success)throw new Error(o.message);return null==o?void 0:o.data})(S)}),L=async e=>{d(!0);try{await(async e=>{const t=await(0,y.IU)(`${f}/mwai-ui/v1/files/delete`,{nonce:N,method:"POST",json:{files:e}});if(!t.success)throw new Error(t.message);return t})(e),await n.invalidateQueries("assistants-files"),C([])}catch(e){s(e)}d(!1)},D=Fl((()=>null==P?void 0:P.files.map((e=>{return{...e,file:(a=e.url,n=e.refId,React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("span",null,(e=>{if(!e)return null;const t=e.split("/").pop();return React.createElement("a",{href:e,target:"_blank",rel:"noreferrer"},t)})(a)),React.createElement("small",null,n))),purpose:(l=e.purpose,"assistant-out"===l?"Generated":"assistant-in"===l?"Uploaded":l),metadata:(t=e.metadata,t?React.createElement("small",null,React.createElement("ul",{style:{margin:0,padding:0}},Object.keys(t).map((e=>React.createElement("li",{key:e,style:{margin:0}},React.createElement("i",null,e),": ",t[e]," ","assistant_id"===e?`(${(e=>{const t=M.find((t=>t.id===e));return(null==t?void 0:t.name)||"N/A"})(t[e])})`:""))))):null),created:new Date(e.created).toLocaleDateString(),actions:React.createElement(React.Fragment,null,React.createElement(R.M,{className:"danger",rounded:!0,icon:"trash",disabled:B,onClick:()=>L([e.id])}))};var t,a,n,l}))),[P]),F=Fl((()=>(null==P?void 0:P.total)||0),[P]),U=Fl((()=>M.map((e=>{var t;return{...e,name:React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("span",null,e.name),React.createElement("small",null,e.id)),instructions:(null===(t=e.instructions)||void 0===t?void 0:t.length)>100?`${e.instructions.slice(0,100)}...`:e.instructions,parameters:React.createElement(React.Fragment,null,React.createElement("ul",{style:{margin:0,padding:0}},React.createElement("li",{style:{margin:0,display:"flex"}},React.createElement($e.z,{icon:"check",width:16,color:O.green}),React.createElement("span",{style:{marginLeft:3}},e.model??"Unknown")),!e.model&&React.createElement("li",{style:{margin:0,display:"flex",lineHeight:"12px"}},React.createElement("small",null,"The model could not be found in your AI environment. Please make sure it exists as a deployment, and Refresh the list of Assistants.")),React.createElement("li",{style:{margin:0,display:"flex"}},React.createElement($e.z,{icon:e.has_file_search?"check":"close",width:16,color:e.has_file_search?O.green:O.gray}),React.createElement("a",{style:{marginLeft:3},href:"https://platform.openai.com/docs/assistants/tools/file-search",target:"_blank",rel:"noreferrer"},"File Search")),React.createElement("li",{style:{margin:0,display:"flex"}},React.createElement($e.z,{icon:e.has_code_interpreter?"check":"close",width:16,color:e.has_code_interpreter?O.green:O.gray}),React.createElement("a",{style:{marginLeft:3},href:"https://platform.openai.com/docs/assistants/tools/code-interpreter",target:"_blank",rel:"noreferrer"},"Code Interpreter")))),createdOn:new Date(e.createdOn).toLocaleDateString()}}))),[M,O.gray,O.green]),B=m,G=Fl((()=>React.createElement(ee.u,{scrolldown:!0,value:u,onChange:E,style:{marginLeft:5}},T.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))))),[u,T]),H=Fl((()=>React.createElement("div",null,React.createElement("div",{style:{display:"flex",flexDirection:"row"}},React.createElement(Xe.Q,{currentPage:S.page,limit:S.limit,total:F,onClick:e=>{A({...S,page:e})}})))),[S,F]);return React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0,minimal:!0,style:{margin:8}},React.createElement(g._,{inversed:!0,currentTab:b,onChange:(e,t)=>{v(t.key)},action:React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),w.length>0&&"files"===b&&React.createElement(React.Fragment,null,React.createElement(R.M,{className:"danger",disabled:!1,onClick:()=>L(w)},Ee.COMMON.DELETE)),"files"===b&&React.createElement(R.M,{disabled:B||!I,busy:B,onClick:async()=>{await n.invalidateQueries("assistants-files")},className:"secondary"},Ee.COMMON.REFRESH),"assistants"===b&&React.createElement(R.M,{disabled:B||!I,busy:B,onClick:async()=>{d(!0);try{await(async e=>{const t=await(0,y.IU)(`${_}/openai/assistants/list?envId=${e}`,{nonce:N});if(!t.success)throw new Error(t.message);return null==t?void 0:t.assistants})(u),await t()}catch(e){s(e)}d(!1)},className:"secondary"},Ee.COMMON.REFRESH),G)},React.createElement(g.V,{title:Ee.COMMON.ASSISTANTS,key:"assistants"},React.createElement(ze.o,{busy:B,data:U,columns:Bl,emptyMessage:Ee.NO_ASSISTANTS_YET})),React.createElement(g.V,{title:Ee.COMMON.FILES,key:"files"},React.createElement(ze.o,{busy:x||B,data:D,columns:Gl,selectedItems:w,onSelect:e=>{C([...w,...e])},onUnselect:e=>{C([...w.filter((t=>!e.includes(t)))])},emptyMessage:Ee.NO_FILES_YET}),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginTop:10}},React.createElement("div",{style:{flex:"auto"}}),H)))),React.createElement(p.Y,{fullWidth:!0,minimal:!0},React.createElement(h.z,{className:"primary"},React.createElement(i.s,{p:!0},(0,y.FE)(Ee.HELP.ASSISTANTS_INTRO)),React.createElement(oe.X,{variant:"danger"},(0,y.FE)(Ee.HELP.ASSISTANTS_WARNINGS))),React.createElement(ae.g,{tiny:!0}),c&&React.createElement(re.n,{isOpen:!!c,title:"Error",onRequestClose:()=>s(null),okButton:{label:"Ok",onClick:()=>s(null)},content:React.createElement("p",null,null==c?void 0:c.message)})))};var jl=a(9491);const{useState:$l,useMemo:Yl}=wp.element,Wl=P.Ay.div`
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;
`,zl=({addons:e})=>{const t=e.some((e=>e.enabled))?"enabled":"all",[a,n]=$l(t),l=Yl((()=>"enabled"===a?e.filter((e=>e.enabled)):"disabled"===a?e.filter((e=>!e.enabled)):e),[e,a]);return React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0,fullWidth:!0,style:{padding:10}},React.createElement(Ve.V,null,React.createElement(We.o,{name:"filter",value:a,onChange:e=>n(e)},React.createElement(We.K,{title:"All",value:"all"}),React.createElement(We.K,{title:"Enabled",value:"enabled"}),React.createElement(We.K,{title:"Disabled",value:"disabled"}))),React.createElement(ae.g,null),React.createElement(Wl,null,l.map((e=>React.createElement(ne.L,{key:e.id,style:{marginBottom:0},footer:React.createElement("div",{style:{display:"flex",width:"100%",alignItems:"center",marginLeft:10,minHeight:30}},React.createElement("span",{style:{fontSize:"11px",marginRight:15,color:e.enabled?"#4CAF50":"#666",textTransform:"uppercase",fontWeight:"bold"}},e.enabled?React.createElement("label",null,"Enabled"):React.createElement("label",null,"Disabled")),React.createElement("div",{style:{flex:"auto"}}),e.enabled&&e.settings_url&&React.createElement(R.M,{className:"primary",onClick:()=>window.open(e.settings_url,"_self")},"Settings"),!e.enabled&&React.createElement(R.M,{className:"primary",onClick:()=>window.open(e.install_url,"_blank")},"Install"))},React.createElement("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",marginBottom:10}},React.createElement("div",{style:{width:32,marginTop:-5}},React.createElement(jl.r,null)),React.createElement(i.s,{h3:!0,style:{margin:0,marginLeft:8,fontWeight:"bold"}},e.name),React.createElement("div",{style:{marginLeft:5,marginTop:3,fontSize:10,color:"#fec74c"}},Array.from({length:e.stars},((e,t)=>React.createElement("span",{key:t},"★"))))),React.createElement("div",{className:"addon-description"},e.description)))))))},{useMemo:Vl,useState:Kl,useEffect:ql,useCallback:Xl}=wp.element,Ql=[{envKey:"ai_embeddings_default_env",modelKey:"ai_embeddings_default_model",defaultModel:"text-embedding-ada-002"},{envKey:"ai_vision_default_env",modelKey:"ai_vision_default_model",defaultModel:"gpt-4o-mini"},{envKey:"ai_images_default_env",modelKey:"ai_images_default_model",defaultModel:"dall-e-3-hd"},{envKey:"ai_audio_default_env",modelKey:"ai_audio_default_model",defaultModel:"whisper-1"},{envKey:"ai_json_default_env",modelKey:"ai_json_default_model",defaultModel:"gpt-4o-mini"}],Jl=["module_forms","module_statistics","module_embeddings","module_assistants"],Zl=()=>{const[e,t]=Kl(I),[a,n]=Kl(null),[l,r]=Kl(!1),o=null==e?void 0:e.module_suggestions,c=null==e?void 0:e.module_advisor,E=null==e?void 0:e.module_forms,f=null==e?void 0:e.module_finetunes,w=null==e?void 0:e.module_statistics,C=null==e?void 0:e.module_playground,M=null==e?void 0:e.module_generator_content,S=null==e?void 0:e.module_generator_images,A=null==e?void 0:e.module_moderation,k=null==e?void 0:e.module_embeddings,x=null==e?void 0:e.module_assistants,P=null==e?void 0:e.module_transcription,L=null==e?void 0:e.module_addons,D=null==e?void 0:e.module_devtools,F=null==e?void 0:e.module_chatbots,U=Vl((()=>null!=e&&e.ai_envs?null==e?void 0:e.ai_envs:[]),[e]),B=null==e?void 0:e.ai_default_env,G=null==e?void 0:e.ai_default_model,H=null==e?void 0:e.ai_vision_default_env,j=null==e?void 0:e.ai_vision_default_model,$=null==e?void 0:e.ai_embeddings_default_env,Y=null==e?void 0:e.ai_embeddings_default_model,W=null==e?void 0:e.ai_images_default_env,z=null==e?void 0:e.ai_images_default_model,V=null==e?void 0:e.ai_audio_default_env,K=null==e?void 0:e.ai_audio_default_model,q=null==e?void 0:e.ai_json_default_env,X=null==e?void 0:e.ai_json_default_model,Q=null==e?void 0:e.ai_streaming,J=null==e?void 0:e.privacy_first,Z=null!=e&&e.embeddings_envs?null==e?void 0:e.embeddings_envs:[],oe=null==e?void 0:e.embeddings_default_env,ce=null==e?void 0:e.syntax_highlight,ie=(null==e||e.chatbot_typewriter,null==e?void 0:e.chatbot_discussions),se=null==e?void 0:e.virtual_keyboard_fix,de=null==e?void 0:e.chatbot_gdpr_consent,ue=null==e?void 0:e.chatbot_gdpr_text,pe=null==e?void 0:e.chatbot_gdpr_button,ge=null==e?void 0:e.speech_recognition,Re=null==e?void 0:e.speech_synthesis,he=null==e?void 0:e.public_api,ye=null==e?void 0:e.statistics_data,fe=null==e?void 0:e.statistics_forms_data,_e=null==e?void 0:e.intro_message,we=null==e?void 0:e.module_addons,Ce=null==e?void 0:e.context_max_length,Oe=null==e?void 0:e.banned_ips,Te=null==e?void 0:e.banned_words,Ie=null==e?void 0:e.ignore_word_boundaries,Me=(null==e?void 0:e.admin_bar)??["settings"],Se=null==e?void 0:e.resolve_shortcodes,Ae=null==e?void 0:e.clean_uninstall,{completionModels:ke}=ve(e),{visionModels:xe}=ve(e,null==e?void 0:e.ai_vision_default_env),{audioModels:Pe}=ve(e,null==e?void 0:e.ai_audio_default_env),{jsonModels:Le}=ve(e,null==e?void 0:e.ai_json_default_env),{imageModels:De}=ve(e,null==e?void 0:e.ai_images_default_env),{embeddingsModels:Fe}=ve(e,null==e?void 0:e.ai_embeddings_default_env),Be=Vl((()=>Fe.find((e=>e.model===Y))),[Fe,Y]),Ge=l,He=Xl((async a=>{try{if((0,y.F1)(a)===(0,y.F1)(e))return;r(!0);const n=await(0,y.IU)(`${_}/settings/update`,{method:"POST",nonce:N,json:{options:a}});t(n.options)}catch(t){console.error(Ee.ERROR.UPDATING_OPTIONS,null!=t&&t.message?{message:t.message,options:e,newOptions:a}:{err:t,options:e,newOptions:a}),t.message&&n(React.createElement(React.Fragment,null,React.createElement("div",null,Ee.ERROR.UPDATING_OPTIONS),React.createElement("small",null,(0,y.FE)(Ee.ERROR.CHECK_YOUR_CONSOLE))))}finally{r(!1)}}),[e]);ql((()=>{(async()=>{let t=!1;const a={...e};Ql.forEach((({envKey:n,modelKey:l,defaultModel:r})=>{let o=!1;if(e[n]&&(o=!!U.find((t=>t.id===e[n]))),!o){const e=U.find((e=>"openai"===(null==e?void 0:e.type)));e?a[n]===e.id&&a[l]===r||(console.warn(`Updating ${n} and ${l} to ${e.id} and ${r}`),t=!0,a[n]=e.id,a[l]=r):null===a[n]&&null===a[l]||(console.warn(`Updating ${n} and ${l} to null`),t=!0,a[n]=null,a[l]=null)}if("ai_embeddings_default_model"===l&&a[l]){const e=(null==a?void 0:a.ai_embeddings_default_dimensions)||null;if(null!==e){const n=Fe.find((e=>e.model===a[l]));if(null==n||!n.dimensions.includes(e)){const e=(null==n?void 0:n.dimensions[(null==n?void 0:n.dimensions.length)-1])||null;null!==e&&(a.ai_embeddings_default_dimensions=e,console.warn(`Updating embeddings default dimensions to ${e}`),t=!0)}}}})),t&&await He(a)})()}),[U,e,He,Fe]);const je=async()=>{r(!0);try{const e=await rt();t(e)}catch(e){console.error(Ee.ERROR.GETTING_OPTIONS,null!=e&&e.message?{message:e.message}:{err:e}),e.message&&n(React.createElement(React.Fragment,null,React.createElement("div",null,Ee.ERROR.GETTING_OPTIONS),React.createElement("small",null,(0,y.FE)(Ee.ERROR.CHECK_YOUR_CONSOLE))))}finally{r(!1)}},$e=async(t,a)=>{const n={...e,[a]:t};console.log("Updating",a,t),await He(n)},Ye=async(e,t)=>{const a=Z.map((a=>a.id===e?{...a,...t}:a));$e(a,"embeddings_envs")};ql((()=>{if(!T){const t={...e};let a=!1;Jl.forEach((e=>{t[e]&&(t[e]=!1,console.warn(`Resetting ${e}`),a=!0)})),a&&(0,y.F1)(t)!==(0,y.F1)(e)&&He(t)}}),[]);const We=React.createElement(s.d,{title:Ee.COMMON.UTILITIES},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"module_suggestions",label:Ee.COMMON.POSTS_SUGGESTIONS,value:"1",checked:o,description:Ee.COMMON.POSTS_SUGGESTIONS_HELP,onChange:$e}))),ze=React.createElement(s.d,{title:Ee.COMMON.ADVISOR},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"module_advisor",label:Ee.COMMON.ENABLE,value:"1",checked:c,description:Ee.HELP.ADVISOR,onChange:$e}))),Ve=React.createElement(s.d,{title:Ee.COMMON.GENERATORS},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"module_generator_content",label:Ee.COMMON.CONTENT_GENERATOR,value:"1",checked:M,description:Ee.COMMON.CONTENT_GENERATOR_HELP,onChange:$e}),React.createElement(d.R,{name:"module_generator_images",label:Ee.COMMON.IMAGES_GENERATOR,value:"1",checked:S,description:Ee.COMMON.IMAGES_GENERATOR_HELP,onChange:$e}))),Ke=React.createElement(s.d,{title:Ee.COMMON.PLAYGROUND},React.createElement(d.R,{name:"module_playground",label:Ee.COMMON.ENABLE,value:"1",checked:C,description:Ee.COMMON.PLAYGROUND_HELP,onChange:$e})),qe=React.createElement(s.d,{title:React.createElement(React.Fragment,null,Ee.COMMON.FORMS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(d.R,{name:"module_forms",label:Ee.COMMON.ENABLE,value:"1",checked:E,requirePro:!0,isPro:T,description:Ee.COMMON.FORMS_HELP,onChange:$e})),Xe=React.createElement(s.d,{title:Ee.COMMON.FINETUNES},React.createElement(d.R,{name:"module_finetunes",label:Ee.COMMON.ENABLE,value:"1",checked:f,description:React.createElement(React.Fragment,null,React.createElement(Ne,{disabled:!f,style:{marginRight:3}}),Ee.HELP.FINETUNES),onChange:$e})),Qe=React.createElement(s.d,{title:React.createElement(React.Fragment,null,Ee.COMMON.STATISTICS)},React.createElement(d.R,{name:"module_statistics",label:Ee.COMMON.ENABLE,value:"1",checked:w,requirePro:!0,isPro:T,description:Ee.COMMON.STATISTICS_HELP,onChange:$e})),Je=React.createElement(s.d,{title:React.createElement(React.Fragment,null,Ee.COMMON.MODERATION)},React.createElement(d.R,{name:"module_moderation",label:Ee.COMMON.ENABLE,value:"1",checked:A,description:React.createElement(React.Fragment,null,React.createElement(Ne,{disabled:!A,style:{marginRight:3}}),Ee.COMMON.MODERATION_HELP),onChange:$e})),Ze=React.createElement(s.d,{title:React.createElement(React.Fragment,null,Ee.COMMON.TRANSCRIPTION)},React.createElement(d.R,{name:"module_transcription",label:Ee.COMMON.ENABLE,value:"1",checked:P,description:Ee.COMMON.TRANSCRIPTION_HELP,onChange:$e})),et=React.createElement(s.d,{title:React.createElement(React.Fragment,null,Ee.COMMON.EMBEDDINGS)},React.createElement(d.R,{name:"module_embeddings",label:Ee.COMMON.ENABLE,value:"1",checked:k,requirePro:!0,isPro:T,description:Ee.COMMON.EMBEDDINGS_HELP,onChange:$e})),ot=React.createElement(s.d,{title:React.createElement(React.Fragment,null,Ee.COMMON.ASSISTANTS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(d.R,{name:"module_assistants",label:Ee.COMMON.ENABLE,value:"1",checked:x,requirePro:!0,isPro:T,description:React.createElement(React.Fragment,null,React.createElement(Ne,{disabled:!x,style:{marginRight:3}}),Ee.HELP.ASSISTANTS),onChange:$e})),ct=React.createElement(s.d,{title:Ee.COMMON.CHATBOT},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"module_chatbots",label:Ee.COMMON.ENABLE,value:"1",checked:F,description:Ee.COMMON.CHATBOT_HELP,onChange:$e}))),it=React.createElement(s.d,{title:Ee.COMMON.QUERIES_DATA},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"statistics_data",label:Ee.COMMON.ENABLE,value:"1",checked:ye,description:Ee.HELP.QUERIES_DATA,onChange:$e}))),st=React.createElement(s.d,{title:Ee.COMMON.QUERIES_FORMS_DATA},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"statistics_forms_data",label:Ee.COMMON.ENABLE,value:"1",checked:fe,description:Ee.HELP.QUERIES_FORMS_DATA,onChange:$e}))),mt=React.createElement(s.d,{title:Ee.COMMON.INTRO_MESSAGE},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"intro_message",label:Ee.COMMON.ENABLE,value:"1",checked:_e,description:Ee.HELP.INTRO_MESSAGE,onChange:$e}))),dt=React.createElement(s.d,{title:Ee.COMMON.ADDONS},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"module_addons",label:Ee.COMMON.ENABLE,value:"1",checked:we,description:Ee.HELP.ADDONS,onChange:$e}))),ut=React.createElement(s.d,{title:Ee.COMMON.CHATBOT_SELECT},React.createElement(ee.u,{scrolldown:!0,name:"chatbot_select",value:null==e?void 0:e.chatbot_select,onChange:$e,description:Ee.HELP.CHATBOT_SELECT},React.createElement(ee.j,{key:"tabs",value:"tabs",label:Ee.COMMON.TABS}),React.createElement(ee.j,{key:"dropdown",value:"dropdown",label:Ee.COMMON.DROPDOWN}))),Et=React.createElement(s.d,{title:Ee.COMMON.WEBSPEECH_API},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"speech_recognition",label:Ee.COMMON.SPEECH_RECOGNITION,value:"1",checked:ge,description:Ee.HELP.SPEECH_RECOGNITION,onChange:$e})),React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"speech_synthesis",label:Ee.COMMON.SPEECH_SYNTHESIS+" (SOON)",value:"1",disabled:!0,checked:Re,description:Ee.HELP.SPEECH_SYNTHESIS,onChange:$e}))),pt=React.createElement(s.d,{title:Ee.COMMON.VIRTUAL_KEYBOARD},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"virtual_keyboard_fix",label:Ee.COMMON.FIX,value:"1",checked:se,description:Ee.HELP.VIRTUAL_KEYBOARD,onChange:$e}))),gt=React.createElement(s.d,{title:Ee.COMMON.GDPR_CONSENT},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"chatbot_gdpr_consent",label:Ee.COMMON.ENABLE,value:"1",checked:de,description:Ee.HELP.GDPR_CONSENT,onChange:$e}))),Rt=React.createElement(s.d,{title:Ee.COMMON.GDPR_TEXT},React.createElement(te.A,{name:"chatbot_gdpr_text",value:ue,onBlur:$e})),ht=React.createElement(s.d,{title:Ee.COMMON.GDPR_BUTTON},React.createElement(te.A,{name:"chatbot_gdpr_button",value:pe,onBlur:$e})),yt=React.createElement(s.d,{title:Ee.COMMON.STREAMING},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"ai_streaming",label:Ee.COMMON.ENABLE,value:"1",checked:Q,description:Ee.HELP.STREAMING,onChange:$e}))),bt=React.createElement(s.d,{title:Ee.COMMON.PRIVACY_FIRST},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"privacy_first",label:Ee.COMMON.ENABLE,value:"1",checked:J,description:Ee.HELP.PRIVACY_FIRST,onChange:$e}))),vt=React.createElement(s.d,{title:Ee.COMMON.DISCUSSIONS},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"chatbot_discussions",label:Ee.COMMON.ENABLE,value:"1",checked:ie,description:Ee.HELP.DISCUSSIONS,onChange:$e}))),_t=React.createElement(s.d,{title:Ee.COMMON.DISCUSSION_TITLES},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"chatbot_discussions_titling",label:Ee.COMMON.GENERATE,value:"1",checked:null==e?void 0:e.chatbot_discussions_titling,description:Ee.HELP.DISCUSSION_TITLES,onChange:$e}))),Ct=React.createElement(s.d,{title:Ee.COMMON.SYNTAX_HIGHLIGHT},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"syntax_highlight",label:Ee.COMMON.ENABLE,value:"1",checked:ce,description:Ee.HELP.SYNTAX_HIGHLIGHT,onChange:$e}))),Ot=React.createElement(s.d,{title:Ee.COMMON.PUBLIC_API},React.createElement(d.R,{name:"public_api",label:Ee.COMMON.ENABLE,value:"1",checked:he,description:Ee.HELP.PUBLIC_API,onChange:$e})),Tt=React.createElement(s.d,{title:Ee.COMMON.BEARER_TOKEN},React.createElement(te.A,{name:"public_api_bearer_token",value:null==e?void 0:e.public_api_bearer_token,description:(0,y.FE)(Ee.HELP.BEARER_TOKEN),onBlur:$e})),Nt=React.createElement(s.d,{title:"Local Upload"},React.createElement(ee.u,{scrolldown:!0,name:"image_local_upload",value:null==e?void 0:e.image_local_upload,onChange:$e,description:"Files can be stored either in the filesystem or the Media Library."},React.createElement(ee.j,{key:"uploads",value:"uploads",label:"Filesystem"}),React.createElement(ee.j,{key:"library",value:"library",label:"Media Library"}))),It=React.createElement(s.d,{title:"Remote Upload"},React.createElement(ee.u,{scrolldown:!0,name:"image_remote_upload",value:null==e?void 0:e.image_remote_upload,onChange:$e,description:"Select Upload Data for private sites; Share URLs requires your WordPress to be online and reachable."},React.createElement(ee.j,{key:"data",value:"data",label:"Upload Data"}),React.createElement(ee.j,{key:"url",value:"url",label:"Share URLs"}))),Mt=React.createElement(s.d,{title:"Expiration"},React.createElement(ee.u,{scrolldown:!0,name:"image_expires",value:(null==e?void 0:e.image_expires)??"never",onChange:$e,description:"Uploaded files will be deleted after a certain amount of time. This also affects files uploaded to OpenAI via the Assistants."},React.createElement(ee.j,{key:300,value:300,label:"5 minutes"}),React.createElement(ee.j,{key:3600,value:3600,label:"1 hour"}),React.createElement(ee.j,{key:21600,value:21600,label:"6 hours"}),React.createElement(ee.j,{key:86400,value:86400,label:"1 day"}),React.createElement(ee.j,{key:604800,value:604800,label:"1 week"}),React.createElement(ee.j,{key:2592e3,value:2592e3,label:"1 month"}),React.createElement(ee.j,{key:"Never",value:"never",label:"Never"}))),St=React.createElement(s.d,{title:"Local Download"},React.createElement(ee.u,{scrolldown:!0,name:"image_local_download",value:(null==e?void 0:e.image_local_download)??null,onChange:$e,description:"Files can be stored either in the filesystem or the Media Library."},React.createElement(ee.j,{key:null,value:null,label:"None"}),React.createElement(ee.j,{key:"uploads",value:"uploads",label:"Filesystem"}),React.createElement(ee.j,{key:"library",value:"library",label:"Media Library"}))),At=React.createElement(s.d,{title:"Expiration"},React.createElement(ee.u,{scrolldown:!0,name:"image_expires_download",value:(null==e?void 0:e.image_expires_download)??"never",onChange:$e,description:"Downloaded files will be deleted after a certain amount of time."},React.createElement(ee.j,{key:300,value:300,label:"5 minutes"}),React.createElement(ee.j,{key:3600,value:3600,label:"1 hour"}),React.createElement(ee.j,{key:21600,value:21600,label:"6 hours"}),React.createElement(ee.j,{key:86400,value:86400,label:"1 day"}),React.createElement(ee.j,{key:604800,value:604800,label:"1 week"}),React.createElement(ee.j,{key:2592e3,value:2592e3,label:"1 month"}),React.createElement(ee.j,{key:"Never",value:"never",label:"Never"}))),kt=React.createElement(s.d,{title:Ee.COMMON.DEV_TOOLS},React.createElement(d.R,{name:"module_devtools",label:Ee.COMMON.ENABLE,value:"1",checked:D,description:Ee.HELP.DEV_TOOLS,onChange:$e})),xt=React.createElement(s.d,{title:Ee.COMMON.SHORTCODES},React.createElement(d.R,{name:"resolve_shortcodes",label:Ee.COMMON.RESOLVE,value:"1",checked:Se,description:Ee.HELP.RESOLVE_SHORTCODE,onChange:$e})),Pt=React.createElement(s.d,{title:Ee.COMMON.CONTEXT_MAX_LENGTH},React.createElement(te.A,{name:"context_max_length",value:Ce,type:"number",step:"1",description:Ee.HELP.CONTEXT_MAX_LENGTH,onBlur:$e})),Lt=React.createElement(s.d,{title:Ee.COMMON.BANNED_WORDS},React.createElement(te.A,{id:"banned_words",name:"banned_words",value:Te,isCommaSeparatedArray:!0,description:Ee.HELP.BANNED_WORDS,onBlur:$e})),Dt=React.createElement(s.d,{title:Ee.COMMON.WORD_BOUNDARIES},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"ignore_word_boundaries",label:Ee.COMMON.IGNORE,value:"1",checked:Ie,description:Ee.HELP.WORD_BOUNDARIES,onChange:$e}))),Ft=React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_default_model",value:G,onChange:$e},ke.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),Ut=React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_embeddings_default_model",value:Y,onChange:$e},Fe.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),Bt=React.createElement(s.d,{title:Ee.COMMON.DIMENSIONS},React.createElement(ee.u,{scrolldown:!0,name:"ai_embeddings_default_dimensions",value:(null==e?void 0:e.ai_embeddings_default_dimensions)||null,onChange:$e},null==Be?void 0:Be.dimensions.map(((e,t)=>React.createElement(ee.j,{key:e,value:e,label:t===Be.dimensions.length-1?`${e} (Default)`:e}))),React.createElement(ee.j,{key:null,value:null,label:"Not Set"}))),Ht=React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_vision_default_model",value:j,onChange:$e},xe.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),jt=React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_audio_default_model",value:K,onChange:$e},Pe.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),$t=React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_json_default_model",value:X,onChange:$e},Le.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),Yt=React.createElement(s.d,{title:Ee.COMMON.MODEL},React.createElement(ee.u,{scrolldown:!0,name:"ai_images_default_model",value:z,onChange:$e},De.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name}))))),Wt=React.createElement(s.d,{title:Ee.COMMON.BANNED_IPS},React.createElement(te.A,{id:"banned_ips",name:"banned_ips",value:Oe,isCommaSeparatedArray:!0,description:Ee.HELP.BANNED_IPS,onBlur:$e})),Vt=React.createElement(s.d,{title:Ee.COMMON.PLAYGROUND},React.createElement(d.R,{label:Ee.COMMON.ENABLE,value:"1",checked:null==Me?void 0:Me.playground,onChange:e=>{const t={...Me,playground:e};$e(t,"admin_bar")}})),Kt=React.createElement(s.d,{title:Ee.COMMON.GENERATE_CONTENT},React.createElement(d.R,{label:Ee.COMMON.ENABLE,value:"1",checked:null==Me?void 0:Me.content_generator,onChange:e=>{const t={...Me,content_generator:e};$e(t,"admin_bar")}})),qt=React.createElement(s.d,{title:Ee.COMMON.GENERATE_IMAGES},React.createElement(d.R,{label:Ee.COMMON.ENABLE,value:"1",checked:null==Me?void 0:Me.images_generator,onChange:e=>{const t={...Me,images_generator:e};$e(t,"admin_bar")}})),Xt=React.createElement(s.d,{title:"AI Engine"},React.createElement(d.R,{label:Ee.COMMON.ENABLE,value:"1",checked:null==Me?void 0:Me.settings,onChange:e=>{const t={...Me,settings:e};$e(t,"admin_bar")}})),Qt=React.createElement("div",null,React.createElement(zt,{options:e}),React.createElement("div",{style:{fontSize:12,marginTop:15,lineHeight:1.3,color:"#666"}},(0,y.FE)(Ee.COMMON.USAGE_HELP))),Jt=React.createElement(React.Fragment,null,React.createElement(ae.g,{height:5}),React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_default_env",value:B,onChange:$e},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))))),Zt=React.createElement(React.Fragment,null,React.createElement(ae.g,{height:5}),React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_embeddings_default_env",value:$,onChange:$e},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))))),ea=React.createElement(React.Fragment,null,React.createElement(ae.g,{height:5}),React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_vision_default_env",value:H,onChange:$e},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))))),ta=React.createElement(React.Fragment,null,React.createElement(ae.g,{height:5}),React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_audio_default_env",value:V,onChange:$e},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))))),aa=React.createElement(React.Fragment,null,React.createElement(ae.g,{height:5}),React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_json_default_env",value:q,onChange:$e},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))))),na=React.createElement(React.Fragment,null,React.createElement(ae.g,{height:5}),React.createElement(s.d,{title:Ee.COMMON.ENVIRONMENT},React.createElement(ee.u,{scrolldown:!0,name:"ai_images_default_env",value:W,onChange:$e},U.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))))),la=React.createElement(ee.u,{scrolldown:!0,name:"embeddings_default_env",value:oe,onChange:$e},Z.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))),ra=React.createElement(s.d,{title:Ee.COMMON.PLUGIN_DATA},React.createElement(m.E,{max:"1"},React.createElement(d.R,{name:"clean_uninstall",label:Ee.COMMON.DELETE_ALL,description:Ee.COMMON.PLUGIN_DATA_DESCRIPTION,value:"1",checked:Ae,onChange:$e})));return React.createElement(u.z,null,React.createElement(Ue,{options:e}),React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0},React.createElement(be,{options:e}),_e&&React.createElement(ne.L,null,(0,y.FE)(Ee.SETTINGS.INTRO)),React.createElement(g._,{keepTabOnReload:!0},React.createElement(g.V,{key:"dashboard",title:Ee.COMMON.DASHBOARD},React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{busy:Ge,title:Ee.COMMON.CLIENT_MODULES,className:"primary"},React.createElement("p",null,Ee.SETTINGS.MODULES_INTRO),React.createElement(ae.g,null),ct,qe),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.SERVER_MODULES,className:"primary"},React.createElement("p",null,Ee.SETTINGS.MODULES_INTRO),React.createElement(ae.g,null),Qe,et,Xe,Je,ot),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.BACKEND_MODULES,className:"primary"},React.createElement("p",null,Ee.SETTINGS.MODULES_INTRO),React.createElement(ae.g,null),ze,Ve,Ke,We,Ze)),React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{busy:Ge,title:Ee.COMMON.USAGE,className:"primary",action:React.createElement(React.Fragment,null,React.createElement("div",null,React.createElement(R.M,{className:"danger",style:{marginLeft:5},disabled:Ge,onClick:async()=>{window.confirm(Ee.COMMON.RESET_USAGE_SURE)&&await $e([],"ai_models_usage")}},Ee.COMMON.RESET)))},Qt)))),F&&React.createElement(g.V,{key:"chatbots",title:Ee.COMMON.CHATBOTS},React.createElement(dl,{options:e,updateOption:$e,busy:Ge})),F&&ie&&React.createElement(g.V,{key:"discussions",title:Ee.COMMON.DISCUSSIONS},React.createElement(ia,null)),w&&React.createElement(g.V,{key:"queries",title:Ee.COMMON.QUERIES},React.createElement(fl,{options:e,updateOption:$e,busy:Ge})),k&&React.createElement(g.V,{key:"embeddings",title:Ee.COMMON.EMBEDDINGS},React.createElement(Gt,{options:e,updateEnvironment:Ye,updateOption:$e})),x&&React.createElement(g.V,{key:"assistants",title:Ee.COMMON.ASSISTANTS},React.createElement(Hl,{options:e,updateOption:$e,refreshOptions:je})),f&&React.createElement(g.V,{key:"finetunes",title:Ee.COMMON.FINETUNES},React.createElement(ft,{options:e,updateOption:$e,refreshOptions:je})),A&&React.createElement(g.V,{key:"moderation",title:Ee.COMMON.MODERATION},React.createElement(wt,{options:e,updateOption:$e,busy:Ge})),P&&React.createElement(g.V,{key:"transcription",title:Ee.COMMON.TRANSCRIPTION},React.createElement(Ll,{options:e,updateOption:$e})),L&&React.createElement(g.V,{key:"addons",title:Ee.COMMON.ADDONS},React.createElement(zl,{addons:null==e?void 0:e.addons,updateOption:$e})),React.createElement(g.V,{key:"settings",title:Ee.COMMON.SETTINGS},React.createElement(p.N,null,React.createElement(p.Y,{minimal:!0},React.createElement(kl,{busy:Ge,options:e,environments:U,updateEnvironment:async(e,t)=>{const a=U.map((a=>a.id===e?{...a,...t}:a));$e(a,"ai_envs")},updateOption:$e}),React.createElement("div",{style:{padding:"0px 10px 15px 10px",marginTop:13,marginBottom:5}},React.createElement(i.s,{h2:!0,style:{color:"white",marginBottom:15}},Ee.COMMON.AI_ENVIRONMENT_DEFAULTS),React.createElement(g._,{inversed:!0},React.createElement(g.V,{key:"ai",title:Ee.COMMON.DEFAULT,busy:Ge},Jt,Ft),React.createElement(g.V,{key:"vision",title:Ee.COMMON.VISION,busy:Ge},ea,Ht),React.createElement(g.V,{key:"images",title:Ee.COMMON.IMAGES,busy:Ge},na,Yt),React.createElement(g.V,{key:"embeddings",title:Ee.COMMON.EMBEDDINGS,busy:Ge},Zt,Ut,Bt),React.createElement(g.V,{key:"audio",title:Ee.COMMON.AUDIO,busy:Ge},ta,jt),React.createElement(g.V,{key:"json",title:Ee.COMMON.JSON,busy:Ge},aa,$t))),k&&React.createElement(React.Fragment,null,React.createElement(Tl,{busy:Ge,options:e,environments:Z,updateEnvironment:Ye,updateOption:$e}),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.EMBEDDINGS_ENVIRONMENT_DEFAULT,className:"primary"},la)),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.MAINTENANCE,className:"primary"},React.createElement(R.M,{className:"blue",onClick:async()=>{r("exportSettings");try{const e=await nt(),t={chatbots:e,themes:await tt(),options:await rt()},a=new Blob([(0,y.F1)(t)],{type:"application/json"}),n=URL.createObjectURL(a),l=document.createElement("a");l.href=n;const r=new Date,o=`ai-engine-${r.getFullYear()}-${r.getMonth()+1}-${r.getDate()}.json`;l.setAttribute("download",o),l.click()}catch(e){alert("Error while exporting settings. Please check your console."),console.log(e)}finally{r(!1)}}},"Export Settings"),React.createElement(R.M,{className:"danger",onClick:async()=>{r("importSettings");try{const e=document.createElement("input");e.type="file",e.accept="application/json",e.onchange=async e=>{const t=e.target.files[0];if(!t)return;const a=new FileReader;a.onload=async e=>{const t=JSON.parse(e.target.result),{chatbots:a,themes:n,options:l}=t;await lt(a),await at(n),await He(l),alert("Settings imported. The page will now reload to reflect the changes."),window.location.reload()},a.readAsText(t)},e.click()}catch(e){alert("Error while importing settings. Please check your console."),console.log(e)}finally{r(!1)}}},"Import Settings"),React.createElement(R.M,{className:"danger",onClick:async()=>{if(window.confirm(Ee.ALERTS.ARE_YOU_SURE)){r(!0);try{await(0,y.IU)(`${_}/settings/reset`,{method:"POST",nonce:N}),alert("Settings reset. The page will now reload to reflect the changes."),window.location.reload()}catch(e){alert("Error while resetting settings. Please check your console."),console.log(e)}finally{r(!1)}}}},"Reset Settings"))),React.createElement(p.Y,{minimal:!0},React.createElement(h.z,{busy:Ge,title:Ee.COMMON.GENERAL,className:"primary"},yt,bt),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.USER_INTERFACE,className:"primary"},mt,dt,ut),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.CHATBOT,className:"primary"},vt,ie&&_t,Ct,Et,pt,gt,de&&React.createElement(React.Fragment,null,Rt,ht)),w&&React.createElement(h.z,{busy:Ge,title:Ee.COMMON.STATISTICS,className:"primary"},React.createElement("p",null,Ee.HELP.STATISTICS),it,st),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.IMAGES_AND_FILES,className:"primary"},React.createElement("p",null,React.createElement("b",null,"Uploaded by Users")),Nt,It,Mt,React.createElement("p",null,React.createElement("b",null,"Generated by AI")),St,null!==(null==e?void 0:e.image_local_download)&&At),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.ADMIN_TOOLS,className:"primary"},React.createElement(le.Y,{title:Ee.COMMON.ADMIN_BAR}),Xt,Vt,Kt,qt),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.ADVANCED,className:"primary"},xt,Pt,Ot,Tt,kt,ra),React.createElement(h.z,{busy:Ge,title:Ee.COMMON.SECURITY,className:"primary"},Lt,(null==Te?void 0:Te.length)>0&&Dt,Wt)))),D&&React.createElement(g.V,{key:"devtools",title:Ee.COMMON.DEV_TOOLS},React.createElement(wl,{options:e,setOptions:t,updateOption:$e})),React.createElement(g.V,{key:"license",title:Ee.COMMON.LICENSE_TAB},React.createElement(me,{domain:v,prefix:b,isPro:O,isRegistered:T}))))),React.createElement(re.n,{isOpen:a,title:Ee.COMMON.ERROR,content:a,onRequestClose:()=>n(!1),okButton:{label:"Close",onClick:()=>n(!1)}}))};var er=a(6087);const tr=[{value:"informative",label:"Informative"},{value:"descriptive",label:"Descriptive"},{value:"creative",label:"Creative"},{value:"narrative",label:"Narrative"},{value:"persuasive",label:"Persuasive"},{value:"reflective",label:"Reflective"},{value:"argumentative",label:"Argumentative"},{value:"analytical",label:"Analytical"},{value:"evaluative",label:"Evaluative"},{value:"journalistic",label:"Journalistic"},{value:"technical",label:"Technical"}],ar=[{value:"neutral",label:"Neutral"},{value:"formal",label:"Formal"},{value:"assertive",label:"Assertive"},{value:"cheerful",label:"Cheerful"},{value:"humorous",label:"Humorous"},{value:"informal",label:"Informal"},{value:"inspirational",label:"Inspirational"},{value:"professional",label:"Professional"},{value:"confluent",label:"Confluent"},{value:"emotional",label:"Emotional"},{value:"persuasive",label:"Persuasive"},{value:"supportive",label:"Supportive"},{value:"sarcastic",label:"Sarcastic"},{value:"condescending",label:"Condescending"},{value:"skeptical",label:"Skeptical"},{value:"narrative",label:"Narrative"},{value:"journalistic",label:"Journalistic"}],nr="gpt-3.5-turbo",lr=[{id:"default",name:"Default",mode:"query",model:nr,temperature:.8,stopSequence:"",maxTokens:2048,prompt:""},{id:"article_translator",name:"Text Translator",mode:"query",model:nr,temperature:.3,stopSequence:"",maxTokens:2048,prompt:"Translate this article into French:\n\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n"},{id:"restaurant_review",name:"Restaurant Review Writer",mode:"query",model:nr,temperature:.8,stopSequence:"",maxTokens:2048,prompt:"Write a review for a French restaurant located in Kagurazaka, Tokyo. Looks like an old restaurant, food is traditional, chef is talkative, it is always full. Not expensive, but not fancy.\n"},{id:"article_corrector",name:"Text Corrector",mode:"query",model:nr,temperature:.2,stopSequence:"",maxTokens:2048,prompt:"Fix the grammar and spelling mistakes in this text:\n\nI wake up at eleben yesderday, I will go bed eary tonigt.\n"},{id:"seo_assistant",name:"SEO Optimizer",mode:"query",model:nr,temperature:.6,stopSequence:"",maxTokens:1024,prompt:"For the following article, write a SEO-friendly and short title, keywords for Google, and a short excerpt to introduce it. Use this format:\n\nTitle: \nKeywords: \nExcerpt:\n\nArticle:\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town."}],rr=[{id:"default",name:"Default",model:"dall-e-3",maxResults:1,prompt:""},{id:"japan",name:"Ghibli Scene",model:"dall-e-3",maxResults:1,prompt:"Create an image in the style of a Ghibli-inspired anime oil painting, depicting a quaint, old house in the Japanese countryside. This house, reminiscent of a traditional izakaya, is surrounded by lush trees and overlooks vibrant rice fields. The scene is bathed in the warm, soft glow of a setting sun, casting gentle shadows and creating a tranquil, nostalgic atmosphere. The composition should be rich in texture, capturing the serene beauty of rural Japan in a whimsical, Ghibli-like manner."},{id:"steampunk",name:"Steampunk Architecture",model:"dall-e-3",maxResults:1,prompt:"Create an image showcasing steampunk architecture, focusing on the exterior view of a grand theater. The style should reflect award-winning architectural photography from a science fiction magazine. The theater, a masterpiece of steampunk design, combines Victorian influences with futuristic, mechanical elements. Its intricate facade features exposed gears, brass pipes, and steam vents, all integrated into the ornate, classical structure. The building should be set against a dramatic sky, highlighting its unique features and the interplay of light and shadow, capturing the essence of a high-quality, professional architectural photograph."},{id:"nyao-illustration",name:"Nyao Illustration",model:"dall-e-3",maxResults:1,prompt:"The character is an anthropomorphic cat with a whimsical and endearing design, featuring a blend of white and blue fur. The right side of the cat's face has a patch of blue fur that also covers the outer part of the ear, while the left side remains predominantly white, except that the eye is surrounded by a green patch of fur. The tail mirrors this pattern with white fur leading to a blue tip. The character's facial expression is joyous, with a wide, open-mouthed smile showcasing a single front tooth and a small, black nose. The cat's paws are also white, with defined fingers that suggest human-like dexterity. An orange collar encircles the neck, contrasting with the green and blue tones of the body. This collar is adorned with a blue and white emblem in the center, reminiscent of the WordPress logo. The drawing style of this image can be defined as a digital illustration with a cartoonish and whimsical aesthetic. It features bold outlines, flat colors, and simplified shapes which are typical of contemporary character design aimed at a broad, family-friendly audience. The style is reminiscent of modern vector art, which is often used for web graphics, animation, and media aimed at engaging a casual viewer with its clear, approachable, and vibrant visuals."}],or=[{id:"default",name:"Default",mode:"single",topic:"",topics:"",topicsAreTitles:!1,title:"",sections:"",model:nr,temperature:.8,maxTokens:2048,sectionsCount:2,paragraphsCount:3,language:"en",customLanguage:"",writingStyle:"creative",writingTone:"cheerful",titlePromptFormat:'Write a title for an article about "{TOPIC}" in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Must be between 40 and 60 characters. Only the title, no formatting, no Markdown, no special characters.',sectionsPromptFormat:'Write {SECTIONS_COUNT} consecutive headings for an article about "{TITLE}", in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Each heading is between 40 and 60 characters. Use Markdown for the headings (## ).',contentPromptFormat:'Write an article about "{TITLE}" in {LANGUAGE}. The article is organized by the following headings:\n\n{SECTIONS}\n\nWrite {PARAGRAPHS_PER_SECTION} paragraphs per heading. Use Markdown for formatting. Add an introduction prefixed by "===INTRO: ", and a conclusion prefixed by "===OUTRO: ". Style: {WRITING_STYLE}. Tone: {WRITING_TONE}.',excerptPromptFormat:'Write an excerpt for an article about "{TITLE}" in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Must be between 40 and 60 characters.'},{id:"",name:"Explore Japan",mode:"single",topic:"Tokyo, its main areas and attractions, one day tour for a first-time visitor. Simple vocabulary, short paragraphs.",topics:"",topicsAreTitles:!1,title:"",sections:"",model:nr,temperature:.8,maxTokens:2048,sectionsCount:3,paragraphsCount:2,language:"en",customLanguage:"",writingStyle:"informative",writingTone:"informal",titlePromptFormat:'Write a title for an article about "{TOPIC}" in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Must be between 40 and 60 characters.',sectionsPromptFormat:'Write {SECTIONS_COUNT} consecutive headings for an article about "{TITLE}", in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Each heading is between 40 and 60 characters. Use Markdown for the headings (## ).',contentPromptFormat:'Write an article about "{TITLE}" in {LANGUAGE}. The article is organized by the following headings:\n\n{SECTIONS}\n\nWrite {PARAGRAPHS_PER_SECTION} paragraphs per heading. Use Markdown for formatting. Add an introduction prefixed by "===INTRO: ", and a conclusion prefixed by "===OUTRO: ". Style: {WRITING_STYLE}. Tone: {WRITING_TONE}.',excerptPromptFormat:'Write an excerpt for an article about "{TITLE}" in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Must be between 40 and 60 characters.'}],{useState:cr,useEffect:ir,useMemo:sr}=wp.element;function mr(){return(new Date).getTime().toString(36)+Math.random().toString(36).substr(2,9)}const dr=e=>{const t=[...e];return t.sort(((e,t)=>e.name.localeCompare(t.name))),t},ur=(e="playground")=>{const[t,a]=cr(),[n,l]=cr(!1),[r,c]=cr([]),{isLoading:i,data:s}=(0,o.I)({queryKey:[`templates-${e}`],queryFn:()=>(async e=>{try{const t=await(0,y.IU)(`${_}/system/templates?category=${e}`,{nonce:N});let a=[];"imagesGenerator"===e?a=rr:"playground"===e?a=lr:"contentGenerator"===e&&(a=or);const n=a.find((e=>"default"===e.id));return null!=t&&t.templates&&t.templates.length>0&&(a=dr(t.templates)),n?a.forEach((e=>{Object.keys(n).forEach((t=>{void 0===e[t]&&(e[t]=n[t])}))})):console.warn("Default template not found for category: "+e),a}catch(e){console.error(e),alert(e.message)}})(e)});ir((()=>{for(let t=0;t<r.length;t++){const a=r[t];let n=!1;if(a&&(!a.envId||!a.model)){const t=(null==I?void 0:I.ai_default_env)||null;let l=(null==I?void 0:I.ai_default_model)||null;"imagesGenerator"===e&&(l="dall-e-3-hd"),t&&l&&(a.envId=t,a.model=l,n=!0)}n&&c([...r])}}),[r]),ir((()=>{s&&(c(s),a(s[0]))}),[s]);const m=async t=>{t=dr(t),c(t);try{return await(0,y.IU)(`${_}/system/templates`,{method:"POST",nonce:N,json:{category:e,templates:t}})}catch(e){console.error(e),alert(e.message)}},d=sr((()=>{if(!t||0===r.length)return!1;if(Object.keys(t).length!==Object.keys(r.find((e=>e.id===t.id))).length)return!0;const e=r.find((e=>e.id===t.id));return Object.keys(e).some((a=>e[a]!==t[a]))}),[t,r]),u=()=>{const e=r.find((e=>e.id===t.id));e&&a({...e})},E=()=>{const e=prompt(Ee.COMMON.NAME,t.name||Ee.TEMPLATES.NEW_TEMPLATE_NAME);if(!e)return!1;const n={...t,id:mr(),name:e};m([...r,n]),a({...n})},p=()=>{const e=r.map((e=>e.id===t.id?t:e));m(e),a({...t})},g=()=>{const e=prompt("Template Name",t.name),n={...r[0],id:mr(),name:e};m([...r,n]),a({...n})},h=()=>{const e=prompt("Template Name",t.name);if(!e)return;const n=r.map((a=>a.id===t.id?{...a,name:e}:a));m([...n]),a({...n.find((e=>e.id===t.id))})},b=()=>{if(!confirm(Ee.TEMPLATES.DELETE_ALL_CONFIRM))return;let t=[];"imagesGenerator"===e?t=[...rr]:"playground"===e?t=[...lr]:"contentGenerator"===e&&(t=[...or]),m(t),a({...t[0]})},v=sr((()=>d&&t&&"default"!==t.id),[d,t]),f=sr((()=>t&&"default"!==t.id),[t]),w=sr((()=>t&&"default"!==t.id),[t]),C=sr((()=>React.createElement("div",{style:{margin:"0"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},React.createElement("h3",{style:{margin:0}},Ee.TEMPLATES.TEMPLATE),React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},React.createElement(Ke.S,{small:!0,onLabel:Ee.TEMPLATES.EDIT,offLabel:Ee.TEMPLATES.EDIT,width:60,onChange:l,checked:n}))),i&&React.createElement("div",{style:{display:"flex",marginTop:30,justifyContent:"center"}},React.createElement("div",{style:{width:60}},React.createElement(er.X,{width:20}))),React.createElement(ae.g,null),n&&React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex"}},React.createElement(R.M,{className:"primary",style:{flex:3},onClick:g},"New"),React.createElement(R.M,{onClick:E,style:{flex:1}},"Duplicate")),React.createElement(ae.g,{tiny:!0})),React.createElement(ee.u,{scrolldown:!0,name:"template",value:null==t?void 0:t.id,onChange:e=>{const t=r.find((t=>t.id===e));a({...t})}},r.filter((e=>"default"!==e.id)).map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name})))),(d||n)&&React.createElement("div",null,React.createElement(ae.g,{tiny:!0}),React.createElement("div",{style:{display:"flex"}},React.createElement(R.M,{className:"secondary",style:{flex:1},disabled:!v,onClick:u},"Reset"),React.createElement(R.M,{className:"primary",style:{flex:3},disabled:!v,onClick:p},"Save")),n&&React.createElement(React.Fragment,null,React.createElement(ae.g,{tiny:!0}),React.createElement("div",{style:{display:"flex"}},React.createElement(R.M,{small:!0,className:"danger",style:{flex:1},disabled:!w,onClick:()=>(e=>{if(!confirm(Ee.TEMPLATES.DELETE_CONFIRM))return;const t=r.filter((t=>t.id!==e.id));m([...t]),a({...t[0]})})(t)},"Delete"),React.createElement(R.M,{small:!0,className:"secondary",style:{flex:3},disabled:!f,onClick:h},"Rename")))),n&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement("div",{style:{display:"flex"}},React.createElement(R.M,{className:"danger",style:{flex:1},onClick:b},"Reset All Templates"))))),[r,t,n,d,v,i]);return{template:t,clearTemplate:u,setTemplate:e=>{a(e)},jsxTemplates:C,isEdit:n}},{useState:Er,useMemo:pr}=wp.element,gr=e=>{const[t,a]=Er(0),[n,l]=Er(0),r=()=>{a(0),l(0)};return{addUsage:(n,r,o)=>{const c=e(n,r,o);l(c),a(t+c)},jsxUsageCosts:pr((()=>{let e=(0,y.FE)(Ee.COMMON.USAGE_HELP);return T||(e=React.createElement(React.Fragment,null,e," ",(0,y.FE)(Ee.COMMON.USAGE_PRO_HELP))),React.createElement(sa,null,React.createElement("h3",null,Ee.COMMON.USAGE),React.createElement("div",null,"Session: ",React.createElement("span",{style:{float:"right"}},"$",t.toFixed(4))),React.createElement("div",null,"Last Request: ",React.createElement("span",{style:{float:"right"}},"$",n.toFixed(4))),React.createElement(ae.g,{height:30}),React.createElement("p",{style:{fontSize:12,lineHeight:1.2,color:"var(--neko-dark-gray)"}},e),React.createElement(R.M,{fullWidth:!0,onClick:r},"Reset Usage"))}),[t,n])}},{useState:Rr,useEffect:hr}=wp.element,yr=(0,P.Ay)(Ye.m)`
.neko-textarea-container {
textarea {
color: white;
font-size: 13px;
padding: 10px;
font-family: monospace;
background: #333d4e;
border: none;
&:focus {
background-color: #333d4e;
}
}
}
`,br=()=>{const{template:e,setTemplate:t,jsxTemplates:a}=ur("playground"),[n,l]=Rr(""),[r,o]=Rr(!1),[c,s]=Rr(""),[m,d]=Rr(),[E,g]=Rr(),h=(null==e?void 0:e.prompt)??"",b=(null==e?void 0:e.model)??"gpt-3.5-turbo",v=(null==e?void 0:e.mode)??"query",f=(null==e?void 0:e.temperature)??1,w=(null==e?void 0:e.envId)??"",C=(null==e?void 0:e.stopSequence)??"",O=(null==e?void 0:e.maxTokens)??2048,{calculatePrice:T,completionModels:S}=ve(I,w||null),{addUsage:k,jsxUsageCosts:x}=gr(T),P=(null==I?void 0:I.ai_envs)||[],L=(a,n)=>{t({...e,[n]:a})},D=a=>{t({...e,prompt:a})};hr((()=>{e&&l("")}),[e]);const F=async(e=h)=>{o(!0),d(new Date);try{var t,a;const n=C.replace(/\\n/g,"\n"),r=A?e=>{l(e)}:null,o=await(0,ba.ti)(`${_}/ai/completions`,{scope:"playground",session:M,message:e,temperature:f,envId:w,model:b,maxTokens:O,stop:n,stream:A},N,A),c=!1,i=await(0,ba.Pn)(o,r,c?"PLAYGROUND":null);if(!1===(null==i?void 0:i.success))throw new Error(null==i?void 0:i.message);console.log("Completions",{prompt:e,result:i}),"continuous"===v?D(e+"\n"+i.data+"\n"):l(i.data),k(b,(null==i||null===(t=i.usage)||void 0===t?void 0:t.prompt_tokens)||0,(null==i||null===(a=i.usage)||void 0===a?void 0:a.completion_tokens)||0)}catch(e){g(e.message)}d(),o(!1)};return React.createElement(u.z,{nekoErrors:[]},React.createElement(Ue,{title:Ee.COMMON.PLAYGROUND}),React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0},React.createElement(be,{options:I}),React.createElement(ne.L,{style:{marginBottom:0}},React.createElement(i.s,{p:!0},(0,y.FE)(Ee.PLAYGROUND.INTRO)))),React.createElement(p.Y,null,React.createElement(sa,null,a)),React.createElement(p.Y,{style:{flex:3}},React.createElement(sa,null,"continuous"!==v&&React.createElement(React.Fragment,null,React.createElement(yr,{rows:12,onChange:D,value:h})),"continuous"===v&&React.createElement(React.Fragment,null,React.createElement(yr,{rows:18,onChange:D,value:h}),React.createElement("div",{style:{display:"flex"}},React.createElement("span",{className:"dashicons dashicons-format-continuous",style:{position:"absolute",color:"white",zIndex:200,fontSize:28,marginTop:12,marginLeft:10}}),React.createElement(ma,{name:"continuousEntry",value:c,onChange:s,onEnter:()=>{const e=h+"Human: "+c;D(e),s(""),F(e)},disabled:r})))),React.createElement(ae.g,null),(n||r)&&React.createElement(sa,null,React.createElement(ba.CI,{content:n,isStreaming:A&&r}))),React.createElement(p.Y,null,"query"===v&&React.createElement(React.Fragment,null,React.createElement(sa,null,React.createElement(R.M,{fullWidth:!0,onClick:()=>{F()},isBusy:r,startTime:m,style:{height:50,fontSize:14,flex:4}},Ee.COMMON.SUBMIT)),React.createElement(ae.g,null)),React.createElement(sa,null,React.createElement("h3",null,Ee.COMMON.SETTINGS),React.createElement("label",null,Ee.COMMON.ENVIRONMENT,":"),React.createElement(ee.u,{scrolldown:!0,name:"envId",value:w??"",onChange:L},P.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(ee.j,{value:"",label:"None"})),React.createElement("label",null,Ee.COMMON.MODEL,":"),React.createElement(ee.u,{name:"model",value:b,scrolldown:!0,onChange:L},S.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name})))),React.createElement("label",null,Ee.COMMON.TEMPERATURE,":"),React.createElement(te.A,{name:"temperature",value:f,type:"number",onChange:e=>L(parseFloat(e),"temperature"),description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:f>=0&&f<=1?"inherit":"red"}},Ee.HELP.TEMPERATURE))}),React.createElement("label",null,Ee.COMMON.MAX_TOKENS,":"),React.createElement(te.A,{name:"maxTokens",value:O,type:"number",onChange:e=>L(parseInt(e),"maxTokens"),description:React.createElement(React.Fragment,null,React.createElement("span",null,Ee.HELP.MAX_TOKENS))}),React.createElement("label",null,Ee.COMMON.STOP_SEQUENCE,":"),React.createElement(te.A,{name:"stopSequence",value:C,type:"text",onChange:L,description:React.createElement(React.Fragment,null,React.createElement("span",null,Ee.HELP.STOP_SEQUENCE))})),React.createElement(ae.g,null),x)),React.createElement(re.n,{isOpen:E,onRequestClose:()=>{g()},okButton:{onClick:()=>{g()}},title:"Error",content:React.createElement("p",null,E)}))},vr=P.Ay.div`
margin-bottom: 5px;
`,fr=P.Ay.div`
margin-top: 5px;
padding: 10px;
font-size: 14px;
cursor: pointer;
background: #dbf2ff;
&:hover {
background: #037cba;
color: white;
}
`,{useState:_r,useEffect:wr,useMemo:Cr}=wp.element,Or=e=>{const{post:t,onTitleClick:a={},onClose:n={}}=e,[l,r]=_r([]),[o,c]=_r(!1),[i,s]=_r(!1);wr((()=>{t&&m(t)}),[t]);const m=async({postId:e,postTitle:t})=>{c(!0);try{var a;const t=await(0,y.IU)(`${_}/ai/magic_wand`,{method:"POST",nonce:N,json:{action:"suggestTitles",data:{postId:e}}});r(null===(a=t.data)||void 0===a?void 0:a.results)}catch(e){console.error(e),s(e.message)}c(!1)},d=async()=>{n(),r([]),s(),c(!1)},u=Cr((()=>o?React.createElement(er.X,{type:"circle",size:"10%"}):i?React.createElement(React.Fragment,null,"Error: ",i):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick a new title by clicking on it.",React.createElement(vr,null,l.map((e=>React.createElement(fr,{key:e,onClick:()=>{(async e=>{c(!0);try{await a(e),d()}catch(e){s(e.message)}c(!1)})(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[o,l,i]);return React.createElement(p.N,null,React.createElement(re.n,{isOpen:t,onRequestClose:d,title:`New title for "${null==t?void 0:t.postTitle}"`,content:u,okButton:{label:"Close",onClick:d}}))},{useState:Tr,useEffect:Nr,useMemo:Ir}=wp.element,Mr=e=>{const{post:t,onExcerptClick:a={},onClose:n={}}=e,[l,r]=Tr([]),[o,c]=Tr(!1),[i,s]=Tr(!1);Nr((()=>{t&&m(t)}),[t]);const m=async({postId:e})=>{c(!0);try{var t;const a=await(0,y.IU)(`${_}/ai/magic_wand`,{method:"POST",nonce:N,json:{action:"suggestExcerpts",data:{postId:e}}});r(null===(t=a.data)||void 0===t?void 0:t.results)}catch(e){console.error(e),s(e.message)}c(!1)},d=async()=>{n(),r([]),s(),c(!1)},u=Ir((()=>o?React.createElement(er.X,{type:"circle",size:"10%"}):i?React.createElement(React.Fragment,null,"Error: ",i):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick a new excerpt by clicking on it.",React.createElement(vr,null,l.map((e=>React.createElement(fr,{key:e,onClick:()=>{(async e=>{c(!0);try{await a(e),d()}catch(e){s(e.message)}c(!1)})(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[o,l,i]);return React.createElement(p.N,null,React.createElement(re.n,{isOpen:t,onRequestClose:d,title:`New excerpt for "${null==t?void 0:t.postTitle}"`,content:u,okButton:{label:"Close",onClick:d}}))},{useState:Sr,useEffect:Ar}=wp.element,kr=()=>{const[e,t]=Sr();return Ar((()=>{document.querySelectorAll(".mwai-link-title").forEach((e=>{const a=e.getAttribute("data-id"),n=e.getAttribute("data-title");e.addEventListener("click",(()=>{t({postId:a,postTitle:n,mode:"title"})}),!1)})),document.querySelectorAll(".mwai-link-excerpt").forEach((e=>{const a=e.getAttribute("data-id"),n=e.getAttribute("data-title");e.addEventListener("click",(()=>{t({postId:a,postTitle:n,mode:"excerpt"})}),!1)}))}),[]),React.createElement(r.A,null,React.createElement(p.N,null,React.createElement(Or,{post:"title"===(null==e?void 0:e.mode)?e:null,onTitleClick:async a=>{const n=await(0,y.IU)(`${_}/helpers/update_post_title`,{method:"POST",nonce:N,json:{postId:e.postId,title:a}});if(!n.success)throw new Error(n.message);{t();const n=document.querySelector(`tr[id="post-${e.postId}"]`);if(n){const e=n.querySelector(".row-title");e&&(e.innerHTML=a)}const l=n.querySelector(".hidden .post_title");l&&(l.innerHTML=a)}},onClose:()=>{t()}}),React.createElement(Mr,{post:"excerpt"===(null==e?void 0:e.mode)?e:null,onExcerptClick:async a=>{const n=await(0,y.IU)(`${_}/helpers/update_post_excerpt`,{method:"POST",nonce:N,json:{postId:e.postId,excerpt:a}});if(!n.success)throw new Error(n.message);t()},onClose:()=>{t()}})))},{useState:xr,useEffect:Pr,useMemo:Lr}=wp.element,Dr=()=>{const[e,t]=xr(""),[a,n]=xr(""),{template:l,setTemplate:r,clearTemplate:c,jsxTemplates:s}=ur("contentGenerator"),m=(0,Je.XS)(),[E,g]=xr(!1),[h,b]=xr(),[v,f]=xr(!1),[w,C]=xr(!1),[O,T]=xr(!1),[S,A]=xr(),[k,x]=xr("post"),[P,L]=xr([]),[D,F]=xr([]),[U,B]=xr({}),{isLoading:G,data:H}=(0,o.I)({queryKey:["postTypes"],queryFn:Ze}),j=m.busy||E||G,$=(null==l?void 0:l.title)??"",Y=(null==l?void 0:l.sections)??"",W=(null==l?void 0:l.mode)??"single",z=(null==l?void 0:l.topic)??"",V=(null==l?void 0:l.topics)??"",K=(null==l?void 0:l.model)??(null==I?void 0:I.ai_default_model)??null,q=(null==l?void 0:l.sectionsCount)??2,X=(null==l?void 0:l.paragraphsCount)??3,Q=(null==l?void 0:l.writingStyle)??"creative",J=(null==l?void 0:l.writingTone)??"cheerful",Z=(null==l?void 0:l.titlePromptFormat)??"",ne=(null==l?void 0:l.sectionsPromptFormat)??"",le=(null==l?void 0:l.contentPromptFormat)??"",oe=(null==l?void 0:l.excerptPromptFormat)??"",ce=(null==l?void 0:l.envId)??"",ie=(null==l?void 0:l.temperature)??.6,se=null==l?void 0:l.maxTokens,me=(null==l?void 0:l.topicsAreTitles)??!1,de=!ne||!q,ue=(null==l?void 0:l.useMaxTokens)??!1,{completionModels:pe,calculatePrice:ye}=ve(I,ce||null),{addUsage:fe,jsxUsageCosts:_e}=gr(ye),we=(null==I?void 0:I.ai_envs)||[],{jsxLanguageSelector:Ce,currentLanguage:Oe,isCustom:Te,currentHumanLanguage:Ne}=(({disabled:e,options:t,language:a,customLanguage:n})=>{const[l,r]=Re(a??"en"),[o,c]=Re(!1),[i,s]=Re(""),m=(null==t?void 0:t.languages)||[],d=ge((()=>Object.keys(m).map((e=>({value:e,label:m[e]})))),[m]);he((()=>{n?(c(!0),s(n)):(c(!1),s(""),r(a??"en"))}),[n]),he((()=>{r(a)}),[a]),he((()=>{const e=localStorage.getItem("mwai_preferred_language");if(e&&d.find((t=>t.value===e)))return void r(e);const t=(document.querySelector("html").lang||navigator.language||navigator.userLanguage).substr(0,2);d.find((e=>e.value===t))&&r(t)}),[]);const u=ge((()=>{if(o)return i;const e=d.find((e=>e.value===l));return e?e.label:(console.warn("A system language or a custom language should be set."),"English")}),[l,i]),E=(e,t)=>{"custom"!==e?(r(e,t),localStorage.setItem("mwai_preferred_language",e)):c(!0)};return{jsxLanguageSelector:ge((()=>React.createElement(React.Fragment,null,o&&React.createElement(te.A,{name:"customLanguage",disabled:e,onReset:()=>{c(!1)},description:(0,y.FE)(Ee.CONTENT_GENERATOR.CUSTOM_LANGUAGE_HELP),value:i,onChange:s}),!o&&React.createElement(ee.u,{scrolldown:!0,name:"language",disabled:e,description:(0,y.FE)(Ee.CONTENT_GENERATOR.CUSTOM_LANGUAGE_HELP),value:l,onChange:E},d.map((e=>React.createElement(ee.j,{key:e.value,value:e.value,label:e.label}))),React.createElement(ee.j,{key:"custom",value:"custom",label:"Other"})))),[l,u,d,o]),currentLanguage:o?"custom":l,currentHumanLanguage:u,isCustom:o}})({options:I,language:null==l?void 0:l.language,customLanguage:null==l?void 0:l.customLanguage}),Ie=Lr((()=>(e=>{if(!e)return null;const t=e.split(" ").length,a=e.length,n=[];return a?(t<3?n.push(Ee.CONTENT_GENERATOR.TITLE_TOO_SHORT):t>8?n.push(Ee.CONTENT_GENERATOR.TITLE_TOO_LONG):a<40?n.push(Ee.CONTENT_GENERATOR.TITLE_TOO_SHORT):a>70&&n.push(Ee.CONTENT_GENERATOR.TITLE_TOO_LONG_2),n.join(" ")):void 0})($)),[$]),Me=(e,t)=>{r((a=>({...a,[t]:e})))};Pr((()=>{const e=V.split("\n").map((e=>e.trim())).filter((e=>!!e));L(e)}),[V]),Pr((()=>{l&&Me("","sections")}),[$,q]),Pr((()=>{t(""),n(""),A()}),[Y,X]),Pr((()=>{l&&(!Te&&l.customLanguage&&Me(null,"customLanguage"),Te&&l.customLanguage!==Ne&&Me(Ne,"customLanguage"),l.language!==Oe&&Me(Oe,"language"))}),[Te,Oe,Ne]);const Se=e=>e.replace("{LANGUAGE}",Ne).replace("{WRITING_STYLE}",Q).replace("{WRITING_TONE}",J).replace("{PARAGRAPHS_PER_SECTION}",X).replace("{SECTIONS_COUNT}",q),Ae=Lr((()=>{const e=(e,t)=>!!t.find((t=>t.includes(e))),t=[Z,ne,le,oe];return{language:e("{LANGUAGE}",t),writingStyle:e("{WRITING_STYLE}",t),writingTone:e("{WRITING_TONE}",t),sectionsCount:e("{SECTIONS_COUNT}",t),paragraphsCount:e("{PARAGRAPHS_PER_SECTION}",t)}}),[Z,ne,le,oe,q,X]),ke=async(e,t=!1)=>{try{var a,n;const t={scope:"admin-tools",envId:ce||null,model:K||null,session:M,message:e,temperature:ie};ue&&se&&(t.maxTokens=se);const l=await(0,y.IU)(`${_}/ai/completions`,{method:"POST",nonce:N,json:t});fe(K,(null==l||null===(a=l.usage)||void 0===a?void 0:a.prompt_tokens)||0,(null==l||null===(n=l.usage)||void 0===n?void 0:n.completion_tokens)||0);let r=l.data.trim();return r.startsWith('"')&&r.endsWith('"')&&(r=r.substring(1,r.length-1)),r}catch(e){if(t)throw new Error(e.message);return console.error(e),b(e.message),null}},xe=async(e=z,t=$,a=!1)=>{if(!t)return void alert(Ee.CONTENT_GENERATOR.TITLE_MISSING);g(!0),Me("","sections");let n=ne.replace("{TITLE}",t).replace("{TOPIC}",e);n=Se(n);let l=await ke(n,a);var r;return l=(r=l)?r.split("\n").map((e=>((e=e.replace(/^\d+\.\s/,"")).startsWith('"')&&(e=e.slice(1)).endsWith('"')&&(e=e.slice(0,-1)),e))).filter((e=>e)).join("\n"):r,l&&Me(l,"sections"),g(!1),l},Pe=async(e=z,a=$,n=Y,l=!1)=>{if(!a)return void alert(Ee.CONTENT_GENERATOR.TITLE_MISSING);if(!de&&!n)return void alert(Ee.CONTENT_GENERATOR.SECTIONS_MISSING);g(!0),t((()=>""));let r=le.replace("{TITLE}",a).replace("{SECTIONS}",n).replace("{TOPIC}",e);r=Se(r);let o=await ke(r,l);return o&&(o=o.replace(/^===INTRO:\n/,"").replace(/^===INTRO: \n/,"").replace(/===INTRO: /,"").replace(/===OUTRO:\n/,"").replace(/===OUTRO: \n/,"").replace(/===OUTRO: /,""),t((()=>o))),g(!1),o},Le=async(e=z,t=$,a=!1)=>{if(!t)return void alert(Ee.CONTENT_GENERATOR.TITLE_MISSING);g(!0),n((()=>""));let l=oe.replace("{TITLE}",t).replace("{TOPIC}",e);l=Se(l);const r=await ke(l,a);return r&&n((()=>r)),g(!1),r},De=async(e=z,t=!1)=>{g(!0),B({...U,all:new Date});try{let a=e;if(!me||!t){const n=Se(Z.replace("{TOPIC}",e));a=await ke(n,t)}let n=null,l=null,r=null;return g(!1),a&&(Me(a,"title"),de||(B((e=>({...e,sections:new Date}))),n=await xe(e,a,t),B((e=>({...e,sections:null})))),(n||de)&&(B((e=>({...e,content:new Date}))),l=await Pe(e,a,n,t),B((e=>({...e,content:null}))),l&&(B((e=>({...e,excerpt:new Date}))),r=await Le(e,a,t),B((e=>({...e,excerpt:null})))))),{title:a,heads:n,content:l,excerpt:r}}catch(e){throw console.error(e),g(!1),B({}),e}},Fe=async(t=$,n=e,l=a,r=!1)=>{g(!0);try{const e=await(0,y.IU)(`${_}/helpers/create_post`,{method:"POST",nonce:N,json:{title:t,content:n,excerpt:l,postType:k}});return r||A(e.postId),e.postId}catch(e){return console.error(e),b(e.message),null}finally{g(!1)}};return React.createElement(u.z,{nekoErrors:[]},React.createElement(Ue,{title:Ee.COMMON.CONTENT_GENERATOR}),React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0},React.createElement(be,{options:I}),React.createElement(i.s,{p:!0,style:{marginTop:0,marginBottom:0}},(0,y.FE)(Ee.CONTENT_GENERATOR.INTRO))),React.createElement(p.Y,{style:{flex:1}},React.createElement(sa,null,React.createElement("h2",{style:{marginTop:0}},"Topic"),React.createElement(Ye.m,{name:"topic",disabled:j||"bulk"===W,rows:5,value:z,onChange:Me}),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,disabled:!z||"bulk"===W,isBusy:j,startTime:null==U?void 0:U.all,onClick:()=>De()},Ee.COMMON.GENERATE)),React.createElement(ae.g,null),React.createElement(sa,null,s)),React.createElement(p.Y,{style:{flex:3}},React.createElement(We.o,{name:"mode",value:W,disabled:j,onChange:Me},React.createElement(We.K,{title:Ee.CONTENT_GENERATOR.SINGLE_GENERATE,value:"single"}),React.createElement(We.K,{title:Ee.CONTENT_GENERATOR.BULK_GENERATE,value:"bulk",count:P.length})),React.createElement(ae.g,null),"bulk"===W&&React.createElement(sa,null,React.createElement("p",{style:{marginTop:0,marginBottom:20}},(0,y.FE)(Ee.CONTENT_GENERATOR.TOPICS_HELP)),React.createElement("div",{style:{display:"flex"}},React.createElement(R.M,{disabled:j||!P.length,onClick:async()=>{F([]);const e=P.map(((e,t)=>async()=>{console.log("Topic "+t);try{const{title:t,content:a,excerpt:n}=await De(e,!0);if(t&&a&&n){const l=await Fe(t,a,n,!0);F((r=>[...r,{postId:l,topic:e,title:t,content:a,excerpt:n}]))}else console.warn("Could not generate the post for: "+e)}catch(e){confirm("An error was caught ("+e.message+"). Should we continue?")||(m.stop(),m.reset(),g(!1))}return{success:!0}}));await m.start(e),m.reset()}},Ee.COMMON.GENERATE),React.createElement(Qe.j,{busy:m.busy,style:{marginLeft:10,flex:"auto"},value:m.value,max:m.max,onStopClick:m.stop})),React.createElement(ae.g,null),React.createElement("h3",null,"Topics"),React.createElement(Ye.m,{name:"topics",rows:10,value:V,onChange:Me}),React.createElement(d.R,{name:"topicsAreTitles",label:"Use Topics as Titles",value:"1",checked:me,onChange:Me}),React.createElement("h3",null,Ee.CONTENT_GENERATOR.GENERATED_POSTS),!D.length&&React.createElement("i",null,"Nothing yet."),D.length>0&&React.createElement("ul",null,D.map((e=>React.createElement("li",{key:e.postId},e.title," ",React.createElement("a",{target:"_blank",href:`/?p=${e.postId}`,rel:"noreferrer"},"View")," ","or"," ",React.createElement("a",{target:"_blank",href:`/wp-admin/post.php?post=${e.postId}&action=edit`,rel:"noreferrer"},"Edit")))))),"single"===W&&React.createElement(sa,null,React.createElement("h2",{style:{marginTop:0}},"Title"),React.createElement(te.A,{name:"title",disabled:j,value:$,onChange:Me}),Ie&&React.createElement("div",{className:"information"},"Advice: ",Ie),ne&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(Be,null,React.createElement("h2",null,Ee.CONTENT_GENERATOR.SECTIONS),React.createElement("div",{style:{display:"flex",alignItems:"center"}},Ae.sectionsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Sections:"," "),React.createElement(ee.u,{scrolldown:!0,name:"sectionsCount",disabled:j,style:{marginRight:10},value:q,description:"",onChange:Me},[2,3,4,6,8,10,12].map((e=>React.createElement(ee.j,{key:e,value:e,label:e}))))),q>0&&React.createElement(R.M,{disabled:!$,isBusy:j,startTime:null==U?void 0:U.sections,onClick:()=>xe()},Ee.CONTENT_GENERATOR.GENERATE_SECTIONS))),q>0&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(Ye.m,{name:"sections",disabled:j,rows:4,value:Y,description:Ee.CONTENT_GENERATOR.SECTIONS_HELP,onChange:Me}))),React.createElement(ae.g,null),React.createElement(Be,null,React.createElement("h2",null,Ee.COMMON.CONTENT),React.createElement("div",{style:{display:"flex",alignItems:"center"}},Ae.paragraphsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},Ee.CONTENT_GENERATOR.PARAGRAPHS_PER_SECTION,": "),React.createElement(ee.u,{scrolldown:!0,name:"paragraphsCount",disabled:j,style:{marginRight:10},value:X,description:"",onChange:Me},[1,2,3,4,6,8,10].map((e=>React.createElement(ee.j,{key:e,value:e,label:e}))))),React.createElement(R.M,{disabled:!$,isBusy:j,startTime:null==U?void 0:U.content,onClick:()=>Pe()},Ee.CONTENT_GENERATOR.GENERATE_CONTENT))),React.createElement(ae.g,null),React.createElement(Ye.m,{countable:"words",disabled:j,rows:12,value:e,description:Ee.CONTENT_GENERATOR.CONTENT_HELP,onChange:t}),React.createElement(ae.g,null),React.createElement(Be,null,React.createElement("h2",null,Ee.COMMON.EXCERPT),React.createElement(R.M,{disabled:!$,isBusy:j,startTime:null==U?void 0:U.excerpt,onClick:()=>Le()},Ee.CONTENT_GENERATOR.GENERATE_EXCERPT)),React.createElement(ae.g,null),React.createElement(Ye.m,{disabled:j,value:a,onBlur:n,rows:3}),React.createElement(ae.g,{line:!0,height:40}),React.createElement(ee.u,{scrolldown:!0,disabled:j,name:"postType",onChange:x,value:k},null==H?void 0:H.map((e=>React.createElement(ee.j,{key:e.type,value:e.type,label:e.name})))),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,style:{height:60},onClick:()=>Fe(),isBusy:j,disabled:!$||!e},Ee.CONTENT_GENERATOR.CREATE_POST))),React.createElement(p.Y,null,React.createElement(sa,null,React.createElement("h2",{style:{marginTop:0}},Ee.CONTENT_GENERATOR.CONTENT_PARAMS),!Ae.language&&!Ae.writingStyle&&!Ae.writingTone&&React.createElement("div",{style:{fontSize:11,lineHeight:"14px"}},Ee.CONTENT_GENERATOR.CONTENT_PARAMS_INTRO),Ae.language&&React.createElement(React.Fragment,null,React.createElement("label",null,Ee.COMMON.LANGUAGE,":"),Ce),Ae.writingStyle&&React.createElement(React.Fragment,null,React.createElement("label",null,Ee.CONTENT_GENERATOR.WRITING_STYLE,":"),React.createElement(ee.u,{scrolldown:!0,name:"writingStyle",disabled:j,value:Q,description:"",onChange:Me},tr.map((e=>React.createElement(ee.j,{key:e.value,value:e.value,label:e.label}))))),Ae.writingTone&&React.createElement(React.Fragment,null,React.createElement("label",null,Ee.CONTENT_GENERATOR.WRITING_TONE,":"),React.createElement(ee.u,{scrolldown:!0,name:"writingTone",disabled:j,value:J,description:"",onChange:Me},ar.map((e=>React.createElement(ee.j,{key:e.value,value:e.value,label:e.label})))))),React.createElement(ae.g,null),React.createElement(sa,null,React.createElement(Be,null,React.createElement("h2",null,Ee.CONTENT_GENERATOR.POST_PARAMS),React.createElement(R.M,{onClick:()=>C(!w)},w?Ee.COMMON.HIDE:Ee.COMMON.SHOW)),w&&React.createElement(React.Fragment,null,React.createElement("label",null,Ee.COMMON.POST_TYPE,":"),React.createElement(ee.u,{scrolldown:!0,disabled:j,name:"postType",onChange:x,value:k},null==H?void 0:H.map((e=>React.createElement(ee.j,{key:e.type,value:e.type,label:e.name})))))),React.createElement(ae.g,null),React.createElement(sa,null,React.createElement(Be,null,React.createElement("h2",null,Ee.COMMON.MODEL_PARAMS),React.createElement(R.M,{onClick:()=>f(!v)},v?Ee.COMMON.HIDE:Ee.COMMON.SHOW)),v&&React.createElement(React.Fragment,null,React.createElement("label",null,Ee.COMMON.ENVIRONMENT,":"),React.createElement(ee.u,{scrolldown:!0,name:"envId",value:ce??"",onChange:Me},we.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(ee.j,{value:"",label:"None"})),React.createElement("label",null,Ee.COMMON.MODEL,":"),React.createElement(ee.u,{name:"model",value:K,description:Ee.CONTENT_GENERATOR.MODEL_HELP,scrolldown:!0,onChange:Me},pe.map((e=>React.createElement(ee.j,{key:e,value:e.model,label:e.name})))),React.createElement("label",null,Ee.COMMON.TEMPERATURE,":"),React.createElement(te.A,{name:"temperature",value:ie,type:"number",onChange:Me,onBlur:Me,description:Ee.HELP.TEMPERATURE}),React.createElement(d.R,{name:"useMaxTokens",label:"Use Max Tokens",value:"1",checked:ue,onChange:Me}),React.createElement("label",null,Ee.COMMON.MAX_TOKENS,":"),React.createElement(te.A,{name:"maxTokens",value:se??"",type:"number",onChange:Me,onBlur:Me,description:Ee.HELP.MAX_TOKENS,disabled:!ue}))),React.createElement(ae.g,null),React.createElement(sa,null,React.createElement(Be,null,React.createElement("h2",null,(0,y.FE)(Ee.COMMON.PROMPTS)),React.createElement(R.M,{onClick:()=>T(!O)},O?"Hide":"Show")),O&&React.createElement(React.Fragment,null,React.createElement("p",{style:{fontSize:11,lineHeight:"14px"}},Ee.CONTENT_GENERATOR.PROMPTS_INTRO),React.createElement("label",null,(0,y.FE)(Ee.CONTENT_GENERATOR.PROMPT_TITLE)),React.createElement(Ye.m,{disabled:j,name:"titlePromptFormat",value:Z,onChange:Me}),React.createElement("label",null,(0,y.FE)(Ee.CONTENT_GENERATOR.PROMPT_SECTIONS)),React.createElement(Ye.m,{disabled:j,name:"sectionsPromptFormat",value:ne,onChange:Me}),React.createElement("label",null,(0,y.FE)(Ee.CONTENT_GENERATOR.PROMPT_CONTENT)),React.createElement(Ye.m,{disabled:j,name:"contentPromptFormat",value:le,onChange:Me}),React.createElement("label",null,(0,y.FE)(Ee.CONTENT_GENERATOR.PROMPT_EXCERPT)),React.createElement(Ye.m,{disabled:j,name:"excerptPromptFormat",value:oe,onChange:Me}))),React.createElement(ae.g,null),_e)),React.createElement(re.n,{isOpen:S,onRequestClose:()=>A(),okButton:{label:Ee.CONTENT_GENERATOR.EDIT_POST,onClick:()=>{window.open(`/wp-admin/post.php?post=${S}&action=edit`,"_blank"),c(),A()}},cancelButton:{label:"Close",onClick:()=>{A()}},title:Ee.CONTENT_GENERATOR.POST_CREATED,content:React.createElement("p",null,Ee.CONTENT_GENERATOR.POST_CREATED_AS_DRAFT)}),React.createElement(re.n,{isOpen:h,onRequestClose:()=>{b()},okButton:{onClick:()=>{b()}},title:"Error",content:React.createElement("p",null,h)}))},{useState:Fr,useEffect:Ur,useMemo:Br}=wp.element,Gr=[1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,40,60,80,100],Hr=P.Ay.div`
margin-bottom: 5px;
label {
margin-bottom: 5px;
display: block;
}
`,jr=()=>{var e,t;const{template:a,setTemplate:n,jsxTemplates:l}=ur("imagesGenerator"),[r,o]=Fr(),[c,s]=Fr(!0),[m,E]=Fr(!1),[g,h]=Fr(!1),b=(null==I?void 0:I.ai_envs)||[],{imageModels:v,getModel:f}=ve(I,(null==a?void 0:a.envId)||null),w=f(null==a?void 0:a.model),[C,O]=Fr([]),[T,S]=Fr([]),[A,k]=Fr(),[x,P]=Fr(""),[L,D]=Fr(""),[F,U]=Fr(""),[B,G]=Fr(""),[H,j]=Fr(""),[$,Y]=Fr([]),W=Br((()=>T.indexOf(A)),[A,T]),z=null==a?void 0:a.prompt,[V,K]=Fr(1),[q,X]=Fr(0),[Q,J]=Fr(0),Z=new AbortController,le=(null==a?void 0:a.style)??null,ce=(e,t)=>{n((a=>({...a,[t]:e})))};Ur((()=>{var e;if(null!=a&&a.envId&&(null==a||!a.model)&&(null==v?void 0:v.length)>0){const e=v.find((e=>"dall-e-3"===e.model))||v[0];n({...a,model:e.model})}if(null!=a&&a.model&&(null==a||!a.resolution)&&(null==w||null===(e=w.resolutions)||void 0===e?void 0:e.length)>0){const e=w.resolutions.map((e=>e.name)),t=e.includes("1024x1024")?"1024x1024":e[0];n({...a,resolution:t})}}),[a]),Ur((()=>{if(A){const e=function(e,t=42){let a=e.replace(/[\s|,]+/g,"-");a=a.replace(/--+/g,"-");const n=a.split("-");let l=n[0],r=1;for(;r<n.length&&n[r]&&l.length+n[r].length<t;)l+="-"+n[r],r++;return l.length>t+1&&(l=l.slice(0,t+2)),l}(z)+".png";j(e),P(z),D(z),U(z),G(z)}}),[A]);const ie=()=>{if(z){for(let e=0;e<V;e++){const e={prompt:z,envId:a.envId,model:a.model,resolution:a.resolution,style:a.style};O((t=>[...t,e]))}X((e=>e+V))}else console.error("Prompt is empty, cannot add to queue.")};Ur((()=>{C.length>0&&!m&&(async()=>{if(0===C.length||m)return;E(!0);const e=C[0];try{const t=await(0,y.IU)(`${_}/ai/images`,{method:"POST",nonce:N,signal:Z.signal,json:{env:"admin-tools",envId:e.envId,model:e.model,resolution:e.resolution,style:e.style,scope:"admin-tools",session:M,message:e.prompt,maxResults:1}});t.data&&t.data.length>0&&S((e=>[...e,t.data[0]])),O((e=>e.slice(1))),J((e=>e+1)),1===C.length&&(X(0),J(0))}catch(e){"AbortError"!==e.name&&(console.error(e),o(e.message+(C.length>1?" The other tasks will continue.":"")),O((e=>e.slice(1))),X((e=>e-1)))}finally{E(!1)}})()}),[C,m]);const se=Br((()=>{const e=$.find((e=>e.url===A));return e?e.id:null}),[A,$]);return React.createElement(u.z,{nekoErrors:[]},React.createElement(Ue,{title:Ee.COMMON.IMAGES_GENERATOR}),React.createElement(p.N,null,React.createElement(p.Y,{fullWidth:!0},React.createElement(be,{options:I}),React.createElement(i.s,{p:!0,style:{marginTop:0,marginBottom:0}},"This will also be available in the Post Editor soon. If you have any idea or request, please join us on the ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/support/plugin/ai-engine/",rel:"noreferrer"},"Support Forum"),"! 🎵")),React.createElement(p.Y,null,React.createElement(sa,{style:{marginBottom:25}},l),React.createElement(ne.L,{style:{marginBottom:25}},React.createElement("h3",{style:{marginTop:0}},"Parameters"),React.createElement("label",null,Ee.COMMON.ENVIRONMENT,":"),React.createElement(ae.g,{tiny:!0}),React.createElement(ee.u,{scrolldown:!0,name:"envId",value:(null==a?void 0:a.envId)??"",onChange:ce},b.map((e=>React.createElement(ee.j,{key:e.id,value:e.id,label:e.name}))),React.createElement(ee.j,{value:"",label:"None"})),React.createElement(ae.g,{tiny:!0}),React.createElement("label",null,Ee.COMMON.MODEL,":"),React.createElement(ae.g,{tiny:!0}),React.createElement(ee.u,{scrolldown:!0,name:"model",value:null==a?void 0:a.model,onChange:ce},v.map((e=>React.createElement(ee.j,{key:e.model,value:e.model,label:e.name})))),React.createElement(ae.g,{tiny:!0}),React.createElement("label",null,Ee.COMMON.RESOLUTION,":"),React.createElement(ae.g,{tiny:!0}),React.createElement(ee.u,{scrolldown:!0,name:"resolution",value:null==a?void 0:a.resolution,onChange:ce},null==w||null===(e=w.resolutions)||void 0===e?void 0:e.map((e=>React.createElement(ee.j,{key:e.name,value:e.name,label:e.label})))),"custom"===(null==a?void 0:a.resolution)&&React.createElement(React.Fragment,null,React.createElement(ae.g,{tiny:!0}),React.createElement("label",null,"Custom Resolution:"),React.createElement(ae.g,{tiny:!0}),React.createElement(te.A,{name:"customResolution",value:null==a?void 0:a.customResolution,onChange:e=>ce(e,"customResolution")})),(null==w||null===(t=w.model)||void 0===t?void 0:t.startsWith("dall-e-3"))&&React.createElement(React.Fragment,null,React.createElement(ae.g,{tiny:!0}),React.createElement("label",null,Ee.COMMON.STYLE,":"),React.createElement(ae.g,{tiny:!0}),React.createElement(ee.u,{scrolldown:!0,name:"style",value:le,onChange:ce},React.createElement(ee.j,{key:"none",value:null,label:"None"}),React.createElement(ee.j,{key:"natural",value:"natural",label:"Natural"}),React.createElement(ee.j,{key:"vivid",value:"vivid",label:"Vivid"})))),React.createElement(ne.L,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Settings"),React.createElement(d.R,{id:"continuous_mode ",label:"Continuous",value:"1",checked:c,description:"New images will be added to the already generated images.",onChange:s}))),React.createElement(p.Y,{style:{flex:3}},React.createElement(Qe.j,{busy:m,value:Q,max:q,onStopClick:()=>{Z.abort(),O([]),X(0),J(0),E(!1)},status:()=>`${Q} / ${q}`}),React.createElement(ae.g,null),React.createElement(ne.L,null,A&&React.createElement(React.Fragment,null,React.createElement(Be,{style:{paddingBottom:10}},React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(R.M,{disabled:W<1||m,onClick:()=>{W>0&&k(T[W-1])}},"<"),React.createElement(R.M,{onClick:()=>k()},"Back to Results"),React.createElement(R.M,{disabled:W>=T.length-1||m,onClick:()=>{W<T.length-1&&k(T[W+1])}},">"))),React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("div",{style:{flex:2}},React.createElement("a",{href:A,target:"_blank",rel:"noreferrer"},React.createElement("img",{src:A,style:{width:"100%"}}))),React.createElement("div",{style:{flex:1,marginLeft:10,display:"flex",flexDirection:"column"}},React.createElement(Hr,null,React.createElement("label",null,"Title:"),React.createElement(Ye.m,{value:x,onBlur:P,rows:2})),React.createElement(Hr,null,React.createElement("label",null,"Caption:"),React.createElement(Ye.m,{value:F,onBlur:U,rows:2})),React.createElement(Hr,null,React.createElement("label",null,"Description:"),React.createElement(Ye.m,{value:L,onBlur:D,rows:2})),React.createElement(Hr,null,React.createElement("label",null,"Alternative Text:"),React.createElement(Ye.m,{value:B,onBlur:G,rows:2})),React.createElement(Hr,null,React.createElement("label",null,"Filename:"),React.createElement(te.A,{value:H,onChange:j})),React.createElement(ae.g,null),React.createElement(R.M,{fullWidth:!0,style:{height:42},onClick:async()=>{h(!0);try{const e=await(0,y.IU)(`${_}/helpers/create_image`,{method:"POST",nonce:N,json:{url:A,title:x,description:L,caption:F,alt:B,filename:H}});Y([...$,{id:e.attachmentId,url:A}])}catch(e){console.error(e),o(e.message)}finally{h(!1)}},isBusy:g},"Add to Media Library"),React.createElement(ae.g,{tiny:!0}),se&&React.createElement(React.Fragment,null,React.createElement(ae.g,null),React.createElement(oe.X,{variant:"success"},"The media has been created! You can edit it here: ",React.createElement("a",{href:`/wp-admin/post.php?post=${se}&action=edit`,target:"_blank",rel:"noreferrer"},"Edit Media #",se),"."))))),!A&&React.createElement(React.Fragment,null,React.createElement(Be,null,React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(R.M,{disabled:!z,isBusy:m,onClick:ie},"Generate"),React.createElement(ee.u,{scrolldown:!0,id:"totalImagesToGenerate",name:"totalImagesToGenerate",style:{marginLeft:10,marginRight:10,width:120},value:V,onChange:e=>K(e)},Gr.map((e=>React.createElement(ee.j,{key:e,id:e,value:e,label:`${e} ${e>1?"Images":"Image"}`})))),m&&React.createElement(R.M,{disabled:!z,onClick:ie},"Add to Queue"),T.length>0&&React.createElement(R.M,{onClick:()=>{S([])}},"Clear"))),React.createElement(ae.g,null),React.createElement(Ye.m,{value:z,onChange:e=>{n({...a,prompt:e})}}),React.createElement(Ge,null,T.map((e=>React.createElement("img",{key:e,src:e,onClick:()=>k(e)}))),[...Array(Math.max(3-T.length,0)).keys()].map((()=>React.createElement("div",{className:"empty-image"})))))))),React.createElement(re.n,{isOpen:r,onRequestClose:()=>{o()},okButton:{onClick:()=>{o()}},title:"Error",content:React.createElement("p",null,r)}))},{useState:$r,useEffect:Yr,useMemo:Wr}=wp.element,zr=e=>{const{isOpen:t=!1,title:a,error:n,results:l,busy:o=!1,onClick:c=(()=>{})}=e,i=e=>{let t=0;if(0===e.length)return t;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a),t|=0;return t},s=Wr((()=>o?React.createElement(er.X,{type:"circle",size:"10%"}):n?React.createElement(React.Fragment,null,"Error: ",n):(null==l?void 0:l.length)>0?React.createElement(React.Fragment,null,"Pick one of those results:",React.createElement(vr,null,l.map((e=>React.createElement(fr,{key:i(e),onClick:()=>{c(e)}},e))))):React.createElement(React.Fragment,null,"Nothing to display.")),[l,n]);return React.createElement(r.A,null,React.createElement(p.N,null,React.createElement(re.n,{isOpen:t,title:a??"Results",content:s,onRequestClose:()=>c(),okButton:{label:"Close",onClick:()=>c()}})))},{useState:Vr,useEffect:Kr}=wp.element,{__:qr}=wp.i18n,{registerPlugin:Xr}=wp.plugins,{Button:Qr,ToolbarDropdownMenu:Jr,ToolbarGroup:Zr,Spinner:eo,MenuGroup:to,MenuItem:ao}=wp.components,{BlockControls:no}=wp.blockEditor,{PluginDocumentSettingPanel:lo}=wp.editor,{registerFormatType:ro}=wp.richText,{useSelect:oo}=wp.data;function co(){const[e,t]=Vr(!1),[a,n]=Vr([]),l=oo((e=>e("core/block-editor").getSelectedBlock()),[]);if(!l)return null;if("core/paragraph"!==l.name)return;const r=e=>{e.style.opacity=.15,e.style.pointerEvents="none",e.style.userSelect="none",e.style.animation="neko-fade-animation 0.85s infinite linear"},o=e=>{e.style.opacity=1,e.style.pointerEvents="auto",e.style.userSelect="auto",e.style.animation="none"};Kr((()=>{if(null==l||!l.clientId)return;const t=document.getElementById("block-"+l.clientId);t?e?r(t):o(t):console.warn("AI Engine: Could not find block element.")}),[e,l]);const c=()=>{const e=document.getElementById("block-"+l.clientId);e?o(e):console.warn("AI Engine: Could not find block element.")},i=l.attributes.content,s=window.getSelection().toString(),m=async e=>{const{getSelectedBlockClientId:a,getBlockIndex:o,getCurrentPost:m}=wp.data.select("core/editor"),d=o(a()),{id:u}=m();t(!0),(()=>{const e=document.getElementById("block-"+l.clientId);e?r(e):console.warn("AI Engine: Could not find block element.")})(),document.activeElement.blur();try{const a=await(0,y.IU)(`${_}/ai/magic_wand`,{method:"POST",nonce:N,json:{action:e,data:{postId:u,text:i,selectedText:s}}});c(),t(!1);const{mode:r,result:o,results:m}=a.data;if("replace"===r)(e=>{wp.data.dispatch("core/block-editor").updateBlockAttributes(l.clientId,{content:e})})(o);else if("suggest"===r)n(m);else if("insertMedia"===r){const{media:e}=a.data,{createBlock:t}=wp.blocks,n=t("core/image",{id:e.id,url:e.url,title:e.title,caption:e.caption,alt:e.alt});wp.data.dispatch("core/block-editor").insertBlock(n,d+1)}}catch(e){c(),t(!1),alert("Error: "+e.message),console.log("ERROR",e)}};return React.createElement(React.Fragment,null,React.createElement("style",null,"\n @keyframes neko-fade-animation {\n 0% { opacity: 0.15; }\n 50% { opacity: 0.3; }\n 100% { opacity: 0.15; }\n }\n "),React.createElement(no,null,React.createElement(Zr,null,React.createElement(Jr,{icon:e?React.createElement(eo,null):React.createElement(Fe,{icon:"wand",style:{marginRight:0}}),label:qr("AI Wand")},(()=>React.createElement(React.Fragment,null,React.createElement(to,null,React.createElement(ao,{onClick:()=>m("correctText")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Correct Text"),React.createElement("small",null,"Grammar & Spelling"))),React.createElement(ao,{onClick:()=>m("enhanceText")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Enhance Text"),React.createElement("small",null,"Readibility & Quality"))),React.createElement(ao,{onClick:()=>m("longerText")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Longer Text"),React.createElement("small",null,"Readibility"))),React.createElement(ao,{onClick:()=>m("shorterText")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Shorter Text"),React.createElement("small",null,"Readibility"))),React.createElement(ao,{onClick:()=>m("translateText")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Translate Text"),React.createElement("small",null,"To Post Language")))),React.createElement(to,null,React.createElement(ao,{disabled:!s,onClick:()=>m("suggestSynonyms")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Suggest Synonyms"),React.createElement("small",null,"For Selected Words")))),React.createElement(to,null,React.createElement(ao,{onClick:()=>m("generateImage")},React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement("b",null,"Generate Image"),React.createElement("small",null,"For this Text"))))))))),React.createElement(zr,{isOpen:null==a?void 0:a.length,results:a,onClick:e=>{n([]),e&&(e=>{const{getSelectionStart:t,getSelectionEnd:a}=wp.data.select("core/block-editor"),n=wp.data.select("core/block-editor").getSelectedBlock(),l=n.attributes.content,r=t().offset,o=a().offset,c=l.substring(0,r)+e+l.substring(o);wp.data.dispatch("core/block-editor").updateBlockAttributes(n.clientId,{content:c})})(e)},onClose:()=>n([])}))}const io=async(e,t)=>{if(!e)return e;const{getCurrentPost:a}=wp.data.select("core/editor"),{id:n}=a();return(await(0,y.IU)(`${_}/ai/magic_wand`,{method:"POST",nonce:N,json:{action:"translateSection",data:{postId:n,context:t,text:e}}})).data.result},so=()=>{const e=null==I?void 0:I.module_suggestions,[t,a]=Vr(),[n,l]=Vr();return e?React.createElement(r.A,null,React.createElement(lo,{name:"mwai-document-settings",title:React.createElement(React.Fragment,null,React.createElement(Fe,null)," AI Engine"),className:"mwai-document-settings"},React.createElement("p",null,"Suggest:"),React.createElement("div",{style:{display:"flex"}},React.createElement(Qr,{variant:"primary",onClick:()=>{const{getCurrentPost:e}=wp.data.select("core/editor"),{id:t,title:n}=e();a({postId:t,postTitle:n})},style:{flex:1,marginRight:10,textAlign:"center"}},React.createElement(Fe,{icon:"wand",style:{marginRight:8}})," Titles"),React.createElement(Qr,{variant:"primary",onClick:()=>{const{getCurrentPost:e}=wp.data.select("core/editor"),{id:t,title:a}=e();l({postId:t,postTitle:a})},style:{flex:1,textAlign:"center"}},React.createElement(Fe,{icon:"wand",style:{marginRight:8}})," Excerpts")),React.createElement("div",{style:{display:"flex"}},React.createElement(Qr,{variant:"primary",onClick:async()=>{await(async()=>{const{getBlocks:e,getBlockAttributes:t}=wp.data.select("core/block-editor"),{updateBlockAttributes:a}=wp.data.dispatch("core/block-editor"),{editPost:n,savePost:l}=wp.data.dispatch("core/editor"),{createInfoNotice:r,removeNotice:o}=wp.data.dispatch("core/notices"),{getEditedPostAttribute:c}=wp.data.select("core/editor"),i="mwai-translation-progress-notice",s=e(),m=c("title"),d=Ae(),u=async e=>{r(`Translating content... ${e}%`,{id:i,isDismissible:!1}),await new Promise((e=>setTimeout(e,100)))},E=e=>{e.style.opacity=.15,e.style.pointerEvents="none",e.style.userSelect="none",e.style.animation="neko-fade-animation 0.85s infinite linear"},p=e=>{e.style.opacity=1,e.style.pointerEvents="auto",e.style.userSelect="auto",e.style.animation="none"};s.forEach((e=>{const t=document.querySelector(`[data-block="${e.clientId}"]`);t&&E(t)}));const g=document.querySelector(".editor-post-title__input");g&&E(g),await u(0);const R=s.length+2;let h=0,y="";try{y=await io(m,d),h++,n({title:y}),g&&p(g),await u(Math.round(h/R*100));for(const e of s){if(["core/paragraph","core/heading","core/list","core/quote","core/table"].includes(e.name)){const n=t(e.clientId).content;if(n){const t=await io(n,d);await a(e.clientId,{content:t})}const l=document.querySelector(`[data-block="${e.clientId}"]`);l&&p(l),wp.data.dispatch("core/block-editor").selectBlock(e.clientId)}h++,await u(Math.round(h/R*100))}const e=c("excerpt");e&&n({excerpt:await io(e,d)})}finally{s.forEach((e=>{const t=document.querySelector(`[data-block="${e.clientId}"]`);t&&p(t)})),o(i)}})()},style:{flex:1,marginTop:10,textAlign:"center"}},React.createElement(Fe,{icon:"wand",style:{marginRight:8}})," Translate Post")),React.createElement(r.A,null,React.createElement(p.N,null,React.createElement(Or,{post:t,onTitleClick:async e=>{wp.data.dispatch("core/editor").editPost({title:e})},onClose:a}),React.createElement(Mr,{post:n,onExcerptClick:async e=>{wp.data.dispatch("core/editor").editPost({excerpt:e})},onClose:l}))))):null};function mo(){return mo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},mo.apply(this,arguments)}const{addFilter:uo}=wp.hooks,{useState:Eo,useRef:po,useEffect:go}=wp.element,{TextControl:Ro,Spinner:ho,ProgressBar:yo,ToggleControl:bo,Card:vo,CardBody:fo}=wp.components,{dispatch:_o}=wp.data,wo="mwai-copilot/prevent-new-block";function Co(){return Co=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Co.apply(this,arguments)}const Oo=React.createElement(Fe,{icon:"ai",style:{width:20,height:20}}),To=P.Ay.div`
color: black;
display: flex;
flex-direction: column;
border: 1px solid black;
font-size: 15px;
box-sizing: content-box;
font-weight: 400;
font-size: 13px;
padding: 10px;
background: hsl(0deg 0% 100% / 75%);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
margin-bottom: 10px;
.mwai-title-container {
flex: inherit;
padding: 5px 0px 5px 10px;
display: flex;
align-items: center;
color: black;
font-weight: 600;
cursor: pointer;
.mwai-hint {
font-size: 10px;
font-weight: 400;
text-align: right;
flex: auto;
.mwai-pill {
background: var(--wp--preset--color--vivid-cyan-blue);
padding: 5px 10px;
border-radius: 8px;
color: white;
}
.mwai-pill-purple {
background: var(--wp--preset--color--vivid-purple);
}
}
}
.mwai-block-container-content {
flex: auto;
padding: 10px;
display: flex;
flex-direction: column;
}
&.mwai-chatbot {
background: var(--neko-main-color);
.mwai-title-container {
color: white;
}
.mwai-block-container-content {
margin-top: 10px;
border-radius: 5px;
background: var(--neko-background-color);
}
}
&.is-selected {
}
`,No=({children:e,type:t="",title:a="",hint:n="",isSelected:l,isDisplayed:r,...o})=>{const c=(0,Je.gR)("mwai-block-container",`mwai-${t}`,{"is-selected":l,"is-meow":!0});return React.createElement(To,Co({className:c},o),React.createElement("div",{className:"mwai-title-container"},React.createElement(Fe,{icon:"ai",style:{width:20,height:20}}),React.createElement("div",null,a),React.createElement("div",{className:"mwai-hint"},n)),(l||r)&&React.createElement("div",{className:"mwai-block-container-content"},e))},{registerBlockType:Io}=wp.blocks,{useMemo:Mo,useState:So}=wp.element,{PanelBody:Ao,SelectControl:ko,ToggleControl:xo}=wp.components,{InspectorControls:Po,useBlockProps:Lo}=wp.blockEditor,Do=e=>e.replace(/[A-Z]/g,(e=>`_${e.toLowerCase()}`)),Fo=e=>{const{attributes:{chatbotId:t,isCustomChatbot:a,shortcodeParams:n}}=e;if(a)return`${Object.entries(n).filter((([,e])=>null!=e&&""!==e)).reduce(((e,[t,a])=>{const n=Do(t),l=encodeURIComponent(a);return"bot_id"===n?`${e} custom_id="${l}"`:`${e} ${n}="${l}"`}),"[mwai_chatbot")}]`;{const e={id:{value:t,insertIfNull:!0}};return`${Object.entries(e).filter((([,{value:e,insertIfNull:t}])=>!!e||t)).reduce(((e,[t,{value:a}])=>`${e} ${Do(t)}="${encodeURIComponent(a)}"`),"[mwai_chatbot")}]`}},Uo=e=>{const{attributes:{chatbotId:t,isCustomChatbot:a,shortcodeParams:n},setAttributes:l,isSelected:r}=e,[o,c]=So(n),i=Lo(),s=Mo((()=>{const e=k.map((e=>({label:e.name,value:e.botId})));return e.unshift({label:"None",value:null}),e}),[k]),m=Mo((()=>k.find((e=>e.botId===t))),[t]),d=Mo((()=>a?"Custom Chatbot":m?`Chatbot (${m.name})`:"Chatbot"),[a,t,m]);return React.createElement(React.Fragment,null,React.createElement("div",i,React.createElement(No,{title:d,type:"chatbot",isSelected:r},a&&React.createElement(React.Fragment,null,React.createElement(Ia,{shortcodeParams:o,updateShortcodeParams:(e,t)=>{const a={...o};a[t]=e,c(a),l({shortcodeParams:a})},options:I,blockMode:!0})),!a&&React.createElement("p",null,"Selected chatbot: ",m?m.name:"None"))),React.createElement(Po,null,React.createElement(Ao,{title:Ee.COMMON.CHATBOT},React.createElement(xo,{label:"Custom Chatbot",checked:a,onChange:e=>l({isCustomChatbot:e})}),!a&&s&&s.length>0&&React.createElement(ko,{label:Ee.COMMON.CHATBOT,value:t,options:s,onChange:e=>l({chatbotId:e})})),!a&&React.createElement(Ao,{title:Ee.COMMON.SETTINGS})))},{registerBlockType:Bo}=wp.blocks,{useMemo:Go}=wp.element,{PanelBody:Ho,SelectControl:jo,ToggleControl:$o,TextControl:Yo}=wp.components,{InspectorControls:Wo,useBlockProps:zo}=wp.blockEditor,Vo=e=>{const{attributes:{isCustomChatbot:t,chatbotId:a,customId:n,textNewChat:l}}=e,r={};return t?n&&(r.customId=n):a&&(r.id=a),l&&(r.textNewChat=l),`${Object.entries(r).filter((([,e])=>null!=e&&""!==e)).reduce(((e,[t,a])=>{const n=(e=>e.replace(/[A-Z]/g,(e=>`_${e.toLowerCase()}`)))(t);return`${e} ${n}="${a}"`}),"[mwai_discussions")}]`},Ko=e=>{const{attributes:{isCustomChatbot:t,chatbotId:a,customId:n,textNewChat:l},setAttributes:r,isSelected:o}=e,c=zo(),i=Go((()=>{const e=k.map((e=>({label:e.name,value:e.botId})));return e.unshift({label:"None",value:""}),e}),[k]),s=Go((()=>k.find((e=>e.botId===a))),[a]),m=Go((()=>t?"Discussions (Custom Chatbot)":s?`Discussions (${s.name})`:"Discussions"),[t,s]);return React.createElement(React.Fragment,null,React.createElement("div",c,React.createElement(No,{title:m,type:"discussions",isSelected:o},React.createElement("span",null,t?`Custom ID: ${n||"None"}`:`Selected chatbot: ${s?s.name:"None"}`),React.createElement("span",null,"New Chat: ",l||"Default"))),React.createElement(Wo,null,React.createElement(Ho,{title:"Discussions Settings"},React.createElement($o,{label:"Custom Chatbot",checked:t,onChange:e=>r({isCustomChatbot:e})}),t?React.createElement(Yo,{label:"Custom Chatbot ID",value:n,onChange:e=>r({customId:e})}):React.createElement(jo,{label:"Select Chatbot",value:a,options:i,onChange:e=>r({chatbotId:e})}),React.createElement(Yo,{label:"Text for New Chat Button",value:l,onChange:e=>r({textNewChat:e})}))))};function qo(){return qo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},qo.apply(this,arguments)}const{__:Xo}=wp.i18n,{registerBlockType:Qo}=wp.blocks,{useEffect:Jo}=wp.element,{PanelBody:Zo,SelectControl:ec,TextControl:tc}=wp.components,{InspectorControls:ac,InnerBlocks:nc,useBlockProps:lc}=wp.blockEditor,rc=e=>{const t=lc.save(),{attributes:{id:a,theme:n}}=e,l=`[mwai-form-container id="${a}" theme="${n}"]`;return React.createElement("div",qo({},t,{id:`mwai-form-container-${a}`,className:"mwai-form-container"}),l,React.createElement(nc.Content,null))},oc=e=>{const{attributes:{id:t,theme:a},setAttributes:n}=e,l=lc();return Jo((()=>{if(!t){const e=Math.random().toString(36).substr(2,9);n({id:e})}}),[t]),React.createElement(React.Fragment,null,React.createElement("div",l,React.createElement(No,{title:"Container",type:"container",isDisplayed:!0},React.createElement(nc,null))),React.createElement(ac,null,React.createElement(Zo,{title:Ee.COMMON.STYLE},React.createElement("p",null,"The theme will be applied to all the AI elements in this container."),React.createElement(ec,{label:"Theme",value:a,onChange:e=>n({theme:e}),options:[{label:"None",value:"none"},{label:"ChatGPT",value:"ChatGPT"},{label:"Timeless",value:"Timeless"}]}),React.createElement(tc,{label:"ID",value:t,onChange:e=>n({id:e})}))))},{__:cc}=wp.i18n,{registerBlockType:ic}=wp.blocks,{useEffect:sc}=wp.element,{Button:mc,PanelBody:dc,TextControl:uc,SelectControl:Ec,CheckboxControl:pc}=wp.components,{useBlockProps:gc,InspectorControls:Rc}=wp.blockEditor,hc=e=>{const{attributes:{id:t,label:a,type:n,name:l,options:r=[],placeholder:o,rows:c,defaultValue:i,maxlength:s,required:m}}=e,d=encodeURIComponent((0,y.F1)(r)),u=gc.save();let E="[mwai-form-field";return t&&(E+=` id="${t}"`),a&&(E+=` label="${a}"`),n&&(E+=` type="${n}"`),l&&(E+=` name="${l}"`),d&&(E+=` options="${d}"`),o&&(E+=` placeholder="${o}"`),"textarea"===n&&c&&(E+=` rows="${c}"`),i&&(E+=` default="${i}"`),s&&(E+=` maxlength="${s}"`),m&&(E+=` required="${m}"`),E+="]",React.createElement("div",u,E)},yc=e=>{const{attributes:{id:t,type:a,name:n,options:l=[],label:r,placeholder:o,rows:c,defaultValue:i,maxlength:s,required:m},setAttributes:d,isSelected:u}=e,E=gc();return sc((()=>{if(!t){const e=Math.random().toString(36).substr(2,9);d({id:"mwai-"+e})}}),[t]),React.createElement(React.Fragment,null,React.createElement("div",E,React.createElement(No,{title:`${p=a,p.charAt(0).toUpperCase()+p.slice(1)}`,type:"field",isSelected:u,hint:React.createElement("span",{className:"mwai-pill"},"{",n,"}")},React.createElement("div",null,r),React.createElement("div",{style:{flex:"auto"}}),React.createElement("div",null,n))),React.createElement(Rc,null,React.createElement(dc,{title:cc("Field")},React.createElement(uc,{label:"Label Text",value:r,onChange:e=>{d({label:e});const t=e.trim().replace(/ /g,"_").replace(/[^\w-]+/g,"").toUpperCase();t&&d({name:t})}}),React.createElement(uc,{label:"Field Name",value:n,onChange:e=>d({name:e})}),React.createElement(Ec,{label:"Field Type",value:a,onChange:e=>d({type:e}),options:[{label:"Input",value:"input"},{label:"Select",value:"select"},{label:"Checkbox",value:"checkbox"},{label:"Radio",value:"radio"},{label:"Text Area",value:"textarea"}]}),("input"===a||"textarea"===a)&&React.createElement(uc,{label:"Placeholder",value:o,onChange:e=>d({placeholder:e})}),("input"===a||"textarea"===a)&&React.createElement(uc,{label:"Default Value",value:i,onChange:e=>d({defaultValue:e})}),("input"===a||"textarea"===a)&&React.createElement(uc,{label:"Max Length",value:s,onChange:e=>d({maxlength:e})}),"textarea"===a&&React.createElement(uc,{label:Ee.COMMON.ROWS,value:c,onChange:e=>d({rows:e}),type:"number",step:"1",min:"1",max:"100"}),React.createElement(pc,{label:"Required",checked:m,onChange:e=>d({required:e})})),("select"===a||"radio"===a||"checkbox"===a)&&React.createElement(dc,{title:React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},React.createElement("div",null,cc("Options")))},l.map(((e,t)=>React.createElement("div",{key:t,style:{display:"flex",marginBottom:-25}},React.createElement("div",{style:{marginRight:5}},React.createElement(uc,{style:{marginRight:10},label:"Label",isInline:!0,value:e.label,onChange:e=>{const a=[...l];a[t].label=e,d({options:a})}})),React.createElement(uc,{style:{},label:"Value",isSubtle:!0,value:e.value,onChange:e=>{const a=[...l];a[t].value=e,d({options:a})}}),React.createElement("div",{style:{marginLeft:5,position:"relative",top:23}},React.createElement(mc,{style:{height:30},isDestructive:!0,icon:"trash",isSmall:!0,onClick:()=>{const e=[...l];e.splice(t,1),d({options:e})}}))))),React.createElement(mc,{isPrimary:!0,style:{width:"100%",marginTop:10},onClick:()=>{const e=[...l];e.push({label:"",value:""}),d({options:e})}},"Add Option")),React.createElement(dc,{title:Ee.COMMON.SYSTEM},React.createElement(uc,{label:"ID",value:t,onChange:e=>d({id:e})}))));var p},{__:bc}=wp.i18n,{registerBlockType:vc}=wp.blocks,{useEffect:fc}=wp.element,{Button:_c,PanelBody:wc,TextControl:Cc,SelectControl:Oc,CheckboxControl:Tc}=wp.components,{useBlockProps:Nc,InspectorControls:Ic}=wp.blockEditor,Mc=e=>{const{attributes:{id:t,label:a,name:n,required:l,accept:r,customAccept:o,multiple:c}}=e,i=Nc.save(),s=function(e,t){switch(e){case"all-images":return"image/*";case"all-documents":return".pdf,.doc,.docx,.txt,.xls,.xlsx";case"all":default:return"";case"custom":return t||""}}(r,o);let m="[mwai-form-upload";return t&&(m+=` id="${t}"`),a&&(m+=` label="${a}"`),n&&(m+=` name="${n}"`),""!==s&&(m+=` accept="${s}"`),c&&(m+=' multiple="true"'),l&&(m+=' required="true"'),m+="]",React.createElement("div",i,m)},Sc=e=>{const{attributes:{id:t,label:a,name:n,required:l,accept:r,customAccept:o,multiple:c},setAttributes:i,isSelected:s}=e,m=Nc();return fc((()=>{if(!t){const e=Math.random().toString(36).substr(2,9);i({id:"mwai-"+e})}}),[t]),React.createElement(React.Fragment,null,React.createElement("div",m,React.createElement(No,{title:"Upload Field",type:"field",isSelected:s,hint:React.createElement("span",{className:"mwai-pill"},"{"+n+"}")},React.createElement("div",null,a),React.createElement("div",{style:{flex:"auto"}}),React.createElement("div",null,n))),React.createElement(Ic,null,React.createElement(wc,{title:bc("Upload Field Settings")},React.createElement(Cc,{label:"Label Text",value:a,onChange:e=>{if(i({label:e}),!n||"LABEL"===n){const t=e.trim().replace(/ /g,"_").replace(/[^\w-]+/g,"").toUpperCase();t&&i({name:t})}}}),React.createElement(Cc,{label:"Field Name",value:n,onChange:e=>i({name:e})}),React.createElement(Oc,{label:"Accept",value:r,onChange:e=>i({accept:e}),options:[{label:"All Images",value:"all-images"},{label:"All Documents",value:"all-documents"},{label:"Any Files",value:"all"},{label:"Custom",value:"custom"}]}),"custom"===r&&React.createElement(Cc,{label:"Custom MIME Types",help:"Comma-separated list (e.g. .png,.jpg)",value:o,onChange:e=>i({customAccept:e})}),React.createElement(Tc,{label:"Multiple",checked:c,onChange:e=>i({multiple:e})}),React.createElement(Tc,{label:"Required",checked:l,onChange:e=>i({required:e})})),React.createElement(wc,{title:Ee.COMMON.SYSTEM},React.createElement(Cc,{label:"ID",value:t,onChange:e=>i({id:e})}))))},{__:Ac}=wp.i18n,{registerBlockType:kc}=wp.blocks,{useEffect:xc}=wp.element,{PanelBody:Pc,TextControl:Lc,CheckboxControl:Dc}=wp.components,{InspectorControls:Fc,useBlockProps:Uc}=wp.blockEditor,Bc=e=>{const{attributes:{id:t,copyButton:a}}=e,n=Uc.save(),l={id:{value:t,insertIfNull:!0},copy_button:{value:a,insertIfNull:!1}};let r=Object.entries(l).filter((([,{value:e,insertIfNull:t}])=>!1!==e&&""!==e||t)).reduce(((e,[t,{value:a}])=>`${e} ${t}="${a}"`),"[mwai-form-output");return r=`${r}]`,React.createElement("div",n,r)},Gc=e=>{const{attributes:{id:t,copyButton:a},setAttributes:n,isSelected:l}=e,r=Uc();return xc((()=>{if(!t){const e=Math.random().toString(36).substr(2,9);n({id:"mwai-"+e})}}),[t]),React.createElement(React.Fragment,null,React.createElement("div",r,React.createElement(No,{title:"Output",type:"output",isSelected:l,hint:React.createElement("span",{className:"mwai-pill mwai-pill-purple"},"#",t)},React.createElement("div",null),React.createElement("div",{style:{flex:"auto"}}),React.createElement("div",null,"#",t))),React.createElement(Fc,null,React.createElement(Pc,{title:Ee.FORMS.OUTPUT},React.createElement(Dc,{label:"Copy Button",checked:a,onChange:e=>n({copyButton:e})}),React.createElement(Lc,{label:"ID",value:t,onChange:e=>n({id:e})}))))},{__:Hc}=wp.i18n,{registerBlockType:jc}=wp.blocks,{useMemo:$c,useEffect:Yc}=wp.element,{PanelBody:Wc,TextControl:zc,TextareaControl:Vc,SelectControl:Kc,CheckboxControl:qc}=wp.components,{InspectorControls:Xc,useBlockProps:Qc}=wp.blockEditor,Jc=e=>{const{attributes:{id:t,scope:a,label:n,prompt:l,message:r,outputElement:o,aiEnvId:c,embeddingsEnvId:i,index:s,namespace:m,localMemory:d,model:u,temperature:E,maxTokens:p,isAssistant:g,assistantId:R,resolution:h}}=e,y=encodeURIComponent(l),b=encodeURIComponent(r),v=Qc.save(),f={id:{value:t,insertIfNull:!0},scope:{value:a,insertIfNull:!1},local_memory:{value:d,insertIfNull:!1},label:{value:n,insertIfNull:!0},prompt:{value:y,insertIfNull:!1},message:{value:b,insertIfNull:!1},output_element:{value:o,insertIfNull:!0},model:{value:u,insertIfNull:!1},temperature:{value:E,insertIfNull:!1},max_tokens:{value:p,insertIfNull:!1},is_assistant:{value:g,insertIfNull:!1},env_id:{value:c,insertIfNull:!1},embeddings_env_id:{value:i,insertIfNull:!1},embeddings_index:{value:s,insertIfNull:!1},embeddings_namespace:{value:m,insertIfNull:!1},assistant_id:{value:R,insertIfNull:!1},resolution:{value:h,insertIfNull:!1}};let _=Object.entries(f).filter((([,{value:e,insertIfNull:t}])=>!!e||t)).reduce(((e,[t,{value:a}])=>`${e} ${t}="${a}"`),"[mwai-form-submit");return _=`${_}]`,React.createElement("div",v,_)},Zc=e=>{var t;const a=Qc(),{attributes:{id:n,scope:l,label:r,message:o,model:c,temperature:i,maxTokens:s,aiEnvId:m,embeddingsEnvId:d,index:u,namespace:E,assistantId:p,resolution:g,isAssistant:R,localMemory:h,outputElement:y,placeholders:b=[]},setAttributes:v,isSelected:f}=e,_=$c((()=>I.embeddings_envs||[]),[]),w=$c((()=>_.find((e=>e.id===d))||null),[_,d]),C=$c((()=>(null==w?void 0:w.indexes)||[]),[w]),O=$c((()=>(null==w?void 0:w.namespaces)||[]),[w]),T=$c((()=>I.ai_envs||[]),[]),{models:N,getModel:M}=ve(I,m),S=M(c),A=null==S||null===(t=S.features)||void 0===t?void 0:t.includes("text-to-image"),k=$c((()=>T.find((e=>e.id===m))||null),[T,m]),x=$c((()=>(null==k?void 0:k.assistants)||[]),[k]),P=$c((()=>x.find((e=>e.id===p))||null),[x,p]);Yc((()=>{!m&&!c||k||v({aiEnvId:null,model:null})}),[m]),Yc((()=>{(d||u||E)&&!w&&v({embeddingsEnvId:null,index:null,namespace:null})}),[d]),Yc((()=>{P&&P.model&&P.model!==c&&v({model:P.model})}),[P]),Yc((()=>{l||v({scope:"form"})}),[l]),Yc((()=>{R||v({assistantId:""})}),[R]),Yc((()=>{if(!n){const e=Math.random().toString(36).substr(2,9);v({id:"mwai-"+e})}}),[n]),Yc((()=>{m||""===c||v({model:""})}),[m]),Yc((()=>{const e=o.match(/{([^}]+)}/g);if(e){const t=e.map((e=>e.replace("{","").replace("}","")));t.join(",")!==b.join(",")&&v({placeholders:t})}else v({placeholders:[]})}),[o]);const L=$c((()=>b?b.length:0),[b]),D=$c((()=>{const e=x.map((e=>({label:e.name,value:e.id})));return e.unshift({label:"None",value:""}),e}),[x]),F=$c((()=>{const e=N.map((e=>({label:e.rawName,value:e.model})));return e.unshift({label:"Default",value:""}),e}),[N]),U=$c((()=>{var e;if(!S||!A)return[];const t=(null==S||null===(e=S.resolutions)||void 0===e?void 0:e.map((e=>({label:e.label,value:e.name}))))||[];return t.unshift({label:"None",value:""}),t}),[S,A]),B=$c((()=>{const e=C.map((e=>({label:e.name,value:e.name})));return e.unshift({label:"None",value:""}),e}),[C]),G=$c((()=>{const e=T.map((e=>({label:e.name,value:e.id})));return e.unshift({label:"Default",value:""}),e}),[T]),H=$c((()=>{const e=_.map((e=>({label:e.name,value:e.id})));return e.unshift({label:"None",value:""}),e}),[_]),j=$c((()=>{const e=O.map((e=>({label:e,value:e})));return e.unshift({label:"None",value:""}),e}),[O]),$=$c((()=>0===L?"N/A":React.createElement("span",{className:"mwai-pill"},L," field",L>1?"s":"")),[L]);return React.createElement(React.Fragment,null,React.createElement("div",a,React.createElement(No,{title:"Submit",type:"submit",isSelected:f,hint:React.createElement(React.Fragment,null,"IN:"," ",React.createElement("span",{className:"mwai-pill"},$)," ","OUT:"," ",React.createElement("span",{className:"mwai-pill mwai-pill-purple"},y||"N/A"))},"Input Fields: ",b.join(", "),React.createElement("br",null),"Prompt: ",o,React.createElement("br",null),"Output Element: ",y)),React.createElement(Xc,null,React.createElement(Wc,{title:Ee.COMMON.OUTPUT},React.createElement(zc,{label:Ee.COMMON.LABEL,value:r,onChange:e=>v({label:e})}),React.createElement(Vc,{label:Ee.COMMON.PROMPT,value:o,onChange:e=>v({message:e}),help:Ee.FORMS.PROMPT_INFO}),React.createElement(zc,{label:Ee.FORMS.OUTPUT_ELEMENT,value:y,onChange:e=>v({outputElement:e}),help:Ee.FORMS.OUTPUT_ELEMENT_INFO})),React.createElement(Wc,{title:Ee.COMMON.MODEL_PARAMS},T&&T.length>0&&React.createElement(Kc,{label:Ee.COMMON.ENVIRONMENT,value:m,options:G,onChange:e=>v({aiEnvId:e})}),T&&T.length>0&&React.createElement(qc,{label:"Assistant Mode",checked:R,onChange:e=>v({isAssistant:e})}),R&&x&&x.length>0&&React.createElement(React.Fragment,null,React.createElement(Kc,{label:Ee.COMMON.ASSISTANT,value:p,options:D,onChange:e=>v({assistantId:e})})),!R&&React.createElement(React.Fragment,null,N&&N.length>0&&React.createElement(Kc,{label:Ee.COMMON.MODEL,value:c,options:F,disabled:!m,onChange:e=>v({model:e})}),!A&&React.createElement(React.Fragment,null,React.createElement(zc,{label:Ee.COMMON.TEMPERATURE,value:i,onChange:e=>v({temperature:parseFloat(e)}),type:"number",step:"0.1",min:"0",max:"1",help:Ee.HELP.TEMPERATURE}),React.createElement(zc,{label:Ee.COMMON.MAX_TOKENS,value:s,onChange:e=>v({maxTokens:parseInt(e)}),type:"number",step:"16",min:"32",max:"4096",help:React.createElement(Ea,{model:S,maxTokens:s,onRecommendedClick:e=>v({maxTokens:e})})})),A&&React.createElement(React.Fragment,null,React.createElement(Kc,{label:Ee.COMMON.RESOLUTION,value:g,options:U,onChange:e=>v({resolution:e})})))),!A&&React.createElement(React.Fragment,null,React.createElement(Wc,{title:Ee.COMMON.CONTEXT_PARAMS},_&&_.length>0&&React.createElement(Kc,{label:Ee.COMMON.EMBEDDINGS_ENV,value:d,options:H,disabled:!(null!=H&&H.length),onChange:e=>v({embeddingsEnvId:e})}),C&&C.length>0&&React.createElement(Kc,{label:Ee.COMMON.EMBEDDINGS_INDEX,value:u,options:B,disabled:!(null!=H&&H.length),onChange:e=>v({index:e})}),"pinecone"===(null==w?void 0:w.type)&&O&&O.length>0&&React.createElement(Kc,{label:Ee.COMMON.NAMESPACE,value:E,options:j,disabled:!(null!=H&&H.length),onChange:e=>v({namespace:e})}))),React.createElement(Wc,{title:Ee.COMMON.SYSTEM},React.createElement(zc,{label:"ID",value:n,onChange:e=>v({id:e})}),React.createElement(qc,{label:"Local Memory",checked:h,onChange:e=>v({localMemory:e}),help:"Store the forms data in the browser's local storage for 12 hours."}),React.createElement(zc,{label:"Scope",value:l,onChange:e=>v({scope:e}),help:"The scope of the form. Different forms can have the same scope."}))))},{__:ei}=wp.i18n,{registerBlockType:ti}=wp.blocks,{useMemo:ai,useEffect:ni}=wp.element,{PanelBody:li,TextControl:ri,CheckboxControl:oi}=wp.components,{InspectorControls:ci,useBlockProps:ii}=wp.blockEditor,si=e=>{const{attributes:{id:t,label:a,localMemory:n}}=e,l=ii.save();let r=`[mwai-form-reset id="${t}" label="${a}"`;return n&&(r+=' local_memory="true"'),r+="]",React.createElement("div",l,r)},mi=e=>{const t=ii(),{attributes:{id:a,label:n,localMemory:l},setAttributes:r,isSelected:o}=e;return ni((()=>{if(!a){const e=Math.random().toString(36).substr(2,9);r({id:"mwai-reset-"+e})}}),[a]),React.createElement(React.Fragment,null,React.createElement("div",t,React.createElement(No,{title:"Reset",type:"reset",isSelected:o,hint:React.createElement(React.Fragment,null,ei("This block resets the AI form fields","ai-engine"))},ei("ID:","ai-engine")," ",a,React.createElement("br",null),ei("Label:","ai-engine")," ",n)),React.createElement(ci,null,React.createElement(li,{title:ei("Reset Button Settings","ai-engine")},React.createElement(ri,{label:ei("ID","ai-engine"),value:a,onChange:e=>r({id:e}),help:ei("Unique identifier. If omitted, one is auto-generated.","ai-engine")}),React.createElement(ri,{label:ei("Label","ai-engine"),value:n,onChange:e=>r({label:e}),help:ei("Text on the reset button.","ai-engine")}),React.createElement(oi,{label:ei("Local Memory","ai-engine"),checked:l,onChange:e=>r({localMemory:e}),help:ei("Clear local storage for this form’s key when resetting.","ai-engine")}))))},{render:di}=wp.element,ui=new n.E({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnMount:!1,retry:!1,placeholderData:e=>e}}}),Ei=I.module_chatbots,pi=I.module_suggestions,gi=I.module_forms;Ei&&(Io("ai-engine/chatbot",{title:"AI Chatbot",description:"Embed an AI Engine Chatbot in your content.",icon:Oo,category:"layout",keywords:["ai","openai","chatbot"],attributes:{id:{type:"string",default:""},chatbotId:{type:"string",default:"default"},isCustomChatbot:{type:"boolean",default:!1},shortcodeParams:{type:"object",default:{}}},edit:Uo,save:Fo}),Bo("ai-engine/discussions",{title:"AI Discussions",description:"Embed AI Engine Discussions in your content.",icon:Oo,category:"layout",keywords:["ai","openai","discussions"],attributes:{isCustomChatbot:{type:"boolean",default:!1},chatbotId:{type:"string",default:""},customId:{type:"string",default:""},textNewChat:{type:"string",default:""}},edit:Ko,save:Vo})),gi&&(ic("ai-engine/form-field",{apiVersion:3,title:"AI Form Field",description:"An AI Field for your AI Form.",icon:Oo,category:"layout",keywords:[cc("ai"),cc("openai"),cc("form")],supports:{dimensions:{width:!0}},attributes:{id:{type:"string",default:""},name:{type:"string",default:"LABEL"},type:{type:"string",default:"input"},options:{type:"array",default:[]},label:{type:"string",default:"Label: "},placeholder:{type:"string",default:""},defaultValue:{type:"string",default:""},maxlength:{type:"string",default:""},rows:{type:"rows",default:4},required:{type:"boolean",default:!0}},edit:yc,save:hc}),vc("ai-engine/upload-field",{apiVersion:3,title:"AI Upload Field",description:"A File Upload field for your AI Form.",icon:Oo,category:"layout",keywords:[bc("ai"),bc("openai"),bc("form"),bc("upload")],attributes:{id:{type:"string",default:""},label:{type:"string",default:"Upload:"},name:{type:"string",default:"UPLOAD"},required:{type:"boolean",default:!1},accept:{type:"string",default:"all-images"},customAccept:{type:"string",default:".png,.jpg"},multiple:{type:"boolean",default:!1}},edit:Sc,save:Mc}),kc("ai-engine/form-output",{title:"AI Form Output",description:"An Output Field for your AI Form.",icon:Oo,category:"layout",keywords:[Ac("ai"),Ac("openai"),Ac("form")],supports:{dimensions:{minHeight:!0}},attributes:{id:{type:"string",default:""},copyButton:{type:"boolean",default:!0}},edit:Gc,save:Bc}),jc("ai-engine/form-submit",{title:"AI Form Submit",description:"The Submit Button for your AI Form.",icon:Oo,category:"layout",keywords:[Hc("ai"),Hc("openai"),Hc("form")],supports:{dimensions:{minHeight:!1}},attributes:{id:{type:"string",default:""},scope:{type:"string",default:"form"},localMemory:{type:"boolean",default:!1},label:{type:"string",default:"Submit"},prompt:{type:"string",default:""},message:{type:"string",default:""},outputElement:{type:"string",default:""},model:{type:"string",default:""},temperature:{type:"number",default:.8},maxTokens:{type:"number",default:4096},placeholders:{type:"array",default:[]},aiEnvId:{type:"string",default:""},embeddingsEnvId:{type:"string",default:""},index:{type:"string",default:""},namespace:{type:"string",default:null},isAssistant:{type:"boolean",default:!1},assistantId:{type:"string",default:""},resolution:{type:"string",default:null}},edit:Zc,save:Jc}),ti("ai-engine/form-reset",{title:"AI Form Reset",description:"A reset button for your AI Form.",icon:Oo,category:"layout",keywords:[ei("ai"),ei("openai"),ei("form"),ei("reset")],supports:{dimensions:{minHeight:!1}},attributes:{id:{type:"string",default:""},label:{type:"string",default:"Reset"},localMemory:{type:"boolean",default:!1}},edit:mi,save:si}),Qo("ai-engine/form-container",{title:"AI Form Container",description:"Container to embed the blocks relative to a specific AI Form.",icon:Oo,category:"layout",keywords:[Xo("ai"),Xo("openai"),Xo("form")],attributes:{id:{type:"string",default:""},theme:{type:"string",default:"ChatGPT"}},edit:oc,save:rc})),pi&&(Xr("ai-engine-document-settings",{render:so}),ro("ai-wand/actions",{title:"AI Wand",tagName:"mwai",className:null,edit:co}),(()=>{const e=e=>{const t=po(),[a,n]=Eo(!1),[l,r]=Eo(""),[o,c]=Eo(!1),[i,s]=Eo(!1),[m,d]=Eo(!1),u=wp.data.select("core/editor").getCurrentPostId();return go((()=>{a&&t.current&&t.current.focus()}),[a]),go((()=>{const e=e=>{if(a&&"Enter"===e.key)return e.preventDefault(),!1};return _o("core/keyboard-shortcuts").registerShortcut({name:wo,category:"block",description:"Prevent new block creation when AI Copilot is active",keyCombination:{character:"enter"}}),window.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0),_o("core/keyboard-shortcuts").unregisterShortcut(wo)}}),[a]),a?React.createElement(vo,null,React.createElement(fo,null,o?React.createElement("div",{style:{textAlign:"center",padding:20}},React.createElement(yo,null)):React.createElement(React.Fragment,null,React.createElement(Ro,{ref:t,label:React.createElement(React.Fragment,null,React.createElement(Fe,{icon:"wand",style:{marginBottom:-4}}),"AI Copilot"),value:l,placeholder:m?"Describe the image...":"Write about...",onChange:e=>r(e),onKeyDown:async t=>{i||("Enter"===t.key?(t.preventDefault(),t.stopPropagation(),await(async t=>{const a=Ae("[== CURRENT BLOCK ==]");try{c(!0);const n=await(0,y.IU)(`${_}/ai/copilot`,{method:"POST",nonce:N,json:{action:m?"image":"text",message:t,context:a,postId:u}});if(m){const{media:e}=n.data,{createBlock:t}=wp.blocks,{replaceBlock:a}=wp.data.dispatch("core/block-editor"),{getSelectedBlockClientId:l}=wp.data.select("core/block-editor"),r=t("core/image",{id:e.id,url:e.url,title:e.title,caption:e.caption,alt:e.alt});a(l(),r)}else e.setAttributes({content:n.data});setTimeout((()=>{const{getSelectedBlockClientId:e}=wp.data.select("core/block-editor"),t=document.querySelector(`[data-block="${e()}"]`);if(t){const e=document.createRange(),a=window.getSelection();e.setStart(t,1),e.collapse(!0),a.removeAllRanges(),a.addRange(e)}}),50)}catch(e){console.error("Error:",e.message),_o("core/notices").createErrorNotice(`AI Copilot error: ${e.message}`,{isDismissible:!0})}finally{c(!1),n(!1),r("")}})(l)):("Escape"===t.key||"Backspace"===t.key&&!l)&&(t.preventDefault(),n(!1),r("")))},onCompositionStart:()=>s(!0),onCompositionEnd:()=>s(!1)}),React.createElement("div",{style:{display:"flex",justifyContent:"end",marginBottom:-12}},React.createElement(bo,{label:"Image Mode",checked:m,onChange:d}))))):React.createElement("div",{onCompositionStart:()=>s(!0),onCompositionEnd:()=>s(!1),onKeyDown:e=>{var t,a;if(i)return;const l=((null==e||null===(t=e.target)||void 0===t?void 0:t.innerText)||"").trim(),r=null==e||null===(a=e.target)||void 0===a?void 0:a.localName;"Space"!==e.code||l||"p"!==r||(e.preventDefault(),n(!0))}},React.createElement(e.BlockEdit,e))};uo("editor.BlockEdit","mwai-copilot/module",(t=>a=>"core/paragraph"===a.name?React.createElement(e,mo({BlockEdit:t},a)):React.createElement(t,a))),uo("blocks.registerBlockType","mwai-copilot/placeholder",((e,t)=>{if("core/paragraph"===t){const t=e.edit;e.edit=e=>(e={...e,attributes:{...e.attributes,placeholder:"Type / to choose a block, or press space to summon the AI Copilot"}},t(e))}return e}))})()),document.addEventListener("DOMContentLoaded",(function(){const e=document.getElementById("mwai-admin-settings");e&&di(React.createElement(l.Ht,{client:ui},React.createElement(r.A,null,React.createElement(Zl,null))),e);const t=document.getElementById("mwai-content-generator");t&&di(React.createElement(l.Ht,{client:ui},React.createElement(r.A,null,React.createElement(Dr,null))),t);const a=document.getElementById("mwai-image-generator");a&&di(React.createElement(l.Ht,{client:ui},React.createElement(r.A,null,React.createElement(jr,null))),a);const n=document.getElementById("mwai-playground");if(n&&di(React.createElement(l.Ht,{client:ui},React.createElement(r.A,null,React.createElement(br,null))),n),pi){const e=document.getElementById("mwai-admin-postsList");e&&di(React.createElement(r.A,null,React.createElement(kr,null)),e)}const o=document.getElementById("meow-common-dashboard");o&&di(React.createElement(l.Ht,{client:ui},React.createElement(r.A,null,React.createElement(Z,null))),o)}))},1594:e=>{e.exports=React},5206:e=>{e.exports=ReactDOM}},__webpack_module_cache__={},deferred;function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var a=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(a.exports,a,a.exports,__webpack_require__),a.exports}__webpack_require__.m=__webpack_modules__,deferred=[],__webpack_require__.O=(e,t,a,n)=>{if(!t){var l=1/0;for(i=0;i<deferred.length;i++){for(var[t,a,n]=deferred[i],r=!0,o=0;o<t.length;o++)(!1&n||l>=n)&&Object.keys(__webpack_require__.O).every((e=>__webpack_require__.O[e](t[o])))?t.splice(o--,1):(r=!1,n<l&&(l=n));if(r){deferred.splice(i--,1);var c=a();void 0!==c&&(e=c)}}return e}n=n||0;for(var i=deferred.length;i>0&&deferred[i-1][2]>n;i--)deferred[i]=deferred[i-1];deferred[i]=[t,a,n]},__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={57:0};__webpack_require__.O.j=t=>0===e[t];var t=(t,a)=>{var n,l,[r,o,c]=a,i=0;if(r.some((t=>0!==e[t]))){for(n in o)__webpack_require__.o(o,n)&&(__webpack_require__.m[n]=o[n]);if(c)var s=c(__webpack_require__)}for(t&&t(a);i<r.length;i++)l=r[i],__webpack_require__.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return __webpack_require__.O(s)},a=self.wpJsonMwai=self.wpJsonMwai||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})(),__webpack_require__.nc=void 0;var __webpack_exports__=__webpack_require__.O(void 0,[121],(()=>__webpack_require__(1615)));__webpack_exports__=__webpack_require__.O(__webpack_exports__)})();