1import{d as D,p as A,u as t,o as a,c as f,b as s,_ as O,h as n,k as g,j as d,D as P,F as B,L as R,n as F,t as h,i as _,g as I,r as k}from"./DWoMLgDN.js";import{_ as W}from"./CUNLfTjD.js";import{T as q}from"./WANXgjlq.js";import{h as G}from"./6anYa7Iu.js";import{u as H}from"./B0JCXcg-.js";import{c as J}from"./Dw-Uj24J.js";import{a as K}from"./Drk0W1TC.js";import"./X4_0oHS_.js";import"./HXR2AMmp.js";import"./BTD4UE6g.js";import"./CSlJ_9zL.js";import"./dqF8RWaO.js";import"./BRscxTRR.js";import"./_eRyTY9J.js";import"./UA1giBXO.js";import"./BsAe3BJS.js";import"./CwnF8Gx8.js";import"./BYv0og-p.js";import"./VKy1EO7P.js";import"./wvMS2G7S.js";import"./QPwwsyr3.js";import"./BuciMvrQ.js";import"./CkluUQOT.js";import"./BFq03PzK.js";import"./BiB4UA1S.js";import"./BZGoDoHF.js";import"./DVw8_agw.js";import"./HkKMkZcV.js";const Q={key:0,class:"flex justify-center py-8"},X={key:1,class:"space-y-4"},Y={class:"flex justify-end gap-2"},Z={key:2,class:"space-y-4"},ee={class:"space-y-2.5"},te=["onClick"],ne={class:"w-10 h-10 rounded-xl bg-brand-50 dark:bg-brand-950/40 flex items-center justify-center shrink-0"},re={class:"flex-1 min-w-0"},se={class:"block text-sm font-semibold font-mono truncate"},oe={class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-0.5"},ae={class:"flex items-center gap-1.5 shrink-0 text-sm font-semibold text-brand-600 dark:text-brand-300"},le={class:"w-10 h-10 rounded-xl bg-brand-50 dark:bg-brand-950/40 text-brand-600 dark:text-brand-300 flex items-center justify-center shrink-0"},ie={class:"flex justify-end"},de={key:3,class:"space-y-4"},ce={class:"flex items-center gap-3 p-3.5 rounded-2xl border-[1.5px] border-gray-200 dark:border-gray-800"},ue={class:"w-10 h-10 rounded-xl bg-brand-50 dark:bg-brand-950/40 flex items-center justify-center shrink-0"},me={class:"min-w-0"},pe={class:"block text-sm font-semibold font-mono truncate"},fe={class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-0.5"},ge={class:"flex justify-end gap-2"},be={key:4,class:"space-y-4"},ye={class:"flex justify-end gap-2"},xe={key:5,class:"space-y-4"},Je=D({__name:"ChannelTelegramBotWizard",props:{channelType:{},typeInfo:{},projectId:{}},emits:["connected","cancel"],setup(V,{emit:M}){const w=V,b=M,N=H(()=>w.projectId),C=J("telegram_bot"),o=k("loading"),v=k([]),c=k(null),y=k(!1),u=k(""),x=k(!1);function S(r){return r.status==="auth_error"?!1:"usages"in r?!r.usages.some(e=>e.channel_type==="telegram_bot"):r.usage_count===0}function $(r){const e="usages"in r?r.usages.filter(m=>m.channel_type==="telegram_comments").length:0;if(!e)return"Ðока нигде не иÑполÑзÑеÑÑÑ";const l=e%10===1&&e%100!==11?"гÑÑппе":"гÑÑппаÑ
";return`СейÑÐ°Ñ ÑабоÑÐ°ÐµÑ Ð² ${e} ${l}`}async function T(){o.value="loading";try{v.value=(await N.listCards()).filter(S),o.value=v.value.length?"start":"form"}catch{o.value="error"}}A(T);function E(r){c.value=r,u.value="",x.value=!1,o.value="bind"}function L(){u.value="",x.value=!1,o.value="form"}function U(){v.value.length?o.value="start":b("cancel")}function z(r){const e=G(r);return e===402?{message:"ÐиÑнÑе ÑообÑÐµÐ½Ð¸Ñ Ð½Ðµ вклÑÑенÑ: доÑÑигнÑÑ Ð»Ð¸Ð¼Ð¸Ñ ÐºÐ°Ð½Ð°Ð»Ð¾Ð² ÑаÑиÑа. Ðогда Ð»Ð¸Ð¼Ð¸Ñ Ð¿Ð¾Ð·Ð²Ð¾Ð»Ð¸Ñ, пÑивÑжиÑе боÑа Ñо ÑÑаÑÑового ÑкÑана â без Ñокена.",retriable:!1}:e===409?{message:"ÐиÑнÑе ÑообÑÐµÐ½Ð¸Ñ ÑÑого боÑа Ñже подклÑÑÐµÐ½Ñ â ÑообÑÐµÐ½Ð¸Ñ Ñже пÑиÑ
одÑÑ Ð² ÑаÑ.",retriable:!1}:e===502?{message:"Telegram не оÑвеÑил пÑи вклÑÑении канала. ÐовÑоÑиÑе â вÑÑ ÑоÑ
Ñанено.",retriable:!0}:{message:K(r,"Ðе ÑдалоÑÑ Ð²ÐºÐ»ÑÑиÑÑ Ð»Ð¸ÑнÑе ÑообÑениÑ"),retriable:!0}}async function j(r){y.value=!0;const e=o.value==="form";try{const{instance:l}=await $fetch("/api/channels",{method:"POST",body:{projectId:w.projectId,channel_type:w.channelType,transport_id:r.id}});b("connected",l)}catch(l){const m=z(l);u.value=m.message,x.value=m.retriable,e&&(c.value=r,o.value="created")}finally{y.value=!1}}return(r,e)=>{const l=O,m=W,p=P;return t(o)==="loading"?(a(),f("div",Q,[s(l,{name:"i-heroicons-arrow-path",class:"w-6 h-6 text-gray-400 animate-spin"})])):t(o)==="error"?(a(),f("div",X,[s(m,{color:"red",variant:"soft",title:"Ðе ÑдалоÑÑ Ð·Ð°Ð³ÑÑзиÑÑ Ð±Ð¾Ñов пÑоекÑа",description:"ÐÑовеÑÑÑе Ñоединение и попÑобÑйÑе еÑÑ Ñаз."}),n("div",Y,[s(p,{color:"gray",variant:"ghost",onClick:e[0]||(e[0]=i=>b("cancel"))},{default:g(()=>[...e[8]||(e[8]=[d("ÐÑмена",-1)])]),_:1}),s(p,{icon:"i-heroicons-arrow-path",onClick:T},{default:g(()=>[...e[9]||(e[9]=[d("ÐовÑоÑиÑÑ",-1)])]),_:1})])])):t(o)==="start"?(a(),f("div",Z,[e[14]||(e[14]=n("div",null,[n("p",{class:"text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500"},"ÐоÑÑ Ð¿ÑоекÑа"),n("p",{class:"text-sm text-gray-600 dark:text-gray-300 mt-0.5"},"Уже Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ñ Ð² Revback â пÑивÑзÑваÑÑÑÑ Ð±ÐµÐ· Ñокена.")],-1)),n("div",ee,[(a(!0),f(B,null,R(t(v),i=>(a(),f("button",{key:i.id,type:"button",class:"w-full flex items-center gap-3 p-3.5 rounded-2xl border-[1.5px] border-gray-200 dark:border-gray-800 text-left transition hover:border-brand-400 dark:hover:border-brand-500 hover:ring-4 hover:ring-brand-400/20",onClick:ve=>E(i)},[n("span",ne,[s(l,{name:t(C).icon,class:"w-5 h-5",style:F({color:t(C).color})},null,8,["name","style"])]),n("span",re,[n("span",se,"@"+h(i.bot_username),1),n("span",oe,[e[10]||(e[10]=n("span",{class:"w-[7px] h-[7px] rounded-full bg-green-600 shrink-0"}
1,null,-1)),d(" "+h($(i)),1)])]),n("span",ae,[e[11]||(e[11]=d(" ÐÑивÑзаÑÑ ",-1)),s(l,{name:"i-heroicons-chevron-right",class:"w-4 h-4 text-gray-400"})])],8,te))),128))]),n("button",{type:"button",class:"w-full flex items-center gap-3 p-3.5 rounded-2xl border-[1.5px] border-dashed border-gray-300 dark:border-gray-700 text-left transition hover:border-brand-400 dark:hover:border-brand-500 hover:ring-4 hover:ring-brand-400/20",onClick:L},[n("span",le,[s(l,{name:"i-heroicons-plus",class:"w-5 h-5"})]),e[12]||(e[12]=n("span",{class:"flex-1 min-w-0"},[n("span",{class:"block text-sm font-semibold"},"ÐобавиÑÑ Ð±Ð¾Ñа"),n("span",{class:"block text-xs text-gray-500 dark:text-gray-400 mt-0.5"},"ÐÐ¾Ñ Ð¸Ð· ваÑего Telegram, коÑоÑого еÑÑ Ð½ÐµÑ Ð² пÑоекÑе, â понадобиÑÑÑ Ñокен из @BotFather")],-1)),s(l,{name:"i-heroicons-chevron-right",class:"w-4 h-4 text-gray-400 shrink-0"})]),n("div",ie,[s(p,{color:"gray",variant:"ghost",onClick:e[1]||(e[1]=i=>b("cancel"))},{default:g(()=>[...e[13]||(e[13]=[d("ÐÑмена",-1)])]),_:1})])])):t(o)==="bind"&&t(c)?(a(),f("div",de,[n("div",ce,[n("span",ue,[s(l,{name:t(C).icon,class:"w-5 h-5",style:F({color:t(C).color})},null,8,["name","style"])]),n("span",me,[n("span",pe,"@"+h(t(c).bot_username),1),n("span",fe,[e[15]||(e[15]=n("span",{class:"w-[7px] h-[7px] rounded-full bg-green-600 shrink-0"},null,-1)),d(" "+h($(t(c))),1)])])]),e[18]||(e[18]=n("p",{class:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed"}," ÐÐ¾Ñ Ñже добавлен в пÑÐ¾ÐµÐºÑ â Ñокен не нÑжен. СообÑениÑ, напиÑаннÑе боÑÑ Ð² лиÑкÑ, наÑнÑÑ Ð¿Ð¾ÑвлÑÑÑÑÑ Ð² ÑаÑе. ",-1)),t(u)?(a(),_(m,{key:0,color:t(x)?"amber":"red",variant:"soft",title:t(u)},null,8,["color","title"])):I("",!0),n("div",ge,[s(p,{color:"gray",variant:"ghost",disabled:t(y),onClick:e[2]||(e[2]=i=>o.value="start")},{default:g(()=>[...e[16]||(e[16]=[d("Ðазад",-1)])]),_:1},8,["disabled"]),t(u)&&!t(x)?(a(),_(p,{key:0,onClick:e[3]||(e[3]=i=>b("cancel"))},{default:g(()=>[...e[17]||(e[17]=[d("ÐонÑÑно",-1)])]),_:1})):(a(),_(p,{key:1,loading:t(y),onClick:e[4]||(e[4]=i=>j(t(c)))},{default:g(()=>[d(h(t(u)?"ÐовÑоÑиÑÑ":"ÐодклÑÑиÑÑ Ð»Ð¸ÑнÑе ÑообÑениÑ"),1)]),_:1},8,["loading"]))])])):t(o)==="created"&&t(c)?(a(),f("div",be,[s(m,{color:"green",variant:"soft",title:`@${t(c).bot_username} добавлен в пÑоекÑ`,description:"Токен пÑинÑÑ, вводиÑÑ ÐµÐ³Ð¾ Ñнова не пÑидÑÑÑÑ."},null,8,["title"]),t(u)?(a(),_(m,{key:0,color:t(x)?"amber":"red",variant:"soft",title:t(u)},null,8,["color","title"])):I("",!0),n("div",ye,[t(x)?(a(),f(B,{key:0},[s(p,{color:"gray",variant:"ghost",disabled:t(y),onClick:e[5]||(e[5]=i=>b("cancel"))},{default:g(()=>[...e[19]||(e[19]=[d("ÐакÑÑÑÑ",-1)])]),_:1},8,["disabled"]),s(p,{loading:t(y),onClick:e[6]||(e[6]=i=>j(t(c)))},{default:g(()=>[...e[20]||(e[20]=[d("ÐовÑоÑиÑÑ Ð²ÐºÐ»ÑÑение",-1)])]),_:1},8,["loading"])],64)):(a(),_(p,{key:1,disabled:t(y),onClick:e[7]||(e[7]=i=>b("cancel"))},{default:g(()=>[...e[21]||(e[21]=[d("ÐонÑÑно",-1)])]),_:1},8,["disabled"]))])])):(a(),f("div",xe,[s(q,{"project-id":w.projectId,"cancel-label":t(v).length?"Ðазад":"ÐÑмена","bind-hint":t(v).length?"ÐÐ»Ñ Ð±Ð¾Ñа из ваÑего Telegram, коÑоÑого еÑÑ Ð½ÐµÑ Ð² ÑÑом пÑоекÑе. ÐоÑ, Ñже добавленнÑй в пÑоекÑ, пÑивÑзÑваеÑÑÑ Ð½Ð° пÑедÑдÑÑем ÑкÑане без Ñокена.":"",onCreated:j,onCancel:U},null,8,["project-id","cancel-label","bind-hint"])]))}}});
1export{Je 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.