(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,308011,e=>{"use strict";var t=e.i(835240),a=e.i(869931);e.i(942394);var s=e.i(84411);e.i(994937);var l=e.i(117146),n=e.i(935139);e.s(["EncryptedBottom",0,e=>{let{t:i}=(0,s.useTranslation)(),{frontTextKey:r="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"}),i(r,{ns:"common"}),(0,t.jsx)(l.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"}),i(o,{ns:"common"})]})}])},665127,808462,e=>{"use strict";var t,a=e.i(835240),s=e.i(869931);e.i(942394);var l=e.i(84411),n=e.i(935139);let i=["code","audio","time","webscraper"];var r=e.i(816709),o=((t={}).drawer="drawer",t.modal="modal",t);let u=(0,r.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:r=o.drawer,className:c,showShortTip:d=!1}=e,{t:m}=(0,l.useTranslation)(),{setCurrentPluginDetail:p}=u();return!t||!t?.plugin_unique_identifier||i.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",r===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,r)},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(835240),l=e.i(736893),n=e.i(151094);e.i(942394);var i=e.i(84411),r=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(571617),g=e.i(804155),f=e.i(367916),b=e.i(722384);let y="plugins-auth";var C=e.i(154033),v=((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",()=>v,"CredentialTypeEnum",()=>j],674245);let w=e=>{let{category:t=v.tool,provider:a}=e;return t===v.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===v.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:""}},_=e=>{let t;return t=w(e).deleteCredential,(0,x.useMutation)({mutationFn:e=>(0,f.post)(t,{body:e})})},k=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})})},A=(0,l.memo)(e=>{var t;let a,n,{pluginPayload:b,onClose:C,editValues:v,onRemove:_,disabled:k,onUpdate:A,formSchemas:S=[]}=e,{t:T}=(0,i.useTranslation)(),{notify:O}=(0,m.useToastContext)(),[P,R]=(0,l.useState)(!1),I=(0,l.useRef)(P),D=(0,l.useCallback)(e=>{I.current=e,R(e)},[]),{data:E=[],isLoading:F}=(t=j.API_KEY,a=w(b).getCredentialSchema(t),(0,g.useQuery)({enabled:!!a,queryKey:[y,"credential-schema",a],queryFn:()=>(0,f.get)(a)})),U=(0,l.useMemo)(()=>S?.length?S:E,[S,E]),$=(0,l.useMemo)(()=>[{type:u.FormTypeEnum.textInput,name:"__name__",label:T("auth.authorizationName",{ns:"plugin"}),required:!1},...U],[U,T]),z=$.reduce((e,t)=>(t.default&&(e[t.name]=t.default),e),{}),{mutateAsync:V}=(n=w(b).addCredential,(0,x.useMutation)({mutationFn:e=>(0,f.post)(n,{body:e})})),{mutateAsync:K}=N(b),q=(0,l.useRef)(null),L=(0,l.useCallback)(async()=>{if(I.current)return;let{isCheckValidated:e,values:t}=q.current?.getFormValues({needCheckValidatedValues:!0,needTransformWhenSecretFieldIsPristine:!0})||{isCheckValidated:!1,values:{}};if(e)try{let{__name__:e,__credential_id__:a,...s}=t;D(!0),v?await K({credentials:s,credential_id:a,name:e||""}):await V({credentials:s,type:j.API_KEY,name:e||""}),O({type:"success",message:T("api.actionSuccess",{ns:"common"})}),C?.(),A?.()}finally{D(!1)}},[V,C,A,K,O,T,v,D]);return(0,s.jsxs)(d.default,{size:"md",title:T("auth.useApiAuth",{ns:"plugin"}),subTitle:T("auth.useApiAuthDesc",{ns:"plugin"}),onClose:C,onCancel:C,footerSlot:(0,s.jsx)("div",{}),bottomSlot:(0,s.jsx)(r.EncryptedBottom,{}),onConfirm:L,showExtraButton:!!v,onExtraButtonClick:_,disabled:k||F||P,clickOutsideNotClose:!0,wrapperClassName:"!z-[101]",children:[b.detail&&(0,s.jsx)(p.ReadmeEntrance,{pluginDetail:b.detail,showType:h.ReadmeShowType.modal}),F&&(0,s.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,s.jsx)(c.default,{})}),!F&&!!U.length&&(0,s.jsx)(o.default,{ref:q,formSchemas:$,defaultValues:v||z,disabled:k})]})});e.s(["default",0,A],494845);let S=(0,l.memo)(e=>{let{pluginPayload:t,buttonVariant:a="secondary-accent",buttonText:i="Use Api Key",disabled:r,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:r,children:i}),c&&(0,s.jsx)(A,{pluginPayload:t,onClose:()=>d(!1),onUpdate:o,formSchemas:u})]})});e.s(["default",0,S],505560);var T=e.i(869931),O=e.i(654313),P=e.i(83278),R=e.i(566210),I=e.i(349714),D=e.i(935139),E=e.i(301293),F=e.i(622111);let U=(0,l.memo)(e=>{let t,a,r,{pluginPayload:u,onClose:c,editValues:g,disabled:C,schemas:v,onAuth:j,hasOriginalClientParams:_,onUpdate:k}=e,{t:N}=(0,i.useTranslation)(),{notify:A}=(0,m.useToastContext)(),[S,T]=(0,l.useState)(!1),O=(0,l.useRef)(S),P=(0,l.useCallback)(e=>{O.current=e,T(e)},[]),R=v.reduce((e,t)=>(t.default&&(e[t.name]=t.default),e),{}),{mutateAsync:I}=(t=w(u).setCustomOauthClient,(0,x.useMutation)({mutationFn:e=>(0,f.post)(t,{body:e})})),D=(a=w(u).getOauthClientSchema,(0,b.useInvalid)([y,"oauth-client-schema",a])),U=(0,l.useRef)(null),$=(0,l.useCallback)(async()=>{if(!O.current)try{let{isCheckValidated:e,values:t}=U.current?.getFormValues({needCheckValidatedValues:!0,needTransformWhenSecretFieldIsPristine:!0})||{isCheckValidated:!1,values:{}};if(!e)throw Error("error");let{__oauth_client__:a,...s}=t;P(!0),await I({client_params:s,enable_oauth_custom_client:"custom"===a}),A({type:"success",message:N("api.actionSuccess",{ns:"common"})}),c?.(),k?.(),D()}finally{P(!1)}},[c,k,D,I,A,N,P]),z=(0,l.useCallback)(async()=>{await $(),j&&await j()},[$,j]),{mutateAsync:V}=(r=w(u).deleteCustomOAuthClient,(0,x.useMutation)({mutationFn:()=>(0,f.del)(r)})),K=(0,l.useCallback)(async()=>{if(!O.current)try{P(!0),await V(),A({type:"success",message:N("api.actionSuccess",{ns:"common"})}),c?.(),k?.(),D()}finally{P(!1)}},[k,D,V,A,N,P,c]),q=(0,E.useForm)({defaultValues:g||R}),L=(0,F.useStore)(q.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:$,onConfirm:z,disabled:C||S,footerSlot:"custom"===L&&_&&(0,s.jsx)("div",{className:"grow",children:(0,s.jsx)(n.default,{variant:"secondary",className:"text-components-button-destructive-secondary-text",disabled:C||S||!g,onClick:K,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:q,ref:U,formSchemas:v,defaultValues:g||R,disabled:C})]})}),$=(0,l.memo)(e=>{let t,a,{pluginPayload:r,buttonVariant:o="primary",buttonText:c="use oauth",className:d,buttonLeftClassName:m,buttonRightClassName:p,dividerClassName:h,disabled:b,onUpdate:C,oAuthData:v}=e,{t:j}=(0,i.useTranslation)(),_=(0,R.useRenderI18nObject)(),[k,N]=(0,l.useState)(!1),{mutateAsync:A}=(t=w(r).getOauthUrl,(0,x.useMutation)({mutationKey:[y,"oauth-url",t],mutationFn:()=>(0,f.get)(t)})),{data:S,isLoading:E}=(a=w(r).getOauthClientSchema,(0,g.useQuery)({enabled:!!a,queryKey:[y,"oauth-client-schema",a],queryFn:()=>(0,f.get)(a),staleTime:0})),{schema:F=[],is_oauth_custom_client_enabled:$,is_system_oauth_params_exists:z,client_params:V,redirect_uri:K}=(0,l.useMemo)(()=>v||S,[v,S])||{},q=z||$,L=(0,l.useCallback)(async()=>{let{authorization_url:e}=await A();e&&(0,I.openOAuthPopup)(e,()=>C?.())},[A,C]),M=(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"})}),K&&(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:K}),(0,s.jsx)(O.default,{className:"shrink-0",onClick:()=>{navigator.clipboard.writeText(K||"")},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:[_(e.label),e.required&&(0,s.jsx)("span",{className:"ml-1 text-text-destructive-secondary",children:"*"})]})]}),[j,K,_]),B=(0,l.useMemo)(()=>{let e=F.map((e,t)=>({...e,label:0===t?M(e):e.label,labelClassName:0===t?"h-auto":void 0}));return z&&(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:$?"custom":"default"}),e.forEach((e,t)=>{t>0&&(e.show_on=[{variable:"__oauth_client__",value:"custom"}],V&&(e.default=V[e.name]||e.default))})),e},[F,M,j,z,$,V]),W=(0,l.useMemo)(()=>q?$?"custom":"default":z?"default":"custom",[q,$,z]);return(0,s.jsxs)(s.Fragment,{children:[q&&(0,s.jsxs)(n.default,{variant:o,className:(0,D.cn)("w-full px-0 py-0 hover:bg-components-button-primary-bg",d),disabled:b,onClick:L,children:[(0,s.jsxs)("div",{className:(0,D.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}),$&&(0,s.jsx)(P.default,{className:(0,D.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,D.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,D.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"})})]}),!q&&(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"})]}),k&&(0,s.jsx)(U,{pluginPayload:r,onClose:()=>N(!1),disabled:b||E,schemas:B,onAuth:L,editValues:{...V,__oauth_client__:W},hasOriginalClientParams:Object.keys(V||{}).length>0,onUpdate:C})]})});e.s(["default",0,$],694354);var z=e.i(547105),V=e.i(391185),K=e.i(836340),q=e.i(421001);let L=(0,l.memo)(e=>{let{pluginPayload:t,theme:a="primary",showDivider:n=!0,canOAuth:r,canApiKey:o,disabled:u,onUpdate:c,notAllowCustomCredential:d}=e,{t:m}=(0,i.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:r?m("auth.addApi",{ns:"plugin"}):m("auth.useApiAuth",{ns:"plugin"})}:{pluginPayload:t,buttonText:r?m("auth.addApi",{ns:"plugin"}):m("auth.useApiAuth",{ns:"plugin"}),buttonVariant:r?"secondary-accent":"primary"},[r,a,t,m]),x=(0,l.useMemo)(()=>{let e=(0,s.jsx)("div",{className:(0,D.cn)("min-w-0 flex-[1]",d&&"opacity-50"),children:(0,s.jsx)($,{...p,disabled:u||d,onUpdate:c})});return d?(0,s.jsx)(q.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,D.cn)("min-w-0 flex-[1]",d&&"opacity-50"),children:(0,s.jsx)(S,{...h,disabled:u||d,onUpdate:c})});return d?(0,s.jsx)(q.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:[r&&x,n&&r&&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 M=e.i(291631);let B=(0,l.memo)(e=>{let{credential:t,disabled:a,onDelete:r,onEdit:o,onSetDefault:u,onRename:c,disableRename:d,disableEdit:m,disableDelete:p,disableSetDefault:h,onItemClick:x,showSelectedIcon:g,selectedCredentialId:f}=e,{t:b}=(0,i.useTranslation)(),[y,C]=(0,l.useState)(!1),[v,w]=(0,l.useState)(t.name),_=t.credential_type===j.OAUTH2,k=(0,l.useMemo)(()=>!(d&&m&&p&&h),[d,m,p,h]),N=(0,s.jsxs)("div",{className:(0,D.cn)("group flex h-8 items-center rounded-lg p-1 hover:bg-state-base-hover",y&&"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:[y&&(0,s.jsxs)("div",{className:"flex w-full items-center space-x-1",children:[(0,s.jsx)(M.default,{wrapperClassName:"grow rounded-[6px]",className:"h-6",value:v,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:v}),C(!1)},children:b("operation.save",{ns:"common"})}),(0,s.jsx)(n.default,{size:"small",onClick:e=>{e.stopPropagation(),C(!1)},children:b("operation.cancel",{ns:"common"})})]}),!y&&(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)(K.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)(P.default,{className:"shrink-0",children:b("auth.default",{ns:"plugin"})})]}),t.from_enterprise&&(0,s.jsx)(P.default,{className:"shrink-0",children:"Enterprise"}),k&&!y&&(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)(q.default,{popupContent:b("operation.rename",{ns:"common"}),children:(0,s.jsx)(O.default,{disabled:a,onClick:e=>{e.stopPropagation(),C(!0),w(t.name)},children:(0,s.jsx)(T.RiEditLine,{className:"h-4 w-4 text-text-tertiary"})})}),!_&&!m&&!t.from_enterprise&&!t.not_allowed_to_use&&(0,s.jsx)(q.default,{popupContent:b("operation.edit",{ns:"common"}),children:(0,s.jsx)(O.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)(q.default,{popupContent:b("operation.delete",{ns:"common"}),children:(0,s.jsx)(O.default,{className:"hover:bg-transparent",disabled:a,onClick:e=>{e.stopPropagation(),r?.(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)(q.default,{popupContent:b("auth.customCredentialUnavailable",{ns:"plugin"}),children:N}):N}),W=(0,l.memo)(e=>{let{pluginPayload:t,credentials:a,canOAuth:r,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:y,extraAuthorizationItems:C,showItemSelectedIcon:v,selectedCredentialId:w,onUpdate:S,notAllowCustomCredential:O}=e,{t:P}=(0,i.useTranslation)(),{notify:R}=(0,m.useToastContext)(),[I,E]=(0,l.useState)(!1),F=d??I,U=(0,l.useCallback)(e=>{p&&p(e),E(e)},[p]),$=a.filter(e=>e.credential_type===j.OAUTH2),q=a.filter(e=>e.credential_type===j.API_KEY),M=(0,l.useRef)(null),[W,H]=(0,l.useState)(null),{mutateAsync:Y}=_(t),Q=(0,l.useCallback)(e=>{e&&(M.current=e),H(M.current)},[]),G=(0,l.useCallback)(()=>{H(null),M.current=null},[]),[J,X]=(0,l.useState)(!1),Z=(0,l.useRef)(J),ee=(0,l.useCallback)(e=>{Z.current=e,X(e)},[]),et=(0,l.useCallback)(async()=>{if(!Z.current){if(!M.current)return void H(null);try{ee(!0),await Y({credential_id:M.current}),R({type:"success",message:P("api.actionSuccess",{ns:"common"})}),S?.(),H(null),M.current=null}finally{ee(!1)}}},[Y,S,R,P,ee]),[ea,es]=(0,l.useState)(null),el=(0,l.useCallback)((e,t)=>{M.current=e,es(t)},[]),en=(0,l.useCallback)(()=>{H(M.current)},[]),{mutateAsync:ei}=k(t),er=(0,l.useCallback)(async e=>{if(!Z.current)try{ee(!0),await ei(e),R({type:"success",message:P("api.actionSuccess",{ns:"common"})}),S?.()}finally{ee(!1)}},[ei,S,R,P,ee]),{mutateAsync:eo}=N(t),eu=(0,l.useCallback)(async e=>{if(!Z.current)try{ee(!0),await eo(e),R({type:"success",message:P("api.actionSuccess",{ns:"common"})}),S?.()}finally{ee(!1)}},[eo,R,P,ee,S]),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)(V.PortalToFollowElem,{open:F,onOpenChange:U,placement:x,offset:h,triggerPopupSameWidth:g,children:[(0,s.jsx)(V.PortalToFollowElemTrigger,{onClick:()=>U(!F),asChild:!0,children:c?c(F):(0,s.jsxs)(n.default,{className:(0,D.cn)("w-full",d&&"bg-components-button-secondary-bg-hover"),children:[(0,s.jsx)(K.default,{className:"mr-2",color:ed?"gray":"green"}),a.length," ",a.length>1?P("auth.authorizations",{ns:"plugin"}):P("auth.authorization",{ns:"plugin"}),!!ec.length&&` (${ec.length} ${P("auth.unavailable",{ns:"plugin"})})`,(0,s.jsx)(T.RiArrowDownSLine,{className:"ml-0.5 h-4 w-4"})]})}),(0,s.jsx)(V.PortalToFollowElemContent,{className:"z-[100]",children:(0,s.jsxs)("div",{className:(0,D.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:[!!C?.length&&(0,s.jsx)("div",{className:"p-1",children:C.map(e=>(0,s.jsx)(B,{credential:e,disabled:u,onItemClick:y,disableRename:!0,disableEdit:!0,disableDelete:!0,disableSetDefault:!0,showSelectedIcon:v,selectedCredentialId:w},e.id))}),!!$.length&&(0,s.jsxs)("div",{className:"p-1",children:[(0,s.jsx)("div",{className:(0,D.cn)("px-3 pb-0.5 pt-1 text-text-tertiary system-xs-medium",v&&"pl-7"),children:"OAuth"}),$.map(e=>(0,s.jsx)(B,{credential:e,disabled:u,disableEdit:!0,onDelete:Q,onSetDefault:er,onRename:eu,disableSetDefault:b,onItemClick:y,showSelectedIcon:v,selectedCredentialId:w},e.id))]}),!!q.length&&(0,s.jsxs)("div",{className:"p-1",children:[(0,s.jsx)("div",{className:(0,D.cn)("px-3 pb-0.5 pt-1 text-text-tertiary system-xs-medium",v&&"pl-7"),children:"API Keys"}),q.map(e=>(0,s.jsx)(B,{credential:e,disabled:u,onDelete:Q,onEdit:el,onSetDefault:er,disableSetDefault:b,disableRename:!0,onItemClick:y,onRename:eu,showSelectedIcon:v,selectedCredentialId:w},e.id))]})]}),!O&&(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)(L,{pluginPayload:t,theme:"secondary",showDivider:!1,canOAuth:r,canApiKey:o,disabled:u,onUpdate:S})})]})]})})]}),W&&(0,s.jsx)(z.default,{isShow:!0,title:P("list.delete.title",{ns:"datasetDocuments"}),isDisabled:J,onCancel:G,onConfirm:et}),!!ea&&(0,s.jsx)(A,{pluginPayload:t,editValues:ea,onClose:()=>{es(null),M.current=null},onRemove:en,disabled:u||J,onUpdate:S})]})}),H=(0,l.memo)(e=>{let{authorizationsNum:t,onJumpToDataSourcePage:a}=e,{t:l}=(0,i.useTranslation)();return(0,s.jsxs)(n.default,{size:"small",onClick:a,children:[(0,s.jsx)(K.default,{className:"mr-1.5",color:"green"}),l(t>1?"auth.authorizations":"auth.authorization",{ns:"plugin"}),(0,s.jsx)(T.RiEqualizer2Line,{className:(0,D.cn)("h-3.5 w-3.5 text-components-button-ghost-text")})]})});e.s(["default",0,H],735964),e.s(["default",()=>G],946468);var Y=e.i(751992);let Q=(e,t)=>{let a,s,l,n,i,r,{data:o}=(a=w(e),s=t?a.getCredentialInfo:"",(0,g.useQuery)({enabled:!!s,queryKey:[y,"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)([y,"credential-info",l]),i=e.providerType,r=(0,C.useInvalidToolsByType)(i),()=>{n(),r()});return{isAuthorized:c,canOAuth:d,canApiKey:m,credentials:o?.credentials||[],disabled:!u,notAllowCustomCredential:o?.allow_custom_token===!1,invalidPluginCredentialInfo:p}},G=(0,l.memo)(e=>{let{pluginPayload:t,onAuthorizationItemClick:a,credentialId:r}=e,{t:o}=(0,i.useTranslation)(),[u,c]=(0,l.useState)(!1),{canApiKey:d,canOAuth:m,credentials:p,disabled:h,invalidPluginCredentialInfo:x,notAllowCustomCredential:g}=Q(t,!0),f=(0,l.useCallback)(e=>{let t="",a=!1,l=!1,i="green",u=!1;if(r){let e=p.find(e=>e.id===r);t=e?e.name:o("auth.authRemoved",{ns:"plugin"}),a=!e,l=!!e?.not_allowed_to_use&&!e?.from_enterprise,a?i="red":l&&(i="gray")}else{t=o("auth.workspaceDefault",{ns:"plugin"});let e=p.find(e=>e.is_default);e?.not_allowed_to_use&&(i="gray",u=!0)}return(0,s.jsxs)(n.default,{size:"small",className:(0,D.cn)(e&&!a&&"bg-components-button-ghost-bg-hover",a&&"bg-transparent text-text-destructive"),variant:u||l?"ghost":"secondary",children:[(0,s.jsx)(K.default,{className:"mr-1.5",color:i}),t,(l||u)&&(0,s.jsxs)(s.Fragment,{children:[" ",o("auth.unavailable",{ns:"plugin"})]}),(0,s.jsx)(T.RiArrowDownSLine,{className:(0,D.cn)("h-3.5 w-3.5 text-components-button-ghost-text",a&&"text-text-destructive")})]})},[r,p,o]),b=p.find(e=>e.is_default)?.not_allowed_to_use,y=[{id:"__workspace_default__",name:o("auth.workspaceDefault",{ns:"plugin"}),provider:"",is_default:!r,isWorkspaceDefault:!0,not_allowed_to_use:b}],C=(0,l.useCallback)(e=>{a(e),c(!1)},[a,c]);return(0,s.jsx)(W,{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:C,extraAuthorizationItems:y,showItemSelectedIcon:!0,selectedCredentialId:r||"__workspace_default__",onUpdate:x,notAllowCustomCredential:g})});e.s(["usePluginAuthAction",0,(e,t)=>{let{t:a}=(0,i.useTranslation)(),{notify:s}=(0,m.useToastContext)(),n=(0,l.useRef)(null),[r,o]=(0,l.useState)(null),{mutateAsync:u}=_(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),y=(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]),C=(0,l.useCallback)((e,t)=>{n.current=e,b(t)},[]),v=(0,l.useCallback)(()=>{o(n.current)},[]),{mutateAsync:j}=k(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:A}=N(e),S=(0,l.useCallback)(async e=>{if(!x.current)try{g(!0),await A(e),s({type:"success",message:a("api.actionSuccess",{ns:"common"})}),t?.()}finally{g(!1)}},[A,s,a,g,t]);return{doingAction:p,handleSetDoingAction:g,openConfirm:c,closeConfirm:d,deleteCredentialId:r,setDeleteCredentialId:o,handleConfirm:y,editValues:f,setEditValues:b,handleEdit:C,handleRemove:v,handleSetDefault:w,handleRename:S,pendingOperationCredentialId:n}}],958692);let J=(0,l.memo)(e=>{let{pluginPayload:t,children:a,className:l}=e,{isAuthorized:n,canOAuth:i,canApiKey:r,credentials:o,disabled:u,invalidPluginCredentialInfo:c,notAllowCustomCredential:d}=Q(t,!!t.provider);return(0,s.jsxs)("div",{className:(0,D.cn)(!n&&l),children:[!n&&(0,s.jsx)(L,{pluginPayload:t,canOAuth:i,canApiKey:r,disabled:u,onUpdate:c,notAllowCustomCredential:d}),n&&!a&&(0,s.jsx)(W,{pluginPayload:t,credentials:o,canOAuth:i,canApiKey:r,disabled:u,onUpdate:c,notAllowCustomCredential:d}),n&&a]})});e.s(["default",0,J],230121);let X=(0,l.memo)(e=>{let{pluginPayload:t,credentialId:a,onAuthorizationItemClick:r}=e,{t:o}=(0,i.useTranslation)(),[u,c]=(0,l.useState)(!1),{isAuthorized:d,canOAuth:m,canApiKey:p,credentials:h,disabled:x,invalidPluginCredentialInfo:g,notAllowCustomCredential:f}=Q(t,!0),b=[{id:"__workspace_default__",name:o("auth.workspaceDefault",{ns:"plugin"}),provider:"",is_default:!a,isWorkspaceDefault:!0}],y=(0,l.useCallback)(e=>{r?.(e),c(!1)},[r,c]),C=(0,l.useCallback)(e=>{let t="",l=!1,i=!1,r="green";if(a){let e=h.find(e=>e.id===a);t=e?e.name:o("auth.authRemoved",{ns:"plugin"}),l=!e,i=!!e?.not_allowed_to_use&&!e?.from_enterprise,l?r="red":i&&(r="gray")}else t=o("auth.workspaceDefault",{ns:"plugin"});return(0,s.jsxs)(n.default,{className:(0,D.cn)("w-full",e&&"bg-components-button-secondary-bg-hover",l&&"text-text-destructive"),children:[(0,s.jsx)(K.default,{className:"mr-2",color:r}),t,i&&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)(L,{pluginPayload:t,canOAuth:m,canApiKey:p,disabled:x,onUpdate:g,notAllowCustomCredential:f}),d&&(0,s.jsx)(W,{pluginPayload:t,credentials:h,canOAuth:m,canApiKey:p,disabled:x,disableSetDefault:!0,onItemClick:y,extraAuthorizationItems:b,showItemSelectedIcon:!0,renderTrigger:C,isOpen:u,onOpenChange:c,selectedCredentialId:a||"__workspace_default__",onUpdate:g,notAllowCustomCredential:f})]})});e.s(["default",0,X],677316);let Z=(0,l.memo)(e=>{let{children:t,isAuthorized:a,onJumpToDataSourcePage:l}=e,{t:r}=(0,i.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"}),r("integrations.connect",{ns:"common"})]})}),a&&t]})});e.s(["default",0,Z],227746)},425667,e=>{"use strict";var t=e.i(835240),a=e.i(736893);e.i(942394);var s=e.i(84411),l=e.i(83278),n=e.i(965676),i=e.i(157884),r=e.i(157644),o=e.i(935139),u=e.i(523614);let c=a.memo(e=>{let{disabled:c=!1,isShow:d,onShowChange:m,pluginID:p,currentVersion:h,trigger:x,placement:g="bottom-start",sideOffset:f=4,alignOffset:b=-16,onSelect:y}=e,{t:C}=(0,s.useTranslation)(),v=C("dateTimeFormat",{ns:"appLog"}).split(" ")[0],{formatDate:j}=(0,i.default)(),{data:w}=(0,r.useVersionListOfPlugin)(p),_=(0,a.useCallback)(e=>{let{version:t,unique_identifier:a,isDowngrade:s}=e;h!==t&&(y({version:t,unique_identifier:a,isDowngrade:s}),m(!1))},[h,y,m]);return(0,t.jsxs)(n.Popover,{open:d,onOpenChange:e=>{c||m(e)},children:[(0,t.jsx)(n.PopoverTrigger,{disabled:c,className:(0,o.cn)("inline-flex cursor-pointer items-center",c&&"cursor-default"),children:x}),(0,t.jsxs)(n.PopoverContent,{placement:g,sideOffset:f,alignOffset:b,popupClassName:"relative w-[209px] bg-components-panel-bg-blur p-1 backdrop-blur-sm",children:[(0,t.jsx)("div",{className:"px-3 pb-0.5 pt-1 text-text-tertiary system-xs-medium-uppercase",children:C("detailPanel.switchVersion",{ns:"plugin"})}),(0,t.jsx)("div",{className:"relative max-h-[224px] overflow-y-auto",children:w?.data.versions.map(e=>(0,t.jsxs)("div",{className:(0,o.cn)("flex h-7 cursor-pointer items-center gap-1 rounded-lg px-3 py-1 hover:bg-state-base-hover",h===e.version&&"cursor-default opacity-30 hover:bg-transparent"),onClick:()=>_({version:e.version,unique_identifier:e.unique_identifier,isDowngrade:(0,u.isEarlierThanVersion)(e.version,h)}),children:[(0,t.jsxs)("div",{className:"flex grow items-center",children:[(0,t.jsx)("div",{className:"text-text-secondary system-sm-medium",children:e.version}),h===e.version&&(0,t.jsx)(l.default,{className:"ml-1",text:"CURRENT"})]}),(0,t.jsx)("div",{className:"shrink-0 text-text-tertiary system-xs-regular",children:j(e.created_at,v)})]},e.unique_identifier))})]})]})});e.s(["default",0,c])}]);