"use strict";(self.webpackChunk_coze_studio_app=self.webpackChunk_coze_studio_app||[]).push([["1793"],{317612:function(e,t,r){r.d(t,{q:()=>b});var o=r("808549"),i=r("473980"),n=r("151064"),l=r("455069"),a=r("550655"),s=r("120454"),d=r("664319"),c=r("252237"),u=r.n(c),p=r("277194"),m=r("336205"),v=r("775699"),f=r("30961"),_=r("458949");r("382534");var{Select:h,TextArea:g}=r("659596").l0;_.nw.NotFoundPlugin,m.o.t("plugin_feedback_modal_request_type_official_plugins_not_found"),_.nw.OfficialPlugin,m.o.t("plugin_feedback_modal_request_type_feedback_to_existing_plugin"),r("398778");var x=r("770131"),y=r("719894"),w=e=>{var{type:t,openMode:r,from:l,openModeCallback:a,showButton:c,showCopyPlugin:_,onCopyPluginCallback:h,pluginApiList:g,projectId:w,clickProjectPluginCallback:b,hideCreateBtn:j,initQuery:C}=e,k=(0,i._)(e,["type","openMode","from","openModeCallback","showButton","showCopyPlugin","onCopyPluginCallback","pluginApiList","projectId","clickProjectPluginCallback","hideCreateBtn","initQuery"]),{pluginApis:N,updateSkillPluginApis:S}=(0,p.Ee)((0,d.N)(e=>({pluginApis:e.pluginApis,updateSkillPluginApis:e.updateSkillPluginApis}))),{sider:E,filter:T,content:I}=(0,x.A)({pluginApiList:g?g:r===f.jG.OnlyOnceAdd?[]:N,onPluginApiListChange:S,openMode:r,from:l,openModeCallback:a,showButton:c,showCopyPlugin:_,onCopyPluginCallback:h,projectId:w,clickProjectPluginCallback:b,onCreateSuccess:null==k?void 0:k.onCreateSuccess,isShowStorePlugin:null==k?void 0:k.isShowStorePlugin,hideCreateBtn:j,initQuery:C});return(0,n.jsx)(v.FS,(0,s._)((0,o._)({"data-testid":"plugin-modal"},k),{header:m.o.t("bot_edit_plugin_select_title"),className:u()(y.Z["plugin-modal"],k.className),sider:E,extra:null,filter:T,content:I}))},b=e=>{var t=e||{},{closeCallback:r}=t,s=(0,i._)(t,["closeCallback"]),[d,c]=(0,l.useState)(!1),[u,p]=(0,l.useState)(1),[m,v]=(0,l.useState)();return{node:d?(0,n.jsx)(w,(0,o._)({type:u,visible:d,onCancel:()=>{c(!1),null==r||r()},initQuery:m,footer:null},s)):null,open:e=>{var t=(0,a.Z)(e)?e:null==e?void 0:e.openType,r=(0,a.Z)(e)?void 0:null==e?void 0:e.initQuery;c(!0),v(r),(0,a.Z)(t)&&p(t)},close:()=>{c(!1),v(void 0),null==r||r()}}}},770131:function(e,t,r){r.d(t,{A:()=>V});var o=r("808549"),i=r("120454"),n=r("151064"),l=r("455069"),a=r("664319"),s=r("287487"),d=r("76672"),c=r("388993"),u=r("214942"),p=r("117140"),m=r("178385"),v=r("833047"),f=r("252237"),_=r.n(f),h=r("336205"),g=r("775699"),x=r("44172"),y=r("150838"),w=e=>{var{isSearching:t,type:r,onChange:o,projectId:i,from:l,isShowStorePlugin:a=!0}=e,s=(0,u.rY)(e=>e.space.space_type),d=(0,v.ir)().id,c=e=>{if(t){o(e);return}if(e!==r)o(e)};return(0,n.jsxs)("div",{className:y.Z["tool-tag-list"],children:[s===m.Sn.Personal&&(0,n.jsxs)("div",{"data-testid":"plugin.modal.filter.option.mine",className:_()(y.Z["tool-tag-list-cell"],{[y.Z.active]:r===v.eL.Mine}),onClick:()=>c(v.eL.Mine),children:[(0,n.jsx)(x.ckl,{className:y.Z["tool-tag-list-cell-icon"]}),h.o.t("add_resource_modal_sidebar_library_tools")]}),i&&l===v.tx.ProjectWorkflow?(0,n.jsxs)("div",{className:_()(y.Z["tool-tag-list-cell"],{[y.Z.active]:r===v.eL.Project}),onClick:()=>c(v.eL.Project),children:[(0,n.jsx)(x.Qi1,{className:y.Z["tool-tag-list-cell-icon"]}),h.o.t("add_resource_modal_sidebar_project_tools")]}):null,a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.yh.Divider,{}),(0,n.jsx)("div",{className:y.Z["tool-content-area"],children:(0,n.jsx)("div",{className:_()(y.Z["tool-tag-list-cell"],{[y.Z.active]:r===d}),onClick:()=>c(d),children:h.o.t("explore_tools")})})]}):null]})},b=r("881305"),j=[{label:h.o.t("Create_time"),value:m.d$.CreateTime},{label:h.o.t("Update_time"),value:m.d$.UpdateTime}],C=e=>{var{query:t,setQuery:r}=e;return(0,n.jsx)("div",{className:b.Z["plugin-modal-filter"],children:t.type===v.eL.Mine||t.type===v.eL.Team||t.type===v.eL.Project?(0,n.jsxs)(g.Cj,{label:h.o.t("Sort"),value:t.orderBy,optionList:j,onChange:e=>{r({orderBy:e})},children:[(0,n.jsx)(g.Ph.Option,{value:m.d$.CreateTime,children:h.o.t("Create_time")}),(0,n.jsx)(g.Ph.Option,{value:m.d$.UpdateTime,children:h.o.t("Edit_time_2")})]}):null})},k=r("998600"),N=r("824113"),S=r("910376"),E=r("196163"),T=e=>{var{query:t,setQuery:r,from:o,onCreateSuccess:i,isShowStorePlugin:a,hideCreateBtn:s}=e,[d,c]=(0,l.useState)(!1),p=(0,u.rY)(e=>e.space.id),m=e=>{r({search:null!=e?e:""})},{run:f,cancel:_}=(0,k.Z)(e=>{m(e)},{wait:300});return(0,n.jsxs)(n.Fragment,{children:[s?null:(0,n.jsx)(S.rm,{projectId:t.projectId,isCreate:!0,visible:d,onSuccess:e=>{null==i||i({spaceId:p,pluginId:e})},onCancel:()=>{c(!1)}}),(0,n.jsxs)(g.yh,{style:{paddingTop:16},children:[(0,n.jsxs)(g.yh.Header,{children:[(0,n.jsx)(N.yO,{tabIndex:-1,value:t.search,maxLength:100,onSearch:e=>{e?f(e):(_(),m(e))},placeholder:h.o.t("Search"),"data-testid":"plugin.modal.search"}),s?null:(0,n.jsx)(g.y3,{"data-testid":"plugin.modal.create.plugin",className:E.Z.addbtn,theme:"solid",onClick:()=>{if(i&&(o===v.tx.ProjectIde||o===v.tx.ProjectWorkflow)){c(!0);return}window.open("/space/".concat(p,"/library?type=1"))},children:h.o.t("plugin_create")})]}),(0,n.jsx)(g.yh.Content,{children:(0,n.jsx)(w,{isSearching:""!==t.search,type:t.type,onChange:e=>{r({type:e})},from:o,projectId:t.projectId,isShowStorePlugin:a})})]})]})},I=r("322512"),D=r("136515"),P=r("309673"),A=r("938382"),L=r("364676"),O=r("44099"),M=r("825955"),F=r("298203"),z=r("366714"),Z=(e,t,r,o)=>(t||r)&&!o?{text:{emptyTitle:h.o.t("plugin_empty_desc"),emptyDesc:h.o.t("plugin_empty_description")},btn:{emptyClick:()=>{window.open("/space/".concat(e,"/library?type=1"))},emptyText:h.o.t("plugin_create")}}:{text:{emptyTitle:h.o.t("plugin_empty_desc"),emptyDesc:""},btn:{emptyClick:()=>{window.open("/store/plugin")},emptyText:h.o.t("mkl_plugin_to_plugin_gallery")}},R=e=>{var{query:t,pluginApiList:r,onPluginApiListChange:s,openMode:d,from:c,openModeCallback:p,showButton:m,showCopyPlugin:f,onCopyPluginCallback:h,clickProjectPluginCallback:x}=e,{type:y,mineActive:w,search:b,isOfficial:j,orderBy:C,orderByPublic:k,orderByFavorite:N,agentId:S,pluginType:E}=t,T=(0,u.rY)(e=>e.space.id),R=(0,l.useRef)(null),[B,V]=(0,l.useState)([]),U=(0,l.useRef)(null),{scroll2Top:W,loadData:H,isSearching:G,isFavorite:K,isTemplate:q,isProject:J,isMine:$,isTeam:X}=function(e){var t,{scrollContainer:r,query:n,triggerService:a,formatCacheKey:s,onSetScrollData:d}=e,{search:c,type:u,mineActive:p}=n,m=""!==c,f=u===v.eL.Mine,_=u===v.eL.Team,h=u===v.eL.Favorite,g=u===v.eL.Project,x=p===v.gp.Mine,y=Number(u)>=0||"recommend"===u,w=(e,t,r)=>{var n=(0,F.lJ)(t);if(!t||!n)return!1;var{data:l}=n;if(!r)return n.data;var a=(null==e?void 0:e.nextPage)||1,{list:s,total:c}=l||{list:[],total:0},u=c>0&&a*v.L8{if(!!e)(0,F.K7)(e,t,{time:Date.now(),data:r})};var j=(t=(0,M._)(function*(e){var t=(null==e?void 0:e.nextPage)||1,r=s({query:n,isSearching:m,isTemplate:y,page:t})||"";!f&&!_&&(r="");var o=w(e,r,!y);!o&&b(r,3e5,o=yield a(n,{nextPage:t,isMine:f,isTeam:_,isCreatorMine:x,isTemplate:y,isFavorite:h,isProject:g}));var{list:i,hasMore:l}=o||{list:[],total:0},d=t+1,c={};return((null==e?void 0:e.list)||[]).map(e=>{var t;c[null==e?void 0:null===(t=e.pluginInfo)||void 0===t?void 0:t.id]=!0}),{list:(i||[]).filter(e=>{var t,r=null==e?void 0:null===(t=e.pluginInfo)||void 0===t?void 0:t.id;return(!r||!c[r])&&!0})||[],hasMore:l,nextPage:d}}),function(e){return t.apply(this,arguments)});return(0,l.useEffect)(()=>{(0,F.LK)()},[]),{scroll2Top:()=>{r.current&&r.current.scrollTo({top:0})},isSearching:m,loadData:j,isFavorite:h,isTemplate:y,isMine:f,isTeam:_,isProject:g}}({query:t,formatCacheKey:v.TB,scrollContainer:R,triggerService:v.Ht,onSetScrollData:e=>{var t;null===(t=U.current)||void 0===t||t.mutate(e)}}),{nodes:Y}=(0,L.I)((0,a.N)(e=>({nodes:e.nodes})));return(0,D.Z)(()=>{W()},[]),(0,n.jsx)(g.vy,{children:(0,n.jsx)("div",{className:z.Z["plugin-content"],ref:R,children:(0,n.jsx)(g.vy.Content,{style:{minHeight:"100%",display:"flex"},children:(0,n.jsx)(g.UO,{className:z.Z["plugin-collapse"],activeKey:B,onChange:e=>{V(e)},expandIcon:(0,n.jsx)(P.Z,{className:z.Z["collapse-icon"],"data-testid":"plugin-collapse-panel-expand"}),collapseIcon:(0,n.jsx)(A.Z,{className:z.Z["collapse-icon"],"data-testid":"plugin-collapse-panel-collapse"}),children:(0,n.jsx)(O.$r,{ref:U,itemClassName:z.Z["item-container"],renderItem:(e,t)=>{var l,a,u,g=null==e?void 0:null===(l=e.pluginInfo)||void 0===l?void 0:l.id;return(0,n.jsx)(v.WB,{agentId:S,index:t,pluginApiList:r,onPluginApiListChange:s,onCopyPluginCallback:h,showButton:m,showCopyPlugin:f,openMode:d,from:c,workflowNodes:Y,openModeCallback:p,highlightWords:[b],showCreator:!0,showMarketLink:K||q,showCreateTime:0===C||"number"==typeof y,showPublishTime:!$&&!X&&!J,activeKey:B,scrollContainerRef:R,isFromMarket:null==e?void 0:e.isFromMarket,info:(0,i._)((0,o._)({},null==e?void 0:e.pluginInfo),{id:g,listed_at:null==e?void 0:null===(a=e.productInfo)||void 0===a?void 0:a.listed_at,plugin_apis:(0,I.Z)(null==e?void 0:null===(u=e.pluginInfo)||void 0===u?void 0:u.plugin_apis,e=>e.name)}),productInfo:null==e?void 0:e.productInfo,commercialSetting:null==e?void 0:e.commercial_setting,type:String(y||""),className:_()(z.Z["plugin-collapse"],{[z.Z.activePanel]:null==B?void 0:B.includes(null!=g?g:"")}),showProjectPluginLink:J,clickProjectPluginCallback:x},g)},emptyConf:Z(T,$,X,J),scrollConf:{reloadDeps:[y,w,b,j,C,k,N,E],targetRef:R,loadData:H},isSearching:G})})})})})},B=(e,t)=>e!==v.tx.ProjectWorkflow&&e===v.tx.ProjectIde&&t&&e?t===m.Sn.Personal?v.eL.Mine:t===m.Sn.Team&&e===v.tx.ProjectIde?v.eL.Team:"":"",V=e=>{var t,r,{pluginApiList:f,onPluginApiListChange:_,agentId:h,openMode:g,from:x,openModeCallback:y,showButton:w,showCopyPlugin:b,onCopyPluginCallback:j,projectId:k,clickProjectPluginCallback:N,onCreateSuccess:S,isShowStorePlugin:E,hideCreateBtn:I,initQuery:D}=e,P=s.Z.useUserInfo(),A=(0,u.rY)(e=>e.space.space_type),[L,O]=(0,l.useState)({agentId:h,projectId:k,devId:(null==P?void 0:P.user_id_str)||"",search:"",page:v.XJ,type:null!==(t=null==D?void 0:D.type)&&void 0!==t?t:B(x,A),orderBy:m.d$.CreateTime,orderByPublic:p.ER.Heat,orderByFavorite:p.ER.Newest,mineActive:v.gp.All,isOfficial:null!==(r=null==D?void 0:D.isOfficial)&&void 0!==r?r:void 0,pluginType:x===v.tx.ProjectWorkflow?p.zV.CLoudPlugin:void 0}),{botId:M}=(0,c.G)((0,a.N)(e=>({botId:e.botId}))),{version:F}=(0,d.c2)((0,a.N)(e=>({version:e.baseVersion}))),z=function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r={current_entity_type:p._J.Bot,current_entity_id:M,current_entity_version:F};O(n=>t?(0,i._)((0,o._)({},n,e),{page:v.XJ,botInfo:r}):(0,i._)((0,o._)({},n,e),{botInfo:r}))},Z=(0,n.jsx)(T,{hideCreateBtn:I,query:L,setQuery:z,from:x,onCreateSuccess:S,isShowStorePlugin:E}),V=(0,n.jsx)(C,{from:x,query:L,setQuery:z});return{sider:Z,content:(0,n.jsx)(R,{query:L,setQuery:z,pluginApiList:f,onPluginApiListChange:_,openMode:g,from:x,openModeCallback:y,showButton:w,showCopyPlugin:b,onCopyPluginCallback:j,clickProjectPluginCallback:N}),filter:V}}},910376:function(e,t,r){r.d(t,{Tj:()=>er,cC:()=>en,e2:()=>ei,rm:()=>Y,_u:()=>eo});var o,i,n=r("825955"),l=r("151064"),a=r("455069"),s=r("808549"),d=r("120454"),c=r("735114"),u=r("215451"),p=r("581259"),m=r("368696"),v=r("75117"),f=r("297158"),_=r("336205"),h=r("873183"),g=r("659596"),x=r("298203"),y=r("189284"),w=r("178385"),b=r("382534"),j=r("625196"),C=r("458949"),k={name:[{required:!0,message:_.o.t("create_plugin_modal_name1_error")},{pattern:RegExp("^[\\w\\s\\u4e00-\\u9fa5]+$","u"),message:_.o.t("create_plugin_modal_nameerror_cn")}],desc:[{required:!0,message:_.o.t("create_plugin_modal_descrip1_error")},{}],url:[{required:!0,message:_.o.t("create_plugin_modal_url1_error")}],key:[{required:!0,message:_.o.t("create_plugin_modal_Parameter_error")},{pattern:/^[\x00-\x7F]+$/,message:_.o.t("plugin_Parametename_error")}],service_token:[{required:!0,message:_.o.t("create_plugin_modal_Servicetoken_error")}]},N=e=>{var t,r;if(!!e)return[{url:(null===(t=e.icon)||void 0===t?void 0:t.url)||"",uid:(null==e?void 0:null===(r=e.icon)||void 0===r?void 0:r.uri)||""}]},S=(e,t,r)=>{if((null==t?void 0:t[0])===0)return e.find(e=>0===e.value);if((null==t?void 0:t[0])===1){var o=e.find(e=>1===e.value);return null==o?void 0:o.children.find(e=>e.value===r)}if((null==t?void 0:t[0])===3){var i=e.find(e=>3===e.value);return null==i?void 0:i.children.find(e=>e.value===r)}},E=()=>{var e,[t,r]=(0,a.useState)([]),[o,i]=(0,a.useState)([]),[l,s]=(0,a.useState)("1");var d=(e=(0,n._)(function*(){var e,t,o=yield b.Js.GetOAuthSchema();r([{label:_.o.t("create_plugin_modal_Authorization_no"),value:0,key:"None"},{label:_.o.t("create_plugin_modal_Authorization_service"),value:1,key:"Service",children:[{label:_.o.t("plugin_auth_method_service_api_key"),value:0,key:"Service Token / API Key"}]},{label:_.o.t("create_plugin_modal_Authorization_oauth"),value:3,key:"OAuth",children:(0,x.dj)(o.oauth_schema)}]);var n=null===(t=(0,x.dj)(o.ide_conf,[]))||void 0===t?void 0:null===(e=t.find)||void 0===e?void 0:e.call(t,e=>"code_runtime_enum"===e.key);n&&(i(n.options.map(e=>({value:e.value,label:e.name}))),s(n.default))}),function(){return e.apply(this,arguments)});return(0,a.useEffect)(()=>{d()},[]),{authOption:t,runtimeOptions:o,defaultRuntime:l}},T=e=>{var t,r,o,i,n,{val:l,spaceId:a,headerList:c,projectId:u,creationMethod:p,defaultRuntime:m,pluginType:v,extItemsJSON:f}=e,_=null===(t=l.auth_type)||void 0===t?void 0:t.at(0),h=null===(r=l.auth_type)||void 0===r?void 0:r.at(-1),g=(0,d._)((0,s._)({},l),{icon:{uri:null==l?void 0:null===(i=l.plugin_uri)||void 0===i?void 0:null===(o=i[0])||void 0===o?void 0:o.uid},auth_type:_,common_params:{[C.Pi.Header]:c,[C.Pi.Body]:[],[C.Pi.Path]:[],[C.Pi.Query]:[]},space_id:a,project_id:u,creation_method:p,ide_code_runtime:null!==(n=l.ide_code_runtime)&&void 0!==n?n:m,plugin_type:Number(v),private_link_id:"0"===l.private_link_id?void 0:l.private_link_id});return 1===_?(0,d._)((0,s._)({},g),{sub_auth_type:h,auth_payload:JSON.stringify(f)}):(0,d._)((0,s._)({},g),{sub_auth_type:3===_?h:void 0,oauth_info:JSON.stringify(f)})};var I=(o=(0,n._)(function*(e){var{params:t}=e;return(yield b.Js.RegisterPluginMeta((0,s._)({},t),{__disableErrorToast:!0})).plugin_id}),function(e){return o.apply(this,arguments)});var D=(i=(0,n._)(function*(e){var{params:t,editInfo:r}=e;return yield b.Js.UpdatePluginMeta((0,d._)((0,s._)({},t),{plugin_id:(null==r?void 0:r.plugin_id)||"",edit_version:null==r?void 0:r.edit_version}),{__disableErrorToast:!0}),""}),function(e){return i.apply(this,arguments)}),P=r("274038"),A=e=>e?"".concat(null==e?void 0:e.plugin_type,"-").concat(null==e?void 0:e.creation_method):"",L=(0,g.Q2)(g.vT),O=()=>[{label:_.o.t("plugin_creation_method_cloud_plugin_use_existing_services"),value:p.Qb}],M=e=>{var t,r,o,i,C,E,T,I,D,M,F,z,Z,R,B,V,U,W,H,{pluginState:G,disabled:K,editInfo:q,isCreate:J,visible:$}=e,{formApi:X,extItems:Y,setExtItems:Q,headerList:ee,setHeaderList:et,isValidCheckResult:er,setIsValidCheckResult:eo,pluginTypeCreationMethod:ei,setPluginTypeCreationMethod:en,authOption:el}=G,[ea]=(0,y.V)(),{compareLevel:es}=(0,u.th)(),ed=(0,m.HU)(),[ec,eu]=(0,a.useState)(0),[ep,em]=(0,a.useState)(0),[ev,ef]=(0,a.useState)(!1),e_=()=>{!er&&eo(!0)},eh=O(),eg=(0,p.C5)(),[ex,ey]=(0,a.useState)(),{data:ew}=(0,c.Z)((0,n._)(function*(){var e,{data:t}=yield b.Js.PrivateLinkList({enterprise_id:null==ed?void 0:ed.enterprise_id});ey(null==t?void 0:t.private_links);var r=null==t?void 0:null===(e=t.private_links)||void 0===e?void 0:e.map(e=>({label:e.name,value:e.id}));return[{label:_.o.t("vpc_plugin_create_plugin_2"),value:"0"},...null!=r?r:[]]}),{ready:es===u.aZ.Enterprise&&ea["bot.studio.plugin_vpc"]&&!1});var eb=(t=(0,n._)(function*(){try{var e,t,r,o=yield b.nA.GetIcon({icon_type:w.Tu.Plugin}),i=null===(t=o.data)||void 0===t?void 0:null===(e=t.icon_list)||void 0===e?void 0:e[0];if(!i)return;var{url:n="",uri:l=""}=i;null===(r=X.current)||void 0===r||r.setValue("plugin_uri",[{url:n,uid:l}])}catch(e){f.kg.info("getIcon error: ".concat(e))}}),function(){return t.apply(this,arguments)});(0,a.useEffect)(()=>{if(!!$)if(!J&&q){var e,t,r,o,i,n,l,a,s,d,c,p,m,v,f,_,h,g;if((null===(t=q.meta_info)||void 0===t?void 0:null===(e=t.auth_type)||void 0===e?void 0:e.at(0))===1)switch(null===(m=q.meta_info)||void 0===m?void 0:m.sub_auth_type){case 0:em(5);break;case 1:em(6);break;case 2:em(7);break;default:em(0)}else em(null!==(_=null===(f=q.meta_info)||void 0===f?void 0:null===(v=f.auth_type)||void 0===v?void 0:v.at(-1))&&void 0!==_?_:0);eu(null!==(h=null===(o=q.meta_info)||void 0===o?void 0:null===(r=o.auth_type)||void 0===r?void 0:r.at(0))&&void 0!==h?h:0),Q((null===(i=S(el,null===(n=q.meta_info)||void 0===n?void 0:n.auth_type,null!==(g=null===(a=q.meta_info)||void 0===a?void 0:null===(l=a.auth_type)||void 0===l?void 0:l[1])&&void 0!==g?g:null===(s=q.meta_info)||void 0===s?void 0:s.sub_auth_type))||void 0===i?void 0:i.items)||[]),et([...(null===(c=q.meta_info)||void 0===c?void 0:null===(d=c.common_params)||void 0===d?void 0:d[4])||[]]),en("".concat(q.plugin_type,"-").concat(q.creation_method)),(null==q?void 0:null===(p=q.meta_info)||void 0===p?void 0:p.private_link_id)&&es===u.aZ.Enterprise&&ea["bot.studio.plugin_vpc"]&&ef(!0)}else ej()},[$]);var ej=()=>{eb(),em(0),em(0),Q([]),et([{name:"User-Agent",value:"Coze/1.0"}]),eo(!0),en(void 0)},eC=()=>{et(e=>[...e,{name:"",value:""}])},ek=e=>{et(t=>t.length<=1?[{name:"",value:""}]:t.filter((t,r)=>r!==e))},eN=(e,t)=>{et(r=>r.map((r,o)=>o===e?t:r))};return(0,l.jsxs)(g.l0,{getFormApi:e=>X.current=e,autoScrollToError:!0,showValidateIcon:!1,className:P.Z["upload-form"],onValueChange:e=>{if("auth_type"in e){if(1===e.auth_type.at(0))switch(e.auth_type.at(-1)){case 0:em(5);break;case 1:em(6);break;case 2:em(7);break;default:em(0)}else em(e.auth_type.at(-1));eu(e.auth_type.at(0))}},children:[(0,l.jsx)(v.s,{noLabel:!0,disabled:K,fieldClassName:P.Z["upload-field"],field:"plugin_uri",iconType:w.Tu.Plugin,fileBizType:w.ym.BIZ_PLUGIN_ICON,initValue:N(null==q?void 0:q.meta_info),onChange:e_}),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(g.ld,{disabled:K,initValue:null==q?void 0:null===(U=q.meta_info)||void 0===U?void 0:U.name,field:"name",className:P.Z["textarea-single-line"],label:_.o.t("create_plugin_modal_name1"),placeholder:_.o.t("create_plugin_modal_name2"),trigger:["blur","change"],maxCount:30,maxLength:30,rows:1,onBlur:()=>{var e,t,r;null===(r=X.current)||void 0===r||r.setValue("name",null===(t=X.current)||void 0===t?void 0:null===(e=t.getValue("name"))||void 0===e?void 0:e.trim())},onChange:e_,rules:k.name}),(0,l.jsx)(g.ld,{disabled:K,initValue:null==q?void 0:null===(W=q.meta_info)||void 0===W?void 0:W.desc,field:"desc",label:_.o.t("create_plugin_modal_descrip1"),trigger:["blur","change"],placeholder:_.o.t("create_plugin_modal_descrip2"),rows:2,maxCount:600,maxLength:600,onBlur:()=>{var e,t,r;null===(r=X.current)||void 0===r||r.setValue("desc",null===(t=X.current)||void 0===t?void 0:null===(e=t.getValue("desc"))||void 0===e?void 0:e.trim())},onChange:e_,rules:k.desc}),(0,l.jsx)(g.l0.Slot,{label:{text:_.o.t("plugin_creation_method"),required:!0,extra:(0,l.jsx)(j.O,{data:eg})},children:J?(0,l.jsx)(g.l0.RadioGroup,{noLabel:!0,className:P.Z["creation-method"],direction:"vertical",rules:[{required:!0,message:_.o.t("plugin_creation_select_creation_method_warning")}],field:"creation_method",disabled:K,options:eh,initValue:q?A(q):void 0,onChange:e=>en(e.target.value)}):(0,l.jsx)(g.ZT.Text,{fontSize:"14px",children:null===(H=eh.find(e=>e.value===ei))||void 0===H?void 0:H.label})})]}),ei===p.Qb?(V=[0],!q&&(V=[0]),(null==q?void 0:null===(o=q.meta_info)||void 0===o?void 0:null===(r=o.auth_type)||void 0===r?void 0:r.length)===2?V=null==q?void 0:null===(D=q.meta_info)||void 0===D?void 0:D.auth_type:(null==q?void 0:null===(F=q.meta_info)||void 0===F?void 0:null===(M=F.auth_type)||void 0===M?void 0:M.at(0))===0?V=null==q?void 0:null===(z=q.meta_info)||void 0===z?void 0:z.auth_type:void 0!==(null==q?void 0:null===(Z=q.meta_info)||void 0===Z?void 0:Z.sub_auth_type)&&(V=[...(null==q?void 0:null===(R=q.meta_info)||void 0===R?void 0:R.auth_type)||[],null==q?void 0:null===(B=q.meta_info)||void 0===B?void 0:B.sub_auth_type]),(0,l.jsxs)(l.Fragment,{children:[es===u.aZ.Enterprise&&ea["bot.studio.plugin_vpc"]?(0,l.jsx)(g.ih,{label:{text:_.o.t("vpc_plugin_create_plugin_1"),required:!0,extra:(0,l.jsx)(j.O,{data:p.HW.private_link_id})},field:"private_link_id",style:{width:"100%"},initValue:(null==q?void 0:null===(i=q.meta_info)||void 0===i?void 0:i.private_link_id)||"0",onChange:e=>{var t,r,o;ef("0"!==e),"0"===e?null===(t=X.current)||void 0===t||t.setValue("url",""):null===(o=X.current)||void 0===o||o.setValue("url",null==ex?void 0:null===(r=ex.find(t=>t.id===e))||void 0===r?void 0:r.plugin_access_url)},optionList:ew}):null,K?null:(0,l.jsx)(g.yt,{disabled:ev,className:P.Z["textarea-single-line"],initValue:null==q?void 0:null===(C=q.meta_info)||void 0===C?void 0:C.url,trigger:["blur","change"],field:"url",label:_.o.t("create_plugin_modal_url1"),placeholder:_.o.t("create_plugin_modal_url2"),onBlur:()=>{var e,t,r;null===(r=X.current)||void 0===r||r.setValue("url",null===(t=X.current)||void 0===t?void 0:null===(e=t.getValue("url"))||void 0===e?void 0:e.trim())},rules:ev?[]:k.url}),(0,l.jsx)(g.l0.Slot,{className:P.Z["header-list"],label:{text:_.o.t("plugin_create_header_list_title"),align:"right",extra:(0,l.jsxs)("div",{className:P.Z["header-list-extra"],children:[(0,l.jsx)(j.O,{data:p.HW.header_list}),ee.length<20&&!K&&(0,l.jsx)(g.hU,{size:"small",color:"secondary",icon:(0,l.jsx)(h.PwN,{className:"coz-fg-hglt text-[16px]"}),onClick:eC})]})},children:(0,l.jsxs)("div",{className:P.Z["header-list-box"],children:[(0,l.jsxs)(g.X2,{className:P.Z["header-row"],children:[(0,l.jsx)(g.JX,{span:9,children:(0,l.jsx)("div",{className:P.Z["header-col-content"],children:"Key"})}),(0,l.jsx)(g.JX,{span:12,children:(0,l.jsx)("div",{className:P.Z["header-col-content"],children:"Value"})}),(0,l.jsx)(g.JX,{span:3,children:(0,l.jsx)("div",{className:P.Z["header-col-content"],children:_.o.t("plugin_create_action_btn")})})]}),(0,l.jsx)("div",{children:null==ee?void 0:ee.map((e,t)=>(0,l.jsxs)(g.X2,{type:"flex",justify:"space-between",align:"middle",children:[(0,l.jsx)(g.JX,{span:9,children:(0,l.jsx)("div",{className:P.Z["col-content"],children:(0,l.jsx)(g.II,{placeholder:"Name",value:e.name,onChange:r=>{eN(t,(0,d._)((0,s._)({},e),{name:r}))},maxLength:100,disabled:K})})}),(0,l.jsx)(g.JX,{span:12,children:(0,l.jsx)("div",{className:P.Z["col-content"],children:(0,l.jsx)(g.II,{placeholder:"Value",value:e.value,onChange:r=>{eN(t,(0,d._)((0,s._)({},e),{value:r}))},maxLength:2e3,disabled:K})})}),(0,l.jsx)(g.JX,{span:3,children:(0,l.jsx)("div",{className:P.Z["col-content"],children:(0,l.jsx)(g.hU,{size:"small",color:"secondary",icon:(0,l.jsx)(h.dVD,{className:"coz-fg-secondary text-[14px]"}),disabled:K,onClick:()=>ek(t)})})})]},t))})]})}),(0,l.jsx)(L,{disabled:K,rules:[{required:!0}],style:{width:"100%"},initValue:V,field:"auth_type",label:{text:_.o.t("create_plugin_modal_auth1"),extra:(0,l.jsx)(j.O,{data:p.HW.auth})},placeholder:_.o.t("please_select_an_authorization_method"),treeData:el,displayRender:e=>"".concat(e.at(-1)),onChange:e=>{var t;Q((null===(t=S(el,[e.at(0)],e.at(-1)))||void 0===t?void 0:t.items)||[])}}),1===ec&&5===ep&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(g.l0.RadioGroup,{disabled:K,rules:[{required:!0}],field:"location",label:{text:_.o.t("create_plugin_modal_location"),extra:(0,l.jsx)(j.O,{data:p.HW.location})},options:p.cg,initValue:(null==q?void 0:null===(E=q.meta_info)||void 0===E?void 0:E.location)||1}),(0,l.jsx)(g.yt,{disabled:K,initValue:null==q?void 0:null===(T=q.meta_info)||void 0===T?void 0:T.key,trigger:["blur","change"],field:"key",label:{text:_.o.t("create_plugin_modal_Parameter"),extra:(0,l.jsx)(j.O,{data:p.HW.key})},placeholder:_.o.t("create_plugin_modal_Parameter_empty"),maxLength:100,rules:k.key}),(0,l.jsx)(g.yt,{disabled:K,initValue:null==q?void 0:null===(I=q.meta_info)||void 0===I?void 0:I.service_token,trigger:["blur","change"],field:"service_token",label:{text:_.o.t("create_plugin_modal_Servicetoken"),extra:(0,l.jsx)(j.O,{data:p.HW.service_token})},placeholder:_.o.t("create_plugin_modal_Servicetoken_empty"),maxLength:2e3,rules:k.service_token})]}),null==Y?void 0:Y.map((e,t)=>{var r,o,i,n,s={};return((null==q?void 0:null===(o=q.meta_info)||void 0===o?void 0:null===(r=o.auth_type)||void 0===r?void 0:r.at(0))===1&&(s=(0,x.dj)(q.meta_info.auth_payload)),(null==q?void 0:null===(n=q.meta_info)||void 0===n?void 0:null===(i=n.auth_type)||void 0===i?void 0:i.at(0))===3&&(s=(0,x.dj)(q.meta_info.oauth_info)),"select"===e.type)?(0,l.jsx)(g.ih,{disabled:K,label:(null==e?void 0:e.label)||e.key,field:e.key,optionList:p.Cx,initValue:(null==s?void 0:s[e.key])||e.default,style:{width:"100%"},rules:[{required:e.required,message:p.VF[e.key]}]},e.key+t):(0,l.jsx)(a.Fragment,{children:(0,l.jsx)(g.yt,{disabled:K,trigger:["blur","change"],field:e.key,label:{text:(null==e?void 0:e.label)||e.key,extra:p.HW[e.key]&&(0,l.jsx)(j.O,{data:p.HW[e.key]})},placeholder:p.VF[e.key],initValue:(null==s?void 0:s[e.key])||e.default,maxLength:e.max_len,rules:[{required:e.required,message:p.VF[e.key]},"url"===e.type?{pattern:/^(http|https):\/\/.+$/,message:_.o.t("create_plugin_modal_URLerror")}:{pattern:/^[\x00-\x7F]+$/,message:_.o.t("create_plugin_modal_descrip_error")},...(null==e?void 0:e.ruleList)||[]]},e.key)},e.key+t)})]})):null]})},F=()=>{var e=(0,a.useRef)(),{authOption:t,runtimeOptions:r,defaultRuntime:o}=E(),[i,n]=(0,a.useState)([]),[l,s]=(0,a.useState)([{name:"User-Agent",value:"Coze/1.0"}]),[d,c]=(0,a.useState)(!0),[u,p]=(0,a.useState)();return{formApi:e,extItems:i,setExtItems:n,headerList:l,setHeaderList:s,isValidCheckResult:d,setIsValidCheckResult:c,pluginTypeCreationMethod:u,setPluginTypeCreationMethod:p,authOption:t,runtimeOptions:r,defaultRuntime:o}},z=r("947578"),Z=r("214942"),R=r("900021"),B=r("927070"),V=r("3779"),U=r("786406"),W=e=>{var{onCancel:t,onSuccess:r,projectId:o}=e,[i,n]=(0,a.useState)(!1);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(U.iy,{projectId:o,visible:i,onSuccess:e=>{var t=null==e?void 0:e.plugin_id;t?null==r||r(t):null==r||r()},onCancel:()=>n(!1)}),(0,l.jsx)(g.zx,{color:"primary",onClick:()=>{n(!0),null==t||t()},children:_.o.t("import")})]})},H=r("44172"),G=r("252237"),K=r.n(G),q=r("775699"),J=r("512421"),$=e=>{var t,{isCreate:r=!0,onCancel:o,editInfo:i,visible:c,onSuccess:u,disabled:p=!1,actions:m,projectId:v}=e,[f,h]=(0,a.useState)(),[g,y]=(0,a.useState)(),[w,j]=(0,a.useState)(),[C,k]=(0,a.useState)(),[N,S]=(0,a.useState)();(0,a.useEffect)(()=>{if(c){var e,t,r,o,n;h(JSON.stringify((0,x.dj)(null==i?void 0:null===(e=i.code_info)||void 0===e?void 0:e.plugin_desc),null,2)||""),S((null==i?void 0:null===(t=i.code_info)||void 0===t?void 0:t.openapi_desc)||""),y(null==i?void 0:null===(r=i.code_info)||void 0===r?void 0:r.client_id),j(null==i?void 0:null===(o=i.code_info)||void 0===o?void 0:o.client_secret),k(null==i?void 0:null===(n=i.code_info)||void 0===n?void 0:n.service_token)}},[c]);var E=(t=(0,n._)(function*(){var e,t,n={ai_plugin:f,client_id:g,client_secret:w,service_token:C,openapi:N};r?t=yield b.Js.RegisterPlugin((0,d._)((0,s._)({},n),{project_id:v,space_id:Z.rY.getState().getSpaceId()})):yield b.Js.UpdatePlugin((0,d._)((0,s._)({},n),{plugin_id:null==i?void 0:i.plugin_id,edit_version:null==i?void 0:i.edit_version})),q.FN.success({content:r?_.o.t("register_success"):_.o.t("Plugin_update_success"),showClose:!1}),null==u||u(null==t?void 0:null===(e=t.data)||void 0===e?void 0:e.plugin_id),null==o||o()}),function(){return t.apply(this,arguments)});return(0,l.jsx)(q.M5,{fullScreen:!0,className:"full-screen-modal",title:(0,l.jsxs)("div",{className:B.Z["bot-code-edit-title-action"],children:[(0,l.jsx)("span",{children:r?_.o.t("plugin_create"):_.o.t("plugin_Update")}),(0,l.jsx)("div",{children:m})]}),visible:c,onCancel:()=>null==o?void 0:o(),footer:p?null:(0,l.jsxs)(q.T,{children:[(0,l.jsx)(q.y3,{type:"tertiary",onClick:()=>null==o?void 0:o(),children:_.o.t("Cancel")}),(0,l.jsx)(q.y3,{type:"primary",onClick:E,children:_.o.t("Confirm")})]}),maskClosable:!1,children:(0,l.jsx)("div",{className:K()(B.Z.flex),children:(0,l.jsx)("div",{className:K()(B.Z["plugin-height"],B.Z.flex5),children:(0,l.jsxs)("div",{style:{display:"flex"},children:[(0,l.jsxs)("div",{style:{flex:1,borderRight:"1px solid rgb(215,218,221)"},children:[(0,l.jsx)("div",{className:B.Z.title,children:_.o.t("ai_plugin_(fill_in_json)_*")}),(0,l.jsx)(J.M,{dataTestID:"create-plugin-code-editor-json",disabled:p,theme:"tomorrow",mode:"json",height:560,value:f,useValidate:!1,onChange:e=>h(e)})]}),(0,l.jsxs)("div",{style:{flex:1},children:[(0,l.jsx)("div",{className:B.Z.title,children:_.o.t("openapi_(fill_in_yaml)_*")}),(0,l.jsx)(J.M,{dataTestID:"create-plugin-code-editor-yaml",disabled:p,theme:"tomorrow",mode:"yaml",height:560,value:N,useValidate:!1,onChange:e=>S(e)})]})]})})})})},X=e=>{var{onCancel:t,onSuccess:r,projectId:o}=e,[i,n]=(0,a.useState)(!1);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)($,{isCreate:!0,visible:i,onSuccess:e=>{null==r||r(e)},onCancel:()=>{n(!1)},projectId:o}),(0,l.jsx)(g.zx,{"data-testid":"create-plugin-code-modal-button",color:"primary",icon:(0,l.jsx)(H.WTs,{}),onClick:()=>{n(!0),null==t||t()}})]})},Y=e=>{var t,{onCancel:r,editInfo:o,isCreate:i=!0,visible:s,onSuccess:d,disabled:c=!1,projectId:u}=e,{id:p}=(0,Z.rY)(e=>e.space),m=(0,a.useMemo)(()=>i?(0,l.jsxs)("div",{className:"w-full flex justify-between items-center pr-[8px]",children:[(0,l.jsx)("div",{children:_.o.t("create_plugin_modal_title1")}),(0,l.jsxs)(g.T,{children:[(0,l.jsx)(X,{onCancel:r,onSuccess:d,projectId:u}),(0,l.jsx)(W,{onCancel:r,onSuccess:d,projectId:u}),(0,l.jsx)(g.iz,{layout:"vertical",className:"h-5"})]})]}):c?_.o.t("plugin_detail_view_modal_title"):_.o.t("plugin_detail_edit_modal_title"),[i,c]),[v,f]=(0,a.useState)(!1),x=F(),{formApi:y,extItems:w,headerList:b,isValidCheckResult:j,setIsValidCheckResult:C,pluginTypeCreationMethod:k,defaultRuntime:N}=x;(0,a.useEffect)(()=>{if(!!i)if(s){var e,t=document.querySelector(".create-plugin-modal-content .semi-modal-body");t&&(t.scrollTop=0)}else null==y||null===(e=y.current)||void 0===e||e.reset()},[s]);var S=(t=(0,n._)(function*(){yield null===(e=y.current)||void 0===e?void 0:e.validate();var e,t,n=i?"create":"edit",l=null===(t=y.current)||void 0===t?void 0:t.getValues();if(!!l&&!!k){var a={};null==w||w.forEach(e=>{e.key in l&&(a[e.key]=l[e.key])});var[s,c]=k.split("-"),m=T({val:l,spaceId:String(p),headerList:b,projectId:u,creationMethod:Number(c),defaultRuntime:N,pluginType:Number(s),extItemsJSON:a});try{f(!0);var v=yield({create:()=>I({params:m}),edit:()=>D({params:m,editInfo:o})})[n]();g.FN.success({content:i?_.o.t("Plugin_new_toast_success"):_.o.t("Plugin_update_toast_success"),showClose:!1}),null==r||r(),null==d||d(v)}catch(e){var{code:h,msg:x}=e;Number(h)===R.B.SAFE_CHECK?C(!1):g.FN.error({content:(0,z.u)(x)})}finally{f(!1)}}}),function(){return t.apply(this,arguments)});return(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(g.u_,{title:m,className:"[&_.semi-modal-header]:items-center",visible:s,keepDOM:i,onCancel:()=>null==r?void 0:r(),modalContentClass:"create-plugin-modal-content",footer:!c&&(0,l.jsxs)("div",{children:[!j&&(0,l.jsx)("div",{className:B.Z["error-msg-box"],children:(0,l.jsx)("span",{className:B.Z["error-msg"],children:_.o.t("plugin_create_modal_safe_error")})}),(0,l.jsxs)(g.ZT.Paragraph,{type:"secondary",fontSize:"12px",className:"text-start mb-[16px]",children:[(0,l.jsx)(h.DIY,{className:"coz-fg-hglt text-[14px] align-sub"}),(0,l.jsx)("span",{className:"mx-[4px]",children:_.o.t("plugin_create_draft_desc")}),(0,l.jsx)(V.v,{})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(g.zx,{color:"primary",onClick:()=>{null==r||r()},children:_.o.t("create_plugin_modal_button_cancel")}),(0,l.jsx)(g.zx,{loading:v,onClick:()=>{S()},children:_.o.t("create_plugin_modal_button_confirm")})]})]}),children:(0,l.jsx)(M,{pluginState:x,visible:s,isCreate:i,disabled:c,editInfo:o})})})},Q=r("664319"),ee=r("228962"),et=r("172742"),er=e=>{var{modalProps:t}=e,{pluginInfo:r,canEdit:o,unlockPlugin:i,wrapWithCheckLock:n}=(0,ee.RQ)((0,Q.N)(e=>({pluginInfo:e.pluginInfo,canEdit:e.canEdit,unlockPlugin:e.unlockPlugin,wrapWithCheckLock:e.wrapWithCheckLock}))),[c,u]=(0,a.useState)(!1),[p,m]=(0,a.useState)(!1),v=(0,a.useMemo)(()=>o?(0,l.jsx)("div",{className:et.Z.actions,children:p?(0,l.jsx)(q.y3,{onClick:()=>{m(!1),i()},children:_.o.t("Cancel")}):(0,l.jsx)(q.y3,{theme:"solid",onClick:n(()=>m(!0)),children:_.o.t("Edit")})}):null,[p,o]);return(0,a.useEffect)(()=>{c&&m(!1)},[c]),{modal:(0,l.jsx)($,(0,d._)((0,s._)({},t),{isCreate:!1,visible:c,onCancel:()=>{u(!1),i()},disabled:!p||!o,editInfo:r,actions:v})),setShowCodePluginModel:u}},eo=e=>{var t,{modalProps:r}=e,[o,i]=(0,a.useState)({}),[c,u]=(0,a.useState)(!1),[p,m]=(0,a.useState)(!1),[v,f]=(0,a.useState)(!1),h=(null==o?void 0:o.plugin_id)||"",g=(0,a.useMemo)(()=>v?null:(0,l.jsx)("div",{className:et.Z.actions,children:p?(0,l.jsx)(q.y3,{onClick:()=>{m(!1),(0,ee.zO)(h)},children:_.o.t("Cancel")}):(0,l.jsx)(q.y3,{theme:"solid",onClick:(0,n._)(function*(){if(!(yield(0,ee.EA)(h)))m(!0)}),children:_.o.t("Edit")})}),[p,h,v]);(0,a.useEffect)(()=>{c&&m(!1)},[c]);var x=(0,l.jsx)($,(0,d._)((0,s._)({},r),{editInfo:o,isCreate:!1,visible:c,onCancel:()=>{u(!1),!v&&(0,ee.zO)(h)},disabled:!p,actions:g}));return{modal:x,open:(0,a.useCallback)((t=(0,n._)(function*(e,t){var r,o,n,l,a,s=yield b.Js.GetPluginInfo({plugin_id:e||""});i({plugin_id:e,code_info:{plugin_desc:null===(r=s.code_info)||void 0===r?void 0:r.plugin_desc,openapi_desc:null===(o=s.code_info)||void 0===o?void 0:o.openapi_desc,client_id:null===(n=s.code_info)||void 0===n?void 0:n.client_id,client_secret:null===(l=s.code_info)||void 0===l?void 0:l.client_secret,service_token:null===(a=s.code_info)||void 0===a?void 0:a.service_token}}),f(t),u(!0)}),function(e,r){return t.apply(this,arguments)}),[])}},ei=e=>{var{modalProps:t}=e,{pluginInfo:r,canEdit:o,unlockPlugin:i}=(0,ee.RQ)(e=>({pluginInfo:e.pluginInfo,canEdit:e.canEdit,unlockPlugin:e.unlockPlugin})),[n,c]=(0,a.useState)(!1);return{modal:(0,l.jsx)(Y,(0,d._)((0,s._)({},t),{isCreate:!1,visible:n,editInfo:r,onCancel:()=>{i(),c(!1)},disabled:!o})),setShowFormPluginModel:c}},en=e=>{var t,r,o,{modalProps:i}=e,{pluginInfo:n,unlockPlugin:c}=(0,ee.RQ)(e=>({pluginInfo:e.pluginInfo,unlockPlugin:e.unlockPlugin})),[u,p]=(0,a.useState)(!1);return{modal:(0,l.jsx)(U.JI,(0,d._)((0,s._)({},i),{pluginInfo:{pluginID:null==n?void 0:n.plugin_id,pluginName:null==n?void 0:null===(t=n.meta_info)||void 0===t?void 0:t.name,pluginUrl:null==n?void 0:null===(r=n.meta_info)||void 0===r?void 0:r.url,pluginDesc:null==n?void 0:null===(o=n.meta_info)||void 0===o?void 0:o.desc,editVersion:null==n?void 0:n.edit_version},visible:u,onCancel:()=>{c(),p(!1)}})),setShowImportToolModal:p}}},512421:function(e,t,r){r.d(t,{M:()=>l});var o=r("151064"),i=r("455069"),n=r("966219"),l=e=>{var{mode:t,value:r,onChange:l,height:a=500,theme:s="monokai",disabled:d=!1,dataTestID:c}=e,[u,p]=(0,i.useState)(a);return(0,i.useEffect)(()=>{p(a)},[a]),(0,o.jsx)("div",{style:{position:"relative"},"data-testid":c,children:(0,o.jsx)(n.Editor,{options:{readOnly:d},language:t,theme:s,width:"100%",onChange:l,height:u,value:r})})}},786406:function(e,t,r){r.d(t,{JI:()=>eh,iy:()=>ef});var o=r("825955"),i=r("808549"),n=r("120454"),l=r("151064"),a=r("455069"),s=r("287487"),d=r("947578"),c=r("297158"),u=r("336205"),p=r("707107"),m=r("214942"),v=r("775699"),f=r("44172"),_=r("178385"),h=r("382534"),g=r("473980"),x=r("494308"),y=r("64605"),w=r("165882"),b=r("298203"),j=r("727914"),C=r("458949");function k(e){var t=e.lastIndexOf(".");return e.slice(t+1)}function N(){return(N=(0,o._)(function*(e,t){return new Promise((r,o)=>{var i=new FileReader;i.onload=e=>{var t,i=null===(t=e.target)||void 0===t?void 0:t.result;if(!i||"string"!=typeof i){o(new j.sH("normal_error","file read fail"));return}r(i)},i.onprogress=e=>{e.total&&t({total:e.total,loaded:e.loaded})},i.readAsText(e)})})).apply(this,arguments)}function S(){return(S=(0,o._)(function*(e){var t=w.Z.create({responseType:"text"});return(yield t.get(e)).data})).apply(this,arguments)}var E={none:_.Mv.None,service_http:_.Mv.Service,oauth:_.Mv.OAuth},T={Header:_.Ot.Header,Query:_.Ot.Query};function I(e){var{aiPlugin:t,openAPI:r}=e;return{aiPlugin:(0,b.dj)(t||"{}"),openAPI:(0,x.Qc)(r||"")}}function D(e,t){if(void 0!==t){for(var[r,o]of Object.entries(e))if(o===t)return r}}function P(e){switch(e){case C.wL.Curl:return"curl";case C.wL.OpenAPI:return"openapi";case C.wL.Postman:return"postman";case C.wL.Swagger:return"swagger";default:return""}}var A=e=>(0,y.Z)(e)&&"paths_duplicated"in e;function L(e){var{duplicateInfos:t=[],onCancel:r,onOk:o}=e;v.M5.warning({title:u.o.t("duplicate_tools_within_plugin"),content:null==t?void 0:t.map(e=>(0,l.jsx)("div",{children:"".concat(e.method," ").concat(u.o.t("path_has_duplicates",{path:e.path,num:e.count}))})),okText:u.o.t("merge_duplicate_tools"),cancelText:u.o.t("Cancel"),centered:!0,icon:(0,l.jsx)(f.O5N,{}),okButtonProps:{type:"warning"},onOk:o,onCancel:r})}var O=r("75117");function M(){return"cn-boe"}var F={SAFE_CHECK:0x2aebbb74,DUP_PATH:0x29d916dd},z=["json","yaml"],Z=z.map(e=>".".concat(e)),R={environment:M(),workspace_id:"",workspace_type:"",status:1,create_type:"import"},B={environment:M(),workspace_id:"",workspace_type:"",status:1,create_type:"import",plugin_id:""},V=r("3779"),U={name:[{required:!0,message:u.o.t("create_plugin_modal_name1_error")},{pattern:RegExp("^[\\w\\s\\u4e00-\\u9fa5]+$","u"),message:u.o.t("create_plugin_modal_nameerror_cn")}],desc:[{required:!0,message:u.o.t("create_plugin_modal_descrip1_error")},!1],url:[{required:!0,message:u.o.t("create_plugin_modal_url1_error")}],key:[{required:!0,message:u.o.t("create_plugin_modal_Parameter_error")},{pattern:/^[\x00-\x7F]+$/,message:u.o.t("plugin_Parametename_error")}],service_token:[{required:!0,message:u.o.t("create_plugin_modal_Servicetoken_error")}]},W=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(var o of e){if(o.value===r)return o;if((null===(t=o.children)||void 0===t?void 0:t.length)>0)return W(o.children,r)}},H=r("335740"),G=r("824113"),K=r("581259"),q=r("625196"),J=r("153796"),$=e=>{var{disabled:t}=e,r=(0,v.XQ)(),o=r.getValues();return t?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_name1"),required:!0},children:(0,l.jsx)("div",{children:null==o?void 0:o.name})}):(0,l.jsx)(v.P6,{field:"name",className:J.Z["textarea-single-line"],label:u.o.t("create_plugin_modal_name1"),placeholder:u.o.t("create_plugin_modal_name2"),trigger:["blur","change"],maxCount:30,maxLength:30,rows:1,onBlur:()=>{var e;r.setValue("name",null===(e=r.getValue("name"))||void 0===e?void 0:e.trim())},rules:U.name})},X=e=>{var{disabled:t}=e,r=(0,v.XQ)(),o=r.getValues();return t?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_descrip1"),required:!0},children:(0,l.jsx)("div",{children:null==o?void 0:o.desc})}):(0,l.jsx)(v.P6,{field:"desc",label:u.o.t("create_plugin_modal_descrip1"),trigger:["blur","change"],placeholder:u.o.t("create_plugin_modal_descrip2"),rows:2,maxCount:600,maxLength:600,onBlur:()=>{var e;r.setValue("desc",null==o?void 0:null===(e=o.desc)||void 0===e?void 0:e.trim())},rules:U.desc})},Y=e=>{var{disabled:t}=e,r=(0,v.XQ)(),o=r.getValues();return t?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_url1"),required:!0},children:(0,l.jsx)("div",{children:null==o?void 0:o.url})}):(0,l.jsx)(v.K9,{className:J.Z["textarea-single-line"],trigger:["blur","change"],field:"url",label:u.o.t("create_plugin_modal_url1"),placeholder:u.o.t("create_plugin_modal_url2"),onBlur:()=>{var e;r.setValue("url",null==o?void 0:null===(e=o.url)||void 0===e?void 0:e.trim())},rules:U.url})},Q=(0,v.Q2)(e=>{var{disabled:t,value:r=[],onChange:o}=e,i=e=>{var t=(0,H.Z)(r);t.splice(e,1),null==o||o(t)};return(0,l.jsx)(v.l0.Slot,{className:J.Z["header-list"],label:{text:u.o.t("plugin_create_header_list_title"),align:"right",extra:(0,l.jsxs)("div",{className:J.Z["header-list-extra"],children:[(0,l.jsx)(q.O,{data:K.HW.header_list}),r.length<20&&!t&&(0,l.jsx)(v._3,{size:"large",icon:(0,l.jsx)(f.N_R,{}),onClick:e=>{var t=[...r];t.push(e.name?e:{name:"",value:""}),null==o||o(t)}})]})},children:(0,l.jsxs)("div",{className:J.Z["herder-list-box"],children:[(0,l.jsxs)(v.X2,{className:J.Z["header-row"],gutter:8,children:[(0,l.jsx)(v.JX,{span:9,children:(0,l.jsx)("div",{className:J.Z["header-col-content"],children:"Key"})}),(0,l.jsx)(v.JX,{span:12,children:(0,l.jsx)("div",{className:J.Z["header-col-content"],children:"Value"})}),(0,l.jsx)(v.JX,{span:3,children:(0,l.jsx)("div",{className:J.Z["header-col-content"],style:{textAlign:"right"},children:u.o.t("plugin_create_action_btn")})})]}),(0,l.jsx)("div",{className:J.Z["herder-list-cotent"],children:null==r?void 0:r.map((e,n)=>(0,l.jsxs)(v.X2,{gutter:8,type:"flex",justify:"space-between",align:"middle",children:[(0,l.jsx)(v.JX,{span:9,children:(0,l.jsx)("div",{className:J.Z["col-content"],children:(0,l.jsx)(v.u3,{placeholder:"Name",value:e.name,onChange:e=>{var t=(0,H.Z)(r);t[n].name=e,null==o||o(t)},maxLength:100,disabled:t})})}),(0,l.jsx)(v.JX,{span:12,children:(0,l.jsx)("div",{className:J.Z["col-content"],children:(0,l.jsx)(v.u3,{placeholder:"Value",value:e.value,onChange:e=>{var t=(0,H.Z)(r);t[n].value=e,null==o||o(t)},maxLength:200,disabled:t})})}),(0,l.jsx)(v.JX,{span:3,children:(0,l.jsx)("div",{className:J.Z["col-content"],children:(0,l.jsx)(v._3,{icon:(0,l.jsx)(f.WDf,{}),type:"secondary",disabled:t,onClick:()=>{i(n)}})})})]},n))})]})})},{valueKey:"value",onKeyChangeFnName:"onChange"}),ee=e=>(0,l.jsx)(Q,(0,n._)((0,i._)({},e),{field:"headerList",label:{text:""}})),et=e=>{var t,r,{disabled:o,authOption:i,onChange:n}=e,a=(0,v.XQ)().getValues();return o?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_auth1"),extra:(0,l.jsx)(q.O,{data:K.HW.auth}),required:!0},children:(0,l.jsx)("div",{children:null===(t=W(i,null==a?void 0:null===(r=a.auth_type)||void 0===r?void 0:r.at(-1)))||void 0===t?void 0:t.label})}):(0,l.jsx)(v.oL.FormItem,{rules:[{required:!0}],style:{width:"100%"},initValue:(null==a?void 0:a.auth_type)||[0],field:"auth_type",label:{text:u.o.t("create_plugin_modal_auth1"),extra:(0,l.jsx)(q.O,{data:K.HW.auth})},placeholder:u.o.t("please_select_an_authorization_method"),treeData:i,displayRender:e=>"".concat(null==e?void 0:e.at(-1)),onChange:e=>{n(e)}})},er=e=>{var t,r,o,{disabled:i}=e,n=(0,v.XQ)(),a=n.getValues();return(0,l.jsxs)(l.Fragment,{children:[i?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_location"),extra:(0,l.jsx)(q.O,{data:K.HW.location}),required:!0},children:(0,l.jsx)("div",{children:null===(t=W(K.cg,null===(r=n.getValues())||void 0===r?void 0:r.location))||void 0===t?void 0:t.label})}):(0,l.jsx)(v.l0.RadioGroup,{rules:[{required:!0}],field:"location",label:{text:u.o.t("create_plugin_modal_location"),extra:(0,l.jsx)(q.O,{data:K.HW.location})},options:K.cg}),i?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_Parameter"),extra:(0,l.jsx)(q.O,{data:K.HW.key}),required:!0},children:(0,l.jsx)("div",{children:null===(o=n.getValues())||void 0===o?void 0:o.key})}):(0,l.jsx)(G.sI,{initValue:null==a?void 0:a.key,trigger:["blur","change"],field:"key",label:{text:u.o.t("create_plugin_modal_Parameter"),extra:(0,l.jsx)(q.O,{data:K.HW.key})},placeholder:u.o.t("create_plugin_modal_Parameter_empty"),maxLength:100,rules:U.key}),i?(0,l.jsx)(v.l0.Slot,{label:{text:u.o.t("create_plugin_modal_Servicetoken"),extra:(0,l.jsx)(q.O,{data:K.HW.service_token}),required:!0},children:(0,l.jsx)("div",{children:null==a?void 0:a.service_token})}):(0,l.jsx)(G.sI,{initValue:null==a?void 0:a.service_token,trigger:["blur","change"],field:"service_token",label:{text:u.o.t("create_plugin_modal_Servicetoken"),extra:(0,l.jsx)(q.O,{data:K.HW.service_token})},placeholder:u.o.t("create_plugin_modal_Servicetoken_empty"),maxLength:400,rules:U.service_token})]})},eo=e=>{var{disabled:t,extItems:r}=e,o=(0,v.XQ)().getValues();return(0,l.jsx)(l.Fragment,{children:null==r?void 0:r.map(e=>(0,l.jsx)(l.Fragment,{children:t?(0,l.jsx)(v.l0.Slot,{label:{text:e.key,extra:K.HW[e.key]&&(0,l.jsx)(q.O,{data:K.HW[e.key]}),required:e.required},children:(0,l.jsx)("div",{children:(null==o?void 0:o.oauth_info)?(0,b.dj)(o.oauth_info)[e.key]:null})},e.key):(0,l.jsx)(G.sI,{trigger:["blur","change"],field:e.key,label:{text:e.key,extra:K.HW[e.key]&&(0,l.jsx)(q.O,{data:K.HW[e.key]})},placeholder:K.VF[e.key],initValue:(null==o?void 0:o.oauth_info)&&(0,b.dj)(o.oauth_info)[e.key]||e.default,maxLength:e.max_len,rules:[{required:e.required,message:K.VF[e.key]},"url"===e.type?{pattern:/^(http|https):\/\/.+$/,message:u.o.t("create_plugin_modal_URLerror")}:{pattern:/^[\x00-\x7F]+$/,message:u.o.t("create_plugin_modal_descrip_error")}]},e.key)}))})},ei={headerList:[{name:"User-Agent",value:"Coze/1.0"}]},en=e=>{var t,r,s,c,y,{onCancel:w,importInfo:j,visible:k,onSuccess:N,disabled:S=!1,projectId:P}=e,[A,L]=(0,a.useState)([]),[M,z]=(0,a.useState)(!0),[Z,B]=(0,a.useState)([]),[U,H]=(0,a.useState)(!1),G=(null==j?void 0:null===(s=j.metaInfo)||void 0===s?void 0:null===(r=s.common_params)||void 0===r?void 0:r[4])||[],K=j?(0,n._)((0,i._)({},null==j?void 0:j.metaInfo),{headerList:G||[]}):ei,q=(0,a.useRef)(),Q=null===(y=q.current)||void 0===y?void 0:null===(c=y.getFormState())||void 0===c?void 0:c.values,en=(0,m.rY)(e=>e.space.id);(0,a.useEffect)(()=>{(0,o._)(function*(){var e,t=yield h.nA.GetOAuthSchema();L((e=null==t?void 0:t.oauth_schema,[{label:u.o.t("create_plugin_modal_Authorization_no"),value:0,key:"None"},{label:u.o.t("create_plugin_modal_Authorization_service"),value:1,key:"Service"},{label:u.o.t("create_plugin_modal_Authorization_oauth"),value:3,key:"OAuth",children:(0,b.dj)(e)}]))})()},[]),(0,a.useEffect)(()=>{if(j){var e,t,r;B((null===(e=W(A,(null===(r=j.metaInfo)||void 0===r?void 0:null===(t=r.auth_type)||void 0===t?void 0:t.at(-1))||0))||void 0===e?void 0:e.items)||[])}else B([])},[A,j]);var el=(t=(0,o._)(function*(){yield null===(o=q.current)||void 0===o?void 0:o.validate();var e=null===(l=q.current)||void 0===l?void 0:l.getValues();if(!!e){var{openAPI:t,aiPlugin:r}=ea(e);try{H(!0);var o,l,a,{data:s}=yield h.Js.RegisterPlugin({ai_plugin:r,openapi:t,plugin_type:C.zV.PLUGIN,client_id:null==e?void 0:e.client_id,client_secret:null==e?void 0:e.client_secret,service_token:null==e?void 0:e.service_token,import_from_file:!0,space_id:en,project_id:P},{__disableErrorToast:!0});v.O$.success(u.o.t("plugin_imported_successfully")),null==w||w(),yield null==N?void 0:N({plugin_id:null==s?void 0:s.plugin_id}),(0,p.Gg)(p.Kg.create_plugin_front,(0,n._)((0,i._)({},(null==j?void 0:null===(a=j.extra)||void 0===a?void 0:a.reportParams)||R),{status:0}))}catch(e){var c,{code:m,msg:f}=e;(0,p.Gg)(p.Kg.create_plugin_front,(0,n._)((0,i._)({},(null==j?void 0:null===(c=j.extra)||void 0===c?void 0:c.reportParams)||R),{status:1,error_message:f})),Number(m)===F.SAFE_CHECK?z(!1):v.O$.error({content:(0,d.u)(f)})}finally{H(!1)}}}),function(){return t.apply(this,arguments)}),ea=e=>{var t,{headerList:r,plugin_uri:o=[]}=e,l=(0,g._)(e,["headerList","plugin_uri"]),a={};return null==Z||Z.forEach(t=>{t.key in e&&(a[t.key]=e[t.key])}),function(e,t){var{aiPlugin:r,openAPI:o}=I(t),{name:l,desc:a,auth_type:s,common_params:d,location:c,key:u,service_token:p,oauth_info:m,icon:v}=e,f={name_for_human:l,name_for_model:l,description_for_human:a,description_for_model:a,logo_url:null==v?void 0:v.uri,common_params:{header:null==d?void 0:d[_.Pi.Header],body:null==d?void 0:d[_.Pi.Body],path:null==d?void 0:d[_.Pi.Path],query:null==d?void 0:d[_.Pi.Query]},auth:(0,i._)({type:D(E,null==s?void 0:s.at(0)),location:D(T,c),key:u,service_token:p},JSON.parse(m||"{}"))},h=(0,i._)({},r,f),g=(0,n._)((0,i._)({},o||{}),{info:(0,n._)((0,i._)({},(null==o?void 0:o.info)||{}),{title:l,description:a}),servers:[{url:e.url}]});return{aiPlugin:JSON.stringify(h),openAPI:(0,x.Pz)(g)}}((0,n._)((0,i._)({},l),{oauth_info:JSON.stringify(a),icon:{uri:null===(t=o[0])||void 0===t?void 0:t.uid},common_params:{[C.Pi.Header]:(null==e?void 0:e.headerList)||[],[C.Pi.Body]:[],[C.Pi.Path]:[],[C.Pi.Query]:[]}}),{openAPI:null==j?void 0:j.openAPI,aiPlugin:null==j?void 0:j.aiPlugin})};return(0,a.useEffect)(()=>{!M&&z(!0)},[(null==Q?void 0:Q.name)||(null==Q?void 0:Q.desc)]),(0,l.jsx)(l.Fragment,{children:k?(0,l.jsx)(v.M5,{type:"action-small",title:u.o.t("confirm_plugin_information"),visible:k,onCancel:()=>null==w?void 0:w(),footer:!S&&(0,l.jsxs)("div",{children:[!M&&(0,l.jsx)("div",{className:J.Z["error-msg-box"],children:(0,l.jsx)("span",{className:J.Z["error-msg"],children:u.o.t("plugin_create_modal_safe_error")})}),(0,l.jsxs)("div",{children:[(0,l.jsx)(v.y3,{type:"tertiary",onClick:()=>{null==w||w()},children:u.o.t("create_plugin_modal_button_cancel")}),(0,l.jsx)(v.y3,{type:"primary",theme:"solid",loading:U,onClick:()=>{el()},children:u.o.t("create_plugin_modal_button_confirm")})]})]}),children:(0,l.jsx)(v.l0,{getFormApi:e=>q.current=e,showValidateIcon:!1,initValues:(0,i._)({},K||{}),className:J.Z["upload-form"],children:e=>{var{values:t}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(O.s,{noLabel:!0,disabled:S,fieldClassName:J.Z["upload-field"],field:"plugin_uri",iconType:_.Tu.Plugin,fileBizType:_.ym.BIZ_PLUGIN_ICON}),(0,l.jsx)($,{disabled:S}),(0,l.jsx)(X,{disabled:S}),(0,l.jsx)(Y,{disabled:!0}),(0,l.jsx)(ee,{disabled:S}),(0,l.jsx)(et,{disabled:S,authOption:A,onChange:e=>{var t;B((null===(t=W(A,null==e?void 0:e.at(-1)))||void 0===t?void 0:t.items)||[])}}),1===t.auth_type.at(-1)&&(0,l.jsx)(er,{disabled:S}),(0,l.jsx)(eo,{disabled:S,extItems:Z}),!S&&(0,l.jsxs)(v.T,{spacing:8,className:J.Z["footer-draft"],children:[(0,l.jsx)(f.Us8,{style:{fontSize:"16px",color:"#4D53E8"}}),(0,l.jsxs)("span",{children:[u.o.t("plugin_create_draft_desc"),(0,l.jsx)(V.v,{})]})]})]})}})}):null})},el=r("252237"),ea=r.n(el),es=r("623159"),ed=r("68344"),ec=r("468163"),eu=e=>{var t,{onUpload:r,disabled:i}=e,[n,s]=(0,a.useState)([]);var d=(t=(0,o._)(function*(e){var{onSuccess:t,file:r,onError:o,onProgress:i}=e;if("string"!=typeof r)try{var{name:n,fileInstance:l}=r;if(l){var a=k(n);if(!z.includes(a))return;var s=yield function(e,t){return N.apply(this,arguments)}(l,i);t(s)}}catch(e){c.kg.error({eventName:"fail_to_read_file",error:e}),o({status:0})}}),function(e){return t.apply(this,arguments)});return(0,l.jsx)(v.gq,{accept:Z.join(","),action:"",onAcceptInvalid:()=>{v.O$.warning(u.o.t("file_format_not_supported"))},onSuccess:e=>{r(e)},disabled:i,fileList:n,onChange:e=>{var{fileList:t}=e;s(t),!t.length&&r()},className:ea()(ec.Z["upload-file-area"],n.length&&ec.Z["drag-area-disabled"]),dragMainText:u.o.t("click_upload_or_drag_files"),draggable:!0,dragSubText:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{children:u.o.t("supports_uploading_json_or_yaml_files")}),(0,l.jsx)("a",{href:"/open/docs/guides/import",target:"_blank",onClick:e=>e.stopPropagation(),children:u.o.t("view_detailed_information")})]}),renderFileItem:e=>{var{name:t,onRemove:r,onRetry:o,percent:n,status:a}=e;return(0,l.jsxs)("div",{className:ea()(ec.Z["upload-file-item"],i&&ec.Z.disabled),children:[(0,l.jsx)(v.Ee,{preview:!1,className:ec.Z["file-icon"],src:"yaml"===k(t)?es:ed}),(0,l.jsx)(v.ZT.Text,{className:ec.Z.text,ellipsis:{showTooltip:{opts:{content:t}}},children:t}),(0,l.jsx)("div",{className:ec.Z.progress,children:(()=>{switch(a){case"success":return(0,l.jsx)(v.ZT.Text,{className:ec.Z["upload-text"],ellipsis:!0,children:u.o.t("file_upload_success")});case"uploadFail":case"validateFail":return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(f.Ucq,{}),(0,l.jsx)(v.y3,{theme:"borderless",className:"ml-[8px]",onClick:o,children:u.o.t("retry")})]});default:return(0,l.jsx)("div",{className:ea()("w-[90px]"),children:(0,l.jsx)(v.Ex,{percent:n})})}})()}),(0,l.jsx)(v._3,{icon:(0,l.jsx)(f.WDf,{className:ec.Z["delete-icon"],onClick:r})})]})},limit:1,customRequest:d})},ep=(0,a.forwardRef)((e,t)=>{var{onChange:r}=e,o=(0,g._)(e,["onChange"]);return(0,l.jsx)(v.Kx,(0,n._)((0,i._)({placeholder:u.o.t("enter_raw_content_or_url"),rows:17},o),{ref:t,onChange:e=>{r(e.trim())},className:ec.Z["text-area"]}))}),em=r("170992"),ev=e=>{var t,{onCancel:r,visible:i,onOk:n,title:s}=e,[d,p]=(0,a.useState)("File"),[m,f]=(0,a.useState)(),[_,h]=(0,a.useState)(),[g,x]=(0,a.useState)(!1),y=(0,a.useRef)(null),w=e=>{f(e)},b=()=>{p("File"),f(void 0)};var j=(t=(0,o._)(function*(){x(!0),h(void 0);var e=m,t="Text"===d?"raw_txt":"file";if("Text"===d&&function(e){try{return!!RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*","i").test(e||"")}catch(e){return!1}}(m))try{e=yield function(e){return S.apply(this,arguments)}(m||""),t="file_url"}catch(e){return c.kg.error({error:e,eventName:"fetch_url_resource_fail"}),h(u.o.t("unable_to_access_input_url")),x(!1),Promise.reject(e)}try{var r=yield null==n?void 0:n({type:t,content:e});!(null==r?void 0:r.success)&&h(null==r?void 0:r.errMsg)}finally{x(!1)}}),function(){return t.apply(this,arguments)});return(0,a.useEffect)(()=>{_&&h(void 0)},[m]),(0,a.useEffect)(()=>{i&&b()},[i]),(0,a.useEffect)(()=>{if("Text"===d&&y.current){var e;null==y||null===(e=y.current)||void 0===e||e.focus()}},[d]),(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(v.M5,{afterClose:b,keepDOM:!1,type:"action-small",title:s,visible:i,onCancel:r,onOk:j,footer:(0,l.jsx)(v.y3,{theme:"solid",type:"primary",disabled:!m,onClick:j,loading:g,children:u.o.t("next")}),className:em.Z["import-modal"],children:(0,l.jsxs)("div",{className:"min-h-[472px]",children:[(0,l.jsx)("div",{className:"flex justify-center mb-[24px]",children:(0,l.jsxs)(v.FX,{onChange:e=>{p(e.target.value),f(void 0)},type:"button",buttonSize:"middle",defaultValue:d,disabled:g,className:em.Z["radio-group"],children:[(0,l.jsx)(v.Y8,{value:"File",children:u.o.t("local_file")}),(0,l.jsx)(v.Y8,{value:"Text",children:u.o.t("url_raw_data")})]})}),(0,l.jsx)("div",{children:"File"===d?(0,l.jsx)(eu,{onUpload:w,disabled:g}):(0,l.jsx)(ep,{onChange:w,disabled:g,ref:y})}),(0,l.jsxs)("div",{className:em.Z["error-msg"],children:[" ",_?(0,l.jsx)(v.ZT.Text,{ellipsis:{showTooltip:{opts:{content:_}}},children:_}):null]})]})})})},ef=e=>{var{visible:t}=e;return t?(0,l.jsx)(e_,(0,i._)({},e)):null},e_=e=>{var t,r,{onCancel:s,visible:f,onSuccess:x,projectId:y}=e,[w,b]=(0,a.useState)(),{id:j,space_type:C}=(0,m.rY)(e=>e.space),k=(0,a.useRef)(R),N=C===_.Sn.Personal;(0,a.useEffect)(()=>{k.current=(0,n._)((0,i._)({},k.current),{environment:M(),workspace_id:j||"",workspace_type:N?"personal_workspace":"team_workspace",status:1,create_type:"import"})},[j,N]);var S=(t=(0,o._)(function*(e){try{var t,{openapi:r,ai_plugin:l,plugin_data_format:a}=yield h.Js.Convert2OpenAPI(e,{__disableErrorToast:!0}),s=I({aiPlugin:l,openAPI:r}),m=function(e){var t,r,o,i,n,l,{aiPlugin:a,openAPI:s}=e,d=(null==a?void 0:a.auth)||{},{type:c,location:u,key:p,service_token:m}=d,v=(0,g._)(d,["type","location","key","service_token"]);return{name:null==a?void 0:a.name_for_human,desc:null==a?void 0:a.description_for_human,url:null==s?void 0:null===(r=s.servers)||void 0===r?void 0:null===(t=r[0])||void 0===t?void 0:t.url,icon:{uri:null==a?void 0:a.logo_url},auth_type:[E[c||"none"]],location:T[u||""],key:p,service_token:m,oauth_info:JSON.stringify(v),common_params:{[_.Pi.Header]:(null==a?void 0:null===(o=a.common_params)||void 0===o?void 0:o.header)||[],[_.Pi.Body]:(null==a?void 0:null===(i=a.common_params)||void 0===i?void 0:i.body)||[],[_.Pi.Path]:(null==a?void 0:null===(n=a.common_params)||void 0===n?void 0:n.path)||[],[_.Pi.Query]:(null==a?void 0:null===(l=a.common_params)||void 0===l?void 0:l.query)||[]}}}(s);return b({aiPlugin:l,openAPI:r,metaInfo:m}),k.current=(0,n._)((0,i._)({},k.current),{import_format_type:P(a),import_tools_count:Object.entries((null==s?void 0:null===(t=s.openAPI)||void 0===t?void 0:t.paths)||{}).length}),{success:!0}}catch(t){var f,x,y,{msg:w,code:j,response:C}=t;if(c.kg.error({error:t,eventName:"plugin_convert_openapi_fail"}),k.current=(0,n._)((0,i._)({},k.current),{import_format_type:P(null==C?void 0:null===(x=C.data)||void 0===x?void 0:x.plugin_data_format),import_tools_count:0}),(0,p.Gg)(p.Kg.create_plugin_front,(0,n._)((0,i._)({},k.current),{status:1,error_message:w})),!(Number(j)===F.DUP_PATH||A(null==C?void 0:C.data)))return{success:!1,errMsg:w||u.o.t("error")};return L({onOk:(f=(0,o._)(function*(){var{errMsg:t,success:r}=yield S((0,n._)((0,i._)({},e),{merge_same_paths:!0}));if(!r)return v.O$.error({content:(0,d.u)(t||u.o.t("error"))}),Promise.reject(t)}),function(){return f.apply(this,arguments)}),duplicateInfos:null==C?void 0:null===(y=C.data)||void 0===y?void 0:y.duplicate_api_infos}),{success:!1,errMsg:""}}}),function(e){return t.apply(this,arguments)});var D=(r=(0,o._)(function*(e){var{content:t,type:r}=e;return k.current=(0,n._)((0,i._)({},k.current),{import_way_type:r}),yield S({data:t||"",space_id:j,merge_same_paths:!1})}),function(e){return r.apply(this,arguments)});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ev,{title:u.o.t("import_plugin"),visible:f,onCancel:s,onOk:D}),w?(0,l.jsx)(en,{visible:!!w,projectId:y,onCancel:()=>b(void 0),importInfo:{metaInfo:w.metaInfo,openAPI:w.openAPI,aiPlugin:w.aiPlugin,extra:{reportParams:k.current}},onSuccess:e=>{null==s||s(),null==x||x(e)}}):null]})},eh=e=>{var{visible:t}=e;return t?(0,l.jsx)(eg,(0,i._)({},e)):null},eg=e=>{var t,r,g,x,{onCancel:y,visible:w,onSuccess:b,pluginInfo:j}=e,C=(0,a.useRef)(B),{id:k,space_type:N}=(0,m.rY)(e=>e.space),S=N===_.Sn.Personal,E=s.Z.useUserInfo();(0,a.useEffect)(()=>{C.current=(0,n._)((0,i._)({},C.current),{environment:M(),workspace_id:k||"",workspace_type:S?"personal_workspace":"team_workspace",status:1,create_type:"import",plugin_id:(null==j?void 0:j.pluginID)||""})},[null==j?void 0:j.pluginID,k,S]);var T=(t=(0,o._)(function*(e){try{var t,r,o,l=yield h.Js.BatchCreateAPI(e,{__disableErrorToast:!0}),a=(null==e?void 0:e.replace_same_paths)?null==e?void 0:null===(t=e.paths_to_replace)||void 0===t?void 0:t.length:null==l?void 0:null===(r=l.paths_created)||void 0===r?void 0:r.length;(0,p.Gg)(p.Kg.create_plugin_tool_front,(0,n._)((0,i._)({},C.current),{status:0,import_tools_count:a||0})),l&&!(null==l?void 0:null===(o=l.paths_duplicated)||void 0===o?void 0:o.length)&&(v.O$.success((null==e?void 0:e.replace_same_paths)?u.o.t("plugin_tool_replace_success"):u.o.t("plugin_tool_import_succes")),null==y||y(),null==b||b())}catch(t){var s,d,{code:c,response:m}=t;if(Number(c)!==F.DUP_PATH&&!A(null==m?void 0:m.data))return Promise.reject(t);(0,p.Gg)(p.Kg.create_plugin_tool_front,(0,n._)((0,i._)({},C.current),{status:0,import_tools_count:(null==m?void 0:null===(d=m.data)||void 0===d?void 0:null===(s=d.paths_created)||void 0===s?void 0:s.length)||0})),I(e,null==m?void 0:m.data)}}),function(e){return t.apply(this,arguments)}),I=(e,t)=>{var{paths_created:r=[],paths_duplicated:a=[]}=t||{},s=r.length,c=a.length,m=u.o.t("failed_to_import_tool",{num:c}),_=u.o.t("tools_imported_successfully",{num:s});v.M5.warning({title:s?"".concat(_,", ").concat(m):m,content:c?u.o.t("plugin_tool_exists_tips",{num:c}):null,okText:u.o.t("replace"),cancelText:u.o.t("Cancel"),centered:!0,icon:(0,l.jsx)(f.O5N,{}),okButtonProps:{type:"warning"},onOk:(0,o._)(function*(){var t=(0,n._)((0,i._)({},e),{replace_same_paths:!0,paths_to_replace:a});try{yield T(t)}catch(e){var{msg:r}=e;v.O$.error({content:(0,d.u)(r||u.o.t("error"))}),(0,p.Gg)(p.Kg.create_plugin_tool_front,(0,n._)((0,i._)({},C.current),{import_tools_count:0,status:1,error_message:r||""}))}}),onCancel:s?(0,o._)(function*(){null==y||y(),yield null==b?void 0:b()}):void 0})};var D=(r=(0,o._)(function*(e){return yield h.Js.Convert2OpenAPI((0,n._)((0,i._)({},e),{plugin_description:null==j?void 0:j.pluginDesc}),{__disableErrorToast:!0})}),function(e){return r.apply(this,arguments)});var O=(g=(0,o._)(function*(e){try{var t=yield D(e);C.current=(0,n._)((0,i._)({},C.current),{import_format_type:P(null==t?void 0:t.plugin_data_format)});var r={plugin_id:null==j?void 0:j.pluginID,ai_plugin:null==t?void 0:t.ai_plugin,openapi:null==t?void 0:t.openapi,replace_same_paths:!1,space_id:k,dev_id:null==E?void 0:E.user_id_str,edit_version:null==j?void 0:j.editVersion};return yield T(r),{success:!0}}catch(t){var l,a,s,{msg:m,code:f,response:_}=t;if(c.kg.error({error:t,eventName:"batch_create_fail"}),C.current=(0,n._)((0,i._)({},C.current),{import_format_type:P(null==_?void 0:null===(a=_.data)||void 0===a?void 0:a.plugin_data_format)}),(0,p.Gg)(p.Kg.create_plugin_tool_front,(0,n._)((0,i._)({},C.current),{import_tools_count:0,status:1,error_message:m||""})),!(Number(f)===F.DUP_PATH||A(null==_?void 0:_.data)))return{success:!1,errMsg:m||u.o.t("error")};return L({onOk:(l=(0,o._)(function*(){var{success:r,errMsg:o}=yield O((0,n._)((0,i._)({},e),{merge_same_paths:!0}));if(!r)return v.O$.error({content:(0,d.u)(o||u.o.t("error"))}),Promise.reject(t)}),function(){return l.apply(this,arguments)}),duplicateInfos:null==_?void 0:null===(s=_.data)||void 0===s?void 0:s.duplicate_api_infos}),{success:!1}}}),function(e){return g.apply(this,arguments)});var z=(x=(0,o._)(function*(e){var{content:t,type:r}=e||{};return C.current=(0,n._)((0,i._)({},C.current),{import_way_type:r}),yield O({data:t||"",plugin_name:null==j?void 0:j.pluginName,plugin_url:null==j?void 0:j.pluginUrl,merge_same_paths:!1,space_id:k})}),function(e){return x.apply(this,arguments)});return(0,l.jsx)(ev,{title:u.o.t("import_plugin_tool"),visible:w,onCancel:y,onOk:z})}},3779:function(e,t,r){r.d(t,{v:function(){return a}});var o=r(151064),i=r(455069),n=r(336205),l=r(659596),a=()=>{var e=(0,i.useMemo)(()=>({"zh-CN":"/docs/guides/plugin",en:"/docs/en_guides/en_plugin"})[n.o.language],[]);return(0,o.jsx)(l.ZT.Text,{link:{href:e,target:"_blank"},fontSize:"12px",children:n.o.t("plugin_create_guide_link")})}},737368:function(e,t,r){r.d(t,{E:()=>h});var o=r("151064"),i=r("336205"),n=r("775699"),l=r("44172"),a=r("286518"),s=r("382534"),d=r("808549"),c=r("120454"),u=r("479910"),p=r("598208"),m={pluginRiskIsRead:!0,toolHiddenModeNewbieGuideIsRead:!0},v=(0,p.Ue)()((0,u.mW)(e=>(0,c._)((0,d._)({},m),{reset:()=>{e(m)},setPluginRiskIsRead:t=>{e({pluginRiskIsRead:t})},setToolHiddenModeNewbieGuideIsRead:t=>{e({toolHiddenModeNewbieGuideIsRead:t})}}),{enabled:!1,name:"botStudio.riskWarningStore"})),f=r("551256"),_=[{icon:(0,o.jsx)(l.KBW,{}),text:i.o.t("plugin_quote_tip_1")},{icon:(0,o.jsx)(l.bu3,{}),text:i.o.t("plugin_quote_tip_2")},{icon:(0,o.jsx)(l.LGu,{}),text:i.o.t("plugin_quote_tip_3")}],h=()=>{var{pluginRiskIsRead:e,setPluginRiskIsRead:t}=v.getState(),r=()=>{s.pr.UpdateUserConfig({risk_alert_type:a.qe.Plugin})};!e&&(t(!0),n.u_.warning({icon:null,title:i.o.t("About_Plugins_tip"),content:(0,o.jsx)("div",{className:f.Z["modal-wrap"],children:_.map(e=>(0,o.jsxs)("div",{className:f.Z["modal-item"],children:[e.icon,(0,o.jsx)("span",{className:f.Z["modal-text"],children:e.text})]}))}),onOk:r,onCancel:r,hasCancel:!1,maskClosable:!1,className:f.Z["ui-modal"],okText:i.o.t("Confirm"),okButtonProps:{style:{minWidth:"96px"}}}))}},625196:function(e,t,r){r.d(t,{O:()=>a});var o=r("151064"),i=r("455069"),n=r("873183"),l=r("659596"),a=e=>{var{data:t}=e;return(0,o.jsx)(l.u,{showArrow:!0,theme:"dark",position:"right",arrowPointAtCenter:!0,className:"!max-w-[320px]",content:null==t?void 0:t.map((e,t)=>(0,o.jsxs)(i.Fragment,{children:["title"===e.type?(0,o.jsx)(l.ZT.Text,{fontSize:"14px",className:"dark coz-fg-primary",children:e.text}):null,"text"===e.type?(0,o.jsx)(l.ZT.Paragraph,{fontSize:"12px",className:"dark coz-fg-secondary",children:e.text}):null,"br"===e.type?(0,o.jsx)("div",{className:"h-[8px]"}):null,"demo"===e.type?(0,o.jsx)("div",{className:"dark mt-[4px] p-[10px] border border-solid coz-stroke-primary",children:(0,o.jsx)(l.ZT.Paragraph,{fontSize:"12px",className:"dark coz-fg-secondary",children:e.text})}):null]},"".concat(e.type).concat(t))),children:(0,o.jsx)(n.L03,{className:"coz-fg-secondary"})})}},827666:function(e,t,r){r.d(t,{Eo:function(){return y},Fc:function(){return p},Il:function(){return u},JN:function(){return L},Oz:function(){return A},RE:function(){return w},TS:function(){return h},UR:function(){return v},YA:function(){return S},Zo:function(){return I},dT:function(){return f},iq:function(){return P},lR:function(){return D},ls:function(){return _},pq:function(){return g},rN:function(){return x},sp:function(){return m},w5:function(){return C}});var o,i,n=r(808549),l=r(120454),a=r(335740),s=r(336205),d=r(458949),c=r(187151),u="sub_parameters",p="id",m="[Array Item]",v="[Root Item]",f=0,_=1,h=2,g=[{label:"Body",value:d.Pi.Body},{label:"Path",value:d.Pi.Path},{label:"Query",value:d.Pi.Query},{label:"Header",value:d.Pi.Header}];var x=((o={})[o.DEFAULT=10001]="DEFAULT",o[o.IMAGE=10002]="IMAGE",o[o.DOC=10003]="DOC",o[o.CODE=10004]="CODE",o[o.PPT=10005]="PPT",o[o.TXT=10006]="TXT",o[o.EXCEL=10007]="EXCEL",o[o.AUDIO=10008]="AUDIO",o[o.ZIP=10009]="ZIP",o[o.VIDEO=10010]="VIDEO",o),y=e=>e+1e4,w=e=>e-1e4,b=[{label:"String",value:d.rH.String},{label:"Integer",value:d.rH.Integer},{label:"Number",value:d.rH.Number},{label:"Object",value:d.rH.Object},{label:"Array",value:d.rH.Array},{label:"Boolean",value:d.rH.Bool}],j=[{label:"Array",value:d.rH.String},{label:"Array",value:d.rH.Integer},{label:"Array",value:d.rH.Number},{label:"Array",value:d.rH.Object},{label:"Array",value:d.rH.Bool}],C={10001:{label:"File",listLabel:"Array",fileTypes:[c.Wz.DEFAULT_UNKNOWN]},10002:{label:"Image",listLabel:"Array",fileTypes:[c.Wz.IMAGE]},10003:{label:"Doc",listLabel:"Array",fileTypes:[c.Wz.DOCX,c.Wz.PDF]},10004:{label:"Code",listLabel:"Array",fileTypes:[c.Wz.CODE]},10005:{label:"PPT",listLabel:"Array",fileTypes:[c.Wz.PPT]},10006:{label:"TXT",listLabel:"Array",fileTypes:[c.Wz.TXT]},10007:{label:"Excel",listLabel:"Array",fileTypes:[c.Wz.EXCEL,c.Wz.CSV]},10008:{label:"Audio",listLabel:"Array