(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,308011,e=>{"use strict";var t=e.i(162115),a=e.i(869931),s=e.i(94517);e.i(816688);var l=e.i(675066),n=e.i(935139);e.s(["EncryptedBottom",0,e=>{let{t:r}=(0,l.useTranslation)(),{frontTextKey:i="provider.encrypted.front",backTextKey:o="provider.encrypted.back",className:u}=e;return(0,t.jsxs)("div",{className:(0,n.cn)("system-xs-regular flex items-center justify-center rounded-b-2xl border-t-[0.5px] border-divider-subtle bg-background-soft px-2 py-3 text-text-tertiary",u),children:[(0,t.jsx)(a.RiLock2Fill,{className:"mx-1 h-3 w-3 text-text-quaternary"}),r(i,{ns:"common"}),(0,t.jsx)(s.default,{className:"mx-1 text-text-accent",target:"_blank",rel:"noopener noreferrer",href:"https://pycryptodome.readthedocs.io/en/latest/src/cipher/oaep.html",children:"PKCS1_OAEP"}),r(o,{ns:"common"})]})}])},665127,808462,e=>{"use strict";var t,a=e.i(162115),s=e.i(869931);e.i(816688);var l=e.i(675066),n=e.i(935139);let r=["code","audio","time","webscraper"];var i=e.i(534011),o=((t={}).drawer="drawer",t.modal="modal",t);let u=(0,i.create)(e=>({currentPluginDetail:void 0,setCurrentPluginDetail:(t,a)=>e({currentPluginDetail:t?{detail:t,showType:a??"drawer"}:void 0})}));e.s(["ReadmeShowType",()=>o,"useReadmePanelStore",0,u],808462),e.s(["ReadmeEntrance",0,e=>{let{pluginDetail:t,showType:i=o.drawer,className:c,showShortTip:d=!1}=e,{t:m}=(0,l.useTranslation)(),{setCurrentPluginDetail:p}=u();return!t||!t?.plugin_unique_identifier||r.includes(t.id)?null:(0,a.jsxs)("div",{className:(0,n.cn)("flex flex-col items-start justify-center gap-2 pb-4 pt-0",i===o.drawer&&"px-4",c),children:[!d&&(0,a.jsx)("div",{className:"relative h-1 w-8 shrink-0",children:(0,a.jsx)("div",{className:"h-px w-full bg-divider-regular"})}),(0,a.jsxs)("button",{onClick:()=>{t&&p(t,i)},className:"flex w-full items-center justify-start gap-1 text-text-tertiary transition-opacity hover:text-text-accent-light-mode-only",children:[(0,a.jsx)("div",{className:"relative flex h-3 w-3 items-center justify-center overflow-hidden",children:(0,a.jsx)(s.RiBookReadLine,{className:"h-3 w-3"})}),(0,a.jsx)("span",{className:"text-xs font-normal leading-4",children:m(d?"readmeInfo.title":"readmeInfo.needHelpCheckReadme",{ns:"plugin"})})]})]})}],665127)},302047,674245,494845,505560,694354,735964,946468,958692,230121,677316,227746,e=>{"use strict";e.s([],302047);var t,a,s=e.i(162115),l=e.i(942347),n=e.i(151094);e.i(816688);var r=e.i(675066),i=e.i(308011),o=e.i(588226),u=e.i(603135),c=e.i(449980),d=e.i(735852),m=e.i(734962),p=e.i(665127),h=e.i(808462),x=e.i(890564),g=e.i(868729),f=e.i(367916),b=e.i(722384);let v="plugins-auth";var y=e.i(154033),C=((t={}).tool="tool",t.datasource="datasource",t.model="model",t.trigger="trigger",t),j=((a={}).OAUTH2="oauth2",a.API_KEY="api-key",a);e.s(["AuthCategory",()=>C,"CredentialTypeEnum",()=>j],674245);let w=e=>{let{category:t=C.tool,provider:a}=e;return t===C.tool?{getCredentialInfo:`/workspaces/current/tool-provider/builtin/${a}/credential/info`,setDefaultCredential:`/workspaces/current/tool-provider/builtin/${a}/default-credential`,getCredentials:`/workspaces/current/tool-provider/builtin/${a}/credentials`,addCredential:`/workspaces/current/tool-provider/builtin/${a}/add`,updateCredential:`/workspaces/current/tool-provider/builtin/${a}/update`,deleteCredential:`/workspaces/current/tool-provider/builtin/${a}/delete`,getCredentialSchema:e=>`/workspaces/current/tool-provider/builtin/${a}/credential/schema/${e}`,getOauthUrl:`/oauth/plugin/${a}/tool/authorization-url`,getOauthClientSchema:`/workspaces/current/tool-provider/builtin/${a}/oauth/client-schema`,setCustomOauthClient:`/workspaces/current/tool-provider/builtin/${a}/oauth/custom-client`,getCustomOAuthClientValues:`/workspaces/current/tool-provider/builtin/${a}/oauth/custom-client`,deleteCustomOAuthClient:`/workspaces/current/tool-provider/builtin/${a}/oauth/custom-client`}:t===C.datasource?{getCredentialInfo:"",setDefaultCredential:`/auth/plugin/datasource/${a}/default`,getCredentials:`/auth/plugin/datasource/${a}`,addCredential:`/auth/plugin/datasource/${a}`,updateCredential:`/auth/plugin/datasource/${a}/update`,deleteCredential:`/auth/plugin/datasource/${a}/delete`,getCredentialSchema:()=>"",getOauthUrl:`/oauth/plugin/${a}/datasource/get-authorization-url`,getOauthClientSchema:"",setCustomOauthClient:`/auth/plugin/datasource/${a}/custom-client`,deleteCustomOAuthClient:`/auth/plugin/datasource/${a}/custom-client`}:{getCredentialInfo:"",setDefaultCredential:"",getCredentials:"",addCredential:"",updateCredential:"",deleteCredential:"",getCredentialSchema:()=>"",getOauthUrl:"",getOauthClientSchema:"",setCustomOauthClient:"",getCustomOAuthClientValues:"",deleteCustomOAuthClient:""}},k=e=>{let t;return t=w(e).deleteCredential,(0,x.useMutation)({mutationFn:e=>(0,f.post)(t,{body:e})})},_=e=>{let t;return t=w(e).setDefaultCredential,(0,x.useMutation)({mutationFn:e=>(0,f.post)(t,{body:{id:e}})})},N=e=>{let t;return t=w(e).updateCredential,(0,x.useMutation)({mutationFn:e=>(0,f.post)(t,{body:e})})},S=(0,l.memo)(e=>{var t;let a,n,{pluginPayload:b,onClose:y,editValues:C,onRemove:k,disabled:_,onUpdate:S,formSchemas:I=[]}=e,{t:T}=(0,r.useTranslation)(),{notify:P}=(0,m.useToastContext)(),[A,F]=(0,l.useState)(!1),E=(0,l.useRef)(A),M=(0,l.useCallback)(e=>{E.current=e,F(e)},[]),{data:R=[],isLoading:O}=(t=j.API_KEY,a=w(b).getCredentialSchema(t),(0,g.useQuery)({enabled:!!a,queryKey:[v,"credential-schema",a],queryFn:()=>(0,f.get)(a)})),L=(0,l.useMemo)(()=>I?.length?I:R,[I,R]),V=(0,l.useMemo)(()=>[{type:u.FormTypeEnum.textInput,name:"__name__",label:T("auth.authorizationName",{ns:"plugin"}),required:!1},...L],[L,T]),$=V.reduce((e,t)=>(t.default&&(e[t.name]=t.default),e),{}),{mutateAsync:D}=(n=w(b).addCredential,(0,x.useMutation)({mutationFn:e=>(0,f.post)(n,{body:e})})),{mutateAsync:U}=N(b),z=(0,l.useRef)(null),q=(0,l.useCallback)(async()=>{if(E.current)return;let{isCheckValidated:e,values:t}=z.current?.getFormValues({needCheckValidatedValues:!0,needTransformWhenSecretFieldIsPristine:!0})||{isCheckValidated:!1,values:{}};if(e)try{let{__name__:e,__credential_id__:a,...s}=t;M(!0),C?await U({credentials:s,credential_id:a,name:e||""}):await D({credentials:s,type:j.API_KEY,name:e||""}),P({type:"success",message:T("api.actionSuccess",{ns:"common"})}),y?.(),S?.()}finally{M(!1)}},[D,y,S,U,P,T,C,M]);return(0,s.jsxs)(d.default,{size:"md",title:T("auth.useApiAuth",{ns:"plugin"}),subTitle:T("auth.useApiAuthDesc",{ns:"plugin"}),onClose:y,onCancel:y,footerSlot:(0,s.jsx)("div",{}),bottomSlot:(0,s.jsx)(i.EncryptedBottom,{}),onConfirm:q,showExtraButton:!!C,onExtraButtonClick:k,disabled:_||O||A,clickOutsideNotClose:!0,wrapperClassName:"!z-[101]",children:[b.detail&&(0,s.jsx)(p.ReadmeEntrance,{pluginDetail:b.detail,showType:h.ReadmeShowType.modal}),O&&(0,s.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,s.jsx)(c.default,{})}),!O&&!!L.length&&(0,s.jsx)(o.default,{ref:z,formSchemas:V,defaultValues:C||$,disabled:_})]})});e.s(["default",0,S],494845);let I=(0,l.memo)(e=>{let{pluginPayload:t,buttonVariant:a="secondary-accent",buttonText:r="Use Api Key",disabled:i,onUpdate:o,formSchemas:u=[]}=e,[c,d]=(0,l.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.default,{className:"w-full",variant:a,onClick:()=>d(!0),disabled:i,children:r}),c&&(0,s.jsx)(S,{pluginPayload:t,onClose:()=>d(!1),onUpdate:o,formSchemas:u})]})});e.s(["default",0,I],505560);var T=e.i(869931),P=e.i(654313),A=e.i(83278),F=e.i(566210),E=e.i(349714),M=e.i(935139),R=e.i(301293),O=e.i(622111);let L=(0,l.memo)(e=>{let t,a,i,{pluginPayload:u,onClose:c,editValues:g,disabled:y,schemas:C,onAuth:j,hasOriginalClientParams:k,onUpdate:_}=e,{t:N}=(0,r.useTranslation)(),{notify:S}=(0,m.useToastContext)(),[I,T]=(0,l.useState)(!1),P=(0,l.useRef)(I),A=(0,l.useCallback)(e=>{P.current=e,T(e)},[]),F=C.reduce((e,t)=>(t.default&&(e[t.name]=t.default),e),{}),{mutateAsync:E}=(t=w(u).setCustomOauthClient,(0,x.useMutation)({mutationFn:e=>(0,f.post)(t,{body:e})})),M=(a=w(u).getOauthClientSchema,(0,b.useInvalid)([v,"oauth-client-schema",a])),L=(0,l.useRef)(null),V=(0,l.useCallback)(async()=>{if(!P.current)try{let{isCheckValidated:e,values:t}=L.current?.getFormValues({needCheckValidatedValues:!0,needTransformWhenSecretFieldIsPristine:!0})||{isCheckValidated:!1,values:{}};if(!e)throw Error("error");let{__oauth_client__:a,...s}=t;A(!0),await E({client_params:s,enable_oauth_custom_client:"custom"===a}),S({type:"success",message:N("api.actionSuccess",{ns:"common"})}),c?.(),_?.(),M()}finally{A(!1)}},[c,_,M,E,S,N,A]),$=(0,l.useCallback)(async()=>{await V(),j&&await j()},[V,j]),{mutateAsync:D}=(i=w(u).deleteCustomOAuthClient,(0,x.useMutation)({mutationFn:()=>(0,f.del)(i)})),U=(0,l.useCallback)(async()=>{if(!P.current)try{A(!0),await D(),S({type:"success",message:N("api.actionSuccess",{ns:"common"})}),c?.(),_?.(),M()}finally{A(!1)}},[_,M,D,S,N,A,c]),z=(0,R.useForm)({defaultValues:g||F}),q=(0,O.useStore)(z.store,e=>e.values.__oauth_client__);return(0,s.jsxs)(d.default,{title:N("auth.oauthClientSettings",{ns:"plugin"}),confirmButtonText:N("auth.saveAndAuth",{ns:"plugin"}),cancelButtonText:N("auth.saveOnly",{ns:"plugin"}),extraButtonText:N("operation.cancel",{ns:"common"}),showExtraButton:!0,extraButtonVariant:"secondary",onExtraButtonClick:c,onClose:c,onCancel:V,onConfirm:$,disabled:y||I,footerSlot:"custom"===q&&k&&(0,s.jsx)("div",{className:"grow",children:(0,s.jsx)(n.default,{variant:"secondary",className:"text-components-button-destructive-secondary-text",disabled:y||I||!g,onClick:U,children:N("operation.remove",{ns:"common"})})}),containerClassName:"pt-0",wrapperClassName:"!z-[101]",clickOutsideNotClose:!0,children:[u.detail&&(0,s.jsx)(p.ReadmeEntrance,{pluginDetail:u.detail,showType:h.ReadmeShowType.modal}),(0,s.jsx)(o.default,{formFromProps:z,ref:L,formSchemas:C,defaultValues:g||F,disabled:y})]})}),V=(0,l.memo)(e=>{let t,a,{pluginPayload:i,buttonVariant:o="primary",buttonText:c="use oauth",className:d,buttonLeftClassName:m,buttonRightClassName:p,dividerClassName:h,disabled:b,onUpdate:y,oAuthData:C}=e,{t:j}=(0,r.useTranslation)(),k=(0,F.useRenderI18nObject)(),[_,N]=(0,l.useState)(!1),{mutateAsync:S}=(t=w(i).getOauthUrl,(0,x.useMutation)({mutationKey:[v,"oauth-url",t],mutationFn:()=>(0,f.get)(t)})),{data:I,isLoading:R}=(a=w(i).getOauthClientSchema,(0,g.useQuery)({enabled:!!a,queryKey:[v,"oauth-client-schema",a],queryFn:()=>(0,f.get)(a),staleTime:0})),{schema:O=[],is_oauth_custom_client_enabled:V,is_system_oauth_params_exists:$,client_params:D,redirect_uri:U}=(0,l.useMemo)(()=>C||I,[C,I])||{},z=$||V,q=(0,l.useCallback)(async()=>{let{authorization_url:e}=await S();e&&(0,E.openOAuthPopup)(e,()=>y?.())},[S,y]),B=(0,l.useCallback)(e=>(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsxs)("div",{className:"mb-4 flex rounded-xl bg-background-section-burn p-4",children:[(0,s.jsx)("div",{className:"mr-3 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border-[0.5px] border-components-card-border bg-components-card-bg shadow-lg",children:(0,s.jsx)(T.RiInformation2Fill,{className:"h-5 w-5 text-text-accent"})}),(0,s.jsxs)("div",{className:"w-0 grow",children:[(0,s.jsx)("div",{className:"system-sm-regular mb-1.5",children:j("auth.clientInfo",{ns:"plugin"})}),U&&(0,s.jsxs)("div",{className:"system-sm-medium flex w-full py-0.5",children:[(0,s.jsx)("div",{className:"w-0 grow break-words break-all",children:U}),(0,s.jsx)(P.default,{className:"shrink-0",onClick:()=>{navigator.clipboard.writeText(U||"")},children:(0,s.jsx)(T.RiClipboardLine,{className:"h-4 w-4"})})]})]})]}),(0,s.jsxs)("div",{className:"system-sm-medium flex h-6 items-center text-text-secondary",children:[k(e.label),e.required&&(0,s.jsx)("span",{className:"ml-1 text-text-destructive-secondary",children:"*"})]})]}),[j,U,k]),K=(0,l.useMemo)(()=>{let e=O.map((e,t)=>({...e,label:0===t?B(e):e.label,labelClassName:0===t?"h-auto":void 0}));return $&&(e.unshift({name:"__oauth_client__",label:j("auth.oauthClient",{ns:"plugin"}),type:u.FormTypeEnum.radio,options:[{label:j("auth.default",{ns:"plugin"}),value:"default"},{label:j("auth.custom",{ns:"plugin"}),value:"custom"}],required:!1,default:V?"custom":"default"}),e.forEach((e,t)=>{t>0&&(e.show_on=[{variable:"__oauth_client__",value:"custom"}],D&&(e.default=D[e.name]||e.default))})),e},[O,B,j,$,V,D]),H=(0,l.useMemo)(()=>z?V?"custom":"default":$?"default":"custom",[z,V,$]);return(0,s.jsxs)(s.Fragment,{children:[z&&(0,s.jsxs)(n.default,{variant:o,className:(0,M.cn)("w-full px-0 py-0 hover:bg-components-button-primary-bg",d),disabled:b,onClick:q,children:[(0,s.jsxs)("div",{className:(0,M.cn)("flex h-full w-0 grow items-center justify-center rounded-l-lg pl-0.5 hover:bg-components-button-primary-bg-hover",m),children:[(0,s.jsx)("div",{className:"truncate",title:c,children:c}),V&&(0,s.jsx)(A.default,{className:(0,M.cn)("ml-1 mr-0.5","primary"===o&&"border-text-primary-on-surface bg-components-badge-bg-dimm text-text-primary-on-surface"),children:j("auth.custom",{ns:"plugin"})})]}),(0,s.jsx)("div",{className:(0,M.cn)("h-4 w-[1px] shrink-0 bg-text-primary-on-surface opacity-[0.15]",h)}),(0,s.jsx)("div",{"data-testid":"oauth-settings-button",className:(0,M.cn)("flex h-full w-8 shrink-0 items-center justify-center rounded-r-lg hover:bg-components-button-primary-bg-hover",p),onClick:e=>{e.stopPropagation(),N(!0)},children:(0,s.jsx)(T.RiEqualizer2Line,{className:"h-4 w-4"})})]}),!z&&(0,s.jsxs)(n.default,{variant:o,onClick:()=>N(!0),disabled:b,className:"w-full",children:[(0,s.jsx)(T.RiEqualizer2Line,{className:"mr-0.5 h-4 w-4"}),j("auth.setupOAuth",{ns:"plugin"})]}),_&&(0,s.jsx)(L,{pluginPayload:i,onClose:()=>N(!1),disabled:b||R,schemas:K,onAuth:q,editValues:{...D,__oauth_client__:H},hasOriginalClientParams:Object.keys(D||{}).length>0,onUpdate:y})]})});e.s(["default",0,V],694354);var $=e.i(547105),D=e.i(391185),U=e.i(836340),z=e.i(421001);let q=(0,l.memo)(e=>{let{pluginPayload:t,theme:a="primary",showDivider:n=!0,canOAuth:i,canApiKey:o,disabled:u,onUpdate:c,notAllowCustomCredential:d}=e,{t:m}=(0,r.useTranslation)(),p=(0,l.useMemo)(()=>"secondary"===a?{buttonText:o?m("auth.addOAuth",{ns:"plugin"}):m("auth.useOAuthAuth",{ns:"plugin"}),buttonVariant:"secondary",className:"hover:bg-components-button-secondary-bg",buttonLeftClassName:"hover:bg-components-button-secondary-bg-hover",buttonRightClassName:"hover:bg-components-button-secondary-bg-hover",dividerClassName:"bg-divider-regular opacity-100",pluginPayload:t}:{buttonText:o?m("auth.addOAuth",{ns:"plugin"}):m("auth.useOAuthAuth",{ns:"plugin"}),pluginPayload:t},[o,a,t,m]),h=(0,l.useMemo)(()=>"secondary"===a?{pluginPayload:t,buttonVariant:"secondary",buttonText:i?m("auth.addApi",{ns:"plugin"}):m("auth.useApiAuth",{ns:"plugin"})}:{pluginPayload:t,buttonText:i?m("auth.addApi",{ns:"plugin"}):m("auth.useApiAuth",{ns:"plugin"}),buttonVariant:i?"secondary-accent":"primary"},[i,a,t,m]),x=(0,l.useMemo)(()=>{let e=(0,s.jsx)("div",{className:(0,M.cn)("min-w-0 flex-[1]",d&&"opacity-50"),children:(0,s.jsx)(V,{...p,disabled:u||d,onUpdate:c})});return d?(0,s.jsx)(z.default,{popupContent:m("auth.credentialUnavailable",{ns:"plugin"}),children:e}):e},[d,p,u,c,m]),g=(0,l.useMemo)(()=>{let e=(0,s.jsx)("div",{className:(0,M.cn)("min-w-0 flex-[1]",d&&"opacity-50"),children:(0,s.jsx)(I,{...h,disabled:u||d,onUpdate:c})});return d?(0,s.jsx)(z.default,{popupContent:m("auth.credentialUnavailable",{ns:"plugin"}),children:e}):e},[d,h,u,c,m]);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"flex items-center space-x-1.5",children:[i&&x,n&&i&&o&&(0,s.jsxs)("div",{className:"system-2xs-medium-uppercase flex shrink-0 flex-col items-center justify-between text-text-tertiary",children:[(0,s.jsx)("div",{className:"h-2 w-[1px] bg-divider-subtle"}),"or",(0,s.jsx)("div",{className:"h-2 w-[1px] bg-divider-subtle"})]}),o&&g]})})});var B=e.i(291631);let K=(0,l.memo)(e=>{let{credential:t,disabled:a,onDelete:i,onEdit:o,onSetDefault:u,onRename:c,disableRename:d,disableEdit:m,disableDelete:p,disableSetDefault:h,onItemClick:x,showSelectedIcon:g,selectedCredentialId:f}=e,{t:b}=(0,r.useTranslation)(),[v,y]=(0,l.useState)(!1),[C,w]=(0,l.useState)(t.name),k=t.credential_type===j.OAUTH2,_=(0,l.useMemo)(()=>!(d&&m&&p&&h),[d,m,p,h]),N=(0,s.jsxs)("div",{className:(0,M.cn)("group flex h-8 items-center rounded-lg p-1 hover:bg-state-base-hover",v&&"bg-state-base-hover",(a||t.not_allowed_to_use)&&"cursor-not-allowed opacity-50"),onClick:()=>{t.not_allowed_to_use||a||x?.("__workspace_default__"===t.id?"":t.id)},children:[v&&(0,s.jsxs)("div",{className:"flex w-full items-center space-x-1",children:[(0,s.jsx)(B.default,{wrapperClassName:"grow rounded-[6px]",className:"h-6",value:C,onChange:e=>w(e.target.value),placeholder:b("placeholder.input",{ns:"common"}),onClick:e=>e.stopPropagation()}),(0,s.jsx)(n.default,{size:"small",variant:"primary",onClick:e=>{e.stopPropagation(),c?.({credential_id:t.id,name:C}),y(!1)},children:b("operation.save",{ns:"common"})}),(0,s.jsx)(n.default,{size:"small",onClick:e=>{e.stopPropagation(),y(!1)},children:b("operation.cancel",{ns:"common"})})]}),!v&&(0,s.jsxs)("div",{className:"flex w-0 grow items-center space-x-1.5",children:[g&&(0,s.jsx)("div",{className:"h-4 w-4",children:f===t.id&&(0,s.jsx)(T.RiCheckLine,{className:"h-4 w-4 text-text-accent"})}),(0,s.jsx)(U.default,{className:"ml-2 mr-1.5 shrink-0",color:t.not_allowed_to_use?"gray":"green"}),(0,s.jsx)("div",{className:"system-md-regular truncate text-text-secondary",title:t.name,children:t.name}),t.is_default&&(0,s.jsx)(A.default,{className:"shrink-0",children:b("auth.default",{ns:"plugin"})})]}),t.from_enterprise&&(0,s.jsx)(A.default,{className:"shrink-0",children:"Enterprise"}),_&&!v&&(0,s.jsxs)("div",{className:"ml-2 hidden shrink-0 items-center group-hover:flex",children:[!t.is_default&&!h&&!t.not_allowed_to_use&&(0,s.jsx)(n.default,{size:"small",disabled:a,onClick:e=>{e.stopPropagation(),u?.(t.id)},children:b("auth.setDefault",{ns:"plugin"})}),!d&&!t.from_enterprise&&!t.not_allowed_to_use&&(0,s.jsx)(z.default,{popupContent:b("operation.rename",{ns:"common"}),children:(0,s.jsx)(P.default,{disabled:a,onClick:e=>{e.stopPropagation(),y(!0),w(t.name)},children:(0,s.jsx)(T.RiEditLine,{className:"h-4 w-4 text-text-tertiary"})})}),!k&&!m&&!t.from_enterprise&&!t.not_allowed_to_use&&(0,s.jsx)(z.default,{popupContent:b("operation.edit",{ns:"common"}),children:(0,s.jsx)(P.default,{disabled:a,onClick:e=>{e.stopPropagation(),o?.(t.id,{...t.credentials,__name__:t.name,__credential_id__:t.id})},children:(0,s.jsx)(T.RiEqualizer2Line,{className:"h-4 w-4 text-text-tertiary"})})}),!p&&!t.from_enterprise&&(0,s.jsx)(z.default,{popupContent:b("operation.delete",{ns:"common"}),children:(0,s.jsx)(P.default,{className:"hover:bg-transparent",disabled:a,onClick:e=>{e.stopPropagation(),i?.(t.id)},children:(0,s.jsx)(T.RiDeleteBinLine,{className:"h-4 w-4 text-text-tertiary hover:text-text-destructive"})})})]})]},t.id);return t.not_allowed_to_use?(0,s.jsx)(z.default,{popupContent:b("auth.customCredentialUnavailable",{ns:"plugin"}),children:N}):N}),H=(0,l.memo)(e=>{let{pluginPayload:t,credentials:a,canOAuth:i,canApiKey:o,disabled:u,renderTrigger:c,isOpen:d,onOpenChange:p,offset:h=8,placement:x="bottom-start",triggerPopupSameWidth:g=!0,popupClassName:f,disableSetDefault:b,onItemClick:v,extraAuthorizationItems:y,showItemSelectedIcon:C,selectedCredentialId:w,onUpdate:I,notAllowCustomCredential:P}=e,{t:A}=(0,r.useTranslation)(),{notify:F}=(0,m.useToastContext)(),[E,R]=(0,l.useState)(!1),O=d??E,L=(0,l.useCallback)(e=>{p&&p(e),R(e)},[p]),V=a.filter(e=>e.credential_type===j.OAUTH2),z=a.filter(e=>e.credential_type===j.API_KEY),B=(0,l.useRef)(null),[H,W]=(0,l.useState)(null),{mutateAsync:Y}=k(t),G=(0,l.useCallback)(e=>{e&&(B.current=e),W(B.current)},[]),Q=(0,l.useCallback)(()=>{W(null),B.current=null},[]),[X,J]=(0,l.useState)(!1),Z=(0,l.useRef)(X),ee=(0,l.useCallback)(e=>{Z.current=e,J(e)},[]),et=(0,l.useCallback)(async()=>{if(!Z.current){if(!B.current)return void W(null);try{ee(!0),await Y({credential_id:B.current}),F({type:"success",message:A("api.actionSuccess",{ns:"common"})}),I?.(),W(null),B.current=null}finally{ee(!1)}}},[Y,I,F,A,ee]),[ea,es]=(0,l.useState)(null),el=(0,l.useCallback)((e,t)=>{B.current=e,es(t)},[]),en=(0,l.useCallback)(()=>{W(B.current)},[]),{mutateAsync:er}=_(t),ei=(0,l.useCallback)(async e=>{if(!Z.current)try{ee(!0),await er(e),F({type:"success",message:A("api.actionSuccess",{ns:"common"})}),I?.()}finally{ee(!1)}},[er,I,F,A,ee]),{mutateAsync:eo}=N(t),eu=(0,l.useCallback)(async e=>{if(!Z.current)try{ee(!0),await eo(e),F({type:"success",message:A("api.actionSuccess",{ns:"common"})}),I?.()}finally{ee(!1)}},[eo,F,A,ee,I]),ec=a.filter(e=>e.not_allowed_to_use),ed=a.find(e=>e.not_allowed_to_use&&e.is_default);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(D.PortalToFollowElem,{open:O,onOpenChange:L,placement:x,offset:h,triggerPopupSameWidth:g,children:[(0,s.jsx)(D.PortalToFollowElemTrigger,{onClick:()=>L(!O),asChild:!0,children:c?c(O):(0,s.jsxs)(n.default,{className:(0,M.cn)("w-full",d&&"bg-components-button-secondary-bg-hover"),children:[(0,s.jsx)(U.default,{className:"mr-2",color:ed?"gray":"green"}),a.length," ",a.length>1?A("auth.authorizations",{ns:"plugin"}):A("auth.authorization",{ns:"plugin"}),!!ec.length&&` (${ec.length} ${A("auth.unavailable",{ns:"plugin"})})`,(0,s.jsx)(T.RiArrowDownSLine,{className:"ml-0.5 h-4 w-4"})]})}),(0,s.jsx)(D.PortalToFollowElemContent,{className:"z-[100]",children:(0,s.jsxs)("div",{className:(0,M.cn)("max-h-[360px] overflow-y-auto rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg",f),children:[(0,s.jsxs)("div",{className:"py-1",children:[!!y?.length&&(0,s.jsx)("div",{className:"p-1",children:y.map(e=>(0,s.jsx)(K,{credential:e,disabled:u,onItemClick:v,disableRename:!0,disableEdit:!0,disableDelete:!0,disableSetDefault:!0,showSelectedIcon:C,selectedCredentialId:w},e.id))}),!!V.length&&(0,s.jsxs)("div",{className:"p-1",children:[(0,s.jsx)("div",{className:(0,M.cn)("system-xs-medium px-3 pb-0.5 pt-1 text-text-tertiary",C&&"pl-7"),children:"OAuth"}),V.map(e=>(0,s.jsx)(K,{credential:e,disabled:u,disableEdit:!0,onDelete:G,onSetDefault:ei,onRename:eu,disableSetDefault:b,onItemClick:v,showSelectedIcon:C,selectedCredentialId:w},e.id))]}),!!z.length&&(0,s.jsxs)("div",{className:"p-1",children:[(0,s.jsx)("div",{className:(0,M.cn)("system-xs-medium px-3 pb-0.5 pt-1 text-text-tertiary",C&&"pl-7"),children:"API Keys"}),z.map(e=>(0,s.jsx)(K,{credential:e,disabled:u,onDelete:G,onEdit:el,onSetDefault:ei,disableSetDefault:b,disableRename:!0,onItemClick:v,onRename:eu,showSelectedIcon:C,selectedCredentialId:w},e.id))]})]}),!P&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"h-[1px] bg-divider-subtle"}),(0,s.jsx)("div",{className:"p-2",children:(0,s.jsx)(q,{pluginPayload:t,theme:"secondary",showDivider:!1,canOAuth:i,canApiKey:o,disabled:u,onUpdate:I})})]})]})})]}),H&&(0,s.jsx)($.default,{isShow:!0,title:A("list.delete.title",{ns:"datasetDocuments"}),isDisabled:X,onCancel:Q,onConfirm:et}),!!ea&&(0,s.jsx)(S,{pluginPayload:t,editValues:ea,onClose:()=>{es(null),B.current=null},onRemove:en,disabled:u||X,onUpdate:I})]})}),W=(0,l.memo)(e=>{let{authorizationsNum:t,onJumpToDataSourcePage:a}=e,{t:l}=(0,r.useTranslation)();return(0,s.jsxs)(n.default,{size:"small",onClick:a,children:[(0,s.jsx)(U.default,{className:"mr-1.5",color:"green"}),l(t>1?"auth.authorizations":"auth.authorization",{ns:"plugin"}),(0,s.jsx)(T.RiEqualizer2Line,{className:(0,M.cn)("h-3.5 w-3.5 text-components-button-ghost-text")})]})});e.s(["default",0,W],735964),e.s(["default",()=>Q],946468);var Y=e.i(751992);let G=(e,t)=>{let a,s,l,n,r,i,{data:o}=(a=w(e),s=t?a.getCredentialInfo:"",(0,g.useQuery)({enabled:!!s,queryKey:[v,"credential-info",s],queryFn:()=>(0,f.get)(s),staleTime:0})),{isCurrentWorkspaceManager:u}=(0,Y.useAppContext)(),c=!!o?.credentials.length,d=o?.supported_credential_types.includes(j.OAUTH2),m=o?.supported_credential_types.includes(j.API_KEY),p=(l=w(e).getCredentialInfo,n=(0,b.useInvalid)([v,"credential-info",l]),r=e.providerType,i=(0,y.useInvalidToolsByType)(r),()=>{n(),i()});return{isAuthorized:c,canOAuth:d,canApiKey:m,credentials:o?.credentials||[],disabled:!u,notAllowCustomCredential:o?.allow_custom_token===!1,invalidPluginCredentialInfo:p}},Q=(0,l.memo)(e=>{let{pluginPayload:t,onAuthorizationItemClick:a,credentialId:i}=e,{t:o}=(0,r.useTranslation)(),[u,c]=(0,l.useState)(!1),{canApiKey:d,canOAuth:m,credentials:p,disabled:h,invalidPluginCredentialInfo:x,notAllowCustomCredential:g}=G(t,!0),f=(0,l.useCallback)(e=>{let t="",a=!1,l=!1,r="green",u=!1;if(i){let e=p.find(e=>e.id===i);t=e?e.name:o("auth.authRemoved",{ns:"plugin"}),a=!e,l=!!e?.not_allowed_to_use&&!e?.from_enterprise,a?r="red":l&&(r="gray")}else{t=o("auth.workspaceDefault",{ns:"plugin"});let e=p.find(e=>e.is_default);e?.not_allowed_to_use&&(r="gray",u=!0)}return(0,s.jsxs)(n.default,{size:"small",className:(0,M.cn)(e&&!a&&"bg-components-button-ghost-bg-hover",a&&"bg-transparent text-text-destructive"),variant:u||l?"ghost":"secondary",children:[(0,s.jsx)(U.default,{className:"mr-1.5",color:r}),t,(l||u)&&(0,s.jsxs)(s.Fragment,{children:[" ",o("auth.unavailable",{ns:"plugin"})]}),(0,s.jsx)(T.RiArrowDownSLine,{className:(0,M.cn)("h-3.5 w-3.5 text-components-button-ghost-text",a&&"text-text-destructive")})]})},[i,p,o]),b=p.find(e=>e.is_default)?.not_allowed_to_use,v=[{id:"__workspace_default__",name:o("auth.workspaceDefault",{ns:"plugin"}),provider:"",is_default:!i,isWorkspaceDefault:!0,not_allowed_to_use:b}],y=(0,l.useCallback)(e=>{a(e),c(!1)},[a,c]);return(0,s.jsx)(H,{pluginPayload:t,credentials:p,canOAuth:m,canApiKey:d,renderTrigger:f,isOpen:u,onOpenChange:c,offset:4,placement:"bottom-end",triggerPopupSameWidth:!1,popupClassName:"w-[360px]",disabled:h,disableSetDefault:!0,onItemClick:y,extraAuthorizationItems:v,showItemSelectedIcon:!0,selectedCredentialId:i||"__workspace_default__",onUpdate:x,notAllowCustomCredential:g})});e.s(["usePluginAuthAction",0,(e,t)=>{let{t:a}=(0,r.useTranslation)(),{notify:s}=(0,m.useToastContext)(),n=(0,l.useRef)(null),[i,o]=(0,l.useState)(null),{mutateAsync:u}=k(e),c=(0,l.useCallback)(e=>{e&&(n.current=e),o(n.current)},[]),d=(0,l.useCallback)(()=>{o(null),n.current=null},[]),[p,h]=(0,l.useState)(!1),x=(0,l.useRef)(p),g=(0,l.useCallback)(e=>{x.current=e,h(e)},[]),[f,b]=(0,l.useState)(null),v=(0,l.useCallback)(async()=>{if(!x.current){if(!n.current)return void o(null);try{g(!0),await u({credential_id:n.current}),s({type:"success",message:a("api.actionSuccess",{ns:"common"})}),t?.(),o(null),n.current=null,b(null)}finally{g(!1)}}},[u,t,s,a,g]),y=(0,l.useCallback)((e,t)=>{n.current=e,b(t)},[]),C=(0,l.useCallback)(()=>{o(n.current)},[]),{mutateAsync:j}=_(e),w=(0,l.useCallback)(async e=>{if(!x.current)try{g(!0),await j(e),s({type:"success",message:a("api.actionSuccess",{ns:"common"})}),t?.()}finally{g(!1)}},[j,t,s,a,g]),{mutateAsync:S}=N(e),I=(0,l.useCallback)(async e=>{if(!x.current)try{g(!0),await S(e),s({type:"success",message:a("api.actionSuccess",{ns:"common"})}),t?.()}finally{g(!1)}},[S,s,a,g,t]);return{doingAction:p,handleSetDoingAction:g,openConfirm:c,closeConfirm:d,deleteCredentialId:i,setDeleteCredentialId:o,handleConfirm:v,editValues:f,setEditValues:b,handleEdit:y,handleRemove:C,handleSetDefault:w,handleRename:I,pendingOperationCredentialId:n}}],958692);let X=(0,l.memo)(e=>{let{pluginPayload:t,children:a,className:l}=e,{isAuthorized:n,canOAuth:r,canApiKey:i,credentials:o,disabled:u,invalidPluginCredentialInfo:c,notAllowCustomCredential:d}=G(t,!!t.provider);return(0,s.jsxs)("div",{className:(0,M.cn)(!n&&l),children:[!n&&(0,s.jsx)(q,{pluginPayload:t,canOAuth:r,canApiKey:i,disabled:u,onUpdate:c,notAllowCustomCredential:d}),n&&!a&&(0,s.jsx)(H,{pluginPayload:t,credentials:o,canOAuth:r,canApiKey:i,disabled:u,onUpdate:c,notAllowCustomCredential:d}),n&&a]})});e.s(["default",0,X],230121);let J=(0,l.memo)(e=>{let{pluginPayload:t,credentialId:a,onAuthorizationItemClick:i}=e,{t:o}=(0,r.useTranslation)(),[u,c]=(0,l.useState)(!1),{isAuthorized:d,canOAuth:m,canApiKey:p,credentials:h,disabled:x,invalidPluginCredentialInfo:g,notAllowCustomCredential:f}=G(t,!0),b=[{id:"__workspace_default__",name:o("auth.workspaceDefault",{ns:"plugin"}),provider:"",is_default:!a,isWorkspaceDefault:!0}],v=(0,l.useCallback)(e=>{i?.(e),c(!1)},[i,c]),y=(0,l.useCallback)(e=>{let t="",l=!1,r=!1,i="green";if(a){let e=h.find(e=>e.id===a);t=e?e.name:o("auth.authRemoved",{ns:"plugin"}),l=!e,r=!!e?.not_allowed_to_use&&!e?.from_enterprise,l?i="red":r&&(i="gray")}else t=o("auth.workspaceDefault",{ns:"plugin"});return(0,s.jsxs)(n.default,{className:(0,M.cn)("w-full",e&&"bg-components-button-secondary-bg-hover",l&&"text-text-destructive"),children:[(0,s.jsx)(U.default,{className:"mr-2",color:i}),t,r&&o("auth.unavailable",{ns:"plugin"}),(0,s.jsx)(T.RiArrowDownSLine,{className:"ml-0.5 h-4 w-4"})]})},[a,h,o]);return(0,s.jsxs)(s.Fragment,{children:[!d&&(0,s.jsx)(q,{pluginPayload:t,canOAuth:m,canApiKey:p,disabled:x,onUpdate:g,notAllowCustomCredential:f}),d&&(0,s.jsx)(H,{pluginPayload:t,credentials:h,canOAuth:m,canApiKey:p,disabled:x,disableSetDefault:!0,onItemClick:v,extraAuthorizationItems:b,showItemSelectedIcon:!0,renderTrigger:y,isOpen:u,onOpenChange:c,selectedCredentialId:a||"__workspace_default__",onUpdate:g,notAllowCustomCredential:f})]})});e.s(["default",0,J],677316);let Z=(0,l.memo)(e=>{let{children:t,isAuthorized:a,onJumpToDataSourcePage:l}=e,{t:i}=(0,r.useTranslation)();return(0,s.jsxs)(s.Fragment,{children:[!a&&(0,s.jsx)("div",{className:"px-4 pb-2",children:(0,s.jsxs)(n.default,{className:"w-full",variant:"primary",onClick:l,children:[(0,s.jsx)(T.RiAddLine,{className:"mr-1 h-4 w-4"}),i("integrations.connect",{ns:"common"})]})}),a&&t]})});e.s(["default",0,Z],227746)},349714,844367,e=>{"use strict";var t=e.i(942347);function a(e){try{let t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("Authorization URL must be HTTP or HTTPS")}catch(t){if(t instanceof Error&&"Authorization URL must be HTTP or HTTPS"===t.message)throw t;throw Error(`Invalid URL: ${e}`)}}function s(e){try{let t=new URL(e).hostname.toLowerCase();if("localhost"===t||"127.0.0.1"===t||"::1"===t)return!0;let a=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(t);if(a){let[,e,t]=a.map(Number);if(10===e||172===e&&t>=16&&t<=31||192===e&&168===t||169===e&&254===t)return!0}return t.endsWith(".local")}catch{return!1}}e.s(["isPrivateOrLocalAddress",()=>s,"validateRedirectUrl",()=>a],844367),e.s(["openOAuthPopup",0,(e,t)=>{let s=window.screenX+(window.outerWidth-600)/2,l=window.screenY+(window.outerHeight-600)/2;a(e);let n=window.open(e,"OAuth",`width=600,height=600,left=${s},top=${l},scrollbars=yes`),r=e=>{e.data?.type==="oauth_callback"&&(window.removeEventListener("message",r),t(e.data))};window.addEventListener("message",r);let i=setInterval(()=>{n?.closed&&(clearInterval(i),window.removeEventListener("message",r),t())},1e3);return n},"useOAuthCallback",0,()=>{(0,t.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get("subscription_id"),a=e.get("error"),s=e.get("error_description");if(window.opener){let e=window.opener?.origin||"*";t?window.opener.postMessage({type:"oauth_callback",success:!0,subscriptionId:t},e):a?window.opener.postMessage({type:"oauth_callback",success:!1,error:a,errorDescription:s},e):window.opener.postMessage({type:"oauth_callback"},e),window.close()}},[])}],349714)},48803,e=>{e.v("/_next/static/media/search-menu.d76c0e7c.svg")},574270,e=>{"use strict";var t=e.i(162115),a=e.i(942347),s=e.i(935139);let l=a.memo(e=>{let{isChecked:a,disabled:l=!1,onCheck:n,className:r}=e;return(0,t.jsx)("div",{role:"radio","aria-checked":a,"aria-disabled":l,className:(0,s.cn)("size-4 rounded-full",a&&!l&&"border-[5px] border-components-radio-border-checked hover:border-components-radio-border-checked-hover",!a&&!l&&"border border-components-radio-border hover:border-components-radio-border-hover",a&&l&&"border-[5px] border-components-radio-border-checked-disabled",!a&&l&&"border border-components-radio-border-disabled bg-components-radio-bg-disabled",!l&&"bg-components-radio-bg shadow-xs shadow-shadow-shadow-3 hover:bg-components-radio-bg-hover",r),onClick:e=>{l||n?.(e)}})});e.s(["default",0,l])},453284,e=>{"use strict";var t=e.i(162115),a=e.i(869931),s=e.i(942347);e.i(816688);var l=e.i(675066),n=e.i(935139);e.s(["default",0,e=>{let{placeholder:r,className:i,value:o,onChange:u,white:c}=e,{t:d}=(0,l.useTranslation)(),m=(0,s.useRef)(null),[p,h]=(0,s.useState)(!1),x=(0,s.useRef)(!1),[g,f]=(0,s.useState)("");return(0,t.jsxs)("div",{className:(0,n.cn)("group flex h-8 items-center overflow-hidden rounded-lg border-none bg-components-input-bg-normal px-2 hover:bg-components-input-bg-hover",p&&"!bg-components-input-bg-active",c&&"!border-gray-300 !bg-white shadow-xs hover:!border-gray-300 hover:!bg-white",i),children:[(0,t.jsx)("div",{className:"pointer-events-none mr-1.5 flex h-4 w-4 shrink-0 items-center justify-center",children:(0,t.jsx)(a.RiSearchLine,{className:"h-4 w-4 text-components-input-text-placeholder","aria-hidden":"true"})}),(0,t.jsx)("input",{ref:m,type:"text",name:"query",className:(0,n.cn)("system-sm-regular caret-#295EFF block h-[18px] grow appearance-none border-0 bg-transparent text-components-input-text-filled outline-none placeholder:text-components-input-text-placeholder",c&&"!bg-white placeholder:!text-gray-400 hover:!bg-white group-hover:!bg-white"),placeholder:r||d("operation.search",{ns:"common"}),value:x.current?g:o,onChange:e=>{let t=e.target.value;x.current?f(t):u(t)},onCompositionStart:()=>{x.current=!0,f(o)},onCompositionEnd:e=>{x.current=!1,f(""),u(e.currentTarget.value)},onFocus:()=>h(!0),onBlur:()=>h(!1),autoComplete:"off"}),o&&(0,t.jsx)("button",{type:"button","aria-label":d("operation.clear",{ns:"common"}),className:"group/clear flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center border-none bg-transparent p-0",onClick:()=>{u(""),m.current?.focus()},children:(0,t.jsx)(a.RiCloseCircleFill,{className:"h-4 w-4 text-text-quaternary group-hover/clear:text-text-tertiary"})})]})}])},588226,449758,566210,456721,610683,e=>{"use strict";var t=e.i(162115),a=e.i(942347);e.s([],456721);var s=e.i(622111);e.i(816688);var l=e.i(675066),n=e.i(83278),r=e.i(324935),i=e.i(453284);let o={src:e.i(48803).default,width:32,height:32,blurWidth:0,blurHeight:0};var u=e.i(935139),c=e.i(151094);let d=e=>{let{title:s="",label:d,description:m,options:p,value:h=[],onChange:x,disabled:g=!1,containerClassName:f,showSelectAll:b=!0,showCount:v=!0,showSearch:y=!0,maxHeight:C}=e,{t:j}=(0,l.useTranslation)(),[w,k]=(0,a.useState)(""),_=(0,a.useMemo)(()=>{if(!w?.trim())return p;let e=w.toLowerCase();return p.filter(t=>t.label.toLowerCase().includes(e)||t.value.toLowerCase().includes(e))},[p,w]),N=h.length,S=(0,a.useMemo)(()=>{let e=p.filter(e=>!e.disabled);return e.length>0&&e.every(e=>h.includes(e.value))},[p,h]),I=(0,a.useMemo)(()=>{let e=p.filter(e=>!e.disabled),t=e.filter(e=>h.includes(e.value)).length;return t>0&&t{if(!g)if(S)x?.([]);else{let e=p.filter(e=>!e.disabled).map(e=>e.value);x?.(e)}},[S,p,x,g]),P=(0,a.useCallback)(e=>{if(g)return;let t=h.includes(e)?h.filter(t=>t!==e):[...h,e];x?.(t)},[h,x,g]);return(0,t.jsxs)("div",{className:(0,u.cn)("flex w-full flex-col gap-1",f),children:[d&&(0,t.jsx)("div",{className:"text-text-secondary system-sm-medium",children:d}),m&&(0,t.jsx)("div",{className:"text-text-tertiary body-xs-regular",children:m}),(0,t.jsxs)("div",{className:"rounded-lg border border-components-panel-border bg-components-panel-bg",children:[(b||s||y)&&(0,t.jsxs)("div",{className:"relative flex items-center gap-2 border-b border-divider-subtle px-3 py-2",children:[!w&&b&&(0,t.jsx)(r.default,{checked:S,indeterminate:I,onCheck:T,disabled:g,id:"selectAll"}),w?(0,t.jsx)("div",{className:"flex-1 leading-6 text-text-secondary system-sm-medium-uppercase",children:_.length>0?j("operation.searchCount",{ns:"common",count:_.length,content:s}):j("operation.noSearchCount",{ns:"common",content:s})}):(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[s&&(0,t.jsx)("span",{className:"truncate leading-5 text-text-secondary system-xs-semibold-uppercase",children:s}),v&&N>0&&(0,t.jsx)(n.default,{uppercase:!0,children:j("operation.selectCount",{ns:"common",count:N})})]}),y&&(0,t.jsx)(i.default,{value:w,onChange:k,placeholder:j("placeholder.search",{ns:"common"}),className:"w-40"})]}),(0,t.jsx)("div",{className:"p-1",style:C?{maxHeight:C,overflowY:"auto"}:{},"data-testid":"options-container",children:_.length?_.map(e=>{let a=h.includes(e.value);return(0,t.jsxs)("div",{"data-testid":"option-item",className:(0,u.cn)("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-state-base-hover",e.disabled&&"cursor-not-allowed opacity-50"),onClick:()=>{e.disabled||g||P(e.value)},children:[(0,t.jsx)(r.default,{checked:a,onCheck:()=>{e.disabled||g||P(e.value)},disabled:e.disabled||g,id:e.value}),(0,t.jsx)("div",{className:"flex-1 truncate text-text-secondary system-sm-medium",title:e.label,children:e.label})]},e.value)}):(0,t.jsx)("div",{className:"px-3 py-6 text-center text-sm text-text-tertiary",children:w?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2",children:[(0,t.jsx)("img",{alt:"search menu",src:o.src,width:32}),(0,t.jsx)("span",{className:"text-text-secondary system-sm-regular",children:j("operation.noSearchResults",{ns:"common",content:s})}),(0,t.jsx)(c.default,{variant:"secondary-accent",size:"small",onClick:()=>k(""),children:j("operation.resetKeywords",{ns:"common"})})]}):j("noData",{ns:"common"})})})]})]})};e.s(["default",0,d],449758);var m=e.i(603135),p=e.i(291631),h=e.i(545766),x=e.i(574270),g=e.i(306101),f=e.i(421001),b=e.i(225162),v=e.i(645429);let y=()=>{let e=(0,b.useLanguage)();return t=>(0,v.renderI18nObject)(t,e)};e.s(["useRenderI18nObject",0,y],566210);var C=e.i(819114);let j=e=>{let{content:t,render:s}=e;return(0,a.isValidElement)(t)||"string"==typeof t?t:"object"==typeof t&&null!==t?s(t):""},w={[m.FormItemValidateStatusEnum.Error]:{componentClassName:"border-components-input-border-destructive focus:border-components-input-border-destructive",textClassName:"text-text-destructive",infoFieldName:"errors"},[m.FormItemValidateStatusEnum.Warning]:{componentClassName:"border-components-input-border-warning focus:border-components-input-border-warning",textClassName:"text-text-warning",infoFieldName:"warnings"},[m.FormItemValidateStatusEnum.Success]:{componentClassName:"",textClassName:"",infoFieldName:""},[m.FormItemValidateStatusEnum.Validating]:{componentClassName:"",textClassName:"",infoFieldName:""}},k=(0,a.memo)(e=>{let{fieldClassName:n,labelClassName:r,inputContainerClassName:i,inputClassName:o,formSchema:c,field:b,disabled:v,onChange:k,fieldState:_}=e,N=y(),{t:S}=(0,l.useTranslation)(),{name:I,label:T,required:P,placeholder:A,options:F,labelClassName:E,disabled:M,type:R,dynamicSelectParams:O,multiple:L=!1,tooltip:V,showCopy:$,description:D,url:U,help:z}=c,q=v||M,[B,K,H,W,Y]=(0,a.useMemo)(()=>{let e=[T,A,V,D,z].map(e=>j({content:e,render:N}));return e[1]||(e[1]=S("placeholder.input",{ns:"common"})),e},[T,A,V,D,z,N]),G=(0,a.useMemo)(()=>{let e=new Set;for(let t of F||[])for(let a of t.show_on||[])e.add(a.variable);return Array.from(e)},[F]),Q=(0,s.useStore)(b.form.store,e=>{let t={};for(let a of G)t[a]=e.values[a];return t}),X=(0,a.useMemo)(()=>F?.filter(e=>!e.show_on?.length||e.show_on.every(e=>Q[e.variable]===e.value)).map(e=>({label:j({content:e.label,render:N}),value:e.value}))||[],[F,N,Q]),J=(0,s.useStore)(b.form.store,e=>e.values[b.name]),{data:Z,isLoading:ee,error:et}=(0,C.useTriggerPluginDynamicOptions)(O||{plugin_id:"",provider:"",action:"",parameter:"",credential_id:""},R===m.FormTypeEnum.dynamicSelect),ea=(0,a.useMemo)(()=>Z?.options?Z.options.map(e=>({label:j({content:e.label,render:N}),value:e.value})):[],[Z,N]),es=(0,a.useCallback)(e=>{b.handleChange(e),k?.(b.name,e)},[b,k]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:(0,u.cn)(n),children:[(0,t.jsxs)("div",{className:(0,u.cn)(r,E),children:[B,P&&!(0,a.isValidElement)(T)&&(0,t.jsx)("span",{className:"ml-1 text-text-destructive-secondary",children:"*"}),V&&(0,t.jsx)(f.default,{triggerTestId:"base-field-tooltip-trigger",popupContent:(0,t.jsx)("div",{className:"w-[200px]",children:H}),triggerClassName:"ml-0.5 w-4 h-4"})]}),(0,t.jsxs)("div",{className:(0,u.cn)(i),children:[[m.FormTypeEnum.textInput,m.FormTypeEnum.secretInput,m.FormTypeEnum.textNumber].includes(R)&&(0,t.jsx)(p.default,{id:b.name,name:b.name,className:(0,u.cn)(o,w[_?.validateStatus]?.componentClassName),value:J||"",onChange:e=>{es(e.target.value)},onBlur:b.handleBlur,disabled:q,placeholder:K,...(e=>{switch(e){case m.FormTypeEnum.secretInput:return{type:"password",autoComplete:"new-password"};case m.FormTypeEnum.textNumber:return{type:"number"};default:return{type:"text"}}})(R),showCopyIcon:$}),R===m.FormTypeEnum.select&&!L&&(0,t.jsx)(g.default,{value:J,onChange:e=>es(e),disabled:q,placeholder:K,options:X,triggerPopupSameWidth:!0,popupProps:{className:"max-h-[320px] overflow-y-auto"}}),R===m.FormTypeEnum.checkbox&&(0,t.jsx)(d,{title:I,value:J,onChange:e=>b.handleChange(e),options:X,maxHeight:"200px"}),R===m.FormTypeEnum.dynamicSelect&&(0,t.jsx)(g.default,{options:ea,value:J,onChange:b.handleChange,disabled:q||ee,placeholder:ee?S("dynamicSelect.loading",{ns:"common"}):K,...et?{popupProps:{title:S("dynamicSelect.error",{ns:"common"}),titleClassName:"text-text-destructive-secondary"}}:!ea.length?{popupProps:{title:S("dynamicSelect.noData",{ns:"common"})}}:{},triggerPopupSameWidth:!0,multiple:L}),R===m.FormTypeEnum.radio&&(0,t.jsx)("div",{className:(0,u.cn)(X.length<3?"flex items-center space-x-2":"space-y-2"),"data-testid":"radio-group",children:X.map(e=>(0,t.jsxs)("div",{className:(0,u.cn)("hover:bg-components-option-card-option-hover-bg hover:border-components-option-card-option-hover-border flex h-8 flex-[1] grow cursor-pointer items-center justify-center gap-2 rounded-lg border border-components-option-card-option-border bg-components-option-card-option-bg p-2 text-text-secondary system-sm-regular",J===e.value&&"border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg text-text-primary shadow-xs",q&&"cursor-not-allowed opacity-50",o),onClick:()=>!q&&es(e.value),children:[c.showRadioUI&&(0,t.jsx)(x.default,{className:"mr-2",isChecked:J===e.value}),e.label]},e.value))}),R===m.FormTypeEnum.boolean&&(0,t.jsxs)(h.default.Group,{className:"flex w-fit items-center",value:J,onChange:e=>b.handleChange(e),children:[(0,t.jsx)(h.default,{value:!0,className:"!mr-1",children:"True"}),(0,t.jsx)(h.default,{value:!1,children:"False"})]}),_?.validateStatus&&[m.FormItemValidateStatusEnum.Error,m.FormItemValidateStatusEnum.Warning].includes(_?.validateStatus)&&(0,t.jsx)("div",{className:(0,u.cn)("mt-1 px-0 py-[2px] system-xs-regular",w[_?.validateStatus].textClassName),children:_?.[w[_?.validateStatus].infoFieldName]})]})]}),D&&(0,t.jsx)("div",{className:"mt-4 text-text-tertiary system-xs-regular",children:W}),U&&(0,t.jsxs)("a",{className:"mt-4 flex items-center text-text-accent system-xs-regular",href:U,target:"_blank",children:[(0,t.jsx)("span",{className:"break-all",children:Y}),(0,t.jsx)("div",{className:"i-ri-external-link-line ml-1 h-3 w-3 shrink-0"})]})]})});var _=e.i(301293),N=e.i(734962);let S=(0,a.memo)(e=>{let{formSchemas:n=[],defaultValues:r,formClassName:i,fieldClassName:o,labelClassName:c,inputContainerClassName:d,inputClassName:p,ref:h,disabled:x,formFromProps:g,onChange:f,onSubmit:b,preventDefaultSubmit:v=!1}=e,C=(0,a.useMemo)(()=>r||n.reduce((e,t)=>(t.default&&(e[t.name]=t.default),e),{}),[r]),j=(0,_.useForm)({defaultValues:C}),w=g||j,{getFormValues:S}=((e,t)=>{let{checkValidated:s}=((e,t)=>{let{notify:s}=(0,N.useToastContext)();return{checkValidated:(0,a.useCallback)(()=>{let a=e?.getAllErrors(),l=e.state.values;if(a){let e=a.fields,n=Object.keys(e).reduce((a,s)=>{let{show_on:n=[]}=t.find(e=>e.name===s)||{},r=n.reduce((e,t)=>(e[t.variable]=l[t.variable],e),{});return[...a,...n?.every(e=>r[e.variable]===e.value)?e[s].errors:[]]},[]);if(n.length)return s({type:"error",message:n[0]}),!1}return!0},[e,s,t])}})(e,t);return{getFormValues:(0,a.useCallback)(a=>{let{needCheckValidatedValues:l=!0,needTransformWhenSecretFieldIsPristine:n}=a,r=e?.store.state.values||{};return l?s()?{values:n?((e,t)=>{let a,s=t?.store.state.values||{},l=[];for(let a=0;a{a[e]&&(a[e]="[__HIDDEN__]")}),a})(t,e):r,isCheckValidated:!0}:{values:{},isCheckValidated:!1}:{values:r,isCheckValidated:!0}},[e,s,t])}})(w,n),{getValidators:I}=(()=>{let{t:e}=(0,l.useTranslation)(),t=y(),s=(0,a.useCallback)(e=>(0,a.isValidElement)(e)?"":"string"==typeof e?e:"object"==typeof e&&null!==e?t(e):void 0,[]);return{getValidators:(0,a.useCallback)(t=>{let{name:a,validators:l,required:n,label:r}=t,i=l,o=s(r);return n&&!l&&(i={onMount:t=>{let{value:s}=t;if(!s)return e("errorMsg.fieldRequired",{ns:"common",field:o||a})},onChange:t=>{let{value:s}=t;if(!s)return e("errorMsg.fieldRequired",{ns:"common",field:o||a})},onBlur:t=>{let{value:a}=t;if(!a)return e("errorMsg.fieldRequired",{ns:"common",field:o})}}),i},[e,s])}})(),[T,P]=(0,a.useState)({}),A=(0,s.useStore)(w.store,e=>{let t={};return n.forEach(a=>{let{show_on:s}=a;s?.length&&s.forEach(a=>{t[a.variable]=e.values[a.variable]})}),t}),F=(0,a.useCallback)(e=>{let t={...T};for(let a of e){let{name:e,value:s,errors:l,warnings:n,validateStatus:r,help:i}=a;void 0!==s&&w.setFieldValue(e,s);let o=r;!o&&(l&&l.length>0?o=m.FormItemValidateStatusEnum.Error:n&&n.length>0&&(o=m.FormItemValidateStatusEnum.Warning)),t[e]={validateStatus:o,help:i,errors:l,warnings:n}}P(t)},[w,T]);(0,a.useImperativeHandle)(h,()=>({getForm:()=>w,getFormValues:e=>S(e),setFields:F}),[w,S,F]);let E=(0,a.useCallback)(e=>{let a=n?.find(t=>t.name===e.name);return a?(0,t.jsx)(k,{field:e,formSchema:a,fieldClassName:o??a.fieldClassName,labelClassName:c??a.labelClassName,inputContainerClassName:d,inputClassName:p,disabled:x,onChange:f,fieldState:T[e.name]}):null},[n,o,c,d,p,x,f,T]),M=(0,a.useCallback)(e=>{let a=I(e),{name:s,show_on:l=[]}=e;return l?.every(e=>A[e.variable]===e.value)?(0,t.jsx)(w.Field,{name:s,validators:a,children:E},s):null},[E,w,I,A]);return n?.length?(0,t.jsx)("form",{className:(0,u.cn)(i),onSubmit:e=>{v&&(e.preventDefault(),e.stopPropagation()),b?.(e)},children:n.map(M)}):null});e.s(["BaseForm",0,S],610683);let I=(0,a.memo)(e=>{let{formSchemas:a=[],defaultValues:s,ref:l,formFromProps:n,...r}=e;return(0,t.jsx)(S,{ref:l,formSchemas:a,defaultValues:s,formClassName:"space-y-4",labelClassName:"h-6 flex items-center mb-1 system-sm-medium text-text-secondary",formFromProps:n,...r})});e.s(["default",0,I],588226)},495187,e=>{"use strict";var t=e.i(824627),a=e.i(942347),s=e.i(875555);e.s(["useDebounce",0,function(e,l){var n=(0,t.__read)((0,a.useState)(e),2),r=n[0],i=n[1],o=(0,s.default)(function(){i(e)},l).run;return(0,a.useEffect)(function(){o()},[e]),r}],495187)},508110,e=>{"use strict";var t=e.i(340801);e.s(["Mcp",()=>t.default])},931576,776388,70486,e=>{"use strict";var t=e.i(162115),a=e.i(942347);e.i(816688);var s=e.i(675066),l=e.i(21151),n=e.i(935139),r=e.i(944911),i=e.i(568349),o=e.i(664826),u=e.i(632717),c=e.i(869931),d=e.i(151094),m=e.i(324935),p=e.i(95085),h=e.i(220365),x=e.i(339548);let g=(0,x.createContext)({emit:h.noop,useSubscribe:h.noop});function f(e){return(0,x.useContextSelector)(g,e)}e.s(["MittContext",0,g,"useMittContextSelector",()=>f],776388);var b=e.i(157644),v=e.i(745754),y=e.i(21693);e.i(36860);var C=e.i(438270);let j=a.memo(()=>{let{t:e}=(0,s.useTranslation)();return(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(m.default,{className:"shrink-0",checked:!1,disabled:!0}),(0,t.jsxs)("div",{className:"hover-bg-components-panel-on-panel-item-bg relative grow rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg p-4 pb-3 shadow-xs",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsxs)("div",{className:"relative flex h-10 w-10 items-center justify-center gap-2 rounded-[10px] border-[0.5px] border-state-destructive-border bg-state-destructive-hover p-1 backdrop-blur-sm",children:[(0,t.jsx)("div",{className:"flex h-5 w-5 items-center justify-center",children:(0,t.jsx)(C.Group,{className:"text-text-quaternary"})}),(0,t.jsx)("div",{className:"absolute bottom-[-4px] right-[-4px] rounded-full border-[2px] border-components-panel-bg bg-state-destructive-solid",children:(0,t.jsx)(c.RiCloseLine,{className:"h-3 w-3 text-text-primary-on-surface"})})]}),(0,t.jsxs)("div",{className:"ml-3 grow",children:[(0,t.jsx)("div",{className:"system-md-semibold flex h-5 items-center text-text-destructive",children:e("installModal.pluginLoadError",{ns:"plugin"})}),(0,t.jsx)("div",{className:"system-xs-regular mt-0.5 text-text-tertiary",children:e("installModal.pluginLoadErrorDesc",{ns:"plugin"})})]})]}),(0,t.jsx)(y.LoadingPlaceholder,{className:"mt-3 w-[420px]"})]})]})}),w=a.memo(()=>(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(m.default,{className:"shrink-0",checked:!1,disabled:!0}),(0,t.jsx)("div",{className:"hover-bg-components-panel-on-panel-item-bg relative grow rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg p-4 pb-3 shadow-xs",children:(0,t.jsx)(y.default,{wrapClassName:"w-full"})})]}));var k=e.i(228403),_=e.i(925521),N=e.i(365181),S=e.i(222573),I=e.i(292005),T=e.i(494268),P=e.i(547682);function A(e,t){if(t.plugin_installation_permission.restrict_to_marketplace_only&&("github"===e.from||"package"===e.from))return{canInstall:!1};if(t.plugin_installation_permission.plugin_installation_scope===P.InstallationScope.ALL)return{canInstall:!0};if(t.plugin_installation_permission.plugin_installation_scope===P.InstallationScope.NONE)return{canInstall:!1};let a=e.verification||{};return(e.verification&&e.verification.authorized_category||(a.authorized_category="langgenius"),t.plugin_installation_permission.plugin_installation_scope===P.InstallationScope.OFFICIAL_ONLY)?{canInstall:"langgenius"===a.authorized_category}:t.plugin_installation_permission.plugin_installation_scope===P.InstallationScope.OFFICIAL_AND_PARTNER?{canInstall:"langgenius"===a.authorized_category||"partner"===a.authorized_category}:{canInstall:!0}}function F(e){return A(e,(0,T.useGlobalPublicStore)(e=>e.systemFeatures))}let E=a.memo(e=>{let{checked:a,onCheckedChange:s,payload:l,isFromMarketPlace:n,versionInfo:r}=e,{getIconUrl:i}=(0,S.default)(),o={...r,toInstallVersion:l.version},{canInstall:u}=F(l);return(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(m.default,{disabled:!u,className:"shrink-0",checked:a,onCheck:()=>s(l)}),(0,t.jsx)(N.default,{className:"grow",payload:{...l,icon:n?`${_.MARKETPLACE_API_PREFIX}/plugins/${l.org}/${l.name}/icon`:i(l.icon)},titleLeft:l.version?(0,t.jsx)(I.default,{...o}):null,limitedInstall:!u})]})}),M=a.memo(e=>{let{checked:s,onCheckedChange:l,dependency:n,versionInfo:r,onFetchedPayload:i,onFetchError:o}=e,u=n.value,{data:c,error:d}=(0,b.useUploadGitHub)({repo:u.repo,version:u.release||u.version,package:u.packages||u.package}),[m,p]=a.useState(null);return((0,a.useEffect)(()=>{if(c){let e={...(0,k.pluginManifestToCardPluginProps)(c.manifest),plugin_id:c.unique_identifier};i(e),p({...e,from:n.type})}},[c]),(0,a.useEffect)(()=>{d&&o()},[d]),m)?(0,t.jsx)(E,{payload:m,versionInfo:r,checked:s,onCheckedChange:l}):(0,t.jsx)(w,{})}),R=a.memo(e=>{let{checked:a,onCheckedChange:s,payload:l,version:n,versionInfo:r}=e;return l?(0,t.jsx)(E,{checked:a,onCheckedChange:s,payload:{...l,version:n},isFromMarketPlace:!0,versionInfo:r}):(0,t.jsx)(w,{})}),O=a.memo(e=>{let{payload:a,checked:s,onCheckedChange:l,isFromMarketPlace:n,versionInfo:r}=e;if(!a.value?.manifest)return(0,t.jsx)(j,{});let i=(0,k.pluginManifestToCardPluginProps)(a.value.manifest);return(0,t.jsx)(E,{payload:{...i,from:a.type},checked:s,onCheckedChange:l,isFromMarketPlace:n,versionInfo:r})});var L=e.i(99649);function V(e){return`${e?.org||e?.author}/${e?.name}`}let $=e=>{let{allPlugins:s,selectedPlugins:l,onSelect:n,onSelectAll:r,onDeSelectAll:i,onLoadedAllPlugin:o,isFromMarketPlace:u,ref:c}=e,{plugins:d,errorIndexes:m,handleGitHubPluginFetched:p,handleGitHubPluginFetchError:h,getVersionInfo:x,handleSelect:g,isPluginSelected:f,getInstallablePlugins:v}=function(e){let{allPlugins:t,selectedPlugins:s,onSelect:l,onLoadedAllPlugin:n}=e,r=(0,T.useGlobalPublicStore)(e=>e.systemFeatures),i=(0,a.useMemo)(()=>t.filter(e=>"marketplace"===e.type),[t]),o=(0,a.useMemo)(()=>t.reduce((e,t,a)=>("marketplace"===t.type&&e.push(a),e),[]),[t]),{isLoading:u,data:c,error:d}=(0,b.useFetchPluginsInMarketPlaceByInfo)(i.map(e=>(function(e){let[t,a]=e.split("@")[0].split("/"),[s,l]=a.split(":");return{organization:t,plugin:s,version:l}})(e.value.marketplace_plugin_unique_identifier))),{isLoading:m,data:p,error:h}=(0,b.useFetchPluginsInMarketPlaceByInfo)(i.map(e=>e.value)),{marketplacePluginMap:x,marketplaceErrorIndexes:g}=(0,a.useMemo)(()=>{let e=new Map,t=new Set;if(!u&&c?.data.list){let a=i.map(e=>{let t=e.value.marketplace_plugin_unique_identifier?.split(":")[0];return{...c.data.list.find(e=>e.plugin.plugin_id===t)?.plugin,from:e.type}});o.forEach((s,l)=>{a[l]?e.set(s,{...a[l],version:a[l].version||a[l].latest_version}):t.add(s)})}if(!m&&p?.data.list){let a=p.data.list;o.forEach((s,l)=>{if(a[l]){let t=a[l];e.set(s,{...t.plugin,plugin_id:t.version.unique_identifier})}else t.add(s)})}return(h||d)&&o.forEach(e=>t.add(e)),{marketplacePluginMap:e,marketplaceErrorIndexes:t}},[u,m,c,p,h,d,o,i]),[f,v]=(0,a.useState)(()=>new Map),[y,C]=(0,a.useState)([]),j=(0,a.useMemo)(()=>{let e=t.some(e=>"package"===e.type)?t.map(e=>{if("package"!==e.type)return;let{manifest:t,unique_identifier:a}=e.value;return{...t,plugin_id:a}}):[],a=t.map((t,a)=>e[a]);return x.forEach((e,t)=>{a[t]=e}),f.forEach((e,t)=>{a[t]=e}),a},[t,x,f]),w=(0,a.useMemo)(()=>[...g,...y],[g,y]),k=j.filter(Boolean).length+w.length===t.length,{installedInfo:_}=(0,L.default)({pluginIds:j.filter(Boolean).map(e=>V(e))||[],enabled:k});(0,a.useEffect)(()=>{k&&_&&n(_)},[k,_]);let N=(0,a.useCallback)(e=>t=>{v(a=>new Map(a).set(e,t))},[]),S=(0,a.useCallback)(e=>()=>{C(t=>[...t,e])},[]),I=(0,a.useCallback)(e=>{let t=_?.[e];return{hasInstalled:!!t,installedVersion:t?.installedVersion,toInstallVersion:""}},[_]),P=(0,a.useCallback)(e=>()=>{let t=j.filter(e=>{let{canInstall:t}=A(e,r);return t});l(j[e],e,t.length)},[l,j,r]),F=(0,a.useCallback)(e=>!!s.find(t=>t.plugin_id===j[e]?.plugin_id),[s,j]),E=(0,a.useCallback)(()=>{let e=[],a=[];return t.forEach((t,s)=>{let l=j[s];if(!l)return;let{canInstall:n}=A(l,r);n&&(e.push(s),a.push(l))}),{selectedIndexes:e,installablePlugins:a}},[t,j,r]);return{plugins:j,errorIndexes:w,handleGitHubPluginFetched:N,handleGitHubPluginFetchError:S,getVersionInfo:I,handleSelect:P,isPluginSelected:F,getInstallablePlugins:E}}({allPlugins:s,selectedPlugins:l,onSelect:n,onLoadedAllPlugin:o});return(0,a.useImperativeHandle)(c,()=>({selectAllPlugins:()=>{let{installablePlugins:e,selectedIndexes:t}=v();r(e,t)},deSelectAllPlugins:i})),(0,t.jsx)(t.Fragment,{children:s.map((e,a)=>{if(m.includes(a))return(0,t.jsx)(j,{},a);let s=d[a],l=f(a),n=x(V(s));return"github"===e.type?(0,t.jsx)(M,{checked:l,onCheckedChange:g(a),dependency:e,onFetchedPayload:p(a),onFetchError:h(a),versionInfo:n},a):"marketplace"===e.type?(0,t.jsx)(R,{checked:l,onCheckedChange:g(a),payload:{...s,from:e.type},version:e.value.version||s?.version||"",versionInfo:n},a):(0,t.jsx)(O,{checked:l,onCheckedChange:g(a),payload:e,isFromMarketPlace:u,versionInfo:n},a)})})},D="installModal",U=a.memo(e=>{let{allPlugins:l,onStartToInstall:n,onInstalled:i,onCancel:o,isFromMarketPlace:h,isHideButton:x}=e,{t:g}=(0,s.useTranslation)(),y=f(e=>e.emit),[C,j]=a.useState([]),[w,k]=a.useState([]),_=C.length,N=(0,a.useRef)(null),{refreshPluginList:S}=(0,u.default)(),[I,T]=(0,a.useState)(!1),P=(0,a.useCallback)(()=>{I?N.current?.deSelectAllPlugins():N.current?.selectAllPlugins()},[I]),[A,F]=a.useState(!1),[E,M]=(0,a.useState)(void 0),R=(0,a.useCallback)(e=>{P(),M(e),F(!0)},[]),{check:O,stop:L}=(0,v.default)(),V=(0,a.useCallback)(()=>{L(),o()},[o,L]),{handleRefetch:U}=(0,b.usePluginTaskList)(),{mutate:z,isPending:q}=(0,b.useInstallOrUpdate)({onSuccess:async e=>{if(e.every(e=>e.status===r.TaskStatus.success||e.status===r.TaskStatus.failed)){i(C,e.map((e,t)=>({success:e.status===r.TaskStatus.success,isFromMarketPlace:"marketplace"===l[w[t]].type}))),e.some(e=>e.status===r.TaskStatus.success)&&(S(void 0,!0),y("plugin:install:success",C.map(e=>`${e.plugin_id}/${e.name}`)));return}U();let t=await Promise.all(e.map(async(e,t)=>{if(e.status!==r.TaskStatus.running)return{success:e.status===r.TaskStatus.success,isFromMarketPlace:"marketplace"===l[w[t]].type};let{status:a}=await O({taskId:e.taskId,pluginUniqueIdentifier:e.uniqueIdentifier});return{success:a===r.TaskStatus.success,isFromMarketPlace:"marketplace"===l[w[t]].type}}));i(C,t),t.some(e=>e.success)&&y("plugin:install:success",C.map(e=>`${e.plugin_id}/${e.name}`))}}),[B,K]=(0,a.useState)(!1),H=(0,a.useCallback)((e,t)=>{j(e),k(t),T(!0),K(!1)},[]),W=(0,a.useCallback)(()=>{j([]),k([]),T(!1),K(!1)},[]),Y=(0,a.useCallback)((e,t,a)=>{let s,l=!!C.find(t=>t.plugin_id===e.plugin_id);j(s=l?C.filter(t=>t.plugin_id!==e.plugin_id):[...C,e]),k(l?w.filter(e=>e!==t):[...w,t]),0===s.length?(T(!1),K(!1)):s.length===a?(T(!0),K(!1)):(K(!0),T(!1))},[C,w]),{canInstallPluginFromMarketplace:G}=(0,p.useCanInstallPluginFromMarketplace)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col items-start justify-center gap-4 self-stretch px-6 py-3",children:[(0,t.jsx)("div",{className:"system-md-regular text-text-secondary",children:(0,t.jsx)("p",{children:g(`${D}.${_>1?"readyToInstallPackages":"readyToInstallPackage"}`,{ns:"plugin",num:_})})}),(0,t.jsx)("div",{className:"w-full space-y-1 rounded-2xl bg-background-section-burn p-2",children:(0,t.jsx)($,{ref:N,allPlugins:l,selectedPlugins:C,onSelect:Y,onSelectAll:H,onDeSelectAll:W,onLoadedAllPlugin:R,isFromMarketPlace:h})})]}),!x&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 self-stretch p-6 pt-5",children:[(0,t.jsx)("div",{className:"px-2",children:A&&(0,t.jsxs)("div",{className:"flex items-center gap-x-2",onClick:P,children:[(0,t.jsx)(m.default,{checked:I,indeterminate:B}),(0,t.jsx)("p",{className:"system-sm-medium cursor-pointer text-text-secondary",children:g(I?"operation.deSelectAll":"operation.selectAll",{ns:"common"})})]})}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 self-stretch",children:[!A&&(0,t.jsx)(d.default,{variant:"secondary",className:"min-w-[72px]",onClick:V,children:g("operation.cancel",{ns:"common"})}),(0,t.jsxs)(d.default,{variant:"primary",className:"flex min-w-[72px] space-x-0.5",disabled:!A||q||0===C.length||!G,onClick:()=>{n?.(),z({payload:l.filter((e,t)=>w.includes(t)),plugin:C,installedInfo:E})},children:[q&&(0,t.jsx)(c.RiLoader2Line,{className:"h-4 w-4 animate-spin-slow"}),(0,t.jsx)("span",{children:g(`${D}.${q?"installing":"install"}`,{ns:"plugin"})})]})]})]})]})});var z=e.i(500536);let q=a.memo(e=>{let{list:a,installStatus:l,onCancel:n,isHideButton:r}=e,{t:i}=(0,s.useTranslation)(),{getIconUrl:o}=(0,S.default)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex flex-col items-start justify-center gap-4 self-stretch px-6 py-3",children:(0,t.jsx)("div",{className:"flex flex-wrap content-start items-start gap-1 space-y-1 self-stretch rounded-2xl bg-background-section-burn p-2",children:a.map((e,a)=>(0,t.jsx)(N.default,{className:"w-full",payload:{...e,icon:l[a].isFromMarketPlace?`${_.MARKETPLACE_API_PREFIX}/plugins/${e.org}/${e.name}/icon`:o(e.icon)},installed:l[a].success,installFailed:!l[a].success,titleLeft:e.version?(0,t.jsx)(z.default,{className:"mx-1",size:"s",state:z.BadgeState.Default,children:e.version}):null},e.plugin_id))})}),!r&&(0,t.jsx)("div",{className:"flex items-center justify-end gap-2 self-stretch p-6 pt-5",children:(0,t.jsx)(d.default,{variant:"primary",className:"min-w-[72px]",onClick:n,children:i("operation.close",{ns:"common"})})})]})}),B=a.memo(e=>{let{step:s,onStepChange:l,onStartToInstall:n,setIsInstalling:i,allPlugins:o,onClose:u,isFromMarketPlace:c}=e,[d,m]=(0,a.useState)([]),[p,h]=(0,a.useState)([]),x=(0,a.useCallback)((e,t)=>{h(t),m(e),l(r.InstallStep.installed),i(!1)},[l,i]);return(0,t.jsxs)(t.Fragment,{children:[s===r.InstallStep.readyToInstall&&(0,t.jsx)(U,{allPlugins:o,onCancel:u,onStartToInstall:n,onInstalled:x,isFromMarketPlace:c}),s===r.InstallStep.installed&&(0,t.jsx)(q,{list:d,installStatus:p,onCancel:u})]})});e.s(["default",0,B],70486);var K=e.i(20302),H=e.i(751992);let W="installModal",Y=a.memo(e=>{let{uniqueIdentifier:l,payload:n,onCancel:i,onStartToInstall:o,onInstalled:u,onFailed:m}=e,{t:p}=(0,s.useTranslation)(),h=n.version||n.latest_version,x=n.plugin_id,{installedInfo:g,isLoading:f}=(0,L.default)({pluginIds:[x],enabled:!!x}),y=g?.[x],C=y?.installedVersion,j=!!C,{mutateAsync:w}=(0,b.useInstallPackageFromMarketPlace)(),{mutateAsync:_}=(0,b.useUpdatePackageFromMarketPlace)(),[S,T]=a.useState(!1),{check:P,stop:A}=(0,v.default)(),{handleRefetch:E}=(0,b.usePluginTaskList)(n.category);(0,a.useEffect)(()=>{j&&l===y.uniqueIdentifier&&u()},[j]);let M=async()=>{if(!S){o?.(),T(!0);try{let e,t;if(j){let{all_installed:a,task_id:s}=await _({original_plugin_unique_identifier:y.uniqueIdentifier,new_plugin_unique_identifier:l});e=s,t=a}else{let{all_installed:a,task_id:s}=await w(l);e=s,t=a}if(t)return void u();E();let{status:a,error:s}=await P({taskId:e,pluginUniqueIdentifier:l});if(a===r.TaskStatus.failed)return void m(s);u(!0)}catch(e){if("string"==typeof e)return void m(e);m()}}},{langGeniusVersionInfo:R}=(0,H.useAppContext)(),{data:O}=(0,b.usePluginDeclarationFromMarketPlace)(l),V=(0,a.useMemo)(()=>!O||!R.current_version||(0,K.gte)(R.current_version,O?.manifest.meta.minimum_dify_version??"0.0.0"),[R.current_version,O]),{canInstall:$}=F({...n,from:"marketplace"});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col items-start justify-center gap-4 self-stretch px-6 py-3",children:[(0,t.jsxs)("div",{className:"system-md-regular text-text-secondary",children:[(0,t.jsx)("p",{children:p(`${W}.readyToInstall`,{ns:"plugin"})}),!V&&(0,t.jsx)("p",{className:"system-md-regular text-text-warning",children:p("difyVersionNotCompatible",{ns:"plugin",minimalDifyVersion:O?.manifest.meta.minimum_dify_version})})]}),(0,t.jsx)("div",{className:"flex flex-wrap content-start items-start gap-1 self-stretch rounded-2xl bg-background-section-burn p-2",children:(0,t.jsx)(N.default,{className:"w-full",payload:(0,k.pluginManifestInMarketToPluginProps)(n),titleLeft:!f&&(0,t.jsx)(I.default,{hasInstalled:j,installedVersion:C,toInstallVersion:h}),limitedInstall:!$})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 self-stretch p-6 pt-5",children:[!S&&(0,t.jsx)(d.default,{variant:"secondary",className:"min-w-[72px]",onClick:()=>{A(),i()},children:p("operation.cancel",{ns:"common"})}),(0,t.jsxs)(d.default,{variant:"primary",className:"flex min-w-[72px] space-x-0.5",disabled:S||f||!$,onClick:M,children:[S&&(0,t.jsx)(c.RiLoader2Line,{className:"h-4 w-4 animate-spin-slow"}),(0,t.jsx)("span",{children:p(`${W}.${S?"installing":"install"}`,{ns:"plugin"})})]})]})]})}),G="installModal";e.s(["default",0,e=>{let{uniqueIdentifier:c,manifest:d,isBundle:m,dependencies:p,onSuccess:h,onClose:x}=e,{t:g}=(0,s.useTranslation)(),[f,b]=(0,a.useState)(r.InstallStep.readyToInstall),[v,y]=(0,a.useState)(null),{refreshPluginList:C}=(0,u.default)(),{modalClassName:j,foldAnimInto:w,setIsInstalling:k,handleStartToInstall:_}=(0,o.default)(x),N=(0,a.useCallback)(()=>m&&f===r.InstallStep.installed?g(`${G}.installComplete`,{ns:"plugin"}):f===r.InstallStep.installed?g(`${G}.installedSuccessfully`,{ns:"plugin"}):f===r.InstallStep.installFailed?g(`${G}.installFailed`,{ns:"plugin"}):g(`${G}.installPlugin`,{ns:"plugin"}),[m,f,g]),S=(0,a.useCallback)(e=>{b(r.InstallStep.installed),e||C(d),k(!1)},[d,C,k]),I=(0,a.useCallback)(e=>{b(r.InstallStep.installFailed),k(!1),e&&y(e)},[k]);return(0,t.jsxs)(l.default,{isShow:!0,onClose:w,wrapperClassName:"z-[9999]",className:(0,n.cn)(j,"shadows-shadow-xl flex min-w-[560px] flex-col items-start rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-0"),closable:!0,children:[(0,t.jsx)("div",{className:"flex items-start gap-2 self-stretch pb-3 pl-6 pr-14 pt-6",children:(0,t.jsx)("div",{className:"title-2xl-semi-bold self-stretch text-text-primary",children:N()})}),m?(0,t.jsx)(B,{step:f,onStepChange:b,onStartToInstall:_,setIsInstalling:k,onClose:x,allPlugins:p,isFromMarketPlace:!0}):(0,t.jsxs)(t.Fragment,{children:[f===r.InstallStep.readyToInstall&&(0,t.jsx)(Y,{uniqueIdentifier:c,payload:d,onCancel:x,onInstalled:S,onFailed:I,onStartToInstall:_}),[r.InstallStep.installed,r.InstallStep.installFailed].includes(f)&&(0,t.jsx)(i.default,{payload:d,isMarketPayload:!0,isFailed:f===r.InstallStep.installFailed,errMsg:v,onCancel:h})]})]})}],931576)}]);