@boomi/embedkit 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embedkit-cdn.js +5 -5
- package/dist/embedkit-cdn.umd.cjs +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -1
- package/dist/index.umd.cjs +2 -1
- package/package.json +1 -1
- package/dist/index.d.ts +0 -910
package/dist/embedkit-cdn.js
CHANGED
|
@@ -39823,19 +39823,19 @@ const cm = ({ children: t, size: e, style: o }) => /* @__PURE__ */ Q.jsxs("div",
|
|
|
39823
39823
|
d(!1);
|
|
39824
39824
|
}, [T]), M = W.useMemo(() => {
|
|
39825
39825
|
const X = (e == null ? void 0 : e.agents) ?? {};
|
|
39826
|
-
return Array.from(new Set(t ?? [])).
|
|
39826
|
+
return Array.from(new Set(t ?? [])).flatMap((Z) => {
|
|
39827
39827
|
var fe, Ae, Se, Ue, _e, De;
|
|
39828
39828
|
const te = X[Z];
|
|
39829
|
-
if (!te) return
|
|
39829
|
+
if (!te) return [];
|
|
39830
39830
|
const oe = te.label || te.installAsName || ((fe = te.ui) == null ? void 0 : fe.pageTitle) || ((Se = (Ae = te.ui) == null ? void 0 : Ae.welcome) == null ? void 0 : Se.title) || Z, ae = ((Ue = te.ui) == null ? void 0 : Ue.pageDescription) || ((De = (_e = te.ui) == null ? void 0 : _e.welcome) == null ? void 0 : De.subtitle) || void 0;
|
|
39831
|
-
return {
|
|
39831
|
+
return [{
|
|
39832
39832
|
agentId: Z,
|
|
39833
39833
|
name: String(oe || Z),
|
|
39834
39834
|
description: ae ? String(ae) : void 0,
|
|
39835
39835
|
icon: te.icon,
|
|
39836
39836
|
hideIcon: te.hideIcon
|
|
39837
|
-
};
|
|
39838
|
-
})
|
|
39837
|
+
}];
|
|
39838
|
+
});
|
|
39839
39839
|
}, [t, e]), [k, $] = W.useState(""), [F, D] = W.useState(1), I = W.useMemo(() => {
|
|
39840
39840
|
const X = k.trim().toLowerCase();
|
|
39841
39841
|
return X ? M.filter((q) => {
|
|
@@ -1916,7 +1916,7 @@ https://sweetalert2.github.io/#ajax-request`),bI(t),typeof t.title=="string"&&(t
|
|
|
1916
1916
|
* 'modal' mode.
|
|
1917
1917
|
*
|
|
1918
1918
|
* @return {JSX.Element} Modal shell container.
|
|
1919
|
-
*/const ih=({children:t,size:e,style:o})=>Q.jsxs("div",{className:"boomi-agent-overlay boomi-agent-overlay--modal",children:[Q.jsx("div",{className:"boomi-agent-overlay__scrim"}),Q.jsx("div",{className:"boomi-agent-overlay__modal",style:{width:e.w,height:e.h,...o},children:t})]}),RI=({integrationPackId:t})=>{var I,x,_,L,H,B,P,G,z,K,V,X,q,Z,te,oe,ae,fe,Ae,Se,Ue;const{boomiConfig:e}=tn(),o=(x=(I=e==null?void 0:e.agents)==null?void 0:I[t])==null?void 0:x.environmentId,d=((L=(_=e==null?void 0:e.agents)==null?void 0:_[t])==null?void 0:L.position)||{corner:"bottom-right",offsetX:24,offsetY:40},T=((B=(H=e==null?void 0:e.agents)==null?void 0:H[t])==null?void 0:B.shape)||"pill",p=((G=(P=e==null?void 0:e.agents)==null?void 0:P[t])==null?void 0:G.label)||"Chat with us",v=(K=(z=e==null?void 0:e.agents)==null?void 0:z[t])==null?void 0:K.icon,E=(X=(V=e==null?void 0:e.agents)==null?void 0:V[t])==null?void 0:X.hideIcon,h=((Z=(q=e==null?void 0:e.agents)==null?void 0:q[t])==null?void 0:Z.installAsName)??"Agent",m=(oe=(te=e==null?void 0:e.agents)==null?void 0:te[t])==null?void 0:oe.transport,{instance:a,installed:l,loading:u}=_u(t||"",o||"",h,m),[c,s]=W.useState(!1),[f,g]=W.useState("info"),[w,A]=W.useState(null),R=(fe=(ae=e==null?void 0:e.agents)==null?void 0:ae[t])==null?void 0:fe.ui,O=(R==null?void 0:R.mode)??"full",S={w:((Ae=R==null?void 0:R.modal)==null?void 0:Ae.width)??980,h:((Se=R==null?void 0:R.modal)==null?void 0:Se.height)??720},y=(Ue=R==null?void 0:R.modal)==null?void 0:Ue.position,N=W.useMemo(()=>({id:(a==null?void 0:a.id)??t,integrationPackId:t,environmentId:o||"",installationType:"MULTI"}),[t,o,a==null?void 0:a.id]),M=W.useMemo(()=>{const _e={position:"fixed",zIndex:999998};if(!d||"corner"in d){const Me=(d==null?void 0:d.corner)??"bottom-right",Ge=(d==null?void 0:d.offsetX)??24,Tt=(d==null?void 0:d.offsetY)??24;return Me.includes("bottom")&&(_e.bottom=Tt),Me.includes("top")&&(_e.top=Tt),Me.includes("right")&&(_e.right=Ge),Me.includes("left")&&(_e.left=Ge),_e}return _e.left=d.x,_e.top=d.y,_e},[d]),k=W.useMemo(()=>{if(!y)return;const _e={position:"fixed",zIndex:999999};if("corner"in y){const Me=y.corner??"bottom-right",Ge=y.offsetX??24,Tt=y.offsetY??24;return Me.includes("bottom")&&(_e.bottom=Tt),Me.includes("top")&&(_e.top=Tt),Me.includes("right")&&(_e.right=Ge),Me.includes("left")&&(_e.left=Ge),_e}return _e.left=y.x,_e.top=y.y,_e},[y]),$=u?"Agent (loading)":l?"Open Agent chat":"Open Agent info";W.useEffect(()=>{if(!c)return;const _e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=_e}},[c]),W.useEffect(()=>{c||A(null)},[c]);const F=()=>a?Q.jsx(nh,{integration:N,onHeaderActionsChange:A}):Q.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:[Q.jsx(Ai,{message:"Preparing agent..."}),Q.jsx("p",{className:"text-sm text-[color-mix(in_srgb,var(--boomi-page-fg-color,#f8fafc) 80%,transparent)]",children:"This agent is not fully installed yet. Configure it to start chatting."})]}),D=()=>!c||!l?null:O==="modal"?Q.jsx(ih,{size:S,style:k,children:Q.jsxs("div",{className:"boomi-agent-overlay__inner",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:p}),Q.jsxs("div",{className:"boomi-agent-overlay__header-actions",children:[w,Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:()=>s(!1),children:"✕"})]})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:F()})]})}):Q.jsxs("div",{className:"boomi-agent-overlay boomi-agent-overlay--full",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:p}),Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:()=>s(!1),children:"✕"})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:F()})]});return Q.jsxs(Q.Fragment,{children:[Q.jsx("button",{"aria-label":$,title:$,onClick:()=>{g(l?"chat":"info"),s(_e=>!_e)},style:M,className:T==="circle"?"w-12 h-12 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.03] transition-transform":"px-4 h-10 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.02] transition-transform",children:(()=>{const _e=E?"":v??"🤖";return T==="circle"?_e||"":Q.jsxs(Q.Fragment,{children:[_e&&Q.jsx("span",{className:"mr-2",children:_e}),Q.jsx("span",{children:p})]})})()}),D()]})},aA=({searchCallback:t})=>{const[e,o]=W.useState(""),d=v=>{const E=v.currentTarget.value;o(E)},T=v=>{if(v.key==="Enter"){const E=v.currentTarget.value;v.preventDefault(),o(E),t(E)}},p=()=>{o(""),t("");const v=document.getElementById("search");v==null||v.focus()};return Q.jsxs("div",{className:"relative flex items-center pr-2 w-[400px]",children:[Q.jsx("input",{type:"text",name:"search",id:"search",placeholder:"Type to search...",value:e,onChange:d,onKeyDown:T,className:"block w-full rounded-md py-2 pl-3 pr-10 text-sm boomi-input","aria-label":"Search"}),e.length>0&&Q.jsx("button",{type:"button",onClick:p,className:"absolute right-3 top-1/2 -translate-y-1/2 p-0.5 rounded-full focus:outline-none focus:ring-2 focus:ring-offset-1","aria-label":"Clear search",title:"Clear",children:Q.jsx(Om,{className:"h-5 w-5"})})]})},oh=({currentPage:t,totalPages:e,onPageChange:o})=>{const[d,T]=W.useState(t.toString()),p=h=>{h>=1&&h<=e&&(o(h),T(h.toString()))},v=h=>{T(h.target.value)},E=()=>{const h=parseInt(d,10);isNaN(h)||p(h)};return Q.jsxs("div",{className:"flex justify-end items-center space-x-2 mt-4",children:[Q.jsx(Ci,{toggle:!1,primary:!1,showIcon:!0,iconOnly:!0,disabled:t===1,icon:Q.jsx(u_,{className:"text-indigo-400 hover:text-indigo-500 w-6 h-6"}),onClick:()=>p(t-1)}),Array.from({length:e}).map((h,m)=>{const a=m+1;return Q.jsx("button",{className:`px-2 py-1 rounded cursor-pointer ${t===a?"text-indigo-500 bg-indigo-100 rounded-md":"text-indigo-400"}`,onClick:()=>p(a),children:a},a)}),Q.jsx(Ci,{toggle:!1,primary:!1,showIcon:!0,iconOnly:!0,disabled:t===e,icon:Q.jsx(d_,{className:"w-6 h-6"}),onClick:()=>p(t+1)}),Q.jsx("span",{className:"text-sm text-gray-700 ml-2",children:"Go to page"}),Q.jsx("input",{type:"number",value:d,onChange:v,className:"w-12 px-1 py-1 border rounded text-sm "}),Q.jsx(Ci,{toggle:!1,primary:!1,showIcon:!1,label:"Go",onClick:E})]})},rh=10,OI=({agentId:t,onClose:e})=>{var R,O,S,y,N;const{boomiConfig:o}=tn(),d=(R=o==null?void 0:o.agents)==null?void 0:R[t],T=d==null?void 0:d.ui,p=d==null?void 0:d.transport,v=(d==null?void 0:d.environmentId)??"",E=(d==null?void 0:d.label)||(d==null?void 0:d.installAsName)||(T==null?void 0:T.pageTitle)||((O=T==null?void 0:T.welcome)==null?void 0:O.title)||"Agent",{instance:h,installed:m,loading:a}=_u(t,v,E,p),[l,u]=W.useState(null),c=(T==null?void 0:T.mode)??"full",s={w:((S=T==null?void 0:T.modal)==null?void 0:S.width)??980,h:((y=T==null?void 0:T.modal)==null?void 0:y.height)??720},f=(N=T==null?void 0:T.modal)==null?void 0:N.position;W.useEffect(()=>{const M=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=M}},[]);const g=W.useMemo(()=>{if(!f)return;const M={position:"fixed",zIndex:999999};if("corner"in f){const k=f.corner??"bottom-right",$=f.offsetX??24,F=f.offsetY??24;return k.includes("bottom")&&(M.bottom=F),k.includes("top")&&(M.top=F),k.includes("right")&&(M.right=$),k.includes("left")&&(M.left=$),M}return M.left=f.x,M.top=f.y,M},[f]),w=W.useMemo(()=>({id:(h==null?void 0:h.id)??t,integrationPackId:t,environmentId:v,installationType:"MULTI"}),[t,v,h==null?void 0:h.id]),A=()=>a?Q.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:Q.jsx(Ai,{message:"Preparing agent..."})}):!h||!m?Q.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:[Q.jsx(Ai,{message:"Preparing agent..."}),Q.jsx("p",{className:"text-sm text-[color-mix(in_srgb,var(--boomi-page-fg-color,#f8fafc) 80%,transparent)]",children:"This agent is not fully installed yet. Configure it to start chatting."})]}):Q.jsx(nh,{integration:w,onHeaderActionsChange:u});return c==="modal"?Q.jsx(ih,{size:s,style:g,children:Q.jsxs("div",{className:"boomi-agent-overlay__inner",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:E}),Q.jsxs("div",{className:"boomi-agent-overlay__header-actions",children:[l,Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:e,children:"✕"})]})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:A()})]})}):Q.jsxs("div",{className:"boomi-agent-overlay boomi-agent-overlay--full",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:E}),Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:e,children:"✕"})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:A()})]})},kI=({agentIds:t})=>{var S,y;const{boomiConfig:e,componentKey:o}=tn(),d=`embed-agents-view:${o||"public"}`,T=((S=e==null?void 0:e.components)==null?void 0:S.agentTiles)??((y=e==null?void 0:e.components)==null?void 0:y.agentList)??{},p=(T==null?void 0:T.header)??{},v=(T==null?void 0:T.search)??{},E=(T==null?void 0:T.viewToggle)??{},[h,m]=W.useState(""),[a,l]=W.useState(1),[u,c]=W.useState("off"),[s,f]=W.useState(null);W.useEffect(()=>{try{const N=localStorage.getItem(d);(N==="on"||N==="off")&&c(N)}catch{}},[d]);const g=W.useCallback(()=>{c(N=>{const M=N==="on"?"off":"on";try{localStorage.setItem(d,M)}catch{}return M})},[d]),w=W.useMemo(()=>Array.from(new Set(t??[])).map(M=>{var D,I,x,_,L,H,B;const k=(D=e==null?void 0:e.agents)==null?void 0:D[M],$=(k==null?void 0:k.label)||(k==null?void 0:k.installAsName)||((I=k==null?void 0:k.ui)==null?void 0:I.pageTitle)||((_=(x=k==null?void 0:k.ui)==null?void 0:x.welcome)==null?void 0:_.title)||M,F=((L=k==null?void 0:k.ui)==null?void 0:L.pageDescription)||((B=(H=k==null?void 0:k.ui)==null?void 0:H.welcome)==null?void 0:B.subtitle)||void 0;return{agentId:M,name:String($||M),description:F?String(F):void 0}}),[t,e]),A=W.useMemo(()=>{const N=h.trim().toLowerCase();return N?w.filter(M=>{var F;const k=M.name.toLowerCase(),$=((F=M.description)==null?void 0:F.toLowerCase())??"";return M.agentId.toLowerCase().includes(N)||k.includes(N)||$.includes(N)}):w},[w,h]),R=Math.max(1,Math.ceil(A.length/rh)),O=A.slice((a-1)*rh,a*rh);return Q.jsxs(Q.Fragment,{children:[s&&Q.jsx(OI,{agentId:s,onClose:()=>f(null)}),Q.jsxs("div",{className:"w-full h-full p-6",children:[((p==null?void 0:p.show)??!0)&&Q.jsxs("div",{className:"space-y-2",children:[Q.jsx("h1",{className:"text-2xl font-semibold",children:(p==null?void 0:p.title)||"Agents"}),Q.jsx("p",{className:"text-sm opacity-70",children:(p==null?void 0:p.description)||"Launch an agent to start chatting."})]}),Q.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[Q.jsx("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:((v==null?void 0:v.show)??!0)&&Q.jsx("div",{className:"min-w-[220px]",children:Q.jsx(aA,{searchCallback:N=>{m(N),l(1)}})})}),((E==null?void 0:E.show)??!0)&&Q.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:Q.jsx(Ci,{toggle:!0,primary:!1,viewLoc:d,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:"View",icon:Q.jsx(b_,{className:"h-5 w-5"}),onIcon:Q.jsx(r_,{className:"h-5 w-5"}),onClick:g})})]}),u==="off"?Q.jsxs(Q.Fragment,{children:[Q.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:O.length>0?O.map(N=>{var k;const M=((k=N.description)==null?void 0:k.trim())||N.agentId;return Q.jsxs("li",{className:"boomi-card",children:[Q.jsx("div",{className:"flex gap-4 p-4",children:Q.jsxs("div",{className:"flex flex-col w-full",children:[Q.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:N.name}),Q.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:M})]})}),Q.jsx("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:Q.jsx(Ci,{toggle:!1,primary:!0,showIcon:!1,label:"Launch",onClick:()=>f(N.agentId)})})]},N.agentId)}):Q.jsx("div",{className:"col-span-full flex justify-center items-center",children:Q.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),R>1&&Q.jsx(oh,{currentPage:a,totalPages:R,onPageChange:N=>l(N)})]}):Q.jsxs(Q.Fragment,{children:[Q.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[Q.jsx("thead",{className:"boomi-table-header",children:Q.jsxs("tr",{children:[Q.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent"}),Q.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Name"}),Q.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent ID"}),Q.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold",children:"Actions"})]})}),Q.jsx("tbody",{className:"divide-y",children:O.length>0?O.map(N=>Q.jsxs("tr",{className:"boomi-table-row",children:[Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:N.name}),Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:N.description||"—"}),Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:N.agentId}),Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:Q.jsx("div",{className:"flex justify-end",children:Q.jsx(Ci,{toggle:!1,primary:!0,showIcon:!1,label:"Launch",onClick:()=>f(N.agentId)})})})]},N.agentId)):Q.jsx("tr",{children:Q.jsx("td",{colSpan:4,children:Q.jsx("div",{className:"flex justify-center items-center py-4",children:Q.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})})})})]}),R>1&&Q.jsx("div",{className:"mt-4 flex justify-end",children:Q.jsx(oh,{currentPage:a,totalPages:R,onPageChange:l})})]})]})]})},ah=10,II=({agentId:t,onHeaderActionsChange:e})=>{var l,u,c,s;const{boomiConfig:o}=tn(),d=(l=o==null?void 0:o.agents)==null?void 0:l[t];if(!d)return Q.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:Q.jsx("p",{className:"text-sm opacity-70",children:"Agent config not found."})});const T=d.environmentId??"",p=d.transport,v=d.label||d.installAsName||((u=d.ui)==null?void 0:u.pageTitle)||((s=(c=d.ui)==null?void 0:c.welcome)==null?void 0:s.title)||t,{instance:E,installed:h,loading:m}=_u(t,T,String(v||"Agent"),p);if(m)return Q.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:Q.jsx(Ai,{message:"Preparing agent..."})});if(!E||!h)return Q.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:[Q.jsx(Ai,{message:"Preparing agent..."}),Q.jsx("p",{className:"text-sm opacity-70",children:"This agent is not fully installed yet."})]});const a={id:(E==null?void 0:E.id)??t,integrationPackId:t,environmentId:T,installationType:"MULTI"};return Q.jsx(nh,{integration:a,onHeaderActionsChange:e})},sA={Agent:RI,AgentTiles:kI,AgentListLauncher:({agentIds:t})=>{var P,G,z,K,V;const{boomiConfig:e}=tn(),[o,d]=W.useState(!1),[T,p]=W.useState(null),[v,E]=W.useState(null),h=((P=e==null?void 0:e.components)==null?void 0:P.agentList)??{},m=(h==null?void 0:h.launcher)??{},a=(h==null?void 0:h.modal)??{},l=(h==null?void 0:h.welcome)??{},u=(h==null?void 0:h.header)??{},c=(h==null?void 0:h.search)??{},s=(m==null?void 0:m.position)||{corner:"bottom-right",offsetX:24,offsetY:40},f=(m==null?void 0:m.shape)||"pill",g=(m==null?void 0:m.label)||"Find an Agent",w=m==null?void 0:m.icon,A=m==null?void 0:m.hideIcon,R=W.useMemo(()=>{const X={position:"fixed",zIndex:999998};if(!s||"corner"in s){const q=(s==null?void 0:s.corner)??"bottom-right",Z=(s==null?void 0:s.offsetX)??24,te=(s==null?void 0:s.offsetY)??24;return q.includes("bottom")&&(X.bottom=te),q.includes("top")&&(X.top=te),q.includes("right")&&(X.right=Z),q.includes("left")&&(X.left=Z),X}return X.left=s.x,X.top=s.y,X},[s]),O={w:(a==null?void 0:a.width)??980,h:(a==null?void 0:a.height)??720},S=a==null?void 0:a.position,y=W.useMemo(()=>{if(!S)return;const X={position:"fixed",zIndex:999999};if("corner"in S){const q=S.corner??"bottom-right",Z=S.offsetX??24,te=S.offsetY??24;return q.includes("bottom")&&(X.bottom=te),q.includes("top")&&(X.top=te),q.includes("right")&&(X.right=Z),q.includes("left")&&(X.left=Z),X}return X.left=S.x,X.top=S.y,X},[S]);W.useEffect(()=>{if(!o)return;const X=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=X}},[o]),W.useEffect(()=>{T||E(null)},[T]);const N=W.useCallback(()=>{if(T){p(null);return}d(!1)},[T]),M=W.useMemo(()=>{const X=(e==null?void 0:e.agents)??{};return Array.from(new Set(t??[])).map(Z=>{var fe,Ae,Se,Ue,_e,Me;const te=X[Z];if(!te)return null;const oe=te.label||te.installAsName||((fe=te.ui)==null?void 0:fe.pageTitle)||((Se=(Ae=te.ui)==null?void 0:Ae.welcome)==null?void 0:Se.title)||Z,ae=((Ue=te.ui)==null?void 0:Ue.pageDescription)||((Me=(_e=te.ui)==null?void 0:_e.welcome)==null?void 0:Me.subtitle)||void 0;return{agentId:Z,name:String(oe||Z),description:ae?String(ae):void 0,icon:te.icon,hideIcon:te.hideIcon}}).filter(Z=>!!Z)},[t,e]),[k,$]=W.useState(""),[F,D]=W.useState(1),I=W.useMemo(()=>{const X=k.trim().toLowerCase();return X?M.filter(q=>{var oe;const Z=q.name.toLowerCase(),te=((oe=q.description)==null?void 0:oe.toLowerCase())??"";return q.agentId.toLowerCase().includes(X)||Z.includes(X)||te.includes(X)}):M},[M,k]),x=Math.max(1,Math.ceil(I.length/ah)),_=I.slice((F-1)*ah,F*ah),L=T?(G=e==null?void 0:e.agents)==null?void 0:G[T]:void 0,H=(L==null?void 0:L.label)||(L==null?void 0:L.installAsName)||((z=L==null?void 0:L.ui)==null?void 0:z.pageTitle)||((V=(K=L==null?void 0:L.ui)==null?void 0:K.welcome)==null?void 0:V.title)||T||"Agent",B=()=>Q.jsxs("div",{className:"w-full h-full p-4",children:[((u==null?void 0:u.show)??!0)&&Q.jsxs("div",{className:"space-y-1 mb-4",children:[Q.jsx("h2",{className:"text-lg font-semibold",children:(u==null?void 0:u.title)||(l==null?void 0:l.title)||"Agents"}),Q.jsx("p",{className:"text-sm opacity-70",children:(u==null?void 0:u.description)||(l==null?void 0:l.subtitle)||"Select an agent to start chatting."})]}),((c==null?void 0:c.show)??!0)&&Q.jsx("div",{className:"mb-4",children:Q.jsx(aA,{searchCallback:X=>{$(X),D(1)}})}),Q.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-6",children:_.length>0?_.map(X=>{const q=X.hideIcon?"":X.icon??"🤖";return Q.jsxs("li",{className:"boomi-card",children:[Q.jsxs("div",{className:"flex gap-4 p-4",children:[Q.jsx("div",{className:"text-2xl",children:q}),Q.jsxs("div",{className:"flex flex-col w-full",children:[Q.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:X.name}),Q.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:X.description||X.agentId})]})]}),Q.jsx("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:Q.jsx(Ci,{toggle:!1,primary:!0,showIcon:!1,label:"Launch",onClick:()=>p(X.agentId)})})]},X.agentId)}):Q.jsx("div",{className:"col-span-full flex justify-center items-center",children:Q.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),x>1&&Q.jsx("div",{className:"mt-4 flex justify-end",children:Q.jsx(oh,{currentPage:F,totalPages:x,onPageChange:D})})]});return Q.jsxs(Q.Fragment,{children:[Q.jsx("button",{"aria-label":g,title:g,onClick:()=>d(!0),style:R,className:f==="circle"?"w-12 h-12 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.03] transition-transform":"px-4 h-10 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.02] transition-transform",children:(()=>{const X=A?"":w??"🤖";return f==="circle"?X||"":Q.jsxs(Q.Fragment,{children:[X&&Q.jsx("span",{className:"mr-2",children:X}),Q.jsx("span",{children:g})]})})()}),o&&Q.jsx(ih,{size:O,style:y,children:Q.jsxs("div",{className:"boomi-agent-overlay__inner",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:T?H:(l==null?void 0:l.title)||"Agents"}),Q.jsxs("div",{className:"boomi-agent-overlay__header-actions",children:[T?v:null,Q.jsx("button",{type:"button","aria-label":"Close",className:"boomi-agent-overlay__close",onClick:N,children:"✕"})]})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:T?Q.jsx(II,{agentId:T,onHeaderActionsChange:E}):B()})]})})]})}};let Kt=null;const Qn={};async function DI(){await co.get().ensureReady()}function lA(t,e="--boomi-show-"){const o=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase();return`${e}${o}`}function MI(t,e,o){var s,f;if(!e)return;const d=[];let T="";const p=e.components??{};for(const[g,w]of Object.entries(p))typeof w=="boolean"&&(T+=`${lA(g)}:${w?"1":"0"};`);const v=e.cssVars??{};for(const[g,w]of Object.entries(v))String(g).startsWith("--")&&(T+=`${g}:${String(w)};`);T&&d.push(`:host{${T}}`);const E=e.cssVarsByTheme??{};for(const[g,w]of Object.entries(E)){const A=Object.entries(w).filter(([R])=>String(R).startsWith("--")).map(([R,O])=>`${R}:${String(O)};`).join("");A&&d.push(`:host([data-theme="${g}"]){${A}}`)}const m=(e.cssVarsByKey??{})[o]??{},a=((s=e.componentsByKey)==null?void 0:s[o])??{},l=(f=e.components)==null?void 0:f[o],u=l==null?void 0:l.modalOffset;let c="";for(const[g,w]of Object.entries(a))typeof w=="boolean"&&(c+=`${lA(g)}:${w?"1":"0"};`);for(const[g,w]of Object.entries(m))String(g).startsWith("--")&&(c+=`${g}:${String(w)};`);if(u){const g=R=>typeof R=="number"&&Number.isFinite(R)?`${R}px`:typeof R=="string"&&R.trim().length>0?R:null,w=g(u.offsetX??u.x??null),A=g(u.offsetY??u.y??null);w&&(c+=`--boomi-modal-offset-x:${w};`),A&&(c+=`--boomi-modal-offset-y:${A};`)}if(c&&d.push(`:host{${c}}`),d.length){t.querySelectorAll("style[data-boomi-vars]").forEach(w=>w.remove());const g=document.createElement("style");g.setAttribute("data-boomi-vars","true"),g.textContent=d.join(`
|
|
1919
|
+
*/const ih=({children:t,size:e,style:o})=>Q.jsxs("div",{className:"boomi-agent-overlay boomi-agent-overlay--modal",children:[Q.jsx("div",{className:"boomi-agent-overlay__scrim"}),Q.jsx("div",{className:"boomi-agent-overlay__modal",style:{width:e.w,height:e.h,...o},children:t})]}),RI=({integrationPackId:t})=>{var I,x,_,L,H,B,P,G,z,K,V,X,q,Z,te,oe,ae,fe,Ae,Se,Ue;const{boomiConfig:e}=tn(),o=(x=(I=e==null?void 0:e.agents)==null?void 0:I[t])==null?void 0:x.environmentId,d=((L=(_=e==null?void 0:e.agents)==null?void 0:_[t])==null?void 0:L.position)||{corner:"bottom-right",offsetX:24,offsetY:40},T=((B=(H=e==null?void 0:e.agents)==null?void 0:H[t])==null?void 0:B.shape)||"pill",p=((G=(P=e==null?void 0:e.agents)==null?void 0:P[t])==null?void 0:G.label)||"Chat with us",v=(K=(z=e==null?void 0:e.agents)==null?void 0:z[t])==null?void 0:K.icon,E=(X=(V=e==null?void 0:e.agents)==null?void 0:V[t])==null?void 0:X.hideIcon,h=((Z=(q=e==null?void 0:e.agents)==null?void 0:q[t])==null?void 0:Z.installAsName)??"Agent",m=(oe=(te=e==null?void 0:e.agents)==null?void 0:te[t])==null?void 0:oe.transport,{instance:a,installed:l,loading:u}=_u(t||"",o||"",h,m),[c,s]=W.useState(!1),[f,g]=W.useState("info"),[w,A]=W.useState(null),R=(fe=(ae=e==null?void 0:e.agents)==null?void 0:ae[t])==null?void 0:fe.ui,O=(R==null?void 0:R.mode)??"full",S={w:((Ae=R==null?void 0:R.modal)==null?void 0:Ae.width)??980,h:((Se=R==null?void 0:R.modal)==null?void 0:Se.height)??720},y=(Ue=R==null?void 0:R.modal)==null?void 0:Ue.position,N=W.useMemo(()=>({id:(a==null?void 0:a.id)??t,integrationPackId:t,environmentId:o||"",installationType:"MULTI"}),[t,o,a==null?void 0:a.id]),M=W.useMemo(()=>{const _e={position:"fixed",zIndex:999998};if(!d||"corner"in d){const Me=(d==null?void 0:d.corner)??"bottom-right",Ge=(d==null?void 0:d.offsetX)??24,Tt=(d==null?void 0:d.offsetY)??24;return Me.includes("bottom")&&(_e.bottom=Tt),Me.includes("top")&&(_e.top=Tt),Me.includes("right")&&(_e.right=Ge),Me.includes("left")&&(_e.left=Ge),_e}return _e.left=d.x,_e.top=d.y,_e},[d]),k=W.useMemo(()=>{if(!y)return;const _e={position:"fixed",zIndex:999999};if("corner"in y){const Me=y.corner??"bottom-right",Ge=y.offsetX??24,Tt=y.offsetY??24;return Me.includes("bottom")&&(_e.bottom=Tt),Me.includes("top")&&(_e.top=Tt),Me.includes("right")&&(_e.right=Ge),Me.includes("left")&&(_e.left=Ge),_e}return _e.left=y.x,_e.top=y.y,_e},[y]),$=u?"Agent (loading)":l?"Open Agent chat":"Open Agent info";W.useEffect(()=>{if(!c)return;const _e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=_e}},[c]),W.useEffect(()=>{c||A(null)},[c]);const F=()=>a?Q.jsx(nh,{integration:N,onHeaderActionsChange:A}):Q.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:[Q.jsx(Ai,{message:"Preparing agent..."}),Q.jsx("p",{className:"text-sm text-[color-mix(in_srgb,var(--boomi-page-fg-color,#f8fafc) 80%,transparent)]",children:"This agent is not fully installed yet. Configure it to start chatting."})]}),D=()=>!c||!l?null:O==="modal"?Q.jsx(ih,{size:S,style:k,children:Q.jsxs("div",{className:"boomi-agent-overlay__inner",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:p}),Q.jsxs("div",{className:"boomi-agent-overlay__header-actions",children:[w,Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:()=>s(!1),children:"✕"})]})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:F()})]})}):Q.jsxs("div",{className:"boomi-agent-overlay boomi-agent-overlay--full",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:p}),Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:()=>s(!1),children:"✕"})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:F()})]});return Q.jsxs(Q.Fragment,{children:[Q.jsx("button",{"aria-label":$,title:$,onClick:()=>{g(l?"chat":"info"),s(_e=>!_e)},style:M,className:T==="circle"?"w-12 h-12 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.03] transition-transform":"px-4 h-10 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.02] transition-transform",children:(()=>{const _e=E?"":v??"🤖";return T==="circle"?_e||"":Q.jsxs(Q.Fragment,{children:[_e&&Q.jsx("span",{className:"mr-2",children:_e}),Q.jsx("span",{children:p})]})})()}),D()]})},aA=({searchCallback:t})=>{const[e,o]=W.useState(""),d=v=>{const E=v.currentTarget.value;o(E)},T=v=>{if(v.key==="Enter"){const E=v.currentTarget.value;v.preventDefault(),o(E),t(E)}},p=()=>{o(""),t("");const v=document.getElementById("search");v==null||v.focus()};return Q.jsxs("div",{className:"relative flex items-center pr-2 w-[400px]",children:[Q.jsx("input",{type:"text",name:"search",id:"search",placeholder:"Type to search...",value:e,onChange:d,onKeyDown:T,className:"block w-full rounded-md py-2 pl-3 pr-10 text-sm boomi-input","aria-label":"Search"}),e.length>0&&Q.jsx("button",{type:"button",onClick:p,className:"absolute right-3 top-1/2 -translate-y-1/2 p-0.5 rounded-full focus:outline-none focus:ring-2 focus:ring-offset-1","aria-label":"Clear search",title:"Clear",children:Q.jsx(Om,{className:"h-5 w-5"})})]})},oh=({currentPage:t,totalPages:e,onPageChange:o})=>{const[d,T]=W.useState(t.toString()),p=h=>{h>=1&&h<=e&&(o(h),T(h.toString()))},v=h=>{T(h.target.value)},E=()=>{const h=parseInt(d,10);isNaN(h)||p(h)};return Q.jsxs("div",{className:"flex justify-end items-center space-x-2 mt-4",children:[Q.jsx(Ci,{toggle:!1,primary:!1,showIcon:!0,iconOnly:!0,disabled:t===1,icon:Q.jsx(u_,{className:"text-indigo-400 hover:text-indigo-500 w-6 h-6"}),onClick:()=>p(t-1)}),Array.from({length:e}).map((h,m)=>{const a=m+1;return Q.jsx("button",{className:`px-2 py-1 rounded cursor-pointer ${t===a?"text-indigo-500 bg-indigo-100 rounded-md":"text-indigo-400"}`,onClick:()=>p(a),children:a},a)}),Q.jsx(Ci,{toggle:!1,primary:!1,showIcon:!0,iconOnly:!0,disabled:t===e,icon:Q.jsx(d_,{className:"w-6 h-6"}),onClick:()=>p(t+1)}),Q.jsx("span",{className:"text-sm text-gray-700 ml-2",children:"Go to page"}),Q.jsx("input",{type:"number",value:d,onChange:v,className:"w-12 px-1 py-1 border rounded text-sm "}),Q.jsx(Ci,{toggle:!1,primary:!1,showIcon:!1,label:"Go",onClick:E})]})},rh=10,OI=({agentId:t,onClose:e})=>{var R,O,S,y,N;const{boomiConfig:o}=tn(),d=(R=o==null?void 0:o.agents)==null?void 0:R[t],T=d==null?void 0:d.ui,p=d==null?void 0:d.transport,v=(d==null?void 0:d.environmentId)??"",E=(d==null?void 0:d.label)||(d==null?void 0:d.installAsName)||(T==null?void 0:T.pageTitle)||((O=T==null?void 0:T.welcome)==null?void 0:O.title)||"Agent",{instance:h,installed:m,loading:a}=_u(t,v,E,p),[l,u]=W.useState(null),c=(T==null?void 0:T.mode)??"full",s={w:((S=T==null?void 0:T.modal)==null?void 0:S.width)??980,h:((y=T==null?void 0:T.modal)==null?void 0:y.height)??720},f=(N=T==null?void 0:T.modal)==null?void 0:N.position;W.useEffect(()=>{const M=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=M}},[]);const g=W.useMemo(()=>{if(!f)return;const M={position:"fixed",zIndex:999999};if("corner"in f){const k=f.corner??"bottom-right",$=f.offsetX??24,F=f.offsetY??24;return k.includes("bottom")&&(M.bottom=F),k.includes("top")&&(M.top=F),k.includes("right")&&(M.right=$),k.includes("left")&&(M.left=$),M}return M.left=f.x,M.top=f.y,M},[f]),w=W.useMemo(()=>({id:(h==null?void 0:h.id)??t,integrationPackId:t,environmentId:v,installationType:"MULTI"}),[t,v,h==null?void 0:h.id]),A=()=>a?Q.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:Q.jsx(Ai,{message:"Preparing agent..."})}):!h||!m?Q.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:[Q.jsx(Ai,{message:"Preparing agent..."}),Q.jsx("p",{className:"text-sm text-[color-mix(in_srgb,var(--boomi-page-fg-color,#f8fafc) 80%,transparent)]",children:"This agent is not fully installed yet. Configure it to start chatting."})]}):Q.jsx(nh,{integration:w,onHeaderActionsChange:u});return c==="modal"?Q.jsx(ih,{size:s,style:g,children:Q.jsxs("div",{className:"boomi-agent-overlay__inner",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:E}),Q.jsxs("div",{className:"boomi-agent-overlay__header-actions",children:[l,Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:e,children:"✕"})]})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:A()})]})}):Q.jsxs("div",{className:"boomi-agent-overlay boomi-agent-overlay--full",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:E}),Q.jsx("button",{type:"button","aria-label":"Close agent",className:"boomi-agent-overlay__close",onClick:e,children:"✕"})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:A()})]})},kI=({agentIds:t})=>{var S,y;const{boomiConfig:e,componentKey:o}=tn(),d=`embed-agents-view:${o||"public"}`,T=((S=e==null?void 0:e.components)==null?void 0:S.agentTiles)??((y=e==null?void 0:e.components)==null?void 0:y.agentList)??{},p=(T==null?void 0:T.header)??{},v=(T==null?void 0:T.search)??{},E=(T==null?void 0:T.viewToggle)??{},[h,m]=W.useState(""),[a,l]=W.useState(1),[u,c]=W.useState("off"),[s,f]=W.useState(null);W.useEffect(()=>{try{const N=localStorage.getItem(d);(N==="on"||N==="off")&&c(N)}catch{}},[d]);const g=W.useCallback(()=>{c(N=>{const M=N==="on"?"off":"on";try{localStorage.setItem(d,M)}catch{}return M})},[d]),w=W.useMemo(()=>Array.from(new Set(t??[])).map(M=>{var D,I,x,_,L,H,B;const k=(D=e==null?void 0:e.agents)==null?void 0:D[M],$=(k==null?void 0:k.label)||(k==null?void 0:k.installAsName)||((I=k==null?void 0:k.ui)==null?void 0:I.pageTitle)||((_=(x=k==null?void 0:k.ui)==null?void 0:x.welcome)==null?void 0:_.title)||M,F=((L=k==null?void 0:k.ui)==null?void 0:L.pageDescription)||((B=(H=k==null?void 0:k.ui)==null?void 0:H.welcome)==null?void 0:B.subtitle)||void 0;return{agentId:M,name:String($||M),description:F?String(F):void 0}}),[t,e]),A=W.useMemo(()=>{const N=h.trim().toLowerCase();return N?w.filter(M=>{var F;const k=M.name.toLowerCase(),$=((F=M.description)==null?void 0:F.toLowerCase())??"";return M.agentId.toLowerCase().includes(N)||k.includes(N)||$.includes(N)}):w},[w,h]),R=Math.max(1,Math.ceil(A.length/rh)),O=A.slice((a-1)*rh,a*rh);return Q.jsxs(Q.Fragment,{children:[s&&Q.jsx(OI,{agentId:s,onClose:()=>f(null)}),Q.jsxs("div",{className:"w-full h-full p-6",children:[((p==null?void 0:p.show)??!0)&&Q.jsxs("div",{className:"space-y-2",children:[Q.jsx("h1",{className:"text-2xl font-semibold",children:(p==null?void 0:p.title)||"Agents"}),Q.jsx("p",{className:"text-sm opacity-70",children:(p==null?void 0:p.description)||"Launch an agent to start chatting."})]}),Q.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[Q.jsx("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:((v==null?void 0:v.show)??!0)&&Q.jsx("div",{className:"min-w-[220px]",children:Q.jsx(aA,{searchCallback:N=>{m(N),l(1)}})})}),((E==null?void 0:E.show)??!0)&&Q.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:Q.jsx(Ci,{toggle:!0,primary:!1,viewLoc:d,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:"View",icon:Q.jsx(b_,{className:"h-5 w-5"}),onIcon:Q.jsx(r_,{className:"h-5 w-5"}),onClick:g})})]}),u==="off"?Q.jsxs(Q.Fragment,{children:[Q.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:O.length>0?O.map(N=>{var k;const M=((k=N.description)==null?void 0:k.trim())||N.agentId;return Q.jsxs("li",{className:"boomi-card",children:[Q.jsx("div",{className:"flex gap-4 p-4",children:Q.jsxs("div",{className:"flex flex-col w-full",children:[Q.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:N.name}),Q.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:M})]})}),Q.jsx("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:Q.jsx(Ci,{toggle:!1,primary:!0,showIcon:!1,label:"Launch",onClick:()=>f(N.agentId)})})]},N.agentId)}):Q.jsx("div",{className:"col-span-full flex justify-center items-center",children:Q.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),R>1&&Q.jsx(oh,{currentPage:a,totalPages:R,onPageChange:N=>l(N)})]}):Q.jsxs(Q.Fragment,{children:[Q.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[Q.jsx("thead",{className:"boomi-table-header",children:Q.jsxs("tr",{children:[Q.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent"}),Q.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Name"}),Q.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Agent ID"}),Q.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold",children:"Actions"})]})}),Q.jsx("tbody",{className:"divide-y",children:O.length>0?O.map(N=>Q.jsxs("tr",{className:"boomi-table-row",children:[Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:N.name}),Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:N.description||"—"}),Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-xs break-words",children:N.agentId}),Q.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:Q.jsx("div",{className:"flex justify-end",children:Q.jsx(Ci,{toggle:!1,primary:!0,showIcon:!1,label:"Launch",onClick:()=>f(N.agentId)})})})]},N.agentId)):Q.jsx("tr",{children:Q.jsx("td",{colSpan:4,children:Q.jsx("div",{className:"flex justify-center items-center py-4",children:Q.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})})})})]}),R>1&&Q.jsx("div",{className:"mt-4 flex justify-end",children:Q.jsx(oh,{currentPage:a,totalPages:R,onPageChange:l})})]})]})]})},ah=10,II=({agentId:t,onHeaderActionsChange:e})=>{var l,u,c,s;const{boomiConfig:o}=tn(),d=(l=o==null?void 0:o.agents)==null?void 0:l[t];if(!d)return Q.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:Q.jsx("p",{className:"text-sm opacity-70",children:"Agent config not found."})});const T=d.environmentId??"",p=d.transport,v=d.label||d.installAsName||((u=d.ui)==null?void 0:u.pageTitle)||((s=(c=d.ui)==null?void 0:c.welcome)==null?void 0:s.title)||t,{instance:E,installed:h,loading:m}=_u(t,T,String(v||"Agent"),p);if(m)return Q.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:Q.jsx(Ai,{message:"Preparing agent..."})});if(!E||!h)return Q.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4",children:[Q.jsx(Ai,{message:"Preparing agent..."}),Q.jsx("p",{className:"text-sm opacity-70",children:"This agent is not fully installed yet."})]});const a={id:(E==null?void 0:E.id)??t,integrationPackId:t,environmentId:T,installationType:"MULTI"};return Q.jsx(nh,{integration:a,onHeaderActionsChange:e})},sA={Agent:RI,AgentTiles:kI,AgentListLauncher:({agentIds:t})=>{var P,G,z,K,V;const{boomiConfig:e}=tn(),[o,d]=W.useState(!1),[T,p]=W.useState(null),[v,E]=W.useState(null),h=((P=e==null?void 0:e.components)==null?void 0:P.agentList)??{},m=(h==null?void 0:h.launcher)??{},a=(h==null?void 0:h.modal)??{},l=(h==null?void 0:h.welcome)??{},u=(h==null?void 0:h.header)??{},c=(h==null?void 0:h.search)??{},s=(m==null?void 0:m.position)||{corner:"bottom-right",offsetX:24,offsetY:40},f=(m==null?void 0:m.shape)||"pill",g=(m==null?void 0:m.label)||"Find an Agent",w=m==null?void 0:m.icon,A=m==null?void 0:m.hideIcon,R=W.useMemo(()=>{const X={position:"fixed",zIndex:999998};if(!s||"corner"in s){const q=(s==null?void 0:s.corner)??"bottom-right",Z=(s==null?void 0:s.offsetX)??24,te=(s==null?void 0:s.offsetY)??24;return q.includes("bottom")&&(X.bottom=te),q.includes("top")&&(X.top=te),q.includes("right")&&(X.right=Z),q.includes("left")&&(X.left=Z),X}return X.left=s.x,X.top=s.y,X},[s]),O={w:(a==null?void 0:a.width)??980,h:(a==null?void 0:a.height)??720},S=a==null?void 0:a.position,y=W.useMemo(()=>{if(!S)return;const X={position:"fixed",zIndex:999999};if("corner"in S){const q=S.corner??"bottom-right",Z=S.offsetX??24,te=S.offsetY??24;return q.includes("bottom")&&(X.bottom=te),q.includes("top")&&(X.top=te),q.includes("right")&&(X.right=Z),q.includes("left")&&(X.left=Z),X}return X.left=S.x,X.top=S.y,X},[S]);W.useEffect(()=>{if(!o)return;const X=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=X}},[o]),W.useEffect(()=>{T||E(null)},[T]);const N=W.useCallback(()=>{if(T){p(null);return}d(!1)},[T]),M=W.useMemo(()=>{const X=(e==null?void 0:e.agents)??{};return Array.from(new Set(t??[])).flatMap(Z=>{var fe,Ae,Se,Ue,_e,Me;const te=X[Z];if(!te)return[];const oe=te.label||te.installAsName||((fe=te.ui)==null?void 0:fe.pageTitle)||((Se=(Ae=te.ui)==null?void 0:Ae.welcome)==null?void 0:Se.title)||Z,ae=((Ue=te.ui)==null?void 0:Ue.pageDescription)||((Me=(_e=te.ui)==null?void 0:_e.welcome)==null?void 0:Me.subtitle)||void 0;return[{agentId:Z,name:String(oe||Z),description:ae?String(ae):void 0,icon:te.icon,hideIcon:te.hideIcon}]})},[t,e]),[k,$]=W.useState(""),[F,D]=W.useState(1),I=W.useMemo(()=>{const X=k.trim().toLowerCase();return X?M.filter(q=>{var oe;const Z=q.name.toLowerCase(),te=((oe=q.description)==null?void 0:oe.toLowerCase())??"";return q.agentId.toLowerCase().includes(X)||Z.includes(X)||te.includes(X)}):M},[M,k]),x=Math.max(1,Math.ceil(I.length/ah)),_=I.slice((F-1)*ah,F*ah),L=T?(G=e==null?void 0:e.agents)==null?void 0:G[T]:void 0,H=(L==null?void 0:L.label)||(L==null?void 0:L.installAsName)||((z=L==null?void 0:L.ui)==null?void 0:z.pageTitle)||((V=(K=L==null?void 0:L.ui)==null?void 0:K.welcome)==null?void 0:V.title)||T||"Agent",B=()=>Q.jsxs("div",{className:"w-full h-full p-4",children:[((u==null?void 0:u.show)??!0)&&Q.jsxs("div",{className:"space-y-1 mb-4",children:[Q.jsx("h2",{className:"text-lg font-semibold",children:(u==null?void 0:u.title)||(l==null?void 0:l.title)||"Agents"}),Q.jsx("p",{className:"text-sm opacity-70",children:(u==null?void 0:u.description)||(l==null?void 0:l.subtitle)||"Select an agent to start chatting."})]}),((c==null?void 0:c.show)??!0)&&Q.jsx("div",{className:"mb-4",children:Q.jsx(aA,{searchCallback:X=>{$(X),D(1)}})}),Q.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-6",children:_.length>0?_.map(X=>{const q=X.hideIcon?"":X.icon??"🤖";return Q.jsxs("li",{className:"boomi-card",children:[Q.jsxs("div",{className:"flex gap-4 p-4",children:[Q.jsx("div",{className:"text-2xl",children:q}),Q.jsxs("div",{className:"flex flex-col w-full",children:[Q.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:X.name}),Q.jsx("p",{className:"text-xs mt-1 opacity-70 break-words overflow-hidden",children:X.description||X.agentId})]})]}),Q.jsx("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:Q.jsx(Ci,{toggle:!1,primary:!0,showIcon:!1,label:"Launch",onClick:()=>p(X.agentId)})})]},X.agentId)}):Q.jsx("div",{className:"col-span-full flex justify-center items-center",children:Q.jsx("p",{className:"text-gray-500 text-xs",children:"No agents found."})})}),x>1&&Q.jsx("div",{className:"mt-4 flex justify-end",children:Q.jsx(oh,{currentPage:F,totalPages:x,onPageChange:D})})]});return Q.jsxs(Q.Fragment,{children:[Q.jsx("button",{"aria-label":g,title:g,onClick:()=>d(!0),style:R,className:f==="circle"?"w-12 h-12 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.03] transition-transform":"px-4 h-10 rounded-full bg-blue-600 text-white shadow-lg hover:scale-[1.02] transition-transform",children:(()=>{const X=A?"":w??"🤖";return f==="circle"?X||"":Q.jsxs(Q.Fragment,{children:[X&&Q.jsx("span",{className:"mr-2",children:X}),Q.jsx("span",{children:g})]})})()}),o&&Q.jsx(ih,{size:O,style:y,children:Q.jsxs("div",{className:"boomi-agent-overlay__inner",children:[Q.jsxs("div",{className:"boomi-agent-overlay__header",children:[Q.jsx("div",{className:"boomi-agent-overlay__title",children:T?H:(l==null?void 0:l.title)||"Agents"}),Q.jsxs("div",{className:"boomi-agent-overlay__header-actions",children:[T?v:null,Q.jsx("button",{type:"button","aria-label":"Close",className:"boomi-agent-overlay__close",onClick:N,children:"✕"})]})]}),Q.jsx("div",{className:"boomi-agent-overlay__body",children:T?Q.jsx(II,{agentId:T,onHeaderActionsChange:E}):B()})]})})]})}};let Kt=null;const Qn={};async function DI(){await co.get().ensureReady()}function lA(t,e="--boomi-show-"){const o=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase();return`${e}${o}`}function MI(t,e,o){var s,f;if(!e)return;const d=[];let T="";const p=e.components??{};for(const[g,w]of Object.entries(p))typeof w=="boolean"&&(T+=`${lA(g)}:${w?"1":"0"};`);const v=e.cssVars??{};for(const[g,w]of Object.entries(v))String(g).startsWith("--")&&(T+=`${g}:${String(w)};`);T&&d.push(`:host{${T}}`);const E=e.cssVarsByTheme??{};for(const[g,w]of Object.entries(E)){const A=Object.entries(w).filter(([R])=>String(R).startsWith("--")).map(([R,O])=>`${R}:${String(O)};`).join("");A&&d.push(`:host([data-theme="${g}"]){${A}}`)}const m=(e.cssVarsByKey??{})[o]??{},a=((s=e.componentsByKey)==null?void 0:s[o])??{},l=(f=e.components)==null?void 0:f[o],u=l==null?void 0:l.modalOffset;let c="";for(const[g,w]of Object.entries(a))typeof w=="boolean"&&(c+=`${lA(g)}:${w?"1":"0"};`);for(const[g,w]of Object.entries(m))String(g).startsWith("--")&&(c+=`${g}:${String(w)};`);if(u){const g=R=>typeof R=="number"&&Number.isFinite(R)?`${R}px`:typeof R=="string"&&R.trim().length>0?R:null,w=g(u.offsetX??u.x??null),A=g(u.offsetY??u.y??null);w&&(c+=`--boomi-modal-offset-x:${w};`),A&&(c+=`--boomi-modal-offset-y:${A};`)}if(c&&d.push(`:host{${c}}`),d.length){t.querySelectorAll("style[data-boomi-vars]").forEach(w=>w.remove());const g=document.createElement("style");g.setAttribute("data-boomi-vars","true"),g.textContent=d.join(`
|
|
1920
1920
|
`),t.appendChild(g)}}function $I(t,e){var d;if(!t)return"base";const o=(d=t.boomiConfig)==null?void 0:d.theme;return!o||(o==null?void 0:o.allowThemes)===!1?"base":o.defaultTheme||"base"}function UI(t){if(t.querySelector("style[data-boomi-base]"))return;const e=document.createElement("style");e.setAttribute("data-boomi-base","true"),e.textContent=`
|
|
1921
1921
|
${y_}
|
|
1922
1922
|
:host { display:block; height:100%; width:100%; min-height:0; margin:0; padding:0; }
|
package/dist/index.cjs
CHANGED
|
@@ -2103,7 +2103,8 @@ https://sweetalert2.github.io/#ajax-request`),c3(t),typeof t.title=="string"&&(t
|
|
|
2103
2103
|
* flows can match other admin mutation hooks.
|
|
2104
2104
|
*/const xH=()=>{const[t,e]=O.useState(!1),[n,o]=O.useState(null),{deleteCorsConfig:i}=Vu(),r=O.useCallback(async s=>{e(!0),o(null);try{await i(s),pe.debug("[useDeleteCors] deleted config",{primaryAccountId:s.primaryAccountId})}catch(c){const a=(c==null?void 0:c.message)||"Failed to delete CORS configuration";throw pe.error({err:c},"[useDeleteCors] failed"),o(a),c}finally{e(!1)}},[i]);return O.useMemo(()=>({deleteCors:r,isDeleting:t,error:n}),[r,n,t])},EH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o})=>{const[i,r]=O.useState(""),[s,c]=O.useState(null);O.useEffect(()=>{t&&(r(""),c(null))},[t]);const a=async()=>{const d=i.trim();if(!d){c("Origin is required");return}c(null),await n(d)};return v.jsx(Tn,{isOpen:t,title:"Add Allowed Origin",description:"Add a new origin to the allowed list for this tenant.",onClose:e,onSubmit:a,submitLabel:o?"Saving...":"Add Origin",showSaveButton:!o,children:v.jsx(Ot,{formName:"corsAdd",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:i,onChange:d=>r(d.target.value),placeholder:"https://app.example.com",error:s||void 0})})},TH=({isOpen:t,origin:e,onClose:n,onSubmit:o,isSaving:i})=>{const[r,s]=O.useState(e??""),[c,a]=O.useState(null);O.useEffect(()=>{t&&(s(e??""),a(null))},[t,e]);const d=async()=>{const l=r.trim();if(!l){a("Origin is required");return}a(null),await o(l)};return v.jsx(Tn,{isOpen:t,title:"Edit Allowed Origin",description:"Update the selected origin for this tenant.",onClose:n,onSubmit:d,submitLabel:i?"Saving...":"Save Changes",showSaveButton:!i,children:v.jsx(Ot,{formName:"corsEdit",label:"Origin",required:!0,inputName:"origin",readOnly:!1,value:r,onChange:l=>s(l.target.value),placeholder:"https://app.example.com",error:c||void 0})})},AH=({isOpen:t,origin:e,onClose:n,onConfirm:o,isDeleting:i})=>v.jsx(Tn,{isOpen:t,title:"Delete Allowed Origin",description:"Remove this origin from the allowed list for this tenant.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:v.jsxs("p",{className:"text-sm",children:["Are you sure you want to remove"," ",v.jsx("span",{className:"font-semibold",children:e})," from the allowed origins?"]})});function eL(){const t=ro(),e=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/sessions",{params:g,signal:p})},[t]),n=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/sessions/all",{params:g,signal:p})},[t]),o=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/keys",{params:g,signal:p})},[t]),i=O.useCallback(async(m={})=>{const{signal:p,...g}=m;return t.get("/admin/redis/keys/all",{params:g,signal:p})},[t]),r=O.useCallback(async(m,p)=>t.get("/admin/redis/sub-accounts",{params:{tenantId:m},signal:p}),[t]),s=O.useCallback(async m=>t.get("/admin/redis/tenants",{signal:m}),[t]),c=O.useCallback(async m=>t.get("/admin/redis/key-types",{signal:m}),[t]),a=O.useCallback(async(m,p)=>(pe.debug("[useAdminRedisService.getKeyDetails]",{key:m,reveal:p==null?void 0:p.reveal}),t.get("/admin/redis/keys/detail",{params:{key:m,reveal:p==null?void 0:p.reveal},signal:p==null?void 0:p.signal})),[t]),d=O.useCallback(async(m,p,g,b)=>{await t.put("/admin/redis/keys",{key:m,value:p,ttlSeconds:g},{signal:b})},[t]),l=O.useCallback(async(m,p)=>{await t.del("/admin/redis/keys",{params:{key:m},signal:p})},[t]),h=O.useCallback(async m=>t.post("/admin/redis/clear/tenant",{},{signal:m}),[t]),f=O.useCallback(async(m,p)=>t.post("/admin/redis/clear/sub-account",{subAccountId:m},{signal:p}),[t]),u=O.useCallback(async(m,p)=>t.post("/admin/redis/sessions/revoke",{subAccountId:m},{signal:p}),[t]);return O.useMemo(()=>({listSessions:e,listSessionsAll:n,listKeys:o,listKeysAll:i,listSubAccounts:r,listTenants:s,listKeyTypes:c,getKeyDetails:a,deleteKey:l,clearTenant:h,clearSubAccount:f,revokeSessions:u,updateKey:d}),[e,n,o,i,r,s,c,a,l,h,f,u,d])}const Ah=12,tL=({componentKey:t,primaryAccountId:e})=>{var Fe,$e,re,ve,je,qe,De;const{boomiConfig:n,tenantId:o,setPageIsLoading:i}=vt(),r=e??o??(n==null?void 0:n.tenantId),s=`cors-view:${t}`,c=($e=(Fe=n==null?void 0:n.components)==null?void 0:Fe[t])==null?void 0:$e.cors;(re=c==null?void 0:c.search)==null||re.show;const a=((ve=c==null?void 0:c.addButton)==null?void 0:ve.show)??!0,d=((je=c==null?void 0:c.viewTypeButton)==null?void 0:je.show)??!0,l=ro(),{listTenants:h,listSubAccounts:f,listKeyTypes:u}=eL(),{allowedOrigins:m,refetch:p,isLoading:g,error:b}=wH({primaryAccountId:r,auto:!!r}),{updateCors:w,isUpdating:E,error:T}=yH(),{deleteCors:y,isDeleting:x,error:_}=xH(),[N,C]=O.useState([]),[L,D]=O.useState(""),[I,k]=O.useState(""),[S,A]=O.useState(""),[R,$]=O.useState([]),[P,U]=O.useState([]),[F,B]=O.useState(!1),[Q,z]=O.useState(1),[G,W]=O.useState("off"),[V,Y]=O.useState(!1),[Z,ee]=O.useState(!1),[J,ae]=O.useState(!1),[K,fe]=O.useState(null),[te,de]=O.useState(null),[xe,ke]=O.useState(null),[Ke,He]=O.useState({add:!1,edit:!1,delete:!1});O.useEffect(()=>{try{const be=localStorage.getItem(s);(be==="on"||be==="off")&&W(be)}catch{}},[s]),O.useEffect(()=>{F||r&&C(m.map(be=>({origin:be,tenantId:r})))},[m,F,r]),O.useEffect(()=>{const be=new AbortController;return u(be.signal).then(Re=>B(!!Re.isSuperAdmin)).catch(()=>B(!1)),()=>be.abort()},[u]),O.useEffect(()=>{if(!F)return;const be=new AbortController;return h(be.signal).then(Re=>$(Re.items??[])).catch(()=>$([])),()=>be.abort()},[F,h]),O.useEffect(()=>{if(!F)return;const be=new AbortController;return f(I||void 0,be.signal).then(Ge=>U(Ge.items??[])).catch(()=>U([])),()=>be.abort()},[F,I,f]);const Xe=O.useCallback(be=>l.get("/admin/cors",{signal:be}).then(Re=>{const Ge=((Re==null?void 0:Re.items)??[]).flatMap(le=>(le.allowedOrigins||[]).map(oe=>({origin:oe,tenantId:le.primaryAccountId})));C(Ge)}),[l]);O.useEffect(()=>{if(!F)return;const be=new AbortController;return Xe(be.signal).catch(()=>C([])),()=>be.abort()},[F,Xe]);const Pe=O.useMemo(()=>{const be=L.trim().toLowerCase(),Re=I?N.filter(Ge=>Ge.tenantId===I):N;return be?Re.filter(Ge=>Ge.origin.toLowerCase().includes(be)):Re},[N,L,I]),Ye=O.useMemo(()=>Pe,[Pe,S]),Ce=Math.max(1,Math.ceil(Ye.length/Ah)),ze=Ye.slice((Q-1)*Ah,Q*Ah),me=be=>{He(Re=>({...Re,[be]:!0})),setTimeout(()=>He(Re=>({...Re,[be]:!1})),3e3)},Te=()=>r||(ke("primaryAccountId is required to manage CORS."),null),ye=()=>F?I||(ke("Select a tenant to modify CORS configuration."),null):Te(),Ae=O.useCallback(()=>{W(be=>{const Re=be==="on"?"off":"on";try{localStorage.setItem(s,Re)}catch{}return Re})},[s]),ue=async be=>{const Re=ye();if(!Re)return;const Ge=Array.from(new Set([...N.filter(le=>le.tenantId===Re).map(le=>le.origin),be]));i(!0);try{const le=await w({primaryAccountId:Re,allowedOrigins:Ge});F||C(le.allowedOrigins.map(oe=>({origin:oe,tenantId:Re}))),Y(!1),me("add"),F?await Xe():await p()}catch(le){pe.error({err:le},"[Cors] add failed")}finally{i(!1)}},ie=async be=>{if(!K)return;const Re=F?te||ye():Te();if(!Re)return;const Ge=N.filter(oe=>oe.tenantId===Re).map(oe=>oe.origin===K?be:oe.origin),le=Array.from(new Set(Ge));i(!0);try{const oe=await w({primaryAccountId:Re,allowedOrigins:le});F||C(oe.allowedOrigins.map(we=>({origin:we,tenantId:Re}))),ee(!1),fe(null),de(null),me("edit"),F?await Xe():await p()}catch(oe){pe.error({err:oe},"[Cors] edit failed")}finally{i(!1)}},ce=async()=>{if(!K)return;const be=F?te||ye():Te();if(!be)return;const Re=N.filter(Ge=>Ge.tenantId===be).map(Ge=>Ge.origin).filter(Ge=>Ge!==K);i(!0);try{if(Re.length===0)await y({primaryAccountId:be}),F||C([]);else{const Ge=await w({primaryAccountId:be,allowedOrigins:Re});F||C(Ge.allowedOrigins.map(le=>({origin:le,tenantId:be})))}ae(!1),fe(null),de(null),me("delete"),F?await Xe():await p()}catch(Ge){pe.error({err:Ge},"[Cors] delete failed")}finally{i(!1)}},Ne=({origin:be,tenantId:Re})=>v.jsxs(xi,{children:[v.jsx(jt.Item,{children:({active:Ge})=>v.jsxs("button",{onClick:()=>{fe(be),de(Re),ee(!0)},className:"boomi-menu-item","data-headlessui-state":Ge?"active":void 0,children:[v.jsx(fu,{className:"boomi-menu-icon"}),"Edit"]})}),v.jsx("div",{className:"boomi-menu-divider"}),v.jsx(jt.Item,{children:({active:Ge})=>v.jsxs("button",{onClick:()=>{fe(be),de(Re),ae(!0)},className:"boomi-menu-item boomi-menu-item--danger","data-headlessui-state":Ge?"active":void 0,children:[v.jsx(oo,{className:"boomi-menu-icon"}),"Delete"]})})]}),Ie=xe||b||T||_||null;return v.jsxs(v.Fragment,{children:[Ke.add&&v.jsx(Mn,{type:"success",content:"Origin added."}),Ke.edit&&v.jsx(Mn,{type:"success",content:"Origin updated."}),Ke.delete&&v.jsx(Mn,{type:"success",content:"Origin deleted."}),v.jsx(EH,{isOpen:V,onClose:()=>Y(!1),onSubmit:ue,isSaving:E}),v.jsx(TH,{isOpen:Z,origin:K,onClose:()=>{ee(!1),fe(null)},onSubmit:ie,isSaving:E}),v.jsx(AH,{isOpen:J,origin:K,onClose:()=>{ae(!1),fe(null)},onConfirm:ce,isDeleting:x}),v.jsxs("div",{className:"w-full h-full p-6",children:[v.jsxs("div",{className:"space-y-2",children:[v.jsx("h1",{className:"text-2xl font-semibold",children:"CORS Configuration"}),v.jsx("p",{className:"text-sm opacity-70",children:"Manage allowed origins for this tenant."})]}),v.jsxs("div",{className:"flex items-end gap-3 mb-4 mt-4",children:[v.jsxs("div",{className:"flex flex-wrap items-end gap-3 flex-1 min-w-0",children:[v.jsx("div",{className:`min-w-[220px]${F?" pt-6":""}`,children:v.jsx(Zi,{searchCallback:be=>{D(be),z(1)}})}),F&&v.jsxs("label",{className:"text-xs font-semibold",children:["Tenant",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:I,onChange:be=>{k(be.target.value),A(""),z(1)},children:[v.jsx("option",{value:"",children:"All"}),R.map(be=>v.jsx("option",{value:be,children:be},be))]})]})]}),v.jsxs("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:[d&&v.jsx(tt,{toggle:!0,primary:!1,viewLoc:s,onClass:"flex w-full justify-center rounded-md px-2 py-2 text-xs font-semibold leading-6 shadow-md transition-colors duration-100",showIcon:!0,label:(qe=c==null?void 0:c.viewTypeButton)==null?void 0:qe.label,icon:v.jsx(mu,{className:"h-5 w-5"}),onIcon:v.jsx(hu,{className:"h-5 w-5"}),onClick:Ae}),a&&v.jsx(tt,{toggle:!1,primary:!0,showIcon:!0,label:`Add ${((De=c==null?void 0:c.addButton)==null?void 0:De.label)??""}`.trim(),icon:v.jsx(or,{className:"h-5 w-5"}),onClick:()=>Y(!0)})]})]}),Ie&&v.jsx("div",{className:"boomi-notice boomi-notice--error text-sm",children:Ie}),G==="off"?v.jsxs(v.Fragment,{children:[v.jsx("ul",{role:"list",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8",children:g?v.jsx("div",{className:"col-span-full flex justify-center items-center",children:v.jsx(Zt,{})}):ze.length>0?ze.map(be=>{var Re;return v.jsxs("li",{className:"boomi-card boomi-cors-card",children:[v.jsx("div",{className:"flex gap-4 p-4",children:v.jsxs("div",{className:"flex flex-col w-full",children:[v.jsx("h3",{className:"text-base font-semibold break-words truncate overflow-hidden pr-2",children:be.origin}),v.jsxs("p",{className:"text-xs mt-1 line-clamp-2 break-words overflow-hidden",children:["Origin allowed for tenant ",be.tenantId,"."]})]})}),v.jsxs("div",{className:"flex w-full p-2 justify-end items-center gap-x-2 relative overflow-visible",children:[v.jsx(tt,{toggle:!1,primary:!0,showIcon:!1,label:((Re=c==null?void 0:c.editButton)==null?void 0:Re.label)??"Edit",onClick:()=>{fe(be.origin),de(be.tenantId),ee(!0)}}),v.jsx(Ne,{origin:be.origin,tenantId:be.tenantId})]})]},`${be.tenantId}:${be.origin}`)}):v.jsx("div",{className:"col-span-full flex justify-center items-center",children:v.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})}),!g&&Ce>1&&v.jsx(gi,{currentPage:Q,totalPages:Ce,onPageChange:be=>z(be)})]}):v.jsxs(v.Fragment,{children:[v.jsxs("table",{className:"w-full table-auto rounded-lg shadow-sm",children:[v.jsx("thead",{className:"boomi-table-header",children:v.jsxs("tr",{children:[v.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold w-3/4",children:"Origin"}),F&&v.jsx("th",{className:"py-3 px-4 text-left text-sm font-semibold",children:"Tenant"}),v.jsx("th",{className:"py-3 px-4 text-right text-sm font-semibold w-1/4",children:"Actions"})]})}),v.jsx("tbody",{className:"divide-y",children:g?v.jsx("tr",{children:v.jsx("td",{colSpan:F?3:2,children:v.jsx("div",{className:"flex justify-center items-center py-6",children:v.jsx(Zt,{})})})}):ze.length>0?ze.map(be=>v.jsxs("tr",{className:"boomi-table-row",children:[v.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2 max-w-md break-words",children:be.origin}),F&&v.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:be.tenantId}),v.jsx("td",{className:"py-4 pl-4 pr-3 text-xs sm:pl-2",children:v.jsx("div",{className:"flex justify-end",children:v.jsx(Ne,{origin:be.origin,tenantId:be.tenantId})})})]},`${be.tenantId}:${be.origin}`)):v.jsx("tr",{children:v.jsx("td",{colSpan:F?3:2,children:v.jsx("div",{className:"flex justify-center items-center py-4",children:v.jsx("p",{className:"text-gray-500 text-xs",children:"No allowed origins found."})})})})})]}),!g&&Ce>1&&v.jsx("div",{className:"mt-4 flex justify-end",children:v.jsx(gi,{currentPage:Q,totalPages:Ce,onPageChange:z})})]})]})]})};function nL(){const t=ro(),e=O.useCallback(s=>`/admin/agents/${encodeURIComponent(s)}`,[]),n=O.useCallback(async s=>{const{primaryAccountId:c,includeDetails:a,signal:d}=s;return t.get(e(c),{signal:d,params:a?{includeDetails:!0}:void 0})},[t,e]),o=O.useCallback(async s=>{const{primaryAccountId:c,signal:a}=s;return t.get(`${e(c)}/available`,{signal:a})},[t,e]),i=O.useCallback(async s=>{const{primaryAccountId:c,agentId:a,boomiAgentId:d,label:l,allowedOrigins:h,config:f,publicTokenIds:u,createToken:m,rateLimit:p,signal:g}=s,b={agentId:a};return d!==void 0&&(b.boomiAgentId=d),l!==void 0&&(b.label=l),h!==void 0&&(b.allowedOrigins=h),f!==void 0&&(b.config=f),u!==void 0&&(b.publicTokenIds=u),m!==void 0&&(b.createToken=m),p!==void 0&&(b.rateLimit=p),t.post(e(c),b,{signal:g})},[t,e]),r=O.useCallback(async s=>{const{primaryAccountId:c,agentId:a,signal:d}=s;await t.del(`${e(c)}/${encodeURIComponent(a)}`,{signal:d})},[t,e]);return O.useMemo(()=>({listAgents:n,listAvailableAgents:o,createAgent:i,deleteAgent:r}),[n,o,i,r])}const oL=({label:t,labelAddon:e,value:n,placeholder:o,helperText:i,error:r,onChange:s})=>{const c=O.useMemo(()=>Math.max(1,n.split(`
|
|
2105
2105
|
`).length),[n]),a=O.useMemo(()=>Array.from({length:c},(d,l)=>String(l+1)).join(`
|
|
2106
|
-
`),[c]);return v.jsxs("div",{children:[v.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[v.jsx("span",{children:t}),e]}),v.jsxs("div",{className:["flex w-full rounded-md border overflow-hidden","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_92%,#000000)]",r?"boomi-input--error":""].join(" ").trim(),children:[v.jsx("pre",{className:["m-0 py-2 px-3 text-xs font-mono leading-5","text-[color-mix(in_srgb,var(--boomi-card-fg,#111)_55%,transparent)]","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_86%,#000000)]","border-r border-[color-mix(in_srgb,var(--boomi-card-border,#e5e7eb)_80%,transparent)]","select-none text-right min-w-[2.5rem]"].join(" "),children:a}),v.jsx("textarea",{className:["boomi-input flex-1 rounded-none border-0 font-mono text-xs leading-5","bg-transparent p-2 min-h-[120px]","focus:outline-none"].join(" "),placeholder:o,value:n,onChange:d=>s(d.target.value)})]}),i&&v.jsx("p",{className:"boomi-form-helper",children:i}),r&&v.jsx("p",{className:"boomi-form-error",children:r})]})},Sh=[{value:"",label:"None"},{value:"🤖",label:"🤖 Robot"},{value:"💬",label:"💬 Chat"},{value:"🗣️",label:"🗣️ Speaking"},{value:"✨",label:"✨ Sparkles"},{value:"🧠",label:"🧠 Brain"},{value:"💡",label:"💡 Idea"},{value:"🚀",label:"🚀 Rocket"},{value:"⚡",label:"⚡ Lightning"},{value:"🔍",label:"🔍 Search"},{value:"🛠️",label:"🛠️ Tools"},{value:"🤝",label:"🤝 Handshake"},{value:"🌐",label:"🌐 Globe"},{value:"🎯",label:"🎯 Target"},{value:"📊",label:"📊 Analytics"}],Lr=["bottom-right","bottom-left","top-right","top-left"],SH=t=>/font|family|radius|scale|speed|direction|angle|opacity|blur/.test(t),AT=["--boomi-font","--default-font-family","--boomi-accent","--boomi-agent-bg","--boomi-agent-blur","--boomi-agent-border","--boomi-agent-bubble-agent-bg","--boomi-agent-bubble-agent-border","--boomi-agent-bubble-agent-fg","--boomi-agent-bubble-border","--boomi-agent-bubble-shadow","--boomi-agent-bubble-user-bg","--boomi-agent-bubble-user-border","--boomi-agent-bubble-user-fg","--boomi-agent-card-tint","--boomi-agent-chat-bg","--boomi-agent-chat-border","--boomi-agent-chat-fg","--boomi-agent-close-bg-hover","--boomi-agent-close-fg","--boomi-agent-close-hover-fg","--boomi-agent-compose-bg","--boomi-agent-compose-border","--boomi-agent-compose-input-bg","--boomi-agent-compose-input-border","--boomi-agent-compose-secondary-bg","--boomi-agent-compose-secondary-border","--boomi-agent-compose-shadow","--boomi-agent-fg","--boomi-agent-header-bg","--boomi-agent-header-border","--boomi-agent-pane-bg","--boomi-agent-pane-bg-color","--boomi-agent-pane-fg","--boomi-agent-pane-fg-color","--boomi-agent-radius","--boomi-agent-ring","--boomi-agent-row-shimmer-opacity","--boomi-agent-row-tint","--boomi-agent-section-bg","--boomi-agent-section-border","--boomi-agent-section-fg","--boomi-agent-section-shadow","--boomi-agent-shadow","--boomi-agent-shimmer-1","--boomi-agent-shimmer-2","--boomi-agent-shimmer-angle","--boomi-agent-shimmer-direction","--boomi-agent-shimmer-opacity","--boomi-agent-shimmer-speed","--boomi-agent-tab-bg","--boomi-agent-tab-bg-active","--boomi-agent-tab-border","--boomi-agent-tab-border-active","--boomi-agent-tab-fg","--boomi-agent-tab-fg-active","--boomi-agent-tab-shadow-active","--boomi-agent-text-bg","--boomi-agent-text-border","--boomi-agent-text-copy-bg","--boomi-agent-text-copy-bg-hover","--boomi-agent-text-copy-fg","--boomi-agent-text-fg","--boomi-agent-thread-separator","--boomi-agent-update-bg","--boomi-agent-update-border","--boomi-agent-update-content-bg","--boomi-agent-update-content-fg","--boomi-agent-update-desc-fg","--boomi-agent-update-fg","--boomi-agent-update-radius","--boomi-agent-update-shadow","--boomi-agent-update-title-fg","--boomi-angle","--boomi-btn-primary-bg","--boomi-btn-primary-bg-active","--boomi-btn-primary-bg-hover","--boomi-btn-primary-border","--boomi-btn-primary-border-active","--boomi-btn-primary-border-hover","--boomi-btn-primary-fg","--boomi-btn-primary-fg-active","--boomi-btn-primary-fg-hover","--boomi-btn-primary-shadow","--boomi-btn-primary-shadow-active","--boomi-btn-primary-shadow-hover","--boomi-btn-secondary-bg","--boomi-btn-secondary-bg-active","--boomi-btn-secondary-bg-hover","--boomi-btn-secondary-border","--boomi-btn-secondary-border-active","--boomi-btn-secondary-border-hover","--boomi-btn-secondary-fg","--boomi-btn-secondary-fg-active","--boomi-btn-secondary-fg-hover","--boomi-btn-secondary-shadow","--boomi-btn-secondary-shadow-active","--boomi-btn-secondary-shadow-hover","--boomi-card-bg","--boomi-card-border","--boomi-card-fg","--boomi-card-hover-scale","--boomi-card-hover-shadow","--boomi-card-radius","--boomi-card-shadow","--boomi-chip-bg","--boomi-chip-border","--boomi-chip-error-bg","--boomi-chip-error-border","--boomi-chip-error-fg","--boomi-chip-fg","--boomi-chip-pulse-color","--boomi-chip-success-bg","--boomi-chip-success-border","--boomi-chip-success-fg","--boomi-chip-warning-bg","--boomi-chip-warning-border","--boomi-chip-warning-fg"],_H=()=>({themeSelection:"boomi",themeDefault:"boomi",themeCustomName:"",themeCustomVars:[],launcherCorner:"bottom-right",launcherOffsetX:"20",launcherOffsetY:"40",launcherShape:"pill",launcherLabel:"Find an Agent",launcherIcon:"🤖",launcherHideIcon:!1,listModalWidth:"500",listModalHeight:"600",listModalCorner:"bottom-right",listModalOffsetX:"20",listModalOffsetY:"100",listWelcomeTitle:"Agents",listWelcomeSubtitle:"Search for an agent and click to launch.",listHeaderShow:!0,listHeaderTitle:"Agents",listHeaderDescription:"Select an agent to launch.",listSearchShow:!0,tilesHeaderShow:!0,tilesHeaderTitle:"Agents",tilesHeaderDescription:"Browse and launch an agent.",tilesSearchShow:!0,tilesViewToggleShow:!0,agentUiMode:"modal",agentModalWidth:"600",agentModalHeight:"800",agentModalCorner:"top-right",agentModalOffsetX:"20",agentModalOffsetY:"40",agentSidebarShow:!0,agentSidebarWidth:"280",agentWelcomeTitle:"Let's Talk",agentWelcomeSubtitle:"Ask me about your Boomi deployment."}),lo=t=>{const e=t.trim();if(!e)return;const n=Number(e);return Number.isNaN(n)?e:n},CH=(t,e,n,o)=>{var r,s,c,a,d,l,h,f,u,m,p,g,b,w,E,T,y,x,_,N,C,L,D,I,k,S;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const A=JSON.parse(t);if(A!=null&&A.theme&&typeof A.theme.defaultTheme=="string"){const W=A.theme.defaultTheme;W==="boomi"||W==="base"?(i.themeSelection=W,i.themeDefault=W,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=W,i.themeCustomName=W);const V=(r=A==null?void 0:A.cssVarsByTheme)==null?void 0:r[W];V&&typeof V=="object"&&(i.themeCustomVars=Object.entries(V).map(([Y,Z])=>({id:`var_${Y}`,varName:Y,value:typeof Z=="string"?Z:String(Z)})))}const R=(s=A==null?void 0:A.components)==null?void 0:s.agentList,$=(c=A==null?void 0:A.components)==null?void 0:c.agentTiles;if(n==="list"&&R){const W=R.launcher??{},V=W.position??{};Lr.includes(V.corner)&&(i.launcherCorner=V.corner),V.offsetX!==void 0&&(i.launcherOffsetX=String(V.offsetX)),V.offsetY!==void 0&&(i.launcherOffsetY=String(V.offsetY)),(W.shape==="pill"||W.shape==="circle")&&(i.launcherShape=W.shape),typeof W.label=="string"&&(i.launcherLabel=W.label),typeof W.icon=="string"&&(i.launcherIcon=W.icon),typeof W.hideIcon=="boolean"&&(i.launcherHideIcon=W.hideIcon);const Y=R.modal??{};Y.width!==void 0&&(i.listModalWidth=String(Y.width)),Y.height!==void 0&&(i.listModalHeight=String(Y.height));const Z=Y.position??{};Lr.includes(Z.corner)&&(i.listModalCorner=Z.corner),Z.offsetX!==void 0&&(i.listModalOffsetX=String(Z.offsetX)),Z.offsetY!==void 0&&(i.listModalOffsetY=String(Z.offsetY)),(a=R.welcome)!=null&&a.title&&(i.listWelcomeTitle=R.welcome.title),(d=R.welcome)!=null&&d.subtitle&&(i.listWelcomeSubtitle=R.welcome.subtitle),((l=R.header)==null?void 0:l.show)!==void 0&&(i.listHeaderShow=!!R.header.show),(h=R.header)!=null&&h.title&&(i.listHeaderTitle=R.header.title),(f=R.header)!=null&&f.description&&(i.listHeaderDescription=R.header.description),((u=R.search)==null?void 0:u.show)!==void 0&&(i.listSearchShow=!!R.search.show)}n==="tiles"&&$&&(((m=$.header)==null?void 0:m.show)!==void 0&&(i.tilesHeaderShow=!!$.header.show),(p=$.header)!=null&&p.title&&(i.tilesHeaderTitle=$.header.title),(g=$.header)!=null&&g.description&&(i.tilesHeaderDescription=$.header.description),((b=$.search)==null?void 0:b.show)!==void 0&&(i.tilesSearchShow=!!$.search.show),((w=$.viewToggle)==null?void 0:w.show)!==void 0&&(i.tilesViewToggleShow=!!$.viewToggle.show));const P=(A==null?void 0:A.agents)??{},U=o.find(W=>P[W])??Object.keys(P)[0],F=U?P[U]:null;F!=null&&F.position&&typeof F.position=="object"&&"corner"in F.position&&(Lr.includes(F.position.corner)&&(i.launcherCorner=F.position.corner),F.position.offsetX!==void 0&&(i.launcherOffsetX=String(F.position.offsetX)),F.position.offsetY!==void 0&&(i.launcherOffsetY=String(F.position.offsetY))),((F==null?void 0:F.shape)==="pill"||(F==null?void 0:F.shape)==="circle")&&(i.launcherShape=F.shape),typeof(F==null?void 0:F.label)=="string"&&(i.launcherLabel=F.label),typeof(F==null?void 0:F.icon)=="string"&&(i.launcherIcon=F.icon),typeof(F==null?void 0:F.hideIcon)=="boolean"&&(i.launcherHideIcon=F.hideIcon);const B=(F==null?void 0:F.ui)??{};(B.mode==="modal"||B.mode==="full")&&(i.agentUiMode=B.mode),((E=B.modal)==null?void 0:E.width)!==void 0&&(i.agentModalWidth=String(B.modal.width)),((T=B.modal)==null?void 0:T.height)!==void 0&&(i.agentModalHeight=String(B.modal.height)),(x=(y=B.modal)==null?void 0:y.position)!=null&&x.corner&&Lr.includes(B.modal.position.corner)&&(i.agentModalCorner=B.modal.position.corner),((N=(_=B.modal)==null?void 0:_.position)==null?void 0:N.offsetX)!==void 0&&(i.agentModalOffsetX=String(B.modal.position.offsetX)),((L=(C=B.modal)==null?void 0:C.position)==null?void 0:L.offsetY)!==void 0&&(i.agentModalOffsetY=String(B.modal.position.offsetY));const Q=B.sessionScope==="mount"?!1:B.sessionScope==="multi"?!0:void 0,G=(((D=B.sidebar)==null?void 0:D.show)!==void 0?!!B.sidebar.show:void 0)??Q;G!==void 0&&(i.agentSidebarShow=G),((I=B.sidebar)==null?void 0:I.width)!==void 0&&(i.agentSidebarWidth=String(B.sidebar.width)),(k=B.welcome)!=null&&k.title&&(i.agentWelcomeTitle=B.welcome.title),(S=B.welcome)!=null&&S.subtitle&&(i.agentWelcomeSubtitle=B.welcome.subtitle)}catch{return i}return i},NH=(t,e,n)=>{const o=t.themeSelection==="custom"?t.themeCustomName.trim()||t.themeDefault||"custom":t.themeSelection,i={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:o}};if(t.themeSelection==="custom"){const s={};for(const c of t.themeCustomVars)c.varName&&c.value&&(s[c.varName]=c.value);Object.keys(s).length&&(i.cssVarsByTheme={[o]:s})}e==="list"&&(i.components={agentList:{launcher:{position:{corner:t.launcherCorner,offsetX:lo(t.launcherOffsetX),offsetY:lo(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon},modal:{width:lo(t.listModalWidth),height:lo(t.listModalHeight),position:{corner:t.listModalCorner,offsetX:lo(t.listModalOffsetX),offsetY:lo(t.listModalOffsetY)}},welcome:{title:t.listWelcomeTitle,subtitle:t.listWelcomeSubtitle},header:{show:t.listHeaderShow,title:t.listHeaderTitle,description:t.listHeaderDescription},search:{show:t.listSearchShow}}}),e==="tiles"&&(i.components={agentTiles:{header:{show:t.tilesHeaderShow,title:t.tilesHeaderTitle,description:t.tilesHeaderDescription},search:{show:t.tilesSearchShow},viewToggle:{show:t.tilesViewToggleShow}}});const r=n.length?n:["agent-id"];return i.agents=r.reduce((s,c)=>(s[c]={transport:"boomi-direct",...e==="single"?{position:{corner:t.launcherCorner,offsetX:lo(t.launcherOffsetX),offsetY:lo(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon}:{},ui:{mode:t.agentUiMode,sessionScope:t.agentSidebarShow?"multi":"mount",modal:{width:lo(t.agentModalWidth),height:lo(t.agentModalHeight),position:{corner:t.agentModalCorner,offsetX:lo(t.agentModalOffsetX),offsetY:lo(t.agentModalOffsetY)}},sidebar:{show:t.agentSidebarShow,width:lo(t.agentSidebarWidth)},welcome:{title:t.agentWelcomeTitle,subtitle:t.agentWelcomeSubtitle}}},s),{}),i.project={embedType:e,agentIds:r},i},iL=({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1})=>{const s=O.useMemo(_H,[]),[c,a]=O.useState(s),d=O.useRef(!1);O.useEffect(()=>{(r||!d.current)&&(a(CH(n,s,t,e)),d.current=!0)},[n,s,t,e,r]),O.useEffect(()=>{i==null||i(c)},[c,i]),O.useEffect(()=>{const u=NH(c,t,e);o(u)},[c,t,e,o]);const l=()=>{const u=AT[0]??"--boomi-root-bg-color";a(m=>({...m,themeCustomVars:[...m.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:u,value:"#000000"}]}))},h=(u,m)=>{a(p=>({...p,themeCustomVars:p.themeCustomVars.map(g=>g.id===u?{...g,...m}:g)}))},f=u=>{a(m=>({...m,themeCustomVars:m.themeCustomVars.filter(p=>p.id!==u)}))};return v.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),v.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),v.jsxs("label",{className:"boomi-form-label",children:["Mode",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentUiMode,onChange:u=>a(m=>({...m,agentUiMode:u.target.value})),children:[v.jsx("option",{value:"modal",children:"Modal"}),v.jsx("option",{value:"full",children:"Full Page"})]})]}),c.agentUiMode==="modal"&&v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Modal width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalWidth,onChange:u=>a(m=>({...m,agentModalWidth:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalHeight,onChange:u=>a(m=>({...m,agentModalHeight:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalCorner,onChange:u=>a(m=>({...m,agentModalCorner:u.target.value})),children:Lr.map(u=>v.jsx("option",{value:u,children:u},u))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetX,onChange:u=>a(m=>({...m,agentModalOffsetX:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetY,onChange:u=>a(m=>({...m,agentModalOffsetY:u.target.value}))})]})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.agentSidebarShow,onChange:u=>a(m=>({...m,agentSidebarShow:u.target.checked}))}),"Show sidebar"]}),v.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentSidebarWidth,onChange:u=>a(m=>({...m,agentSidebarWidth:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeTitle,onChange:u=>a(m=>({...m,agentWelcomeTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeSubtitle,onChange:u=>a(m=>({...m,agentWelcomeSubtitle:u.target.value}))})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),v.jsxs("label",{className:"boomi-form-label",children:["Theme",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeSelection,onChange:u=>a(m=>({...m,themeSelection:u.target.value,themeDefault:u.target.value==="custom"?m.themeDefault:u.target.value})),children:[v.jsx("option",{value:"boomi",children:"boomi"}),v.jsx("option",{value:"base",children:"base"}),v.jsx("option",{value:"custom",children:"custom"})]})]}),c.themeSelection==="custom"&&v.jsxs(v.Fragment,{children:[v.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeCustomName,onChange:u=>a(m=>({...m,themeCustomName:u.target.value,themeDefault:u.target.value})),placeholder:"my-theme"})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Custom CSS Vars"}),c.themeCustomVars.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),v.jsx("div",{className:"space-y-2",children:c.themeCustomVars.map(u=>v.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[v.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:u.varName,onChange:m=>h(u.id,{varName:m.target.value}),children:AT.map(m=>v.jsx("option",{value:m,children:m},m))}),SH(u.varName)?v.jsx("input",{type:"text",value:u.value,onChange:m=>h(u.id,{value:m.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"e.g. Inter, sans-serif"}):v.jsx("input",{type:"color",value:u.value,onChange:m=>h(u.id,{value:m.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),v.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>f(u.id),children:"Remove"})]},u.id))}),v.jsx("div",{children:v.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs disabled:opacity-50",onClick:l,disabled:!c.themeCustomName.trim(),children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&v.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherCorner,onChange:u=>a(m=>({...m,launcherCorner:u.target.value})),children:Lr.map(u=>v.jsx("option",{value:u,children:u},u))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetX,onChange:u=>a(m=>({...m,launcherOffsetX:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetY,onChange:u=>a(m=>({...m,launcherOffsetY:u.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Shape",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherShape,onChange:u=>a(m=>({...m,launcherShape:u.target.value})),children:[v.jsx("option",{value:"pill",children:"Pill"}),v.jsx("option",{value:"circle",children:"Circle"})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Label",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherLabel,onChange:u=>a(m=>({...m,launcherLabel:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Icon",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Sh.some(u=>u.value===c.launcherIcon)?c.launcherIcon:"__custom__",onChange:u=>a(m=>({...m,launcherIcon:u.target.value==="__custom__"?m.launcherIcon:u.target.value})),children:[!Sh.some(u=>u.value===c.launcherIcon)&&v.jsxs("option",{value:"__custom__",children:[c.launcherIcon," (custom)"]}),Sh.map(u=>v.jsx("option",{value:u.value,children:u.label},u.value))]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.launcherHideIcon,onChange:u=>a(m=>({...m,launcherHideIcon:u.target.checked}))}),"Hide icon"]})]}),t==="list"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalWidth,onChange:u=>a(m=>({...m,listModalWidth:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalHeight,onChange:u=>a(m=>({...m,listModalHeight:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalCorner,onChange:u=>a(m=>({...m,listModalCorner:u.target.value})),children:Lr.map(u=>v.jsx("option",{value:u,children:u},u))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetX,onChange:u=>a(m=>({...m,listModalOffsetX:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetY,onChange:u=>a(m=>({...m,listModalOffsetY:u.target.value}))})]})]})]}),v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listHeaderShow,onChange:u=>a(m=>({...m,listHeaderShow:u.target.checked}))}),"Show header"]}),v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderTitle,onChange:u=>a(m=>({...m,listHeaderTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderDescription,onChange:u=>a(m=>({...m,listHeaderDescription:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listSearchShow,onChange:u=>a(m=>({...m,listSearchShow:u.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeTitle,onChange:u=>a(m=>({...m,listWelcomeTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeSubtitle,onChange:u=>a(m=>({...m,listWelcomeSubtitle:u.target.value}))})]})]})]}),t==="tiles"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesHeaderShow,onChange:u=>a(m=>({...m,tilesHeaderShow:u.target.checked}))}),"Show header"]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderTitle,onChange:u=>a(m=>({...m,tilesHeaderTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderDescription,onChange:u=>a(m=>({...m,tilesHeaderDescription:u.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesSearchShow,onChange:u=>a(m=>({...m,tilesSearchShow:u.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesViewToggleShow,onChange:u=>a(m=>({...m,tilesViewToggleShow:u.target.checked}))}),"Show tiles/table toggle"]})]})]})};function LH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const kH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=O.useState(""),[a,d]=O.useState(null),[l,h]=O.useState(!1),[f,u]=O.useState([]),[m,p]=O.useState(""),[g,b]=O.useState("single"),[w,E]=O.useState(""),[T,y]=O.useState([]),[x,_]=O.useState(null),[N,C]=O.useState(null),[L,D]=O.useState(null),[I,k]=O.useState("builder"),S=(G,W)=>(G.length>0?G:["agent-id"]).reduce((Y,Z)=>(Y[Z]={transport:"boomi-direct",ui:{mode:W,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:W==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},Y),{}),$=JSON.stringify(((G,W)=>{const V={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};G==="list"&&(V.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const Y=W.length>0?W:["agent-id"];return V.agents=S(Y,G==="single"?"modal":"full"),V})(g,g==="single"?w?[w]:[]:T),null,2);O.useEffect(()=>{var W;if(!t)return;const G=((W=r==null?void 0:r[0])==null?void 0:W.id)||"";c(""),d(null),h(!1),u([]),p(""),b("single"),E(G),y(G?[G]:[]),_(null),C(null),D(null),k("builder")},[t,i,r]),O.useEffect(()=>{g==="single"?!w&&T[0]&&E(T[0]):T.length===0&&w&&y([w])},[g,T,w]);const P=G=>{y(W=>W.includes(G)?W.filter(V=>V!==G):[...W,G])},U=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,F=async()=>{if(!s.trim()){h(!0),d("Project name is required.");return}d(null);const G=g==="single"?w?[w]:[]:T;if(!G.length){_("Select at least one agent");return}_(null);let W;const V=m.trim();if(V)try{W=JSON.parse(V)}catch{D("Config must be valid JSON");return}D(null);const Y=W&&typeof W=="object"?{...W}:{},Z=Y.project&&typeof Y.project=="object"?{...Y.project}:{};Y.project={...Z,embedType:g,agentIds:G};const ee=Array.from(new Set(f.map(ae=>ae.trim()).filter(Boolean)));if(!ee.length){C("At least one allowed origin is required.");return}for(const ae of ee)if(!LH(ae)){C(`Invalid origin (must be http/https): ${ae}`);return}C(null);const J=U();if(g==="single"&&w){const ae={...Y.agents??{}};ae[w]&&!ae[J]&&(ae[J]=ae[w],Y.agents=ae)}await n({agentId:J,boomiAgentId:g==="single"?w:void 0,label:s.trim()||void 0,allowedOrigins:ee,config:Y})},B=()=>{u(G=>[...G,""])},Q=(G,W)=>{u(V=>V.map((Y,Z)=>Z===G?W:Y))},z=G=>{u(W=>W.filter((V,Y)=>Y!==G))};return v.jsxs(Tn,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:F,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",v.jsx("strong",{children:g==="single"?"Single Agent":g==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),v.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",v.jsx("strong",{children:g==="single"?w?1:0:T.length})]}),v.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Ot,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:G=>{c(G.target.value),a&&d(null)},onBlur:()=>{h(!0),s.trim()||d("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&v.jsx("div",{className:"boomi-form-error",children:a}),v.jsxs("label",{className:"boomi-form-label",children:["Embed Type",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g,onChange:G=>b(G.target.value),children:[v.jsx("option",{value:"single",children:"Single Agent"}),v.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),v.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),g==="single"?v.jsxs("label",{className:"boomi-form-label",children:["Agent",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:w,onChange:G=>E(G.target.value),children:[(r??[]).length===0&&v.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(G=>v.jsx("option",{value:G.id,children:G.label},G.id))]}),x&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:x})]}):v.jsxs("div",{children:[v.jsx("label",{className:"boomi-form-label",children:"Agents"}),v.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:(r??[]).length===0?v.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(G=>v.jsxs("label",{className:"flex items-center gap-2",children:[v.jsx("input",{type:"checkbox",checked:T.includes(G.id),onChange:()=>P(G.id)}),v.jsx("span",{className:"text-xs",children:G.label})]},G.id))}),x&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:x})]})]}),v.jsx("div",{className:"space-y-4",children:v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.jsx("div",{className:"text-xs opacity-70",children:"Select origins from your CORS list. If you don’t see one you need, add it first in the CORS page."}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((G,W)=>{const V=new Set(f.map(ee=>ee.trim()).filter(Boolean)),Y=(i??[]).filter(ee=>ee===G||!V.has(ee)),Z=Y.includes(G);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:G,onChange:ee=>Q(W,ee.target.value),children:[!G&&v.jsx("option",{value:"",children:"Select an origin"}),Z?null:G?v.jsx("option",{value:G,children:G}):null,Y.map(ee=>v.jsx("option",{value:ee,children:ee},ee))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>z(W),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&z(W)},"aria-label":"Remove origin",children:v.jsx(oo,{})})]},`${G}-${W}`)})]}),v.jsx("div",{className:"flex",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:B})}),N&&v.jsx("div",{className:"text-xs text-red-500",children:N}),v.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),v.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),I==="builder"?v.jsx(iL,{embedType:g,agentIds:g==="single"?w?[w]:[]:T,configRaw:m,onChangeConfig:G=>{const W=JSON.stringify(G,null,2);W!==m&&p(W)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oL,{label:"Config (JSON)",value:m,placeholder:$,error:L,onChange:p}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>p($)})})]})]})]})},IH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>v.jsx(Tn,{isOpen:t,title:"Delete Agent",description:"Remove this agent and all associated public tokens.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:v.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",v.jsx("span",{className:"font-semibold",children:e}),"?"]})});function ST(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const RH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:d})=>{const[l,h]=O.useState(""),[f,u]=O.useState([]),[m,p]=O.useState(""),[g,b]=O.useState(!1),[w,E]=O.useState(""),[T,y]=O.useState(null),[x,_]=O.useState(null),[N,C]=O.useState("builder"),L=(B,Q)=>(B.length>0?B:["agent-id"]).reduce((G,W)=>(G[W]={transport:"boomi-direct",ui:{mode:Q,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:Q==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},G),{}),D=(B,Q)=>{const z={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};B==="list"&&(z.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const G=Q.length>0?Q:["agent-id"];return z.agents=L(G,B==="single"?"modal":"full"),z},k=(()=>{try{const B=w.trim()?JSON.parse(w):null,Q=B&&typeof B=="object"?B.project:null,z=typeof(Q==null?void 0:Q.embedType)=="string"?Q.embedType:"single",G=Array.isArray(Q==null?void 0:Q.agentIds)?Q.agentIds.filter(Boolean):[];return{embedType:z,agentIds:G}}catch{return{embedType:"single",agentIds:[]}}})(),S=k.agentIds.length>0?k.agentIds:e?[e]:[],A=JSON.stringify(D(k.embedType,S),null,2);O.useEffect(()=>{if(t){h(n??"");const B=(o&&o.length?o:i)??[];u(B),p(""),E(s?JSON.stringify(s,null,2):""),y(null),_(null),C("builder")}},[t,n,s,o,i]);const R=async()=>{if(!e)return;let B;const Q=w.trim();if(Q)try{B=JSON.parse(Q)}catch{_("Config must be valid JSON");return}_(null);const z=Array.from(new Set(f.map(G=>G.trim()).filter(Boolean)));if(!z.length){y("At least one allowed origin is required.");return}for(const G of z)if(!ST(G)){y(`Invalid origin (must be http/https): ${G}`);return}if(y(null),B&&e){const G=B.project,W=G==null?void 0:G.embedType,V=Array.isArray(G==null?void 0:G.agentIds)?G.agentIds[0]:null;if(W==="single"&&V){const Y={...B.agents??{}};Y[V]&&!Y[e]&&(Y[e]=Y[V],B.agents=Y)}}await a({agentId:e,label:l.trim()||void 0,allowedOrigins:z,config:B})},$=()=>{const B=i??[],Q=new Set(f.map(G=>G.trim()).filter(Boolean)),z=B.find(G=>!Q.has(G))??"";u(G=>[...G,z])},P=(B,Q)=>{u(z=>z.map((G,W)=>W===B?Q:G))},U=B=>{u(Q=>Q.filter((z,G)=>G!==B))},F=async()=>{const B=m.trim();if(!B){y("Enter an origin before adding.");return}if(!ST(B)){y(`Invalid origin (must be http/https): ${B}`);return}if(y(null),!r){u(Q=>Q.includes(B)?Q:[...Q,B]),p("");return}b(!0);try{await r(B),u(Q=>Q.includes(B)?Q:[...Q,B]),p("")}catch(Q){y((Q==null?void 0:Q.message)||"Failed to add origin.")}finally{b(!1)}};return v.jsxs(Tn,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:R,submitLabel:d?"Saving...":"Save Changes",showSaveButton:!d,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",v.jsx("strong",{children:e??"—"})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Ot,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:l,onChange:B=>h(B.target.value),placeholder:"Customer Support Agent"}),v.jsx(Ot,{formName:"agentEdit",label:"Agent ID",required:!0,inputName:"agentId",readOnly:!0,value:e??"",onChange:()=>{},helperText:"This is the Boomi Agent ID for your agent and cannot be changed."})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((B,Q)=>{const z=new Set(f.map(V=>V.trim()).filter(Boolean)),G=(i??[]).filter(V=>V===B||!z.has(V)),W=G.includes(B);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:B,onChange:V=>P(Q,V.target.value),children:[!B&&v.jsx("option",{value:"",children:"Select an origin"}),W?null:B?v.jsx("option",{value:B,children:B}):null,G.map(V=>v.jsx("option",{value:V,children:V},V))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>U(Q),onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&U(Q)},"aria-label":"Remove origin",children:v.jsx(oo,{})})]},`${B}-${Q}`)})]}),T&&v.jsx("div",{className:"text-xs text-red-500",children:T}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:$}),v.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[v.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:m,onChange:B=>p(B.target.value),placeholder:"https://example.com"}),v.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:F,disabled:g,"aria-label":"Add new origin",children:v.jsx(or,{})})]})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),v.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("json"),children:"JSON"})]})]}),N==="builder"?v.jsx(iL,{embedType:k.embedType,agentIds:S,configRaw:w,onChangeConfig:B=>{const Q=JSON.stringify(B,null,2);Q!==w&&E(Q)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oL,{label:"Config (JSON)",value:w,placeholder:A,error:x,onChange:E}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>E(A)})})]})]})]})},OH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=O.useState(!1),[d,l]=O.useState(!1),[h,f]=O.useState("single"),[u,m]=O.useState([]),[p,g]=O.useState(""),[b,w]=O.useState(!1),[E,T]=O.useState(null),[y,x]=O.useState(null),{createAgent:_}=nL(),N=O.useMemo(()=>(o??[]).map(A=>{var R;return{id:A.agentId,label:((R=A.label)==null?void 0:R.trim())||A.agentId,tokenIds:A.publicTokenIds??[]}}),[o]);O.useEffect(()=>{var A;if(!t)return;const S=e||((A=N[0])==null?void 0:A.id)||"";g(S),m(S?[S]:[]),T(null),x(null),e&&f("single")},[t,e,N]);const C=S=>{m(A=>A.includes(S)?A.filter(R=>R!==S):[...A,S])},L=async()=>{const S=n??y;if(!i||!S)return;const A=u.filter(R=>{var P;const $=N.find(U=>U.id===R);return!((P=$==null?void 0:$.tokenIds)!=null&&P.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}w(!0),T(null);try{await Promise.all(A.map(R=>_({primaryAccountId:i,agentId:R,publicTokenIds:[S]}))),T("Token attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to attach token to selected agents.")}finally{w(!1)}},D=async()=>{var A;if(!i)return;const S=h==="single"?p:u[0];if(!S){T("Select at least one agent first.");return}w(!0),T(null);try{const $=((A=(await _({primaryAccountId:i,agentId:S,createToken:!0})).createdToken)==null?void 0:A.tokenId)||null;if(!$)throw new Error("Token generation failed.");x($),r==null||r($);const P=h==="single"?[]:u.filter(U=>U!==S);P.length>0&&await Promise.all(P.map(U=>_({primaryAccountId:i,agentId:U,publicTokenIds:[$]}))),T("Token generated and attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to generate token.")}finally{w(!1)}},I=O.useMemo(()=>{const S=n??y;if(!S)return"";const A=p||e||"";return u.length,`<script>
|
|
2106
|
+
`),[c]);return v.jsxs("div",{children:[v.jsxs("label",{className:"boomi-form-label inline-flex items-center gap-2",children:[v.jsx("span",{children:t}),e]}),v.jsxs("div",{className:["flex w-full rounded-md border overflow-hidden","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_92%,#000000)]",r?"boomi-input--error":""].join(" ").trim(),children:[v.jsx("pre",{className:["m-0 py-2 px-3 text-xs font-mono leading-5","text-[color-mix(in_srgb,var(--boomi-card-fg,#111)_55%,transparent)]","bg-[color-mix(in_srgb,var(--boomi-card-bg,#ffffff)_86%,#000000)]","border-r border-[color-mix(in_srgb,var(--boomi-card-border,#e5e7eb)_80%,transparent)]","select-none text-right min-w-[2.5rem]"].join(" "),children:a}),v.jsx("textarea",{className:["boomi-input flex-1 rounded-none border-0 font-mono text-xs leading-5","bg-transparent p-2 min-h-[120px]","focus:outline-none"].join(" "),placeholder:o,value:n,onChange:d=>s(d.target.value)})]}),i&&v.jsx("p",{className:"boomi-form-helper",children:i}),r&&v.jsx("p",{className:"boomi-form-error",children:r})]})},Sh=[{value:"",label:"None"},{value:"🤖",label:"🤖 Robot"},{value:"💬",label:"💬 Chat"},{value:"🗣️",label:"🗣️ Speaking"},{value:"✨",label:"✨ Sparkles"},{value:"🧠",label:"🧠 Brain"},{value:"💡",label:"💡 Idea"},{value:"🚀",label:"🚀 Rocket"},{value:"⚡",label:"⚡ Lightning"},{value:"🔍",label:"🔍 Search"},{value:"🛠️",label:"🛠️ Tools"},{value:"🤝",label:"🤝 Handshake"},{value:"🌐",label:"🌐 Globe"},{value:"🎯",label:"🎯 Target"},{value:"📊",label:"📊 Analytics"}],Lr=["bottom-right","bottom-left","top-right","top-left"],SH=t=>/font|family|radius|scale|speed|direction|angle|opacity|blur/.test(t),AT=["--boomi-font","--default-font-family","--boomi-accent","--boomi-agent-bg","--boomi-agent-blur","--boomi-agent-border","--boomi-agent-bubble-agent-bg","--boomi-agent-bubble-agent-border","--boomi-agent-bubble-agent-fg","--boomi-agent-bubble-border","--boomi-agent-bubble-shadow","--boomi-agent-bubble-user-bg","--boomi-agent-bubble-user-border","--boomi-agent-bubble-user-fg","--boomi-agent-card-tint","--boomi-agent-chat-bg","--boomi-agent-chat-border","--boomi-agent-chat-fg","--boomi-agent-close-bg-hover","--boomi-agent-close-fg","--boomi-agent-close-hover-fg","--boomi-agent-compose-bg","--boomi-agent-compose-border","--boomi-agent-compose-input-bg","--boomi-agent-compose-input-border","--boomi-agent-compose-secondary-bg","--boomi-agent-compose-secondary-border","--boomi-agent-compose-shadow","--boomi-agent-fg","--boomi-agent-header-bg","--boomi-agent-header-border","--boomi-agent-pane-bg","--boomi-agent-pane-bg-color","--boomi-agent-pane-fg","--boomi-agent-pane-fg-color","--boomi-agent-radius","--boomi-agent-ring","--boomi-agent-row-shimmer-opacity","--boomi-agent-row-tint","--boomi-agent-section-bg","--boomi-agent-section-border","--boomi-agent-section-fg","--boomi-agent-section-shadow","--boomi-agent-shadow","--boomi-agent-shimmer-1","--boomi-agent-shimmer-2","--boomi-agent-shimmer-angle","--boomi-agent-shimmer-direction","--boomi-agent-shimmer-opacity","--boomi-agent-shimmer-speed","--boomi-agent-tab-bg","--boomi-agent-tab-bg-active","--boomi-agent-tab-border","--boomi-agent-tab-border-active","--boomi-agent-tab-fg","--boomi-agent-tab-fg-active","--boomi-agent-tab-shadow-active","--boomi-agent-text-bg","--boomi-agent-text-border","--boomi-agent-text-copy-bg","--boomi-agent-text-copy-bg-hover","--boomi-agent-text-copy-fg","--boomi-agent-text-fg","--boomi-agent-thread-separator","--boomi-agent-update-bg","--boomi-agent-update-border","--boomi-agent-update-content-bg","--boomi-agent-update-content-fg","--boomi-agent-update-desc-fg","--boomi-agent-update-fg","--boomi-agent-update-radius","--boomi-agent-update-shadow","--boomi-agent-update-title-fg","--boomi-angle","--boomi-btn-primary-bg","--boomi-btn-primary-bg-active","--boomi-btn-primary-bg-hover","--boomi-btn-primary-border","--boomi-btn-primary-border-active","--boomi-btn-primary-border-hover","--boomi-btn-primary-fg","--boomi-btn-primary-fg-active","--boomi-btn-primary-fg-hover","--boomi-btn-primary-shadow","--boomi-btn-primary-shadow-active","--boomi-btn-primary-shadow-hover","--boomi-btn-secondary-bg","--boomi-btn-secondary-bg-active","--boomi-btn-secondary-bg-hover","--boomi-btn-secondary-border","--boomi-btn-secondary-border-active","--boomi-btn-secondary-border-hover","--boomi-btn-secondary-fg","--boomi-btn-secondary-fg-active","--boomi-btn-secondary-fg-hover","--boomi-btn-secondary-shadow","--boomi-btn-secondary-shadow-active","--boomi-btn-secondary-shadow-hover","--boomi-card-bg","--boomi-card-border","--boomi-card-fg","--boomi-card-hover-scale","--boomi-card-hover-shadow","--boomi-card-radius","--boomi-card-shadow","--boomi-chip-bg","--boomi-chip-border","--boomi-chip-error-bg","--boomi-chip-error-border","--boomi-chip-error-fg","--boomi-chip-fg","--boomi-chip-pulse-color","--boomi-chip-success-bg","--boomi-chip-success-border","--boomi-chip-success-fg","--boomi-chip-warning-bg","--boomi-chip-warning-border","--boomi-chip-warning-fg"],_H=()=>({themeSelection:"boomi",themeDefault:"boomi",themeCustomName:"",themeCustomVars:[],launcherCorner:"bottom-right",launcherOffsetX:"20",launcherOffsetY:"40",launcherShape:"pill",launcherLabel:"Find an Agent",launcherIcon:"🤖",launcherHideIcon:!1,listModalWidth:"500",listModalHeight:"600",listModalCorner:"bottom-right",listModalOffsetX:"20",listModalOffsetY:"100",listWelcomeTitle:"Agents",listWelcomeSubtitle:"Search for an agent and click to launch.",listHeaderShow:!0,listHeaderTitle:"Agents",listHeaderDescription:"Select an agent to launch.",listSearchShow:!0,tilesHeaderShow:!0,tilesHeaderTitle:"Agents",tilesHeaderDescription:"Browse and launch an agent.",tilesSearchShow:!0,tilesViewToggleShow:!0,agentUiMode:"modal",agentModalWidth:"600",agentModalHeight:"800",agentModalCorner:"top-right",agentModalOffsetX:"20",agentModalOffsetY:"40",agentSidebarShow:!0,agentSidebarWidth:"280",agentWelcomeTitle:"Let's Talk",agentWelcomeSubtitle:"Ask me about your Boomi deployment."}),lo=t=>{const e=t.trim();if(!e)return;const n=Number(e);return Number.isNaN(n)?e:n},CH=(t,e,n,o)=>{var r,s,c,a,d,l,h,f,u,m,p,g,b,w,E,T,y,x,_,N,C,L,D,I,k,S;const i={...e};if(i.themeCustomVars=[],!t.trim())return i;try{const A=JSON.parse(t);if(A!=null&&A.theme&&typeof A.theme.defaultTheme=="string"){const W=A.theme.defaultTheme;W==="boomi"||W==="base"?(i.themeSelection=W,i.themeDefault=W,i.themeCustomName=""):(i.themeSelection="custom",i.themeDefault=W,i.themeCustomName=W);const V=(r=A==null?void 0:A.cssVarsByTheme)==null?void 0:r[W];V&&typeof V=="object"&&(i.themeCustomVars=Object.entries(V).map(([Y,Z])=>({id:`var_${Y}`,varName:Y,value:typeof Z=="string"?Z:String(Z)})))}const R=(s=A==null?void 0:A.components)==null?void 0:s.agentList,$=(c=A==null?void 0:A.components)==null?void 0:c.agentTiles;if(n==="list"&&R){const W=R.launcher??{},V=W.position??{};Lr.includes(V.corner)&&(i.launcherCorner=V.corner),V.offsetX!==void 0&&(i.launcherOffsetX=String(V.offsetX)),V.offsetY!==void 0&&(i.launcherOffsetY=String(V.offsetY)),(W.shape==="pill"||W.shape==="circle")&&(i.launcherShape=W.shape),typeof W.label=="string"&&(i.launcherLabel=W.label),typeof W.icon=="string"&&(i.launcherIcon=W.icon),typeof W.hideIcon=="boolean"&&(i.launcherHideIcon=W.hideIcon);const Y=R.modal??{};Y.width!==void 0&&(i.listModalWidth=String(Y.width)),Y.height!==void 0&&(i.listModalHeight=String(Y.height));const Z=Y.position??{};Lr.includes(Z.corner)&&(i.listModalCorner=Z.corner),Z.offsetX!==void 0&&(i.listModalOffsetX=String(Z.offsetX)),Z.offsetY!==void 0&&(i.listModalOffsetY=String(Z.offsetY)),(a=R.welcome)!=null&&a.title&&(i.listWelcomeTitle=R.welcome.title),(d=R.welcome)!=null&&d.subtitle&&(i.listWelcomeSubtitle=R.welcome.subtitle),((l=R.header)==null?void 0:l.show)!==void 0&&(i.listHeaderShow=!!R.header.show),(h=R.header)!=null&&h.title&&(i.listHeaderTitle=R.header.title),(f=R.header)!=null&&f.description&&(i.listHeaderDescription=R.header.description),((u=R.search)==null?void 0:u.show)!==void 0&&(i.listSearchShow=!!R.search.show)}n==="tiles"&&$&&(((m=$.header)==null?void 0:m.show)!==void 0&&(i.tilesHeaderShow=!!$.header.show),(p=$.header)!=null&&p.title&&(i.tilesHeaderTitle=$.header.title),(g=$.header)!=null&&g.description&&(i.tilesHeaderDescription=$.header.description),((b=$.search)==null?void 0:b.show)!==void 0&&(i.tilesSearchShow=!!$.search.show),((w=$.viewToggle)==null?void 0:w.show)!==void 0&&(i.tilesViewToggleShow=!!$.viewToggle.show));const P=(A==null?void 0:A.agents)??{},U=o.find(W=>P[W])??Object.keys(P)[0],F=U?P[U]:null;F!=null&&F.position&&typeof F.position=="object"&&"corner"in F.position&&(Lr.includes(F.position.corner)&&(i.launcherCorner=F.position.corner),F.position.offsetX!==void 0&&(i.launcherOffsetX=String(F.position.offsetX)),F.position.offsetY!==void 0&&(i.launcherOffsetY=String(F.position.offsetY))),((F==null?void 0:F.shape)==="pill"||(F==null?void 0:F.shape)==="circle")&&(i.launcherShape=F.shape),typeof(F==null?void 0:F.label)=="string"&&(i.launcherLabel=F.label),typeof(F==null?void 0:F.icon)=="string"&&(i.launcherIcon=F.icon),typeof(F==null?void 0:F.hideIcon)=="boolean"&&(i.launcherHideIcon=F.hideIcon);const B=(F==null?void 0:F.ui)??{};(B.mode==="modal"||B.mode==="full")&&(i.agentUiMode=B.mode),((E=B.modal)==null?void 0:E.width)!==void 0&&(i.agentModalWidth=String(B.modal.width)),((T=B.modal)==null?void 0:T.height)!==void 0&&(i.agentModalHeight=String(B.modal.height)),(x=(y=B.modal)==null?void 0:y.position)!=null&&x.corner&&Lr.includes(B.modal.position.corner)&&(i.agentModalCorner=B.modal.position.corner),((N=(_=B.modal)==null?void 0:_.position)==null?void 0:N.offsetX)!==void 0&&(i.agentModalOffsetX=String(B.modal.position.offsetX)),((L=(C=B.modal)==null?void 0:C.position)==null?void 0:L.offsetY)!==void 0&&(i.agentModalOffsetY=String(B.modal.position.offsetY));const Q=B.sessionScope==="mount"?!1:B.sessionScope==="multi"?!0:void 0,G=(((D=B.sidebar)==null?void 0:D.show)!==void 0?!!B.sidebar.show:void 0)??Q;G!==void 0&&(i.agentSidebarShow=G),((I=B.sidebar)==null?void 0:I.width)!==void 0&&(i.agentSidebarWidth=String(B.sidebar.width)),(k=B.welcome)!=null&&k.title&&(i.agentWelcomeTitle=B.welcome.title),(S=B.welcome)!=null&&S.subtitle&&(i.agentWelcomeSubtitle=B.welcome.subtitle)}catch{return i}return i},NH=(t,e,n)=>{const o=t.themeSelection==="custom"?t.themeCustomName.trim()||t.themeDefault||"custom":t.themeSelection,i={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:o}};if(t.themeSelection==="custom"){const s={};for(const c of t.themeCustomVars)c.varName&&c.value&&(s[c.varName]=c.value);Object.keys(s).length&&(i.cssVarsByTheme={[o]:s})}e==="list"&&(i.components={agentList:{launcher:{position:{corner:t.launcherCorner,offsetX:lo(t.launcherOffsetX),offsetY:lo(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon},modal:{width:lo(t.listModalWidth),height:lo(t.listModalHeight),position:{corner:t.listModalCorner,offsetX:lo(t.listModalOffsetX),offsetY:lo(t.listModalOffsetY)}},welcome:{title:t.listWelcomeTitle,subtitle:t.listWelcomeSubtitle},header:{show:t.listHeaderShow,title:t.listHeaderTitle,description:t.listHeaderDescription},search:{show:t.listSearchShow}}}),e==="tiles"&&(i.components={agentTiles:{header:{show:t.tilesHeaderShow,title:t.tilesHeaderTitle,description:t.tilesHeaderDescription},search:{show:t.tilesSearchShow},viewToggle:{show:t.tilesViewToggleShow}}});const r=n.length?n:["agent-id"];return i.agents=r.reduce((s,c)=>(s[c]={transport:"boomi-direct",...e==="single"?{position:{corner:t.launcherCorner,offsetX:lo(t.launcherOffsetX),offsetY:lo(t.launcherOffsetY)},shape:t.launcherShape,label:t.launcherLabel,icon:t.launcherIcon,hideIcon:t.launcherHideIcon}:{},ui:{mode:t.agentUiMode,sessionScope:t.agentSidebarShow?"multi":"mount",modal:{width:lo(t.agentModalWidth),height:lo(t.agentModalHeight),position:{corner:t.agentModalCorner,offsetX:lo(t.agentModalOffsetX),offsetY:lo(t.agentModalOffsetY)}},sidebar:{show:t.agentSidebarShow,width:lo(t.agentSidebarWidth)},welcome:{title:t.agentWelcomeTitle,subtitle:t.agentWelcomeSubtitle}}},s),{}),i.project={embedType:e,agentIds:r},i},iL=({embedType:t,agentIds:e,configRaw:n,onChangeConfig:o,onUpdateBuilder:i,syncFromConfig:r=!1})=>{const s=O.useMemo(_H,[]),[c,a]=O.useState(s),d=O.useRef(!1);O.useEffect(()=>{(r||!d.current)&&(a(CH(n,s,t,e)),d.current=!0)},[n,s,t,e,r]),O.useEffect(()=>{i==null||i(c)},[c,i]),O.useEffect(()=>{const u=NH(c,t,e);o(u)},[c,t,e,o]);const l=()=>{const u=AT[0]??"--boomi-root-bg-color";a(m=>({...m,themeCustomVars:[...m.themeCustomVars,{id:`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,varName:u,value:"#000000"}]}))},h=(u,m)=>{a(p=>({...p,themeCustomVars:p.themeCustomVars.map(g=>g.id===u?{...g,...m}:g)}))},f=u=>{a(m=>({...m,themeCustomVars:m.themeCustomVars.filter(p=>p.id!==u)}))};return v.jsxs("div",{className:"boomi-card p-4 space-y-4",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"Config Builder"}),v.jsx("div",{className:"text-xs opacity-70",children:"Updates the JSON configuration automatically as you make changes."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Agent UI"}),v.jsxs("label",{className:"boomi-form-label",children:["Mode",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentUiMode,onChange:u=>a(m=>({...m,agentUiMode:u.target.value})),children:[v.jsx("option",{value:"modal",children:"Modal"}),v.jsx("option",{value:"full",children:"Full Page"})]})]}),c.agentUiMode==="modal"&&v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Modal width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalWidth,onChange:u=>a(m=>({...m,agentModalWidth:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalHeight,onChange:u=>a(m=>({...m,agentModalHeight:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Modal corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalCorner,onChange:u=>a(m=>({...m,agentModalCorner:u.target.value})),children:Lr.map(u=>v.jsx("option",{value:u,children:u},u))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetX,onChange:u=>a(m=>({...m,agentModalOffsetX:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentModalOffsetY,onChange:u=>a(m=>({...m,agentModalOffsetY:u.target.value}))})]})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.agentSidebarShow,onChange:u=>a(m=>({...m,agentSidebarShow:u.target.checked}))}),"Show sidebar"]}),v.jsxs("label",{className:"boomi-form-label",children:["Sidebar width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentSidebarWidth,onChange:u=>a(m=>({...m,agentSidebarWidth:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeTitle,onChange:u=>a(m=>({...m,agentWelcomeTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.agentWelcomeSubtitle,onChange:u=>a(m=>({...m,agentWelcomeSubtitle:u.target.value}))})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Theme"}),v.jsxs("label",{className:"boomi-form-label",children:["Theme",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeSelection,onChange:u=>a(m=>({...m,themeSelection:u.target.value,themeDefault:u.target.value==="custom"?m.themeDefault:u.target.value})),children:[v.jsx("option",{value:"boomi",children:"boomi"}),v.jsx("option",{value:"base",children:"base"}),v.jsx("option",{value:"custom",children:"custom"})]})]}),c.themeSelection==="custom"&&v.jsxs(v.Fragment,{children:[v.jsxs("label",{className:"boomi-form-label",children:["Custom theme name",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.themeCustomName,onChange:u=>a(m=>({...m,themeCustomName:u.target.value,themeDefault:u.target.value})),placeholder:"my-theme"})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Custom CSS Vars"}),c.themeCustomVars.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No custom variables yet."}),v.jsx("div",{className:"space-y-2",children:c.themeCustomVars.map(u=>v.jsxs("div",{className:"flex items-center gap-2 flex-nowrap w-full overflow-x-auto",children:[v.jsx("select",{className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",value:u.varName,onChange:m=>h(u.id,{varName:m.target.value}),children:AT.map(m=>v.jsx("option",{value:m,children:m},m))}),SH(u.varName)?v.jsx("input",{type:"text",value:u.value,onChange:m=>h(u.id,{value:m.target.value}),className:"boomi-input flex-1 min-w-0 rounded-md p-2 text-sm",placeholder:"e.g. Inter, sans-serif"}):v.jsx("input",{type:"color",value:u.value,onChange:m=>h(u.id,{value:m.target.value}),className:"h-9 w-12 shrink-0 cursor-pointer rounded-md border border-[var(--boomi-card-border)] bg-transparent"}),v.jsx("button",{type:"button",className:"text-xs text-red-500 whitespace-nowrap shrink-0",onClick:()=>f(u.id),children:"Remove"})]},u.id))}),v.jsx("div",{children:v.jsx("button",{type:"button",className:"boomi-btn-primary px-3 py-2 text-xs disabled:opacity-50",onClick:l,disabled:!c.themeCustomName.trim(),children:"Add CSS Variable"})})]})]})]})]}),(t==="list"||t==="single")&&v.jsxs("div",{className:t==="list"?"grid gap-4 md:grid-cols-2":"space-y-3",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Launcher (Pill)"}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherCorner,onChange:u=>a(m=>({...m,launcherCorner:u.target.value})),children:Lr.map(u=>v.jsx("option",{value:u,children:u},u))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetX,onChange:u=>a(m=>({...m,launcherOffsetX:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherOffsetY,onChange:u=>a(m=>({...m,launcherOffsetY:u.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Shape",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherShape,onChange:u=>a(m=>({...m,launcherShape:u.target.value})),children:[v.jsx("option",{value:"pill",children:"Pill"}),v.jsx("option",{value:"circle",children:"Circle"})]})]}),v.jsxs("label",{className:"boomi-form-label",children:["Label",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.launcherLabel,onChange:u=>a(m=>({...m,launcherLabel:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Icon",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:Sh.some(u=>u.value===c.launcherIcon)?c.launcherIcon:"__custom__",onChange:u=>a(m=>({...m,launcherIcon:u.target.value==="__custom__"?m.launcherIcon:u.target.value})),children:[!Sh.some(u=>u.value===c.launcherIcon)&&v.jsxs("option",{value:"__custom__",children:[c.launcherIcon," (custom)"]}),Sh.map(u=>v.jsx("option",{value:u.value,children:u.label},u.value))]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.launcherHideIcon,onChange:u=>a(m=>({...m,launcherHideIcon:u.target.checked}))}),"Hide icon"]})]}),t==="list"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"List Modal"}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Width",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalWidth,onChange:u=>a(m=>({...m,listModalWidth:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Height",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalHeight,onChange:u=>a(m=>({...m,listModalHeight:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Corner",v.jsx("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalCorner,onChange:u=>a(m=>({...m,listModalCorner:u.target.value})),children:Lr.map(u=>v.jsx("option",{value:u,children:u},u))})]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Offset X",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetX,onChange:u=>a(m=>({...m,listModalOffsetX:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Offset Y",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listModalOffsetY,onChange:u=>a(m=>({...m,listModalOffsetY:u.target.value}))})]})]})]}),v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70 pt-2",children:"List Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listHeaderShow,onChange:u=>a(m=>({...m,listHeaderShow:u.target.checked}))}),"Show header"]}),v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderTitle,onChange:u=>a(m=>({...m,listHeaderTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listHeaderDescription,onChange:u=>a(m=>({...m,listHeaderDescription:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.listSearchShow,onChange:u=>a(m=>({...m,listSearchShow:u.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeTitle,onChange:u=>a(m=>({...m,listWelcomeTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Welcome subtitle",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.listWelcomeSubtitle,onChange:u=>a(m=>({...m,listWelcomeSubtitle:u.target.value}))})]})]})]}),t==="tiles"&&v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide opacity-70",children:"Tiles Header & Search"}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesHeaderShow,onChange:u=>a(m=>({...m,tilesHeaderShow:u.target.checked}))}),"Show header"]}),v.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[v.jsxs("label",{className:"boomi-form-label",children:["Header title",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderTitle,onChange:u=>a(m=>({...m,tilesHeaderTitle:u.target.value}))})]}),v.jsxs("label",{className:"boomi-form-label",children:["Header description",v.jsx("input",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:c.tilesHeaderDescription,onChange:u=>a(m=>({...m,tilesHeaderDescription:u.target.value}))})]})]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesSearchShow,onChange:u=>a(m=>({...m,tilesSearchShow:u.target.checked}))}),"Show search"]}),v.jsxs("label",{className:"boomi-form-label flex items-center gap-4",children:[v.jsx("input",{type:"checkbox",checked:c.tilesViewToggleShow,onChange:u=>a(m=>({...m,tilesViewToggleShow:u.target.checked}))}),"Show tiles/table toggle"]})]})]})};function LH(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const kH=({isOpen:t,onClose:e,onSubmit:n,isSaving:o,defaultOrigins:i,availableAgents:r})=>{const[s,c]=O.useState(""),[a,d]=O.useState(null),[l,h]=O.useState(!1),[f,u]=O.useState([]),[m,p]=O.useState(""),[g,b]=O.useState("single"),[w,E]=O.useState(""),[T,y]=O.useState([]),[x,_]=O.useState(null),[N,C]=O.useState(null),[L,D]=O.useState(null),[I,k]=O.useState("builder"),S=(G,W)=>(G.length>0?G:["agent-id"]).reduce((Y,Z)=>(Y[Z]={transport:"boomi-direct",ui:{mode:W,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:W==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},Y),{}),$=JSON.stringify(((G,W)=>{const V={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};G==="list"&&(V.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const Y=W.length>0?W:["agent-id"];return V.agents=S(Y,G==="single"?"modal":"full"),V})(g,g==="single"?w?[w]:[]:T),null,2);O.useEffect(()=>{var W;if(!t)return;const G=((W=r==null?void 0:r[0])==null?void 0:W.id)||"";c(""),d(null),h(!1),u([]),p(""),b("single"),E(G),y(G?[G]:[]),_(null),C(null),D(null),k("builder")},[t,i,r]),O.useEffect(()=>{g==="single"?!w&&T[0]&&E(T[0]):T.length===0&&w&&y([w])},[g,T,w]);const P=G=>{y(W=>W.includes(G)?W.filter(V=>V!==G):[...W,G])},U=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`project_${crypto.randomUUID()}`:`project_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,F=async()=>{if(!s.trim()){h(!0),d("Project name is required.");return}d(null);const G=g==="single"?w?[w]:[]:T;if(!G.length){_("Select at least one agent");return}_(null);let W;const V=m.trim();if(V)try{W=JSON.parse(V)}catch{D("Config must be valid JSON");return}D(null);const Y=W&&typeof W=="object"?{...W}:{},Z=Y.project&&typeof Y.project=="object"?{...Y.project}:{};Y.project={...Z,embedType:g,agentIds:G};const ee=Array.from(new Set(f.map(ae=>ae.trim()).filter(Boolean)));if(!ee.length){C("At least one allowed origin is required.");return}for(const ae of ee)if(!LH(ae)){C(`Invalid origin (must be http/https): ${ae}`);return}C(null);const J=U();if(g==="single"&&w){const ae={...Y.agents??{}};ae[w]&&!ae[J]&&(ae[J]=ae[w],Y.agents=ae)}await n({agentId:J,boomiAgentId:g==="single"?w:void 0,label:s.trim()||void 0,allowedOrigins:ee,config:Y})},B=()=>{u(G=>[...G,""])},Q=(G,W)=>{u(V=>V.map((Y,Z)=>Z===G?W:Y))},z=G=>{u(W=>W.filter((V,Y)=>Y!==G))};return v.jsxs(Tn,{isOpen:t,title:"Add Project",description:"Create a new embedded agent group and its allowed embed origins.",onClose:e,onSubmit:F,submitLabel:o?"Saving...":"Create Project",showSaveButton:!o,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Project Summary"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Embed type: ",v.jsx("strong",{children:g==="single"?"Single Agent":g==="tiles"?"Multi-Agent (Tiles)":"Multi-Agent (List)"})]}),v.jsxs("div",{className:"text-xs opacity-80",children:["Selected agents: ",v.jsx("strong",{children:g==="single"?w?1:0:T.length})]}),v.jsx("div",{className:"text-xs opacity-70",children:"You can start with the form below and optionally layer in advanced JSON config."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Ot,{formName:"agentAdd",label:"Project Name",required:!0,inputName:"name",readOnly:!1,value:s,onChange:G=>{c(G.target.value),a&&d(null)},onBlur:()=>{h(!0),s.trim()||d("Project name is required.")},placeholder:"Customer Support Project"}),l&&a&&v.jsx("div",{className:"boomi-form-error",children:a}),v.jsxs("label",{className:"boomi-form-label",children:["Embed Type",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:g,onChange:G=>b(G.target.value),children:[v.jsx("option",{value:"single",children:"Single Agent"}),v.jsx("option",{value:"tiles",children:"Multi-Agent (Tiles)"}),v.jsx("option",{value:"list",children:"Multi-Agent (Pill + Modal List)"})]})]}),g==="single"?v.jsxs("label",{className:"boomi-form-label",children:["Agent",v.jsxs("select",{className:"boomi-input mt-1 w-full rounded-md p-2 text-sm",value:w,onChange:G=>E(G.target.value),children:[(r??[]).length===0&&v.jsx("option",{value:"",children:"No agents available"}),(r??[]).map(G=>v.jsx("option",{value:G.id,children:G.label},G.id))]}),x&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:x})]}):v.jsxs("div",{children:[v.jsx("label",{className:"boomi-form-label",children:"Agents"}),v.jsx("div",{className:"boomi-input w-full rounded-md p-2 text-sm space-y-2 max-h-48 overflow-auto",children:(r??[]).length===0?v.jsx("div",{className:"text-xs opacity-70",children:"No agents available"}):(r??[]).map(G=>v.jsxs("label",{className:"flex items-center gap-2",children:[v.jsx("input",{type:"checkbox",checked:T.includes(G.id),onChange:()=>P(G.id)}),v.jsx("span",{className:"text-xs",children:G.label})]},G.id))}),x&&v.jsx("div",{className:"text-xs text-red-500 mt-1",children:x})]})]}),v.jsx("div",{className:"space-y-4",children:v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.jsx("div",{className:"text-xs opacity-70",children:"Select origins from your CORS list. If you don’t see one you need, add it first in the CORS page."}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((G,W)=>{const V=new Set(f.map(ee=>ee.trim()).filter(Boolean)),Y=(i??[]).filter(ee=>ee===G||!V.has(ee)),Z=Y.includes(G);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:G,onChange:ee=>Q(W,ee.target.value),children:[!G&&v.jsx("option",{value:"",children:"Select an origin"}),Z?null:G?v.jsx("option",{value:G,children:G}):null,Y.map(ee=>v.jsx("option",{value:ee,children:ee},ee))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>z(W),onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&z(W)},"aria-label":"Remove origin",children:v.jsx(oo,{})})]},`${G}-${W}`)})]}),v.jsx("div",{className:"flex",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Allowed Origin",onClick:B})}),N&&v.jsx("div",{className:"text-xs text-red-500",children:N}),v.jsx("div",{className:"text-xs opacity-70",children:"Add new origins from the CORS page before selecting them here."})]})})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI beyond the form inputs."})]}),v.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${I==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>k("json"),children:"JSON"})]})]}),I==="builder"?v.jsx(iL,{embedType:g,agentIds:g==="single"?w?[w]:[]:T,configRaw:m,onChangeConfig:G=>{const W=JSON.stringify(G,null,2);W!==m&&p(W)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oL,{label:"Config (JSON)",value:m,placeholder:$,error:L,onChange:p}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>p($)})})]})]})]})},IH=({isOpen:t,agentId:e,onClose:n,onConfirm:o,isDeleting:i})=>v.jsx(Tn,{isOpen:t,title:"Delete Agent",description:"Remove this agent and all associated public tokens.",onClose:n,onSubmit:o,submitLabel:i?"Deleting...":"Delete",showSaveButton:!i,children:v.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete"," ",v.jsx("span",{className:"font-semibold",children:e}),"?"]})});function ST(t){try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const RH=({isOpen:t,agentId:e,label:n,allowedOrigins:o,defaultOrigins:i,onAddOrigin:r,config:s,onClose:c,onSubmit:a,isSaving:d})=>{const[l,h]=O.useState(""),[f,u]=O.useState([]),[m,p]=O.useState(""),[g,b]=O.useState(!1),[w,E]=O.useState(""),[T,y]=O.useState(null),[x,_]=O.useState(null),[N,C]=O.useState("builder"),L=(B,Q)=>(B.length>0?B:["agent-id"]).reduce((G,W)=>(G[W]={transport:"boomi-direct",ui:{mode:Q,modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},sidebar:{show:Q==="full",width:280},welcome:{title:"Let's Talk",subtitle:"Ask me about your Boomi deployment."}}},G),{}),D=(B,Q)=>{const z={transport:"boomi-direct",theme:{allowThemes:!0,defaultTheme:"boomi"},cssVarsByTheme:{oem:{"--boomi-root-bg-color":"#0b1220","--boomi-root-fg-color":"#e5e7eb","--boomi-page-bg-color":"#0b1220","--boomi-page-fg-color":"#e5e7eb","--boomi-header-bg-color":"rgba(15, 23, 42, 0.8)","--boomi-header-fg-color":"#e5e7eb","--boomi-btn-primary-bg":"#2563eb","--boomi-btn-primary-fg":"#ffffff","--boomi-card-bg":"#0f172a","--boomi-card-border":"#1f2937","--boomi-menu-bg":"#0f172a","--boomi-menu-fg":"#e5e7eb","--boomi-modal-bg":"#0f172a","--boomi-modal-fg":"#e5e7eb","--boomi-input-bg":"#0b1220","--boomi-input-fg":"#e5e7eb"}}};B==="list"&&(z.components={agentList:{launcher:{position:{corner:"bottom-right",offsetX:20,offsetY:40},shape:"pill",label:"Find an Agent",icon:"bot",hideIcon:!1},modal:{width:500,height:600,position:{corner:"bottom-right",offsetX:20,offsetY:100}},welcome:{title:"Agents",subtitle:"Search for an agent and click to launch."}}});const G=Q.length>0?Q:["agent-id"];return z.agents=L(G,B==="single"?"modal":"full"),z},k=(()=>{try{const B=w.trim()?JSON.parse(w):null,Q=B&&typeof B=="object"?B.project:null,z=typeof(Q==null?void 0:Q.embedType)=="string"?Q.embedType:"single",G=Array.isArray(Q==null?void 0:Q.agentIds)?Q.agentIds.filter(Boolean):[];return{embedType:z,agentIds:G}}catch{return{embedType:"single",agentIds:[]}}})(),S=k.agentIds.length>0?k.agentIds:e?[e]:[],A=JSON.stringify(D(k.embedType,S),null,2);O.useEffect(()=>{if(t){h(n??"");const B=(o&&o.length?o:i)??[];u(B),p(""),E(s?JSON.stringify(s,null,2):""),y(null),_(null),C("builder")}},[t,n,s,o,i]);const R=async()=>{if(!e)return;let B;const Q=w.trim();if(Q)try{B=JSON.parse(Q)}catch{_("Config must be valid JSON");return}_(null);const z=Array.from(new Set(f.map(G=>G.trim()).filter(Boolean)));if(!z.length){y("At least one allowed origin is required.");return}for(const G of z)if(!ST(G)){y(`Invalid origin (must be http/https): ${G}`);return}if(y(null),B&&e){const G=B.project,W=G==null?void 0:G.embedType,V=Array.isArray(G==null?void 0:G.agentIds)?G.agentIds[0]:null;if(W==="single"&&V){const Y={...B.agents??{}};Y[V]&&!Y[e]&&(Y[e]=Y[V],B.agents=Y)}}await a({agentId:e,label:l.trim()||void 0,allowedOrigins:z,config:B})},$=()=>{const B=i??[],Q=new Set(f.map(G=>G.trim()).filter(Boolean)),z=B.find(G=>!Q.has(G))??"";u(G=>[...G,z])},P=(B,Q)=>{u(z=>z.map((G,W)=>W===B?Q:G))},U=B=>{u(Q=>Q.filter((z,G)=>G!==B))},F=async()=>{const B=m.trim();if(!B){y("Enter an origin before adding.");return}if(!ST(B)){y(`Invalid origin (must be http/https): ${B}`);return}if(y(null),!r){u(Q=>Q.includes(B)?Q:[...Q,B]),p("");return}b(!0);try{await r(B),u(Q=>Q.includes(B)?Q:[...Q,B]),p("")}catch(Q){y((Q==null?void 0:Q.message)||"Failed to add origin.")}finally{b(!1)}};return v.jsxs(Tn,{isOpen:t,title:"Edit Agent",description:"Update agent details and allowed origins.",onClose:c,onSubmit:R,submitLabel:d?"Saving...":"Save Changes",showSaveButton:!d,children:[v.jsxs("div",{className:"boomi-card p-4 space-y-2",children:[v.jsx("div",{className:"text-sm font-semibold",children:"Agent Overview"}),v.jsxs("div",{className:"text-xs opacity-80",children:["Agent ID: ",v.jsx("strong",{children:e??"—"})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Update the friendly name, allowed origins, and optional config overrides below."})]}),v.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[v.jsxs("div",{className:"space-y-4",children:[v.jsx(Ot,{formName:"agentEdit",label:"Name",required:!1,inputName:"name",readOnly:!1,value:l,onChange:B=>h(B.target.value),placeholder:"Customer Support Agent"}),v.jsx(Ot,{formName:"agentEdit",label:"Agent ID",required:!0,inputName:"agentId",readOnly:!0,value:e??"",onChange:()=>{},helperText:"This is the Boomi Agent ID for your agent and cannot be changed."})]}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{className:"boomi-form-label",children:"Allowed Origins"}),v.jsxs("div",{className:"space-y-2",children:[f.length===0&&v.jsx("div",{className:"text-xs opacity-70",children:"No origins selected."}),f.map((B,Q)=>{const z=new Set(f.map(V=>V.trim()).filter(Boolean)),G=(i??[]).filter(V=>V===B||!z.has(V)),W=G.includes(B);return v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsxs("select",{className:"boomi-input w-full rounded-md p-2 text-sm",value:B,onChange:V=>P(Q,V.target.value),children:[!B&&v.jsx("option",{value:"",children:"Select an origin"}),W?null:B?v.jsx("option",{value:B,children:B}):null,G.map(V=>v.jsx("option",{value:V,children:V},V))]}),v.jsx("span",{role:"button",tabIndex:0,className:"text-red-500 text-lg cursor-pointer",onClick:()=>U(Q),onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&U(Q)},"aria-label":"Remove origin",children:v.jsx(oo,{})})]},`${B}-${Q}`)})]}),T&&v.jsx("div",{className:"text-xs text-red-500",children:T}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Add Row",onClick:$}),v.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[v.jsx("input",{className:"boomi-input w-full rounded-md p-2 text-sm",value:m,onChange:B=>p(B.target.value),placeholder:"https://example.com"}),v.jsx("button",{type:"button",className:"boomi-btn-primary px-2 py-2 text-xs",onClick:F,disabled:g,"aria-label":"Add new origin",children:v.jsx(or,{})})]})]}),v.jsx("div",{className:"text-xs opacity-70",children:"Pick from existing CORS origins or add a new one here."})]})]}),v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("div",{className:"text-sm font-semibold",children:"UI Configuration"}),v.jsx("div",{className:"text-xs opacity-70",children:"Optional. Use JSON to customize themes, layout, and agent UI."})]}),v.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-[var(--boomi-card-bg)] p-1 border border-[var(--boomi-card-border)]",children:[v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="builder"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("builder"),children:"Builder"}),v.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full ${N==="json"?"boomi-btn-primary":"opacity-70"}`,onClick:()=>C("json"),children:"JSON"})]})]}),N==="builder"?v.jsx(iL,{embedType:k.embedType,agentIds:S,configRaw:w,onChangeConfig:B=>{const Q=JSON.stringify(B,null,2);Q!==w&&E(Q)},syncFromConfig:!1}):v.jsxs(v.Fragment,{children:[v.jsx(oL,{label:"Config (JSON)",value:w,placeholder:A,error:x,onChange:E}),v.jsx("div",{className:"flex justify-end",children:v.jsx(tt,{toggle:!1,primary:!1,showIcon:!1,label:"Insert Starter Config",onClick:()=>E(A)})})]})]})]})},OH=({isOpen:t,agentId:e,tokenId:n,agents:o,primaryAccountId:i,onTokenGenerated:r,onClose:s})=>{const[c,a]=O.useState(!1),[d,l]=O.useState(!1),[h,f]=O.useState("single"),[u,m]=O.useState([]),[p,g]=O.useState(""),[b,w]=O.useState(!1),[E,T]=O.useState(null),[y,x]=O.useState(null),{createAgent:_}=nL(),N=O.useMemo(()=>(o??[]).map(A=>{var R;return{id:A.agentId,label:((R=A.label)==null?void 0:R.trim())||A.agentId,tokenIds:A.publicTokenIds??[]}}),[o]);O.useEffect(()=>{var A;if(!t)return;const S=e||((A=N[0])==null?void 0:A.id)||"";g(S),m(S?[S]:[]),T(null),x(null),e&&f("single")},[t,e,N]);const C=S=>{m(A=>A.includes(S)?A.filter(R=>R!==S):[...A,S])},L=async()=>{const S=n??y;if(!i||!S)return;const A=u.filter(R=>{var P;const $=N.find(U=>U.id===R);return!((P=$==null?void 0:$.tokenIds)!=null&&P.includes(S))});if(A.length===0){T("Token already attached to selected agents.");return}w(!0),T(null);try{await Promise.all(A.map(R=>_({primaryAccountId:i,agentId:R,publicTokenIds:[S]}))),T("Token attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to attach token to selected agents.")}finally{w(!1)}},D=async()=>{var A;if(!i)return;const S=h==="single"?p:u[0];if(!S){T("Select at least one agent first.");return}w(!0),T(null);try{const $=((A=(await _({primaryAccountId:i,agentId:S,createToken:!0})).createdToken)==null?void 0:A.tokenId)||null;if(!$)throw new Error("Token generation failed.");x($),r==null||r($);const P=h==="single"?[]:u.filter(U=>U!==S);P.length>0&&await Promise.all(P.map(U=>_({primaryAccountId:i,agentId:U,publicTokenIds:[$]}))),T("Token generated and attached to selected agents.")}catch(R){T((R==null?void 0:R.message)||"Failed to generate token.")}finally{w(!1)}},I=O.useMemo(()=>{const S=n??y;if(!S)return"";const A=p||e||"";return u.length,`<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
2107
|
+
<script>
|
|
2107
2108
|
window.BoomiEmbed = {
|
|
2108
2109
|
publicToken: "${S}",
|
|
2109
2110
|
agentId: "${A||"project-id"}",
|
package/dist/index.js
CHANGED
|
@@ -43958,7 +43958,8 @@ const q8 = ({
|
|
|
43958
43958
|
const A = n ?? w;
|
|
43959
43959
|
if (!A) return "";
|
|
43960
43960
|
const T = p || e || "";
|
|
43961
|
-
return d.length, `<
|
|
43961
|
+
return d.length, `<link rel="stylesheet" href="https://cdn.boomi.space/cdn/embedkit-cdn.css" />
|
|
43962
|
+
<script>
|
|
43962
43963
|
window.BoomiEmbed = {
|
|
43963
43964
|
publicToken: "${A}",
|
|
43964
43965
|
agentId: "${T || "project-id"}",
|