PageSourceSearch

https://studio.d-id.com/v0.1309.0/assets/backoffice-B_8FiiPY.js

js d-id.com collected 2026-10-01 08:27:37 UTC 75,822 bytes, 6 lines download raw bytes

1import{j_ as wr,r as u,a1 as st,aQ as V,dY as lt,aM as bt,aN as xt,aO as Ct,aP as Re,V as ne,aR as Sr,aS as kt,aT as P,a7 as ie,bI as Tr,n as re,j$ as _r,d_ as Ir,bd as we,bx as Be,by as Ne,bz as qe,bA as We,T as wt,j as i,e as t,x as Se,bK as G,a5 as D,dD as Te,aE as U,fa as Or,I as St,J as Oe,ar as Me,dW as Ar,dL as Dr,at as q,g1 as zr,F as He,e_ as te,ap as X,an as Q,R as M,b as Ae,b$ as fe,f7 as ye,f8 as ve,bo as Z,aJ as Le,cu as Tt,aH as Je,ct as Pr,v as $,O as Fr,eY as Ur,fG as Er,i as v,M as B,aG as _e,bN as _t,u as Rr,f as ct,k0 as W,B as Mr}from"./index-yQyqfSHr.js";import{C as Ye,P as je,D as It}from"./react-beautiful-dnd.esm-o3WYmfYl.js";import{D as Ke,g as Ot,u as Lr,a as jr,b as Gr,c as $r,d as Vr,e as Br,f as Nr}from"./DragIndicator-CAmD2a-c.js";import{A as At}from"./Alert-DPbPzh2b.js";import{C as qr}from"./ClickAwayListener-BGC3yvCD.js";import{C as Dt}from"./Card-BmSqVt4l.js";import{a as Wr,T as dt}from"./Tabs-CwIPjB1_.js";import{u as zt}from"./useGetPresenterByID-Do9gQ_Ec.js";import{f as Pt,s as pt,r as Hr}from"./s3-DDsDx53b.js";import{C as Ft}from"./ConfirmationModal-CDfhMWwR.js";import{t as Ce}from"./Trash-C3B4jp0P.js";import{u as Ut}from"./index.esm-CE99IrRV.js";import"./chunk-C51TLUcr.js";import{C as Jr}from"./Container-CkXRG7ex.js";import"./chunk-Bd1qRqEj.js";import"./styled-BlPcXvYz.js";function Yr(e={}){const{autoHideDuration:r=null,disableWindowBlurListener:a=!1,onClose:n,open:s,resumeHideDuration:p}=e,o=wr();u.useEffect(()=>{if(!s)return;function c(g){g.defaultPrevented||(g.key==="Escape"||g.key==="Esc")&&(n==null||n(g,"escapeKeyDown"))}return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[s,n]);const h=st((c,g)=>{n==null||n(c,g)}),l=st(c=>{!n||c==null||o.start(c,()=>{h(null,"timeout")})});u.useEffect(()=>(s&&l(r),o.clear),[s,r,l,o]);const m=c=>{n==null||n(c,"clickaway")},x=o.clear,_=u.useCallback(()=>{r!=null&&l(p??r*.5)},[r,p,l]),b=c=>g=>{const d=c.onBlur;d==null||d(g),_()},k=c=>g=>{const d=c.onFocus;d==null||d(g),x()},w=c=>g=>{const d=c.onMouseEnter;d==null||d(g),x()},y=c=>g=>{const d=c.onMouseLeave;d==null||d(g),_()};return u.useEffect(()=>{if(!a&&s)return window.addEventListener("focus",_),window.addEventListener("blur",x),()=>{window.removeEventListener("focus",_),window.removeEventListener("blur",x)}},[a,s,_,x]),{getRootProps:(c={})=>{const g=V({},lt(e),lt(c));return V({role:"presentation"},c,g,{onBlur:b(g),onFocus:k(g),onMouseEnter:w(g),onMouseLeave:y(g)})},onClickAway:m}}function Kr(e){return bt("MuiSnackbarContent",e)}xt("MuiSnackbarContent",["root","message","action"]);const Zr=["action","className","message","role"],Xr=e=>{const{classes:r}=e;return kt({root:["root"],action:["action"],message:["message"]},Kr,r)},Qr=P(ie,{name:"MuiSnackbarContent",slot:"Root",overridesResolver:(e,r)=>r.root})(({theme:e})=>{const r=e.palette.mode==="light"?.8:.98,a=Tr.emphasize(e.palette.background.default,r);return V({},e.typography.body2,{color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(a),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:a,display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",borderRadius:(e.vars||e).shape.borderRadius,flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}})}),en=P("div",{name:"MuiSnackbarContent",slot:"Message",overridesResolver:(e,r)=>r.message})({padding:"8px 0"}),tn=P("div",{name:"MuiSnackbarContent",slot:"Action",overridesResolver:(e,r)=>r.action})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),rn=u.forwardRef(function(r,a){const n=Ct({props:r,name:"MuiSnackbarContent"}),{action:s,className:p,message:o,role:h="alert"}=n,l=Re(n,Zr),m=n,x=Xr(m);return ne.jsxs(Qr,V({role:h,square:!0,elevation:6,className:Sr(x.root,p),ownerState:m,ref:a},l,{children:[ne.jsx(en,{className:x.message,ownerState:m,children:o}),s?ne.jsx(tn,{className:x.action,ownerState:m,children:s}):null]}))});function nn(e){return bt("MuiSnackbar",e)}xt("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const an=["onEnter","onExited"],on=["action","anchorOrigin","autoHideDuration","children","className","ClickAwayListenerProps","ContentProps","disableWindowBlurListener","message","onBlur","onClose","onFocus","onMouseEnter","onMouseLeave","open","resumeHideDuration","TransitionComponent","transitionDuration","TransitionProps"],sn=e=>{const{classes:r,anchorOrigin:a}=e,n={root:["root",`anchorOrigin${we(a.vertical)}${we(a.horizontal)}`]};return kt(n,nn,r)},ut=P("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:a}=e;
1return[r.root,r[`anchorOrigin${we(a.anchorOrigin.vertical)}${we(a.anchorOrigin.horizontal)}`]]}})(({theme:e,ownerState:r})=>{const a={left:"50%",right:"auto",transform:"translateX(-50%)"};return V({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center"},r.anchorOrigin.vertical==="top"?{top:8}:{bottom:8},r.anchorOrigin.horizontal==="left"&&{justifyContent:"flex-start"},r.anchorOrigin.horizontal==="right"&&{justifyContent:"flex-end"},{[e.breakpoints.up("sm")]:V({},r.anchorOrigin.vertical==="top"?{top:24}:{bottom:24},r.anchorOrigin.horizontal==="center"&&a,r.anchorOrigin.horizontal==="left"&&{left:24,right:"auto"},r.anchorOrigin.horizontal==="right"&&{right:24,left:"auto"})})}),ln=u.forwardRef(function(r,a){const n=Ct({props:r,name:"MuiSnackbar"}),s=re(),p={enter:s.transitions.duration.enteringScreen,exit:s.transitions.duration.leavingScreen},{action:o,anchorOrigin:{vertical:h,horizontal:l}={vertical:"bottom",horizontal:"left"},autoHideDuration:m=null,children:x,className:_,ClickAwayListenerProps:b,ContentProps:k,disableWindowBlurListener:w=!1,message:y,open:f,TransitionComponent:c=_r,transitionDuration:g=p,TransitionProps:{onEnter:d,onExited:C}={}}=n,T=Re(n.TransitionProps,an),z=Re(n,on),A=V({},n,{anchorOrigin:{vertical:h,horizontal:l},autoHideDuration:m,disableWindowBlurListener:w,TransitionComponent:c,transitionDuration:g}),O=sn(A),{getRootProps:I,onClickAway:S}=Yr(V({},A)),[F,L]=u.useState(!0),N=Ir({elementType:ut,getSlotProps:I,externalForwardedProps:z,ownerState:A,additionalProps:{ref:a},className:[O.root,_]}),H=ce=>{L(!0),C&&C(ce)},ze=(ce,Pe)=>{L(!1),d&&d(ce,Pe)};return!f&&F?null:ne.jsx(qr,V({onClickAway:S},b,{children:ne.jsx(ut,V({},N,{children:ne.jsx(c,V({appear:!0,in:f,timeout:g,direction:h==="top"?"down":"up",onEnter:ze,onExited:H},T,{children:x||ne.jsx(rn,V({message:y,action:o},k))}))}))}))});var pe={},ht;function cn(){if(ht)return pe;ht=1;var e=Be();Object.defineProperty(pe,"__esModule",{value:!0}),pe.default=void 0;var r=e(Ne()),a=qe();return pe.default=(0,r.default)((0,a.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy"),pe}var dn=cn();const Et=We(dn),Rt=P(D)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1.5),maxHeight:"600px",overflowY:"auto",padding:e.spacing(2),border:`1px solid ${e.palette.divider}`,borderRadius:e.spacing(1)})),Ze=P(Dt,{shouldForwardProp:e=>e!=="isDragging"})(({theme:e,isDragging:r})=>({display:"flex",alignItems:"center",padding:e.spacing(1.5),cursor:"default",opacity:r?.5:1,backgroundColor:r?e.colors.primary.bgLight:e.palette.background.paper,transform:r?"scale(1.02)":"none",transition:"all 0.2s ease",minHeight:"80px",position:"relative",userSelect:"none","&:hover":{boxShadow:e.palette.mode==="dark"?"none":e.shadows[4],backgroundColor:e.palette.action.hover}})),Ie=P("img")(({theme:e,width:r="60px",height:a="60px"})=>({width:r,height:a,objectFit:"cover",borderRadius:e.spacing(1),marginRight:e.spacing(2),flexShrink:0})),Xe=P(D)({flex:1,display:"flex",flexDirection:"column",justifyContent:"center",minWidth:0}),Qe=P(D)(({theme:e})=>({display:"flex",alignItems:"center",marginRight:e.spacing(1),color:e.palette.text.secondary,cursor:"grab",userSelect:"none","&:hover":{color:e.palette.primary.main},"&:active":{cursor:"grabbing"}})),Mt=P(D)(({theme:e})=>({marginTop:e.spacing(2),padding:e.spacing(2),backgroundColor:e.palette.background.default,border:`1px solid ${e.palette.divider}`,borderRadius:e.spacing(1),position:"relative"})),Lt=P(Te)(({theme:e})=>({position:"absolute",top:e.spacing(1),right:e.spacing(1)})),jt=P("pre")(({theme:e})=>({backgroundColor:e.palette.background.paper,color:e.palette.text.primary,padding:e.spacing(2),borderRadius:e.spacing(.5),border:`1px solid ${e.palette.divider}`,fontSize:"12px",fontFamily:"monospace",maxHeight:"200px",overflowY:"auto",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"})),Gt=P(D)(({theme:e})=>({display:"flex",gap:e.spacing(2),marginBottom:e.spacing(2),alignItems:"center"})),pn=P(D)(({theme:e})=>({marginLeft:e.spacing(4),paddingLeft:e.spacing(2),borderLeft:`2px solid ${e.palette.primary.light}`,backgroundColor:e.palette.background.default,borderRadius:e.spacing(1)})),un=P(D)(({theme:e})=>({minHeight:"60px",border:`2px dashed ${e.palette.grey[300]}`,borderRadius:e.spacing(1),display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:e.palette.background.paper,margin:e.spacing(1,0),transition:"all 0.2s ease","&.drag-over":{borderColor:e.palette.primary.main,backgroundColor:e.colors.primary.bgLight}})),$t=({isLoading:e,message:r="Loading avatars..."})=>e?i(D,{display:"flex",flexDirection:"column",alignItems:"center",gap:2,py:4,children:[t(Se,{}),t(G,{children:r})]}):null,Vt=({message:e,severity:r="warning"})=>t(D,{children:t(At,{severity:r,children:t(G,{variant:"body2",children:t("strong",{children:e})})})}),hn=({title:e,jsonContent:r,onCopy:a,linkUrl:n})=>i(Mt,{children:[t(G,{variant:"subtitle2",sx:{mb:1,fontWeight:600},children:n?t(G,{component:"a",href:n,target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline",fontWeight:600,fontSize:"inherit","&:hover":{textDecoration:"none"}},children:e}):e}),t(Lt,{onClick:a,size:"small",title:"Copy to clipboard",children:t(Et,{fontSize:"small"})}),t(jt,{children:r})]}),Bt=({open:e,onClose:r,message:a="JSON copied to clipboard!"})=>t(ln,{open:e,autoHideDuration:3e3,onClose:r,message:a}),gn=({avatar:e,index:r,provided:a,snapshot:n,children:s})=>i(Ze,{ref:a.innerRef,...a.draggableProps,isDragging:n.isDragging,children:[t(Qe,{...a.dragHandleProps,children:t(Ke,{})}),t(Ie,{src:e.thumbnail||e.poster,alt:e.name}),i(Xe,{children:[i(G,{variant:"body2",sx:{fontWeight:600,mb:.3,lineHeight:1.2,fontSize:"1.2rem"},children:["#",r+1," - ",e.name]}),t(G,{variant:"body2",sx:{color:"text.secondary",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.2,whiteSpace:"nowrap",fontSize:"1rem"},children:e.id})]}),s]}),Nt=()=>{const e=u.useCallback(()=>{typeof window<"u"&&(document.body.style.overflow="hidden")},[]),r=u.useCallback(()=>{typeof window<"u"&&(document.body.style.overflow="unset")},[]);return wt.useEffect(()=>()=>{typeof window<"u"&&(document.body.style.overflow="unset")},[]),{handleDragStart:e,handleDragEndCleanup:r}},qt=(e,r)=>u.useCallback(async()=>{try{await navigator.clipboard.writeText(e()),r(!0)}catch(a){console.error("Failed to copy: ",a)}},[e,r]);var ue={},gt;function mn(){if(gt)return ue;gt=1;var e=Be();
1Object.defineProperty(ue,"__esModule",{value:!0}),ue.default=void 0;var r=e(Ne()),a=qe();return ue.default=(0,r.default)((0,a.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M8 17.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5M9.5 8c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5S9.5 9.38 9.5 8m6.5 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5"}),"GroupWork"),ue}var fn=mn();const Ge=We(fn);var he={},mt;function yn(){if(mt)return he;mt=1;var e=Be();Object.defineProperty(he,"__esModule",{value:!0}),he.default=void 0;var r=e(Ne()),a=qe();return he.default=(0,r.default)((0,a.jsx)("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"Person"),he}var vn=yn();const bn=We(vn),xn=({avatar:e,index:r,provided:a,snapshot:n,onCreateGroup:s})=>i(Ze,{ref:a.innerRef,...a.draggableProps,isDragging:n.isDragging,children:[t(Qe,{...a.dragHandleProps,children:t(Ke,{})}),t(bn,{sx:{mr:1,color:"primary.main"}}),t(Ie,{src:e.thumbnail||e.poster,alt:e.name}),t(Xe,{children:i(U,{variant:"caption",as:"p",weight:600,children:["#",r+1," - ",e.name]})}),t(Te,{size:"small",onClick:()=>s(e),title:"Create group",children:t(Ge,{})})]}),Cn=({group:e,index:r,provided:a,snapshot:n,onUngroupAvatar:s,onRemoveFromGroup:p})=>i(D,{children:[i(Ze,{ref:a.innerRef,...a.draggableProps,isDragging:n.isDragging,children:[t(Qe,{...a.dragHandleProps,children:t(Ke,{})}),t(Ge,{sx:{mr:1,color:"secondary.main"}}),t(Ie,{src:e.mainAvatar.thumbnail||e.mainAvatar.poster,alt:e.mainAvatar.name}),i(Xe,{children:[i(U,{variant:"caption",as:"p",weight:600,children:["#",r+1," - ",e.mainAvatar.name," (Group ",e.alternatives.length+1,")"]}),i(U,{variant:"caption",color:"muted",children:[e.alternatives.length," alternatives"]})]}),t(Te,{size:"small",onClick:()=>s(e.id),title:"Ungroup",color:"error",children:t(Ge,{})})]}),t(pn,{children:t(Ye,{droppableId:`group-${e.id}`,type:"AVATAR",children:(o,h)=>i(D,{...o.droppableProps,ref:o.innerRef,sx:{minHeight:"60px"},children:[e.alternatives.length===0?t(un,{className:h.isDraggingOver?"drag-over":"",children:t(U,{variant:"caption",color:"muted",children:"Drag avatars here to add alternatives"})}):t(D,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.alternatives.map(l=>i(Dt,{sx:{p:1,display:"flex",alignItems:"center"},children:[t(Ie,{src:l.thumbnail||l.poster,alt:l.name,width:"40px",height:"40px",sx:{mr:1}}),t(U,{variant:"caption",as:"p",style:{flex:1},children:l.name}),t(Te,{size:"small",onClick:()=>p(e.id,l.id),color:"error",children:"×"})]},l.id))}),o.placeholder]})})}),t(Or,{sx:{my:2}})]}),kn=()=>i(G,{variant:"body2",sx:{mb:4,color:"text.secondary"},children:["Manage avatar ordering and grouping using drag and drop. Reorder avatars by dragging them. Click the group icon (👥) on any avatar to create a group, then drag other avatars into the group to add alternatives.",t("br",{}),t("br",{}),"The output includes both the ordering (",t(G,{component:"a",href:"https://app.launchdarkly.com/projects/default/flags/top_avatars/targeting?env=test&selected-env=test",target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline","&:hover":{textDecoration:"none"}},children:"top_avatars"}),") and grouping (",t(G,{component:"a",href:"https://app.launchdarkly.com/projects/default/flags/avatars_grouping/variations?env=test&selected-env=test",target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline","&:hover":{textDecoration:"none"}},children:"avatars_grouping"}),") configurations for LaunchDarkly."]}),wn=({jsonTab:e,onTabChange:r,topAvatarsJson:a,avatarsGroupingJson:n,onCopy:s})=>i(Mt,{children:[t(D,{sx:{borderBottom:1,borderColor:"divider",mb:2},children:i(Wr,{value:e,onChange:(p,o)=>r(o),children:[t(dt,{label:"Top Avatars JSON"}),t(dt,{label:"Avatars Grouping JSON"})]})}),i(D,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1},children:[i(G,{variant:"subtitle2",sx:{fontWeight:600},children:[t(G,{component:"a",href:e===0?"https://app.launchdarkly.com/projects/default/flags/top_avatars/targeting?env=test&selected-e
1nv=test":"https://app.launchdarkly.com/projects/default/flags/avatars_grouping/variations?env=test&selected-env=test",target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline",fontWeight:600,fontSize:"inherit","&:hover":{textDecoration:"none"}},children:e===0?"top_avatars":"avatars_grouping"})," JSON for LaunchDarkly"]}),t(Lt,{onClick:s,size:"small",title:"Copy to clipboard",children:t(Et,{fontSize:"small"})})]}),i(jt,{children:[e===0&&a,e===1&&n]})]}),Sn=()=>{const{publicAvatars:e,isLoading:r}=St(Oe.AgentV2),a=Me("top_avatars",Ar),n=Me("avatars_grouping",Dr),[s,p]=u.useState([]),o=u.useCallback(()=>{if(e.length===0)return[];const b=[],k=new Set(Object.values(n).flat()),w=new Set(Object.keys(n));return Object.entries(n).forEach(([f,c])=>{const g=e.find(C=>C.id===f),d=c.map(C=>e.find(T=>T.id===C)).filter(Boolean);g&&b.push({type:"group",group:{id:f,mainAvatar:g,alternatives:d}})}),e.filter(f=>!k.has(f.id)&&!w.has(f.id)).forEach(f=>{b.push({type:"avatar",avatar:f})}),b.sort((f,c)=>{const g=f.type==="avatar"?f.avatar.id:f.group.mainAvatar.id,d=c.type==="avatar"?c.avatar.id:c.group.mainAvatar.id,C=a.indexOf(g),T=a.indexOf(d);return C===-1&&T===-1?g.localeCompare(d):C===-1?1:T===-1?-1:C-T})},[e,a,n]),h=u.useCallback((b,k)=>{var w;k();try{if(!b.destination)return;const{source:y,destination:f}=b;if(y.droppableId==="ordered-items"&&f.droppableId==="ordered-items"){if(y.index===f.index)return;const c=[...s],[g]=c.splice(y.index,1);c.splice(f.index,0,g),p(c)}else if(f.droppableId.startsWith("group-")){const c=f.droppableId.replace("group-",""),g=b.draggableId,d=(w=s.find(C=>C.type==="avatar"&&C.avatar.id===g))==null?void 0:w.avatar;if(d){const C=s.filter(T=>!(T.type==="avatar"&&T.avatar.id===g)).map(T=>T.type==="group"&&T.group.id===c?{...T,group:{...T.group,alternatives:[...T.group.alternatives,d]}}:T);p(C)}}}catch(y){console.error("Drag error:",y)}},[s]),l=u.useCallback(b=>{const k=s.map(w=>w.type==="avatar"&&w.avatar.id===b.id?{type:"group",group:{id:b.id,mainAvatar:b,alternatives:[]}}:w);p(k)},[s]),m=u.useCallback(b=>{const k=[];s.forEach(w=>{w.type==="group"&&w.group.id===b?(k.push({type:"avatar",avatar:w.group.mainAvatar}),w.group.alternatives.forEach(y=>{k.push({type:"avatar",avatar:y})})):k.push(w)}),p(k)},[s]),x=u.useCallback((b,k)=>{const w=s.map(y=>{if(y.type==="group"&&y.group.id===b){const f=y.group.alternatives.filter(c=>c.id!==k);return{...y,group:{...y.group,alternatives:f}}}return y});p(w)},[s]),_=u.useCallback(()=>{const b=o();p(b)},[o]);return{publicAvatars:e,isLoading:r,orderedItems:s,setOrderedItems:p,buildOrderedItems:o,handleDragEnd:h,createGroup:l,ungroupAvatar:m,removeFromGroup:x,resetToDefaults:_}},Tn=e=>{const r=u.useCallback(()=>{const n=[],s={};return e.forEach(p=>{p.type==="avatar"?n.push(p.avatar.id):p.type==="group"&&(n.push(p.group.mainAvatar.id),p.group.alternatives.length>0&&(s[p.group.mainAvatar.id]=p.group.alternatives.map(o=>o.id)))}),{top_avatars:n,avatars_grouping:s}},[e]);return{generateJsonOutput:u.useCallback(n=>{const s=r();switch(n){case"top_avatars":return JSON.stringify(s.top_avatars,null,2);case"avatars_grouping":return JSON.stringify(s.avatars_grouping,null,2);default:return""}},[r]),generateJsonOutputs:r}},_n=()=>{const{publicAvatars:e,isLoading:r,orderedItems:a,setOrderedItems:n,buildOrderedItems:s,handleDragEnd:p,createGroup:o,ungroupAvatar:h,removeFromGroup:l,resetToDefaults:m}=Sn(),{generateJsonOutput:x}=Tn(a),[_,b]=u.useState(!1),[k,w]=u.useState(0),{handleDragStart:y,handleDragEndCleanup:f}=Nt();u.useEffect(()=>{const d=s();n(d)},[s,n]);const c=qt(()=>x(k===0?"top_avatars":"avatars_grouping"),b),g=d=>{p(d,f)};return r?t($t,{isLoading:r}):e.length===0?t(Vt,{message:"No avatars found."}):i(D,{children:[t(kn,{}),t(Gt,{children:t(q,{variant:"outlined",onClick:m,size:"small",children:"Reset to Current LD Values"})}),i(U,{variant:"caption",as:"h6",weight:600,style:{marginBottom:16},children:["Ordered Avatars & Groups (",a.length,")"]}),t(It,{onDragEnd:g,onDragStart:y,children:t(Ye,{droppableId:"ordered-items",type:"AVATAR",children:(d,C)=>i(Rt,{...d.droppableProps,ref:d.innerRef,sx:{backgroundColor:C.isDraggingOver?"primary.light":"transparent",transition:"background-color 0.2s ease"},children:[a.map((T,z)=>{if(T.type==="avatar"){const A=T.avatar;return t(je,{draggableId:A.id,index:z,children:(O,I)=>t(xn,{avatar:A,index:z,provided:O,snapshot:I,onCreateGroup:o})},A.id)}else{const A=T.group;return t(D,{children:t(je,{draggableId:A.mainAvatar.id,index:z,children:(O,I)=>t(Cn,{group:A,index:z,provided:O,snapshot:I,onUngroupAvatar:h,onRemoveFromGroup:l})})},A.id)}}),d.placeholder]})})}),t(wn,{jsonTab:k,onTabChange:w,topAvatarsJson:x("top_avatars"),avatarsGroupingJson:x("avatars_grouping"),onCopy:c}),t(Bt,{open:_,onClose:()=>b(!1)})]})},In=()=>{const{publicAvatars:e,isLoading:r}=St(Oe.Video,"all",!0),{sortAvatars:a}=zr(),[n,s]=u.useState([]),[p,o]=u.useState(!1),{handleDragStart:h,handleDragEndCleanup:l}=Nt(),m=u.useMemo(()=>a(e),[e,a]);u.useEffect(()=>{if(m.length>0){const y=m.map(f=>f.id);s(y)}},[m]);const x=u.useMemo(()=>n.length===0&&e.length>0?m:n.map(y=>e.find(f=>f.id===y)).filter(y=>y!=null),[n,e,m]),_=u.useCallback(y=>{l();try{if(!y.destination||y.destination.index===y.source.index)return;const f=Array.from(n),[c]=f.splice(y.source.index,1);f.splice(y.destination.index,0,c),s(f)}catch(f){console.error("Drag error:",f)}},[n,l]),b=u.useCallback(()=>JSON.stringify(n,null,2),[n]),k=qt(b,o),w=u.useCallback(()=>
1{if(m.length>0){const y=m.map(f=>f.id);s(y)}},[m]);return r?t($t,{isLoading:r}):e.length===0?t(Vt,{message:"No public avatars found."}):i(He,{children:[i(G,{variant:"body2",sx:{mb:4,color:"text.secondary"},children:["Drag and drop public avatars to reorder them for the Studio. This uses the sorting logic from",t(G,{component:"span",sx:{fontFamily:"monospace",backgroundColor:"grey.100",px:.5,borderRadius:.5},children:"top_avatars_for_lib"})," ","feature flag.",t("br",{}),t("br",{}),"The generated JSON can be copied and pasted back into"," ",t(G,{component:"a",href:"https://app.launchdarkly.com/projects/default/flags/top_avatars_for_lib/targeting?env=test&selected-env=test",target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline","&:hover":{textDecoration:"none"}},children:"LaunchDarkly's top_avatars_for_lib flag"}),"."]}),t(Gt,{children:t(q,{variant:"outlined",onClick:w,size:"small",children:"Reset to Current Sorting Logic"})}),i(G,{variant:"subtitle2",sx:{mb:1,fontWeight:600},children:["Studio Avatars (",x.length," total public avatars)"]}),t(It,{onDragEnd:_,onDragStart:h,children:t(Ye,{droppableId:"avatars",type:"AVATAR",children:(y,f)=>i(Rt,{...y.droppableProps,ref:y.innerRef,sx:{backgroundColor:f.isDraggingOver?"primary.light":"transparent",transition:"background-color 0.2s ease"},children:[x.map((c,g)=>c?t(je,{draggableId:c.id,index:g,children:(d,C)=>t(gn,{avatar:c,index:g,provided:d,snapshot:C})},c.id):null),y.placeholder]})})}),t(hn,{title:"JSON Output for LaunchDarkly (top_avatars_for_lib)",jsonContent:b(),onCopy:k,linkUrl:"https://app.launchdarkly.com/projects/default/flags/top_avatars_for_lib/targeting?env=test&selected-env=test"}),t(Bt,{open:p,onClose:()=>o(!1)})]})},Wt=async e=>{const r=await X.get(`${Q}/organizations/${e}`);return r==null?void 0:r.data},On=async(e,r)=>{var n;const a=await((n=X)==null?void 0:n.put(`${Q}/organizations/${e}`,{name:r}));return a==null?void 0:a.data},An=async(e,r)=>{const a=await X.patch(`${Q}/clips/presenters/${e}`,r);return a==null?void 0:a.data},Dn=async(e,r)=>{const a=await X.patch(`${Q}/clips/presenters/${e}`,r);return a==null?void 0:a.data},ft=async e=>{const r=await X.get(`${Q}/tts/owner-voices/${e}`);return r==null?void 0:r.data},zn=async(e,r)=>{const a=await X.patch(`${Q}/tts/voices/${e}`,r);return a==null?void 0:a.data},Pn=async(e,r)=>{const a=await X.patch(`${Q}/expressives/avatars/${e}`,{ownerId:r.ownerId,background_url:r.background_url,avatar_with_bg_url:r.avatar_with_bg_url});return a==null?void 0:a.data},Fn=async(e,r)=>{const a=await X.patch(`${Q}/expressives/avatars/${e}`,r);return a==null?void 0:a.data},Un=[te.Elevenlabs,te.Microsoft,te.AzureOpenAi,te.Amazon,te.Google],En=async(e,r)=>{const a=await X.patch(`${Q}/expressives/avatars/${e}`,r);return a==null?void 0:a.data},yt=P("form")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1.5)})),Fe=P(q)(({theme:e})=>({padding:e.spacing(1,2),fontSize:"1.5rem"})),Rn=()=>{const[e,r]=u.useState(""),[a,n]=u.useState(""),[s,p]=u.useState(""),[o,h]=u.useState(!1),[l,m]=u.useState(!1),[x,_]=u.useState(""),[b,k]=u.useState(!1),[w,y]=u.useState("");return t(D,{children:l?i(yt,{onSubmit:async d=>{d.preventDefault(),k(!1),y("");try{if(!e||!s){y("Organization ID and new name are required");return}await On(e,s),k(!0),n(s)}catch{y("Failed to rename organization. Please try again.")}},children:[t(M,{label:"Current Organization Name",value:a,disabled:!0,fullWidth:!0,size:"small"}),t(M,{label:"New Organization Name",value:s,onChange:d=>p(d.target.value),required:!0,fullWidth:!0,size:"small",error:!!w,helperText:w}),b&&t(At,{severity:"success",sx:{mt:1},children:"Organization renamed successfully!"}),i(D,{sx:{display:"flex",justifyContent:"space-between"},children:[t(Fe,{variant:"contained",color:"secondary",onClick:()=>{r(""),n(""),h(!1),m(!1),_(""),k(!1),y("")},children:"Back"}),t(Fe,{type:"submit",variant:"contained",color:"primary",children:"Rename Organization"})]})]}):i(yt,{onSubmit:async d=>{d.preventDefault(),h(!0),_(""),k(!1),y("");try{if(!e){_("Please enter a valid organization ID");return}const C=await Wt(e);n(C.name),p(C.name),m(!0)}catch{_("Failed to fetch organization data. Please check the ID and try again.")}finally{h(!1)}}
1,children:[t(M,{label:"Organization ID",value:e,onChange:d=>r(d.target.value),required:!0,fullWidth:!0,size:"small",error:!!x,helperText:x}),t(D,{sx:{display:"flex",justifyContent:"flex-end"},children:t(Fe,{type:"submit",variant:"contained",color:"primary",disabled:o,children:o?i(He,{children:[t(Se,{size:20,color:"inherit",sx:{mr:1}}),"Loading..."]}):"Fetch Organization"})})]})})},Mn=P(q)(({theme:e})=>({padding:e.spacing(1,2),fontSize:"1.5rem"})),Ln=({onSuccess:e,onError:r})=>{const{user:a}=Ae(),[n,s]=u.useState(""),p=zt(n||void 0,Oe.Agent),[o,h]=u.useState(""),[l,m]=u.useState(!0),[x,_]=u.useState(!1),[b,k]=u.useState(null),w=n.startsWith("v2_");return t(D,{sx:{mt:4},children:i(ie,{sx:{p:3},children:[t(U,{variant:"caption",as:"h6",weight:700,style:{marginBottom:"0.35em"},children:"Update V4 Presenter Background Image"}),i(D,{component:"form",onSubmit:async g=>{var d,C;if(g.preventDefault(),!!b){_(!0);try{const T=(p==null?void 0:p.poster)||(p==null?void 0:p.thumbnail);if(!T)throw new Error("Could not find presenter poster image. Make sure the Presenter ID is correct.");const z={bucket:Le,image_id:n},{url:A}=await Tt({file:b,metadata:z}),O=Pt(Je,A),{result_url:I}=await Pr({source_url:T,background_url:O,bucket:Le,image_id:n});await Pn(n,{ownerId:l?a==null?void 0:a.id:o,background_url:pt(A),avatar_with_bg_url:pt(I)}),$.success({title:"Presenter background updated successfully"}),e==null||e(),s(""),h(""),m(!0),k(null);const S=document.querySelector('input[type="file"]');S&&(S.value="")}catch(T){const z=((C=(d=T==null?void 0:T.response)==null?void 0:d.data)==null?void 0:C.message)||"Failed to update presenter background";$.error({title:z}),r==null||r(z)}finally{_(!1)}}},sx:{display:"flex",flexDirection:"column",gap:2},children:[t(M,{label:"Presenter ID",value:n,onChange:g=>s(g.target.value),required:!0,fullWidth:!0,error:n!==""&&w,helperText:n!==""&&w?"Only v4 (expressive) presenters are supported":""}),i(fe,{fullWidth:!0,children:[t(ye,{children:"Current Owner"}),i(ve,{value:l?"me":"other",onChange:g=>m(g.target.value==="me"),label:"Current Owner",defaultValue:"me",children:[t(Z,{value:"me",children:"Me"}),t(Z,{value:"other",children:"Other User"})]})]}),!l&&t(M,{label:"Current Owner ID",value:o,onChange:g=>h(g.target.value),required:!0,fullWidth:!0}),t(M,{type:"file",inputProps:{accept:"image/*"},onChange:g=>{var C;const d=(C=g.target.files)==null?void 0:C[0];if(d){if(!d.type.startsWith("image/")){$.error({title:"Please select an image file"});return}k(d)}},required:!0,fullWidth:!0}),t(Mn,{type:"submit",variant:"contained",disabled:x||!(!w&&n&&(l||o)&&b),children:x?"Updating...":"Update Background Image"})]})]})})},jn=P(q)(({theme:e})=>({padding:e.spacing(1,2),fontSize:"1.5rem"})),Gn=({onSuccess:e,onError:r})=>{const{user:a}=Ae(),[n,s]=u.useState(""),[p,o]=u.useState(""),[h,l]=u.useState(!0),[m,x]=u.useState(!1),[_,b]=u.useState(null),k=n.startsWith("v2_");return t(D,{sx:{mt:4},children:i(ie,{sx:{p:3},children:[t(U,{variant:"caption",as:"h6",weight:700,style:{marginBottom:"0.35em"},children:"Update Presenter Idle Video"}),i(D,{component:"form",onSubmit:async c=>{var g,d;if(c.preventDefault(),!!_){x(!0);try{const C=await Fr(_);await Dn(n,{ownerId:h?a==null?void 0:a.id:p,idle_video:C}),$.success({title:"Presenter idle video updated successfully"}),e==null||e(),s(""),o(""),l(!0),b(null)}catch(C){const T=((d=(g=C==null?void 0:C.response)==null?void 0:g.data)==null?void 0:d.message)||"Failed to update presenter idle video";$.error({title:T}),r==null||r(T)}finally{x(!1)}}},sx:{display:"flex",flexDirection:"column",gap:2},children:[t(M,{label:"Presenter ID",value:n,onChange:c=>s(c.target.value),required:!0,fullWidth:!0,error:n!==""&&!k,helperText:n!==""&&!k?"Only v2 presenters are supported":""}),i(fe,{fullWidth:!0,children:[t(ye,{children:"Current Owner"}),i(ve,{value:h?"me":"other",onChange:c=>l(c.target.value==="me"),label:"Current Owner",defaultValue:"me",children:[t(Z,{value:"me",children:"Me"}),t(Z,{value:"other",children:"Other User"})]})]}),!h&&t(M,{label:"Current Owner ID",value:p,onChange:c=>o(c.target.value),required:!0,fullWidth:!0}),t(M,{type:"file",inputProps:{accept:"video/*"},onChange:c=>{var d;const g=(d=c.target.files)==null?void 0:d[0];g&&b(g)},required:!0,fullWidth:!0}),t(jn,{type:"submit",variant:"contained",disabled:m||!(k&&n&&(h||p)&&_),children:m?"Updating...":"Update Idle Video"})]})]})})},$n=P(q)(({theme:e})=>({padding:e.spacing(1,2),fontSize:"1.5rem"})),Vn=({onSuccess:e,onError:r})=>{const a=re(),{user:n}=Ae(),[s,p]=u.useState(""),[o,h]=u.useState(""),[l,m]=u.useState(""),[x,_]=u.useState(!0),[b,k]=u.useState(!1),[w,y]=u.useState(!1),[f,c]=u.useState(null),[g,d]=u.useState(!1),C=s.startsWith("v2_"),T=b&&!C,z=C||T,A=C?"V2 (clips)":T?"V4 (expressive)":'Unrecognized — tick "V4 avatar" or use a v2_ id',O=!!s&&z&&(x||o)&&!!l&&!g;return u.useEffect(()=>{(async()=>
1{if(l.startsWith("org_"))try{const F=await Wt(l);c(F.name),d(!1)}catch{c(null),d(!0)}else c(null),d(!1)})()},[l]),i(ie,{sx:{p:3},children:[t(U,{variant:"caption",as:"h6",weight:700,style:{marginBottom:"0.35em"},children:"Modify Presenter Owner"}),i(D,{component:"form",onSubmit:async S=>{var F,L;S.preventDefault(),y(!0);try{const N=x?(n==null?void 0:n.owner_id)||(n==null?void 0:n.org_id)||(n==null?void 0:n.sub):o;if(!N){$.error({title:"Could not resolve the current owner id"}),y(!1);return}const H={ownerId:N,newOwnerId:l};if(C)await An(s,H);else if(T)await Fn(s,H);else{$.error({title:'Tick "V4 avatar" for an expressive avatar, or enter a v2_ presenter id'});return}$.success({title:"Presenter owner updated successfully"}),e==null||e(),p(""),h(""),m(""),_(!0),k(!1)}catch(N){const H=((L=(F=N==null?void 0:N.response)==null?void 0:F.data)==null?void 0:L.message)||"Failed to update presenter owner";$.error({title:H}),r==null||r(H)}finally{y(!1)}},sx:{display:"flex",flexDirection:"column",gap:2},children:[t(M,{label:"Presenter ID",value:s,onChange:S=>p(S.target.value),required:!0,fullWidth:!0,helperText:s!==""?A:""}),t(Er,{label:"V4 avatar (Expressive)",children:t(Ur,{checked:b,onChange:k,disabled:C,"aria-label":"V4 avatar (Expressive)"})}),i(fe,{fullWidth:!0,children:[t(ye,{children:"Current Owner"}),i(ve,{value:x?"me":"other",onChange:S=>_(S.target.value==="me"),label:"Current Owner",defaultValue:"me",children:[t(Z,{value:"me",children:"Me"}),t(Z,{value:"other",children:"Other User"})]})]}),!x&&t(M,{label:"Current Owner ID",value:o,onChange:S=>h(S.target.value),required:!0,fullWidth:!0}),t(M,{label:"New Owner ID",value:l,onChange:S=>m(S.target.value),required:!0,fullWidth:!0,error:g,helperText:g?"Organization not found":""}),f&&i(U,{variant:"title-sm",as:"h5",weight:700,style:{marginTop:8,marginBottom:8,color:a.colors.primary.main},children:["Organization: ",f]}),t($n,{type:"submit",variant:"contained",disabled:w||!O,children:w?"Updating...":g?"Organization Not Found":f?`Change Owner to ${f}`:"Change Owner"})]})]})},Bn=P(q)(({theme:e})=>({padding:e.spacing(1,2),fontSize:"1.5rem"})),Nn=({onSuccess:e,onError:r})=>{const{user:a}=Ae(),[n,s]=u.useState(""),p=zt(n||void 0,Oe.Agent),[o,h]=u.useState(""),[l,m]=u.useState(!0),[x,_]=u.useState(""),[b,k]=u.useState(te.Elevenlabs),[w,y]=u.useState(!1),f=n.startsWith("v2_"),c=!f&&!!n&&(l||!!o)&&!!x.trim();return t(D,{sx:{mt:4},children:i(ie,{sx:{p:3},children:[t(U,{variant:"caption",as:"h6",weight:700,style:{marginBottom:"0.35em"},children:"Update V4 Presenter Voice"}),i(D,{component:"form",onSubmit:async d=>{var C,T,z,A,O,I;d.preventDefault(),y(!0);try{const S=l?(a==null?void 0:a.owner_id)||(a==null?void 0:a.org_id)||(a==null?void 0:a.sub):o;if(!S)throw new Error("Could not resolve the current owner id");const F={voice_id:x.trim(),type:b},L=await En(n,{ownerId:S,default_voice:F});if(((C=L==null?void 0:L.default_voice)==null?void 0:C.voice_id)!==F.voice_id||((T=L==null?void 0:L.default_voice)==null?void 0:T.type)!==F.type)throw new Error("Server did not apply the voice — the avatar came back with a different default_voice");$.success({title:"Presenter voice updated successfully"}),e==null||e(),s(""),h(""),m(!0),_(""),k(te.Elevenlabs)}catch(S){const F=((A=(z=S==null?void 0:S.response)==null?void 0:z.data)==null?void 0:A.description)||((I=(O=S==null?void 0:S.response)==null?void 0:O.data)==null?void 0:I.message)||(S==null?void 0:S.message)||"Failed to update presenter voice";$.error({title:F}),r==null||r(F)}finally{y(!1)}},sx:{display:"flex",flexDirection:"column",gap:2},children:[t(M,{label:"Presenter ID",value:n,onChange:d=>s(d.target.value),required:!0,fullWidth:!0,error:n!==""&&f,helperText:n!==""&&f?"Only v4 (expressive) presenters are supported":p!=null&&p.default_voice?`Current voice: ${p.default_voice.voice_id} (${p.default_voice.type})`:""}),i(fe,{fullWidth:!0,children:[t(ye,{children:"Current Owner"}),i(ve,{value:l?"me":"other",onChange:d=>m(d.target.value==="me"),label:"Current Owner",defaultValue:"me",children:[t(Z,{value:"me",children:"Me"}),t(Z,{value:"other",children:"Other User"})]})]}),!l&&t(M,{label:"Current Owner ID",value:o,onChange:d=>h(d.target.value),required:!0,fullWidth:!0}),t(M,{label:"Voice ID",value:x,onChange:d=>
1_(d.target.value),required:!0,fullWidth:!0,helperText:"Applied to the primary sentiment too; sentiments set to a different voice are left as-is."}),i(fe,{fullWidth:!0,children:[t(ye,{children:"Voice Provider"}),t(ve,{value:b,onChange:d=>k(d.target.value),label:"Voice Provider",defaultValue:te.Elevenlabs,children:Un.map(d=>t(Z,{value:d,children:d},d))})]}),t(Bn,{type:"submit",variant:"contained",disabled:w||!c,children:w?"Updating...":"Update Voice"})]})]})})},De="/v0.1309.0/assets/PlusSign-Zpm6OuZh.svg",qn=/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,Ue=/^https:\/\/\S+$/,Wn=["streamable_http","sse"],Hn=["none","bearer","api_key","basic","oauth2"],Ht=()=>Math.random().toString(36).slice(2),et=()=>({enabled:!1,url:"",transportType:"",authType:"none",authScopes:"",oauthAuthorizationUrl:"",oauthTokenUrl:"",setupFields:[],setupGuide:""}),Jn=()=>({id:Ht(),key:"",label:"",description:"",placeholder:""}),Yn=e=>({id:Ht(),key:e.key??"",label:e.label??"",description:e.description??"",required:e.required,placeholder:e.placeholder??""}),Kn=e=>{if(!e)return et();const r=Array.isArray(e.setup_fields)?e.setup_fields:[];return{enabled:!!e.enabled,url:e.url??"",transportType:e.transport_type??"",authType:e.auth_type??"none",authScopes:Array.isArray(e.auth_scopes)?e.auth_scopes.join(`
2`):"",oauthAuthorizationUrl:e.oauth_authorization_url??"",oauthTokenUrl:e.oauth_token_url??"",setupFields:r.map(Yn),setupGuide:e.setup_guide?JSON.stringify(e.setup_guide,null,2):""}},Jt=e=>!e.key.trim()&&!e.label.trim()&&!e.description.trim()&&!e.placeholder.trim(),Zn=e=>!e.enabled&&!e.url.trim()&&!e.transportType&&e.authType==="none"&&!e.authScopes.trim()&&!e.oauthAuthorizationUrl.trim()&&!e.oauthTokenUrl.trim()&&!e.setupGuide.trim()&&e.setupFields.every(Jt),Xn=e=>[...new Set([...e.matchAll(qn)].map(r=>r[1]))],Ee=e=>`Undeclared setup placeholders: ${e.map(r=>`{{${r}}}`).join(", ")}`,Qn=e=>e.split(`
3`).map(r=>r.trim()).filter(Boolean),ea=e=>({key:e.key.trim(),label:e.label.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.required===void 0?{}:{required:e.required},...e.placeholder.trim()?{placeholder:e.placeholder.trim()}:{}}),ta=e=>{let r;try{r=JSON.parse(e)}catch{return{error:"Must be valid JSON"}}return!r||typeof r!="object"||Array.isArray(r)?{error:"Must be a JSON object"}:Array.isArray(r.steps)?{guide:r}:{error:'"steps" must be an array'}},ra=e=>{if(Zn(e))return{ok:!0,value:null};const r={},a=e.setupFields.filter(f=>!Jt(f));a.some(f=>!f.key.trim()||!f.label.trim())&&(r.setupFields="Every setup field needs a key and a label");const n=new Set(a.map(f=>f.key.trim()).filter(Boolean)),s=f=>Xn(f).filter(c=>!n.has(c)),p=e.url.trim(),o=s(p);p?o.length?r.url=Ee(o):Ue.test(p)||(r.url="URL must be an https address"):r.url="URL is required";const h=e.authType==="oauth2",l=h?e.oauthAuthorizationUrl.trim():"",m=h?e.oauthTokenUrl.trim():"",x=s(l);x.length?r.oauthAuthorizationUrl=Ee(x):l&&!Ue.test(l)&&(r.oauthAuthorizationUrl="Authorization URL must be an https address");const _=s(m);_.length?r.oauthTokenUrl=Ee(_):m&&!Ue.test(m)&&(r.oauthTokenUrl="Token URL must be an https address");const b=e.setupGuide.trim(),{guide:k,error:w}=b?ta(b):{};if(w&&(r.setupGuide=w),Object.keys(r).length)return{ok:!1,errors:r};const y=Qn(e.authScopes);return{ok:!0,value:{enabled:e.enabled,url:p,...e.transportType?{transport_type:e.transportType}:{},auth_type:e.authType,...y.length?{auth_scopes:y}:{},...l?{oauth_authorization_url:l}:{},...m?{oauth_token_url:m}:{},...a.length?{setup_fields:a.map(ea)}:{},...k?{setup_guide:k}:{}}}},Yt=v("div",{target:"ernllfv27"})("padding:1rem 2rem;display:flex;align-items:center;gap:8px;font-size:2rem;font-weight:600;color:",({theme:e})=>e.colors.black.main,";"),Kt=v("div",{target:"ernllfv26"})({name:"6741fj",styles:"display:flex;padding:0 2rem;flex-direction:column"}),Zt=v("div",{target:"ernllfv25"})({name:"ljmx88",styles:"display:flex;gap:8px;justify-content:flex-end;padding:1rem 2rem;margin-top:24px"}),j=v("input",{target:"ernllfv24"})("width:100%;padding:10px 14px;font-size:14px;border:1px solid ",({$error:e,theme:r})=>e?r.colors.static.errorMui:r.colors.black[300],";border-radius:8px;background:",({theme:e})=>e.colors.chill.panelBg,";color:",({theme:e})=>e.colors.secondary.main,";font-family:inherit;&:focus{outline:none;border-color:",({$error:e,theme:r})=>e?r.colors.static.errorMui:r.colors.black.main,";}&::placeholder{color:",({theme:e})=>e.colors.black[500],";}"),Y=v("span",{target:"ernllfv23"})({name:"q1t9ox",styles:"display:block;font-size:12px;color:#d32f2f;margin-top:4px"}),R=v("label",{target:"ernllfv22"})("display:block;font-size:14px;font-weight:500;color:",({theme:e})=>e.colors.secondary.main,";margin-bottom:4px;"),me=v("div",{target:"ernllfv21"})({name:"18uqayh",styles:"margin-bottom:16px"}),ae=v("button",{target:"ernllfv20"})("display:inline-flex;align-items:center;justify-content:center;padding:8px;border:none;background:transparent;cursor:pointer;border-radius:8px;color:",({theme:e})=>e.colors.secondary.main,";&:hover:not(:disabled){background:",({theme:e})=>e.colors.black[100],";color:",({theme:e})=>e.colors.black.main,";}&:disabled{opacity:0.5;cursor:not-allowed;}"),tt=v("button",{target:"ernllfv19"})("display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:10px 20px;font-size:14px;font-weight:600;border:none;border-radius:8px;
3cursor:pointer;background:",({theme:e})=>e.colors.primary.main,";color:",({theme:e})=>e.colors.black.main,";font-family:inherit;&:hover:not(:disabled){background:",({theme:e})=>e.colors.primary.hover,";}&:disabled{opacity:0.5;cursor:not-allowed;}"),oe=v("button",{target:"ernllfv18"})("display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:10px 20px;font-size:14px;font-weight:600;border:1px solid ",({theme:e})=>e.colors.primary.main,";border-radius:8px;cursor:pointer;background:transparent;color:",({theme:e})=>e.colors.primary.main,";font-family:inherit;&:hover:not(:disabled){background:",({theme:e})=>e.colors.primary.bgLight,";}&:disabled{opacity:0.5;cursor:not-allowed;}"),$e=v("textarea",{target:"ernllfv17"})("width:100%;padding:10px 14px;font-size:14px;border:1px solid ",({theme:e})=>e.colors.black[300],";border-radius:8px;background:",({theme:e})=>e.colors.chill.panelBg,";color:",({theme:e})=>e.colors.secondary.main,";font-family:inherit;resize:vertical;min-height:60px;&:focus{outline:none;border-color:",({theme:e})=>e.colors.black.main,";}&::placeholder{color:",({theme:e})=>e.colors.black[500],";}"),be=v("select",{target:"ernllfv16"})("padding:10px 14px;font-size:14px;border:1px solid ",({theme:e})=>e.colors.black[300],";border-radius:8px;background:",({theme:e})=>e.colors.chill.panelBg,";color:",({theme:e})=>e.colors.secondary.main,";font-family:inherit;min-width:120px;&:focus{outline:none;border-color:",({theme:e})=>e.colors.black.main,";}"),rt=v("label",{target:"ernllfv15"})("display:flex;align-items:center;gap:8px;cursor:pointer;font-size:14px;color:",({theme:e})=>e.colors.secondary.main,";user-select:none;"),nt=v("input",{target:"ernllfv14"})("width:40px;height:22px;appearance:none;background:",({theme:e})=>e.colors.black[300],";border-radius:11px;cursor:pointer;position:relative;transition:background 0.2s;&:checked{background:",({theme:e})=>e.colors.primary.main,";}&::before{content:'';position:absolute;width:18px;height:18px;border-radius:50%;background:white;top:2px;left:2px;transition:transform 0.2s;box-shadow:0 1px 3px rgba(0, 0, 0, 0.2);}&:checked::before{transform:translateX(18px);}"),na=v(nt,{target:"ernllfv13"})({name:"h42g3g",styles:"width:32px;height:18px;&::before{width:14px;height:14px;top:2px;left:2px;}&:checked::before{transform:translateX(14px);}"}),le=v("div",{target:"ernllfv12"})({name:"1neb8ay",styles:"display:flex;gap:16px;margin-top:16px"}),K=v("div",{target:"ernllfv11"})({name:"fxp7t8",styles:"flex:1;min-width:0"}),Ve=v("div",{target:"ernllfv10"})("width:",({$width:e})=>e??150,"px;flex-shrink:0;"),xe=v("span",{target:"ernllfv9"})("font-size:14px;font-weight:600;color:",({theme:e})=>e.colors.secondary.main,";margin-bottom:8px;display:block;"),at=v("span",{target:"ernllfv8"})("font-size:12px;color:",({theme:e})=>e.colors.secondary.main,";font-style:italic;"),aa=v("table",{target:"ernllfv7"})({name:"nabbac",styles:"width:100%;border-collapse:collapse;margin-bottom:8px"}),oa=v("thead",{target:"ernllfv6"})(),ia=v("tbody",{target:"ernllfv5"})(),vt=v("tr",{target:"ernllfv4"})(),ee=v("td",{target:"ernllfv3"})({name:"1fnvks1",styles:"padding:8px;vertical-align:middle;&:first-of-type{padding-left:0;}"}),se=v("th",{target:"ernllfv2"})("padding:8px;font-weight:600;text-align:left;font-size:12px;color:",({theme:e})=>e.colors.secondary.main,";&:first-of-type{padding-left:0;}"),Xt=v("input",{target:"ernllfv1"})("width:18px;height:18px;cursor:pointer;accent-color:",({theme:e})=>e.colors.primary.main,";"),Qt=v("span",{target:"ernllfv0"})("display:inline-flex;align-items:center;padding:2px 8px;font-size:12px;font-weight:500;border-radius:4px;background:",({$variant:e,theme:r})=>e==="warning"?r.colors.primary.bgLight:r.colors.black[100],";color:",({$variant:e,theme:r})=>e==="warning"?r.colors.primary.main:r.colors.secondary.main,";"),sa=v("div",{target:"em2bsj41"})("margin-top:8px;padding:12px;border:1px solid ",({theme:e})=>e.colors.black[300],";border-radius:8px;background:",({theme:e})=>e.colors.chill.panelBg,";"),la=v("div",{target:"em2bsj40"})({name:"1fw1t5q",styles:"display:flex;align-items:flex-end;padding-bottom:2px"}),ca=({fields:e,onChange:r,error:a,disabled:n})=>{const s=re(),p=(o,h)=>r(e.map(l=>l.id===o?{...l,...h}:l));return i("div",{children:[t(xe,{style:{marginBottom:0},children:"Setup Fields"}),i(at,{children:["Every ","{{key}}"," used in the URLs above needs a field here."]}),e.map(o=>i(sa,{children:[i(le,{style:{marginTop:0,gap:12},children:[i(K,{children:[t(R,{htmlFor:`mcp-setup-key-${o.id}`,children:"Key"}),t(j,{id:`mcp-setup-key-${o.id}`,placeholder:"subdomain",value:o.key,onChange:h=>p(o.id,{key:h.target.value}),disabled:n})]}),i(K,{children:[t(R,{htmlFor:`mcp-setup-label-${o.id}`,children:"Label"}),t(j,{id:`mcp-setup-label-${o.id}`,placeholder:"Zendesk subdomain",value:o.label,onChange:h=>p(o.id,{label:h.target.value}),disabled:n})]}),t(la,{children:t(ae,{type:"button","aria-label":"Remove setup field",onClick:()=>r(e.filter(h=>h.id!==o.id)),disabled:n,children:t(B,{src:Ce,size:"18px",tone:"secondary"})})})]}),i(le,{style:{marginTop:12,gap:12},children:[i(K,{children:[t(R,{htmlFor:`mcp-setup-description-${o.id}`,children:"Description"}),t(j,{id:`mcp-setup-description-${o.id}`,placeholder:"Helper text shown under the input",value:o.description,onChange:h=>p(o.id,{description:h.target.value}),disabled:n})]}),i(K,{children:[t(R,{htmlFor:`mcp-setup-placeholder-${o.id}`,children:"Placeholder"}),t(j,{id:`mcp-setup-placeholder-${o.id}`,placeholder:"acme",value:o.placeholder,onChange:h=>p(o.id,{placeholder:h.target.value}),disabled:n})]})]}),i(rt,{style:{marginTop:12},children:[t(Xt,{type:"checkbox",checked:o.required!==!1,onChange:h=>p(o.id,{required:h.target.checked}),disabled:n}),"Required"]})]},o.id)),a&&t(Y,{children:a}),t("div",{style:{marginTop:8},children:i(oe,{type:"button",onClick:()=>r([...e,Jn()]),disabled:n,children:[t(B,{src:De,size:"16px",color:s.colors.primary.main}),"Add setup field"]})})]})},da=v("div",{target:"e13nvhwo5"})({name:"1ko91nu",styles:"display:flex;align-items:center;justify-content:space-between;gap:8px"}),pa=v(oe,{target:"e13nvhwo4"})({name:"miue9w",styles:"padding:4px 10px;font-size:12px"}),ua=v("div",{target:"e13nvhwo3"})("margin-top:8px;padding:12px 16px 16px;border:1px solid ",({theme:e})=>e.colors.black[200],";border-radius:8px;background:",({theme:e})=>e.colors.black[50],";"),ha=v("div",{target:"e13nvhwo2"})("display:flex;flex-direction:column;gap:2px;padding:10px 12px;margin-bottom:12px;border:1px solid ",({theme:e})=>e.colors.primary.main,";border-radius:8px;background:",({theme:e})=>e.colors.primary.bgLight,";"),ge=v("div",{target:"e13nvhwo1"})({name:"xda5ep",styles:"margin-top:12px"}),ga=v(le,{target:"e13nvhwo0"})({name:"d7no16",styles:"margin-top:12px;gap:12px"}),ma={streamable_http:"Streamable HTTP",sse:"SSE"},fa=({values:e,onChange:r,errors:a,disabled:n})=>{const s=(o,h)=>r({...e,[o]:h}),p=o=>r(o==="oauth2"?{...e,authType:o}:{...e,authType:o,oauthAuthorizationUrl:"",oauthTokenUrl:""});return i(ua,{children:[i(da,{children:[t(xe,{children:"MCP Server"}),t(pa,{type:"button",onClick:()=>
3r(et()),disabled:n,children:"Clear MCP block"})]}),i(ha,{children:[i(rt,{children:[t(nt,{type:"checkbox",checked:e.enabled,onChange:o=>s("enabled",o.target.checked),disabled:n}),"MCP enabled"]}),t(at,{children:"Only when enabled does this provider connect through MCP instead of its HTTP templates."})]}),i("div",{children:[t(R,{htmlFor:"mcp-url",children:"MCP URL"}),t(j,{id:"mcp-url",placeholder:"https://mcp.example.com/mcp",$error:!!a.url,value:e.url,onChange:o=>s("url",o.target.value),disabled:n}),a.url&&t(Y,{children:a.url})]}),i(ga,{children:[i(Ve,{$width:170,children:[t(R,{htmlFor:"mcp-transport-type",children:"Transport"}),i(be,{id:"mcp-transport-type",value:e.transportType,onChange:o=>s("transportType",o.target.value),disabled:n,children:[t("option",{value:"",children:"Server default"}),Wn.map(o=>t("option",{value:o,children:ma[o]},o))]})]}),i(K,{children:[t(R,{htmlFor:"mcp-auth-type",children:"Auth Type"}),t(be,{id:"mcp-auth-type",value:e.authType,onChange:o=>p(o.target.value),disabled:n,children:Hn.map(o=>t("option",{value:o,children:Ot(o)},o))})]})]}),i(ge,{children:[t(R,{htmlFor:"mcp-auth-scopes",children:"Auth Scopes"}),t($e,{id:"mcp-auth-scopes",rows:3,placeholder:"One scope per line",value:e.authScopes,onChange:o=>s("authScopes",o.target.value),disabled:n})]}),e.authType==="oauth2"&&i(He,{children:[i(ge,{children:[t(R,{htmlFor:"mcp-oauth-authorization-url",children:"OAuth Authorization URL"}),t(j,{id:"mcp-oauth-authorization-url",placeholder:"https://provider.com/oauth/authorize",$error:!!a.oauthAuthorizationUrl,value:e.oauthAuthorizationUrl,onChange:o=>s("oauthAuthorizationUrl",o.target.value),disabled:n}),a.oauthAuthorizationUrl&&t(Y,{children:a.oauthAuthorizationUrl})]}),i(ge,{children:[t(R,{htmlFor:"mcp-oauth-token-url",children:"OAuth Token URL"}),t(j,{id:"mcp-oauth-token-url",placeholder:"https://provider.com/oauth/token",$error:!!a.oauthTokenUrl,value:e.oauthTokenUrl,onChange:o=>s("oauthTokenUrl",o.target.value),disabled:n}),a.oauthTokenUrl&&t(Y,{children:a.oauthTokenUrl})]})]}),t(ge,{children:t(ca,{fields:e.setupFields,onChange:o=>s("setupFields",o),error:a.setupFields,disabled:n})}),i(ge,{children:[t(R,{htmlFor:"mcp-setup-guide",children:"Setup Guide (JSON)"}),t($e,{id:"mcp-setup-guide",rows:6,placeholder:`{
4  "estimatedMinutes": 5,
5  "steps": [{ "title": "Open OAuth clients" }]
6}`,value:e.setupGuide,onChange:o=>s("setupGuide",o.target.value),disabled:n}),a.setupGuide&&t(Y,{children:a.setupGuide})]})]})},ya=v("div",{target:"e6qj09f2"})({name:"1ysj5zb",styles:"display:flex;align-items:center;gap:8px;margin-top:16px"}),va=v("img",{target:"e6qj09f1"})({name:"1g9coqo",styles:"width:32px;height:32px;object-fit:contain;border-radius:4px"}),ba=v("span",{target:"e6qj09f0"})("font-size:12px;color:",({theme:e})=>e.colors.secondary.main,";"),xa=({open:e,onClose:r,onSave:a,group:n,isLoading:s})=>{const[p,o]=u.useState(void 0),[h,l]=u.useState(et),[m,x]=u.useState({}),[_,b]=u.useState(!1),k=u.useRef(null),{register:w,handleSubmit:y,reset:f,formState:{isValid:c,errors:g}}=Ut({mode:"onChange"}),d=s||_;u.useEffect(()=>{e&&(f({name:(n==null?void 0:n.name)??"",description:(n==null?void 0:n.description)??"",instructionUrl:(n==null?void 0:n.instruction_url)??""}),o(void 0),l(Kn(n==null?void 0:n.mcp)),x({}))},[e,n,f]);const C=O=>{const I=ra(h);if(!I.ok){x(I.errors);return}x({});const S={name:O.name,icon_url:p,description:O.description||void 0,instruction_url:O.instructionUrl||void 0,mcp:I.value??void 0};a(n?{...S,mcp:I.value}:S)},T=async O=>{var S;const I=(S=O.target.files)==null?void 0:S[0];if(I){try{b(!0);const{url:F}=await Tt({file:I,metadata:{bucket:Le}});o(F)}catch{$.error({title:"Failed to upload image. Please try again."}),o(void 0)}finally{b(!1)}O.target.value=""}},z=()=>{o(void 0)},A=p?Pt(Je,p):void 0;return t(_t,{open:e,onClose:r,width:"560px",children:i("form",{onSubmit:y(C),children:[t(Yt,{children:n?"Edit Group":"Create Group"}),i(Kt,{children:[i(me,{children:[t(R,{htmlFor:"group-name",children:"Group Name"}),t(j,{id:"group-name",placeholder:"e.g., Google, Slack, HubSpot",...w("name",{required:!0})})]}),i(me,{children:[t(R,{htmlFor:"group-description",children:"Description"}),t(j,{id:"group-description",placeholder:"Brief description of this integration group",...w("description")})]}),i(me,{children:[t(R,{htmlFor:"group-instruction-url",children:"Instruction URL"}),t(j,{id:"group-instruction-url",placeholder:"https://docs.example.com/setup-guide",$error:!!g.instructionUrl,...w("instructionUrl",{val
6idate:O=>!O||O.startsWith("http://")||O.startsWith("https://")?!0:"Must start with http:// or https://"})}),g.instructionUrl&&t(Y,{children:g.instructionUrl.message})]}),i(ya,{children:[A?i("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t(va,{src:A,alt:"Icon preview",onError:()=>{}}),t(ae,{type:"button","aria-label":"Remove icon",onClick:z,disabled:d,children:t(B,{src:Ce,size:"20px",tone:"secondary"})})]}):t(ba,{children:"No icon uploaded"}),t("input",{ref:k,type:"file",accept:"image/*",onChange:T,style:{display:"none"}}),t(oe,{type:"button",disabled:d,onClick:()=>{var O;return(O=k.current)==null?void 0:O.click()},children:_?t(_e,{size:"size-20","aria-label":"Uploading"}):"Upload icon"})]}),t(fa,{values:h,onChange:O=>{l(O),x({})},errors:m,disabled:d})]}),i(Zt,{children:[t(oe,{type:"button",onClick:r,disabled:d,children:"Cancel"}),t(tt,{type:"submit",disabled:d||!c,children:s?t(_e,{size:"size-24","aria-label":"Saving"}):n?"Update":"Create"})]})]})})},er="/v0.1309.0/assets/Edit-DEgmFw1s.svg",Ca="/v0.1309.0/assets/Expand-Cq9KJoL3.svg",ka=v("ul",{target:"ezj9gp15"})({name:"z06qs",styles:"list-style:none;margin:0;padding:0"}),wa=v("li",{target:"ezj9gp14"})("display:flex;align-items:center;justify-content:space-between;padding:12px 0;border-bottom:1px solid ",({theme:e})=>e.colors.black[200],";gap:16px;&:last-child{border-bottom:none;}"),Sa=v("div",{target:"ezj9gp13"})({name:"fxp7t8",styles:"flex:1;min-width:0"}),Ta=v("div",{target:"ezj9gp12"})("display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:",({theme:e})=>e.colors.black.main,";"),_a=v("div",{target:"ezj9gp11"})("font-size:12px;color:",({theme:e})=>e.colors.secondary.main,";margin-top:2px;"),Ia=v("div",{target:"ezj9gp10"})({name:"197tvr9",styles:"display:flex;gap:8px;align-items:center"}),Oa=({templates:e,groupId:r,onEdit:a,onDelete:n,onToggleEnabled:s,isUpdating:p})=>{const o=re();return t(ka,{children:e.map(h=>i(wa,{children:[i(Sa,{children:[i(Ta,{children:[t("span",{children:h.name}),!h.enabled&&t(Qt,{$variant:"warning",children:"Disabled"})]}),h.description&&t(_a,{children:h.description})]}),i(Ia,{children:[t("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"}
6,children:t(na,{type:"checkbox",checked:h.enabled,onChange:()=>s(h),disabled:p})}),t(ae,{type:"button","aria-label":"Edit template",onClick:()=>a(h),children:t(B,{src:er,size:"18px",tone:"secondary"})}),t(ae,{type:"button","aria-label":"Delete template",onClick:()=>n(r,h.id),children:t(B,{src:Ce,size:"18px",color:o.colors.error[750]})})]})]},h.id))})},Aa=v("div",{target:"e1la4pv39"})("margin-bottom:8px;border:1px solid ",({theme:e})=>e.colors.black[200],";border-radius:8px;overflow:hidden;"),Da=v("button",{target:"e1la4pv38"})("width:100%;display:flex;align-items:center;padding:12px 16px;background:",({theme:e})=>e.colors.chill.panelBg,";color:",({theme:e})=>e.colors.secondary.main,";border:none;cursor:pointer;font-size:14px;font-family:inherit;text-align:left;&:hover{background:",({theme:e})=>e.colors.black[50],";}"),za=v("div",{target:"e1la4pv37"})({name:"ytxwrz",styles:"display:flex;align-items:center;width:100%;padding-right:16px"}),Pa=v("img",{target:"e1la4pv36"})({name:"1yjbmqi",styles:"width:24px;height:24px;margin-right:12px;object-fit:contain"}),Fa=v("span",{target:"e1la4pv35"})({name:"82a6rk",styles:"flex:1"}),Ua=v("span",{target:"e1la4pv34"})("display:inline-flex;transition:transform 0.2s;transform:",({$open:e})=>e?"rotate(180deg)":"rotate(0)",";"),Ea=v("div",{target:"e1la4pv33"})({name:"9gxvqt",styles:"display:flex;gap:4px;align-items:center"}),Ra=v("div",{target:"e1la4pv32"})("padding:0 16px 16px;border-top:1px solid ",({theme:e})=>e.colors.black[200],";"),Ma=v("div",{target:"e1la4pv31"})({name:"1ssarhz",styles:"display:flex;justify-content:flex-end;margin-bottom:8px;padding-top:12px"}),La=v("div",{target:"e1la4pv30"})("text-align:center;padding:24px;font-size:14px;color:",({theme:e})=>e.colors.secondary.main,";"),ja=({group:e,onEdit:r,onDelete:a,onAddTemplate:n,onEditTemplate:s,onDeleteTemplate:p,onToggleEnabled:o,isUpdatingTemplate:h,isCreatingTemplate:l})=>{const m=re(),[x,_]=u.useState(!1),b=Hr(Je,e.icon_url);return i(Aa,{children:[t(Da,{onClick:()=>_(k=>!k),children:i(za,{children:[b&&t(Pa,{src:b,alt:e.name}),t(Fa,{children:e.name}),i(Qt,{style:{marginRight:12},children:[e.templates.length," template",e.templates.length!==1?"s":""]}),i(Ea,{onClick:k=>k.stopPropagation(),children:[t(ae,{type:"button","aria-label":"Edit group",onClick:()=>r(e),children:t(B,{src:er,size:"18px",tone:"secondary"})}),t(ae,{type:"button","aria-label":"Delete group",onClick:()=>a(e.id),children:t(B,{src:Ce,size:"18px",color:m.colors.error[750]})})]}),t(Ua,{$open:x,children:t(B,{src:Ca,size:"20px",tone:"secondary"})})]})}),x&&i(Ra,{children:[t(Ma,{children:i(oe,{type:"button",onClick:()=>n(e.id),disabled:l,children:[t(B,{src:De,size:"16px",color:m.colors.primary.main}),"Add Template"]})}),e.templates.length===0?t(La,{children:"No templates in this group"}):t(Oa,{templates:e.templates,groupId:e.id,onEdit:s,onDelete:p,onToggleEnabled:o,isUpdating:h})]})]})},tr=["string","number","integer","boolean","array","object"],rr=e=>({properties:e.type==="object"&&e.properties?nr(e.properties,e.required):void 0,items:e.type==="array"&&e.items?Ga(e.items):void 0}),Ga=e=>({type:e.type??"string",description:e.description??"",...rr(e)}),nr=(e,r=[])=>Object.entries(e).map(([a,n])=>({_id:Math.random().toString(36).slice(2),name:a,type:n.type??"string",description:n.description??"",required:r.includes(a),...rr(n)})),$a=e=>{var a,n;const r=(a=e==null?void 0:e.parameters)==null?void 0:a.properties;return r?nr(r,((n=e==null?void 0:e.parameters)==null?void 0:n.required)??[]):[]},ar=e=>{var a;const r={type:e.type};if(e.description.trim()&&(r.description=e.description.trim()),e.type==="object"&&((a=e.properties)!=null&&a.length)){const n=or(e.properties);r.properties=n.properties,n.required.length&&(r.required=n.required),r.additionalProperties=!1}return e.type==="array"&&e.items&&(r.items=ar(e.items)),r},or=e=>{const r=e.filter(a=>a.name.trim());return{properties:Object.fromEntries(r.map(a=>[a.name.trim(),ar(a)])),required:r.filter(a=>a.required).map(a=>a.name.trim())}},Va=e=>({parameters:{type:"object",...or(e),additionalProperties:!1}}),ir=e=>e==="object"?{properties:[],items:void 0}:e==="array"?{items:{type:"string",description:""},properties:void 0}:{properties:void 0,items:void 0},sr=(e,r,a)=>{var n,s;for(const p of e){const o=p.name.trim();if(!o)continue;const h=r?`${r}.${o}`:o,l=(n=p.label)==null?void 0:n.trim();l&&(a[h]={label:l}
6),p.type==="object"&&((s=p.properties)!=null&&s.length)&&sr(p.properties,h,a)}},Ba=e=>{const r={};return sr(e,"",r),Object.keys(r).length===0?void 0:r},lr=(e,r,a)=>{var n;for(const s of e){const p=r?`${r}.${s.name}`:s.name,o=a[p];o!=null&&o.label&&(s.label=o.label),s.type==="object"&&((n=s.properties)!=null&&n.length)&&lr(s.properties,p,a)}},Na=(e,r)=>{!r||Object.keys(r).length===0||lr(e,"",r)},ke=v(j,{target:"e1rwcv5m2"})({name:"w0ucn",styles:"padding:6px 10px;font-size:13px"}),cr=v(be,{target:"e1rwcv5m1"})({name:"1v6gab8",styles:"padding:6px 10px;font-size:13px;min-width:100px"}),dr=v("div",{target:"e1rwcv5m0"})("display:flex;flex-direction:column;gap:8px;margin-top:8px;margin-left:16px;padding:12px;border:1px solid ",({theme:e})=>e.colors.black[300],";border-radius:8px;background:",({theme:e})=>e.colors.black[50],";"),qa=v("div",{target:"e177qxh11"})({name:"1mg4cuz",styles:"display:flex;gap:8px;align-items:end"}),pr=({items:e,onChange:r,disabled:a})=>i(dr,{children:[t(xe,{style:{margin:0},children:"Array Items"}),i(qa,{children:[t("div",{style:{minWidth:100},children:t(cr,{value:e.type,onChange:n=>{const s=n.target.value;r({...e,...ir(s),type:s})},disabled:a,children:tr.map(n=>t("option",{value:n,children:n},n))})}),t("div",{style:{flex:1},children:t(ke,{value:e.description,onChange:n=>r({...e,description:n.target.value}),placeholder:"Description of array items",disabled:a})})]}),e.type==="object"&&t(ot,{parameters:e.properties??[],onChange:n=>r({...e,properties:n}),disabled:a}),e.type==="array"&&e.items&&t(pr,{items:e.items,onChange:n=>r({...e,items:n}),disabled:a})]}),Wa=v("div",{target:"e177qxh10"})({name:"hkh81z",styles:"margin-top:8px"}),ot=({parameters:e,onChange:r,disabled:a})=>{const n=re(),s=u.useId(),p=()=>{r([...e,{_id:Math.random().toString(36).slice(2),name:"",type:"string",description:"",required:!1}])},o=(l,m)=>{r(e.map(x=>x._id===l?{...x,...m}:x))},h=l=>{r(e.filter(m=>m._id!==l))};return i("div",{children:[t(xe,{children:"Parameters"}),e.length>0&&i(aa,{children:[t(oa,{children:i(vt,{children:[t(se,{style:{width:"20%"},children:"Name"}),t(se,{style:{width:"15%"},children:"Type"}),t(se,{style:{width:"20%"},children:"Label"}),t(se,{children:"Description"}),t(se,{style:{textAlign:"center",width:80},children:"Required"}),t(se,{style:{width:40}})]})}),t(ia,{children:e.map(l=>i(wt.Fragment,{children:[i(vt,{children:[t(ee,{style:{width:"20%"},children:t(ke,{value:l.name,onChange:m=>o(l._id,{name:m.target.value}),placeholder:"param_name",disabled:a,id:`${s}-name-${l._id}`})}),t(ee,{style:{width:"15%"},children:t(cr,{value:l.type,onChange:m=>{const x=m.target.value;o(l._id,{type:x,...ir(x)})},disabled:a,id:`${s}-type-${l._id}`,children:tr.map(m=>t("option",{value:m,children:m},m))})}),t(ee,{style:{width:"20%"},children:t(ke,{value:l.label??"",onChange:m=>o(l._id,{label:m.target.value}),placeholder:"Friendly label",disabled:a,id:`${s}-label-${l._id}`})}),t(ee,{children:t(ke,{value:l.description,onChange:m=>o(l._id,{description:m.target.value}),placeholder:"What this parameter does",disabled:a})}),t(ee,{style:{textAlign:"center",width:80},children:t("label",{title:l.required?"Required":"Optional",style:{display:"inline-flex",cursor:"pointer"},children:t(Xt,{type:"checkbox",checked:l.required,onChange:m=>o(l._id,{required:m.target.checked}),disabled:a})})}),t(ee,{style:{paddingRight:0},children:t(ae,{type:"button",title:"Remove parameter",onClick:()=>h(l._id),disabled:a,children:t(B,{src:Ce,size:"18px",tone:"secondary"})})})]}),l.type==="object"&&t("tr",{children:t(ee,{colSpan:6,style:{paddingTop:0},children:i(dr,{children:[i(xe,{style:{margin:0},children:["Properties of “",l.name||"…","”"]}),t(ot,{parameters:l.properties??[],onChange:m=>o(l._id,{properties:m}),disabled:a})]})})}),l.type==="array"&&t("tr",{children:t(ee,{colSpan:6,style:{paddingTop:0},children:t(pr,{items:l.items??{type:"string",description:""},onChange:m=>o(l._id,{items:m}),disabled:a})})})]},l._id))})]}),e.length===0&&t(at,{style:{display:"block",marginBottom:8},children:"No parameters defined. This tool will be called without any parameters."}),t(Wa,{children:i(oe,{type:"button",onClick:p,disabled:a,children:[t(B,{src:De,size:"16px",color:n.colors.primary.main}),"Add parameter"]})})]})},Ha=["GET","POST","PUT","DELETE","PATCH"],Ja=["none","bearer","api_key","basic","oauth2"],Ya=/^[a-zA-Z0-9_-]+$/,Ka=({open:e,onClose:r,onSave:a,template:n,isLoading:s,siblingTemplates:p=[]})=>{const[o,h]=u.useState([]),{register:l,handleSubmit:m,reset:x,watch:_,formState:{errors:b,isValid:k}}=Ut({mode:"onChange"}),w=_("authType");u.useEffect(()=>{var c,g;if(e){const d=p.find(I=>I.auth_type&&I.auth_type!=="none"),C=(n==null?void 0:n.auth_type)??(d==null?void 0:d.auth_type)??"none",T=(n==null?void 0:n.auth_scopes)??(d==null?void 0:d.auth_scopes),z=(n==null?void 0:n.oauth_authorization_url)??(d==null?void 0:d.oauth_authorization_url)??"",A=(n==null?void 0:n.oauth_token_url)??(d==null?void 0:d.oauth_token_url)??"";x({name:(n==null?void 0:n.name)??"",description:(n==null?void 0:n.description)??"",url:(((c=n==null?void 0:n.config)==null?void 0:c.type)==="server"?n.config.url:void 0)??"",method:(((g=n==null?void 0:n.config)==null?void 0:g.type)==="server"?n.config.method:void 0)??"GET",authType:C,authScopes:(T==null?void 0:T.join(", "))??"",oauthAuthorizationUrl:z,oauthTokenUrl:A,enabled:(n==null?void 0:n.enabled)??!1});const O=n!=null&&n.schema?$a(n.schema):[];Na(O,n==null?void 0:n.params_metadata),h(O)}}
6,[e,n,p,x]);const y=c=>{var d;const g={name:c.name,description:c.description||void 0,config:((d=n==null?void 0:n.config)==null?void 0:d.type)==="client"?n.config:{type:"server",url:c.url,method:c.method},auth_type:c.authType!=="none"?c.authType:void 0,auth_scopes:c.authType==="oauth2"&&c.authScopes?c.authScopes.split(",").map(C=>C.trim()).filter(Boolean):void 0,oauth_authorization_url:c.authType==="oauth2"&&c.oauthAuthorizationUrl?c.oauthAuthorizationUrl:void 0,oauth_token_url:c.authType==="oauth2"&&c.oauthTokenUrl?c.oauthTokenUrl:void 0,schema:Va(o),params_metadata:Ba(o),enabled:c.enabled};a(g)},f=!!n;return t(_t,{open:e,onClose:r,children:i("form",{onSubmit:m(y),children:[t(Yt,{children:f?"Edit Template":"Create Template"}),i(Kt,{children:[i(me,{children:[t(R,{htmlFor:"template-name",children:"Template Name"}),t(j,{id:"template-name",$error:!!b.name,placeholder:"e.g., get_calendar_events",...l("name",{required:"Name is required",pattern:{value:Ya,message:"Only letters, numbers, underscores and hyphens allowed (no spaces)"}})}),b.name&&t(Y,{children:b.name.message})]}),i(me,{children:[t(R,{htmlFor:"template-desc",children:"Description"}),t($e,{id:"template-desc",rows:2,placeholder:"Describe what this tool does for the LLM",...l("description")})]}),i(le,{children:[i(Ve,{$width:120,children:[t(R,{htmlFor:"template-method",children:"Method"}),t(be,{id:"template-method",...l("method"),children:Ha.map(c=>t("option",{value:c,children:c},c))})]}),i(K,{children:[t(R,{htmlFor:"template-url",children:"API URL"}),t(j,{id:"template-url",$error:!!b.url,placeholder:"https://api.example.com/endpoint",...l("url",{required:"URL is required"})}),b.url&&t(Y,{children:b.url.message})]})]}),i(le,{children:[i(Ve,{$width:150,children:[t(R,{htmlFor:"template-auth",children:"Auth Type"}),t(be,{id:"template-auth",...l("authType"),children:Ja.map(c=>t("option",{value:c,children:Ot(c)},c))})]}),w==="oauth2"&&i(K,{children:[t(R,{htmlFor:"template-scopes",children:"OAuth Scopes"}),t(j,{id:"template-scopes",placeholder:"scope1, scope2, scope3",...l("authScopes")}),t(Y,{as:"span",style:{color:"#707070"},children:"Comma-separated list of OAuth scopes"})]})]}),w==="oauth2"&&i(le,{children:[i(K,{children:[t(R,{htmlFor:"template-oauth-auth-url",children:"Authorization URL"}),t(j,{id:"template-oauth-auth-url",placeholder:"https://provider.com/oauth/authorize",...l("oauthAuthorizationUrl")})]}),i(K,{children:[t(R,{htmlFor:"template-oauth-token-url",children:"Token URL"}),t(j,{id:"template-oauth-token-url",placeholder:"https://provider.com/oauth/token",...l("oauthTokenUrl")})]})]}),t("div",{style:{marginTop:24},children:t(ot,{parameters:o,onChange:h,disabled:s})}),i(rt,{style:{marginTop:16},children:[t(nt,{type:"checkbox",...l("enabled")}),"Enabled (visible to users)"]})]}),i(Zt,{children:[t(oe,{type:"button",onClick:r,disabled:s,children:"Cancel"}),t(tt,{type:"submit",disabled:s||!k,children:s?t(_e,{size:"size-24","aria-label":"Saving"}):f?"Update":"Create"})]})]})})},ur=u.createContext(null),Za=()=>{const e=u.useContext(ur);if(!e)throw new Error("useToolTemplatesContext must be used within ToolTemplatesProvider");return e},Xa=({children:e})=>{var it;const{data:r,isLoading:a}=Lr(!0),{mutateAsync:n,isLoading:s}=jr(),{mutateAsync:p,isLoading:o}=Gr(),{mutateAsync:h,isLoading:l}=$r(),{mutateAsync:m,isLoading:x}=Vr(),{mutateAsync:_,isLoading:b}=Br(),{mutateAsync:k,isLoading:w}=Nr(),[y,f]=u.useState(!1),[c,g]=u.useState(null),[d,C]=u.useState(!1),[T,z]=u.useState(null),[A,O]=u.useState(null),[I,S]=u.useState(!1),[F,L]=u.useState(null),N=(r==null?void 0:r.groups)??[],H=((it=N.find(E=>E.id===A))==null?void 0:it.templates)??[],ze=()=>{g(null),f(!0)},ce=E=>{g(E),f(!0)},Pe=async E=>{try{c?await p({groupId:c.id,data:E}):await n(E),f(!1),g(null)}catch(de){console.error("Failed to save group:",de)}},hr=E=>{L({type:"group",id:E}),S(!0)},gr=E=>{O(E),z(null),C(!0)},mr=E=>{O(E.group_id),z(E),C(!0)},fr=async E=>{if(A)try{T?await _({groupId:A,templateId:T.id,data:E}):await m({groupId:A,data:E}),C(!1),z(null),O(null)}catch(de){console.error("Failed to save template:",de)}},yr=(E,de)=>{L({type:"template",id:de,groupId:E}),S(!0)},vr=async E=>{try{await _({groupId:E.group_id,templateId:E.id,data:{enabled:!E.enabled}})}catch{$.error({title:"Failed to toggle template status"})}},br=async()=>
6{if(F)try{F.type==="group"?await h(F.id):F.groupId&&await k({groupId:F.groupId,templateId:F.id}),S(!1),L(null)}catch(E){console.error("Failed to delete:",E)}},xr=()=>{f(!1),g(null)},Cr=()=>{C(!1),z(null),O(null)},kr=()=>{S(!1),L(null)};return t(ur.Provider,{value:{groups:N,isLoading:a,groupDialogOpen:y,editingGroup:c,templateDialogOpen:d,editingTemplate:T,selectedGroupId:A,selectedGroupTemplates:H,deleteConfirmOpen:I,itemToDelete:F,isCreatingGroup:s,isUpdatingGroup:o,isCreatingTemplate:x,isUpdatingTemplate:b,isDeletingGroup:l,isDeletingTemplate:w,handleCreateGroup:ze,handleEditGroup:ce,handleSaveGroup:Pe,handleDeleteGroup:hr,handleCreateTemplate:gr,handleEditTemplate:mr,handleSaveTemplate:fr,handleDeleteTemplate:yr,handleToggleEnabled:vr,confirmDelete:br,closeGroupDialog:xr,closeTemplateDialog:Cr,closeDeleteConfirm:kr},children:e})},Qa=v("div",{target:"e1pdoihh4"})({name:"2ptt9o",styles:"display:flex;justify-content:space-between;align-items:center;margin-bottom:16px"}),eo=v("div",{target:"e1pdoihh3"})({name:"1fttcpj",styles:"display:flex;flex-direction:column"}),to=v("div",{target:"e1pdoihh2"})({name:"o9v1p9",styles:"display:flex;justify-content:center;padding:32px 0"}),ro=v("span",{target:"e1pdoihh1"})("font-size:14px;color:",({theme:e})=>e.colors.secondary.main,";"),no=v("div",{target:"e1pdoihh0"})("text-align:center;padding:32px;font-size:14px;color:",({theme:e})=>e.colors.secondary.main,";"),ao=()=>{var a,n;const e=Za(),r=re();return e.isLoading?t(to,{children:t(_e,{size:"size-20","aria-label":"Loading"})}):i(eo,{children:[i(Qa,{children:[i(ro,{children:[e.groups.length," group",e.groups.length!==1?"s":""," total"]}),i(tt,{type:"button",onClick:e.handleCreateGroup,disabled:e.isCreatingGroup,children:[t(B,{src:De,size:"16px",color:r.colors.black.main}),"Add Group"]})]}),e.groups.length===0?t(no,{children:"No template groups yet. Create one to get started."}):e.groups.map(s=>t(ja,{group:s,onEdit:e.handleEditGroup,onDelete:e.handleDeleteGroup,onAddTemplate:e.handleCreateTemplate,onEditTemplate:e.handleEditTemplate,onDeleteTemplate:e.handleDeleteTemplate,onToggleEnabled:e.handleToggleEnabled,isUpdatingTemplate:e.isUpdatingTemplate,isCreatingTemplate:e.isCreatingTemplate},s.id)),t(xa,{open:e.groupDialogOpen,onClose:e.closeGroupDialog,onSave:e.handleSaveGroup,group:e.editingGroup,isLoading:e.isCreatingGroup||e.isUpdatingGroup}),t(Ka,{open:e.templateDialogOpen,onClose:e.closeTemplateDialog,onSave:e.handleSaveTemplate,template:e.editingTemplate,isLoading:e.isCreatingTemplate||e.isUpdatingTemplate,siblingTemplates:e.selectedGroupTemplates}),t(Ft,{open:e.deleteConfirmOpen,onClose:e.closeDeleteConfirm,title:`Delete ${((a=e.itemToDelete)==null?void 0:a.type)==="group"?"Group":"Template"}`,text:((n=e.itemToDelete)==null?void 0:n.type)==="group"?"Are you sure you want to delete this group? All templates in this group will also be deleted.":"Are you sure you want to delete this template?",primaryButtonText:"Delete",secondaryButtonText:"Cancel",onConfirm:e.confirmDelete,onSecondaryClick:e.closeDeleteConfirm,isLoading:e.isDeletingGroup||e.isDeletingTemplate})]})},oo=()=>t(Xa,{children:t(ao,{})}),io=P("form")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1.5)})),so=P(q)(({theme:e})=>({padding:e.spacing(1,2),fontSize:"1.5rem"})),lo=P(D)(({theme:e})=>({marginTop:e.spacing(2),display:"flex",flexDirection:"column",gap:e.spacing(2)})),co=P(ie)(({theme:e})=>({padding:e.spacing(2),display:"flex",alignItems:"center",gap:e.spacing(2)})),po=()=>{const[e,r]=u.useState(""),[a,n]=u.useState([]),[s,p]=u.useState(!1),[o,h]=u.useState(!1),[l,m]=u.useState(""),[x,_]=u.useState(!1),[b,k]=u.useState(null),[w,y]=u.useState(""),[f,c]=u.useState(""),[g,d]=u.useState(!1),C=async I=>{I.preventDefault(),p(!0),m(""),n([]),_(!0);try{if(!e){m("Please enter a valid owner ID");return}const S=await ft(e);n(S)}catch{m("Failed to fetch voices. Please check the owner ID and try again.")}finally{p(!1)}},T=async I=>{if(f&&f!==e){d(!0);return}await z(I)},z=async I=>{h(!0);try{const S={overrideOwnerId:e};w&&(S.name=w),f&&(S.newOwnerId=f),await zn(I,S),$.success({title:"Voice updated successfully"});const F=await ft(e);n(F),k(null),y(""),c("")}catch{$.error({title:"Failed to update voice"})}finally{h(!1)}},A=async()=>{b&&(await z(b),d(!1))},O=I=>{k(I.id),y(I.name)};return i(D,{children:[i(io,{onSubmit:C,children:[t(M,{label:"Owner ID",value:e,onCh
6ange:I=>r(I.target.value),fullWidth:!0,required:!0}),t(so,{type:"submit",disabled:s,children:s?t(Se,{size:24}):"Fetch Voices"})]}),l&&t(U,{variant:"body",color:"error",style:{marginTop:16},children:l}),!s&&x&&a.length===0&&t(U,{variant:"body",align:"center",color:"muted",style:{marginTop:16},children:"No voices found for this owner ID"}),t(lo,{children:a.map(I=>i(co,{children:[i(D,{sx:{flex:1},children:[t(U,{variant:"caption",as:"h6",weight:700,children:I.name}),i(U,{variant:"body-sm",color:"muted",children:["Voice ID: ",I.id]})]}),b===I.id?i(D,{sx:{display:"flex",gap:2},children:[t(M,{label:"New Name",value:w,onChange:S=>y(S.target.value),size:"small"}),t(M,{label:"New Owner ID",value:f,onChange:S=>c(S.target.value),size:"small"}),t(q,{onClick:()=>T(I.id),disabled:o,children:o?t(Se,{size:24}):"Save"}),t(q,{onClick:()=>{k(null),y(""),c("")},disabled:o,children:"Cancel"})]}):t(q,{onClick:()=>O(I),children:"Edit"})]},I.id))}),t(Ft,{open:g,onClose:()=>{d(!1)},title:"Change Voice Owner",text:"Are you sure you want to change the voice owner? This will remove the voice from the current owner.",primaryButtonText:"Yes, change owner",secondaryButtonText:"Cancel",onConfirm:A,onSecondaryClick:()=>{d(!1)},isLoading:o})]})},uo=P(Jr)(({theme:e})=>({paddingTop:e.spacing(4),paddingBottom:e.spacing(4)})),J=P(ie)(({theme:e})=>({padding:e.spacing(3),height:"100%",display:"flex",flexDirection:"column",transition:"box-shadow 0.3s ease-in-out",color:e.palette.text.primary,backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.divider}`,boxShadow:e.palette.mode==="dark"?"none":e.shadows[2],"&:hover":{boxShadow:e.palette.mode==="dark"?"none":e.shadows[4]}})),Ao=()=>{const e=Me("backoffice_is_enabled",!1),r=Rr(),a=re(),n={marginBottom:32,color:a.colors.primary.main},s={marginBottom:24,paddingBottom:8,borderBottom:`2px solid ${a.colors.primary.main}`};return u.useEffect(()=>{e||r(ct.Home)},[]),i(uo,{maxWidth:"lg",children:[t(U,{variant:"title",as:"h1",style:n,children:"Backoffice"}),i(W,{container:!0,spacing:4,children:[t(W,{item:!0,xs:12,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Agent Variant Playground"}),t(U,{variant:"body",style:{marginBottom:24},children:"Test Fabio and Full embeds across agent versions, themes, layouts, and viewport sizes without publishing a share page."}),t(Mr,{variant:"contained",onClick:()=>r(ct.BackofficeAgentPlayground),sx:{alignSelf:"flex-start"},children:"Open playground"})]})}),t(W,{item:!0,xs:12,md:6,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Organization Management"}),t(Rn,{})]})}),t(W,{item:!0,xs:12,md:6,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Presenter Management"}),t(Vn,{}),t(Gn,{})]})}),t(W,{item:!0,xs:12,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Voice Management"}),t(po,{})]})}),t(W,{item:!0,xs:12,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Agents Avatars Ordering"}),t(_n,{})]})}),t(W,{item:!0,xs:12,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Avatars Ordering for Studio"}),t(In,{})]})}),t(W,{item:!0,xs:12,md:6,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"V4 Presenter Management"}),t(Ln,{})]})}),t(W,{item:!0,xs:12,md:6,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"V4 Voice Management"}),t(Nn,{})]})}),t(W,{item:!0,xs:12,children:i(J,{elevation:2,children:[t(U,{variant:"title-sm",as:"h2",style:s,children:"Tool Templates"}),t(oo,{})]})})]})]})};export{Ao as BackofficePage};

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