import{d as ue,O as De,k as _,v as Fe,p as ne,m as Oe,r as re,o as a,x as d,b as s,a as i,F as L,h as P,u as t,c as y,z as m,t as w,A as j,B as x,E as Re,y as ie,G as qe,H as Ae}from"./vue.1703796278973.js";import{F as le,cx as Je,cy as Ve,aP as He,L as Ue,Y as Ee,av as Ge,aw as Ke,a as Qe,E as ze,I as Ye,r as We,aG as Xe,aK as Ze,K as et}from"./index.17037962789732.js";import"./index.170379627897315.js";import"./index.1703796278973305.js";import"./index.170379627897317.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.js";import"./index.1703796278973303.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897314.js";import"./index.1703796278973304.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import{_ as tt}from"./index.17037962789739.js";import{h as ot}from"./system.1703796278973.js";import"./index.170379627897327.js";import"./index.170379627897333.js";import{_ as st}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import"./index.1703796278973316.js";import"./index.170379627897330.js";import{c as at,e as nt,s as rt,u as it,f as lt,h as ct}from"./accessConfig.1703796278973.js";import{d as dt,N as ce,P as E,C as ut,a as pt}from"./data.17037962789734.js";import de from"./index.1703796278973191.js";import"./default.1703796278973.js";import"./index.170379627897310.js";import"./index.17037962789737.js";import{o as G}from"./comm.1703796278973.js";import{_ as mt}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./index.170379627897334.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./index.1703796278973308.js";const K=g=>(qe("data-v-bd7bd2d6"),g=g(),Ae(),g),_t={class:"steps-content"},vt={key:0,class:"steps-box"},ht={class:"alert"},ft={class:"search"},gt={class:"other"},yt={key:0},wt={key:0},xt={key:1,class:"steps-box"},kt={class:"alert"},Ct={class:"search"},bt={key:2,class:"steps-box"},St={class:"doc"},Lt=K(()=>m("h1",null,"接入方式",-1)),Tt=K(()=>m("h1",null,"消息协议",-1)),Pt={key:0},jt={key:1},It=K(()=>m("h1",null,"网络组件",-1)),Nt={key:2},Mt={class:"steps-action"},$t=ue({name:"AccessNetwork"}),Bt=ue({...$t,props:{provider:{type:Object,default:()=>{}},data:{type:Object,default:()=>{}}},setup(g){const r=g,Q=ot();function pe(){var e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var l=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(o==="x"?l:l&3|8).toString(16)})}const z=document.body.clientHeight,B=r.provider.channel,Y=De(),me=Y.query.view,I=Y.params.id,_e=_(),ve=le.useForm,c=_(0),W=_(0),N=_(["网络组件","消息协议","完成"]),b=_([]),q=_([]),M=_([]),A=_([]),v=_(""),h=_(""),k=_({}),X=_([]),Z=_([]),S=_({name:"",description:""}),J=_(!1),{resetFields:Dt,validate:he,validateInfos:ee}=ve(S,Fe({name:[{required:!0,message:"请输入名称",trigger:"blur"},{max:64,message:"最多可输入64个字符",trigger:"blur"}],description:[{max:200,message:"最多可输入200个字符"}]})),V=async(e,o,l={})=>{const u=await at(ce.get(e),o,l);u.status===200&&(b.value=u.result,q.value=u.result)},D=async(e,o={})=>{const l=await nt(E.get(e),{...o,"sorts[0].name":"createTime","sorts[0].order":"desc"});l.status===200&&(M.value=l.result,A.value=l.result)},fe=()=>{var l,u;const e=(l=Q.menus["link/Type/Detail"])==null?void 0:l.path,o=window.open(`${window.location.origin+window.location.pathname}#${e}?type=${ce.get((u=r.provider)==null?void 0:u.id)||""}`);o.onTabSaveSuccess=p=>{var f;p.success&&(v.value=p.result.id,V((f=r.provider)==null?void 0:f.id,v.value||""))}},ge=()=>{var l;const e=(l=Q.menus["link/Protocol"])==null?void 0:l.path,o=window.open(`${window.location.origin+window.location.pathname}#${e}?save=true`);o.onTabSaveSuccess=u=>{var p,f;u.success&&(h.value=(p=u.result)==null?void 0:p.id,D((f=r.provider)==null?void 0:f.id))}},te=()=>b.value.find(e=>e.id===v)&&(b.value.find(e=>e.id===v).addresses||[]).length>0,ye=()=>te()?b.value.find(e=>e.id===v).addresses:[],H=e=>e.health===-1?"error":"processing",we=e=>{let o="";return e.upstream&&e.downstream?o="上行、下行":e.upstream?o="上行":e.downstream&&(o="下行"),o},xe=e=>{v.value=e},ke=e=>{b.value=e?q.value.filter(o=>o.name&&o.name.toLocaleLowerCase().includes(e.toLocaleLowerCase())):q.value},Ce=e=>{r.data.id||(h.value=e)},be=e=>{M.value=e?A.value.filter(o=>o.name&&o.name.toLocaleLowerCase().includes(e.toLocaleLowerCase())):A.value},Se=()=>{he().then(async e=>{var u,p;const o={...r.data,...e,protocol:h.value,channel:"network",channelId:v.value,provider:r.provider.id,transport:((u=r.provider)==null?void 0:u.id)==="child-device"?"Gateway":E.get(r.provider.id)};J.value=!0;const l=I===":id"?await rt(o):await it({...o,id:I});J.value=!1,l.status===200&&(G("操作成功","success"),history.back(),window.onTabSaveSuccess&&(p=l.result)!=null&&p.id&&(window.onTabSaveSuccess(l),setTimeout(()=>window.close(),300)))}).catch(e=>{})},Le=async()=>{if(c.value===0)v.value?(D(r.provider.id),c.value=c.value+1):G("请选择网络组件!","error");else if(c.value===1)if(!h.value)G("请选择消息协议!","error");else{const e=B!=="child-device"?await lt(h.value,E.get(r.provider.id)):await ct(h.value);if(e.status===200){k.value=e.result,c.value=c.value+1;const o={title:"分组",dataIndex:"group",key:"group",ellipsis:!0,align:"center",width:100,customCell:(l,u)=>{var O;const p={children:l,rowSpan:0},f=((O=k.value)==null?void 0:O.routes)||[],$=f.filter(T=>T.group===l.group);return(u===0||f[u-1].group!==l.group)&&(p.rowSpan=$.length),p}};X.value=[o,...ut],Z.value=[o,...pt]}}},Te=()=>{c.value=c.value-1};return ne(()=>{var e;r.data&&r.data.id?r.data.provider!=="child-device"?(h.value=r.data.protocol,c.value=0,v.value=r.data.channelId,V(r.provider.id,v.value),h.value=r.data.protocol,N.value=["网络组件","消息协议","完成"]):(N.value=["消息协议","完成"],c.value=1,D(r.provider.id)):(e=r.provider)!=null&&e.id&&(B!=="child-device"?(V(r.provider.id,""),N.value=["网络组件","消息协议","完成"],c.value=0):(N.value=["消息协议","完成"],c.value=1,D(r.provider.id)))}),ne(()=>{I!==":id"&&(h.value=r.data.protocol,S.value={name:r.data.name,description:r.data.description})}),Oe(c,e=>{W.value=B==="child-device"?e-1:e},{deep:!0,immediate:!0}),(e,o)=>{const l=Je,u=Ve,p=re("AIcon"),f=He,$=st,F=Ue,O=Ee,T=Ge,U=Ke,oe=Qe,R=ze,Pe=tt,je=Ye,se=We,Ie=Xe,Ne=le,Me=re("Markdown"),$e=Ze,ae=et;return a(),d("div",null,[s(u,{current:t(W)},{default:i(()=>[(a(!0),d(L,null,P(t(N),n=>(a(),y(l,{disabled:"",key:n,title:n},null,8,["title"]))),128))]),_:1},8,["current"]),m("div",_t,[t(c)===0?(a(),d("div",vt,[m("div",ht,[s(p,{type:"InfoCircleOutlined"}),w(" 选择与设备通信的网络组件 ")]),m("div",ft,[s(f,{allowClear:"",placeholder:"请输入",style:{width:"300px"},onSearch:ke}),s($,{type:"primary",onClick:fe,hasPermission:"link/Type:add"},{icon:i(()=>[s(p,{type:"PlusOutlined"})]),default:i(()=>[w(" 新增 ")]),_:1})]),s(R,{height:"480"},{default:i(()=>[t(b).length>0?(a(),y(U,{key:0,gutter:[24,24],style:{width:"100%"}},{default:i(()=>[(a(!0),d(L,null,P(t(b),n=>(a(),y(T,{span:8,key:n.id},{default:i(()=>[s(de,{onCheckedChange:xe,checked:t(v),data:{...n,description:n.description?n.description:t(dt)[g.provider.id],type:"network"}},{other:i(()=>[m("div",gt,[s(O,{placement:"topLeft"},{default:i(()=>[(n.addresses||[]).length>1?(a(),d("div",yt,[(a(!0),d(L,null,P(n.addresses||[],C=>(a(),d("div",{key:C.address,class:"item"},[s(F,{status:H(C)},null,8,["status"]),w(j(C.address),1)]))),128))])):x("",!0),(a(!0),d(L,null,P((n.addresses||[]).slice(0,1),C=>(a(),d("div",{key:C.address,class:"item"},[s(F,{status:H(C),text:C.address},null,8,["status","text"]),(n.addresses||[]).length>1?(a(),d("span",wt,"...")):x("",!0)]))),128))]),_:2},1024)])]),_:2},1032,["checked","data"])]),_:2},1024))),128))]),_:1})):(a(),y(oe,{key:1,style:{"margin-top":"10%"},description:"暂无数据"}))]),_:1})])):t(c)===1?(a(),d("div",xt,[m("div",kt,[s(p,{type:"InfoCircleOutlined"}),w(" 使用选择的消息协议,对网络组件通信数据进行编解码、认证等操作 ")]),m("div",Ct,[s(f,{allowClear:"",placeholder:"请输入",style:{width:"300px"},onSearch:be}),s($,{type:"primary",onClick:ge,hasPermission:"link/Protocol:add"},{icon:i(()=>[s(p,{type:"PlusOutlined"})]),default:i(()=>[w(" 新增 ")]),_:1})]),s(R,{height:"480"},{default:i(()=>[t(M).length>0?(a(),y(U,{key:0,gutter:[24,24],style:{width:"100%"}},{default:i(()=>[(a(!0),d(L,null,P(t(M),n=>(a(),y(T,{span:8,key:n==null?void 0:n.id},{default:i(()=>[s(de,{onCheckedChange:Ce,checked:t(h),disabled:t(I)!==":id",data:{...n,type:"protocol"}},null,8,["checked","disabled","data"])]),_:2},1024))),128))]),_:1})):(a(),y(oe,{key:1,style:{"margin-top":"10%"},description:"暂无数据"}))]),_:1})])):(a(),d("div",bt,[m("div",{class:"card-last",style:Re(`max-height:${t(z)>900?750:t(z)*.7}px`)},[s(U,{gutter:[24,24]},{default:i(()=>[s(T,{span:12},{default:i(()=>[s(Pe,{data:"基本信息"}),s(Ne,{ref_key:"formRef",ref:_e,model:t(S),layout:"vertical"},{default:i(()=>[s(se,ie({label:"名称"},t(ee).name),{default:i(()=>[s(je,{value:t(S).name,"onUpdate:value":o[0]||(o[0]=n=>t(S).name=n),allowClear:"",placeholder:"请输入名称"},null,8,["value"])]),_:1},16),s(se,ie({label:"说明"},t(ee).description),{default:i(()=>[s(Ie,{placeholder:"请输入说明",rows:4,value:t(S).description,"onUpdate:value":o[1]||(o[1]=n=>t(S).description=n),"show-count":"",maxlength:200},null,8,["value"])]),_:1},16)]),_:1},8,["model"])]),_:1}),s(T,{span:12},{default:i(()=>[s(R,{height:"580"},{default:i(()=>[m("div",St,[Lt,m("p",null,j(g.provider.name),1),m("p",null,j(g.provider.description),1),Tt,m("p",null,j(t(M).find(n=>n.id===t(h)).name),1),t(k).document?(a(),d("p",Pt,[s(Me,{source:t(k).document},null,8,["source"])])):x("",!0),te()?(a(),d("div",jt,[It,(a(!0),d(L,null,P(ye(),n=>(a(),d("p",{key:n.address},[s(F,{status:H(n),text:n.address},null,8,["status","text"])]))),128))])):x("",!0),t(k).routes&&t(k).routes.length>0?(a(),d("div",Nt,[m("h1",null,j(g.data.provider==="mqtt-server-gateway"||g.data.provider==="mqtt-client-gateway"?"topic":"URL信息"),1),s(R,{height:"400"},{default:i(()=>[s($e,{pagination:!1,rowKey:pe(),"data-source":t(k).routes||[],bordered:"",columns:t(k).id==="MQTT"?t(X):t(Z),scroll:{y:400}},{bodyCell:i(({column:n,text:C,record:Be})=>[n.dataIndex==="stream"?(a(),d(L,{key:0},[w(j(we(Be)),1)],64)):x("",!0)]),_:1},8,["rowKey","data-source","columns"])]),_:1})])):x("",!0)])]),_:1})]),_:1})]),_:1})],4)]))]),m("div",Mt,[(t(B)==="child-device"?t(c)>1:t(c)>0)?(a(),y(ae,{key:0,style:{"margin-right":"8px"},onClick:Te},{default:i(()=>[w(" 上一步 ")]),_:1})):x("",!0),t(c)===2&&t(me)==="false"?(a(),y($,{key:1,type:"primary",style:{"margin-right":"8px"},onClick:Se,hasPermission:`link/AccessConfig:${t(I)===":id"?"add":"update"}`,loading:t(J)},{default:i(()=>[w(" 保存 ")]),_:1},8,["hasPermission","loading"])):x("",!0),[0,1].includes(t(c))?(a(),y(ae,{key:2,type:"primary",onClick:Le},{default:i(()=>[w(" 下一步 ")]),_:1})):x("",!0)])])}}});const Lo=mt(Bt,[["__scopeId","data-v-bd7bd2d6"]]);export{Lo as default};