PageSourceSearch

https://wobr.ai/assets/my-wobr-ai2-C_8Bc_Rc.js

js wobr.ai collected 2026-10-05 15:19:56 UTC 91,300 bytes, 68 lines download raw bytes

1import{j as e}from"./vendor-motion-f-lEJJ3p.js";import{r as i,R as Me}from"./vendor-charts-CR-R150p.js";import{ad as we,a as ge,M as z,s as _,C as F,d as $,i as ke,h as w,aC as Re,B as W,X as Ae,am as pe,a7 as Ie,cB as Ce,aF as Ue,aH as We,a8 as Se,a9 as Ee,aa as Te,ab as Le,U as Q,n as R,Y as U,bL as Ne,af as q,a2 as He,aj as qe,Q as ze,V as Pe,aM as Xe,ax as Je,j as Qe,w as ye,c1 as ie,a3 as ue,k as J,ai as je,A as Ye,e as Ze,f as es,r as ss,aI as ts,c5 as as}from"./index-BqVW9VJZ.js";import{T as rs,a as ns,b as ne,c as le}from"./tabs-C_YRcYIQ.js";import{A as ls,a as is,b as cs,c as os}from"./accordion-BsJ_Lh8k.js";import{b as ds,c as ms,a as ve,d as ee,e as xs,T as se}from"./table-CqAa5UOM.js";import{L as O}from"./label-IxQBxpFl.js";import{S as _e}from"./switch-BPa9mf65.js";import{S as ce,a as oe,b as de,c as me,d as P}from"./select-djCtWb6Y.js";import{C as hs,a as ps,b as us}from"./collapsible-C9EkqXOp.js";import{C as xe}from"./copy-DC5Rwvwx.js";import{E as gs}from"./eye-off-BQQzT3vR.js";import{U as js}from"./upload-BoZTs9Md.js";import{P as fs}from"./pen-Ctxmsj9j.js";import{T as bs}from"./target-GV9PGts2.js";import{C as Oe}from"./clock-DlwmAbAs.js";import{Q as Ns}from"./qr-code-DjaTm_eD.js";import{C as ys}from"./code-xml-BvoDcPOs.js";import"./vendor-supabase-4ECGrJoe.js";import"./vendor-radix-2Gpnlba9.js";import"./chevron-up-BJk5GoZd.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const vs=we("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const De=we("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]),_s=()=>{const{user:r}=ge(),{toast:n}=z(),[x,h]=i.useState([]),[c,g]=i.useState(null),[f,j]=i.useState(null),[N,b]=i.useState(!1),[I,C]=i.useState(null),A=i.useCallback(async()=>{var a;if(r)try{const{data:s,error:l}=await _.functions.invoke("ai-agent-keys",{body:{action:"list"}});if(l)throw l;h(s.keys||[]),!c&&((a=s.keys)==null?void 0:a.length)>0&&g(s.keys[0].id)}catch(s){console.error("Error fetching AI agent keys:",s),n({title:"Error",description:"Failed to fetch AI agent keys",variant:"destructive"})}},[r,c,n]),T=i.useCallback(async()=>{if(!c){j(null);return}try{const a=x.find(s=>s.id===c);if(!a)return;j({ai_agent_working:a.ai_agent_working,ai_model:a.ai_model,ai_system_prompt:a.ai_system_prompt,ai_system_prompt_continue:a.ai_system_prompt_continue,ai_user_prompt:a.ai_user_prompt,ai_user_prompt_continue:a.ai_user_prompt_continue,fxdreema_name:a.fxdreema_name||""})}catch(a){console.error("Error fetching settings:",a),n({title:"Error",description:"Failed to fetch AI agent settings",variant:"destructive"})}},[c,x,n]),D=async a=>{if(r){b(!0);try{const{data:s,error:l}=await _.functions.invoke("ai-agent-keys",{body:{action:"generate",key_name:a}});if(l)throw l;C(s.key);const E={key:s.key,key_id:s.key_id,timestamp:Date.now()};return localStorage.setItem(`wobr_key_${s.key_id}`,JSON.stringify(E)),await A(),g(s.key_id),n({title:"Success",description:"AI Agent Key generated successfully!"}),s.key}catch(s){console.error("Error generating key:",s),n({title:"Error",description:"Failed to generate AI Agent Key",variant:"destructive"})}finally{b(!1)}}},u=async(a,s)=>{try{const{error:l}=await _.functions.invoke("ai-agent-keys",{body:{action:"toggle",key_id:a,is_active:s}});if(l)throw l;await A(),n({title:"Success",description:`AI Agent Key ${s?"activated":"deactivated"}`})}catch(l){console.error("Error toggling key:",l),n({title:"Error",description:"Failed to update key status",variant:"destructive"})}},y=async a=>{if(c)try{const{error:s}=await _.functions.invoke("ai-agent-keys",{body:{action:"update_settings",key_id:c,settings:a}});if(s)throw s;await A(),await T(),n({title:"Success",description:"Settings updated successfully!"})}catch(s){console.error("Error updating settings:",s),n({title:"Error",description:"Failed to update settings",variant:"destructive"})}},v=async(a,s)=>{try{const{error:l}=await _.functions.invoke("ai-agent-keys",{body:{action:"update_name",key_id:a,key_name:s}});if(l)throw l;await A(),n({title:"Success",description:"Agent name updated successfully"})}catch(l){console.error("Error updating agent name:",l),n({title:"Error",description:"Failed to update agent name",variant:"destructive"})}},t=async a=>{try{const{error:s}=await _.functions.invoke("ai-agent-keys",{body:{action:"delete",ke
11y_id:a}});if(s)throw s;localStorage.removeItem(`wobr_key_${a}`),await A(),n({title:"Success",description:"AI Agent Key deleted successfully"})}catch(s){console.error("Error deleting key:",s),n({title:"Error",description:"Failed to delete AI Agent Key",variant:"destructive"})}},k=()=>{C(null)},d=a=>{const s=localStorage.getItem(`wobr_key_${a}`);if(s)try{return JSON.parse(s).key}catch(l){console.error("Error parsing stored key:",l)}return null};return i.useEffect(()=>{A()},[A]),i.useEffect(()=>{T()},[T]),{keys:x,selectedKeyId:c,setSelectedKeyId:g,settings:f,generatedKey:I,isLoading:N,generateKey:D,toggleKeyActive:u,updateSettings:y,deleteKey:t,updateAgentName:v,clearGeneratedKey:k,getStoredKey:d,refetch:A}},ws=()=>{const[r,n]=i.useState([]),[x,h]=i.useState(!0),{toast:c}=z(),g=async()=>{try{h(!0);const{data:f,error:j}=await _.from("openrouter_ai_models").select("id, model_id, model_name, provider, input_price, output_price, context_tokens, is_free").order("model_name");if(j){console.error("Error fetching OpenRouter models:",j),c({title:"Error",description:"Failed to fetch AI models",variant:"destructive"});return}n(f||[])}catch(f){console.error("Error fetching OpenRouter models:",f),c({title:"Error",description:"Failed to fetch AI models",variant:"destructive"})}finally{h(!1)}};return i.useEffect(()=>{g()},[]),{models:r,isLoading:x,refetch:g}},ks=()=>{const[r,n]=i.useState([]),[x,h]=i.useState(!0),{toast:c}=z(),g=async()=>{try{h(!0);const{data:f,error:j}=await _.from("ai_agent_system_prompts").select("id, title, prompt_text, sort_order").eq("is_active",!0).order("sort_order");if(j){console.error("Error fetching system prompts:",j),c({title:"Error",description:"Failed to fetch system prompts",variant:"destructive"});return}n(f||[])}catch(f){console.error("Error fetching system prompts:",f),c({title:"Error",description:"Failed to fetch system prompts",variant:"destructive"})}finally{h(!1)}};return i.useEffect(()=>{g()},[]),{prompts:r,isLoading:x,refetch:g}},Fe=()=>{const[r,n]=i.useState([]),[x,h]=i.useState(!0),{toast:c}=z(),g=async()=>{try{h(!0);const{data:f,error:j}=await _.from("ai_trading_variables").select("json_key, ea_variable, data_type, thai_description, english_description, example_lock_1, example_lock_2, example_lock_3, example_lock_4").order("json_key");if(j){console.error("Error fetching trading variables:",j),c({title:"Error",description:"Failed to fetch trading variables",variant:"destructive"});return}n(f||[])}catch(f){console.error("Error fetching trading variables:",f),c({title:"Error",description:"Failed to fetch trading variables",variant:"destructive"})}finally{h(!1)}};return i.useEffect(()=>{g()},[]),{variables:r,isLoading:x,refetch:g}},As=({value:r,onChange:n,placeholder:x})=>{const{variables:h,isLoading:c}=Fe(),[g,f]=i.useState(""),[j,N]=i.useState("1"),[b,I]=i.useState([]),[C,A]=i.useState(!1);i.useEffect(()=>{if(r&&!r.startsWith("{")){const t=`{
12${r}
13}`;n(t)}else r||n(`{
14
15}`)},[]);const T=()=>{if(!g||!j)return;const t=h.find(l=>l.json_key===g);if(!t)return;const k=`example_lock_${j}`,d=t[k];if(!d)return;const a={json_key:g,lockVersion:parseInt(j),content:d.trim()},s=[...b,a];I(s),u(s),f(""),N("1")},D=t=>{const k=b.filter((d,a)=>a!==t);I(k),u(k)},u=t=>{if(t.length===0){n(`{
16
17}`);return}const k=t.map(s=>`  ${s.content}`).join(`,
18`);if(k.length>200)return;const a=`{
19${k}
20}`;n(a)},y=h.find(t=>t.json_key===g),v=b.reduce((t,k)=>t+k.content.length,0)+(b.length>0?b.length-1:0);return e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(F,{className:"bg-slate-800 border-slate-700",children:e.jsxs($,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ke,{className:"h-4 w-4 text-blue-400"}),e.jsx(O,{className:"text-slate-200 font-medium",children:"Add Trading Variable"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(O,{className:"text-slate-300 text-sm",children:"Variable"}),e.jsxs(ce,{value:g,onValueChange:f,children:[e.jsx(oe,{className:"bg-slate-700 border-slate-600 text-slate-100",children:e.jsx(de,{placeholder:"Select variable..."})}),e.jsx(me,{className:"bg-slate-700 border-slate-600",children:h.map(t=>e.jsx(P,{value:t.json_key,className:"text-slate-100 hover:bg-slate-600",children:t.json_key},t.json_key))})]})]}),e.jsxs("div",{children:[e.jsx(O,{className:"text-slate-300 text-sm",children:"Format Option"}),e.jsxs(ce,{value:j,onValueChange:N,children:[e.jsx(oe,{className:"bg-slate-700 border-slate-600 text-slate-100",children:e.jsx(de,{})}),e.jsxs(me,{className:"bg-slate-700 border-slate-600 max-w-sm",children:[y&&e.jsxs(e.Fragment,{children:[e.jsx(P,{value:"1",className:"text-slate-100 hover:bg-slate-600",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:"Option 1"}),e.jsx("code",{className:"text-xs text-green-400 truncate max-w-xs",children:y.example_lock_1})]})}),e.jsx(P,{value:"2",className:"text-slate-100 hover:bg-slate-600",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:"Option 2"}),e.jsx("code",{className:"text-xs text-green-400 truncate max-w-xs",children:y.example_lock_2})]})}),e.jsx(P,{value:"3",className:"text-slate-100 hover:bg-slate-600",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:"Option 3"}),e.jsx("code",{className:"text-xs text-green-400 truncate max-w-xs",children:y.example_lock_3})]})}),e.jsx(P,{value:"4",className:"text-slate-100 hover:bg-slate-600",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:"Option 4"}),e.jsx("code",{className:"text-xs text-green-400 truncate max-w-xs",children:y.example_lock_4})]})})]}),!y&&e.jsxs(e.Fragment,{children:[e.jsx(P,{value:"1",className:"text-slate-100 hover:bg-slate-600",children:"Option 1"}),e.jsx(P,{value:"2",className:"text-slate-100 hover:bg-slate-600",children:"Option 2"}),e.jsx(P,{value:"3",className:"text-slate-100 hover:bg-slate-600",children:"Option 3"}),e.jsx(P,{value:"4",className:"text-slate-100 hover:bg-slate-600",children:"Option 4"})]})]})]})]}),e.jsx("div",{className:"flex items-end",children:e.jsx(w,{onClick:T,disabled:!g||!j||c||v>=180,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:"Add Variable"})})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-sm",children:[e.jsxs("span",{className:`${v>180?"text-red-400":v>150?"text-yellow-400":"text-slate-400"}`,children:[v,"/200 characters"]}),v>180&&e.jsx("span",{className:"text-red-400",children:"Character limit almost reached!"})]})]})}),y&&e.jsxs(hs,{open:C,onOpenChange:A,children:[e.jsx(ps,{asChild:!0,children:e.jsxs(w,{variant:"ghost",className:"w-full flex items-center gap-2 text-slate-300 bg-slate-800 hover:bg-slate-700",children:[e.jsx(Re,{className:"h-4 w-4"}),"Variable Information"]})}),e.jsx(us,{children:e.jsx(F,{className:"bg-slate-800 border-slate-700",children:e.jsxs($,{className:"p-4 space-y-3",children:[e.jsx("div",{className:"text-slate-200 font-medium mb-3",children:"Selected Variables Information"}),b.length===0?e.jsx("p",{className:"text-slate-400 text-sm",children:"No variables selected yet"}):e.jsx("div",{className:"space-y-3",children:b.map((t,k)=>{const d=h.find(a=>a.json_key===t.json_key);
20return d?e.jsxs("div",{className:"bg-slate-700 p-3 rounded-lg",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx(W,{variant:"outline",className:"text-blue-400 border-blue-400",children:t.json_key})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx(O,{className:"text-slate-300 text-xs",children:"EA Variable:"}),e.jsx("p",{className:"text-slate-100 font-mono",children:d.ea_variable})]}),e.jsxs("div",{children:[e.jsx(O,{className:"text-slate-300 text-xs",children:"Data Type:"}),e.jsx(W,{variant:"secondary",className:"ml-1",children:d.data_type})]}),e.jsxs("div",{children:[e.jsx(O,{className:"text-slate-300 text-xs",children:"Description:"}),e.jsx("p",{className:"text-slate-100",children:d.thai_description})]})]})]},k):null})})]})})})]}),b.length>0&&e.jsx(F,{className:"bg-slate-800 border-slate-700",children:e.jsxs($,{className:"p-4",children:[e.jsx(O,{className:"text-slate-200 font-medium mb-3 block",children:"Added Variables:"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-600",children:[e.jsx("th",{className:"text-left py-2 px-3 text-slate-300 font-medium",children:"Global Variable"}),e.jsx("th",{className:"text-left py-2 px-3 text-slate-300 font-medium",children:"Data Type"}),e.jsx("th",{className:"text-left py-2 px-3 text-slate-300 font-medium",children:"Description"}),e.jsx("th",{className:"text-center py-2 px-3 text-slate-300 font-medium",children:"Action"})]})}),e.jsx("tbody",{children:b.map((t,k)=>{const d=h.find(a=>a.json_key===t.json_key);return d?e.jsxs("tr",{className:"border-b border-slate-700 hover:bg-slate-700/30",children:[e.jsx("td",{className:"py-3 px-3",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(W,{variant:"outline",className:"text-blue-400 border-blue-400 w-fit",children:t.json_key}),e.jsx("code",{className:"text-xs text-slate-900 bg-slate-300 px-1 rounded font-mono",children:d.ea_variable})]})}),e.jsx("td",{className:"py-3 px-3",children:e.jsx(W,{variant:"secondary",className:"bg-green-500 text-black hover:bg-green-600",children:d.data_type})}),e.jsx("td",{className:"py-3 px-3 text-slate-100",children:d.thai_description}),e.jsx("td",{className:"py-3 px-3 text-center",children:e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>D(k),className:"text-red-400 hover:text-red-300 hover:bg-red-900/20",children:e.jsx(Ae,{className:"h-4 w-4"})})})]},k):null})})]})})]})}),e.jsxs("div",{children:[e.jsx(O,{htmlFor:"jsonOutput",className:"text-slate-200",children:"JSON Output Variable Format Specification"}),e.jsx(pe,{id:"jsonOutput",value:r,onChange:t=>n(t.target.value),placeholder:x,className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400 min-h-[120px] font-mono text-sm"})]})]})})},Is=()=>{const[r,n]=i.useState([]),[x,h]=i.useState({}),[c,g]=i.useState(!0),{toast:f}=z(),j=async()=>{try{g(!0);const{data:I,error:C}=await _.from("user_prompts").select("*").eq("is_active",!0).order("group_number",{ascending:!0}).order("sort_order",{ascending:!0});if(C){console.error("Error fetching user prompts:",C),f({title:"Error",description:"Failed to fetch user prompts",variant:"destructive"});return}n(I||[]);const A=(I||[]).reduce((T,D)=>{const u=D.group_name;return T[u]||(T[u]=[]),T[u].push(D),T},{});h(A)}catch(I){console.error("Error fetching user prompts:",I),f({title:"Error",description:"Failed to fetch user prompts",variant:"destructive"})}finally{g(!1)}};return i.useEffect(()=>{j()},[]),{prompts:r,groupedPrompts:x,isLoading:c,refetch:j,getGroupNames:()=>Object.keys(x).sort(),getPromptsByGroup:I=>x[I]||[]}},Cs=({onPromptSelect:r})=>{const{groupedPrompts:n,isLoading:x,getGroupNames:h,getPromptsByGroup:c}=Is(),{toast:g}=z(),[f,j]=i.useState(!1),[N,b]=i.useState(""),[I,C]=i.useState(""),[A,T]=i.useState(""),D=t=>{r(t),j(!1),b(""),C(""),T(""),g({title:"Success",description:"Prompt selected successfully!"})},u=(t,k)=>{k.stopPropagation(),navigator.clipboard.writeText(t),g({title:"Copied",description:"Prompt text copied to clipboard"})},y=h(),v=i.useMemo(()=>
20{if(!A.trim())return N?c(N):[];const t=A.toLowerCase();return Object.values(n).flat().filter(d=>d.prompt_text.toLowerCase().includes(t)||d.group_name.toLowerCase().includes(t))},[A,N,n,c]);return e.jsxs(Ie,{open:f,onOpenChange:j,children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(w,{variant:"outline",className:"border-blue-500 text-blue-400 hover:bg-blue-600 hover:text-white bg-blue-950",children:[e.jsx(Ue,{className:"h-4 w-4 mr-2"}),"Select Prompt",e.jsx(We,{className:"h-4 w-4 ml-2"})]})}),e.jsxs(Se,{className:"bg-slate-800 border-slate-700 text-slate-100 max-w-4xl max-h-[80vh] overflow-hidden",children:[e.jsxs(Ee,{children:[e.jsx(Te,{className:"text-slate-100",children:"Select User Prompt"}),e.jsx(Le,{className:"text-slate-300",children:"Select a category first, then choose the prompt you want"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-200",children:"Search Keywords:"}),e.jsx(Q,{type:"text",placeholder:"Search prompts by keywords...",value:A,onChange:t=>T(t.target.value),className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-200",children:"Category:"}),e.jsxs(ce,{value:N,onValueChange:t=>{b(t),C("")},children:[e.jsx(oe,{className:"bg-slate-900 border-slate-600 text-slate-100",children:e.jsx(de,{placeholder:"Select category..."})}),e.jsx(me,{className:"bg-slate-800 border-slate-600 text-slate-100 z-50",children:y.map(t=>e.jsx(P,{value:t,className:"hover:bg-slate-700 focus:bg-slate-700",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:t}),e.jsx(W,{variant:"secondary",className:"ml-2 bg-slate-600 text-slate-200",children:c(t).length})]})},t))})]})]}),(N||A.trim())&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-200",children:A.trim()?`Search Results (${v.length})`:"Prompts:"}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto space-y-2 pr-2",children:v.map(t=>e.jsx("div",{className:`p-3 border rounded-lg cursor-pointer transition-colors hover:bg-slate-700/50 ${I===t.id?"border-blue-500 bg-blue-600/20":"border-slate-600"}`,onClick:()=>C(t.id),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-slate-200 mb-2 line-clamp-3",children:[t.prompt_text.substring(0,200),"..."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"outline",className:"text-xs border-slate-500 text-slate-400",children:t.group_name}),e.jsxs(W,{variant:"outline",className:"text-xs border-slate-500 text-slate-400",children:["#",t.group_number]}),e.jsxs("span",{className:"text-xs text-slate-500",children:["Sort: ",t.sort_order]})]})]}),e.jsxs("div",{className:"flex gap-1 ml-2",children:[e.jsx(w,{size:"sm",variant:"ghost",onClick:k=>u(t.prompt_text,k),className:"h-8 w-8 p-0 text-slate-400 hover:text-slate-200",children:e.jsx(xe,{className:"h-3 w-3"})}),e.jsx(w,{size:"sm",onClick:()=>D(t.prompt_text),className:"bg-blue-600 hover:bg-blue-700 text-white text-xs px-3",children:"Select"})]})]})},t.id))})]}),x&&e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-400"}),e.jsx("span",{className:"ml-2 text-slate-300",children:"Loading prompts..."})]}),!x&&y.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-slate-400",children:"No prompts found"})})]})]})]})},Ss=()=>{const{keys:r,selectedKeyId:n,setSelectedKeyId:x,settings:h,generatedKey:c,isLoading:g,generateKey:f,toggleKeyActive:j,updateSettings:N,clearGeneratedKey:b,getStoredKey:I,deleteKey:C,updateAgentName:A,refetch:T}=_s(),{models:D,isLoading:u}=ws(),{prompts:y,isLoading:v}=ks(),{toast:t}=z(),[k,d]=i.useState(""),[a,s]=i.useState(!1),[l,E]=i.useState(!1),[p,L]=i.useState({}),[V,S]=i.useState(!1),Y=()=>{if(!ae||!h){t({title:"Error",description:"Please select an agent to export settings",variant:"destructive"});return}const o={agentName:ae.key_name,exportDate:new Date().toISOString(),version:"1.0",settings:{ai_model:p.ai_model,ai_system_prompt:p.ai_system_prompt,ai_system_prompt_continue:p.ai_system_prompt_continue,ai_user_prompt:p.ai_user_prompt,ai_user_prompt_continue:p.ai_user_prompt_continue,fxdreema_name:p.fxdreema_name}},G=JSON.stringify(o,null,2),m=new Blob([G],{type:"application/json"}),K=URL.createObjectURL(m),M=document.createElement("a");M.href=K,M.download=`${ae.key_name}_settings.json`,document.body.appendChild(M),M.click(),document.body.removeChild(M),URL.revokeObjectURL(K),t({title:"Success",description:`Settings exported for ${ae.key_name}`})},H=o=>{var K;const G=(K=o.target.files)==null?void 0:K[0];if(!G)return;
20if(!ae){t({title:"Error",description:"Please select an agent to import settings to",variant:"destructive"});return}const m=new FileReader;m.onload=M=>{var Z;try{const re=(Z=M.target)==null?void 0:Z.result,B=JSON.parse(re);if(!B.settings)throw new Error("Invalid settings file format");const he={...p,ai_model:B.settings.ai_model||p.ai_model,ai_system_prompt:B.settings.ai_system_prompt||p.ai_system_prompt,ai_system_prompt_continue:B.settings.ai_system_prompt_continue||p.ai_system_prompt_continue,ai_user_prompt:B.settings.ai_user_prompt||p.ai_user_prompt,ai_user_prompt_continue:B.settings.ai_user_prompt_continue||p.ai_user_prompt_continue,fxdreema_name:B.settings.fxdreema_name||p.fxdreema_name};L(he),t({title:"Success",description:`Settings imported${B.agentName?` from ${B.agentName}`:""}. Click Save Settings to apply.`})}catch{t({title:"Error",description:"Failed to import settings. Invalid file format.",variant:"destructive"})}},m.readAsText(G),o.target.value=""};Me.useEffect(()=>{h&&L({ai_agent_working:h.ai_agent_working,ai_model:h.ai_model,ai_system_prompt:h.ai_system_prompt,ai_system_prompt_continue:h.ai_system_prompt_continue,ai_user_prompt:h.ai_user_prompt,ai_user_prompt_continue:h.ai_user_prompt_continue,fxdreema_name:h.fxdreema_name||""})},[h]);const te=async()=>{const o=k.trim();if(!o){t({title:"Error",description:"Please enter a name for the AI Agent Key",variant:"destructive"});return}if(r.map(m=>m.key_name.toLowerCase()).includes(o.toLowerCase())){t({title:"Error",description:"Agent name already exists. Please choose a different name.",variant:"destructive"});return}await f(o),d(""),s(!0),E(!1)},fe=async o=>{try{await navigator.clipboard.writeText(o),t({title:"Copied",description:"Key copied to clipboard"})}catch{t({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},$e=async()=>{S(!0);try{await T(),t({title:"Success",description:"Connector Keys refreshed successfully!"})}catch{t({title:"Error",description:"Failed to refresh Connector Keys",variant:"destructive"})}finally{S(!1)}},Ge=async()=>{await N(p)},Ve=async(o,G)=>{confirm(`Are you sure you want to delete "${G}"? This action cannot be undone.`)&&(await C(o),n===o&&x(null))},ae=r.find(o=>o.id===n),Ke=({agentId:o,initialName:G,onNameUpdate:m,existingNames:K})=>{const[M,Z]=i.useState(!1),[re,B]=i.useState(G),he=()=>{const X=re.trim();if(!X){t({title:"Error",description:"Agent name cannot be empty",variant:"destructive"});return}if(K.map(Be=>Be.toLowerCase()).includes(X.toLowerCase())){t({title:"Error",description:"Agent name already exists. Please choose a different name.",variant:"destructive"});return}m(X),Z(!1)},be=()=>{B(G),Z(!1)};return M?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{value:re,onChange:X=>B(X.target.value),className:"flex-1 h-8 text-sm",onKeyDown:X=>{X.key==="Enter"&&he(),X.key==="Escape"&&be()},autoFocus:!0}),e.jsx(w,{size:"sm",variant:"ghost",onClick:he,className:"h-8 w-8 p-0",children:e.jsx(Je,{className:"h-4 w-4 text-green-400"})}),e.jsx(w,{size:"sm",variant:"ghost",onClick:be,className:"h-8 w-8 p-0",children:e.jsx(Ae,{className:"h-4 w-4 text-red-400"})})]}):e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsxs("h3",{className:"font-medium text-slate-100",children:["Agent : ",G]}),e.jsx(w,{size:"sm",variant:"ghost",onClick:()=>Z(!0),className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(fs,{className:"h-3 w-3"})})]})};return e.jsx("div",{className:"space-y-6",children:e.jsxs(F,{className:"bg-slate-800/60 border-slate-700",children:[e.jsx(R,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(U,{className:"flex items-center gap-2 text-slate-100",children:[e.jsx(Ne,{className:"h-5 w-5"}),"AI Multi-Agent Swarm"]}),e.jsx(q,{className:"text-slate-300",children:"Create and manage Connector Keys with Prompt-based control and FXDreema EA integration for MT5."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{onClick:$e,disabled:V,variant:"outline",className:"flex items-center gap-2 border-slate-600 text-slate-300 hover:bg-slate-700",children:[e.jsx(He,{className:`h-4 w-4 ${V?"animate-spin":""}`}),V?"Refreshing...":"Refresh"]}),e.jsxs(Ie,{open:l,onOpenChange:E,children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(w,{className:"flex items-center gap-2 bg-blue-600 hover:bg-blue-700 text-white",children:[e.jsx(ke,{className:"h-4 w-4"}),"Create AI Agent"]})}),e.jsxs(Se,{className:"bg-slate-800 border-slate-700 text-slate-100",children:[e.jsxs(Ee,{children:[e.jsx(Te,{className:"text-slate-100",children:"Generate AI Agent Key"}),e.jsx(Le,{className:"text-slate-300",children:"Create a new AI Agent WOBR Key for your MT5 EA"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(O,{htmlFor:"keyName",className:"text-slate-200",children:"Key Name"}),e.jsx(Q,{id:"keyName",placeholder:"e.g., My Trading Bot",value:k,onChange:o=>d(o.target.value),className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400"}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"English letters and numbers only — no spaces; underscores ( _ ) are allowed"})]}),e.jsx(w,{onClick:te,disabled:g,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:g?"Creating...":"Create AI Agent"})]})]})]})]})]})}),e.jsxs($,{className:"space-y-4",children:[c&&e.jsx(F,{className:"bg-green-600/20 border-green-400/50",children:e.jsx($,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-green-200 mb-2",children:"🎉 New AI Agent Key Generated!"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{type:a?"text":"password",value:c,readOnly:!0,className:"font-mono bg-slate-900 border-slate-600 text-slate-100"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:()=>s(!a),className:"text-slate-300 hover:bg-slate-700",children:a?e.jsx(gs,{className:"h-4 w-4"}):e.jsx(qe,{className:"h-4 w-4"})}),e.jsx(w,{size:"sm",onClick:()=>fe(c),className:"bg-green-600 hover:bg-green-700 text-white",children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-green-300 mt-2",children:"⚠️ Key saved! You can copy it anytime from the key list below."})]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:b,className:"text-slate-400 hover:bg-slate-700",children:"✕"})]})})}),r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Ne,{className:"h-12 w-12 mx-auto text-slate-400 mb-4"}),e.jsx("p",{className:"text-slate-400",children:"No Connector Keys found"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Generate your first key to get started"})]}):e.jsx("div",{className:"space-y-2",children:r.map((o,G)=>e.jsxs("div",{className:`border rounded-lg transition-colors ${n===o.id?"border-blue-500 bg-blue-600/20":"border-slate-600 hover:border-slate-500 bg-slate-700/40"}`,children:[e.jsx("div",{className:"p-4 cursor-pointer",onClick:()=>{x(n===o.id?null:o.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"flex-1 mr-2",children:e.jsx(Ke,{agentId:o.id,initialName:o.key_name,onNameUpdate:m=>A(o.id,m),existingNames:r.filter(m=>m.id!==o.id).map(m=>m.key_name)}
20)}),e.jsx(W,{variant:o.is_active?"default":"secondary",className:o.is_active?"bg-green-600 text-white":"bg-slate-600 text-slate-300",children:o.is_active?"Active":"Inactive"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:m=>{m.stopPropagation(),Ve(o.id,o.key_name)},className:"text-red-400 hover:bg-red-900/20 hover:text-red-300",children:e.jsx(ze,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Q,{type:"password",value:I(o.id)||o.key_hash,readOnly:!0,className:"font-mono bg-slate-900 border-slate-600 text-slate-100 text-sm flex-1"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:m=>{m.stopPropagation();const K=I(o.id)||o.key_hash;fe(K)},className:"text-slate-300 hover:bg-slate-700",children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"text-sm text-slate-400 space-y-1",children:[e.jsxs("p",{children:["Last used: ",o.last_used_at?new Date(o.last_used_at).toLocaleString("th-TH"):"Never"]}),(o.mt_login||o.broker)&&e.jsxs("p",{className:"text-emerald-400",children:["MT5: ",o.mt_login," (",o.broker,") - ",o.account_status]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-500 mt-1 pt-2 border-t border-slate-600",children:[e.jsxs("span",{children:["API Calls: ",o.usage_count.toLocaleString()]}),e.jsxs("span",{children:["Credits Used: ",(()=>{const m=Math.ceil((Date.now()-new Date(o.created_at).getTime())/864e5);return o.is_active?m:0})()," (1/day)"]})]})]}),e.jsx(_e,{checked:o.is_active,onCheckedChange:m=>j(o.id,m),onClick:m=>m.stopPropagation()})]})}),n===o.id&&h&&e.jsx("div",{className:"border-t border-slate-600 bg-slate-800/40",children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Pe,{className:"h-4 w-4 text-slate-300"}),e.jsxs("h4",{className:"text-sm font-medium text-slate-200",children:["Configuring Agent: ",o.key_name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(O,{htmlFor:"working",className:"text-slate-200",children:"AI Agent Working"}),e.jsx("p",{className:"text-sm text-slate-400",children:"Enable/disable AI agent"})]}),e.jsx(_e,{id:"working",checked:p.ai_agent_working,onCheckedChange:m=>L({...p,ai_agent_working:m})})]}),e.jsxs("div",{children:[e.jsx(O,{htmlFor:"model",className:"text-slate-200",children:"AI Model"}),e.jsxs(ce,{value:p.ai_model||"",onValueChange:m=>L({...p,ai_model:m}),children:[e.jsx(oe,{className:"bg-slate-900 border-slate-600 text-slate-100",children:e.jsx(de,{placeholder:"Select AI model"})}),e.jsx(me,{className:"bg-slate-800 border-slate-600",children:u?e.jsx(P,{value:"loading",disabled:!0,className:"text-slate-400",children:"Loading models..."}):D.length===0?e.jsx(P,{value:"no-models",disabled:!0,className:"text-slate-400",children:"No models available"}):D.map(m=>e.jsxs(P,{value:m.model_id,className:"text-slate-100",children:[m.model_name," (",m.provider,")"]},m.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(O,{htmlFor:"systemPrompt",className:"text-slate-200",children:"System Prompt"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ce,{value:"",onValueChange:m=>{const K=y.find(M=>M.id===m);K&&L({...p,ai_system_prompt:K.prompt_text})},children:[e.jsx(oe,{className:"bg-slate-900 border-slate-600 text-slate-100",children:e.jsx(de,{placeholder:"Select predefined prompt"})}),e.jsx(me,{className:"bg-slate-800 border-slate-600",children:v?e.jsx(P,{value:"loading",disabled:!0,className:"text-slate-400",children:"Loading prompts..."}):y.length===0?e.jsx(P,{value:"no-prompts",disabled:!0,className:"text-slate-400",children:"No prompts available"}):y.map(m=>e.jsx(P,{value:m.id,className:"text-slate-100",children:m.title},m.id))})]}),e.jsx(pe,{id:"systemPrompt",placeholder:"Enter system prompt for AI agent...",value:p.ai_system_prompt||"",onChange:m=>L({...p,ai_system_prompt:m.target.value}),className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400 min-h-[100px]"})]})]}),e.jsxs("div",{children:[e.jsx(O,{htmlFor:"systemPromptContinue",className:"text-slate-200",children:"System Prompt continue - JSON Output Variable Format Specification"}),e.jsx("p",{className:"text-sm text-slate-400 mb-2",children:"Define the JSON structure the AI should return, specifying variable types and allowed value ranges"}),e.jsx(As,{value:p.ai_system_prompt_continue||"",onChange:m=>L({...p,ai_system_prompt_continue:m}),placeholder:"Click Add Variable to build the JSON format..."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs(O,{htmlFor:"userPrompt",className:"text-slate-200",children:["User Prompt - ",e.jsx("span",{className:"font-light text-slate-400",children:"Describe the trading strategy or free-form instructions you want the AI Agent to analyze and act on"})]}),e.jsx(Cs,{onPromptSelect:m=>L({...p,ai_user_prompt:m})})]}),e.jsx(pe,{id:"userPrompt",placeholder:"Enter user prompt...",value:p.ai_user_prompt||"",onChange:m=>L({...p,ai_user_prompt:m.target.value}),className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400 min-h-[100px]"})]}),e.jsxs("div",{children:[e.jsx(O,{htmlFor:"userPromptContinue",className:"text-slate-200",children:"User Prompt Continue"}),e.jsx(pe,{id:"userPromptContinue",placeholder:"Continue user prompt...",value:p.ai_user_prompt_continue||"",onChange:m=>L({...p,ai_user_prompt_continue:m.target.value}),className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400 min-h-[80px]"})]}),e.jsxs("div",{className:"flex items-end justify-between gap-4 pt-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(Q,{id:"fxdreemaName",placeholder:"Enter FXDreema name or link...",value:p.fxdreema_name||"",onChange:m=>L({...p,fxdreema_name:m.target.value}),className:"bg-slate-900 border-slate-600 text-slate-100 placeholder:text-slate-400"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{htmlFor:"fxdreemaName",className:"text-slate-200 whitespace-nowrap",children:"(Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{onClick:Y,variant:"outline",size:"sm",className:"border-slate-600 text-slate-300 hover:bg-slate-700",children:[e.jsx(Xe,{className:"h-4 w-4 mr-1"}),"Export"]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"file",accept:".json",onChange:H,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",id:`import-${o.id}`}),e.jsx(w,{variant:"outline",size:"sm",className:"border-slate-600 text-slate-300 hover:bg-slate-700",asChild:!0,children:e.jsxs("label",{htmlFor:`import-${o.id}`,className:"cursor-pointer flex items-center",children:[e.jsx(js,{className:"h-4 w-4 mr-1"}),"Import"]})})]}),e.jsx(w,{onClick:Ge,disabled:g,className:"bg-blue-600 hover:bg-blue-700 text-white",children:g?"Saving...":"Save Settings"})]})]})]})]})]})})]},o.id))})]})]})})},Es=()=>{const[r,n]=i.useState([]),[x,h]=i.useState(!0),[c,g]=i.useState(null);return i.useEffect(()=>{(async()=>{try{h(!0);const{data:b,error:I}=await _.from("gpt_oss_guides").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});if(I)throw I;n(b||[])}catch(b){console.error("Error fetching GPT-OSS guides:",b),g(b instanceof Error?b.message:"Unknown error")}finally{h(!1)}})()},[]),{guides:r,loading:x,error:c,getGuidesByCategory:N=>r.filter(b=>b.category===N),getCategories:()=>[...new Set(r.map(b=>b.category))].sort()}},Ts=()=>{const{guides:r,loading:n,error:x,getGuidesByCategory:h,getCategories:c}=Es(),g=j=>{switch(j){case"setup":return e.jsx(as,{className:"h-5 w-5"});case"usage":return e.jsx(ys,{className:"h-5 w-5"});case"security":return e.jsx(ts,{className:"h-5 w-5"});case"automation":return e.jsx(Pe,{className:"h-5 w-5"});case"trading":return e.jsx(ss,{className:"h-5 w-5"});case"architecture":return e.jsx(ue,{className:"h-5 w-5"});default:return e.jsx(J,{className:"h-5 w-5"})}},f=j=>({setup:"System Setup",usage:"API Usage",security:"Security",automation:"Automation",trading:"Trading with MT5",architecture:"System Architecture"})[j]||j;return n?e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"GPT-OSS RAG Knowledge Base"]}),e.jsx(q,{children:"Guide to installing and using GPT-OSS as an API for AI Trading"})]}),e.jsx($,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(je,{className:"h-5 w-5 animate-spin"}),"Loading guide..."]})})]}):x?e.jsxs(F,{children:[e.jsx(R,{children:e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"GPT-OSS RAG Knowledge Base"]})}),e.jsx($,{className:"text-center py-8",children:e.jsxs("p",{className:"text-destructive",children:["Error loading data: ",x]})})]}):e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"GPT-OSS RAG Knowledge Base"]}),e.jsx(q,{children:"Guide to installing and using GPT-OSS as an API for AI Trading"})]}),e.jsxs($,{children:[e.jsxs("div",{className:"mb-8 p-6 bg-gradient-to-r from-purple-50 to-blue-50 dark:from-purple-900/20 dark:to-blue-900/20 rounded-lg border border-purple-200 dark:border-purple-800/50",children:[e.jsxs("h3",{className:"text-lg font-semibold text-purple-900 dark:text-purple-100 mb-3 flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"🧠 Build a personal AI that understands you - Fine-tune it with your own data"]}),e.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none mb-4",children:e.jsxs("p",{className:"text-purple-800 dark:text-purple-200 leading-relaxed",children:[e.jsx("strong",{children:"GPT-OSS"})," is an open-source AI model you can install and fine-tune with your own private data. No depen
20dence on ChatGPT or external APIs - you get an ",e.jsx("strong",{children:"AI that understands your trading style 100%"})]})}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 flex items-center gap-2",children:"🎯 What makes GPT-OSS special"}),e.jsxs("ul",{className:"space-y-2 text-sm text-purple-700 dark:text-purple-300",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 dark:text-green-400 mt-0.5",children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Self fine-tuning:"})," Train the AI on your own trading strategies"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 dark:text-green-400 mt-0.5",children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{children:"No limits:"})," Unlimited usage with no API fees"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 dark:text-green-400 mt-0.5",children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Data privacy:"})," The AI runs on your machine — nothing is sent outside"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-green-600 dark:text-green-400 mt-0.5",children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Fully customizable:"})," Swap models and adjust parameters as needed"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 flex items-center gap-2",children:"🚀 What you get"}),e.jsxs("ul",{className:"space-y-2 text-sm text-purple-700 dark:text-purple-300",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 mt-0.5",children:"🎯"}),e.jsxs("span",{children:[e.jsx("strong",{children:"An AI that understands you:"})," Knows your trading style and risk management"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 mt-0.5",children:"🔬"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Teachable:"})," Feed it more data on whatever you want it to master"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 mt-0.5",children:"⚡"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Faster:"})," No waiting for external APIs — processed locally"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 mt-0.5",children:"💰"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Cost-effective:"})," No monthly API fees"]})]})]})]})]}),e.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-900/30 dark:to-orange-900/30 rounded-lg border border-amber-200 dark:border-amber-600/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-amber-500/20 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-amber-600 dark:text-amber-400 text-sm",children:"💡"})})}),e.jsxs("div",{children:[e.jsx("h5",{className:"font-medium text-amber-800 dark:text-amber-200 mb-1",children:"Examples of teaching the AI"}),e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:["• Feed it your profitable trade history → the AI learns the patterns that work",e.jsx("br",{}),"• Add your risk management rules → the AI keeps risk in check by your principles",e.jsx("br",{}),"• Teach it economics → the AI analyzes news and its impact on markets"]})]})]})})]}),c().length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(J,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No guide available yet"})]}):e.jsx("div",{className:"space-y-6",children:c().map(j=>{const N=h(j);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-lg font-semibold",children:[g(j),f(j),e.jsxs(W,{variant:"secondary",className:"ml-auto",children:[N.length," guides"]})]}),e.jsx(ls,{type:"single",collapsible:!0,className:"w-full",children:N.map(b=>e.jsxs(is,{value:b.id,className:"border border-border/50 rounded-lg mb-2 px-4",children:[e.jsx(cs,{className:"hover:no-underline py-4",children:e.jsx("span",{className:"text-left font-medium",children:b.title})}),e.jsx(os,{className:"pb-4",children:e.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",dangerouslySetInnerHTML:{__html:b.content.replace(/```(\w+)?\n([\s\S]*?)```/g,'<pre class="bg-muted p-3 rounded-md overflow-x-auto"><code class="language-$1">$2</code></pre>').replace(/`([^`]+)`/g,'<code class="bg-muted px-1 py-0.5 rounded text-xs">$1</code>').replace(/## (.*)/g,'<h3 class="text-base font-semibold mt-4 mb-2 text-foreground">$1</h3>
20').replace(/### (.*)/g,'<h4 class="text-sm font-medium mt-3 mb-1 text-foreground">$1</h4>').replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\n/g,"<br/>")}})})})]},b.id))})]},j)})})]})]})},Ls=()=>{const{user:r}=ge(),{toast:n}=z(),[x,h]=i.useState(null),[c,g]=i.useState(!0),[f,j]=i.useState(""),[N,b]=i.useState(0),I=async u=>{try{await navigator.clipboard.writeText(u),n({title:"Copied!",description:"Command copied to clipboard"})}catch{n({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},C=i.useCallback(async()=>{if(r!=null&&r.id){g(!0);try{console.log("Fetching LINE connection for user:",r==null?void 0:r.id);const{data:u,error:y}=await _.from("line_connections").select("*").eq("user_id",r.id).order("created_at",{ascending:!1});if(y&&y.code!=="PGRST116")throw console.error("Error fetching LINE connection:",y),y;console.log("LINE connection data:",u),u&&u.length>0?(console.log("Setting LINE connection:",u[0]),h(u[0])):h(null)}catch(u){console.error("Error fetching LINE connection:",u),n({title:"Error",description:"Failed to fetch LINE connection status",variant:"destructive"})}finally{g(!1)}}},[r==null?void 0:r.id,n]),A=async()=>{try{const u=Math.random().toString(36).substr(2,9).toUpperCase();j(u),b(300);const y=new Date(Date.now()+5*60*1e3).toISOString();if(x&&!x.is_connected){const{error:v}=await _.from("line_connections").update({link_code:u,link_expires:y,is_connected:!1,updated_at:new Date().toISOString()}).eq("id",x.id);if(v)throw console.error("Error updating PIN:",v),v}else{const{error:v}=await _.from("line_connections").insert({user_id:r==null?void 0:r.id,link_code:u,link_expires:y,is_connected:!1,created_at:new Date().toISOString()});if(v)throw console.error("Error creating PIN record:",v),v}C(),n({title:"PIN Generated!",description:"Send the PIN code via LINE chat to connect your account."})}catch(u){console.error("Error generating PIN:",u),n({title:"Error",description:"Failed to generate PIN code",variant:"destructive"})}},T=async()=>{if(!f){n({title:"Error",description:"No PIN code available for testing",variant:"destructive"});return}try{console.log("Testing LINE connection with PIN:",f);const u=await _.functions.invoke("test-line-connection",{body:{pin_code:f,user_id:r==null?void 0:r.id}});if(u.error)throw u.error;n({title:"Test Successful!",description:"LINE connection test completed successfully"}),C()}catch(u){console.error("Error testing LINE connection:",u),n({title:"Test Failed",description:"Unable to test LINE connection. Please try again.",variant:"destructive"})}},D=async()=>{try{const{error:u}=await _.from("line_connections").update({is_connected:!1,line_user_id:null,line_display_name:null,line_profile_picture:null,connected_at:null}).eq("user_id",r==null?void 0:r.id);if(u)throw u;h(null),n({title:"Disconnected",description:"LINE account disconnected successfully!"})}catch(u){console.error("Error disconnecting LINE:",u),n({title:"Error",description:"Failed to disconnect LINE account",variant:"destructive"})}};return i.useEffect(()=>{C();const u=_.channel("line-connections-changes").on("postgres_changes",{event:"*",schema:"public",table:"line_connections",filter:`user_id=eq.${r==null?void 0:r.id}`},v=>{console.log("LINE connection updated:",v);const t=v.new;h(t),t!=null&&t.is_connected&&n({title:"🎉 LINE Connected!",description:`Welcome ${t.line_display_name||"LINE User"}!`}),C()}).subscribe(),y=_.channel("line-connection-broadcast").on("broadcast",{event:"line_connected"},v=>{var t;console.log("Received LINE connection broadcast:",v),((t=v.payload)==null?void 0:t.user_id)===(r==null?void 0:r.id)&&
20(C(),n({title:"🎉 LINE Connected!",description:"Your LINE account has been connected successfully!"}))}).subscribe();return()=>{_.removeChannel(u),_.removeChannel(y)}},[C,r==null?void 0:r.id]),i.useEffect(()=>{let u;return N>0?u=setInterval(()=>{b(y=>y-1)},1e3):N===0&&f&&j(""),()=>clearInterval(u)},[N,f]),e.jsxs(F,{className:"bg-slate-800/60 border-slate-700",children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2 text-slate-100",children:[e.jsx(ie,{className:"h-5 w-5 text-green-500"}),"LINE Account Connection"]}),e.jsx(q,{className:"text-slate-300",children:"Connect your LINE account to control AI trading via chat"})]}),e.jsx($,{className:"space-y-4",children:c?e.jsx("div",{className:"text-center py-4",children:e.jsx("p",{className:"text-slate-400",children:"Checking connection status..."})}):x!=null&&x.is_connected?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-gradient-to-r from-green-600/20 to-emerald-600/20 rounded-lg border border-green-500/30",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"h-8 w-8 bg-green-600/20 rounded-full flex items-center justify-center",children:e.jsx(ie,{className:"h-4 w-4 text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-green-400",children:"🎉 LINE Account Connected Successfully!"}),e.jsx("p",{className:"text-sm text-green-300",children:"You can now control your AI Bot via LINE Chat"})]}),e.jsx(w,{size:"sm",variant:"outline",onClick:D,className:"text-red-400 border-red-500/30 hover:bg-red-600/20",children:"Disconnect"})]}),e.jsxs("div",{className:"flex items-center gap-4 p-3 bg-slate-900/60 rounded-lg border border-green-500/20",children:[e.jsxs(Ye,{className:"h-16 w-16 border-2 border-green-400/30",children:[e.jsx(Ze,{src:x.line_profile_picture||"",alt:x.line_display_name||"LINE User"}),e.jsx(es,{className:"bg-green-600/20 text-green-400 text-lg",children:x.line_display_name?x.line_display_name.charAt(0).toUpperCase():e.jsx(ie,{className:"h-6 w-6"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-slate-100 text-lg",children:x.line_display_name||"LINE User"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("p",{className:"text-sm text-slate-400 font-mono truncate max-w-[200px]",title:x.line_user_id,children:["LINE ID: ",x.line_user_id]}),e.jsx(w,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-slate-400 hover:text-slate-200",onClick:()=>navigator.clipboard.writeText(x.line_user_id),children:e.jsx(xe,{className:"h-3 w-3"})})]}),e.jsxs("p",{className:"text-xs text-green-400 mt-1",children:["Connected at: ",x.connected_at?new Date(x.connected_at).toLocaleString("th-TH"):"Unknown"]})]}),e.jsx("div",{className:"text-right flex-shrink-0",children:e.jsx(W,{variant:"outline",className:"text-green-400 border-green-500/30 bg-green-600/20",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"}),"Connected"]})})})]})]}),e.jsxs("div",{className:"p-4 bg-blue-600/20 rounded-lg border border-blue-500/30",children:[e.jsx("h4",{className:"font-medium text-blue-400 mb-3",children:"📋 Next steps:"}),e.jsxs("ul",{className:"space-y-2 text-sm text-blue-300",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-blue-400",children:"1."}),e.jsx("span",{children:"Create Connector Keys above"})]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-blue-400",children:"2."}),e.jsx("span",{children:"Use commands from Quick Reference"})]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-blue-400",children:"3."}),e.jsx("span",{children:"Check command history in Commands tab"})]})]})]})]}):e.jsx("div",{className:"space-y-4",children:f&&N>0?e.jsxs("div",{className:"p-4 bg-blue-600/20 rounded-lg border border-blue-500/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"font-medium text-blue-400",children:"Send this code in LINE Chat:"}),e.jsxs("div",{className:"flex items-center gap-2 text-blue-300",children:[e.jsx(Oe,{className:"h-4 w-4"}),e.jsxs("span",{className:"font-mono",children:[N,"s"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"bg-slate-900 px-4 py-3 rounded-lg border border-blue-500/30 shadow-sm",children:e.jsxs("code",{className:"text-2xl font-mono font-bold text-slate-100 tracking-wider",children:["/connect ",f]})}),e.jsx(w,{size:"sm",variant:"outline",onClick:()=>I(`/connect ${f}`),className:"border-slate-600 text-slate-300 hover:bg-slate-700",children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 text-sm text-blue-300",children:[e.jsx("p",{children:"💡 Send this command in LINE OA chat to connect your account"}),e.jsxs("p",{children:["🔄 PIN expires in ",Math.floor(N/60),":",(N%60).toString().padStart(2,"0")]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs(w,{onClick:A,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:[e.jsx(Ns,{className:"h-4 w-4 mr-2"}),"Generate Connection PIN"]}),f&&e.jsxs(w,{onClick:T,variant:"outline",className:"w-full border-slate-600 text-slate-300 hover:bg-slate-700",children:[e.jsx(De,{className:"h-4 w-4 mr-2"}),"Test Connection (PIN: ",f,")"]}),e.jsxs("div",{className:"p-4 bg-slate-700/40 rounded-lg border border-slate-600",children:[e.jsx("h4",{className:"font-medium text-slate-200 mb-3",children:"🔗 Connection Steps:"}),e.jsx("div",{className:"mb-4 p-3 bg-slate-800/50 rounded-lg border border-slate-600",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("img",{src:"/lovable-uploads/74ad5c33-a7f0-477e-a5d7-2f9a2178aa17.png",alt:"My WOBR AI Official bot QR Code",className:"w-16 h-16 rounded-lg"}),e.jsxs("div",{children:[e.jsx("h5",{className:"font-medium text-slate-200",children:"My WOBR AI Official bot"}),e.jsx(w,{asChild:!0,size:"sm",variant:"outline",className:"h-6 px-2 border-slate-600 text-slate-300 hover:bg-slate-700",children:e.jsx("a",{href:"https://line.me/R/ti/p/%40mywobrai",target:"_blank",rel:"noopener noreferrer",children:"@mywobrai"})})]})]})}),e.jsxs("ol",{className:"space-y-2 text-sm text-slate-300",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-400 font-bold",children:"1."}),e.jsx("span",{children:"Add LINE Official Account above or scan QR code"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-400 font-bold",children:"2."}),e.jsx("span",{children:'Click "Generate Connection PIN" above'})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-400 font-bold",children:"3."}),e.jsxs("span",{children:["Send the PIN code in LINE chat: ",e.jsx("code",{className:"bg-slate-800 px-1 rounded",children:"/connect [PIN]"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-400 font-bold",children:"4."}),e.jsx("span",{children:"Wait for confirmation message"})]})]})]})]})})})]})},Ps=()=>{ge();const{toast:r}=z(),[n,x]=i.useState(""),[h,c]=i.useState([]),[g,f]=i.useState(!1),j=async d=>{f(!0);const a=new Date;let s="";try{const l=d.trim();l.startsWith("/status")?s=await N():l.startsWith("/performance")?s=await b():l.startsWith("/balance")?s=await I():l.startsWith("/equity")?s=await C():l.startsWith("/trades")?s=await A():l.startsWith("/stop_all")?s=await T():l.startsWith("/start_all")?s=await D():l.startsWith("/emergency_stop")?s=await u():l.startsWith("/ask")?s=await y(l):l.includes("/working=")||l.includes("/model=")||l.includes("/system_prompt=")||l.includes("/system_prompt_con=")||l.includes("/system_prompt_continue=")||l.includes("/user_prompt=")||l.includes("/user_prompt_con=")||l.includes("/user_prompt_continue=")?s=await v(l):l.includes("/check")?s=await t(l):s=`❌ Unknown command: ${l}
21
22Available commands:
23• /status - View system status
24• /performance - View performance
25• /ask = {question} - Ask a question
26• /{agent}/working=true/false - Turn Agent on/off
27• /{agent}/check - View Agent settings`,c(E=>[{command:l,response:s,timestamp:a}
27,...E.slice(0,49)]),r({title:"Command executed",description:"Command executed successfully"})}catch(l){s=`❌ Error: ${l}`,r({title:"Command Error",description:"Failed to execute command",variant:"destructive"})}finally{f(!1)}},N=async()=>{var d,a;try{const{data:s}=await _.functions.invoke("ai-agent-keys",{body:{action:"list"}}),l=((d=s==null?void 0:s.keys)==null?void 0:d.filter(p=>p.ai_agent_working))||[];return`🤖 WOBR.AI System Status
28
29✅ Total AI Agents: ${((a=s==null?void 0:s.keys)==null?void 0:a.length)||0}
30🟢 Active AI Agents: ${l.length}
31⏰ Checked at: ${new Date().toLocaleString("th-TH")}
32
33Active Agents:
34${l.map(p=>`• ${p.key_name} (${p.ai_model})`).join(`
35`)||"None"}`}catch(s){return`❌ Unable to get status: ${s}`}},b=async()=>`📊 Performance Report
36
37💰 Account Balance: Loading...
38📈 Equity: Loading...
39💹 Today's P/L: Loading...
40📋 Trade Count: Loading...
41⚠️ Margin Level: Loading...
42
43🔄 Connecting to MT5 to fetch the latest data...`,I=async()=>`💰 Account Balance: Fetching from MT5...
44⏰ Updated: ${new Date().toLocaleString("th-TH")}`,C=async()=>`📈 Equity: Fetching from MT5...
45⏰ Updated: ${new Date().toLocaleString("th-TH")}`,A=async()=>`📋 Open Trades: Fetching from MT5...
46⏰ Updated: ${new Date().toLocaleString("th-TH")}`,T=async()=>{var d;try{const{data:a}=await _.functions.invoke("ai-agent-keys",{body:{action:"list"}});if(((d=a==null?void 0:a.keys)==null?void 0:d.length)>0){for(const s of a.keys)await _.functions.invoke("ai-agent-keys",{body:{action:"update_settings",key_id:s.id,settings:{ai_agent_working:!1}}});return`🛑 All AI Agents stopped (${a.keys.length} agents)
47⏰ Time: ${new Date().toLocaleString("th-TH")}`}else return"ℹ️ No AI Agents to stop"}catch(a){return`❌ Unable to stop AI Agents: ${a}`}},D=async()=>{var d;try{const{data:a}=await _.functions.invoke("ai-agent-keys",{body:{action:"list"}});if(((d=a==null?void 0:a.keys)==null?void 0:d.length)>0){for(const s of a.keys)await _.functions.invoke("ai-agent-keys",{body:{action:"update_settings",key_id:s.id,settings:{ai_agent_working:!0}}});return`🚀 All AI Agents started (${a.keys.length} agents)
48⏰ Time: ${new Date().toLocaleString("th-TH")}`}else return"ℹ️ No AI Agents to start"}catch(a){return`❌ Unable to start AI Agents: ${a}`}},u=async()=>{try{return await T(),`🚨 EMERGENCY STOP complete!
49
50✅ All AI Agents stopped
51⏰ Time: ${new Date().toLocaleString("th-TH")}
52
53📢 Please check your trading status in MT5`}catch(d){return`❌ EMERGENCY STOP failed: ${d}`}},y=async d=>{const a=d.replace("/ask","").replace("=","").trim();return a?`🤖 Question: ${a}
54
55Searching the WOBR.AI knowledge base for an answer...
56
57The AI Q&A system is still in development — please await updates`:"❓ Please enter a question, e.g.: /ask = What is WOBR.AI?"},v=async d=>{var L,V;const a=d.split("/");if(a.length<2)return"❌ Invalid command format. Use: /{agent_name}/{setting}={value}";const s=a[1].split("/")[0],l=d.substring(d.lastIndexOf("/")+1);if(!s||!l.includes("="))return`❌ Invalid command format. Use: /${s}/working=true`;const[E,p]=l.split("=");try{const{data:S}=await _.functions.invoke("ai-agent-keys",{body:{action:"list"}}),Y=(L=S==null?void 0:S.keys)==null?void 0:L.find(te=>te.key_name===s);if(!Y)return`❌ AI Agent not found: ${s}
58
59Available Agents: ${((V=S==null?void 0:S.keys)==null?void 0:V.map(te=>te.key_name).join(", "))||"None"}`;const H={};if(E==="working")H.ai_agent_working=p.toLowerCase()==="true";else if(E==="model")H.ai_model=p;else if(E==="system_prompt")H.ai_system_prompt=p;else if(E==="system_prompt_con"||E==="system_prompt_continue")H.ai_system_prompt_continue=p;else if(E==="user_prompt")H.ai_user_prompt=p;else if(E==="user_prompt_con"||E==="user_prompt_continue")H.ai_user_prompt_continue=p;else return`❌ Unknown setting: ${E}`;return await _.functions.invoke("ai-agent-keys",{body:{action:"update_settings",key_id:Y.id,settings:H}}),`✅ Updated ${E} for Agent "${s}"
60📝 New value: ${p}
61⏰ Time: ${new Date().toLocaleString("th-TH")}`}catch(S){return`❌ Unable to update Agent: ${S}`}},t=async d=>{var s,l,E,p,L;const a=d.split("/")[1];try{const{data:V}=await _.functions.invoke("ai-agent-keys",{body:{action:"list"}}),S=(s=V==null?void 0:V.keys)==null?void 0:s.find(Y=>Y.key_name===a);
61return S?`🤖 AI Agent Settings "${a}"
62
63🟢 Working status: ${S.ai_agent_working?"On":"Off"}
64🧠 AI Model: ${S.ai_model}
65📝 System Prompt: ${(l=S.ai_system_prompt)==null?void 0:l.substring(0,100)}${((E=S.ai_system_prompt)==null?void 0:E.length)>100?"...":""}
66👤 User Prompt: ${(p=S.ai_user_prompt)==null?void 0:p.substring(0,100)}${((L=S.ai_user_prompt)==null?void 0:L.length)>100?"...":""}
67📊 Usage count: ${S.usage_count}
68⏰ Last used: ${S.last_used_at?new Date(S.last_used_at).toLocaleString("th-TH"):"Never"}`:`❌ AI Agent not found: ${a}`}catch(V){return`❌ Unable to get Agent info: ${V}`}},k=async d=>{d.preventDefault(),!(!n.trim()||g)&&(await j(n),x(""))};return e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(vs,{className:"h-5 w-5"}),"Command Line Interface"]}),e.jsx(q,{children:"Execute AI Agent commands directly"})]}),e.jsxs($,{children:[e.jsx("div",{className:"mb-6",children:e.jsxs("form",{onSubmit:k,className:"flex gap-2",children:[e.jsx(Q,{value:n,onChange:d=>x(d.target.value),placeholder:"Type a command, e.g. /status or /myagent/working=false",className:"flex-1 font-mono text-sm bg-slate-800 border-slate-600 text-slate-100",disabled:g}),e.jsx(w,{type:"submit",size:"sm",disabled:g||!n.trim(),children:g?e.jsx(je,{className:"h-4 w-4 animate-spin"}):"Execute"})]})}),h.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h4",{className:"font-semibold text-sm mb-3 flex items-center gap-2",children:[e.jsx(Oe,{className:"h-4 w-4"}),"Command History"]}),e.jsx("div",{className:"space-y-3 max-h-60 overflow-y-auto",children:h.slice(0,5).map((d,a)=>e.jsxs("div",{className:"bg-slate-800/50 rounded-lg p-3 border border-slate-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-mono text-sm text-blue-400",children:d.command}),e.jsx("span",{className:"text-xs text-slate-400",children:d.timestamp.toLocaleTimeString("th-TH")})]}),e.jsx("div",{className:"text-sm text-slate-300 whitespace-pre-wrap bg-slate-900/50 p-2 rounded border border-slate-600",children:d.response})]},a))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"🧠 AI Q&A Commands"}),e.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-purple-50 dark:from-blue-900/20 dark:to-purple-900/20 p-3 rounded-md space-y-1 text-sm font-mono border-2 border-blue-200 dark:border-blue-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-blue-600 dark:text-blue-400 font-bold",children:["/ask = ","{question}"]})," ",e.jsx("span",{className:"text-foreground font-medium",children:"- Ask about WOBR.AI and trading"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-2 space-y-1",children:[e.jsx("div",{children:"• The AI searches the knowledge base and answers your question"}),e.jsxs("div",{children:["• Example: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-mono",children:"/ask = What is WOBR.AI?"})]}),e.jsxs("div",{children:["• Example: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-mono",children:"/ask = How do I install an EA?"})]}),e.jsxs("div",{children:["• Example: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-mono",children:"/ask = Recommend a trading strategy"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"🤖 AI Agent Control"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md space-y-1 text-sm font-mono",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-blue-600 dark:text-blue-400 font-semibold",children:["/","{Agent Name}","/check"]})," ",e.jsx("span",{className:"text-foreground",children:"- View AI Agent settings"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:["/","{Agent Name}","/working=true"]})," ",e.jsx("span",{className:"text-foreground",children:"- Enable/disable AI agent"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:["/","{Agent Name}","/model=openai/gpt-4o"]})," ",e.jsx("span",{className:"text-foreground",children:"- Set AI model"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:["/","{Agent Name}","/system_prompt="]})," ",e.jsx("span",{className:"text-foreground",children:"- Set system prompt"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:["/","{Agent Name}","/system_prompt_con="]})," ",e.jsx("span",{className:"text-foreground",children:"- Set system prompt continue"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:["/","{Agent Name}","/user_prompt="]})," ",e.jsx("span",{className:"text-foreground",children:"- Set user prompt"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:["/","{Agent Name}","/user_prompt_con="]})," ",e.jsx("span",{className:"text-foreground",children:"- Set user prompt continue"})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"📊 Status & Monitoring Commands"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md space-y-1 text-sm font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dar
68k:text-blue-400 font-semibold",children:"/status"})," ",e.jsx("span",{className:"text-foreground",children:"- Check AI agent and panel status"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-semibold",children:"/performance"})," ",e.jsx("span",{className:"text-foreground",children:"- View balance, equity, profit, margin%, total trades"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-semibold",children:"/balance"})," ",e.jsx("span",{className:"text-foreground",children:"- Check current account balance"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-semibold",children:"/equity"})," ",e.jsx("span",{className:"text-foreground",children:"- Check current equity"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400 font-semibold",children:"/trades"})," ",e.jsx("span",{className:"text-foreground",children:"- View active trades count"})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"🎮 Global Control Commands"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md space-y-1 text-sm font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-red-600 dark:text-red-400 font-semibold",children:"/stop_all"})," ",e.jsx("span",{className:"text-foreground",children:"- Stop all AI agents (set all working=false)"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-green-600 dark:text-green-400 font-semibold",children:"/start_all"})," ",e.jsx("span",{className:"text-foreground",children:"- Start all AI agents (set all working=true)"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-orange-600 dark:text-orange-400 font-semibold",children:"/emergency_stop"})," ",e.jsx("span",{className:"text-foreground",children:"- Emergency stop all trading activities"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-purple-600 dark:text-purple-400 font-semibold",children:"/risk_check"})," ",e.jsx("span",{className:"text-foreground",children:"- Check risk levels across all agents"})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"📈 Reporting Commands"}),e.jsxs("div",{className:"bg-muted p-3 rounded-md space-y-1 text-sm font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-600 dark:text-indigo-400 font-semibold",children:"/daily_report"})," ",e.jsx("span",{className:"text-foreground",children:"- Generate daily performance report"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-600 dark:text-indigo-400 font-semibold",children:"/weekly_report"})," ",e.jsx("span",{className:"text-foreground",children:"- Generate weekly performance summary"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-600 dark:text-indigo-400 font-semibold",children:"/monthly_report"})," ",e.jsx("span",{className:"text-foreground",children:"- Generate monthly performance analysis"})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm mb-2",children:"📝 Examples"}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-md space-y-1 text-sm font-mono border border-blue-200 dark:border-blue-700",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"/myagent/working=false"})," - Disable AI Agent"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"/myagent/model=openai/gpt-4o"})," - Set AI model to GPT-4o"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"/myagent/system_prompt=You are a conservative trader"})," - Update system prompt"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"/myagent/user_prompt=Analyze this market data"})," - Update user prompt"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground bg-amber-50 dark:bg-amber-900/20 p-3 rounded-md border border-amber-200 dark:border-amber-600",children:[e.jsxs("p",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{children:"💡"}),e.jsxs("span",{children:["Replace ","{key_name}"," with your actual AI agent key name"]})]}),e.jsxs("p",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{children:"🔄"}),e.jsx("span",{children:"Changes are applied instantly and create new version"})]}),e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx("span",{children:"📱"}),e.jsx("span",{children:"Commands work both here and in LINE OA after connecting your account"})]})]})]})]})]})};function st(){const[r,n]=i.useState("basic-knowledge"),{variables:x,isLoading:h}=Fe();return e.jsx("div",{className:"min-h-screen text-foreground p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-100 mb-2",children:"Connector Keys"}),e.jsx("p",{className:"text-slate-300",children:"Smart AI Agent Control Panel for Automated Trading Management"})]}),e.jsxs(F,{className:"mb-8 bg-gradient-to-r from-blue-900/30 to-indigo-900/30 border-blue-700/50",children:[e.jsx(R,{children:e.jsxs(U,{className:"flex items-center gap-2 text-blue-100",children:[e.jsx(Qe,{className:"h-6 w-6"}),"🤖 AI Trading Agent Swarm - Your Personal AI Fleet Control Panel"]})}),e.jsxs($,{className:"space-y-4",children:[e.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:e.jsxs("p",{className:"text-blue-200 leading-relaxed text-lg",children:[e.jsx("strong",{children:"Build an AI that understands your trading style"})," — connect MT5 + LINE and control everything with ease"]})}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4 mt-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold text-blue-100 text-sm",children:"🎯 Goals"}),e.jsxs("ul",{className:"space-y-1 text-sm text-blue-200",children:[e.jsx("li",{children:"✓ An AI that understands your strategy"}),e.jsx("li",{children:"✓ Automated trading via MT5 bots"}),e.jsx("li",{children:"✓ Command it through LINE"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold text-blue-100 text-sm",children:"⚡ Benefits"}),e.jsxs("ul",{className:"space-y-1 text-sm text-blue-200",children:[e.jsx("li",{children:"⚡ World-class AI brains trading in your style"}),e.jsx("li",{children:"⚡ Fast, precise, high-performance decisions"}),e.jsx("li",{children:"🔒 100% data security"})]})]})]}),e.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-amber-900/20 to-yellow-900/20 rounded-lg border border-amber-700/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-amber-500/20 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-amber-400 text-sm",children:"💡"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-amber-200 mb-3",children:"4 steps to get started"}),e.jsxs("div",{className:"space-y-2 text-sm text-amber-100",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-amber-600 text-amber-50 rounded-full w-5 h-5 flex items-center justify-center text-xs font-bold flex-shrink-0",children:"1"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Create Connector Keys"})," - Generate keys for your AI Agents"]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-amber-600 text-amber-50 rounded-full w-5 h-5 flex items-center justify-center text-xs font-bold flex-shrink-0",children:"2"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Build an FXDreema job linked to your AI Agent"})," - Set up automated trading"]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-amber-600 text-amber-50 rounded-full w-5 h-5 flex items-center justify-center text-xs font-bold flex-shrink-0",children:"3"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Run the AI Agent Manager bot on MT5"})," - Connect to your trading platform"]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-amber-600 text-amber-50 rounded-full w-5 h-5 flex items-center justify-center text-xs font-bold flex-shrink-0",children:"4"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Connect your LINE Account"})," - Command and control the AI via LINE"]})]})]})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsx(Ss,{})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ls,{}),e.jsx(Ps,{})]})]}),e.jsx("div",{className:"mt-8",children:e.jsxs(rs,{value:r,onValueChange:n,className:"w-full",children:[e.jsxs(ns,{className:"grid w-full grid-cols-5",children:[e.jsxs(ne,{value:"basic-knowledge",className:"flex items-center gap-2",children:[e.jsx(ye,{className:"h-4 w-4"}),"Basic Knowledge"]}),e.jsxs(ne,{value:"ai-prompt-guide",className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4"}),"AI Prompt Guide"]}),e.jsxs(ne,{value:"fxdreema-examples",className:"flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),"FXDreema Examples"]}),e.jsxs(ne,{value:"variable-dictionary",className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Variable Dictionary"]}),e.jsxs(ne,{value:"gpt-oss-rag",className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-4 w-4"}),"GPT-OSS RAG"]})]}),e.jsx(le,{value:"basic-knowledge",className:"mt-6",children:e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsx(U,{children:"Basic Knowledge"}),e.jsx(q,{children:"Fundamentals of AI Trading and working with FXDreema"})]}),e.jsx($,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ye,{className:"h-12 w-12 mx-auto text-gray-400 mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Fundamentals content coming soon"})]})})]})}),e.jsx(le,{value:"ai-prompt-guide",className:"mt-6",children:e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsx(U,{children:"AI Prompt Guide"}),e.jsx(q,{children:"Guide to writing effective prompts for AI Trading"})]}),e.jsx($,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ie,{className:"h-12 w-12 mx-auto text-gray-400 mb-4"}),e.jsx("p",{className:"text-gray-500",children:"AI Prompt guide coming soon"})]})})]})}),e.jsx(le,{value:"fxdreema-examples",className:"mt-6",children:e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsx(U,{children:"FXDreema Integration with LLM AI Examples"}),e.jsx(q,{children:"Example strategies and various ways to use FXDreema"})]}),e.jsx($,{children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"1"}),e.jsx("h3",{className:"text-lg font-semibold",children:"How to build an AI Agent Custom Block"})]}),e.jsx("img",{src:"/lovable-uploads/269c6ed0-0198-4b3c-a95a-3cbe95251d12.png",alt:"FXDreema Example 1",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Building an AI Agent Custom Block that connects to AI:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"Using Terminal Variables to send data"}),e.jsx("li",{children:"Configuring Send HTTP Request to connect to AI services"}),e.jsx("li",{children:"Building EA bots connected to AI with various trading strategies"}),e.jsx("li",{children:"Using AI brains such as ChatGPT, Claude, Gemini, DeepSeek, Grok"}),e.jsx("li",{children:"Basics of connecting FXDreema with Large Language Models"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"2"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Web Request GET for OpenAI"})]}),e.jsx("img",{src:"/lovable-uploads/3798a8a1-52ae-46aa-9b12-a5c80e505577.png",alt:"FXDreema Example 2",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Using the Web Request GET method to communicate with OpenAI:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"Setting up HTTP GET request headers and parameters"}),e.jsx("li",{children:"Sending market data to the OpenAI API"}),e.jsx("li",{children:"Receiving analysis back from the AI model"}
68),e.jsx("li",{children:"Handling response data and converting it into trading signals"}),e.jsx("li",{children:"Setting up authentication and the API key for OpenAI"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"3"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Web Request POST for OpenAI"})]}),e.jsx("img",{src:"/lovable-uploads/240bffef-ec01-4198-894b-3259941cffe0.png",alt:"FXDreema Example 3",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Using the Web Request POST method to communicate with OpenAI:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"Building a correctly structured POST request body"}),e.jsx("li",{children:"Sending a JSON payload to the OpenAI Chat Completion API"}),e.jsx("li",{children:"Setting Content-Type and Authorization headers"}),e.jsx("li",{children:"Handling errors and timeouts in the HTTP request"}),e.jsx("li",{children:"Parsing the response JSON and extracting the data you need"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Example: running the AI Agent block on every candle"})]}),e.jsx("img",{src:"/lovable-uploads/d336a0f6-e37d-4407-9603-b4e67792f1e1.png",alt:"FXDreema Example 4",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Configuring the AI Agent block to run on every new candle:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"Using the OnTick event so the AI analyzes every price change"}),e.jsx("li",{children:"Sending current OHLC (Open, High, Low, Close) data to the AI"}),e.jsx("li",{children:"Receiving real-time trading recommendations from OpenAI"}),e.jsx("li",{children:"Controlling rate limits to avoid calling the API too often"}),e.jsx("li",{children:"Examples of the AI Agent working in a live environment"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"5"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Building an AI Agent FXDreema Custom Block in detail"})]}),e.jsx("img",{src:"/lovable-uploads/6ce38e65-121b-4bfe-af2e-f1e19fc3bef8.png",alt:"FXDreema Example 5",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Building an AI Agent Custom Block step by step, with every line of code:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"Every line of code needed to build an AI-connected Custom Block"}),e.jsx("li",{children:"Copy-paste ready — no additional edits required"}),e.jsx("li",{children:"Extend it to build unlimited variations of trading bots"}),e.jsx("li",{children:"Details of the Custom Block's input/output parameters"}),e.jsx("li",{children:"Complete error and exception handling"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"6"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Prototype trading bot with the AI Agent Custom Block"})]}),e.jsx("img",{src:"/lovable-uploads/de38ddce-6a62-4bb5-b232-f68924770f38.png",alt:"FXDreema Example 6",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Using the AI Agent block to build a complete prototype trading bot:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"A bot that opens Buy and Sell trades on commands from the AI LLM"}),e.jsx("li",{children:"Automatic Stop Loss placement based on AI recommendations"}),e.jsx("li",{children:"Take Profit levels set from the AI model's anal
68ysis"}),e.jsx("li",{children:"Using the AI LLM brain for real-time trading decisions"}),e.jsx("li",{children:"A basic template example you can adapt for real use"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"7"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Advanced Template with intelligent AI LLM integration"})]}),e.jsx("img",{src:"/lovable-uploads/b0d8dfc4-1d45-425a-ae8c-ea191f75195a.png",alt:"FXDreema Example 7",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Using the Advanced Template for a highly intelligent AI trading bot:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"An advanced template blending technical analysis with AI intelligence"}),e.jsx("li",{children:"Using multiple AI models simultaneously for more accurate decisions"}),e.jsx("li",{children:"Market sentiment analysis via AI natural language processing"}),e.jsx("li",{children:"Dynamically adjusting strategy parameters to market conditions"}),e.jsx("li",{children:"AI-powered risk assessment and automatic position sizing"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"8"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Advance Template + Money Management"})]}),e.jsx("img",{src:"/lovable-uploads/0ca0199e-4d9d-4806-b854-2220258e378e.png",alt:"FXDreema Example 8",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Advanced Template with an excellent Money Management system:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"AI-powered money management that sizes lots to market volatility"}),e.jsx("li",{children:"Using AI to analyze risk-reward ratios before entering trades"}),e.jsx("li",{children:"Drawdown protection with real-time AI analysis"}),e.jsx("li",{children:"Risk diversification through intelligent portfolio management"}),e.jsx("li",{children:"AI-driven capital allocation and performance-based strategy tuning"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground px-2 py-1 rounded text-sm font-semibold",children:"9"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Extending trading strategies with AI LLMs"})]}),e.jsx("img",{src:"/lovable-uploads/e85091df-d0ea-47da-96ac-c994c4d7d177.png",alt:"FXDreema Example 9",className:"w-full max-w-4xl mx-auto rounded-lg shadow-lg border"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Ways to extend trading strategies with AI LLMs, from simple to advanced:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[e.jsx("li",{children:"Building multi-strategy trading systems with AI ensemble methods"}),e.jsx("li",{children:"Using reinforcement learning to improve strategies automatically"}),e.jsx("li",{children:"Blending fundamental and technical analysis through AI"}),e.jsx("li",{children:"Advanced AI techniques: neural networks and deep learning for trading"}),e.jsx("li",{children:"Building trading systems that learn and improve continuously"})]})]})]})]})})]})}),e.jsx(le,{value:"variable-dictionary",className:"mt-6",children:e.jsxs(F,{children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"}),"Variable Dictionary"]}),e.jsx(q,{children:"📚 Variable glossary for EA FXDreema connected to AI LLMs - terms, spelling, and meanings"})]}),e.jsx($,{children:h?e.jsxs("div",{className:"flex justify-center items-center py-12",children:[e.jsx(je,{className:"h-8 w-8 animate-spin text-primary mr-3"}),e.jsx("span",{className:"text-muted-foreground",children:"Loading variable data..."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[e.jsxs(ds,{children:[e.jsx(ms,{children:e.jsxs(ve,{className:"bg-muted/50",children:[e.jsx(ee,{className:"w-32 font-semibold",children:"JSON Key"}),e.jsx(ee,{className:"w-32 font-semibold",children:"EA Variable"}),e.jsx(ee,{className:"w-24 font-semibold",children:"Data Type"}),e.jsx(ee,{className:"font-semibold",children:"Description"}),e.jsx(ee,{className:"font-semibold",children:"English Description"}),e.jsx(ee,{className:"w-48 font-semibold",children:"Usage Example"})]})}),e.jsx(xs,{children:x.map((c,g)=>e.jsxs(ve,{className:"hover:bg-muted/30",children:[e.jsx(se,{className:"font-mono text-sm bg-muted/20 font-medium",children:c.json_key}),e.jsx(se,{className:"font-mono text-sm text-primary",children:c.ea_variable}),e.jsx(se,{children:e.jsx("span",{className:"inline-flex items-center rounded-md bg-blue-50 px-2 py-1 text-xs font-medium text-blue-700 ring-1 ring-inset ring-blue-700/10",children:c.data_type})}),e.jsx(se,{className:"text-sm leading-relaxed",children:c.thai_description}),e.jsx(se,{className:"text-sm leading-relaxed text-muted-foreground",children:c.english_description}),e.jsx(se,{className:"text-sm text-foreground",children:e.jsxs("div",{className:"space-y-1",children:[c.example_lock_1&&e.jsx("div",{className:"font-mono text-xs bg-background border border-border p-2 rounded border-l-4 border-l-green-500 text-foreground",children:c.example_lock_1}),c.example_lock_2&&e.jsx("div",{className:"font-mono text-xs bg-background border border-border p-2 rounded border-l-4 border-l-blue-500 text-foreground",children:c.example_lock_2}),c.example_lock_3&&e.jsx("div",{className:"font-mono text-xs bg-background border border-border p-2 rounded border-l-4 border-l-orange-500 text-foreground",children:c.example_lock_3}),c.example_lock_4&&e.jsx("div",{className:"font-mono text-xs bg-background border border-border p-2 rounded border-l-4 border-l-purple-500 text-foreground",children:c.example_lock_4})]})})]},`${c.json_key}-${g}`))})]}),x.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ue,{className:"h-12 w-12 mx-auto text-gray-400 mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No variable data found"})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[e.jsxs("h4",{className:"font-semibold text-blue-900 mb-2 flex items-center gap-2",children:[e.jsx(bs,{className:"h-4 w-4"}),"💡 How to use the Variable Dictionary"]}),e.jsxs("ul",{className:"text-sm text-blue-800 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"JSON Key:"})," Variable name used when sending data to the AI LLM"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"EA Variable:"})," Variable name used in the FXDreema Expert Advisor"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Data Type:"})," The variable's data type (string, number, boolean)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Usage Example:"})," Sample values you can use for testing and data transfer"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Coordination:"}
68)," These variables let the EA and AI LLM work together efficiently"]})]})]})]})})]})}),e.jsx(le,{value:"gpt-oss-rag",className:"mt-6",children:e.jsx(Ts,{})})]})})]})})}export{st as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.