UNPKG

goldpankit

Version:

GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。

1 lines 62.4 kB
import{C as D}from"./CompilerSelect-2141b92d.js";import{_ as I,r as o,o as m,g as y,w as n,b as a,c as g,F,j as N,a1 as G,K as J,a as r,H as j,t as p,a2 as Y,R as P,e as T,a3 as oe,a4 as M,f as U,E as H,i as $,p as L,l as W,z as K,A as X,X as re,a5 as Q}from"./index-99dec0ae.js";import{g as ue,h as de,i as Z,e as B,j as ce,c as ee,k as me}from"./service-76f6a9b4.js";import{c as pe,d as he,i as te,b as O,s as le,e as be}from"./plugin-57ed05df.js";import{a as ae}from"./form.check-189b470c.js";import{p as fe}from"./service.version-7e8b4412.js";import{O as _e,V as x}from"./ServiceCodeErrorWindow-e6874a2f.js";const ve={name:"InputTypeSelect",props:{withGroup:{default:!1}}};function ge(e,t,l,h,s,i){const u=o("el-option"),c=o("el-select");return m(),y(c,{class:"input-type-select"},{default:n(()=>[a(u,{value:"input",label:"Input"}),a(u,{value:"number_input",label:"Number Input"}),a(u,{value:"textarea",label:"Textarea"}),a(u,{value:"select",label:"Select"}),a(u,{value:"checkbox",label:"Checkbox"}),a(u,{value:"radio",label:"Radio"}),a(u,{value:"switch",label:"Switch"}),l.withGroup?N("",!0):(m(),g(F,{key:0},[a(u,{value:"datasource",label:"Data Source"}),a(u,{value:"table",label:"Table"}),a(u,{value:"query_model",label:"Query Model"})],64))]),_:1})}const E=I(ve,[["render",ge],["__scopeId","data-v-72eb8421"]]);const ye={name:"SettingFiles",components:{SortableButton:G,CompilerSelect:D,InputTypeSelect:E},props:{space:{required:!0},service:{required:!0},plugin:{required:!1}},data(){return{currentNode:null,files:[]}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},fetchFilesApi(){return this.isPlugin?pe:ue},saveFileSettingApi(){return this.isPlugin?he:de}},methods:{fetchFiles(){this.fetchFilesApi(this.unique).then(e=>{this.files=e,J(this.files)}).catch(e=>{this.$tip.apiFailed(e)})},saveFileSetting(){this.saveTimeout!=null&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>{this.saveFileSettingApi({...this.unique,type:this.currentNode.type,path:this.currentNode.path,relativePath:this.currentNode.relativePath,compiler:this.currentNode.compiler,enableExpress:this.currentNode.enableExpress,variables:this.currentNode.variables.filter(e=>e.name.trim().length>0)}).then(()=>{}).catch(e=>{this.$tip.apiFailed(e)})},300)},createVariable(){this.currentNode.variables.push({name:"",value:"",compiler:"static",remark:""})},deleteVariable(e){this.currentNode.variables.splice(e,1)},handleNodeClick(e){this.currentNode=e},isFlagFile(e){return e.compiler!=null&&e.compiler!==""||e.enableExpress!=null&&e.enableExpress!==""||e.variables.length>0},handleSorted(e){this.currentNode.variables=[],this.$nextTick(()=>{this.currentNode.variables=e,this.saveFileSetting()})}},created(){this.fetchFiles()}},Ve={class:"tree"},Ce={class:"files-wrap"},ke={class:"search-wrap"},Se={class:"node-label"},Te={class:"file-setting"},Re={class:"content-wrap"},Ie={key:1,class:"setting-holder"},we={class:"holder-wrap"};function Ne(e,t,l,h,s,i){const u=o("el-input"),c=o("Document"),b=o("el-icon"),C=o("Folder"),R=o("el-tree"),f=o("CompilerSelect"),k=o("el-form-item"),w=o("el-form");return m(),g("div",Ve,[r("div",Ce,[r("div",ke,[a(u,{placeholder:e.$t("service.settings.file.filterKeyword")},null,8,["placeholder"])]),a(R,{data:s.files,"highlight-current":!0,"empty-text":e.$t("service.settings.file.noFiles"),onNodeClick:i.handleNodeClick},{default:n(({node:_,data:v})=>[r("span",Se,[v.type==="FILE"?(m(),y(b,{key:0},{default:n(()=>[a(c)]),_:1})):v.type==="DIRECTORY"?(m(),y(b,{key:1},{default:n(()=>[a(C)]),_:1})):N("",!0),r("span",{class:j(["filename",{"flag-file":i.isFlagFile(v)}])},p(v.label),3)])]),_:1},8,["data","empty-text","onNodeClick"])]),r("div",Te,[r("h4",null,p(e.$t("service.settings.file.fileSetting")),1),r("div",Re,[s.currentNode!=null?(m(),y(w,{key:0},{default:n(()=>[a(k,{label:e.$t("service.settings.file.compiler")},{default:n(()=>[a(f,{modelValue:s.currentNode.compiler,"onUpdate:modelValue":t[0]||(t[0]=_=>s.currentNode.compiler=_),"with-follow-service":!0,onChange:i.saveFileSetting},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(k,{label:e.$t("service.settings.file.enableExpress")},{default:n(()=>[a(u,{modelValue:s.currentNode.enableExpress,"onUpdate:modelValue":t[1]||(t[1]=_=>s.currentNode.enableExpress=_),type:"textarea",rows:8,placeholder:e.$t("service.settings.file.enableExpressHolder"),onInput:i.saveFileSetting},null,8,["modelValue","placeholder","onInput"])]),_:1},8,["label"])]),_:1})):(m(),g("div",Ie,[r("div",we,[r("h5",null,p(e.$t("service.settings.file.fileSetting")),1),r("p",null,p(e.$t("service.settings.file.fileSettingHolder")),1)])]))])])])}const Nl=I(ye,[["render",Ne],["__scopeId","data-v-45f8d15f"]]);const Fe={name:"InitializeView",components:{DatabaseTypeSelect:Y,CompilerSelect:D,DirectorySelect:P},props:{spaceName:{required:!0},serviceName:{required:!0},serviceLabel:{required:!1},pluginName:{required:!1},pluginLabel:{required:!1}},data(){return{form:{space:this.spaceName,name:null,version:"1.0.0",compiler:"static",supportedDatabases:[],codespace:""}}},computed:{isInitPlugin(){return this.pluginName!=null}},methods:{initialize(){let e;this.isInitPlugin?e=te({...this.form,service:this.serviceName,name:this.pluginName,label:this.pluginLabel}):e=Z({...this.form,name:this.serviceName,label:this.serviceLabel}),e.then(()=>{this.$emit("initialized",this.form)}).catch(t=>{this.$tip.apiFailed(t)})},fetchConfig(e){let t;this.isInitPlugin?(console.log("查询插件配置",e),t=O({codespace:e})):t=B({codespace:e}),t.then(l=>{l!=null&&(this.form.version=l.version||this.form.version,this.form.compiler=l.compiler||this.form.compiler,this.form.supportedDatabases=l.supportedDatabases||this.form.supportedDatabases)}).catch(l=>{this.$tip.apiFailed(l)})}}},$e={class:"initialize-wrap"},Ae={class:"tip"},ze={class:"directory-select-wrap"},De={class:"opera-bottom"};function qe(e,t,l,h,s,i){const u=o("DirectorySelect"),c=o("el-button");return m(),g("div",$e,[r("div",Ae,[r("h3",null,p(e.$t("service.settings.initialize.initializeService")),1),r("p",null,p(e.$t("service.settings.initialize.initializeServiceTip")),1)]),r("div",ze,[a(u,{modelValue:s.form.codespace,"onUpdate:modelValue":t[0]||(t[0]=b=>s.form.codespace=b),title:e.$t("service.settings.initialize.selectServiceCodespace"),height:"235px",onChange:i.fetchConfig},null,8,["modelValue","title","onChange"])]),r("div",De,[a(c,{type:"primary",size:"large",onClick:i.initialize},{default:n(()=>[T(p(e.$t("service.settings.initialize.initializeService")),1)]),_:1},8,["onClick"])])])}const Fl=I(Fe,[["render",qe],["__scopeId","data-v-848197ab"]]);const Ue={name:"BuildCommandTypeSelect"};function Be(e,t,l,h,s,i){const u=o("el-option"),c=o("el-select");return m(),y(c,{class:"build-command-type-select"},{default:n(()=>[a(u,{value:"Node",label:"Node"}),a(u,{value:"MySQL",label:"MySQL"})]),_:1})}const Oe=I(Ue,[["render",Be],["__scopeId","data-v-3b21c3bd"]]);const Ee={name:"ServiceFileSelectWindow",props:{title:{default:"Select Service File"},serviceConfig:{required:!0}},data(){return{visible:!1,paths:[],files:[],selectedFilepath:null}},methods:{open(){this.visible=!0,this.paths=[this.__getProjectName()],this.__fetchFiles(),this.selectedFilepath=null},confirmSelect(){this.visible=!1;let e=`${this.paths.slice(1).join("/")}/${this.selectedFilepath}`;e.startsWith("/")||(e="/"+e),this.$emit("change",e)},cancelSelect(){this.visible=!1},changePath(e){if(e===this.paths.length-1)return;const t=this.paths.slice(0,e+1);this.__fetchFiles(t,()=>{this.paths.splice(e+1),this.selectedFilepath=null})},openOrSelectFile(e){if(e.type==="DIRECTORY"){const t=JSON.parse(JSON.stringify(this.paths));t.push(e.path),this.__fetchFiles(t,()=>{this.paths.push(e.path),this.selectedFilepath=null});return}this.selectedFilepath=e.path},__fetchFiles(e,t){oe(this.__getAbsolutePath(e)).then(l=>{this.files=l,J(this.files),t&&t()}).catch(l=>{this.$tip.apiFailed(l)})},__getProjectName(){return M.split(this.serviceConfig.codespace).pop()},__getAbsolutePath(e){e==null&&(e=JSON.parse(JSON.stringify(this.paths))),e.shift();let t=M.join([this.serviceConfig.codespace,...e]);return this.serviceConfig.translator.settings.length>0&&(t=M.join([this.serviceConfig.codespace,this.serviceConfig.translator.output,...e])),t}}},Me=["id"],je={class:"paths"},Pe=["onClick"],Le={class:"files"},We=["onClick"],xe={class:"opera"};function Qe(e,t,l,h,s,i){const u=o("el-button"),c=o("Folder"),b=o("Document"),C=o("el-icon"),R=o("el-dialog");return m(),y(R,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=f=>s.visible=f),"show-close":!1,"custom-class":"service-file-select-window","append-to-body":""},{header:n(({close:f,titleId:k,titleClass:w})=>[r("h4",{id:k,class:j(w)},p(l.title),11,Me),a(u,{class:"button-icon",icon:"Refresh",onClick:i.__fetchFiles},null,8,["onClick"])]),default:n(()=>[r("ul",je,[(m(!0),g(F,null,U(s.paths,(f,k)=>(m(),g("li",{key:f,onClick:w=>i.changePath(k)},p(f),9,Pe))),128))]),r("div",Le,[r("ul",null,[(m(!0),g(F,null,U(s.files,f=>(m(),g("li",{key:f.path,class:j({"is-file":f.type==="FILE",selected:s.selectedFilepath===f.path}),onClick:k=>i.openOrSelectFile(f)},[a(C,null,{default:n(()=>[f.type==="DIRECTORY"?(m(),y(c,{key:0})):(m(),y(b,{key:1}))]),_:2},1024),r("p",null,p(f.path),1)],10,We))),128))])]),r("div",xe,[a(u,{size:"large",onClick:i.cancelSelect},{default:n(()=>[T("Cancel")]),_:1},8,["onClick"]),a(u,{type:"primary",size:"large",disabled:s.selectedFilepath==null,onClick:i.confirmSelect},{default:n(()=>[T("Confirm Select")]),_:1},8,["disabled","onClick"])])]),_:1},8,["modelValue"])}const Ge=I(Ee,[["render",Qe]]);const Je={name:"BuildList",components:{ServiceFileSelectWindow:Ge,DirectorySelect:P,Empty:H,BuildCommandTypeSelect:Oe},props:{builds:{required:!0,type:Array},withUnbuild:{default:!1},serviceConfig:{required:!0}},data(){return{actives:[],varIndex:1,selectFileData:{currentBuild:null}}},watch:{builds:{immediate:!0,handler(){this.__handleBuildList("builds")}},unbuilds:{immediate:!0,handler(){this.__handleBuildList("unbuilds")}}},methods:{handleFileChange(e){this.selectFileData.currentBuild.__filepath=e,this.handleSave()},create(){const e=""+Math.random();this.builds.push({id:e,name:this.__generateBuildName(),type:"Node",contentType:"string",content:"",__readonly:!1,__filepath:""}),this.actives.push(e)},handleChange(e){for(const t of this.builds){const l=e.find(h=>h===t.id)!=null;t.__readonly=!l}},handleSave(){this.$emit("save")},deleteBuild(e){this.builds.splice(e,1),this.handleSave()},openSelectFileWindow(e){this.selectFileData.currentBuild=e,this.$refs.serviceFileSelectWindow.open()},__generateBuildName(){let e;for(;;)if(e=`${this.withUnbuild?"un":""}build${this.varIndex}`,this.varIndex++,this.builds.findIndex(t=>t.name===e)===-1)return e},__handleBuildList(e){this[e]!=null&&this[e].forEach(t=>{t.id=""+Math.random(),t.contentType==="file"&&(t.__filepath=t.content,t.content=""),t.__readonly=!0})}}},Ye={class:"service-build-list"},He={class:"toolbar"},Ke={key:0},Xe={key:1},Ze={class:"title-wrap"},et={key:0,class:"view"},tt={class:"name"},lt={class:"type"},at={key:1,class:"edit"},nt={class:"opera"},it=["onClick"],st={key:0,class:"holder"},ot={key:1};function rt(e,t,l,h,s,i){const u=o("el-button"),c=o("el-input"),b=o("el-form-item"),C=o("BuildCommandTypeSelect"),R=o("el-form"),f=o("el-tab-pane"),k=o("el-tabs"),w=o("el-collapse-item"),_=o("el-collapse"),v=o("Empty"),V=o("ServiceFileSelectWindow");return m(),g("div",Ye,[r("div",He,[l.withUnbuild?(m(),g("p",Ke,p(e.$t("service.settings.build.unBuildTip")),1)):(m(),g("p",Xe,p(e.$t("service.settings.build.buildTip")),1)),a(u,{type:"primary",onClick:i.create},{default:n(()=>[T(p(e.$t("common.create")),1)]),_:1},8,["onClick"])]),l.builds.length>0?(m(),y(_,{key:0,modelValue:s.actives,"onUpdate:modelValue":t[2]||(t[2]=S=>s.actives=S),onChange:i.handleChange},{default:n(()=>[(m(!0),g(F,null,U(l.builds,(S,q)=>(m(),y(w,{key:S.id,name:S.id},{title:n(()=>[r("div",Ze,[S.__readonly?(m(),g("div",et,[r("p",tt,p(S.name),1),r("p",lt,p(S.type),1)])):(m(),g("div",at,[a(R,{model:S},{default:n(()=>[a(b,{label:e.$t("common.name"),required:""},{default:n(()=>[a(c,{class:"name",modelValue:S.name,"onUpdate:modelValue":d=>S.name=d,onClick:t[0]||(t[0]=$(()=>{},["stop"])),onKeypress:t[1]||(t[1]=$(()=>{},["stop"])),onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1032,["label"]),a(b,{label:e.$t("common.type"),required:""},{default:n(()=>[a(C,{class:"type",modelValue:S.type,"onUpdate:modelValue":d=>S.type=d,onChange:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label"])]),_:2},1032,["model"])])),r("div",nt,[a(u,{icon:"Delete",onClick:$(d=>i.deleteBuild(q),["stop"])},{default:n(()=>[T(p(e.$t("common.delete")),1)]),_:2},1032,["onClick"])])])]),default:n(()=>[a(k,{modelValue:S.contentType,"onUpdate:modelValue":d=>S.contentType=d},{default:n(()=>[a(f,{name:"string",label:e.$t("service.settings.build.input")},{default:n(()=>[a(c,{modelValue:S.content,"onUpdate:modelValue":d=>S.content=d,type:"textarea",placeholder:e.$t("service.settings.build.buildCommand"),rows:5,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","placeholder","onInput"])]),_:2},1032,["label"]),a(f,{name:"file",label:e.$t("service.settings.build.file")},{default:n(()=>[r("div",{class:"select-holder",onClick:d=>i.openSelectFileWindow(S)},[S.__filepath==null||S.__filepath===""?(m(),g("p",st,p(e.$t("common.clickToSelectFile")),1)):(m(),g("p",ot,p(S.__filepath),1))],8,it)]),_:2},1032,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["name"]))),128))]),_:1},8,["modelValue","onChange"])):(m(),y(v,{key:1})),a(V,{ref:"serviceFileSelectWindow","service-config":l.serviceConfig,onChange:i.handleFileChange},null,8,["service-config","onChange"])])}const ut=I(Je,[["render",rt],["__scopeId","data-v-a44c5960"]]);const dt={name:"TranslatorTypeSelect"};function ct(e,t,l,h,s,i){const u=o("el-option"),c=o("el-select");return m(),y(c,{class:"translator-type-select"},{default:n(()=>[a(u,{value:"pattern",label:e.$t("service.settings.translator.pattern")},null,8,["label"]),a(u,{value:"code",label:e.$t("service.settings.translator.code")},null,8,["label"])]),_:1})}const mt=I(dt,[["render",ct],["__scopeId","data-v-f6d00470"]]);const pt={name:"TranslatorList",components:{TranslatorTypeSelect:mt,Empty:H},props:{space:{required:!0},service:{required:!0},plugin:{required:!0},translator:{required:!0}},data(){return{actives:[],varIndex:1}},computed:{translators(){return this.translator.settings}},watch:{translators:{immediate:!0,handler(){this.translators.forEach(e=>{e.id=""+Math.random(),e.__readonly=!0})}}},methods:{add(){const e=""+Math.random();this.translator.settings.push({id:e,name:this.__generateTranslatorName(),type:"pattern",path:".*",source:"",target:"",code:" return {filepath: filepath, content: content};",__readonly:!1}),this.actives.push(e)},deleteTranslator(e){this.translator.settings.splice(e,1),this.handleSave()},handleChange(e){for(const t of this.translators){const l=e.find(h=>h===t.id)!=null;t.__readonly=!l}},handleSave(){this.$emit("save")},__generateTranslatorName(){let e;for(;;)if(e=`translator${this.varIndex}`,this.varIndex++,this.translators.findIndex(t=>t.name===e)===-1)return e}}},ne=e=>(L("data-v-6ba15df0"),e=e(),W(),e),ht={class:"translator-setting"},bt={class:"toolbar"},ft={class:"opera"},_t={class:"title-wrap"},vt={key:0,class:"view"},gt={class:"name"},yt={class:"path"},Vt={class:"type"},Ct={key:1,class:"edit"},kt={class:"opera"},St=ne(()=>r("p",{class:"code"},[r("em",{class:"keyword"},"function"),T(),r("em",null,"translate"),T(" ("),r("em",null,"filepath"),T(", "),r("em",null,"content"),T(", "),r("em",null,"fileSetting"),T(") {")],-1)),Tt=ne(()=>r("p",null,"}",-1));function Rt(e,t,l,h,s,i){const u=o("el-button"),c=o("el-input"),b=o("el-form-item"),C=o("TranslatorTypeSelect"),R=o("el-form"),f=o("el-collapse-item"),k=o("el-collapse"),w=o("Empty");return m(),g("div",ht,[r("div",bt,[r("p",null,p(e.$t("service.settings.translator.translatorTip")),1),r("div",ft,[a(u,{type:"primary",onClick:i.add},{default:n(()=>[T(p(e.$t("common.add")),1)]),_:1},8,["onClick"])])]),i.translators.length>0?(m(),y(k,{key:0,modelValue:s.actives,"onUpdate:modelValue":t[4]||(t[4]=_=>s.actives=_),onChange:i.handleChange},{default:n(()=>[(m(!0),g(F,null,U(i.translators,(_,v)=>(m(),y(f,{key:_.id,name:_.id},{title:n(()=>[r("div",_t,[_.__readonly?(m(),g("div",vt,[r("p",gt,p(_.name),1),r("p",yt,p(_.path),1),r("p",Vt,p(_.type),1)])):(m(),g("div",Ct,[a(R,{model:_},{default:n(()=>[a(b,{label:e.$t("common.name"),required:""},{default:n(()=>[a(c,{class:"name",modelValue:_.name,"onUpdate:modelValue":V=>_.name=V,onClick:t[0]||(t[0]=$(()=>{},["stop"])),onKeypress:t[1]||(t[1]=$(()=>{},["stop"])),onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1032,["label"]),a(b,{label:e.$t("service.settings.translator.path"),required:""},{default:n(()=>[a(c,{class:"path",modelValue:_.path,"onUpdate:modelValue":V=>_.path=V,onClick:t[2]||(t[2]=$(()=>{},["stop"])),onKeypress:t[3]||(t[3]=$(()=>{},["stop"])),onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1032,["label"]),a(b,{label:e.$t("service.settings.translator.type"),required:""},{default:n(()=>[a(C,{class:"type",modelValue:_.type,"onUpdate:modelValue":V=>_.type=V,onChange:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label"])]),_:2},1032,["model"])])),r("div",kt,[a(u,{icon:"Delete",onClick:$(V=>i.deleteTranslator(v),["stop"])},{default:n(()=>[T("Delete")]),_:2},1032,["onClick"])])])]),default:n(()=>[_.type==="pattern"?(m(),y(R,{key:0},{default:n(()=>[a(b,{label:"Source",required:""},{default:n(()=>[a(c,{modelValue:_.source,"onUpdate:modelValue":V=>_.source=V,type:"textarea",rows:1,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024),a(b,{label:"Target",required:""},{default:n(()=>[a(c,{modelValue:_.target,"onUpdate:modelValue":V=>_.target=V,type:"textarea",rows:1,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024)]),_:2},1024)):_.type==="code"?(m(),g(F,{key:1},[St,a(c,{modelValue:_.code,"onUpdate:modelValue":V=>_.code=V,type:"textarea",rows:5,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"]),Tt],64)):N("",!0)]),_:2},1032,["name"]))),128))]),_:1},8,["modelValue","onChange"])):(m(),y(w,{key:1}))])}const It=I(pt,[["render",Rt],["__scopeId","data-v-6ba15df0"]]),wt="data:image/png;base64,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";const Nt={name:"BasicSetting",components:{TranslatorList:It,BuildList:ut,DirectorySelect:P,DatabaseTypeSelect:Y,CompilerSelect:D},props:{space:{required:!0},service:{required:!0},plugin:{required:!1},serviceConfig:{}},data(){return{isWorking:{clone:!1},newCodespace:{changing:!1,value:""},originForm:null,form:{name:"",label:"",version:"",private:!1,receivable:!1,compiler:"",introduce:"",repository:"",branch:"",supportedDatabases:[],tableFieldDefinitions:[],builds:[],unbuilds:[],prices:[{type:"free",value:0}],translator:{output:"",settings:[]},codespace:""}}},computed:{isPlugin(){return this.plugin!=null},clonable(){return this.form.repository.trim()!==""&&this.form.branch.trim()!==""}},methods:{initData(){for(const e in this.form)e==="label"&&(this.form.label=this.serviceConfig.label||this.serviceConfig.name||this.form.label),this.form[e]=this.serviceConfig[e]||this.form[e];this.originForm=JSON.parse(JSON.stringify(this.form))},initialize(){this.form.codespace=this.newCodespace.value;let e;this.isPlugin?e=te({space:this.space,service:this.service,name:this.plugin,...this.form}):e=Z({space:this.space,name:this.service,...this.form}),e.then(()=>{this.newCodespace.changing=!1,this.$emit("initialized",this.form)}).catch(t=>{this.$tip.apiFailed(t)})},handleBranchInput(e){(e.startsWith("v")||e.startsWith("V"))&&(e=e.substring(1)),ae(null,e,t=>{t||(this.form.version=e),this.saveConfig()})},clone(){this.isWorking.clone||this.alert(this.$t("gitClone.cloneTip"),this.$t("common.importantTip"),{showCancelButton:!0,cancelButtonText:this.$t("common.cancel"),confirmButtonText:this.$t("gitClone.confirm"),confirmButtonClass:"danger-button"}).then(()=>{this.isWorking.clone=!0,ce({space:this.space,service:this.service,plugin:this.plugin}).then(()=>{this.alert(this.$t("gitClone.cloneSuccess")).then(()=>{window.location.reload()}).catch(()=>{})}).catch(e=>{this.alert(this.$t("gitClone.cloneFailed",{message:e.message}),this.$t("gitClone.cloneFailedTitle")).catch(()=>{})}).finally(()=>{this.isWorking.clone=!1})}).catch(()=>{})},changePriceType(e){e==="free"&&(this.form.prices[0].value=0),this.saveConfig()},changeCodespace(){this.newCodespace.changing=!0,this.newCodespace.value=this.form.codespace},fetchConfig(e){let t;this.isPlugin?t=O({codespace:e}):t=B({codespace:e}),t.then(l=>{l!=null&&(this.form.name=l.name||this.form.name,this.form.label=l.label||l.name||this.form.label,this.form.version=l.version||this.form.version,this.form.introduce=l.introduce||this.form.introduce,this.form.compiler=l.compiler||this.form.compiler,this.form.prices=l.prices||this.form.prices,this.form.supportedDatabases=l.supportedDatabases||this.form.supportedDatabases,this.form.builds=l.builds||this.form.builds,this.form.unbuilds=l.unbuilds||this.form.unbuilds,this.form.translator=l.translator||this.form.translator)}).catch(l=>{this.$tip.apiFailed(l)})},saveConfig(){if(this.newCodespace.changing)return;let e,t;this.isPlugin?(t=le,e={space:this.space,service:this.service,plugin:this.plugin}):(t=ee,e={space:this.space,service:this.service}),t({...e,...this.form,translator:{...this.form.translator,settings:this.form.translator.settings.filter(l=>l.type==="code"&&l.code.trim().length>0||l.type==="pattern"&&l.source.trim()!==""&&l.target.trim()!=="").map(l=>({name:l.name,path:l.path.trim().length===0?".*":l.path,type:l.type,source:l.type==="pattern"?l.source:"",target:l.type==="pattern"?l.target:"",code:l.type==="code"?l.code:""}))},builds:this.form.builds.map(l=>({name:l.name,type:l.type,content:l.contentType==="file"?l.__filepath:l.content,contentType:l.contentType})),unbuilds:this.form.unbuilds.map(l=>({name:l.name,type:l.type,content:l.contentType==="file"?l.__filepath:l.content,contentType:l.contentType}))}).then(()=>{this.originForm=JSON.parse(JSON.stringify(this.form))}).catch(l=>{this.$tip.apiFailed(l)})}},created(){this.initData()}},ie=e=>(L("data-v-39d15fab"),e=e(),W(),e),Ft={class:"basic-setting"},$t={class:"wrap"},At={class:"repository-input-wrap"},zt=ie(()=>r("span",null,"/",-1)),Dt=ie(()=>r("span",null,[r("img",{src:wt})],-1)),qt={key:0,class:"codespace-wrap"},Ut={key:0,class:"opera-wrap"};function Bt(e,t,l,h,s,i){const u=o("el-input"),c=o("el-form-item"),b=o("CompilerSelect"),C=o("DatabaseTypeSelect"),R=o("el-button"),f=o("el-radio-button"),k=o("el-radio-group"),w=o("el-input-number"),_=o("el-checkbox"),v=o("TranslatorList"),V=o("BuildList"),S=o("DirectorySelect"),q=o("el-form");return m(),g("div",Ft,[r("div",$t,[a(q,{model:s.form},{default:n(()=>[l.plugin==null?(m(),g(F,{key:0},[a(c,{label:e.$t("service.settings.name"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.name,"onUpdate:modelValue":t[0]||(t[0]=d=>s.form.name=d),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.label"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.label,"onUpdate:modelValue":t[1]||(t[1]=d=>s.form.label=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)):(m(),g(F,{key:1},[a(c,{label:e.$t("plugin.name"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.name,"onUpdate:modelValue":t[2]||(t[2]=d=>s.form.name=d),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),a(c,{label:e.$t("plugin.label"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.label,"onUpdate:modelValue":t[3]||(t[3]=d=>s.form.label=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)),a(c,{label:e.$t("service.settings.version"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.version,"onUpdate:modelValue":t[4]||(t[4]=d=>s.form.version=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.compiler"),prop:"compiler",required:""},{default:n(()=>[a(b,{modelValue:s.form.compiler,"onUpdate:modelValue":t[5]||(t[5]=d=>s.form.compiler=d),onChange:i.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.supportedDatabases"),prop:"supportedDatabases"},{default:n(()=>[a(C,{modelValue:s.form.supportedDatabases,"onUpdate:modelValue":t[6]||(t[6]=d=>s.form.supportedDatabases=d),onChange:i.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.repository"),prop:"repository"},{default:n(()=>[r("div",At,[a(u,{class:"repository-input",modelValue:s.form.repository,"onUpdate:modelValue":t[7]||(t[7]=d=>s.form.repository=d),onInput:i.saveConfig},null,8,["modelValue","onInput"]),zt,a(u,{class:"branch-input",modelValue:s.form.branch,"onUpdate:modelValue":t[8]||(t[8]=d=>s.form.branch=d),placeholder:e.$t("gitClone.branch"),onInput:i.handleBranchInput},null,8,["modelValue","placeholder","onInput"]),a(R,{type:"primary",disabled:s.isWorking.clone||!i.clonable,loading:s.isWorking.clone,onClick:i.clone},{default:n(()=>[T(p(e.$t("gitClone.clone")),1)]),_:1},8,["disabled","loading","onClick"])])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.introduce"),prop:"introduce",required:""},{default:n(()=>[a(u,{type:"textarea",rows:5,modelValue:s.form.introduce,"onUpdate:modelValue":t[9]||(t[9]=d=>s.form.introduce=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.charge"),prop:"prices[0].type",required:""},{default:n(()=>[a(k,{modelValue:s.form.prices[0].type,"onUpdate:modelValue":t[10]||(t[10]=d=>s.form.prices[0].type=d),onChange:i.changePriceType},{default:n(()=>[(m(!0),g(F,null,U(e.$const.getServiceLeaseTypes(e.$t),d=>(m(),y(f,{key:d.code,label:d.code},{default:n(()=>[T(p(d.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1},8,["label"]),s.form.prices[0].type!=="free"?(m(),y(c,{key:2,label:"Price",prop:"prices[0].value",class:"item-price",required:""},{default:n(()=>[Dt,a(w,{controls:!1,modelValue:s.form.prices[0].value,"onUpdate:modelValue":t[11]||(t[11]=d=>s.form.prices[0].value=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1})):N("",!0),a(c,{label:e.$t("service.settings.otherSettings"),class:"item-other-settings"},{default:n(()=>[r("div",null,[a(_,{modelValue:s.form.private,"onUpdate:modelValue":t[12]||(t[12]=d=>s.form.private=d),label:"Is a private service",onChange:i.saveConfig},null,8,["modelValue","onChange"])])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.translator.translator"),prop:"translator"},{default:n(()=>[a(v,{space:l.space,service:l.service,plugin:l.plugin,translator:s.form.translator,onSave:i.saveConfig},null,8,["space","service","plugin","translator","onSave"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.installBuilds"),prop:"builds"},{default:n(()=>[a(V,{builds:s.form.builds,"service-config":l.serviceConfig,onSave:i.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.uninstallBuilds"),prop:"unbuilds"},{default:n(()=>[a(V,{builds:s.form.unbuilds,"with-unbuild":!0,"service-config":l.serviceConfig,onSave:i.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.codespace"),prop:"codespace"},{default:n(()=>[s.newCodespace.changing?(m(),y(S,{key:1,title:e.$t("service.settings.selectNewCodespace"),modelValue:s.newCodespace.value,"onUpdate:modelValue":t[13]||(t[13]=d=>s.newCodespace.value=d),onChange:i.fetchConfig},null,8,["title","modelValue","onChange"])):(m(),g("div",qt,[r("p",null,p(s.form.codespace),1),a(R,{type:"primary",onClick:i.changeCodespace},{default:n(()=>[T(p(e.$t("service.settings.changeCodespace")),1)]),_:1},8,["onClick"])]))]),_:1},8,["label"])]),_:1},8,["model"]),s.newCodespace.changing?(m(),g("div",Ut,[a(R,{size:"large",onClick:t[14]||(t[14]=d=>s.newCodespace.changing=!1)},{default:n(()=>[T(p(e.$t("common.cancel")),1)]),_:1}),a(R,{size:"large",type:"primary",onClick:i.initialize},{default:n(()=>[T(p(e.$t("service.settings.reinitialize")),1)]),_:1},8,["onClick"])])):N("",!0)])])}const $l=I(Nt,[["render",Bt],["__scopeId","data-v-39d15fab"]]),Ot={name:"PublishWindow",data(){return{visible:!1,isWorking:!1,space:null,service:null,plugin:null,form:{version:"",publishDescription:""}}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},fetchConfigApi(){return this.isPlugin?B:O},saveConfigApi(){return this.isPlugin?le:ee}},methods:{open(e,t,l){this.space=e,this.service=t,this.plugin=l,this.visible=!0,this.fetchConfig()},getRules(){return{version:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionNumber")})},{validator:ae,message:this.$t("form.isIncorrect",{field:this.$t("service.versionNumber")})}],publishDescription:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionDescription")}),trigger:"blur"}]}},fetchConfig(){this.fetchConfigApi(this.unique).then(e=>{this.form.version=e.version}).catch(e=>{this.$tip.apiFailed(e)})},saveConfig(){this.saveConfigApi({...this.unique,version:this.form.version}).catch(e=>{this.$tip.apiFailed(e)})},publish(){this.$refs.form.validate().then(()=>{this.isWorking||(this.isWorking=!0,fe({...this.unique,publishDescription:this.form.publishDescription}).then(()=>{this.visible=!1,this.$message.success("发布成功")}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.isWorking=!1}))})}}},Et={class:"dialog-footer"};function Mt(e,t,l,h,s,i){const u=o("el-input"),c=o("el-form-item"),b=o("el-form"),C=o("el-button"),R=o("el-dialog"),f=K("loading");return m(),y(R,{modelValue:s.visible,"onUpdate:modelValue":t[3]||(t[3]=k=>s.visible=k),class:"publish-window",title:e.$t("service.settings.publishVersion"),width:"500px",draggable:"","close-on-press-escape":!1,"close-on-click-modal":!1},{footer:n(()=>[r("span",Et,[a(C,{onClick:t[2]||(t[2]=k=>s.visible=!1)},{default:n(()=>[T(p(e.$t("common.cancel")),1)]),_:1}),a(C,{type:"primary",disabled:s.isWorking,onClick:i.publish},{default:n(()=>[T(p(e.$t("service.settings.publish")),1)]),_:1},8,["disabled","onClick"])])]),default:n(()=>[X((m(),y(b,{ref:"form",model:s.form,rules:i.getRules()},{default:n(()=>[a(c,{label:e.$t("service.versionNumber"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.version,"onUpdate:modelValue":t[0]||(t[0]=k=>s.form.version=k),onInput:i.saveConfig},{prefix:n(()=>[T("v")]),_:1},8,["modelValue","onInput"])]),_:1},8,["label"]),a(c,{label:e.$t("service.versionDescription"),prop:"publishDescription",required:""},{default:n(()=>[a(u,{type:"textarea",rows:5,modelValue:s.form.publishDescription,"onUpdate:modelValue":t[1]||(t[1]=k=>s.form.publishDescription=k)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model","rules"])),[[f,s.isWorking]])]),_:1},8,["modelValue","title"])}const Al=I(Ot,[["render",Mt]]);const jt={name:"OptionSettingWindow",components:{OptionValueInput:_e},data(){return{visible:!1,option:null}},methods:{open(e){this.option=e,this.visible=!0},add(){this.option.settings.push({label:"",name:"",inputType:"input",required:!0,defaultValue:""})},deleteSetting(e){this.option.settings.splice(e,1),this.emitChange()},emitChange(){this.$emit("change")}}},Pt={class:"toolbar"};function Lt(e,t,l,h,s,i){const u=o("el-button"),c=o("el-input"),b=o("el-table-column"),C=o("el-option"),R=o("el-select"),f=o("el-switch"),k=o("OptionValueInput"),w=o("el-table"),_=o("el-dialog");return m(),y(_,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=v=>s.visible=v),title:e.$t("service.settings.variable.optionSettings"),"append-to-body":"","custom-class":"option-setting-window"},{default:n(()=>[r("div",Pt,[a(u,{icon:"Plus",type:"primary",onClick:i.add},{default:n(()=>[T(p(e.$t("common.add")),1)]),_:1},8,["onClick"])]),a(w,{data:s.option.settings},{default:n(()=>[a(b,{prop:"label",label:e.$t("service.settings.variable.label")},{default:n(({row:v})=>[a(c,{modelValue:v.label,"onUpdate:modelValue":V=>v.label=V,onInput:i.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(b,{prop:"name",label:e.$t("service.settings.variable.name")},{default:n(({row:v})=>[a(c,{modelValue:v.name,"onUpdate:modelValue":V=>v.name=V,onInput:i.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(b,{prop:"inputType",label:e.$t("service.settings.variable.inputType")},{default:n(({row:v})=>[a(R,{modelValue:v.inputType,"onUpdate:modelValue":V=>v.inputType=V,onChange:i.emitChange},{default:n(()=>[a(C,{value:"input",label:"Input"}),a(C,{value:"number_input",label:"Number Input"}),a(C,{value:"textarea",label:"Textarea"})]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),_:1},8,["label"]),a(b,{prop:"required",label:e.$t("service.settings.variable.required")},{default:n(({row:v})=>[a(f,{modelValue:v.required,"onUpdate:modelValue":V=>v.required=V},null,8,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),a(b,{prop:"defaultValue",label:e.$t("service.settings.variable.defaultValue")},{default:n(({row:v})=>[a(k,{"option-setting":v,modelValue:v.defaultValue,"onUpdate:modelValue":V=>v.defaultValue=V,onInput:i.emitChange},null,8,["option-setting","modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(b,{width:"60px"},{default:n(({row:v,$index:V})=>[a(u,{icon:"Delete",onClick:S=>i.deleteSetting(V)},null,8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1},8,["modelValue","title"])}const Wt=I(jt,[["render",Lt]]),xt={name:"VariableSettingForm",components:{OptionSettingWindow:Wt,SortableButton:G,VariableInput:x,CompilerSelect:D,InputTypeSelect:E},props:{variable:{required:!0},rootVariable:{required:!0},variableGroup:{default:!1}},computed:{withGroup(){return this.variableGroup!=null}},watch:{"variable.defaultValue":function(){this.handleFieldVariableValues(),this.handleChange()},"variable.name":function(){this.handleFieldVariableValues(),this.handleChange()}},methods:{handleChange(){this.$emit("change")},handleDefaultValueChange(){this.handleFieldVariableValues(),this.$emit("change")},handleFieldVariableValues(){if(this.rootVariable!==this.variable&&(this.rootVariable.inputType==="query_model"||this.rootVariable.inputType==="table")){for(const e of this.rootVariable.children)if(e.defaultValue!=null)for(const t of e.defaultValue){t[this.variable.name]=this.variable.defaultValue;for(const l in t){if(l==="origin")continue;e.children.find(s=>s.name===l)==null&&!t.origin.hasOwnProperty(l)&&delete t[l]}}}},createOption(){this.variable.options.push({value:"",label:"",remark:"",settings:[]})},deleteOption(e){this.variable.options.splice(e,1)},handleInputTypeChange(){let e=this.variable.defaultValue;if(e!=null&&e.value!=null&&(e=e.value),e instanceof Array&&(e=e[0]),typeof e=="number"&&(e=e+""),this.variable.inputType==="number_input"){let t=Number(parseInt(e));isNaN(t)&&(t=0),this.variable.defaultValue=t}else if(this.variable.inputType==="select"){const t=this.variable.options.find(l=>l.value===e);this.variable.defaultValue={value:t==null?null:e,settings:t==null?[]:t.settings}}else this.variable.inputType==="checkbox"?this.variable.defaultValue=[]:this.variable.inputType==="radio"?this.variable.defaultValue="":this.variable.inputType==="datasource"||this.variable.inputType==="table"||this.variable.inputType==="query_model"?this.variable.defaultValue=null:this.variable.defaultValue=e;this.handleChange()},handleOptionSorted(e){this.variable.options=[],this.$nextTick(()=>{this.variable.options=e,this.handleChange()})}}},Qt={class:"opera"};function Gt(e,t,l,h,s,i){const u=o("el-input"),c=o("el-form-item"),b=o("InputTypeSelect"),C=o("el-button"),R=o("SortableButton"),f=o("el-table-column"),k=o("el-table"),w=o("OptionSettingWindow"),_=o("VariableInput"),v=o("el-switch"),V=o("CompilerSelect"),S=o("el-form"),q=K("sortable");return m(),y(S,{model:l.variable},{default:n(()=>[a(c,{label:e.$t("service.settings.variable.label"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=d=>l.variable.label=d),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.variable.name"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=d=>l.variable.name=d),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.variable.inputType"),required:""},{default:n(()=>[a(b,{modelValue:l.variable.inputType,"onUpdate:modelValue":t[2]||(t[2]=d=>l.variable.inputType=d),"with-group":i.withGroup,onChange:i.handleInputTypeChange},null,8,["modelValue","with-group","onChange"])]),_:1},8,["label"]),l.variable.inputType==="select"||l.variable.inputType==="checkbox"||l.variable.inputType==="radio"?(m(),y(c,{key:0,label:e.$t("service.settings.variable.options"),class:"item-options",required:""},{label:n(()=>[r("div",null,[r("label",null,p(e.$t("service.settings.variable.options")),1),r("div",Qt,[a(C,{type:"primary",onClick:i.createOption},{default:n(()=>[T(p(e.$t("common.add")),1)]),_:1},8,["onClick"])])])]),default:n(()=>[X((m(),y(k,{data:l.variable.options},{default:n(()=>[a(f,{width:"25px"},{default:n(()=>[a(R)]),_:1}),a(f,{label:"*"+e.$t("service.settings.variable.optionLabel"),"min-width":"200px"},{default:n(({row:d})=>[a(u,{modelValue:d.label,"onUpdate:modelValue":A=>d.label=A,type:"textarea",rows:1,onInput:i.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(f,{label:"*"+e.$t("service.settings.variable.optionValue"),"min-width":"120px"},{default:n(({row:d})=>[a(u,{modelValue:d.value,"onUpdate:modelValue":A=>d.value=A,onInput:i.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(f,{label:e.$t("common.remark"),"min-width":"150px"},{default:n(({row:d})=>[a(u,{modelValue:d.remark,"onUpdate:modelValue":A=>d.remark=A,type:"textarea",rows:1,onInput:i.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),l.variable.options.length>0?(m(),y(f,{key:0,"min-width":l.variable.inputType==="select"?"120px":"60px",fixed:"right"},{default:n(({row:d,$index:A})=>[l.variable.inputType==="select"?(m(),y(C,{key:0,icon:"Setting",class:"button-icon",onClick:se=>e.$refs.optionSettingWindow.open(d)},null,8,["onClick"])):N("",!0),a(C,{icon:"Delete",class:"button-icon",onClick:se=>i.deleteOption(A)},null,8,["onClick"])]),_:1},8,["min-width"])):N("",!0)]),_:1},8,["data"])),[[q,{data:l.variable.options,onChange:i.handleOptionSorted},"config"]]),a(w,{ref:"optionSettingWindow",onChange:i.handleChange},null,8,["onChange"])]),_:1},8,["label"])):N("",!0),a(c,{label:e.$t("service.settings.variable.defaultValue")},{default:n(()=>[a(_,{variable:l.variable,"value-key":"defaultValue",onChange:i.handleDefaultValueChange},null,8,["variable","onChange"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.variable.required")},{default:n(()=>[a(v,{modelValue:l.variable.required,"onUpdate:modelValue":t[3]||(t[3]=d=>l.variable.required=d),onChange:i.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.variable.hidden")},{default:n(()=>[a(v,{modelValue:l.variable.hidden,"onUpdate:modelValue":t[4]||(t[4]=d=>l.variable.hidden=d),onChange:i.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),l.variable.inputType!=="number_input"&&l.variable.inputType!=="table"&&l.variable.inputType!=="query_model"&&l.variable.inputType!=="datasource"&&l.rootVariable.inputType!=="query_model"&&l.rootVariable.inputType!=="table"?(m(),y(c,{key:1,label:e.$t("service.settings.variable.compiler")},{default:n(()=>[a(V,{modelValue:l.variable.compiler,"onUpdate:modelValue":t[5]||(t[5]=d=>l.variable.compiler=d),onChange:i.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"])):N("",!0),a(c,{label:e.$t("common.remark")},{default:n(()=>[a(u,{modelValue:l.variable.remark,"onUpdate:modelValue":t[6]||(t[6]=d=>l.variable.remark=d),type:"textarea",rows:3,onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const Jt=I(xt,[["render",Gt]]),Yt={name:"VariableGroupSettingForm",components:{VariableInput:x,CompilerSelect:D,InputTypeSelect:E},props:{variable:{required:!0}},methods:{changeScope(){if(this.variable.type==="group")for(const e of this.variable.children)e.scope=this.variable.scope;this.handleChange()},handleChange(){this.$emit("change")}}};function Ht(e,t,l,h,s,i){const u=o("el-input"),c=o("el-form-item"),b=o("el-form");return m(),y(b,{model:l.variable},{default:n(()=>[a(c,{label:e.$t("service.settings.variable.groupLabel"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=C=>l.variable.label=C),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(c,{label:e.$t("service.settings.variable.groupName"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=C=>l.variable.name=C),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const Kt=I(Yt,[["render",Ht]]);const Xt={name:"Variables",components:{VariableGroupSettingForm:Kt,VariableSettingForm:Jt,VariableInput:x,I18nInput:re,InputTypeSelect:E,CompilerSelect:D},props:{space:{required:!0},service:{required:!0},plugin:{required:!1}},data(){return{isWorking:{save:!1},timeout:{save:null},varIndex:1,groupIndex:1,currentVariable:null,currentGroup:null,currentRootVariable:null,variables:[],dragData:{target:null}}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},saveVariablesApi(){return this.isPlugin?be:me},fetchConfigApi(){return this.isPlugin?O:B}},methods:{selectVariable(e,t){this.currentVariable=null,this.$nextTick(()=>{this.currentVariable=e,this.currentGroup=null,this.currentRootVariable=null,t.level>2?(this.currentRootVariable=t.parent.parent.data,this.currentGroup=t.parent.data):t.level>1?(this.currentRootVariable=t.parent.data,this.currentGroup=t.parent.data):this.currentRootVariable=t.data})},createChild(e){if(e.type==="group"){this.createVariable(e);return}if(e.inputType==="query_model"){this.createGroup(e,[]);return}e.inputType==="table"&&this.createGroup(e,[])},createVariable(e){const t=this.__generateVariableName(e==null?this.variables:e.children),l={id:Q(),type:"variable",name:t,label:t,inputType:"input",required:!1,hidden:!1,defaultValue:"",compiler:"static",remark:"",options:[]};e!=null?e.children.push(l):this.variables.push(l),this.saveVariables()},createGroup(e,t){const l=this.__generateGroupName(),h={id:Q(),type:"group",name:l,label:l,children:[],defaultValue:t};e==null?this.variables.push(h):(e.children==null&&(e.children=[]),e.children.push(h)),this.currentVariable=h,this.saveVariables()},saveVariables(){this.timeout.save!=null&&clearTimeout(this.timeout.save),this.timeout.save=setTimeout(()=>{this.saveVariablesApi({...this.unique,variables:this.getVariables()}).then(()=>{}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.timeout.save=null})},1e3)},fetchVariables(){this.fetchConfigApi({...this.unique}).then(e=>{this.variables=e.variables.map(t=>this.__getInitVariable(t))}).catch(e=>{this.$tip.apiFailed(e)})},getVariables(){return this.variables.filter(t=>t.name.trim().length>0&&t.label.trim().length>0).map(t=>this.__getSaveVariable(t))},deleteVariable(){const e=this.currentVariable.type==="variable"?"variable":"variable group";this.deleteConfirm(`Do you want to delete the ${e} named 「${this.currentVariable.name}」?`).then(()=>{if(this.currentRootVariable!==this.currentVariable&&(this.currentRootVariable.inputType==="query_model"||this.currentRootVariable.inputType==="table")&&this.currentGroup!=null){const l=this.currentGroup.children.findIndex(h=>h.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1);for(const h of this.currentRootVariable.children)for(const s of h.defaultValue)for(const i in s){if(i==="origin")continue;h.children.find(c=>c.name===i)==null&&!s.origin.hasOwnProperty(i)&&delete s[i]}this.currentVariable=null,this.saveVariables();return}if(this.currentGroup!=null){const l=this.currentGroup.children.findIndex(h=>h.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1),this.currentVariable=null,this.saveVariables();return}const t=this.variables.findIndex(l=>l.id===this.currentVariable.id);t!==-1&&(this.variables.splice(t,1),this.currentVariable=null,this.saveVariables())}).catch(t=>{if(t!=="cancel")throw new Error(t)})},handleDragStart(e){this.dragData.target=e.data},handleDrop(){this.saveVariables()},allowDrag(){return!0},allowDrop(e,t,l){return e.data.type==="variable"?!(t.data.type==="variable"&&l==="inner"):e.data.type==="group"?t.data.type!=="variable":!1},__getValidOptions(e){return e.filter(t=>t.value.trim().length>0&&t.label.trim().length>0)},__getInitVariable(e){const t=JSON.parse(JSON.stringify(e));return t.type==="group"?(t.children=t.children==null?[]:t.children.map(l=>(l.options=l.options==null?[]:l.options,this.__getInitVariable(l))),t):(t.options=t.options==null?[]:t.options,t.options.forEach(l=>{l.settings=l.settings==null?[]:l.settings}),t.inputType==="select"&&(JSON.stringify(t.defaultValue.settings)==="{}"||t.options.forEach(l=>{l.settings=l.settings.map(h=>({...h,value:t.defaultValue.settings[h.name]}))})),t)},__getSaveVariable(e){const t=JSON.parse(JSON.stringify(e));return t.type==="group"?(t.children=t.children.map(l=>this.__getSaveVariable(l)),t):t.inputType==="number_input"?(t.defaultValue=parseInt(t.defaultValue),t):t.inputType==="query_model"||t.inputType==="table"?(t.children!=null&&t.children.length>0&&(t.children=t.children.map(l=>(l.children=l.children.map(h=>this.__getSaveVariable(h)),l))),delete t.options,t):t.inputType==="select"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{l.settings=l.settings.filter(h=>h.name.trim()!==""&&h.label.trim()!=="")}),t.options.forEach(l=>{l.settings.forEach(h=>{delete h.value})}),t):t.inputType==="radio"||t.inputType==="checkbox"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{delete l.settings}),t):(delete t.options,t)},__generateVariableName(e){let t;for(;;)if(t=`var${this.varIndex}`,this.varIndex++,e.findIndex(l=>l.type==="variable"&&l.name===t)===-1)return t},__generateGroupName(){let e;for(;;)if(e=`group${this.groupIndex}`,this.groupIndex++,this.variables.findIndex(t=>t.type==="group"&&t.name===e)===-1)return e}},created(){this.fetchVariables()}},Zt={class:"tree"},el={class:"variables-wrap"},tl={class:"tools"},ll={class:"title"},al={key:0,class:"opera"},nl={class:"variable-setting"},il={class:"title"},sl={class:"content-wrap"},ol={key:1,class:"variable-holder"};function rl(e,t,l,h,s,i){const u=o("el-button"),c=o("el-tree"),b=o("VariableSettingForm"