PageSourceSearch

https://www.agenthost.ai/_next/static/chunks/9169-718aa1d5f714dfc2.js

js agenthost.ai collected 2026-10-05 11:50:13 UTC 156,746 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eb46e550-1cbd-4ea9-9604-6318db805041",e._sentryDebugIdIdentifier="sentry-dbid-eb46e550-1cbd-4ea9-9604-6318db805041")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9169],{47258:function(e,n,t){t.d(n,{Z:function(){return SimpleSSEManager}});let SimpleSSEManager=class SimpleSSEManager{runUntilCompletion(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],n=new EventSource(this.endpoint);return this.sse=n,new Promise((t,l)=>{n.onopen=e=>{console.log(e)},n.onmessage=n=>{console.log("sse data recieved",n),n.data.includes("download_done")||n.data.includes("/DONE")||n.data.includes("/END/")?(this.sse.close(),this.used=!0,e?t(this.fullRespArr):(console.log(this.singleEntity),t(this.singleEntity))):e?this.fullRespArr.push(JSON.parse(n.data)):(JSON.parse(n.data),this.singleEntity=JSON.parse(n.data))},n.onerror=e=>{console.log(e),this.sse.close(),this.used=!0,l(this.fullRespArr)}})}constructor(e){this.fullRespArr=[],this.used=!1,this.singleEntity=null,this.endpoint=e}}},79169:function(e,n,t){t.d(n,{Z:function(){return AgentDetailView}});var l=t(85893),i=t(14866),s=t(28743),a=t(61639),r=t(7963),o=t(74153),d=t(7405),c=t(92798),u=t(81136),h=t(80510),g=t(64698),x=t(71293),p=t(34292),j=t(93108),m=t(55281),v=t(57747),f=t(85970),_=t(5418),S=t(33090),y=t(87874),b=t(57169),C=t(32883),w=t(22797),k=t(89993),D=t(22757),A=t(24880),z=t(82215),T=t(88087),I=t(64071),U=t(87334),F=t(47234),P=t(13990),N=t(40607),E=t(4046),O=t(11365),M=t(50151),R=t(64325),Z=t(72303),V=t(13591),H=t(74574),K=t(82509),L=t(94160),q=t(78590),Q=t(70959),J=t(44461),X=t(24124),B=t(84028),W=t(90889),G=t(48244),Y=t(57035),$=t(25694),ee=t(4260),en=t(82140),et=t(51680),el=t(5674),ei=t(36948),es=t(67294),ea=t(41731),er=t(53978),eo=t(39440),ed=t(86650),ec=t(18652),eu=t(32568),eh=t(45966),eg=t(96137),ex=t(90523);function PlanCard(e){var n,t,i,s,a,r,o,d,c,u,h,g,v,y,C,k,D,A,z,T,I,U,F,E,O,M;let[R,Z]=(0,es.useState)(null!==(A=null===(n=e.plan)||void 0===n?void 0:n.name)&&void 0!==A?A:""),[V,H]=(0,es.useState)(null!==(z=null===(t=e.plan)||void 0===t?void 0:t.description)&&void 0!==z?z:""),[K,L]=(0,es.useState)((null===(i=e.plan)||void 0===i?void 0:i.price)>0?"".concat((null===(s=e.plan)||void 0===s?void 0:s.price)/100):""),[q,Q]=(0,es.useState)(null!==(T=null===(a=e.plan)||void 0===a?void 0:a.interval)&&void 0!==T?T:"once"),[J,X]=(0,es.useState)(null!==(I=null===(r=e.plan)||void 0===r?void 0:r.currency)&&void 0!==I?I:"USD"),[B,W]=(0,es.useState)((null===(o=e.plan)||void 0===o?void 0:o.msg_limit)!=-1?null===(d=e.plan)||void 0===d?void 0:d.msg_limit:null),[G,Y]=(0,es.useState)(!1),[$,ee]=(0,es.useState)(!1),[en,et]=(0,es.useState)(null!==(U=null===(c=e.plan)||void 0===c?void 0:c.extra_instruction)&&void 0!==U?U:""),[el,ei]=(0,es.useState)([]),[er,eo]=(0,es.useState)(null!==(F=null===(u=e.plan)||void 0===u?void 0:u.total_quantity)&&void 0!==F?F:""),[ed,ec]=(0,es.useState)(null!==(E=null==e?void 0:null===(h=e.plan)||void 0===h?void 0:h.code)&&void 0!==E?E:""),[ep,ej]=(0,es.useState)(null!==(O=null==e?void 0:null===(g=e.plan)||void 0===g?void 0:g.user_expiration_weeks)&&void 0!==O?O:null),[em,ev]=(0,es.useState)((null==e?void 0:null===(v=e.plan)||void 0===v?void 0:v.metadata)?JSON.parse(null==e?void 0:null===(y=e.plan)||void 0===y?void 0:y.metadata):{}),[ef,e_]=(0,es.useState)((null==em?void 0:em.exclude_skus)?!em.exclude_skus.includes("user_file_uploads"):e.allowFileUploads),[eS,ey]=(0,es.useState)((null==em?void 0:em.exclude_skus)?!em.exclude_skus.includes("vision"):e.allowVision),[eb,eC]=(0,es.useState)((null==em?void 0:em.exclude_skus)?!em.exclude_skus.includes("live_voice"):e.allowLiveVoice),[ew,ek]=(0,es.useState)([]),[eD,eA]=(0,es.useState)(null!==(M=null==em?void 0:em.expire_text)&&void 0!==M?M:null),[ez,eT]=(0,es.useState)(e.isDefault),getPlan=()=>{var n,t=K;""===t&&(t="0"),console.error([t]);let l=100*parseFloat(t),i=q;"once"===i&&(i=null);let s=[];ef||s.push("user_file_uploads"),eS||s.push("vision"),e.allowLiveVoice&&!eb&&s.push("live_voice");let a={exclude_skus:s,...em};eD&&(a.expire_text=eD),console.log("expire text is",eD);let r={id:null===(n=e.plan)||void 0===n?void 0:n.id,name:R,description:V,price:l.toFixed(0),code:ed,metadata:JSON.stringify(a),interval:i,currency:J,extra_instruction:en,msg_limit:""!=B&&null!=B?B:-1};return er&&(r.total_quantity=er),ep&&(r.user_expiration_weeks=ep),r},onAction=async()=>{ee(!0),await e.onAction(getPlan()),ee(!1)},handleDeletePlan=async()=>{Y(!0),await e.onDelete(getPlan()),Y(!1)};(0,es.useEffect)(()=>{console.log("PLAN ISSSS...."),console.log(e.plan);let n=new Set;
1(0,eg.l)().forEach(e=>{n.add(e.currency)});let t=[];n.forEach(e=>{t.push(e)}),t.sort(),ei(t)},[]);let eI=(0,l.jsx)(j.z,{size:"xs",rounded:"full",children:"?"});return(0,l.jsx)(P.Z,{children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(m.K,{children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Name"}),(0,l.jsx)(S.I,{placeholder:"Free...",value:R,onChange:e=>Z(e.target.value)})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Description"}),(0,l.jsx)(S.I,{placeholder:"Try a limited version for free...",value:V,onChange:e=>H(e.target.value)})]}),(0,l.jsxs)(p.U,{children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Currency"}),(0,l.jsxs)(ea.P,{onChange:e=>X(e.target.value),value:J,children:[J&&(0,l.jsx)("option",{value:J,children:J}),el.map(e=>(0,l.jsx)("option",{value:e,children:e},e))]})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Cost amount"}),(0,l.jsx)(ex.Z,{type:"numeric",inputProps:{placeholder:"Free.."},value:K,onChangeText:e=>L(e)})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Interval"}),(0,l.jsxs)(ea.P,{onChange:e=>Q(e.target.value),value:q,children:[(0,l.jsx)("option",{value:"once",children:"once"}),(0,l.jsx)("option",{value:"month",children:"monthly"}),(0,l.jsx)("option",{value:"year",children:"yearly"}),(0,l.jsx)("option",{value:"week",children:"weekly"})]})]})]}),!e.hideLimitsSection&&(0,l.jsxs)(p.U,{mb:4,mt:2,children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{alignItems:"center",mb:2,children:[(0,l.jsx)(_.l,{m:0,children:"User message limit"}),(0,l.jsx)(eu.u,{label:"How many messages per month a user can send. Leave blank for infinite<",children:eI})]}),(0,l.jsx)(S.I,{placeholder:"None",value:B,onChange:e=>W(e.target.value)})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{alignItems:"center",mb:2,children:[(0,l.jsx)(_.l,{m:0,children:"Coupon code"}),(0,l.jsx)(eu.u,{label:"Code that unlocks this plan. Useful for discounted plans or giveaways",children:eI})]}),(0,l.jsx)(S.I,{placeholder:"black_friday_2024...",value:ed,onChange:e=>ec(e.target.value)})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{alignItems:"center",mb:2,children:[(0,l.jsx)(_.l,{m:0,children:"Total quantity"}),(0,l.jsx)(eu.u,{label:"How many of this plan are available in total for purchase. Leave blank for infinite",children:eI})]}),(0,l.jsx)(ex.Z,{type:"numeric",inputProps:{placeholder:"Infinite..."},value:er,onChangeText:e=>eo(e)})]})]}),""===K&&!ep&&(0,l.jsx)(f.NI,{mb:2,children:(0,l.jsxs)(p.U,{children:[(0,l.jsx)(x.x,{children:"Default plan"}
1),(0,l.jsx)(w.r,{isChecked:e.isDefault,onChange:n=>{eT(n.target.checked),e.onDefaultPlanSelected(n.target.checked)}})]})}),(0,l.jsxs)(p.U,{children:[!e.hideFeatures&&(0,l.jsxs)(f.NI,{mb:2,children:[(0,l.jsx)(_.l,{children:"Features"}),(0,l.jsxs)(m.K,{direction:["column","row"],children:[(0,l.jsx)(eh.X,{isDisabled:!e.allowFileUploads,defaultChecked:ef,onChange:()=>e_(!ef),children:"File uploads"}),(0,l.jsx)(eh.X,{isDisabled:!e.allowVision,defaultChecked:eS,onChange:()=>ey(!eS),children:"Vision"}),e.allowLiveVoice&&(0,l.jsx)(eh.X,{isDisabled:!e.allowLiveVoice,defaultChecked:eb,onChange:()=>eC(!eb),children:"Live voice chat"})]})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{alignItems:"center",mb:2,children:[(0,l.jsx)(_.l,{m:0,children:"Plan expiration (weeks)"}),(0,l.jsx)(eu.u,{label:"How many weeks a user can use this plan before it expires starting from when they first sign up",children:eI})]}),(0,l.jsx)(S.I,{type:"number",placeholder:"None",value:ep,onChange:e=>ej(e.target.value)})]})]}),ep&&(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{mb:2,children:[(0,l.jsx)(_.l,{m:0,children:"Expiration text"}),(0,l.jsx)(eu.u,{label:"Text to be shown to user once their plan expires",children:eI})]}),(0,l.jsx)(b.g,{placeholder:"Thanks so much for trying our trial plan...upgrade!",value:eD,onChange:e=>eA(e.target.value)})]}),!e.hideExtraInstruction&&(0,l.jsxs)(f.NI,{mb:4,children:[(0,l.jsx)(_.l,{children:"Extra instruction"}),(0,l.jsx)(b.g,{disabled:ez,placeholder:"Be more specific and do something extra...",value:en,onChange:e=>et(e.target.value)}),(0,l.jsx)(f.Q6,{children:"Extra agent instruction that will only be applied to users on this plan. Cannot be used on default plan."})]}),(0,l.jsxs)(p.U,{mt:2,children:[(0,l.jsx)(j.z,{colorScheme:"blue",variant:"outline",isLoading:$,onClick:onAction,children:(null===(C=e.plan)||void 0===C?void 0:C.id)?"Update":"Create"}),!(null===(k=e.plan)||void 0===k?void 0:k.id)&&(0,l.jsx)(j.z,{colorScheme:"red",variant:"outline",onClick:()=>e.onCancel(),children:"Cancel"}),(null===(D=e.plan)||void 0===D?void 0:D.id)&&(0,l.jsx)(j.z,{colorScheme:"red",variant:"ghost",onClick:handleDeletePlan,isLoading:G,children:"Delete"})]})]})})})}var ep=t(50797),ej=t(36609),em=t(3272);function PaymentsView(e){let[n,t]=(0,es.useState)(null!==(f=e.plans)&&void 0!==f?f:[]),[i,s]=(0,es.useState)([]),[r,u]=(0,es.useState)(null);function getAlertView(n){return(0,l.jsxs)(o.b,{status:"warning",children:[(0,l.jsx)(d.z,{}),(0,l.jsxs)(v.xu,{children:[(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(ec.C,{children:"You can't add paid plans"}),(0,l.jsx)(c.X,{children:n})]}),(0,l.jsxs)(p.U,{children:[!(0,ep.MV)(e.user.plan.feature_skus,"paid_plans")&&(0,l.jsx)(C.r,{href:e.paidPurchaseLink,target:"_blank",children:(0,l.jsx)(j.z,{mt:2,children:"Upgrade to a paid plan"})}),(0,ep.MV)(e.user.plan.feature_skus,"paid_plans")&&(0,l.jsx)(j.z,{onClick:e.onOnboardPress,mt:2,children:"Onboard to payments"})]})]})]})}(0,es.useEffect)(()=>{console.log("PROPS.PLANS CHANGED..."),console.log(e.plans),e.plans&&t([...e.plans])},[e.plans]),(0,es.useEffect)(()=>{console.log(e.plans)},[]);let onAction=async n=>{await e.onAction(n),u(null)},onDelete=async n=>{await e.onDelete(n),u(null)},onClearPlanDraft=()=>{u(null)},onDefaultPlanSelected=async n=>{await e.onDefaultPlanSelected(r,n)};function getView(){let t=(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(em.Z,{headers:[{name:"plan name"},{name:"cost"},{name:"actions"}],children:n.map((e,n)=>(0,l.jsxs)(h.Tr,{children:[(0,l.jsx)(g.Td,{children:(0,l.jsxs)(p.U,{children:[(0,l.jsx)(x.x,{children:e.name}),y==e.id&&(0,l.jsx)(A.C,{colorScheme:"green",children:"Default"})]})}),(0,l.jsx)(g.Td,{children:"0.00"==e.pretty_price?"Free":e.pretty_price}),(0,l.jsx)(g.Td,{children:(0,l.jsx)(j.z,{onClick:()=>u(e),children:"Edit"})})]},e.id))})});return e.selectedAgentId||e.user.connect_id?!e.selectedAgentId||e.user.connect_id?t:(0,ep.MV)(e.user.plan.feature_skus,"paid_plans")?(0,l.jsxs)(m.K,{children:[getAlertView("To get started with payments and monetizations for your agents, you'll need to onboard to Stripe with Agenhost"),t]}):(0,l.jsxs)(m.K,{children:[getAlertView("Paid plans is available to paid plan users only. Please upgrade to add payments and subscriptions for your GPTs"),t]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(D.X,{size:"md",children:"Monetize your Agents"}),(0,l.jsx)(x.x,{children:"You can add payments to your GPT after it is created."})]})}var f,_,S,y=e.defaultPlanId;return null!=y&&y||(y=null==e?void 0:null===(S=e.plans)||void 0===S?void 0:null===(_=S.find(e=>0===e.price))||void 0===_?void 0:_.id),(0,l.jsxs)(l.Fragment,{children:[e.hideTabs&&(0,l.jsxs)(m.K,{direction:["column","row"],mb:4,justifyContent:"space-between",alignItems:["flex-start","center"],children:[(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(D.X,{mb:1,children:(0,ej.t)("agentDetail.plans")}),(0,l.jsx)(x.x,{children:(0,ej.t)("agentDetail.monietize")})]}),(0,l.jsxs)(p.U,{children:[(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/monetizing-agents",target:"_blank",children:(0,l.jsx)(j.z,{children:"View docs"})}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>{u({})},children:(0,ej.t)("agentDetail.add_plan")})]})]}),(0,l.jsxs)(v.xu,{children:[getView(),(0,l.jsx)(a.Z,{size:"2xl",isOpen:null!==r,onClose:()=>u(null),title:"Create/update plan",children:(0,l.jsx)(PlanCard,{isDefault:(null==r?void 0:r.id)==y,v2:e.v2,allowFileUploads:e.allowFileUploads,allowVision:e.allowVision,allowLiveVoice:e.allowLiveVoice,onDefaultPlanSelected:onDefaultPlanSelected,plan:r,onAction:onAction,onDelete:onDelete,onCancel:()=>onClearPlanDraft()})})]})]})}
1var ev=t(8244),ef=t(1653),e_=t(83198),eS=t(47880),ey=t(79078),eb=t(68519),eC=t(93717),ew=t(6216),ek=t(46939);function SimpleInfoToolTip(e){return(0,l.jsxs)(eC.k,{alignItems:"center",mb:2,children:[e.children,(0,l.jsx)(eu.u,{label:e.text,placement:"top",children:(0,l.jsx)(ek.s,{ml:2})})]})}let eD=new s.Z("agent"),eA=[{type:"widget",name:"Chat Widget",description:"Deploy your agent as a floating chat widget."},{type:"embed",name:"iFrame",description:"Embed your agent in your website via an iframe code"},{type:"custom_domain",name:"Custom Domain",description:"Deploy your agent to a custom domain"},{type:"email",name:"Email",description:"Deploy your GPT as an email address"},{type:"telegram",name:"Telegram",description:"Deploy your GPT as a telegram bot"},{type:"zapier",name:"Zapier",description:"Connect your agent to 6,000+ other applications"},{type:"text_sms",name:"Text/SMS",description:"Deploy your GPT as a text message bot",paidOnly:!0}];function AgentShareView(e){var n,t,s,a,r,u,h,g;let[y,k]=(0,es.useState)(!1),[E,O]=(0,es.useState)(!1),[M,R]=(0,es.useState)(null),[Z,V]=(0,es.useState)({loadMessage:(null===(t=e.agent)||void 0===t?void 0:null===(n=t.json_data)||void 0===n?void 0:n.load_message)||""}),[H,K]=(0,es.useState)(!1),[L,q]=(0,es.useState)(!1),Q=null===(s=e.agent)||void 0===s?void 0:s.json_data,[J,X]=(0,es.useState)(null!=Q&&!!Q.forward_email),[B,W]=(0,es.useState)(null!==(u=null==Q?void 0:Q.forward_email)&&void 0!==u?u:""),[G,Y]=(0,es.useState)(null!==(h=null==Q?void 0:Q.cc_on_response)&&void 0!==h&&h),[$,ee]=(0,es.useState)(null!==(g=null==Q?void 0:Q.test_mode)&&void 0!==g&&g),[en,et]=(0,es.useState)(!0),el="".concat(e.agent.slug,"@").concat(i.ZP.testOrProd("test",""),"agent.agenthost.ai"),ei=["Before responding to a user, you must check the user's message limit using the available plugin. This check must be performed for every user interaction to ensure compliance with the message limit policy, regardless of the user's previous limit status. If a user has reached their message limit, inform them of this status but do not provide any further responses until the limit is reset or expanded. When a user informs you that they have already purchased a plan, initiate the login process by asking for their email, and then use the logIn plugin to request the login code. Once the user provides the code, complete the login using the plugin. If a user expresses interest in upgrading their account, provide information on available plans, ensuring that the signup links are opened in a new tab.","".concat(i.ZP.getFullUrl(),"/api/openapi"),e.token,"https://www.agenthost.ai/privacy"],{onCopy:ea,value:ed,setValue:eu,hasCopied:eh}=(0,er.V)(e.value);(0,es.useEffect)(()=>{var n,t,l,i,s;console.log("agent metadata",null===(n=e.agent)||void 0===n?void 0:n.json_data);let a=null===(t=e.agent)||void 0===t?void 0:t.json_data;X(null!=a&&!!a.forward_email),W(null!==(l=null==a?void 0:a.forward_email)&&void 0!==l?l:""),Y(null!==(i=null==a?void 0:a.cc_on_response)&&void 0!==i&&i),ee(null!==(s=null==a?void 0:a.test_mode)&&void 0!==s&&s)},[e.agent]);let getGptId=()=>{if(console.log("selected agent_gpt id",e.agent.gpt_id),e.agent.gpt_id)return e.agent.gpt_id;let n=/g-\w+/.exec(e.agent.gptUrl);return n?n[0]:null},getCopyValue=()=>{if("embed"==M){let n="https://www.agenthost.ai/chat/".concat(e.agent.slug,"?embed=true");return E&&(n+="&hide_sidebar=true"),'<iframe src="'.concat(n,'" width="100%" height="').concat(y?"100%":"600px",'"></iframe>')}return"widget"==M?'<script src="https://www.agenthost.ai/loader.js"  data-agent="'.concat(e.agent.slug,'" />'):"email"==M?el:void 0};(0,es.useEffect)(()=>{(y||E)&&eu(getCopyValue())},[y,E]),(0,es.useEffect)(()=>{M&&eu(getCopyValue())},[M]);let handleIntegrationSelect=(n,t)=>{if(t&&!e.isPaidUser){alert("This feature requires a pro account. Please upgrade to access it.");return}e_.Z.track("Integration Selected",{integrationType:n}),"custom_domain"===n?e.onCustomDomainSelected():"zapier"===n?e.onZapierSelected():R(n)},validateEmail=e=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(e).toLowerCase()),saveEmailForwarding=async()=>
1{if(en){console.log("Saving forwarding email:",B),K(!0);let n=await eD.update(e.agent.id,{json_data:{...Q,forward_email:B,cc_on_response:G,test_mode:$}});if(n&&!n.error)W(B),alert("Forward email saved successfully."),e.refreshAgent();else{let e=(0,eo.HH)(null==n?void 0:n.error,"Sorry, something went wrong when saving your forward email. Please try again.");alert(e)}K(!1)}else alert("Please enter a valid email address.")},updateIntegrationInput=(e,n)=>{console.log("INTEGRATION INPUT",Z,e,n);let t={...Z};t[e]=n,V(t)},onSaveIntegration=async(n,t)=>{K(!0);let l={type:n,data:t,agent:e.agent.id};await e.onSaveIntegration(l),V({}),K(!1)},eg=(0,l.jsx)(p.U,{mb:2,children:(0,l.jsx)(j.z,{onClick:()=>R(null),children:"Back"})}),ex="+18664137963";return(0,l.jsxs)(l.Fragment,{children:[!M&&(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(x.x,{children:"Select an integration to deploy your GPT to"}),(0,l.jsx)(ey.r,{templateColumns:["repeat(1, 1fr)","repeat(2, 1fr)","repeat(4, 1fr)"],gap:4,mt:4,children:eA.map(n=>{let t=n.paidOnly,i=t&&!e.isPaidUser;return(0,l.jsx)(eb.P,{onClick:()=>handleIntegrationSelect(n.type,t),cursor:i?"not-allowed":"pointer",children:(0,l.jsx)(P.Z,{h:"150px",position:"relative",opacity:i?.6:1,children:(0,l.jsxs)(N.e,{children:[(0,l.jsx)(D.X,{mb:2,fontSize:"lg",children:n.name}),(0,l.jsx)(x.x,{fontSize:"sm",children:n.description}),t&&(0,l.jsx)(A.C,{colorScheme:e.isPaidUser?"green":"gray",mt:2,children:e.isPaidUser?"Pro":"Requires pro account"}),i&&(0,l.jsx)(v.xu,{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",children:(0,l.jsx)(eS.m,{boxSize:8,color:"gray.500"})})]})})},n.type)})})]}),"embed"==M&&(null===(a=e.agent)||void 0===a?void 0:a.fully_hosted)&&(0,l.jsxs)(l.Fragment,{children:[eg,(0,l.jsxs)(eC.k,{mb:2,children:[(0,l.jsx)(S.I,{value:getCopyValue(),onChange:e=>{eu(e.target.value)},mr:2}),(0,l.jsx)(j.z,{onClick:ea,children:eh?"Copied!":"Copy"})]})," "]}),"embed"==M&&(null===(r=e.agent)||void 0===r?void 0:r.fully_hosted)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.x,{mb:2,children:"Options"}),(0,l.jsxs)(p.U,{children:[(0,l.jsx)(f.NI,{children:(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",isChecked:y,onChange:e=>k(!y)}),(0,l.jsx)(x.x,{children:"100% height"})]})}),(0,l.jsx)(f.NI,{children:(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",isChecked:E,onChange:e=>O(!E)}),(0,l.jsx)(x.x,{children:"Hide left sidebar"})]})})]})]}),"widget"===M&&(0,l.jsxs)(m.K,{spacing:4,children:[eg,(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Widget Code"}),(0,l.jsxs)(p.U,{children:[(0,l.jsx)(S.I,{value:'<script src="https://www.agenthost.ai/loader.js"  data-agent="'.concat(e.agent.slug,'" />')}),(0,l.jsx)(j.z,{onClick:ea,children:eh?"Copied!":"Copy"})]}),(0,l.jsx)(f.Q6,{children:"Put the following code into the html head section of the pages you want your chatbot to be visible"})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Popup Message"}),(0,l.jsx)(S.I,{placeholder:"Enter a popup message for your chatbot",value:Z.loadMessage||"",onChange:e=>updateIntegrationInput("loadMessage",e.target.value)}),(0,l.jsx)(f.Q6,{children:"This message will appear when the chatbot widget is first loaded"})]}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:async()=>{K(!0);let n={...Q,load_message:Z.loadMessage},t=await eD.update(e.agent.id,{json_data:n});if(t&&!t.error)alert("Popup message saved successfully."),e.refreshAgent();else{let e=(0,eo.HH)(null==t?void 0:t.error,"Sorry, something went wrong when saving your popup message. Please try again.");alert(e)}K(!1)},isLoading:H,children:"Save Popup Message"})]}),"qr_code"===M&&(0,l.jsxs)(m.K,{spacing:4,children:[eg,(0,l.jsx)(ef.ZP,{id:"QRCode",value:"https://www.agenthost.ai/chat/".concat(e.agent.slug)}),(0,l.jsx)(j.z,{onClick:()=>{let e=document.getElementById("QRCode");console.log("svg is",e);let n=new XMLSerializer().serializeToString(e),t=document.createElement("canvas"),l=t.getContext("2d"),i=new Image;i.onload=()=>{t.width=i.width,t.height=i.height,l.drawImage(i,0,0);let e=t.toDataURL("image/png"),n=document.createElement("a");n.download="QRCode",n.href="".concat(e),n.click()},i.src="data:image/svg+xml;base64,".concat(btoa(n))},children:"Download"})]}),"telegram"==M&&(0,l.jsxs)(m.K,{spacing:4,children:[eg,(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Telegram Bot Token"}),(0,l.jsx)(S.I,{placeholder:e.integrations.filter(e=>"telegram"==e.type).length>0?"****":"Your bot token",value:null,onChange:e=>updateIntegrationInput("bot_token",e.target.value)}),(0,l.jsxs)(f.Q6,{children:["Enter the bot token you received from BotFather. You can follow ",(0,l.jsx)("a",{href:"https://medium.com/@agenthostai/how-to-connect-your-openai-custom-gpt-to-telegram-82ccb41a27c1",
1style:{textDecoration:"underline"},children:"this guide"})," here to get this. This token will not be shown again."]})]}),(0,l.jsx)(p.U,{children:(0,l.jsx)(j.z,{isLoading:H,onClick:()=>onSaveIntegration("telegram",{bot_token:Z.bot_token}),children:e.integrations.filter(e=>"telegram"==e.type).length>0?"Update":"Activate"})})]}),"email"===M&&(0,l.jsxs)(v.xu,{children:[eg,(0,l.jsxs)(p.U,{justifyContent:"space-between",alignItems:"center",mb:2,children:[(0,l.jsx)(D.X,{size:"md",children:"Email Integration"}),(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/email-agents",children:(0,l.jsx)(j.z,{children:"Docs"})})]}),(0,l.jsx)(x.x,{mb:4,children:"Your agent can be reached at the following email address"}),(0,l.jsxs)(eC.k,{mb:4,children:[(0,l.jsx)(S.I,{value:el,isReadOnly:!0,mr:2}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:ea,children:eh?"Copied!":"Copy"})]}),(0,l.jsx)(p.U,{children:(0,l.jsxs)(f.NI,{mb:4,children:[(0,l.jsx)(SimpleInfoToolTip,{text:"Email forwarding allows you to automatically have emails sent to your agent from your own email",children:(0,l.jsx)(_.l,{htmlFor:"email-forwarding",my:0,children:"Email Forwarding"})}),(0,l.jsx)(w.r,{id:"email-forwarding",isChecked:J,onChange:()=>{X(!J),J||(W(""),et(!0))}})]})}),J&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(f.NI,{mb:4,isInvalid:!en,children:[(0,l.jsx)(SimpleInfoToolTip,{text:"The email address that the forwarding will be setup to be sent from",children:(0,l.jsx)(_.l,{m:0,htmlFor:"forwarding-email",children:"Forwarding Email Address"})}),(0,l.jsx)(S.I,{id:"forwarding-email",type:"email",value:B,onChange:e=>{let n=e.target.value;W(n),et(validateEmail(n))},placeholder:"Enter your forwarding email"}),!en&&(0,l.jsx)(f.Q6,{color:"red.500",children:"Please enter a valid email address."})]}),(0,l.jsxs)(p.U,{my:2,justifyContent:"space-between",children:[(0,l.jsxs)(f.NI,{mb:4,children:[(0,l.jsx)(SimpleInfoToolTip,{text:"When enabled, the agent will automatically cc you on the response to users",children:(0,l.jsx)(_.l,{m:0,htmlFor:"cc-on-response",children:"Cc on response"})}),(0,l.jsx)(w.r,{id:"cc-on-response",isChecked:G,onChange:e=>Y(e.target.checked)})]}),(0,l.jsxs)(f.NI,{mb:4,children:[(0,l.jsx)(SimpleInfoToolTip,{text:"The agent will send it's response to you, with the sender in the reply to for you to easily send the response or change it.",children:(0,l.jsx)(_.l,{m:0,htmlFor:"cc-on-response",children:"Test mode"})}),(0,l.jsx)(w.r,{id:"test-mode",isChecked:$,onChange:e=>ee(e.target.checked)})]})]}),(0,l.jsx)(j.z,{onClick:saveEmailForwarding,isLoading:H,isDisabled:!en||!B,mb:4,variant:"outline",colorScheme:"blue",children:"Save Forwarding Settings"}),(0,l.jsxs)(x.x,{children:["Finally, set up email forwarding on your email provider so that your incoming emails are sent to ",el]}),(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/email-agents#8PVLB",children:(0,l.jsx)(j.z,{mt:4,children:"View documentation"})})]})]}),"openai"==M&&(0,l.jsxs)(m.K,{children:[eg,0===e.agentPlans.length&&(0,l.jsxs)(o.b,{status:"error",children:[(0,l.jsx)(d.z,{}),(0,l.jsxs)(v.xu,{children:[(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(ec.C,{children:"You have no plans"}),(0,l.jsx)(c.X,{children:"Without any plans, your users will be able to send infinite messages which makes Agenthost pointless."})]}),(0,l.jsx)(j.z,{mt:2,onClick:()=>e.handlePlanAdd(),children:"Add plans"})]})]}),(0,l.jsxs)(z.U,{onChange:e=>eu(ei.at(e)),defaultIndex:0,children:[(0,l.jsxs)(T.Q,{children:[(0,l.jsx)(D.X,{children:(0,l.jsxs)(I.K,{children:[(0,l.jsx)(v.xu,{as:"span",flex:"1",textAlign:"left",children:"1) Add our instruction to your GPT"}),(0,l.jsx)(U.X,{})]})}),(0,l.jsx)(F.H,{pb:2,children:(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(f.Q6,{mb:4,children:["Copy and paste the following in the ",(0,l.jsx)(C.r,{href:"https://chat.openai.com/gpts/editor/".concat(getGptId()),target:"__blank",children:(0,l.jsx)("u",{children:"configure screen"})})," after your existing prompt"]}),(0,l.jsx)(b.g,{readOnly:!0,value:ei[0]}),(0,l.jsx)(j.z,{mt:2,onClick:ea,children:eh?"Copied!":"Copy"}),(0,l.jsx)(ew.E,{mt:2,alt:"Screenshot of Agenthost App",src:"/tutorial_1.gif"})]})})]}),(0,l.jsxs)(T.Q,{children:[(0,l.jsx)(D.X,{children:(0,l.jsxs)(I.K,{children:[(0,l.jsx)(v.xu,{as:"span",flex:"1",textAlign:"left",children:"2) Add API Actions"}),(0,l.jsx)(U.X,{})]})}),(0,l.jsx)(F.H,{pb:4,children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(S.I,{value:ei[1],readOnly:!0}),(0,l.jsx)(j.z,{mt:2,onClick:ea,children:eh?"Copied!":"Copy"}),(0,l.jsxs)(f.Q6,{children:["This should be placed in ",(0,l.jsx)(C.r,{href:"https://chat.openai.com/gpts/editor/".concat(getGptId()),target:"__blank",children:(0,l.jsx)("u",{children:"configure screen"})})," then go to Actions and click ",(0,l.jsx)("i",{children:"Create new action"})]}),(0,l.jsx)(ew.E,{mt:2,alt:"Screenshot of Agenthost App",src:"/tutorial_2.gif"})]})})]}),(0,l.jsxs)(T.Q,{children:[(0,l.jsx)(D.X,{children:(0,l.jsxs)(I.K,{children:[(0,l.jsx)(v.xu,{as:"span",flex:"1",textAlign:"left",children:"3) Add your API Key"}),(0,l.jsx)(U.X,{})]})}),(0,l.jsx)(F.H,{pb:4,children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(S.I,{value:ei[2],readOnly:!0}),(0,l.jsx)(j.z,{mt:2,onClick:ea,children:eh?"Copied!":"Copy"}),(0,l.jsxs)(f.Q6,{children:["This should be placed in ",(0,l.jsx)(C.r,{href:"https://chat.openai.com/gpts/editor/".concat(getGptId()),target:"__blank",children:(0,l.jsx)("u",{children:"configure screen's"})})," action page by clicking API Key "]}
1),(0,l.jsx)(ew.E,{mt:2,alt:"Screenshot of Agenthost App",src:"/tutorial_3.gif"})]})})]}),(0,l.jsxs)(T.Q,{children:[(0,l.jsx)(D.X,{children:(0,l.jsxs)(I.K,{children:[(0,l.jsx)(v.xu,{as:"span",flex:"1",textAlign:"left",children:"4) Add your privacy policy and publish"}),(0,l.jsx)(U.X,{})]})}),(0,l.jsx)(F.H,{pb:4,children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(S.I,{value:ei[3],readOnly:!0}),(0,l.jsx)(j.z,{mt:2,onClick:ea,children:eh?"Copied!":"Copy"}),(0,l.jsxs)(f.Q6,{children:["This should be placed in ",(0,l.jsx)(C.r,{href:"https://chat.openai.com/gpts/editor/".concat(getGptId()),target:"__blank",children:(0,l.jsx)("u",{children:"configure screen's"})})," privacy policy input box. After this is done make sure you hit ",(0,l.jsx)("strong",{children:(0,l.jsx)("u",{children:"update"})})," to update your GPT and deploy your unsaved changes"]})]})})]})]})]}),"text_sms"===M&&(0,l.jsxs)(v.xu,{children:[eg,(0,l.jsx)(p.U,{justifyContent:"space-between",alignItems:"center",mb:2,children:(0,l.jsxs)(p.U,{mb:4,children:[(0,l.jsx)(D.X,{size:"md",children:"Text/SMS Integration"}),(0,l.jsx)(A.C,{colorScheme:"green",children:"Preview"})]})}),(0,l.jsx)(x.x,{mb:4,children:"You can text your agent by sending a message to:"}),(0,l.jsxs)(f.NI,{mb:4,children:[(0,l.jsxs)(eC.k,{mb:4,children:[(0,l.jsx)(S.I,{value:ex,isReadOnly:!0,mr:2}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>{ea(),eu(ex)},children:eh?"Copied!":"Copy"})]}),(0,l.jsx)(f.Q6,{children:"Please note that this US number is new and may not work with all carriers. We are working to increase it's responsiveness and sending limit."})]}),(0,l.jsx)(x.x,{mb:4,children:"Send the following message to start chatting with your agent:"}),(0,l.jsxs)(eC.k,{mb:4,children:[(0,l.jsx)(S.I,{value:"/a ".concat(e.agent.slug),isReadOnly:!0,mr:2}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>{ea(),eu("/a ".concat(e.agent.slug))},children:eh?"Copied!":"Copy"})]}),(0,l.jsx)(x.x,{children:"Simply send this message to the number above to start chatting with your agent via text message."})]})]})}var ez=t(30381),eT=t.n(ez),eI=t(29009),eU=t(77180),eF=t(14195),eP=t(3023),eN=t(75358),eE=t(26050),eO=t(33558),eM=t(56880),eR=t(83461),eZ=t(8799),eV=t(85392),eH=t(73614),eK=t(8371),eL=t(5434),eq=t(45527),components_AddNewQuestion=e=>{let{addQuestion:n}=e,[t,i]=(0,es.useState)({question:"",description:"",inputType:"text",options:""}),s=(0,r.p)();return(0,l.jsx)(P.Z,{children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(m.K,{spacing:4,children:[(0,l.jsxs)(m.K,{spacing:2,children:[(0,l.jsx)(x.x,{children:"Question"}),(0,l.jsx)(S.I,{id:"question",onChange:e=>i(n=>({...n,question:e.target.value})),placeholder:"Enter your question",value:t.question})]}),(0,l.jsxs)(m.K,{spacing:2,children:[(0,l.jsx)(x.x,{children:"Description"}),(0,l.jsx)(S.I,{value:t.description,id:"description",onChange:e=>i(n=>({...n,description:e.target.value})),placeholder:"Enter a description (optional)"})]}),(0,l.jsxs)(m.K,{spacing:2,children:[(0,l.jsx)(x.x,{children:"Input Type"}),(0,l.jsxs)(ea.P,{value:t.inputType,defaultValue:t.inputType,onChange:e=>{i(n=>({...n,inputType:e.target.value}))},id:"inputType",children:[(0,l.jsx)("option",{value:"text",children:"Text"}),(0,l.jsx)("option",{value:"number",children:"Number"}),(0,l.jsx)("option",{value:"select",children:"Select option"}),(0,l.jsx)("option",{value:"date",children:"Date"}),(0,l.jsx)("option",{value:"checkbox",children:"Checkbox"}),(0,l.jsx)("option",{value:"radio",children:"Radio"})]})]}),("checkbox"===t.inputType||"radio"===t.inputType||"select"===t.inputType)&&(0,l.jsxs)(m.K,{spacing:2,children:[(0,l.jsx)(x.x,{children:"Options"}),(0,l.jsx)(S.I,{id:"options",onChange:e=>i(n=>({...n,options:e.target.value})),placeholder:"Enter your options. seperate with comma ','"})]}),(0,l.jsx)(eC.k,{justify:"end",mt:4,children:(0,l.jsx)(j.z,{size:"sm",onClick:()=>{if(""===t.question)return s({title:"Question is required",status:"error",duration:2e3,isClosable:!0});if(("select"===t.inputType||"checkbox"===t.inputType||"radio"===t.inputType)&&0===t.options.length){var e;return null===(e=document.getElementById("options"))||void 0===e||e.focus(),s({title:"Options are required for selected input type",status:"error",duration:2e3,isClosable:!0})}n(t),i({question:"",description:"",inputType:"text",options:""})},colorScheme:"blue",children:"+ Add question"})})]})})})},eQ=t(34392),components_FormTab=e=>{var n,t,i;let{setModalIndex:o,selectedAgent:d,fileIngestionApi:c,agentCustomData:h,formResponseResult:g,onNext:S,onPrev:y}=e,[b,C]=(0,es.useState)(null!==(t=null==h?void 0:h.form)&&void 0!==t?t:[]),[A,z]=(0,es.useState)(null),[T,I]=(0,es.useState)(null!==(i=null==h?void 0:h.send_form_to_agent)&&void 0!==i&&i),[U,F]=(0,es.useState)(!1);console.log("selectedAgent",d);let deleteQuestion=e=>{let n=b.filter(n=>n.id!==e);C(n)},moveQuestionUpOneStep=e=>{C((0,eQ.Z)(b,+e,+e-1))},moveQuestionDownOneStep=e=>{C((0,eQ.Z)(b,+e,+e+1))},getOptions=e=>{if("select"===e.inputType||"radio"===e.inputType||"checkbox"===e.inputType){var n,t,l;return e.options&&(null===(n=e.options)||void 0===n?void 0:n.trim)?null===(l=e.options)||void 0===l?void 0:null===(t=l.trim())||void 0===t?void 0:t.split(",").filter(e=>e&&"string"==typeof e).map(e=>e.trim()):[]}return[]},E=new s.Z("agent"),O=(0,r.p)(),saveForm=async()=>{F(!0);let e={...h};e.form=b,e.send_form_to_agent=T;let n={custom_data:JSON.stringify(e)},t=await E.update(d.id,n);if(t&&!t.error)O({title:"Form saved",status:"success",duration:3e3,isClosable:!0});else{let e=(0,eo.HH)(t.error,"Sorry, something went wrong. Please try again later.");alert(e)}F(!1)};return(0,l.jsxs)("div",{children:[(0,l.jsxs)(Q.m,{children:[(0,l.jsxs)(J.t,{children:[(0,l.jsx)(X.O,{fontSize:"sm",children:"Form"}),(0,l.jsx)(X.O,{fontSize:"sm",children:"Responses"})]}),(0,l.jsxs)(B.n,{children:[(0,l.jsxs)(W.x,{children:[(0,l.jsx)(m.K,{children:(0,l.jsx)(f.NI,{children:(0,l.jsxs)(m.K,{direction:["column","row"],children:[(0,l.jsxs)(v.xu,{flex:1,children:[(0,l.jsx)(D.X,{fontSize:32,fontWeight:"bold",children:"Forms"}),(0,l.jsx)(f.Q6,{children:"Forms allow you to collect user data and trigger actions based on user input. Forms are currently only visible to users when they first load your agent. You should open an incognito window to test."})]}),(0,l.jsx)(v.xu,{children:(0,l.jsxs)(p.U,{children:[(0,l.jsx)(j.z,{w:"50%",size:"md",colorScheme:"blue",isLoading:U,onClick:saveForm,children:"Save form"}),(0,l.jsx)(j.z,{variant:"outline",colorScheme:"red",onClick:()=>C([]),children:"Clear form"})]})})]})})}),(0,l.jsxs)(m.K,{mt:4,spacing:4,direction:"column",children:[(0,l.jsxs)(P.Z,{mb:2,children:[(0,l.jsxs)(eH.O,{children:[(0,l.jsx)(D.X,{fontSize:"lg",children:"Form Builder"}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{mt:1,children:"Send the form response to the agent to get a response"}),(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{defaultChecked:T,colorScheme:"blue",onCh
1ange:e=>I(!T)}),(0,l.jsx)(x.x,{children:"Send form response to agent"})]})]})]}),(0,l.jsxs)(N.e,{children:[(0,l.jsx)(D.X,{size:"md",mb:4,children:"Questions"}),(0,l.jsx)(m.K,{spacing:6,children:b.length>0&&b.map((e,n)=>{var t;return(0,l.jsxs)(m.K,{direction:"row",align:"start",children:[(0,l.jsx)(v.xu,{children:(0,l.jsx)(x.x,{fontSize:18,children:n+1})}),(0,l.jsxs)(v.xu,{flex:1,children:[(0,l.jsx)(x.x,{fontSize:18,fontWeight:500,children:null==e?void 0:e.question}),(0,l.jsx)(x.x,{children:e.description}),("select"===e.inputType||"radio"===e.inputType||"checkbox"===e.inputType)&&(0,l.jsxs)(eC.k,{gap:2,children:[(0,l.jsx)(x.x,{children:"Options: "}),null===(t=getOptions(e))||void 0===t?void 0:t.map((e,n)=>(0,l.jsx)(eK.Vp,{children:e},n))]})]}),(0,l.jsx)(v.xu,{children:(0,l.jsxs)(q.h,{children:[(0,l.jsx)(k.h,{onClick:()=>{moveQuestionUpOneStep(n)},"aria-label":"Edit",icon:(0,l.jsx)(eL.b5c,{})}),(0,l.jsx)(k.h,{onClick:()=>{moveQuestionDownOneStep(n)},"aria-label":"Edit",icon:(0,l.jsx)(eL.MSz,{})}),(0,l.jsx)(k.h,{onClick:()=>{deleteQuestion(e.id)},"aria-label":"Delete",icon:(0,l.jsx)(eq.p,{})})]})})]},n)})})]})]}),(0,l.jsx)(components_AddNewQuestion,{addQuestion:e=>{C(n=>[...n,{...e,position:n.length+1,id:n.length+1}])}})]})]}),(0,l.jsxs)(W.x,{children:[(0,l.jsx)(D.X,{fontSize:32,children:"Form Responses"}),(0,l.jsxs)(m.K,{spacing:2,children:[!g&&(0,l.jsx)(u.$,{}),g&&(null==g?void 0:null===(n=g.results)||void 0===n?void 0:n.map((e,n)=>{var t,i,s;let a=JSON.parse(e.response);return(0,l.jsx)(P.Z,{children:(0,l.jsxs)(N.e,{children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:null===(i=a[0])||void 0===i?void 0:null===(t=i.question)||void 0===t?void 0:t.question}),(0,l.jsx)(x.x,{children:null===(s=a[0])||void 0===s?void 0:s.answer}),(0,l.jsx)(j.z,{mt:2,size:"sm",colorScheme:"blue",variant:"outline",onClick:()=>z(a),children:"View"})]})},e.id)})),(0,l.jsxs)(p.U,{justifyContent:"flex-end",children:[g&&(null==g?void 0:g.previous)&&(0,l.jsx)(j.z,{onClick:y,children:"Previous"}),g&&(null==g?void 0:g.next)&&(0,l.jsx)(j.z,{onClick:S,children:"Next"})]})]})]})]})]}),(0,l.jsx)(a.Z,{title:"View response",isOpen:A,onClose:()=>z(null),children:A&&(0,l.jsx)(m.K,{children:A.map((e,n)=>{var t,i;return(0,l.jsx)(P.Z,{children:(0,l.jsxs)(N.e,{children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:null==e?void 0:null===(t=e.question)||void 0===t?void 0:t.question}),(0,l.jsx)(x.x,{children:null==e?void 0:e.answer})]})},null==e?void 0:null===(i=e.question)||void 0===i?void 0:i.id)})})})]})},eJ=t(47516),eX=t(67421),eB=t(85518),eW=t(47258),eG=t(36653),eY=t(44704),e$=t(79688),e0=t(96225);function MessageFineTuneView(e){let[n,t]=(0,es.useState)(!1),[i,s]=(0,es.useState)(!1),a=e.activeFinetune,r=e.activeFinetuneMessageMap,o=e.message,d=r[o._id];if(!a||!o||"assistant"!==o.role)return null;let handleClick=async()=>{s(!0);let n=await e.onClick();n&&t(!0),s(!1)};return(0,l.jsx)(j.z,{isLoading:i,isDisabled:d||n,leftIcon:(0,l.jsx)(ei.J,{as:e0.oVG}),variant:"outline",colorScheme:"red",size:"sm",onClick:()=>handleClick(),children:"Train"})}var e1=t(37527);let ChatMessage=e=>{var n;let t=e.message,i="modal"===e.variant;return(0,l.jsx)(v.xu,{p:i?3:4,border:i?"none":"1px solid #ccc",borderRadius:i?0:4,borderBottom:i?"1px solid #e2e8f0":"none",mb:i?2:0,children:(0,l.jsxs)(p.U,{justifyContent:"space-between",spacing:4,children:[(0,l.jsxs)(m.K,{spacing:2,flex:1,children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:t.role}),(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(e$.Z,{children:t.message}),(0,l.jsxs)(p.U,{flexWrap:"wrap",spacing:2,mt:2,children:[t.rating&&(0,l.jsx)(A.C,{colorScheme:t.rating>0?"green":"red",children:t.rating>0?"Thumb up":"Thumb down"}),e.showFinetune&&(0,l.jsx)(MessageFineTuneView,{message:t,activeFinetune:e.activeFinetune,activeFinetuneMessageMap:e.finetuneMessageMap,onClick:()=>e.addToFineTuneQueue(t)}),(null===(n=t.usage_data)||void 0===n?void 0:n.message_count)&&(0,l.jsxs)(x.x,{fontSize:"2xs",colorScheme:"blue",children:[t.usage_data.message_count," message credit(s)"]})]}),t.citations&&(0,l.jsx)(e1.Z,{citations:t.citations})]})]}),(0,l.jsx)(x.x,{fontSize:"xs",color:"gray.500",flexShrink:0,children:eT()(t.created_at).format("lll")})]})},t.id)},e4="gpt-4o-mini-2024-07-18";function FinetuneView(e){let n=e.finetunes,[t,i]=(0,es.useState)(""),[s,o]=(0,es.useState)(!1),[d,c]=(0,es.useState)(!1),[u,v]=(0,es.useState)(e4),[
1y,b]=(0,es.useState)(null),[w,k]=(0,es.useState)({}),[z,T]=(0,es.useState)({}),[I,U]=(0,es.useState)({}),[F,P]=(0,es.useState)(null),[N,E]=(0,es.useState)(!1),O=(0,r.p)(),M=(0,ed.cF)();var R,Z,V,H,K,L=[{name:"name"},{name:"model"},{name:"status"},{name:"messages"}];e.hideActions||L.push({name:"actions"}),e.allowSelection&&(L=[{name:"name"},{name:"model"},{name:"status"}]);let handleOnCreate=async()=>{console.log("Agent",e.agent);let n={name:t,base_model:u};if(c(!0),E(!0),F)try{let t="/agent/".concat(e.agent.id,"/train/").concat(F.name),{url:l}=await (0,ep.Xs)(F,null,M,t);n.csv_url=l,O({title:"File uploaded successfully",status:"success",duration:3e3,isClosable:!0})}catch(e){console.error("Error uploading file:",e),O({title:"Error uploading file",description:"Please try again.",status:"error",duration:3e3,isClosable:!0}),c(!1),E(!1);return}await e.onCreate(n),c(!1),E(!1),o(!1),P(null)};(0,es.useEffect)(()=>{if(y){var e,n;i(null!==(e=null==y?void 0:y.name)&&void 0!==e?e:""),v(null!==(n=null==y?void 0:y.base_model)&&void 0!==n?n:e4)}else i(""),v(e4)},[y]);let handleSelect=e=>{b(e),o(!0)},handleCloseModal=()=>{y&&b(null),o(!1),P(null)},onDelete=async n=>{k((0,ep.SO)(w,n.uuid,!0)),await e.onDelete(n),k((0,ep.SO)(w,n.uuid,!1))},onRefresh=async n=>{U((0,ep.SO)(I,n.uuid,!0)),await e.onRefresh(n),U((0,ep.SO)(I,n.uuid,!1))},onRun=async n=>{T((0,ep.SO)(z,n.uuid,!0)),await e.onRun(n),T((0,ep.SO)(z,n.uuid,!1))},onAddMessage=()=>{o(!1),e.onAddMessage()},getJobDataProps=n=>e.allowSelection?{onClick:()=>e.onSelect(n),cursor:"pointer",textDecoration:"underline"}:{};return(0,l.jsxs)(m.K,{children:[!e.hideHeader&&(0,l.jsxs)(m.K,{justifyContent:"space-between",direction:["column","row"],children:[(0,l.jsxs)(m.K,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(D.X,{children:"Fine-tuning"}),(0,l.jsx)(A.C,{colorScheme:"green",children:"Beta"})]}),(0,l.jsx)(x.x,{children:"Create a fine tuned model to take your agent to the next level"})]}),(0,l.jsxs)(p.U,{spacing:4,children:[(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/fine-tuning",children:(0,l.jsx)(j.z,{size:"lg",variant:"link",children:"View Docs"})}),(0,l.jsx)(j.z,{size:"lg",colorScheme:"blue",onClick:()=>o(!0),children:"Create"})]})]}),(0,l.jsx)(m.K,{mt:2,children:(0,l.jsx)(em.Z,{headers:L,children:n&&n.map(n=>{var t,i,s;return(0,l.jsxs)(h.Tr,{children:[(0,l.jsx)(g.Td,{...getJobDataProps(n),children:n.name}),(0,l.jsx)(g.Td,{...getJobDataProps(n),children:null!==(s=n.model_name)&&void 0!==s?s:"-"}),(0,l.jsx)(g.Td,{children:n.status}),!e.hideActions&&(0,l.jsx)(g.Td,{children:(0,l.jsx)(p.U,{children:(0,l.jsx)(x.x,{children:null===(i=n.data)||void 0===i?void 0:null===(t=i.messages)||void 0===t?void 0:t.length})})}),!e.hideActions&&(0,l.jsx)(g.Td,{children:(0,l.jsxs)(p.U,{children:[!n.start_at&&(0,l.jsx)(j.z,{size:"sm",colorScheme:"blue",isLoading:z[n.uuid],onClick:()=>onRun(n),children:"Run"}),n.start_at&&!n.finished_at&&(0,l.jsx)(j.z,{isLoading:I[n.uuid],size:"sm",colorScheme:"blue",variant:"outline",onClick:()=>onRefresh(n),children:"Refresh"}),!n.start_at&&!n.finished_at&&(0,l.jsx)(j.z,{size:"sm",onClick:()=>handleSelect(n),colorScheme:"blue",variant:"outline",children:" Manage"}),(0,l.jsx)(eG.Z,{onConfirm:()=>onDelete(n),children:(0,l.jsx)(j.z,{size:"sm",isLoading:w[n.uuid],variant:"outline",colorScheme:"red",children:"Delete"})})]})})]},n.uuid)})})}),(0,l.jsx)(a.Z,{size:"2xl",isOpen:s,hideScroll:!0,onClose:()=>handleCloseModal(),title:"".concat(y?"Manage":"Create"," fine-tuned model"),children:(0,l.jsxs)(m.K,{spacing:5,children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Name"}),(0,l.jsx)(S.I,{isDisabled:y,value:t,onChange:e=>i(e.target.value)}),(0,l.jsx)(f.Q6,{children:"Give this fine-tune a name"})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Model"}),(0,l.jsx)(S.I,{value:u,isDisabled:!0}),(0,l.jsxs)(f.Q6,{children:["The model to fine-tune. Only ",e4," is currently available"]})]}),!y&&(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Upload CSV file (optional, max 100 MB)"}),(0,l.jsx)(S.I,{type:"file",accept:".csv",onChange:e=>{let n=e.target.files[0];n&&n.size<=104857600?(console.log("File",n),P(n)):O({title:"File too large",description:"Please upload a CSV file smaller than 100 MB.",status:"error",duration:3e3,isClosable:!0})}}),(0,l.jsxs)(f.Q6,{children:['Upload a CSV file containing your training data. MUST contain "message" csv header ',(0,l.jsx)(C.r,{textDecor:"underline",href:"https://docs.agenthost.ai/fine-tuning",target:"_blank",children:"Learn more"})]})]}),y&&(0,l.jsxs)(m.K,{children:[(0,l.jsxs)(p.U,{mb:2,justifyContent:"space-between",children:[(0,l.jsx)(D.X,{size:"md",children:"Messages"}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>onAddMessage(),children:"Add messages"})]}),((null===(Z=y.data)||void 0===Z?void 0:null===(R=Z.messages)||void 0===R?void 0:R.length)==0||!(null===(V=y.data)||void 0===V?void 0:V.messages))&&(0,l.jsx)(x.x,{children:"No messages added..."}),(null===(H=y.data)||void 0===H?void 0:H.messages)&&(null===(K=y.data)||void 0===K?void 0:K.messages.map(e=>
1(0,l.jsx)(ChatMessage,{message:e},e._id)))]}),!y&&(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>handleOnCreate(),isLoading:d||N,children:N?"Uploading...":"Create"})]})})]})}var e2=t(30780),e3=t(21090),e6=t(98254);function AgentInterfaceView(e){var n,t,i,s,a;let{selectedAgentStyle:r,updateSelectedAgentStyleJson:o,saveStyleJson:d,parentLoading:c,hasAgentSku:u}=e,[h,g]=(0,es.useState)(JSON.parse(null!==(s=null===(n=e.agent)||void 0===n?void 0:n.style_json)&&void 0!==s?s:"{}")),[v,S]=(0,es.useState)(null!=c&&c),[y,C]=(0,es.useState)(!1),[w,k]=(0,es.useState)([]),[A,z]=(0,es.useState)([]);(0,es.useEffect)(()=>{console.log("start json",h),console.log("selected agent style",r);var e=!0;if(r)for(var n of Object.keys(r)){if(r[n]!==h[n]){C(!0),e=!1;break}e&&C(!1)}},[r,h]);let handleSave=async()=>{S(!0),console.log("deleting files",w);let n=w.forEach(async e=>{(0,ep._I)(e)});console.log("uploadingFiles",A);let t=A.forEach(async n=>{var t;(0,ep.Xs)(n,null,null,"/agent/".concat(null===(t=e.agent)||void 0===t?void 0:t.id,"/ui"))}),l=await Promise.all([n,t]);console.log("results",l),await e.saveStyleJson(),g({...r}),S(!1)};return(0,l.jsxs)(l.Fragment,{children:[e.hideTabs&&(0,l.jsxs)(p.U,{mb:4,justifyContent:"space-between",children:[(0,l.jsx)(D.X,{children:(0,ej.t)("agentDetail.int")}),(0,l.jsx)(j.z,{colorScheme:"blue",isDisabled:!y,onClick:()=>handleSave(),isLoading:v,children:(0,ej.t)("agentDetail.save_changes")})]}),(0,l.jsxs)(Q.m,{children:[(0,l.jsxs)(J.t,{children:[(0,l.jsx)(X.O,{children:"Chat"}),(0,l.jsx)(X.O,{children:"Agent page"}),(0,l.jsx)(X.O,{children:(0,ej.t)("agentDetail.forms")})]}),(0,l.jsxs)(B.n,{children:[(0,l.jsxs)(W.x,{children:[(0,l.jsxs)(m.K,{spacing:4,children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:(0,ej.t)("agentDetail.style")}),(0,l.jsxs)(ea.P,{placeholder:"Select style",value:null==r?void 0:r.default_style,onChange:e=>o("default_style",e.target.value),children:[(0,l.jsx)("option",{value:"light",children:(0,ej.t)("agentDetail.light")}),(0,l.jsx)("option",{value:"dark",children:(0,ej.t)("agentDetail.dark")})]})]}),(0,l.jsxs)(f.NI,{my:8,children:[(0,l.jsx)(_.l,{children:"Font"}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(e6.Z,{defaultValue:null!==(a=null==r?void 0:r.font_family)&&void 0!==a?a:"Inter",value:e=>o("font_family",e)})]}),(0,l.jsxs)(f.NI,{my:8,children:[(0,l.jsx)(_.l,{children:"Chat background image"}),(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(m.K,{children:(0,l.jsx)(f.Q6,{children:"Enter the image url"})}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(e3.Z,{deleteOnChange:!0,uploadOnChange:!0,accept:"image/*",filePath:"/agent/".concat(null===(t=e.agent)||void 0===t?void 0:t.id,"/ui"),fileUrl:null==r?void 0:r.chat_bg_image_url,onFileUpload:e=>{o("chat_bg_image_url",e.url)},onFileDelete:e=>o("chat_bg_image_url",null)})})]})]}),(0,l.jsxs)(f.NI,{my:8,children:[(0,l.jsx)(_.l,{children:"Side background image"}),(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(m.K,{children:(0,l.jsx)(f.Q6,{children:"Enter the image url"})}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(e3.Z,{deleteOnChange:!0,uploadOnChange:!0,accept:"image/*",filePath:"/agent/".concat(null===(i=e.agent)||void 0===i?void 0:i.id,"/ui"),fileUrl:null==r?void 0:r.side_bg_image_url,onFileUpload:e=>{o("side_bg_image_url",e.url)},onFileDelete:e=>o("side_bg_image_url",null)})})]})]}),(0,l.jsx)(f.NI,{children:(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(_.l,{children:(0,ej.t)("agentDetail.side")}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(e2.AI,{disabled:!0,color:null==r?void 0:r.side_bg_color,onChangeComplete:e=>o("side_bg_color",e.hex)})]})}),(0,l.jsx)(f.NI,{children:(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(_.l,{children:"Side text color"}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(e2.AI,{color:null==r?void 0:r.side_text_color,onChangeComplete:e=>o("side_text_color",e.hex)})]})}),(0,l.jsx)(f.NI,{children:(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(_.l,{children:"Chat background color"}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(e2.AI,{color:null==r?void 0:r.chat_bg_color,onChangeComplete:e=>o("chat_bg_color",e.hex)})]})}),(0,l.jsx)(f.NI,{children:(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(_.l,{children:"Chat text color"}),!u("custom_styles")&&(0,l.jsx)(x.x,{fontSize:"sm",children:(0,ej.t)("agentDetail.pro_color")}),u("custom_styles")&&(0,l.jsx)(e2.AI,{color:null==r?void 0:r.chat_text_color,onChangeComplete:e=>o("chat_text_color",e.hex)})]})})]}),!e.hideTabs&&(0,l.jsx)(j.z,{isLoading:v,colorScheme:"blue",onClick:()=>d(),children:(0,ej.t)("agentDetail.save")})]}),(0,l.jsx)(W.x,{children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Agent marketing description"}),(0,l.jsx)(b.g,{height:250,value:null==r?void 0:r.marketing_description,onChange:e=>o("marketing_description",e.target.value)}),(0,l.jsx)(f.Q6,{children:"Describe your agent to a prospective user. This will be shown on your agent landing page"})]})}),(0,l.jsx)(W.x,{children:e.formView})]})]})]})}t(48683);
1var e5=t(95873),e8=t(20967),e9=t(10991),e7=t(99840),ne=t(4693),nn=t(15115),nt=t(35541),nl=t(19778),ni=t(14581),ns=t(64859),na=t(66205),nr=t(54346),no=t(14253),nd=t(36855),nc=t(19784);function CustomActionCard(e){var n,t,i,s,a,r;let o=e.action,[d,c]=(0,es.useState)(null!==(n=null==o?void 0:o.name)&&void 0!==n?n:""),[u,h]=(0,es.useState)(null!==(t=null==o?void 0:o.schema_json)&&void 0!==t?t:""),[g,v]=(0,es.useState)(null!==(i=null==o?void 0:o.credential_type)&&void 0!==i?i:""),[y,C]=(0,es.useState)(null!==(s=null==o?void 0:o.auth_token)&&void 0!==s?s:""),[k,D]=(0,es.useState)(null!==(a=null==o?void 0:o.has_token)&&void 0!==a&&a),[A,z]=(0,es.useState)(null!==(r=null==o?void 0:o.approval_required)&&void 0!==r&&r),[T,I]=(0,es.useState)((null==o?void 0:o.credential_type)!=="Basic"&&(null==o?void 0:o.credential_type)!=="Bearer"&&o.credential_type),[U,F]=(0,es.useState)(!1),[E,O]=(0,es.useState)(!1),handleSave=async()=>{var n;F(!0);let t={id:null===(n=e.action)||void 0===n?void 0:n.id,name:d,schema_json:u,credential_type:g,credential:y,has_token:k,approval_required:A};await e.onSave(t),F(!1)};(0,es.useEffect)(()=>{"Bearer"!==g&&"Basic"!==g&&g&&I(!0)},[]);let handleDelete=async()=>{O(!0),await e.onDelete(e.action),O(!1)};return(0,l.jsx)(P.Z,{children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(m.K,{spacing:4,children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Action title"}),(0,l.jsx)(S.I,{placeholder:"What should your action be called?",value:d,onChange:e=>c(e.target.value)})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"OpenAPI Schema"}),(0,l.jsx)(b.g,{h:"200px",placeholder:"Your OpenAPI schema...",value:u,onChange:e=>h(e.target.value)})]}),(0,l.jsx)(x.x,{fontWeight:"bold",children:"Operations"}),(()=>{if(""===u)return[];try{let e=JSON.parse(u);return Object.keys(e.paths).map(n=>{let t=e.paths[n];return Object.keys(t).map(e=>{let i=t[e];return(0,l.jsx)(p.U,{justifyContent:"space-between",children:(0,l.jsxs)("option",{value:"".concat(e.toUpperCase()," ").concat(n),children:[" ",i.operationId," ",e.toUpperCase()," ",n]})},i.operationId)})})}catch(e){return console.error(e),[]}})(),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Authentication Type"}),(0,l.jsxs)(ea.P,{defaultValue:g,onChange:e=>v(e.target.value),children:["Bearer"!==g&&"Basic"!==g&&g&&(0,l.jsx)("option",{value:"custom",children:"Custom"}),(0,l.jsx)("option",{value:"",children:"None"}),(0,l.jsx)("option",{value:"Basic",children:"Basic"}),(0,l.jsx)("option",{value:"Bearer",children:"Bearer"}),(0,l.jsx)("option",{value:"custom",children:"Custom"})]})]}),"Bearer"!==g&&"Basic"!==g&&g&&(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Custom Authentication Type"}),(0,l.jsx)(S.I,{placeholder:"Enter value",value:g,onChange:e=>v(e.target.value)})]}),""!==g&&(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Authentication Token"}),(0,l.jsx)(S.I,{placeholder:"Enter value",value:k?"wewontshowyourtokenagain":null,type:"password",onChange:e=>C(e.target.value)}),(0,l.jsx)(f.Q6,{children:"This will not be shown again"})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"blue",isChecked:A,onChange:e=>z(e.target.checked)}),(0,l.jsx)(x.x,{children:"Require approval for this action"})]}),(0,l.jsx)(f.Q6,{children:"When enabled, this action will require explicit approval before execution"})]}),(0,l.jsxs)(p.U,{justifyContent:"flex-end",children:[(0,l.jsx)(j.z,{colorScheme:"blue",onClick:handleSave,isLoading:U,children:"Save"}),(0,l.jsx)(j.z,{colorScheme:"red",onClick:handleDelete,isLoading:E,variant:"outline",children:"Delete"})]})]})})},o.id)}var nu=t(480);let nh=new s.Z("custom_action"),ng=new s.Z("app-integration");var components_CustomActionAdminView=e=>{let{selectedAgentId:n,user:t,showSuccessToast:i}=e,{t:s}=(0,eX.$G)(),[a,o]=(0,es.useState)([]),[d,c]=(0,es.useState)([]),[f,_]=(0,es.useState)(!1),[S,y]=(0,es.useState)(!1),[b,w]=(0,es.useState)(null),{isOpen:k,onOpen:A,onClose:z}=(0,e8.q)(),[T,I]=(0,es.useState)(!1),[U,F]=(0,es.useState)(""),[P,N]=(0,es.useState)(null),[E,O]=(0,es.useState)(1),[M,R]=(0,es.useState)(!1),[Z,V]=(0,es.useState)(!1),H=(0,r.p)();(0,es.useEffect)(()=>{n&&(O(1),getCustomActions(),getAppActions())},[n]),(0,es.useEffect)(()=>{n&&getCustomActions()},[n,E]),(0,es.useEffect)(()=>{let handleVisibilityChange=()=>{!document.hidden&&n&&getCustomActions()},handleFocus=()=>{n&&getCustomActions()};return document.addEventListener("visibilitychange",handleVisibilityChange),window.addEventListener("focus",handleFocus),()=>{document.removeEventListener("visibilitychange",handleVisibilityChange),window.removeEventListener("focus",handleFocus)}},[n]);let getCustomActions=async()=>{_(!0);let e=await nh.query({agent_id:n,page:E,page_size:10});if(e&&!e.error)o(e.results),R(!!e.next),V(!!e.previous);else{let n=(0,eo.HH)(e.error,s("customActionAdmin.loading_error"));alert(n)}_(!1)},getAppActions=async()=>{y(!0);let e=await ng.query({page_size:10});if(e&&!e.error)c(e.results);else{let n=(0,eo.HH)(e.error,s("customActionAdmin.loading_error"));alert(n)}y(!1)},handleEditAction=e=>{w(e),A()},handleSaveAction=async e=>{if(-1===e.id){let t=await nh.create({agent:n,...e});if(!t||t.error){let e=(0,eo.HH)(t.error,s("customActionAdmin.custom_error"));alert(e)}else i(s("customActionAdmin.custom_created")),o([...a,t])}else{let n=await nh.update(e.id,e);if(!n||n.error){let e=(0,eo.HH)(n.error,s("customActionAdmin.custom_update_error"));alert(e)}else i(s("customActionAdmin.custom_updated")),o(a.map(t=>
1t.id===e.id?n:t))}z()},handleDeleteAction=async e=>{if(window.confirm(s("customActionAdmin.delete_confirmation"))){let n=await nh.delete(e.id);if(!n||n.error){let e=(0,eo.HH)(n.error,s("customActionAdmin.delete_custom_error"));alert(e)}else i(s("customActionAdmin.custom_deleted")),o(a.filter(n=>n.id!==e.id))}},handleAuthenticate=async()=>{try{let e=await ng.nonStandard("GET","".concat(P,"/oauth_url"));if(e&&!e.error)window.open(e.url,"_blank");else throw Error("Failed to fetch authentication URL")}catch(e){console.error("Error fetching authentication URL:",e),H({title:"Error",description:"Failed to fetch authentication URL",status:"error",duration:5e3,isClosable:!0})}I(!1)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(v.xu,{mb:2,children:(0,l.jsx)(D.X,{children:s("customActionAdmin.title")})}),(0,l.jsxs)(Q.m,{variant:"enclosed",colorScheme:"blue",children:[(0,l.jsxs)(J.t,{children:[(0,l.jsx)(X.O,{children:"Integrations"}),(0,l.jsx)(X.O,{children:s("agentDetail.actions")})]}),(0,l.jsxs)(B.n,{children:[(0,l.jsx)(W.x,{children:(0,l.jsx)(v.xu,{children:(0,l.jsx)(nu.Z,{page:!1,agentId:n})})}),(0,l.jsxs)(W.x,{children:[(0,l.jsxs)(m.K,{mb:4,children:[(0,l.jsx)(x.x,{children:s("customActionAdmin.description")}),(0,l.jsxs)(p.U,{mt:2,spacing:4,children:[(0,l.jsx)(j.z,{leftIcon:(0,l.jsx)(nd.d,{}),colorScheme:"blue",onClick:()=>{w({id:-1,name:"",schema_json:"",credential_type:""}),A()},children:s("customActionAdmin.create_action")}),(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/custom-actions",target:"_blank",textDecoration:"underline",children:"View Docs"})]})]}),(0,l.jsx)(D.X,{size:"md",mb:3,children:s("agentDetail.actions")}),f?(0,l.jsx)(u.$,{}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(e9.i,{variant:"simple",children:[(0,l.jsx)(e7.h,{children:(0,l.jsxs)(h.Tr,{children:[(0,l.jsx)(ne.Th,{children:"Name"}),(0,l.jsx)(ne.Th,{children:"Credential Type"}),(0,l.jsx)(ne.Th,{children:"Actions"})]})}),(0,l.jsx)(nn.p,{children:null==a?void 0:a.map(e=>(0,l.jsxs)(h.Tr,{children:[(0,l.jsx)(g.Td,{children:e.name}),(0,l.jsx)(g.Td,{children:e.credential_type}),(0,l.jsx)(g.Td,{children:(0,l.jsxs)(p.U,{spacing:2,children:[(0,l.jsx)(j.z,{size:"sm",leftIcon:(0,l.jsx)(nc.d,{}),onClick:()=>handleEditAction(e),children:"Edit"}),(0,l.jsx)(j.z,{size:"sm",colorScheme:"red",leftIcon:(0,l.jsx)(eq.p,{}),onClick:()=>handleDeleteAction(e),children:"Delete"})]})})]},e.id))})]}),(0,l.jsxs)(p.U,{justifyContent:"flex-end",spacing:4,mt:4,children:[Z&&(0,l.jsx)(j.z,{onClick:()=>O(E-1),isDisabled:f,children:"Previous"}),M&&(0,l.jsx)(j.z,{onClick:()=>O(E+1),isDisabled:f,children:"Next"})]})]}),(0,l.jsxs)(nt.u_,{isOpen:k,onClose:z,size:"xl",children:[(0,l.jsx)(nl.Z,{}),(0,l.jsxs)(ni.h,{children:[(0,l.jsxs)(ns.x,{children:[(null==b?void 0:b.id)===-1?"Create":"Edit"," Custom Action"]}),(0,l.jsx)(na.o,{}),(0,l.jsx)(nr.f,{children:b&&(0,l.jsx)(CustomActionCard,{action:b,onSave:handleSaveAction,onCancel:z})})]})]})]})]})]}),(0,l.jsxs)(nt.u_,{isOpen:T,onClose:()=>I(!1),children:[(0,l.jsx)(nl.Z,{}),(0,l.jsxs)(ni.h,{children:[(0,l.jsx)(ns.x,{children:"Authentication Required"}),(0,l.jsx)(na.o,{}),(0,l.jsx)(nr.f,{children:(0,l.jsxs)(x.x,{children:["You must authenticate with ",U," to connect this integration."]})}),(0,l.jsx)(no.m,{children:(0,l.jsx)(j.z,{colorScheme:"blue",onClick:handleAuthenticate,children:"Authenticate"})})]})]})]})},nx=t(48783);let np=new s.Z("transfer-request"),TransferAgentModal=e=>{let{isOpen:n,onClose:t,agentId:i}=e,[s,a]=(0,es.useState)(""),[o,d]=(0,es.useState)(""),[c,u]=(0,es.useState)(!1),h=(0,r.p)(),handleTransferConfirm=async()=>{if("transfer"!==o){h({title:"Invalid confirmation",description:"Please type 'transfer' to confirm",status:"error",duration:3e3,isClosable:!0});return}u(!0);try{let e=await np.create({agent:i,email:s});if(e&&!e.error)h({title:"Transfer request created",description:"The transfer request has been sent successfully.",status:"success",duration:5e3,isClosable:!0}),t();else throw Error(e.error||"An error occurred while creating the transfer request")}catch(e){h({title:"Error",description:e.message,status:"error",duration:5e3,isClosable:!0})}finally{u(!1)}};return(0,l.jsxs)(nt.u_,{isOpen:n,onClose:t,children:[(0,l.jsx)(nl.Z,{}),(0,l.jsxs)(ni.h,{children:[(0,l.jsx)(ns.x,{children:"Transfer Agent"}),(0,l.jsx)(na.o,{}),(0,l.jsx)(nr.f,{children:(0,l.jsxs)(nx.g,{spacing:4,children:[(0,l.jsx)(x.x,{children:"Are you sure you want to transfer this agent to another user?"}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Recipient's Email"}),(0,l.jsx)(S.I,{value:s,onChange:e=>a(e.target.value),placeholder:"Enter recipient's email"})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Confirmation"}),(0,l.jsx)(S.I,{value:o,onChange:e=>d(e.target.value),placeholder:"Type 'transfer' to confirm"})]})]})}),(0,l.jsxs)(no.m,{children:[(0,l.jsx)(j.z,{colorScheme:"blue",mr:3,onClick:handleTransferConfirm,isLoading:c,children:"Confirm Transfer"}),(0,l.jsx)(j.z,{variant:"ghost",onClick:t,children:"Cancel"})]})]})]})};function AgentUserManageModal(e){var n,t,i,o,d;let c=new s.Z("agent_user"),{t:h,i18n:g}=(0,eX.$G)(),{isOpen:y,onClose:C,agentUser:w,agentPlans:k}=e,[z,T]=(0,es.useState)(w),I=(0,r.p)(),[U,F]=(0,es.useState)(null!==(o=null!==(i=null==z?void 0:z.email)&&void 0!==i?i:null==z?void 0:null===(n=z.customer_user_data)||void 0===n?void 0:n.email)&&void 0!==o?o:null==z?void 0:null===(t=z.user_data)||void 0===t?void 0:t.email),[P,N]=(0,es.useState)(0),[E,q]=(0,es.useState)((null==z?void 0:z.plan_name)||""),[Q,J]=(0,es.useState)(!1),[X,B]=(0,es.useState)(!1),[W,G]=(0,es.useState)(!1),[Y,$]=(0,es.useState)(null),[ee,el]=(0,es.useState)(!1),[ei,er]=(0,es.useState)(null),[ed,ec]=(0,es.useState)(!1),[eu,ex]=(0,es.useState)(!1),[ep,ej]=(0,es.useState)(!1),[em,ev]=(0,es.useState)(""),[ef,e_]=(0,es.useState)(!1);(0,es.useEffect)(()=>{let n=e.agentUser;if(T(n),console.log("_user is ",n),n){var t,l,i,s,a;console.log("user message limit is ",null==n?void 0:n.message_limit),N((null==n?void 0:n.message_limit)||0),q((null==n?void 0:n.plan_name)||""),F(null!==(a=null!==(s=null==n?void 0:n.email)&&void 0!==s?s:null==n?void 0:null===(t=n.customer_user_data)||void 0===t?void 0:t.email)&&void 0!==a?a:null==n?void 0:null===(l=n.user_data)||void 0===l?void 0:l.email),J((null==n?void 0:null===(i=n.metadata)||void 0===i?void 0:i.onboarding_required)||!1),ec(!1)}n&&getUserPayments(n),n||ec(!0)},[e.agentUser]);let getUserPayments=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(e||(e=z),!e)return;console.log("fetching payments for user ",e),$(void 0);let n=await c.nonStandard("GET","".concat(e.id,"/payments"));console.log("payments are ",n),n.error?(console.log("error fetching payments",n),(0,eo.W6)(I,"Error fetching payments"),$([])):$(n)},handleSaveChanges=async()=>{console.log("saving changes");let n=null==k?void 0:k.find(e=>e.name===E);G(!0);let t=null==k?void 0:k.find(e=>e.name===E),l={...z,message_limit:P,agent_plan:null==t?void 0:t.id,plan_name:E,metadata:{...null==z?void 0:z.metadata}};Q&&(console.log("agent user re-onboarding required"),l.metadata.onboarding_required=!0),n&&n.name!==(null==z?void 0:z.plan_name)&&(console.log("agent user plan changed to ",n.name),l.agent_plan=n.id
1),console.log("existingUser is ",l),await e.onSaveChanges(l),G(!1)},handleDeleteUser=async()=>{B(!0),await e.onDeleteUser(z.id),B(!1),C()},handleRefundPayment=async e=>{console.log("refunding payment ",e);let n=await c.nonStandard("POST","refund",{payment_id:e,agent_user_id:z.id});if(console.log("refund resp ",n),n.error){let e=(0,eo.HH)(n.error,"An error occurred while refunding the payment.");(0,eo.W6)(I,e)}else getUserPayments(),(0,eo.XA)("Payment has been successfully refunded",I,"It will take about 5 minutes to reflected on the dashboard")},handleConfirmRefund=async e=>{el(!0),await handleRefundPayment(e),el(!1),er(null)},isRefunded=e=>{var n,t;return(null==e?void 0:null===(n=e.latest_charge)||void 0===n?void 0:n.refunded)||(null==e?void 0:null===(t=e.latest_charge)||void 0===t?void 0:t.amount_refunded)>0},handleCancelSubscription=()=>{ej(!0)},cancelSubscription=async()=>{var n;if(!em||""===em.trim()){I({title:"Please provide a reason for cancellation",status:"warning",duration:3e3,isClosable:!0});return}if(!(null===(n=e.agent)||void 0===n?void 0:n.id)||!(null==z?void 0:z.id)){I({title:"Invalid agent or user data",status:"error",duration:3e3,isClosable:!0});return}e_(!0);try{let n=await c.nonStandard("POST","cancel_sub",{agent_id:e.agent.id,agent_user_id:z.id,cancel_reason:em});if(n&&!n.error)I({title:"Subscription cancelled successfully",status:"success",duration:3e3,isClosable:!0}),ej(!1),ev(""),getUserPayments(),e.getAgentUsers();else{let e=(0,eo.HH)(null==n?void 0:n.error,"Sorry, something went wrong. Please try again");I({title:e,status:"error",duration:3e3,isClosable:!0})}}catch(e){console.error("Error cancelling subscription:",e),I({title:"An unexpected error occurred while cancelling the subscription",status:"error",duration:3e3,isClosable:!0})}finally{e_(!1)}},handleCreateUser=async()=>{console.log("creating user"),ex(!0);let n=null==k?void 0:k.find(e=>e.name===E);console.log("agent plan id = ",null==n?void 0:n.id);let t=await c.create({agent:e.agent.id,email:U,agent_plan:null==n?void 0:n.id,message_limit:P});if(console.log("agent user resp ",t),t.error){let e=(0,eo.HH)(t.error,"An error occurred while creating the user");(0,eo.W6)(I,e)}else(0,eo.XA)("User created successfully",I,"They will be sent an email to sign in"),C(),e.getAgentUsers();ex(!1)},getStatusRender=e=>{var n,t,i,s;if(null==e?void 0:null===(n=e.latest_charge)||void 0===n?void 0:n.refunded)return(0,l.jsx)(A.C,{color:"gray",children:"Refunded"});if((null==e?void 0:null===(t=e.latest_charge)||void 0===t?void 0:t.amount_refunded)>0)return(0,l.jsxs)(A.C,{color:"gray",children:[(0,eg.l_)("currency",e.currency.toUpperCase(),"symbol")+((null==e?void 0:null===(s=e.latest_charge)||void 0===s?void 0:s.amount_refunded)/100).toFixed(2)," Refunded"]});if(null==e?void 0:null===(i=e.latest_charge)||void 0===i?void 0:i.disputed)return(0,l.jsx)(A.C,{color:"red",children:"Disputed"});if((null==e?void 0:e.status)=="failed")return(0,l.jsx)(A.C,{color:"red",children:"Failed"});if((null==e?void 0:e.status)=="processing")return(0,l.jsx)(A.C,{color:"yellow",children:"Pending"});if((null==e?void 0:e.status)=="canceled")return(0,l.jsx)(A.C,{color:"red",children:"Canceled"});if((null==e?void 0:e.status)=="succeeded")return(0,l.jsx)(A.C,{color:"green",children:"Success"})};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a.Z,{title:ed?"Create Agent User":"Manage Agent User",isOpen:y,onClose:C,children:(0,l.jsxs)(m.K,{spacing:6,children:[(0,l.jsxs)(m.K,{children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Email"}),ed?(0,l.jsx)(S.I,{value:null==z?void 0:z.email,onChange:e=>F(e.target.value)}):(0,l.jsx)(x.x,{children:U})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Plan"}),(0,l.jsxs)(ea.P,{value:E,onChange:e=>q(e.target.value),children:[(0,l.jsx)("option",{value:"",children:null!==(d=null==z?void 0:z.plan_name)&&void 0!==d?d:h("agentDetail.free")}),null==k?void 0:k.map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.id))]})]})]}),(0,l.jsx)(m.K,{children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Message Limit"}),(0,l.jsxs)(en.B,{children:[(0,l.jsx)(et.Ui,{children:"Message Limit"}),(0,l.jsx)(S.I,{type:"number",value:-1==P?"Infinite":P,onChange:e=>N(parseInt(e.target.value))})]}),-1==P&&(0,l.jsx)(f.Q6,{children:"There is currently no limit on the number of messages."})]})}),ed&&(0,l.jsx)(j.z,{colorScheme:"blue",isLoading:eu,onClick:()=>handleCreateUser(),children:h("agentDetail.create")}),!ed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(eh.X,{isChecked:Q,onChange:e=>J(e.target.checked),children:"Re-onboard"}),(0,l.jsx)(no.m,{children:(0,l.jsxs)(p.U,{spacing:3,children:[(0,l.jsxs)(O.J,{children:[(0,l.jsx)(M.x,{children:(0,l.jsx)(p.U,{children:(0,l.jsx)(j.z,{colorScheme:"red",variant:"outline",isLoading:X,children:h("agentDetail.delete")})})}),(0,l.jsxs)(R.y,{children:[(0,l.jsx)(Z.Q,{}),(0,l.jsx)(V.u,{}),(0,l.jsx)(H.Y,{children:h("agentDetail.confirmation")}),(0,l.jsx)(K.b,{children:h("agentDetail.delete_confirmation")}),(0,l.jsx)(L.D,{children:(0,l.jsx)(j.z,{colorScheme:"red",onClick:()=>handleDeleteUser(),isLoading:X,children:h("agentDetail.confirm")})})]})]}),(null==z?void 0:z.customer_id)&&!(null==z?void 0:z.cancelled_at)&&(0,l.jsx)(j.z,{colorScheme:"orange",variant:"outline",onClick:()=>handleCancelSubscription(),children:"Cancel subscription"}),(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>handleSaveChanges(),isLoading:W,children:h("agentDetail.save")})]})}),(0,l.jsxs)(m.K,{children:[(0,l.jsx)(D.X,{size:"md",mb:4,children:"Payments"}),void 0==Y&&(0,l.jsx)(u.$,{}),(null==Y?void 0:Y.length)>0&&(null==Y?void 0:Y.map(e=>(0,l.jsxs)(v.xu,{bg:"white",p:4,borderRadius:"md",boxShadow:"md",display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,l.jsx)(p.U,{spacing:4,children:(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:(0,eg.l_)("currency",e.currency.toUpperCase(),"symbol")+(e.amount/100).toFixed(2)}),(0,l.jsx)(x.x,{fontSize:"sm",color:"gray.500",children:eT().unix(e.created).format("lll")}),getStatusRender(e)]})}),!isRefunded(e)&&(null==e?void 0:e.status)=="succeeded"&&(0,l.jsxs)(O.J,{isOpen:ei==e.id,onOpen:()=>er(e.id),onClose:()=>er(null),children:[(0,l.jsx)(M.x,{children:(0,l.jsx)(j.z,{colorScheme:"red",variant:"outline",size:"sm",onClick:()=>er(e.id),children:"Refund"})}),(0,l.jsxs)(R.y,{children:[(0,l.jsx)(Z.Q,{}),(0,l.jsx)(V.u,{}),(0,l.jsx)(H.Y,{children:"Confirm Refund"}),(0,l.jsx)(K.b,{children:"Refunding this payment will refund the cost minus the Stripe and Agenthost fee. It usually takes 3-5 business days to process. Continue?"}),(0,l.jsx)(L.D,{children:(0,l.jsx)(j.z,{colorScheme:"red",onClick:()=>handleConfirmRefund(e.id),isLoading:ee,children:"Confirm"})})]})]})]},e.id))),(null==Y?void 0:Y.length)==0&&(0,l.jsx)(x.x,{children:"No payments found."})]})]})]})}),(0,l.jsx)(a.Z,{isOpen:ep,title:"Cancel Subscription",onClose:()=>{ej(!1),ev("")},children:(0,l.jsxs)(m.K,{spacing:4,children:[(0,l.jsx)(x.x,{children:"Please provide a reason for cancelling this subscription:"}),(0,l.jsx)(f.NI,{children:(0,l.jsx)(b.g,{placeholder:"Enter your reason for cancellation...",value:em,onChange:e=>ev(e.target.value),rows:4})}),(0,l.jsxs)(p.U,{children:[(0,l.jsx)(j.z,{colorScheme:"red",onClick:()=>cancelSubscription(),isLoading:ef,children:"Cancel subscription"}),(0,l.jsx)(j.z,{onClick:()=>{ej(!1),ev("")},children:"Close"})]})]})})]})}var nj=t(89583),nm=t(88007),nv=t(59109),nf=t(51607),n_=t(24259),nS=t(55512),ny=t(70231);function AgentDataStorageView(e){var n,t;let i=e.agentApi,{user:s,agent:a,agentCustomData:r,setAgentCustomData:o}=e,d=(null==a?void 0:null===(n=a.json_data)||void 0===n?void 0:n.region)||"anywhere",[c,u]=(0,es.useState)(d),h=(0,es.useRef)(null),{isOpen:g,onOpen:f,onClose:_}=(0,e8.q)(),[S,y]=(0,es.useState)(!1),[b,w]=(0,es.useState)(null==a?void 0:null===(t=a.json_data)||void 0===t?void 0:t.regi
1on_migration),onSave=async()=>{y(!0);let e=await i.nonStandard("POST","".concat(a.id,"/region"),{region:c});if(console.log(e),e&&!e.error)alert("Migration started"),w(e);else{let n=(0,eo.HH)(null==e?void 0:e.error);alert("Migration failed: "+n)}y(!1)},handleRegionChange=async()=>{await onSave(),_()};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(D.X,{size:"md",mb:4,children:"Data Storage"}),(0,l.jsx)(x.x,{mb:2,children:"Select the region where you want your agent's data to be hosted."}),(0,l.jsx)(nf.E,{value:c,onChange:e=>u(e),children:(0,l.jsxs)(m.K,{spacing:5,children:[(0,l.jsx)(n_.Y,{value:"anywhere",children:(0,l.jsxs)(p.U,{spacing:4,children:[(0,l.jsx)(v.xu,{bg:"gray.100",p:3,borderRadius:"md",children:(0,l.jsx)(ei.J,{as:ny.ssk,boxSize:6})}),(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(D.X,{size:"sm",children:"Anywhere"}),(0,l.jsx)(x.x,{fontSize:"sm",color:"gray.500",children:"Your data can be hosted in any of our global data centers."})]})]})}),(0,l.jsx)(nv.Z,{sku:"region",user:e.user,title:"Upgrade to access Region Data Hosting",subtitle:"Region Data Hosting is only supported on our custom plans. Please contact us to learn more.",children:(0,l.jsx)(n_.Y,{value:"eu",children:(0,l.jsxs)(p.U,{spacing:4,children:[(0,l.jsx)(v.xu,{bg:"gray.100",p:3,borderRadius:"md",children:(0,l.jsx)(ei.J,{as:ny.Jzf,boxSize:6})}),(0,l.jsxs)(v.xu,{children:[(0,l.jsx)(D.X,{size:"sm",children:"European Union"}),(0,l.jsx)(x.x,{fontSize:"sm",color:"gray.500",children:"Your data will be hosted exclusively in our EU data centers."})]})]})})})]})}),b&&(0,l.jsxs)(m.K,{mt:4,spacing:2,mb:4,children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:"Your agent is currently being migrated. "}),(0,l.jsx)(x.x,{children:"Your agent has been copied to the new region. Please test the new agent and reupload any uploaded files to verify it is working as expected. Once happy with the new agent, you may publish the new agent then delete the old agent. All traffic will be switched over to the new agent once published."}),(0,l.jsxs)(p.U,{children:[(null==b?void 0:b.new_aid)&&(0,l.jsx)(C.r,{href:"/project/".concat(null==b?void 0:b.new_aid),children:(0,l.jsx)(j.z,{children:"New Agent"})}),(null==b?void 0:b.old_aid)&&(0,l.jsx)(C.r,{href:"/project/".concat(null==b?void 0:b.old_aid),children:(0,l.jsx)(j.z,{children:"Old Agent"})})]})]}),c!==d&&(0,l.jsx)(p.U,{mt:4,children:(0,l.jsx)(j.z,{colorScheme:"blue",onClick:()=>{console.log("saving"),c!==d&&"eu"==c&&(console.log("region changed"),f())},children:"Save"})}),(0,l.jsx)(nS.a,{isOpen:g,leastDestructiveRef:h,onClose:_,children:(0,l.jsx)(nl.Z,{children:(0,l.jsxs)(nS._,{children:[(0,l.jsx)(ns.x,{fontSize:"lg",fontWeight:"bold",children:"Change Data Region"}),(0,l.jsx)(nr.f,{children:(0,l.jsxs)(m.K,{children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:"Please read and understand the following before proceeding:"}),(0,l.jsx)(x.x,{fontSize:"sm",children:"Performing a data region change will create a copy of your agent in the new region. Your old agent will continue working as before. "}),(0,l.jsx)(x.x,{fontSize:"sm",children:"You will need to test the new agent and reupload any uploaded files to verify it is working as expected."}),(0,l.jsx)(x.x,{fontSize:"sm",children:"Once happy with the new agent, you may complete the migration then delete the old agent if you wish to."}),(0,l.jsx)(x.x,{fontSize:"sm",children:"Your agent users chats will be migrated but any files uploaded to the chat will need to be reuploaded."}),(0,l.jsx)(x.x,{fontSize:"sm",children:"All traffic will be switched over to the new agent once published."}),(0,l.jsx)(x.x,{fontSize:"sm",children:"We encourage letting your agent user's know about this change should you have significant existing users."})]})}),(0,l.jsxs)(no.m,{children:[(0,l.jsx)(j.z,{ref:h,onClick:_,children:"Cancel"}),(0,l.jsx)(j.z,{isLoading:S,isDisabled:S,colorScheme:"red",onClick:handleRegionChange,ml:3,children:"Change Region"})]})]})})})]})}function AgentMarketplaceView(e){var n,t,i,s;let a=e.agentApi,{agent:r}=e,[u,h]=(0,es.useState)(null!=r&&!!r.marketplace_setting),[g,v]=(0,es.useState)((null==r?void 0:r.marketplace_setting)||"simple"),[f,_]=(0,es.useState)(!1),handleToggle=async e=>{h(e),e||await saveMarketplaceSettings(null)},handleSettingChange=e=>{v(e)},saveMarketplaceSettings=async n=>{_(!0);try{let t=await a.update(r.id,{marketplace_setting:n});if(t&&!t.error)e.onSuccess&&e.onSuccess(null===n?"Marketplace disabled successfully":"Marketplace settings updated successfully"),e.onUpdate&&e.onUpdate(t);else{let e=(0,eo.HH)(null==t?void 0:t.error,"Failed to update marketplace settings");alert(e),null===n&&h(!0)}}catch(e){console.error("Error updating marketplace settings:",e),alert("An unexpected error occurred while updating marketplace settings"),null===n&&h(!0)}finally{_(!1)}},handleSave=async()=>{await saveMarketplaceSettings(g)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(D.X,{size:"md",mb:4,children:"Marketplace Settings"}),(0,l.jsxs)(m.K,{spacing:6,children:[(null===(t=e.agent)||void 0===t?void 0:null===(n=t.parent_data)||void 0===n?void 0:n.marketplace_setting)&&(0,l.jsx)(x.x,{children:"Managed agents from the marketplace cannot be put on the marketplace"}),!(null===(s=e.agent)||void 0===s?void 0:null===(i=s.parent_data)||void 0===i?void 0:i.marketplace_setting)&&(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",isChecked:u,onChange:e=>handleToggle(e.target.checked),isDisabled:f}),(0,l.jsx)(x.x,{fontWeight:"medium",children:"Enable Marketplace Agent"})]}),u&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.b,{status:"info",borderRadius:"md",children:[(0,l.jsx)(d.z,{}),(0,l.jsx)(c.X,{children:"Turning on marketplace agent allows other users to leverage and customize the agent for their own deployment and use."})]}),(0,l.jsxs)(m.K,{spacing:3,children:[(0,l.jsx)(x.x,{fontWeight:"medium",children:"Marketplace Type"}),(0,l.jsxs)(ea.P,{value:g,onChange:e=>handleSettingChange(e.target.value),maxW:"200px",isDisabled:f,children:[(0,l.jsx)("option",{value:"simple",children:"Simple"}),(0,l.jsx)("option",{value:"advanced",children:"Advanced"})]}),(0,l.jsx)(x.x,{fontSize:"sm",color:"gray.500",children:"simple"===g?"With Simple mode, you are in control of the main settings and you are charged for token usage. Your users can customize basic parameters like name and image url. They cannot see or access the prompt.":"Advanced agents allows the user full customization and access of the agent settings and they are charged directly for usage."})]}),(0,l.jsx)(p.U,{children:(0,l.jsx)(j.z,{colorScheme:"blue",onClick:handleSave,isLoading:f,children:"Save Changes"})})]})]})]})}var nb=t(38166),components_InterfaceTypeSelector=e=>{let{value:n,onChange:t,hasVoiceSku:i,onUpgradeClick:s}=e,handleSelect=e=>{if("voice"===e&&!i){s();return}t(e)};return(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Interface Type"}),(0,l.jsxs)(p.U,{spacing:4,children:[(0,l.jsx)(j.z,{flex:1,variant:"outline",bg:"voice"===n?"white":"transparent",borderColor:"voice"===n?"blue.500":"gray.200",borderWidth:"2px",color:"voice"===n?"blue.500":"gray.600",_hover:{borderColor:"blue.300",bg:"gray.50"},onClick:()=>handleSelect("voice"),py:6,children:(0,l.jsxs)(v.xu,{textAlign:"center",children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:"Voice"}),(0,l.jsx)(x.x,{fontSize:"sm",mt:1,children:"Voice-based interactions"})]})}),(0,l.jsx)(j.z,{flex:1,variant:"outline",bg:"text"===n?"white":"transparent",borderColor:"text"===n?"blue.500":"gray.200",borderWidth:"2px",color:"text"===n?"blue.500":"gray.600",_hover:{borderColor:"blue.300",bg:"gray.50"},onClick:()=>handleSelect("text"),py:6,children:(0,l.jsxs)(v.xu,{textAlign:"center",children:[(0,l.jsx)(x.x,{fontWeight:"bold",children:"Text"}),(0,l.jsx)(x.x,{fontSize:"sm",mt:1,children:"Text-based chat"})]})})]}),(0,l.jsx)(f.Q6,{children:i?"Select the interface type for your agent."
1:"Select the interface type for your agent. Voice interface requires an upgrade."})]})},nC=t(95392),nw=t(9715);let nk=i.ZP.getEnvUrl().substring(0,i.ZP.getEnvUrl().length-4)+":8001/api";console.log("envUrl",nk);let nD=new s.Z("agent",null,nk),nA="use fine tuned model",nz=["gpt-4o","gpt-4.1","gpt-4.1-mini","gpt-4o-mini","gpt-4.1-nano",nA];function AgentDetailView(e){var n,t,ec,eu,eh,eg,ex,ej,ef,e_,eS,ey,eb,eC,ew,ek,eD,eA,ez,eH,eK,eL,eq,eQ,e$,e0,e1,e4,e2,e3,e6,e8;let{t:e9}=(0,eX.$G)(),e7=e.context,ne=new s.Z("agent"),nn=new s.Z("user");new s.Z("plan");let nt=new s.Z("agent_plan"),nl=new s.Z("agent_user");new s.Z("agent_domain");let ni=new s.Z("agent_integration"),ns=new s.Z("form_response"),na=new s.Z("finetune");e9("agentDetail.accordion"),i.ZP.getFullUrl(),e.token;let[nr,no]=(0,es.useState)(e.agent),nd=(0,ed.cF)(),{onCopy:nc,value:nu,setValue:nh,hasCopied:ng}=(0,er.V)("".concat(i.ZP.getFullUrl(),"/agent/").concat(null==nr?void 0:nr.slug)),nx=(0,r.p)(),[np,nf]=(0,es.useState)(!1),n_=(null==nr?void 0:nr.custom_data)?JSON.parse(nr.custom_data):{},[nS,ny]=(0,es.useState)(e.showModal),[nk,nT]=(0,es.useState)((null==nr?void 0:nr.style_json)?JSON.parse(nr.style_json):null),[nI,nU]=(0,es.useState)(null==nr?void 0:nr.name),[nF,nP]=(0,es.useState)(null),[nN,nE]=(0,es.useState)(null==nr?void 0:nr.avatar_url),[nO,nM]=(0,es.useState)(null!==(eb=null==nr?void 0:nr.allow_file_uploads)&&void 0!==eb&&eb),[nR,nZ]=(0,es.useState)(null==nr?void 0:nr.slug),[nV,nH]=(0,es.useState)(null==nr?void 0:nr.description),[nK,nL]=(0,es.useState)(null!==(eC=null==nr?void 0:nr.assistant_id)&&void 0!==eC?eC:null),[nq,nQ]=(0,es.useState)(!1),[nJ,nX]=(0,es.useState)([]),[nB,nW]=(0,es.useState)(null!==(ew=null==nr?void 0:nr.publicity)&&void 0!==ew?ew:"private"),[nG,nY]=(0,es.useState)({}),[n$,n0]=(0,es.useState)(!1),[n1,n4]=(0,es.useState)(!1),[n2,n3]=(0,es.useState)(null==nr?void 0:nr.instruction),[n6,n5]=(0,es.useState)([]),[n8,n9]=(0,es.useState)(!1),[n7,te]=(0,es.useState)(e.activeModalIndex),[tn,tt]=(0,es.useState)(null==e?void 0:e.agent),tl=null==tn?void 0:tn.id,[ti,ts]=(0,es.useState)(null==nr?void 0:nr.plans),[ta,tr]=(0,es.useState)({}),[to,td]=(0,es.useState)(!1),[tc,tu]=(0,es.useState)((null==nr?void 0:nr.gpt_id)?"https://chat.openai.com/g/".concat(null==nr?void 0:nr.gpt_id):null),[th,tg]=(0,es.useState)(null==nr||!nr.id||null!=nr&&!!nr.fully_hosted),[tx,tp]=(0,es.useState)({}),[tj,tm]=(0,es.useState)(null!==(ek=null==nr?void 0:null===(n=nr.json_data)||void 0===n?void 0:n.prevent_hallucination)&&void 0!==ek&&ek),[tv,tf]=(0,es.useState)(null!==(eD=null==nr?void 0:null===(t=nr.json_data)||void 0===t?void 0:t.allow_prefilled_responses)&&void 0!==eD&&eD),[t_,tS]=(0,es.useState)(null==nr?void 0:nr.welcome_message),[ty,tb]=(0,es.useState)(null!==(eA=null==nr?void 0:nr.model_name)&&void 0!==eA?eA:nz[0]),[tC,tw]=(0,es.useState)(null!==(ez=null==nr?void 0:nr.native_rag)&&void 0!==ez&&ez),[tk,tD]=(0,es.useState)(!1),[tA,tz]=(0,es.useState)(null),[tT,tI]=(0,es.useState)(null),[tU,tF]=(0,es.useState)(30),[tP,tN]=(0,es.useState)(null!==(eH=null==nr?void 0:nr.allow_email_signup)&&void 0!==eH&&eH),[tE,tO]=(0,es.useState)({}),[tM,tR]=(0,es.useState)([]),[tZ,tV]=(0,es.useState)(null),[tH,tK]=(0,es.useState)((null==nr?void 0:nr.custom_data)?JSON.parse(nr.custom_data):{}),[tL,tq]=(0,es.useState)((null==nr?void 0:nr.json_data)?nr.json_data:{}),[tQ,tJ]=(0,es.useState)(null!==(eK=null==nr?void 0:nr.interview_rubric)&&void 0!==eK?eK:null),[tX,tB]=(0,es.useState)(null!=nr&&!!nr.landing_page_data),[tW,tG]=(0,es.useState)(!1),[tY,t$]=(0,es.useState)(e.threadId?{id:e.threadId,thread_id:e.threadId}:null),[t0,t1]=(0,es.useState)({}),[t4,t2]=(0,es.useState)({});console.log("selectedConversation",t4);let[t3,t6]=(0,es.useState)(null),[t5,t8]=(0,es.useState)([]),[t9,t7]=(0,es.useState)(!1),[le,ln]=(0,es.useState)(""),[lt,ll]=(0,es.useState)(!1),[li,ls]=(0,es.useState)({}),[la,lr]=(0,es.useState)(null),[lo,ld]=(0,es.useState)(!1),[lc,lu]=(0,es.useState)(null),[lh,lg]=(0,es.useState)(null),[lx,lp]=(0,es.useState)(!1),[lj,lm]=(0,es.useState)(null),[lv,lf]=(0,es.useState)(0),[l_,lS]=(0,es.useState)(!1),[ly,lb]=(0,es.useState)(null),[lC,lw]=(0,es.useState)(""),[lk,lD]=(0,es.useState)(null),[lA,lz]=(0,es.useState)(!1),[lT,lI]=(0,es.useState)(!1),[lU,lF]=(0,es.useState)(null!==(eL=null==nr?void 0:nr.allow_install)&&void 0!==eL&&eL),[lP,lN]=(0,es.useState)([]),[lE,lO]=(0,es.useState)({}),[lM,lR]=(0,es.useState)(null),[lZ,lV]=(0,es.useState)(!1),[lH,lK]=(0,es.useState)(null),[lL,lq]=(0,es.useState)(!1),[lQ,lJ]=(0,es.useState)(null!==(eq=null==n_?void 0:n_.links)&&void 0!==eq?eq:[]),[lX,lB]=(0,es.useState)(null),[lW,lG]=(0,es.useState)({}),[lY,l$]=(0,es.useState)(null),[l0,l1]=(0,es.useState)(null),[l4,l2]=(0,es.useState)(!1),[l3,l6]=(0,es.useState)(null),[l5,l8]=(0,es.useState)("interview"===e7?"voice":null),[l9,l7]=(0,es.useState)({}),[ie,it]=(0,es.useState)(null),[il,ii]=(0,es.useState)({}),[is,ia]=(0,es.useState)((null!==(eQ=null==nr?void 0:nr.temperature)&&void 0!==eQ?eQ:1)*100),[ir,io]=(0,es.useState)((null!==(e$=null==nr?void 0:nr.top_p)&&void 0!==e$?e$:1)*100),[id,ic]=(0,es.useState)(null!==(e0=null==nr?void 0:null===(ec=nr.
1json_data)||void 0===ec?void 0:ec.prompt_token_limit)&&void 0!==e0?e0:""),[iu,ih]=(0,es.useState)(null!==(e1=null==nr?void 0:null===(eu=nr.json_data)||void 0===eu?void 0:eu.completion_token_limit)&&void 0!==e1?e1:""),[ig,ix]=(0,es.useState)(null!==(e4=null==nr?void 0:null===(eh=nr.json_data)||void 0===eh?void 0:eh.agentic_enabled)&&void 0!==e4&&e4),[ip,ij]=(0,es.useState)(""),[im,iv]=(0,es.useState)(null!==(e2=null==nr?void 0:null===(eg=nr.json_data)||void 0===eg?void 0:eg.web_links)&&void 0!==e2?e2:[]),[i_,iS]=(0,es.useState)(!1),[iy,ib]=(0,es.useState)(1),[iC,iw]=(0,es.useState)(1),[ik,iD]=(0,es.useState)(0),[iA,iz]=(0,es.useState)(!1),[iT,iI]=(0,es.useState)({}),[iU,iF]=(0,es.useState)(null!==(e3=null==nr?void 0:nr.interface_type)&&void 0!==e3?e3:"text"),[iP,iN]=(0,es.useState)(!1),iE=[{icon:nj.ssk,text:"View Agent",description:"View your agent on the web and test it out.",href:"/agent/".concat(null==tn?void 0:tn.slug)},{icon:nj.ef0,text:"Deploy Agent",description:"Access agent via iframe, custom domain + more.",onClick:()=>n4(!0)},{icon:nj.RcD,text:"Setup Monetization",description:"Setup your agent to start generating revenue",onClick:()=>e.onNavChange(3)},{icon:nj.iNY,text:"Add Custom Actions",description:"Add custom actions/functions to your agent",onClick:()=>e.onNavChange(6)},{icon:nj.eKD,text:"Connect to Apps via Zapier",description:"Connect your agent to 6000+ other apps",onClick:()=>e.onNavChange(9)}];(0,es.useEffect)(()=>{window.sessionStorage.getItem("created_agent_id")&&(tG(!0),sessionStorage.removeItem("created_agent_id"))},[]),(0,es.useEffect)(()=>{nr&&(console.log("agent is ",nr),iD(ik+1))},[nr]);let getAgentConvos=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t7(!0),console.log("conversation filters",l9);let t={start:e,limit:10,...l9};console.log("request body",t),lY&&(t.guest_uuid=lY),n?t.query=n:l0&&(t.query=l0),t.agent_id=tl;let l=await ne.nonStandard("GET","conversations",null,t);console.log("convos are ",l),l&&!l.error&&(t6(l),0==e?t8(l.conversations):t8([...t5,...l.conversations]),lO((0,ep.SO)(lE,"conversations",e))),t7(!1)};(0,es.useEffect)(()=>{let e={};if(ti){for(var n of ti)e[n.id]=n;tr(e)}},[ti]),(0,es.useEffect)(()=>{0===lv?getAgentRealUsers():getAgentEmails()},[iy,iC,lv]),(0,es.useEffect)(()=>{getAgentConvos()},[lY]),(0,es.useEffect)(()=>{l0||getAgentConvos()},[l0]),(0,es.useEffect)(()=>{lC||(0===lv?getAgentRealUsers():getAgentEmails())},[lC,lv]),(0,es.useEffect)(()=>{var e;let n=getActiveFineTune();if(!n)return;let t=null===(e=n.data)||void 0===e?void 0:e.messages;if(!t)return;let l={};for(let e of t)l[e._id]=n;ii(l)},[ie]);let getActiveFineTune=()=>{if(!ie)return null;{let e=ie.filter(e=>"open"==e.status||!e.start_at);return e.length>0?e[0]:null}};(0,es.useEffect)(()=>{e.showDeploy&&n4(!0)},[e.showDeploy]),(0,es.useEffect)(()=>{e.showNextSteps&&tG(!0)},[e.showNextSteps]),(0,es.useEffect)(()=>{nr&&!e.doNotFetch&&getAgentMetrics()},[tU]);let getAgentFormResponses=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;console.log("calling get agent form resposnes with page",e);let n=await ns.query({agent_id:tl,page:e,page_size:10});console.log("form responses are ",n),n&&!n.error?(lB(n),lO((0,ep.SO)(lE,"form",e))):lB([])},handleDeleteAgentUser=async e=>{lG((0,ep.SO)(lW,e,!0)),await nl.delete(e),await getAgentRealUsers(!0),await getAgentEmails(!0),lG((0,ep.SO)(lW,e,!1))};(0,es.useEffect)(()=>{te(e.activeModalIndex)},[e.activeModalIndex]);let handleRemoveLink=e=>{let n=im.filter((n,t)=>t!==e);iv(n)},getAgentMetrics=async()=>{tD(!0);let e=(0,ep.mO)(tU),n=await ne.nonStandard("GET","".concat(tl,"/metrics"),null,{start_date:e});if(console.log("metrics are ",n),n&&!n.error){tz(n);var t="MMM Do YY";let e=(0,ep.ig)(tU,0),a=(0,ep.ig)(tU,0),r=(0,ep.ig)(tU,0);for(var l of n.messages){var i=eT()(l._id.created_at).format(t);void 0!==e[i]&&(e[i]=l.count)}for(var l of n.threads){var i=eT()(l._id.created_at).format(t);void 0!==a[i]&&(a[i]=l.count)}for(var l of n.messages){var i=eT()(l._id.created_at).format(t);void 0!==r[i]&&(r[i]=l.message_credits)}console.log("metrics map is",e);let o=[];for(var s in e)o.push({date:s,messages:e[s],threads:a[s],creditUsage:r[s]});console.log("final data array is ",o),tI(o)}tD(!1)},getAgentUsers=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;"users"===l?ld(!0):"emails"===l?lp(!0):ld(!0),t||(t="users"===l?iy:"emails"===l?iC:iy);let i={agent_id:tl,page:t,page_size:10};"users"===l?i.user=!0:"emails"===l&&(i.email=!0),lC&&(i.user_email=lC),n?n&&(i.agent_plan_id=n):n=lk;let s=await nl.query(i);if(console.log("agent users",s),s&&!s.error&&("users"===l?(lr(s.results),lu(s)):"emails"===l?(lg(s.results),lm(s)):(lr(s.results),lu(s)),lO((0,ep.SO)(lE,"users",iy))),e&&s.error){let e=(0,eo.HH)(s.error,e9("agentDetail.user_error"));alert(e)}"users"===l?ld(!1):"emails"===l?lp(!1):ld(!1)},getAgentRealUsers=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return getAgentUsers(e,n,t,"users")},getAgentEmails=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return getAgentUsers(e,n,t,"emails")};(0,es.useEffect)(()=>{nr&&!e.doNotFetch&&(ts(null==nr?void 0:nr.plans),tK((null==nr?void 0:nr.custom_data)?JSON.parse(nr.custom_data):{}),getAgentConvos(),getAgentMetrics(),getAgentRealUsers(),getAgentEmails(),getAgentIntegrations(),getAgentFormResponses(),getFinetuneJobs());let n=null==nr?void 0:nr.file_mapping;if(console.log("agent file mappings",n),n){let e=JSON.parse(n),t=Object.keys(e).map(n=>(console.log(n),{...e[n],fileKey:n}));console.log("computed file arr",t),n5(t)}},[nr]);let getAgentIntegrations=async()=>{let e=await ni.query({agent_id:tl});console.log(e),e&&!e.error&&lN(e.results)},getFinetuneJobs=async()=>{let e=await na.query({agent_id:tl});
1console.log("finetune jobs are ",e),e&&!e.error&&it(e.results)};(0,es.useEffect)(()=>{tY?(console.log("selected conversation is",tY),t0[tY.id]||(console.log("fetching new selected conversation"),fetchMessages(tY))):(lK(null),lq(!1))},[tY]),(0,es.useEffect)(()=>{e.agent&&(console.log("AgentDetail -- detected changes in prop.agent"),manageAgent(e.agent,!1),tt(e.agent),no(e.agent))},[e.agent]);let fetchMessages=async function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;lz(!0);let t=await ne.nonStandard("GET","convo_messages",null,{thread_id:e.thread_id,start:n,limit:10,agent_id:tl});if(console.log("messages are ",t),t&&!t.error){let l={...t0};l[e.thread_id]=t,t1(l);let i=t.messages;if(console.log(t4),n>0){let n=t4[e.thread_id];console.log("exsiting messages are.",n),i=[...n,...i]}t2((0,ep.SO)(t4,e.thread_id,i))}lz(!1)},manageAgent=function(e){var n,t,l,i,s,a;let r=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(console.log("manage agent"),console.log(e),nU(null==e?void 0:e.name),tw(null==e?void 0:e.native_rag),nM(null==e?void 0:e.allow_file_uploads),e.style_json){let n=JSON.parse(e.style_json);nT(n)}nP(null==e?void 0:e.avatar),nE(null==e?void 0:e.avatar_url),nZ(null==e?void 0:e.slug),e.gpt_id&&tu("https://chat.openai.com/g/".concat(e.gpt_id)),tg(null==e?void 0:e.fully_hosted),nH(null==e?void 0:e.description),nL(null==e?void 0:e.assistant_id),n3(null==e?void 0:e.instructions),tS(null==e?void 0:e.welcome_message),ic(null!==(i=null==e?void 0:null===(n=e.json_data)||void 0===n?void 0:n.prompt_token_limit)&&void 0!==i?i:""),ih(null!==(s=null==e?void 0:null===(t=e.json_data)||void 0===t?void 0:t.completion_token_limit)&&void 0!==s?s:""),ix(null!==(a=null==e?void 0:null===(l=e.json_data)||void 0===l?void 0:l.agentic_enabled)&&void 0!==a&&a),r&&ny(!0)},saveAgent=async()=>{(0,ep.if)("CustomizeProduct",{},e.user);let n=Date.now();nQ(!0),console.log(n6);let t=new FormData;t.append("name",null!=nI?nI:nR),t.append("slug",nR),t.append("description",nV),t.append("assistant_id",nK),t.append("fully_hosted",null==th?void 0:th.toString()),t.append("instructions",n2),t.append("model_name",ty),t.append("welcome_message",t_),t.append("allow_file_uploads",null==nO?void 0:nO.toString()),t.append("native_rag",null==tC?void 0:tC.toString()),t.append("publicity",nB);let l={...tH};l.links=lQ,l.editor_type=l5;let i={...tL};if(i.web_links=im,void 0!==tj&&(i.prevent_hallucination=tj),void 0!==tv&&(i.allow_prefilled_responses=tv),""!==id?i.prompt_token_limit=parseInt(id)||null:i.prompt_token_limit=null,""!==iu?i.completion_token_limit=parseInt(iu)||null:i.completion_token_limit=null,i.agentic_enabled=ig,!tX||(null==nr?void 0:nr.landing_page_data)||t.append("landing_page_data",JSON.stringify({})),(null==nr?void 0:nr.landing_page_data)&&!tX&&t.append("landing_page_data",null),t.append("interview_rubric",tQ),t.append("custom_data",JSON.stringify(l)),t.append("allow_email_signup",tP),t.append("temperature",(is/100).toString()),t.append("top_p",(ir/100).toString()),t.append("gpt_id",getGptId()),t.append("allow_install",null==lU?void 0:lU.toString()),t.append("json_data",JSON.stringify(i)),tl||t.append("interface_type",iU),e.onPreProcessAgentSave&&(t=e.onPreProcessAgentSave(t)),nF){let{url:n,relativePath:l}=await (0,ep.Xs)(nF,e.user.id,nd);t.append("avatar_url",n)}let s={},a=[];console.log("agent files are",n6);let r=tC&&!0;for(var o of n6)if(o.fileKey)s[o.fileKey]=o;else if(r){let n=(0,ep.Xs)(o,e.user.id,nd);a.push(n)}else t.append("file_".concat(o.name),o);if(a.length>0){console.log("awaiting remote files");let e=await Promise.all(a);console.log("finished upload responses",e),a=e}(Object.keys(s).length>0||(null==nr?void 0:nr.file_mapping))&&t.append("file_mapping",JSON.stringify(s)),console.log("save agent body",t);var d=null;tl?d=await nD.genericNoType("PATCH",tl,t):(d=await nD.genericCreate(t),nJ&&await bulkCreateAgentPlans(nJ,d.id));let c=d&&!d.error;if(r&&a.length>0&&c){lI(!0);let e=d.id,n=await nD.nonStandard("POST","".concat(e,"/ingest_url"),{file_data:a});if(console.log(n),lI(!1),n&&!n.error)showSuccessToast(e9("agentDetail.file_success"));else{let e=(0,eo.HH)(n.error,e9("agentDetail.file_error"));alert(e)}}let u=Date.now();if(console.log("Save agent took ".concat(u-n," ms")),console.log(d),d&&!d.error)showSuccessToast(e9("agentDetail.toast_save")),e.onPostProcessAgentSave?e.onPostProcessAgentSave(d,!tl):nr&&e.refreshAgent();else{let e=(0,eo.HH)(d.error,e9("agentDetail.update_error"));e=e.replace("slug","agent handle"),alert(e)}
1nQ(!1)},showSuccessToast=e=>{nx({position:"top",title:e,status:"success",duration:2e3})},deleteAgent=async()=>{n0(!0);let e=await ne.delete(tl);if(console.log(e),e&&!e.error)showSuccessToast("Agent deleted"),window.location.href="/workspace";else{let n=(0,eo.HH)(e.error,e9("agentDetail.delete_error"));alert(n)}n0(!1)},handleOnboardPress=async()=>{let e=await nn.nonStandard("GET","onboard_stripe",null,null);if(console.log(e),e&&!e.error){let n=e.url;window.location.href=n}else alert(e9("agentDetail.retry"));td(!1)},handleFileOnChage=async e=>{console.log("FILES ON FILE ON CHANGE"),console.log(e);let n=[...n6,...e];n5(n)},handleAgentFileDelete=async e=>{let n=[...n6],t=n.indexOf(e);t>-1&&n.splice(t,1),n5(n)},onDeleteAgentPlan=async e=>{if(console.log("DELETE AGENT PLAN",e),(null==e?void 0:e.id)&&(null==e?void 0:e.id)!==-1){let n=await nt.delete(e.id);if(!n||n.error){let e=(0,eo.HH)(n.error,e9("agentDetail.plan_error"));alert(e);return}}var n=[...ti];let t={};for(var l of n)t[l.name]=l;console.log("Delete plan withn name",e.name),console.log(t),delete t[e.name],console.log(t),console.log(n=Object.values(t)),showSuccessToast(e9("agentDetail.deleted")),ts(n);let i={...tx};i[tl]=n,tp(i)};function maybeHandleChargesNotSetup(e){let n=!(arguments.length>1)||void 0===arguments[1]||arguments[1],t=(0,eo.HH)(e.error,e9("agentDetail.update_error"));(t.includes(e9("agentDetail.charges"))||t.includes("No Stripe account found"))&&n?td(!0):alert(t)}function handleAvatarFileSelected(e){nP(e[0]),nE(URL.createObjectURL(e[0]))}function hasAgentSku(n){return(0,ep.MV)(e.user.skus,n)}async function refreshAgent(){let e=await ne.getById(tl,{expansions:["skus"]});if(e&&!e.error)no(e);else{let n=(0,eo.HH)(e.error,e9("agentDetail.update_error"));return n}}let onPaymentAction=async e=>{if(e.id&&-1!==e.id){console.log("UPDATING PLANS");let n=await nt.update(e.id,e);if(!n||n.error){let e=(0,eo.HH)(n.error,e9("agentDetail.fail_plan"));alert(e);return}showSuccessToast(e9("agentDetail.succ_plan"))}else if(tl){console.log("CREATING PLAN",e);let n=await nt.create({agent:tl,...e});console.log("agent plans resp",n),n&&!n.error?(showSuccessToast(e9("agentDetail.created_plan")),refreshAgent()):maybeHandleChargesNotSetup(n)}else{let n=[...nJ],t={...e,id:-1};console.log("plan copy is ",t),n.push(t),nX(n),ts(n)}},bulkCreateAgentPlans=async(e,n)=>{let t=e.map(e=>nt.create({agent:n,...e})),l=await Promise.all(t);var i=null;for(var s of l)if(console.log(s),!s||s.error){let e=(0,eo.HH)(s.error,e9("agentDetail.update_error"));e.includes(e9("agentDetail.charges"))&&(i=e9("agentDetail.error_to_show")),nx({title:e9("agentDetail.plan_create_fail"),status:"error"})}i&&alert(i)},isManagedByMarketplaceCreator=()=>{var e;return(null==nr?void 0:nr.parent_data)&&(null==nr?void 0:null===(e=nr.parent_data)||void 0===e?void 0:e.marketplace_setting)!=="transparent"},getManagedByOriginalCreatorView=()=>(0,l.jsxs)(o.b,{status:"info",mt:4,children:[(0,l.jsx)(d.z,{}),(0,l.jsx)(c.X,{children:"This agent setting is managed by the original creator."})]}),handleSlugInput=e=>{(null!==/^[a-zA-Z0-9_-]+$/.exec(e)||""===e)&&nZ(e.toLowerCase())},handleConversationClick=e=>{console.log(history),window.history.pushState({convo:e},""),window.scrollTo(0,0),t$(e)},getGptId=()=>{if(console.log("selected agent_gpt id",null==tn?void 0:tn.gpt_id),null==tn?void 0:tn.gpt_id)return tn.gpt_id;let e=/g-\w+/.exec(tc);return e?e[0]:null},saveStyleJson=async()=>{nQ(!0);let e=await ne.update(tl,{style_json:JSON.stringify(nk)});if(console.log(e),e&&!e.error)showSuccessToast("Agent style saved");else{let n=(0,eo.HH)(e.error,e9("agentDetail.save_error"));alert(n)}nQ(!1)},handlePlanAdd=()=>{ny(!0),te(1),n4(!1)},handleAgentModelChange=n=>{var t,l,i;if(n==nA){if((0,ep.MV)(null===(t=e.user)||void 0===t?void 0:t.skus,"finetune"))iS(!0);else{alert(e9("agentDetail.alert_plan"));return}}else if(n.includes("gpt-4-")){if(!(0,ep.MV)(null===(l=e.user)||void 0===l?void 0:l.skus,"gpt-4")){alert(e9("agentDetail.alert_plan"));return}}else if(!(0,ep.MV)(null===(i=e.user)||void 0===i?void 0:i.skus,n)){alert(e9("agentDetail.alert_plan"));return}tb(n)},fileNeedsReupload=e=>{if(e.v2&&tC||e.v3&&!tC)return!0},handleIntegrationSave=async n=>{n.user=e.user.id;let t=lP.find(e=>e.type==n.type);if(t&&(n.id=t.id),n.id){let e=await ni.update(n.id,n);if(!e||e.error){let n=(0,eo.HH)(e.error,e9("agentDetail.integrate_error"));alert(n)}else{showSuccessToast("Integration updated");let e=[...lP],t=e.findIndex(e=>e.id==n.id);e[t]=n,n4(!1),lN(e)}}else{let e=await ni.create(n);if(!e||e.error){let n=(0,eo.HH)(e.error,e9("agentDetail.integrate_fail"));alert(n)}else{showSuccessToast(e9("agentDetail.integration_created"));let n=[...lP];n.push(e),lN(n),n4(!1)}}},handleViewWordConvos=e=>{l1(e),te(5),getAgentConvos(0,e)},handleCreateLink=e=>{let n=[...lQ];n.push({title:"",type:e,value:""}),lJ(n)},updateLink=(e,n,t)=>{let l=[...lQ];l[e][n]=t,lJ(l)},createFineTuneJob=async e=>{e.agent=tl;let n=await na.create(e);if(n&&!n.error)showSuccessToast("Fine tune job created"),getFinetuneJobs();else{let e=(0,eo.HH)(n.error,"Sorry, something went wrong");alert(e)}},deleteFinetuneJob=async e=>{let n=await na.delete(e.uuid);if(n&&!n.error)showSuccessToast("Fine tune job deleted"),getFinetuneJobs();else{let e=(0,eo.HH)(n.error,"Sorry, something went wrong");alert(e)}},downloadAllAgentUsers=async()=>{lV(!0);let e=await nl.nonStandard("GET","download_all",null,{agent_id:tl});if(e&&!e.error){let n=e.map(e=>{var n;return{email:e.email,plan_name:null!==(n=e.plan_name)&&void 0!==n?n:"Free"}});lR(n)}else{let n=(0,eo.HH)(e.error,e9("agentDetail.download_fail"));alert(n)}lV(!1)},exportAllMessages=async()=>{l2(!0);let e=await ne.nonStandard("POST","download_pin",{agent_id:tl});if(console.log(e),!e||e.error){let n=(0,eo.HH)(e.error,"Sorry, something went wrong");alert(n)}let n=e.pin,t=new eW.Z("".concat(i.ZP.getEnvUrl(),"/agent/downloads/?pin=").concat(n));try{let e=await t.runUntilCompletion(),n=e.map(e=>({...e,message:e.message?e.message.replace(/"/g,'""'):e.message}));l6(n)}catch(e){alert("Sorry, something went wrong")}l2(!1)},checkHandleAvalability=async()=>
1{if(!nR){alert(e9("agentDetail.handle"));return}tV(void 0);let e=await ne.nonStandard("GET","".concat(nR,"/slug"));if(e&&!e.error)tV(!1);else{let n=(0,eo.HH)(e.error,e9("agentDetail.wrong_handle"));n.includes("does not exist")?tV(!0):(alert(e9("agentDetail.err")),tV(null))}},getCurrentStartNumber=e=>{var n;let t=null!==(n=lE[e])&&void 0!==n?n:0;return t},refreshFinetuneJob=async e=>{let n=await na.nonStandard("GET","".concat(e.uuid,"/refresh"));if(n&&!n.error)showSuccessToast("Fine tune job refreshed"),getFinetuneJobs();else{let e=(0,eo.HH)(n.error,"Sorry, something went wrong");alert(e)}},addToFineTuneQueue=async e=>{console.log("add fine tune message ot queue",e);let n={message_id:e._id,agent_id:tl},t=await na.nonStandard("POST","add_message",n);if(t&&!t.error)return showSuccessToast("Message added to fine tune queue"),getFinetuneJobs(),!0;{let e=(0,eo.HH)(t.error,"Sorry, something went wrong");return alert(e),!1}},onSaveAgentUser=async e=>{let n=await nl.update(e.id,e);if(n&&!n.error)showSuccessToast("Agent user has been updated.");else{let e=(0,eo.HH)(n.error,"Sorry, something went wrong");alert(e)}lS(!1),await getAgentRealUsers(),await getAgentEmails()},handleSelectUserAgentFilterPlan=e=>{console.log("Updating selected agent user filter plan",e),"All plans"==e?(lD(null),0===lv?getAgentRealUsers(!0,null,0):getAgentEmails(!0,null,0)):(lD(e),0===lv?getAgentRealUsers(!0,e,0):getAgentEmails(!0,e,0))},handleManageAgentUser=e=>{lb(e),lS(!0)},runFinetuneJob=async e=>{let n=await na.nonStandard("POST","".concat(e.uuid,"/run"));if(n&&!n.error)showSuccessToast("Fine tune job started"),getFinetuneJobs();else{let e=(0,eo.HH)(n.error,"Sorry, something went wrong");alert(e)}},triggerNextStep=e=>{(0,nm.T)().track("Next step",{step:e.text}),e.onClick&&e.onClick(),tG(!1)},handleDefaultPlanChange=async(e,n)=>{var t={...tH};t=n?(0,ep.SO)(tH,"default_plan_id",e.id):(0,ep.SO)(tH,"default_plan_id",null);let l=await ne.update(tl,{custom_data:JSON.stringify(t)});if(console.log("update default plan resp",l),l&&!l.error)showSuccessToast("Default plan updated!"),tK(t);else{let e=(0,eo.HH)(l.error,"Sorry, something went wrong");alert(e)}},getAgentConvosView=()=>(0,l.jsxs)(l.Fragment,{children:[t9&&(0,l.jsx)(u.$,{}),(0,l.jsx)(em.Z,{headers:[{name:"Thread id"},{name:"Created at"}],children:t3&&t5.map(e=>(0,l.jsxs)(h.Tr,{cursor:"pointer",onClick:()=>handleConversationClick(e),children:[(0,l.jsx)(g.Td,{children:(0,l.jsxs)(l.Fragment,{children:[e.initial_message&&(0,l.jsx)(eY.Z,{limit:60,fontSize:"lg",mb:2,children:e.initial_message}),(0,l.jsxs)(x.x,{fontSize:"sm",children:["Thread ",e.thread_id]}),e.user_updated_at&&(0,l.jsxs)(x.x,{fontSize:"xs",mt:1,children:[e9("agentDetail.last_active"),": ",eT()(e.user_updated_at).format("lll")]})]})}),(0,l.jsx)(g.Td,{fontSize:"sm",children:eT()(e.created_at).format("lll")})]},e.thread_id))}),(0,l.jsxs)(p.U,{children:[(null==t3?void 0:t3.has_more)&&(0,l.jsx)(j.z,{mt:3,onClick:()=>getAgentConvos(getCurrentStartNumber("conversations")+10),children:e9("agentDetail.more")}),(null==t3?void 0:t3.count)&&!lY&&(0,l.jsxs)(x.x,{mt:4,children:[null==t3?void 0:t3.count," conversation(s)"]})]})]}),handleThreadExportToCsv=async()=>{let e="".concat(i.ZP.getEnvUrl(),"/agent/downloads/?thread_id=").concat(tY.thread_id),n=new eW.Z(e);lq(!0);try{let e=await n.runUntilCompletion(),t=e.map(e=>({...e,message:e.message?e.message.replace(/"/g,'""'):e.message}));lK(t)}catch(e){alert(e9("agentDetail.csv_error"))}lq(!1)},iO="245px",iM=(0,l.jsxs)(m.K,{direction:["column","row"],spacing:4,w:"100%",children:[(0,l.jsx)(v.xu,{flex:"1",overflowY:nr?"auto":null,maxH:eB.tq||!nr?"100%":"calc(100vh - ".concat(iO,")"),children:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(m.K,{spacing:6,mb:6,children:["interview"!==e7&&(0,l.jsxs)(f.NI,{isRequired:!0,children:[(0,l.jsx)(_.l,{children:"Handle"}),(0,l.jsx)(S.I,{placeholder:"chatgpt...",value:nR,onChange:e=>handleSlugInput(e.target.value)}),(0,l.jsx)(f.Q6,{children:"Think of this like your GPT's twitter handle. Mu
1st be globally unique"}),null!=tZ&&nR&&(0,l.jsx)(f.Q6,{mt:2,color:!0===tZ?"green":"red",children:"Handle is ".concat(!0==tZ?"":"not"," available")}),!tn&&(0,l.jsx)(j.z,{mt:2,onClick:()=>checkHandleAvalability(),isLoading:void 0===tZ,children:"Check"})]}),!tn&&(0,l.jsx)(components_InterfaceTypeSelector,{value:iU,onChange:iF,hasVoiceSku:hasAgentSku("voice"),onUpgradeClick:()=>iN(!0)}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.avatar")}),(0,l.jsxs)(m.K,{children:[nN&&(0,l.jsx)(y.q,{size:"xl",src:nN}),(0,l.jsx)(p.U,{children:(0,l.jsx)(ev.Z,{accept:"image/*",onChange:e=>handleAvatarFileSelected(e)})})]})]}),(0,l.jsxs)(f.NI,{isRequired:!0,children:[(0,l.jsx)(_.l,{children:e9("agentDetail.name")}),(0,l.jsx)(S.I,{placeholder:"ChatGPT",value:nI,onChange:e=>nU(e.target.value)}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.display_user")})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.description")}),(0,l.jsx)(b.g,{placeholder:e9("agentDetail.description"),value:nV,onChange:e=>nH(e.target.value)}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.visible")})]}),(0,l.jsxs)(f.NI,{mt:4,isRequired:!0,children:[(0,l.jsx)(_.l,{children:e9("agentDetail.instruction")}),isManagedByMarketplaceCreator()?getManagedByOriginalCreatorView():(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(b.g,{placeholder:e9("agentDetail.instruction_placeholder"),value:n2,onChange:e=>n3(e.target.value)}),(0,l.jsxs)(f.Q6,{children:[e9("agentDetail.instruction_helper")," ",(0,l.jsx)(C.r,{href:"https://www.loom.com/share/e34d89f0093d4c818708032685c7cca9",target:"_blank",children:(0,l.jsx)("u",{children:e9("agentDetail.guide_link")})})]})]})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",id:"landing_page",isChecked:tX,onChange:e=>tB(e.target.checked)}),(0,l.jsx)(x.x,{children:"Create Landing page"})]}),(0,l.jsx)(f.Q6,{children:"This will create a beautiful editable landing page for your agent."})]}),(0,l.jsx)(nv.Z,{sku:"agentic_enabled",user:e.user,title:"Upgrade to access Agentic agents",subtitle:"Agentic Enabled is only supported on our Growth or custom plans. Please upgrade or contact us to learn more.",children:(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",id:"agenticEnabled",isChecked:ig,onChange:e=>ix(e.target.checked)}),(0,l.jsx)(x.x,{children:e9("agentDetail.work_with_agents")}),(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/collaborating-agents-and-agentic-workflows",target:"_blank",children:(0,l.jsx)(k.h,{variant:"link","aria-label":"Help",icon:(0,l.jsx)(nj.MXt,{})})})]}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.work_with_agents_helper")})]})}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.visibility")}),(0,l.jsx)(f.Q6,{children:e9("public"===nB?"agentDetail.public_agent_desc":"unlisted"===nB?"agentDetail.unlisted_agent_desc":"agentDetail.private_agent_desc")}),(0,l.jsxs)(ea.P,{mt:3,maxW:"200px",value:nB,onChange:e=>nW(e.target.value),children:[(0,l.jsx)("option",{value:"private",children:e9("agentDetail.private")}),(0,l.jsx)("option",{value:"unlisted",children:e9("agentDetail.unlisted")}),(0,l.jsx)("option",{value:"public",children:e9("agentDetail.public")})]})]})]}),(0,l.jsxs)(m.K,{spacing:2,mt:4,mb:4,children:[(0,l.jsx)(D.X,{size:"md",children:"Knowledge base"}),(0,l.jsx)(_.l,{children:e9("agentDetail.upload_files")}),(0,l.jsx)(p.U,{children:(0,l.jsx)(ev.Z,{checkFileSuffix:!0,maxFileSizeMb:tC?35:null,multiple:!1,isLoading:n8,label:e9("agentDetail.gpt_upload"),accept:(0,ep.sV)((null===(e8=e.agent)||void 0===e8?void 0:e8.native_rag)||tC),onChange:handleFileOnChage})}),(0,l.jsx)(v.xu,{mt:2,children:n6&&n6.map(e=>(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsxs)(m.K,{children:[fileNeedsReupload(e)&&(0,l.jsx)(p.U,{children:(0,l.jsx)(A.C,{colorScheme:"red",children:e9("agentDetail.need_upload")})}),(0,l.jsx)(x.x,{children:e.name})]}),(0,l.jsx)(j.z,{size:"sm",colorScheme:"red",variant:"link",onClick:()=>handleAgentFileDelete(e),children:e9("agentDetail.delete")})]},e.url))}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.provide_links")}),(0,l.jsx)(S.I,{placeholder:"https://example.com",value:ip,onChange:e=>ij(e.target.value)}),(0,l.jsx)(j.z,{mt:2,onClick:()=>{ip&&!im.includes(ip)&&(iv([...im,ip]),ij(""))},children:e9("agentDetail.add_link")}),im.length>0&&(0,l.jsx)(v.xu,{mt:2,children:im.map((e,n)=>(0,l.jsxs)(p.U,{justifyContent:"space-between",children:[(0,l.jsx)(x.x,{children:e}),(0,l.jsx)(j.z,{size:"sm",colorScheme:"red",variant:"link",onClick:()=>handleRemoveLink(n),children:e9("agentDetail.delete")})]},n))})]})]}),(0,l.jsxs)(f.NI,{mt:4,mb:4,children:[(0,l.jsx)(_.l,{children:e9("agentDetail.welcome")}),(0,l.jsx)(b.g,{size:"md",placeholder:e9("agentDetail.chatting"),value:t_,onChange:e=>tS(e.target.value)})]}),(0,l.jsx)(z.U,{allowToggle:!0,mt:8,defaultIndex:nr?0:null,children:(0,l.jsxs)(T.Q,{children:[(0,l.jsxs)(I.K,{children:[(0,l.jsx)(v.xu,{as:"span",children:(0,l.jsx)(D.X,{size:"md",children:"Advanced settings"})}),(0,l.jsx)(U.X,{})]}),(0,l.jsxs)(F.H,{children:[(0,l.jsx)(m.K,{direction:"column",mb:4,spacing:4,children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.model")}),!isManagedByMarketplaceCreator()&&(0,l.jsxs)(ea.P,{mt:3,maxW:"200px",value:ty,onChange:e=>handleAgentModelChange(e.target.value),children:[ty&&(0,l.jsx)("option",{children:ty}),nz.filter(e=>e!=ty).map(e=>(0,l.jsx)("option",{value:e,children:e},e))]}),isManagedByMarketplaceCreator()&&getManagedByOriginalCreatorView()]})}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.link")}),(0,l.jsxs)(f.Q6,{children:[e9("agentDetail.link_helper")," "]}),(0,l.jsx)(j.z,{mt:2,onClick:()=>handleCreateLink(""),children:e9("agentDetail.add_link")}),lQ.length>0&&(0,l.jsx)(m.K,{spacing:4,children:lQ.map((e,n)=>(0,l.jsx)(P.Z,{children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(m.K,{spacing:3,children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Link Type"}
1),(0,l.jsxs)(ea.P,{size:"sm",value:e.type,onChange:e=>updateLink(n,"type",e.target.value),children:[(0,l.jsx)("option",{value:"prompt",children:e9("agentDetail.prompt")}),(0,l.jsx)("option",{value:"website",children:e9("agentDetail.website")})]})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Title"}),(0,l.jsx)(S.I,{size:"sm",placeholder:e9("agentDetail.link_title"),value:e.title,onChange:e=>updateLink(n,"title",e.target.value)})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Value"}),(0,l.jsx)(S.I,{size:"sm",placeholder:e9("agentDetail.link_prompt"),value:e.value,onChange:e=>updateLink(n,"value",e.target.value)})]}),(0,l.jsx)(j.z,{size:"sm",colorScheme:"red",variant:"outline",onClick:()=>{let e=[...lQ];e.splice(n,1),lJ(e)},children:e9("agentDetail.clear")})]})})},n))})]}),(0,l.jsxs)(m.K,{direction:"column",mt:8,mb:8,alignItems:"flex-start",children:[(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{isDisabled:!hasAgentSku("prevent_halluc"),colorScheme:"green",id:"prevent_halluc",isChecked:tj,onChange:e=>tm(e.target.checked)}),(0,l.jsx)(x.x,{children:e9("agentDetail.prevent_hallucination")}),(0,l.jsx)(A.C,{colorScheme:"blue",children:"beta"})]}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.prevent_hallucination_helper")})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{isDisabled:!hasAgentSku("user_file_uploads"),colorScheme:"green",id:"allowUserFileUploads",isChecked:nO,onChange:e=>nM(e.target.checked)}),(0,l.jsx)(x.x,{children:e9("agentDetail.allow_upload")})]}),(0,l.jsxs)(m.K,{children:[(0,l.jsx)(f.Q6,{children:e9("agentDetail.allow_pro")}),nO&&(0,l.jsxs)(m.K,{children:[(0,l.jsx)(x.x,{fontSize:"sm",children:e9("agentDetail.files")}),(0,l.jsxs)(ea.P,{size:"sm",value:tH.use_vision?"images_and_documents":"documents",onChange:e=>tK((0,ep.SO)(tH,"use_vision","images_and_documents"==e.target.value)),children:[(0,l.jsx)("option",{value:"images_and_documents",children:e9("agentDetail.img_doc")}),(0,l.jsx)("option",{value:"documents",children:e9("agentDetail.doc")})]})]})]})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{isDisabled:!hasAgentSku("email_gate"),colorScheme:"green",id:"email_gate",isChecked:tH.email_gate,onChange:e=>tK((0,ep.SO)(tH,"email_gate",!tH.email_gate))}),(0,l.jsx)(x.x,{children:e9("agentDetail.req_email")})]}),(0,l.jsx)(m.K,{children:(0,l.jsx)(f.Q6,{children:e9("agentDetail.req_email_helper")})}),tH.email_gate&&(0,l.jsxs)(m.K,{mt:2,mb:4,children:[(0,l.jsx)(x.x,{fontSize:"sm",children:e9("agentDetail.email_sign_in_type")}),(0,l.jsxs)(ea.P,{size:"sm",value:tH.email_gate_type,onChange:e=>tK((0,ep.SO)(tH,"email_gate_type",e.target.value)),children:[(0,l.jsx)("option",{value:"raw",children:"Entered text email"}),(0,l.jsx)("option",{value:"gmail",children:"Gmail/Google sign in"})]}),(0,l.jsx)(f.Q6,{mt:0,fontSize:"xs",children:e9("agentDetail.email_sign_in_type_helper")})]}),tH.email_gate&&(0,l.jsxs)(m.K,{mt:2,children:[(0,l.jsx)(x.x,{fontSize:"sm",children:e9("agentDetail.email_gate_label")}),(0,l.jsx)(b.g,{size:"md",placeholder:e9("agentDetail.email_gate_placeholder"),value:tH.email_gate_copy,onChange:e=>tK((0,ep.SO)(tH,"email_gate_copy",e.target.value))})]})]})]}),(0,l.jsxs)(m.K,{direction:"column",mt:6,mb:6,children:[(null==nr?void 0:nr.native_rag)&&(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",id:"allowUserFileUploads",isChecked:tC,onChange:e=>tw(e.target.checked)}),(0,l.jsx)(x.x,{children:e9("agentDetail.use")})]}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.v2agent")}),tn&&(0,l.jsx)(f.Q6,{fontSize:"xs",children:e9("agentDetail.history")})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Temperature"}),(0,l.jsx)(f.Q6,{children:"The higher this value, the more random responses will be."}),!isManagedByMarketplaceCreator()&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.x,{mt:4,children:(is/100).toString()}),(0,l.jsxs)(E.iR,{"aria-label":"slider-ex-1",mt:4,value:is,defaultValue:100,max:200,min:0,onChange:e=>ia(e),children:[(0,l.jsx)(E.Uj,{children:(0,l.jsx)(E.Ms,{})}),(0,l.jsx)(E.gs,{})]})]}),isManagedByMarketplaceCreator()&&getManagedByOriginalCreatorView()]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Top P"}),(0,l.jsx)(f.Q6,{children:"Controls diversity. Lower values result in more focused responses."}),!isManagedByMarketplaceCreator()&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.x,{mt:4,children:(ir/100).toString()}),(0,l.jsxs)(E.iR,{"aria-label":"slider-ex-2",mt:4,value:ir,defaultValue:100,max:100,min:0,onChange:e=>io(e),children:[(0,l.jsx)(E.Uj,{children:(0,l.jsx)(E.Ms,{})}),(0,l.jsx)(E.gs,{})]})]}),isManagedByMarketplaceCreator()&&getManagedByOriginalCreatorView()]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.prompt_token_limit")}),(0,l.jsx)(S.I,{type:"number",placeholder:"e.g., 4000",value:id,onChange:e=>ic(e.target.value)}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.prompt_token_limit_helper")})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.completion_token_limit")}),(0,l.jsx)(S.I,{type:"number",placeholder:"e.g., 1000",value:iu,onChange:e=>ih(e.target.value)}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.completion_token_limit_helper")})]})]}),(0,l.jsxs)(m.K,{direction:"column",children:[(0,l.jsxs)(f.NI,{mt:6,mb:6,children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",id:"allowUserFileUploads",isChecked:tP,onChange:e=>tN(e.target.checked)}),(0,l.jsx)(x.x,{children:e9("agentDetail.collect")})]}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.add")})]}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",id:"allowUserFileUploads",isChecked:tv,onChange:e=>tf(e.target.checked)}),(0,l.jsx)(x.x,{children:"Provide response choices for user"})]}),(0,l.jsx)(f.Q6,{children:"This will provide the user with choices to 
1select when the agent is responding."})]}),(0,l.jsxs)(f.NI,{mt:6,mb:6,children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{isDisabled:!hasAgentSku("install"),colorScheme:"green",id:"allowUserFileUploads",isChecked:lU,onChange:e=>lF(e.target.checked)}),(0,l.jsx)(x.x,{children:e9("agentDetail.mobile_download")})]}),(0,l.jsx)(f.Q6,{children:e9("agentDetail.device")})]})]}),tP&&(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:e9("agentDetail.email_signup")}),(0,l.jsx)(b.g,{size:"md",placeholder:e9("agentDetail.awesome_email"),value:tH.email_signup_copy,onChange:e=>tK((0,ep.SO)(tH,"email_signup_copy",e.target.value))})]})]})]})}),(0,ep.AR)(e.user,"custom")&&(0,l.jsxs)(m.K,{mt:6,mb:6,children:[(0,l.jsx)(x.x,{fontSize:"lg",fontWeight:"bold",children:"Custom plan"}),(0,l.jsxs)(f.NI,{children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(w.r,{colorScheme:"green",isChecked:tL.insert_file_content,onChange:e=>tq((0,ep.SO)(tL,"insert_file_content",!tL.insert_file_content))}),(0,l.jsx)(x.x,{children:"Insert user file content"})]}),(0,l.jsx)(f.Q6,{children:"Enabling this will have all user file uploaded content inserted into the chat history. This will lead to higher message usage corresponding with the amount of text in the files. Only supprots pdf, docx, and txt files."})]})]}),(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(p.U,{mt:4,justifyContent:"space-between",w:"100%",children:[(0,l.jsx)(p.U,{children:tl&&(0,l.jsxs)(p.U,{children:[(0,l.jsxs)(O.J,{children:[(0,l.jsx)(M.x,{children:(0,l.jsx)(j.z,{isDisabled:!1,colorScheme:"red",variant:"outline",children:e9("agentDetail.delete_agent")})}),(0,l.jsxs)(R.y,{children:[(0,l.jsx)(Z.Q,{}),(0,l.jsx)(V.u,{}),(0,l.jsx)(H.Y,{children:e9("agentDetail.confirmation")}),(0,l.jsx)(K.b,{children:e9("agentDetail.undone")}),(0,l.jsx)(L.D,{display:"flex",justifyContent:"flex-end",children:(0,l.jsx)(q.h,{size:"sm",children:(0,l.jsx)(j.z,{colorScheme:"red",isDisabled:!1,onClick:()=>deleteAgent(),isLoading:n$,children:e9("agentDetail.delete")})})})]})]}),(0,l.jsx)(j.z,{colorScheme:"blue",variant:"outline",onClick:()=>{nf(!0)},isDisabled:!1,children:"Transfer Agent"})]})}),!e.hideTabs&&(0,l.jsxs)(p.U,{children:[(0,l.jsx)(j.z,{colorScheme:"blue",isDisabled:!1,onClick:()=>saveAgent(),isLoading:nq,children:e9("agentDetail.save")}),(0,l.jsx)(j.z,{onClick:()=>e.onCancel(),children:e9("agentDetail.cancel")})]})]})})]})}),!eB.tq&&nr&&(0,l.jsx)(v.xu,{flex:"2",h:"calc(100vh - ".concat(iO,")"),border:"1px solid lightgray",children:(0,l.jsx)("iframe",{src:"/chat/".concat(null==nr?void 0:nr.slug,"?workspace=true"),width:"100%",height:"100%",frameBorder:"",title:"Agent Chat"},ik)})]});return(0,l.jsxs)(l.Fragment,{children:[e.agent&&!e.hideTabs&&(0,l.jsxs)(m.K,{mb:6,mt:6,children:[(0,l.jsx)(p.U,{justifyContent:"space-between",children:(0,l.jsxs)(p.U,{mt:2,justifyContent:"space-between",children:[(0,l.jsx)(C.r,{href:(null==nr?void 0:nr.fully_hosted)?"/chat/".concat(null==nr?void 0:nr.slug):"https://chat.openai.com/g/".concat(null==nr?void 0:nr.gpt_id),target:"_blank",children:(0,l.jsx)(j.z,{variant:"ghost",children:(0,l.jsx)("u",{children:nG[nr.id]?"agentDetail.visit":"agentDetail.preview"})})}),(0,l.jsx)(j.z,{variant:"outline",onClick:()=>{n4(!0)},colorScheme:"blue",children:"agentDetail.integrations"})]})}),(null==nr?void 0:nr.ingesting_files_at)&&(0,l.jsx)(p.U,{mt:2,children:(0,l.jsx)(j.z,{size:"sm",colorScheme:"yellow",variant:"outline",isLoading:!0,loadingText:e9("agentDetail.inj")})})]}),(0,l.jsxs)(Q.m,{variant:"soft-rounded",index:n7,minW:"100%",onChange:e=>te(e),children:[!e.hideTabs&&nr&&(0,l.jsxs)(J.t,{children:[nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.analytics")}),(0,l.jsx)(X.O,{children:e9("agentDetail.details")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.users")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.payments")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.styling")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.conversations")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.actions")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.domains")}),nr&&(0,l.jsx)(X.O,{children:e9("agentDetail.approvals")}),nr&&(0,ep.AR)(e.user,"finetune")&&(0,l.jsx)(X.O,{children:e9("agentDetail.training")})]}),(0,l.jsxs)(B.n,{minW:"100%",children:[nr&&(0,l.jsxs)(W.x,{w:"100%",children:[tk&&(0,l.jsx)(u.$,{}),tA&&e.hideTabs&&(0,l.jsxs)(m.K,{mb:4,direction:eB.tq?"column":"row",justifyContent:"space-between",children:[(0,l.jsx)(D.X,{children:e9("agentDetail.dashboard")}),(0,l.jsxs)(p.U,{mt:2,children:[(0,l.jsx)(C.r,{href:"/chat/".concat(e.agent.slug),children:(0,l.jsx)(j.z,{variant:"ghost",children:e9("agentDetail.visit")})}),(0,l.jsx)(j.z,{colorScheme:"blue",variant:"outline",onClick:()=>n4(!0),children:e9("agentDetail.connect")})]})]}),tT&&(0,l.jsxs)(v.xu,{mb:6,children:[(0,l.jsx)(p.U,{justify:"flex-start",align:"center",mb:4,children:(0,l.jsx)(ea.P,{maxW:"200px",value:tU,onChange:e=>tF(Number(e.target.value)),children:ep.BS.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))})}),(0,l.jsxs)(p.U,{spacing:4,children:[(0,l.jsx)(P.Z,{w:"200px",children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(G.k,{children:[(0,l.jsx)(Y.d,{children:"Total Messages"}),(0,l.jsx)($.J,{children:tT.reduce((e,n)=>e+(n.messages||0),0)}),(0,l.jsx)(ee.v,{children:(0,ep.st)(tU)})]})})}),(0,l.jsx)(P.Z,{w:"200px",children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(G.k,{children:[(0,l.jsx)(Y.d,{children:"Total Chats"}),(0,l.jsx)($.J,{children:tT.reduce((e,n)=>e+(n.threads||0),0)}),(0,l.jsx)(ee.v,{children:(0,ep.st)(tU)})]})})}),(0,l.jsx)(P.Z,{w:"200px",children:(0,l.jsx)(N.e,{children:(0,l.jsxs)(G.k,{children:[(0,l.jsx)(Y.d,{children:"Total Credits"}),(0,l.jsx)($.J,{children:tT.reduce((e,n)=>e+(n.creditUsage||0),0)}),(0,l.jsx)(ee.v,{children:(0,ep.st)(tU)})]})})})]})]}),(0,l.jsx)(P.Z,{children:(0,l.jsxs)(N.e,{children:[(0,l.jsxs)(G.k,{children:[(0,l.jsx)(Y.d,{children:e9("agentDetail.usage")}),(0,l.jsx)(ee.v,{children:(0,ep.st)(tU)})]}),(0,l.jsx)(eI.h,{height:300,width:"100%",children:(0,l.jsxs)(eU.w,{width:800,height:300,data:tT,margin:{top:0,right:0,left:0,bottom:0},children:[(0,l.jsx)(eF.q,{strokeDasharray:"1 3"}),(0,l.jsx)(eP.K,{dataKey:"date",padding:{right:20}}),(0,l.jsx)(eN.B,{width:0,padding:{top:10,bottom:20}}),(0,l.jsx)(eE.u,{}),(0,l.jsx)(eO.D,{}),(0,l.jsx)(eM.x,{dot:!1,type:"monotone",dataKey:"messages",stroke:"green"}),(0,l.jsx)(eM.x,{dot:!1,type:"monotone",dataKey:"threads",stroke:"#8884d8"}),(0,l.jsx)(eM.x,{dot:!1,type:"monotone",dataKey:"creditUsage",stroke:"red"})]})})]})}),(0,l.jsx)(P.Z,{w:"50%",mt:4,children:(0,l.jsxs)(N.e,{children:[(0,l.jsxs)(G.k,{mb:4,children:[(0,l.jsx)(Y.d,{children:e9("agentDetail.top")}),(0,l.jsx)(ee.v,{children:e9("agentDetail.last_30")})]}),(0,l.jsx)(em.Z,{headers:[{name:"Word"},{name:"count"}],children:tA&&tA.most_used_words.map(e=>(0,l.jsxs)(h.Tr,{children:[(0,l.jsxs)(g.Td,{children:[(0,l.jsx)(x.x,{children:e._id})," ",(0,l.jsx)(j.z,{size:"sm",variant:"link",flexGrow:0,onClick:()=>handleViewWordConvos(e._id),children:"View"})]}),(0,l.jsx)(g.Td,{children:e.count})]},e.date))})]})})]}),(0,l.jsxs)(W.x,{p:0,children:[nr&&(0,l.jsxs)(Q.m,{mt:0,children:[(0,l.jsxs)(J.t,{children:[(0,l.jsx)(X.O,{children:"Agent"}),(0,l.jsx)(X.O,{children:"Data & Storage"}),(0,l.jsx)(X.O,{children:"Marketplace"})]}),(0,l.jsxs)(B.n,{children:[(0,l.jsxs)(W.x,{mt:0,children:[e.hideTabs&&(0,l.jsxs)(m.K,{mb:4,justifyContent:"space-between",alignItems:["flex-start","center"],direction:["column","row"],children:[(0,l.jsxs)(p.U,{children:[(0,l.jsx)(D.X,{children:e9("agentDetail.agent_details")}),(null==nr?void 0:null===(ex=nr.parent_data)||void 0===ex?void 0:ex.marketplace_setting)&&(0,l.jsx)("a",{href:"/marketplace/".concat(nr.parent_data.slug),children:(0,l.jsx)(j.z,{colorScheme:"green",variant:"outline",rounded:"full",children:"Marketplace Agent"})})]}),(0,l.jsxs)(p.U,{children:[i.ZP.isNotProd()&&(0,l.jsx)(C.r,{href:"/builder?agent_id=".concat(nr.id),target:"_blank",children:(0,l.jsx)(j.z,{leftIcon:(0,l.jsx)(nj.iNY,{}),colorScheme:"purple",variant:"outline",children:"Edit with Builder"})}),(0,l.jsx)(j.z,{isDisabled:!1,colorScheme:"blue",onClick:saveAgent,isLoading:nq,children:nr?e9("agentDetail.save_changes"):e9("agentDetail.create")})]})]}),iM]}),(0,l.jsx)(W.x,{children:(0,l.jsx)(v.xu,{mt:4,children:(0,l.jsx)(AgentDataStorageView,{agent:nr,user:e.user,agentCustomData:tH,setAgentCustomData:tK,agentApi:ne})})}),(0,l.jsx)(W.x,{children:(0,l.jsx)(v.xu,{mt:4,children:(0,l.jsx)(AgentMarketplaceView,{agent:nr,agentApi:ne,onSuccess:showSuccessToast,onUpdate:e.refreshAgent})})})]})]}),!nr&&(0,l.jsxs)(l.Fragment,{children:[e.hideTabs&&(0,l.jsxs)(m.K,{mb:6,justifyContent:"space-between",alignItems:["flex-start","center"],direction:["column","row"],children:[(0,l.jsx)(v.xu,{children:(0,l.jsx)(D.X,{children:e9("agentDetail.agent_details")})}
1),(0,l.jsxs)(p.U,{children:["interview"!==e7&&(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/agent-properties",target:"_blank",children:(0,l.jsx)(j.z,{children:"View docs"})}),(0,l.jsx)(j.z,{isDisabled:!1,colorScheme:"blue",onClick:saveAgent,isLoading:nq,children:nr?e9("agentDetail.save_changes"):e9("agentDetail.create")})]})]}),iM]})]}),nr&&(0,l.jsx)(W.x,{children:(0,l.jsxs)(Q.m,{variant:"soft-rounded",index:lv,onChange:e=>lf(e),children:[(0,l.jsxs)(J.t,{children:[(0,l.jsx)(X.O,{children:e9("agentDetail.users_tab")}),(0,l.jsx)(X.O,{children:e9("agentDetail.emails_tab")})]}),(0,l.jsxs)(B.n,{children:[(0,l.jsx)(W.x,{children:(0,l.jsxs)(m.K,{children:[(0,l.jsx)(v.xu,{children:(0,l.jsxs)(m.K,{justifyContent:"space-between",direction:["column","row"],children:[(0,l.jsxs)(m.K,{children:[(0,l.jsx)(D.X,{fontWeight:"bold",children:e9("agentDetail.users_tab")}),(0,l.jsx)(x.x,{children:e9("agentDetail.users_tab_description")})]}),(0,l.jsxs)(p.U,{children:[(0,l.jsx)(j.z,{variant:"outline",colorScheme:"blue",onClick:()=>handleManageAgentUser(null),children:e9("agentDetail.create")}),!lM&&(0,l.jsx)(j.z,{variant:"outline",colorScheme:"blue",isLoading:lZ,onClick:downloadAllAgentUsers,children:e9("agentDetail.exp")}),lM&&(0,l.jsx)(eR.CSVLink,{data:lM,filename:"".concat(null==tn?void 0:tn.slug,"_users.csv"),children:(0,l.jsx)(j.z,{variant:"outline",colorScheme:"blue",children:e9("agentDetail.download")})})]})]})}),(0,l.jsx)(f.NI,{mb:2,children:(0,l.jsxs)(ea.P,{maxW:"200px",value:lk?null===(ej=ta[lk])||void 0===ej?void 0:ej.name:"All plans",onChange:e=>handleSelectUserAgentFilterPlan(e.target.value),children:[lk&&(0,l.jsx)("option",{value:lk,children:null===(ef=ta[lk])||void 0===ef?void 0:ef.name}),(0,l.jsx)("option",{value:"All plans",children:"All plans"}),ti.map(e=>(0,l.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,l.jsxs)(en.B,{mb:2,children:[(0,l.jsx)(S.I,{placeholder:"Search users by email...",value:lC,variant:"filled",onChange:e=>lw(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(getAgentRealUsers(!0,null,0),e.preventDefault())}}),(0,l.jsx)(et.xW,{children:(0,l.jsx)(j.z,{onClick:()=>getAgentRealUsers(!0,null,0),children:"Search"})})]}),lo&&(0,l.jsx)(u.$,{}),(0,l.jsx)(em.Z,{headers:[{name:"email"},{name:"plan"},{name:"Action"}],children:la&&la.map(e=>{var n,t,i,s,a,r;return(0,l.jsxs)(h.Tr,{children:[(0,l.jsx)(g.Td,{children:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.x,{children:null!==(a=null!==(s=e.email)&&void 0!==s?s:null===(n=e.customer_user_data)||void 0===n?void 0:n.email)&&void 0!==a?a:null===(t=e.user_data)||void 0===t?void 0:t.email}),e.canceled_at&&(0,l.jsx)(A.C,{mt:2,colorScheme:"red",children:e9("agentDetail.canceled")}),e.last_active_at&&(0,l.jsxs)(x.x,{fontSize:"sm",children:[e9("agentDetail.last_active"),": ",eT()(e.last_active_at).format("lll")]}),e.expires_at&&(0,l.jsxs)(x.x,{fontSize:"xs",children:["Expires ",eT()(e.expires_at).format("ll")]})]})}),(0,l.jsx)(g.Td,{children:(0,l.jsxs)(m.K,{direction:"row",spacing:2,children:[(0,l.jsx)(x.x,{children:null!==(r=e.plan_name)&&void 0!==r?r:e9("agentDetail.free")}),e.bundle&&(0,l.jsx)(p.U,{children:(0,l.jsx)(A.C,{mt:1,colorScheme:"green",children:e9("agentDetail.bundle")})}),(0,l.jsx)(A.C,{colorScheme:"blue",children:"User"})]})}),(0,l.jsx)(g.Td,{children:(0,l.jsxs)(p.U,{spacing:2,children:[(null==e?void 0:null===(i=e.metadata_json)||void 0===i?void 0:i.guest_uuid)&&(0,l.jsx)(j.z,{size:"sm",onClick:()=>{var n;return l$(null==e?void 0:null===(n=e.metadata_json)||void 0===n?void 0:n.guest_uuid)},leftIcon:(0,l.jsx)(eZ.k,{}),children:e9("agentDetail.view_chats")}),e.customer_user_data&&(0,l.jsx)(j.z,{size:"sm",variant:"secondary",onClick:()=>handleManageAgentUser(e),children:"Manage"})]})})]},e.id)})}),(0,l.jsxs)(m.K,{mt:4,direction:"row",spacing:4,align:"center",children:[(null==lc?void 0:lc.previous)&&(0,l.jsx)(j.z,{onClick:()=>ib(iy-1),disabled:1===iy,children:"Previous"}),(null==lc?void 0:lc.next)&&(0,l.jsx)(j.z,{onClick:()=>ib(iy+1),disabled:10*iy>=(null==la?void 0:la.length),children:"Next"}),(0,l.jsxs)(x.x,{children:[null==la?void 0:la.length," of ",null==lc?void 0:lc.count," users"]})]})]})}),(0,l.jsx)(W.x,{children:(0,l.jsxs)(m.K,{children:[(0,l.jsx)(v.xu,{children:(0,l.jsxs)(m.K,{justifyContent:"space-between",direction:["column","row"],children:[(0,l.jsxs)(m.K,{children:[(0,l.jsx)(D.X,{fontWeight:"bold",children:e9("agentDetail.emails_tab")}),(0,l.jsx)(x.x,{children:e9("agentDetail.emails_tab_description")})]}),(0,l.jsxs)(p.U,{children:[!lM&&(0,l.jsx)(j.z,{variant:"outline",colorScheme:"blue",isLoading:lZ,onClick:downloadAllAgentUsers,children:e9("agentDetail.exp")}),lM&&(0,l.jsx)(eR.CSVLink,{data:lM,filename:"".concat(null==tn?void 0:tn.slug,"_emails.csv"),children:(0,l.jsx)(j.z,{variant:"outline",colorScheme:"blue",children:e9("agentDetail.download")})})]})]})}),(0,l.jsxs)(en.B,{mb:2,children:[(0,l.jsx)(S.I,{placeholder:"Search emails...",value:lC,variant:"filled",onChange:e=>lw(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(getAgentEmails(!0,null,0),e.preventDefault())}}),(0,l.jsx)(et.xW,{children:(0,l.jsx)(j.z,{onClick:()=>getAgentEmails(!0,null,0),children:"Search"})})]}),lx&&(0,l.jsx)(u.$,{}),(0,l.jsx)(em.Z,{headers:[{name:"email"},{name:"plan"},{name:"Action"}],children:lh&&lh.map(e=>{var n,t,i,s,a,r;return(0,l.jsxs)(h.Tr,{children:[(0,l.jsx)(g.Td,{children:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.x,{children:null!==(a=null!==(s=e.email)&&void 0!==s?s:null===(n=e.customer_user_data)||void 0===n?void 0:n.email)&&void 0!==a?a:null===(t=e.user_data)||void 0===t?void 0:t.email}),e.canceled_at&&(0,l.jsx)(A.C,{mt:2,colorScheme:"red",children:e9("agentDetail.canceled")}),e.last_active_at&&(0,l.jsxs)(x.x,{fontSize:"sm",children:[e9("agentDetail.last_active"),": ",eT()(e.last_active_at).format("lll")]}),e.expires_at&&(0,l.jsxs)(x.x,{fontSize:"xs",children:["Expires ",eT()(e.expires_at).format("ll")]})]})}),(0,l.jsx)(g.Td,{children:(0,l.jsxs)(m.K,{direction:"row",spacing:2,children:[(0,l.jsx)(x.x,{children:null!==(r=e.plan_name)&&void 0!==r?r:e9("agentDetail.free")}),e.bundle&&(0,l.jsx)(p.U,{children:(0,l.jsx)(A.C,{mt:1,colorScheme:"green",children:e9("agentDetail.bundle")})}),(0,l.jsx)(A.C,{colorScheme:"yellow",children:"Email"})]})}),(0,l.jsx)(g.Td,{children:(0,l.jsxs)(p.U,{spacing:2,children:[(null==e?void 0:null===(i=e.metadata_json)||void 0===i?void 0:i.guest_uuid)&&(0,l.jsx)(j.z,{size:"sm",onClick:()=>{var n;return l$(null==e?void 0:null===(n=e.metadata_json)||void 0===n?void 0:n.guest_uuid)},leftIcon:(0,l.jsx)(eZ.k,{}),children:e9("agentDetail.view_chats")}),e.customer_user_data&&(0,l.jsx)(j.z,{size:"sm",variant:"secondary",onClick:()=>handleManageAgentUser(e),children:"Manage"})]})})]},e.id)})}),(0,l.jsxs)(m.K,{mt:4,direction:"row",spacing:4,align:"center",children:[(null==lj?void 0:lj.previous)&&(0,l.jsx)(j.z,{onClick:()=>iw(iC-1),disabled:1===iC,children:"Previous"}),(null==lj?void 0:lj.next)&&(0,l.jsx)(j.z,{onClick:()=>iw(iC+1),disabled:10*iC>=(null==lh?void 0:lh.length),children:"Next"}),(0,l.jsxs)(x.x,{children:[null==lh?void 0:lh.length," of ",null==lj?void 0:lj.count," emails"]})]})]})})]})]})}),nr&&(0,l.jsx)(W.x,{children:(0,l.jsx)(PaymentsView,{hideTabs:e.hideTabs,v2:tC,paidPurchaseLink:(null===(e_=e.paidPlan)||void 0===e_?void 0:e_.purchase_link)+"?client_reference_id=".concat(e.user.id),paidPlan:e.paidPlan,selectedAgentId:tl,allowFileUploads:nO,allowVision:tH.use_vision,allowLiveVoice:null!==(e6=tH.retell_agent_id)&&void 0!==e6?e6:tH.voice_agent_id,user:e.user,plans:ti,onOnboardPress:handleOnboardPress,onAction:onPaymentAction,onDelete:onDeleteAgentPlan,onDefaultPlanSelected:(e,n)=>handleDefaultPlanChange(e,n),defaultPlanId:tH.default_plan_id})}),(0,l.jsx)(W.x,{children:(0,l.jsx)(AgentInterfaceView,{agent:nr,selectedAgentStyle:nk,updateSelectedAgentStyleJson:(e,n)=>{let t={...nk};t[e]=n,nT(t)},saveStyleJson:saveStyleJson,loading:nq,hasAgentSku:hasAgentSku,hideTabs:e.hideTabs,formView:(0,l.jsx)(components_FormTab,{formResponseResult:lX,agentCustomData:tH,fileIngestionApi:nD,selectedAgent:tn,setModalIndex:te,onNext:()=>getAgentFormResponses(getCurrentStartNumber("form")+1),onPrev:()=>getAgentFormResponses(getCurrentStartNumber("form")-1)})})}),nr&&(0,l.jsxs)(W.x,{children:[e.hideTabs&&(0,l.jsxs)(m.K,{mb:4,justifyContent:"space-between",alignItems:"flex-start",direction:["column","row"],children:[(0,l.jsx)(D.X,{children:e9("agentDetail.conv")}),l3&&(0,l.jsx)(eR.CSVLink,{data:l3,filename:"".concat(null==tn?void 0:tn.slug,"_messages.csv"),children:(0,l.jsx)(j.z,{variant:"outline",colorScheme:"blue",children:e9("agentDetail.download")})}),!l3&&(0,l.jsx)(j.z,{onClick:exportAllMessages,isLoading:l4,variant:"outline",colorScheme:"blue",children:"Export messages"})]}),(0,l.jsx)(p.U,{mb:2,children:(0,l.jsx)(eG.Z,{color:"blue",headerText:"Filter",onConfirm:()=>getAgentConvos(),body:(0,l.jsx)(m.K,{children:(0,l.jsxs)(f.NI,{children:[(0,l.jsx)(_.l,{children:"Select rating type"}),(0,l.jsxs)(ea.P,{value:null==l9?void 0:l9.rating,onChange:e=>l7((0,ep.SO)(l9,"rating",e.target.value)),children:[(0,l.jsx)("option",{value:"",children:"None"}),(0,l.jsx)("option",{value:"1",children:"Thumbs up"}),(0,l.jsx)("option",{value:"-1",children:"Thumbs down"})]})]})}),children:(0,l.jsx)(j.z,{children:"Filter by rating"})})}),(0,l.jsxs)(en.B,{mb:2,children:[(0,l.jsx)(S.I,{placeholder:"Search conversations...",value:l0,variant:"filled",onChange:e=>l1(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(getAgentConvos(),e.preventDefault())}}),(0,l.jsx)(et.xW,{children:(0,l.jsx)(j.z,{onClick:()=>getAgentConvos(),children:"Search"})})]}),getAgentConvosView()]}),nr&&(0,l.jsx)(W.x,{children:(0,l.jsx)(components_CustomActionAdminView,{selectedAgentId:tl,user:e.user,showSuccessToast:showSuccessToast})}),nr&&(0,l.jsxs)(W.x,{children:[e.hideTabs&&(0,l.jsx)(D.X,{mb:4,children:e9("agentDetail.domains")}),(0,l.jsxs)(p.U,{mb:4,justifyContent:"space-between",alignItems:"flex-start",direction:["column","row"],children:[(0,l.jsx)(x.x,{children:e9("agentDetail.domains_description")}),(0,l.jsx)(C.r,{href:"https://docs.agenthost.ai/custom-domains-and-embedding-agents",target:"_blank",textDecoration:"underline",children:(0,l.jsx)(j.z,{children:"View Docs"})})]}),(0,l.jsx)(nb.Z,{apiEndpoint:"agent_domain",queryParams:{agent_id:tl,agent:tl},domainPlaceholder:"chat.yourdomain.com",addDomainButtonText:"Add domain",requiresSku:"custom_domain",hasSku:hasAgentSku("custom_domain"),upgradeMessage:e9("agentDetail.domain_up")})]}),nr&&(0,l.jsx)(W.x,{children:(0,l.jsx)(e5.Z,{selectedAgentId:tl,user:e.user,showSuccessToast:showSuccessToast})}),nr&&(0,l.jsx)(W.x,{children:(0,l.jsx)(FinetuneView,{agent:nr,onCreate:createFineTuneJob,finetunes:ie,onAddMessage:()=>e.onNavChange(5),onDelete:deleteFinetuneJob,onRun:runFinetuneJob,onRefresh:refreshFinetuneJob})})]})]}),(0,l.jsx)(TransferAgentModal,{isOpen:np,onClose:()=>nf(!1),agentId:null==tn?void 0:tn.id}),(0,l.jsxs)(a.Z,{isOpen:tW,size:"2xl",onClose:()=>tG(!1),children:[(0,l.jsxs)(m.K,{justifyContent:"center",alignItems:"center",textAlign:"center",children:[(0,l.jsx)(x.x,{fontSize:40,children:"\uD83C\uDF89"}),(0,l.jsx)(D.X,{children:"Agent created!"}),(0,l.jsx)(x.x,{mb:4,children:"Congratulations! Your agent is ready to use. Here are some common next steps"})]}),(0,l.jsxs)(m.K,{children:[(0,l.jsx)(v.xu,{mb:2,children:(0,l.jsxs)(en.B,{children:[(0,l.jsx)(S.I,{isDisabled:!0,value:"".concat(i.ZP.getFullUrl(),"/agent/").concat(null==nr?void 0:nr.slug),isReadOnly:!0}),(0,l.jsxs)(et.xW,{children:[!ng&&(0,l.jsx)(k.h,{"aria-label":"Copy link",icon:(0,l.jsx)(eV.T,{}),onClick:()=>nc()}),ng&&(0,l.jsx)(x.x,{children:"Copied!"})]})]})}),(0,l.jsx)(el.M,{columns:3,spacing:4,cursor:"pointer",mt:2,children:iE.map(e=>{let n=(0,l.jsx)(P.Z,{onClick:()=>triggerNextStep(e),children:(0,l.jsxs)(N.e,{children:[(0,l.jsx)(p.U,{children:(0,l.jsx)(ei.J,{as:e.icon,boxSize:8,mb:2})}),(0,l.jsx)(x.x,{size:"sm",mb:2,children:e.text}),(0,l.jsx)(x.x,{fontSize:"xs",color:"gray.500",children:e.description})]})});return e.href?(0,l.jsx)(C.r,{href:e.href,children:n}):n})})]})]}),(0,l.jsx)(AgentUserManageModal,{agent:nr,isOpen:l_,onClose:()=>lS(!1),getAgentUsers:getAgentUsers,agentUser:ly,agentPlans:ti,onSaveChanges:onSaveAgentUser,onDeleteUser:handleDeleteAgentUser}),(0,l.jsx)(a.Z,{isOpen:lY&&!tY,onClose:()=>l$(null),size:"4xl",children:getAgentConvosView()}),(0,l.jsx)(a.Z,{isOpen:tY,size:"4xl",onClose:()=>t$(null),children:tY&&(0,l.jsxs)(m.K,{spacing:4,children:[(0,l.jsx)(p.U,{children:(0,l.jsx)(j.z,{leftIcon:(0,l.jsx)(ei.J,{as:eJ.u_m}),onClick:()=>t$(null),children:e9("agentDetail.back")})}),(0,l.jsxs)(m.K,{direction:eB.tq?"column":"row",justifyContent:"space-between",children:[(0,l.jsxs)(D.X,{fontSize:"xl",color:"gray.500",children:[e9("agentDetail.thread")," ",tY.thread_id]}),!lH&&(0,l.jsx)(j.z,{isLoading:lL,onClick:()=>handleThreadExportToCsv(),children:"Export to CSV"}),lH&&(0,l.jsx)(eR.CSVLink,{data:lH,filename:"thread_".concat(tY.thread_id,".csv"),children:"Download CSV"})]}),lA&&(0,l.jsx)(u.$,{}),(0,l.jsx)(v.xu,{maxH:"60vh",overflowY:"auto",border:"1px solid #e2e8f0",borderRadius:"md",bg:"white",children:null===(eS=t4[tY.thread_id])||void 0===eS?void 0:eS.map((e,n)=>
1(0,l.jsx)(ChatMessage,{variant:"modal",message:e,activeFinetune:getActiveFineTune(),showFinetune:!0,addToFineTuneQueue:addToFineTuneQueue,finetuneMessageMap:il},e.id))}),(null===(ey=t0[tY.thread_id])||void 0===ey?void 0:ey.has_more)&&(0,l.jsx)(j.z,{onClick:()=>fetchMessages(tY,getCurrentStartNumber("message")+10),children:e9("agentDetail.more")})]})}),(0,l.jsx)(a.Z,{isOpen:n1,size:"3xl",onClose:()=>{n4(!1)},title:"Deploy your GPT",children:(0,l.jsx)(AgentShareView,{integrations:lP,token:e.token,value:nu,agent:tn,handlePlanAdd:()=>handlePlanAdd(),agentPlans:ti,isPaidUser:hasAgentSku("hide_ag_promo"),onSaveIntegration:handleIntegrationSave,onCustomDomainSelected:()=>{n4(!1),e.onNavChange(7)},refreshAgent:e.refreshAgent,onZapierSelected:()=>{n4(!1),e.onNavChange(9)}})}),(0,l.jsxs)(a.Z,{isOpen:i_,onClose:()=>iS(!1),children:[(0,l.jsx)(D.X,{size:"md",children:"Select your fine tuned model model"}),(0,l.jsx)(x.x,{children:"Only completed fine tuned models may be used."}),(0,l.jsx)(FinetuneView,{agent:tn,hideHeader:!0,hideActions:!0,allowSelection:!0,onCreate:createFineTuneJob,finetunes:ie,onAddMessage:()=>e.onNavChange(5),onDelete:deleteFinetuneJob,onRun:runFinetuneJob,onRefresh:refreshFinetuneJob,onSelect:e=>{if(!e.finished_at){alert("You must select a completed fine tune model");return}if(!e.model_name){alert("Model name is missing");return}tb(e.model_name),iS(!1)}})]}),(0,l.jsxs)(a.Z,{hideClose:!0,size:"2xl",isOpen:lT,children:[(0,l.jsx)(p.U,{justifyContent:"center",mb:4,children:(0,l.jsx)(u.$,{size:"lg"})}),(0,l.jsx)(D.X,{textAlign:"center",children:e9("agentDetail.up")}),(0,l.jsx)(x.x,{mt:2,textAlign:"center",children:e9("agentDetail.fst")})]}),(0,l.jsxs)(a.Z,{isOpen:to,title:"Your payment account isn't fully setup",onClose:()=>td(!1),children:[(0,l.jsx)(x.x,{children:e9("agentDetail.onbrd")}),(0,l.jsx)(j.z,{mt:4,onClick:()=>handleOnboardPress(),children:e9("agentDetail.conn")})]}),(0,l.jsx)(a.Z,{isOpen:iP,onClose:()=>iN(!1),title:"Upgrade Required",size:"3xl",children:(0,l.jsxs)(m.K,{spacing:4,children:[(0,l.jsx)(x.x,{children:"Voice interface requires an upgrade to access this feature."}),(0,l.jsx)(nC.Z,{user:e.user,fetchTargetPlans:!0,title:"Upgrade to enable voice agents",subtitle:"Choose a plan that includes voice capabilities",customRenderer:n=>(0,l.jsx)(nw.Z,{plans:n,user:e.user})})]})})]})}},95873:function(e,n,t){t.d(n,{Z:function(){return ApprovalTab}});
1var l=t(85893),i=t(67294),s=t(7963),a=t(24880),r=t(55281),o=t(57747),d=t(22757),c=t(71293),u=t(93108),h=t(81136),g=t(13990),x=t(40607),p=t(10991),j=t(99840),m=t(80510),v=t(4693),f=t(15115),_=t(64698),S=t(32883),y=t(34292),b=t(28743),C=t(39440),w=t(61639),k=t(30381),D=t.n(k);let A=new b.Z("agent-action-call");function ApprovalTab(e){let{selectedAgentId:n=null,user:t,showSuccessToast:b,showAgentInfo:k=!1}=e,[z,T]=(0,i.useState)([]),[I,U]=(0,i.useState)(!1),[F,P]=(0,i.useState)(1),[N,E]=(0,i.useState)(1),[O,M]=(0,i.useState)(!1),[R,Z]=(0,i.useState)(null),[V,H]=(0,i.useState)(!1),[K,L]=(0,i.useState)(!1),[q,Q]=(0,i.useState)(""),J=(0,s.p)();(0,i.useEffect)(()=>{fetchApprovalRequests()},[n,F]),(0,i.useEffect)(()=>{let handleVisibilityChange=()=>{!document.hidden&&n&&fetchApprovalRequests()},handleFocus=()=>{n&&fetchApprovalRequests()};return document.addEventListener("visibilitychange",handleVisibilityChange),window.addEventListener("focus",handleFocus),()=>{document.removeEventListener("visibilitychange",handleVisibilityChange),window.removeEventListener("focus",handleFocus)}},[n]);let fetchApprovalRequests=async()=>{U(!0);try{let e={page:F,page_size:10};n?e.agent_id=n:e.expansions=["agent"];let t=await A.query(e);if(t&&!t.error)T(t.results),E(Math.ceil(t.count/10));else{let e=(0,C.HH)(null==t?void 0:t.error,"Failed to load approval requests");J({title:"Error",description:e,status:"error",duration:5e3,isClosable:!0})}}catch(e){console.error("Failed to fetch approval requests:",e),J({title:"Error",description:"Failed to load approval requests",status:"error",duration:5e3,isClosable:!0})}finally{U(!1)}},handleApprove=async()=>{H(!0);try{let e=await A.nonStandard("POST","".concat(R.id,"/approve"));if(e&&!e.error)b("Action request approved successfully"),fetchApprovalRequests();else{let n=(0,C.HH)(null==e?void 0:e.error,"Failed to approve request");J({title:"Error",description:n,status:"error",duration:5e3,isClosable:!0})}}catch(e){console.error("Failed to approve request:",e),J({title:"Error",description:"Failed to approve request",status:"error",duration:5e3,isClosable:!0})}finally{H(!1),M(!1),Z(null)}},handleReject=async()=>{L(!0);try{let e=await A.nonStandard("POST","".concat(R.id,"/reject"));if(e&&!e.error)b("Action request rejected successfully"),fetchApprovalRequests();else{let n=(0,C.HH)(null==e?void 0:e.error,"Failed to reject request");J({title:"Error",description:n,status:"error",duration:5e3,isClosable:!0})}}catch(e){console.error("Failed to reject request:",e),J({title:"Error",description:"Failed to reject request",status:"error",duration:5e3,isClosable:!0})}finally{L(!1),M(!1),Z(null)}},initiateApproval=e=>{Z(e),Q("approve"),M(!0)},initiateRejection=e=>{Z(e),Q("reject"),M(!0)},formatTime=e=>{if(!e)return"N/A";try{return D()(e).format("LL")}catch(n){return e}},getStatusBadge=e=>e.approved_at?(0,l.jsx)(a.C,{colorScheme:"green",children:"Approved"}):e.rejected_at?(0,l.jsx)(a.C,{colorScheme:"red",children:"Rejected"}):(0,l.jsx)(a.C,{colorScheme:"yellow",children:"Pending"});return(0,l.jsxs)(r.K,{spacing:4,children:[(0,l.jsxs)(r.K,{justifyContent:"space-between",direction:["column","row"],children:[(0,l.jsxs)(o.xu,{children:[(0,l.jsx)(d.X,{size:"md",mb:2,children:n?"Action Approval Requests":"All Action Approval Requests"}),(0,l.jsx)(c.x,{mb:4,children:n?"Manage approval requests for agent actions":"Manage approval requests across all agents"})]}),(0,l.jsx)(u.z,{onClick:fetchApprovalRequests,isLoading:I,children:"Refresh"})]}),I?(0,l.jsx)(o.xu,{display:"flex",justifyContent:"center",children:(0,l.jsx)(h.$,{size:"lg"})}):(null==z?void 0:z.length)===0?(0,l.jsx)(g.Z,{children:(0,l.jsx)(x.e,{children:(0,l.jsx)(c.x,{children:"No approval requests found"})})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(p.i,{variant:"simple",children:[(0,l.jsx)(j.h,{children:(0,l.jsxs)(m.Tr,{children:[k&&(0,l.jsx)(v.Th,{children:"Agent"}),(0,l.jsx)(v.Th,{children:"Action Name"}),(0,l.jsx)(v.Th,{children:"Arguments"}),(0,l.jsx)(v.Th,{children:"Status"}),(0,l.jsx)(v.Th,{children:"Requested"}),(0,l.jsx)(v.Th,{children:"Actions"})]})}),(0,l.jsx)(f.p,{children:null==z?void 0:z.map(e=>{var n;return(0,l.jsxs)(m.Tr,{children:[k&&(0,l.jsx)(_.Td,{children:(null===(n=e.agent_data)||void 0===n?void 0:n.name)||"Unknown Agent"}),(0,l.jsx)(_.Td,{children:e.function_name}),(0,l.jsx)(_.Td,{children:(0,l.jsxs)(r.K,{children:[(0,l.jsx)(o.xu,{bg:"gray.50",p:2,borderRadius:"md",children:(0,l.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.function_args,null,2)})}),(0,l.jsx)(o.xu,{children:(0,l.jsx)(S.r,{href:"/project/".concat(e.agent,"?threadId=").concat(e.thread_id),children:(0,l.jsx)(u.z,{variant:"link",children:"View conversation"})})})]})}),(0,l.jsx)(_.Td,{children:getStatusBadge(e)}),(0,l.jsx)(_.Td,{children:formatTime(e.created_at)}),(0,l.jsx)(_.Td,{children:e.approved_at||e.rejected_at?(0,l.jsx)(c.x,{fontSize:"sm",children:e.approved_at?"Approved ".concat(formatTime(e.approved_at)):"Rejected ".concat(formatTime(e.rejected_at))}):(0,l.jsxs)(y.U,{spacing:2,children:[(0,l.jsx)(u.z,{colorScheme:"green",size:"sm",onClick:()=>initiateApproval(e),children:"Approve"}),(0,l.jsx)(u.z,{colorScheme:"red",size:"sm",onClick:()=>initiateRejection(e),isLoading:K&&(null==R?void 0:R.id)===e.id,children:"Reject"})]})})]},e.id)})})]}),(0,l.jsxs)(y.U,{justifyContent:"flex-end",spacing:4,children:[(0,l.jsx)(u.z,{onClick:()=>P(F-1),isDisabled:1===F||I,children:"Previous"}),(0,l.jsxs)(c.x,{children:["Page ",F," of ",N]}),(0,l.jsx)(u.z,{onClick:()=>P(F+1),isDisabled:F>=N||I,children:"Next"})]})]}),(0,l.jsx)(w.Z,{isOpen:O,onClose:()=>M(!1),title:"Confirm ".concat("approve"===q?"Approval":"Rejection"),children:(0,l.jsxs)(r.K,{spacing:4,children:[(0,l.jsxs)(c.x,{children:["Are you sure you want to ",q," this action request?"]}),R&&(0,l.jsx)(g.Z,{children:(0,l.jsx)(x.e,{children:(0,l.jsxs)(r.K,{spacing:2,children:[k&&R.agent_data&&(0,l.jsxs)(c.x,{children:[(0,l.jsx)("strong",{children:"Agent:"})," ",R.agent_data.name]}),(0,l.jsxs)(c.x,{children:[(0,l.jsx)("strong",{children:"Action Name:"})," ",R.function_name]}),(0,l.jsx)(c.x,{children:(0,l.jsx)("strong",{children:"Arguments:"})}),(0,l.jsx)(o.xu,{bg:"gray.50",p:2,borderRadius:"md",children:(0,l.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(R.function_args,null,2)})})]})})}),(0,l.jsxs)(y.U,{spacing:4,children:[(0,l.jsxs)(u.z,{colorScheme:"approve"===q?"green":"red",onClick:"approve"===q?handleApprove:handleReject,isLoading:"approve"===q?V:K,children:["Confirm ","approve"===q?"Approval":"Rejection"]}),(0,l.jsx)(u.z,{onClick:()=>M(!1),children:"Cancel"})]})]})})]})}},90523:function(e,n,t){t.d(n,{Z:function(){return ConstrainedInput}});
1var l=t(85893),i=t(50797),s=t(33090);function ConstrainedInput(e){let handleInput=n=>{(0,i._o)(n,e.type,e.regex)&&e.onChangeText(n)};return(0,l.jsx)(s.I,{...e.inputProps,value:e.value,onChange:e=>handleInput(e.target.value)})}},38166:function(e,n,t){t.d(n,{Z:function(){return DomainVerificationView}});var l=t(85893),i=t(67294),s=t(7963),a=t(55281),r=t(34292),o=t(93108),d=t(13990),c=t(40607),u=t(57747),h=t(22757),g=t(11365),x=t(50151),p=t(64325),j=t(13591),m=t(74574),v=t(82509),f=t(94160),_=t(78590),S=t(71293),y=t(85970),b=t(5418),C=t(33090),w=t(19754),k=t(1679),D=t(61639),A=t(3272),z=t(80510),T=t(64698),I=t(28743),U=t(14866),F=t(50797),P=t(39440);function DomainVerificationView(e){let{apiEndpoint:n,queryParams:t={},connected_key:N="is_connected",verified_key:E="is_verified",dnsWebsite:O="agenthost-dns.com",domainPlaceholder:M="chat.yourdomain.com",addDomainButtonText:R="Add domain",requiresSku:Z,hasSku:V=!0,upgradeMessage:H="Please upgrade to use this feature",domainValidation:K,onDomainAdded:L,onDomainDeleted:q}=e,[Q,J]=(0,i.useState)([]),[X,B]=(0,i.useState)({}),[W,G]=(0,i.useState)(""),[Y,$]=(0,i.useState)(!1),[ee,en]=(0,i.useState)(!1),[et,el]=(0,i.useState)({}),ei=(0,s.p)(),es=new I.Z(n);(0,i.useEffect)(()=>{getDomains()},[]);let getDomains=async()=>{let e=await es.query(t);if(console.log("domains response:",e),e&&!e.error){J(e.results);let n={};for(let t of e.results)n[t.id]=t;B(n)}},checkDomainVerification=async e=>{let n=await es.nonStandard("GET","".concat(e,"/verify_domain"),null);if(console.log("domain verification response:",n),n&&!n.error){let t={...X};return t[e]=n,B(t),n}{let e=(0,P.HH)(n.error,"Failed to verify domain");return(0,P.W6)(ei,"Verification failed",e),null}},checkDomainConfiguration=async e=>{let n=await es.nonStandard("GET","".concat(e,"/verify_configuration"),null);if(console.log("domain configuration response:",n),n&&!n.error){let t={...X};return t[e]=n,B(t),n}{let e=(0,P.HH)(n.error,"Failed to verify configuration");return(0,P.W6)(ei,"Configuration failed",e),null}},refreshDomainStatus=async e=>{el((0,F.SO)(et,e.id,!0)),e[E]?await checkDomainConfiguration(e.id):await checkDomainVerification(e.id),el((0,F.SO)(et,e.id,!1))},onAddDomain=async()=>{if(!W){(0,P.W6)(ei,"Invalid domain","Please enter a domain");return}if(K){let e=K(W);if(!e.valid){(0,P.W6)(ei,"Invalid domain",e.message||"Invalid domain");return}}else{if(!W.includes(".")){(0,P.W6)(ei,"Invalid domain","Please enter a valid subdomain (e.g. chat.example.com)");return}let e=W.split(".");if(e.length<3){(0,P.W6)(ei,"Invalid domain","Please enter a valid subdomain (e.g. chat.example.com)");return}}let e={domain:W,...t};$(!0);let n=await es.create(e);if(n&&!n.error){let e=[...Q];e.push(n);let t={...X};t[n.id]=n,J(e),B(t),G(""),(0,P.XA)("Domain added",ei,"Your domain has been added successfully"),L&&L(n)}else{let e=(0,P.HH)(n.error,"Failed to add domain");(0,P.W6)(ei,"Failed to add domain",e)}$(!1),en(!1)},deleteDomain=async e=>{$(!0),console.log("deleting domain with id",e.id);let n=await es.delete(e.id);if(n&&!n.error){let n={...X};delete n[e.id],B(n),J(Q.filter(n=>n.id!==e.id)),(0,P.XA)("Domain deleted",ei,"Your domain has been deleted successfully"),q&&q(e)}else{let e=(0,P.HH)(n.error,"Failed to delete domain");(0,P.W6)(ei,"Failed to delete domain",e)}$(!1)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a.K,{justifyContent:"space-between",direction:["column","row"],mb:4,children:(0,l.jsx)(r.U,{children:(0,l.jsx)(o.z,{colorScheme:"blue",onClick:()=>en(!0),children:R})})}),Object.values(X).map(e=>(0,l.jsx)(d.Z,{mb:4,children:(0,l.jsxs)(c.e,{children:[(0,l.jsx)(a.K,{children:(0,l.jsxs)(u.xu,{children:[(0,l.jsxs)(r.U,{justifyContent:"space-between",children:[(0,l.jsx)(h.X,{size:"md",children:e.domain}),e[N]&&(0,l.jsx)(o.z,{colorScheme:"green",leftIcon:(0,l.jsx)(w.n,{}),variant:"outline",size:"sm",children:"Connected"}),!e[N]&&(0,l.jsx)(o.z,{colorScheme:"red",leftIcon:(0,l.jsx)(k.T,{}),variant:"outline",size:"sm",children:"Not connected"}),(0,l.jsxs)(g.J,{children:[(0,l.jsx)(x.x,{children:(0,l.jsx)(o.z,{colorScheme:"red",children:"Delete"})}),(0,l.jsxs)(p.y,{children:[(0,l.jsx)(j.u,{}),(0,l.jsx)(m.Y,{children:"Confirm Delete"}),(0,l.jsx)(v.b,{children:"Are you sure you want to delete this domain?"}),(0,l.jsx)(f.D,{children:(0,l.jsxs)(_.h,{size:"sm",children:[(0,l.jsx)(o.z,{variant:"outline",children:"Cancel"}),(0,l.jsx)(o.z,{colorScheme:"red",onClick:()=>deleteDomain(e),children:"Delete"})]})})]})]})]}),e[N]&&(0,l.jsx)(S.x,{mb:2,fontSize:"sm",mt:2,color:"green.500",children:"Your domain is connected and ready to use"})]})}),!e[N]&&(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(u.xu,{children:[e[E]&&!e[N]&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(S.x,{fontSize:"sm",mb:2,children:"Add the following DNS record to complete setup:"}),(0,l.jsx)(A.Z,{headers:[{name:"Type"},{name:"Name"},{name:"Value"}],children:(0,l.jsxs)(z.Tr,{children:[(0,l.jsx)(T.Td,{children:"CNAME"}),(0,l.jsx)(T.Td,{children:1===e.domain.split(".").length?"www":e.domain.split(".")[0]}),(0,l.jsx)(T.Td,{children:(0,l.jsxs)(S.x,{children:[U.ZP.testOrProd("stage.",""),O,"."]})})]})})]}),!e[E]&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(S.x,{fontSize:"sm",color:"red.500",children:"Please add the following DNS records to verify domain ownership:"}),(0,l.jsx)(A.Z,{headers:[{name:"Type"},{name:"Domain"},{name:"Value"}],children:e.verification_data&&e.verification_data.map(e=>(0,l.jsxs)(z.Tr,{children:[(0,l.jsx)(T.Td,{children:e.type}),(0,l.jsx)(T.Td,{children:e.domain}),(0,l.jsx)(T.Td,{children:e.value})]},e.value))})]})]})}),(0,l.jsx)(o.z,{mt:2,colorScheme:"blue",isLoading:et[e.id],onClick:()=>refreshDomainStatus(e),children:"Check Status"})]})},e.id)),(0,l.jsxs)(D.Z,{isOpen:ee,title:"Add domain",onClose:()=>en(!1),children:[Z&&!V&&(0,l.jsx)(S.x,{fontSize:"sm",mb:4,color:"red.500",children:H}),(0,l.jsxs)(y.NI,{mt:4,children:[(0,l.jsx)(b.l,{children:"Your domain"}),(0,l.jsx)(C.I,{placeholder:M,value:W,onChange:e=>G(e.target.value.toLowerCase())})]}),(0,l.jsx)(o.z,{isDisabled:Z&&!V,mt:4,mb:8,colorScheme:"blue",onClick:()=>onAddDomain(),isLoading:Y,children:R})]})]})}},59109:function(e,n,t){t.d(n,{Z:function(){return PlanFeature}});
1var l=t(85893),i=t(67294),s=t(50797),a=t(34292),r=t(24880),o=t(95392),d=t(61639),c=t(9715);function PlanFeature(e){var n,t;let[u,h]=(0,i.useState)(!1),handleUpgradeClick=e=>{e.stopPropagation(),e.preventDefault(),h(!0)};return(0,l.jsxs)("div",{children:[(0,s.MV)(e.user.skus,e.sku)?e.children:(0,l.jsx)("div",{onClick:handleUpgradeClick,onClickCapture:handleUpgradeClick,children:(0,l.jsxs)(a.U,{alignItems:"center",children:[e.showDisabled&&(0,i.isValidElement)(e.children)?(0,i.cloneElement)(e.children,{isDisabled:!0}):e.children,!e.hideBadge&&(0,l.jsx)(r.C,{colorScheme:"gray",children:"✨"})]})}),(0,l.jsx)(d.Z,{size:"3xl",isOpen:u,onClose:()=>h(!1),title:"Upgrade",children:(0,l.jsx)(o.Z,{user:e.user,fetchTargetPlans:!0,title:null!==(n=e.title)&&void 0!==n?n:"Your plan doesn't support this feature",subtitle:null!==(t=e.subtitle)&&void 0!==t?t:"Upgrade to access this feature",customRenderer:n=>(0,l.jsx)(c.Z,{plans:n,user:e.user})})})]})}},36653:function(e,n,t){t.d(n,{Z:function(){return SimplePopOver}});var l=t(85893),i=t(11365),s=t(50151),a=t(64325),r=t(72303),o=t(13591),d=t(74574),c=t(82509),u=t(94160),h=t(78590),g=t(93108),x=t(67294);function SimplePopOver(e){let n=(0,x.useRef)(),[t,p]=(0,x.useState)(!1),handleConfirm=async n=>{p(!0),await e.onConfirm(),p(!1),n()};return(0,l.jsx)(i.J,{closeOnBlur:!1,initialFocusRef:n,children:n=>{var i,x,p,j;let{isOpen:m,onClose:v}=n;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.x,{children:e.children}),(0,l.jsxs)(a.y,{children:[(0,l.jsx)(r.Q,{}),(0,l.jsx)(o.u,{}),!e.hideHeader&&(0,l.jsx)(d.Y,{children:null!==(i=e.headerText)&&void 0!==i?i:"Confirm"}),e.body&&(0,l.jsx)(c.b,{children:e.body}),!e.body&&(0,l.jsx)(c.b,{children:null!==(x=e.confirmText)&&void 0!==x?x:"Are you sure you would like to continue?"}),e.footer&&(0,l.jsx)(u.D,{children:e.footer}),!e.footer&&(0,l.jsx)(u.D,{display:"flex",justifyContent:"flex-end",children:(0,l.jsx)(h.h,{size:"sm",children:(0,l.jsx)(g.z,{colorScheme:null!==(p=e.color)&&void 0!==p?p:"red",onClick:()=>handleConfirm(v),isLoading:t,children:null!==(j=e.confirmButtonText)&&void 0!==j?j:"Confirm"})})})]})]})}})}},3272:function(e,n,t){t.d(n,{Z:function(){return SimpleTable}});
1var l=t(85893),i=t(61557),s=t(10991),a=t(40853),r=t(99840),o=t(80510),d=t(4693),c=t(15115),u=t(93108);function SimpleTable(e){return(0,l.jsxs)(i.x,{...e,suppressHydrationWarning:!0,children:[(0,l.jsxs)(s.i,{variant:"simple",children:[e.caption&&(0,l.jsx)(a.R,{children:e.caption}),(0,l.jsx)(r.h,{suppressHydrationWarning:!0,children:(0,l.jsx)(o.Tr,{children:e.headers&&e.headers.map((e,n)=>(0,l.jsx)(d.Th,{isNumeric:e.isNumeric,children:e.name},n))})}),(0,l.jsx)(c.p,{children:e.children})]}),e.showLoadMore&&(0,l.jsx)(u.z,{mt:4,onClick:e.onLoadMore,children:"Load more"})]})}},21090:function(e,n,t){t.d(n,{Z:function(){return FileController}});var l=t(85893),i=t(8244),s=t(50797),a=t(57747),r=t(81136),o=t(79970),d=t(34292),c=t(93108),u=t(67294);function FileController(e){var n;let[t,h]=(0,u.useState)(e.fileUrl),[g,x]=(0,u.useState)(!1),[p,j]=(0,u.useState)(null);(0,u.useEffect)(()=>{h(e.fileUrl)},[e.fileUrl]);let{file:m,label:v,deleteOnChange:f,uploadOnChange:_,filePath:S}=e,deleteFileUrl=n=>{(0,s._I)(t).then(()=>{console.log("file deleted!"),h(null),e.onFileDelete&&e.onFileDelete(t)}).catch(l=>{console.error("Error deleting file",l),n&&e.onFileDelete&&e.onFileDelete(t)})};return(0,l.jsxs)(a.xu,{children:[g&&(0,l.jsx)(r.$,{}),t&&(0,l.jsx)(o.E,{src:t,h:"80px"}),(0,l.jsxs)(d.U,{children:[(0,l.jsx)(i.Z,{accept:e.accept,label:(null!==(n=null==p?void 0:p.name)&&void 0!==n?n:t)?"Edit":null!=v?v:null,onChange:n=>{console.log("file change"),f?deleteFileUrl(!1):t&&e.setFilesToBeDeleted(t),console.log("uploadOnChange",_),_?(x(!0),(0,s.Xs)(n[0],null==e?void 0:e.userId,null,S,null==e?void 0:e.itemId).then(n=>{console.log("File uploaded",n),h(n.url),x(!1),e.onFileUpload&&e.onFileUpload(n)})):(console.log("selected file is",n[0]),e.setFilesToBeUploaded(n[0]),j(n[0]))}}),e.fileUrl&&(0,l.jsx)(c.z,{onClick:()=>{deleteFileUrl(!0)},children:"Clear"})]})]})}}}]);

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.