@ddrinnova/agentsgt-widget 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.es.js CHANGED
@@ -66032,7 +66032,7 @@ function QF({
66032
66032
  }, T = async (R) => {
66033
66033
  var w;
66034
66034
  try {
66035
- const L = n.split("/").slice(0, 3).join("/"), k = await fetch(`${L}/api/v1/agents/${R}`, {
66035
+ const L = n.split("/").slice(0, 3).join("/"), k = await fetch(`${L}/api/v1/agents/agent/${R}`, {
66036
66036
  headers: {
66037
66037
  Authorization: `Bearer ${r}`,
66038
66038
  "Content-Type": "application/json"
@@ -66151,8 +66151,8 @@ const bue = (e, t) => {
66151
66151
  {
66152
66152
  title: e,
66153
66153
  initialMessage: t,
66154
- runtimeUrl: n || "https://local.agentsgt.com:3000/api/v1/agents/copilotkit/6291b995-d61f-437d-a9b5-792f05a58303",
66155
- apiKey: r || "pk_755527fdc20e4431feff8029923967ae:sk_3213b7e4eee84774074656d0f357432b86b69714bf3fd1fd",
66154
+ runtimeUrl: n || "DEMO",
66155
+ apiKey: r || "DEMO",
66156
66156
  properties: i,
66157
66157
  actions: s,
66158
66158
  customComponents: l
@@ -395,4 +395,4 @@ Available tools: `+s+`
395
395
 
396
396
  `,requestType:zu.Task,parameters:[{name:"suggestions",type:"object[]",attributes:[{name:"title",description:"The title of the suggestion. This is shown as a button and should be short.",type:"string"},{name:"message",description:"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.",type:"string"}]}],include:{messages:!0,readable:!0},abortSignal:i==null?void 0:i.signal,stream:({status:m,args:g})=>{const E=g.suggestions||[],b=[];for(let T=0;T<E.length&&!(c.maxSuggestions!==void 0&&T>=c.maxSuggestions);T++){const{title:A,message:x}=E[T],C=T==E.length-1&&m!=="complete";b.push({title:A,message:x,partial:C,className:c.className})}n([...l,...b])}});l.push(...p.suggestions)}catch(d){console.error("Error loading suggestions",d)}r.current===i&&(r.current=null)});function eae({suggestions:e,onSuggestionClick:t}){return U.jsx("div",{className:"suggestions",children:e.map((n,r)=>U.jsx(Zre,{title:n.title,message:n.message,partial:n.partial,className:n.className,onClick:()=>t(n.message)},r))})}var tae=({images:e,onRemoveImage:t,className:n=""})=>e.length===0?null:U.jsx("div",{className:`copilotKitImageUploadQueue ${n}`,style:{display:"flex",flexWrap:"wrap",gap:"8px",margin:"8px",padding:"8px"},children:e.map((r,i)=>U.jsxs("div",{className:"copilotKitImageUploadQueueItem",style:{position:"relative",display:"inline-block",width:"60px",height:"60px",borderRadius:"4px",overflow:"hidden"},children:[U.jsx("img",{src:`data:${r.contentType};base64,${r.bytes}`,alt:`Selected image ${i+1}`,style:{width:"100%",height:"100%",objectFit:"cover"}}),U.jsx("button",{onClick:()=>t(i),className:"copilotKitImageUploadQueueRemoveButton",style:{position:"absolute",top:"2px",right:"2px",background:"rgba(0,0,0,0.6)",color:"white",border:"none",borderRadius:"50%",width:"18px",height:"18px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"10px",padding:0},children:"✕"})]},i))}),nae=()=>typeof window>"u"?!1:document.documentElement.classList.contains("dark")||document.body.classList.contains("dark")||document.documentElement.getAttribute("data-theme")==="dark"||document.body.getAttribute("data-theme")==="dark"||window.matchMedia("(prefers-color-scheme: dark)").matches;function rae({showPoweredBy:e=!0}){const t=nae();if(!e)return null;const n={visibility:"visible",display:"block",position:"static",textAlign:"center",fontSize:"12px",padding:"3px 0",color:t?"rgb(69, 69, 69)":"rgb(214, 214, 214)"};return U.jsx("div",{children:U.jsx("p",{className:"poweredBy",style:n,children:"Powered by CopilotKit"})})}var aae=O.forwardRef(({maxRows:e=1,placeholder:t,value:n,onChange:r,onKeyDown:i,onCompositionStart:s,onCompositionEnd:l,autoFocus:c},d)=>{const p=O.useRef(null),[m,g]=O.useState(0);return O.useImperativeHandle(d,()=>p.current),O.useEffect(()=>{(()=>{const b=p.current;if(b){b.style.height="auto";const T=b.scrollHeight;g(T*e),c&&b.focus()}})()},[e]),O.useEffect(()=>{const E=p.current;E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,m)}px`)},[n,m]),U.jsx("textarea",{ref:p,value:n,onChange:r,onKeyDown:i,onCompositionStart:s,onCompositionEnd:l,placeholder:t,style:{overflow:"auto",resize:"none",maxHeight:`${m}px`},rows:1})}),iae=aae,oae=(e,t,n,r,i)=>ra(void 0,null,function*(){(!e.current||!n.current)&&(e.current=yield navigator.mediaDevices.getUserMedia({audio:!0}),n.current=new window.AudioContext,yield n.current.resume()),t.current=new MediaRecorder(e.current),t.current.start(1e3),t.current.ondataavailable=s=>{r.push(s.data)},t.current.onstop=i}),A2=e=>{e.current&&e.current.state!=="inactive"&&e.current.stop()},sae=(e,t)=>ra(void 0,null,function*(){const n=new Blob(e,{type:"audio/mp4"}),r=new FormData;r.append("file",n,"recording.mp4");const i=yield fetch(t,{method:"POST",body:r});if(!i.ok)throw new Error(`Error: ${i.statusText}`);return(yield i.json()).text}),lae=(e,t,n)=>{const r=encodeURIComponent(e),i=`${t}?text=${r}`;fetch(i).then(s=>s.arrayBuffer()).then(s=>n.decodeAudioData(s)).then(s=>{const l=n.createBufferSource();l.buffer=s,l.connect(n.destination),l.start(0)}).catch(s=>{console.error("Error with decoding audio data",s)})},uae=({sendFunction:e,inProgress:t})=>{const[n,r]=O.useState("idle"),i=O.useRef(null),s=O.useRef(null),l=O.useRef(null),c=O.useRef([]),d=Dn(),p=ol(),m=Tt(Tt({},d),p),[g,E]=O.useState(null);return O.useEffect(()=>(n==="recording"?oae(i,l,s,c.current,()=>{r("transcribing")}):(A2(l),n==="transcribing"&&sae(c.current,m.copilotApiConfig.transcribeAudioUrl).then(b=>ra(void 0,null,function*(){c.current=[],r("idle");const T=yield e(b);E(T.id)}))),()=>{A2(l)}),[n]),O.useEffect(()=>{if(t===!1&&g){const b=m.messages.findIndex(x=>x.id===g),A=m.messages.slice(b+1).filter(x=>x.isTextMessage()&&x.role==="assistant").map(x=>x.content).join(`
397
397
  `);lae(A,m.copilotApiConfig.textToSpeechUrl,s.current),E(null)}},[g,t]),{pushToTalkState:n,setPushToTalkState:r}},cae=6,_2=({inProgress:e,onSend:t,isVisible:n=!1,onStop:r,onUpload:i,hideStopButton:s=!1})=>{var l,c;const d=xi(),p=Dn(),m=!((l=p.copilotApiConfig)!=null&&l.publicApiKey),g=p.copilotApiConfig.textToSpeechUrl!==void 0&&p.copilotApiConfig.transcribeAudioUrl!==void 0,E=O.useRef(null),[b,T]=O.useState(!1),A=$=>{var V;const Q=$.target;Q.closest("button")||Q.tagName!=="TEXTAREA"&&((V=E.current)==null||V.focus())},[x,C]=O.useState(""),_=()=>{var $;e||(t(x),C(""),($=E.current)==null||$.focus())},{pushToTalkState:R,setPushToTalkState:w}=uae({sendFunction:t,inProgress:e}),L=e||R==="transcribing",k=L&&!s?d.icons.stopIcon:d.icons.sendIcon,M=g&&(R==="idle"||R==="recording")&&!e,j=O.useMemo(()=>{var $;const V=($=p.langGraphInterruptAction)==null?void 0:$.event,Q=(V==null?void 0:V.name)==="LangGraphInterruptEvent"&&!(V!=null&&V.response);return!L&&x.trim().length>0&&R==="idle"&&!Q},[(c=p.langGraphInterruptAction)==null?void 0:c.event,L,x,R]),P=O.useMemo(()=>L&&!s,[L,s]),B=!j&&!P;return U.jsxs("div",{className:`copilotKitInputContainer ${m?"poweredByContainer":""}`,children:[U.jsxs("div",{className:"copilotKitInput",onClick:A,children:[U.jsx(iae,{ref:E,placeholder:d.labels.placeholder,autoFocus:!1,maxRows:cae,value:x,onChange:$=>C($.target.value),onCompositionStart:()=>T(!0),onCompositionEnd:()=>T(!1),onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&!b&&($.preventDefault(),j&&_())}}),U.jsxs("div",{className:"copilotKitInputControls",children:[i&&U.jsx("button",{onClick:i,className:"copilotKitInputControlButton",children:d.icons.uploadIcon}),U.jsx("div",{style:{flexGrow:1}}),M&&U.jsx("button",{onClick:()=>w(R==="idle"?"recording":"transcribing"),className:R==="recording"?"copilotKitInputControlButton copilotKitPushToTalkRecording":"copilotKitInputControlButton",children:d.icons.pushToTalkIcon}),U.jsx("button",{disabled:B,onClick:L&&!s?r:_,"data-copilotkit-in-progress":e,"data-test-id":e?"copilot-chat-request-in-progress":"copilot-chat-ready",className:"copilotKitInputControlButton",children:k})]})]}),U.jsx(rae,{showPoweredBy:m})]})},C2=({messages:e,inProgress:t,children:n,RenderTextMessage:r,RenderActionExecutionMessage:i,RenderAgentStateMessage:s,RenderResultMessage:l,RenderImageMessage:c,AssistantMessage:d,UserMessage:p,onRegenerate:m,onCopy:g,onThumbsUp:E,onThumbsDown:b,markdownTagRenderers:T})=>{const A=xi();e=[...O.useMemo(()=>dae(A.labels.initial),[A.labels.initial]),...e];const C={};for(let L=0;L<e.length;L++)if(e[L].isActionExecutionMessage()){const k=e[L].id,M=e.find(j=>j.isResultMessage()&&j.actionExecutionId===k);M&&(C[k]=Qs.decodeResult(M.result||""))}const{messagesContainerRef:_,messagesEndRef:R}=fae(e),w=q5();return U.jsxs("div",{className:"copilotKitMessages",ref:_,children:[U.jsxs("div",{className:"copilotKitMessagesContainer",children:[e.map((L,k)=>{const M=k===e.length-1;if(L.isTextMessage())return U.jsx(r,{message:L,inProgress:t,index:k,isCurrentMessage:M,AssistantMessage:d,UserMessage:p,onRegenerate:m,onCopy:g,onThumbsUp:E,onThumbsDown:b,markdownTagRenderers:T},k);if(L.isActionExecutionMessage())return U.jsx(i,{message:L,inProgress:t,index:k,isCurrentMessage:M,actionResult:C[L.id],AssistantMessage:d,UserMessage:p},k);if(L.isAgentStateMessage())return U.jsx(s,{message:L,inProgress:t,index:k,isCurrentMessage:M,AssistantMessage:d,UserMessage:p},k);if(L.isResultMessage())return U.jsx(l,{message:L,inProgress:t,index:k,isCurrentMessage:M,AssistantMessage:d,UserMessage:p},k);if(L.isImageMessage&&L.isImageMessage())return U.jsx(c,{message:L,inProgress:t,index:k,isCurrentMessage:M,AssistantMessage:d,UserMessage:p,onRegenerate:m,onCopy:g,onThumbsUp:E,onThumbsDown:b},k)}),w]}),U.jsx("footer",{className:"copilotKitMessagesFooter",ref:R,children:n})]})};function dae(e){let t=[];return e&&(Array.isArray(e)?t.push(...e):t.push(e)),t.map(n=>new Kn({role:vr.Assistant,content:n}))}function fae(e){const t=O.useRef(null),n=O.useRef(null),r=O.useRef(!1),i=O.useRef(!1),s=()=>{n.current&&t.current&&(r.current=!0,n.current.scrollTop=n.current.scrollHeight)},l=()=>{if(r.current){r.current=!1;return}if(n.current){const{scrollTop:c,scrollHeight:d,clientHeight:p}=n.current;i.current=c+p<d}};return O.useEffect(()=>{const c=n.current;return c&&c.addEventListener("scroll",l),()=>{c&&c.removeEventListener("scroll",l)}},[]),O.useEffect(()=>{const c=n.current;if(!c)return;const d=new MutationObserver(()=>{i.current||s()});return d.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{d.disconnect()}},[]),O.useEffect(()=>{i.current=!1,s()},[e.filter(c=>c.isTextMessage()&&c.role===vr.User).length]),{messagesEndRef:t,messagesContainerRef:n}}function pae({instructions:e,onSubmitMessage:t,makeSystemMessage:n,onInProgress:r,onStopGeneration:i,onReloadMessages:s,onRegenerate:l,onCopy:c,onThumbsUp:d,onThumbsDown:p,markdownTagRenderers:m,Messages:g=C2,RenderTextMessage:E=Qre,RenderActionExecutionMessage:b=Yre,RenderAgentStateMessage:T=Wre,RenderResultMessage:A=Xre,RenderImageMessage:x=Kre,RenderSuggestionsList:C=eae,Input:_=_2,className:R,icons:w,labels:L,AssistantMessage:k=Yi,UserMessage:M=cd,imageUploadsEnabled:j,inputFileAccept:P="image/*",hideStopButton:B}){const{additionalInstructions:$,setChatInstructions:V}=Dn(),[Q,Y]=O.useState([]),re=O.useRef(null);O.useEffect(()=>{if(!j)return;const _e=Re=>ra(this,null,function*(){var Me,Qe;if(!((Me=Re.target.parentElement)!=null&&Me.classList.contains("copilotKitInput")))return;const wt=Array.from(((Qe=Re.clipboardData)==null?void 0:Qe.items)||[]).filter(At=>At.type.startsWith("image/"));if(wt.length===0)return;Re.preventDefault();const ht=wt.map(At=>{const Fe=At.getAsFile();return Fe?new Promise((_t,Rt)=>{const qt=new FileReader;qt.onload=nn=>{var Gt,ot;const Nt=(ot=(Gt=nn.target)==null?void 0:Gt.result)==null?void 0:ot.split(",")[1];_t(Nt?{contentType:Fe.type,bytes:Nt}:null)},qt.onerror=Rt,qt.readAsDataURL(Fe)}):Promise.resolve(null)});try{const At=(yield Promise.all(ht)).filter(Fe=>Fe!==null);Y(Fe=>[...Fe,...At])}catch(At){console.error("Error processing pasted images:",At)}});return document.addEventListener("paste",_e),()=>document.removeEventListener("paste",_e)},[j]),O.useEffect(()=>{if(!($!=null&&$.length)){V(e||"");return}const _e=[e,"Additionally, follow these instructions:",...$.map(Re=>`- ${Re}`)];console.log("combinedAdditionalInstructions",_e),V(_e.join(`
398
- `)||"")},[e,$]);const{visibleMessages:J,isLoading:le,currentSuggestions:W,sendMessage:fe,stopGeneration:v,reloadMessages:ne}=hae(n,r,t,i,s),me=_e=>{const Re=Q;return Y([]),re.current&&(re.current.value=""),fe(_e,Re)},N=Ye.useContext(pc),ue=N?N.open:!0,ke=_e=>{l&&l(_e),ne(_e)},Ee=_e=>{c&&c(_e)},we=_e=>ra(this,null,function*(){if(!_e.target.files||_e.target.files.length===0)return;const Re=Array.from(_e.target.files).filter(Qe=>Qe.type.startsWith("image/"));if(Re.length===0)return;const Me=Re.map(Qe=>new Promise((ct,Yt)=>{const wt=new FileReader;wt.onload=ht=>{var At,Fe;const _t=((Fe=(At=ht.target)==null?void 0:At.result)==null?void 0:Fe.split(",")[1])||"";_t&&ct({contentType:Qe.type,bytes:_t})},wt.onerror=Yt,wt.readAsDataURL(Qe)}));try{const Qe=yield Promise.all(Me);Y(ct=>[...ct,...Qe])}catch(Qe){console.error("Error reading files:",Qe)}}),Ce=_e=>{Y(Re=>Re.filter((Me,Qe)=>Qe!==_e))};return U.jsxs(mae,{icons:w,labels:L,className:R,children:[U.jsx(g,{AssistantMessage:k,UserMessage:M,RenderTextMessage:E,RenderActionExecutionMessage:b,RenderAgentStateMessage:T,RenderResultMessage:A,RenderImageMessage:x,messages:J,inProgress:le,onRegenerate:ke,onCopy:Ee,onThumbsUp:d,onThumbsDown:p,markdownTagRenderers:m,children:W.length>0&&U.jsx(C,{onSuggestionClick:me,suggestions:W})}),j&&U.jsxs(U.Fragment,{children:[U.jsx(tae,{images:Q,onRemoveImage:Ce}),U.jsx("input",{type:"file",multiple:!0,ref:re,onChange:we,accept:P,style:{display:"none"}})]}),U.jsx(_,{inProgress:le,onSend:me,isVisible:ue,onStop:v,onUpload:j?()=>{var _e;return(_e=re.current)==null?void 0:_e.click()}:void 0,hideStopButton:B})]})}function mae({children:e,icons:t,labels:n,className:r}){return Ye.useContext(pc)?U.jsx(U.Fragment,{children:e}):U.jsx(R_,{icons:t,labels:n,open:!0,setOpen:()=>{},children:U.jsx("div",{className:`copilotKitChat ${r??""}`,children:e})})}var gae=1e3,hae=(e,t,n,r,i)=>{var s;const{visibleMessages:l,appendMessage:c,reloadMessages:d,stopGeneration:p,runChatCompletion:m,isLoading:g}=S_({id:To(),makeSystemMessage:e}),[E,b]=O.useState([]),T=O.useRef(null),A=O.useRef(),x=()=>{var Y;(Y=T.current)==null||Y.abort(),T.current=null},C=Dn(),_=ol(),R=Tt(Tt({},C),_);O.useEffect(()=>(t==null||t(g),x(),A.current=setTimeout(()=>{!g&&Object.keys(R.chatSuggestionConfiguration).length!==0&&(T.current=new AbortController,Jre(R,R.chatSuggestionConfiguration,b,T))},E.length==0?0:gae),()=>{clearTimeout(A.current)}),[g,R.chatSuggestionConfiguration,l.length==0]);const w=(Y,re)=>ra(void 0,null,function*(){const J=re||[];x(),b([]);let le=null;if(Y.trim().length>0){const W=new Kn({content:Y,role:vr.User});if(n)try{yield n(Y)}catch(fe){console.error("Error in onSubmitMessage:",fe)}yield c(W,{followUp:J.length===0}),le||(le=W)}if(J.length>0)for(let W=0;W<J.length;W++){const fe=new Wf({format:J[W].contentType.replace("image/",""),bytes:J[W].bytes,role:vr.User});yield c(fe,{followUp:W===J.length-1}),le||(le=fe)}return le||new Kn({content:"",role:vr.User})}),L=l,{setMessages:k}=_,M=(s=C.agentSession)==null?void 0:s.agentName,j=Y=>ra(void 0,null,function*(){C.agentSession&&(C.setAgentSession(un(Tt({},C.agentSession),{nodeName:void 0,threadId:void 0})),C.setCoagentStates(re=>un(Tt({},re),{[C.agentSession.agentName]:un(Tt({},re[C.agentSession.agentName]),{threadId:void 0,nodeName:void 0,runId:void 0})})))}),P=Y=>ra(void 0,null,function*(){C.agentSession&&(yield K5(C.agentSession.agentName,R,c,m,Y))}),B=()=>{C.agentSession&&W5(C.agentSession.agentName,R)},$=Y=>{C.agentSession&&C.setCoagentStates(re=>un(Tt({},re),{[C.agentSession.agentName]:{state:Y}}))};function V(){r?r({messages:L,setMessages:k,stopGeneration:p,currentAgentName:M,restartCurrentAgent:j,stopCurrentAgent:B,runCurrentAgent:P,setCurrentAgentState:$}):p()}function Q(Y){i?i({messages:L,setMessages:k,stopGeneration:p,currentAgentName:M,restartCurrentAgent:j,stopCurrentAgent:B,runCurrentAgent:P,setCurrentAgentState:$,messageId:Y}):d(Y)}return{visibleMessages:l,isLoading:g,currentSuggestions:E,sendMessage:w,stopGeneration:V,reloadMessages:Q}},bae=e=>{var t=e,{instructions:n,defaultOpen:r=!1,clickOutsideToClose:i=!0,hitEscapeToClose:s=!0,onSetOpen:l,onSubmitMessage:c,onStopGeneration:d,onReloadMessages:p,shortcut:m="/",icons:g,labels:E,makeSystemMessage:b,onInProgress:T,Window:A=h8,Button:x=lz,Header:C=sz,Messages:_=C2,Input:R=_2,AssistantMessage:w=Yi,UserMessage:L=cd,onThumbsUp:k,onThumbsDown:M,onCopy:j,onRegenerate:P,markdownTagRenderers:B,className:$,children:V}=t,Q=bn(t,["instructions","defaultOpen","clickOutsideToClose","hitEscapeToClose","onSetOpen","onSubmitMessage","onStopGeneration","onReloadMessages","shortcut","icons","labels","makeSystemMessage","onInProgress","Window","Button","Header","Messages","Input","AssistantMessage","UserMessage","onThumbsUp","onThumbsDown","onCopy","onRegenerate","markdownTagRenderers","className","children"]);const[Y,re]=Ye.useState(r),J=fe=>{l==null||l(fe),re(fe)},le=O.useMemo(()=>U.jsx(C,{}),[C]),W=O.useMemo(()=>V,[V]);return U.jsxs(R_,{icons:g,labels:E,open:Y,setOpen:J,children:[W,U.jsxs("div",{className:$,children:[U.jsx(x,{}),U.jsxs(A,{clickOutsideToClose:i,shortcut:m,hitEscapeToClose:s,children:[le,U.jsx(pae,un(Tt({},Q),{instructions:n,onSubmitMessage:c,onStopGeneration:d,onReloadMessages:p,makeSystemMessage:b,onInProgress:T,Messages:_,Input:R,AssistantMessage:w,UserMessage:L,onThumbsUp:k,onThumbsDown:M,onCopy:j,onRegenerate:P,markdownTagRenderers:B}))]})]})]})};function Eae(e){return e=un(Tt({},e),{className:e.className?e.className+" copilotKitPopup":"copilotKitPopup"}),U.jsx(bae,un(Tt({},e),{children:e.children}))}const R2=O.forwardRef(({maxRows:e=1,placeholder:t,value:n,onChange:r,onKeyDown:i,autoFocus:s},l)=>{const c=O.useRef(null),[d,p]=O.useState(0);return O.useImperativeHandle(l,()=>c.current),O.useEffect(()=>{(()=>{const g=c.current;if(g){g.style.height="auto";const E=g.scrollHeight;p(E*e),s&&g.focus()}})()},[e]),O.useEffect(()=>{const m=c.current;m&&(m.style.height="auto",m.style.height=`${Math.min(m.scrollHeight,d)}px`)},[n,d]),U.jsx("textarea",{ref:c,value:n,onChange:r,onKeyDown:i,placeholder:t,style:{overflow:"auto",resize:"none",maxHeight:`${d}px`},rows:1})});R2.displayName="AutoResizingTextarea";const yae=({inProgress:e,onSend:t,runtimeUrl:n,apiKey:r,isVisible:i=!1,onStop:s,labels:l})=>{const[c,d]=O.useState(!1),{icons:p,labels:m}=xi(),g={...m,...l},{appendMessage:E}=S_(),b=O.useRef(null),T=M=>{var j;M.target===M.currentTarget&&((j=b.current)==null||j.focus())},[A,x]=O.useState("");O.useEffect(()=>{var M;i&&((M=b.current)==null||M.focus())},[i]);const C=async()=>{if(!n)return!0;try{const j=await(await fetch(`${n}/check-balance`,{headers:{authorization:`Bearer ${r}`}})).json();return j.success?j.hasCredits?!0:(E(new Kn({content:"Agent not available. Credit limit reached.",role:vr.Assistant})),!1):(E(new Kn({content:"Agent not available.",role:vr.Assistant})),!1)}catch(M){return console.error("Failed to check balance:",M),E(new Kn({content:"Agent not available.",role:vr.Assistant})),!1}},_=async()=>{var P;if(R)return;d(!0);const M=A;if(x(""),!await C()){x(""),d(!1),s&&s();return}t(M),(P=b.current)==null||P.focus(),d(!1)},R=c||e,w=R?p.stopIcon:p.sendIcon,L=()=>R||!R&&A.trim().length>0,k=!L();return U.jsx("div",{className:"copilotKitInputContainer",children:U.jsxs("div",{className:"copilotKitInput",onClick:T,children:[U.jsx(R2,{ref:b,placeholder:g.placeholder,autoFocus:!0,maxRows:5,value:A,onChange:M=>x(M.target.value),onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),L()&&_())}}),U.jsxs("div",{className:"copilotKitInputControls",children:[U.jsx("div",{style:{flexGrow:1}}),U.jsx("button",{disabled:k,onClick:R?s:_,"data-copilotkit-in-progress":R,"data-test-id":R?"copilot-chat-request-in-progress":"copilot-chat-ready",className:"copilotKitInputControlButton",children:w})]})]})})},ri={english:{title:"Popup Assistant",initial:"Need any help?",placeholder:"Type your message...",actionSuccess:`I've completed the action "{actionName}". Is there anything else you'd like me to help you with?`,actionError:'I encountered an error while performing "{actionName}": {error}'},spanish:{title:"Asistente Emergente",initial:"¿Necesitas ayuda?",placeholder:"Escribe tu mensaje...",actionSuccess:'He completado la acción "{actionName}". ¿Hay algo más en lo que pueda ayudarte?',actionError:'Encontré un error al realizar "{actionName}": {error}'},french:{title:"Assistant Popup",initial:"Besoin d'aide ?",placeholder:"Tapez votre message...",actionSuccess:`J'ai terminé l'action "{actionName}". Y a-t-il autre chose que je puisse faire pour vous aider ?`,actionError:`J'ai rencontré une erreur lors de l'exécution de "{actionName}": {error}`},german:{title:"Popup-Assistent",initial:"Brauchen Sie Hilfe?",placeholder:"Geben Sie Ihre Nachricht ein...",actionSuccess:'Ich habe die Aktion "{actionName}" abgeschlossen. Kann ich Ihnen bei etwas anderem helfen?',actionError:'Beim Ausführen von "{actionName}" ist ein Fehler aufgetreten: {error}'},portuguese:{title:"Assistente Popup",initial:"Precisa de ajuda?",placeholder:"Digite sua mensagem...",actionSuccess:'Concluí a ação "{actionName}". Há mais alguma coisa que eu possa ajudá-lo?',actionError:'Encontrei um erro ao executar "{actionName}": {error}'},italian:{title:"Assistente Popup",initial:"Hai bisogno di aiuto?",placeholder:"Scrivi il tuo messaggio...",actionSuccess:`Ho completato l'azione "{actionName}". C'è qualcos'altro che posso fare per aiutarti?`,actionError:`Ho riscontrato un errore durante l'esecuzione di "{actionName}": {error}`}};function Sae({properties:e}){return e&&Object.entries(e).forEach(([,t])=>{Z5({description:t.description,value:t.value})}),null}function Tae({customComponents:e}){return e?U.jsx(U.Fragment,{children:e.map(({name:t,component:n,props:r},i)=>U.jsx(n,{...r},`${t}-${i}`))}):null}function vae({action:e,currentLanguage:t}){const[n,r]=O.useState(null);return X5({name:e.name,description:e.description,parameters:e.parameters.map(i=>({name:i.name,type:i.type,description:i.description})),handler:async i=>{var s,l;try{const c=await e.handler(i);return r(c),{success:!0,message:(((s=ri[t])==null?void 0:s.actionSuccess)||ri.english.actionSuccess).replace("{actionName}",e.name)}}catch(c){return{success:!1,message:(((l=ri[t])==null?void 0:l.actionError)||ri.english.actionError).replace("{actionName}",e.name).replace("{error}",String(c))}}},render:e.render?({status:i,args:s})=>{const l=i==="complete"?"success":i==="executing"||i==="inProgress"?"running":"idle",c=e.render({status:l,args:s,result:n});return typeof c=="string"||Ye.isValidElement(c)?c:""}:void 0}),null}function Aae({actions:e,currentLanguage:t}){return U.jsx(U.Fragment,{children:e.map((n,r)=>U.jsx(vae,{action:n,currentLanguage:t},`${n.name}-${r}`))})}function _ae({previousMessages:e,onMessagesChange:t}){const{messages:n,setMessages:r}=ol();return O.useEffect(()=>{const i=e.map(s=>new Kn({content:s.content,role:s.role==="user"?Ga.User:Ga.Assistant,id:s.id}));r(i)},[e]),O.useEffect(()=>{t(n)},[n]),null}function CS({title:e,initialMessage:t,runtimeUrl:n,apiKey:r,properties:i,actions:s,customComponents:l}){var C,_;const[c,d]=O.useState([]),[p,m]=O.useState(null),[g,E]=O.useState("english"),b=R=>{try{const w=R.split("/");return w[w.length-1]||null}catch(w){return console.error("Error extracting agent ID from URL:",w),null}},T=async R=>{var w;try{const L=n.split("/").slice(0,3).join("/"),k=await fetch(`${L}/api/v1/agents/${R}`,{headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"}});if(k.ok){const M=await k.json();m(M.data);const j=((w=M.data.language)==null?void 0:w.toLowerCase())||"english",B=Object.keys(ri).includes(j)?j:"english";E(B)}}catch(L){console.error("Error fetching agent info:",L),E("english")}},A=R=>{var w;return U.jsx(yae,{...R,runtimeUrl:n,apiKey:r,labels:{placeholder:((w=ri[g])==null?void 0:w.placeholder)||"Type your message..."}})};O.useEffect(()=>{const R=sessionStorage.getItem("messages");if(R){const L=JSON.parse(R).map(k=>({content:k.content,role:k.role,id:k.id}));d(L)}},[]),O.useEffect(()=>{const R=b(n);R&&T(R)},[n,r]);const x=R=>{if(R.length===0)return;const w=R.map(L=>({content:L.content,role:L.role===Ga.User?"user":"assistant",id:L.id}));sessionStorage.setItem("messages",JSON.stringify(w))};return U.jsxs(D5,{runtimeUrl:n,headers:{authorization:"Bearer "+r},properties:i,children:[U.jsx(Sae,{properties:i}),U.jsx(Aae,{actions:s||[],currentLanguage:g}),U.jsx(Tae,{customComponents:l}),U.jsx(_ae,{previousMessages:c,onMessagesChange:x}),U.jsx(Eae,{labels:{title:e||((C=ri[g])==null?void 0:C.title)||"Popup Assistant",initial:t||((_=ri[g])==null?void 0:_.initial)||"Need any help?"},Input:A})]})}function Cae(e,t={runtimeUrl:""}){const n=t.basePath||"";return new Promise((r,i)=>{try{const s=document.createElement("link");s.rel="stylesheet",s.href=`${n}/dist/widget.css`,document.head.appendChild(s);const l=document.createElement("script");l.src=`${n}/dist/widget.umd.js`,l.onload=()=>{const c=document.getElementById(e);if(c&&window.AgentSGTWidget){const d=window.AgentSGTWidget.mountApp(c,t);r(d)}else i(new Error("Failed to initialize widget"))},l.onerror=c=>{i(c)},document.body.appendChild(l)}catch(s){i(s)}})}const Rae=(e,t)=>{const n=zv.createRoot(e);return n.render(U.jsx(CS,{...t})),()=>{n.unmount()}},kae=(e,t,n,r,i,s,l)=>{zv.createRoot(document.getElementById("root")).render(U.jsx(CS,{title:e,initialMessage:t,runtimeUrl:n||"https://local.agentsgt.com:3000/api/v1/agents/copilotkit/6291b995-d61f-437d-a9b5-792f05a58303",apiKey:r||"pk_755527fdc20e4431feff8029923967ae:sk_3213b7e4eee84774074656d0f357432b86b69714bf3fd1fd",properties:i,actions:s,customComponents:l}))};Ea.App=CS,Ea.loadWidget=Cae,Ea.mountApp=Rae,Ea.renderApp=kae,Object.defineProperty(Ea,Symbol.toStringTag,{value:"Module"})});
398
+ `)||"")},[e,$]);const{visibleMessages:J,isLoading:le,currentSuggestions:W,sendMessage:fe,stopGeneration:v,reloadMessages:ne}=hae(n,r,t,i,s),me=_e=>{const Re=Q;return Y([]),re.current&&(re.current.value=""),fe(_e,Re)},N=Ye.useContext(pc),ue=N?N.open:!0,ke=_e=>{l&&l(_e),ne(_e)},Ee=_e=>{c&&c(_e)},we=_e=>ra(this,null,function*(){if(!_e.target.files||_e.target.files.length===0)return;const Re=Array.from(_e.target.files).filter(Qe=>Qe.type.startsWith("image/"));if(Re.length===0)return;const Me=Re.map(Qe=>new Promise((ct,Yt)=>{const wt=new FileReader;wt.onload=ht=>{var At,Fe;const _t=((Fe=(At=ht.target)==null?void 0:At.result)==null?void 0:Fe.split(",")[1])||"";_t&&ct({contentType:Qe.type,bytes:_t})},wt.onerror=Yt,wt.readAsDataURL(Qe)}));try{const Qe=yield Promise.all(Me);Y(ct=>[...ct,...Qe])}catch(Qe){console.error("Error reading files:",Qe)}}),Ce=_e=>{Y(Re=>Re.filter((Me,Qe)=>Qe!==_e))};return U.jsxs(mae,{icons:w,labels:L,className:R,children:[U.jsx(g,{AssistantMessage:k,UserMessage:M,RenderTextMessage:E,RenderActionExecutionMessage:b,RenderAgentStateMessage:T,RenderResultMessage:A,RenderImageMessage:x,messages:J,inProgress:le,onRegenerate:ke,onCopy:Ee,onThumbsUp:d,onThumbsDown:p,markdownTagRenderers:m,children:W.length>0&&U.jsx(C,{onSuggestionClick:me,suggestions:W})}),j&&U.jsxs(U.Fragment,{children:[U.jsx(tae,{images:Q,onRemoveImage:Ce}),U.jsx("input",{type:"file",multiple:!0,ref:re,onChange:we,accept:P,style:{display:"none"}})]}),U.jsx(_,{inProgress:le,onSend:me,isVisible:ue,onStop:v,onUpload:j?()=>{var _e;return(_e=re.current)==null?void 0:_e.click()}:void 0,hideStopButton:B})]})}function mae({children:e,icons:t,labels:n,className:r}){return Ye.useContext(pc)?U.jsx(U.Fragment,{children:e}):U.jsx(R_,{icons:t,labels:n,open:!0,setOpen:()=>{},children:U.jsx("div",{className:`copilotKitChat ${r??""}`,children:e})})}var gae=1e3,hae=(e,t,n,r,i)=>{var s;const{visibleMessages:l,appendMessage:c,reloadMessages:d,stopGeneration:p,runChatCompletion:m,isLoading:g}=S_({id:To(),makeSystemMessage:e}),[E,b]=O.useState([]),T=O.useRef(null),A=O.useRef(),x=()=>{var Y;(Y=T.current)==null||Y.abort(),T.current=null},C=Dn(),_=ol(),R=Tt(Tt({},C),_);O.useEffect(()=>(t==null||t(g),x(),A.current=setTimeout(()=>{!g&&Object.keys(R.chatSuggestionConfiguration).length!==0&&(T.current=new AbortController,Jre(R,R.chatSuggestionConfiguration,b,T))},E.length==0?0:gae),()=>{clearTimeout(A.current)}),[g,R.chatSuggestionConfiguration,l.length==0]);const w=(Y,re)=>ra(void 0,null,function*(){const J=re||[];x(),b([]);let le=null;if(Y.trim().length>0){const W=new Kn({content:Y,role:vr.User});if(n)try{yield n(Y)}catch(fe){console.error("Error in onSubmitMessage:",fe)}yield c(W,{followUp:J.length===0}),le||(le=W)}if(J.length>0)for(let W=0;W<J.length;W++){const fe=new Wf({format:J[W].contentType.replace("image/",""),bytes:J[W].bytes,role:vr.User});yield c(fe,{followUp:W===J.length-1}),le||(le=fe)}return le||new Kn({content:"",role:vr.User})}),L=l,{setMessages:k}=_,M=(s=C.agentSession)==null?void 0:s.agentName,j=Y=>ra(void 0,null,function*(){C.agentSession&&(C.setAgentSession(un(Tt({},C.agentSession),{nodeName:void 0,threadId:void 0})),C.setCoagentStates(re=>un(Tt({},re),{[C.agentSession.agentName]:un(Tt({},re[C.agentSession.agentName]),{threadId:void 0,nodeName:void 0,runId:void 0})})))}),P=Y=>ra(void 0,null,function*(){C.agentSession&&(yield K5(C.agentSession.agentName,R,c,m,Y))}),B=()=>{C.agentSession&&W5(C.agentSession.agentName,R)},$=Y=>{C.agentSession&&C.setCoagentStates(re=>un(Tt({},re),{[C.agentSession.agentName]:{state:Y}}))};function V(){r?r({messages:L,setMessages:k,stopGeneration:p,currentAgentName:M,restartCurrentAgent:j,stopCurrentAgent:B,runCurrentAgent:P,setCurrentAgentState:$}):p()}function Q(Y){i?i({messages:L,setMessages:k,stopGeneration:p,currentAgentName:M,restartCurrentAgent:j,stopCurrentAgent:B,runCurrentAgent:P,setCurrentAgentState:$,messageId:Y}):d(Y)}return{visibleMessages:l,isLoading:g,currentSuggestions:E,sendMessage:w,stopGeneration:V,reloadMessages:Q}},bae=e=>{var t=e,{instructions:n,defaultOpen:r=!1,clickOutsideToClose:i=!0,hitEscapeToClose:s=!0,onSetOpen:l,onSubmitMessage:c,onStopGeneration:d,onReloadMessages:p,shortcut:m="/",icons:g,labels:E,makeSystemMessage:b,onInProgress:T,Window:A=h8,Button:x=lz,Header:C=sz,Messages:_=C2,Input:R=_2,AssistantMessage:w=Yi,UserMessage:L=cd,onThumbsUp:k,onThumbsDown:M,onCopy:j,onRegenerate:P,markdownTagRenderers:B,className:$,children:V}=t,Q=bn(t,["instructions","defaultOpen","clickOutsideToClose","hitEscapeToClose","onSetOpen","onSubmitMessage","onStopGeneration","onReloadMessages","shortcut","icons","labels","makeSystemMessage","onInProgress","Window","Button","Header","Messages","Input","AssistantMessage","UserMessage","onThumbsUp","onThumbsDown","onCopy","onRegenerate","markdownTagRenderers","className","children"]);const[Y,re]=Ye.useState(r),J=fe=>{l==null||l(fe),re(fe)},le=O.useMemo(()=>U.jsx(C,{}),[C]),W=O.useMemo(()=>V,[V]);return U.jsxs(R_,{icons:g,labels:E,open:Y,setOpen:J,children:[W,U.jsxs("div",{className:$,children:[U.jsx(x,{}),U.jsxs(A,{clickOutsideToClose:i,shortcut:m,hitEscapeToClose:s,children:[le,U.jsx(pae,un(Tt({},Q),{instructions:n,onSubmitMessage:c,onStopGeneration:d,onReloadMessages:p,makeSystemMessage:b,onInProgress:T,Messages:_,Input:R,AssistantMessage:w,UserMessage:L,onThumbsUp:k,onThumbsDown:M,onCopy:j,onRegenerate:P,markdownTagRenderers:B}))]})]})]})};function Eae(e){return e=un(Tt({},e),{className:e.className?e.className+" copilotKitPopup":"copilotKitPopup"}),U.jsx(bae,un(Tt({},e),{children:e.children}))}const R2=O.forwardRef(({maxRows:e=1,placeholder:t,value:n,onChange:r,onKeyDown:i,autoFocus:s},l)=>{const c=O.useRef(null),[d,p]=O.useState(0);return O.useImperativeHandle(l,()=>c.current),O.useEffect(()=>{(()=>{const g=c.current;if(g){g.style.height="auto";const E=g.scrollHeight;p(E*e),s&&g.focus()}})()},[e]),O.useEffect(()=>{const m=c.current;m&&(m.style.height="auto",m.style.height=`${Math.min(m.scrollHeight,d)}px`)},[n,d]),U.jsx("textarea",{ref:c,value:n,onChange:r,onKeyDown:i,placeholder:t,style:{overflow:"auto",resize:"none",maxHeight:`${d}px`},rows:1})});R2.displayName="AutoResizingTextarea";const yae=({inProgress:e,onSend:t,runtimeUrl:n,apiKey:r,isVisible:i=!1,onStop:s,labels:l})=>{const[c,d]=O.useState(!1),{icons:p,labels:m}=xi(),g={...m,...l},{appendMessage:E}=S_(),b=O.useRef(null),T=M=>{var j;M.target===M.currentTarget&&((j=b.current)==null||j.focus())},[A,x]=O.useState("");O.useEffect(()=>{var M;i&&((M=b.current)==null||M.focus())},[i]);const C=async()=>{if(!n)return!0;try{const j=await(await fetch(`${n}/check-balance`,{headers:{authorization:`Bearer ${r}`}})).json();return j.success?j.hasCredits?!0:(E(new Kn({content:"Agent not available. Credit limit reached.",role:vr.Assistant})),!1):(E(new Kn({content:"Agent not available.",role:vr.Assistant})),!1)}catch(M){return console.error("Failed to check balance:",M),E(new Kn({content:"Agent not available.",role:vr.Assistant})),!1}},_=async()=>{var P;if(R)return;d(!0);const M=A;if(x(""),!await C()){x(""),d(!1),s&&s();return}t(M),(P=b.current)==null||P.focus(),d(!1)},R=c||e,w=R?p.stopIcon:p.sendIcon,L=()=>R||!R&&A.trim().length>0,k=!L();return U.jsx("div",{className:"copilotKitInputContainer",children:U.jsxs("div",{className:"copilotKitInput",onClick:T,children:[U.jsx(R2,{ref:b,placeholder:g.placeholder,autoFocus:!0,maxRows:5,value:A,onChange:M=>x(M.target.value),onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),L()&&_())}}),U.jsxs("div",{className:"copilotKitInputControls",children:[U.jsx("div",{style:{flexGrow:1}}),U.jsx("button",{disabled:k,onClick:R?s:_,"data-copilotkit-in-progress":R,"data-test-id":R?"copilot-chat-request-in-progress":"copilot-chat-ready",className:"copilotKitInputControlButton",children:w})]})]})})},ri={english:{title:"Popup Assistant",initial:"Need any help?",placeholder:"Type your message...",actionSuccess:`I've completed the action "{actionName}". Is there anything else you'd like me to help you with?`,actionError:'I encountered an error while performing "{actionName}": {error}'},spanish:{title:"Asistente Emergente",initial:"¿Necesitas ayuda?",placeholder:"Escribe tu mensaje...",actionSuccess:'He completado la acción "{actionName}". ¿Hay algo más en lo que pueda ayudarte?',actionError:'Encontré un error al realizar "{actionName}": {error}'},french:{title:"Assistant Popup",initial:"Besoin d'aide ?",placeholder:"Tapez votre message...",actionSuccess:`J'ai terminé l'action "{actionName}". Y a-t-il autre chose que je puisse faire pour vous aider ?`,actionError:`J'ai rencontré une erreur lors de l'exécution de "{actionName}": {error}`},german:{title:"Popup-Assistent",initial:"Brauchen Sie Hilfe?",placeholder:"Geben Sie Ihre Nachricht ein...",actionSuccess:'Ich habe die Aktion "{actionName}" abgeschlossen. Kann ich Ihnen bei etwas anderem helfen?',actionError:'Beim Ausführen von "{actionName}" ist ein Fehler aufgetreten: {error}'},portuguese:{title:"Assistente Popup",initial:"Precisa de ajuda?",placeholder:"Digite sua mensagem...",actionSuccess:'Concluí a ação "{actionName}". Há mais alguma coisa que eu possa ajudá-lo?',actionError:'Encontrei um erro ao executar "{actionName}": {error}'},italian:{title:"Assistente Popup",initial:"Hai bisogno di aiuto?",placeholder:"Scrivi il tuo messaggio...",actionSuccess:`Ho completato l'azione "{actionName}". C'è qualcos'altro che posso fare per aiutarti?`,actionError:`Ho riscontrato un errore durante l'esecuzione di "{actionName}": {error}`}};function Sae({properties:e}){return e&&Object.entries(e).forEach(([,t])=>{Z5({description:t.description,value:t.value})}),null}function Tae({customComponents:e}){return e?U.jsx(U.Fragment,{children:e.map(({name:t,component:n,props:r},i)=>U.jsx(n,{...r},`${t}-${i}`))}):null}function vae({action:e,currentLanguage:t}){const[n,r]=O.useState(null);return X5({name:e.name,description:e.description,parameters:e.parameters.map(i=>({name:i.name,type:i.type,description:i.description})),handler:async i=>{var s,l;try{const c=await e.handler(i);return r(c),{success:!0,message:(((s=ri[t])==null?void 0:s.actionSuccess)||ri.english.actionSuccess).replace("{actionName}",e.name)}}catch(c){return{success:!1,message:(((l=ri[t])==null?void 0:l.actionError)||ri.english.actionError).replace("{actionName}",e.name).replace("{error}",String(c))}}},render:e.render?({status:i,args:s})=>{const l=i==="complete"?"success":i==="executing"||i==="inProgress"?"running":"idle",c=e.render({status:l,args:s,result:n});return typeof c=="string"||Ye.isValidElement(c)?c:""}:void 0}),null}function Aae({actions:e,currentLanguage:t}){return U.jsx(U.Fragment,{children:e.map((n,r)=>U.jsx(vae,{action:n,currentLanguage:t},`${n.name}-${r}`))})}function _ae({previousMessages:e,onMessagesChange:t}){const{messages:n,setMessages:r}=ol();return O.useEffect(()=>{const i=e.map(s=>new Kn({content:s.content,role:s.role==="user"?Ga.User:Ga.Assistant,id:s.id}));r(i)},[e]),O.useEffect(()=>{t(n)},[n]),null}function CS({title:e,initialMessage:t,runtimeUrl:n,apiKey:r,properties:i,actions:s,customComponents:l}){var C,_;const[c,d]=O.useState([]),[p,m]=O.useState(null),[g,E]=O.useState("english"),b=R=>{try{const w=R.split("/");return w[w.length-1]||null}catch(w){return console.error("Error extracting agent ID from URL:",w),null}},T=async R=>{var w;try{const L=n.split("/").slice(0,3).join("/"),k=await fetch(`${L}/api/v1/agents/agent/${R}`,{headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"}});if(k.ok){const M=await k.json();m(M.data);const j=((w=M.data.language)==null?void 0:w.toLowerCase())||"english",B=Object.keys(ri).includes(j)?j:"english";E(B)}}catch(L){console.error("Error fetching agent info:",L),E("english")}},A=R=>{var w;return U.jsx(yae,{...R,runtimeUrl:n,apiKey:r,labels:{placeholder:((w=ri[g])==null?void 0:w.placeholder)||"Type your message..."}})};O.useEffect(()=>{const R=sessionStorage.getItem("messages");if(R){const L=JSON.parse(R).map(k=>({content:k.content,role:k.role,id:k.id}));d(L)}},[]),O.useEffect(()=>{const R=b(n);R&&T(R)},[n,r]);const x=R=>{if(R.length===0)return;const w=R.map(L=>({content:L.content,role:L.role===Ga.User?"user":"assistant",id:L.id}));sessionStorage.setItem("messages",JSON.stringify(w))};return U.jsxs(D5,{runtimeUrl:n,headers:{authorization:"Bearer "+r},properties:i,children:[U.jsx(Sae,{properties:i}),U.jsx(Aae,{actions:s||[],currentLanguage:g}),U.jsx(Tae,{customComponents:l}),U.jsx(_ae,{previousMessages:c,onMessagesChange:x}),U.jsx(Eae,{labels:{title:e||((C=ri[g])==null?void 0:C.title)||"Popup Assistant",initial:t||((_=ri[g])==null?void 0:_.initial)||"Need any help?"},Input:A})]})}function Cae(e,t={runtimeUrl:""}){const n=t.basePath||"";return new Promise((r,i)=>{try{const s=document.createElement("link");s.rel="stylesheet",s.href=`${n}/dist/widget.css`,document.head.appendChild(s);const l=document.createElement("script");l.src=`${n}/dist/widget.umd.js`,l.onload=()=>{const c=document.getElementById(e);if(c&&window.AgentSGTWidget){const d=window.AgentSGTWidget.mountApp(c,t);r(d)}else i(new Error("Failed to initialize widget"))},l.onerror=c=>{i(c)},document.body.appendChild(l)}catch(s){i(s)}})}const Rae=(e,t)=>{const n=zv.createRoot(e);return n.render(U.jsx(CS,{...t})),()=>{n.unmount()}},kae=(e,t,n,r,i,s,l)=>{zv.createRoot(document.getElementById("root")).render(U.jsx(CS,{title:e,initialMessage:t,runtimeUrl:n||"DEMO",apiKey:r||"DEMO",properties:i,actions:s,customComponents:l}))};Ea.App=CS,Ea.loadWidget=Cae,Ea.mountApp=Rae,Ea.renderApp=kae,Object.defineProperty(Ea,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "ddrinnova",
3
3
  "name": "@ddrinnova/agentsgt-widget",
4
4
  "license": "MIT",
5
- "version": "0.1.02",
5
+ "version": "0.1.3",
6
6
  "type": "module",
7
7
  "repository": {
8
8
  "type": "git",