@amp-labs/react 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),I=require("react"),y=require("@chakra-ui/react"),Uo=require("@emotion/react"),ui=require("@emotion/styled"),$o={primary:{bg:"black",color:"white",_hover:{bg:"gray.700",_disabled:{bg:"gray.600"}},_disabled:{bg:"gray.600",color:"gray.300",cursor:"not-allowed",opacity:1}},warning:{bg:"red.50",outline:"2px solid red.100",outlineOffset:"0",borderColor:"red.100",color:"red.800",_hover:{bg:"red.100"}}},qo=y.extendTheme({components:{Tabs:{baseStyle:{tab:{width:"100%",borderRadius:"4px",_hover:{bg:"gray.200"},_selected:{color:"black",fontWeight:"500",bg:"gray.100",border:"none",_hover:{bg:"gray.200"}}},warningTab:{width:"100%",borderRadius:"4px",_hover:{bg:"red.100"},_selected:{color:"red.800",fontWeight:"500",bg:"red.50",border:"none",_hover:{bg:"red.100"}}}}},Button:{variants:$o}}}),Wo=y.extendTheme(qo);function zo({children:e}){return s.jsx(y.ChakraProvider,{theme:Wo,children:e})}const Fi=I.createContext(null),Jo=Fi.Provider,ee=()=>{const e=I.useContext(Fi);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var V=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e))(V||{});const Pi=I.createContext(void 0);function We(){const e=I.useContext(Pi);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Ho=(()=>{const e={};return Object.values(V).forEach(t=>{e[t]={}}),e})();function Xo({children:e}){const[t,r]=I.useState(Ho),n=I.useCallback((h,m)=>{r(v=>{const w={...v};return w[h]=w[h]||{},w[h][m]=!0,w})},[r]),i=I.useCallback((h,m)=>{var v;return!!((v=t[h])!=null&&v[m])},[t]),a=I.useCallback((h,m)=>{r(v=>{var b;const w={...v};return(b=w[h])==null||delete b[m],w})},[r]),c=I.useCallback(h=>{r(m=>{const v={...m};return v[h]={},v})},[r]),u=I.useCallback((h,m)=>{r(v=>{const w={...v};return w[h]=w[h]||{},m.forEach(b=>{w[h][b]=!0}),w})},[r]),p=I.useMemo(()=>({errorState:t,setErrorState:r,setError:n,isError:i,removeError:a,resetBoundary:c,setErrors:u}),[t,r,n,i,a,c,u]);return s.jsx(Pi.Provider,{value:p,children:e})}function Ce({message:e}){return s.jsx(y.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:s.jsxs(y.Stack,{alignItems:"center",children:[s.jsx(y.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"}),e&&s.jsx(y.Text,{fontSize:"40px",color:"#4299e1",children:e})]})})}function Fe({message:e}){return s.jsxs(y.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx(y.Box,{boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center","align-self":"stretch",padding:"12px 50px 12px 50px",borderRadius:"8px",border:"2px solid #FECACA",background:"#FEF2F2",children:s.jsx(y.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const Go="https://api.withampersand.com/v1".replace(/\/+$/,"");class Di{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Go}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Bi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Vo=new Di,_r=class _r{constructor(t=Vo){this.configuration=t,this.fetchApi=async(r,n)=>{let i={url:r,init:n};for(const c of this.middleware)c.pre&&(i=await c.pre({fetch:this.fetchApi,...i})||i);let a;try{a=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(c){for(const u of this.middleware)u.onError&&(a=await u.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:c,response:a?a.clone():void 0})||a);if(a===void 0)throw c instanceof Error?new ea(c,"The request failed and the interceptors did not return an alternative response"):c}for(const c of this.middleware)c.post&&(a=await c.post({fetch:this.fetchApi,url:i.url,init:i.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const r=this.clone();return r.middleware=r.middleware.concat(...t),r}withPreMiddleware(...t){const r=t.map(n=>({pre:n}));return this.withMiddleware(...r)}withPostMiddleware(...t){const r=t.map(n=>({post:n}));return this.withMiddleware(...r)}isJsonMime(t){return t?_r.jsonRegex.test(t):!1}async request(t,r){const{url:n,init:i}=await this.createFetchParams(t,r),a=await this.fetchApi(n,i);if(a&&a.status>=200&&a.status<300)return a;throw new Qo(a,"Response returned an error code")}async createFetchParams(t,r){let n=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(n+="?"+this.configuration.queryParamsStringify(t.query));const i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(h=>i[h]===void 0?delete i[h]:{});const a=typeof r=="function"?r:async()=>r,c={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},u={...c,...await a({init:c,context:t})},p={...u,body:Zo(u.body)||u.body instanceof URLSearchParams||Yo(u.body)?u.body:JSON.stringify(u.body)};return{url:n,init:p}}clone(){const t=this.constructor,r=new t(this.configuration);return r.middleware=this.middleware.slice(),r}};_r.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let ae=_r;function Yo(e){return typeof Blob<"u"&&e instanceof Blob}function Zo(e){return typeof FormData<"u"&&e instanceof FormData}class Qo extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class ea extends Error{constructor(t,r){super(r),this.cause=t,this.name="FetchError"}}class _ extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}function N(e,t){const r=e[t];return r!=null}function Bi(e,t=""){return Object.keys(e).map(r=>Li(r,e[r],t)).filter(r=>r.length>0).join("&")}function Li(e,t,r=""){const n=r+(r.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${i}`}if(t instanceof Set){const i=Array.from(t);return Li(e,i,r)}return t instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Bi(t,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`}function Qn(e,t){return Object.keys(e).reduce((r,n)=>({...r,[n]:t(e[n])}),{})}class K{constructor(t,r=n=>n){this.raw=t,this.transformer=r}async value(){return this.transformer(await this.raw.json())}}class Pe{constructor(t){this.raw=t}async value(){}}class ta{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function ra(e){return na(e)}function na(e,t){return e==null?e:{fieldUsed:N(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:N(e,"keyFormat")?e.keyFormat:void 0}}function ia(e){return oa(e)}function oa(e,t){return e==null?e:{name:e.name,valuePrefix:N(e,"valuePrefix")?e.valuePrefix:void 0}}function aa(e){return sa(e)}function sa(e,t){return e==null?e:{name:e.name}}function ca(e){return da(e)}function da(e,t){return e==null?e:{attachmentType:e.attachmentType,query:N(e,"query")?aa(e.query):void 0,header:N(e,"header")?ia(e.header):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function la(e){return ua(e)}function ua(e,t){return e}function pa(e){return fa(e)}function fa(e,t){return e==null?e:{days:N(e,"days")?e.days:void 0,fullHistory:N(e,"fullHistory")?e.fullHistory:void 0}}function Ki(e){return ha(e)}function ha(e,t){return e==null?e:{defaultPeriod:pa(e.defaultPeriod)}}function ga(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ma(e){if(e!==void 0)return e===null?null:{defaultPeriod:ga(e.defaultPeriod)}}function ya(e){return wa(e)}function wa(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Mi(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Ia(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedFieldMappings:e.selectedFieldMappings,backfill:ma(e.backfill)}}function va(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,Ia)}}function ba(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function Sa(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,ba)}}function xa(e){return Oa(e)}function Oa(e,t){return e==null?e:{apiKeyAsBasic:N(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:N(e,"apiKeyAsBasicOpts")?ra(e.apiKeyAsBasicOpts):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function Ca(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function gr(e){return Na(e)}function Na(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:N(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ta(e){return Ra(e)}function Ra(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function _a(e){return Aa(e)}function Aa(e,t){return e==null?e:{provider:e.provider,read:N(e,"read")?e.read:void 0,write:N(e,"write")?e.write:void 0,proxy:N(e,"proxy")?ya(e.proxy):void 0}}function Ui(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Mi(e.proxy)}}function ja(e){return ka(e)}function ka(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:_a(e.content)}}function Ea(e){return Fa(e)}function Fa(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function $i(e){return Pa(e)}function Pa(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return Da(e)}function Da(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:N(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:N(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function vr(e){return Ba(e)}function Ba(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:Ir(e.providerApp),group:$i(e.group),consumer:Ea(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:N(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function La(e){if(e!==void 0)return e===null?null:{consumerRef:e.consumerRef,consumerName:e.consumerName}}function Ka(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function Ma(e){if(e!==void 0)return e===null?null:{name:e.name,type:e.type,metadata:Ka(e.metadata)}}function Ua(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,groupName:e.groupName}}function $a(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Ui(e.content)}}function qa(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:$a(e.config)}}function Wa(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function za(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:Wa(e.latestRevision)}}function Ja(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function Ha(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Xa(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Ga(e){return Va(e)}function Va(e,t){return e==null?e:{mode:N(e,"mode")?e.mode:void 0,pageSize:N(e,"pageSize")?e.pageSize:void 0}}function Ya(e){return Za(e)}function Za(e,t){return e==null?e:{url:N(e,"url")?e.url:void 0,headers:N(e,"headers")?e.headers:void 0}}function Qa(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function mr(e){return es(e)}function es(e,t){return e==null?e:{id:e.id,name:e.name,type:e.type,metadata:Ya(e.metadata),createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function ts(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function rs(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function ns(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function is(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:ts(e.basicAuth),oauth2ClientCredentials:rs(e.oauth2ClientCredentials),oauth2Password:ns(e.oauth2Password)}}function os(e){return as(e)}function as(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function ss(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function qi(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:N(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:N(e,"default")?e.default:void 0,prompt:N(e,"prompt")?e.prompt:void 0}}function Bn(e){return cs(e)}function cs(e,t){return e==null?e:{...ss(e),...qi(e)}}function Wi(e){return ds(e)}function ds(e,t){return e}function ls(e){return us(e)}function us(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(Bn):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(Bn):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Wi(e.optionalFieldsAuto):void 0,allFields:N(e,"allFields")?e.allFields.map(Bn):void 0,backfill:N(e,"backfill")?Ki(e.backfill):void 0}}function ps(e){return fs(e)}function fs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(ls):void 0}}function hs(e){return gs(e)}function gs(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function ms(e){return ys(e)}function ys(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(hs):void 0}}function ws(e){return Is(e)}function Is(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?ps(e.read):void 0,write:N(e,"write")?ms(e.write):void 0,proxy:N(e,"proxy")?os(e.proxy):void 0}}function vs(e){return bs(e)}function bs(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:ws(e.content)}}function Ss(e){if(e!==void 0)return e===null?null:{providerAppId:e.providerAppId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:e.providerConsumerRef,refreshToken:e.refreshToken,scopes:e.scopes}}function xs(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:Ui(e.content)}}function Os(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:Ss(e.connection),config:xs(e.config)}}function $t(e){return Cs(e)}function Cs(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:N(e,"group")?$i(e.group):void 0,healthStatus:e.healthStatus,connection:vr(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,config:ja(e.config)}}function Ns(e){return Ts(e)}function Ts(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Rs(e,t){return e==null?e:{fieldName:e.fieldName}}function pi(e){return _s(e)}function _s(e,t){return e==null?e:{...Rs(e),...qi(e)}}function As(e){return js(e)}function js(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(pi):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(pi):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Wi(e.optionalFieldsAuto):void 0,backfill:N(e,"backfill")?Ki(e.backfill):void 0,delivery:N(e,"delivery")?Ga(e.delivery):void 0}}function ks(e){return Es(e)}function Es(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(As):void 0}}function Fs(e){return Ps(e)}function Ps(e,t){return e==null?e:{objectName:e.objectName}}function Ds(e){return Bs(e)}function Bs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(Fs):void 0}}function Ls(e){return Ks(e)}function Ks(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?ks(e.read):void 0,write:N(e,"write")?Ds(e.write):void 0,proxy:N(e,"proxy")?Ns(e.proxy):void 0}}function Ms(e){return Us(e)}function Us(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ls(e.content)}}function fi(e){return $s(e)}function $s(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Ms(e.latestRevision)}}function qs(e){return Ws(e)}function Ws(e,t){return e==null?e:{msg:e.msg,operationEventId:N(e,"operation_event_id")?e.operation_event_id:void 0,operationId:N(e,"operation_id")?e.operation_id:void 0}}function zs(e){return Js(e)}function Js(e,t){return e==null?e:{timestamp:e.timestamp,message:qs(e.message),severity:e.severity}}function Hs(e){return Xs(e)}function Xs(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Gs(e){return Vs(e)}function Vs(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Ys(e){return Zs(e)}function Zs(e,t){return e==null?e:{regular:N(e,"regular")?Gs(e.regular):void 0,darkMode:N(e,"darkMode")?Hs(e.darkMode):void 0}}function Qs(e){return ec(e)}function ec(e,t){return e==null?e:{workspaceRefField:N(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:N(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:N(e,"scopesField")?e.scopesField:void 0}}function tc(e){return rc(e)}function rc(e,t){return e==null?e:{grantType:e.grantType,authURL:N(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:N(e,"audience")?e.audience:void 0,tokenMetadataFields:Qs(e.tokenMetadataFields),docsURL:N(e,"docsURL")?e.docsURL:void 0,authURLParams:N(e,"authURLParams")?e.authURLParams:void 0}}function nc(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,projectId:e.projectId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerAppId:e.providerAppId,provider:e.provider}}function hi(e){return ic(e)}function ic(e,t){return e==null?e:{projectId:e.projectId,integrationId:e.integrationId,configId:e.configId,actionType:e.actionType,id:e.id,installationId:e.installationId,status:e.status,result:N(e,"result")?e.result:void 0,latestOperationEventId:N(e,"latestOperationEventId")?e.latestOperationEventId:void 0,metadata:N(e,"metadata")?e.metadata:void 0,createTime:N(e,"createTime")?new Date(e.createTime):void 0}}function oc(e){return ac(e)}function ac(e,t){return e==null?e:{bulkWrite:Ta(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function gi(e){return sc(e)}function sc(e,t){return e==null?e:{name:e.name,authType:la(e.authType),baseURL:e.baseURL,oauth2Opts:N(e,"oauth2Opts")?tc(e.oauth2Opts):void 0,apiKeyOpts:N(e,"apiKeyOpts")?ca(e.apiKeyOpts):void 0,basicOpts:N(e,"basicOpts")?xa(e.basicOpts):void 0,support:oc(e.support),providerOpts:e.providerOpts,displayName:N(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:N(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:N(e,"media")?Ys(e.media):void 0,labels:N(e,"labels")?e.labels:void 0}}function cc(e){return dc(e)}function dc(e,t){return e==null?e:{url:e.url,bucket:e.bucket,path:e.path}}function lc(e){if(e!==void 0)return e===null?null:{name:e.name,metadata:Qa(e.metadata)}}function uc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,destination:lc(e.destination)}}function pc(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:va(e.read),write:Sa(e.write),proxy:Mi(e.proxy)}}function fc(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:pc(e.content)}}function hc(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:fc(e.config)}}function gc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:hc(e.installation)}}function mc(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function yc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:mc(e.project)}}function wc(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Ic(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:wc(e.providerApp)}}class vc extends ae{async generateConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:is(t.generateConnectionParams)},r);return new K(a,c=>vr(c))}async generateConnection(t,r){return await(await this.generateConnectionRaw(t,r)).value()}async getConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:i,query:n},r);return new K(a,c=>vr(c))}async getConnection(t,r){return await(await this.getConnectionRaw(t,r)).value()}async listConnectionsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const n={};t.provider!==void 0&&(n.provider=t.provider),t.groupRef!==void 0&&(n.groupRef=t.groupRef),t.consumerRef!==void 0&&(n.consumerRef=t.consumerRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(vr))}async listConnections(t,r){return await(await this.listConnectionsRaw(t,r)).value()}}class bc extends ae{async createConsumerRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createConsumer.");if(t.consumer===null||t.consumer===void 0)throw new _("consumer","Required parameter requestParameters.consumer was null or undefined when calling createConsumer.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/consumers".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:La(t.consumer)},r);return new Pe(a)}async createConsumer(t,r){await this.createConsumerRaw(t,r)}}class Sc extends ae{async createDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createDestination.");if(t.destination===null||t.destination===void 0)throw new _("destination","Required parameter requestParameters.destination was null or undefined when calling createDestination.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ma(t.destination)},r);return new K(a,c=>mr(c))}async createDestination(t,r){return await(await this.createDestinationRaw(t,r)).value()}async deleteDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling deleteDestination.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteDestination(t,r){await this.deleteDestinationRaw(t,r)}async getDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getDestination.");if(t.destinationName===null||t.destinationName===void 0)throw new _("destinationName","Required parameter requestParameters.destinationName was null or undefined when calling getDestination.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationName}",encodeURIComponent(String(t.destinationName))),method:"GET",headers:i,query:n},r);return new K(a,c=>mr(c))}async getDestination(t,r){return await(await this.getDestinationRaw(t,r)).value()}async listDestinationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listDestinations.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(mr))}async listDestinations(t,r){return await(await this.listDestinationsRaw(t,r)).value()}async updateDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling updateDestination.");if(t.destinationUpdate===null||t.destinationUpdate===void 0)throw new _("destinationUpdate","Required parameter requestParameters.destinationUpdate was null or undefined when calling updateDestination.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"PATCH",headers:i,query:n,body:uc(t.destinationUpdate)},r);return new K(a,c=>mr(c))}async updateDestination(t,r){return await(await this.updateDestinationRaw(t,r)).value()}}class xc extends ae{async createGroupRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createGroup.");if(t.group===null||t.group===void 0)throw new _("group","Required parameter requestParameters.group was null or undefined when calling createGroup.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/groups".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ua(t.group)},r);return new Pe(a)}async createGroup(t,r){await this.createGroupRaw(t,r)}}class Oc extends ae{async createInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:n,body:qa(t.installation)},r);return new K(a,c=>$t(c))}async createInstallation(t,r){return await(await this.createInstallationRaw(t,r)).value()}async deleteInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteInstallation(t,r){await this.deleteInstallationRaw(t,r)}async getInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>$t(c))}async getInstallation(t,r){return await(await this.getInstallationRaw(t,r)).value()}async importInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations:import".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:n,body:Os(t.installation)},r);return new K(a,c=>$t(c))}async importInstallation(t,r){return await(await this.importInstallationRaw(t,r)).value()}async listInstallationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const n={};t.groupRef!==void 0&&(n.groupRef=t.groupRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map($t))}async listInstallations(t,r){return await(await this.listInstallationsRaw(t,r)).value()}async updateInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new _("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"PATCH",headers:i,query:n,body:gc(t.installationUpdate)},r);return new K(a,c=>$t(c))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class Cc extends ae{async batchUpsertIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:n,body:Ca(t.batchUpsertIntegrationsRequest)},r);return new K(a,c=>c.map(fi))}async batchUpsertIntegrations(t,r){return await(await this.batchUpsertIntegrationsRaw(t,r)).value()}async createIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new _("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:za(t.integration)},r);return new Pe(a)}async createIntegration(t,r){await this.createIntegrationRaw(t,r)}async deleteIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteIntegration(t,r){await this.deleteIntegrationRaw(t,r)}async listIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(fi))}async listIntegrations(t,r){return await(await this.listIntegrationsRaw(t,r)).value()}}class Nc extends ae{async oauthConnectRaw(t,r){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new _("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const n={},i={};i["Content-Type"]="application/json";const a=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:n,body:nc(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new K(a):new ta(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}}class Tc extends ae{async getOperationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getOperation.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling getOperation.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>hi(c))}async getOperation(t,r){return await(await this.getOperationRaw(t,r)).value()}async listOperationLogsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperationLogs.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling listOperationLogs.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}/logs".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(zs))}async listOperationLogs(t,r){return await(await this.listOperationLogsRaw(t,r)).value()}async listOperationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listOperations.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling listOperations.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}/operations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(hi))}async listOperations(t,r){return await(await this.listOperationsRaw(t,r)).value()}}class Rc extends ae{async createProjectRaw(t,r){if(t.project===null||t.project===void 0)throw new _("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects",method:"POST",headers:i,query:n,body:Ja(t.project)},r);return new K(a,c=>gr(c))}async createProject(t,r){return await(await this.createProjectRaw(t,r)).value()}async deleteProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteProject(t,r){await this.deleteProjectRaw(t,r)}async getProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>gr(c))}async getProject(t,r){return await(await this.getProjectRaw(t,r)).value()}async listProjectsRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:n,query:r},t);return new K(i,a=>a.map(gr))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new _("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:n,body:yc(t.projectUpdate)},r);return new K(a,c=>gr(c))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class _c extends ae{async getProviderRaw(t,r){if(t.provider===null||t.provider===void 0)throw new _("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:n},r);return new K(a,c=>gi(c))}async getProvider(t,r){return await(await this.getProviderRaw(t,r)).value()}async listProvidersRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:n,query:r},t);return new K(i,a=>Qn(a,gi))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Ac extends ae{async createProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new _("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ha(t.providerApp)},r);return new K(a,c=>Ir(c))}async createProviderApp(t,r){return await(await this.createProviderAppRaw(t,r)).value()}async deleteProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteProviderApp(t,r){await this.deleteProviderAppRaw(t,r)}async listProviderAppsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(Ir))}async listProviderApps(t,r){return await(await this.listProviderAppsRaw(t,r)).value()}async updateProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new _("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:i,query:n,body:Ic(t.providerAppUpdate)},r);return new K(a,c=>Ir(c))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class jc extends ae{async createRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:n,body:Xa(t.revision)},r);return new Pe(a)}async createRevision(t,r){await this.createRevisionRaw(t,r)}async getHydratedRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new _("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const n={};t.connectionId!==void 0&&(n.connectionId=t.connectionId);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions/{revisionId}:hydrate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{revisionId}",encodeURIComponent(String(t.revisionId))),method:"GET",headers:i,query:n},r);return new K(a,c=>vs(c))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class kc extends ae{async generateUploadUrlRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/generate-upload-url",method:"GET",headers:n,query:r},t);return new K(i,a=>cc(a))}async generateUploadUrl(t){return await(await this.generateUploadUrlRaw(t)).value()}}class Ec{constructor(t){this.connectionApi=new vc(t),this.consumerApi=new bc(t),this.destinationApi=new Sc(t),this.groupApi=new xc(t),this.installationApi=new Oc(t),this.integrationApi=new Cc(t),this.oAuthApi=new Nc(t),this.operationApi=new Tc(t),this.projectApi=new Rc(t),this.providerApi=new _c(t),this.providerAppApi=new Ac(t),this.revisionApi=new jc(t),this.uploadURLApi=new kc(t)}}const Fc="1.11.0",Pc="v1",yr="https://api.withampersand.com";function zi(){try{const e=process.env.REACT_APP_AMP_SERVER;switch(e){case"local":return"http://localhost:8080";case"dev":return"https://dev-api.withampersand.com";case"staging":return"https://staging-api.withampersand.com";case"prod":return yr;case"mock":return"http://127.0.0.1:4010";case"":return yr;default:return e??yr}}catch{return yr}}const Dc=(e,t)=>`${e}/${t}`;function Bc(){return Dc(zi(),Pc)}const Lc=zi(),Kc=Bc(),Mc=new Di({basePath:Kc,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Fc}});let Uc=new Ec(Mc);const H=()=>Uc,Ji=I.createContext({integrations:null}),Hi=()=>{const e=I.useContext(Ji);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function $c({projectIdOrName:e,children:t}){const r=ee(),{setError:n,isError:i}=We(),[a,c]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),c(m||[])}).catch(m=>{p(!1),n(V.INTEGRATION_LIST,e),console.error("Error retrieving integration information for : ",m)})},[e,r,n]);const h=I.useMemo(()=>({integrations:a}),[a]);return i(V.INTEGRATION_LIST,e)?s.jsx(Fe,{message:"Error retrieving integrations for the project, double check the API key"}):s.jsx(Ji.Provider,{value:h,children:u?s.jsx(Ce,{}):t})}const Xi=I.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),Z=()=>{const e=I.useContext(Xi);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function qc({projectIdOrName:e,children:t}){const r=ee(),{isError:n,setError:i}=We(),[a,c]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),c(m)}).catch(m=>{i(V.PROJECT,e),p(!1),console.error("Error loading Ampersand project: ",m)})},[e,r,p,i]);const h=I.useMemo(()=>({projectId:(a==null?void 0:a.id)||"",projectIdOrName:e,project:a,appName:(a==null?void 0:a.appName)||""}),[e,a]);return n(V.PROJECT,e)?s.jsx(Fe,{message:`Error loading project ${e}`}):s.jsx(Xi.Provider,{value:h,children:u?s.jsx(Ce,{}):t})}function Wc(e){const{options:{apiKey:t,projectId:r,project:n},children:i}=e,a=n||r;if(r&&n)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!a)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return s.jsx(zo,{children:s.jsx(Xo,{children:s.jsx(Jo,{value:t,children:s.jsx(qc,{projectIdOrName:a,children:s.jsx($c,{projectIdOrName:a,children:i})})})})})}const Gi=I.createContext(null);function zc(){const e=I.useContext(Gi);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),I=require("react"),y=require("@chakra-ui/react"),$o=require("@emotion/react"),ui=require("@emotion/styled"),qo={primary:{bg:"black",color:"white",_hover:{bg:"gray.700",_disabled:{bg:"gray.600"}},_disabled:{bg:"gray.600",color:"gray.300",cursor:"not-allowed",opacity:1}},warning:{bg:"red.50",outline:"2px solid red.100",outlineOffset:"0",borderColor:"red.100",color:"red.800",_hover:{bg:"red.100"}}},Wo=y.extendTheme({components:{Tabs:{baseStyle:{tab:{width:"100%",borderRadius:"4px",_hover:{bg:"gray.200"},_selected:{color:"black",fontWeight:"500",bg:"gray.100",border:"none",_hover:{bg:"gray.200"}}},warningTab:{width:"100%",borderRadius:"4px",_hover:{bg:"red.100"},_selected:{color:"red.800",fontWeight:"500",bg:"red.50",border:"none",_hover:{bg:"red.100"}}}}},Button:{variants:qo}}}),zo=y.extendTheme(Wo);function Jo({children:e}){return s.jsx(y.ChakraProvider,{theme:zo,children:e})}const Fi=I.createContext(null),Ho=Fi.Provider,ee=()=>{const e=I.useContext(Fi);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var V=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e))(V||{});const Pi=I.createContext(void 0);function We(){const e=I.useContext(Pi);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Xo=(()=>{const e={};return Object.values(V).forEach(t=>{e[t]={}}),e})();function Go({children:e}){const[t,r]=I.useState(Xo),n=I.useCallback((h,m)=>{r(v=>{const w={...v};return w[h]=w[h]||{},w[h][m]=!0,w})},[r]),i=I.useCallback((h,m)=>{var v;return!!((v=t[h])!=null&&v[m])},[t]),a=I.useCallback((h,m)=>{r(v=>{var b;const w={...v};return(b=w[h])==null||delete b[m],w})},[r]),c=I.useCallback(h=>{r(m=>{const v={...m};return v[h]={},v})},[r]),u=I.useCallback((h,m)=>{r(v=>{const w={...v};return w[h]=w[h]||{},m.forEach(b=>{w[h][b]=!0}),w})},[r]),p=I.useMemo(()=>({errorState:t,setErrorState:r,setError:n,isError:i,removeError:a,resetBoundary:c,setErrors:u}),[t,r,n,i,a,c,u]);return s.jsx(Pi.Provider,{value:p,children:e})}function Ce({message:e}){return s.jsx(y.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:s.jsxs(y.Stack,{alignItems:"center",children:[s.jsx(y.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"}),e&&s.jsx(y.Text,{fontSize:"40px",color:"#4299e1",children:e})]})})}function Fe({message:e}){return s.jsxs(y.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),s.jsx(y.Box,{boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"center","align-self":"stretch",padding:"12px 50px 12px 50px",borderRadius:"8px",border:"2px solid #FECACA",background:"#FEF2F2",children:s.jsx(y.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const Vo="https://api.withampersand.com/v1".replace(/\/+$/,"");class Di{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Vo}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Bi}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const t=this.configuration.apiKey;if(t)return typeof t=="function"?t:()=>t}get accessToken(){const t=this.configuration.accessToken;if(t)return typeof t=="function"?t:async()=>t}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const Yo=new Di,_r=class _r{constructor(t=Yo){this.configuration=t,this.fetchApi=async(r,n)=>{let i={url:r,init:n};for(const c of this.middleware)c.pre&&(i=await c.pre({fetch:this.fetchApi,...i})||i);let a;try{a=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(c){for(const u of this.middleware)u.onError&&(a=await u.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:c,response:a?a.clone():void 0})||a);if(a===void 0)throw c instanceof Error?new ta(c,"The request failed and the interceptors did not return an alternative response"):c}for(const c of this.middleware)c.post&&(a=await c.post({fetch:this.fetchApi,url:i.url,init:i.init,response:a.clone()})||a);return a},this.middleware=t.middleware}withMiddleware(...t){const r=this.clone();return r.middleware=r.middleware.concat(...t),r}withPreMiddleware(...t){const r=t.map(n=>({pre:n}));return this.withMiddleware(...r)}withPostMiddleware(...t){const r=t.map(n=>({post:n}));return this.withMiddleware(...r)}isJsonMime(t){return t?_r.jsonRegex.test(t):!1}async request(t,r){const{url:n,init:i}=await this.createFetchParams(t,r),a=await this.fetchApi(n,i);if(a&&a.status>=200&&a.status<300)return a;throw new ea(a,"Response returned an error code")}async createFetchParams(t,r){let n=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(n+="?"+this.configuration.queryParamsStringify(t.query));const i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(h=>i[h]===void 0?delete i[h]:{});const a=typeof r=="function"?r:async()=>r,c={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},u={...c,...await a({init:c,context:t})},p={...u,body:Qo(u.body)||u.body instanceof URLSearchParams||Zo(u.body)?u.body:JSON.stringify(u.body)};return{url:n,init:p}}clone(){const t=this.constructor,r=new t(this.configuration);return r.middleware=this.middleware.slice(),r}};_r.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let ae=_r;function Zo(e){return typeof Blob<"u"&&e instanceof Blob}function Qo(e){return typeof FormData<"u"&&e instanceof FormData}class ea extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class ta extends Error{constructor(t,r){super(r),this.cause=t,this.name="FetchError"}}class _ extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}function N(e,t){const r=e[t];return r!=null}function Bi(e,t=""){return Object.keys(e).map(r=>Li(r,e[r],t)).filter(r=>r.length>0).join("&")}function Li(e,t,r=""){const n=r+(r.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(a=>encodeURIComponent(String(a))).join(`&${encodeURIComponent(n)}=`);return`${encodeURIComponent(n)}=${i}`}if(t instanceof Set){const i=Array.from(t);return Li(e,i,r)}return t instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Bi(t,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`}function Qn(e,t){return Object.keys(e).reduce((r,n)=>({...r,[n]:t(e[n])}),{})}class K{constructor(t,r=n=>n){this.raw=t,this.transformer=r}async value(){return this.transformer(await this.raw.json())}}class Pe{constructor(t){this.raw=t}async value(){}}class ra{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function na(e){return ia(e)}function ia(e,t){return e==null?e:{fieldUsed:N(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:N(e,"keyFormat")?e.keyFormat:void 0}}function oa(e){return aa(e)}function aa(e,t){return e==null?e:{name:e.name,valuePrefix:N(e,"valuePrefix")?e.valuePrefix:void 0}}function sa(e){return ca(e)}function ca(e,t){return e==null?e:{name:e.name}}function da(e){return la(e)}function la(e,t){return e==null?e:{attachmentType:e.attachmentType,query:N(e,"query")?sa(e.query):void 0,header:N(e,"header")?oa(e.header):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function ua(e){return pa(e)}function pa(e,t){return e}function fa(e){return ha(e)}function ha(e,t){return e==null?e:{days:N(e,"days")?e.days:void 0,fullHistory:N(e,"fullHistory")?e.fullHistory:void 0}}function Ki(e){return ga(e)}function ga(e,t){return e==null?e:{defaultPeriod:fa(e.defaultPeriod)}}function ma(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ya(e){if(e!==void 0)return e===null?null:{defaultPeriod:ma(e.defaultPeriod)}}function wa(e){return Ia(e)}function Ia(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function Mi(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function va(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedFieldMappings:e.selectedFieldMappings,backfill:ya(e.backfill)}}function ba(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,va)}}function Sa(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function xa(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Qn(e.objects,Sa)}}function Oa(e){return Ca(e)}function Ca(e,t){return e==null?e:{apiKeyAsBasic:N(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:N(e,"apiKeyAsBasicOpts")?na(e.apiKeyAsBasicOpts):void 0,docsURL:N(e,"docsURL")?e.docsURL:void 0}}function Na(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function gr(e){return Ta(e)}function Ta(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:N(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ra(e){return _a(e)}function _a(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Aa(e){return ja(e)}function ja(e,t){return e==null?e:{provider:e.provider,read:N(e,"read")?e.read:void 0,write:N(e,"write")?e.write:void 0,proxy:N(e,"proxy")?wa(e.proxy):void 0}}function Ui(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Mi(e.proxy)}}function ka(e){return Ea(e)}function Ea(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Aa(e.content)}}function Fa(e){return Pa(e)}function Pa(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function $i(e){return Da(e)}function Da(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ir(e){return Ba(e)}function Ba(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:N(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:N(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function vr(e){return La(e)}function La(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:Ir(e.providerApp),group:$i(e.group),consumer:Fa(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:N(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function Ka(e){if(e!==void 0)return e===null?null:{consumerRef:e.consumerRef,consumerName:e.consumerName}}function Ma(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function Ua(e){if(e!==void 0)return e===null?null:{name:e.name,type:e.type,metadata:Ma(e.metadata)}}function $a(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,groupName:e.groupName}}function qa(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Ui(e.content)}}function Wa(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:qa(e.config)}}function za(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Ja(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:za(e.latestRevision)}}function Ha(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function Xa(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Ga(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Va(e){return Ya(e)}function Ya(e,t){return e==null?e:{mode:N(e,"mode")?e.mode:void 0,pageSize:N(e,"pageSize")?e.pageSize:void 0}}function Za(e){return Qa(e)}function Qa(e,t){return e==null?e:{url:N(e,"url")?e.url:void 0,headers:N(e,"headers")?e.headers:void 0}}function es(e){if(e!==void 0)return e===null?null:{url:e.url,headers:e.headers}}function mr(e){return ts(e)}function ts(e,t){return e==null?e:{id:e.id,name:e.name,type:e.type,metadata:Za(e.metadata),createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0}}function rs(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function ns(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function is(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function os(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:rs(e.basicAuth),oauth2ClientCredentials:ns(e.oauth2ClientCredentials),oauth2Password:is(e.oauth2Password)}}function as(e){return ss(e)}function ss(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function cs(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function qi(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:N(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:N(e,"default")?e.default:void 0,prompt:N(e,"prompt")?e.prompt:void 0}}function Bn(e){return ds(e)}function ds(e,t){return e==null?e:{...cs(e),...qi(e)}}function Wi(e){return ls(e)}function ls(e,t){return e}function us(e){return ps(e)}function ps(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(Bn):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(Bn):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Wi(e.optionalFieldsAuto):void 0,allFields:N(e,"allFields")?e.allFields.map(Bn):void 0,backfill:N(e,"backfill")?Ki(e.backfill):void 0}}function fs(e){return hs(e)}function hs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(us):void 0}}function gs(e){return ms(e)}function ms(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function ys(e){return ws(e)}function ws(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(gs):void 0}}function Is(e){return vs(e)}function vs(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?fs(e.read):void 0,write:N(e,"write")?ys(e.write):void 0,proxy:N(e,"proxy")?as(e.proxy):void 0}}function bs(e){return Ss(e)}function Ss(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Is(e.content)}}function xs(e){if(e!==void 0)return e===null?null:{providerAppId:e.providerAppId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:e.providerConsumerRef,refreshToken:e.refreshToken,scopes:e.scopes}}function Os(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:Ui(e.content)}}function Cs(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:xs(e.connection),config:Os(e.config)}}function $t(e){return Ns(e)}function Ns(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:N(e,"group")?$i(e.group):void 0,healthStatus:e.healthStatus,connection:vr(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,config:ka(e.config)}}function Ts(e){return Rs(e)}function Rs(e,t){return e==null?e:{enabled:N(e,"enabled")?e.enabled:void 0}}function _s(e,t){return e==null?e:{fieldName:e.fieldName}}function pi(e){return As(e)}function As(e,t){return e==null?e:{..._s(e),...qi(e)}}function js(e){return ks(e)}function ks(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:N(e,"requiredFields")?e.requiredFields.map(pi):void 0,optionalFields:N(e,"optionalFields")?e.optionalFields.map(pi):void 0,optionalFieldsAuto:N(e,"optionalFieldsAuto")?Wi(e.optionalFieldsAuto):void 0,backfill:N(e,"backfill")?Ki(e.backfill):void 0,delivery:N(e,"delivery")?Va(e.delivery):void 0}}function Es(e){return Fs(e)}function Fs(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(js):void 0}}function Ps(e){return Ds(e)}function Ds(e,t){return e==null?e:{objectName:e.objectName}}function Bs(e){return Ls(e)}function Ls(e,t){return e==null?e:{objects:N(e,"objects")?e.objects.map(Ps):void 0}}function Ks(e){return Ms(e)}function Ms(e,t){return e==null?e:{name:e.name,displayName:N(e,"displayName")?e.displayName:void 0,provider:e.provider,read:N(e,"read")?Es(e.read):void 0,write:N(e,"write")?Bs(e.write):void 0,proxy:N(e,"proxy")?Ts(e.proxy):void 0}}function Us(e){return $s(e)}function $s(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ks(e.content)}}function fi(e){return qs(e)}function qs(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:N(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Us(e.latestRevision)}}function Ws(e){return zs(e)}function zs(e,t){return e==null?e:{msg:e.msg,operationEventId:N(e,"operation_event_id")?e.operation_event_id:void 0,operationId:N(e,"operation_id")?e.operation_id:void 0}}function Js(e){return Hs(e)}function Hs(e,t){return e==null?e:{timestamp:e.timestamp,message:Ws(e.message),severity:e.severity}}function Xs(e){return Gs(e)}function Gs(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Vs(e){return Ys(e)}function Ys(e,t){return e==null?e:{iconURL:N(e,"iconURL")?e.iconURL:void 0,logoURL:N(e,"logoURL")?e.logoURL:void 0}}function Zs(e){return Qs(e)}function Qs(e,t){return e==null?e:{regular:N(e,"regular")?Vs(e.regular):void 0,darkMode:N(e,"darkMode")?Xs(e.darkMode):void 0}}function ec(e){return tc(e)}function tc(e,t){return e==null?e:{workspaceRefField:N(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:N(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:N(e,"scopesField")?e.scopesField:void 0}}function rc(e){return nc(e)}function nc(e,t){return e==null?e:{grantType:e.grantType,authURL:N(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:N(e,"audience")?e.audience:void 0,tokenMetadataFields:ec(e.tokenMetadataFields),docsURL:N(e,"docsURL")?e.docsURL:void 0,authURLParams:N(e,"authURLParams")?e.authURLParams:void 0}}function ic(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,projectId:e.projectId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerAppId:e.providerAppId,provider:e.provider}}function hi(e){return oc(e)}function oc(e,t){return e==null?e:{projectId:e.projectId,integrationId:e.integrationId,configId:e.configId,actionType:e.actionType,id:e.id,installationId:e.installationId,status:e.status,result:N(e,"result")?e.result:void 0,latestOperationEventId:N(e,"latestOperationEventId")?e.latestOperationEventId:void 0,metadata:N(e,"metadata")?e.metadata:void 0,createTime:N(e,"createTime")?new Date(e.createTime):void 0}}function ac(e){return sc(e)}function sc(e,t){return e==null?e:{bulkWrite:Ra(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function gi(e){return cc(e)}function cc(e,t){return e==null?e:{name:e.name,authType:ua(e.authType),baseURL:e.baseURL,oauth2Opts:N(e,"oauth2Opts")?rc(e.oauth2Opts):void 0,apiKeyOpts:N(e,"apiKeyOpts")?da(e.apiKeyOpts):void 0,basicOpts:N(e,"basicOpts")?Oa(e.basicOpts):void 0,support:ac(e.support),providerOpts:e.providerOpts,displayName:N(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:N(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:N(e,"media")?Zs(e.media):void 0,labels:N(e,"labels")?e.labels:void 0}}function dc(e){return lc(e)}function lc(e,t){return e==null?e:{url:e.url,bucket:e.bucket,path:e.path}}function uc(e){if(e!==void 0)return e===null?null:{name:e.name,metadata:es(e.metadata)}}function pc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,destination:uc(e.destination)}}function fc(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:ba(e.read),write:xa(e.write),proxy:Mi(e.proxy)}}function hc(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:fc(e.content)}}function gc(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:hc(e.config)}}function mc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:gc(e.installation)}}function yc(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function wc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:yc(e.project)}}function Ic(e){if(e!==void 0)return e===null?null:{externalRef:e.externalRef,provider:e.provider,clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function vc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:Ic(e.providerApp)}}class bc extends ae{async generateConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:os(t.generateConnectionParams)},r);return new K(a,c=>vr(c))}async generateConnection(t,r){return await(await this.generateConnectionRaw(t,r)).value()}async getConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:i,query:n},r);return new K(a,c=>vr(c))}async getConnection(t,r){return await(await this.getConnectionRaw(t,r)).value()}async listConnectionsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const n={};t.provider!==void 0&&(n.provider=t.provider),t.groupRef!==void 0&&(n.groupRef=t.groupRef),t.consumerRef!==void 0&&(n.consumerRef=t.consumerRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(vr))}async listConnections(t,r){return await(await this.listConnectionsRaw(t,r)).value()}}class Sc extends ae{async createConsumerRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createConsumer.");if(t.consumer===null||t.consumer===void 0)throw new _("consumer","Required parameter requestParameters.consumer was null or undefined when calling createConsumer.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/consumers".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ka(t.consumer)},r);return new Pe(a)}async createConsumer(t,r){await this.createConsumerRaw(t,r)}}class xc extends ae{async createDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createDestination.");if(t.destination===null||t.destination===void 0)throw new _("destination","Required parameter requestParameters.destination was null or undefined when calling createDestination.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ua(t.destination)},r);return new K(a,c=>mr(c))}async createDestination(t,r){return await(await this.createDestinationRaw(t,r)).value()}async deleteDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling deleteDestination.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteDestination(t,r){await this.deleteDestinationRaw(t,r)}async getDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getDestination.");if(t.destinationName===null||t.destinationName===void 0)throw new _("destinationName","Required parameter requestParameters.destinationName was null or undefined when calling getDestination.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationName}",encodeURIComponent(String(t.destinationName))),method:"GET",headers:i,query:n},r);return new K(a,c=>mr(c))}async getDestination(t,r){return await(await this.getDestinationRaw(t,r)).value()}async listDestinationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listDestinations.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(mr))}async listDestinations(t,r){return await(await this.listDestinationsRaw(t,r)).value()}async updateDestinationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateDestination.");if(t.destinationId===null||t.destinationId===void 0)throw new _("destinationId","Required parameter requestParameters.destinationId was null or undefined when calling updateDestination.");if(t.destinationUpdate===null||t.destinationUpdate===void 0)throw new _("destinationUpdate","Required parameter requestParameters.destinationUpdate was null or undefined when calling updateDestination.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/destinations/{destinationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{destinationId}",encodeURIComponent(String(t.destinationId))),method:"PATCH",headers:i,query:n,body:pc(t.destinationUpdate)},r);return new K(a,c=>mr(c))}async updateDestination(t,r){return await(await this.updateDestinationRaw(t,r)).value()}}class Oc extends ae{async createGroupRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createGroup.");if(t.group===null||t.group===void 0)throw new _("group","Required parameter requestParameters.group was null or undefined when calling createGroup.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/groups".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:$a(t.group)},r);return new Pe(a)}async createGroup(t,r){await this.createGroupRaw(t,r)}}class Cc extends ae{async createInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:n,body:Wa(t.installation)},r);return new K(a,c=>$t(c))}async createInstallation(t,r){return await(await this.createInstallationRaw(t,r)).value()}async deleteInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteInstallation(t,r){await this.deleteInstallationRaw(t,r)}async getInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>$t(c))}async getInstallation(t,r){return await(await this.getInstallationRaw(t,r)).value()}async importInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new _("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations:import".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:n,body:Cs(t.installation)},r);return new K(a,c=>$t(c))}async importInstallation(t,r){return await(await this.importInstallationRaw(t,r)).value()}async listInstallationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const n={};t.groupRef!==void 0&&(n.groupRef=t.groupRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map($t))}async listInstallations(t,r){return await(await this.listInstallationsRaw(t,r)).value()}async updateInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new _("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"PATCH",headers:i,query:n,body:mc(t.installationUpdate)},r);return new K(a,c=>$t(c))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class Nc extends ae{async batchUpsertIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:n,body:Na(t.batchUpsertIntegrationsRequest)},r);return new K(a,c=>c.map(fi))}async batchUpsertIntegrations(t,r){return await(await this.batchUpsertIntegrationsRaw(t,r)).value()}async createIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new _("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Ja(t.integration)},r);return new Pe(a)}async createIntegration(t,r){await this.createIntegrationRaw(t,r)}async deleteIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteIntegration(t,r){await this.deleteIntegrationRaw(t,r)}async listIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(fi))}async listIntegrations(t,r){return await(await this.listIntegrationsRaw(t,r)).value()}}class Tc extends ae{async oauthConnectRaw(t,r){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new _("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const n={},i={};i["Content-Type"]="application/json";const a=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:n,body:ic(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new K(a):new ra(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}}class Rc extends ae{async getOperationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getOperation.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling getOperation.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>hi(c))}async getOperation(t,r){return await(await this.getOperationRaw(t,r)).value()}async listOperationLogsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperationLogs.");if(t.operationId===null||t.operationId===void 0)throw new _("operationId","Required parameter requestParameters.operationId was null or undefined when calling listOperationLogs.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/operations/{operationId}/logs".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{operationId}",encodeURIComponent(String(t.operationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(Js))}async listOperationLogs(t,r){return await(await this.listOperationLogsRaw(t,r)).value()}async listOperationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listOperations.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listOperations.");if(t.installationId===null||t.installationId===void 0)throw new _("installationId","Required parameter requestParameters.installationId was null or undefined when calling listOperations.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}/operations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(hi))}async listOperations(t,r){return await(await this.listOperationsRaw(t,r)).value()}}class _c extends ae{async createProjectRaw(t,r){if(t.project===null||t.project===void 0)throw new _("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects",method:"POST",headers:i,query:n,body:Ha(t.project)},r);return new K(a,c=>gr(c))}async createProject(t,r){return await(await this.createProjectRaw(t,r)).value()}async deleteProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteProject(t,r){await this.deleteProjectRaw(t,r)}async getProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>gr(c))}async getProject(t,r){return await(await this.getProjectRaw(t,r)).value()}async listProjectsRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:n,query:r},t);return new K(i,a=>a.map(gr))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new _("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:n,body:wc(t.projectUpdate)},r);return new K(a,c=>gr(c))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class Ac extends ae{async getProviderRaw(t,r){if(t.provider===null||t.provider===void 0)throw new _("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:n},r);return new K(a,c=>gi(c))}async getProvider(t,r){return await(await this.getProviderRaw(t,r)).value()}async listProvidersRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:n,query:r},t);return new K(i,a=>Qn(a,gi))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class jc extends ae{async createProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new _("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:n,body:Xa(t.providerApp)},r);return new K(a,c=>Ir(c))}async createProviderApp(t,r){return await(await this.createProviderAppRaw(t,r)).value()}async deleteProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:i,query:n},r);return new Pe(a)}async deleteProviderApp(t,r){await this.deleteProviderAppRaw(t,r)}async listProviderAppsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const n={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:n},r);return new K(a,c=>c.map(Ir))}async listProviderApps(t,r){return await(await this.listProviderAppsRaw(t,r)).value()}async updateProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new _("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new _("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:i,query:n,body:vc(t.providerAppUpdate)},r);return new K(a,c=>Ir(c))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class kc extends ae{async createRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const n={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:i,query:n,body:Ga(t.revision)},r);return new Pe(a)}async createRevision(t,r){await this.createRevisionRaw(t,r)}async getHydratedRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new _("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new _("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new _("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new _("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const n={};t.connectionId!==void 0&&(n.connectionId=t.connectionId);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const a=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions/{revisionId}:hydrate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{revisionId}",encodeURIComponent(String(t.revisionId))),method:"GET",headers:i,query:n},r);return new K(a,c=>bs(c))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class Ec extends ae{async generateUploadUrlRaw(t){const r={},n={};this.configuration&&this.configuration.apiKey&&(n["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/generate-upload-url",method:"GET",headers:n,query:r},t);return new K(i,a=>dc(a))}async generateUploadUrl(t){return await(await this.generateUploadUrlRaw(t)).value()}}class Fc{constructor(t){this.connectionApi=new bc(t),this.consumerApi=new Sc(t),this.destinationApi=new xc(t),this.groupApi=new Oc(t),this.installationApi=new Cc(t),this.integrationApi=new Nc(t),this.oAuthApi=new Tc(t),this.operationApi=new Rc(t),this.projectApi=new _c(t),this.providerApi=new Ac(t),this.providerAppApi=new jc(t),this.revisionApi=new kc(t),this.uploadURLApi=new Ec(t)}}const Pc="1.12.0",Dc="v1",yr="https://api.withampersand.com";function zi(){try{const e=process.env.REACT_APP_AMP_SERVER;switch(e){case"local":return"http://localhost:8080";case"dev":return"https://dev-api.withampersand.com";case"staging":return"https://staging-api.withampersand.com";case"prod":return yr;case"mock":return"http://127.0.0.1:4010";case"":return yr;default:return e??yr}}catch{return yr}}const Bc=(e,t)=>`${e}/${t}`;function Lc(){return Bc(zi(),Dc)}const Kc=zi(),Mc=Lc(),Uc=new Di({basePath:Mc,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Pc}});let $c=new Fc(Uc);const H=()=>$c,Ji=I.createContext({integrations:null}),Hi=()=>{const e=I.useContext(Ji);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function qc({projectIdOrName:e,children:t}){const r=ee(),{setError:n,isError:i}=We(),[a,c]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),c(m||[])}).catch(m=>{p(!1),n(V.INTEGRATION_LIST,e),console.error("Error retrieving integration information for : ",m)})},[e,r,n]);const h=I.useMemo(()=>({integrations:a}),[a]);return i(V.INTEGRATION_LIST,e)?s.jsx(Fe,{message:"Error retrieving integrations for the project, double check the API key"}):s.jsx(Ji.Provider,{value:h,children:u?s.jsx(Ce,{}):t})}const Xi=I.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),Z=()=>{const e=I.useContext(Xi);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Wc({projectIdOrName:e,children:t}){const r=ee(),{isError:n,setError:i}=We(),[a,c]=I.useState(null),[u,p]=I.useState(!0);I.useEffect(()=>{H().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),c(m)}).catch(m=>{i(V.PROJECT,e),p(!1),console.error("Error loading Ampersand project: ",m)})},[e,r,p,i]);const h=I.useMemo(()=>({projectId:(a==null?void 0:a.id)||"",projectIdOrName:e,project:a,appName:(a==null?void 0:a.appName)||""}),[e,a]);return n(V.PROJECT,e)?s.jsx(Fe,{message:`Error loading project ${e}`}):s.jsx(Xi.Provider,{value:h,children:u?s.jsx(Ce,{}):t})}function zc(e){const{options:{apiKey:t,projectId:r,project:n},children:i}=e,a=n||r;if(r&&n)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!a)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return s.jsx(Jo,{children:s.jsx(Go,{children:s.jsx(Ho,{value:t,children:s.jsx(Wc,{projectIdOrName:a,children:s.jsx(qc,{projectIdOrName:a,children:i})})})})})}const Gi=I.createContext(null);function Jc(){const e=I.useContext(Gi);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
2
2
  component is wrapped with AmpersandProvider`);return e}function Vi(e){return e.charAt(0).toUpperCase()+e.slice(1)}function st(e,t){return(t==null?void 0:t.displayName)??Vi(e)}const Yi=e=>e.split(`
3
- `).filter(r=>r.trim()!==""),Jc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Hc=()=>{const[e,t]=I.useState(!1),r=I.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:r}},Zi=I.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0,onUninstallSuccess:void 0,isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}});function Ne(){const e=I.useContext(Zi);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Xc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,onInstallSuccess:c,onUpdateSuccess:u,onUninstallSuccess:p}){const h=ee(),{projectId:m}=Z(),{integrations:v}=Hi(),{setError:w,isError:b}=We(),{isIntegrationDeleted:x,setIntegrationDeleted:S}=Hc(),[O,T]=I.useState([]),[A,P]=I.useState(!0),$=(O==null?void 0:O[0])||null,k=I.useMemo(()=>Jc(t,v||[]),[t,v]);I.useEffect(()=>{k===null&&(v!=null&&v.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,k,v]);const Q=I.useCallback(Y=>{T([Y])},[T]),X=I.useCallback(()=>{k!=null&&k.id&&H().installationApi.listInstallations({projectIdOrName:m,integrationId:k.id,groupRef:i},{headers:{"X-Api-Key":h??""}}).then(Y=>{P(!1),T(Y||[])}).catch(Y=>{w(V.INSTALLATION_LIST,k.id),P(!1),console.error("Error retrieving installation information: ",Y)})},[k,m,h,w,i]),te=(k==null?void 0:k.id)||"";I.useEffect(()=>{X()},[X]);const J=I.useMemo(()=>({integrationId:(k==null?void 0:k.id)||"",provider:(k==null?void 0:k.provider)||"",integrationObj:k,consumerRef:r,consumerName:n,groupRef:i,groupName:a,installation:$,setInstallation:Q,resetInstallations:X,onInstallSuccess:c,onUpdateSuccess:u,onUninstallSuccess:p,isIntegrationDeleted:x,setIntegrationDeleted:S}),[k,r,n,i,a,$,Q,X,c,u,p,x,S]);if(k!==null){const Y=`Error retrieving installation information for integration "${(k==null?void 0:k.name)||"unknown"}"`;return b(V.INSTALLATION_LIST,te)?s.jsx(Fe,{message:Y}):s.jsx(Zi.Provider,{value:J,children:A?s.jsx(Ce,{}):e})}return s.jsx(Fe,{message:`Integration "${t}" not found`})}const Qi=I.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),xt=()=>{const e=I.useContext(Qi);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function eo({provider:e,groupRef:t,children:r}){const n=ee(),{projectId:i}=Z(),[a,c]=I.useState(null),[u,p]=I.useState(null),[h,m]=I.useState(!0),{setError:v,isError:w}=We(),{provider:b}=Ne();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const x=e||b;if(!x)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");I.useEffect(()=>{H().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:x},{headers:{"X-Api-Key":n??""}}).then(O=>{m(!1),c(O)}).catch(O=>{m(!1),v(V.CONNECTION_LIST,i),console.error(`Error retrieving existing OAuth connections for group ID ${t}:`,O)})},[i,n,t,x,v]);const S=I.useMemo(()=>({connections:a,selectedConnection:u,setConnections:c,setSelectedConnection:p}),[a,u,c,p]);return w(V.CONNECTION_LIST,i)?s.jsx(Fe,{message:"Error retrieving existing connections"}):s.jsx(Qi.Provider,{value:S,children:h?s.jsx(Ce,{}):r})}var $e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xr={exports:{}};xr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=1,a=2,c=9007199254740991,u="[object Arguments]",p="[object Array]",h="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",w="[object Error]",b="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",T="[object Null]",A="[object Object]",P="[object Promise]",$="[object Proxy]",k="[object RegExp]",Q="[object Set]",X="[object String]",te="[object Symbol]",J="[object Undefined]",Y="[object WeakMap]",Te="[object ArrayBuffer]",ct="[object DataView]",Br="[object Float32Array]",Lr="[object Float64Array]",Kr="[object Int8Array]",Mr="[object Int16Array]",Ur="[object Int32Array]",$r="[object Uint8Array]",qr="[object Uint8ClampedArray]",Wr="[object Uint16Array]",zr="[object Uint32Array]",Jr=/[\\^$.*+?()[\]{}|]/g,M=/^\[object .+?Constructor\]$/,Yt=/^(?:0|[1-9]\d*)$/,U={};U[Br]=U[Lr]=U[Kr]=U[Mr]=U[Ur]=U[$r]=U[qr]=U[Wr]=U[zr]=!0,U[u]=U[p]=U[Te]=U[m]=U[ct]=U[v]=U[w]=U[b]=U[S]=U[O]=U[A]=U[k]=U[Q]=U[X]=U[Y]=!1;var De=typeof $e=="object"&&$e&&$e.Object===Object&&$e,Zt=typeof self=="object"&&self&&self.Object===Object&&self,oe=De||Zt||Function("return this")(),Ct=t&&!t.nodeType&&t,dt=Ct&&!0&&e&&!e.nodeType&&e,Nt=dt&&dt.exports===Ct,lt=Nt&&De.process,Qt=function(){try{return lt&&lt.binding&&lt.binding("util")}catch{}}(),er=Qt&&Qt.isTypedArray;function Hr(l,o){for(var d=-1,f=l==null?0:l.length,C=0,R=[];++d<f;){var j=l[d];o(j,d,l)&&(R[C++]=j)}return R}function Xr(l,o){for(var d=-1,f=o.length,C=l.length;++d<f;)l[C+d]=o[d];return l}function Gr(l,o){for(var d=-1,f=l==null?0:l.length;++d<f;)if(o(l[d],d,l))return!0;return!1}function Vr(l,o){for(var d=-1,f=Array(l);++d<l;)f[d]=o(d);return f}function Yr(l){return function(o){return l(o)}}function ut(l,o){return l.has(o)}function Tt(l,o){return l==null?void 0:l[o]}function pt(l){var o=-1,d=Array(l.size);return l.forEach(function(f,C){d[++o]=[C,f]}),d}function be(l,o){return function(d){return l(o(d))}}function tr(l){var o=-1,d=Array(l.size);return l.forEach(function(f){d[++o]=f}),d}var rr=Array.prototype,Zr=Function.prototype,ft=Object.prototype,Be=oe["__core-js_shared__"],Rt=Zr.toString,ce=ft.hasOwnProperty,_t=function(){var l=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),At=ft.toString,Qr=RegExp("^"+Rt.call(ce).replace(Jr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nr=Nt?oe.Buffer:void 0,ue=oe.Symbol,ze=oe.Uint8Array,ir=ft.propertyIsEnumerable,or=rr.splice,Re=ue?ue.toStringTag:void 0,jt=Object.getOwnPropertySymbols,Je=nr?nr.isBuffer:void 0,en=be(Object.keys,Object),ge=Ke(oe,"DataView"),He=Ke(oe,"Map"),kt=Ke(oe,"Promise"),Et=Ke(oe,"Set"),Ft=Ke(oe,"WeakMap"),Xe=Ke(Object,"create"),me=Ie(ge),tn=Ie(He),rn=Ie(kt),nn=Ie(Et),on=Ie(Ft),ar=ue?ue.prototype:void 0,Se=ar?ar.valueOf:void 0;function _e(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function an(){this.__data__=Xe?Xe(null):{},this.size=0}function sn(l){var o=this.has(l)&&delete this.__data__[l];return this.size-=o?1:0,o}function cn(l){var o=this.__data__;if(Xe){var d=o[l];return d===n?void 0:d}return ce.call(o,l)?o[l]:void 0}function dn(l){var o=this.__data__;return Xe?o[l]!==void 0:ce.call(o,l)}function Le(l,o){var d=this.__data__;return this.size+=this.has(l)?0:1,d[l]=Xe&&o===void 0?n:o,this}_e.prototype.clear=an,_e.prototype.delete=sn,_e.prototype.get=cn,_e.prototype.has=dn,_e.prototype.set=Le;function ye(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function ln(){this.__data__=[],this.size=0}function un(l){var o=this.__data__,d=mt(o,l);if(d<0)return!1;var f=o.length-1;return d==f?o.pop():or.call(o,d,1),--this.size,!0}function pn(l){var o=this.__data__,d=mt(o,l);return d<0?void 0:o[d][1]}function fn(l){return mt(this.__data__,l)>-1}function hn(l,o){var d=this.__data__,f=mt(d,l);return f<0?(++this.size,d.push([l,o])):d[f][1]=o,this}ye.prototype.clear=ln,ye.prototype.delete=un,ye.prototype.get=pn,ye.prototype.has=fn,ye.prototype.set=hn;function we(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function gn(){this.size=0,this.__data__={hash:new _e,map:new(He||ye),string:new _e}}function ht(l){var o=Ye(this,l).delete(l);return this.size-=o?1:0,o}function Pt(l){return Ye(this,l).get(l)}function mn(l){return Ye(this,l).has(l)}function gt(l,o){var d=Ye(this,l),f=d.size;return d.set(l,o),this.size+=d.size==f?0:1,this}we.prototype.clear=gn,we.prototype.delete=ht,we.prototype.get=Pt,we.prototype.has=mn,we.prototype.set=gt;function Ge(l){var o=-1,d=l==null?0:l.length;for(this.__data__=new we;++o<d;)this.add(l[o])}function yn(l){return this.__data__.set(l,n),this}function wn(l){return this.__data__.has(l)}Ge.prototype.add=Ge.prototype.push=yn,Ge.prototype.has=wn;function xe(l){var o=this.__data__=new ye(l);this.size=o.size}function sr(){this.__data__=new ye,this.size=0}function In(l){var o=this.__data__,d=o.delete(l);return this.size=o.size,d}function vn(l){return this.__data__.get(l)}function bn(l){return this.__data__.has(l)}function Sn(l,o){var d=this.__data__;if(d instanceof ye){var f=d.__data__;if(!He||f.length<r-1)return f.push([l,o]),this.size=++d.size,this;d=this.__data__=new we(f)}return d.set(l,o),this.size=d.size,this}xe.prototype.clear=sr,xe.prototype.delete=In,xe.prototype.get=vn,xe.prototype.has=bn,xe.prototype.set=Sn;function xn(l,o){var d=Ze(l),f=!d&&Fn(l),C=!d&&!f&&vt(l),R=!d&&!f&&!C&&Ut(l),j=d||f||C||R,D=j?Vr(l.length,String):[],E=D.length;for(var F in l)ce.call(l,F)&&!(j&&(F=="length"||C&&(F=="offset"||F=="parent")||R&&(F=="buffer"||F=="byteLength"||F=="byteOffset")||jn(F,E)))&&D.push(F);return D}function mt(l,o){for(var d=l.length;d--;)if(It(l[d][0],o))return d;return-1}function On(l,o,d){var f=o(l);return Ze(l)?f:Xr(f,d(l))}function Ve(l){return l==null?l===void 0?J:T:Re&&Re in Object(l)?_n(l):Lt(l)}function cr(l){return Qe(l)&&Ve(l)==u}function dr(l,o,d,f,C){return l===o?!0:l==null||o==null||!Qe(l)&&!Qe(o)?l!==l&&o!==o:yt(l,o,d,f,dr,C)}function yt(l,o,d,f,C,R){var j=Ze(l),D=Ze(o),E=j?p:pe(l),F=D?p:pe(o);E=E==u?A:E,F=F==u?A:F;var q=E==A,W=F==A,G=E==F;if(G&&vt(l)){if(!vt(o))return!1;j=!0,q=!1}if(G&&!q)return R||(R=new xe),j||Ut(l)?Bt(l,o,d,f,C,R):Tn(l,o,E,d,f,C,R);if(!(d&i)){var ne=q&&ce.call(l,"__wrapped__"),ie=W&&ce.call(o,"__wrapped__");if(ne||ie){var ve=ne?l.value():l,je=ie?o.value():o;return R||(R=new xe),C(ve,je,d,f,R)}}return G?(R||(R=new xe),Rn(l,o,d,f,C,R)):!1}function Dt(l){if(!Mt(l)||En(l))return!1;var o=Me(l)?Qr:M;return o.test(Ie(l))}function Cn(l){return Qe(l)&&ur(l.length)&&!!U[Ve(l)]}function Nn(l){if(!wt(l))return en(l);var o=[];for(var d in Object(l))ce.call(l,d)&&d!="constructor"&&o.push(d);return o}function Bt(l,o,d,f,C,R){var j=d&i,D=l.length,E=o.length;if(D!=E&&!(j&&E>D))return!1;var F=R.get(l);if(F&&R.get(o))return F==o;var q=-1,W=!0,G=d&a?new Ge:void 0;for(R.set(l,o),R.set(o,l);++q<D;){var ne=l[q],ie=o[q];if(f)var ve=j?f(ie,ne,q,o,l,R):f(ne,ie,q,l,o,R);if(ve!==void 0){if(ve)continue;W=!1;break}if(G){if(!Gr(o,function(je,et){if(!ut(G,et)&&(ne===je||C(ne,je,d,f,R)))return G.push(et)})){W=!1;break}}else if(!(ne===ie||C(ne,ie,d,f,R))){W=!1;break}}return R.delete(l),R.delete(o),W}function Tn(l,o,d,f,C,R,j){switch(d){case ct:if(l.byteLength!=o.byteLength||l.byteOffset!=o.byteOffset)return!1;l=l.buffer,o=o.buffer;case Te:return!(l.byteLength!=o.byteLength||!R(new ze(l),new ze(o)));case m:case v:case O:return It(+l,+o);case w:return l.name==o.name&&l.message==o.message;case k:case X:return l==o+"";case S:var D=pt;case Q:var E=f&i;if(D||(D=tr),l.size!=o.size&&!E)return!1;var F=j.get(l);if(F)return F==o;f|=a,j.set(l,o);var q=Bt(D(l),D(o),f,C,R,j);return j.delete(l),q;case te:if(Se)return Se.call(l)==Se.call(o)}return!1}function Rn(l,o,d,f,C,R){var j=d&i,D=lr(l),E=D.length,F=lr(o),q=F.length;if(E!=q&&!j)return!1;for(var W=E;W--;){var G=D[W];if(!(j?G in o:ce.call(o,G)))return!1}var ne=R.get(l);if(ne&&R.get(o))return ne==o;var ie=!0;R.set(l,o),R.set(o,l);for(var ve=j;++W<E;){G=D[W];var je=l[G],et=o[G];if(f)var li=j?f(et,je,G,o,l,R):f(je,et,G,l,o,R);if(!(li===void 0?je===et||C(je,et,d,f,R):li)){ie=!1;break}ve||(ve=G=="constructor")}if(ie&&!ve){var fr=l.constructor,hr=o.constructor;fr!=hr&&"constructor"in l&&"constructor"in o&&!(typeof fr=="function"&&fr instanceof fr&&typeof hr=="function"&&hr instanceof hr)&&(ie=!1)}return R.delete(l),R.delete(o),ie}function lr(l){return On(l,Pn,An)}function Ye(l,o){var d=l.__data__;return kn(o)?d[typeof o=="string"?"string":"hash"]:d.map}function Ke(l,o){var d=Tt(l,o);return Dt(d)?d:void 0}function _n(l){var o=ce.call(l,Re),d=l[Re];try{l[Re]=void 0;var f=!0}catch{}var C=At.call(l);return f&&(o?l[Re]=d:delete l[Re]),C}var An=jt?function(l){return l==null?[]:(l=Object(l),Hr(jt(l),function(o){return ir.call(l,o)}))}:Dn,pe=Ve;(ge&&pe(new ge(new ArrayBuffer(1)))!=ct||He&&pe(new He)!=S||kt&&pe(kt.resolve())!=P||Et&&pe(new Et)!=Q||Ft&&pe(new Ft)!=Y)&&(pe=function(l){var o=Ve(l),d=o==A?l.constructor:void 0,f=d?Ie(d):"";if(f)switch(f){case me:return ct;case tn:return S;case rn:return P;case nn:return Q;case on:return Y}return o});function jn(l,o){return o=o??c,!!o&&(typeof l=="number"||Yt.test(l))&&l>-1&&l%1==0&&l<o}function kn(l){var o=typeof l;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?l!=="__proto__":l===null}function En(l){return!!_t&&_t in l}function wt(l){var o=l&&l.constructor,d=typeof o=="function"&&o.prototype||ft;return l===d}function Lt(l){return At.call(l)}function Ie(l){if(l!=null){try{return Rt.call(l)}catch{}try{return l+""}catch{}}return""}function It(l,o){return l===o||l!==l&&o!==o}var Fn=cr(function(){return arguments}())?cr:function(l){return Qe(l)&&ce.call(l,"callee")&&!ir.call(l,"callee")},Ze=Array.isArray;function Kt(l){return l!=null&&ur(l.length)&&!Me(l)}var vt=Je||pr;function Ae(l,o){return dr(l,o)}function Me(l){if(!Mt(l))return!1;var o=Ve(l);return o==b||o==x||o==h||o==$}function ur(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=c}function Mt(l){var o=typeof l;return l!=null&&(o=="object"||o=="function")}function Qe(l){return l!=null&&typeof l=="object"}var Ut=er?Yr(er):Cn;function Pn(l){return Kt(l)?xn(l):Nn(l)}function Dn(){return[]}function pr(){return!1}e.exports=Ae})(xr,xr.exports);var Gc=xr.exports;const Vc=ei(Gc),it="other";function qe(e){return e.mapToName!==void 0}function Yc(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function Zc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!qe(r)&&!!r.fieldName))||null}function Qc(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>qe(n)&&!!n.mapToName))||[]}function ed(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!qe(r)&&!!r.fieldName))||null}const to=(e,t)=>{var r,n,i;return(i=(n=(r=e==null?void 0:e.content)==null?void 0:r.read)==null?void 0:n.objects)==null?void 0:i[t]};function td(e){return qe(e)?e.mapToName:e.fieldName}const ro=(e,t)=>{var n,i,a;const r=[];return(a=(i=(n=t.content)==null?void 0:n.read)==null?void 0:i.objects)==null||a.forEach(c=>{r.push({name:c==null?void 0:c.objectName,completed:e?!!to(e,c.objectName):!1})}),r},no=e=>{var r;return{name:it,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function rd(e,t){var a;const r=ro(e,t),i=!!((a=t==null?void 0:t.content)!=null&&a.write)?no(e):void 0;return i&&r.push(i),r}function io(e,t,r){const n=(e==null?void 0:e.filter(a=>!(t!=null&&t[a==null?void 0:a.mapToName])))||[],i=n.map(a=>a.mapToName);return r(V.MAPPING,i),n!=null&&n.length&&console.error("required fields not met",n.map(a=>a.mapToDisplayName)),{errorList:i}}function ti(e,t){return Vc(e,t)}const nd=(e,t,r)=>{var b,x,S,O,T,A;if(!e)return null;const n=Yc(e,t),i=n&&Zc(n),a=n&&ed(n),c=n&&Qc(n),u=(n==null?void 0:n.allFields)||[],p=r==null?void 0:r.content,h=((S=(x=(b=p==null?void 0:p.read)==null?void 0:b.objects)==null?void 0:x[t])==null?void 0:S.selectedFields)||{},m=((A=(T=(O=p==null?void 0:p.read)==null?void 0:O.objects)==null?void 0:T[t])==null?void 0:A.selectedFieldMappings)||{},v={...h},w={...m};return{allFields:u,requiredFields:i,optionalFields:a,requiredMapFields:c,selectedOptionalFields:h,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:v,requiredMapFields:w}}},id=(e,t)=>{var c,u;if(!e)return null;const r=(u=(c=t==null?void 0:t.content)==null?void 0:c.write)==null?void 0:u.objects,n=Object.keys(r||{}),i={};n.forEach(p=>{i[p]=!0});const a={...i};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:i,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:a}}};function oo(e,t,r){var a,c;const n=(a=e==null?void 0:e.content)==null?void 0:a.read,i=(c=e==null?void 0:e.content)==null?void 0:c.write;return{read:nd(n,t,r),write:id(i,r)}}const ao=(e,t,r,n)=>{const i=oo(e,r,t);n(r,i)},od=(e,t,r)=>{const n=rd(t,e),i={};n.forEach(({name:a,completed:c})=>{c&&(i[a]=oo(e,a,t))}),r(i)},so=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(td(a))),{...Array.from(n).reduce((a,c)=>({...a,[c]:!0}),{}),...r||{}}},co=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},r={};return t&&Object.keys(t).forEach(n=>{t[n]!==void 0?r[n]=t[n]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${n}`)}),r};function lo(e,t){return t[e]||void 0}function ri({createConfig:e,projectId:t,integrationId:r,groupRef:n,connectionId:i,apiKey:a,setInstallation:c,onInstallSuccess:u}){const p={projectIdOrName:t,integrationId:r,installation:{groupRef:n,connectionId:i,config:e}};return H().installationApi.createInstallation(p,{headers:{"X-Api-Key":a,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{console.error("ERROR: ",h)})}function Ar(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const ad=(e,t)=>{const r=e.content.read,n=r==null?void 0:r.objects;return n==null?void 0:n.find(i=>i.objectName===t)},sd=(e,t,r,n)=>{const i=so(e),a=co(e),c=ad(r,t);if(!c)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const u={revisionId:r.id,createdBy:`consumer:${n}`,content:{provider:r.content.provider,read:{objects:{[t]:{objectName:t,schedule:c.schedule,destination:c.destination,selectedFields:i,selectedFieldMappings:a,backfill:c.backfill}}}}};return Ar(r)&&(u.content.proxy={enabled:!0}),u},cd=(e,t,r,n,i,a,c,u,p,h,m)=>{const v=sd(p,a,u,n);return v?ri({createConfig:v,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:c,setInstallation:h,onInstallSuccess:m}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},uo=e=>{var a,c;const t={},r=(a=e.write)==null?void 0:a.writeObjects,n=(c=e.write)==null?void 0:c.selectedNonConfigurableWriteFields,i=n?Object.keys(n):[];return r&&r.forEach(u=>{const p=u.objectName;i.includes(p)&&(t[p]={objectName:p})}),t},dd=e=>{const t=e.content.write;return t==null?void 0:t.objects},ld=(e,t,r)=>{if(!dd(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=uo(e),a={revisionId:t.id,createdBy:`consumer:${r}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return Ar(t)&&(a.content.proxy={enabled:!0}),a},ud=(e,t,r,n,i,a,c,u,p,h)=>{const m=ld(u,c,n);return m?ri({createConfig:m,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setInstallation:p,onInstallSuccess:h}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))};function pd(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M14.25 4.5V15C14.25 15.3978 14.092 15.7794 13.8107 16.0607C13.5294 16.342 13.1478 16.5 12.75 16.5H5.25C4.85218 16.5 4.47064 16.342 4.18934 16.0607C3.90804 15.7794 3.75 15.3978 3.75 15V4.5M6 4.5V3C6 2.60218 6.15804 2.22064 6.43934 1.93934C6.72064 1.65804 7.10218 1.5 7.5 1.5H10.5C10.8978 1.5 11.2794 1.65804 11.5607 1.93934C11.842 2.22064 12 2.60218 12 3V4.5",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const po="uninstall-installation",fd=I.forwardRef(({text:e="Uninstall"},t)=>{const r=y.useTab({ref:t}),n=y.useMultiStyleConfig("Tabs",r);return s.jsxs(y.Button,{__css:n.warningTab,...r,minHeight:15,children:[s.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[pd(),s.jsx(y.Box,{textAlign:"left",children:s.jsx(y.Text,{color:"red.800",children:e})})]}),r.children]})}),fo=I.createContext({hydratedRevision:null,loading:!1}),Xt=()=>{const e=I.useContext(fo);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function hd({projectId:e,children:t}){var P;const{selectedConnection:r}=xt(),{integrationId:n,integrationObj:i}=Ne(),[a,c]=I.useState(null),[u,p]=I.useState(!0),{isError:h,removeError:m,setError:v}=We(),w=ee(),b=r==null?void 0:r.id,x=(P=i==null?void 0:i.latestRevision)==null?void 0:P.id,S=(i==null?void 0:i.name)||n;I.useEffect(()=>{e&&n&&x&&b&&w&&H().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:n,revisionId:x,connectionId:b},{headers:{"X-Api-Key":w??""}}).then($=>{c($),p(!1),m(V.HYDRATED_REVISION,S)}).catch($=>{console.error(`Error loading integration ${S}`,$),p(!1),v(V.HYDRATED_REVISION,S)})},[e,n,x,b,w,m,v,S]);const O=I.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),A=`Error retrieving integration details for '${(i==null?void 0:i.name)||n||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return s.jsx(fo.Provider,{value:O,children:h(V.HYDRATED_REVISION,S)?s.jsx(Fe,{message:A}):t})}var ho=Symbol.for("immer-nothing"),mi=Symbol.for("immer-draftable"),de=Symbol.for("immer-state"),gd=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function se(e,...t){if(process.env.NODE_ENV!=="production"){const r=gd[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var bt=Object.getPrototypeOf;function St(e){return!!e&&!!e[de]}function ot(e){var t;return e?go(e)||Array.isArray(e)||!!e[mi]||!!((t=e.constructor)!=null&&t[mi])||kr(e)||Er(e):!1}var md=Object.prototype.constructor.toString();function go(e){if(!e||typeof e!="object")return!1;const t=bt(e);if(t===null)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===md}function Or(e,t){jr(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function jr(e){const t=e[de];return t?t.type_:Array.isArray(e)?1:kr(e)?2:Er(e)?3:0}function $n(e,t){return jr(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function mo(e,t,r){const n=jr(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function yd(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kr(e){return e instanceof Map}function Er(e){return e instanceof Set}function tt(e){return e.copy_||e.base_}function qn(e,t){if(kr(e))return new Map(e);if(Er(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=go(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[de];let i=Reflect.ownKeys(n);for(let a=0;a<i.length;a++){const c=i[a],u=n[c];u.writable===!1&&(u.writable=!0,u.configurable=!0),(u.get||u.set)&&(n[c]={configurable:!0,writable:!0,enumerable:u.enumerable,value:e[c]})}return Object.create(bt(e),n)}else{const n=bt(e);if(n!==null&&r)return{...e};const i=Object.create(n);return Object.assign(i,e)}}function ni(e,t=!1){return Fr(e)||St(e)||!ot(e)||(jr(e)>1&&(e.set=e.add=e.clear=e.delete=wd),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>ni(n,!0))),e}function wd(){se(2)}function Fr(e){return Object.isFrozen(e)}var Id={};function at(e){const t=Id[e];return t||se(0,e),t}var Jt;function yo(){return Jt}function vd(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yi(e,t){t&&(at("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Wn(e){zn(e),e.drafts_.forEach(bd),e.drafts_=null}function zn(e){e===Jt&&(Jt=e.parent_)}function wi(e){return Jt=vd(Jt,e)}function bd(e){const t=e[de];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ii(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[de].modified_&&(Wn(t),se(4)),ot(e)&&(e=Cr(t,e),t.parent_||Nr(t,e)),t.patches_&&at("Patches").generateReplacementPatches_(r[de].base_,e,t.patches_,t.inversePatches_)):e=Cr(t,r,[]),Wn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ho?e:void 0}function Cr(e,t,r){if(Fr(t))return t;const n=t[de];if(!n)return Or(t,(i,a)=>vi(e,n,t,i,a,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return Nr(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let a=i,c=!1;n.type_===3&&(a=new Set(i),i.clear(),c=!0),Or(a,(u,p)=>vi(e,n,i,u,p,r,c)),Nr(e,i,!1),r&&e.patches_&&at("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function vi(e,t,r,n,i,a,c){if(process.env.NODE_ENV!=="production"&&i===r&&se(5),St(i)){const u=a&&t&&t.type_!==3&&!$n(t.assigned_,n)?a.concat(n):void 0,p=Cr(e,i,u);if(mo(r,n,p),St(p))e.canAutoFreeze_=!1;else return}else c&&r.add(i);if(ot(i)&&!Fr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Cr(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Nr(e,i)}}function Nr(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ni(t,r)}function Sd(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:yo(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,a=ii;r&&(i=[n],a=Ht);const{revoke:c,proxy:u}=Proxy.revocable(i,a);return n.draft_=u,n.revoke_=c,u}var ii={get(e,t){if(t===de)return e;const r=tt(e);if(!$n(r,t))return xd(e,r,t);const n=r[t];return e.finalized_||!ot(n)?n:n===Ln(e.base_,t)?(Kn(e),e.copy_[t]=Hn(n,e)):n},has(e,t){return t in tt(e)},ownKeys(e){return Reflect.ownKeys(tt(e))},set(e,t,r){const n=wo(tt(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=Ln(tt(e),t),a=i==null?void 0:i[de];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(yd(r,i)&&(r!==void 0||$n(e.base_,t)))return!0;Kn(e),Jn(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ln(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Kn(e),Jn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=tt(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){se(11)},getPrototypeOf(e){return bt(e.base_)},setPrototypeOf(){se(12)}},Ht={};Or(ii,(e,t)=>{Ht[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ht.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&se(13),Ht.set.call(this,e,t,void 0)};Ht.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&se(14),ii.set.call(this,e[0],t,r,e[0])};function Ln(e,t){const r=e[de];return(r?tt(r):e)[t]}function xd(e,t,r){var i;const n=wo(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function wo(e,t){if(!(t in e))return;let r=bt(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=bt(r)}}function Jn(e){e.modified_||(e.modified_=!0,e.parent_&&Jn(e.parent_))}function Kn(e){e.copy_||(e.copy_=qn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Od=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const a=r;r=t;const c=this;return function(p=a,...h){return c.produce(p,m=>r.call(this,m,...h))}}typeof r!="function"&&se(6),n!==void 0&&typeof n!="function"&&se(7);let i;if(ot(t)){const a=wi(this),c=Hn(t,void 0);let u=!0;try{i=r(c),u=!1}finally{u?Wn(a):zn(a)}return yi(a,n),Ii(i,a)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===ho&&(i=void 0),this.autoFreeze_&&ni(i,!0),n){const a=[],c=[];at("Patches").generateReplacementPatches_(t,i,a,c),n(a,c)}return i}else se(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(c,...u)=>this.produceWithPatches(c,p=>t(p,...u));let n,i;return[this.produce(t,r,(c,u)=>{n=c,i=u}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ot(e)||se(8),St(e)&&(e=Cd(e));const t=wi(this),r=Hn(e,void 0);return r[de].isManual_=!0,zn(t),r}finishDraft(e,t){const r=e&&e[de];(!r||!r.isManual_)&&se(9);const{scope_:n}=r;return yi(n,t),Ii(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=at("Patches").applyPatches_;return St(e)?n(e,t):this.produce(e,i=>n(i,t))}};function Hn(e,t){const r=kr(e)?at("MapSet").proxyMap_(e,t):Er(e)?at("MapSet").proxySet_(e,t):Sd(e,t);return(t?t.scope_:yo()).drafts_.push(r),r}function Cd(e){return St(e)||se(10,e),Io(e)}function Io(e){if(!ot(e)||Fr(e))return e;const t=e[de];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=qn(e,t.scope_.immer_.useStrictShallowCopy_)}else r=qn(e,!0);return Or(r,(n,i)=>{mo(r,n,Io(i))}),t&&(t.finalized_=!1),r}var le=new Od,qt=le.produce;le.produceWithPatches.bind(le);le.setAutoFreeze.bind(le);le.setUseStrictShallowCopy.bind(le);le.applyPatches.bind(le);le.createDraft.bind(le);le.finishDraft.bind(le);const vo=I.createContext(void 0),Nd={};function oi(){const e=I.useContext(vo);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function Td({children:e}){const{installation:t}=Ne(),{hydratedRevision:r,loading:n}=Xt(),[i,a]=I.useState(Nd),c=t==null?void 0:t.config;I.useEffect(()=>{r!=null&&r.content&&!n&&c&&!(Object.entries(i).length>0)&&od(r,c,a)},[r,n,c,i]);const u=I.useCallback((b,x)=>{a(S=>qt(S,O=>{O[b]=qt(O[b],x)}))},[a]),p=I.useCallback((b,x)=>{a(S=>qt(S,O=>{O[b]=x}))},[a]),h=I.useCallback(()=>{a(qt(b=>{const x=b.other.write;x&&(x.isWriteModified=!1)}))},[a]),m=I.useCallback(b=>{a(qt(x=>{var O;const S=(O=x[b])==null?void 0:O.read;S&&(S.isOptionalFieldsModified=!1,S.isRequiredMapFieldsModified=!1)}))},[a]),v=I.useCallback(b=>{b===it?h():m(b)},[m,h]),w=I.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:v}),[i,p,v,u]);return s.jsx(vo.Provider,{value:w,children:e})}const Rd=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[s.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),s.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function _d(e,t){return t?I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},I.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Rd:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:s.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}const bo=I.forwardRef(({objectName:e,completed:t,pending:r,displayName:n},i)=>{const a=y.useTab({ref:i}),c=y.useMultiStyleConfig("Tabs",a);return s.jsxs(y.Button,{__css:c.tab,...a,variant:"outline",minHeight:15,children:[s.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[_d(t,r),s.jsxs(y.Box,{textAlign:"left",children:[s.jsx(y.Text,{children:n||e}),r&&s.jsx(y.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function Ad({pending:e,completed:t,displayName:r}){return s.jsxs(s.Fragment,{children:[s.jsx(y.Divider,{marginY:3}),s.jsx(bo,{objectName:it,completed:t,pending:e,displayName:r},"other-write")]})}const So=I.createContext(null);function xo(){const e=I.useContext(So);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function jd(e,t){return e!=null&&e[t]?e[t]:{name:po,completed:!1}}function kd({children:e}){var O,T,A;const{project:t}=Z(),{installation:r,provider:n}=Ne(),{hydratedRevision:i}=Xt(),{objectConfigurationsState:a}=oi(),[c,u]=I.useState(0),p=(t==null?void 0:t.appName)||"",h=r==null?void 0:r.config,m=i&&ro(h,i),v=m!==null,w=!!((O=i==null?void 0:i.content)!=null&&O.write),b=w?no(h):void 0,x=[...m||[]];b&&w&&x.push(b);const S=jd(x,c);return s.jsx(So.Provider,{value:S==null?void 0:S.name,children:s.jsxs(y.Box,{p:8,maxWidth:"55rem",borderRadius:4,margin:"auto",display:"flex",gap:"6",minHeight:"100%",fontSize:"md",backgroundColor:"#FCFCFC",border:"1px solid #EFEFEF",boxShadow:"0px 4px 8px rgba(0, 0, 0, 0.05)",children:[s.jsxs(y.Box,{width:"20rem",children:[s.jsxs(y.Text,{children:[st(n)," integration"]}),s.jsx(y.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),v&&s.jsxs(y.Tabs,{index:c,onChange:u,orientation:"horizontal",children:[m.map(P=>{var $,k,Q,X;return s.jsx(bo,{objectName:P.name,completed:P.completed,pending:((k=($=a[P.name])==null?void 0:$.read)==null?void 0:k.isOptionalFieldsModified)||((X=(Q=a[P.name])==null?void 0:Q.read)==null?void 0:X.isRequiredMapFieldsModified)},P.name)}),w&&b&&s.jsx(Ad,{completed:b.completed,pending:(A=(T=a==null?void 0:a.other)==null?void 0:T.write)==null?void 0:A.isWriteModified,displayName:m!=null&&m.length?"other":"write"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(y.Divider,{marginTop:10,marginBottom:3}),s.jsx(fd,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]})})}const Ot=()=>{const{appName:e}=Z(),{objectConfigurationsState:t,setConfigureState:r}=oi(),{selectedObjectName:n}=xo(),i=lo(n||"",t);return{appName:e,configureState:i,setConfigureState:r,selectedObjectName:n}};function Ed(e,t,r){var i;const n=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(n[t]=r,e!=null&&e.read){const a=e.read.savedConfig.requiredMapFields,u=!ti(a,n);e.read.isRequiredMapFieldsModified=u}}function Oo(e,t,r,n){t(e,i=>Ed(i,r,n))}function Fd({field:e,onSelectChange:t,allFields:r}){var v;const{configureState:n,selectedObjectName:i,setConfigureState:a}=Ot(),[c,u]=I.useState(!0),p=(v=n==null?void 0:n.read)==null?void 0:v.selectedFieldMappings,h=p==null?void 0:p[e.mapToName];I.useEffect(()=>{e._default&&!h&&i&&n&&Oo(i,a,e.mapToName,e._default),u(!1)},[e,a,i,h,n]);const m=I.useMemo(()=>r==null?void 0:r.map(w=>s.jsx("option",{value:w.fieldName,children:w.displayName},w.fieldName)),[r]);return s.jsxs(y.Stack,{children:[s.jsx(y.Text,{fontWeight:"500",children:e.mapToDisplayName}),s.jsx(y.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),s.jsx(y.Select,{name:e.mapToName,variant:"flushed",value:h||void 0,onChange:t,placeholder:h?void 0:"Please select one",disabled:c,children:m})]},e.mapToName)}function Pr({string:e}){return s.jsxs(y.Flex,{position:"relative",paddingTop:8,paddingBottom:4,children:[s.jsx(y.Heading,{color:"gray.500",as:"h3",fontSize:16,fontWeight:"500",children:e}),s.jsx(y.Flex,{flex:"1",justifyContent:"flex-end",alignItems:"center",children:s.jsx(y.Divider,{marginLeft:2})})]})}function Pd(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Ot(),{isError:n,removeError:i}=We(),a=u=>{const{value:p,name:h}=u.target;p&&(e&&Oo(e,r,h,p),n(V.MAPPING,h)&&i(V.MAPPING,h))},c=I.useMemo(()=>{var u,p;return((p=(u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)==null?void 0:p.filter(qe))||[]},[t]);return c.length?s.jsxs(y.Box,{children:[s.jsx(Pr,{string:"Map the following fields (required)"}),s.jsx(y.Stack,{children:c.map(u=>{var p;return s.jsxs(y.FormControl,{isInvalid:n(V.MAPPING,u.mapToName),children:[s.jsx(Fd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),s.jsx(y.FormErrorMessage,{children:" * required"})]},u.mapToName)})})]}):null}function Dd(e,t,r){var i,a;const n=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(n[t]=r,r||delete n[t],(a=e.read)!=null&&a.savedConfig.optionalFields){const c=e.read.savedConfig.optionalFields,p=!ti(c,n);e.read.isOptionalFieldsModified=p}else console.warn("read.savedConfig.optionalFields is undefined")}function bi(e,t,r,n){t(e,i=>Dd(i,r,n))}function Bd(){var v,w;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Ot(),i=(v=t==null?void 0:t.read)==null?void 0:v.selectedOptionalFields,a=b=>{const{name:x,checked:S}=b.target;n&&t&&bi(n,r,x,S)},c=(w=t==null?void 0:t.read)==null?void 0:w.optionalFields,u=b=>{const{checked:x}=b.target;n&&c&&c.forEach(S=>{qe(S)||bi(n,r,S.fieldName,x)})},p=!!(c&&c.length>0),h=Object.keys(i||{}).length===(c==null?void 0:c.length),m=!h&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${e} reads the following optional fields`}),s.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((c==null?void 0:c.length)||0)>=2&&s.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:h,children:"Select all"})}),c.map(b=>qe(b)?null:s.jsx(y.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:s.jsx(y.Checkbox,{name:b.fieldName,id:b.fieldName,isChecked:!!(i!=null&&i[b==null?void 0:b.fieldName]),onChange:a,children:b.displayName})},b.fieldName))]})]})}function Ld(){var n,i,a;const{configureState:e,selectedObjectName:t}=Ot(),{appName:r}=Z();return s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${r} reads the following ${t} fields`}),s.jsx(y.Box,{marginBottom:"20px",display:"flex",gap:1,children:(i=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&i.length?(a=e.read)==null?void 0:a.requiredFields.map(c=>qe(c)?null:s.jsx(y.Tag,{children:c.displayName},c.fieldName)):"There are no required fields."})]})}function Kd(){return s.jsxs(s.Fragment,{children:[s.jsx(Ld,{}),s.jsx(Pd,{}),s.jsx(Bd,{})]})}function Md(e,t,r){var n,i,a;if(((n=e==null?void 0:e.write)==null?void 0:n.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const c=e.write.selectedNonConfigurableWriteFields;if(c[t]=r,r||delete c[t],(a=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&a.selectedNonConfigurableWriteFields){const u=e.write.savedConfig.selectedNonConfigurableWriteFields,h=!ti(u,c);e.write.isWriteModified=h}}}function Si(e,t,r,n){t(e,i=>{Md(i,r,n)})}function Ud(){var v,w,b,x;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Ot(),i=(v=r==null?void 0:r.write)==null?void 0:v.selectedNonConfigurableWriteFields,a=(w=r==null?void 0:r.write)==null?void 0:w.writeObjects,c=S=>{const{name:O,checked:T}=S.target;t&&r&&Si(t,n,O,T)},u=S=>{var T,A;const{checked:O}=S.target;t&&r&&((A=(T=r==null?void 0:r.write)==null?void 0:T.writeObjects)==null||A.forEach(P=>{Si(t,n,P.objectName,O)}))},p=!!a,h=Object.keys(i||{}).length===((x=(b=r==null?void 0:r.write)==null?void 0:b.writeObjects)==null?void 0:x.length),m=!h&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`Allow ${e} to write to these object`}),s.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((a==null?void 0:a.length)||0)>=2&&s.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:h,children:"Select all"})}),a.map(S=>s.jsx(y.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:S.objectName,id:S.objectName,onChange:c,isChecked:!!(i!=null&&i[S.objectName]),children:S.displayName})},S.objectName))]})]})}function $d(){const e=ee(),{projectId:t,appName:r}=Z(),{integrationId:n,installation:i,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:u}=Ne(),[p,h]=I.useState(!1),m=!t||!n||!(i!=null&&i.id)||p,v=async()=>{if(!m){h(!0),console.warn("uninstalling installation",{projectId:t,integrationId:n,installationId:i.id});try{await H().installationApi.deleteInstallation({projectIdOrName:t,integrationId:n,installationId:i.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation: ",i.id),u==null||u(i==null?void 0:i.id),a(),c()}catch(x){console.error("error uninstalling installation",x)}finally{h(!1)}}},w=p?"Uninstalling...":"Yes, uninstall",b=i!=null&&i.id?`Once you uninstall this integration, all your configuration will be lost, and "${r}" may stop working.`:"You've successfully uninstalled the integration.";return s.jsxs(y.Stack,{children:[s.jsx(y.Text,{paddingBottom:3,children:b}),(i==null?void 0:i.id)&&s.jsx(y.Button,{onClick:v,variant:"warning",isDisabled:m,children:w})]})}function Co({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1}){var P,$,k;const{installation:i}=Ne(),{hydratedRevision:a,loading:c}=Xt(),{configureState:u,selectedObjectName:p}=Ot(),h=i==null?void 0:i.config,m=h&&p&&!!to(h,p)||!1,v=((P=u==null?void 0:u.read)==null?void 0:P.isOptionalFieldsModified)||(($=u==null?void 0:u.read)==null?void 0:$.isRequiredMapFieldsModified),w=(k=u==null?void 0:u.write)==null?void 0:k.isWriteModified,O=c||r||!u||!p||!(v||w||n||p!==it&&!m),T=p===it,A=p===po;return r?s.jsx(Ce,{}):s.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[s.jsxs(y.Stack,{direction:"row",spacing:4,marginBottom:"20px",flexDir:"row-reverse",children:[s.jsx(y.Button,{variant:"primary",type:"submit",isDisabled:O,children:n?"Install":"Save"}),s.jsx(y.Button,{isDisabled:O,onClick:t,children:"Reset"})]}),s.jsxs(y.Box,{p:8,borderRadius:4,boxShadow:"sm",margin:"auto",backgroundColor:"white",border:"1px solid gray.100",minHeight:300,children:[c&&s.jsx(Ce,{}),a&&!A&&!T&&s.jsx(Kd,{}),a&&!A&&T&&s.jsx(Ud,{}),!c&&A&&s.jsx($d,{})]})]})}const No=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:i,onUpdateSuccess:a}=Ne(),{hydratedRevision:c,loading:u}=Xt(),{selectedObjectName:p}=xo(),{selectedConnection:h}=xt(),m=ee(),{projectId:v}=Z(),{resetBoundary:w,setErrors:b}=We(),{resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O}=oi(),T=lo(p||"",S);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:c,loading:u,selectedObjectName:p,selectedConnection:h,apiKey:m,projectId:v,resetBoundary:w,setErrors:b,resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O,configureState:T,onInstallSuccess:i,onUpdateSuccess:a}},qd=void 0;function Wd(){const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:i,loading:a,selectedObjectName:c,selectedConnection:u,apiKey:p,projectId:h,resetBoundary:m,setErrors:v,resetConfigureState:w,objectConfigurationsState:b,resetPendingConfigurationState:x,configureState:S,onInstallSuccess:O}=No(),[T,A]=I.useState(!1),P=c===it,$=I.useCallback(()=>{m(V.MAPPING),i!=null&&i.content&&!a&&c&&ao(i,qd,c,w)},[m,i,a,c,w]);I.useEffect(()=>{!S&&(i!=null&&i.content)&&!a&&$()},[S,b,i,a,$]);const k=()=>{const{requiredMapFields:te,selectedFieldMappings:J}=(S==null?void 0:S.read)||{},{errorList:Y}=io(te,J,v);Y.length>0||(c&&(u!=null&&u.id)&&p&&h&&e&&t&&r&&i?(A(!0),cd(h,e,t,r,u.id,c,p,i,S,n,O).finally(()=>{A(!1),x(c)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},Q=()=>{c&&(u!=null&&u.id)&&p&&h&&e&&t&&r&&i?(A(!0),ud(h,e,t,r,u.id,p,i,S,n,O).finally(()=>{A(!1),x(c)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},X=te=>{te.preventDefault(),P?Q():k()};return s.jsx(Co,{isCreateMode:!0,isLoading:T,onSave:X,onReset:$})}function zd({updateConfig:e,projectId:t,integrationId:r,installationId:n,apiKey:i,selectedObjectName:a,setInstallation:c,onUpdateSuccess:u}){const p={projectIdOrName:t,installationId:n,integrationId:r,installationUpdate:{updateMask:[`config.content.read.objects.${a}`],installation:{config:e}}};return H().installationApi.updateInstallation(p,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{console.error("ERROR: ",h)})}const Jd=(e,t,r,n,i,a)=>{const c=so(e),u=co(e),p={content:{read:{objects:{[t]:{objectName:t,schedule:n,destination:(r==null?void 0:r.destination)||"",selectedFields:c,selectedFieldMappings:u,backfill:a}}}}};return Ar(i)&&(p.content||(p.content={}),p.content.proxy={enabled:!0}),p},Hd=(e,t,r,n,i,a,c,u,p,h)=>{const m=Jd(a,n||"",u,u.schedule,p,u.backfill);return m?zd({updateConfig:m,projectId:e,integrationId:t,installationId:r,apiKey:i,selectedObjectName:n,setInstallation:c,onUpdateSuccess:h}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Xd=(e,t)=>{const n={content:{write:{objects:uo(e)}}};return Ar(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},Gd=(e,t,r,n,i,a,c,u)=>{const p=Xd(i,a);if(!p)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const h={projectIdOrName:e,installationId:r,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:p}}};return H().installationApi.updateInstallation(h,{headers:{"X-Api-Key":n,"Content-Type":"application/json"}}).then(m=>{c(m),u==null||u(m.id,m.config)}).catch(m=>{console.error("ERROR: ",m)})};function Vd({installation:e,integrationObj:t}){const{setInstallation:r,hydratedRevision:n,loading:i,selectedObjectName:a,apiKey:c,projectId:u,resetBoundary:p,setErrors:h,resetConfigureState:m,resetPendingConfigurationState:v,configureState:w,onUpdateSuccess:b}=No(),[x,S]=I.useState(!1),O=a===it,{config:T}=e,A=I.useCallback(()=>{p(V.MAPPING),n!=null&&n.content&&!i&&a&&ao(n,T,a,m)},[p,n,i,a,T,m]);I.useEffect(()=>{w||A()},[w,A]),I.useEffect(()=>{e&&A()},[e,A]);const P=I.useMemo(()=>{var te,J,Y;return(Y=(J=(te=n==null?void 0:n.content)==null?void 0:te.read)==null?void 0:J.objects)==null?void 0:Y.find(Te=>(Te==null?void 0:Te.objectName)===a)},[n,a]),$=()=>{const{requiredMapFields:X,selectedFieldMappings:te}=(w==null?void 0:w.read)||{},{errorList:J}=io(X,te,h);J.length>0||(n&&e&&a&&c&&u&&P?(S(!0),Hd(u,t.id,e.id,a,c,w,r,P,n,b).finally(()=>{S(!1),v(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},k=()=>{e&&a&&c&&u&&n?(S(!0),Gd(u,t.id,e.id,c,w,n,r,b).finally(()=>{S(!1),v(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},Q=X=>{X.preventDefault(),O?k():$()};return s.jsx(Co,{onSave:Q,onReset:A,isLoading:x})}function Yd(){const{integrationObj:e,installation:t}=Ne();return e?t&&e?s.jsx(Vd,{installation:t,integrationObj:e}):s.jsx(Wd,{}):s.jsx(Fe,{message:"We can't load the integration"})}function Zd(){return s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),s.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ai({text:e}){return s.jsx(y.Container,{children:s.jsxs(y.Box,{p:8,maxWidth:"600px",minHeight:"290px",borderWidth:1,borderRadius:8,boxShadow:"lg",margin:"auto",marginTop:"40px",bgColor:"white",paddingTop:"100px",color:"gray.800",fontSize:"md",children:[s.jsx(y.Box,{width:"100%",display:"flex",alignContent:"center",justifyContent:"center",children:s.jsx(y.Box,{margin:"auto",children:s.jsx(Zd,{})})}),s.jsx(y.Box,{textAlign:"center",paddingTop:"25px",children:e})]})})}const Qd=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function el({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:i,apiKey:a,hydratedRevision:c,setInstallation:u,onInstallSuccess:p}){const h=Qd(c,n);return h?ri({createConfig:h,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setInstallation:u,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function tl({provider:e}){const t=`You have successfully installed your ${st(e)} integration.`;return s.jsx(ai,{text:t})}const rl=e=>{const{read:t,write:r,proxy:n}=(e==null?void 0:e.content)??{};return!t&&!r&&(n==null?void 0:n.enabled)||!1};function nl({children:e}){var A;const{projectId:t}=Z(),r=ee(),{hydratedRevision:n,loading:i}=Xt(),{integrationObj:a,installation:c,groupRef:u,consumerRef:p,setInstallation:h,onInstallSuccess:m,isIntegrationDeleted:v}=Ne(),{selectedConnection:w}=xt(),[b,x]=I.useState(!1),S=i||b,O=(A=n==null?void 0:n.content)==null?void 0:A.provider,T=rl(n);return I.useEffect(()=>{!S&&n&&T&&!c&&w&&r&&(a!=null&&a.id)&&(x(!0),el({apiKey:r,projectId:t,integrationId:a==null?void 0:a.id,groupRef:u,consumerRef:p,connectionId:w==null?void 0:w.id,hydratedRevision:n,setInstallation:h,onInstallSuccess:m}).then(()=>{x(!1)}).catch(P=>{x(!1),console.error("Error when creating proxy installation:",P)}))},[n,T,c,w,r,t,a==null?void 0:a.id,u,p,h,S,m]),a?S?s.jsx(Ce,{}):T&&O&&c?s.jsx(tl,{provider:O}):v?s.jsx(ai,{text:"Integration successfully uninstalled."}):s.jsx("div",{children:e}):s.jsx(Fe,{message:"We can't load the integration"})}function il({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function ol({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function To({url:e,providerDisplayName:t,credentialName:r}){return s.jsxs(y.Text,{align:"left",color:"darkgray",children:[s.jsx(y.Link,{href:e,target:"_blank",rel:"noreferrer",color:"blackAlpha.600",isExternal:!0,children:s.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",r,"."]})}function al({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var S;const[a,c]=I.useState(!1),u=()=>c(!a),[p,h]=I.useState(""),m=O=>h(O.currentTarget.value),v=p.length>0,w=i||!v,b=st(e,t),x=(S=t.apiKeyOpts)==null?void 0:S.docsURL;return s.jsx(il,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{my:"6",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${b} integration`})}),s.jsx(ol,{error:n}),s.jsxs(y.Stack,{spacing:4,children:[x&&s.jsx(To,{url:x,providerDisplayName:b,credentialName:"API key"}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:m,pr:"4.5rem",type:a?"text":"password",placeholder:"API Key"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:w,width:"100%",type:"submit",onClick:()=>{r(p)},children:"Next"})]})})}function sl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:c,selectedConnection:u,setSelectedConnection:p}){const h=Z(),[m,v]=I.useState(!1),[w,b]=I.useState(null),x=ee();I.useEffect(()=>{if(e&&H&&m&&w!=null){const O={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,apiKey:w};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:O},{headers:{"X-Api-Key":x??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info: ",T)})}},[x,e,m,n,r,a,i,h,p,w]);const S=O=>{b(O),v(!0)};return u===null?s.jsx(al,{provider:e,providerInfo:t,handleSubmit:S,error:null}):c}function cl({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:4,margin:"auto",marginTop:"40px",fontSize:"md",children:e})})}function dl({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function ll({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var A;const[a,c]=I.useState(!1),u=()=>c(!a),[p,h]=I.useState(""),[m,v]=I.useState(""),w=P=>h(P.currentTarget.value),b=P=>v(P.currentTarget.value),x=st(e,t),S=(A=t.basicOpts)==null?void 0:A.docsURL,O=p.length>0,T=i||!O;return s.jsx(cl,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${x} integration`})}),s.jsx(dl,{error:n}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[S&&s.jsx(To,{url:S,providerDisplayName:x,credentialName:"credentials"}),s.jsx(y.Input,{placeholder:"Username",onChange:w}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:b,pr:"4.5rem",type:a?"text":"password",placeholder:"Password"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:T,width:"100%",type:"submit",onClick:()=>{r(p,m)},children:"Next"})]})})}function ul({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:c,selectedConnection:u,setSelectedConnection:p}){const h=Z(),[m,v]=I.useState(!1),[w,b]=I.useState(null),x=ee();I.useEffect(()=>{if(e&&H&&m&&w!=null){const O={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,basicAuth:{username:w.user,password:w.pass}};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:O},{headers:{"X-Api-Key":x??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info: ",T)})}},[x,e,m,n,r,a,i,h,w,p]);const S=(O,T)=>{b({user:O,pass:T}),v(!0)};return u===null?s.jsx(ll,{provider:e,providerInfo:t,handleSubmit:S,error:null}):c}function pl(e){const{selectedConnection:t}=xt();I.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function fl({onSuccess:e}){pl(e)}function hl({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function gl({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function ml({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(hl,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(gl,{error:t}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function yl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,selectedConnection:c,setSelectedConnection:u,providerName:p}){const h=Z(),m=ee(),[v,w]=I.useState(!1);I.useEffect(()=>{if(e&&H&&v){const x={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:x},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(S=>{u(S)}).catch(S=>{console.error("Error loading provider info: ",S)})}},[m,e,v,r,t,i,n,u,h]);const b=()=>{w(!0)};return c===null?s.jsx(ml,{handleSubmit:b,error:null,providerName:p}):a}function Gt({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function Vt({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function wl({handleSubmit:e,error:t,explicitScopesRequired:r,isButtonDisabled:n,providerName:i}){const[a,c]=I.useState(!1),[u,p]=I.useState(""),[h,m]=I.useState(""),[v,w]=I.useState(""),b=()=>c(!a),x=k=>p(k.currentTarget.value),S=k=>m(k.currentTarget.value),O=k=>w(k.currentTarget.value),T=u.length>0,A=h.length>0,P=n||!T||!A,$=()=>{const k={clientId:h,clientSecret:u};r&&v.length>0&&(k.scopes=Yi(v)),e(k)};return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${i} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[s.jsx(y.Input,{placeholder:"Client ID",onChange:S}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:x,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:b,children:a?"Hide":"Show"})})]}),r&&s.jsx(y.Textarea,{placeholder:"Scopes separated by new line",onChange:O})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:P,width:"100%",type:"submit",onClick:$,children:"Next"})]})})}function Il({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,explicitScopesRequired:a,providerName:c,selectedConnection:u,setSelectedConnection:p}){const{projectId:h}=Z(),m=ee(),[v,w]=I.useState(null),b=async x=>{w(null);const S={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};H().connectionApi.generateConnection({projectIdOrName:h,generateConnectionParams:S},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(O=>{p(O)}).catch(O=>{console.error("Error loading provider info: ",O),w("Error loading provider info")})};return u===null?s.jsx(wl,{providerName:c,handleSubmit:b,error:v,explicitScopesRequired:a}):s.jsx(Ce,{})}const Ro=async(e,t,r,n,i,a,c,u)=>{var h;const p=await H().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":n??""}});if(!p)throw new Error(`Provider ${i} not found`);if(p.authType==="oauth2"&&((h=p.oauth2Opts)==null?void 0:h.grantType)==="authorizationCode"){const v=(await H().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":n??""}})).find(S=>S.provider===i),w=st(i,p);if(!v)throw new Error(`You must first set up a ${w} Provider App using the Ampersand Console.`);const b={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:c,providerAppId:v.id,provider:i}};return await H().oAuthApi.oauthConnect(b)}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},xi=600,Oi=600,vl="AUTHORIZATION_SUCCEEDED",bl="AUTHORIZATION_FAILED";function Sl(e,t,r){return I.useCallback(async n=>{const i=await H().connectionApi.getConnection({projectIdOrName:e,connectionId:n},{headers:{"X-Api-Key":t??""}});r(i)},[e,t,r])}function xl(e,t,r,n){return I.useCallback(()=>{if(!n)return;const i=window.screenX+(window.outerWidth-xi)/2,a=window.screenY+(window.outerHeight-Oi)/2.5,c=`width=${xi},height=${Oi},left=${i},top=${a}`,u=window.open(n,e,c);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function Ol(e){return I.useCallback(t=>{var r;if(t.origin===Lc){if(t.data.eventType===vl){const n=(r=t.data.data)==null?void 0:r.connection;n?e(n):console.error("Connection ID not found in event data: ",{event:t})}t.data.eventType===bl&&console.error("OAuth failed: ",{event:t})}},[e])}function _o({children:e,oauthUrl:t,windowTitle:r="Connect to Provider",onClose:n}){const i=ee(),{projectId:a}=Z(),[c,u]=I.useState(null),[p,h]=I.useState(null),{setSelectedConnection:m}=xt(),v=Ol(u),w=xl(r,h,v,t),b=Sl(a,i,m);I.useEffect(()=>{t&&!p&&w()},[t,p,w,v,r]),I.useEffect(()=>{c&&b(c).then(()=>{p==null||p.close()}).catch(S=>{console.error("Error refreshing connection: ",S),n(S.message??"Unexpected error: not able to refresh connection")})},[c,i,m,b,p,n]);const x=p&&setInterval(()=>{(p!=null&&p.closed||!p)&&x&&(clearInterval(x),window.removeEventListener("message",v),h(null),c?c&&n&&n(null):(console.error("OAuth failed. Please try again."),n&&n("OAuth failed. Please try again.")))},500);return s.jsx("div",{children:e})}function Cl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Nl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:c}=Z(),u=ee(),[p,h]=I.useState(null),[m,v]=I.useState(null),w=async()=>{v(null);try{const x=await Ro(c,t,n,u,e,void 0,r,i);h(x)}catch(x){console.error("Could not fetch OAuth popup URL",{err:x}),v(x.message??"Unexpected error")}},b=I.useCallback(x=>{v(x),h(null)},[]);return s.jsx(_o,{windowTitle:`Connect to ${a}`,oauthUrl:p,onClose:b,children:s.jsx(Cl,{handleSubmit:w,error:m,providerName:a})})}function Tl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n,explicitScopesRequired:i}){const[a,c]=I.useState(!1),[u,p]=I.useState(""),[h,m]=I.useState(""),[v,w]=I.useState(""),[b,x]=I.useState(""),S=()=>c(!a),O=J=>p(J.currentTarget.value),T=J=>m(J.currentTarget.value),A=J=>w(J.currentTarget.value),P=J=>x(J.currentTarget.value),$=u.length>0,k=h.length>0,Q=v.length>0,X=r||!$||!k||!Q,te=()=>{const J={workspace:v,clientId:h,clientSecret:u};i&&b.length>0&&(J.scopes=Yi(b)),e(J)};return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[s.jsx(y.Input,{placeholder:"MyWorkspace",onChange:A}),s.jsx(y.Input,{placeholder:"Client ID",onChange:T}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:O,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:S,children:a?"Hide":"Show"})})]}),i&&s.jsx(y.Textarea,{placeholder:"Scopes separated by new line",onChange:P})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:X,width:"100%",type:"submit",onClick:te,children:"Next"})]})})}function Rl({provider:e,providerName:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:c,selectedConnection:u,setSelectedConnection:p}){const{projectId:h}=Z(),m=ee(),[v,w]=I.useState(null),b=async x=>{w(null);const S={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,providerWorkspaceRef:x.workspace,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};H().connectionApi.generateConnection({projectIdOrName:h,generateConnectionParams:S},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(O=>{p(O)}).catch(O=>{console.error("Error loading provider info: ",O),w("Error loading provider info")})};return u===null?s.jsx(Tl,{providerName:t,handleSubmit:b,error:v,explicitScopesRequired:c}):s.jsx(Ce,{})}function _l(){const e=I.useContext(Uo.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var Ao=I.createContext({});Ao.displayName="ColorModeContext";function jo(){const e=I.useContext(Ao);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function Al(){const e=jo(),t=_l();return{...e,theme:t}}var jl=(...e)=>e.filter(Boolean).join(" ");function nt(e){const t=typeof e;return e!=null&&(t==="object"||t==="function")&&!Array.isArray(e)}function rt(e,...t){return kl(e)?e(...t):e}var kl=e=>typeof e=="function",Tr={exports:{}};Tr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=800,a=16,c=9007199254740991,u="[object Arguments]",p="[object Array]",h="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",w="[object Error]",b="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",T="[object Null]",A="[object Object]",P="[object Proxy]",$="[object RegExp]",k="[object Set]",Q="[object String]",X="[object Undefined]",te="[object WeakMap]",J="[object ArrayBuffer]",Y="[object DataView]",Te="[object Float32Array]",ct="[object Float64Array]",Br="[object Int8Array]",Lr="[object Int16Array]",Kr="[object Int32Array]",Mr="[object Uint8Array]",Ur="[object Uint8ClampedArray]",$r="[object Uint16Array]",qr="[object Uint32Array]",Wr=/[\\^$.*+?()[\]{}|]/g,zr=/^\[object .+?Constructor\]$/,Jr=/^(?:0|[1-9]\d*)$/,M={};M[Te]=M[ct]=M[Br]=M[Lr]=M[Kr]=M[Mr]=M[Ur]=M[$r]=M[qr]=!0,M[u]=M[p]=M[J]=M[m]=M[Y]=M[v]=M[w]=M[b]=M[S]=M[O]=M[A]=M[$]=M[k]=M[Q]=M[te]=!1;var Yt=typeof $e=="object"&&$e&&$e.Object===Object&&$e,U=typeof self=="object"&&self&&self.Object===Object&&self,De=Yt||U||Function("return this")(),Zt=t&&!t.nodeType&&t,oe=Zt&&!0&&e&&!e.nodeType&&e,Ct=oe&&oe.exports===Zt,dt=Ct&&Yt.process,Nt=function(){try{var o=oe&&oe.require&&oe.require("util").types;return o||dt&&dt.binding&&dt.binding("util")}catch{}}(),lt=Nt&&Nt.isTypedArray;function Qt(o,d,f){switch(f.length){case 0:return o.call(d);case 1:return o.call(d,f[0]);case 2:return o.call(d,f[0],f[1]);case 3:return o.call(d,f[0],f[1],f[2])}return o.apply(d,f)}function er(o,d){for(var f=-1,C=Array(o);++f<o;)C[f]=d(f);return C}function Hr(o){return function(d){return o(d)}}function Xr(o,d){return o==null?void 0:o[d]}function Gr(o,d){return function(f){return o(d(f))}}var Vr=Array.prototype,Yr=Function.prototype,ut=Object.prototype,Tt=De["__core-js_shared__"],pt=Yr.toString,be=ut.hasOwnProperty,tr=function(){var o=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),rr=ut.toString,Zr=pt.call(Object),ft=RegExp("^"+pt.call(be).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Be=Ct?De.Buffer:void 0,Rt=De.Symbol,ce=De.Uint8Array;Be&&Be.allocUnsafe;var _t=Gr(Object.getPrototypeOf,Object),At=Object.create,Qr=ut.propertyIsEnumerable,nr=Vr.splice,ue=Rt?Rt.toStringTag:void 0,ze=function(){try{var o=Dt(Object,"defineProperty");return o({},"",{}),o}catch{}}(),ir=Be?Be.isBuffer:void 0,or=Math.max,Re=Date.now,jt=Dt(De,"Map"),Je=Dt(Object,"create"),en=function(){function o(){}return function(d){if(!Ae(d))return{};if(At)return At(d);o.prototype=d;var f=new o;return o.prototype=void 0,f}}();function ge(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function He(){this.__data__=Je?Je(null):{},this.size=0}function kt(o){var d=this.has(o)&&delete this.__data__[o];return this.size-=d?1:0,d}function Et(o){var d=this.__data__;if(Je){var f=d[o];return f===n?void 0:f}return be.call(d,o)?d[o]:void 0}function Ft(o){var d=this.__data__;return Je?d[o]!==void 0:be.call(d,o)}function Xe(o,d){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=Je&&d===void 0?n:d,this}ge.prototype.clear=He,ge.prototype.delete=kt,ge.prototype.get=Et,ge.prototype.has=Ft,ge.prototype.set=Xe;function me(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function tn(){this.__data__=[],this.size=0}function rn(o){var d=this.__data__,f=ht(d,o);if(f<0)return!1;var C=d.length-1;return f==C?d.pop():nr.call(d,f,1),--this.size,!0}function nn(o){var d=this.__data__,f=ht(d,o);return f<0?void 0:d[f][1]}function on(o){return ht(this.__data__,o)>-1}function ar(o,d){var f=this.__data__,C=ht(f,o);return C<0?(++this.size,f.push([o,d])):f[C][1]=d,this}me.prototype.clear=tn,me.prototype.delete=rn,me.prototype.get=nn,me.prototype.has=on,me.prototype.set=ar;function Se(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function _e(){this.size=0,this.__data__={hash:new ge,map:new(jt||me),string:new ge}}function an(o){var d=yt(this,o).delete(o);return this.size-=d?1:0,d}function sn(o){return yt(this,o).get(o)}function cn(o){return yt(this,o).has(o)}function dn(o,d){var f=yt(this,o),C=f.size;return f.set(o,d),this.size+=f.size==C?0:1,this}Se.prototype.clear=_e,Se.prototype.delete=an,Se.prototype.get=sn,Se.prototype.has=cn,Se.prototype.set=dn;function Le(o){var d=this.__data__=new me(o);this.size=d.size}function ye(){this.__data__=new me,this.size=0}function ln(o){var d=this.__data__,f=d.delete(o);return this.size=d.size,f}function un(o){return this.__data__.get(o)}function pn(o){return this.__data__.has(o)}function fn(o,d){var f=this.__data__;if(f instanceof me){var C=f.__data__;if(!jt||C.length<r-1)return C.push([o,d]),this.size=++f.size,this;f=this.__data__=new Se(C)}return f.set(o,d),this.size=f.size,this}Le.prototype.clear=ye,Le.prototype.delete=ln,Le.prototype.get=un,Le.prototype.has=pn,Le.prototype.set=fn;function hn(o,d){var f=Ie(o),C=!f&&Lt(o),R=!f&&!C&&Ze(o),j=!f&&!C&&!R&&Mt(o),D=f||C||R||j,E=D?er(o.length,String):[],F=E.length;for(var q in o)D&&(q=="length"||R&&(q=="offset"||q=="parent")||j&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||Bt(q,F))||E.push(q);return E}function we(o,d,f){(f!==void 0&&!wt(o[d],f)||f===void 0&&!(d in o))&&Pt(o,d,f)}function gn(o,d,f){var C=o[d];(!(be.call(o,d)&&wt(C,f))||f===void 0&&!(d in o))&&Pt(o,d,f)}function ht(o,d){for(var f=o.length;f--;)if(wt(o[f][0],d))return f;return-1}function Pt(o,d,f){d=="__proto__"&&ze?ze(o,d,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[d]=f}var mn=dr();function gt(o){return o==null?o===void 0?X:T:ue&&ue in Object(o)?Cn(o):_n(o)}function Ge(o){return Me(o)&&gt(o)==u}function yn(o){if(!Ae(o)||lr(o))return!1;var d=Kt(o)?ft:zr;return d.test(En(o))}function wn(o){return Me(o)&&vt(o.length)&&!!M[gt(o)]}function xe(o){if(!Ae(o))return Ke(o);var d=Ye(o),f=[];for(var C in o)C=="constructor"&&(d||!be.call(o,C))||f.push(C);return f}function sr(o,d,f,C,R){o!==d&&mn(d,function(j,D){if(R||(R=new Le),Ae(j))In(o,d,D,f,sr,C,R);else{var E=C?C(pe(o,D),j,D+"",o,d,R):void 0;E===void 0&&(E=j),we(o,D,E)}},Ut)}function In(o,d,f,C,R,j,D){var E=pe(o,f),F=pe(d,f),q=D.get(F);if(q){we(o,f,q);return}var W=j?j(E,F,f+"",o,d,D):void 0,G=W===void 0;if(G){var ne=Ie(F),ie=!ne&&Ze(F),ve=!ne&&!ie&&Mt(F);W=F,ne||ie||ve?Ie(E)?W=E:Fn(E)?W=On(E):ie?(G=!1,W=Sn(F)):ve?(G=!1,W=mt(F)):W=[]:ur(F)||Lt(F)?(W=E,Lt(E)?W=Qe(E):(!Ae(E)||Kt(E))&&(W=Nn(F))):G=!1}G&&(D.set(F,W),R(W,F,C,j,D),D.delete(F)),we(o,f,W)}function vn(o,d){return jn(An(o,d,pr),o+"")}var bn=ze?function(o,d){return ze(o,"toString",{configurable:!0,enumerable:!1,value:Dn(d),writable:!0})}:pr;function Sn(o,d){return o.slice()}function xn(o){var d=new o.constructor(o.byteLength);return new ce(d).set(new ce(o)),d}function mt(o,d){var f=xn(o.buffer);return new o.constructor(f,o.byteOffset,o.length)}function On(o,d){var f=-1,C=o.length;for(d||(d=Array(C));++f<C;)d[f]=o[f];return d}function Ve(o,d,f,C){var R=!f;f||(f={});for(var j=-1,D=d.length;++j<D;){var E=d[j],F=void 0;F===void 0&&(F=o[E]),R?Pt(f,E,F):gn(f,E,F)}return f}function cr(o){return vn(function(d,f){var C=-1,R=f.length,j=R>1?f[R-1]:void 0,D=R>2?f[2]:void 0;for(j=o.length>3&&typeof j=="function"?(R--,j):void 0,D&&Tn(f[0],f[1],D)&&(j=R<3?void 0:j,R=1),d=Object(d);++C<R;){var E=f[C];E&&o(d,E,C,j)}return d})}function dr(o){return function(d,f,C){for(var R=-1,j=Object(d),D=C(d),E=D.length;E--;){var F=D[++R];if(f(j[F],F,j)===!1)break}return d}}function yt(o,d){var f=o.__data__;return Rn(d)?f[typeof d=="string"?"string":"hash"]:f.map}function Dt(o,d){var f=Xr(o,d);return yn(f)?f:void 0}function Cn(o){var d=be.call(o,ue),f=o[ue];try{o[ue]=void 0;var C=!0}catch{}var R=rr.call(o);return C&&(d?o[ue]=f:delete o[ue]),R}function Nn(o){return typeof o.constructor=="function"&&!Ye(o)?en(_t(o)):{}}function Bt(o,d){var f=typeof o;return d=d??c,!!d&&(f=="number"||f!="symbol"&&Jr.test(o))&&o>-1&&o%1==0&&o<d}function Tn(o,d,f){if(!Ae(f))return!1;var C=typeof d;return(C=="number"?It(f)&&Bt(d,f.length):C=="string"&&d in f)?wt(f[d],o):!1}function Rn(o){var d=typeof o;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?o!=="__proto__":o===null}function lr(o){return!!tr&&tr in o}function Ye(o){var d=o&&o.constructor,f=typeof d=="function"&&d.prototype||ut;return o===f}function Ke(o){var d=[];if(o!=null)for(var f in Object(o))d.push(f);return d}function _n(o){return rr.call(o)}function An(o,d,f){return d=or(d===void 0?o.length-1:d,0),function(){for(var C=arguments,R=-1,j=or(C.length-d,0),D=Array(j);++R<j;)D[R]=C[d+R];R=-1;for(var E=Array(d+1);++R<d;)E[R]=C[R];return E[d]=f(D),Qt(o,this,E)}}function pe(o,d){if(!(d==="constructor"&&typeof o[d]=="function")&&d!="__proto__")return o[d]}var jn=kn(bn);function kn(o){var d=0,f=0;return function(){var C=Re(),R=a-(C-f);if(f=C,R>0){if(++d>=i)return arguments[0]}else d=0;return o.apply(void 0,arguments)}}function En(o){if(o!=null){try{return pt.call(o)}catch{}try{return o+""}catch{}}return""}function wt(o,d){return o===d||o!==o&&d!==d}var Lt=Ge(function(){return arguments}())?Ge:function(o){return Me(o)&&be.call(o,"callee")&&!Qr.call(o,"callee")},Ie=Array.isArray;function It(o){return o!=null&&vt(o.length)&&!Kt(o)}function Fn(o){return Me(o)&&It(o)}var Ze=ir||l;function Kt(o){if(!Ae(o))return!1;var d=gt(o);return d==b||d==x||d==h||d==P}function vt(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=c}function Ae(o){var d=typeof o;return o!=null&&(d=="object"||d=="function")}function Me(o){return o!=null&&typeof o=="object"}function ur(o){if(!Me(o)||gt(o)!=A)return!1;var d=_t(o);if(d===null)return!0;var f=be.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&pt.call(f)==Zr}var Mt=lt?Hr(lt):wn;function Qe(o){return Ve(o,Ut(o))}function Ut(o){return It(o)?hn(o):xe(o)}var Pn=cr(function(o,d,f,C){sr(o,d,f,C)});function Dn(o){return function(){return o}}function pr(o){return o}function l(){return!1}e.exports=Pn})(Tr,Tr.exports);var El=Tr.exports;const Ee=ei(El);var Fl=e=>/!(important)?$/.test(e),Ci=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,Pl=(e,t)=>r=>{const n=String(t),i=Fl(n),a=Ci(n),c=e?`${e}.${a}`:a;let u=nt(r.__cssMap)&&c in r.__cssMap?r.__cssMap[c].varRef:t;return u=Ci(u),i?`${u} !important`:u};function si(e){const{scale:t,transform:r,compose:n}=e;return(a,c)=>{var u;const p=Pl(t,a)(c);let h=(u=r==null?void 0:r(p,c))!=null?u:p;return n&&(h=n(h,c)),h}}var wr=(...e)=>t=>e.reduce((r,n)=>n(r),t);function fe(e,t){return r=>{const n={property:r,scale:e};return n.transform=si({scale:e,transform:t}),n}}var Dl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function Bl(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:Dl(t),transform:r?si({scale:r,compose:n}):n}}var ko=["rotate(var(--chakra-rotate, 0))","scaleX(var(--chakra-scale-x, 1))","scaleY(var(--chakra-scale-y, 1))","skewX(var(--chakra-skew-x, 0))","skewY(var(--chakra-skew-y, 0))"];function Ll(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",...ko].join(" ")}function Kl(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",...ko].join(" ")}var Ml={"--chakra-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-sepia":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-drop-shadow":"var(--chakra-empty,/*!*/ /*!*/)",filter:["var(--chakra-blur)","var(--chakra-brightness)","var(--chakra-contrast)","var(--chakra-grayscale)","var(--chakra-hue-rotate)","var(--chakra-invert)","var(--chakra-saturate)","var(--chakra-sepia)","var(--chakra-drop-shadow)"].join(" ")},Ul={backdropFilter:["var(--chakra-backdrop-blur)","var(--chakra-backdrop-brightness)","var(--chakra-backdrop-contrast)","var(--chakra-backdrop-grayscale)","var(--chakra-backdrop-hue-rotate)","var(--chakra-backdrop-invert)","var(--chakra-backdrop-opacity)","var(--chakra-backdrop-saturate)","var(--chakra-backdrop-sepia)"].join(" "),"--chakra-backdrop-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-opacity":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-sepia":"var(--chakra-empty,/*!*/ /*!*/)"};function $l(e){return{"--chakra-ring-offset-shadow":"var(--chakra-ring-inset) 0 0 0 var(--chakra-ring-offset-width) var(--chakra-ring-offset-color)","--chakra-ring-shadow":"var(--chakra-ring-inset) 0 0 0 calc(var(--chakra-ring-width) + var(--chakra-ring-offset-width)) var(--chakra-ring-color)","--chakra-ring-width":e,boxShadow:["var(--chakra-ring-offset-shadow)","var(--chakra-ring-shadow)","var(--chakra-shadow, 0 0 #0000)"].join(", ")}}var ql={"row-reverse":{space:"--chakra-space-x-reverse",divide:"--chakra-divide-x-reverse"},"column-reverse":{space:"--chakra-space-y-reverse",divide:"--chakra-divide-y-reverse"}},Xn={"to-t":"to top","to-tr":"to top right","to-r":"to right","to-br":"to bottom right","to-b":"to bottom","to-bl":"to bottom left","to-l":"to left","to-tl":"to top left"},Wl=new Set(Object.values(Xn)),Gn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),zl=e=>e.trim();function Jl(e,t){if(e==null||Gn.has(e))return e;if(!(Vn(e)||Gn.has(e)))return`url('${e}')`;const i=/(^[a-z-A-Z]+)\((.*)\)/g.exec(e),a=i==null?void 0:i[1],c=i==null?void 0:i[2];if(!a||!c)return e;const u=a.includes("-gradient")?a:`${a}-gradient`,[p,...h]=c.split(",").map(zl).filter(Boolean);if((h==null?void 0:h.length)===0)return e;const m=p in Xn?Xn[p]:p;h.unshift(m);const v=h.map(w=>{if(Wl.has(w))return w;const b=w.indexOf(" "),[x,S]=b!==-1?[w.substr(0,b),w.substr(b+1)]:[w],O=Vn(S)?S:S&&S.split(" "),T=`colors.${x}`,A=T in t.__cssMap?t.__cssMap[T].varRef:x;return O?[A,...Array.isArray(O)?O:[O]].join(" "):A});return`${u}(${v.join(", ")})`}var Vn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Hl=(e,t)=>Jl(e,t??{});function Xl(e){return/^var\(--.+\)$/.test(e)}var Gl=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Oe=e=>t=>`${e}(${t})`,B={filter(e){return e!=="auto"?e:Ml},backdropFilter(e){return e!=="auto"?e:Ul},ring(e){return $l(B.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?Ll():e==="auto-gpu"?Kl():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=Gl(e);return t||typeof e=="number"?`${e}px`:e},fraction(e){return typeof e!="number"||e>1?e:`${e*100}%`},float(e,t){const r={left:"right",right:"left"};return t.direction==="rtl"?r[e]:e},degree(e){if(Xl(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Hl,blur:Oe("blur"),opacity:Oe("opacity"),brightness:Oe("brightness"),contrast:Oe("contrast"),dropShadow:Oe("drop-shadow"),grayscale:Oe("grayscale"),hueRotate:e=>Oe("hue-rotate")(B.degree(e)),invert:Oe("invert"),saturate:Oe("saturate"),sepia:Oe("sepia"),bgImage(e){return e==null||Vn(e)||Gn.has(e)?e:`url(${e})`},outline(e){const t=String(e)==="0"||String(e)==="none";return e!==null&&t?{outline:"2px solid transparent",outlineOffset:"2px"}:{outline:e}},flexDirection(e){var t;const{space:r,divide:n}=(t=ql[e])!=null?t:{},i={flexDirection:e};return r&&(i[r]=1),n&&(i[n]=1),i}},g={borderWidths:fe("borderWidths"),borderStyles:fe("borderStyles"),colors:fe("colors"),borders:fe("borders"),gradients:fe("gradients",B.gradient),radii:fe("radii",B.px),space:fe("space",wr(B.vh,B.px)),spaceT:fe("space",wr(B.vh,B.px)),degreeT(e){return{property:e,transform:B.degree}},prop(e,t,r){return{property:e,scale:t,...t&&{transform:si({scale:t,transform:r})}}},propT(e,t){return{property:e,transform:t}},sizes:fe("sizes",wr(B.vh,B.px)),sizesT:fe("sizes",wr(B.vh,B.fraction)),shadows:fe("shadows"),logical:Bl,blur:fe("blur",B.blur)},br={background:g.colors("background"),backgroundColor:g.colors("backgroundColor"),backgroundImage:g.gradients("backgroundImage"),backgroundSize:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundAttachment:!0,backgroundClip:{transform:B.bgClip},bgSize:g.prop("backgroundSize"),bgPosition:g.prop("backgroundPosition"),bg:g.colors("background"),bgColor:g.colors("backgroundColor"),bgPos:g.prop("backgroundPosition"),bgRepeat:g.prop("backgroundRepeat"),bgAttachment:g.prop("backgroundAttachment"),bgGradient:g.gradients("backgroundImage"),bgClip:{transform:B.bgClip}};Object.assign(br,{bgImage:br.backgroundImage,bgImg:br.backgroundImage});var L={border:g.borders("border"),borderWidth:g.borderWidths("borderWidth"),borderStyle:g.borderStyles("borderStyle"),borderColor:g.colors("borderColor"),borderRadius:g.radii("borderRadius"),borderTop:g.borders("borderTop"),borderBlockStart:g.borders("borderBlockStart"),borderTopLeftRadius:g.radii("borderTopLeftRadius"),borderStartStartRadius:g.logical({scale:"radii",property:{ltr:"borderTopLeftRadius",rtl:"borderTopRightRadius"}}),borderEndStartRadius:g.logical({scale:"radii",property:{ltr:"borderBottomLeftRadius",rtl:"borderBottomRightRadius"}}),borderTopRightRadius:g.radii("borderTopRightRadius"),borderStartEndRadius:g.logical({scale:"radii",property:{ltr:"borderTopRightRadius",rtl:"borderTopLeftRadius"}}),borderEndEndRadius:g.logical({scale:"radii",property:{ltr:"borderBottomRightRadius",rtl:"borderBottomLeftRadius"}}),borderRight:g.borders("borderRight"),borderInlineEnd:g.borders("borderInlineEnd"),borderBottom:g.borders("borderBottom"),borderBlockEnd:g.borders("borderBlockEnd"),borderBottomLeftRadius:g.radii("borderBottomLeftRadius"),borderBottomRightRadius:g.radii("borderBottomRightRadius"),borderLeft:g.borders("borderLeft"),borderInlineStart:{property:"borderInlineStart",scale:"borders"},borderInlineStartRadius:g.logical({scale:"radii",property:{ltr:["borderTopLeftRadius","borderBottomLeftRadius"],rtl:["borderTopRightRadius","borderBottomRightRadius"]}}),borderInlineEndRadius:g.logical({scale:"radii",property:{ltr:["borderTopRightRadius","borderBottomRightRadius"],rtl:["borderTopLeftRadius","borderBottomLeftRadius"]}}),borderX:g.borders(["borderLeft","borderRight"]),borderInline:g.borders("borderInline"),borderY:g.borders(["borderTop","borderBottom"]),borderBlock:g.borders("borderBlock"),borderTopWidth:g.borderWidths("borderTopWidth"),borderBlockStartWidth:g.borderWidths("borderBlockStartWidth"),borderTopColor:g.colors("borderTopColor"),borderBlockStartColor:g.colors("borderBlockStartColor"),borderTopStyle:g.borderStyles("borderTopStyle"),borderBlockStartStyle:g.borderStyles("borderBlockStartStyle"),borderBottomWidth:g.borderWidths("borderBottomWidth"),borderBlockEndWidth:g.borderWidths("borderBlockEndWidth"),borderBottomColor:g.colors("borderBottomColor"),borderBlockEndColor:g.colors("borderBlockEndColor"),borderBottomStyle:g.borderStyles("borderBottomStyle"),borderBlockEndStyle:g.borderStyles("borderBlockEndStyle"),borderLeftWidth:g.borderWidths("borderLeftWidth"),borderInlineStartWidth:g.borderWidths("borderInlineStartWidth"),borderLeftColor:g.colors("borderLeftColor"),borderInlineStartColor:g.colors("borderInlineStartColor"),borderLeftStyle:g.borderStyles("borderLeftStyle"),borderInlineStartStyle:g.borderStyles("borderInlineStartStyle"),borderRightWidth:g.borderWidths("borderRightWidth"),borderInlineEndWidth:g.borderWidths("borderInlineEndWidth"),borderRightColor:g.colors("borderRightColor"),borderInlineEndColor:g.colors("borderInlineEndColor"),borderRightStyle:g.borderStyles("borderRightStyle"),borderInlineEndStyle:g.borderStyles("borderInlineEndStyle"),borderTopRadius:g.radii(["borderTopLeftRadius","borderTopRightRadius"]),borderBottomRadius:g.radii(["borderBottomLeftRadius","borderBottomRightRadius"]),borderLeftRadius:g.radii(["borderTopLeftRadius","borderBottomLeftRadius"]),borderRightRadius:g.radii(["borderTopRightRadius","borderBottomRightRadius"])};Object.assign(L,{rounded:L.borderRadius,roundedTop:L.borderTopRadius,roundedTopLeft:L.borderTopLeftRadius,roundedTopRight:L.borderTopRightRadius,roundedTopStart:L.borderStartStartRadius,roundedTopEnd:L.borderStartEndRadius,roundedBottom:L.borderBottomRadius,roundedBottomLeft:L.borderBottomLeftRadius,roundedBottomRight:L.borderBottomRightRadius,roundedBottomStart:L.borderEndStartRadius,roundedBottomEnd:L.borderEndEndRadius,roundedLeft:L.borderLeftRadius,roundedRight:L.borderRightRadius,roundedStart:L.borderInlineStartRadius,roundedEnd:L.borderInlineEndRadius,borderStart:L.borderInlineStart,borderEnd:L.borderInlineEnd,borderTopStartRadius:L.borderStartStartRadius,borderTopEndRadius:L.borderStartEndRadius,borderBottomStartRadius:L.borderEndStartRadius,borderBottomEndRadius:L.borderEndEndRadius,borderStartRadius:L.borderInlineStartRadius,borderEndRadius:L.borderInlineEndRadius,borderStartWidth:L.borderInlineStartWidth,borderEndWidth:L.borderInlineEndWidth,borderStartColor:L.borderInlineStartColor,borderEndColor:L.borderInlineEndColor,borderStartStyle:L.borderInlineStartStyle,borderEndStyle:L.borderInlineEndStyle});var Vl={color:g.colors("color"),textColor:g.colors("color"),fill:g.colors("fill"),stroke:g.colors("stroke")},Yn={boxShadow:g.shadows("boxShadow"),mixBlendMode:!0,blendMode:g.prop("mixBlendMode"),backgroundBlendMode:!0,bgBlendMode:g.prop("backgroundBlendMode"),opacity:!0};Object.assign(Yn,{shadow:Yn.boxShadow});var Yl={filter:{transform:B.filter},blur:g.blur("--chakra-blur"),brightness:g.propT("--chakra-brightness",B.brightness),contrast:g.propT("--chakra-contrast",B.contrast),hueRotate:g.propT("--chakra-hue-rotate",B.hueRotate),invert:g.propT("--chakra-invert",B.invert),saturate:g.propT("--chakra-saturate",B.saturate),dropShadow:g.propT("--chakra-drop-shadow",B.dropShadow),backdropFilter:{transform:B.backdropFilter},backdropBlur:g.blur("--chakra-backdrop-blur"),backdropBrightness:g.propT("--chakra-backdrop-brightness",B.brightness),backdropContrast:g.propT("--chakra-backdrop-contrast",B.contrast),backdropHueRotate:g.propT("--chakra-backdrop-hue-rotate",B.hueRotate),backdropInvert:g.propT("--chakra-backdrop-invert",B.invert),backdropSaturate:g.propT("--chakra-backdrop-saturate",B.saturate)},Rr={alignItems:!0,alignContent:!0,justifyItems:!0,justifyContent:!0,flexWrap:!0,flexDirection:{transform:B.flexDirection},flex:!0,flexFlow:!0,flexGrow:!0,flexShrink:!0,flexBasis:g.sizes("flexBasis"),justifySelf:!0,alignSelf:!0,order:!0,placeItems:!0,placeContent:!0,placeSelf:!0,gap:g.space("gap"),rowGap:g.space("rowGap"),columnGap:g.space("columnGap")};Object.assign(Rr,{flexDir:Rr.flexDirection});var Eo={gridGap:g.space("gridGap"),gridColumnGap:g.space("gridColumnGap"),gridRowGap:g.space("gridRowGap"),gridColumn:!0,gridRow:!0,gridAutoFlow:!0,gridAutoColumns:!0,gridColumnStart:!0,gridColumnEnd:!0,gridRowStart:!0,gridRowEnd:!0,gridAutoRows:!0,gridTemplate:!0,gridTemplateColumns:!0,gridTemplateRows:!0,gridTemplateAreas:!0,gridArea:!0},Zl={appearance:!0,cursor:!0,resize:!0,userSelect:!0,pointerEvents:!0,outline:{transform:B.outline},outlineOffset:!0,outlineColor:g.colors("outlineColor")},he={width:g.sizesT("width"),inlineSize:g.sizesT("inlineSize"),height:g.sizes("height"),blockSize:g.sizes("blockSize"),boxSize:g.sizes(["width","height"]),minWidth:g.sizes("minWidth"),minInlineSize:g.sizes("minInlineSize"),minHeight:g.sizes("minHeight"),minBlockSize:g.sizes("minBlockSize"),maxWidth:g.sizes("maxWidth"),maxInlineSize:g.sizes("maxInlineSize"),maxHeight:g.sizes("maxHeight"),maxBlockSize:g.sizes("maxBlockSize"),overflow:!0,overflowX:!0,overflowY:!0,overscrollBehavior:!0,overscrollBehaviorX:!0,overscrollBehaviorY:!0,display:!0,aspectRatio:!0,hideFrom:{scale:"breakpoints",transform:(e,t)=>{var r,n,i;return{[`@media screen and (min-width: ${(i=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n.minW)!=null?i:e})`]:{display:"none"}}}},hideBelow:{scale:"breakpoints",transform:(e,t)=>{var r,n,i;return{[`@media screen and (max-width: ${(i=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n._minW)!=null?i:e})`]:{display:"none"}}}},verticalAlign:!0,boxSizing:!0,boxDecorationBreak:!0,float:g.propT("float",B.float),objectFit:!0,objectPosition:!0,visibility:!0,isolation:!0};Object.assign(he,{w:he.width,h:he.height,minW:he.minWidth,maxW:he.maxWidth,minH:he.minHeight,maxH:he.maxHeight,overscroll:he.overscrollBehavior,overscrollX:he.overscrollBehaviorX,overscrollY:he.overscrollBehaviorY});var Ql={listStyleType:!0,listStylePosition:!0,listStylePos:g.prop("listStylePosition"),listStyleImage:!0,listStyleImg:g.prop("listStyleImage")};function eu(e,t,r,n){const i=typeof t=="string"?t.split("."):[t];for(n=0;n<i.length&&e;n+=1)e=e[i[n]];return e===void 0?r:e}var tu=e=>{const t=new WeakMap;return(n,i,a,c)=>{if(typeof n>"u")return e(n,i,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(i))return u.get(i);const p=e(n,i,a,c);return u.set(i,p),p}},ru=tu(eu),nu={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},iu={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},Mn=(e,t,r)=>{const n={},i=ru(e,t,{});for(const a in i)a in r&&r[a]!=null||(n[a]=i[a]);return n},ou={srOnly:{transform(e){return e===!0?nu:e==="focusable"?iu:{}}},layerStyle:{processResult:!0,transform:(e,t,r)=>Mn(t,`layerStyles.${e}`,r)},textStyle:{processResult:!0,transform:(e,t,r)=>Mn(t,`textStyles.${e}`,r)},apply:{processResult:!0,transform:(e,t,r)=>Mn(t,e,r)}},zt={position:!0,pos:g.prop("position"),zIndex:g.prop("zIndex","zIndices"),inset:g.spaceT("inset"),insetX:g.spaceT(["left","right"]),insetInline:g.spaceT("insetInline"),insetY:g.spaceT(["top","bottom"]),insetBlock:g.spaceT("insetBlock"),top:g.spaceT("top"),insetBlockStart:g.spaceT("insetBlockStart"),bottom:g.spaceT("bottom"),insetBlockEnd:g.spaceT("insetBlockEnd"),left:g.spaceT("left"),insetInlineStart:g.logical({scale:"space",property:{ltr:"left",rtl:"right"}}),right:g.spaceT("right"),insetInlineEnd:g.logical({scale:"space",property:{ltr:"right",rtl:"left"}})};Object.assign(zt,{insetStart:zt.insetInlineStart,insetEnd:zt.insetInlineEnd});var au={ring:{transform:B.ring},ringColor:g.colors("--chakra-ring-color"),ringOffset:g.prop("--chakra-ring-offset-width"),ringOffsetColor:g.colors("--chakra-ring-offset-color"),ringInset:g.prop("--chakra-ring-inset")},z={margin:g.spaceT("margin"),marginTop:g.spaceT("marginTop"),marginBlockStart:g.spaceT("marginBlockStart"),marginRight:g.spaceT("marginRight"),marginInlineEnd:g.spaceT("marginInlineEnd"),marginBottom:g.spaceT("marginBottom"),marginBlockEnd:g.spaceT("marginBlockEnd"),marginLeft:g.spaceT("marginLeft"),marginInlineStart:g.spaceT("marginInlineStart"),marginX:g.spaceT(["marginInlineStart","marginInlineEnd"]),marginInline:g.spaceT("marginInline"),marginY:g.spaceT(["marginTop","marginBottom"]),marginBlock:g.spaceT("marginBlock"),padding:g.space("padding"),paddingTop:g.space("paddingTop"),paddingBlockStart:g.space("paddingBlockStart"),paddingRight:g.space("paddingRight"),paddingBottom:g.space("paddingBottom"),paddingBlockEnd:g.space("paddingBlockEnd"),paddingLeft:g.space("paddingLeft"),paddingInlineStart:g.space("paddingInlineStart"),paddingInlineEnd:g.space("paddingInlineEnd"),paddingX:g.space(["paddingInlineStart","paddingInlineEnd"]),paddingInline:g.space("paddingInline"),paddingY:g.space(["paddingTop","paddingBottom"]),paddingBlock:g.space("paddingBlock")};Object.assign(z,{m:z.margin,mt:z.marginTop,mr:z.marginRight,me:z.marginInlineEnd,marginEnd:z.marginInlineEnd,mb:z.marginBottom,ml:z.marginLeft,ms:z.marginInlineStart,marginStart:z.marginInlineStart,mx:z.marginX,my:z.marginY,p:z.padding,pt:z.paddingTop,py:z.paddingY,px:z.paddingX,pb:z.paddingBottom,pl:z.paddingLeft,ps:z.paddingInlineStart,paddingStart:z.paddingInlineStart,pr:z.paddingRight,pe:z.paddingInlineEnd,paddingEnd:z.paddingInlineEnd});var su={textDecorationColor:g.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:g.shadows("textShadow")},cu={clipPath:!0,transform:g.propT("transform",B.transform),transformOrigin:!0,translateX:g.spaceT("--chakra-translate-x"),translateY:g.spaceT("--chakra-translate-y"),skewX:g.degreeT("--chakra-skew-x"),skewY:g.degreeT("--chakra-skew-y"),scaleX:g.prop("--chakra-scale-x"),scaleY:g.prop("--chakra-scale-y"),scale:g.prop(["--chakra-scale-x","--chakra-scale-y"]),rotate:g.degreeT("--chakra-rotate")},du={transition:!0,transitionDelay:!0,animation:!0,willChange:!0,transitionDuration:g.prop("transitionDuration","transition.duration"),transitionProperty:g.prop("transitionProperty","transition.property"),transitionTimingFunction:g.prop("transitionTimingFunction","transition.easing")},lu={fontFamily:g.prop("fontFamily","fonts"),fontSize:g.prop("fontSize","fontSizes",B.px),fontWeight:g.prop("fontWeight","fontWeights"),lineHeight:g.prop("lineHeight","lineHeights"),letterSpacing:g.prop("letterSpacing","letterSpacings"),textAlign:!0,fontStyle:!0,textIndent:!0,wordBreak:!0,overflowWrap:!0,textOverflow:!0,textTransform:!0,whiteSpace:!0,isTruncated:{transform(e){if(e===!0)return{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},noOfLines:{static:{overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"var(--chakra-line-clamp)"},property:"--chakra-line-clamp"}},uu={scrollBehavior:!0,scrollSnapAlign:!0,scrollSnapStop:!0,scrollSnapType:!0,scrollMargin:g.spaceT("scrollMargin"),scrollMarginTop:g.spaceT("scrollMarginTop"),scrollMarginBottom:g.spaceT("scrollMarginBottom"),scrollMarginLeft:g.spaceT("scrollMarginLeft"),scrollMarginRight:g.spaceT("scrollMarginRight"),scrollMarginX:g.spaceT(["scrollMarginLeft","scrollMarginRight"]),scrollMarginY:g.spaceT(["scrollMarginTop","scrollMarginBottom"]),scrollPadding:g.spaceT("scrollPadding"),scrollPaddingTop:g.spaceT("scrollPaddingTop"),scrollPaddingBottom:g.spaceT("scrollPaddingBottom"),scrollPaddingLeft:g.spaceT("scrollPaddingLeft"),scrollPaddingRight:g.spaceT("scrollPaddingRight"),scrollPaddingX:g.spaceT(["scrollPaddingLeft","scrollPaddingRight"]),scrollPaddingY:g.spaceT(["scrollPaddingTop","scrollPaddingBottom"])};function Fo(e){return nt(e)&&e.reference?e.reference:String(e)}var Dr=(e,...t)=>t.map(Fo).join(` ${e} `).replace(/calc/g,""),Ni=(...e)=>`calc(${Dr("+",...e)})`,Ti=(...e)=>`calc(${Dr("-",...e)})`,Zn=(...e)=>`calc(${Dr("*",...e)})`,Ri=(...e)=>`calc(${Dr("/",...e)})`,_i=e=>{const t=Fo(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith("-")?String(t).slice(1):`-${t}`:Zn(t,-1)},Wt=Object.assign(e=>({add:(...t)=>Wt(Ni(e,...t)),subtract:(...t)=>Wt(Ti(e,...t)),multiply:(...t)=>Wt(Zn(e,...t)),divide:(...t)=>Wt(Ri(e,...t)),negate:()=>Wt(_i(e)),toString:()=>e.toString()}),{add:Ni,subtract:Ti,multiply:Zn,divide:Ri,negate:_i});function pu(e){const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}}function Ai(e){if(e==null)return e;const{unitless:t}=pu(e);return t||typeof e=="number"?`${e}px`:e}function fu(e,t){const r=["@media screen"];return e&&r.push("and",`(min-width: ${Ai(e)})`),t&&r.push("and",`(max-width: ${Ai(t)})`),r.join(" ")}var re={hover:(e,t)=>`${e}:hover ${t}, ${e}[data-hover] ${t}`,focus:(e,t)=>`${e}:focus ${t}, ${e}[data-focus] ${t}`,focusVisible:(e,t)=>`${e}:focus-visible ${t}`,focusWithin:(e,t)=>`${e}:focus-within ${t}`,active:(e,t)=>`${e}:active ${t}, ${e}[data-active] ${t}`,disabled:(e,t)=>`${e}:disabled ${t}, ${e}[data-disabled] ${t}`,invalid:(e,t)=>`${e}:invalid ${t}, ${e}[data-invalid] ${t}`,checked:(e,t)=>`${e}:checked ${t}, ${e}[data-checked] ${t}`,indeterminate:(e,t)=>`${e}:indeterminate ${t}, ${e}[aria-checked=mixed] ${t}, ${e}[data-indeterminate] ${t}`,readOnly:(e,t)=>`${e}:read-only ${t}, ${e}[readonly] ${t}, ${e}[data-read-only] ${t}`,expanded:(e,t)=>`${e}:read-only ${t}, ${e}[aria-expanded=true] ${t}, ${e}[data-expanded] ${t}`,placeholderShown:(e,t)=>`${e}:placeholder-shown ${t}`},Ue=e=>Po(t=>e(t,"&"),"[role=group]","[data-group]",".group"),ke=e=>Po(t=>e(t,"~ &"),"[data-peer]",".peer"),Po=(e,...t)=>t.map(e).join(", "),ci={_hover:"&:hover, &[data-hover]",_active:"&:active, &[data-active]",_focus:"&:focus, &[data-focus]",_highlighted:"&[data-highlighted]",_focusWithin:"&:focus-within",_focusVisible:"&:focus-visible, &[data-focus-visible]",_disabled:"&:disabled, &[disabled], &[aria-disabled=true], &[data-disabled]",_readOnly:"&[aria-readonly=true], &[readonly], &[data-readonly]",_before:"&::before",_after:"&::after",_empty:"&:empty",_expanded:"&[aria-expanded=true], &[data-expanded]",_checked:"&[aria-checked=true], &[data-checked]",_grabbed:"&[aria-grabbed=true], &[data-grabbed]",_pressed:"&[aria-pressed=true], &[data-pressed]",_invalid:"&[aria-invalid=true], &[data-invalid]",_valid:"&[data-valid], &[data-state=valid]",_loading:"&[data-loading], &[aria-busy=true]",_selected:"&[aria-selected=true], &[data-selected]",_hidden:"&[hidden], &[data-hidden]",_autofill:"&:-webkit-autofill",_even:"&:nth-of-type(even)",_odd:"&:nth-of-type(odd)",_first:"&:first-of-type",_firstLetter:"&::first-letter",_last:"&:last-of-type",_notFirst:"&:not(:first-of-type)",_notLast:"&:not(:last-of-type)",_visited:"&:visited",_activeLink:"&[aria-current=page]",_activeStep:"&[aria-current=step]",_indeterminate:"&:indeterminate, &[aria-checked=mixed], &[data-indeterminate]",_groupHover:Ue(re.hover),_peerHover:ke(re.hover),_groupFocus:Ue(re.focus),_peerFocus:ke(re.focus),_groupFocusVisible:Ue(re.focusVisible),_peerFocusVisible:ke(re.focusVisible),_groupActive:Ue(re.active),_peerActive:ke(re.active),_groupDisabled:Ue(re.disabled),_peerDisabled:ke(re.disabled),_groupInvalid:Ue(re.invalid),_peerInvalid:ke(re.invalid),_groupChecked:Ue(re.checked),_peerChecked:ke(re.checked),_groupFocusWithin:Ue(re.focusWithin),_peerFocusWithin:ke(re.focusWithin),_peerPlaceholderShown:ke(re.placeholderShown),_placeholder:"&::placeholder",_placeholderShown:"&:placeholder-shown",_fullScreen:"&:fullscreen",_selection:"&::selection",_rtl:"[dir=rtl] &, &[dir=rtl]",_ltr:"[dir=ltr] &, &[dir=ltr]",_mediaDark:"@media (prefers-color-scheme: dark)",_mediaReduceMotion:"@media (prefers-reduced-motion: reduce)",_dark:".chakra-ui-dark &:not([data-theme]),[data-theme=dark] &:not([data-theme]),&[data-theme=dark]",_light:".chakra-ui-light &:not([data-theme]),[data-theme=light] &:not([data-theme]),&[data-theme=light]",_horizontal:"&[data-orientation=horizontal]",_vertical:"&[data-orientation=vertical]"},hu=Object.keys(ci),di=Ee({},br,L,Vl,Rr,he,Yl,au,Zl,Eo,ou,zt,Yn,z,uu,lu,su,cu,Ql,du);Object.assign({},z,he,Rr,Eo,zt);var gu=[...Object.keys(di),...hu],mu={...di,...ci},yu=e=>e in mu,wu=e=>t=>{if(!t.__breakpoints)return e;const{isResponsive:r,toArrayValue:n,media:i}=t.__breakpoints,a={};for(const c in e){let u=rt(e[c],t);if(u==null)continue;if(u=nt(u)&&r(u)?n(u):u,!Array.isArray(u)){a[c]=u;continue}const p=u.slice(0,i.length).length;for(let h=0;h<p;h+=1){const m=i==null?void 0:i[h];if(!m){a[c]=u[h];continue}a[m]=a[m]||{},u[h]!=null&&(a[m][c]=u[h])}}return a};function Iu(e){const t=[];let r="",n=!1;for(let i=0;i<e.length;i++){const a=e[i];a==="("?(n=!0,r+=a):a===")"?(n=!1,r+=a):a===","&&!n?(t.push(r),r=""):r+=a}return r=r.trim(),r&&t.push(r),t}function vu(e){return/^var\(--.+\)$/.test(e)}var bu=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!vu(t),Su=(e,t)=>{var r,n;if(t==null)return t;const i=p=>{var h,m;return(m=(h=e.__cssMap)==null?void 0:h[p])==null?void 0:m.varRef},a=p=>{var h;return(h=i(p))!=null?h:p},[c,u]=Iu(t);return t=(n=(r=i(c))!=null?r:a(u))!=null?n:a(t),t};function xu(e){const{configs:t={},pseudos:r={},theme:n}=e,i=(a,c=!1)=>{var u,p,h;const m=rt(a,n),v=wu(m)(n);let w={};for(let b in v){const x=v[b];let S=rt(x,n);b in r&&(b=r[b]),bu(b,S)&&(S=Su(n,S));let O=t[b];if(O===!0&&(O={property:b}),nt(S)){w[b]=(u=w[b])!=null?u:{},w[b]=Ee({},w[b],i(S,!0));continue}let T=(h=(p=O==null?void 0:O.transform)==null?void 0:p.call(O,S,n,m))!=null?h:S;T=O!=null&&O.processResult?i(T,!0):T;const A=rt(O==null?void 0:O.property,n);if(!c&&(O!=null&&O.static)){const P=rt(O.static,n);w=Ee({},w,P)}if(A&&Array.isArray(A)){for(const P of A)w[P]=T;continue}if(A){A==="&"&&nt(T)?w=Ee({},w,T):w[A]=T;continue}if(nt(T)){w=Ee({},w,T);continue}w[b]=T}return w};return i}var Ou=e=>t=>xu({theme:t,pseudos:ci,configs:di})(e);function Cu(e,t){if(Array.isArray(e))return e;if(nt(e))return t(e);if(e!=null)return[e]}function Nu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function Tu(e){const t=e.__breakpoints;return function(n,i,a,c){var u,p;if(!t)return;const h={},m=Cu(a,t.toArrayValue);if(!m)return h;const v=m.length,w=v===1,b=!!n.parts;for(let x=0;x<v;x++){const S=t.details[x],O=t.details[Nu(m,x)],T=fu(S.minW,O==null?void 0:O._minW),A=rt((u=n[i])==null?void 0:u[m[x]],c);if(A){if(b){(p=n.parts)==null||p.forEach(P=>{Ee(h,{[P]:w?A[P]:{[T]:A[P]}})});continue}if(!b){w?Ee(h,A):h[T]=A;continue}h[T]=A}}return h}}function Ru(e){return t=>{var r;const{variant:n,size:i,theme:a}=t,c=Tu(a);return Ee({},rt((r=e.baseStyle)!=null?r:{},t),c(e,"sizes",i,t),c(e,"variants",n,t))}}function _u(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function Au(e,t,r,n){const i=typeof t=="string"?t.split("."):[t];for(n=0;n<i.length&&e;n+=1)e=e[i[n]];return e===void 0?r:e}var ju=e=>{const t=new WeakMap;return(n,i,a,c)=>{if(typeof n>"u")return e(n,i,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(i))return u.get(i);const p=e(n,i,a,c);return u.set(i,p),p}},ku=ju(Au);function Do(e,t){const r={};return Object.keys(e).forEach(n=>{const i=e[n];t(i,n,e)&&(r[n]=i)}),r}var Bo=e=>Do(e,t=>t!=null);function Eu(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function Fu(e,...t){return Eu(e)?e(...t):e}var Pu=typeof Element<"u",Du=typeof Map=="function",Bu=typeof Set=="function",Lu=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Sr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,n,i;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(!Sr(e[n],t[n]))return!1;return!0}var a;if(Du&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;for(a=e.entries();!(n=a.next()).done;)if(!Sr(n.value[1],t.get(n.value[0])))return!1;return!0}if(Bu&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;return!0}if(Lu&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(e[n]!==t[n])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[n]))return!1;if(Pu&&e instanceof Element)return!1;for(n=r;n--!==0;)if(!((i[n]==="_owner"||i[n]==="__v"||i[n]==="__o")&&e.$$typeof)&&!Sr(e[i[n]],t[i[n]]))return!1;return!0}return e!==e&&t!==t}var Ku=function(t,r){try{return Sr(t,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const Mu=ei(Ku);function Uu(e,t={}){var r;const{styleConfig:n,...i}=t,{theme:a,colorMode:c}=Al(),u=ku(a,`components.${e}`),p=n||u,h=Ee({theme:a,colorMode:c},(r=p==null?void 0:p.defaultProps)!=null?r:{},Bo(_u(i,["children"]))),m=I.useRef({});if(p){const w=Ru(p)(h);Mu(m.current,w)||(m.current=w)}return m.current}function $u(e,t={}){return Uu(e,t)}var qu=new Set([...gu,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),Wu=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function zu(e){return Wu.has(e)||!qu.has(e)}function Ju(e,...t){if(e==null)throw new TypeError("Cannot convert undefined or null to object");const r={...e};for(const n of t)if(n!=null)for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(i in r&&delete r[i],r[i]=n[i]);return r}var ji,Hu=(ji=ui.default)!=null?ji:ui,Xu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:i,sx:a,...c}=t,u=Do(c,(v,w)=>yu(w)),p=Fu(e,t),h=Ju({},i,p,Bo(u),a),m=Ou(h)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=zu);const i=Xu({baseStyle:r}),a=Hu(e,n)(i);return I.forwardRef(function(p,h){const{colorMode:m,forced:v}=jo();return I.createElement(a,{ref:h,"data-theme":v?m:void 0,...p})})}function Gu(){const e=new Map;return new Proxy(Un,{apply(t,r,n){return Un(...n)},get(t,r){return e.has(r)||e.set(r,Un(r)),e.get(r)}})}var ki=Gu();function Lo(e){return I.forwardRef(e)}var Ei={path:s.jsxs("g",{stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("path",{strokeLinecap:"round",fill:"none",d:"M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"}),s.jsx("path",{fill:"currentColor",strokeLinecap:"round",d:"M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"}),s.jsx("circle",{fill:"none",strokeMiterlimit:"10",cx:"12",cy:"12",r:"11.25"})]}),viewBox:"0 0 24 24"},Ko=Lo((e,t)=>{const{as:r,viewBox:n,color:i="currentColor",focusable:a=!1,children:c,className:u,__css:p,...h}=e,m=jl("chakra-icon",u),v=$u("Icon",e),w={w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:i,...p,...v},b={ref:t,focusable:a,className:m,__css:w},x=n??Ei.viewBox;if(r&&typeof r!="string")return s.jsx(ki.svg,{as:r,...b,...h});const S=c??Ei.path;return s.jsx(ki.svg,{verticalAlign:"middle",viewBox:x,...b,...h,children:S})});Ko.displayName="Icon";function Vu(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:i={}}=e,a=I.Children.toArray(e.path),c=Lo((u,p)=>s.jsx(Ko,{ref:p,viewBox:t,...i,...u,children:a.length?a:s.jsx("path",{fill:"currentColor",d:r})}));return c.displayName=n,c}var Yu=Vu({displayName:"ExternalLinkIcon",path:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("path",{d:"M15 3h6v6"}),s.jsx("path",{d:"M10 14L21 3"})]})});const Zu="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function Qu({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),s.jsxs(y.Link,{href:Zu,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",s.jsx(Yu,{mx:"2px"})]}),s.jsx(Vt,{error:r}),s.jsxs(y.Flex,{marginTop:"1em",children:[s.jsx(y.Input,{placeholder:"MyDomain",onChange:i=>t(i.currentTarget.value)}),s.jsx(y.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function ep({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n,providerName:i}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsxs(y.Heading,{as:"h4",size:"md",children:["Enter your ",i," workspace"]})}),s.jsx(Vt,{error:r}),s.jsx(y.Flex,{marginTop:"1em",children:s.jsx(y.Input,{placeholder:"MyWorkspace",onChange:a=>t(a.currentTarget.value)})}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}const tp="salesforce";function rp({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:c}=Z(),u=ee(),[p,h]=I.useState(""),[m,v]=I.useState(null),[w,b]=I.useState(null),x=async()=>{if(b(null),!p){b("Workspace is required");return}try{const T=await Ro(c,t,n,u,e,p,r,i);v(T)}catch(T){console.error(T),b((T==null?void 0:T.message)??"Unexpected error")}},S=I.useCallback(T=>{b(T),v(null)},[]),O=e===tp?s.jsx(Qu,{handleSubmit:x,setWorkspace:h,error:w,isButtonDisabled:p.length===0}):s.jsx(ep,{handleSubmit:x,setWorkspace:h,error:w,isButtonDisabled:p.length===0,providerName:a});return s.jsx(_o,{windowTitle:`Connect to ${a}`,oauthUrl:m,onClose:S,children:O})}const np="authorizationCode",ip="clientCredentials";function op({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,selectedConnection:c,setSelectedConnection:u}){if(t.oauth2Opts===void 0)return s.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:p,explicitScopesRequired:h,explicitWorkspaceRequired:m}=t.oauth2Opts,v=st(e,t);return p===np?m?s.jsx(rp,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):s.jsx(Nl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):p===ip?m?s.jsx(Rl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:h,setSelectedConnection:u,selectedConnection:c,providerName:v}):s.jsx(Il,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:h,setSelectedConnection:u,selectedConnection:c,providerName:v}):p==="password"?s.jsx("em",{children:"Password flow not supported yet"}):p==="PKCE"?s.jsx("em",{children:"PKCE flow not supported yet"}):s.jsxs("em",{children:["Unsupported grant type: ",p]})}const ap=async(e,t)=>{const r=await H().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!r)throw new Error(`Provider ${t} not found`);return r};function Mo({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,onSuccess:c}){const u=ee(),[p,h]=I.useState(null),{provider:m}=Ne(),{selectedConnection:v,setSelectedConnection:w,connections:b}=xt();fl({onSuccess:c});const x=e||m,S=(p==null?void 0:p.displayName)??Vi(x);if(I.useEffect(()=>{if(!v&&b&&b.length>0){const[O]=b;w(O)}ap(u,x).then(O=>{h(O)}).catch(O=>{console.error("Error loading provider info: ",O)})},[b,v,w,u,x]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");return v?a:p==null?s.jsx("strong",{children:"Provider not found"}):p.authType==="none"?s.jsx(yl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,providerName:S,children:a}):p.authType==="basic"?s.jsx(ul,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,children:a}):p.authType==="apiKey"?s.jsx(sl,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,children:a}):s.jsx(op,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:i,setSelectedConnection:w,selectedConnection:v})}function sp({integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:c,onUninstallSuccess:u}){var m;const{projectId:p}=Z(),{errorState:h}=We();return(m=h[V.INTEGRATION_LIST])!=null&&m.apiError?s.jsx(Fe,{message:"Something went wrong, couldn't find integration information"}):s.jsx(Xc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:c,onUninstallSuccess:u,children:s.jsx(eo,{groupRef:n,children:s.jsx(Mo,{consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:s.jsx(hd,{projectId:p,children:s.jsx(nl,{children:s.jsx(Td,{children:s.jsx(kd,{children:s.jsx(Yd,{})})})})})})})})}function cp({redirectURL:e,children:t}){return I.useEffect(()=>{e&&window.location.replace(e)},[e]),e?s.jsx(y.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:s.jsx(Ce,{message:"Redirecting..."})}):t}function dp({provider:e}){const{appName:t}=Z(),r=`You have successfully connected your ${st(e)} account to ${t}.`;return s.jsx(ai,{text:r})}function lp({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,redirectUrl:a,onSuccess:c}){return s.jsx(eo,{provider:e,groupRef:n,children:s.jsx(Mo,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onSuccess:c,children:s.jsx(cp,{redirectURL:a,children:s.jsx(dp,{provider:e})})})})}const up=(e,t)=>{const r=ee(),{projectId:n}=Z(),{integrations:i}=Hi(),[a,c]=I.useState(!1),[u,p]=I.useState(null);if(!r||!n)throw new Error("useIsIntegrationInstalled must be used within AmpersandProvider");if(!e)throw new Error("useIsIntegrationInstalled requires an integration name");if(!t)throw new Error("useIsIntegrationInstalled requires a groupRef");const h=I.useMemo(()=>i==null?void 0:i.reduce((m,v)=>(v==null?void 0:v.name)===e?v:m,{}),[i,e]);return I.useEffect(()=>{h&&H().installationApi.listInstallations({projectIdOrName:n,integrationId:h.id,groupRef:t},{headers:{"x-api-key":r}}).then(m=>{c(!0),p(m.length>0)}).catch(m=>{console.error("Error listing installations: ",m),c(!0)})},[t,r,n,h]),{isLoaded:a,isIntegrationInstalled:u}};exports.AmpersandContext=Gi;exports.AmpersandProvider=Wc;exports.ConnectProvider=lp;exports.InstallIntegration=sp;exports.useAmpersandProvider=zc;exports.useIsIntegrationInstalled=up;
3
+ `).filter(r=>r.trim()!==""),Hc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Xc=()=>{const[e,t]=I.useState(!1),r=I.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:r}},Zi=I.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0,onUninstallSuccess:void 0,isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}});function Ne(){const e=I.useContext(Zi);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Gc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,onInstallSuccess:c,onUpdateSuccess:u,onUninstallSuccess:p}){const h=ee(),{projectId:m}=Z(),{integrations:v}=Hi(),{setError:w,isError:b}=We(),{isIntegrationDeleted:x,setIntegrationDeleted:S}=Xc(),[O,T]=I.useState([]),[A,P]=I.useState(!0),$=(O==null?void 0:O[0])||null,k=I.useMemo(()=>Hc(t,v||[]),[t,v]);I.useEffect(()=>{k===null&&(v!=null&&v.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,k,v]);const Q=I.useCallback(Y=>{T([Y])},[T]),X=I.useCallback(()=>{k!=null&&k.id&&H().installationApi.listInstallations({projectIdOrName:m,integrationId:k.id,groupRef:i},{headers:{"X-Api-Key":h??""}}).then(Y=>{P(!1),T(Y||[])}).catch(Y=>{w(V.INSTALLATION_LIST,k.id),P(!1),console.error("Error retrieving installation information: ",Y)})},[k,m,h,w,i]),te=(k==null?void 0:k.id)||"";I.useEffect(()=>{X()},[X]);const J=I.useMemo(()=>({integrationId:(k==null?void 0:k.id)||"",provider:(k==null?void 0:k.provider)||"",integrationObj:k,consumerRef:r,consumerName:n,groupRef:i,groupName:a,installation:$,setInstallation:Q,resetInstallations:X,onInstallSuccess:c,onUpdateSuccess:u,onUninstallSuccess:p,isIntegrationDeleted:x,setIntegrationDeleted:S}),[k,r,n,i,a,$,Q,X,c,u,p,x,S]);if(k!==null){const Y=`Error retrieving installation information for integration "${(k==null?void 0:k.name)||"unknown"}"`;return b(V.INSTALLATION_LIST,te)?s.jsx(Fe,{message:Y}):s.jsx(Zi.Provider,{value:J,children:A?s.jsx(Ce,{}):e})}return s.jsx(Fe,{message:`Integration "${t}" not found`})}const Qi=I.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),xt=()=>{const e=I.useContext(Qi);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function eo({provider:e,groupRef:t,children:r}){const n=ee(),{projectId:i}=Z(),[a,c]=I.useState(null),[u,p]=I.useState(null),[h,m]=I.useState(!0),{setError:v,isError:w}=We(),{provider:b}=Ne();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const x=e||b;if(!x)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");I.useEffect(()=>{H().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:x},{headers:{"X-Api-Key":n??""}}).then(O=>{m(!1),c(O)}).catch(O=>{m(!1),v(V.CONNECTION_LIST,i),console.error(`Error retrieving existing OAuth connections for group ID ${t}:`,O)})},[i,n,t,x,v]);const S=I.useMemo(()=>({connections:a,selectedConnection:u,setConnections:c,setSelectedConnection:p}),[a,u,c,p]);return w(V.CONNECTION_LIST,i)?s.jsx(Fe,{message:"Error retrieving existing connections"}):s.jsx(Qi.Provider,{value:S,children:h?s.jsx(Ce,{}):r})}var $e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xr={exports:{}};xr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=1,a=2,c=9007199254740991,u="[object Arguments]",p="[object Array]",h="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",w="[object Error]",b="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",T="[object Null]",A="[object Object]",P="[object Promise]",$="[object Proxy]",k="[object RegExp]",Q="[object Set]",X="[object String]",te="[object Symbol]",J="[object Undefined]",Y="[object WeakMap]",Te="[object ArrayBuffer]",ct="[object DataView]",Br="[object Float32Array]",Lr="[object Float64Array]",Kr="[object Int8Array]",Mr="[object Int16Array]",Ur="[object Int32Array]",$r="[object Uint8Array]",qr="[object Uint8ClampedArray]",Wr="[object Uint16Array]",zr="[object Uint32Array]",Jr=/[\\^$.*+?()[\]{}|]/g,M=/^\[object .+?Constructor\]$/,Yt=/^(?:0|[1-9]\d*)$/,U={};U[Br]=U[Lr]=U[Kr]=U[Mr]=U[Ur]=U[$r]=U[qr]=U[Wr]=U[zr]=!0,U[u]=U[p]=U[Te]=U[m]=U[ct]=U[v]=U[w]=U[b]=U[S]=U[O]=U[A]=U[k]=U[Q]=U[X]=U[Y]=!1;var De=typeof $e=="object"&&$e&&$e.Object===Object&&$e,Zt=typeof self=="object"&&self&&self.Object===Object&&self,oe=De||Zt||Function("return this")(),Ct=t&&!t.nodeType&&t,dt=Ct&&!0&&e&&!e.nodeType&&e,Nt=dt&&dt.exports===Ct,lt=Nt&&De.process,Qt=function(){try{return lt&&lt.binding&&lt.binding("util")}catch{}}(),er=Qt&&Qt.isTypedArray;function Hr(l,o){for(var d=-1,f=l==null?0:l.length,C=0,R=[];++d<f;){var j=l[d];o(j,d,l)&&(R[C++]=j)}return R}function Xr(l,o){for(var d=-1,f=o.length,C=l.length;++d<f;)l[C+d]=o[d];return l}function Gr(l,o){for(var d=-1,f=l==null?0:l.length;++d<f;)if(o(l[d],d,l))return!0;return!1}function Vr(l,o){for(var d=-1,f=Array(l);++d<l;)f[d]=o(d);return f}function Yr(l){return function(o){return l(o)}}function ut(l,o){return l.has(o)}function Tt(l,o){return l==null?void 0:l[o]}function pt(l){var o=-1,d=Array(l.size);return l.forEach(function(f,C){d[++o]=[C,f]}),d}function be(l,o){return function(d){return l(o(d))}}function tr(l){var o=-1,d=Array(l.size);return l.forEach(function(f){d[++o]=f}),d}var rr=Array.prototype,Zr=Function.prototype,ft=Object.prototype,Be=oe["__core-js_shared__"],Rt=Zr.toString,ce=ft.hasOwnProperty,_t=function(){var l=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),At=ft.toString,Qr=RegExp("^"+Rt.call(ce).replace(Jr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nr=Nt?oe.Buffer:void 0,ue=oe.Symbol,ze=oe.Uint8Array,ir=ft.propertyIsEnumerable,or=rr.splice,Re=ue?ue.toStringTag:void 0,jt=Object.getOwnPropertySymbols,Je=nr?nr.isBuffer:void 0,en=be(Object.keys,Object),ge=Ke(oe,"DataView"),He=Ke(oe,"Map"),kt=Ke(oe,"Promise"),Et=Ke(oe,"Set"),Ft=Ke(oe,"WeakMap"),Xe=Ke(Object,"create"),me=Ie(ge),tn=Ie(He),rn=Ie(kt),nn=Ie(Et),on=Ie(Ft),ar=ue?ue.prototype:void 0,Se=ar?ar.valueOf:void 0;function _e(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function an(){this.__data__=Xe?Xe(null):{},this.size=0}function sn(l){var o=this.has(l)&&delete this.__data__[l];return this.size-=o?1:0,o}function cn(l){var o=this.__data__;if(Xe){var d=o[l];return d===n?void 0:d}return ce.call(o,l)?o[l]:void 0}function dn(l){var o=this.__data__;return Xe?o[l]!==void 0:ce.call(o,l)}function Le(l,o){var d=this.__data__;return this.size+=this.has(l)?0:1,d[l]=Xe&&o===void 0?n:o,this}_e.prototype.clear=an,_e.prototype.delete=sn,_e.prototype.get=cn,_e.prototype.has=dn,_e.prototype.set=Le;function ye(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function ln(){this.__data__=[],this.size=0}function un(l){var o=this.__data__,d=mt(o,l);if(d<0)return!1;var f=o.length-1;return d==f?o.pop():or.call(o,d,1),--this.size,!0}function pn(l){var o=this.__data__,d=mt(o,l);return d<0?void 0:o[d][1]}function fn(l){return mt(this.__data__,l)>-1}function hn(l,o){var d=this.__data__,f=mt(d,l);return f<0?(++this.size,d.push([l,o])):d[f][1]=o,this}ye.prototype.clear=ln,ye.prototype.delete=un,ye.prototype.get=pn,ye.prototype.has=fn,ye.prototype.set=hn;function we(l){var o=-1,d=l==null?0:l.length;for(this.clear();++o<d;){var f=l[o];this.set(f[0],f[1])}}function gn(){this.size=0,this.__data__={hash:new _e,map:new(He||ye),string:new _e}}function ht(l){var o=Ye(this,l).delete(l);return this.size-=o?1:0,o}function Pt(l){return Ye(this,l).get(l)}function mn(l){return Ye(this,l).has(l)}function gt(l,o){var d=Ye(this,l),f=d.size;return d.set(l,o),this.size+=d.size==f?0:1,this}we.prototype.clear=gn,we.prototype.delete=ht,we.prototype.get=Pt,we.prototype.has=mn,we.prototype.set=gt;function Ge(l){var o=-1,d=l==null?0:l.length;for(this.__data__=new we;++o<d;)this.add(l[o])}function yn(l){return this.__data__.set(l,n),this}function wn(l){return this.__data__.has(l)}Ge.prototype.add=Ge.prototype.push=yn,Ge.prototype.has=wn;function xe(l){var o=this.__data__=new ye(l);this.size=o.size}function sr(){this.__data__=new ye,this.size=0}function In(l){var o=this.__data__,d=o.delete(l);return this.size=o.size,d}function vn(l){return this.__data__.get(l)}function bn(l){return this.__data__.has(l)}function Sn(l,o){var d=this.__data__;if(d instanceof ye){var f=d.__data__;if(!He||f.length<r-1)return f.push([l,o]),this.size=++d.size,this;d=this.__data__=new we(f)}return d.set(l,o),this.size=d.size,this}xe.prototype.clear=sr,xe.prototype.delete=In,xe.prototype.get=vn,xe.prototype.has=bn,xe.prototype.set=Sn;function xn(l,o){var d=Ze(l),f=!d&&Fn(l),C=!d&&!f&&vt(l),R=!d&&!f&&!C&&Ut(l),j=d||f||C||R,D=j?Vr(l.length,String):[],E=D.length;for(var F in l)ce.call(l,F)&&!(j&&(F=="length"||C&&(F=="offset"||F=="parent")||R&&(F=="buffer"||F=="byteLength"||F=="byteOffset")||jn(F,E)))&&D.push(F);return D}function mt(l,o){for(var d=l.length;d--;)if(It(l[d][0],o))return d;return-1}function On(l,o,d){var f=o(l);return Ze(l)?f:Xr(f,d(l))}function Ve(l){return l==null?l===void 0?J:T:Re&&Re in Object(l)?_n(l):Lt(l)}function cr(l){return Qe(l)&&Ve(l)==u}function dr(l,o,d,f,C){return l===o?!0:l==null||o==null||!Qe(l)&&!Qe(o)?l!==l&&o!==o:yt(l,o,d,f,dr,C)}function yt(l,o,d,f,C,R){var j=Ze(l),D=Ze(o),E=j?p:pe(l),F=D?p:pe(o);E=E==u?A:E,F=F==u?A:F;var q=E==A,W=F==A,G=E==F;if(G&&vt(l)){if(!vt(o))return!1;j=!0,q=!1}if(G&&!q)return R||(R=new xe),j||Ut(l)?Bt(l,o,d,f,C,R):Tn(l,o,E,d,f,C,R);if(!(d&i)){var ne=q&&ce.call(l,"__wrapped__"),ie=W&&ce.call(o,"__wrapped__");if(ne||ie){var ve=ne?l.value():l,je=ie?o.value():o;return R||(R=new xe),C(ve,je,d,f,R)}}return G?(R||(R=new xe),Rn(l,o,d,f,C,R)):!1}function Dt(l){if(!Mt(l)||En(l))return!1;var o=Me(l)?Qr:M;return o.test(Ie(l))}function Cn(l){return Qe(l)&&ur(l.length)&&!!U[Ve(l)]}function Nn(l){if(!wt(l))return en(l);var o=[];for(var d in Object(l))ce.call(l,d)&&d!="constructor"&&o.push(d);return o}function Bt(l,o,d,f,C,R){var j=d&i,D=l.length,E=o.length;if(D!=E&&!(j&&E>D))return!1;var F=R.get(l);if(F&&R.get(o))return F==o;var q=-1,W=!0,G=d&a?new Ge:void 0;for(R.set(l,o),R.set(o,l);++q<D;){var ne=l[q],ie=o[q];if(f)var ve=j?f(ie,ne,q,o,l,R):f(ne,ie,q,l,o,R);if(ve!==void 0){if(ve)continue;W=!1;break}if(G){if(!Gr(o,function(je,et){if(!ut(G,et)&&(ne===je||C(ne,je,d,f,R)))return G.push(et)})){W=!1;break}}else if(!(ne===ie||C(ne,ie,d,f,R))){W=!1;break}}return R.delete(l),R.delete(o),W}function Tn(l,o,d,f,C,R,j){switch(d){case ct:if(l.byteLength!=o.byteLength||l.byteOffset!=o.byteOffset)return!1;l=l.buffer,o=o.buffer;case Te:return!(l.byteLength!=o.byteLength||!R(new ze(l),new ze(o)));case m:case v:case O:return It(+l,+o);case w:return l.name==o.name&&l.message==o.message;case k:case X:return l==o+"";case S:var D=pt;case Q:var E=f&i;if(D||(D=tr),l.size!=o.size&&!E)return!1;var F=j.get(l);if(F)return F==o;f|=a,j.set(l,o);var q=Bt(D(l),D(o),f,C,R,j);return j.delete(l),q;case te:if(Se)return Se.call(l)==Se.call(o)}return!1}function Rn(l,o,d,f,C,R){var j=d&i,D=lr(l),E=D.length,F=lr(o),q=F.length;if(E!=q&&!j)return!1;for(var W=E;W--;){var G=D[W];if(!(j?G in o:ce.call(o,G)))return!1}var ne=R.get(l);if(ne&&R.get(o))return ne==o;var ie=!0;R.set(l,o),R.set(o,l);for(var ve=j;++W<E;){G=D[W];var je=l[G],et=o[G];if(f)var li=j?f(et,je,G,o,l,R):f(je,et,G,l,o,R);if(!(li===void 0?je===et||C(je,et,d,f,R):li)){ie=!1;break}ve||(ve=G=="constructor")}if(ie&&!ve){var fr=l.constructor,hr=o.constructor;fr!=hr&&"constructor"in l&&"constructor"in o&&!(typeof fr=="function"&&fr instanceof fr&&typeof hr=="function"&&hr instanceof hr)&&(ie=!1)}return R.delete(l),R.delete(o),ie}function lr(l){return On(l,Pn,An)}function Ye(l,o){var d=l.__data__;return kn(o)?d[typeof o=="string"?"string":"hash"]:d.map}function Ke(l,o){var d=Tt(l,o);return Dt(d)?d:void 0}function _n(l){var o=ce.call(l,Re),d=l[Re];try{l[Re]=void 0;var f=!0}catch{}var C=At.call(l);return f&&(o?l[Re]=d:delete l[Re]),C}var An=jt?function(l){return l==null?[]:(l=Object(l),Hr(jt(l),function(o){return ir.call(l,o)}))}:Dn,pe=Ve;(ge&&pe(new ge(new ArrayBuffer(1)))!=ct||He&&pe(new He)!=S||kt&&pe(kt.resolve())!=P||Et&&pe(new Et)!=Q||Ft&&pe(new Ft)!=Y)&&(pe=function(l){var o=Ve(l),d=o==A?l.constructor:void 0,f=d?Ie(d):"";if(f)switch(f){case me:return ct;case tn:return S;case rn:return P;case nn:return Q;case on:return Y}return o});function jn(l,o){return o=o??c,!!o&&(typeof l=="number"||Yt.test(l))&&l>-1&&l%1==0&&l<o}function kn(l){var o=typeof l;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?l!=="__proto__":l===null}function En(l){return!!_t&&_t in l}function wt(l){var o=l&&l.constructor,d=typeof o=="function"&&o.prototype||ft;return l===d}function Lt(l){return At.call(l)}function Ie(l){if(l!=null){try{return Rt.call(l)}catch{}try{return l+""}catch{}}return""}function It(l,o){return l===o||l!==l&&o!==o}var Fn=cr(function(){return arguments}())?cr:function(l){return Qe(l)&&ce.call(l,"callee")&&!ir.call(l,"callee")},Ze=Array.isArray;function Kt(l){return l!=null&&ur(l.length)&&!Me(l)}var vt=Je||pr;function Ae(l,o){return dr(l,o)}function Me(l){if(!Mt(l))return!1;var o=Ve(l);return o==b||o==x||o==h||o==$}function ur(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=c}function Mt(l){var o=typeof l;return l!=null&&(o=="object"||o=="function")}function Qe(l){return l!=null&&typeof l=="object"}var Ut=er?Yr(er):Cn;function Pn(l){return Kt(l)?xn(l):Nn(l)}function Dn(){return[]}function pr(){return!1}e.exports=Ae})(xr,xr.exports);var Vc=xr.exports;const Yc=ei(Vc),it="other";function qe(e){return e.mapToName!==void 0}function Zc(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function Qc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!qe(r)&&!!r.fieldName))||null}function ed(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>qe(n)&&!!n.mapToName))||[]}function td(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!qe(r)&&!!r.fieldName))||null}const to=(e,t)=>{var r,n,i;return(i=(n=(r=e==null?void 0:e.content)==null?void 0:r.read)==null?void 0:n.objects)==null?void 0:i[t]};function rd(e){return qe(e)?e.mapToName:e.fieldName}const ro=(e,t)=>{var n,i,a;const r=[];return(a=(i=(n=t.content)==null?void 0:n.read)==null?void 0:i.objects)==null||a.forEach(c=>{r.push({name:c==null?void 0:c.objectName,completed:e?!!to(e,c.objectName):!1})}),r},no=e=>{var r;return{name:it,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function nd(e,t){var a;const r=ro(e,t),i=!!((a=t==null?void 0:t.content)!=null&&a.write)?no(e):void 0;return i&&r.push(i),r}function io(e,t,r){const n=(e==null?void 0:e.filter(a=>!(t!=null&&t[a==null?void 0:a.mapToName])))||[],i=n.map(a=>a.mapToName);return r(V.MAPPING,i),n!=null&&n.length&&console.error("required fields not met",n.map(a=>a.mapToDisplayName)),{errorList:i}}function ti(e,t){return Yc(e,t)}const id=(e,t,r)=>{var b,x,S,O,T,A;if(!e)return null;const n=Zc(e,t),i=n&&Qc(n),a=n&&td(n),c=n&&ed(n),u=(n==null?void 0:n.allFields)||[],p=r==null?void 0:r.content,h=((S=(x=(b=p==null?void 0:p.read)==null?void 0:b.objects)==null?void 0:x[t])==null?void 0:S.selectedFields)||{},m=((A=(T=(O=p==null?void 0:p.read)==null?void 0:O.objects)==null?void 0:T[t])==null?void 0:A.selectedFieldMappings)||{},v={...h},w={...m};return{allFields:u,requiredFields:i,optionalFields:a,requiredMapFields:c,selectedOptionalFields:h,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:v,requiredMapFields:w}}},od=(e,t)=>{var c,u;if(!e)return null;const r=(u=(c=t==null?void 0:t.content)==null?void 0:c.write)==null?void 0:u.objects,n=Object.keys(r||{}),i={};n.forEach(p=>{i[p]=!0});const a={...i};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:i,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:a}}};function oo(e,t,r){var a,c;const n=(a=e==null?void 0:e.content)==null?void 0:a.read,i=(c=e==null?void 0:e.content)==null?void 0:c.write;return{read:id(n,t,r),write:od(i,r)}}const ao=(e,t,r,n)=>{const i=oo(e,r,t);n(r,i)},ad=(e,t,r)=>{const n=nd(t,e),i={};n.forEach(({name:a,completed:c})=>{c&&(i[a]=oo(e,a,t))}),r(i)},so=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(rd(a))),{...Array.from(n).reduce((a,c)=>({...a,[c]:!0}),{}),...r||{}}},co=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},r={};return t&&Object.keys(t).forEach(n=>{t[n]!==void 0?r[n]=t[n]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${n}`)}),r};function lo(e,t){return t[e]||void 0}function ri({createConfig:e,projectId:t,integrationId:r,groupRef:n,connectionId:i,apiKey:a,setInstallation:c,onInstallSuccess:u}){const p={projectIdOrName:t,integrationId:r,installation:{groupRef:n,connectionId:i,config:e}};return H().installationApi.createInstallation(p,{headers:{"X-Api-Key":a,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{console.error("ERROR: ",h)})}function Ar(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const sd=(e,t)=>{const r=e.content.read,n=r==null?void 0:r.objects;return n==null?void 0:n.find(i=>i.objectName===t)},cd=(e,t,r,n)=>{const i=so(e),a=co(e),c=sd(r,t);if(!c)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const u={revisionId:r.id,createdBy:`consumer:${n}`,content:{provider:r.content.provider,read:{objects:{[t]:{objectName:t,schedule:c.schedule,destination:c.destination,selectedFields:i,selectedFieldMappings:a,backfill:c.backfill}}}}};return Ar(r)&&(u.content.proxy={enabled:!0}),u},dd=(e,t,r,n,i,a,c,u,p,h,m)=>{const v=cd(p,a,u,n);return v?ri({createConfig:v,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:c,setInstallation:h,onInstallSuccess:m}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},uo=e=>{var a,c;const t={},r=(a=e.write)==null?void 0:a.writeObjects,n=(c=e.write)==null?void 0:c.selectedNonConfigurableWriteFields,i=n?Object.keys(n):[];return r&&r.forEach(u=>{const p=u.objectName;i.includes(p)&&(t[p]={objectName:p})}),t},ld=e=>{const t=e.content.write;return t==null?void 0:t.objects},ud=(e,t,r)=>{if(!ld(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=uo(e),a={revisionId:t.id,createdBy:`consumer:${r}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return Ar(t)&&(a.content.proxy={enabled:!0}),a},pd=(e,t,r,n,i,a,c,u,p,h)=>{const m=ud(u,c,n);return m?ri({createConfig:m,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setInstallation:p,onInstallSuccess:h}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))};function fd(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M14.25 4.5V15C14.25 15.3978 14.092 15.7794 13.8107 16.0607C13.5294 16.342 13.1478 16.5 12.75 16.5H5.25C4.85218 16.5 4.47064 16.342 4.18934 16.0607C3.90804 15.7794 3.75 15.3978 3.75 15V4.5M6 4.5V3C6 2.60218 6.15804 2.22064 6.43934 1.93934C6.72064 1.65804 7.10218 1.5 7.5 1.5H10.5C10.8978 1.5 11.2794 1.65804 11.5607 1.93934C11.842 2.22064 12 2.60218 12 3V4.5",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const po="uninstall-installation",hd=I.forwardRef(({text:e="Uninstall"},t)=>{const r=y.useTab({ref:t}),n=y.useMultiStyleConfig("Tabs",r);return s.jsxs(y.Button,{__css:n.warningTab,...r,minHeight:15,children:[s.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[fd(),s.jsx(y.Box,{textAlign:"left",children:s.jsx(y.Text,{color:"red.800",children:e})})]}),r.children]})}),fo=I.createContext({hydratedRevision:null,loading:!1}),Xt=()=>{const e=I.useContext(fo);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function gd({projectId:e,children:t}){var P;const{selectedConnection:r}=xt(),{integrationId:n,integrationObj:i}=Ne(),[a,c]=I.useState(null),[u,p]=I.useState(!0),{isError:h,removeError:m,setError:v}=We(),w=ee(),b=r==null?void 0:r.id,x=(P=i==null?void 0:i.latestRevision)==null?void 0:P.id,S=(i==null?void 0:i.name)||n;I.useEffect(()=>{e&&n&&x&&b&&w&&H().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:n,revisionId:x,connectionId:b},{headers:{"X-Api-Key":w??""}}).then($=>{c($),p(!1),m(V.HYDRATED_REVISION,S)}).catch($=>{console.error(`Error loading integration ${S}`,$),p(!1),v(V.HYDRATED_REVISION,S)})},[e,n,x,b,w,m,v,S]);const O=I.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),A=`Error retrieving integration details for '${(i==null?void 0:i.name)||n||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return s.jsx(fo.Provider,{value:O,children:h(V.HYDRATED_REVISION,S)?s.jsx(Fe,{message:A}):t})}function ho(){return s.jsxs("footer",{style:{backgroundColor:"#EFEFEF",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[s.jsx("p",{children:"Secured by"}),s.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:s.jsx("img",{style:{height:".8em"},src:"https://ampersand-website.vercel.app/logo-black.svg",alt:"Ampersand"})})]})}var go=Symbol.for("immer-nothing"),mi=Symbol.for("immer-draftable"),de=Symbol.for("immer-state"),md=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function se(e,...t){if(process.env.NODE_ENV!=="production"){const r=md[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var bt=Object.getPrototypeOf;function St(e){return!!e&&!!e[de]}function ot(e){var t;return e?mo(e)||Array.isArray(e)||!!e[mi]||!!((t=e.constructor)!=null&&t[mi])||kr(e)||Er(e):!1}var yd=Object.prototype.constructor.toString();function mo(e){if(!e||typeof e!="object")return!1;const t=bt(e);if(t===null)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===yd}function Or(e,t){jr(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function jr(e){const t=e[de];return t?t.type_:Array.isArray(e)?1:kr(e)?2:Er(e)?3:0}function $n(e,t){return jr(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function yo(e,t,r){const n=jr(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function wd(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kr(e){return e instanceof Map}function Er(e){return e instanceof Set}function tt(e){return e.copy_||e.base_}function qn(e,t){if(kr(e))return new Map(e);if(Er(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=mo(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[de];let i=Reflect.ownKeys(n);for(let a=0;a<i.length;a++){const c=i[a],u=n[c];u.writable===!1&&(u.writable=!0,u.configurable=!0),(u.get||u.set)&&(n[c]={configurable:!0,writable:!0,enumerable:u.enumerable,value:e[c]})}return Object.create(bt(e),n)}else{const n=bt(e);if(n!==null&&r)return{...e};const i=Object.create(n);return Object.assign(i,e)}}function ni(e,t=!1){return Fr(e)||St(e)||!ot(e)||(jr(e)>1&&(e.set=e.add=e.clear=e.delete=Id),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>ni(n,!0))),e}function Id(){se(2)}function Fr(e){return Object.isFrozen(e)}var vd={};function at(e){const t=vd[e];return t||se(0,e),t}var Jt;function wo(){return Jt}function bd(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yi(e,t){t&&(at("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Wn(e){zn(e),e.drafts_.forEach(Sd),e.drafts_=null}function zn(e){e===Jt&&(Jt=e.parent_)}function wi(e){return Jt=bd(Jt,e)}function Sd(e){const t=e[de];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ii(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[de].modified_&&(Wn(t),se(4)),ot(e)&&(e=Cr(t,e),t.parent_||Nr(t,e)),t.patches_&&at("Patches").generateReplacementPatches_(r[de].base_,e,t.patches_,t.inversePatches_)):e=Cr(t,r,[]),Wn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==go?e:void 0}function Cr(e,t,r){if(Fr(t))return t;const n=t[de];if(!n)return Or(t,(i,a)=>vi(e,n,t,i,a,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return Nr(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let a=i,c=!1;n.type_===3&&(a=new Set(i),i.clear(),c=!0),Or(a,(u,p)=>vi(e,n,i,u,p,r,c)),Nr(e,i,!1),r&&e.patches_&&at("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function vi(e,t,r,n,i,a,c){if(process.env.NODE_ENV!=="production"&&i===r&&se(5),St(i)){const u=a&&t&&t.type_!==3&&!$n(t.assigned_,n)?a.concat(n):void 0,p=Cr(e,i,u);if(yo(r,n,p),St(p))e.canAutoFreeze_=!1;else return}else c&&r.add(i);if(ot(i)&&!Fr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Cr(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Nr(e,i)}}function Nr(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ni(t,r)}function xd(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:wo(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,a=ii;r&&(i=[n],a=Ht);const{revoke:c,proxy:u}=Proxy.revocable(i,a);return n.draft_=u,n.revoke_=c,u}var ii={get(e,t){if(t===de)return e;const r=tt(e);if(!$n(r,t))return Od(e,r,t);const n=r[t];return e.finalized_||!ot(n)?n:n===Ln(e.base_,t)?(Kn(e),e.copy_[t]=Hn(n,e)):n},has(e,t){return t in tt(e)},ownKeys(e){return Reflect.ownKeys(tt(e))},set(e,t,r){const n=Io(tt(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=Ln(tt(e),t),a=i==null?void 0:i[de];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(wd(r,i)&&(r!==void 0||$n(e.base_,t)))return!0;Kn(e),Jn(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ln(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Kn(e),Jn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=tt(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){se(11)},getPrototypeOf(e){return bt(e.base_)},setPrototypeOf(){se(12)}},Ht={};Or(ii,(e,t)=>{Ht[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ht.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&se(13),Ht.set.call(this,e,t,void 0)};Ht.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&se(14),ii.set.call(this,e[0],t,r,e[0])};function Ln(e,t){const r=e[de];return(r?tt(r):e)[t]}function Od(e,t,r){var i;const n=Io(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function Io(e,t){if(!(t in e))return;let r=bt(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=bt(r)}}function Jn(e){e.modified_||(e.modified_=!0,e.parent_&&Jn(e.parent_))}function Kn(e){e.copy_||(e.copy_=qn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Cd=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const a=r;r=t;const c=this;return function(p=a,...h){return c.produce(p,m=>r.call(this,m,...h))}}typeof r!="function"&&se(6),n!==void 0&&typeof n!="function"&&se(7);let i;if(ot(t)){const a=wi(this),c=Hn(t,void 0);let u=!0;try{i=r(c),u=!1}finally{u?Wn(a):zn(a)}return yi(a,n),Ii(i,a)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===go&&(i=void 0),this.autoFreeze_&&ni(i,!0),n){const a=[],c=[];at("Patches").generateReplacementPatches_(t,i,a,c),n(a,c)}return i}else se(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(c,...u)=>this.produceWithPatches(c,p=>t(p,...u));let n,i;return[this.produce(t,r,(c,u)=>{n=c,i=u}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ot(e)||se(8),St(e)&&(e=Nd(e));const t=wi(this),r=Hn(e,void 0);return r[de].isManual_=!0,zn(t),r}finishDraft(e,t){const r=e&&e[de];(!r||!r.isManual_)&&se(9);const{scope_:n}=r;return yi(n,t),Ii(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=at("Patches").applyPatches_;return St(e)?n(e,t):this.produce(e,i=>n(i,t))}};function Hn(e,t){const r=kr(e)?at("MapSet").proxyMap_(e,t):Er(e)?at("MapSet").proxySet_(e,t):xd(e,t);return(t?t.scope_:wo()).drafts_.push(r),r}function Nd(e){return St(e)||se(10,e),vo(e)}function vo(e){if(!ot(e)||Fr(e))return e;const t=e[de];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=qn(e,t.scope_.immer_.useStrictShallowCopy_)}else r=qn(e,!0);return Or(r,(n,i)=>{yo(r,n,vo(i))}),t&&(t.finalized_=!1),r}var le=new Cd,qt=le.produce;le.produceWithPatches.bind(le);le.setAutoFreeze.bind(le);le.setUseStrictShallowCopy.bind(le);le.applyPatches.bind(le);le.createDraft.bind(le);le.finishDraft.bind(le);const bo=I.createContext(void 0),Td={};function oi(){const e=I.useContext(bo);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function Rd({children:e}){const{installation:t}=Ne(),{hydratedRevision:r,loading:n}=Xt(),[i,a]=I.useState(Td),c=t==null?void 0:t.config;I.useEffect(()=>{r!=null&&r.content&&!n&&c&&!(Object.entries(i).length>0)&&ad(r,c,a)},[r,n,c,i]);const u=I.useCallback((b,x)=>{a(S=>qt(S,O=>{O[b]=qt(O[b],x)}))},[a]),p=I.useCallback((b,x)=>{a(S=>qt(S,O=>{O[b]=x}))},[a]),h=I.useCallback(()=>{a(qt(b=>{const x=b.other.write;x&&(x.isWriteModified=!1)}))},[a]),m=I.useCallback(b=>{a(qt(x=>{var O;const S=(O=x[b])==null?void 0:O.read;S&&(S.isOptionalFieldsModified=!1,S.isRequiredMapFieldsModified=!1)}))},[a]),v=I.useCallback(b=>{b===it?h():m(b)},[m,h]),w=I.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:v}),[i,p,v,u]);return s.jsx(bo.Provider,{value:w,children:e})}const _d=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[s.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),s.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function Ad(e,t){return t?I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},I.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?_d:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:s.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}const So=I.forwardRef(({objectName:e,completed:t,pending:r,displayName:n},i)=>{const a=y.useTab({ref:i}),c=y.useMultiStyleConfig("Tabs",a);return s.jsxs(y.Button,{__css:c.tab,...a,variant:"outline",minHeight:15,children:[s.jsxs(y.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[Ad(t,r),s.jsxs(y.Box,{textAlign:"left",children:[s.jsx(y.Text,{children:n||e}),r&&s.jsx(y.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function jd({pending:e,completed:t,displayName:r}){return s.jsxs(s.Fragment,{children:[s.jsx(y.Divider,{marginY:3}),s.jsx(So,{objectName:it,completed:t,pending:e,displayName:r},"other-write")]})}const xo=I.createContext(null);function Oo(){const e=I.useContext(xo);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function kd(e,t){return e!=null&&e[t]?e[t]:{name:po,completed:!1}}function Ed({children:e}){var O,T,A;const{project:t}=Z(),{installation:r,provider:n}=Ne(),{hydratedRevision:i}=Xt(),{objectConfigurationsState:a}=oi(),[c,u]=I.useState(0),p=(t==null?void 0:t.appName)||"",h=r==null?void 0:r.config,m=i&&ro(h,i),v=m!==null,w=!!((O=i==null?void 0:i.content)!=null&&O.write),b=w?no(h):void 0,x=[...m||[]];b&&w&&x.push(b);const S=kd(x,c);return s.jsx(xo.Provider,{value:S==null?void 0:S.name,children:s.jsxs(y.Container,{maxWidth:"55rem",children:[s.jsxs(y.Box,{p:8,borderRadius:4,margin:"auto",display:"flex",gap:"6",minHeight:"100%",fontSize:"md",backgroundColor:"#FCFCFC",border:"1px solid #EFEFEF",boxShadow:"0px 4px 8px rgba(0, 0, 0, 0.05)",children:[s.jsxs(y.Box,{width:"20rem",children:[s.jsxs(y.Text,{children:[st(n)," integration"]}),s.jsx(y.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),v&&s.jsxs(y.Tabs,{index:c,onChange:u,orientation:"horizontal",children:[m.map(P=>{var $,k,Q,X;return s.jsx(So,{objectName:P.name,completed:P.completed,pending:((k=($=a[P.name])==null?void 0:$.read)==null?void 0:k.isOptionalFieldsModified)||((X=(Q=a[P.name])==null?void 0:Q.read)==null?void 0:X.isRequiredMapFieldsModified)},P.name)}),w&&b&&s.jsx(jd,{completed:b.completed,pending:(A=(T=a==null?void 0:a.other)==null?void 0:T.write)==null?void 0:A.isWriteModified,displayName:m!=null&&m.length?"other":"write"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(y.Divider,{marginTop:10,marginBottom:3}),s.jsx(hd,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]}),s.jsx(ho,{})]})})}const Ot=()=>{const{appName:e}=Z(),{objectConfigurationsState:t,setConfigureState:r}=oi(),{selectedObjectName:n}=Oo(),i=lo(n||"",t);return{appName:e,configureState:i,setConfigureState:r,selectedObjectName:n}};function Fd(e,t,r){var i;const n=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(n[t]=r,e!=null&&e.read){const a=e.read.savedConfig.requiredMapFields,u=!ti(a,n);e.read.isRequiredMapFieldsModified=u}}function Co(e,t,r,n){t(e,i=>Fd(i,r,n))}function Pd({field:e,onSelectChange:t,allFields:r}){var v;const{configureState:n,selectedObjectName:i,setConfigureState:a}=Ot(),[c,u]=I.useState(!0),p=(v=n==null?void 0:n.read)==null?void 0:v.selectedFieldMappings,h=p==null?void 0:p[e.mapToName];I.useEffect(()=>{e._default&&!h&&i&&n&&Co(i,a,e.mapToName,e._default),u(!1)},[e,a,i,h,n]);const m=I.useMemo(()=>r==null?void 0:r.map(w=>s.jsx("option",{value:w.fieldName,children:w.displayName},w.fieldName)),[r]);return s.jsxs(y.Stack,{children:[s.jsx(y.Text,{fontWeight:"500",children:e.mapToDisplayName}),s.jsx(y.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),s.jsx(y.Select,{name:e.mapToName,variant:"flushed",value:h||void 0,onChange:t,placeholder:h?void 0:"Please select one",disabled:c,children:m})]},e.mapToName)}function Pr({string:e}){return s.jsxs(y.Flex,{position:"relative",paddingTop:8,paddingBottom:4,children:[s.jsx(y.Heading,{color:"gray.500",as:"h3",fontSize:16,fontWeight:"500",children:e}),s.jsx(y.Flex,{flex:"1",justifyContent:"flex-end",alignItems:"center",children:s.jsx(y.Divider,{marginLeft:2})})]})}function Dd(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Ot(),{isError:n,removeError:i}=We(),a=u=>{const{value:p,name:h}=u.target;p&&(e&&Co(e,r,h,p),n(V.MAPPING,h)&&i(V.MAPPING,h))},c=I.useMemo(()=>{var u,p;return((p=(u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)==null?void 0:p.filter(qe))||[]},[t]);return c.length?s.jsxs(y.Box,{children:[s.jsx(Pr,{string:"Map the following fields (required)"}),s.jsx(y.Stack,{children:c.map(u=>{var p;return s.jsxs(y.FormControl,{isInvalid:n(V.MAPPING,u.mapToName),children:[s.jsx(Pd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),s.jsx(y.FormErrorMessage,{children:" * required"})]},u.mapToName)})})]}):null}function Bd(e,t,r){var i,a;const n=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(n[t]=r,r||delete n[t],(a=e.read)!=null&&a.savedConfig.optionalFields){const c=e.read.savedConfig.optionalFields,p=!ti(c,n);e.read.isOptionalFieldsModified=p}else console.warn("read.savedConfig.optionalFields is undefined")}function bi(e,t,r,n){t(e,i=>Bd(i,r,n))}function Ld(){var v,w;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Ot(),i=(v=t==null?void 0:t.read)==null?void 0:v.selectedOptionalFields,a=b=>{const{name:x,checked:S}=b.target;n&&t&&bi(n,r,x,S)},c=(w=t==null?void 0:t.read)==null?void 0:w.optionalFields,u=b=>{const{checked:x}=b.target;n&&c&&c.forEach(S=>{qe(S)||bi(n,r,S.fieldName,x)})},p=!!(c&&c.length>0),h=Object.keys(i||{}).length===(c==null?void 0:c.length),m=!h&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${e} reads the following optional fields`}),s.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((c==null?void 0:c.length)||0)>=2&&s.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:h,children:"Select all"})}),c.map(b=>qe(b)?null:s.jsx(y.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:s.jsx(y.Checkbox,{name:b.fieldName,id:b.fieldName,isChecked:!!(i!=null&&i[b==null?void 0:b.fieldName]),onChange:a,children:b.displayName})},b.fieldName))]})]})}function Kd(){var n,i,a;const{configureState:e,selectedObjectName:t}=Ot(),{appName:r}=Z();return s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`${r} reads the following ${t} fields`}),s.jsx(y.Box,{marginBottom:"20px",display:"flex",gap:1,children:(i=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&i.length?(a=e.read)==null?void 0:a.requiredFields.map(c=>qe(c)?null:s.jsx(y.Tag,{children:c.displayName},c.fieldName)):"There are no required fields."})]})}function Md(){return s.jsxs(s.Fragment,{children:[s.jsx(Kd,{}),s.jsx(Dd,{}),s.jsx(Ld,{})]})}function Ud(e,t,r){var n,i,a;if(((n=e==null?void 0:e.write)==null?void 0:n.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const c=e.write.selectedNonConfigurableWriteFields;if(c[t]=r,r||delete c[t],(a=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&a.selectedNonConfigurableWriteFields){const u=e.write.savedConfig.selectedNonConfigurableWriteFields,h=!ti(u,c);e.write.isWriteModified=h}}}function Si(e,t,r,n){t(e,i=>{Ud(i,r,n)})}function $d(){var v,w,b,x;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Ot(),i=(v=r==null?void 0:r.write)==null?void 0:v.selectedNonConfigurableWriteFields,a=(w=r==null?void 0:r.write)==null?void 0:w.writeObjects,c=S=>{const{name:O,checked:T}=S.target;t&&r&&Si(t,n,O,T)},u=S=>{var T,A;const{checked:O}=S.target;t&&r&&((A=(T=r==null?void 0:r.write)==null?void 0:T.writeObjects)==null||A.forEach(P=>{Si(t,n,P.objectName,O)}))},p=!!a,h=Object.keys(i||{}).length===((x=(b=r==null?void 0:r.write)==null?void 0:b.writeObjects)==null?void 0:x.length),m=!h&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Pr,{string:`Allow ${e} to write to these object`}),s.jsxs(y.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((a==null?void 0:a.length)||0)>=2&&s.jsx(y.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:h,children:"Select all"})}),a.map(S=>s.jsx(y.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:s.jsx(y.Checkbox,{name:S.objectName,id:S.objectName,onChange:c,isChecked:!!(i!=null&&i[S.objectName]),children:S.displayName})},S.objectName))]})]})}function qd(){const e=ee(),{projectId:t,appName:r}=Z(),{integrationId:n,installation:i,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:u}=Ne(),[p,h]=I.useState(!1),m=!t||!n||!(i!=null&&i.id)||p,v=async()=>{if(!m){h(!0),console.warn("uninstalling installation",{projectId:t,integrationId:n,installationId:i.id});try{await H().installationApi.deleteInstallation({projectIdOrName:t,integrationId:n,installationId:i.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation: ",i.id),u==null||u(i==null?void 0:i.id),a(),c()}catch(x){console.error("error uninstalling installation",x)}finally{h(!1)}}},w=p?"Uninstalling...":"Yes, uninstall",b=i!=null&&i.id?`Once you uninstall this integration, all your configuration will be lost, and "${r}" may stop working.`:"You've successfully uninstalled the integration.";return s.jsxs(y.Stack,{children:[s.jsx(y.Text,{paddingBottom:3,children:b}),(i==null?void 0:i.id)&&s.jsx(y.Button,{onClick:v,variant:"warning",isDisabled:m,children:w})]})}function No({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1}){var P,$,k;const{installation:i}=Ne(),{hydratedRevision:a,loading:c}=Xt(),{configureState:u,selectedObjectName:p}=Ot(),h=i==null?void 0:i.config,m=h&&p&&!!to(h,p)||!1,v=((P=u==null?void 0:u.read)==null?void 0:P.isOptionalFieldsModified)||(($=u==null?void 0:u.read)==null?void 0:$.isRequiredMapFieldsModified),w=(k=u==null?void 0:u.write)==null?void 0:k.isWriteModified,O=c||r||!u||!p||!(v||w||n||p!==it&&!m),T=p===it,A=p===po;return r?s.jsx(Ce,{}):s.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[s.jsxs(y.Stack,{direction:"row",spacing:4,marginBottom:"20px",flexDir:"row-reverse",children:[s.jsx(y.Button,{variant:"primary",type:"submit",isDisabled:O,children:n?"Install":"Save"}),s.jsx(y.Button,{isDisabled:O,onClick:t,children:"Reset"})]}),s.jsxs(y.Box,{p:8,borderRadius:4,boxShadow:"sm",margin:"auto",backgroundColor:"white",border:"1px solid gray.100",minHeight:300,children:[c&&s.jsx(Ce,{}),a&&!A&&!T&&s.jsx(Md,{}),a&&!A&&T&&s.jsx($d,{}),!c&&A&&s.jsx(qd,{})]})]})}const To=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:i,onUpdateSuccess:a}=Ne(),{hydratedRevision:c,loading:u}=Xt(),{selectedObjectName:p}=Oo(),{selectedConnection:h}=xt(),m=ee(),{projectId:v}=Z(),{resetBoundary:w,setErrors:b}=We(),{resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O}=oi(),T=lo(p||"",S);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:c,loading:u,selectedObjectName:p,selectedConnection:h,apiKey:m,projectId:v,resetBoundary:w,setErrors:b,resetConfigureState:x,objectConfigurationsState:S,resetPendingConfigurationState:O,configureState:T,onInstallSuccess:i,onUpdateSuccess:a}},Wd=void 0;function zd(){const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:i,loading:a,selectedObjectName:c,selectedConnection:u,apiKey:p,projectId:h,resetBoundary:m,setErrors:v,resetConfigureState:w,objectConfigurationsState:b,resetPendingConfigurationState:x,configureState:S,onInstallSuccess:O}=To(),[T,A]=I.useState(!1),P=c===it,$=I.useCallback(()=>{m(V.MAPPING),i!=null&&i.content&&!a&&c&&ao(i,Wd,c,w)},[m,i,a,c,w]);I.useEffect(()=>{!S&&(i!=null&&i.content)&&!a&&$()},[S,b,i,a,$]);const k=()=>{const{requiredMapFields:te,selectedFieldMappings:J}=(S==null?void 0:S.read)||{},{errorList:Y}=io(te,J,v);Y.length>0||(c&&(u!=null&&u.id)&&p&&h&&e&&t&&r&&i?(A(!0),dd(h,e,t,r,u.id,c,p,i,S,n,O).finally(()=>{A(!1),x(c)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},Q=()=>{c&&(u!=null&&u.id)&&p&&h&&e&&t&&r&&i?(A(!0),pd(h,e,t,r,u.id,p,i,S,n,O).finally(()=>{A(!1),x(c)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},X=te=>{te.preventDefault(),P?Q():k()};return s.jsx(No,{isCreateMode:!0,isLoading:T,onSave:X,onReset:$})}function Jd({updateConfig:e,projectId:t,integrationId:r,installationId:n,apiKey:i,selectedObjectName:a,setInstallation:c,onUpdateSuccess:u}){const p={projectIdOrName:t,installationId:n,integrationId:r,installationUpdate:{updateMask:[`config.content.read.objects.${a}`],installation:{config:e}}};return H().installationApi.updateInstallation(p,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{console.error("ERROR: ",h)})}const Hd=(e,t,r,n,i,a)=>{const c=so(e),u=co(e),p={content:{read:{objects:{[t]:{objectName:t,schedule:n,destination:(r==null?void 0:r.destination)||"",selectedFields:c,selectedFieldMappings:u,backfill:a}}}}};return Ar(i)&&(p.content||(p.content={}),p.content.proxy={enabled:!0}),p},Xd=(e,t,r,n,i,a,c,u,p,h)=>{const m=Hd(a,n||"",u,u.schedule,p,u.backfill);return m?Jd({updateConfig:m,projectId:e,integrationId:t,installationId:r,apiKey:i,selectedObjectName:n,setInstallation:c,onUpdateSuccess:h}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Gd=(e,t)=>{const n={content:{write:{objects:uo(e)}}};return Ar(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},Vd=(e,t,r,n,i,a,c,u)=>{const p=Gd(i,a);if(!p)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const h={projectIdOrName:e,installationId:r,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:p}}};return H().installationApi.updateInstallation(h,{headers:{"X-Api-Key":n,"Content-Type":"application/json"}}).then(m=>{c(m),u==null||u(m.id,m.config)}).catch(m=>{console.error("ERROR: ",m)})};function Yd({installation:e,integrationObj:t}){const{setInstallation:r,hydratedRevision:n,loading:i,selectedObjectName:a,apiKey:c,projectId:u,resetBoundary:p,setErrors:h,resetConfigureState:m,resetPendingConfigurationState:v,configureState:w,onUpdateSuccess:b}=To(),[x,S]=I.useState(!1),O=a===it,{config:T}=e,A=I.useCallback(()=>{p(V.MAPPING),n!=null&&n.content&&!i&&a&&ao(n,T,a,m)},[p,n,i,a,T,m]);I.useEffect(()=>{w||A()},[w,A]),I.useEffect(()=>{e&&A()},[e,A]);const P=I.useMemo(()=>{var te,J,Y;return(Y=(J=(te=n==null?void 0:n.content)==null?void 0:te.read)==null?void 0:J.objects)==null?void 0:Y.find(Te=>(Te==null?void 0:Te.objectName)===a)},[n,a]),$=()=>{const{requiredMapFields:X,selectedFieldMappings:te}=(w==null?void 0:w.read)||{},{errorList:J}=io(X,te,h);J.length>0||(n&&e&&a&&c&&u&&P?(S(!0),Xd(u,t.id,e.id,a,c,w,r,P,n,b).finally(()=>{S(!1),v(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},k=()=>{e&&a&&c&&u&&n?(S(!0),Vd(u,t.id,e.id,c,w,n,r,b).finally(()=>{S(!1),v(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},Q=X=>{X.preventDefault(),O?k():$()};return s.jsx(No,{onSave:Q,onReset:A,isLoading:x})}function Zd(){const{integrationObj:e,installation:t}=Ne();return e?t&&e?s.jsx(Yd,{installation:t,integrationObj:e}):s.jsx(zd,{}):s.jsx(Fe,{message:"We can't load the integration"})}function Qd(){return s.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),s.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ai({text:e}){return s.jsx(y.Container,{children:s.jsxs(y.Box,{p:8,maxWidth:"600px",minHeight:"290px",borderWidth:1,borderRadius:8,boxShadow:"lg",margin:"auto",marginTop:"40px",bgColor:"white",paddingTop:"100px",color:"gray.800",fontSize:"md",children:[s.jsx(y.Box,{width:"100%",display:"flex",alignContent:"center",justifyContent:"center",children:s.jsx(y.Box,{margin:"auto",children:s.jsx(Qd,{})})}),s.jsx(y.Box,{textAlign:"center",paddingTop:"25px",children:e})]})})}const el=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function tl({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:i,apiKey:a,hydratedRevision:c,setInstallation:u,onInstallSuccess:p}){const h=el(c,n);return h?ri({createConfig:h,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setInstallation:u,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function rl({provider:e}){const t=`You have successfully installed your ${st(e)} integration.`;return s.jsx(ai,{text:t})}const nl=e=>{const{read:t,write:r,proxy:n}=(e==null?void 0:e.content)??{};return!t&&!r&&(n==null?void 0:n.enabled)||!1};function il({children:e}){var A;const{projectId:t}=Z(),r=ee(),{hydratedRevision:n,loading:i}=Xt(),{integrationObj:a,installation:c,groupRef:u,consumerRef:p,setInstallation:h,onInstallSuccess:m,isIntegrationDeleted:v}=Ne(),{selectedConnection:w}=xt(),[b,x]=I.useState(!1),S=i||b,O=(A=n==null?void 0:n.content)==null?void 0:A.provider,T=nl(n);return I.useEffect(()=>{!S&&n&&T&&!c&&w&&r&&(a!=null&&a.id)&&(x(!0),tl({apiKey:r,projectId:t,integrationId:a==null?void 0:a.id,groupRef:u,consumerRef:p,connectionId:w==null?void 0:w.id,hydratedRevision:n,setInstallation:h,onInstallSuccess:m}).then(()=>{x(!1)}).catch(P=>{x(!1),console.error("Error when creating proxy installation:",P)}))},[n,T,c,w,r,t,a==null?void 0:a.id,u,p,h,S,m]),a?S?s.jsx(Ce,{}):T&&O&&c?s.jsx(rl,{provider:O}):v?s.jsx(ai,{text:"Integration successfully uninstalled."}):s.jsx("div",{children:e}):s.jsx(Fe,{message:"We can't load the integration"})}function ol({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function al({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function Ro({url:e,providerDisplayName:t,credentialName:r}){return s.jsxs(y.Text,{align:"left",color:"darkgray",children:[s.jsx(y.Link,{href:e,target:"_blank",rel:"noreferrer",color:"blackAlpha.600",isExternal:!0,children:s.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",r,"."]})}function sl({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var S;const[a,c]=I.useState(!1),u=()=>c(!a),[p,h]=I.useState(""),m=O=>h(O.currentTarget.value),v=p.length>0,w=i||!v,b=st(e,t),x=(S=t.apiKeyOpts)==null?void 0:S.docsURL;return s.jsx(ol,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{my:"6",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${b} integration`})}),s.jsx(al,{error:n}),s.jsxs(y.Stack,{spacing:4,children:[x&&s.jsx(Ro,{url:x,providerDisplayName:b,credentialName:"API key"}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:m,pr:"4.5rem",type:a?"text":"password",placeholder:"API Key"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:w,width:"100%",type:"submit",onClick:()=>{r(p)},children:"Next"})]})})}function cl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:c,selectedConnection:u,setSelectedConnection:p}){const h=Z(),[m,v]=I.useState(!1),[w,b]=I.useState(null),x=ee();I.useEffect(()=>{if(e&&H&&m&&w!=null){const O={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,apiKey:w};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:O},{headers:{"X-Api-Key":x??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info: ",T)})}},[x,e,m,n,r,a,i,h,p,w]);const S=O=>{b(O),v(!0)};return u===null?s.jsx(sl,{provider:e,providerInfo:t,handleSubmit:S,error:null}):c}function dl({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:4,margin:"auto",marginTop:"40px",fontSize:"md",children:e})})}function ll({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function ul({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var A;const[a,c]=I.useState(!1),u=()=>c(!a),[p,h]=I.useState(""),[m,v]=I.useState(""),w=P=>h(P.currentTarget.value),b=P=>v(P.currentTarget.value),x=st(e,t),S=(A=t.basicOpts)==null?void 0:A.docsURL,O=p.length>0,T=i||!O;return s.jsx(dl,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${x} integration`})}),s.jsx(ll,{error:n}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[S&&s.jsx(Ro,{url:S,providerDisplayName:x,credentialName:"credentials"}),s.jsx(y.Input,{placeholder:"Username",onChange:w}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:b,pr:"4.5rem",type:a?"text":"password",placeholder:"Password"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:T,width:"100%",type:"submit",onClick:()=>{r(p,m)},children:"Next"})]})})}function pl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:c,selectedConnection:u,setSelectedConnection:p}){const h=Z(),[m,v]=I.useState(!1),[w,b]=I.useState(null),x=ee();I.useEffect(()=>{if(e&&H&&m&&w!=null){const O={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,basicAuth:{username:w.user,password:w.pass}};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:O},{headers:{"X-Api-Key":x??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info: ",T)})}},[x,e,m,n,r,a,i,h,w,p]);const S=(O,T)=>{b({user:O,pass:T}),v(!0)};return u===null?s.jsx(ul,{provider:e,providerInfo:t,handleSubmit:S,error:null}):c}function fl(e){const{selectedConnection:t}=xt();I.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function hl({onSuccess:e}){fl(e)}function gl({children:e}){return s.jsx(y.Container,{children:s.jsx(y.Box,{p:8,maxWidth:"600px",borderWidth:1,borderRadius:8,boxShadow:"lg",textAlign:["left"],margin:"auto",marginTop:"40px",bgColor:"white",color:"gray.800",fontSize:"md",children:e})})}function ml({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function yl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(gl,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(ml,{error:t}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function wl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,selectedConnection:c,setSelectedConnection:u,providerName:p}){const h=Z(),m=ee(),[v,w]=I.useState(!1);I.useEffect(()=>{if(e&&H&&v){const x={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e};H().connectionApi.generateConnection({projectIdOrName:h.projectId,generateConnectionParams:x},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(S=>{u(S)}).catch(S=>{console.error("Error loading provider info: ",S)})}},[m,e,v,r,t,i,n,u,h]);const b=()=>{w(!0)};return c===null?s.jsx(yl,{handleSubmit:b,error:null,providerName:p}):a}function Gt({children:e}){return s.jsx(y.Container,{children:s.jsxs(y.Box,{maxWidth:"600px",borderWidth:1,borderRadius:4,children:[s.jsx("div",{style:{padding:"3rem 2rem"},children:e}),s.jsx(ho,{})]})})}function Vt({error:e}){return e?s.jsxs(y.Alert,{status:"error",marginTop:"2em",children:[s.jsx(y.AlertIcon,{}),s.jsx(y.AlertDescription,{children:e})]}):null}function Il({handleSubmit:e,error:t,explicitScopesRequired:r,isButtonDisabled:n,providerName:i}){const[a,c]=I.useState(!1),[u,p]=I.useState(""),[h,m]=I.useState(""),[v,w]=I.useState(""),b=()=>c(!a),x=k=>p(k.currentTarget.value),S=k=>m(k.currentTarget.value),O=k=>w(k.currentTarget.value),T=u.length>0,A=h.length>0,P=n||!T||!A,$=()=>{const k={clientId:h,clientSecret:u};r&&v.length>0&&(k.scopes=Yi(v)),e(k)};return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${i} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[s.jsx(y.Input,{placeholder:"Client ID",onChange:S}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:x,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:b,children:a?"Hide":"Show"})})]}),r&&s.jsx(y.Textarea,{placeholder:"Scopes separated by new line",onChange:O})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:P,width:"100%",type:"submit",onClick:$,children:"Next"})]})})}function vl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,explicitScopesRequired:a,providerName:c,selectedConnection:u,setSelectedConnection:p}){const{projectId:h}=Z(),m=ee(),[v,w]=I.useState(null),b=async x=>{w(null);const S={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};H().connectionApi.generateConnection({projectIdOrName:h,generateConnectionParams:S},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(O=>{p(O)}).catch(O=>{console.error("Error loading provider info: ",O),w("Error loading provider info")})};return u===null?s.jsx(Il,{providerName:c,handleSubmit:b,error:v,explicitScopesRequired:a}):s.jsx(Ce,{})}const _o=async(e,t,r,n,i,a,c,u)=>{var h;const p=await H().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":n??""}});if(!p)throw new Error(`Provider ${i} not found`);if(p.authType==="oauth2"&&((h=p.oauth2Opts)==null?void 0:h.grantType)==="authorizationCode"){const v=(await H().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":n??""}})).find(S=>S.provider===i),w=st(i,p);if(!v)throw new Error(`You must first set up a ${w} Provider App using the Ampersand Console.`);const b={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:c,providerAppId:v.id,provider:i}};return await H().oAuthApi.oauthConnect(b)}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},xi=600,Oi=600,bl="AUTHORIZATION_SUCCEEDED",Sl="AUTHORIZATION_FAILED";function xl(e,t,r){return I.useCallback(async n=>{const i=await H().connectionApi.getConnection({projectIdOrName:e,connectionId:n},{headers:{"X-Api-Key":t??""}});r(i)},[e,t,r])}function Ol(e,t,r,n){return I.useCallback(()=>{if(!n)return;const i=window.screenX+(window.outerWidth-xi)/2,a=window.screenY+(window.outerHeight-Oi)/2.5,c=`width=${xi},height=${Oi},left=${i},top=${a}`,u=window.open(n,e,c);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function Cl(e){return I.useCallback(t=>{var r;if(t.origin===Kc){if(t.data.eventType===bl){const n=(r=t.data.data)==null?void 0:r.connection;n?e(n):console.error("Connection ID not found in event data: ",{event:t})}t.data.eventType===Sl&&console.error("OAuth failed: ",{event:t})}},[e])}function Ao({children:e,oauthUrl:t,windowTitle:r="Connect to Provider",onClose:n}){const i=ee(),{projectId:a}=Z(),[c,u]=I.useState(null),[p,h]=I.useState(null),{setSelectedConnection:m}=xt(),v=Cl(u),w=Ol(r,h,v,t),b=xl(a,i,m);I.useEffect(()=>{t&&!p&&w()},[t,p,w,v,r]),I.useEffect(()=>{c&&b(c).then(()=>{p==null||p.close()}).catch(S=>{console.error("Error refreshing connection: ",S),n(S.message??"Unexpected error: not able to refresh connection")})},[c,i,m,b,p,n]);const x=p&&setInterval(()=>{(p!=null&&p.closed||!p)&&x&&(clearInterval(x),window.removeEventListener("message",v),h(null),c?c&&n&&n(null):(console.error("OAuth failed. Please try again."),n&&n("OAuth failed. Please try again.")))},500);return s.jsx("div",{children:e})}function Nl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Tl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:c}=Z(),u=ee(),[p,h]=I.useState(null),[m,v]=I.useState(null),w=async()=>{v(null);try{const x=await _o(c,t,n,u,e,void 0,r,i);h(x)}catch(x){console.error("Could not fetch OAuth popup URL",{err:x}),v(x.message??"Unexpected error")}},b=I.useCallback(x=>{v(x),h(null)},[]);return s.jsx(Ao,{windowTitle:`Connect to ${a}`,oauthUrl:p,onClose:b,children:s.jsx(Nl,{handleSubmit:w,error:m,providerName:a})})}function Rl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n,explicitScopesRequired:i}){const[a,c]=I.useState(!1),[u,p]=I.useState(""),[h,m]=I.useState(""),[v,w]=I.useState(""),[b,x]=I.useState(""),S=()=>c(!a),O=J=>p(J.currentTarget.value),T=J=>m(J.currentTarget.value),A=J=>w(J.currentTarget.value),P=J=>x(J.currentTarget.value),$=u.length>0,k=h.length>0,Q=v.length>0,X=r||!$||!k||!Q,te=()=>{const J={workspace:v,clientId:h,clientSecret:u};i&&b.length>0&&(J.scopes=Yi(b)),e(J)};return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(y.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Vt,{error:t}),s.jsx("br",{}),s.jsxs(y.Stack,{spacing:4,children:[s.jsx(y.Input,{placeholder:"MyWorkspace",onChange:A}),s.jsx(y.Input,{placeholder:"Client ID",onChange:T}),s.jsxs(y.InputGroup,{size:"md",children:[s.jsx(y.Input,{onChange:O,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(y.InputRightElement,{width:"4.5rem",children:s.jsx(y.Button,{h:"1.75rem",size:"sm",onClick:S,children:a?"Hide":"Show"})})]}),i&&s.jsx(y.Textarea,{placeholder:"Scopes separated by new line",onChange:P})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:X,width:"100%",type:"submit",onClick:te,children:"Next"})]})})}function _l({provider:e,providerName:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:c,selectedConnection:u,setSelectedConnection:p}){const{projectId:h}=Z(),m=ee(),[v,w]=I.useState(null),b=async x=>{w(null);const S={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,providerWorkspaceRef:x.workspace,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};H().connectionApi.generateConnection({projectIdOrName:h,generateConnectionParams:S},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(O=>{p(O)}).catch(O=>{console.error("Error loading provider info: ",O),w("Error loading provider info")})};return u===null?s.jsx(Rl,{providerName:t,handleSubmit:b,error:v,explicitScopesRequired:c}):s.jsx(Ce,{})}function Al(){const e=I.useContext($o.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var jo=I.createContext({});jo.displayName="ColorModeContext";function ko(){const e=I.useContext(jo);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function jl(){const e=ko(),t=Al();return{...e,theme:t}}var kl=(...e)=>e.filter(Boolean).join(" ");function nt(e){const t=typeof e;return e!=null&&(t==="object"||t==="function")&&!Array.isArray(e)}function rt(e,...t){return El(e)?e(...t):e}var El=e=>typeof e=="function",Tr={exports:{}};Tr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=800,a=16,c=9007199254740991,u="[object Arguments]",p="[object Array]",h="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",w="[object Error]",b="[object Function]",x="[object GeneratorFunction]",S="[object Map]",O="[object Number]",T="[object Null]",A="[object Object]",P="[object Proxy]",$="[object RegExp]",k="[object Set]",Q="[object String]",X="[object Undefined]",te="[object WeakMap]",J="[object ArrayBuffer]",Y="[object DataView]",Te="[object Float32Array]",ct="[object Float64Array]",Br="[object Int8Array]",Lr="[object Int16Array]",Kr="[object Int32Array]",Mr="[object Uint8Array]",Ur="[object Uint8ClampedArray]",$r="[object Uint16Array]",qr="[object Uint32Array]",Wr=/[\\^$.*+?()[\]{}|]/g,zr=/^\[object .+?Constructor\]$/,Jr=/^(?:0|[1-9]\d*)$/,M={};M[Te]=M[ct]=M[Br]=M[Lr]=M[Kr]=M[Mr]=M[Ur]=M[$r]=M[qr]=!0,M[u]=M[p]=M[J]=M[m]=M[Y]=M[v]=M[w]=M[b]=M[S]=M[O]=M[A]=M[$]=M[k]=M[Q]=M[te]=!1;var Yt=typeof $e=="object"&&$e&&$e.Object===Object&&$e,U=typeof self=="object"&&self&&self.Object===Object&&self,De=Yt||U||Function("return this")(),Zt=t&&!t.nodeType&&t,oe=Zt&&!0&&e&&!e.nodeType&&e,Ct=oe&&oe.exports===Zt,dt=Ct&&Yt.process,Nt=function(){try{var o=oe&&oe.require&&oe.require("util").types;return o||dt&&dt.binding&&dt.binding("util")}catch{}}(),lt=Nt&&Nt.isTypedArray;function Qt(o,d,f){switch(f.length){case 0:return o.call(d);case 1:return o.call(d,f[0]);case 2:return o.call(d,f[0],f[1]);case 3:return o.call(d,f[0],f[1],f[2])}return o.apply(d,f)}function er(o,d){for(var f=-1,C=Array(o);++f<o;)C[f]=d(f);return C}function Hr(o){return function(d){return o(d)}}function Xr(o,d){return o==null?void 0:o[d]}function Gr(o,d){return function(f){return o(d(f))}}var Vr=Array.prototype,Yr=Function.prototype,ut=Object.prototype,Tt=De["__core-js_shared__"],pt=Yr.toString,be=ut.hasOwnProperty,tr=function(){var o=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),rr=ut.toString,Zr=pt.call(Object),ft=RegExp("^"+pt.call(be).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Be=Ct?De.Buffer:void 0,Rt=De.Symbol,ce=De.Uint8Array;Be&&Be.allocUnsafe;var _t=Gr(Object.getPrototypeOf,Object),At=Object.create,Qr=ut.propertyIsEnumerable,nr=Vr.splice,ue=Rt?Rt.toStringTag:void 0,ze=function(){try{var o=Dt(Object,"defineProperty");return o({},"",{}),o}catch{}}(),ir=Be?Be.isBuffer:void 0,or=Math.max,Re=Date.now,jt=Dt(De,"Map"),Je=Dt(Object,"create"),en=function(){function o(){}return function(d){if(!Ae(d))return{};if(At)return At(d);o.prototype=d;var f=new o;return o.prototype=void 0,f}}();function ge(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function He(){this.__data__=Je?Je(null):{},this.size=0}function kt(o){var d=this.has(o)&&delete this.__data__[o];return this.size-=d?1:0,d}function Et(o){var d=this.__data__;if(Je){var f=d[o];return f===n?void 0:f}return be.call(d,o)?d[o]:void 0}function Ft(o){var d=this.__data__;return Je?d[o]!==void 0:be.call(d,o)}function Xe(o,d){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=Je&&d===void 0?n:d,this}ge.prototype.clear=He,ge.prototype.delete=kt,ge.prototype.get=Et,ge.prototype.has=Ft,ge.prototype.set=Xe;function me(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function tn(){this.__data__=[],this.size=0}function rn(o){var d=this.__data__,f=ht(d,o);if(f<0)return!1;var C=d.length-1;return f==C?d.pop():nr.call(d,f,1),--this.size,!0}function nn(o){var d=this.__data__,f=ht(d,o);return f<0?void 0:d[f][1]}function on(o){return ht(this.__data__,o)>-1}function ar(o,d){var f=this.__data__,C=ht(f,o);return C<0?(++this.size,f.push([o,d])):f[C][1]=d,this}me.prototype.clear=tn,me.prototype.delete=rn,me.prototype.get=nn,me.prototype.has=on,me.prototype.set=ar;function Se(o){var d=-1,f=o==null?0:o.length;for(this.clear();++d<f;){var C=o[d];this.set(C[0],C[1])}}function _e(){this.size=0,this.__data__={hash:new ge,map:new(jt||me),string:new ge}}function an(o){var d=yt(this,o).delete(o);return this.size-=d?1:0,d}function sn(o){return yt(this,o).get(o)}function cn(o){return yt(this,o).has(o)}function dn(o,d){var f=yt(this,o),C=f.size;return f.set(o,d),this.size+=f.size==C?0:1,this}Se.prototype.clear=_e,Se.prototype.delete=an,Se.prototype.get=sn,Se.prototype.has=cn,Se.prototype.set=dn;function Le(o){var d=this.__data__=new me(o);this.size=d.size}function ye(){this.__data__=new me,this.size=0}function ln(o){var d=this.__data__,f=d.delete(o);return this.size=d.size,f}function un(o){return this.__data__.get(o)}function pn(o){return this.__data__.has(o)}function fn(o,d){var f=this.__data__;if(f instanceof me){var C=f.__data__;if(!jt||C.length<r-1)return C.push([o,d]),this.size=++f.size,this;f=this.__data__=new Se(C)}return f.set(o,d),this.size=f.size,this}Le.prototype.clear=ye,Le.prototype.delete=ln,Le.prototype.get=un,Le.prototype.has=pn,Le.prototype.set=fn;function hn(o,d){var f=Ie(o),C=!f&&Lt(o),R=!f&&!C&&Ze(o),j=!f&&!C&&!R&&Mt(o),D=f||C||R||j,E=D?er(o.length,String):[],F=E.length;for(var q in o)D&&(q=="length"||R&&(q=="offset"||q=="parent")||j&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||Bt(q,F))||E.push(q);return E}function we(o,d,f){(f!==void 0&&!wt(o[d],f)||f===void 0&&!(d in o))&&Pt(o,d,f)}function gn(o,d,f){var C=o[d];(!(be.call(o,d)&&wt(C,f))||f===void 0&&!(d in o))&&Pt(o,d,f)}function ht(o,d){for(var f=o.length;f--;)if(wt(o[f][0],d))return f;return-1}function Pt(o,d,f){d=="__proto__"&&ze?ze(o,d,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[d]=f}var mn=dr();function gt(o){return o==null?o===void 0?X:T:ue&&ue in Object(o)?Cn(o):_n(o)}function Ge(o){return Me(o)&&gt(o)==u}function yn(o){if(!Ae(o)||lr(o))return!1;var d=Kt(o)?ft:zr;return d.test(En(o))}function wn(o){return Me(o)&&vt(o.length)&&!!M[gt(o)]}function xe(o){if(!Ae(o))return Ke(o);var d=Ye(o),f=[];for(var C in o)C=="constructor"&&(d||!be.call(o,C))||f.push(C);return f}function sr(o,d,f,C,R){o!==d&&mn(d,function(j,D){if(R||(R=new Le),Ae(j))In(o,d,D,f,sr,C,R);else{var E=C?C(pe(o,D),j,D+"",o,d,R):void 0;E===void 0&&(E=j),we(o,D,E)}},Ut)}function In(o,d,f,C,R,j,D){var E=pe(o,f),F=pe(d,f),q=D.get(F);if(q){we(o,f,q);return}var W=j?j(E,F,f+"",o,d,D):void 0,G=W===void 0;if(G){var ne=Ie(F),ie=!ne&&Ze(F),ve=!ne&&!ie&&Mt(F);W=F,ne||ie||ve?Ie(E)?W=E:Fn(E)?W=On(E):ie?(G=!1,W=Sn(F)):ve?(G=!1,W=mt(F)):W=[]:ur(F)||Lt(F)?(W=E,Lt(E)?W=Qe(E):(!Ae(E)||Kt(E))&&(W=Nn(F))):G=!1}G&&(D.set(F,W),R(W,F,C,j,D),D.delete(F)),we(o,f,W)}function vn(o,d){return jn(An(o,d,pr),o+"")}var bn=ze?function(o,d){return ze(o,"toString",{configurable:!0,enumerable:!1,value:Dn(d),writable:!0})}:pr;function Sn(o,d){return o.slice()}function xn(o){var d=new o.constructor(o.byteLength);return new ce(d).set(new ce(o)),d}function mt(o,d){var f=xn(o.buffer);return new o.constructor(f,o.byteOffset,o.length)}function On(o,d){var f=-1,C=o.length;for(d||(d=Array(C));++f<C;)d[f]=o[f];return d}function Ve(o,d,f,C){var R=!f;f||(f={});for(var j=-1,D=d.length;++j<D;){var E=d[j],F=void 0;F===void 0&&(F=o[E]),R?Pt(f,E,F):gn(f,E,F)}return f}function cr(o){return vn(function(d,f){var C=-1,R=f.length,j=R>1?f[R-1]:void 0,D=R>2?f[2]:void 0;for(j=o.length>3&&typeof j=="function"?(R--,j):void 0,D&&Tn(f[0],f[1],D)&&(j=R<3?void 0:j,R=1),d=Object(d);++C<R;){var E=f[C];E&&o(d,E,C,j)}return d})}function dr(o){return function(d,f,C){for(var R=-1,j=Object(d),D=C(d),E=D.length;E--;){var F=D[++R];if(f(j[F],F,j)===!1)break}return d}}function yt(o,d){var f=o.__data__;return Rn(d)?f[typeof d=="string"?"string":"hash"]:f.map}function Dt(o,d){var f=Xr(o,d);return yn(f)?f:void 0}function Cn(o){var d=be.call(o,ue),f=o[ue];try{o[ue]=void 0;var C=!0}catch{}var R=rr.call(o);return C&&(d?o[ue]=f:delete o[ue]),R}function Nn(o){return typeof o.constructor=="function"&&!Ye(o)?en(_t(o)):{}}function Bt(o,d){var f=typeof o;return d=d??c,!!d&&(f=="number"||f!="symbol"&&Jr.test(o))&&o>-1&&o%1==0&&o<d}function Tn(o,d,f){if(!Ae(f))return!1;var C=typeof d;return(C=="number"?It(f)&&Bt(d,f.length):C=="string"&&d in f)?wt(f[d],o):!1}function Rn(o){var d=typeof o;return d=="string"||d=="number"||d=="symbol"||d=="boolean"?o!=="__proto__":o===null}function lr(o){return!!tr&&tr in o}function Ye(o){var d=o&&o.constructor,f=typeof d=="function"&&d.prototype||ut;return o===f}function Ke(o){var d=[];if(o!=null)for(var f in Object(o))d.push(f);return d}function _n(o){return rr.call(o)}function An(o,d,f){return d=or(d===void 0?o.length-1:d,0),function(){for(var C=arguments,R=-1,j=or(C.length-d,0),D=Array(j);++R<j;)D[R]=C[d+R];R=-1;for(var E=Array(d+1);++R<d;)E[R]=C[R];return E[d]=f(D),Qt(o,this,E)}}function pe(o,d){if(!(d==="constructor"&&typeof o[d]=="function")&&d!="__proto__")return o[d]}var jn=kn(bn);function kn(o){var d=0,f=0;return function(){var C=Re(),R=a-(C-f);if(f=C,R>0){if(++d>=i)return arguments[0]}else d=0;return o.apply(void 0,arguments)}}function En(o){if(o!=null){try{return pt.call(o)}catch{}try{return o+""}catch{}}return""}function wt(o,d){return o===d||o!==o&&d!==d}var Lt=Ge(function(){return arguments}())?Ge:function(o){return Me(o)&&be.call(o,"callee")&&!Qr.call(o,"callee")},Ie=Array.isArray;function It(o){return o!=null&&vt(o.length)&&!Kt(o)}function Fn(o){return Me(o)&&It(o)}var Ze=ir||l;function Kt(o){if(!Ae(o))return!1;var d=gt(o);return d==b||d==x||d==h||d==P}function vt(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=c}function Ae(o){var d=typeof o;return o!=null&&(d=="object"||d=="function")}function Me(o){return o!=null&&typeof o=="object"}function ur(o){if(!Me(o)||gt(o)!=A)return!1;var d=_t(o);if(d===null)return!0;var f=be.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&pt.call(f)==Zr}var Mt=lt?Hr(lt):wn;function Qe(o){return Ve(o,Ut(o))}function Ut(o){return It(o)?hn(o):xe(o)}var Pn=cr(function(o,d,f,C){sr(o,d,f,C)});function Dn(o){return function(){return o}}function pr(o){return o}function l(){return!1}e.exports=Pn})(Tr,Tr.exports);var Fl=Tr.exports;const Ee=ei(Fl);var Pl=e=>/!(important)?$/.test(e),Ci=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,Dl=(e,t)=>r=>{const n=String(t),i=Pl(n),a=Ci(n),c=e?`${e}.${a}`:a;let u=nt(r.__cssMap)&&c in r.__cssMap?r.__cssMap[c].varRef:t;return u=Ci(u),i?`${u} !important`:u};function si(e){const{scale:t,transform:r,compose:n}=e;return(a,c)=>{var u;const p=Dl(t,a)(c);let h=(u=r==null?void 0:r(p,c))!=null?u:p;return n&&(h=n(h,c)),h}}var wr=(...e)=>t=>e.reduce((r,n)=>n(r),t);function fe(e,t){return r=>{const n={property:r,scale:e};return n.transform=si({scale:e,transform:t}),n}}var Bl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function Ll(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:Bl(t),transform:r?si({scale:r,compose:n}):n}}var Eo=["rotate(var(--chakra-rotate, 0))","scaleX(var(--chakra-scale-x, 1))","scaleY(var(--chakra-scale-y, 1))","skewX(var(--chakra-skew-x, 0))","skewY(var(--chakra-skew-y, 0))"];function Kl(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",...Eo].join(" ")}function Ml(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",...Eo].join(" ")}var Ul={"--chakra-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-sepia":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-drop-shadow":"var(--chakra-empty,/*!*/ /*!*/)",filter:["var(--chakra-blur)","var(--chakra-brightness)","var(--chakra-contrast)","var(--chakra-grayscale)","var(--chakra-hue-rotate)","var(--chakra-invert)","var(--chakra-saturate)","var(--chakra-sepia)","var(--chakra-drop-shadow)"].join(" ")},$l={backdropFilter:["var(--chakra-backdrop-blur)","var(--chakra-backdrop-brightness)","var(--chakra-backdrop-contrast)","var(--chakra-backdrop-grayscale)","var(--chakra-backdrop-hue-rotate)","var(--chakra-backdrop-invert)","var(--chakra-backdrop-opacity)","var(--chakra-backdrop-saturate)","var(--chakra-backdrop-sepia)"].join(" "),"--chakra-backdrop-blur":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-brightness":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-contrast":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-grayscale":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-hue-rotate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-invert":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-opacity":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-saturate":"var(--chakra-empty,/*!*/ /*!*/)","--chakra-backdrop-sepia":"var(--chakra-empty,/*!*/ /*!*/)"};function ql(e){return{"--chakra-ring-offset-shadow":"var(--chakra-ring-inset) 0 0 0 var(--chakra-ring-offset-width) var(--chakra-ring-offset-color)","--chakra-ring-shadow":"var(--chakra-ring-inset) 0 0 0 calc(var(--chakra-ring-width) + var(--chakra-ring-offset-width)) var(--chakra-ring-color)","--chakra-ring-width":e,boxShadow:["var(--chakra-ring-offset-shadow)","var(--chakra-ring-shadow)","var(--chakra-shadow, 0 0 #0000)"].join(", ")}}var Wl={"row-reverse":{space:"--chakra-space-x-reverse",divide:"--chakra-divide-x-reverse"},"column-reverse":{space:"--chakra-space-y-reverse",divide:"--chakra-divide-y-reverse"}},Xn={"to-t":"to top","to-tr":"to top right","to-r":"to right","to-br":"to bottom right","to-b":"to bottom","to-bl":"to bottom left","to-l":"to left","to-tl":"to top left"},zl=new Set(Object.values(Xn)),Gn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),Jl=e=>e.trim();function Hl(e,t){if(e==null||Gn.has(e))return e;if(!(Vn(e)||Gn.has(e)))return`url('${e}')`;const i=/(^[a-z-A-Z]+)\((.*)\)/g.exec(e),a=i==null?void 0:i[1],c=i==null?void 0:i[2];if(!a||!c)return e;const u=a.includes("-gradient")?a:`${a}-gradient`,[p,...h]=c.split(",").map(Jl).filter(Boolean);if((h==null?void 0:h.length)===0)return e;const m=p in Xn?Xn[p]:p;h.unshift(m);const v=h.map(w=>{if(zl.has(w))return w;const b=w.indexOf(" "),[x,S]=b!==-1?[w.substr(0,b),w.substr(b+1)]:[w],O=Vn(S)?S:S&&S.split(" "),T=`colors.${x}`,A=T in t.__cssMap?t.__cssMap[T].varRef:x;return O?[A,...Array.isArray(O)?O:[O]].join(" "):A});return`${u}(${v.join(", ")})`}var Vn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Xl=(e,t)=>Hl(e,t??{});function Gl(e){return/^var\(--.+\)$/.test(e)}var Vl=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Oe=e=>t=>`${e}(${t})`,B={filter(e){return e!=="auto"?e:Ul},backdropFilter(e){return e!=="auto"?e:$l},ring(e){return ql(B.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?Kl():e==="auto-gpu"?Ml():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=Vl(e);return t||typeof e=="number"?`${e}px`:e},fraction(e){return typeof e!="number"||e>1?e:`${e*100}%`},float(e,t){const r={left:"right",right:"left"};return t.direction==="rtl"?r[e]:e},degree(e){if(Gl(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Xl,blur:Oe("blur"),opacity:Oe("opacity"),brightness:Oe("brightness"),contrast:Oe("contrast"),dropShadow:Oe("drop-shadow"),grayscale:Oe("grayscale"),hueRotate:e=>Oe("hue-rotate")(B.degree(e)),invert:Oe("invert"),saturate:Oe("saturate"),sepia:Oe("sepia"),bgImage(e){return e==null||Vn(e)||Gn.has(e)?e:`url(${e})`},outline(e){const t=String(e)==="0"||String(e)==="none";return e!==null&&t?{outline:"2px solid transparent",outlineOffset:"2px"}:{outline:e}},flexDirection(e){var t;const{space:r,divide:n}=(t=Wl[e])!=null?t:{},i={flexDirection:e};return r&&(i[r]=1),n&&(i[n]=1),i}},g={borderWidths:fe("borderWidths"),borderStyles:fe("borderStyles"),colors:fe("colors"),borders:fe("borders"),gradients:fe("gradients",B.gradient),radii:fe("radii",B.px),space:fe("space",wr(B.vh,B.px)),spaceT:fe("space",wr(B.vh,B.px)),degreeT(e){return{property:e,transform:B.degree}},prop(e,t,r){return{property:e,scale:t,...t&&{transform:si({scale:t,transform:r})}}},propT(e,t){return{property:e,transform:t}},sizes:fe("sizes",wr(B.vh,B.px)),sizesT:fe("sizes",wr(B.vh,B.fraction)),shadows:fe("shadows"),logical:Ll,blur:fe("blur",B.blur)},br={background:g.colors("background"),backgroundColor:g.colors("backgroundColor"),backgroundImage:g.gradients("backgroundImage"),backgroundSize:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundAttachment:!0,backgroundClip:{transform:B.bgClip},bgSize:g.prop("backgroundSize"),bgPosition:g.prop("backgroundPosition"),bg:g.colors("background"),bgColor:g.colors("backgroundColor"),bgPos:g.prop("backgroundPosition"),bgRepeat:g.prop("backgroundRepeat"),bgAttachment:g.prop("backgroundAttachment"),bgGradient:g.gradients("backgroundImage"),bgClip:{transform:B.bgClip}};Object.assign(br,{bgImage:br.backgroundImage,bgImg:br.backgroundImage});var L={border:g.borders("border"),borderWidth:g.borderWidths("borderWidth"),borderStyle:g.borderStyles("borderStyle"),borderColor:g.colors("borderColor"),borderRadius:g.radii("borderRadius"),borderTop:g.borders("borderTop"),borderBlockStart:g.borders("borderBlockStart"),borderTopLeftRadius:g.radii("borderTopLeftRadius"),borderStartStartRadius:g.logical({scale:"radii",property:{ltr:"borderTopLeftRadius",rtl:"borderTopRightRadius"}}),borderEndStartRadius:g.logical({scale:"radii",property:{ltr:"borderBottomLeftRadius",rtl:"borderBottomRightRadius"}}),borderTopRightRadius:g.radii("borderTopRightRadius"),borderStartEndRadius:g.logical({scale:"radii",property:{ltr:"borderTopRightRadius",rtl:"borderTopLeftRadius"}}),borderEndEndRadius:g.logical({scale:"radii",property:{ltr:"borderBottomRightRadius",rtl:"borderBottomLeftRadius"}}),borderRight:g.borders("borderRight"),borderInlineEnd:g.borders("borderInlineEnd"),borderBottom:g.borders("borderBottom"),borderBlockEnd:g.borders("borderBlockEnd"),borderBottomLeftRadius:g.radii("borderBottomLeftRadius"),borderBottomRightRadius:g.radii("borderBottomRightRadius"),borderLeft:g.borders("borderLeft"),borderInlineStart:{property:"borderInlineStart",scale:"borders"},borderInlineStartRadius:g.logical({scale:"radii",property:{ltr:["borderTopLeftRadius","borderBottomLeftRadius"],rtl:["borderTopRightRadius","borderBottomRightRadius"]}}),borderInlineEndRadius:g.logical({scale:"radii",property:{ltr:["borderTopRightRadius","borderBottomRightRadius"],rtl:["borderTopLeftRadius","borderBottomLeftRadius"]}}),borderX:g.borders(["borderLeft","borderRight"]),borderInline:g.borders("borderInline"),borderY:g.borders(["borderTop","borderBottom"]),borderBlock:g.borders("borderBlock"),borderTopWidth:g.borderWidths("borderTopWidth"),borderBlockStartWidth:g.borderWidths("borderBlockStartWidth"),borderTopColor:g.colors("borderTopColor"),borderBlockStartColor:g.colors("borderBlockStartColor"),borderTopStyle:g.borderStyles("borderTopStyle"),borderBlockStartStyle:g.borderStyles("borderBlockStartStyle"),borderBottomWidth:g.borderWidths("borderBottomWidth"),borderBlockEndWidth:g.borderWidths("borderBlockEndWidth"),borderBottomColor:g.colors("borderBottomColor"),borderBlockEndColor:g.colors("borderBlockEndColor"),borderBottomStyle:g.borderStyles("borderBottomStyle"),borderBlockEndStyle:g.borderStyles("borderBlockEndStyle"),borderLeftWidth:g.borderWidths("borderLeftWidth"),borderInlineStartWidth:g.borderWidths("borderInlineStartWidth"),borderLeftColor:g.colors("borderLeftColor"),borderInlineStartColor:g.colors("borderInlineStartColor"),borderLeftStyle:g.borderStyles("borderLeftStyle"),borderInlineStartStyle:g.borderStyles("borderInlineStartStyle"),borderRightWidth:g.borderWidths("borderRightWidth"),borderInlineEndWidth:g.borderWidths("borderInlineEndWidth"),borderRightColor:g.colors("borderRightColor"),borderInlineEndColor:g.colors("borderInlineEndColor"),borderRightStyle:g.borderStyles("borderRightStyle"),borderInlineEndStyle:g.borderStyles("borderInlineEndStyle"),borderTopRadius:g.radii(["borderTopLeftRadius","borderTopRightRadius"]),borderBottomRadius:g.radii(["borderBottomLeftRadius","borderBottomRightRadius"]),borderLeftRadius:g.radii(["borderTopLeftRadius","borderBottomLeftRadius"]),borderRightRadius:g.radii(["borderTopRightRadius","borderBottomRightRadius"])};Object.assign(L,{rounded:L.borderRadius,roundedTop:L.borderTopRadius,roundedTopLeft:L.borderTopLeftRadius,roundedTopRight:L.borderTopRightRadius,roundedTopStart:L.borderStartStartRadius,roundedTopEnd:L.borderStartEndRadius,roundedBottom:L.borderBottomRadius,roundedBottomLeft:L.borderBottomLeftRadius,roundedBottomRight:L.borderBottomRightRadius,roundedBottomStart:L.borderEndStartRadius,roundedBottomEnd:L.borderEndEndRadius,roundedLeft:L.borderLeftRadius,roundedRight:L.borderRightRadius,roundedStart:L.borderInlineStartRadius,roundedEnd:L.borderInlineEndRadius,borderStart:L.borderInlineStart,borderEnd:L.borderInlineEnd,borderTopStartRadius:L.borderStartStartRadius,borderTopEndRadius:L.borderStartEndRadius,borderBottomStartRadius:L.borderEndStartRadius,borderBottomEndRadius:L.borderEndEndRadius,borderStartRadius:L.borderInlineStartRadius,borderEndRadius:L.borderInlineEndRadius,borderStartWidth:L.borderInlineStartWidth,borderEndWidth:L.borderInlineEndWidth,borderStartColor:L.borderInlineStartColor,borderEndColor:L.borderInlineEndColor,borderStartStyle:L.borderInlineStartStyle,borderEndStyle:L.borderInlineEndStyle});var Yl={color:g.colors("color"),textColor:g.colors("color"),fill:g.colors("fill"),stroke:g.colors("stroke")},Yn={boxShadow:g.shadows("boxShadow"),mixBlendMode:!0,blendMode:g.prop("mixBlendMode"),backgroundBlendMode:!0,bgBlendMode:g.prop("backgroundBlendMode"),opacity:!0};Object.assign(Yn,{shadow:Yn.boxShadow});var Zl={filter:{transform:B.filter},blur:g.blur("--chakra-blur"),brightness:g.propT("--chakra-brightness",B.brightness),contrast:g.propT("--chakra-contrast",B.contrast),hueRotate:g.propT("--chakra-hue-rotate",B.hueRotate),invert:g.propT("--chakra-invert",B.invert),saturate:g.propT("--chakra-saturate",B.saturate),dropShadow:g.propT("--chakra-drop-shadow",B.dropShadow),backdropFilter:{transform:B.backdropFilter},backdropBlur:g.blur("--chakra-backdrop-blur"),backdropBrightness:g.propT("--chakra-backdrop-brightness",B.brightness),backdropContrast:g.propT("--chakra-backdrop-contrast",B.contrast),backdropHueRotate:g.propT("--chakra-backdrop-hue-rotate",B.hueRotate),backdropInvert:g.propT("--chakra-backdrop-invert",B.invert),backdropSaturate:g.propT("--chakra-backdrop-saturate",B.saturate)},Rr={alignItems:!0,alignContent:!0,justifyItems:!0,justifyContent:!0,flexWrap:!0,flexDirection:{transform:B.flexDirection},flex:!0,flexFlow:!0,flexGrow:!0,flexShrink:!0,flexBasis:g.sizes("flexBasis"),justifySelf:!0,alignSelf:!0,order:!0,placeItems:!0,placeContent:!0,placeSelf:!0,gap:g.space("gap"),rowGap:g.space("rowGap"),columnGap:g.space("columnGap")};Object.assign(Rr,{flexDir:Rr.flexDirection});var Fo={gridGap:g.space("gridGap"),gridColumnGap:g.space("gridColumnGap"),gridRowGap:g.space("gridRowGap"),gridColumn:!0,gridRow:!0,gridAutoFlow:!0,gridAutoColumns:!0,gridColumnStart:!0,gridColumnEnd:!0,gridRowStart:!0,gridRowEnd:!0,gridAutoRows:!0,gridTemplate:!0,gridTemplateColumns:!0,gridTemplateRows:!0,gridTemplateAreas:!0,gridArea:!0},Ql={appearance:!0,cursor:!0,resize:!0,userSelect:!0,pointerEvents:!0,outline:{transform:B.outline},outlineOffset:!0,outlineColor:g.colors("outlineColor")},he={width:g.sizesT("width"),inlineSize:g.sizesT("inlineSize"),height:g.sizes("height"),blockSize:g.sizes("blockSize"),boxSize:g.sizes(["width","height"]),minWidth:g.sizes("minWidth"),minInlineSize:g.sizes("minInlineSize"),minHeight:g.sizes("minHeight"),minBlockSize:g.sizes("minBlockSize"),maxWidth:g.sizes("maxWidth"),maxInlineSize:g.sizes("maxInlineSize"),maxHeight:g.sizes("maxHeight"),maxBlockSize:g.sizes("maxBlockSize"),overflow:!0,overflowX:!0,overflowY:!0,overscrollBehavior:!0,overscrollBehaviorX:!0,overscrollBehaviorY:!0,display:!0,aspectRatio:!0,hideFrom:{scale:"breakpoints",transform:(e,t)=>{var r,n,i;return{[`@media screen and (min-width: ${(i=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n.minW)!=null?i:e})`]:{display:"none"}}}},hideBelow:{scale:"breakpoints",transform:(e,t)=>{var r,n,i;return{[`@media screen and (max-width: ${(i=(n=(r=t.__breakpoints)==null?void 0:r.get(e))==null?void 0:n._minW)!=null?i:e})`]:{display:"none"}}}},verticalAlign:!0,boxSizing:!0,boxDecorationBreak:!0,float:g.propT("float",B.float),objectFit:!0,objectPosition:!0,visibility:!0,isolation:!0};Object.assign(he,{w:he.width,h:he.height,minW:he.minWidth,maxW:he.maxWidth,minH:he.minHeight,maxH:he.maxHeight,overscroll:he.overscrollBehavior,overscrollX:he.overscrollBehaviorX,overscrollY:he.overscrollBehaviorY});var eu={listStyleType:!0,listStylePosition:!0,listStylePos:g.prop("listStylePosition"),listStyleImage:!0,listStyleImg:g.prop("listStyleImage")};function tu(e,t,r,n){const i=typeof t=="string"?t.split("."):[t];for(n=0;n<i.length&&e;n+=1)e=e[i[n]];return e===void 0?r:e}var ru=e=>{const t=new WeakMap;return(n,i,a,c)=>{if(typeof n>"u")return e(n,i,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(i))return u.get(i);const p=e(n,i,a,c);return u.set(i,p),p}},nu=ru(tu),iu={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},ou={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},Mn=(e,t,r)=>{const n={},i=nu(e,t,{});for(const a in i)a in r&&r[a]!=null||(n[a]=i[a]);return n},au={srOnly:{transform(e){return e===!0?iu:e==="focusable"?ou:{}}},layerStyle:{processResult:!0,transform:(e,t,r)=>Mn(t,`layerStyles.${e}`,r)},textStyle:{processResult:!0,transform:(e,t,r)=>Mn(t,`textStyles.${e}`,r)},apply:{processResult:!0,transform:(e,t,r)=>Mn(t,e,r)}},zt={position:!0,pos:g.prop("position"),zIndex:g.prop("zIndex","zIndices"),inset:g.spaceT("inset"),insetX:g.spaceT(["left","right"]),insetInline:g.spaceT("insetInline"),insetY:g.spaceT(["top","bottom"]),insetBlock:g.spaceT("insetBlock"),top:g.spaceT("top"),insetBlockStart:g.spaceT("insetBlockStart"),bottom:g.spaceT("bottom"),insetBlockEnd:g.spaceT("insetBlockEnd"),left:g.spaceT("left"),insetInlineStart:g.logical({scale:"space",property:{ltr:"left",rtl:"right"}}),right:g.spaceT("right"),insetInlineEnd:g.logical({scale:"space",property:{ltr:"right",rtl:"left"}})};Object.assign(zt,{insetStart:zt.insetInlineStart,insetEnd:zt.insetInlineEnd});var su={ring:{transform:B.ring},ringColor:g.colors("--chakra-ring-color"),ringOffset:g.prop("--chakra-ring-offset-width"),ringOffsetColor:g.colors("--chakra-ring-offset-color"),ringInset:g.prop("--chakra-ring-inset")},z={margin:g.spaceT("margin"),marginTop:g.spaceT("marginTop"),marginBlockStart:g.spaceT("marginBlockStart"),marginRight:g.spaceT("marginRight"),marginInlineEnd:g.spaceT("marginInlineEnd"),marginBottom:g.spaceT("marginBottom"),marginBlockEnd:g.spaceT("marginBlockEnd"),marginLeft:g.spaceT("marginLeft"),marginInlineStart:g.spaceT("marginInlineStart"),marginX:g.spaceT(["marginInlineStart","marginInlineEnd"]),marginInline:g.spaceT("marginInline"),marginY:g.spaceT(["marginTop","marginBottom"]),marginBlock:g.spaceT("marginBlock"),padding:g.space("padding"),paddingTop:g.space("paddingTop"),paddingBlockStart:g.space("paddingBlockStart"),paddingRight:g.space("paddingRight"),paddingBottom:g.space("paddingBottom"),paddingBlockEnd:g.space("paddingBlockEnd"),paddingLeft:g.space("paddingLeft"),paddingInlineStart:g.space("paddingInlineStart"),paddingInlineEnd:g.space("paddingInlineEnd"),paddingX:g.space(["paddingInlineStart","paddingInlineEnd"]),paddingInline:g.space("paddingInline"),paddingY:g.space(["paddingTop","paddingBottom"]),paddingBlock:g.space("paddingBlock")};Object.assign(z,{m:z.margin,mt:z.marginTop,mr:z.marginRight,me:z.marginInlineEnd,marginEnd:z.marginInlineEnd,mb:z.marginBottom,ml:z.marginLeft,ms:z.marginInlineStart,marginStart:z.marginInlineStart,mx:z.marginX,my:z.marginY,p:z.padding,pt:z.paddingTop,py:z.paddingY,px:z.paddingX,pb:z.paddingBottom,pl:z.paddingLeft,ps:z.paddingInlineStart,paddingStart:z.paddingInlineStart,pr:z.paddingRight,pe:z.paddingInlineEnd,paddingEnd:z.paddingInlineEnd});var cu={textDecorationColor:g.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:g.shadows("textShadow")},du={clipPath:!0,transform:g.propT("transform",B.transform),transformOrigin:!0,translateX:g.spaceT("--chakra-translate-x"),translateY:g.spaceT("--chakra-translate-y"),skewX:g.degreeT("--chakra-skew-x"),skewY:g.degreeT("--chakra-skew-y"),scaleX:g.prop("--chakra-scale-x"),scaleY:g.prop("--chakra-scale-y"),scale:g.prop(["--chakra-scale-x","--chakra-scale-y"]),rotate:g.degreeT("--chakra-rotate")},lu={transition:!0,transitionDelay:!0,animation:!0,willChange:!0,transitionDuration:g.prop("transitionDuration","transition.duration"),transitionProperty:g.prop("transitionProperty","transition.property"),transitionTimingFunction:g.prop("transitionTimingFunction","transition.easing")},uu={fontFamily:g.prop("fontFamily","fonts"),fontSize:g.prop("fontSize","fontSizes",B.px),fontWeight:g.prop("fontWeight","fontWeights"),lineHeight:g.prop("lineHeight","lineHeights"),letterSpacing:g.prop("letterSpacing","letterSpacings"),textAlign:!0,fontStyle:!0,textIndent:!0,wordBreak:!0,overflowWrap:!0,textOverflow:!0,textTransform:!0,whiteSpace:!0,isTruncated:{transform(e){if(e===!0)return{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},noOfLines:{static:{overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"var(--chakra-line-clamp)"},property:"--chakra-line-clamp"}},pu={scrollBehavior:!0,scrollSnapAlign:!0,scrollSnapStop:!0,scrollSnapType:!0,scrollMargin:g.spaceT("scrollMargin"),scrollMarginTop:g.spaceT("scrollMarginTop"),scrollMarginBottom:g.spaceT("scrollMarginBottom"),scrollMarginLeft:g.spaceT("scrollMarginLeft"),scrollMarginRight:g.spaceT("scrollMarginRight"),scrollMarginX:g.spaceT(["scrollMarginLeft","scrollMarginRight"]),scrollMarginY:g.spaceT(["scrollMarginTop","scrollMarginBottom"]),scrollPadding:g.spaceT("scrollPadding"),scrollPaddingTop:g.spaceT("scrollPaddingTop"),scrollPaddingBottom:g.spaceT("scrollPaddingBottom"),scrollPaddingLeft:g.spaceT("scrollPaddingLeft"),scrollPaddingRight:g.spaceT("scrollPaddingRight"),scrollPaddingX:g.spaceT(["scrollPaddingLeft","scrollPaddingRight"]),scrollPaddingY:g.spaceT(["scrollPaddingTop","scrollPaddingBottom"])};function Po(e){return nt(e)&&e.reference?e.reference:String(e)}var Dr=(e,...t)=>t.map(Po).join(` ${e} `).replace(/calc/g,""),Ni=(...e)=>`calc(${Dr("+",...e)})`,Ti=(...e)=>`calc(${Dr("-",...e)})`,Zn=(...e)=>`calc(${Dr("*",...e)})`,Ri=(...e)=>`calc(${Dr("/",...e)})`,_i=e=>{const t=Po(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith("-")?String(t).slice(1):`-${t}`:Zn(t,-1)},Wt=Object.assign(e=>({add:(...t)=>Wt(Ni(e,...t)),subtract:(...t)=>Wt(Ti(e,...t)),multiply:(...t)=>Wt(Zn(e,...t)),divide:(...t)=>Wt(Ri(e,...t)),negate:()=>Wt(_i(e)),toString:()=>e.toString()}),{add:Ni,subtract:Ti,multiply:Zn,divide:Ri,negate:_i});function fu(e){const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}}function Ai(e){if(e==null)return e;const{unitless:t}=fu(e);return t||typeof e=="number"?`${e}px`:e}function hu(e,t){const r=["@media screen"];return e&&r.push("and",`(min-width: ${Ai(e)})`),t&&r.push("and",`(max-width: ${Ai(t)})`),r.join(" ")}var re={hover:(e,t)=>`${e}:hover ${t}, ${e}[data-hover] ${t}`,focus:(e,t)=>`${e}:focus ${t}, ${e}[data-focus] ${t}`,focusVisible:(e,t)=>`${e}:focus-visible ${t}`,focusWithin:(e,t)=>`${e}:focus-within ${t}`,active:(e,t)=>`${e}:active ${t}, ${e}[data-active] ${t}`,disabled:(e,t)=>`${e}:disabled ${t}, ${e}[data-disabled] ${t}`,invalid:(e,t)=>`${e}:invalid ${t}, ${e}[data-invalid] ${t}`,checked:(e,t)=>`${e}:checked ${t}, ${e}[data-checked] ${t}`,indeterminate:(e,t)=>`${e}:indeterminate ${t}, ${e}[aria-checked=mixed] ${t}, ${e}[data-indeterminate] ${t}`,readOnly:(e,t)=>`${e}:read-only ${t}, ${e}[readonly] ${t}, ${e}[data-read-only] ${t}`,expanded:(e,t)=>`${e}:read-only ${t}, ${e}[aria-expanded=true] ${t}, ${e}[data-expanded] ${t}`,placeholderShown:(e,t)=>`${e}:placeholder-shown ${t}`},Ue=e=>Do(t=>e(t,"&"),"[role=group]","[data-group]",".group"),ke=e=>Do(t=>e(t,"~ &"),"[data-peer]",".peer"),Do=(e,...t)=>t.map(e).join(", "),ci={_hover:"&:hover, &[data-hover]",_active:"&:active, &[data-active]",_focus:"&:focus, &[data-focus]",_highlighted:"&[data-highlighted]",_focusWithin:"&:focus-within",_focusVisible:"&:focus-visible, &[data-focus-visible]",_disabled:"&:disabled, &[disabled], &[aria-disabled=true], &[data-disabled]",_readOnly:"&[aria-readonly=true], &[readonly], &[data-readonly]",_before:"&::before",_after:"&::after",_empty:"&:empty",_expanded:"&[aria-expanded=true], &[data-expanded]",_checked:"&[aria-checked=true], &[data-checked]",_grabbed:"&[aria-grabbed=true], &[data-grabbed]",_pressed:"&[aria-pressed=true], &[data-pressed]",_invalid:"&[aria-invalid=true], &[data-invalid]",_valid:"&[data-valid], &[data-state=valid]",_loading:"&[data-loading], &[aria-busy=true]",_selected:"&[aria-selected=true], &[data-selected]",_hidden:"&[hidden], &[data-hidden]",_autofill:"&:-webkit-autofill",_even:"&:nth-of-type(even)",_odd:"&:nth-of-type(odd)",_first:"&:first-of-type",_firstLetter:"&::first-letter",_last:"&:last-of-type",_notFirst:"&:not(:first-of-type)",_notLast:"&:not(:last-of-type)",_visited:"&:visited",_activeLink:"&[aria-current=page]",_activeStep:"&[aria-current=step]",_indeterminate:"&:indeterminate, &[aria-checked=mixed], &[data-indeterminate]",_groupHover:Ue(re.hover),_peerHover:ke(re.hover),_groupFocus:Ue(re.focus),_peerFocus:ke(re.focus),_groupFocusVisible:Ue(re.focusVisible),_peerFocusVisible:ke(re.focusVisible),_groupActive:Ue(re.active),_peerActive:ke(re.active),_groupDisabled:Ue(re.disabled),_peerDisabled:ke(re.disabled),_groupInvalid:Ue(re.invalid),_peerInvalid:ke(re.invalid),_groupChecked:Ue(re.checked),_peerChecked:ke(re.checked),_groupFocusWithin:Ue(re.focusWithin),_peerFocusWithin:ke(re.focusWithin),_peerPlaceholderShown:ke(re.placeholderShown),_placeholder:"&::placeholder",_placeholderShown:"&:placeholder-shown",_fullScreen:"&:fullscreen",_selection:"&::selection",_rtl:"[dir=rtl] &, &[dir=rtl]",_ltr:"[dir=ltr] &, &[dir=ltr]",_mediaDark:"@media (prefers-color-scheme: dark)",_mediaReduceMotion:"@media (prefers-reduced-motion: reduce)",_dark:".chakra-ui-dark &:not([data-theme]),[data-theme=dark] &:not([data-theme]),&[data-theme=dark]",_light:".chakra-ui-light &:not([data-theme]),[data-theme=light] &:not([data-theme]),&[data-theme=light]",_horizontal:"&[data-orientation=horizontal]",_vertical:"&[data-orientation=vertical]"},gu=Object.keys(ci),di=Ee({},br,L,Yl,Rr,he,Zl,su,Ql,Fo,au,zt,Yn,z,pu,uu,cu,du,eu,lu);Object.assign({},z,he,Rr,Fo,zt);var mu=[...Object.keys(di),...gu],yu={...di,...ci},wu=e=>e in yu,Iu=e=>t=>{if(!t.__breakpoints)return e;const{isResponsive:r,toArrayValue:n,media:i}=t.__breakpoints,a={};for(const c in e){let u=rt(e[c],t);if(u==null)continue;if(u=nt(u)&&r(u)?n(u):u,!Array.isArray(u)){a[c]=u;continue}const p=u.slice(0,i.length).length;for(let h=0;h<p;h+=1){const m=i==null?void 0:i[h];if(!m){a[c]=u[h];continue}a[m]=a[m]||{},u[h]!=null&&(a[m][c]=u[h])}}return a};function vu(e){const t=[];let r="",n=!1;for(let i=0;i<e.length;i++){const a=e[i];a==="("?(n=!0,r+=a):a===")"?(n=!1,r+=a):a===","&&!n?(t.push(r),r=""):r+=a}return r=r.trim(),r&&t.push(r),t}function bu(e){return/^var\(--.+\)$/.test(e)}var Su=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!bu(t),xu=(e,t)=>{var r,n;if(t==null)return t;const i=p=>{var h,m;return(m=(h=e.__cssMap)==null?void 0:h[p])==null?void 0:m.varRef},a=p=>{var h;return(h=i(p))!=null?h:p},[c,u]=vu(t);return t=(n=(r=i(c))!=null?r:a(u))!=null?n:a(t),t};function Ou(e){const{configs:t={},pseudos:r={},theme:n}=e,i=(a,c=!1)=>{var u,p,h;const m=rt(a,n),v=Iu(m)(n);let w={};for(let b in v){const x=v[b];let S=rt(x,n);b in r&&(b=r[b]),Su(b,S)&&(S=xu(n,S));let O=t[b];if(O===!0&&(O={property:b}),nt(S)){w[b]=(u=w[b])!=null?u:{},w[b]=Ee({},w[b],i(S,!0));continue}let T=(h=(p=O==null?void 0:O.transform)==null?void 0:p.call(O,S,n,m))!=null?h:S;T=O!=null&&O.processResult?i(T,!0):T;const A=rt(O==null?void 0:O.property,n);if(!c&&(O!=null&&O.static)){const P=rt(O.static,n);w=Ee({},w,P)}if(A&&Array.isArray(A)){for(const P of A)w[P]=T;continue}if(A){A==="&"&&nt(T)?w=Ee({},w,T):w[A]=T;continue}if(nt(T)){w=Ee({},w,T);continue}w[b]=T}return w};return i}var Cu=e=>t=>Ou({theme:t,pseudos:ci,configs:di})(e);function Nu(e,t){if(Array.isArray(e))return e;if(nt(e))return t(e);if(e!=null)return[e]}function Tu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function Ru(e){const t=e.__breakpoints;return function(n,i,a,c){var u,p;if(!t)return;const h={},m=Nu(a,t.toArrayValue);if(!m)return h;const v=m.length,w=v===1,b=!!n.parts;for(let x=0;x<v;x++){const S=t.details[x],O=t.details[Tu(m,x)],T=hu(S.minW,O==null?void 0:O._minW),A=rt((u=n[i])==null?void 0:u[m[x]],c);if(A){if(b){(p=n.parts)==null||p.forEach(P=>{Ee(h,{[P]:w?A[P]:{[T]:A[P]}})});continue}if(!b){w?Ee(h,A):h[T]=A;continue}h[T]=A}}return h}}function _u(e){return t=>{var r;const{variant:n,size:i,theme:a}=t,c=Ru(a);return Ee({},rt((r=e.baseStyle)!=null?r:{},t),c(e,"sizes",i,t),c(e,"variants",n,t))}}function Au(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function ju(e,t,r,n){const i=typeof t=="string"?t.split("."):[t];for(n=0;n<i.length&&e;n+=1)e=e[i[n]];return e===void 0?r:e}var ku=e=>{const t=new WeakMap;return(n,i,a,c)=>{if(typeof n>"u")return e(n,i,a);t.has(n)||t.set(n,new Map);const u=t.get(n);if(u.has(i))return u.get(i);const p=e(n,i,a,c);return u.set(i,p),p}},Eu=ku(ju);function Bo(e,t){const r={};return Object.keys(e).forEach(n=>{const i=e[n];t(i,n,e)&&(r[n]=i)}),r}var Lo=e=>Bo(e,t=>t!=null);function Fu(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function Pu(e,...t){return Fu(e)?e(...t):e}var Du=typeof Element<"u",Bu=typeof Map=="function",Lu=typeof Set=="function",Ku=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Sr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,n,i;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(!Sr(e[n],t[n]))return!1;return!0}var a;if(Bu&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;for(a=e.entries();!(n=a.next()).done;)if(!Sr(n.value[1],t.get(n.value[0])))return!1;return!0}if(Lu&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(a=e.entries();!(n=a.next()).done;)if(!t.has(n.value[0]))return!1;return!0}if(Ku&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(n=r;n--!==0;)if(e[n]!==t[n])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[n]))return!1;if(Du&&e instanceof Element)return!1;for(n=r;n--!==0;)if(!((i[n]==="_owner"||i[n]==="__v"||i[n]==="__o")&&e.$$typeof)&&!Sr(e[i[n]],t[i[n]]))return!1;return!0}return e!==e&&t!==t}var Mu=function(t,r){try{return Sr(t,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const Uu=ei(Mu);function $u(e,t={}){var r;const{styleConfig:n,...i}=t,{theme:a,colorMode:c}=jl(),u=Eu(a,`components.${e}`),p=n||u,h=Ee({theme:a,colorMode:c},(r=p==null?void 0:p.defaultProps)!=null?r:{},Lo(Au(i,["children"]))),m=I.useRef({});if(p){const w=_u(p)(h);Uu(m.current,w)||(m.current=w)}return m.current}function qu(e,t={}){return $u(e,t)}var Wu=new Set([...mu,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),zu=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function Ju(e){return zu.has(e)||!Wu.has(e)}function Hu(e,...t){if(e==null)throw new TypeError("Cannot convert undefined or null to object");const r={...e};for(const n of t)if(n!=null)for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(i in r&&delete r[i],r[i]=n[i]);return r}var ji,Xu=(ji=ui.default)!=null?ji:ui,Gu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:i,sx:a,...c}=t,u=Bo(c,(v,w)=>wu(w)),p=Pu(e,t),h=Hu({},i,p,Lo(u),a),m=Cu(h)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=Ju);const i=Gu({baseStyle:r}),a=Xu(e,n)(i);return I.forwardRef(function(p,h){const{colorMode:m,forced:v}=ko();return I.createElement(a,{ref:h,"data-theme":v?m:void 0,...p})})}function Vu(){const e=new Map;return new Proxy(Un,{apply(t,r,n){return Un(...n)},get(t,r){return e.has(r)||e.set(r,Un(r)),e.get(r)}})}var ki=Vu();function Ko(e){return I.forwardRef(e)}var Ei={path:s.jsxs("g",{stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("path",{strokeLinecap:"round",fill:"none",d:"M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"}),s.jsx("path",{fill:"currentColor",strokeLinecap:"round",d:"M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"}),s.jsx("circle",{fill:"none",strokeMiterlimit:"10",cx:"12",cy:"12",r:"11.25"})]}),viewBox:"0 0 24 24"},Mo=Ko((e,t)=>{const{as:r,viewBox:n,color:i="currentColor",focusable:a=!1,children:c,className:u,__css:p,...h}=e,m=kl("chakra-icon",u),v=qu("Icon",e),w={w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:i,...p,...v},b={ref:t,focusable:a,className:m,__css:w},x=n??Ei.viewBox;if(r&&typeof r!="string")return s.jsx(ki.svg,{as:r,...b,...h});const S=c??Ei.path;return s.jsx(ki.svg,{verticalAlign:"middle",viewBox:x,...b,...h,children:S})});Mo.displayName="Icon";function Yu(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:i={}}=e,a=I.Children.toArray(e.path),c=Ko((u,p)=>s.jsx(Mo,{ref:p,viewBox:t,...i,...u,children:a.length?a:s.jsx("path",{fill:"currentColor",d:r})}));return c.displayName=n,c}var Zu=Yu({displayName:"ExternalLinkIcon",path:s.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("path",{d:"M15 3h6v6"}),s.jsx("path",{d:"M10 14L21 3"})]})});const Qu="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function ep({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{children:s.jsx(y.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),s.jsxs(y.Link,{href:Qu,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",s.jsx(Zu,{mx:"2px"})]}),s.jsx(Vt,{error:r}),s.jsxs(y.Flex,{marginTop:"1em",children:[s.jsx(y.Input,{placeholder:"MyDomain",onChange:i=>t(i.currentTarget.value)}),s.jsx(y.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function tp({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n,providerName:i}){return s.jsx(Gt,{children:s.jsxs(y.FormControl,{children:[s.jsx(y.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsxs(y.Heading,{as:"h4",size:"md",children:["Enter your ",i," workspace"]})}),s.jsx(Vt,{error:r}),s.jsx(y.Flex,{marginTop:"1em",children:s.jsx(y.Input,{placeholder:"MyWorkspace",onChange:a=>t(a.currentTarget.value)})}),s.jsx("br",{}),s.jsx(y.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}const rp="salesforce";function np({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:c}=Z(),u=ee(),[p,h]=I.useState(""),[m,v]=I.useState(null),[w,b]=I.useState(null),x=async()=>{if(b(null),!p){b("Workspace is required");return}try{const T=await _o(c,t,n,u,e,p,r,i);v(T)}catch(T){console.error(T),b((T==null?void 0:T.message)??"Unexpected error")}},S=I.useCallback(T=>{b(T),v(null)},[]),O=e===rp?s.jsx(ep,{handleSubmit:x,setWorkspace:h,error:w,isButtonDisabled:p.length===0}):s.jsx(tp,{handleSubmit:x,setWorkspace:h,error:w,isButtonDisabled:p.length===0,providerName:a});return s.jsx(Ao,{windowTitle:`Connect to ${a}`,oauthUrl:m,onClose:S,children:O})}const ip="authorizationCode",op="clientCredentials";function ap({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,selectedConnection:c,setSelectedConnection:u}){if(t.oauth2Opts===void 0)return s.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:p,explicitScopesRequired:h,explicitWorkspaceRequired:m}=t.oauth2Opts,v=st(e,t);return p===ip?m?s.jsx(np,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):s.jsx(Tl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):p===op?m?s.jsx(_l,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:h,setSelectedConnection:u,selectedConnection:c,providerName:v}):s.jsx(vl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:h,setSelectedConnection:u,selectedConnection:c,providerName:v}):p==="password"?s.jsx("em",{children:"Password flow not supported yet"}):p==="PKCE"?s.jsx("em",{children:"PKCE flow not supported yet"}):s.jsxs("em",{children:["Unsupported grant type: ",p]})}const sp=async(e,t)=>{const r=await H().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!r)throw new Error(`Provider ${t} not found`);return r};function Uo({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,onSuccess:c}){const u=ee(),[p,h]=I.useState(null),{provider:m}=Ne(),{selectedConnection:v,setSelectedConnection:w,connections:b}=xt();hl({onSuccess:c});const x=e||m,S=(p==null?void 0:p.displayName)??Vi(x);if(I.useEffect(()=>{if(!v&&b&&b.length>0){const[O]=b;w(O)}sp(u,x).then(O=>{h(O)}).catch(O=>{console.error("Error loading provider info: ",O)})},[b,v,w,u,x]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");return v?a:p==null?s.jsx("strong",{children:"Provider not found"}):p.authType==="none"?s.jsx(wl,{provider:x,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,providerName:S,children:a}):p.authType==="basic"?s.jsx(pl,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,children:a}):p.authType==="apiKey"?s.jsx(cl,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:w,selectedConnection:v,groupRef:n,groupName:i,children:a}):s.jsx(ap,{provider:x,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:i,setSelectedConnection:w,selectedConnection:v})}function cp({integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:c,onUninstallSuccess:u}){var m;const{projectId:p}=Z(),{errorState:h}=We();return(m=h[V.INTEGRATION_LIST])!=null&&m.apiError?s.jsx(Fe,{message:"Something went wrong, couldn't find integration information"}):s.jsx(Gc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:c,onUninstallSuccess:u,children:s.jsx(eo,{groupRef:n,children:s.jsx(Uo,{consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:s.jsx(gd,{projectId:p,children:s.jsx(il,{children:s.jsx(Rd,{children:s.jsx(Ed,{children:s.jsx(Zd,{})})})})})})})})}function dp({redirectURL:e,children:t}){return I.useEffect(()=>{e&&window.location.replace(e)},[e]),e?s.jsx(y.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:s.jsx(Ce,{message:"Redirecting..."})}):t}function lp({provider:e}){const{appName:t}=Z(),r=`You have successfully connected your ${st(e)} account to ${t}.`;return s.jsx(ai,{text:r})}function up({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,redirectUrl:a,onSuccess:c}){return s.jsx(eo,{provider:e,groupRef:n,children:s.jsx(Uo,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onSuccess:c,children:s.jsx(dp,{redirectURL:a,children:s.jsx(lp,{provider:e})})})})}const pp=(e,t)=>{const r=ee(),{projectId:n}=Z(),{integrations:i}=Hi(),[a,c]=I.useState(!1),[u,p]=I.useState(null);if(!r||!n)throw new Error("useIsIntegrationInstalled must be used within AmpersandProvider");if(!e)throw new Error("useIsIntegrationInstalled requires an integration name");if(!t)throw new Error("useIsIntegrationInstalled requires a groupRef");const h=I.useMemo(()=>i==null?void 0:i.reduce((m,v)=>(v==null?void 0:v.name)===e?v:m,{}),[i,e]);return I.useEffect(()=>{h&&H().installationApi.listInstallations({projectIdOrName:n,integrationId:h.id,groupRef:t},{headers:{"x-api-key":r}}).then(m=>{c(!0),p(m.length>0)}).catch(m=>{console.error("Error listing installations: ",m),c(!0)})},[t,r,n,h]),{isLoaded:a,isIntegrationInstalled:u}};exports.AmpersandContext=Gi;exports.AmpersandProvider=zc;exports.ConnectProvider=up;exports.InstallIntegration=cp;exports.useAmpersandProvider=Jc;exports.useIsIntegrationInstalled=pp;