1import{u as Q,_ as Z}from"./useDeferredNotificationPanel.Tx8mA6ng.js";import{f as G,q as J,m as K,s as B,k as X,v as k,am as ee,x,r as te,o as b,c as oe,b as o,w as s,n as A,C as ae,h as n,aW as se,fx as le,a3 as ne,g,bg as re,H as w,a as y,t as h,bz as ie,d as S,aZ as ue,aY as ce,M as N,a4 as de,j as me}from"./entry.zWacJm0J.js";import{B as fe,a as _e}from"./index.brBj_up_.js";import{_ as pe}from"./BotSelector.vue.QKtb_92r.js";import{a as ve}from"./branding.sWsq-axH.js";import{B as Be}from"./index.O_uCKy1G.js";import{B as be,a as he}from"./index.r_ptKcrW.js";import{u as ge}from"./title.zs55-qWZ.js";import{a as we}from"./BotCreateModal.vue.UCY97fss.js";import"./index.9saEWeny.js";import"./index.092pZDko.js";import"./index.HW1lKSwA.js";import"./index.H_fF91Kl.js";import"./flowNodeBadges.AVufbeWZ.js";import"./apiError.pIY-JWgJ.js";import"./IconSitemap.0CMCTWaj.js";const ye={class:"overflow-x-hidden"},$e={class:"leading-8 font-size-7"},Ce={class:"rounded-max"},ke={class:"flex justify-end"},Oe=G({__name:"build",setup(Ae){const{getTitle:W}=ge(),d=J(),t=K(),m=B(!0),{t:u}=X(),_=B(!1),f=B(!1),$=B(!1),V=Q(),D=k(()=>t.selectedBot&&t.selectedBot.delete_available&&C.value),r=ee(),C=k(()=>r.path.startsWith("/build/")&&!!r.params.id||r.path.startsWith("/ncs-integration")||r.path.startsWith("/tag-manager")),M=k(()=>t.selectedBot&&!t.isAllBotsSelected);x(()=>r.fullPath,()=>{});const z=async a=>{_.value=!1,await t.fetchBots(),t.selectBot(a),A(`/build/${a}?tab=prompt`)},I=B(""),P=async()=>{d.isDevelopmentOrQA&&await d.fetchCurrentAiModel()};x(()=>d.currentAiModel,a=>{I.value=a},{immediate:!0});const R=async()=>{var a;if(t.selectedBot){$.value=!0;try{const e=t.selectedBot.id;if(!Number.isInteger(e)||e<=0){console.error(`[layouts/build] Refusing DELETE with invalid bot id=${String(e)}`),N({type:"error",title:u("common.error"),message:u("common.error_occurred","An error occurred")});return}await de(`/ai/bot/${e}/delete-bot`,{method:"DELETE"}),t.removeBot(e),await t.fetchBots(),t.bots.length>0&&t.selectBot(t.bots[0].id),f.value=!1,N({type:"success",title:u("common.success"),message:u("bot.delete_success","Bot deleted successfully")}),A("/build")}catch(e){const p=(a=e==null?void 0:e.data)==null?void 0:a.detail;let i=p||u("common.error_occurred","An error occurred");p==="You cannot delete the last bot"?i=u("build.cannot_delete_last_bot"):p==="You cannot delete a bot that has chats"&&(i=u("build.cannot_delete_bot_with_chats")),N({type:"error",title:u("common.error"),message:i}),f.value=!1}finally{$.value=!1}}},Y=()=>{t.selectAllBots(),!r.path.startsWith("/tag-manager")&&A("/build")};return te(async()=>{if(await t.fetchBots(),P(),r.path.startsWith("/build/")&&r.params.id){const a=parseInt(r.params.id,10);!isNaN(a)&&t.bots.some(e=>e.id===a)&&t.selectBot(a)}}),(a,e)=>{const p=Z,i=me,c=fe,j=pe,L=ve,O=Be,U=_e,q=he,F=be,H=ae;return b(),oe("main",ye,[o(F,{"off-canvas":m.value,"aside-width":240,class:"h-screen bg-[url(/background-integration.svg)] bg-cover"},{default:s(()=>[o(p,{onSelect:e[0]||(e[0]=l=>m.value=!1)}),o(q,{fluid:"",class:"flex flex-col"},{default:s(()=>[o(U,{items:"center",gutter:3,class:"mb-3 mt--3 max-h-10"},{default:s(()=>{var l,E;return[o(c,{span:"auto",class:"lg-hidden"},{default:s(()=>[o(i,{small:"",icon:m.value?n(se):n(le),class:ne({"shadow-lv1":m.value}),onClick:e[1]||(e[1]=v=>m.value=!m.value)},null,8,["icon","class"])]),_:1}),C.value&&M.value&&((((E=(l=n(d).client)==null?void 0:l.subscription)==null?void 0:E.number_of_bots)??1)>1||n(t).bots.length>1)?(b(),g(c,{key:0,span:"auto"},{default:s(()=>[o(i,{small:"",icon:n(re),onClick:Y},null,8,["icon"])]),_:1})):w("",!0),o(c,{span:"auto"},{default:s(()=>[y("h2",$e,h(n(W)()),1)]),_:1}),o(c,{span:D.value?"auto":"",class:"ml-2"},{default:s(()=>[C.value&&M.value?(b(),g(j,{key:0,"hide-all-bots":!0,"show-add-bot":!0,onAddBot:e[2]||(e[2]=v=>_.value=!0)})):w("",!0)]),_:1},8,["span"]),D.value?(b(),g(c,{key:1},{default:s(()=>[o(i,{type:"danger",icon:n(ie),onClick:e[3]||(e[3]=v=>f.value=!0)},{default:s(()=>[S(h(a.$t("common.delete")),1)]),_:1},8,["icon"])]),_:1})):w("",!0),o(c,{span:"auto"},{default:s(()=>[o(L)]),_:1}),o(c,{span:"auto"},{default:s(()=>{var v,T;return[y("div",Ce,[o(O,{name:(v=n(d).client)==null?void 0:v.company_name,size:32,circle:"",gradient:"","color-id":`${(T=n(d).client)==null?void 0:T.id}`},null,8,["name","color-id"])])]}),_:1}),o(c,{span:"auto"},{default:s(()=>[n(V)?(b(),g(ue(n(V)),{key:0})):w("",!0)]),_:1})]}),_:1}),ce(a.$slots,"default")]),_:3})]),_:3},8,["off-canvas"]),o(we,{modelValue:_.value,"onUpdate:modelValue":e[4]||(e[4]=l=>_.value=l),onClose:e[5]||(e[5]=l=>_.value=!1),onCreated:z},null,8,["modelValue"]),o(H,{center:"",modelValue:f.value,"onUpdate:modelValue":e[7]||
1(e[7]=l=>f.value=l),title:a.$t("bot.delete"),width:"30%"},{footer:s(()=>[y("div",ke,[o(i,{class:"mr-4",onClick:e[6]||(e[6]=l=>f.value=!1)},{default:s(()=>[S(h(a.$t("common.cancel")),1)]),_:1}),o(i,{type:"danger",loading:$.value,onClick:R},{default:s(()=>[S(h(a.$t("common.delete")),1)]),_:1},8,["loading"])])]),default:s(()=>{var l;return[y("span",null,h(a.$t("bot.delete_confirmation",[((l=n(t).selectedBot)==null?void 0:l.bot_name)||"New Bot "])),1)]}),_:1},8,["modelValue","title"])])}}});export{Oe as default};
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.