PageSourceSearch

https://orygofrontend-production.up.railway.app/_next/static/chunks/1840-7f3b4753d892d141.js

js orygofrontend-production.up.railway.app collected 2026-10-03 12:16:01 UTC 83,479 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1840],{22502:(e,t,r)=>{r.d(t,{AS:()=>f,G$:()=>g,Kl:()=>p,Sv:()=>b,Tc:()=>c,XH:()=>u,ZZ:()=>l,_k:()=>_,bQ:()=>x,fU:()=>h,ic:()=>m,j$:()=>j,js:()=>y,rJ:()=>d,zm:()=>o});var n=r(75656),a=r(34333),i=r(8863),s=r(72943);let l=e=>{let{user:t}=(0,s.J)();return(0,n.Ay)(t&&e?["/fetch_integrations?agent_id=".concat(e),t.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))},o=e=>{let{user:t}=(0,s.J)();return(0,n.Ay)(t&&e?["/fetch_configs?agent_id=".concat(e),t.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))},c=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/save_config?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t,n={integration_id:r.integration_id,credentials:r.credentials,ai_enabled:r.ai_enabled,is_private:r.is_private,copilot_filters:r.copilot_filters};return void 0!==r.status_mapping&&(n.status_mapping=r.status_mapping),(0,i.eh)(e,{arg:n})})},d=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/enable_config?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{integration_id:r.integration_id}})})},g=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/disable_config?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{integration_id:r.integration_id}})})},u=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/delete_config?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.Nw)(e,{arg:r})})},h=()=>{let{user:e}=(0,s.J)();return(0,a.A)(e?["/oauth/meta/disconnect",e.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.eh)(e,{arg:{agent_id:r.agent_id,channel:r.channel}})})},p=e=>{let{user:t,loading:r}=(0,s.J)();return(0,n.Ay)(!r&&t&&e?["/shopify_order_webhooks_status/".concat(e),t.accessToken]:null,e=>(0,i.we)(e),{revalidateOnFocus:!1})},m=e=>{let{user:t,loading:r}=(0,s.J)();return(0,a.A)(!r&&t&&e?["/create_shopify_order_webhooks/".concat(e),t.accessToken]:null,e=>(0,i.eh)(e,{arg:void 0}))},x=e=>{let{user:t,loading:r}=(0,s.J)();return(0,a.A)(!r&&t&&e?["/delete_shopify_order_webhooks/".concat(e),t.accessToken]:null,e=>(0,i.Nw)(e,{arg:void 0}))},f=e=>{let{user:t,loading:r}=(0,s.J)();return(0,n.Ay)(!r&&t&&e?["/prestashop_conversion_setup/".concat(e),t.accessToken]:null,e=>(0,i.we)(e),{revalidateOnFocus:!1})},b=e=>{let{user:t,loading:r}=(0,s.J)();return(0,n.Ay)(!r&&t&&e?["/magento_conversion_setup/".concat(e),t.accessToken]:null,e=>(0,i.we)(e),{revalidateOnFocus:!1})},_=e=>{let{user:t,loading:r}=(0,s.J)();return(0,n.Ay)(!r&&t&&e?["/sfcc_conversion_setup/".concat(e),t.accessToken]:null,e=>(0,i.we)(e),{revalidateOnFocus:!1})},j=e=>{let{user:t,loading:r}=(0,s.J)();return(0,n.Ay)(!r&&t&&e?["/woocommerce_conversion_setup/".concat(e),t.accessToken]:null,e=>(0,i.we)(e),{revalidateOnFocus:!1})},y=e=>{let{user:t}=(0,s.J)();return(0,n.Ay)(t&&e?["/fetch_available_channels?agent_id=".concat(e),t.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))}},67878:(e,t,r)=>{r.d(t,{A:()=>g});var n=r(37876);r(14232);var a=r(39822),i=r(14741),s=r(53224),l=r(12324),o=r(82703);let c="https://orygobackend-production.up.railway.app",d="# Orygo AI — Agent API\n\n## Overview\n\nCall one agent over HTTP from your own backend. Each API key belongs to a single agent. Create and revoke keys in the panel above.\n\n**Base URL**\n\n```\n".concat(c,"\n```\n\nCall this API from your server. Do not put the key in browser or mobile client code.\n\n---\n\n## Authentication\n\nSend the key in the `Authorization` header. A key created for one agent returns 403 if it is used with another agent's URL.\n\n```\nAuthorization: Bearer sk_live_YOUR_KEY\n```\n\n---\n\n## POST /v1/agents/{agent_id}/chat\n\nStream a chat response token by token (Server-Sent Events).\n\n### Request\n\n| Parameter | In | Type | Required | Description |\n|-----------|-----|------|----------|-------------|\n| `Authorization` | Header | string | Yes | `Bearer sk_live_...` |\n| `agent_id` | Path | string | Yes | The agent this key belongs to. |\n| `message` | Body | string | Yes | The user's message. |\n| `session_id` | Body | string | No | Continue this conversation. Omit to start a new one. |\n| `external_user_id` | Body | string | No | Your own user id. Later calls with the same id resume that conversation. |\n| `message_id` | Body | string | No | Your id for this message. A UUID is generated 
1when omitted. |\n| `customer` | Body | object | No | Optional `email`, `name`, and `phone` shown in the inbox. |\n\n### Example\n\n```bash\ncurl -N -X POST \"").concat(c,'/v1/agents/AGENT_ID/chat" \\\n  -H "Authorization: Bearer sk_live_YOUR_KEY" \\\n  -H "Content-Type: application/json" \\\n  -d \'{\n    "message": "How can I return an order?",\n    "external_user_id": "user_42",\n    "customer": { "email": "[email protected]", "name": "Ada" }\n  }\'\n```\n\n### Response\n\n`Content-Type: text/event-stream`\n\nEach event is a JSON object in a `data:` line.\n\n| Event | Payload | Description |\n|-------|---------|-------------|\n| `session` | `{ "session_id" }` | Conversation id. Send it back as `session_id` to continue. |\n| `delta` | `{ "text" }` | One piece of the assistant reply. Concatenate `text` values. |\n| `done` | `{ "session_id", "message_id" }` | The turn finished. |\n| `error` | `{ "error" }` | The turn failed (for example, not enough credits). |\n| `live_handover` | `{ "session_id" }` | A human operator took over. Poll the messages endpoint for their replies. |\n\n### Error responses\n\nThese are HTTP statuses, before the stream opens.\n\n| Status | Detail |\n|--------|--------|\n| 401 | Invalid or revoked API key. |\n| 403 | The key does not belong to this agent. |\n| 404 | Agent or session not found. |\n| 409 | `conversation_stop_ai` (a human owns the thread) or `session_expired` (start a new session). |\n| 429 | `rate_limited`. |\n\n---\n\n## GET /v1/agents/{agent_id}/sessions/{session_id}/messages\n\nFull transcript for this session, including operator replies after a handover. Same `Authorization` header.\n\n```bash\ncurl "').concat(c,'/v1/agents/AGENT_ID/sessions/SESSION_ID/messages" \\\n  -H "Authorization: Bearer sk_live_YOUR_KEY"\n```\n\nEach message has `sender` `human`, `AI`, or `operator`.\n\n---\n\n## Tips\n\n- Keep using the same `session_id` or `external_user_id` so the agent remembers the conversation.\n- After `session_expired`, omit `session_id` and call again. The same `external_user_id` starts a new conversation.\n- After `live_handover` or `conversation_stop_ai`, read operator replies with the messages endpoint.\n');function g(){let{resolvedTheme:e}=(0,o.j)();return(0,n.jsx)(a.a,{w:"100%",maxW:"900px",children:(0,n.jsx)(i.oz,{remarkPlugins:[s.A],components:(0,l.A)({},void 0,!1,e||"dark","sm",!0),children:d})})}},77876:(e,t,r)=>{r.d(t,{$t:()=>j,B:()=>c,BP:()=>T,C$:()=>z,Cf:()=>k,GW:()=>m,Rk:()=>w,SD:()=>x,SO:()=>E,UW:()=>v,XT:()=>A,YR:()=>_,_$:()=>g,aV:()=>d,b1:()=>y,b7:()=>C,bB:()=>p,cr:()=>f,gm:()=>l,hE:()=>u,jM:()=>I,jd:()=>o,pT:()=>h,rK:()=>b,yP:()=>S});var n=r(75656),a=r(34333),i=r(8863),s=r(72943);let l=e=>{let{user:t}=(0,s.J)();return(0,n.Ay)(t&&e?["/fetch_custom_actions?agent_id=".concat(e),t.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))},o=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/create_custom_action?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{var r;let{arg:n}=t;return(0,i.eh)(e,{arg:{name:n.name,description:n.description,webhook_url:n.webhook_url,http_method:n.http_method||"POST",auth_header:n.auth_header,headers_json:n.headers_json,parameters_schema:n.parameters_schema,flatten_query_params:null!=(r=n.flatten_query_params)&&r}})})},c=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/edit_custom_action?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t,n={action_id:r.action_id};return void 0!==r.name&&null!==r.name&&(n.name=r.name),void 0!==r.description&&null!==r.description&&(n.description=r.description),void 0!==r.webhook_url&&null!==r.webhook_url&&(n.webhook_url=r.webhook_url),void 0!==r.http_method&&null!==r.http_method&&(n.http_method=r.http_method),void 0!==r.auth_header&&null!==r.auth_header&&(n.auth_header=r.auth_header),void 0!==r.headers_json&&null!==r.headers_json&&(n.headers_json=r.headers_json),void 0!==r.parameters_schema&&null!==r.parameters_schema&&(n.parameters_schema=r.parameters_schema),void 0!==r.flatten_query_params&&null!==r.flatten_query_params&&(n.flatten_query_params=r.flatten_query_params),(0,i.wf)(e,{arg:n})})},d=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/delete_custom_action?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.Nw)(e,{arg:r})})},g=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_custom_action_enabled?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:r})})},u=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_custom_action_disabled?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:r})})},h=(e,t)=>{let{user:r}=(0,s.J)(),a=e?"/fetch_integrations_callables?agent_id=".concat(e):null;return a&&t&&(a+="&integration_id=".concat(t)),(0,n.Ay)(r&&a?[a,r.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))},p=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_integration_action_enabled?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{var r;let{arg:n}=t;return(0,i.wf)(e,{arg:{callable_id:n.callable_id,enabled:null==(r=n.enabled)||r}})})},m=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_integration_action_disabled?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.Nw)(e,{arg:r})})},x=e=>{let{user:t}=(0,s.J)();return(0,n.Ay)(t&&e?["/fetch_system_callables?agent_id=".concat(e),t.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))},f=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_system_action_enabled?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id}})})},b=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_system_action_disabled?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.Nw)(e,{arg:r})})},_=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/update_system_action_excluded_channels?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,excluded_channels:r.excluded_channels}})})},j=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_system_action_config?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,config:r.config}})})},y=e=>{let{user:t}=(0,s.J)();return(0,n.Ay)(t&&e?["/fetch_active_actions?agent_id=".concat(e),t.accessToken]:null,e=>(0,i.we)(e).then(e=>e.data))},v=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/test_action?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.eh)(e,{arg:{action_id:r.action_id,action_type:r.action_type,parameters:r.parameters}})})},k=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/update_custom_action_excluded_channels?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{action_id:r.action_id,excluded_channels:r.excluded_channels}})})},w=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/update_integration_action_excluded_channels?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,excluded_channels:r.excluded_channels}})})},z=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_integration_action_config?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,config:r.config}})})},C=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_custom_action_available_for_automations?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{action_id:r.action_id,available_for_automations:r.available_for_automations}})})},S=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_integration_action_available_for_automations?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,available_for_automations:r.available_for_automations}})})},T=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_system_action_available_for_automations?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,available_for_automations:r.available_for_automations}})})},A=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_custom_action_available_for_customer_lookup?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{action_id:r.action_id,available_for_customer_lookup:r.available_for_customer_lookup}})})},E=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_integration_action_available_for_customer_lookup?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,available_for_customer_lookup:r.available_for_customer_lookup}})})},I=e=>{let{user:t}=(0,s.J)();return(0,a.A)(t&&e?["/set_system_action_available_for_customer_lookup?agent_id=".concat(e),t.accessToken]:null,(e,t)=>{let{arg:r}=t;return(0,i.wf)(e,{arg:{callable_id:r.callable_id,available_for_customer_lookup:r.available_for_customer_lookup}})})}},91840:(e,t,r)=>{r.d(t,{A:()=>el});var n=r(37876),a=r(14232),i=r(30488),s=r(1924),l=r(39822),o=r(92146),c=r(72953),d=r(77362),g=r(44448),u=r(68495),h=r(9463),p=r(43123),m=r(7357),x=r(8091),f=r(95563),b=r(97120),_=r(70294),j=r(48230),y=r.n(j),v=r(89099),k=r(49038),w=r(22502),z=r(77876);let C=["cancel_shopify_order","cancel_medusa_order","cancel_magento_order"],S=e=>{let{serviceName:t,tools:r,locked:a,isDisabled:c=!1,isToggling:d=!1,onToggle:m,onTest:x,onEdit:f}=e;if(!r||0===r.length)return null;let b=[...r].sort((e,t)=>
1e.name.localeCompare(t.name));return(0,n.jsxs)(l.a,{children:[a&&(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Enable ",t," to turn these tools on."]}),(0,n.jsx)(p.s,{direction:"column",gap:3,opacity:a?.6:1,children:b.map(e=>(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"flex-start",gap:3,children:[(0,n.jsxs)(o.z,{gap:3,align:"flex-start",flex:1,minW:0,children:[(0,n.jsx)(l.a,{pt:"2px",onClick:t=>{t.stopPropagation(),c||d||a||m(e,!e.enabled)},cursor:c||a?"not-allowed":"pointer",children:(0,n.jsxs)(g.lq,{checked:e.enabled,onCheckedChange:t=>{c||a||m(e,t.checked)},disabled:c||d||a,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]})}),(0,n.jsxs)(s.T,{gap:0,align:"flex-start",minW:0,children:[(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"medium",children:e.name}),C.includes(e.name)&&(0,n.jsx)(u.f8,{colorPalette:"purple",size:"sm",variant:"subtle",children:(0,n.jsx)(u.d1,{children:"Beta"})})]}),e.description&&(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:e.description})]})]}),e.enabled&&!a&&(x||f)&&(0,n.jsxs)(o.z,{gap:1,alignItems:"center",flexShrink:0,children:[x&&(0,n.jsx)(h.K,{"aria-label":"Test Integration Action",size:"xs",variant:"ghost",colorPalette:"blue",onClick:()=>x(e),disabled:c,children:(0,n.jsx)(_.aze,{})}),f&&(0,n.jsx)(h.K,{"aria-label":"Edit Integration Action",size:"xs",variant:"ghost",colorPalette:"gray",onClick:()=>f(e),disabled:c,children:(0,n.jsx)(_.WXf,{})})]})]},e.id))})]})};var T=r(61385),A=r(72943),E=r(91553),I=r(40950),P=r(82703),R=r(52807),W=r(67878);let D=(0,r(57175).B)("button"),L=e=>{var t;let{sections:r,defaultOpenId:s=null,forceOpenId:c=null}=e,[d,g]=(0,a.useState)(s),u=(0,a.useRef)(!1);if((0,a.useEffect)(()=>{u.current||g(s)},[s]),(0,a.useEffect)(()=>{c&&(u.current=!0,g(c))},[c]),0===r.length)return null;let h=null!=(t=r.find(e=>e.id===d))?t:null;return(0,n.jsxs)(l.a,{children:[(0,n.jsx)(o.z,{gap:4,flexWrap:"wrap",children:r.map(e=>{let t=e.id===d;return(0,n.jsxs)(D,{type:"button",display:"flex",alignItems:"center",gap:1.5,bg:"transparent",border:"none",p:0,cursor:"pointer","aria-expanded":t,onClick:()=>{u.current=!0,g(t?null:e.id)},color:t?"gray.900":"gray.500",_dark:{color:t?"gray.100":"gray.400"},_hover:{color:"gray.900",_dark:{color:"gray.100"}},children:[(0,n.jsx)(l.a,{display:"flex",color:"gray.400",transform:t?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s ease",children:(0,n.jsx)(_.fK4,{size:12})}),(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",children:e.label}),e.count&&(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.400",fontWeight:"normal",children:e.count})]},e.id)})}),h&&(0,n.jsx)(l.a,{mt:4,children:h.content})]})};function O(e,t){if(!t)return{...e};let r={...e};for(let[n,a]of Object.entries(t))a.secret&&function(e){if(null==e||"string"!=typeof e)return!1;let t=String(e).trim();return!!(""===t||/^[\*•·]{2,}$/.test(t)||/\*{2,}$/.test(t)&&t.length<=12||/^[\*•·]+$/.test(t)&&t.length<=12)}(e[n])&&delete r[n];return r}function X(e){var t,r,n,a;let i=null!=(t=null==e?void 0:e.ai_settings)?t:{};return{direct_message:null==(r=i.direct_message)||r,story_reply:null==(n=i.story_reply)||n,native_takeover:null==(a=i.native_takeover)||a}}let N=[],F=[],J=["email","amazon","whatsapp","instagram","messenger"],U={shopify:"ecommerce",medusa:"ecommerce",magento:"ecommerce",bigcommerce:"ecommerce",woocommerce:"ecommerce",prestashop:"ecommerce",sfcc:"ecommerce","salesforce commerce cloud":"ecommerce",qapla:"logistic",shippypro:"logistic",hubspot:"crm",attio:"crm",klaviyo:"crm",zendesk:"ticketing",freshdesk:"ticketing",helpdesk:"ticketing",crisp:"ticketing",callbell:"ticketing",slack:"ticketing"},$=["ecommerce","logistic","crm","ticketing"],H={ecommerce:{title:"Ecommerce",description:"Connect your online store to sync products, orders and customers"},logistic:{title:"Logistic",description:"Connect shipping and order tracking platforms"},crm:{title:"CRM",description:"Connect customer relationship platforms to sync contacts and deals"},ticketing:{title:"Ticketing",description:"Connect helpdesk, ticketing and team messaging platforms"}};function q(e){var t;return J.includes((null!=(t=e.service)?t:"").toLowerCase())}let M=["messenger","instagram"],B=[{key:"after_public_reply_id",label:"When the AI replies publicly to a customer",description:"Applied after the AI sends a public reply to the requester.",placeholder:"e.g. solved or 1900000771674"},{key:"after_create_ticket_id",label:"When the AI creates a new ticket",description:"Applied to brand-new tickets created by the AI.",placeholder:"e.g. pending or 1900000771634"},{key:"after_escalation_id",label:"When the AI hands off to a human or writes a copilot note",description:"Applied after escalations and private/internal notes.",placeholder:"e.g. pending or 1900000771634"}],K=[{key:"after_public_reply_id",label:"When the AI replies publicly to a customer",description:"Applied after the AI sends a public reply to the requester.",placeholder:"e.g. 4 (Resolved)"},{key:"after_create_ticket_id",label:"When the AI creates a new ticket",description:"Applied to brand-new tickets created by the AI.",placeholder:"e.g. 3 (Pending)"},{key:"after_escalation_id",label:"When the AI hands off to a human or writes a copilot note",description:"Applied after escalations and private/internal notes.",placeholder:"e.g. 3 (Pending)"}],Z=["new","open","pending","hold","solved","closed"],Y=["open","pending","resolved","closed"],G=e=>null==e?"":String(e),V=e=>{let t=e.trim();return""===t?null:/^\d+$/.test(t)?Number(t):t},Q=e=>({after_public_reply_id:G(null==e?void 0:e.after_public_reply_id),after_create_ticket_id:G(null==e?void 0:e.after_create_ticket_id),after_escalation_id:G(null==e?void 0:e.after_escalation_id)}),ee=e=>{var t,r,g;let{integration:u,savedCreds:h,isPrivate:p,isDisabled:m,onSaved:x,saveCredentials:f}=e,b="freshdesk"===(null!=(t=u.service)?t:"").toLowerCase(),j=b?Y:Z,[y,v]=(0,a.useState)(()=>Q(h.status_mapping)),[k,w]=(0,a.useState)(!1),z=JSON.stringify(null!=(r=h.status_mapping)?r:{});(0,a.useEffect)(()=>{v(Q(h.status_mapping))},[z]);let C=Q(h.status_mapping),S=y.after_public_reply_id.trim()!==C.after_public_reply_id.trim()||y.after_create_ticket_id.trim()!==C.after_create_ticket_id.trim()||y.after_escalation_id.trim()!==C.after_escalation_id.trim(),A=Object.values(null!=(g=h.status_mapping)?g:{}).some(e=>null!=e&&""!==e),E=async()=>{w(!0);let e=O(h.credentials,u.credentials_schema),t={after_public_reply_id:V(y.after_public_reply_id),after_create_ticket_id:V(y.after_create_ticket_id),after_escalation_id:V(y.after_escalation_id)};try{await f({integration_id:u.id,credentials:e,status_mapping:t}),x(),T.X.create({title:"Ticket status automation saved",type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error saving status automation",description:(null==e?void 0:e.message)||"Please try again.",type:"error",duration:3e3,closable:!0})}finally{w(!1)}},I=async()=>{w(!0);let e=O(h.credentials,u.credentials_schema);try{await f({integration_id:u.id,credentials:e,status_mapping:{}}),x(),T.X.create({title:"Ticket status automation reset",type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error resetting status automation",description:(null==e?void 0:e.message)||"Please try again.",type:"error",duration:3e3,closable:!0})}finally{w(!1)}},P=p&&""!==y.after_public_reply_id.trim();return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Ticket status automation"}),A&&(0,n.jsxs)(c.$,{size:"xs",variant:"ghost",colorPalette:"red",onClick:I,loading:k,disabled:m,children:[(0,n.jsx)(_.IXo,{}),"Reset all"]})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Automatically transition the ",b?"Freshdesk":"Zendesk"," ticket to a specific status after key AI actions.",b?(0,n.jsxs)(n.Fragment,{children:[" Enter the numeric status ID (e.g. ",(0,n.jsx)("strong",{children:"4"})," for Resolved). Standard IDs are 2 Open, 3 Pending, 4 Resolved, 5 Closed; the status names (",j.join(", "),") are also accepted. Leave empty to keep Freshdesk's default behavior."]}):(0,n.jsxs)(n.Fragment,{children:[" Enter a custom status ID (e.g. ",(0,n.jsx)("strong",{children:"1900000771674"}),") or one of the standard statuses: ",j.join(", "),". Leave empty to keep Zendesk's default behavior."]})]}),(0,n.jsxs)(s.T,{gap:4,align:"stretch",children:[(b?K:B).map(e=>(0,n.jsxs)(l.a,{children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",mb:1,children:e.label}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mb:2,children:e.description}),(0,n.jsx)(d.p,{size:"sm",value:y[e.key],onChange:t=>{var r,n;return r=e.key,n=t.target.value,void v(e=>({...e,[r]:n}))},placeholder:e.placeholder,disabled:m}),"after_public_reply_id"===e.key&&P&&(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mt:1,children:"Note: copilot mode is on, so the AI usually writes private notes. This status only applies when the AI actually sends a public reply."})]},e.key)),S&&(0,n.jsxs)(o.z,{gap:2,mt:1,children:[(0,n.jsx)(c.$,{size:"sm",colorPalette:"blue",onClick:E,loading:k,disabled:m,children:"Save status automation"}),(0,n.jsx)(c.$,{size:"sm",variant:"ghost",onClick:()=>v(Q(h.status_mapping)),disabled:m||k,children:"Cancel"})]})]})]})},et=e=>{var t,r,d;let{agentId:g,isDisabled:p=!1}=e,{data:m,mutate:x,isLoading:j,error:y}=(0,w.Kl)(g),{trigger:v,isMutating:k}=(0,w.ic)(g),{trigger:z,isMutating:C}=(0,w.bQ)(g),[S,A]=(0,a.useState)(null),[E,I]=(0,a.useState)(!1),P=!!(null==m?void 0:m.registered),R=null!=(t=null==m?void 0:m.callback_base)?t:"",W=Object.keys(null!=(r=null==m?void 0:m.webhook_ids)?r:{}),D=async()=>{A(null);try{var e;let t=await v();if(!t||(null!=(e=t.created_count)?e:0)<1){let e="Shopify rejected the webhook subscription. This usually means your custom app is missing the `write_orders` access scope. Add it in your Shopify Admin, reinstall the app on your store, and try again.";
1A(e),T.X.create({title:"Could not register webhook",description:e,type:"error",duration:8e3,closable:!0}),await x();return}await x(),T.X.create({title:"Conversion tracking connected",description:"Shopify orders/paid webhook registered successfully.",type:"success",duration:4e3,closable:!0})}catch(t){let e=t.message||"Failed to register webhook.";A(e),T.X.create({title:"Could not register webhook",description:e,type:"error",duration:6e3,closable:!0})}},L=async()=>{I(!1),A(null);try{var e;let t=await z();await x();let r=(null!=(e=null==t?void 0:t.deleted_count)?e:0)>=1;T.X.create({title:r?"Conversion tracking disconnected":"Already disconnected",description:r?"New orders will no longer be tracked. Historical attribution data is preserved.":"No active webhook subscription was registered.",type:"success",duration:4e3,closable:!0})}catch(e){T.X.create({title:"Could not disconnect",description:e.message||"Failed to remove webhook.",type:"error",duration:6e3,closable:!0})}};return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Conversion tracking"}),!j&&!y&&(P?(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Connected"})}):(0,n.jsx)(u.f8,{colorPalette:"gray",size:"sm",children:(0,n.jsx)(u.d1,{children:"Not connected"})}))]}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Refresh status",onClick:()=>x(),disabled:p||j,title:"Refresh status",children:(0,n.jsx)(_.jTZ,{})})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Register a Shopify ",(0,n.jsx)("strong",{children:"orders/paid"})," webhook so we can attribute paid orders back to your AI agent. Disconnecting stops new attribution but preserves historical data."]}),j?(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(f.y,{size:"xs"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Checking webhook status…"})]}):y?(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"red.50",_dark:{bg:"red.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",flex:1,children:[(0,n.jsxs)(i.E,{fontSize:"xs",color:"red.700",_dark:{color:"red.300"},children:["Could not load webhook status. ",null!=(d=null==y?void 0:y.message)?d:""]}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",colorPalette:"red",alignSelf:"flex-start",onClick:()=>x(),disabled:p,children:[(0,n.jsx)(_.jTZ,{}),"Try again"]})]})]})}):P?(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"green.50",_dark:{bg:"green.900/30"},children:(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(_.YrT,{}),(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"semibold",color:"green.700",_dark:{color:"green.300"},children:"Webhook registered"})]}),W.length>0&&(0,n.jsxs)(o.z,{gap:2,alignItems:"center",flexWrap:"wrap",children:[(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Topics:"}),W.map(e=>(0,n.jsx)(u.f8,{size:"sm",variant:"subtle",colorPalette:"green",children:(0,n.jsx)(u.d1,{children:e})},e))]}),R&&(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",minW:"fit-content",children:"Callback:"}),(0,n.jsx)(i.E,{fontSize:"xs",wordBreak:"break-all",color:"gray.600",_dark:{color:"gray.400"},children:R})]})]})}),(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsxs)(c.$,{size:"xs",variant:"outline",onClick:D,loading:k,disabled:p||C,children:[(0,n.jsx)(_.jTZ,{}),"Reconnect"]}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",colorPalette:"red",onClick:()=>I(!0),disabled:p||k||C,children:[(0,n.jsx)(_.IXo,{}),"Disconnect"]})]})]}):(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[S&&(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"orange.50",_dark:{bg:"orange.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",color:"orange.500",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsx)(i.E,{fontSize:"xs",color:"orange.700",_dark:{color:"orange.300"},children:S})]})}),(0,n.jsxs)(c.$,{size:"xs",colorPalette:"blue",onClick:D,loading:k,disabled:p,alignSelf:"flex-start",children:[(0,n.jsx)(_.ayE,{}),S?"Try again":"Connect conversion tracking"]})]}),(0,n.jsxs)(b.Dz,{open:E,onOpenChange:e=>I(e.open),placement:"center",motionPreset:"slide-in-bottom",children:[(0,n.jsx)(b.Xi,{}),(0,n.jsxs)(b.Cf,{maxW:"md",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",margin:"0",...{},children:[(0,n.jsx)(b.c7,{fontSize:"lg",fontWeight:"bold",children:"Disconnect conversion tracking?"}),(0,n.jsx)(b.R4,{children:(0,n.jsx)(i.E,{fontSize:"sm",children:"New paid orders will no longer be attributed to your AI agent. Existing attribution data will be preserved and remain visible in your analytics. You can reconnect at any time."})}),(0,n.jsxs)(b.Es,{gap:3,children:[(0,n.jsx)(c.$,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),(0,n.jsx)(c.$,{colorPalette:"red",onClick:L,loading:C,children:"Disconnect"})]}),(0,n.jsx)(b.tK,{})]})]})]})},er=e=>{var t,r,d;let{agentId:g,isDisabled:p=!1}=e,{user:x}=(0,A.J)(),{data:b,mutate:j,isLoading:v,error:k}=(0,w.AS)(g),[z,C]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),I=!!(null==b?void 0:b.configured),P=null!=(t=null==b?void 0:b.webhook_url)?t:"",R=null!=(r=null==b?void 0:b.signing_secret)?r:"",W=async(e,t)=>{if(e)try{await navigator.clipboard.writeText(e),T.X.create({title:"".concat(t," copied"),type:"success",duration:2e3,closable:!0})}catch(e){T.X.create({title:"Could not copy ".concat(t.toLowerCase()),description:"Copy it manually from the field.",type:"error",duration:4e3,closable:!0})}},D=async()=>{C(!0);try{let e=await fetch("".concat("https://orygobackend-production.up.railway.app","/download_prestashop_module/").concat(g));if(!e.ok){let t="Download failed (".concat(e.status,")");try{let r=await e.json();t=r.message||r.detail||t}catch(e){}throw Error(t)}let t=await e.blob(),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="orygoconversion-1.1.0.zip",document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(r),T.X.create({title:"Module downloaded",description:"Upload orygoconversion-1.1.0.zip in PrestaShop → Modules → Upload a module.",type:"success",duration:5e3,closable:!0})}catch(e){T.X.create({title:"Could not download module",description:e.message||"Please try again.",type:"error",duration:6e3,closable:!0})}finally{C(!1)}},L=e=>{let{label:t,value:r,secret:a=!1}=e,c=a&&!S,d=r?c?"•".repeat(24):r:"—";return(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:t}),(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(l.a,{flex:1,px:2.5,py:1.5,borderRadius:"md",borderWidth:"1px",borderColor:"gray.200",_dark:{borderColor:"gray.600",bg:"gray.800"},bg:"gray.50",overflow:"hidden",children:(0,n.jsx)(i.E,{fontSize:"xs",fontFamily:"mono",wordBreak:"break-all",color:"gray.700",_dark:{color:"gray.300"},children:d})}),a&&(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":c?"Reveal secret":"Hide secret",title:c?"Reveal secret":"Hide secret",onClick:()=>E(e=>!e),disabled:!r,children:c?(0,n.jsx)(_.Vap,{}):(0,n.jsx)(_._NO,{})}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Copy ".concat(t.toLowerCase()),title:"Copy ".concat(t.toLowerCase()),onClick:()=>W(r,t),disabled:!r,children:(0,n.jsx)(_.nxz,{})})]})]})};return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Conversion tracking"}),!v&&!k&&(I?(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Ready"})}):(0,n.jsx)(u.f8,{colorPalette:"orange",size:"sm",children:(0,n.jsx)(u.d1,{children:"Needs setup"})}))]}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Refresh setup",onClick:()=>j(),disabled:p||v,title:"Refresh setup",children:(0,n.jsx)(_.jTZ,{})})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Attribute paid PrestaShop orders to your AI agent by installing the Orygo module on your store. Download it below, then paste the webhook URL and signing secret into the module’s config screen."," ",(0,n.jsxs)(m.N,{as:y(),href:"/docs/prestashop",target:"_blank",color:"blue.500",children:["Setup guide ",(0,n.jsx)(_.HaR,{style:{display:"inline",verticalAlign:"middle"}})]})]}),v?(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(f.y,{size:"xs"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Loading setup…"})]}):k?(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"red.50",_dark:{bg:"red.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",flex:1,children:[(0,n.jsxs)(i.E,{fontSize:"xs",color:"red.700",_dark:{color:"red.300"},children:["Could not load conversion setup. ",null!=(d=null==k?void 0:k.message)?d:""]}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",colorPalette:"red",alignSelf:"flex-start",onClick:()=>j(),disabled:p,children:[(0,n.jsx)(_.jTZ,{}),"Try again"]})]})]})}):(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[!I&&(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"orange.50",_dark:{bg:"orange.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",color:"orange.500",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsx)(i.E,{fontSize:"xs",color:"orange.700",_dark:{color:"orange.300"},children:"Signing secret not provisioned yet. Re-save your PrestaShop credentials above to generate one, then refresh."})]})}),(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"1. Install the module"}),(0,n.jsxs)(c.$,{size:"xs",colorPalette:"blue",onClick:D,loading:z,disabled:p,alignSelf:"flex-start",children:[(0,n.jsx)(_.a4x,{}),"Download module (.zip)"]}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"In PrestaShop: Modules → Module Manager → Upload a module → select the ZIP → Install."})]}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"2. Paste into the module’s config screen"}),(0,n.jsx)(L,{label:"Webhook URL",value:P}),(0,n.jsx)(L,{label:"Signing secret",value:R,secret:!0})]})]})]})},en=()=>(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",mb:1,children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Conversion tracking"}),(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Active"})})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Paid BigCommerce orders are automatically attributed to your AI agent — no setup required."," ",(0,n.jsxs)(m.N,{as:y(),href:"/docs/bigcommerce",target:"_blank",color:"blue.500",children:["Learn more ",(0,n.jsx)(_.HaR,{style:{display:"inline",verticalAlign:"middle"}})]})]}),(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"green.50",_dark:{bg:"green.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",color:"green.500",children:(0,n.jsx)(_.YrT,{})}),(0,n.jsx)(i.E,{fontSize:"xs",color:"green.700",_dark:{color:"green.300"},children:"The order webhook was registered automatically when you connected BigCommerce. We match each paid order back to the visitor via the cart created from the chat, so conversions are tracked out of the box."})]})})]}),ea=e=>{var t,r,d;let{agentId:g,isDisabled:p=!1}=e,{user:x}=(0,A.J)(),{data:b,mutate:j,isLoading:v,error:k}=(0,w.Sv)(g),[z,C]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),I=!!(null==b?void 0:b.configured),P=null!=(t=null==b?void 0:b.webhook_url)?t:"",R=null!=(r=null==b?void 0:b.signing_secret)?r:"",W=async(e,t)=>{if(e)try{await navigator.clipboard.writeText(e),T.X.create({title:"".concat(t," copied"),type:"success",duration:2e3,closable:!0})}catch(e){T.X.create({title:"Could not copy ".concat(t.toLowerCase()),description:"Copy it manually from the field.",type:"error",duration:4e3,closable:!0})}},D=async()=>{C(!0);try{let e=await fetch("".concat("https://orygobackend-production.up.railway.app","/download_magento_module/").concat(g));if(!e.ok){let t="Download failed (".concat(e.status,")");try{let r=await e.json();t=r.message||r.detail||t}catch(e){}throw Error(t)}let t=await e.blob(),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="Orygo_Conversion-1.1.0.zip",document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(r),T.X.create({title:"Module downloaded",description:"Unzip into app/code/Orygo/Conversion, then run bin/magento setup:upgrade.",type:"success",duration:5e3,closable:!0})}catch(e){T.X.create({title:"Could not download module",description:e.message||"Please try again.",type:"error",duration:6e3,closable:!0})}finally{C(!1)}},L=e=>{let{label:t,value:r,secret:a=!1}=e,c=a&&!S,d=r?c?"•".repeat(24):r:"—";return(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:t}),(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(l.a,{flex:1,px:2.5,py:1.5,borderRadius:"md",borderWidth:"1px",borderColor:"gray.200",_dark:{borderColor:"gray.600",bg:"gray.800"},bg:"gray.50",overflow:"hidden",children:(0,n.jsx)(i.E,{fontSize:"xs",fontFamily:"mono",wordBreak:"break-all",color:"gray.700",_dark:{color:"gray.300"},children:d})}),a&&(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":c?"Reveal secret":"Hide secret",title:c?"Reveal secret":"Hide secret",onClick:()=>E(e=>!e),disabled:!r,children:c?(0,n.jsx)(_.Vap,{}):(0,n.jsx)(_._NO,{})}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Copy ".concat(t.toLowerCase()),title:"Copy ".concat(t.toLowerCase()),onClick:()=>W(r,t),disabled:!r,children:(0,n.jsx)(_.nxz,{})})]})]})};return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Conversion tracking"}),!v&&!k&&(I?(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Ready"})}):(0,n.jsx)(u.f8,{colorPalette:"orange",size:"sm",children:(0,n.jsx)(u.d1,{children:"Needs setup"})}))]}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Refresh setup",onClick:()=>j(),disabled:p||v,title:"Refresh setup",children:(0,n.jsx)(_.jTZ,{})})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Attribute paid Magento orders to your AI agent by installing the Orygo module on your store. Download it below, then paste the webhook URL and signing secret into the module’s config screen."," ",(0,n.jsxs)(m.N,{as:y(),href:"/docs/magento",target:"_blank",color:"blue.500",children:["Setup guide ",(0,n.jsx)(_.HaR,{style:{display:"inline",verticalAlign:"middle"}})]})]}),v?(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(f.y,{size:"xs"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Loading setup…"})]}):k?(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"red.50",_dark:{bg:"red.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",flex:1,children:[(0,n.jsxs)(i.E,{fontSize:"xs",color:"red.700",_dark:{color:"red.300"},children:["Could not load conversion setup. ",null!=(d=null==k?void 0:k.message)?d:""]}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",colorPalette:"red",alignSelf:"flex-start",onClick:()=>j(),disabled:p,children:[(0,n.jsx)(_.jTZ,{}),"Try again"]})]})]})}):(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[!I&&(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"orange.50",_dark:{bg:"orange.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",color:"orange.500",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsx)(i.E,{fontSize:"xs",color:"orange.700",_dark:{color:"orange.300"},children:"Signing secret not provisioned yet. Re-save your Magento credentials above to generate one, then refresh."})]})}),(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"1. Install the module"}),(0,n.jsxs)(c.$,{size:"xs",colorPalette:"blue",onClick:D,loading:z,dis
1abled:p,alignSelf:"flex-start",children:[(0,n.jsx)(_.a4x,{}),"Download module (.zip)"]}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Unzip into app/code/Orygo/Conversion, then run bin/magento setup:upgrade && bin/magento cache:flush."})]}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"2. Paste into Stores → Configuration → Orygo → Conversion Tracking"}),(0,n.jsx)(L,{label:"Webhook URL",value:P}),(0,n.jsx)(L,{label:"Signing secret",value:R,secret:!0})]})]})]})},ei=e=>{var t,r,d;let{agentId:g,isDisabled:p=!1}=e,{user:x}=(0,A.J)(),{data:b,mutate:j,isLoading:v,error:k}=(0,w._k)(g),[z,C]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),I=!!(null==b?void 0:b.configured),P=null!=(t=null==b?void 0:b.webhook_url)?t:"",R=null!=(r=null==b?void 0:b.signing_secret)?r:"",W=async(e,t)=>{if(e)try{await navigator.clipboard.writeText(e),T.X.create({title:"".concat(t," copied"),type:"success",duration:2e3,closable:!0})}catch(e){T.X.create({title:"Could not copy ".concat(t.toLowerCase()),description:"Copy it manually from the field.",type:"error",duration:4e3,closable:!0})}},D=async()=>{C(!0);try{let e=await fetch("".concat("https://orygobackend-production.up.railway.app","/download_sfcc_cartridge/").concat(g));if(!e.ok){let t="Download failed (".concat(e.status,")");try{let r=await e.json();t=r.message||r.detail||t}catch(e){}throw Error(t)}let t=await e.blob(),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="int_orygo_conversion-1.1.0.zip",document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(r),T.X.create({title:"Cartridge downloaded",description:"Deploy int_orygo_conversion via your code pipeline, then follow the setup guide.",type:"success",duration:5e3,closable:!0})}catch(e){T.X.create({title:"Could not download cartridge",description:e.message||"Please try again.",type:"error",duration:6e3,closable:!0})}finally{C(!1)}},L=e=>{let{label:t,value:r,secret:a=!1}=e,c=a&&!S,d=r?c?"•".repeat(24):r:"—";return(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:t}),(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(l.a,{flex:1,px:2.5,py:1.5,borderRadius:"md",borderWidth:"1px",borderColor:"gray.200",_dark:{borderColor:"gray.600",bg:"gray.800"},bg:"gray.50",overflow:"hidden",children:(0,n.jsx)(i.E,{fontSize:"xs",fontFamily:"mono",wordBreak:"break-all",color:"gray.700",_dark:{color:"gray.300"},children:d})}),a&&(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":c?"Reveal secret":"Hide secret",title:c?"Reveal secret":"Hide secret",onClick:()=>E(e=>!e),disabled:!r,children:c?(0,n.jsx)(_.Vap,{}):(0,n.jsx)(_._NO,{})}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Copy ".concat(t.toLowerCase()),title:"Copy ".concat(t.toLowerCase()),onClick:()=>W(r,t),disabled:!r,children:(0,n.jsx)(_.nxz,{})})]})]})};return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Conversion tracking"}),!v&&!k&&(I?(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Ready"})}):(0,n.jsx)(u.f8,{colorPalette:"orange",size:"sm",children:(0,n.jsx)(u.d1,{children:"Needs setup"})}))]}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Refresh setup",onClick:()=>j(),disabled:p||v,title:"Refresh setup",children:(0,n.jsx)(_.jTZ,{})})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Attribute paid SFCC orders to your AI agent by deploying the Orygo cartridge to your storefront. Download it below, deploy it through your code pipeline, then paste the webhook URL and signing secret into the cartridge’s site preferences."," ",(0,n.jsxs)(m.N,{as:y(),href:"/docs/sfcc",target:"_blank",color:"blue.500",children:["Setup guide ",(0,n.jsx)(_.HaR,{style:{display:"inline",verticalAlign:"middle"}})]})]}),v?(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(f.y,{size:"xs"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Loading setup…"})]}):k?(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"red.50",_dark:{bg:"red.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",flex:1,children:[(0,n.jsxs)(i.E,{fontSize:"xs",color:"red.700",_dark:{color:"red.300"},children:["Could not load conversion setup. ",null!=(d=null==k?void 0:k.message)?d:""]}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",colorPalette:"red",alignSelf:"flex-start",onClick:()=>j(),disabled:p,children:[(0,n.jsx)(_.jTZ,{}),"Try again"]})]})]})}):(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[!I&&(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"orange.50",_dark:{bg:"orange.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",color:"orange.500",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsx)(i.E,{fontSize:"xs",color:"orange.700",_dark:{color:"orange.300"},children:"Signing secret not provisioned yet. Re-save your SFCC credentials above to generate one, then refresh."})]})}),(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"1. Deploy the cartridge"}),(0,n.jsxs)(c.$,{size:"xs",colorPalette:"blue",onClick:D,loading:z,disabled:p,alignSelf:"flex-start",children:[(0,n.jsx)(_.a4x,{}),"Download cartridge (.zip)"]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",children:["Unlike a Business Manager upload, the cartridge installs through your code-deploy pipeline: deploy the code (sfcc-ci / SFRA build), add"," ",(0,n.jsx)(i.E,{as:"span",fontFamily:"mono",children:"int_orygo_conversion"})," to the site cartridge path before ",(0,n.jsx)(i.E,{as:"span",fontFamily:"mono",children:"app_storefront_base"}),", then import the cartridge metadata. See the setup guide for the full steps."]})]}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"2. Paste into the cartridge’s site preferences (Orygo Conversion Tracking)"}),(0,n.jsx)(L,{label:"Webhook URL",value:P}),(0,n.jsx)(L,{label:"Signing secret",value:R,secret:!0})]})]})]})},es=e=>{var t,r,d;let{agentId:g,isDisabled:p=!1}=e,{user:x}=(0,A.J)(),{data:b,mutate:j,isLoading:v,error:k}=(0,w.j$)(g),[z,C]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),I=!!(null==b?void 0:b.configured),P=null!=(t=null==b?void 0:b.webhook_url)?t:"",R=null!=(r=null==b?void 0:b.signing_secret)?r:"",W=async(e,t)=>{if(e)try{await navigator.clipboard.writeText(e),T.X.create({title:"".concat(t," copied"),type:"success",duration:2e3,closable:!0})}catch(e){T.X.create({title:"Could not copy ".concat(t.toLowerCase()),description:"Copy it manually from the field.",type:"error",duration:4e3,closable:!0})}},D=async()=>{C(!0);try{let e=await fetch("".concat("https://orygobackend-production.up.railway.app","/download_w
1oocommerce_plugin/").concat(g));if(!e.ok){let t="Download failed (".concat(e.status,")");try{let r=await e.json();t=r.message||r.detail||t}catch(e){}throw Error(t)}let t=await e.blob(),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="orygo-conversion-1.1.0.zip",document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(r),T.X.create({title:"Plugin downloaded",description:"Upload orygo-conversion-1.1.0.zip in Plugins → Add New → Upload Plugin, then activate.",type:"success",duration:5e3,closable:!0})}catch(e){T.X.create({title:"Could not download plugin",description:e.message||"Please try again.",type:"error",duration:6e3,closable:!0})}finally{C(!1)}},L=e=>{let{label:t,value:r,secret:a=!1}=e,c=a&&!S,d=r?c?"•".repeat(24):r:"—";return(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:t}),(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(l.a,{flex:1,px:2.5,py:1.5,borderRadius:"md",borderWidth:"1px",borderColor:"gray.200",_dark:{borderColor:"gray.600",bg:"gray.800"},bg:"gray.50",overflow:"hidden",children:(0,n.jsx)(i.E,{fontSize:"xs",fontFamily:"mono",wordBreak:"break-all",color:"gray.700",_dark:{color:"gray.300"},children:d})}),a&&(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":c?"Reveal secret":"Hide secret",title:c?"Reveal secret":"Hide secret",onClick:()=>E(e=>!e),disabled:!r,children:c?(0,n.jsx)(_.Vap,{}):(0,n.jsx)(_._NO,{})}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Copy ".concat(t.toLowerCase()),title:"Copy ".concat(t.toLowerCase()),onClick:()=>W(r,t),disabled:!r,children:(0,n.jsx)(_.nxz,{})})]})]})};return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Conversion tracking"}),!v&&!k&&(I?(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Ready"})}):(0,n.jsx)(u.f8,{colorPalette:"orange",size:"sm",children:(0,n.jsx)(u.d1,{children:"Needs setup"})}))]}),(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Refresh setup",onClick:()=>j(),disabled:p||v,title:"Refresh setup",children:(0,n.jsx)(_.jTZ,{})})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["Attribute paid WooCommerce orders to your AI agent by installing the Orygo plugin on your store. Download it below, then paste the webhook URL and signing secret into the plugin’s settings screen."," ",(0,n.jsxs)(m.N,{as:y(),href:"/docs/woocommerce",target:"_blank",color:"blue.500",children:["Setup guide ",(0,n.jsx)(_.HaR,{style:{display:"inline",verticalAlign:"middle"}})]})]}),v?(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(f.y,{size:"xs"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Loading setup…"})]}):k?(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"red.50",_dark:{bg:"red.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",flex:1,children:[(0,n.jsxs)(i.E,{fontSize:"xs",color:"red.700",_dark:{color:"red.300"},children:["Could not load conversion setup. ",null!=(d=null==k?void 0:k.message)?d:""]}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",colorPalette:"red",alignSelf:"flex-start",onClick:()=>j(),disabled:p,children:[(0,n.jsx)(_.jTZ,{}),"Try again"]})]})]})}):(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[!I&&(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"orange.50",_dark:{bg:"orange.900/30"},children:(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(l.a,{mt:"2px",color:"orange.500",children:(0,n.jsx)(_.eHT,{})}),(0,n.jsx)(i.E,{fontSize:"xs",color:"orange.700",_dark:{color:"orange.300"},children:"Signing secret not provisioned yet. Re-save your WooCommerce credentials above to generate one, then refresh."})]})}),(0,n.jsxs)(s.T,{gap:1,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"1. Install the plugin"}),(0,n.jsxs)(c.$,{size:"xs",colorPalette:"blue",onClick:D,loading:z,disabled:p,alignSelf:"flex-start",children:[(0,n.jsx)(_.a4x,{}),"Download plugin (.zip)"]}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"In WordPress: Plugins → Add New → Upload Plugin → select the ZIP → Install Now → Activate."})]}),(0,n.jsxs)(s.T,{gap:2,align:"stretch",children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"medium",color:"gray.500",children:"2. Paste into WooCommerce → Orygo Conversion"}),(0,n.jsx)(L,{label:"Webhook URL",value:P}),(0,n.jsx)(L,{label:"Signing secret",value:R,secret:!0})]})]})]})},el=e=>{let{agentId:t,isDisabled:r=!1,mode:f="all",channelFilter:b,renderBelowCard:j,onToolTest:C,onToolEdit:A}=e,[D,J]=(0,a.useState)(!1),[B,K]=(0,a.useState)(null),[Z,Y]=(0,a.useState)({}),[G,V]=(0,a.useState)(!1),[Q,el]=(0,a.useState)(!1),[eo,ec]=(0,a.useState)(null),[ed,eg]=(0,a.useState)(null),[eu,eh]=(0,a.useState)(""),[ep,em]=(0,a.useState)(!1),{data:ex,mutate:ef,error:eb}=(0,w.ZZ)(t||null),{data:e_,mutate:ej,error:ey}=(0,w.zm)(t||null),{trigger:ev,isMutating:ek}=(0,w.Tc)(t||null),{trigger:ew,isMutating:ez}=(0,w.rJ)(t||null),{trigger:eC,isMutating:eS}=(0,w.G$)(t||null),{trigger:eT}=(0,w.XH)(t||null),{data:eA,mutate:eE}=(0,z.pT)(t||null),{trigger:eI,isMutating:eP}=(0,z.bB)(t||null),{trigger:eR,isMutating:eW}=(0,z.GW)(t||null),eD=a.useMemo(()=>{let e={};
1return(null!=eA?eA:[]).forEach(t=>{let r=t.integration_id;e[r]||(e[r]=[]),e[r].push(t)}),e},[eA]),eL=async(e,t)=>{try{t?await eI({callable_id:e.id}):await eR({callable_id:e.id}),eE(),T.X.create({title:t?"Integration action enabled":"Integration action disabled",description:"".concat(e.name," has been ").concat(t?"activated":"deactivated","."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error",description:e.message||"An error occurred. Please try again.",type:"error",duration:3e3,closable:!0})}},{resolvedTheme:eO}=(0,P.j)(),eX=(0,v.useRouter)(),{trigger:eN,isMutating:eF}=(0,w.fU)(),eJ=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(!eX.isReady||eJ.current)return;let e=eX.query.meta_success,t=eX.query.meta_error;if(!e&&!t)return;if(eJ.current=!0,"true"===e){let e=eX.query.messenger||"0",t=eX.query.instagram||"0";T.X.create({title:"Connected successfully",description:"Connected: ".concat(e," Messenger page(s), ").concat(t," Instagram account(s)"),type:"success",duration:5e3,closable:!0})}t&&T.X.create({title:"Connection failed",description:{access_denied:"Facebook login was cancelled.",token_exchange_failed:"Failed to connect with Facebook. Please try again.",pages_fetch_failed:"Could not retrieve your Facebook Pages.",no_pages_found:"No Facebook Pages found on your account."}[t]||"Connection failed: ".concat(t),type:"error",duration:5e3,closable:!0});let r={...eX.query};delete r.meta_success,delete r.meta_error,delete r.messenger,delete r.instagram,eX.replace({pathname:eX.pathname,query:r},void 0,{shallow:!0}),ej()},[eX.isReady,eX.query]);let eU=["email","amazon","instagram","messenger"],e$=((null==ex?void 0:ex.filter(e=>{var t;return"direct"===e.channel_type&&"whatsapp"!==(null!=(t=e.service)?t:"").toLowerCase()}))||[]).sort((e,t)=>{var r,n;let a=eU.indexOf(null==(r=e.service)?void 0:r.toLowerCase()),i=eU.indexOf(null==(n=t.service)?void 0:n.toLowerCase());return(-1===a?999:a)-(-1===i?999:i)}),eH=b?Array.isArray(b)?b:[b]:null;eH&&(e$=e$.filter(e=>{var t;return eH.includes((null!=(t=e.service)?t:"").toLowerCase())}));let eq=(null==ex?void 0:ex.filter(e=>"direct"!==e.channel_type))||[],eM={ecommerce:[],logistic:[],crm:[],ticketing:[]};for(let e of eq)eM[function(e){var t,r;return null!=(r=U[(null!=(t=e.service)?t:"").toLowerCase()])?r:"ticketing"}(e)].push(e);for(let e of $)eM[e].sort((e,t)=>{var r,n;return(null!=(r=e.service)?r:"").localeCompare(null!=(n=t.service)?n:"")});let eB=e=>null==e_?void 0:e_.find(t=>t.integration_id===e),eK=e=>!!eB(e),eZ=e=>{let t=eB(e);return(null==t?void 0:t.integration_enabled)===!0},eY=e=>{K(e.id),V(!1);let t=eB(e.id),r={};e.credentials_schema&&Object.keys(e.credentials_schema).forEach(e=>{(null==t?void 0:t.credentials)&&void 0!==t.credentials[e]?r[e]=t.credentials[e]:r[e]=""}),Y(r),q(e)||J(!0)},eG=async(e,t)=>{let r=eK(e.id),n=eZ(e.id);if(t)if(r){if(!n)try{await ew({integration_id:e.id}),ej(),T.X.create({title:"Integration enabled",description:"".concat(e.service," has been activated."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error enabling integration",description:e.message||"An error occurred while enabling the integration.",type:"error",duration:3e3,closable:!0})}}else(e=>{K(e.id),V(!0);let t={};e.credentials_schema&&Object.keys(e.credentials_schema).forEach(e=>{t[e]=""}),Y(t),q(e)||J(!0)})(e);else if(r&&n)try{await eC({integration_id:e.id}),ej(),T.X.create({title:"Integration disabled",description:"".concat(e.service," has been deactivated."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error disabling integration",description:e.message||"An error occurred while disabling the integration.",type:"error",duration:3e3,closable:!0})}},eV=()=>{J(!1),K(null),Y({}),V(!1)},eQ=async()=>{if(!B)return;let e=null==ex?void 0:ex.find(e=>e.id===B);if(!e)return;if(e.credentials_schema){for(let[t,r]of Object.entries(e.credentials_schema))if(r.required&&(!Z[t]||""===Z[t]))return void T.X.create({title:"Validation Error",description:"Field '".concat(t,"' is required."),type:"error",duration:3e3,closable:!0})}let t=O(Z,e.credentials_schema);try{if(await ev({integration_id:B,credentials:t}),G)try{await ew({integration_id:B})}catch(e){console.error("Failed to auto-enable credentials:",e)}eV(),ej(),T.X.create({title:"Credentials saved successfully",description:G?"The credentials have been saved and the integration is now active.":"The credentials have been updated.",type:"success",duration:3e3,closable:!0})}catch(e){console.error(e),T.X.create({title:"Error saving credentials",description:e.message||"An error occurred while saving the credentials. Please try again.",type:"error",duration:3e3,closable:!0})}},e0=()=>{t&&(window.location.href="".concat("https://orygobackend-production.up.railway.app","/oauth/meta/start?agent_id=").concat(t))},e1=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"both";if(t)try{await eN({agent_id:t,channel:e}),ej();let r="both"===e?"Messenger and Instagram":e.charAt(0).toUpperCase()+e.slice(1);T.X.create({title:"Disconnected successfully",description:"".concat(r," has been disconnected."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error disconnecting",description:e.message||"An error occurred while disconnecting.",type:"error",duration:3e3,closable:!0})}},e3=async(e,t)=>{let r=eB(e.id);if(!r)return;ec(e.id);let n=O(r.credentials,e.credentials_schema);try{await ev({integration_id:e.id,credentials:n,ai_enabled:t}),ej(),T.X.create({title:t?"AI agent enabled":"AI agent disabled",description:t?"The AI agent is now active on ".concat(e.service,"."):"The AI agent is now disabled on ".concat(e.service,"."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error updating AI setting",description:e.message||"An error occurred.",type:"error",duration:3e3,closable:!0})}finally{ec(null)}},e5=async(e,t,r)=>{let n=eB(e.id);if(!n)return;ec(e.id);let a=X(n.credentials),i={direct_message:a.direct_message,story_reply:a.story_reply,native_takeover:a.native_takeover,[t]:r},s=O({...n.credentials,ai_settings:i},e.credentials_schema),l="direct_message"===t?"Direct messages":"Story replies";try{var o;await ev({integration_id:e.id,credentials:s,ai_enabled:null==(o=n.ai_enabled)||o}),ej(),"native_takeover"===t?T.X.create({title:r?"Team takeover on":"Team takeover off",description:r?"The AI will pause when your team replies directly on ".concat(e.service,"."):"The AI keeps replying even if your team writes directly on ".concat(e.service,"."),type:"success",duration:3e3,closable:!0}):T.X.create({title:r?"".concat(l,": AI replies on"):"".concat(l,": AI replies off"),description:r?"The AI agent will reply to ".concat(l.toLowerCase()," on ").concat(e.service,"."):"".concat(l," will only appear in the inbox for a human on ").concat(e.service,"."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error updating AI setting",description:e.message||"An error occurred.",type:"error",duration:3e3,closable:!0})}finally{ec(null)}},e2=async(e,t)=>{let r=eB(e.id);if(!r)return;ec(e.id);let n=O(r.credentials,e.credentials_schema);try{await ev({integration_id:e.id,credentials:n,is_private:t}),ej(),T.X.create({title:t?"Private notes enabled":"Private notes disabled",description:t?"AI replies on ".concat(e.service," will be sent as private/internal notes."):"AI replies on ".concat(e.service," will be sent as public replies."),type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error updating notes setting",description:e.message||"An error occurred.",type:"error",duration:3e3,closable:!0})}finally{ec(null)}},e4=e=>{var t;return"freshdesk"===(null!=(t=e.service)?t:"").toLowerCase()}
1,e7=e=>(e=>{var t;return"zendesk"===(null!=(t=e.service)?t:"").toLowerCase()})(e)||e4(e),e8=e=>{var t;return"shopify"===(null!=(t=e.service)?t:"").toLowerCase()},e9=e=>{var t;return"prestashop"===(null!=(t=e.service)?t:"").toLowerCase()},e6=e=>{var t;return"bigcommerce"===(null!=(t=e.service)?t:"").toLowerCase()},te=e=>{var t;return"magento"===(null!=(t=e.service)?t:"").toLowerCase()},tt=e=>{var t;let r=(null!=(t=e.service)?t:"").toLowerCase();return"sfcc"===r||"salesforce commerce cloud"===r},tr=e=>{var t;return"woocommerce"===(null!=(t=e.service)?t:"").toLowerCase()},tn=e=>{let t=eB(e.id),r=null==t?void 0:t.copilot_filters;return!!(r&&(r.field_id||r.field_name))},ta=()=>{eg(null),eh("")},ti=()=>{let e=eu.trim();if(e&&ed){if(ed.direct_values.includes(e))return void eh("");eg(t=>t?{...t,direct_values:[...t.direct_values,e]}:t),eh("")}},ts=async e=>{if(!ed)return;let t=eB(e.id);if(!t)return;let r=ed.field_id.trim(),n=[...ed.direct_values],a=eu.trim();if(a&&!n.includes(a)&&n.push(a),!r)return void T.X.create({title:"Validation Error",description:"Please enter a Custom Field ID.",type:"error",duration:3e3,closable:!0});if(0===n.length)return void T.X.create({title:"Validation Error",description:"Please add at least one direct answer value.",type:"error",duration:3e3,closable:!0});em(!0);let i=O(t.credentials,e.credentials_schema),s=e4(e)?{field_name:r,direct_values:n}:{field_id:r,direct_values:n};try{await ev({integration_id:e.id,credentials:i,copilot_filters:s,is_private:!0}),ej(),eg(null),eh(""),T.X.create({title:"Direct answer filter saved",description:"The AI will answer directly for the specified field values. All other tickets will be handled via copilot (private notes).",type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error saving filter",description:e.message||"An error occurred.",type:"error",duration:3e3,closable:!0})}finally{em(!1)}},tl=async e=>{let t=eB(e.id);if(!t)return;em(!0);let r=O(t.credentials,e.credentials_schema);try{var n;await ev({integration_id:e.id,credentials:r,copilot_filters:null,is_private:null!=(n=t.is_private)&&n}),ej(),eg(null),eh(""),T.X.create({title:"Filter removed",description:"Direct answer filter has been removed.",type:"success",duration:3e3,closable:!0})}catch(e){T.X.create({title:"Error removing filter",description:e.message||"An error occurred.",type:"error",duration:3e3,closable:!0})}finally{em(!1)}},to=(e,t)=>{Y(r=>({...r,[e]:t}))},tc=(e,t)=>{var a,g;if(!e.credentials_schema||0===Object.keys(e.credentials_schema).length)return(0,n.jsx)(i.E,{fontSize:"sm",color:"gray.500",children:"No credentials required for this integration."});let u=null!=(a=null==t?void 0:t.readonly)&&a,h=null!=(g=null==t?void 0:t.values)?g:Z;return(0,n.jsx)(s.T,{gap:4,align:"stretch",children:Object.entries(e.credentials_schema).map(e=>{var t;let[a,s]=e,g=null!=(t=h[a])?t:"",p=u&&s.secret&&g?"••••••••":g,m=s.required||!1;return(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(i.E,{fontSize:"sm",fontWeight:"semibold",mb:2,children:[a,m&&!u&&(0,n.jsx)(i.E,{as:"span",color:"red.500",ml:1,children:"*"})]}),"boolean"===s.type?(0,n.jsxs)(o.z,{children:[(0,n.jsx)(c.$,{size:"sm",variant:!0===g?"solid":"outline",colorScheme:"blue",onClick:()=>to(a,!0),disabled:r||u,children:(0,n.jsx)(_.YrT,{})}),(0,n.jsx)(c.$,{size:"sm",variant:!1===g?"solid":"outline",colorScheme:"red",onClick:()=>to(a,!1),disabled:r||u,children:(0,n.jsx)(_.yGN,{})})]}):(0,n.jsxs)(l.a,{children:[(0,n.jsx)(d.p,{type:"number"===s.type||"integer"===s.type?"number":s.secret&&u?"text":s.secret?"password":"text",value:null==p||""===p?"":String(p),placeholder:u||g&&""!==g?"":"Enter ".concat(a,"..."),onChange:e=>{if(u)return;let t=e.target.value;("number"===s.type||"integer"===s.type)&&(""===t||null==t?t="":isNaN(t="integer"===s.type?parseInt(t):parseFloat(t))&&(t="")),to(a,t)},size:"sm",disabled:r||u,readOnly:u}),s.secret&&!G&&!u&&(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mt:1,children:"Leave unchanged to keep the existing value."})]})]},a)})})},td=e=>{var t;switch(null==(t=e.service)?void 0:t.toLowerCase()){case"zendesk":return"/docs/zendesk";case"freshdesk":return"/docs/freshdesk";case"helpdesk":return"/docs/helpdesk";case"shopify":return"/docs/shopify";case"crisp":return"/docs/crisp";case"callbell":return"/docs/callbell";case"medusa":return"/docs/medusa";case"magento":return"/docs/magento";case"whatsapp":return"/docs/whatsapp";case"email":return"/docs/email";case"instagram":return"/docs/instagram";case"messenger":return"/docs/messenger";
1case"hubspot":return"/docs/hubspot";case"attio":return"/docs/attio";case"klaviyo":return"/docs/klaviyo";case"sfcc":case"salesforce commerce cloud":return"/docs/sfcc";case"bigcommerce":return"/docs/bigcommerce";case"woocommerce":return"/docs/woocommerce";case"prestashop":return"/docs/prestashop";case"qapla":return"/docs/qapla";case"slack":return"/docs/slack";default:return null}},tg=e=>{var a,x,b,v,w,z,T,I;if(function(e){var t;return M.includes((null!=(t=e.service)?t:"").toLowerCase())}(e))return(e=>{var a,d,h,p;let m=eK(e.id),x=eZ(e.id),f=eB(e.id),b=eo===e.id,_=(null!=(d=e.service)?d:"").toLowerCase(),j="instagram"===_,y="messenger"===_,v=null==(h=null==f?void 0:f.ai_enabled)||h,w=X(null==f?void 0:f.credentials),z=y?"instagram":"messenger",C=null==ex?void 0:ex.find(e=>{var t;return(null!=(t=e.service)?t:"").toLowerCase()===z}),S=!!C&&eK(C.id);if(!m){let a="instagram"===_&&S;return(0,n.jsx)(l.a,{p:4,children:(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[(0,n.jsxs)(s.T,{gap:1,align:"start",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"bold",children:e.service}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:a?"No Instagram Professional account was found linked to your Facebook Page.":"Connect your Facebook Page to enable ".concat(e.service," automation. One connection sets up both Messenger and Instagram.")})]}),a?(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"orange.50",_dark:{bg:"orange.900/30"},children:(0,n.jsx)(i.E,{fontSize:"xs",color:"orange.700",_dark:{color:"orange.300"},children:"Make sure your Instagram Professional account is connected to your Facebook Page, then try connecting again."})}):(0,n.jsxs)(c.$,{size:"xs",colorPalette:"blue",onClick:e0,disabled:r||!t,alignSelf:"flex-start",children:[(0,n.jsx)(k.iYk,{}),"Connect with Facebook"]})]})})}let T=y?"MESSENGER_PAGE_ID":"INSTAGRAM_PAGE_ID",A=null==f||null==(a=f.credentials)?void 0:a[T];return(0,n.jsx)(l.a,{p:4,children:(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsx)(l.a,{onClick:t=>{t.stopPropagation(),r||ez||eS||eG(e,!x)},cursor:r?"not-allowed":"pointer",children:(0,n.jsxs)(g.lq,{checked:x,onCheckedChange:t=>{r||ez||eS||eG(e,t.checked)},disabled:r||ez||eS,size:"md",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]})}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"bold",children:e.service}),x?(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Connected"})}):(0,n.jsx)(u.f8,{colorPalette:"gray",size:"sm",children:(0,n.jsx)(u.d1,{children:"Connected"})})]}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:x?A?"Page ID: ".concat(A):"".concat(e.service," is connected and active."):"".concat(e.service," is connected but disabled. Toggle to activate.")})]})]}),(0,n.jsx)(c.$,{size:"xs",variant:"outline",colorPalette:"red",onClick:()=>e1(_),disabled:r||eF,children:"Disconnect"})]}),m&&x&&(0,n.jsxs)(l.a,{pl:12,children:[(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsxs)(g.lq,{checked:null==(p=null==f?void 0:f.ai_enabled)||p,onCheckedChange:t=>{r||b||e3(e,t.checked)},disabled:r||b,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsx)(i.E,{fontSize:"sm",children:"AI agent enabled"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:(null==f?void 0:f.ai_enabled)?"The AI agent is active and handling messages on this channel.":"The AI agent is disabled. Messages will only appear in the inbox."})]})]}),j&&(0,n.jsxs)(s.T,{gap:3,align:"stretch",mt:3,opacity:v?1:.55,children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"semibold",color:"gray.600",children:"AI auto-reply by message type"}),!v&&(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"Enable AI agent above to configure which message types receive auto-replies."}),(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsxs)(g.lq,{checked:w.direct_message,onCheckedChange:t=>{r||b||!v||e5(e,"direct_message",t.checked)},disabled:r||b||!v,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsx)(i.E,{fontSize:"sm",children:"Direct messages"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"AI replies to normal DMs sent to your inbox."})]})]}),(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsxs)(g.lq,{checked:w.story_reply,onCheckedChange:t=>{r||b||!v||e5(e,"story_reply",t.checked)},disabled:r||b||!v,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsx)(i.E,{fontSize:"sm",children:"Replies to stories"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"AI replies when someone responds to your Instagram story. When off, messages still appear in the inbox for a human."})]})]})]}),(j||y)&&(0,n.jsxs)(s.T,{gap:3,align:"stretch",mt:3,opacity:v?1:.55,children:[(0,n.jsx)(i.E,{fontSize:"xs",fontWeight:"semibold",color:"gray.600",children:"Human takeover"}),(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsxs)(g.lq,{checked:w.native_takeover,onCheckedChange:t=>{r||b||!v||e5(e,"native_takeover",t.checked)},disabled:r||b||!v,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsxs)(i.E,{fontSize:"sm",children:["Pause AI when your team replies from ",j?"Instagram":"Messenger"]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",children:["If someone answers a customer directly in ",j?"the Instagram app":"Messenger or Page Inbox"," or Meta Business Suite, the AI stops and the conversation moves to your Inbox."]})]})]})]})]})]})})})(e);let P=eK(e.id),R=eZ(e.id),W=eB(e.id),D=eo===e.id,O=!!P&&!!R&&!!t&&(e8(e)||e9(e)||e6(e)||te(e)||tt(e)||tr(e)),J=e7(e)&&P&&R,U=q(e)&&!!e.credentials_schema&&Object.keys(e.credentials_schema).length>0&&(B===e.id||P),$=J||U,H=null!=(w=eD[e.id])?w:[],K=("all"===f||"integrations"===f)&&H.length>0,Z=H.filter(e=>e.enabled).length,Y=null==j?void 0:j(e,{isEnabled:R,hasCreds:P});return(0,n.jsx)(l.a,{children:(0,n.jsx)(l.a,{p:4,children:(0,n.jsxs)(s.T,{gap:3,align:"stretch",children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsx)(l.a,{onClick:t=>{t.stopPropagation(),r||ez||eS||eG(e,!R)},cursor:r?"not-allowed":"pointer",children:(0,n.jsxs)(g.lq,{checked:R,onCheckedChange:t=>{r||ez||eS||eG(e,t.checked)},disabled:r||ez||eS,size:"md",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]})}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"bold",children:e.service}),N.includes(null==(a=e.service)?void 0:a.toLowerCase())&&(0,n.jsx)(u.f8,{colorPalette:"purple",size:"sm",variant:"subtle",children:(0,n.jsx)(u.d1,{children:"Beta"})}),F.includes(null==(x=e.service)?void 0:x.toLowerCase())&&(0,n.jsx)(u.f8,{colorPalette:"orange",size:"sm",variant:"subtle",children:(0,n.jsx)(u.d1,{children:"Work in Progress"})}),R&&(0,n.jsx)(u.f8,{colorPalette:"green",size:"sm",children:(0,n.jsx)(u.d1,{children:"Active"})}),P&&!R&&(0,n.jsx)(u.f8,{colorPalette:"gray",size:"sm",children:(0,n.jsx)(u.d1,{children:"Configured"})})]}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:R?"".concat(e.service," integration is active and connected."):P?"".concat(e.service," is configured but disabled. Toggle to activate."):"Toggle to set up and enable ".concat(e.service,".")})]})]}),P&&!q(e)&&(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsxs)(c.$,{size:"xs",variant:"outline",onClick:()=>eY(e),disabled:r,children:[(0,n.jsx)(_.WXf,{}),"Edit Credentials"]}),(0,n.jsx)(E.A,{triggerDelete:()=>eT({integration_id:e.id}),alertMessage:"Are you sure you want to permanently delete credentials for ".concat(e.service,"? This action cannot be undone."),mutate:ej,variant:"icon",iconSize:"xs",isDisabled:r})]}),P&&q(e)&&(0,n.jsx)(E.A,{triggerDelete:()=>eT({integration_id:e.id}),alertMessage:"Are you sure you want to permanently delete credentials for ".concat(e.service,"? This action cannot be undone."),mutate:ej,variant:"icon",iconSize:"xs",isDisabled:r})]}),"direct"===e.channel_type&&P&&R&&(0,n.jsx)(l.a,{pl:12,children:(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsxs)(g.lq,{checked:null==(z=null==W?void 0:W.ai_enabled)||z,onCheckedChange:t=>{r||D||e3(e,t.checked)},disabled:r||D,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]}),(0,n.jsxs)(s.T,{gap:0,align:"start",children:[(0,n.jsx)(i.E,{fontSize:"sm",children:"AI agent enabled"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:(null==W?void 0:W.ai_enabled)?"The AI agent is active and handling messages on this channel."
1:"The AI agent is disabled. Messages will only appear in the inbox."})]})]})}),"external"===e.channel_type&&P&&R&&(()=>{var t;let a=e7(e)&&tn(e);return(0,n.jsx)(l.a,{pl:12,children:(0,n.jsxs)(o.z,{gap:3,alignItems:"center",children:[(0,n.jsxs)(g.lq,{checked:!!a||null!=(t=null==W?void 0:W.is_private)&&t,onCheckedChange:t=>{r||D||a||e2(e,t.checked)},disabled:r||D||a,size:"sm",children:[(0,n.jsx)(g.tD,{}),(0,n.jsx)(g.oO,{})]}),(0,n.jsx)(i.E,{fontSize:"sm",children:"Send as private notes (copilot)"})]})})})(),(0,n.jsx)(l.a,{pl:12,children:(0,n.jsx)(L,{defaultOpenId:K?R?"tools":null:$?"configs":null,forceOpenId:B===e.id&&U?"configs":null,sections:[K&&{id:"tools",label:"Tools",count:R?"".concat(Z,"/").concat(H.length):"".concat(H.length),content:(0,n.jsx)(S,{serviceName:e.service,tools:H,locked:!R,isDisabled:r,isToggling:eP||eW,onToggle:eL,onTest:C,onEdit:A})},O&&{id:"tracking",label:"Tracking",content:(0,n.jsxs)(n.Fragment,{children:[e8(e)&&t&&(0,n.jsx)(et,{agentId:t,isDisabled:r}),e9(e)&&t&&(0,n.jsx)(er,{agentId:t,isDisabled:r}),e6(e)&&(0,n.jsx)(en,{}),te(e)&&t&&(0,n.jsx)(ea,{agentId:t,isDisabled:r}),tt(e)&&t&&(0,n.jsx)(ei,{agentId:t,isDisabled:r}),tr(e)&&t&&(0,n.jsx)(es,{agentId:t,isDisabled:r})]})},$&&{id:"configs",label:J?"Configs":"Credentials",content:(0,n.jsxs)(s.T,{gap:6,align:"stretch",children:[e7(e)&&P&&R&&(0,n.jsxs)(l.a,{children:[(0,n.jsxs)(o.z,{justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",children:"Direct Answer Filter"}),null===ed&&(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(h.K,{size:"xs",variant:"ghost","aria-label":"Edit filter",onClick:()=>(e=>{var t,r;let n=eB(e.id),a=null==n?void 0:n.copilot_filters;eg({field_id:null!=(r=null!=(t=null==a?void 0:a.field_name)?t:null==a?void 0:a.field_id)?r:"",direct_values:Array.isArray(null==a?void 0:a.direct_values)?[...a.direct_values]:[]}),eh("")})(e),disabled:r,children:(0,n.jsx)(_.WXf,{})}),tn(e)&&(0,n.jsx)(h.K,{size:"xs",variant:"ghost",colorPalette:"red","aria-label":"Delete filter",onClick:()=>tl(e),disabled:r||ep,children:(0,n.jsx)(_.IXo,{})})]})]}),(0,n.jsxs)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:["When configured, the AI answers directly only for tickets where the specified ",e4(e)?"Freshdesk":"Zendesk"," custom field matches one of the listed values. All other tickets are handled as copilot (private notes)."]}),null!==ed?(0,n.jsxs)(s.T,{gap:4,align:"stretch",children:[(0,n.jsxs)(l.a,{children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",mb:1,children:e4(e)?"Custom Field Name":"Custom Field ID"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mb:2,children:e4(e)?"The Freshdesk custom field name to filter on (e.g. cf_channel).":"The Zendesk custom field ID to filter on (e.g. 14052519334034)."}),(0,n.jsx)(d.p,{size:"sm",placeholder:e4(e)?"e.g. cf_channel":"e.g. 14052519334034",value:ed.field_id,onChange:e=>eg(t=>t?{...t,field_id:e.target.value}:t),disabled:r})]}),(0,n.jsxs)(l.a,{children:[(0,n.jsx)(i.E,{fontSize:"sm",fontWeight:"semibold",mb:1,children:"Direct Answer Values"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mb:2,children:"When the custom field matches one of these values, the AI will reply directly to the customer. For all other values, it replies as copilot (private note)."}),ed.direct_values.length>0&&(0,n.jsx)(p.s,{gap:2,flexWrap:"wrap",mb:2,children:ed.direct_values.map(e=>(0,n.jsxs)(u.f8,{size:"sm",colorPalette:"blue",variant:"subtle",children:[(0,n.jsx)(u.d1,{children:e}),(0,n.jsx)(l.a,{as:"button",ml:1,cursor:"pointer",display:"inline-flex",alignItems:"center",onClick:()=>{eg(t=>t?{...t,direct_values:t.direct_values.filter(t=>t!==e)}:t)},"aria-label":"Remove ".concat(e),_hover:{color:"red.500"},children:(0,n.jsx)(_.yGN,{size:12})})]},e))}),(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(d.p,{size:"sm",placeholder:"Add a value (e.g. mail, form, chat)",value:eu,onChange:e=>eh(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ti())},disabled:r}),(0,n.jsxs)(c.$,{size:"sm",variant:"outline",onClick:ti,disabled:r||!eu.trim(),children:[(0,n.jsx)(_.GGD,{}),"Add"]})]})]}),ed.field_id.trim()&&ed.direct_values.length>0&&(0,n.jsx)(l.a,{p:3,borderRadius:"md",bg:"blue.50",_dark:{bg:"blue.900/30"},children:(0,n.jsxs)(i.E,{fontSize:"xs",color:"blue.700",_dark:{color:"blue.300"},children:['Saving this filter will automatically enable "Send as private notes" (copilot mode). The AI will answer directly only for tickets where field ',(0,n.jsx)("strong",{children:ed.field_id.trim()})," matches: ",ed.direct_values.join(", "),". All other tickets will receive private-note replies."]})}),(0,n.jsxs)(o.z,{gap:2,mt:1,justifyContent:"space-between",children:[(0,n.jsxs)(o.z,{gap:2,children:[(0,n.jsx)(c.$,{size:"sm",colorPalette:"blue",onClick:()=>ts(e),loading:ep,disabled:r,children:"Save Filter"}),(0,n.jsx)(c.$,{size:"sm",variant:"ghost",onClick:ta,disabled:r||ep,children:"Cancel"})]}),tn(e)&&(0,n.jsxs)(c.$,{size:"sm",variant:"ghost",colorPalette:"red",onClick:()=>tl(e),loading:ep,disabled:r,children:[(0,n.jsx)(_.IXo,{}),"Delete Filter"]})]})]}):(0,n.jsx)(l.a,{children:(null==W||null==(b=W.copilot_filters)?void 0:b.field_id)||(null==W||null==(v=W.copilot_filters)?void 0:v.field_name)?(0,n.jsxs)(s.T,{gap:2,align:"stretch",children:[(0,n.jsxs)(o.z,{gap:2,alignItems:"center",children:[(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",minW:"fit-content",children:e4(e)?"Field:":"Field ID:"}),(0,n.jsx)(u.f8,{size:"sm",variant:"outline",children:(0,n.jsx)(u.d1,{children:null!=(T=W.copilot_filters.field_name)?T:W.copilot_filters.field_id})})]}),(0,n.jsxs)(o.z,{gap:2,alignItems:"start",children:[(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",minW:"fit-content",mt:.5,children:"Direct values:"}),(0,n.jsx)(p.s,{gap:1,flexWrap:"wrap",children:(Array.isArray(W.copilot_filters.direct_values)?W.copilot_filters.direct_values:[]).map(e=>(0,n.jsx)(u.f8,{size:"sm",colorPalette:"blue",variant:"subtle",children:(0,n.jsx)(u.d1,{children:e})},e))})]})]}):(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",children:"No filter configured. All tickets are handled with the current reply mode above."})})]}
1),e7(e)&&P&&R&&W&&(0,n.jsx)(ee,{integration:e,savedCreds:W,isPrivate:null!=(I=W.is_private)&&I,isDisabled:r,onSaved:()=>ej(),saveCredentials:ev}),U&&(0,n.jsx)(l.a,{children:B===e.id?(0,n.jsxs)(s.T,{gap:4,align:"stretch",children:[tc(e),(0,n.jsxs)(o.z,{gap:2,mt:2,children:[(0,n.jsx)(c.$,{size:"sm",colorPalette:"blue",onClick:()=>eQ(),loading:ek||ez,disabled:r,children:G?"Save & Enable":"Save Changes"}),(0,n.jsx)(c.$,{size:"sm",variant:"ghost",onClick:eV,disabled:r,children:"Cancel"}),td(e)&&(0,n.jsx)(m.N,{asChild:!0,fontSize:"sm",color:"blue.500",_hover:{textDecoration:"underline"},ml:2,children:(0,n.jsx)(y(),{href:td(e),target:"_blank",rel:"noopener noreferrer",children:(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(i.E,{children:"View setup guide"}),(0,n.jsx)(_.HaR,{size:14})]})})})]})]}):P&&(null==W?void 0:W.credentials)?(0,n.jsxs)(s.T,{gap:4,align:"stretch",children:[tc(e,{readonly:!0,values:W.credentials}),(0,n.jsxs)(c.$,{size:"xs",variant:"outline",onClick:()=>eY(e),disabled:r,alignSelf:"flex-start",children:[(0,n.jsx)(_.WXf,{}),"Edit credentials"]})]}):null})]})}].filter(Boolean)})}),Y]})})})};if(eb||ey)return(0,n.jsx)(i.E,{color:"red.500",children:"Failed to load integrations."});let tu=null==ex?void 0:ex.find(e=>e.id===B);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(s.T,{gap:8,align:"stretch",children:[("all"===f||"channels"===f||b)&&(0,n.jsxs)(l.a,{children:["all"===f&&!b&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.E,{fontSize:"md",fontWeight:"bold",mb:1,children:"Channels"}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:"Deploy your AI agent directly on these channels"})]}),(0,n.jsx)(l.a,{borderWidth:"1px",borderRadius:"md",children:(0,n.jsxs)(p.s,{direction:"column",children:[e$.map((e,t)=>(0,n.jsxs)(a.Fragment,{children:[tg(e),t<e$.length-1&&(0,n.jsx)(x.w,{})]},e.id)),0===e$.length&&(0,n.jsx)(i.E,{fontSize:"sm",color:"gray.500",p:4,children:eH?"No ".concat(eH.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" or ")," channel available."):"No channels available."})]})})]}),("all"===f||"integrations"===f)&&$.map(e=>{let t=eM[e];if(0===t.length)return null;let r=H[e];return(0,n.jsxs)(l.a,{children:[(0,n.jsx)(i.E,{fontSize:"md",fontWeight:"bold",mb:1,children:r.title}),(0,n.jsx)(i.E,{fontSize:"xs",color:"gray.500",mb:3,children:r.description}),(0,n.jsx)(l.a,{borderWidth:"1px",borderRadius:"md",children:(0,n.jsx)(p.s,{direction:"column",children:t.map((e,r)=>(0,n.jsxs)(a.Fragment,{children:[tg(e),r<t.length-1&&(0,n.jsx)(x.w,{})]},e.id))})})]},e)}),("all"===f||"integrations"===f)&&0===eq.length&&(0,n.jsx)(l.a,{children:(0,n.jsx)(l.a,{borderWidth:"1px",borderRadius:"md",children:(0,n.jsx)(i.E,{fontSize:"sm",color:"gray.500",p:4,children:"No integrations available."})})}),"all"===f&&ex&&0===ex.length&&0===e$.length&&(0,n.jsx)(i.E,{fontSize:"sm",color:"gray.500",children:"No integrations available."})]}),tu&&!q(tu)&&(0,n.jsx)(I.A,{isOpen:D,onClose:eV,title:G?"Configure ".concat(tu.service):"Edit ".concat(tu.service," Credentials"),onSubmit:eQ,isSubmitting:ek||ez,submitButtonText:G?"Save & Enable":"Save Changes",isDisabled:r,headerRight:td(tu)&&(0,n.jsx)(m.N,{asChild:!0,fontSize:"sm",color:"blue.500",_hover:{textDecoration:"underline"},children:(0,n.jsx)(y(),{href:td(tu),target:"_blank",rel:"noopener noreferrer",children:(0,n.jsxs)(o.z,{gap:1,children:[(0,n.jsx)(i.E,{children:"View full guide"}),(0,n.jsx)(_.HaR,{size:14})]})})}),children:(0,n.jsx)(s.T,{gap:4,align:"stretch",children:tc(tu)})}),"all"===f&&(0,n.jsx)(I.A,{isOpen:Q,onClose:()=>el(!1),title:"API Configuration",onSubmit:()=>el(!1),showActions:!1,isDisabled:r,children:(0,n.jsxs)(s.T,{gap:6,align:"stretch",children:[(0,n.jsx)(R.A,{agentId:t||null,isDisabled:r}),(0,n.jsx)(x.w,{}),(0,n.jsx)(W.A,{})]})})]})}}}]);

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.