var f=(y,x,d)=>new Promise((K,m)=>{var w=i=>{try{p(d.next(i))}catch(e){m(e)}},r=i=>{try{p(d.throw(i))}catch(e){m(e)}},p=i=>i.done?K(i.value):Promise.resolve(i.value).then(w,r);p((d=d.apply(y,x)).next())});import{g as N,a as U,b as j,__tla as H}from"./index-0d38e276.js";import{d as Q,a4 as q,f as J,n as E,j as M,y as o,o as V,c as W,w as h,a as I,t as _,u as g,e as c,b as F,_ as G,__tla as X}from"./index-b5895273.js";let D,Y=Promise.all([(()=>{try{return H}catch(y){}})(),(()=>{try{return X}catch(y){}})()]).then(()=>f(void 0,null,function*(){const y={class:"box-left"},x={class:"title"},d={class:"box-right"},K={class:"title"},m=Q({__name:"ApiConfigSelect",props:{apiSelectDialog:{type:Boolean},selectedApiId:{type:String}},emits:["update:apiSelectDialog","update:selectedApiId","success"],setup(w,{emit:r}){const p=w,{t:i}=q(),e=J({apiSelectDia:p.apiSelectDialog,interfaceTreeData:[],expandedKeys:[],selectedKeys:[],interfaceList:[],interfaceListSearch:[],interfaceDataSource:[],selectedRowKeys:[],searchText:"",isSearch:!1,fieldNames:{children:"children",title:"name",key:"id"},modalBodyStyle:{display:"flex",padding:"15px 15px 10px 10px",minHeight:"400px"},apiConfigColumns:[{key:"name",title:i("\u63A5\u53E3\u540D\u79F0"),dataIndex:"name",width:300},{key:"path",title:i("\u63A5\u53E3\u5730\u5740"),dataIndex:"path"}],paginationProps:{current:1,total:0,pageSize:10,showQuickJumper:!0,showSizeChanger:!0,onChange:t=>S(t),onShowSizeChange:(t,a)=>{e.paginationProps.pageSize=a,S(t)}},interfaceInfo:[{key:"1",title:"Query Params",tableInfo:[]},{key:"2",title:"Header",tableInfo:[]},{key:"3",title:"Body",tableInfo:[]}],configInfo:{path:"",method:"",apiId:"",apiParams:[],script:""}});E(()=>{C()}),M(()=>p.selectedApiId,t=>{t&&e.selectedRowKeys.push(t)},{immediate:!0,deep:!0});const C=()=>f(this,null,function*(){if(e.interfaceTreeData=yield N(),e.interfaceTreeData.length&&e.interfaceTreeData[0].id){const t=e.interfaceTreeData[0].id;e.selectedKeys.push(t),e.expandedKeys.push(t),b(e.selectedKeys)}}),b=(t,a)=>f(this,null,function*(){e.isSearch=!1,t.length||e.selectedKeys.push(a.node.dataRef.id);const s=t[t.length-1],u=yield U({groupId:s});e.interfaceList=[],u.map(n=>{e.interfaceList.push({id:n.id,name:n.name,path:n.path})}),S(1)}),S=t=>{const a=e.paginationProps.pageSize,s=(t-1)*a,u=t*a,n=e.isSearch?e.interfaceListSearch:e.interfaceList;e.paginationProps.current=t,e.paginationProps.total=n.length,e.interfaceDataSource=n.slice(s,u)},v=()=>{e.isSearch=!0,e.interfaceListSearch=e.interfaceList.filter(t=>Object.values(t).find((a,s)=>s!==0&&a.indexOf(e.searchText)!==-1)),S(1)},R=t=>({onClick:()=>{let a=[...e.selectedRowKeys];if(a.indexOf(t.id)>=0){let s=a.indexOf(t.id);a.splice(s,1)}else a=[t.id];e.configInfo.apiId=a[0],e.selectedRowKeys=a}}),k=t=>{e.selectedRowKeys=t,e.configInfo.apiId=t[0]},P=t=>f(this,null,function*(){var s;const a=yield j({id:t});e.interfaceInfo[0].tableInfo=a.parameters,e.interfaceInfo[1].tableInfo=a.headers,e.interfaceInfo[2].tableInfo=(s=a.requestBodyDefinition)==null?void 0:s.children,e.configInfo.path=a.path,e.configInfo.method=a.method,e.configInfo.script=a.script,e.configInfo.apiParams=e.interfaceInfo,r("success",e.configInfo)}),T=()=>f(this,null,function*(){e.selectedRowKeys[0]&&(yield P(e.selectedRowKeys[0]),r("update:selectedApiId",e.selectedRowKeys[0])),r("update:apiSelectDialog",!1)}),L=()=>{r("update:apiSelectDialog",!1)};return(t,a)=>{const s=o("a-tree"),u=o("a-input"),n=o("a-col"),A=o("a-button"),z=o("a-row"),B=o("a-table"),O=o("a-modal");return V(),W(O,{width:900,visible:e.apiSelectDia,"onUpdate:visible":a[3]||(a[3]=l=>e.apiSelectDia=l),title:g(i)("\u9009\u62E9\u63A5\u53E3"),maskClosable:!1,bodyStyle:e.modalBodyStyle,onOk:T,onCancel:L},{default:h(()=>[I("div",y,[I("div",x,_(g(i)("\u63A5\u53E3\u5206\u7C7B")),1),c(s,{expandedKeys:e.expandedKeys,"onUpdate:expandedKeys":a[0]||(a[0]=l=>e.expandedKeys=l),selectedKeys:e.selectedKeys,"onUpdate:selectedKeys":a[1]||(a[1]=l=>e.selectedKeys=l),"tree-data":e.interfaceTreeData,fieldNames:e.fieldNames,onSelect:b},null,8,["expandedKeys","selectedKeys","tree-data","fieldNames"])]),I("div",d,[I("div",K,_(g(i)("\u63A5\u53E3\u5217\u8868")),1),c(z,{gutter:12,style:{padding:"10px 0","border-top":"1px solid #f0f0f0"}},{default:h(()=>[c(n,{span:8},{default:h(()=>[c(u,{value:e.searchText,"onUpdate:value":a[2]||(a[2]=l=>e.searchText=l),placeholder:g(i)("\u8F93\u5165\u641C\u7D22\u5173\u952E\u5B57"),allowClear:""},null,8,["value","placeholder"])]),_:1}),c(n,null,{default:h(()=>[c(A,{type:"primary",onClick:v},{default:h(()=>[F(_(g(i)("\u641C\u7D22")),1)]),_:1})]),_:1})]),_:1}),c(B,{dataSource:e.interfaceDataSource,columns:e.apiConfigColumns,rowKey:"id",pagination:e.paginationProps,"row-selection":{selectedRowKeys:e.selectedRowKeys,onChange:k,type:"radio"},customRow:R,scroll:{y:"200px"}},null,8,["dataSource","columns","pagination","row-selection"])])]),_:1},8,["visible","title","bodyStyle"])}}});D=G(m,[["__scopeId","data-v-dcb46f92"]])}));export{D as A,Y as __tla};