@amp-labs/react 1.12.0 → 1.13.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.
- package/build/amp-react.cjs.js +4 -3
- package/build/amp-react.es.js +2949 -3276
- package/build/style.css +1 -0
- package/package.json +6 -3
package/build/amp-react.cjs.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
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
|
-
|
|
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&<.binding&<.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)&>(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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),w=require("react"),S=require("@chakra-ui/react"),qo=require("@emotion/react"),hi=require("@emotion/styled"),Ho={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"}}},Jo=S.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:Ho}}}),Xo=S.extendTheme(Jo);function Go({children:e}){return s.jsx(S.ChakraProvider,{theme:Xo,children:e})}const Bi=w.createContext(null),Vo=Bi.Provider,ee=()=>{const e=w.useContext(Bi);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var J=(e=>(e.MAPPING="mappingError",e.INTEGRATION_LIST="integrationListError",e.PROJECT="projectError",e.CONNECTION_LIST="connectionListError",e.HYDRATED_REVISION="hydratedRevisionError",e.INSTALLATION_LIST="installationListError",e.INSTALLATION_MUTATION="installationMutationError",e))(J||{});const Di=w.createContext(void 0);function Je(){const e=w.useContext(Di);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const Yo=(()=>{const e={};return Object.values(J).forEach(t=>{e[t]={}}),e})();function Zo({children:e}){const[t,r]=w.useState(Yo),n=w.useCallback((m,v,y=!0)=>{r(b=>{const I={...b};return I[m]=I[m]||{},I[m][v]=y,I})},[r]),i=w.useCallback((m,v)=>{var y;return!!((y=t[m])!=null&&y[v])},[t]),a=w.useCallback((m,v)=>{var y;return(y=t[m])==null?void 0:y[v]},[t]),d=w.useCallback((m,v)=>{r(y=>{var I;const b={...y};return(I=b[m])==null||delete I[v],b})},[r]),u=w.useCallback(m=>{r(v=>{const y={...v};return y[m]={},y})},[r]),p=w.useCallback((m,v)=>{r(y=>{const b={...y};return b[m]=b[m]||{},v.forEach(I=>{b[m][I]=!0}),b})},[r]),g=w.useMemo(()=>({errorState:t,setErrorState:r,setError:n,isError:i,removeError:d,resetBoundary:u,setErrors:p,getError:a}),[t,r,n,i,d,u,p,a]);return s.jsx(Di.Provider,{value:g,children:e})}function Qo(){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("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"})]})}function Qt({children:e,className:t,style:r}){return s.jsx(S.Box,{className:t,style:r,borderWidth:1,borderRadius:4,children:e})}function ei({children:e,className:t,style:r}){return s.jsx(S.Container,{className:t,style:r,children:e})}function Le({message:e}){return s.jsxs(S.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[s.jsx(Qo,{}),s.jsx(S.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(S.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const ea="https://api.withampersand.com/v1".replace(/\/+$/,"");class Li{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:ea}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||$i}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 ta=new Li,Er=class Er{constructor(t=ta){this.configuration=t,this.fetchApi=async(r,n)=>{let i={url:r,init:n};for(const d of this.middleware)d.pre&&(i=await d.pre({fetch:this.fetchApi,...i})||i);let a;try{a=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(d){for(const u of this.middleware)u.onError&&(a=await u.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:d,response:a?a.clone():void 0})||a);if(a===void 0)throw d instanceof Error?new ia(d,"The request failed and the interceptors did not return an alternative response"):d}for(const d of this.middleware)d.post&&(a=await d.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?Er.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 Mi(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(g=>i[g]===void 0?delete i[g]:{});const a=typeof r=="function"?r:async()=>r,d={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},u={...d,...await a({init:d,context:t})},p={...u,body:na(u.body)||u.body instanceof URLSearchParams||ra(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}};Er.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let Ne=Er;function ra(e){return typeof Blob<"u"&&e instanceof Blob}function na(e){return typeof FormData<"u"&&e instanceof FormData}class Mi extends Error{constructor(t,r){super(r),this.response=t,this.name="ResponseError"}}class ia extends Error{constructor(t,r){super(r),this.cause=t,this.name="FetchError"}}class E extends Error{constructor(t,r){super(r),this.field=t,this.name="RequiredError"}}function _(e,t){const r=e[t];return r!=null}function $i(e,t=""){return Object.keys(e).map(r=>Ki(r,e[r],t)).filter(r=>r.length>0).join("&")}function Ki(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 Ki(e,i,r)}return t instanceof Date?`${encodeURIComponent(n)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?$i(t,n):`${encodeURIComponent(n)}=${encodeURIComponent(String(t))}`}function ti(e,t){return Object.keys(e).reduce((r,n)=>({...r,[n]:t(e[n])}),{})}class Y{constructor(t,r=n=>n){this.raw=t,this.transformer=r}async value(){return this.transformer(await this.raw.json())}}class Ot{constructor(t){this.raw=t}async value(){}}class oa{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function aa(e){return sa(e)}function sa(e,t){return e==null?e:{fieldUsed:_(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:_(e,"keyFormat")?e.keyFormat:void 0}}function ca(e){return da(e)}function da(e,t){return e==null?e:{name:e.name,valuePrefix:_(e,"valuePrefix")?e.valuePrefix:void 0}}function la(e){return ua(e)}function ua(e,t){return e==null?e:{name:e.name}}function pa(e){return fa(e)}function fa(e,t){return e==null?e:{attachmentType:e.attachmentType,query:_(e,"query")?la(e.query):void 0,header:_(e,"header")?ca(e.header):void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0}}function ha(e){return ga(e)}function ga(e,t){return e}function ma(e){return ya(e)}function ya(e,t){return e==null?e:{days:_(e,"days")?e.days:void 0,fullHistory:_(e,"fullHistory")?e.fullHistory:void 0}}function Ui(e){return wa(e)}function wa(e,t){return e==null?e:{defaultPeriod:ma(e.defaultPeriod)}}function va(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ba(e){if(e!==void 0)return e===null?null:{defaultPeriod:va(e.defaultPeriod)}}function Ia(e){return Sa(e)}function Sa(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function Wi(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function xa(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:ba(e.backfill)}}function Ca(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:ti(e.objects,xa)}}function Oa(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function Ta(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:ti(e.objects,Oa)}}function Na(e){return _a(e)}function _a(e,t){return e==null?e:{apiKeyAsBasic:_(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:_(e,"apiKeyAsBasicOpts")?aa(e.apiKeyAsBasicOpts):void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0}}function Ra(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function br(e){return Aa(e)}function Aa(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:_(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function ja(e){return ka(e)}function ka(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Ea(e){return Fa(e)}function Fa(e,t){return e==null?e:{provider:e.provider,read:_(e,"read")?e.read:void 0,write:_(e,"write")?e.write:void 0,proxy:_(e,"proxy")?Ia(e.proxy):void 0}}function zi(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Wi(e.proxy)}}function Pa(e){return Ba(e)}function Ba(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Ea(e.content)}}function Da(e){return La(e)}function La(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function qi(e){return Ma(e)}function Ma(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function xr(e){return $a(e)}function $a(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:_(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:_(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function Cr(e){return Ka(e)}function Ka(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:xr(e.providerApp),group:qi(e.group),consumer:Da(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:_(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function Ua(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:zi(e.content)}}function Wa(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Ua(e.config)}}function za(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function qa(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 Ja(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:_(e,"mode")?e.mode:void 0,pageSize:_(e,"pageSize")?e.pageSize:void 0}}function Ya(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Za(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Qa(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 es(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:Ya(e.basicAuth),oauth2ClientCredentials:Za(e.oauth2ClientCredentials),oauth2Password:Qa(e.oauth2Password)}}function ts(e){return rs(e)}function rs(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function ns(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function Hi(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:_(e,"default")?e.default:void 0,prompt:_(e,"prompt")?e.prompt:void 0}}function Ln(e){return is(e)}function is(e,t){return e==null?e:{...ns(e),...Hi(e)}}function Ji(e){return os(e)}function os(e,t){return e}function as(e){return ss(e)}function ss(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:_(e,"requiredFields")?e.requiredFields.map(Ln):void 0,optionalFields:_(e,"optionalFields")?e.optionalFields.map(Ln):void 0,optionalFieldsAuto:_(e,"optionalFieldsAuto")?Ji(e.optionalFieldsAuto):void 0,allFields:_(e,"allFields")?e.allFields.map(Ln):void 0,backfill:_(e,"backfill")?Ui(e.backfill):void 0}}function cs(e){return ds(e)}function ds(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(as):void 0}}function ls(e){return us(e)}function us(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function ps(e){return fs(e)}function fs(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(ls):void 0}}function hs(e){return gs(e)}function gs(e,t){return e==null?e:{name:e.name,displayName:_(e,"displayName")?e.displayName:void 0,provider:e.provider,read:_(e,"read")?cs(e.read):void 0,write:_(e,"write")?ps(e.write):void 0,proxy:_(e,"proxy")?ts(e.proxy):void 0}}function ms(e){return ys(e)}function ys(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:hs(e.content)}}function ws(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 vs(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:zi(e.content)}}function bs(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:ws(e.connection),config:vs(e.config)}}function Jt(e){return Is(e)}function Is(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:_(e,"group")?qi(e.group):void 0,healthStatus:e.healthStatus,connection:Cr(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,config:Pa(e.config)}}function Ss(e){return xs(e)}function xs(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function Cs(e,t){return e==null?e:{fieldName:e.fieldName}}function gi(e){return Os(e)}function Os(e,t){return e==null?e:{...Cs(e),...Hi(e)}}function Ts(e){return Ns(e)}function Ns(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:_(e,"requiredFields")?e.requiredFields.map(gi):void 0,optionalFields:_(e,"optionalFields")?e.optionalFields.map(gi):void 0,optionalFieldsAuto:_(e,"optionalFieldsAuto")?Ji(e.optionalFieldsAuto):void 0,backfill:_(e,"backfill")?Ui(e.backfill):void 0,delivery:_(e,"delivery")?Ga(e.delivery):void 0}}function _s(e){return Rs(e)}function Rs(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Ts):void 0}}function As(e){return js(e)}function js(e,t){return e==null?e:{objectName:e.objectName}}function ks(e){return Es(e)}function Es(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(As):void 0}}function Fs(e){return Ps(e)}function Ps(e,t){return e==null?e:{name:e.name,displayName:_(e,"displayName")?e.displayName:void 0,provider:e.provider,read:_(e,"read")?_s(e.read):void 0,write:_(e,"write")?ks(e.write):void 0,proxy:_(e,"proxy")?Ss(e.proxy):void 0}}function Bs(e){return Ds(e)}function Ds(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Fs(e.content)}}function mi(e){return Ls(e)}function Ls(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Bs(e.latestRevision)}}function Ms(e){return $s(e)}function $s(e,t){return e==null?e:{iconURL:_(e,"iconURL")?e.iconURL:void 0,logoURL:_(e,"logoURL")?e.logoURL:void 0}}function Ks(e){return Us(e)}function Us(e,t){return e==null?e:{iconURL:_(e,"iconURL")?e.iconURL:void 0,logoURL:_(e,"logoURL")?e.logoURL:void 0}}function Ws(e){return zs(e)}function zs(e,t){return e==null?e:{regular:_(e,"regular")?Ks(e.regular):void 0,darkMode:_(e,"darkMode")?Ms(e.darkMode):void 0}}function qs(e){return Hs(e)}function Hs(e,t){return e==null?e:{workspaceRefField:_(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:_(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:_(e,"scopesField")?e.scopesField:void 0}}function Js(e){return Xs(e)}function Xs(e,t){return e==null?e:{grantType:e.grantType,authURL:_(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:_(e,"audience")?e.audience:void 0,tokenMetadataFields:qs(e.tokenMetadataFields),docsURL:_(e,"docsURL")?e.docsURL:void 0,authURLParams:_(e,"authURLParams")?e.authURLParams:void 0}}function Gs(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 Vs(e){return Ys(e)}function Ys(e,t){return e==null?e:{bulkWrite:ja(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function yi(e){return Zs(e)}function Zs(e,t){return e==null?e:{name:e.name,authType:ha(e.authType),baseURL:e.baseURL,oauth2Opts:_(e,"oauth2Opts")?Js(e.oauth2Opts):void 0,apiKeyOpts:_(e,"apiKeyOpts")?pa(e.apiKeyOpts):void 0,basicOpts:_(e,"basicOpts")?Na(e.basicOpts):void 0,support:Vs(e.support),providerOpts:e.providerOpts,displayName:_(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:_(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:_(e,"media")?Ws(e.media):void 0,labels:_(e,"labels")?e.labels:void 0}}function Qs(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Ca(e.read),write:Ta(e.write),proxy:Wi(e.proxy)}}function ec(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Qs(e.content)}}function tc(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:ec(e.config)}}function rc(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:tc(e.installation)}}function nc(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function ic(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:nc(e.project)}}function oc(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 ac(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:oc(e.providerApp)}}class sc extends Ne{async generateConnectionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("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:es(t.generateConnectionParams)},r);return new Y(a,d=>Cr(d))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new E("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 Y(a,d=>Cr(d))}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 E("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 Y(a,d=>d.map(Cr))}async listConnections(t,r){return await(await this.listConnectionsRaw(t,r)).value()}}class cc extends Ne{async createInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new E("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new E("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 Y(a,d=>Jt(d))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new E("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new E("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 Ot(a)}async deleteInstallation(t,r){await this.deleteInstallationRaw(t,r)}async getInstallationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new E("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new E("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 Y(a,d=>Jt(d))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new E("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new E("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:bs(t.installation)},r);return new Y(a,d=>Jt(d))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new E("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 Y(a,d=>d.map(Jt))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new E("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new E("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new E("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:rc(t.installationUpdate)},r);return new Y(a,d=>Jt(d))}async updateInstallation(t,r){return await(await this.updateInstallationRaw(t,r)).value()}}class dc extends Ne{async batchUpsertIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("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:Ra(t.batchUpsertIntegrationsRequest)},r);return new Y(a,d=>d.map(mi))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new E("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:qa(t.integration)},r);return new Ot(a)}async createIntegration(t,r){await this.createIntegrationRaw(t,r)}async deleteIntegrationRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new E("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 Ot(a)}async deleteIntegration(t,r){await this.deleteIntegrationRaw(t,r)}async listIntegrationsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("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 Y(a,d=>d.map(mi))}async listIntegrations(t,r){return await(await this.listIntegrationsRaw(t,r)).value()}}class lc extends Ne{async oauthConnectRaw(t,r){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new E("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:Gs(t.connectOAuthParams)},r);return this.isJsonMime(a.headers.get("content-type"))?new Y(a):new oa(a)}async oauthConnect(t,r){return await(await this.oauthConnectRaw(t,r)).value()}}class uc extends Ne{async createProjectRaw(t,r){if(t.project===null||t.project===void 0)throw new E("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 Y(a,d=>br(d))}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 E("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 Ot(a)}async deleteProject(t,r){await this.deleteProjectRaw(t,r)}async getProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("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 Y(a,d=>br(d))}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 Y(i,a=>a.map(br))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new E("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:ic(t.projectUpdate)},r);return new Y(a,d=>br(d))}async updateProject(t,r){return await(await this.updateProjectRaw(t,r)).value()}}class pc extends Ne{async getProviderRaw(t,r){if(t.provider===null||t.provider===void 0)throw new E("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 Y(a,d=>yi(d))}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 Y(i,a=>ti(a,yi))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class fc extends Ne{async createProviderAppRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new E("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:Ja(t.providerApp)},r);return new Y(a,d=>xr(d))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new E("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 Ot(a)}async deleteProviderApp(t,r){await this.deleteProviderAppRaw(t,r)}async listProviderAppsRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("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 Y(a,d=>d.map(xr))}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 E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new E("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new E("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:ac(t.providerAppUpdate)},r);return new Y(a,d=>xr(d))}async updateProviderApp(t,r){return await(await this.updateProviderAppRaw(t,r)).value()}}class hc extends Ne{async createRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new E("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 Ot(a)}async createRevision(t,r){await this.createRevisionRaw(t,r)}async getHydratedRevisionRaw(t,r){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new E("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new E("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new E("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new E("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 Y(a,d=>ms(d))}async getHydratedRevision(t,r){return await(await this.getHydratedRevisionRaw(t,r)).value()}}class gc{constructor(t){this.connectionApi=new sc(t),this.installationApi=new cc(t),this.integrationApi=new dc(t),this.oAuthApi=new lc(t),this.projectApi=new uc(t),this.providerApi=new pc(t),this.providerAppApi=new fc(t),this.revisionApi=new hc(t)}}const mc="1.13.0",yc="v1",Ir="https://api.withampersand.com";function Xi(){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 Ir;case"mock":return"http://127.0.0.1:4010";case"":return Ir;default:return e??Ir}}catch{return Ir}}const wc=(e,t)=>`${e}/${t}`;function vc(){return wc(Xi(),yc)}const bc=Xi(),Ic=vc(),Sc=new Li({basePath:Ic,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":mc}});let xc=new gc(Sc);const X=()=>xc;function Cc(){return s.jsx(S.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:s.jsx(S.Stack,{alignItems:"center",children:s.jsx(S.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"})})})}function _e(){return s.jsx(Cc,{})}const ae=async(e,t)=>{var r;if(e instanceof Mi){const{status:n,statusText:i}=e.response;console.error(n===500?"Internal Server Error (500):":n===400?"Bad Request (400):":`Error (${n}):`,i);const a=await e.response.json(),d=((r=a==null?void 0:a.causes)==null?void 0:r.join(`
|
|
2
|
+
`))||"[ERROR] Creating installation failed.";console.error("[Error Message]",d),t&&t(d)}else console.error("Unexpected error:",e.message)},Gi=w.createContext({integrations:null}),Vi=()=>{const e=w.useContext(Gi);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Oc({projectIdOrName:e,children:t}){const r=ee(),{setError:n,isError:i}=Je(),[a,d]=w.useState(null),[u,p]=w.useState(!0);w.useEffect(()=>{X().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),d(m||[])}).catch(m=>{console.error("Error retrieving integration information."),ae(m),p(!1),n(J.INTEGRATION_LIST,e)})},[e,r,n]);const g=w.useMemo(()=>({integrations:a}),[a]);return i(J.INTEGRATION_LIST,e)?s.jsx(Le,{message:"Error retrieving integrations for the project, double check the API key"}):s.jsx(Gi.Provider,{value:g,children:u?s.jsx(_e,{}):t})}const Yi=w.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),Q=()=>{const e=w.useContext(Yi);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Tc({projectIdOrName:e,children:t}){const r=ee(),{isError:n,setError:i}=Je(),[a,d]=w.useState(null),[u,p]=w.useState(!0);w.useEffect(()=>{X().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":r??""}}).then(m=>{p(!1),d(m)}).catch(m=>{console.error("Error loading Ampersand project."),ae(m),i(J.PROJECT,e),p(!1)})},[e,r,p,i]);const g=w.useMemo(()=>({projectId:(a==null?void 0:a.id)||"",projectIdOrName:e,project:a,appName:(a==null?void 0:a.appName)||""}),[e,a]);return n(J.PROJECT,e)?s.jsx(Le,{message:`Error loading project ${e}`}):s.jsx(Yi.Provider,{value:g,children:u?s.jsx(_e,{}):t})}function Nc(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(Go,{children:s.jsx(Zo,{children:s.jsx(Vo,{value:t,children:s.jsx(Tc,{projectIdOrName:a,children:s.jsx(Oc,{projectIdOrName:a,children:i})})})})})}const Zi=w.createContext(null);function _c(){const e=w.useContext(Zi);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
3
|
+
component is wrapped with AmpersandProvider`);return e}function Qi(e){return e.charAt(0).toUpperCase()+e.slice(1)}function pt(e,t){return(t==null?void 0:t.displayName)??Qi(e)}const eo=e=>e.split(`
|
|
4
|
+
`).filter(r=>r.trim()!==""),Rc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(r=>r.name===e)??null,Ac=()=>{const[e,t]=w.useState(!1),r=w.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:r}},to=w.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 Re(){const e=w.useContext(to);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function jc({children:e,integration:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,onInstallSuccess:d,onUpdateSuccess:u,onUninstallSuccess:p}){const g=ee(),{projectId:m}=Q(),{integrations:v}=Vi(),{setError:y,isError:b}=Je(),{isIntegrationDeleted:I,setIntegrationDeleted:x}=Ac(),[C,T]=w.useState([]),[R,F]=w.useState(!0),L=(C==null?void 0:C[0])||null,A=w.useMemo(()=>Rc(t,v||[]),[t,v]);w.useEffect(()=>{A===null&&(v!=null&&v.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,A,v]);const q=w.useCallback(V=>{T([V])},[T]),H=w.useCallback(()=>{A!=null&&A.id&&X().installationApi.listInstallations({projectIdOrName:m,integrationId:A.id,groupRef:i},{headers:{"X-Api-Key":g??""}}).then(V=>{F(!1),T(V||[])}).catch(V=>{y(J.INSTALLATION_LIST,A.id),F(!1),console.error("Error retrieving installation information: ",V)})},[A,m,g,y,i]),te=(A==null?void 0:A.id)||"";w.useEffect(()=>{H()},[H]);const Z=w.useMemo(()=>({integrationId:(A==null?void 0:A.id)||"",provider:(A==null?void 0:A.provider)||"",integrationObj:A,consumerRef:r,consumerName:n,groupRef:i,groupName:a,installation:L,setInstallation:q,resetInstallations:H,onInstallSuccess:d,onUpdateSuccess:u,onUninstallSuccess:p,isIntegrationDeleted:I,setIntegrationDeleted:x}),[A,r,n,i,a,L,q,H,d,u,p,I,x]);if(A!==null){const V=`Error retrieving installation information for integration "${(A==null?void 0:A.name)||"unknown"}"`;return b(J.INSTALLATION_LIST,te)?s.jsx(Le,{message:V}):s.jsx(to.Provider,{value:Z,children:R?s.jsx(_e,{}):e})}return s.jsx(Le,{message:`Integration "${t}" not found`})}const ro=w.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),_t=()=>{const e=w.useContext(ro);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function no({provider:e,groupRef:t,children:r}){const n=ee(),{projectId:i}=Q(),[a,d]=w.useState(null),[u,p]=w.useState(null),[g,m]=w.useState(!0),{setError:v,isError:y}=Je(),{provider:b}=Re();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const I=e||b;if(!I)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");w.useEffect(()=>{X().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:I},{headers:{"X-Api-Key":n??""}}).then(C=>{m(!1),d(C)}).catch(C=>{console.error(`Error retrieving existing OAuth connections for group ID ${t}.`),ae(C),m(!1),v(J.CONNECTION_LIST,i)})},[i,n,t,I,v]);const x=w.useMemo(()=>({connections:a,selectedConnection:u,setConnections:d,setSelectedConnection:p}),[a,u,d,p]);return y(J.CONNECTION_LIST,i)?s.jsx(Le,{message:"Error retrieving existing connections"}):s.jsx(ro.Provider,{value:x,children:g?s.jsx(_e,{}):r})}var qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ri(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nr={exports:{}};Nr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=1,a=2,d=9007199254740991,u="[object Arguments]",p="[object Array]",g="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",y="[object Error]",b="[object Function]",I="[object GeneratorFunction]",x="[object Map]",C="[object Number]",T="[object Null]",R="[object Object]",F="[object Promise]",L="[object Proxy]",A="[object RegExp]",q="[object Set]",H="[object String]",te="[object Symbol]",Z="[object Undefined]",V="[object WeakMap]",me="[object ArrayBuffer]",ne="[object DataView]",Ae="[object Float32Array]",je="[object Float64Array]",tr="[object Int8Array]",Kr="[object Int16Array]",Ur="[object Int32Array]",Wr="[object Uint8Array]",zr="[object Uint8ClampedArray]",qr="[object Uint16Array]",Hr="[object Uint32Array]",Jr=/[\\^$.*+?()[\]{}|]/g,$=/^\[object .+?Constructor\]$/,rr=/^(?:0|[1-9]\d*)$/,K={};K[Ae]=K[je]=K[tr]=K[Kr]=K[Ur]=K[Wr]=K[zr]=K[qr]=K[Hr]=!0,K[u]=K[p]=K[me]=K[m]=K[ne]=K[v]=K[y]=K[b]=K[x]=K[C]=K[R]=K[A]=K[q]=K[H]=K[V]=!1;var Me=typeof qe=="object"&&qe&&qe.Object===Object&&qe,nr=typeof self=="object"&&self&&self.Object===Object&&self,se=Me||nr||Function("return this")(),At=t&&!t.nodeType&&t,ft=At&&!0&&e&&!e.nodeType&&e,jt=ft&&ft.exports===At,ht=jt&&Me.process,ir=function(){try{return ht&&ht.binding&&ht.binding("util")}catch{}}(),or=ir&&ir.isTypedArray;function Xr(l,o){for(var c=-1,f=l==null?0:l.length,O=0,N=[];++c<f;){var j=l[c];o(j,c,l)&&(N[O++]=j)}return N}function Gr(l,o){for(var c=-1,f=o.length,O=l.length;++c<f;)l[O+c]=o[c];return l}function Vr(l,o){for(var c=-1,f=l==null?0:l.length;++c<f;)if(o(l[c],c,l))return!0;return!1}function Yr(l,o){for(var c=-1,f=Array(l);++c<l;)f[c]=o(c);return f}function Zr(l){return function(o){return l(o)}}function gt(l,o){return l.has(o)}function kt(l,o){return l==null?void 0:l[o]}function mt(l){var o=-1,c=Array(l.size);return l.forEach(function(f,O){c[++o]=[O,f]}),c}function xe(l,o){return function(c){return l(o(c))}}function ar(l){var o=-1,c=Array(l.size);return l.forEach(function(f){c[++o]=f}),c}var sr=Array.prototype,Qr=Function.prototype,yt=Object.prototype,$e=se["__core-js_shared__"],Et=Qr.toString,de=yt.hasOwnProperty,Ft=function(){var l=/[^.]+$/.exec($e&&$e.keys&&$e.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),Pt=yt.toString,en=RegExp("^"+Et.call(de).replace(Jr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),cr=jt?se.Buffer:void 0,pe=se.Symbol,Ve=se.Uint8Array,dr=yt.propertyIsEnumerable,lr=sr.splice,ke=pe?pe.toStringTag:void 0,Bt=Object.getOwnPropertySymbols,Ye=cr?cr.isBuffer:void 0,tn=xe(Object.keys,Object),ye=Ue(se,"DataView"),Ze=Ue(se,"Map"),Dt=Ue(se,"Promise"),Lt=Ue(se,"Set"),Mt=Ue(se,"WeakMap"),Qe=Ue(Object,"create"),we=Ie(ye),rn=Ie(Ze),nn=Ie(Dt),on=Ie(Lt),an=Ie(Mt),ur=pe?pe.prototype:void 0,Ce=ur?ur.valueOf:void 0;function Ee(l){var o=-1,c=l==null?0:l.length;for(this.clear();++o<c;){var f=l[o];this.set(f[0],f[1])}}function sn(){this.__data__=Qe?Qe(null):{},this.size=0}function cn(l){var o=this.has(l)&&delete this.__data__[l];return this.size-=o?1:0,o}function dn(l){var o=this.__data__;if(Qe){var c=o[l];return c===n?void 0:c}return de.call(o,l)?o[l]:void 0}function ln(l){var o=this.__data__;return Qe?o[l]!==void 0:de.call(o,l)}function Ke(l,o){var c=this.__data__;return this.size+=this.has(l)?0:1,c[l]=Qe&&o===void 0?n:o,this}Ee.prototype.clear=sn,Ee.prototype.delete=cn,Ee.prototype.get=dn,Ee.prototype.has=ln,Ee.prototype.set=Ke;function ve(l){var o=-1,c=l==null?0:l.length;for(this.clear();++o<c;){var f=l[o];this.set(f[0],f[1])}}function un(){this.__data__=[],this.size=0}function pn(l){var o=this.__data__,c=bt(o,l);if(c<0)return!1;var f=o.length-1;return c==f?o.pop():lr.call(o,c,1),--this.size,!0}function fn(l){var o=this.__data__,c=bt(o,l);return c<0?void 0:o[c][1]}function hn(l){return bt(this.__data__,l)>-1}function gn(l,o){var c=this.__data__,f=bt(c,l);return f<0?(++this.size,c.push([l,o])):c[f][1]=o,this}ve.prototype.clear=un,ve.prototype.delete=pn,ve.prototype.get=fn,ve.prototype.has=hn,ve.prototype.set=gn;function be(l){var o=-1,c=l==null?0:l.length;for(this.clear();++o<c;){var f=l[o];this.set(f[0],f[1])}}function mn(){this.size=0,this.__data__={hash:new Ee,map:new(Ze||ve),string:new Ee}}function wt(l){var o=rt(this,l).delete(l);return this.size-=o?1:0,o}function $t(l){return rt(this,l).get(l)}function yn(l){return rt(this,l).has(l)}function vt(l,o){var c=rt(this,l),f=c.size;return c.set(l,o),this.size+=c.size==f?0:1,this}be.prototype.clear=mn,be.prototype.delete=wt,be.prototype.get=$t,be.prototype.has=yn,be.prototype.set=vt;function et(l){var o=-1,c=l==null?0:l.length;for(this.__data__=new be;++o<c;)this.add(l[o])}function wn(l){return this.__data__.set(l,n),this}function vn(l){return this.__data__.has(l)}et.prototype.add=et.prototype.push=wn,et.prototype.has=vn;function Oe(l){var o=this.__data__=new ve(l);this.size=o.size}function pr(){this.__data__=new ve,this.size=0}function bn(l){var o=this.__data__,c=o.delete(l);return this.size=o.size,c}function In(l){return this.__data__.get(l)}function Sn(l){return this.__data__.has(l)}function xn(l,o){var c=this.__data__;if(c instanceof ve){var f=c.__data__;if(!Ze||f.length<r-1)return f.push([l,o]),this.size=++c.size,this;c=this.__data__=new be(f)}return c.set(l,o),this.size=c.size,this}Oe.prototype.clear=pr,Oe.prototype.delete=bn,Oe.prototype.get=In,Oe.prototype.has=Sn,Oe.prototype.set=xn;function Cn(l,o){var c=nt(l),f=!c&&Pn(l),O=!c&&!f&&Ct(l),N=!c&&!f&&!O&&Ht(l),j=c||f||O||N,B=j?Yr(l.length,String):[],k=B.length;for(var P in l)de.call(l,P)&&!(j&&(P=="length"||O&&(P=="offset"||P=="parent")||N&&(P=="buffer"||P=="byteLength"||P=="byteOffset")||kn(P,k)))&&B.push(P);return B}function bt(l,o){for(var c=l.length;c--;)if(xt(l[c][0],o))return c;return-1}function On(l,o,c){var f=o(l);return nt(l)?f:Gr(f,c(l))}function tt(l){return l==null?l===void 0?Z:T:ke&&ke in Object(l)?An(l):Wt(l)}function fr(l){return it(l)&&tt(l)==u}function hr(l,o,c,f,O){return l===o?!0:l==null||o==null||!it(l)&&!it(o)?l!==l&&o!==o:It(l,o,c,f,hr,O)}function It(l,o,c,f,O,N){var j=nt(l),B=nt(o),k=j?p:fe(l),P=B?p:fe(o);k=k==u?R:k,P=P==u?R:P;var U=k==R,W=P==R,G=k==P;if(G&&Ct(l)){if(!Ct(o))return!1;j=!0,U=!1}if(G&&!U)return N||(N=new Oe),j||Ht(l)?Ut(l,o,c,f,O,N):_n(l,o,k,c,f,O,N);if(!(c&i)){var ie=U&&de.call(l,"__wrapped__"),oe=W&&de.call(o,"__wrapped__");if(ie||oe){var Se=ie?l.value():l,Pe=oe?o.value():o;return N||(N=new Oe),O(Se,Pe,c,f,N)}}return G?(N||(N=new Oe),Rn(l,o,c,f,O,N)):!1}function Kt(l){if(!qt(l)||Fn(l))return!1;var o=We(l)?en:$;return o.test(Ie(l))}function Tn(l){return it(l)&&mr(l.length)&&!!K[tt(l)]}function Nn(l){if(!St(l))return tn(l);var o=[];for(var c in Object(l))de.call(l,c)&&c!="constructor"&&o.push(c);return o}function Ut(l,o,c,f,O,N){var j=c&i,B=l.length,k=o.length;if(B!=k&&!(j&&k>B))return!1;var P=N.get(l);if(P&&N.get(o))return P==o;var U=-1,W=!0,G=c&a?new et:void 0;for(N.set(l,o),N.set(o,l);++U<B;){var ie=l[U],oe=o[U];if(f)var Se=j?f(oe,ie,U,o,l,N):f(ie,oe,U,l,o,N);if(Se!==void 0){if(Se)continue;W=!1;break}if(G){if(!Vr(o,function(Pe,ot){if(!gt(G,ot)&&(ie===Pe||O(ie,Pe,c,f,N)))return G.push(ot)})){W=!1;break}}else if(!(ie===oe||O(ie,oe,c,f,N))){W=!1;break}}return N.delete(l),N.delete(o),W}function _n(l,o,c,f,O,N,j){switch(c){case ne:if(l.byteLength!=o.byteLength||l.byteOffset!=o.byteOffset)return!1;l=l.buffer,o=o.buffer;case me:return!(l.byteLength!=o.byteLength||!N(new Ve(l),new Ve(o)));case m:case v:case C:return xt(+l,+o);case y:return l.name==o.name&&l.message==o.message;case A:case H:return l==o+"";case x:var B=mt;case q:var k=f&i;if(B||(B=ar),l.size!=o.size&&!k)return!1;var P=j.get(l);if(P)return P==o;f|=a,j.set(l,o);var U=Ut(B(l),B(o),f,O,N,j);return j.delete(l),U;case te:if(Ce)return Ce.call(l)==Ce.call(o)}return!1}function Rn(l,o,c,f,O,N){var j=c&i,B=gr(l),k=B.length,P=gr(o),U=P.length;if(k!=U&&!j)return!1;for(var W=k;W--;){var G=B[W];if(!(j?G in o:de.call(o,G)))return!1}var ie=N.get(l);if(ie&&N.get(o))return ie==o;var oe=!0;N.set(l,o),N.set(o,l);for(var Se=j;++W<k;){G=B[W];var Pe=l[G],ot=o[G];if(f)var fi=j?f(ot,Pe,G,o,l,N):f(Pe,ot,G,l,o,N);if(!(fi===void 0?Pe===ot||O(Pe,ot,c,f,N):fi)){oe=!1;break}Se||(Se=G=="constructor")}if(oe&&!Se){var wr=l.constructor,vr=o.constructor;wr!=vr&&"constructor"in l&&"constructor"in o&&!(typeof wr=="function"&&wr instanceof wr&&typeof vr=="function"&&vr instanceof vr)&&(oe=!1)}return N.delete(l),N.delete(o),oe}function gr(l){return On(l,Bn,jn)}function rt(l,o){var c=l.__data__;return En(o)?c[typeof o=="string"?"string":"hash"]:c.map}function Ue(l,o){var c=kt(l,o);return Kt(c)?c:void 0}function An(l){var o=de.call(l,ke),c=l[ke];try{l[ke]=void 0;var f=!0}catch{}var O=Pt.call(l);return f&&(o?l[ke]=c:delete l[ke]),O}var jn=Bt?function(l){return l==null?[]:(l=Object(l),Xr(Bt(l),function(o){return dr.call(l,o)}))}:Dn,fe=tt;(ye&&fe(new ye(new ArrayBuffer(1)))!=ne||Ze&&fe(new Ze)!=x||Dt&&fe(Dt.resolve())!=F||Lt&&fe(new Lt)!=q||Mt&&fe(new Mt)!=V)&&(fe=function(l){var o=tt(l),c=o==R?l.constructor:void 0,f=c?Ie(c):"";if(f)switch(f){case we:return ne;case rn:return x;case nn:return F;case on:return q;case an:return V}return o});function kn(l,o){return o=o??d,!!o&&(typeof l=="number"||rr.test(l))&&l>-1&&l%1==0&&l<o}function En(l){var o=typeof l;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?l!=="__proto__":l===null}function Fn(l){return!!Ft&&Ft in l}function St(l){var o=l&&l.constructor,c=typeof o=="function"&&o.prototype||yt;return l===c}function Wt(l){return Pt.call(l)}function Ie(l){if(l!=null){try{return Et.call(l)}catch{}try{return l+""}catch{}}return""}function xt(l,o){return l===o||l!==l&&o!==o}var Pn=fr(function(){return arguments}())?fr:function(l){return it(l)&&de.call(l,"callee")&&!dr.call(l,"callee")},nt=Array.isArray;function zt(l){return l!=null&&mr(l.length)&&!We(l)}var Ct=Ye||yr;function Fe(l,o){return hr(l,o)}function We(l){if(!qt(l))return!1;var o=tt(l);return o==b||o==I||o==g||o==L}function mr(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=d}function qt(l){var o=typeof l;return l!=null&&(o=="object"||o=="function")}function it(l){return l!=null&&typeof l=="object"}var Ht=or?Zr(or):Tn;function Bn(l){return zt(l)?Cn(l):Nn(l)}function Dn(){return[]}function yr(){return!1}e.exports=Fe})(Nr,Nr.exports);var kc=Nr.exports;const Ec=ri(kc),dt="other";function He(e){return e.mapToName!==void 0}function Fc(e,t){var r;return((r=e==null?void 0:e.objects)==null?void 0:r.find(n=>n.objectName===t))||null}function Pc(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(r=>!He(r)&&!!r.fieldName))||null}function Bc(e){var r;return((r=e==null?void 0:e.requiredFields)==null?void 0:r.filter(n=>He(n)&&!!n.mapToName))||[]}function Dc(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(r=>!He(r)&&!!r.fieldName))||null}const io=(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 Lc(e){return He(e)?e.mapToName:e.fieldName}const oo=(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(d=>{r.push({name:d==null?void 0:d.objectName,completed:e?!!io(e,d.objectName):!1})}),r},ao=e=>{var r;return{name:dt,completed:e?!!((r=e==null?void 0:e.content)!=null&&r.write):!1}};function Mc(e,t){var a;const r=oo(e,t),i=!!((a=t==null?void 0:t.content)!=null&&a.write)?ao(e):void 0;return i&&r.push(i),r}function so(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(J.MAPPING,i),n!=null&&n.length&&console.error("required fields not met",n.map(a=>a.mapToDisplayName)),{errorList:i}}function ni(e,t){return Ec(e,t)}const $c=(e,t,r)=>{var b,I,x,C,T,R;if(!e)return null;const n=Fc(e,t),i=n&&Pc(n),a=n&&Dc(n),d=n&&Bc(n),u=(n==null?void 0:n.allFields)||[],p=r==null?void 0:r.content,g=((x=(I=(b=p==null?void 0:p.read)==null?void 0:b.objects)==null?void 0:I[t])==null?void 0:x.selectedFields)||{},m=((R=(T=(C=p==null?void 0:p.read)==null?void 0:C.objects)==null?void 0:T[t])==null?void 0:R.selectedFieldMappings)||{},v={...g},y={...m};return{allFields:u,requiredFields:i,optionalFields:a,requiredMapFields:d,selectedOptionalFields:g,selectedFieldMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:v,requiredMapFields:y}}},Kc=(e,t)=>{var d,u;if(!e)return null;const r=(u=(d=t==null?void 0:t.content)==null?void 0:d.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 co(e,t,r){var a,d;const n=(a=e==null?void 0:e.content)==null?void 0:a.read,i=(d=e==null?void 0:e.content)==null?void 0:d.write;return{read:$c(n,t,r),write:Kc(i,r)}}const lo=(e,t,r,n)=>{const i=co(e,r,t);n(r,i)},Uc=(e,t,r)=>{const n=Mc(t,e),i={};n.forEach(({name:a,completed:d})=>{d&&(i[a]=co(e,a,t))}),r(i)},uo=e=>{const{requiredFields:t,selectedOptionalFields:r}=(e==null?void 0:e.read)||{},n=new Set;return t==null||t.forEach(a=>n.add(Lc(a))),{...Array.from(n).reduce((a,d)=>({...a,[d]:!0}),{}),...r||{}}},po=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 fo(e,t){return t[e]||void 0}async function ii({createConfig:e,projectId:t,integrationId:r,groupRef:n,connectionId:i,apiKey:a,setError:d,setInstallation:u,onInstallSuccess:p}){const g={projectIdOrName:t,integrationId:r,installation:{groupRef:n,connectionId:i,config:e}};try{const m=await X().installationApi.createInstallation(g,{headers:{"X-Api-Key":a,"Content-Type":"application/json"}});u(m),p==null||p(m.id,m.config)}catch(m){ae(m,d)}}function Fr(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const Wc=(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)},zc=(e,t,r,n)=>{const i=uo(e),a=po(e),d=Wc(r,t);if(!d)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:d.schedule,destination:d.destination,selectedFields:i,selectedFieldMappings:a,backfill:d.backfill}}}}};return Fr(r)&&(u.content.proxy={enabled:!0}),u},qc=(e,t,r,n,i,a,d,u,p,g,m,v)=>{const y=zc(p,a,u,n);return y?ii({createConfig:y,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:d,setError:g,setInstallation:m,onInstallSuccess:v}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ho=e=>{var a,d;const t={},r=(a=e.write)==null?void 0:a.writeObjects,n=(d=e.write)==null?void 0:d.selectedNonConfigurableWriteFields,i=n?Object.keys(n):[];return r&&r.forEach(u=>{const p=u.objectName;i.includes(p)&&(t[p]={objectName:p})}),t},Hc=e=>{const t=e.content.write;return t==null?void 0:t.objects},Jc=(e,t,r)=>{if(!Hc(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=ho(e),a={revisionId:t.id,createdBy:`consumer:${r}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return Fr(t)&&(a.content.proxy={enabled:!0}),a},Xc=(e,t,r,n,i,a,d,u,p,g,m)=>{const v=Jc(u,d,n);return v?ii({createConfig:v,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setError:p,setInstallation:g,onInstallSuccess:m}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},Gc=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-background").trim()||"#FEF2F2",Vc=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-border").trim()||"#FECACA",Yc=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-text").trim()||"#991B1B",Zc={backgroundColor:Gc,borderColor:Vc,color:Yc,padding:".5rem 1rem"};function Qc({children:e,style:t}){return s.jsx(Qt,{style:{...Zc,...t},children:e})}function ed(){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 go="uninstall-installation",td=w.forwardRef(({text:e="Uninstall"},t)=>{const r=S.useTab({ref:t}),n=S.useMultiStyleConfig("Tabs",r);return s.jsxs(S.Button,{__css:n.warningTab,...r,minHeight:15,children:[s.jsxs(S.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[ed(),s.jsx(S.Box,{textAlign:"left",children:s.jsx(S.Text,{color:"red.800",children:e})})]}),r.children]})}),mo=w.createContext({hydratedRevision:null,loading:!1}),er=()=>{const e=w.useContext(mo);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function rd({projectId:e,children:t}){var F;const{selectedConnection:r}=_t(),{integrationId:n,integrationObj:i}=Re(),[a,d]=w.useState(null),[u,p]=w.useState(!0),{isError:g,removeError:m,setError:v}=Je(),y=ee(),b=r==null?void 0:r.id,I=(F=i==null?void 0:i.latestRevision)==null?void 0:F.id,x=(i==null?void 0:i.name)||n;w.useEffect(()=>{e&&n&&I&&b&&y&&X().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:n,revisionId:I,connectionId:b},{headers:{"X-Api-Key":y??""}}).then(L=>{d(L),p(!1),m(J.HYDRATED_REVISION,x)}).catch(L=>{console.error(`Error loading integration ${x}.`),ae(L),p(!1),v(J.HYDRATED_REVISION,x)})},[e,n,I,b,y,m,v,x]);const C=w.useMemo(()=>({hydratedRevision:a,loading:u}),[a,u]),R=`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(mo.Provider,{value:C,children:g(J.HYDRATED_REVISION,x)?s.jsx(Le,{message:R}):t})}function oi({className:e,style:t}){return s.jsx(S.Divider,{className:e,style:t})}function yo(){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 wo=Symbol.for("immer-nothing"),wi=Symbol.for("immer-draftable"),le=Symbol.for("immer-state"),nd=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 ce(e,...t){if(process.env.NODE_ENV!=="production"){const r=nd[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 Tt=Object.getPrototypeOf;function Nt(e){return!!e&&!!e[le]}function lt(e){var t;return e?vo(e)||Array.isArray(e)||!!e[wi]||!!((t=e.constructor)!=null&&t[wi])||Br(e)||Dr(e):!1}var id=Object.prototype.constructor.toString();function vo(e){if(!e||typeof e!="object")return!1;const t=Tt(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)===id}function _r(e,t){Pr(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function Pr(e){const t=e[le];return t?t.type_:Array.isArray(e)?1:Br(e)?2:Dr(e)?3:0}function Wn(e,t){return Pr(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function bo(e,t,r){const n=Pr(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function od(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Br(e){return e instanceof Map}function Dr(e){return e instanceof Set}function at(e){return e.copy_||e.base_}function zn(e,t){if(Br(e))return new Map(e);if(Dr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=vo(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[le];let i=Reflect.ownKeys(n);for(let a=0;a<i.length;a++){const d=i[a],u=n[d];u.writable===!1&&(u.writable=!0,u.configurable=!0),(u.get||u.set)&&(n[d]={configurable:!0,writable:!0,enumerable:u.enumerable,value:e[d]})}return Object.create(Tt(e),n)}else{const n=Tt(e);if(n!==null&&r)return{...e};const i=Object.create(n);return Object.assign(i,e)}}function ai(e,t=!1){return Lr(e)||Nt(e)||!lt(e)||(Pr(e)>1&&(e.set=e.add=e.clear=e.delete=ad),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>ai(n,!0))),e}function ad(){ce(2)}function Lr(e){return Object.isFrozen(e)}var sd={};function ut(e){const t=sd[e];return t||ce(0,e),t}var Yt;function Io(){return Yt}function cd(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function vi(e,t){t&&(ut("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function qn(e){Hn(e),e.drafts_.forEach(dd),e.drafts_=null}function Hn(e){e===Yt&&(Yt=e.parent_)}function bi(e){return Yt=cd(Yt,e)}function dd(e){const t=e[le];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[le].modified_&&(qn(t),ce(4)),lt(e)&&(e=Rr(t,e),t.parent_||Ar(t,e)),t.patches_&&ut("Patches").generateReplacementPatches_(r[le].base_,e,t.patches_,t.inversePatches_)):e=Rr(t,r,[]),qn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==wo?e:void 0}function Rr(e,t,r){if(Lr(t))return t;const n=t[le];if(!n)return _r(t,(i,a)=>Si(e,n,t,i,a,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return Ar(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let a=i,d=!1;n.type_===3&&(a=new Set(i),i.clear(),d=!0),_r(a,(u,p)=>Si(e,n,i,u,p,r,d)),Ar(e,i,!1),r&&e.patches_&&ut("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Si(e,t,r,n,i,a,d){if(process.env.NODE_ENV!=="production"&&i===r&&ce(5),Nt(i)){const u=a&&t&&t.type_!==3&&!Wn(t.assigned_,n)?a.concat(n):void 0,p=Rr(e,i,u);if(bo(r,n,p),Nt(p))e.canAutoFreeze_=!1;else return}else d&&r.add(i);if(lt(i)&&!Lr(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Rr(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Ar(e,i)}}function Ar(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ai(t,r)}function ld(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:Io(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,a=si;r&&(i=[n],a=Zt);const{revoke:d,proxy:u}=Proxy.revocable(i,a);return n.draft_=u,n.revoke_=d,u}var si={get(e,t){if(t===le)return e;const r=at(e);if(!Wn(r,t))return ud(e,r,t);const n=r[t];return e.finalized_||!lt(n)?n:n===Mn(e.base_,t)?($n(e),e.copy_[t]=Xn(n,e)):n},has(e,t){return t in at(e)},ownKeys(e){return Reflect.ownKeys(at(e))},set(e,t,r){const n=So(at(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=Mn(at(e),t),a=i==null?void 0:i[le];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(od(r,i)&&(r!==void 0||Wn(e.base_,t)))return!0;$n(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 Mn(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,$n(e),Jn(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=at(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){ce(11)},getPrototypeOf(e){return Tt(e.base_)},setPrototypeOf(){ce(12)}},Zt={};_r(si,(e,t)=>{Zt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Zt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&ce(13),Zt.set.call(this,e,t,void 0)};Zt.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&ce(14),si.set.call(this,e[0],t,r,e[0])};function Mn(e,t){const r=e[le];return(r?at(r):e)[t]}function ud(e,t,r){var i;const n=So(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function So(e,t){if(!(t in e))return;let r=Tt(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Tt(r)}}function Jn(e){e.modified_||(e.modified_=!0,e.parent_&&Jn(e.parent_))}function $n(e){e.copy_||(e.copy_=zn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var pd=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 d=this;return function(p=a,...g){return d.produce(p,m=>r.call(this,m,...g))}}typeof r!="function"&&ce(6),n!==void 0&&typeof n!="function"&&ce(7);let i;if(lt(t)){const a=bi(this),d=Xn(t,void 0);let u=!0;try{i=r(d),u=!1}finally{u?qn(a):Hn(a)}return vi(a,n),Ii(i,a)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===wo&&(i=void 0),this.autoFreeze_&&ai(i,!0),n){const a=[],d=[];ut("Patches").generateReplacementPatches_(t,i,a,d),n(a,d)}return i}else ce(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(d,...u)=>this.produceWithPatches(d,p=>t(p,...u));let n,i;return[this.produce(t,r,(d,u)=>{n=d,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){lt(e)||ce(8),Nt(e)&&(e=fd(e));const t=bi(this),r=Xn(e,void 0);return r[le].isManual_=!0,Hn(t),r}finishDraft(e,t){const r=e&&e[le];(!r||!r.isManual_)&&ce(9);const{scope_:n}=r;return vi(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=ut("Patches").applyPatches_;return Nt(e)?n(e,t):this.produce(e,i=>n(i,t))}};function Xn(e,t){const r=Br(e)?ut("MapSet").proxyMap_(e,t):Dr(e)?ut("MapSet").proxySet_(e,t):ld(e,t);return(t?t.scope_:Io()).drafts_.push(r),r}function fd(e){return Nt(e)||ce(10,e),xo(e)}function xo(e){if(!lt(e)||Lr(e))return e;const t=e[le];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=zn(e,t.scope_.immer_.useStrictShallowCopy_)}else r=zn(e,!0);return _r(r,(n,i)=>{bo(r,n,xo(i))}),t&&(t.finalized_=!1),r}var ue=new pd,Xt=ue.produce;ue.produceWithPatches.bind(ue);ue.setAutoFreeze.bind(ue);ue.setUseStrictShallowCopy.bind(ue);ue.applyPatches.bind(ue);ue.createDraft.bind(ue);ue.finishDraft.bind(ue);const Co=w.createContext(void 0),hd={};function ci(){const e=w.useContext(Co);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function gd({children:e}){const{installation:t}=Re(),{hydratedRevision:r,loading:n}=er(),[i,a]=w.useState(hd),d=t==null?void 0:t.config;w.useEffect(()=>{r!=null&&r.content&&!n&&d&&!(Object.entries(i).length>0)&&Uc(r,d,a)},[r,n,d,i]);const u=w.useCallback((b,I)=>{a(x=>Xt(x,C=>{C[b]=Xt(C[b],I)}))},[a]),p=w.useCallback((b,I)=>{a(x=>Xt(x,C=>{C[b]=I}))},[a]),g=w.useCallback(()=>{a(Xt(b=>{const I=b.other.write;I&&(I.isWriteModified=!1)}))},[a]),m=w.useCallback(b=>{a(Xt(I=>{var C;const x=(C=I[b])==null?void 0:C.read;x&&(x.isOptionalFieldsModified=!1,x.isRequiredMapFieldsModified=!1)}))},[a]),v=w.useCallback(b=>{b===dt?g():m(b)},[m,g]),y=w.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:a,setConfigureState:u,resetConfigureState:p,resetPendingConfigurationState:v}),[i,p,v,u]);return s.jsx(Co.Provider,{value:y,children:e})}const md=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 yd(e,t){return t?w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},w.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?md: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 Oo=w.forwardRef(({objectName:e,completed:t,pending:r,displayName:n},i)=>{const a=S.useTab({ref:i}),d=S.useMultiStyleConfig("Tabs",a);return s.jsxs(S.Button,{__css:d.tab,...a,variant:"outline",minHeight:15,children:[s.jsxs(S.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[yd(t,r),s.jsxs(S.Box,{textAlign:"left",children:[s.jsx(S.Text,{children:n||e}),r&&s.jsx(S.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),a.children]})});function wd({pending:e,completed:t,displayName:r}){return s.jsxs(s.Fragment,{children:[s.jsx(oi,{style:{margin:"1rem 0"}}),s.jsx(Oo,{objectName:dt,completed:t,pending:e,displayName:r},"other-write")]})}const To=w.createContext(null);function No(){const e=w.useContext(To);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}function vd(e,t){return e!=null&&e[t]?e[t]:{name:go,completed:!1}}const bd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-background-secondary").trim()||"#FCFCFC";function Id({children:e}){var C,T,R;const{project:t}=Q(),{installation:r,provider:n}=Re(),{hydratedRevision:i}=er(),{objectConfigurationsState:a}=ci(),[d,u]=w.useState(0),p=(t==null?void 0:t.appName)||"",g=r==null?void 0:r.config,m=i&&oo(g,i),v=m!==null,y=!!((C=i==null?void 0:i.content)!=null&&C.write),b=y?ao(g):void 0,I=[...m||[]];b&&y&&I.push(b);const x=vd(I,d);return s.jsx(To.Provider,{value:x==null?void 0:x.name,children:s.jsxs(ei,{style:{maxWidth:"55rem"},children:[s.jsxs(Qt,{style:{display:"flex",gap:"4rem",padding:"3rem",backgroundColor:bd},children:[s.jsxs("div",{style:{width:"20rem"},children:[s.jsxs(S.Text,{children:[pt(n)," integration"]}),s.jsx(S.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:p}),v&&s.jsxs(S.Tabs,{index:d,onChange:u,orientation:"horizontal",children:[m.map(F=>{var L,A,q,H;return s.jsx(Oo,{objectName:F.name,completed:F.completed,pending:((A=(L=a[F.name])==null?void 0:L.read)==null?void 0:A.isOptionalFieldsModified)||((H=(q=a[F.name])==null?void 0:q.read)==null?void 0:H.isRequiredMapFieldsModified)},F.name)}),y&&b&&s.jsx(wd,{completed:b.completed,pending:(R=(T=a==null?void 0:a.other)==null?void 0:T.write)==null?void 0:R.isWriteModified,displayName:m!=null&&m.length?"other":"write"}),r&&s.jsxs(s.Fragment,{children:[s.jsx(oi,{style:{margin:"3rem 0 1rem 0"}}),s.jsx(td,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]}),s.jsx(yo,{})]})})}const Rt=()=>{const{appName:e}=Q(),{objectConfigurationsState:t,setConfigureState:r}=ci(),{selectedObjectName:n}=No(),i=fo(n||"",t);return{appName:e,configureState:i,setConfigureState:r,selectedObjectName:n}};function Sd(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=!ni(a,n);e.read.isRequiredMapFieldsModified=u}}function _o(e,t,r,n){t(e,i=>Sd(i,r,n))}function xd({field:e,onSelectChange:t,allFields:r}){var v;const{configureState:n,selectedObjectName:i,setConfigureState:a}=Rt(),[d,u]=w.useState(!0),p=(v=n==null?void 0:n.read)==null?void 0:v.selectedFieldMappings,g=p==null?void 0:p[e.mapToName];w.useEffect(()=>{e._default&&!g&&i&&n&&_o(i,a,e.mapToName,e._default),u(!1)},[e,a,i,g,n]);const m=w.useMemo(()=>r==null?void 0:r.map(y=>s.jsx("option",{value:y.fieldName,children:y.displayName},y.fieldName)),[r]);return s.jsxs(S.Stack,{children:[s.jsx(S.Text,{fontWeight:"500",children:e.mapToDisplayName}),s.jsx(S.Text,{marginBottom:"5px",fontSize:14,children:e==null?void 0:e.prompt}),s.jsx(S.Select,{name:e.mapToName,variant:"flushed",value:g||void 0,onChange:t,placeholder:g?void 0:"Please select one",disabled:d,children:m})]},e.mapToName)}const Cd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-text-secondary").trim()||"#737373";function Mr({string:e}){return s.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"2rem",paddingBottom:"1rem"},children:[s.jsx("h3",{style:{color:Cd,fontSize:"1rem",fontWeight:"500"},children:e}),s.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:s.jsx(oi,{style:{marginLeft:"1rem"}})})]})}function Od(){const{selectedObjectName:e,configureState:t,setConfigureState:r}=Rt(),{isError:n,removeError:i}=Je(),a=u=>{const{value:p,name:g}=u.target;p&&(e&&_o(e,r,g,p),n(J.MAPPING,g)&&i(J.MAPPING,g))},d=w.useMemo(()=>{var u,p;return((p=(u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)==null?void 0:p.filter(He))||[]},[t]);return d.length?s.jsxs(s.Fragment,{children:[s.jsx(Mr,{string:"Map the following fields (required)"}),d.map(u=>{var p;return s.jsxs(S.FormControl,{isInvalid:n(J.MAPPING,u.mapToName),children:[s.jsx(xd,{allFields:((p=t.read)==null?void 0:p.allFields)||[],field:u,onSelectChange:a}),s.jsx(S.FormErrorMessage,{children:" * required"})]},u.mapToName)})]}):null}function Td(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 d=e.read.savedConfig.optionalFields,p=!ni(d,n);e.read.isOptionalFieldsModified=p}else console.warn("read.savedConfig.optionalFields is undefined")}function xi(e,t,r,n){t(e,i=>Td(i,r,n))}function Nd(){var v,y;const{appName:e,configureState:t,setConfigureState:r,selectedObjectName:n}=Rt(),i=(v=t==null?void 0:t.read)==null?void 0:v.selectedOptionalFields,a=b=>{const{name:I,checked:x}=b.target;n&&t&&xi(n,r,I,x)},d=(y=t==null?void 0:t.read)==null?void 0:y.optionalFields,u=b=>{const{checked:I}=b.target;n&&d&&d.forEach(x=>{He(x)||xi(n,r,x.fieldName,I)})},p=!!(d&&d.length>0),g=Object.keys(i||{}).length===(d==null?void 0:d.length),m=!g&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Mr,{string:`${e} reads the following optional fields`}),s.jsxs(S.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((d==null?void 0:d.length)||0)>=2&&s.jsx(S.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(S.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),d.map(b=>He(b)?null:s.jsx(S.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:s.jsx(S.Checkbox,{name:b.fieldName,id:b.fieldName,isChecked:!!(i!=null&&i[b==null?void 0:b.fieldName]),onChange:a,children:b.displayName})},b.fieldName))]})]})}const _d=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-badge").trim()||"#e5e5e5",Rd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-badge-text").trim()||"#404040",Ad={color:Rd,backgroundColor:_d,borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function jd({children:e,style:t,...r}){return s.jsx("span",{style:{...Ad,...t},...r,children:e})}function kd(){var n,i,a;const{configureState:e,selectedObjectName:t}=Rt(),{appName:r}=Q();return s.jsxs(s.Fragment,{children:[s.jsx(Mr,{string:`${r} reads the following ${t} fields`}),s.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:"2rem"},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(d=>He(d)?null:s.jsx(jd,{children:d.displayName},d.fieldName)):"There are no required fields."})]})}function Ed(){return s.jsxs(s.Fragment,{children:[s.jsx(kd,{}),s.jsx(Od,{}),s.jsx(Nd,{})]})}function Fd(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 d=e.write.selectedNonConfigurableWriteFields;if(d[t]=r,r||delete d[t],(a=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&a.selectedNonConfigurableWriteFields){const u=e.write.savedConfig.selectedNonConfigurableWriteFields,g=!ni(u,d);e.write.isWriteModified=g}}}function Ci(e,t,r,n){t(e,i=>{Fd(i,r,n)})}function Pd(){var v,y,b,I;const{appName:e,selectedObjectName:t,configureState:r,setConfigureState:n}=Rt(),i=(v=r==null?void 0:r.write)==null?void 0:v.selectedNonConfigurableWriteFields,a=(y=r==null?void 0:r.write)==null?void 0:y.writeObjects,d=x=>{const{name:C,checked:T}=x.target;t&&r&&Ci(t,n,C,T)},u=x=>{var T,R;const{checked:C}=x.target;t&&r&&((R=(T=r==null?void 0:r.write)==null?void 0:T.writeObjects)==null||R.forEach(F=>{Ci(t,n,F.objectName,C)}))},p=!!a,g=Object.keys(i||{}).length===((I=(b=r==null?void 0:r.write)==null?void 0:b.writeObjects)==null?void 0:I.length),m=!g&&Object.keys(i||{}).length>0;return p&&s.jsxs(s.Fragment,{children:[s.jsx(Mr,{string:`Allow ${e} to write to these object`}),s.jsxs(S.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(S.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:s.jsx(S.Checkbox,{name:"selectAll",id:"selectAll",onChange:u,isIndeterminate:m,isChecked:g,children:"Select all"})}),a.map(x=>s.jsx(S.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:s.jsx(S.Checkbox,{name:x.objectName,id:x.objectName,onChange:d,isChecked:!!(i!=null&&i[x.objectName]),children:x.displayName})},x.objectName))]})]})}function Bd(){const e=ee(),{projectId:t,appName:r}=Q(),{integrationId:n,installation:i,resetInstallations:a,setIntegrationDeleted:d,onUninstallSuccess:u}=Re(),[p,g]=w.useState(!1),m=!t||!n||!(i!=null&&i.id)||p,v=async()=>{if(!m){g(!0),console.warn("uninstalling installation",{projectId:t,integrationId:n,installationId:i.id});try{await X().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(),d()}catch(I){console.error("Error uninstalling installation."),ae(I)}finally{g(!1)}}},y=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(S.Stack,{children:[s.jsx(S.Text,{paddingBottom:3,children:b}),(i==null?void 0:i.id)&&s.jsx(S.Button,{onClick:v,variant:"warning",isDisabled:m,children:y})]})}const Dd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-neutral-100").trim()||"#f5f5f5",Ld=getComputedStyle(document.documentElement).getPropertyValue("--amp-shadows-sm").trim()||"0 1px 2px 0 rgba(0, 0, 0, 0.05)";function Ro({onSave:e,onReset:t,isLoading:r,isCreateMode:n=!1,errorMsg:i}){var L,A,q;const{installation:a}=Re(),{hydratedRevision:d,loading:u}=er(),{configureState:p,selectedObjectName:g}=Rt(),m=a==null?void 0:a.config,v=m&&g&&!!io(m,g)||!1,y=((L=p==null?void 0:p.read)==null?void 0:L.isOptionalFieldsModified)||((A=p==null?void 0:p.read)==null?void 0:A.isRequiredMapFieldsModified),b=(q=p==null?void 0:p.write)==null?void 0:q.isWriteModified,T=u||r||!p||!g||!(y||b||n||g!==dt&&!v),R=g===dt,F=g===go;return r?s.jsx(_e,{}):s.jsxs("form",{style:{width:"100%",maxWidth:"50rem"},onSubmit:e,children:[s.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:"1rem",marginBottom:"2rem"},children:[s.jsx(S.Button,{variant:"primary",type:"submit",isDisabled:T,children:n?"Install":"Save"}),s.jsx(S.Button,{isDisabled:T,onClick:t,children:"Reset"})]}),s.jsxs(Qt,{style:{padding:"2rem",minHeight:"300px",backgroundColor:"white",borderColor:Dd,boxShadow:Ld},children:[i&&s.jsx(Qc,{children:typeof i=="string"?i:"Installation Failed."}),u&&s.jsx(_e,{}),d&&!F&&!R&&s.jsx(Ed,{}),d&&!F&&R&&s.jsx(Pd,{}),!u&&F&&s.jsx(Bd,{})]})]})}const Ao=()=>{const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,onInstallSuccess:i,onUpdateSuccess:a}=Re(),{hydratedRevision:d,loading:u}=er(),{selectedObjectName:p}=No(),{selectedConnection:g}=_t(),m=ee(),{projectId:v}=Q(),{resetBoundary:y,setErrors:b,setError:I,getError:x}=Je(),{resetConfigureState:C,objectConfigurationsState:T,resetPendingConfigurationState:R}=ci(),F=fo(p||"",T),L=w.useCallback(()=>{y(J.INSTALLATION_MUTATION)},[y]),A=w.useCallback(H=>H?te=>{I(J.INSTALLATION_MUTATION,H,te)}:te=>{console.error("objectName is required to set installation error: ",te)},[I]),q=w.useCallback(H=>H?x(J.INSTALLATION_MUTATION,H):"",[x]);return{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:d,loading:u,selectedObjectName:p,selectedConnection:g,apiKey:m,projectId:v,resetBoundary:y,setErrors:b,setMutateInstallationError:A,getMutateInstallationError:q,resetMutateInstallationErrorState:L,resetConfigureState:C,objectConfigurationsState:T,resetPendingConfigurationState:R,configureState:F,onInstallSuccess:i,onUpdateSuccess:a}},Md=void 0;function $d(){const{integrationId:e,groupRef:t,consumerRef:r,setInstallation:n,hydratedRevision:i,loading:a,selectedObjectName:d,selectedConnection:u,apiKey:p,projectId:g,resetBoundary:m,setErrors:v,setMutateInstallationError:y,getMutateInstallationError:b,resetMutateInstallationErrorState:I,resetConfigureState:x,objectConfigurationsState:C,resetPendingConfigurationState:T,configureState:R,onInstallSuccess:F}=Ao(),[L,A]=w.useState(!1),q=d===dt,H=b(d),te=w.useCallback(()=>{m(J.MAPPING),i!=null&&i.content&&!a&&d&&lo(i,Md,d,x)},[m,i,a,d,x]);w.useEffect(()=>{!R&&(i!=null&&i.content)&&!a&&te()},[R,C,i,a,te]);const Z=()=>{I();const{requiredMapFields:ne,selectedFieldMappings:Ae}=(R==null?void 0:R.read)||{},{errorList:je}=so(ne,Ae,v);je.length>0||(d&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&i?(A(!0),qc(g,e,t,r,u.id,d,p,i,R,y(d),n,F).finally(()=>{A(!1),T(d)})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},V=()=>{I(),d&&(u!=null&&u.id)&&p&&g&&e&&t&&r&&i?(A(!0),Xc(g,e,t,r,u.id,p,i,R,y(d),n,F).finally(()=>{A(!1),T(d)})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},me=ne=>{ne.preventDefault(),q?V():Z()};return s.jsx(Ro,{errorMsg:H,isCreateMode:!0,isLoading:L,onSave:me,onReset:te})}function Kd({updateConfig:e,projectId:t,integrationId:r,installationId:n,apiKey:i,selectedObjectName:a,setInstallation:d,onUpdateSuccess:u,setError:p}){const g={projectIdOrName:t,installationId:n,integrationId:r,installationUpdate:{updateMask:[`config.content.read.objects.${a}`],installation:{config:e}}};return X().installationApi.updateInstallation(g,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(m=>{d(m),u==null||u(m.id,m.config)}).catch(m=>{ae(m,p)})}const Ud=(e,t,r,n,i,a)=>{const d=uo(e),u=po(e),p={content:{read:{objects:{[t]:{objectName:t,schedule:n,destination:(r==null?void 0:r.destination)||"",selectedFields:d,selectedFieldMappings:u,backfill:a}}}}};return Fr(i)&&(p.content||(p.content={}),p.content.proxy={enabled:!0}),p},Wd=(e,t,r,n,i,a,d,u,p,g,m)=>{const v=Ud(a,n||"",u,u.schedule,p,u.backfill);return v?Kd({updateConfig:v,projectId:e,integrationId:t,installationId:r,apiKey:i,selectedObjectName:n,setError:g,setInstallation:d,onUpdateSuccess:m}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},zd=(e,t)=>{const n={content:{write:{objects:ho(e)}}};return Fr(t)&&(n.content||(n.content={}),n.content.proxy={enabled:!0}),n},qd=(e,t,r,n,i,a,d,u,p)=>{const g=zd(i,a);if(!g)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const m={projectIdOrName:e,installationId:r,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:g}}};return X().installationApi.updateInstallation(m,{headers:{"X-Api-Key":n,"Content-Type":"application/json"}}).then(v=>{u(v),p==null||p(v.id,v.config)}).catch(v=>{ae(v,d)})};function Hd({installation:e,integrationObj:t}){const{setInstallation:r,hydratedRevision:n,loading:i,selectedObjectName:a,apiKey:d,projectId:u,resetBoundary:p,setErrors:g,setMutateInstallationError:m,getMutateInstallationError:v,resetConfigureState:y,resetPendingConfigurationState:b,configureState:I,onUpdateSuccess:x}=Ao(),[C,T]=w.useState(!1),R=a===dt,F=v(a),{config:L}=e,A=w.useCallback(()=>{p(J.MAPPING),n!=null&&n.content&&!i&&a&&lo(n,L,a,y)},[p,n,i,a,L,y]);w.useEffect(()=>{I||A()},[I,A]),w.useEffect(()=>{e&&A()},[e,A]);const q=w.useMemo(()=>{var me,ne,Ae;return(Ae=(ne=(me=n==null?void 0:n.content)==null?void 0:me.read)==null?void 0:ne.objects)==null?void 0:Ae.find(je=>(je==null?void 0:je.objectName)===a)},[n,a]),H=()=>{const{requiredMapFields:V,selectedFieldMappings:me}=(I==null?void 0:I.read)||{},{errorList:ne}=so(V,me,g);ne.length>0||(n&&e&&a&&d&&u&&q?(T(!0),Wd(u,t.id,e.id,a,d,I,r,q,n,m(a),x).finally(()=>{T(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},te=()=>{e&&a&&d&&u&&n?(T(!0),qd(u,t.id,e.id,d,I,n,m(a),r,x).finally(()=>{T(!1),b(a)})):console.error("UpdateInstallation - onSaveUpdate missing required props")},Z=V=>{V.preventDefault(),R?te():H()};return s.jsx(Ro,{errorMsg:F,onSave:Z,onReset:A,isLoading:C})}function Jd(){const{integrationObj:e,installation:t}=Re();return e?t&&e?s.jsx(Hd,{installation:t,integrationObj:e}):s.jsx($d,{}):s.jsx(Le,{message:"We can't load the integration"})}function Xd(){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 di({text:e}){return s.jsx(ei,{children:s.jsxs(Qt,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},children:[s.jsx(Xd,{}),s.jsx("p",{children:e})]})})}const Gd=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function Vd({projectId:e,integrationId:t,groupRef:r,consumerRef:n,connectionId:i,apiKey:a,hydratedRevision:d,setError:u,setInstallation:p,onInstallSuccess:g}){const m=Gd(d,n);return m?ii({createConfig:m,projectId:e,integrationId:t,groupRef:r,connectionId:i,apiKey:a,setError:u,setInstallation:p,onInstallSuccess:g}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function Yd({provider:e}){const t=`You have successfully installed your ${pt(e)} integration.`;return s.jsx(di,{text:t})}const Zd=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 Qd({children:e}){var F;const{projectId:t}=Q(),r=ee(),{hydratedRevision:n,loading:i}=er(),{integrationObj:a,installation:d,groupRef:u,consumerRef:p,setInstallation:g,onInstallSuccess:m,isIntegrationDeleted:v}=Re(),{selectedConnection:y}=_t(),[b,I]=w.useState(!1),x=i||b,C=(F=n==null?void 0:n.content)==null?void 0:F.provider,T=Zd(n),R=L=>{console.error("Error when creating proxy installation:",L)};return w.useEffect(()=>{!x&&n&&T&&!d&&y&&r&&(a!=null&&a.id)&&(I(!0),Vd({apiKey:r,projectId:t,integrationId:a==null?void 0:a.id,groupRef:u,consumerRef:p,connectionId:y==null?void 0:y.id,hydratedRevision:n,setError:R,setInstallation:g,onInstallSuccess:m}).then(()=>{I(!1)}).catch(L=>{I(!1),console.error("Error when creating proxy installation:",L)}))},[n,T,d,y,r,t,a==null?void 0:a.id,u,p,g,x,m]),a?x?s.jsx(_e,{}):T&&C&&d?s.jsx(Yd,{provider:C}):v?s.jsx(di,{text:"Integration successfully uninstalled."}):s.jsx("div",{children:e}):s.jsx(Le,{message:"We can't load the integration"})}function jo({url:e,providerDisplayName:t,credentialName:r}){return s.jsxs(S.Text,{align:"left",color:"darkgray",children:[s.jsx(S.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 Xe({error:e}){return e?s.jsxs(S.Alert,{status:"error",marginTop:"2em",children:[s.jsx(S.AlertIcon,{}),s.jsx(S.AlertDescription,{children:e})]}):null}function Ge({children:e}){return s.jsx(ei,{children:s.jsxs(Qt,{children:[s.jsx("div",{style:{padding:"3rem 2rem"},children:e}),s.jsx(yo,{})]})})}function el({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var x;const[a,d]=w.useState(!1),u=()=>d(!a),[p,g]=w.useState(""),m=C=>g(C.currentTarget.value),v=p.length>0,y=i||!v,b=pt(e,t),I=(x=t.apiKeyOpts)==null?void 0:x.docsURL;return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{my:"6",children:s.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${b} integration`})}),s.jsx(Xe,{error:n}),s.jsxs(S.Stack,{spacing:4,children:[I&&s.jsx(jo,{url:I,providerDisplayName:b,credentialName:"API key"}),s.jsxs(S.InputGroup,{size:"md",children:[s.jsx(S.Input,{onChange:m,pr:"4.5rem",type:a?"text":"password",placeholder:"API Key"}),s.jsx(S.InputRightElement,{width:"4.5rem",children:s.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:y,width:"100%",type:"submit",onClick:()=>{r(p)},children:"Next"})]})})}function tl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:d,selectedConnection:u,setSelectedConnection:p}){const g=Q(),[m,v]=w.useState(!1),[y,b]=w.useState(null),I=ee();w.useEffect(()=>{if(e&&X&&m&&y!=null){const C={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,apiKey:y};X().connectionApi.generateConnection({projectIdOrName:g.projectId,generateConnectionParams:C},{headers:{"X-Api-Key":I??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info."),ae(T)})}},[I,e,m,n,r,a,i,g,p,y]);const x=C=>{b(C),v(!0)};return u===null?s.jsx(el,{provider:e,providerInfo:t,handleSubmit:x,error:null}):d}function rl({provider:e,providerInfo:t,handleSubmit:r,error:n,isButtonDisabled:i}){var R;const[a,d]=w.useState(!1),u=()=>d(!a),[p,g]=w.useState(""),[m,v]=w.useState(""),y=F=>g(F.currentTarget.value),b=F=>v(F.currentTarget.value),I=pt(e,t),x=(R=t.basicOpts)==null?void 0:R.docsURL,C=p.length>0,T=i||!C;return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${I} integration`})}),s.jsx(Xe,{error:n}),s.jsx("br",{}),s.jsxs(S.Stack,{spacing:4,children:[x&&s.jsx(jo,{url:x,providerDisplayName:I,credentialName:"credentials"}),s.jsx(S.Input,{placeholder:"Username",onChange:y}),s.jsxs(S.InputGroup,{size:"md",children:[s.jsx(S.Input,{onChange:b,pr:"4.5rem",type:a?"text":"password",placeholder:"Password"}),s.jsx(S.InputRightElement,{width:"4.5rem",children:s.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:u,children:a?"Hide":"Show"})})]})]}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:T,width:"100%",type:"submit",onClick:()=>{r(p,m)},children:"Next"})]})})}function nl({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,children:d,selectedConnection:u,setSelectedConnection:p}){const g=Q(),[m,v]=w.useState(!1),[y,b]=w.useState(null),I=ee();w.useEffect(()=>{if(e&&X&&m&&y!=null){const C={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,basicAuth:{username:y.user,password:y.pass}};X().connectionApi.generateConnection({projectIdOrName:g.projectId,generateConnectionParams:C},{headers:{"X-Api-Key":I??"","Content-Type":"application/json"}}).then(T=>{p(T)}).catch(T=>{console.error("Error loading provider info."),ae(T)})}},[I,e,m,n,r,a,i,g,y,p]);const x=(C,T)=>{b({user:C,pass:T}),v(!0)};return u===null?s.jsx(rl,{provider:e,providerInfo:t,handleSubmit:x,error:null}):d}function il({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Xe,{error:t}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function ol({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,selectedConnection:d,setSelectedConnection:u,providerName:p}){const g=Q(),m=ee(),[v,y]=w.useState(!1);w.useEffect(()=>{if(e&&X&&v){const I={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e};X().connectionApi.generateConnection({projectIdOrName:g.projectId,generateConnectionParams:I},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(x=>{u(x)}).catch(x=>{console.error("Error loading provider info."),ae(x)})}},[m,e,v,r,t,i,n,u,g]);const b=()=>{y(!0)};return d===null?s.jsx(il,{handleSubmit:b,error:null,providerName:p}):a}function al({handleSubmit:e,error:t,explicitScopesRequired:r,isButtonDisabled:n,providerName:i}){const[a,d]=w.useState(!1),[u,p]=w.useState(""),[g,m]=w.useState(""),[v,y]=w.useState(""),b=()=>d(!a),I=A=>p(A.currentTarget.value),x=A=>m(A.currentTarget.value),C=A=>y(A.currentTarget.value),T=u.length>0,R=g.length>0,F=n||!T||!R,L=()=>{const A={clientId:g,clientSecret:u};r&&v.length>0&&(A.scopes=eo(v)),e(A)};return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${i} integration`})}),s.jsx(Xe,{error:t}),s.jsx("br",{}),s.jsxs(S.Stack,{spacing:4,children:[s.jsx(S.Input,{placeholder:"Client ID",onChange:x}),s.jsxs(S.InputGroup,{size:"md",children:[s.jsx(S.Input,{onChange:I,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(S.InputRightElement,{width:"4.5rem",children:s.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:b,children:a?"Hide":"Show"})})]}),r&&s.jsx(S.Textarea,{placeholder:"Scopes separated by new line",onChange:C})]}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:F,width:"100%",type:"submit",onClick:L,children:"Next"})]})})}function sl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,explicitScopesRequired:a,providerName:d,selectedConnection:u,setSelectedConnection:p}){const{projectId:g}=Q(),m=ee(),[v,y]=w.useState(null),b=async I=>{y(null);const x={groupName:i,groupRef:n,consumerName:r,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:I.clientId,clientSecret:I.clientSecret,scopes:I.scopes}};X().connectionApi.generateConnection({projectIdOrName:g,generateConnectionParams:x},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(C=>{p(C)}).catch(C=>{console.error("Error loading provider info."),ae(C),y("Error loading provider info")})};return u===null?s.jsx(al,{providerName:d,handleSubmit:b,error:v,explicitScopesRequired:a}):s.jsx(_e,{})}const ko=async(e,t,r,n,i,a,d,u)=>{var g;const p=await X().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":n??""}});if(!p)throw new Error(`Provider ${i} not found`);if(p.authType==="oauth2"&&((g=p.oauth2Opts)==null?void 0:g.grantType)==="authorizationCode"){const v=(await X().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":n??""}})).find(x=>x.provider===i),y=pt(i,p);if(!v)throw new Error(`You must first set up a ${y} Provider App using the Ampersand Console.`);const b={connectOAuthParams:{providerWorkspaceRef:a,projectId:e,groupRef:r,groupName:u,consumerRef:t,consumerName:d,providerAppId:v.id,provider:i}};return await X().oAuthApi.oauthConnect(b)}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},Oi=600,Ti=600,cl="AUTHORIZATION_SUCCEEDED",dl="AUTHORIZATION_FAILED";function ll(e,t,r){return w.useCallback(async n=>{const i=await X().connectionApi.getConnection({projectIdOrName:e,connectionId:n},{headers:{"X-Api-Key":t??""}});r(i)},[e,t,r])}function ul(e,t,r,n){return w.useCallback(()=>{if(!n)return;const i=window.screenX+(window.outerWidth-Oi)/2,a=window.screenY+(window.outerHeight-Ti)/2.5,d=`width=${Oi},height=${Ti},left=${i},top=${a}`,u=window.open(n,e,d);t(u),window.addEventListener("message",r,!1)},[n,e,t,r])}function pl(e,t){return w.useCallback(r=>{var n,i;if(r.origin===bc){if(r.data.eventType===cl){const a=(n=r.data.data)==null?void 0:n.connection;a?e(a):console.error("Connection ID not found in event data: ",{event:r})}r.data.eventType===dl&&(console.error("OAuth failed: ",{event:r}),t==null||t(((i=r==null?void 0:r.data)==null?void 0:i.message)??"OAuth failed. Please try again."))}},[t,e])}function Eo({children:e,oauthUrl:t,windowTitle:r="Connect to Provider",onError:n,error:i}){const a=ee(),{projectId:d}=Q(),[u,p]=w.useState(null),[g,m]=w.useState(null),{setSelectedConnection:v}=_t(),y=pl(p,n),b=ul(r,m,y,t),I=ll(d,a,v);w.useEffect(()=>{t&&!g&&b()},[t,g,b,y,r]),w.useEffect(()=>{u&&I(u).then(()=>{g==null||g.close()}).catch(C=>{console.error("Error refreshing connection: ",C),n==null||n(C.message??"Unexpected error: not able to refresh connection")})},[u,a,v,I,g,n]);const x=g&&setInterval(()=>{(g!=null&&g.closed||!g)&&x&&(clearInterval(x),window.removeEventListener("message",y),m(null),!u&&!i?(console.error("OAuth failed. Please try again."),n==null||n("OAuth failed. Please try again.")):u&&n&&(n==null||n(null)))},500);return s.jsx("div",{children:e})}function fl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n}){return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Xe,{error:t}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:r,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function hl({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:d}=Q(),u=ee(),[p,g]=w.useState(null),[m,v]=w.useState(null),y=async()=>{v(null);try{const I=await ko(d,t,n,u,e,void 0,r,i);g(I)}catch(I){console.error("Could not fetch OAuth popup URL."),ae(I),v(I.message??"Unexpected error")}},b=w.useCallback(I=>{v(I),g(null)},[]);return s.jsx(Eo,{windowTitle:`Connect to ${a}`,oauthUrl:p,onError:b,children:s.jsx(fl,{handleSubmit:y,error:m,providerName:a})})}function gl({handleSubmit:e,error:t,isButtonDisabled:r,providerName:n,explicitScopesRequired:i}){const[a,d]=w.useState(!1),[u,p]=w.useState(""),[g,m]=w.useState(""),[v,y]=w.useState(""),[b,I]=w.useState(""),x=()=>d(!a),C=Z=>p(Z.currentTarget.value),T=Z=>m(Z.currentTarget.value),R=Z=>y(Z.currentTarget.value),F=Z=>I(Z.currentTarget.value),L=u.length>0,A=g.length>0,q=v.length>0,H=r||!L||!A||!q,te=()=>{const Z={workspace:v,clientId:g,clientSecret:u};i&&b.length>0&&(Z.scopes=eo(b)),e(Z)};return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${n} integration`})}),s.jsx(Xe,{error:t}),s.jsx("br",{}),s.jsxs(S.Stack,{spacing:4,children:[s.jsx(S.Input,{placeholder:"MyWorkspace",onChange:R}),s.jsx(S.Input,{placeholder:"Client ID",onChange:T}),s.jsxs(S.InputGroup,{size:"md",children:[s.jsx(S.Input,{onChange:C,pr:"4.5rem",type:a?"text":"password",placeholder:"Client Secret"}),s.jsx(S.InputRightElement,{width:"4.5rem",children:s.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:x,children:a?"Hide":"Show"})})]}),i&&s.jsx(S.Textarea,{placeholder:"Scopes separated by new line",onChange:F})]}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:H,width:"100%",type:"submit",onClick:te,children:"Next"})]})})}function ml({provider:e,providerName:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:d,selectedConnection:u,setSelectedConnection:p}){const{projectId:g}=Q(),m=ee(),[v,y]=w.useState(null),b=async I=>{y(null);const x={groupName:a,groupRef:i,consumerName:n,consumerRef:r,provider:e,providerWorkspaceRef:I.workspace,oauth2ClientCredentials:{clientId:I.clientId,clientSecret:I.clientSecret,scopes:I.scopes}};X().connectionApi.generateConnection({projectIdOrName:g,generateConnectionParams:x},{headers:{"X-Api-Key":m??"","Content-Type":"application/json"}}).then(C=>{p(C)}).catch(C=>{console.error("Error loading provider info."),ae(C),y("Error loading provider info")})};return u===null?s.jsx(gl,{providerName:t,handleSubmit:b,error:v,explicitScopesRequired:d}):s.jsx(_e,{})}function yl(){const e=w.useContext(qo.ThemeContext);if(!e)throw Error("useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`");return e}var Fo=w.createContext({});Fo.displayName="ColorModeContext";function Po(){const e=w.useContext(Fo);if(e===void 0)throw new Error("useColorMode must be used within a ColorModeProvider");return e}function wl(){const e=Po(),t=yl();return{...e,theme:t}}var vl=(...e)=>e.filter(Boolean).join(" ");function ct(e){const t=typeof e;return e!=null&&(t==="object"||t==="function")&&!Array.isArray(e)}function st(e,...t){return bl(e)?e(...t):e}var bl=e=>typeof e=="function",jr={exports:{}};jr.exports;(function(e,t){var r=200,n="__lodash_hash_undefined__",i=800,a=16,d=9007199254740991,u="[object Arguments]",p="[object Array]",g="[object AsyncFunction]",m="[object Boolean]",v="[object Date]",y="[object Error]",b="[object Function]",I="[object GeneratorFunction]",x="[object Map]",C="[object Number]",T="[object Null]",R="[object Object]",F="[object Proxy]",L="[object RegExp]",A="[object Set]",q="[object String]",H="[object Undefined]",te="[object WeakMap]",Z="[object ArrayBuffer]",V="[object DataView]",me="[object Float32Array]",ne="[object Float64Array]",Ae="[object Int8Array]",je="[object Int16Array]",tr="[object Int32Array]",Kr="[object Uint8Array]",Ur="[object Uint8ClampedArray]",Wr="[object Uint16Array]",zr="[object Uint32Array]",qr=/[\\^$.*+?()[\]{}|]/g,Hr=/^\[object .+?Constructor\]$/,Jr=/^(?:0|[1-9]\d*)$/,$={};$[me]=$[ne]=$[Ae]=$[je]=$[tr]=$[Kr]=$[Ur]=$[Wr]=$[zr]=!0,$[u]=$[p]=$[Z]=$[m]=$[V]=$[v]=$[y]=$[b]=$[x]=$[C]=$[R]=$[L]=$[A]=$[q]=$[te]=!1;var rr=typeof qe=="object"&&qe&&qe.Object===Object&&qe,K=typeof self=="object"&&self&&self.Object===Object&&self,Me=rr||K||Function("return this")(),nr=t&&!t.nodeType&&t,se=nr&&!0&&e&&!e.nodeType&&e,At=se&&se.exports===nr,ft=At&&rr.process,jt=function(){try{var o=se&&se.require&&se.require("util").types;return o||ft&&ft.binding&&ft.binding("util")}catch{}}(),ht=jt&&jt.isTypedArray;function ir(o,c,f){switch(f.length){case 0:return o.call(c);case 1:return o.call(c,f[0]);case 2:return o.call(c,f[0],f[1]);case 3:return o.call(c,f[0],f[1],f[2])}return o.apply(c,f)}function or(o,c){for(var f=-1,O=Array(o);++f<o;)O[f]=c(f);return O}function Xr(o){return function(c){return o(c)}}function Gr(o,c){return o==null?void 0:o[c]}function Vr(o,c){return function(f){return o(c(f))}}var Yr=Array.prototype,Zr=Function.prototype,gt=Object.prototype,kt=Me["__core-js_shared__"],mt=Zr.toString,xe=gt.hasOwnProperty,ar=function(){var o=/[^.]+$/.exec(kt&&kt.keys&&kt.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),sr=gt.toString,Qr=mt.call(Object),yt=RegExp("^"+mt.call(xe).replace(qr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$e=At?Me.Buffer:void 0,Et=Me.Symbol,de=Me.Uint8Array;$e&&$e.allocUnsafe;var Ft=Vr(Object.getPrototypeOf,Object),Pt=Object.create,en=gt.propertyIsEnumerable,cr=Yr.splice,pe=Et?Et.toStringTag:void 0,Ve=function(){try{var o=Kt(Object,"defineProperty");return o({},"",{}),o}catch{}}(),dr=$e?$e.isBuffer:void 0,lr=Math.max,ke=Date.now,Bt=Kt(Me,"Map"),Ye=Kt(Object,"create"),tn=function(){function o(){}return function(c){if(!Fe(c))return{};if(Pt)return Pt(c);o.prototype=c;var f=new o;return o.prototype=void 0,f}}();function ye(o){var c=-1,f=o==null?0:o.length;for(this.clear();++c<f;){var O=o[c];this.set(O[0],O[1])}}function Ze(){this.__data__=Ye?Ye(null):{},this.size=0}function Dt(o){var c=this.has(o)&&delete this.__data__[o];return this.size-=c?1:0,c}function Lt(o){var c=this.__data__;if(Ye){var f=c[o];return f===n?void 0:f}return xe.call(c,o)?c[o]:void 0}function Mt(o){var c=this.__data__;return Ye?c[o]!==void 0:xe.call(c,o)}function Qe(o,c){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=Ye&&c===void 0?n:c,this}ye.prototype.clear=Ze,ye.prototype.delete=Dt,ye.prototype.get=Lt,ye.prototype.has=Mt,ye.prototype.set=Qe;function we(o){var c=-1,f=o==null?0:o.length;for(this.clear();++c<f;){var O=o[c];this.set(O[0],O[1])}}function rn(){this.__data__=[],this.size=0}function nn(o){var c=this.__data__,f=wt(c,o);if(f<0)return!1;var O=c.length-1;return f==O?c.pop():cr.call(c,f,1),--this.size,!0}function on(o){var c=this.__data__,f=wt(c,o);return f<0?void 0:c[f][1]}function an(o){return wt(this.__data__,o)>-1}function ur(o,c){var f=this.__data__,O=wt(f,o);return O<0?(++this.size,f.push([o,c])):f[O][1]=c,this}we.prototype.clear=rn,we.prototype.delete=nn,we.prototype.get=on,we.prototype.has=an,we.prototype.set=ur;function Ce(o){var c=-1,f=o==null?0:o.length;for(this.clear();++c<f;){var O=o[c];this.set(O[0],O[1])}}function Ee(){this.size=0,this.__data__={hash:new ye,map:new(Bt||we),string:new ye}}function sn(o){var c=It(this,o).delete(o);return this.size-=c?1:0,c}function cn(o){return It(this,o).get(o)}function dn(o){return It(this,o).has(o)}function ln(o,c){var f=It(this,o),O=f.size;return f.set(o,c),this.size+=f.size==O?0:1,this}Ce.prototype.clear=Ee,Ce.prototype.delete=sn,Ce.prototype.get=cn,Ce.prototype.has=dn,Ce.prototype.set=ln;function Ke(o){var c=this.__data__=new we(o);this.size=c.size}function ve(){this.__data__=new we,this.size=0}function un(o){var c=this.__data__,f=c.delete(o);return this.size=c.size,f}function pn(o){return this.__data__.get(o)}function fn(o){return this.__data__.has(o)}function hn(o,c){var f=this.__data__;if(f instanceof we){var O=f.__data__;if(!Bt||O.length<r-1)return O.push([o,c]),this.size=++f.size,this;f=this.__data__=new Ce(O)}return f.set(o,c),this.size=f.size,this}Ke.prototype.clear=ve,Ke.prototype.delete=un,Ke.prototype.get=pn,Ke.prototype.has=fn,Ke.prototype.set=hn;function gn(o,c){var f=Ie(o),O=!f&&Wt(o),N=!f&&!O&&nt(o),j=!f&&!O&&!N&&qt(o),B=f||O||N||j,k=B?or(o.length,String):[],P=k.length;for(var U in o)B&&(U=="length"||N&&(U=="offset"||U=="parent")||j&&(U=="buffer"||U=="byteLength"||U=="byteOffset")||Ut(U,P))||k.push(U);return k}function be(o,c,f){(f!==void 0&&!St(o[c],f)||f===void 0&&!(c in o))&&$t(o,c,f)}function mn(o,c,f){var O=o[c];(!(xe.call(o,c)&&St(O,f))||f===void 0&&!(c in o))&&$t(o,c,f)}function wt(o,c){for(var f=o.length;f--;)if(St(o[f][0],c))return f;return-1}function $t(o,c,f){c=="__proto__"&&Ve?Ve(o,c,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[c]=f}var yn=hr();function vt(o){return o==null?o===void 0?H:T:pe&&pe in Object(o)?Tn(o):An(o)}function et(o){return We(o)&&vt(o)==u}function wn(o){if(!Fe(o)||gr(o))return!1;var c=zt(o)?yt:Hr;return c.test(Fn(o))}function vn(o){return We(o)&&Ct(o.length)&&!!$[vt(o)]}function Oe(o){if(!Fe(o))return Ue(o);var c=rt(o),f=[];for(var O in o)O=="constructor"&&(c||!xe.call(o,O))||f.push(O);return f}function pr(o,c,f,O,N){o!==c&&yn(c,function(j,B){if(N||(N=new Ke),Fe(j))bn(o,c,B,f,pr,O,N);else{var k=O?O(fe(o,B),j,B+"",o,c,N):void 0;k===void 0&&(k=j),be(o,B,k)}},Ht)}function bn(o,c,f,O,N,j,B){var k=fe(o,f),P=fe(c,f),U=B.get(P);if(U){be(o,f,U);return}var W=j?j(k,P,f+"",o,c,B):void 0,G=W===void 0;if(G){var ie=Ie(P),oe=!ie&&nt(P),Se=!ie&&!oe&&qt(P);W=P,ie||oe||Se?Ie(k)?W=k:Pn(k)?W=On(k):oe?(G=!1,W=xn(P)):Se?(G=!1,W=bt(P)):W=[]:mr(P)||Wt(P)?(W=k,Wt(k)?W=it(k):(!Fe(k)||zt(k))&&(W=Nn(P))):G=!1}G&&(B.set(P,W),N(W,P,O,j,B),B.delete(P)),be(o,f,W)}function In(o,c){return kn(jn(o,c,yr),o+"")}var Sn=Ve?function(o,c){return Ve(o,"toString",{configurable:!0,enumerable:!1,value:Dn(c),writable:!0})}:yr;function xn(o,c){return o.slice()}function Cn(o){var c=new o.constructor(o.byteLength);return new de(c).set(new de(o)),c}function bt(o,c){var f=Cn(o.buffer);return new o.constructor(f,o.byteOffset,o.length)}function On(o,c){var f=-1,O=o.length;for(c||(c=Array(O));++f<O;)c[f]=o[f];return c}function tt(o,c,f,O){var N=!f;f||(f={});for(var j=-1,B=c.length;++j<B;){var k=c[j],P=void 0;P===void 0&&(P=o[k]),N?$t(f,k,P):mn(f,k,P)}return f}function fr(o){return In(function(c,f){var O=-1,N=f.length,j=N>1?f[N-1]:void 0,B=N>2?f[2]:void 0;for(j=o.length>3&&typeof j=="function"?(N--,j):void 0,B&&_n(f[0],f[1],B)&&(j=N<3?void 0:j,N=1),c=Object(c);++O<N;){var k=f[O];k&&o(c,k,O,j)}return c})}function hr(o){return function(c,f,O){for(var N=-1,j=Object(c),B=O(c),k=B.length;k--;){var P=B[++N];if(f(j[P],P,j)===!1)break}return c}}function It(o,c){var f=o.__data__;return Rn(c)?f[typeof c=="string"?"string":"hash"]:f.map}function Kt(o,c){var f=Gr(o,c);return wn(f)?f:void 0}function Tn(o){var c=xe.call(o,pe),f=o[pe];try{o[pe]=void 0;var O=!0}catch{}var N=sr.call(o);return O&&(c?o[pe]=f:delete o[pe]),N}function Nn(o){return typeof o.constructor=="function"&&!rt(o)?tn(Ft(o)):{}}function Ut(o,c){var f=typeof o;return c=c??d,!!c&&(f=="number"||f!="symbol"&&Jr.test(o))&&o>-1&&o%1==0&&o<c}function _n(o,c,f){if(!Fe(f))return!1;var O=typeof c;return(O=="number"?xt(f)&&Ut(c,f.length):O=="string"&&c in f)?St(f[c],o):!1}function Rn(o){var c=typeof o;return c=="string"||c=="number"||c=="symbol"||c=="boolean"?o!=="__proto__":o===null}function gr(o){return!!ar&&ar in o}function rt(o){var c=o&&o.constructor,f=typeof c=="function"&&c.prototype||gt;return o===f}function Ue(o){var c=[];if(o!=null)for(var f in Object(o))c.push(f);return c}function An(o){return sr.call(o)}function jn(o,c,f){return c=lr(c===void 0?o.length-1:c,0),function(){for(var O=arguments,N=-1,j=lr(O.length-c,0),B=Array(j);++N<j;)B[N]=O[c+N];N=-1;for(var k=Array(c+1);++N<c;)k[N]=O[N];return k[c]=f(B),ir(o,this,k)}}function fe(o,c){if(!(c==="constructor"&&typeof o[c]=="function")&&c!="__proto__")return o[c]}var kn=En(Sn);function En(o){var c=0,f=0;return function(){var O=ke(),N=a-(O-f);if(f=O,N>0){if(++c>=i)return arguments[0]}else c=0;return o.apply(void 0,arguments)}}function Fn(o){if(o!=null){try{return mt.call(o)}catch{}try{return o+""}catch{}}return""}function St(o,c){return o===c||o!==o&&c!==c}var Wt=et(function(){return arguments}())?et:function(o){return We(o)&&xe.call(o,"callee")&&!en.call(o,"callee")},Ie=Array.isArray;function xt(o){return o!=null&&Ct(o.length)&&!zt(o)}function Pn(o){return We(o)&&xt(o)}var nt=dr||l;function zt(o){if(!Fe(o))return!1;var c=vt(o);return c==b||c==I||c==g||c==F}function Ct(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=d}function Fe(o){var c=typeof o;return o!=null&&(c=="object"||c=="function")}function We(o){return o!=null&&typeof o=="object"}function mr(o){if(!We(o)||vt(o)!=R)return!1;var c=Ft(o);if(c===null)return!0;var f=xe.call(c,"constructor")&&c.constructor;return typeof f=="function"&&f instanceof f&&mt.call(f)==Qr}var qt=ht?Xr(ht):vn;function it(o){return tt(o,Ht(o))}function Ht(o){return xt(o)?gn(o):Oe(o)}var Bn=fr(function(o,c,f,O){pr(o,c,f,O)});function Dn(o){return function(){return o}}function yr(o){return o}function l(){return!1}e.exports=Bn})(jr,jr.exports);var Il=jr.exports;const De=ri(Il);var Sl=e=>/!(important)?$/.test(e),Ni=e=>typeof e=="string"?e.replace(/!(important)?$/,"").trim():e,xl=(e,t)=>r=>{const n=String(t),i=Sl(n),a=Ni(n),d=e?`${e}.${a}`:a;let u=ct(r.__cssMap)&&d in r.__cssMap?r.__cssMap[d].varRef:t;return u=Ni(u),i?`${u} !important`:u};function li(e){const{scale:t,transform:r,compose:n}=e;return(a,d)=>{var u;const p=xl(t,a)(d);let g=(u=r==null?void 0:r(p,d))!=null?u:p;return n&&(g=n(g,d)),g}}var Sr=(...e)=>t=>e.reduce((r,n)=>n(r),t);function he(e,t){return r=>{const n={property:r,scale:e};return n.transform=li({scale:e,transform:t}),n}}var Cl=({rtl:e,ltr:t})=>r=>r.direction==="rtl"?e:t;function Ol(e){const{property:t,scale:r,transform:n}=e;return{scale:r,property:Cl(t),transform:r?li({scale:r,compose:n}):n}}var Bo=["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 Tl(){return["translateX(var(--chakra-translate-x, 0))","translateY(var(--chakra-translate-y, 0))",...Bo].join(" ")}function Nl(){return["translate3d(var(--chakra-translate-x, 0), var(--chakra-translate-y, 0), 0)",...Bo].join(" ")}var _l={"--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(" ")},Rl={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 Al(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 jl={"row-reverse":{space:"--chakra-space-x-reverse",divide:"--chakra-divide-x-reverse"},"column-reverse":{space:"--chakra-space-y-reverse",divide:"--chakra-divide-y-reverse"}},Gn={"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"},kl=new Set(Object.values(Gn)),Vn=new Set(["none","-moz-initial","inherit","initial","revert","unset"]),El=e=>e.trim();function Fl(e,t){if(e==null||Vn.has(e))return e;if(!(Yn(e)||Vn.has(e)))return`url('${e}')`;const i=/(^[a-z-A-Z]+)\((.*)\)/g.exec(e),a=i==null?void 0:i[1],d=i==null?void 0:i[2];if(!a||!d)return e;const u=a.includes("-gradient")?a:`${a}-gradient`,[p,...g]=d.split(",").map(El).filter(Boolean);if((g==null?void 0:g.length)===0)return e;const m=p in Gn?Gn[p]:p;g.unshift(m);const v=g.map(y=>{if(kl.has(y))return y;const b=y.indexOf(" "),[I,x]=b!==-1?[y.substr(0,b),y.substr(b+1)]:[y],C=Yn(x)?x:x&&x.split(" "),T=`colors.${I}`,R=T in t.__cssMap?t.__cssMap[T].varRef:I;return C?[R,...Array.isArray(C)?C:[C]].join(" "):R});return`${u}(${v.join(", ")})`}var Yn=e=>typeof e=="string"&&e.includes("(")&&e.includes(")"),Pl=(e,t)=>Fl(e,t??{});function Bl(e){return/^var\(--.+\)$/.test(e)}var Dl=e=>{const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}},Te=e=>t=>`${e}(${t})`,D={filter(e){return e!=="auto"?e:_l},backdropFilter(e){return e!=="auto"?e:Rl},ring(e){return Al(D.px(e))},bgClip(e){return e==="text"?{color:"transparent",backgroundClip:"text"}:{backgroundClip:e}},transform(e){return e==="auto"?Tl():e==="auto-gpu"?Nl():e},vh(e){return e==="$100vh"?"var(--chakra-vh)":e},px(e){if(e==null)return e;const{unitless:t}=Dl(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(Bl(e)||e==null)return e;const t=typeof e=="string"&&!e.endsWith("deg");return typeof e=="number"||t?`${e}deg`:e},gradient:Pl,blur:Te("blur"),opacity:Te("opacity"),brightness:Te("brightness"),contrast:Te("contrast"),dropShadow:Te("drop-shadow"),grayscale:Te("grayscale"),hueRotate:e=>Te("hue-rotate")(D.degree(e)),invert:Te("invert"),saturate:Te("saturate"),sepia:Te("sepia"),bgImage(e){return e==null||Yn(e)||Vn.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=jl[e])!=null?t:{},i={flexDirection:e};return r&&(i[r]=1),n&&(i[n]=1),i}},h={borderWidths:he("borderWidths"),borderStyles:he("borderStyles"),colors:he("colors"),borders:he("borders"),gradients:he("gradients",D.gradient),radii:he("radii",D.px),space:he("space",Sr(D.vh,D.px)),spaceT:he("space",Sr(D.vh,D.px)),degreeT(e){return{property:e,transform:D.degree}},prop(e,t,r){return{property:e,scale:t,...t&&{transform:li({scale:t,transform:r})}}},propT(e,t){return{property:e,transform:t}},sizes:he("sizes",Sr(D.vh,D.px)),sizesT:he("sizes",Sr(D.vh,D.fraction)),shadows:he("shadows"),logical:Ol,blur:he("blur",D.blur)},Or={background:h.colors("background"),backgroundColor:h.colors("backgroundColor"),backgroundImage:h.gradients("backgroundImage"),backgroundSize:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundAttachment:!0,backgroundClip:{transform:D.bgClip},bgSize:h.prop("backgroundSize"),bgPosition:h.prop("backgroundPosition"),bg:h.colors("background"),bgColor:h.colors("backgroundColor"),bgPos:h.prop("backgroundPosition"),bgRepeat:h.prop("backgroundRepeat"),bgAttachment:h.prop("backgroundAttachment"),bgGradient:h.gradients("backgroundImage"),bgClip:{transform:D.bgClip}};Object.assign(Or,{bgImage:Or.backgroundImage,bgImg:Or.backgroundImage});var M={border:h.borders("border"),borderWidth:h.borderWidths("borderWidth"),borderStyle:h.borderStyles("borderStyle"),borderColor:h.colors("borderColor"),borderRadius:h.radii("borderRadius"),borderTop:h.borders("borderTop"),borderBlockStart:h.borders("borderBlockStart"),borderTopLeftRadius:h.radii("borderTopLeftRadius"),borderStartStartRadius:h.logical({scale:"radii",property:{ltr:"borderTopLeftRadius",rtl:"borderTopRightRadius"}}),borderEndStartRadius:h.logical({scale:"radii",property:{ltr:"borderBottomLeftRadius",rtl:"borderBottomRightRadius"}}),borderTopRightRadius:h.radii("borderTopRightRadius"),borderStartEndRadius:h.logical({scale:"radii",property:{ltr:"borderTopRightRadius",rtl:"borderTopLeftRadius"}}),borderEndEndRadius:h.logical({scale:"radii",property:{ltr:"borderBottomRightRadius",rtl:"borderBottomLeftRadius"}}),borderRight:h.borders("borderRight"),borderInlineEnd:h.borders("borderInlineEnd"),borderBottom:h.borders("borderBottom"),borderBlockEnd:h.borders("borderBlockEnd"),borderBottomLeftRadius:h.radii("borderBottomLeftRadius"),borderBottomRightRadius:h.radii("borderBottomRightRadius"),borderLeft:h.borders("borderLeft"),borderInlineStart:{property:"borderInlineStart",scale:"borders"},borderInlineStartRadius:h.logical({scale:"radii",property:{ltr:["borderTopLeftRadius","borderBottomLeftRadius"],rtl:["borderTopRightRadius","borderBottomRightRadius"]}}),borderInlineEndRadius:h.logical({scale:"radii",property:{ltr:["borderTopRightRadius","borderBottomRightRadius"],rtl:["borderTopLeftRadius","borderBottomLeftRadius"]}}),borderX:h.borders(["borderLeft","borderRight"]),borderInline:h.borders("borderInline"),borderY:h.borders(["borderTop","borderBottom"]),borderBlock:h.borders("borderBlock"),borderTopWidth:h.borderWidths("borderTopWidth"),borderBlockStartWidth:h.borderWidths("borderBlockStartWidth"),borderTopColor:h.colors("borderTopColor"),borderBlockStartColor:h.colors("borderBlockStartColor"),borderTopStyle:h.borderStyles("borderTopStyle"),borderBlockStartStyle:h.borderStyles("borderBlockStartStyle"),borderBottomWidth:h.borderWidths("borderBottomWidth"),borderBlockEndWidth:h.borderWidths("borderBlockEndWidth"),borderBottomColor:h.colors("borderBottomColor"),borderBlockEndColor:h.colors("borderBlockEndColor"),borderBottomStyle:h.borderStyles("borderBottomStyle"),borderBlockEndStyle:h.borderStyles("borderBlockEndStyle"),borderLeftWidth:h.borderWidths("borderLeftWidth"),borderInlineStartWidth:h.borderWidths("borderInlineStartWidth"),borderLeftColor:h.colors("borderLeftColor"),borderInlineStartColor:h.colors("borderInlineStartColor"),borderLeftStyle:h.borderStyles("borderLeftStyle"),borderInlineStartStyle:h.borderStyles("borderInlineStartStyle"),borderRightWidth:h.borderWidths("borderRightWidth"),borderInlineEndWidth:h.borderWidths("borderInlineEndWidth"),borderRightColor:h.colors("borderRightColor"),borderInlineEndColor:h.colors("borderInlineEndColor"),borderRightStyle:h.borderStyles("borderRightStyle"),borderInlineEndStyle:h.borderStyles("borderInlineEndStyle"),borderTopRadius:h.radii(["borderTopLeftRadius","borderTopRightRadius"]),borderBottomRadius:h.radii(["borderBottomLeftRadius","borderBottomRightRadius"]),borderLeftRadius:h.radii(["borderTopLeftRadius","borderBottomLeftRadius"]),borderRightRadius:h.radii(["borderTopRightRadius","borderBottomRightRadius"])};Object.assign(M,{rounded:M.borderRadius,roundedTop:M.borderTopRadius,roundedTopLeft:M.borderTopLeftRadius,roundedTopRight:M.borderTopRightRadius,roundedTopStart:M.borderStartStartRadius,roundedTopEnd:M.borderStartEndRadius,roundedBottom:M.borderBottomRadius,roundedBottomLeft:M.borderBottomLeftRadius,roundedBottomRight:M.borderBottomRightRadius,roundedBottomStart:M.borderEndStartRadius,roundedBottomEnd:M.borderEndEndRadius,roundedLeft:M.borderLeftRadius,roundedRight:M.borderRightRadius,roundedStart:M.borderInlineStartRadius,roundedEnd:M.borderInlineEndRadius,borderStart:M.borderInlineStart,borderEnd:M.borderInlineEnd,borderTopStartRadius:M.borderStartStartRadius,borderTopEndRadius:M.borderStartEndRadius,borderBottomStartRadius:M.borderEndStartRadius,borderBottomEndRadius:M.borderEndEndRadius,borderStartRadius:M.borderInlineStartRadius,borderEndRadius:M.borderInlineEndRadius,borderStartWidth:M.borderInlineStartWidth,borderEndWidth:M.borderInlineEndWidth,borderStartColor:M.borderInlineStartColor,borderEndColor:M.borderInlineEndColor,borderStartStyle:M.borderInlineStartStyle,borderEndStyle:M.borderInlineEndStyle});var Ll={color:h.colors("color"),textColor:h.colors("color"),fill:h.colors("fill"),stroke:h.colors("stroke")},Zn={boxShadow:h.shadows("boxShadow"),mixBlendMode:!0,blendMode:h.prop("mixBlendMode"),backgroundBlendMode:!0,bgBlendMode:h.prop("backgroundBlendMode"),opacity:!0};Object.assign(Zn,{shadow:Zn.boxShadow});var Ml={filter:{transform:D.filter},blur:h.blur("--chakra-blur"),brightness:h.propT("--chakra-brightness",D.brightness),contrast:h.propT("--chakra-contrast",D.contrast),hueRotate:h.propT("--chakra-hue-rotate",D.hueRotate),invert:h.propT("--chakra-invert",D.invert),saturate:h.propT("--chakra-saturate",D.saturate),dropShadow:h.propT("--chakra-drop-shadow",D.dropShadow),backdropFilter:{transform:D.backdropFilter},backdropBlur:h.blur("--chakra-backdrop-blur"),backdropBrightness:h.propT("--chakra-backdrop-brightness",D.brightness),backdropContrast:h.propT("--chakra-backdrop-contrast",D.contrast),backdropHueRotate:h.propT("--chakra-backdrop-hue-rotate",D.hueRotate),backdropInvert:h.propT("--chakra-backdrop-invert",D.invert),backdropSaturate:h.propT("--chakra-backdrop-saturate",D.saturate)},kr={alignItems:!0,alignContent:!0,justifyItems:!0,justifyContent:!0,flexWrap:!0,flexDirection:{transform:D.flexDirection},flex:!0,flexFlow:!0,flexGrow:!0,flexShrink:!0,flexBasis:h.sizes("flexBasis"),justifySelf:!0,alignSelf:!0,order:!0,placeItems:!0,placeContent:!0,placeSelf:!0,gap:h.space("gap"),rowGap:h.space("rowGap"),columnGap:h.space("columnGap")};Object.assign(kr,{flexDir:kr.flexDirection});var Do={gridGap:h.space("gridGap"),gridColumnGap:h.space("gridColumnGap"),gridRowGap:h.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},$l={appearance:!0,cursor:!0,resize:!0,userSelect:!0,pointerEvents:!0,outline:{transform:D.outline},outlineOffset:!0,outlineColor:h.colors("outlineColor")},ge={width:h.sizesT("width"),inlineSize:h.sizesT("inlineSize"),height:h.sizes("height"),blockSize:h.sizes("blockSize"),boxSize:h.sizes(["width","height"]),minWidth:h.sizes("minWidth"),minInlineSize:h.sizes("minInlineSize"),minHeight:h.sizes("minHeight"),minBlockSize:h.sizes("minBlockSize"),maxWidth:h.sizes("maxWidth"),maxInlineSize:h.sizes("maxInlineSize"),maxHeight:h.sizes("maxHeight"),maxBlockSize:h.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:h.propT("float",D.float),objectFit:!0,objectPosition:!0,visibility:!0,isolation:!0};Object.assign(ge,{w:ge.width,h:ge.height,minW:ge.minWidth,maxW:ge.maxWidth,minH:ge.minHeight,maxH:ge.maxHeight,overscroll:ge.overscrollBehavior,overscrollX:ge.overscrollBehaviorX,overscrollY:ge.overscrollBehaviorY});var Kl={listStyleType:!0,listStylePosition:!0,listStylePos:h.prop("listStylePosition"),listStyleImage:!0,listStyleImg:h.prop("listStyleImage")};function Ul(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 Wl=e=>{const t=new WeakMap;return(n,i,a,d)=>{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,d);return u.set(i,p),p}},zl=Wl(Ul),ql={border:"0px",clip:"rect(0, 0, 0, 0)",width:"1px",height:"1px",margin:"-1px",padding:"0px",overflow:"hidden",whiteSpace:"nowrap",position:"absolute"},Hl={position:"static",width:"auto",height:"auto",clip:"auto",padding:"0",margin:"0",overflow:"visible",whiteSpace:"normal"},Kn=(e,t,r)=>{const n={},i=zl(e,t,{});for(const a in i)a in r&&r[a]!=null||(n[a]=i[a]);return n},Jl={srOnly:{transform(e){return e===!0?ql:e==="focusable"?Hl:{}}},layerStyle:{processResult:!0,transform:(e,t,r)=>Kn(t,`layerStyles.${e}`,r)},textStyle:{processResult:!0,transform:(e,t,r)=>Kn(t,`textStyles.${e}`,r)},apply:{processResult:!0,transform:(e,t,r)=>Kn(t,e,r)}},Vt={position:!0,pos:h.prop("position"),zIndex:h.prop("zIndex","zIndices"),inset:h.spaceT("inset"),insetX:h.spaceT(["left","right"]),insetInline:h.spaceT("insetInline"),insetY:h.spaceT(["top","bottom"]),insetBlock:h.spaceT("insetBlock"),top:h.spaceT("top"),insetBlockStart:h.spaceT("insetBlockStart"),bottom:h.spaceT("bottom"),insetBlockEnd:h.spaceT("insetBlockEnd"),left:h.spaceT("left"),insetInlineStart:h.logical({scale:"space",property:{ltr:"left",rtl:"right"}}),right:h.spaceT("right"),insetInlineEnd:h.logical({scale:"space",property:{ltr:"right",rtl:"left"}})};Object.assign(Vt,{insetStart:Vt.insetInlineStart,insetEnd:Vt.insetInlineEnd});var Xl={ring:{transform:D.ring},ringColor:h.colors("--chakra-ring-color"),ringOffset:h.prop("--chakra-ring-offset-width"),ringOffsetColor:h.colors("--chakra-ring-offset-color"),ringInset:h.prop("--chakra-ring-inset")},z={margin:h.spaceT("margin"),marginTop:h.spaceT("marginTop"),marginBlockStart:h.spaceT("marginBlockStart"),marginRight:h.spaceT("marginRight"),marginInlineEnd:h.spaceT("marginInlineEnd"),marginBottom:h.spaceT("marginBottom"),marginBlockEnd:h.spaceT("marginBlockEnd"),marginLeft:h.spaceT("marginLeft"),marginInlineStart:h.spaceT("marginInlineStart"),marginX:h.spaceT(["marginInlineStart","marginInlineEnd"]),marginInline:h.spaceT("marginInline"),marginY:h.spaceT(["marginTop","marginBottom"]),marginBlock:h.spaceT("marginBlock"),padding:h.space("padding"),paddingTop:h.space("paddingTop"),paddingBlockStart:h.space("paddingBlockStart"),paddingRight:h.space("paddingRight"),paddingBottom:h.space("paddingBottom"),paddingBlockEnd:h.space("paddingBlockEnd"),paddingLeft:h.space("paddingLeft"),paddingInlineStart:h.space("paddingInlineStart"),paddingInlineEnd:h.space("paddingInlineEnd"),paddingX:h.space(["paddingInlineStart","paddingInlineEnd"]),paddingInline:h.space("paddingInline"),paddingY:h.space(["paddingTop","paddingBottom"]),paddingBlock:h.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 Gl={textDecorationColor:h.colors("textDecorationColor"),textDecoration:!0,textDecor:{property:"textDecoration"},textDecorationLine:!0,textDecorationStyle:!0,textDecorationThickness:!0,textUnderlineOffset:!0,textShadow:h.shadows("textShadow")},Vl={clipPath:!0,transform:h.propT("transform",D.transform),transformOrigin:!0,translateX:h.spaceT("--chakra-translate-x"),translateY:h.spaceT("--chakra-translate-y"),skewX:h.degreeT("--chakra-skew-x"),skewY:h.degreeT("--chakra-skew-y"),scaleX:h.prop("--chakra-scale-x"),scaleY:h.prop("--chakra-scale-y"),scale:h.prop(["--chakra-scale-x","--chakra-scale-y"]),rotate:h.degreeT("--chakra-rotate")},Yl={transition:!0,transitionDelay:!0,animation:!0,willChange:!0,transitionDuration:h.prop("transitionDuration","transition.duration"),transitionProperty:h.prop("transitionProperty","transition.property"),transitionTimingFunction:h.prop("transitionTimingFunction","transition.easing")},Zl={fontFamily:h.prop("fontFamily","fonts"),fontSize:h.prop("fontSize","fontSizes",D.px),fontWeight:h.prop("fontWeight","fontWeights"),lineHeight:h.prop("lineHeight","lineHeights"),letterSpacing:h.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"}},Ql={scrollBehavior:!0,scrollSnapAlign:!0,scrollSnapStop:!0,scrollSnapType:!0,scrollMargin:h.spaceT("scrollMargin"),scrollMarginTop:h.spaceT("scrollMarginTop"),scrollMarginBottom:h.spaceT("scrollMarginBottom"),scrollMarginLeft:h.spaceT("scrollMarginLeft"),scrollMarginRight:h.spaceT("scrollMarginRight"),scrollMarginX:h.spaceT(["scrollMarginLeft","scrollMarginRight"]),scrollMarginY:h.spaceT(["scrollMarginTop","scrollMarginBottom"]),scrollPadding:h.spaceT("scrollPadding"),scrollPaddingTop:h.spaceT("scrollPaddingTop"),scrollPaddingBottom:h.spaceT("scrollPaddingBottom"),scrollPaddingLeft:h.spaceT("scrollPaddingLeft"),scrollPaddingRight:h.spaceT("scrollPaddingRight"),scrollPaddingX:h.spaceT(["scrollPaddingLeft","scrollPaddingRight"]),scrollPaddingY:h.spaceT(["scrollPaddingTop","scrollPaddingBottom"])};function Lo(e){return ct(e)&&e.reference?e.reference:String(e)}var $r=(e,...t)=>t.map(Lo).join(` ${e} `).replace(/calc/g,""),_i=(...e)=>`calc(${$r("+",...e)})`,Ri=(...e)=>`calc(${$r("-",...e)})`,Qn=(...e)=>`calc(${$r("*",...e)})`,Ai=(...e)=>`calc(${$r("/",...e)})`,ji=e=>{const t=Lo(e);return t!=null&&!Number.isNaN(parseFloat(t))?String(t).startsWith("-")?String(t).slice(1):`-${t}`:Qn(t,-1)},Gt=Object.assign(e=>({add:(...t)=>Gt(_i(e,...t)),subtract:(...t)=>Gt(Ri(e,...t)),multiply:(...t)=>Gt(Qn(e,...t)),divide:(...t)=>Gt(Ai(e,...t)),negate:()=>Gt(ji(e)),toString:()=>e.toString()}),{add:_i,subtract:Ri,multiply:Qn,divide:Ai,negate:ji});function eu(e){const t=parseFloat(e.toString()),r=e.toString().replace(String(t),"");return{unitless:!r,value:t,unit:r}}function ki(e){if(e==null)return e;const{unitless:t}=eu(e);return t||typeof e=="number"?`${e}px`:e}function tu(e,t){const r=["@media screen"];return e&&r.push("and",`(min-width: ${ki(e)})`),t&&r.push("and",`(max-width: ${ki(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}`},ze=e=>Mo(t=>e(t,"&"),"[role=group]","[data-group]",".group"),Be=e=>Mo(t=>e(t,"~ &"),"[data-peer]",".peer"),Mo=(e,...t)=>t.map(e).join(", "),ui={_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:ze(re.hover),_peerHover:Be(re.hover),_groupFocus:ze(re.focus),_peerFocus:Be(re.focus),_groupFocusVisible:ze(re.focusVisible),_peerFocusVisible:Be(re.focusVisible),_groupActive:ze(re.active),_peerActive:Be(re.active),_groupDisabled:ze(re.disabled),_peerDisabled:Be(re.disabled),_groupInvalid:ze(re.invalid),_peerInvalid:Be(re.invalid),_groupChecked:ze(re.checked),_peerChecked:Be(re.checked),_groupFocusWithin:ze(re.focusWithin),_peerFocusWithin:Be(re.focusWithin),_peerPlaceholderShown:Be(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]"},ru=Object.keys(ui),pi=De({},Or,M,Ll,kr,ge,Ml,Xl,$l,Do,Jl,Vt,Zn,z,Ql,Zl,Gl,Vl,Kl,Yl);Object.assign({},z,ge,kr,Do,Vt);var nu=[...Object.keys(pi),...ru],iu={...pi,...ui},ou=e=>e in iu,au=e=>t=>{if(!t.__breakpoints)return e;const{isResponsive:r,toArrayValue:n,media:i}=t.__breakpoints,a={};for(const d in e){let u=st(e[d],t);if(u==null)continue;if(u=ct(u)&&r(u)?n(u):u,!Array.isArray(u)){a[d]=u;continue}const p=u.slice(0,i.length).length;for(let g=0;g<p;g+=1){const m=i==null?void 0:i[g];if(!m){a[d]=u[g];continue}a[m]=a[m]||{},u[g]!=null&&(a[m][d]=u[g])}}return a};function su(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 cu(e){return/^var\(--.+\)$/.test(e)}var du=(e,t)=>e.startsWith("--")&&typeof t=="string"&&!cu(t),lu=(e,t)=>{var r,n;if(t==null)return t;const i=p=>{var g,m;return(m=(g=e.__cssMap)==null?void 0:g[p])==null?void 0:m.varRef},a=p=>{var g;return(g=i(p))!=null?g:p},[d,u]=su(t);return t=(n=(r=i(d))!=null?r:a(u))!=null?n:a(t),t};function uu(e){const{configs:t={},pseudos:r={},theme:n}=e,i=(a,d=!1)=>{var u,p,g;const m=st(a,n),v=au(m)(n);let y={};for(let b in v){const I=v[b];let x=st(I,n);b in r&&(b=r[b]),du(b,x)&&(x=lu(n,x));let C=t[b];if(C===!0&&(C={property:b}),ct(x)){y[b]=(u=y[b])!=null?u:{},y[b]=De({},y[b],i(x,!0));continue}let T=(g=(p=C==null?void 0:C.transform)==null?void 0:p.call(C,x,n,m))!=null?g:x;T=C!=null&&C.processResult?i(T,!0):T;const R=st(C==null?void 0:C.property,n);if(!d&&(C!=null&&C.static)){const F=st(C.static,n);y=De({},y,F)}if(R&&Array.isArray(R)){for(const F of R)y[F]=T;continue}if(R){R==="&"&&ct(T)?y=De({},y,T):y[R]=T;continue}if(ct(T)){y=De({},y,T);continue}y[b]=T}return y};return i}var pu=e=>t=>uu({theme:t,pseudos:ui,configs:pi})(e);function fu(e,t){if(Array.isArray(e))return e;if(ct(e))return t(e);if(e!=null)return[e]}function hu(e,t){for(let r=t+1;r<e.length;r++)if(e[r]!=null)return r;return-1}function gu(e){const t=e.__breakpoints;return function(n,i,a,d){var u,p;if(!t)return;const g={},m=fu(a,t.toArrayValue);if(!m)return g;const v=m.length,y=v===1,b=!!n.parts;for(let I=0;I<v;I++){const x=t.details[I],C=t.details[hu(m,I)],T=tu(x.minW,C==null?void 0:C._minW),R=st((u=n[i])==null?void 0:u[m[I]],d);if(R){if(b){(p=n.parts)==null||p.forEach(F=>{De(g,{[F]:y?R[F]:{[T]:R[F]}})});continue}if(!b){y?De(g,R):g[T]=R;continue}g[T]=R}}return g}}function mu(e){return t=>{var r;const{variant:n,size:i,theme:a}=t,d=gu(a);return De({},st((r=e.baseStyle)!=null?r:{},t),d(e,"sizes",i,t),d(e,"variants",n,t))}}function yu(e,t){const r={};return Object.keys(e).forEach(n=>{t.includes(n)||(r[n]=e[n])}),r}function wu(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 vu=e=>{const t=new WeakMap;return(n,i,a,d)=>{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,d);return u.set(i,p),p}},bu=vu(wu);function $o(e,t){const r={};return Object.keys(e).forEach(n=>{const i=e[n];t(i,n,e)&&(r[n]=i)}),r}var Ko=e=>$o(e,t=>t!=null);function Iu(e){return typeof e=="function"}process.env.NODE_ENV;process.env.NODE_ENV;function Su(e,...t){return Iu(e)?e(...t):e}var xu=typeof Element<"u",Cu=typeof Map=="function",Ou=typeof Set=="function",Tu=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Tr(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(!Tr(e[n],t[n]))return!1;return!0}var a;if(Cu&&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(!Tr(n.value[1],t.get(n.value[0])))return!1;return!0}if(Ou&&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(Tu&&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(xu&&e instanceof Element)return!1;for(n=r;n--!==0;)if(!((i[n]==="_owner"||i[n]==="__v"||i[n]==="__o")&&e.$$typeof)&&!Tr(e[i[n]],t[i[n]]))return!1;return!0}return e!==e&&t!==t}var Nu=function(t,r){try{return Tr(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 _u=ri(Nu);function Ru(e,t={}){var r;const{styleConfig:n,...i}=t,{theme:a,colorMode:d}=wl(),u=bu(a,`components.${e}`),p=n||u,g=De({theme:a,colorMode:d},(r=p==null?void 0:p.defaultProps)!=null?r:{},Ko(yu(i,["children"]))),m=w.useRef({});if(p){const y=mu(p)(g);_u(m.current,y)||(m.current=y)}return m.current}function Au(e,t={}){return Ru(e,t)}var ju=new Set([...nu,"textStyle","layerStyle","apply","noOfLines","focusBorderColor","errorBorderColor","as","__css","css","sx"]),ku=new Set(["htmlWidth","htmlHeight","htmlSize","htmlTranslate"]);function Eu(e){return ku.has(e)||!ju.has(e)}function Fu(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 Ei,Pu=(Ei=hi.default)!=null?Ei:hi,Bu=({baseStyle:e})=>t=>{const{theme:r,css:n,__css:i,sx:a,...d}=t,u=$o(d,(v,y)=>ou(y)),p=Su(e,t),g=Fu({},i,p,Ko(u),a),m=pu(g)(t.theme);return n?[m,n]:m};function Un(e,t){const{baseStyle:r,...n}=t??{};n.shouldForwardProp||(n.shouldForwardProp=Eu);const i=Bu({baseStyle:r}),a=Pu(e,n)(i);return w.forwardRef(function(p,g){const{colorMode:m,forced:v}=Po();return w.createElement(a,{ref:g,"data-theme":v?m:void 0,...p})})}function Du(){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 Fi=Du();function Uo(e){return w.forwardRef(e)}var Pi={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"},Wo=Uo((e,t)=>{const{as:r,viewBox:n,color:i="currentColor",focusable:a=!1,children:d,className:u,__css:p,...g}=e,m=vl("chakra-icon",u),v=Au("Icon",e),y={w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:i,...p,...v},b={ref:t,focusable:a,className:m,__css:y},I=n??Pi.viewBox;if(r&&typeof r!="string")return s.jsx(Fi.svg,{as:r,...b,...g});const x=d??Pi.path;return s.jsx(Fi.svg,{verticalAlign:"middle",viewBox:I,...b,...g,children:x})});Wo.displayName="Icon";function Lu(e){const{viewBox:t="0 0 24 24",d:r,displayName:n,defaultProps:i={}}=e,a=w.Children.toArray(e.path),d=Uo((u,p)=>s.jsx(Wo,{ref:p,viewBox:t,...i,...u,children:a.length?a:s.jsx("path",{fill:"currentColor",d:r})}));return d.displayName=n,d}var Mu=Lu({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 $u="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function Ku({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n}){return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{children:s.jsx(S.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),s.jsxs(S.Link,{href:$u,color:"blackAlpha.600",isExternal:!0,children:["What is my Salesforce subdomain?",s.jsx(Mu,{mx:"2px"})]}),s.jsx(Xe,{error:r}),s.jsxs(S.Flex,{marginTop:"1em",children:[s.jsx(S.Input,{placeholder:"MyDomain",onChange:i=>t(i.currentTarget.value)}),s.jsx(S.Text,{lineHeight:"2.2em",marginLeft:"0.4em",children:".my.salesforce.com"})]}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Uu({handleSubmit:e,setWorkspace:t,error:r,isButtonDisabled:n,providerName:i}){return s.jsx(Ge,{children:s.jsxs(S.FormControl,{children:[s.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:s.jsxs(S.Heading,{as:"h4",size:"md",children:["Enter your ",i," workspace"]})}),s.jsx(Xe,{error:r}),s.jsx(S.Flex,{marginTop:"1em",children:s.jsx(S.Input,{placeholder:"MyWorkspace",onChange:a=>t(a.currentTarget.value)})}),s.jsx("br",{}),s.jsx(S.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}const Wu="salesforce";function zu({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,providerName:a}){const{projectId:d}=Q(),u=ee(),[p,g]=w.useState(""),[m,v]=w.useState(null),[y,b]=w.useState(null),I=async()=>{if(b(null),!p){b("Workspace is required");return}try{const T=await ko(d,t,n,u,e,p,r,i);v(T)}catch(T){console.error(T),b((T==null?void 0:T.message)??"Unexpected error")}},x=w.useCallback(T=>{b(T),v(null)},[]),C=e===Wu?s.jsx(Ku,{handleSubmit:I,setWorkspace:g,error:y,isButtonDisabled:p.length===0}):s.jsx(Uu,{handleSubmit:I,setWorkspace:g,error:y,isButtonDisabled:p.length===0,providerName:a});return s.jsx(Eo,{windowTitle:`Connect to ${a}`,oauthUrl:m,onError:x,children:C})}const qu="authorizationCode",Hu="clientCredentials";function Ju({provider:e,providerInfo:t,consumerRef:r,consumerName:n,groupRef:i,groupName:a,selectedConnection:d,setSelectedConnection:u}){if(t.oauth2Opts===void 0)return s.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:p,explicitScopesRequired:g,explicitWorkspaceRequired:m}=t.oauth2Opts,v=pt(e,t);return p===qu?m?s.jsx(zu,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):s.jsx(hl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,providerName:v}):p===Hu?m?s.jsx(ml,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:g,setSelectedConnection:u,selectedConnection:d,providerName:v}):s.jsx(sl,{provider:e,consumerRef:r,consumerName:n,groupRef:i,groupName:a,explicitScopesRequired:g,setSelectedConnection:u,selectedConnection:d,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]})}function Xu(e){const{selectedConnection:t}=_t();w.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function Gu({onSuccess:e}){Xu(e)}const Vu=async(e,t)=>{const r=await X().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!r)throw new Error(`Provider ${t} not found`);return r};function zo({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:a,onSuccess:d}){const u=ee(),[p,g]=w.useState(null),{provider:m}=Re(),{selectedConnection:v,setSelectedConnection:y,connections:b}=_t();Gu({onSuccess:d});const I=e||m,x=(p==null?void 0:p.displayName)??Qi(I);if(w.useEffect(()=>{if(!v&&b&&b.length>0){const[C]=b;y(C)}Vu(u,I).then(C=>{g(C)}).catch(C=>{console.error("Error loading provider info."),ae(C)})},[b,v,y,u,I]),!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(ol,{provider:I,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:v,groupRef:n,groupName:i,providerName:x,children:a}):p.authType==="basic"?s.jsx(nl,{provider:I,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:v,groupRef:n,groupName:i,children:a}):p.authType==="apiKey"?s.jsx(tl,{provider:I,providerInfo:p,consumerRef:t,consumerName:r,setSelectedConnection:y,selectedConnection:v,groupRef:n,groupName:i,children:a}):s.jsx(Ju,{provider:I,providerInfo:p,consumerRef:t,consumerName:r,groupRef:n,groupName:i,setSelectedConnection:y,selectedConnection:v})}function Yu({integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:d,onUninstallSuccess:u}){var m;const{projectId:p}=Q(),{errorState:g}=Je();return(m=g[J.INTEGRATION_LIST])!=null&&m.apiError?s.jsx(Le,{message:"Something went wrong, couldn't find integration information"}):s.jsx(jc,{integration:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onInstallSuccess:a,onUpdateSuccess:d,onUninstallSuccess:u,children:s.jsx(no,{groupRef:n,children:s.jsx(zo,{consumerRef:t,consumerName:r,groupRef:n,groupName:i,children:s.jsx(rd,{projectId:p,children:s.jsx(Qd,{children:s.jsx(gd,{children:s.jsx(Id,{children:s.jsx(Jd,{})})})})})})})})}function Zu({redirectURL:e,children:t}){return w.useEffect(()=>{e&&window.location.replace(e)},[e]),e?s.jsxs(S.Box,{display:"flex",alignItems:"center",justifyContent:"center",children:[s.jsx(_e,{}),s.jsx("p",{children:"Redirecting"})]}):t}function Qu({provider:e}){const{appName:t}=Q(),r=`You have successfully connected your ${pt(e)} account to ${t}.`;return s.jsx(di,{text:r})}function ep({provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,redirectUrl:a,onSuccess:d}){return s.jsx(no,{provider:e,groupRef:n,children:s.jsx(zo,{provider:e,consumerRef:t,consumerName:r,groupRef:n,groupName:i,onSuccess:d,children:s.jsx(Zu,{redirectURL:a,children:s.jsx(Qu,{provider:e})})})})}const tp=(e,t)=>{const r=ee(),{projectId:n}=Q(),{integrations:i}=Vi(),[a,d]=w.useState(!1),[u,p]=w.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 g=w.useMemo(()=>i==null?void 0:i.reduce((m,v)=>(v==null?void 0:v.name)===e?v:m,{}),[i,e]);return w.useEffect(()=>{g&&X().installationApi.listInstallations({projectIdOrName:n,integrationId:g.id,groupRef:t},{headers:{"x-api-key":r}}).then(m=>{d(!0),p(m.length>0)}).catch(m=>{console.error("Error listing installations."),ae(m),d(!0)})},[t,r,n,g]),{isLoaded:a,isIntegrationInstalled:u}};exports.AmpersandContext=Zi;exports.AmpersandProvider=Nc;exports.ConnectProvider=ep;exports.InstallIntegration=Yu;exports.useAmpersandProvider=_c;exports.useIsIntegrationInstalled=tp;
|