@amp-labs/react 1.13.0 → 1.14.1
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 +43 -4
- package/build/amp-react.es.js +7511 -5901
- package/build/style.css +1 -1
- package/package.json +7 -2
package/build/amp-react.cjs.js
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
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
|
-
|
|
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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),y=require("react"),S=require("@chakra-ui/react");require("react-dom");function Xa(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const X=Xa(y),Ya={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"}}},Ga=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:Ya}}}),Za=S.extendTheme(Ga);function Qa({children:e}){return a.jsx(S.ChakraProvider,{theme:Za,children:e})}const Xo=y.createContext(null),ec=Xo.Provider,xe=()=>{const e=y.useContext(Xo);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var me=(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))(me||{});const Yo=y.createContext(void 0);function dt(){const e=y.useContext(Yo);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const tc=(()=>{const e={};return Object.values(me).forEach(t=>{e[t]={}}),e})();function nc({children:e}){const[t,n]=y.useState(tc),o=y.useCallback((p,h,v=!0)=>{n(f=>{const g={...f};return g[p]=g[p]||{},g[p][h]=v,g})},[n]),i=y.useCallback((p,h)=>{var v;return!!((v=t[p])!=null&&v[h])},[t]),r=y.useCallback((p,h)=>{var v;return(v=t[p])==null?void 0:v[h]},[t]),s=y.useCallback((p,h)=>{n(v=>{var g;const f={...v};return(g=f[p])==null||delete g[h],f})},[n]),c=y.useCallback(p=>{n(h=>{const v={...h};return v[p]={},v})},[n]),u=y.useCallback((p,h)=>{n(v=>{const f={...v};return f[p]=f[p]||{},h.forEach(g=>{f[p][g]=!0}),f})},[n]),d=y.useMemo(()=>({errorState:t,setErrorState:n,setError:o,isError:i,removeError:s,resetBoundary:c,setErrors:u,getError:r}),[t,n,o,i,s,c,u,r]);return a.jsx(Yo.Provider,{value:d,children:e})}function ho(){return a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function rc(e,t){try{return process.env[e]}catch{return t}}function Go(e){return e.charAt(0).toUpperCase()+e.slice(1)}function it(e,t){return(t==null?void 0:t.displayName)??Go(e)}const Ir=e=>e.split(`
|
|
2
|
+
`).filter(n=>n.trim()!==""),oc=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,ve=rc("REACT_APP_ENABLE_CSS",!1),ic="_box_3e1nt_1",mo={box:ic};function Dt({children:e,className:t,style:n}){return ve?a.jsx("div",{className:t?`${mo.box} ${t}`:mo.box,style:n,children:e}):a.jsx(S.Box,{className:t,style:n,borderWidth:1,borderRadius:4,children:e})}const sc="_container_1wvzr_1",go={container:sc};function Gt({children:e,className:t,style:n}){return ve?a.jsx("div",{className:t?`${go.container} ${t}`:go.container,style:n,children:e}):a.jsx(S.Container,{className:t,style:n,children:e})}const ac="_errorBoxContainer_1qhwq_1",cc="_errorBox_1qhwq_1",uc="_errorText_1qhwq_20",qn={errorBoxContainer:ac,errorBox:cc,errorText:uc};function ot({message:e}){return ve?a.jsxs(Gt,{className:qn.errorBoxContainer,children:[a.jsx(ho,{}),a.jsx(Dt,{className:qn.errorBox,children:a.jsx("p",{className:qn.errorText,children:e})})]}):a.jsxs(S.Box,{minHeight:"300px",padding:"30px",display:"flex",flexDirection:"column",justifyContent:"space-evenly",alignItems:"center",children:[a.jsx(ho,{}),a.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:a.jsx(S.Text,{color:"#991B1B",fontSize:"md",children:e})})]})}const lc="https://api.withampersand.com/v1".replace(/\/+$/,"");class Zo{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:lc}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ei}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 dc=new Zo,An=class An{constructor(t=dc){this.configuration=t,this.fetchApi=async(n,o)=>{let i={url:n,init:o};for(const s of this.middleware)s.pre&&(i=await s.pre({fetch:this.fetchApi,...i})||i);let r;try{r=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(s){for(const c of this.middleware)c.onError&&(r=await c.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:s,response:r?r.clone():void 0})||r);if(r===void 0)throw s instanceof Error?new hc(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(r=await s.post({fetch:this.fetchApi,url:i.url,init:i.init,response:r.clone()})||r);return r},this.middleware=t.middleware}withMiddleware(...t){const n=this.clone();return n.middleware=n.middleware.concat(...t),n}withPreMiddleware(...t){const n=t.map(o=>({pre:o}));return this.withMiddleware(...n)}withPostMiddleware(...t){const n=t.map(o=>({post:o}));return this.withMiddleware(...n)}isJsonMime(t){return t?An.jsonRegex.test(t):!1}async request(t,n){const{url:o,init:i}=await this.createFetchParams(t,n),r=await this.fetchApi(o,i);if(r&&r.status>=200&&r.status<300)return r;throw new Qo(r,"Response returned an error code")}async createFetchParams(t,n){let o=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(o+="?"+this.configuration.queryParamsStringify(t.query));const i=Object.assign({},this.configuration.headers,t.headers);Object.keys(i).forEach(d=>i[d]===void 0?delete i[d]:{});const r=typeof n=="function"?n:async()=>n,s={method:t.method,headers:i,body:t.body,credentials:this.configuration.credentials},c={...s,...await r({init:s,context:t})},u={...c,body:fc(c.body)||c.body instanceof URLSearchParams||pc(c.body)?c.body:JSON.stringify(c.body)};return{url:o,init:u}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};An.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let ze=An;function pc(e){return typeof Blob<"u"&&e instanceof Blob}function fc(e){return typeof FormData<"u"&&e instanceof FormData}class Qo extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class hc extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class Y extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function M(e,t){const n=e[t];return n!=null}function ei(e,t=""){return Object.keys(e).map(n=>ti(n,e[n],t)).filter(n=>n.length>0).join("&")}function ti(e,t,n=""){const o=n+(n.length?`[${e}]`:e);if(t instanceof Array){const i=t.map(r=>encodeURIComponent(String(r))).join(`&${encodeURIComponent(o)}=`);return`${encodeURIComponent(o)}=${i}`}if(t instanceof Set){const i=Array.from(t);return ti(e,i,n)}return t instanceof Date?`${encodeURIComponent(o)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?ei(t,o):`${encodeURIComponent(o)}=${encodeURIComponent(String(t))}`}function wr(e,t){return Object.keys(e).reduce((n,o)=>({...n,[o]:t(e[o])}),{})}class ye{constructor(t,n=o=>o){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class Nt{constructor(t){this.raw=t}async value(){}}class mc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function gc(e){return yc(e)}function yc(e,t){return e==null?e:{fieldUsed:M(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:M(e,"keyFormat")?e.keyFormat:void 0}}function vc(e){return Ic(e)}function Ic(e,t){return e==null?e:{name:e.name,valuePrefix:M(e,"valuePrefix")?e.valuePrefix:void 0}}function wc(e){return xc(e)}function xc(e,t){return e==null?e:{name:e.name}}function _c(e){return bc(e)}function bc(e,t){return e==null?e:{attachmentType:e.attachmentType,query:M(e,"query")?wc(e.query):void 0,header:M(e,"header")?vc(e.header):void 0,docsURL:M(e,"docsURL")?e.docsURL:void 0}}function Cc(e){return Oc(e)}function Oc(e,t){return e}function Sc(e){return Ec(e)}function Ec(e,t){return e==null?e:{days:M(e,"days")?e.days:void 0,fullHistory:M(e,"fullHistory")?e.fullHistory:void 0}}function ni(e){return Nc(e)}function Nc(e,t){return e==null?e:{defaultPeriod:Sc(e.defaultPeriod)}}function Rc(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Tc(e){if(e!==void 0)return e===null?null:{defaultPeriod:Rc(e.defaultPeriod)}}function Ac(e){return jc(e)}function jc(e,t){return e==null?e:{enabled:M(e,"enabled")?e.enabled:void 0}}function ri(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Pc(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:Tc(e.backfill)}}function Dc(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:wr(e.objects,Pc)}}function kc(e){if(e!==void 0)return e===null?null:{objectName:e.objectName}}function Fc(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:wr(e.objects,kc)}}function Mc(e){return Kc(e)}function Kc(e,t){return e==null?e:{apiKeyAsBasic:M(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:M(e,"apiKeyAsBasicOpts")?gc(e.apiKeyAsBasicOpts):void 0,docsURL:M(e,"docsURL")?e.docsURL:void 0}}function Lc(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function un(e){return $c(e)}function $c(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:M(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function Hc(e){return Vc(e)}function Vc(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Uc(e){return Bc(e)}function Bc(e,t){return e==null?e:{provider:e.provider,read:M(e,"read")?e.read:void 0,write:M(e,"write")?e.write:void 0,proxy:M(e,"proxy")?Ac(e.proxy):void 0}}function oi(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:ri(e.proxy)}}function qc(e){return Wc(e)}function Wc(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Uc(e.content)}}function Jc(e){return zc(e)}function zc(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function ii(e){return Xc(e)}function Xc(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function gn(e){return Yc(e)}function Yc(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:M(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:M(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function yn(e){return Gc(e)}function Gc(e,t){return e==null?e:{id:e.id,projectId:e.projectId,providerApp:gn(e.providerApp),group:ii(e.group),consumer:Jc(e.consumer),providerWorkspaceRef:e.providerWorkspaceRef,providerConsumerRef:M(e,"ProviderConsumerRef")?e.ProviderConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0}}function Zc(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:oi(e.content)}}function Qc(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Zc(e.config)}}function eu(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function tu(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:eu(e.latestRevision)}}function nu(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function ru(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 ou(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function iu(e){return su(e)}function su(e,t){return e==null?e:{mode:M(e,"mode")?e.mode:void 0,pageSize:M(e,"pageSize")?e.pageSize:void 0}}function au(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function cu(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function uu(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 lu(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:au(e.basicAuth),oauth2ClientCredentials:cu(e.oauth2ClientCredentials),oauth2Password:uu(e.oauth2Password)}}function du(e){return pu(e)}function pu(e,t){return e==null?e:{enabled:M(e,"enabled")?e.enabled:void 0}}function fu(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName}}function si(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:M(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:M(e,"default")?e.default:void 0,prompt:M(e,"prompt")?e.prompt:void 0}}function Wn(e){return hu(e)}function hu(e,t){return e==null?e:{...fu(e),...si(e)}}function ai(e){return mu(e)}function mu(e,t){return e}function gu(e){return yu(e)}function yu(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,destination:e.destination,schedule:e.schedule,requiredFields:M(e,"requiredFields")?e.requiredFields.map(Wn):void 0,optionalFields:M(e,"optionalFields")?e.optionalFields.map(Wn):void 0,optionalFieldsAuto:M(e,"optionalFieldsAuto")?ai(e.optionalFieldsAuto):void 0,allFields:M(e,"allFields")?e.allFields.map(Wn):void 0,backfill:M(e,"backfill")?ni(e.backfill):void 0}}function vu(e){return Iu(e)}function Iu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map(gu):void 0}}function wu(e){return xu(e)}function xu(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName}}function _u(e){return bu(e)}function bu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map(wu):void 0}}function Cu(e){return Ou(e)}function Ou(e,t){return e==null?e:{name:e.name,displayName:M(e,"displayName")?e.displayName:void 0,provider:e.provider,read:M(e,"read")?vu(e.read):void 0,write:M(e,"write")?_u(e.write):void 0,proxy:M(e,"proxy")?du(e.proxy):void 0}}function Su(e){return Eu(e)}function Eu(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Cu(e.content)}}function Nu(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 Ru(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,content:oi(e.content)}}function Tu(e){if(e!==void 0)return e===null?null:{provider:e.provider,connection:Nu(e.connection),config:Ru(e.config)}}function Ut(e){return Au(e)}function Au(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:M(e,"group")?ii(e.group):void 0,healthStatus:e.healthStatus,connection:yn(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0,config:qc(e.config)}}function ju(e){return Pu(e)}function Pu(e,t){return e==null?e:{enabled:M(e,"enabled")?e.enabled:void 0}}function Du(e,t){return e==null?e:{fieldName:e.fieldName}}function yo(e){return ku(e)}function ku(e,t){return e==null?e:{...Du(e),...si(e)}}function Fu(e){return Mu(e)}function Mu(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,requiredFields:M(e,"requiredFields")?e.requiredFields.map(yo):void 0,optionalFields:M(e,"optionalFields")?e.optionalFields.map(yo):void 0,optionalFieldsAuto:M(e,"optionalFieldsAuto")?ai(e.optionalFieldsAuto):void 0,backfill:M(e,"backfill")?ni(e.backfill):void 0,delivery:M(e,"delivery")?iu(e.delivery):void 0}}function Ku(e){return Lu(e)}function Lu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map(Fu):void 0}}function $u(e){return Hu(e)}function Hu(e,t){return e==null?e:{objectName:e.objectName}}function Vu(e){return Uu(e)}function Uu(e,t){return e==null?e:{objects:M(e,"objects")?e.objects.map($u):void 0}}function Bu(e){return qu(e)}function qu(e,t){return e==null?e:{name:e.name,displayName:M(e,"displayName")?e.displayName:void 0,provider:e.provider,read:M(e,"read")?Ku(e.read):void 0,write:M(e,"write")?Vu(e.write):void 0,proxy:M(e,"proxy")?ju(e.proxy):void 0}}function Wu(e){return Ju(e)}function Ju(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Bu(e.content)}}function vo(e){return zu(e)}function zu(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:M(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Wu(e.latestRevision)}}function Xu(e){return Yu(e)}function Yu(e,t){return e==null?e:{iconURL:M(e,"iconURL")?e.iconURL:void 0,logoURL:M(e,"logoURL")?e.logoURL:void 0}}function Gu(e){return Zu(e)}function Zu(e,t){return e==null?e:{iconURL:M(e,"iconURL")?e.iconURL:void 0,logoURL:M(e,"logoURL")?e.logoURL:void 0}}function Qu(e){return el(e)}function el(e,t){return e==null?e:{regular:M(e,"regular")?Gu(e.regular):void 0,darkMode:M(e,"darkMode")?Xu(e.darkMode):void 0}}function tl(e){return nl(e)}function nl(e,t){return e==null?e:{workspaceRefField:M(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:M(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:M(e,"scopesField")?e.scopesField:void 0}}function rl(e){return ol(e)}function ol(e,t){return e==null?e:{grantType:e.grantType,authURL:M(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:M(e,"audience")?e.audience:void 0,tokenMetadataFields:tl(e.tokenMetadataFields),docsURL:M(e,"docsURL")?e.docsURL:void 0,authURLParams:M(e,"authURLParams")?e.authURLParams:void 0}}function il(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 sl(e){return al(e)}function al(e,t){return e==null?e:{bulkWrite:Hc(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function Io(e){return cl(e)}function cl(e,t){return e==null?e:{name:e.name,authType:Cc(e.authType),baseURL:e.baseURL,oauth2Opts:M(e,"oauth2Opts")?rl(e.oauth2Opts):void 0,apiKeyOpts:M(e,"apiKeyOpts")?_c(e.apiKeyOpts):void 0,basicOpts:M(e,"basicOpts")?Mc(e.basicOpts):void 0,support:sl(e.support),providerOpts:e.providerOpts,displayName:M(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:M(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:M(e,"media")?Qu(e.media):void 0,labels:M(e,"labels")?e.labels:void 0}}function ul(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Dc(e.read),write:Fc(e.write),proxy:ri(e.proxy)}}function ll(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:ul(e.content)}}function dl(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:ll(e.config)}}function pl(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:dl(e.installation)}}function fl(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function hl(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:fl(e.project)}}function ml(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 gl(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:ml(e.providerApp)}}class yl extends ze{async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:o,body:lu(t.generateConnectionParams)},n);return new ye(r,s=>yn(s))}async generateConnection(t,n){return await(await this.generateConnectionRaw(t,n)).value()}async getConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new Y("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new ye(r,s=>yn(s))}async getConnection(t,n){return await(await this.getConnectionRaw(t,n)).value()}async listConnectionsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const o={};t.provider!==void 0&&(o.provider=t.provider),t.groupRef!==void 0&&(o.groupRef=t.groupRef),t.consumerRef!==void 0&&(o.consumerRef=t.consumerRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(yn))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}}class vl extends ze{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new Y("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o,body:Qc(t.installation)},n);return new ye(r,s=>Ut(s))}async createInstallation(t,n){return await(await this.createInstallationRaw(t,n)).value()}async deleteInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new Y("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new Nt(r)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new Y("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new ye(r,s=>Ut(s))}async getInstallation(t,n){return await(await this.getInstallationRaw(t,n)).value()}async importInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling importInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling importInstallation.");if(t.installation===null||t.installation===void 0)throw new Y("installation","Required parameter requestParameters.installation was null or undefined when calling importInstallation.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o,body:Tu(t.installation)},n);return new ye(r,s=>Ut(s))}async importInstallation(t,n){return await(await this.importInstallationRaw(t,n)).value()}async listInstallationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const o={};t.groupRef!==void 0&&(o.groupRef=t.groupRef);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new ye(r,s=>s.map(Ut))}async listInstallations(t,n){return await(await this.listInstallationsRaw(t,n)).value()}async updateInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new Y("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new Y("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o,body:pl(t.installationUpdate)},n);return new ye(r,s=>Ut(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Il extends ze{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:i,query:o,body:Lc(t.batchUpsertIntegrationsRequest)},n);return new ye(r,s=>s.map(vo))}async batchUpsertIntegrations(t,n){return await(await this.batchUpsertIntegrationsRaw(t,n)).value()}async createIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new Y("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:o,body:tu(t.integration)},n);return new Nt(r)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new Nt(r)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(vo))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class wl extends ze{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new Y("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const o={},i={};i["Content-Type"]="application/json";const r=await this.request({path:"/oauth-connect",method:"POST",headers:i,query:o,body:il(t.connectOAuthParams)},n);return this.isJsonMime(r.headers.get("content-type"))?new ye(r):new mc(r)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}}class xl extends ze{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new Y("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects",method:"POST",headers:i,query:o,body:nu(t.project)},n);return new ye(r,s=>un(s))}async createProject(t,n){return await(await this.createProjectRaw(t,n)).value()}async deleteProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:i,query:o},n);return new Nt(r)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>un(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"GET",headers:o,query:n},t);return new ye(i,r=>r.map(un))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new Y("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:i,query:o,body:hl(t.projectUpdate)},n);return new ye(r,s=>un(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class _l extends ze{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new Y("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:i,query:o},n);return new ye(r,s=>Io(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers",method:"GET",headers:o,query:n},t);return new ye(i,r=>wr(r,Io))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class bl extends ze{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new Y("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:i,query:o,body:ru(t.providerApp)},n);return new ye(r,s=>gn(s))}async createProviderApp(t,n){return await(await this.createProviderAppRaw(t,n)).value()}async deleteProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new Y("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new Nt(r)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const o={},i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:i,query:o},n);return new ye(r,s=>s.map(gn))}async listProviderApps(t,n){return await(await this.listProviderAppsRaw(t,n)).value()}async updateProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new Y("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new Y("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o,body:gl(t.providerAppUpdate)},n);return new ye(r,s=>gn(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Cl extends ze{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const o={},i={};i["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o,body:ou(t.revision)},n);return new Nt(r)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new Y("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new Y("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new Y("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new Y("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const o={};t.connectionId!==void 0&&(o.connectionId=t.connectionId);const i={};this.configuration&&this.configuration.apiKey&&(i["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const r=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:o},n);return new ye(r,s=>Su(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class Ol{constructor(t){this.connectionApi=new yl(t),this.installationApi=new vl(t),this.integrationApi=new Il(t),this.oAuthApi=new wl(t),this.projectApi=new xl(t),this.providerApi=new _l(t),this.providerAppApi=new bl(t),this.revisionApi=new Cl(t)}}const Sl="1.14.1",El="v1",ln="https://api.withampersand.com";function ci(){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 ln;case"mock":return"http://127.0.0.1:4010";case"":return ln;default:return e??ln}}catch{return ln}}const Nl=(e,t)=>`${e}/${t}`;function Rl(){return Nl(ci(),El)}const Tl=ci(),Al=Rl(),jl=new Zo({basePath:Al,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Sl}});let Pl=new Ol(jl);const fe=()=>Pl;function Dl(){return a.jsx(S.Box,{className:"loading-icon",height:"100%",width:"100%",display:"flex",justifyContent:"center",marginTop:"20%",marginBottom:"20%",children:a.jsx(S.Stack,{alignItems:"center",children:a.jsx(S.Spinner,{height:"100px",width:"100px",alignSelf:"center",thickness:"8px",speed:"1s",emptyColor:"gray.200",color:"blue.500",size:"xl",margin:"20px"})})})}const kl="_loader_h78nh_1",Fl="_rotate_h78nh_1",Ml="_ball1_h78nh_1",Kl="_ball2_h78nh_1",Ll={loader:kl,rotate:Fl,ball1:Ml,ball2:Kl};function $l(){return a.jsx("span",{className:Ll.loader})}function qe(){return ve?a.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:a.jsx($l,{})}):a.jsx(Dl,{})}const Ce=async(e,t)=>{var n;if(e instanceof Qo){const{status:o,statusText:i}=e.response;console.error(o===500?"Internal Server Error (500):":o===400?"Bad Request (400):":`Error (${o}):`,i);const r=await e.response.json(),s=((n=r==null?void 0:r.causes)==null?void 0:n.join(`
|
|
3
|
+
`))||"[ERROR] Creating installation failed.";console.error("[Error Message]",s),t&&t(s)}else console.error("Unexpected error:",e.message)},ui=y.createContext({integrations:null}),li=()=>{const e=y.useContext(ui);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Hl({projectIdOrName:e,children:t}){const n=xe(),{setError:o,isError:i}=dt(),[r,s]=y.useState(null),[c,u]=y.useState(!0);y.useEffect(()=>{fe().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(p=>{u(!1),s(p||[])}).catch(p=>{console.error("Error retrieving integration information."),Ce(p),u(!1),o(me.INTEGRATION_LIST,e)})},[e,n,o]);const d=y.useMemo(()=>({integrations:r}),[r]);return i(me.INTEGRATION_LIST,e)?a.jsx(ot,{message:"Error retrieving integrations for the project, double check the API key"}):a.jsx(ui.Provider,{value:d,children:c?a.jsx(qe,{}):t})}const di=y.createContext({project:null,appName:"",projectId:"",projectIdOrName:""}),Ie=()=>{const e=y.useContext(di);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Vl({projectIdOrName:e,children:t}){const n=xe(),{isError:o,setError:i}=dt(),[r,s]=y.useState(null),[c,u]=y.useState(!0);y.useEffect(()=>{fe().projectApi.getProject({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(p=>{u(!1),s(p)}).catch(p=>{console.error("Error loading Ampersand project."),Ce(p),i(me.PROJECT,e),u(!1)})},[e,n,u,i]);const d=y.useMemo(()=>({projectId:(r==null?void 0:r.id)||"",projectIdOrName:e,project:r,appName:(r==null?void 0:r.appName)||""}),[e,r]);return o(me.PROJECT,e)?a.jsx(ot,{message:`Error loading project ${e}`}):a.jsx(di.Provider,{value:d,children:c?a.jsx(qe,{}):t})}function Ul(e){const{options:{apiKey:t,projectId:n,project:o},children:i}=e,r=o||n;if(n&&o)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!r)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return a.jsx(Qa,{children:a.jsx(nc,{children:a.jsx(ec,{value:t,children:a.jsx(Vl,{projectIdOrName:r,children:a.jsx(Hl,{projectIdOrName:r,children:i})})})})})}const pi=y.createContext(null);function Bl(){const e=y.useContext(pi);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
4
|
+
component is wrapped with AmpersandProvider`);return e}const ql=()=>{const[e,t]=y.useState(!1),n=y.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n}},fi=y.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 Ye(){const e=y.useContext(fi);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Wl({children:e,integration:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,onInstallSuccess:s,onUpdateSuccess:c,onUninstallSuccess:u}){const d=xe(),{projectId:p}=Ie(),{integrations:h}=li(),{setError:v,isError:f}=dt(),{isIntegrationDeleted:g,setIntegrationDeleted:x}=ql(),[w,O]=y.useState([]),[I,C]=y.useState(!0),b=(w==null?void 0:w[0])||null,m=y.useMemo(()=>oc(t,h||[]),[t,h]);y.useEffect(()=>{m===null&&(h!=null&&h.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,m,h]);const j=y.useCallback(B=>{O([B])},[O]),$=y.useCallback(()=>{m!=null&&m.id&&fe().installationApi.listInstallations({projectIdOrName:p,integrationId:m.id,groupRef:i},{headers:{"X-Api-Key":d??""}}).then(B=>{C(!1),O(B||[])}).catch(B=>{v(me.INSTALLATION_LIST,m.id),C(!1),console.error("Error retrieving installation information: ",B)})},[m,p,d,v,i]),F=(m==null?void 0:m.id)||"";y.useEffect(()=>{$()},[$]);const V=y.useMemo(()=>({integrationId:(m==null?void 0:m.id)||"",provider:(m==null?void 0:m.provider)||"",integrationObj:m,consumerRef:n,consumerName:o,groupRef:i,groupName:r,installation:b,setInstallation:j,resetInstallations:$,onInstallSuccess:s,onUpdateSuccess:c,onUninstallSuccess:u,isIntegrationDeleted:g,setIntegrationDeleted:x}),[m,n,o,i,r,b,j,$,s,c,u,g,x]);if(m!==null){const B=`Error retrieving installation information for integration "${(m==null?void 0:m.name)||"unknown"}"`;return f(me.INSTALLATION_LIST,F)?a.jsx(ot,{message:B}):a.jsx(fi.Provider,{value:V,children:I?a.jsx(qe,{}):e})}return a.jsx(ot,{message:`Integration "${t}" not found`})}const hi=y.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),kt=()=>{const e=y.useContext(hi);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function mi({provider:e,groupRef:t,children:n}){const o=xe(),{projectId:i}=Ie(),[r,s]=y.useState(null),[c,u]=y.useState(null),[d,p]=y.useState(!0),{setError:h,isError:v}=dt(),{provider:f}=Ye();if(!i)throw new Error("ConnectionsProvider must be used within AmpersandProvider");const g=e||f;if(!g)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");y.useEffect(()=>{fe().connectionApi.listConnections({projectIdOrName:i,groupRef:t,provider:g},{headers:{"X-Api-Key":o??""}}).then(w=>{p(!1),s(w)}).catch(w=>{console.error(`Error retrieving existing OAuth connections for group ID ${t}.`),Ce(w),p(!1),h(me.CONNECTION_LIST,i)})},[i,o,t,g,h]);const x=y.useMemo(()=>({connections:r,selectedConnection:c,setConnections:s,setSelectedConnection:u}),[r,c,s,u]);return v(me.CONNECTION_LIST,i)?a.jsx(ot,{message:"Error retrieving existing connections"}):a.jsx(hi.Provider,{value:x,children:d?a.jsx(qe,{}):n})}var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xn={exports:{}};xn.exports;(function(e,t){var n=200,o="__lodash_hash_undefined__",i=1,r=2,s=9007199254740991,c="[object Arguments]",u="[object Array]",d="[object AsyncFunction]",p="[object Boolean]",h="[object Date]",v="[object Error]",f="[object Function]",g="[object GeneratorFunction]",x="[object Map]",w="[object Number]",O="[object Null]",I="[object Object]",C="[object Promise]",b="[object Proxy]",m="[object RegExp]",j="[object Set]",$="[object String]",F="[object Symbol]",V="[object Undefined]",B="[object WeakMap]",Z="[object ArrayBuffer]",G="[object DataView]",te="[object Float32Array]",Q="[object Float64Array]",ue="[object Int8Array]",le="[object Int16Array]",re="[object Int32Array]",Oe="[object Uint8Array]",Ee="[object Uint8ClampedArray]",N="[object Uint16Array]",K="[object Uint32Array]",k=/[\\^$.*+?()[\]{}|]/g,D=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,R={};R[te]=R[Q]=R[ue]=R[le]=R[re]=R[Oe]=R[Ee]=R[N]=R[K]=!0,R[c]=R[u]=R[Z]=R[p]=R[G]=R[h]=R[v]=R[f]=R[x]=R[w]=R[I]=R[m]=R[j]=R[$]=R[B]=!1;var q=typeof dn=="object"&&dn&&dn.Object===Object&&dn,J=typeof self=="object"&&self&&self.Object===Object&&self,U=q||J||Function("return this")(),z=t&&!t.nodeType&&t,W=z&&!0&&e&&!e.nodeType&&e,oe=W&&W.exports===z,A=oe&&q.process,de=function(){try{return A&&A.binding&&A.binding("util")}catch{}}(),L=de&&de.isTypedArray;function Ne(l,_){for(var E=-1,H=l==null?0:l.length,pe=0,ee=[];++E<H;){var ge=l[E];_(ge,E,l)&&(ee[pe++]=ge)}return ee}function Re(l,_){for(var E=-1,H=_.length,pe=l.length;++E<H;)l[pe+E]=_[E];return l}function Ge(l,_){for(var E=-1,H=l==null?0:l.length;++E<H;)if(_(l[E],E,l))return!0;return!1}function Ve(l,_){for(var E=-1,H=Array(l);++E<l;)H[E]=_(E);return H}function Ct(l){return function(_){return l(_)}}function Mt(l,_){return l.has(_)}function Ue(l,_){return l==null?void 0:l[_]}function ft(l){var _=-1,E=Array(l.size);return l.forEach(function(H,pe){E[++_]=[pe,H]}),E}function Kt(l,_){return function(E){return l(_(E))}}function Ot(l){var _=-1,E=Array(l.size);return l.forEach(function(H){E[++_]=H}),E}var We=Array.prototype,Ze=Function.prototype,je=Object.prototype,Te=U["__core-js_shared__"],en=Ze.toString,Je=je.hasOwnProperty,Yr=function(){var l=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),Gr=je.toString,Gs=RegExp("^"+en.call(Je).replace(k,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Zr=oe?U.Buffer:void 0,tn=U.Symbol,Qr=U.Uint8Array,eo=je.propertyIsEnumerable,Zs=We.splice,ht=tn?tn.toStringTag:void 0,to=Object.getOwnPropertySymbols,Qs=Zr?Zr.isBuffer:void 0,ea=Kt(Object.keys,Object),Ln=St(U,"DataView"),Lt=St(U,"Map"),$n=St(U,"Promise"),Hn=St(U,"Set"),Vn=St(U,"WeakMap"),$t=St(Object,"create"),ta=yt(Ln),na=yt(Lt),ra=yt($n),oa=yt(Hn),ia=yt(Vn),no=tn?tn.prototype:void 0,Un=no?no.valueOf:void 0;function mt(l){var _=-1,E=l==null?0:l.length;for(this.clear();++_<E;){var H=l[_];this.set(H[0],H[1])}}function sa(){this.__data__=$t?$t(null):{},this.size=0}function aa(l){var _=this.has(l)&&delete this.__data__[l];return this.size-=_?1:0,_}function ca(l){var _=this.__data__;if($t){var E=_[l];return E===o?void 0:E}return Je.call(_,l)?_[l]:void 0}function ua(l){var _=this.__data__;return $t?_[l]!==void 0:Je.call(_,l)}function la(l,_){var E=this.__data__;return this.size+=this.has(l)?0:1,E[l]=$t&&_===void 0?o:_,this}mt.prototype.clear=sa,mt.prototype.delete=aa,mt.prototype.get=ca,mt.prototype.has=ua,mt.prototype.set=la;function Qe(l){var _=-1,E=l==null?0:l.length;for(this.clear();++_<E;){var H=l[_];this.set(H[0],H[1])}}function da(){this.__data__=[],this.size=0}function pa(l){var _=this.__data__,E=rn(_,l);if(E<0)return!1;var H=_.length-1;return E==H?_.pop():Zs.call(_,E,1),--this.size,!0}function fa(l){var _=this.__data__,E=rn(_,l);return E<0?void 0:_[E][1]}function ha(l){return rn(this.__data__,l)>-1}function ma(l,_){var E=this.__data__,H=rn(E,l);return H<0?(++this.size,E.push([l,_])):E[H][1]=_,this}Qe.prototype.clear=da,Qe.prototype.delete=pa,Qe.prototype.get=fa,Qe.prototype.has=ha,Qe.prototype.set=ma;function gt(l){var _=-1,E=l==null?0:l.length;for(this.clear();++_<E;){var H=l[_];this.set(H[0],H[1])}}function ga(){this.size=0,this.__data__={hash:new mt,map:new(Lt||Qe),string:new mt}}function ya(l){var _=on(this,l).delete(l);return this.size-=_?1:0,_}function va(l){return on(this,l).get(l)}function Ia(l){return on(this,l).has(l)}function wa(l,_){var E=on(this,l),H=E.size;return E.set(l,_),this.size+=E.size==H?0:1,this}gt.prototype.clear=ga,gt.prototype.delete=ya,gt.prototype.get=va,gt.prototype.has=Ia,gt.prototype.set=wa;function nn(l){var _=-1,E=l==null?0:l.length;for(this.__data__=new gt;++_<E;)this.add(l[_])}function xa(l){return this.__data__.set(l,o),this}function _a(l){return this.__data__.has(l)}nn.prototype.add=nn.prototype.push=xa,nn.prototype.has=_a;function st(l){var _=this.__data__=new Qe(l);this.size=_.size}function ba(){this.__data__=new Qe,this.size=0}function Ca(l){var _=this.__data__,E=_.delete(l);return this.size=_.size,E}function Oa(l){return this.__data__.get(l)}function Sa(l){return this.__data__.has(l)}function Ea(l,_){var E=this.__data__;if(E instanceof Qe){var H=E.__data__;if(!Lt||H.length<n-1)return H.push([l,_]),this.size=++E.size,this;E=this.__data__=new gt(H)}return E.set(l,_),this.size=E.size,this}st.prototype.clear=ba,st.prototype.delete=Ca,st.prototype.get=Oa,st.prototype.has=Sa,st.prototype.set=Ea;function Na(l,_){var E=sn(l),H=!E&&Ua(l),pe=!E&&!H&&Bn(l),ee=!E&&!H&&!pe&&po(l),ge=E||H||pe||ee,_e=ge?Ve(l.length,String):[],be=_e.length;for(var he in l)Je.call(l,he)&&!(ge&&(he=="length"||pe&&(he=="offset"||he=="parent")||ee&&(he=="buffer"||he=="byteLength"||he=="byteOffset")||Ka(he,be)))&&_e.push(he);return _e}function rn(l,_){for(var E=l.length;E--;)if(ao(l[E][0],_))return E;return-1}function Ra(l,_,E){var H=_(l);return sn(l)?H:Re(H,E(l))}function Ht(l){return l==null?l===void 0?V:O:ht&&ht in Object(l)?Fa(l):Va(l)}function ro(l){return Vt(l)&&Ht(l)==c}function oo(l,_,E,H,pe){return l===_?!0:l==null||_==null||!Vt(l)&&!Vt(_)?l!==l&&_!==_:Ta(l,_,E,H,oo,pe)}function Ta(l,_,E,H,pe,ee){var ge=sn(l),_e=sn(_),be=ge?u:at(l),he=_e?u:at(_);be=be==c?I:be,he=he==c?I:he;var Pe=be==I,Be=he==I,Se=be==he;if(Se&&Bn(l)){if(!Bn(_))return!1;ge=!0,Pe=!1}if(Se&&!Pe)return ee||(ee=new st),ge||po(l)?io(l,_,E,H,pe,ee):Da(l,_,be,E,H,pe,ee);if(!(E&i)){var Le=Pe&&Je.call(l,"__wrapped__"),$e=Be&&Je.call(_,"__wrapped__");if(Le||$e){var ct=Le?l.value():l,et=$e?_.value():_;return ee||(ee=new st),pe(ct,et,E,H,ee)}}return Se?(ee||(ee=new st),ka(l,_,E,H,pe,ee)):!1}function Aa(l){if(!lo(l)||$a(l))return!1;var _=co(l)?Gs:D;return _.test(yt(l))}function ja(l){return Vt(l)&&uo(l.length)&&!!R[Ht(l)]}function Pa(l){if(!Ha(l))return ea(l);var _=[];for(var E in Object(l))Je.call(l,E)&&E!="constructor"&&_.push(E);return _}function io(l,_,E,H,pe,ee){var ge=E&i,_e=l.length,be=_.length;if(_e!=be&&!(ge&&be>_e))return!1;var he=ee.get(l);if(he&&ee.get(_))return he==_;var Pe=-1,Be=!0,Se=E&r?new nn:void 0;for(ee.set(l,_),ee.set(_,l);++Pe<_e;){var Le=l[Pe],$e=_[Pe];if(H)var ct=ge?H($e,Le,Pe,_,l,ee):H(Le,$e,Pe,l,_,ee);if(ct!==void 0){if(ct)continue;Be=!1;break}if(Se){if(!Ge(_,function(et,vt){if(!Mt(Se,vt)&&(Le===et||pe(Le,et,E,H,ee)))return Se.push(vt)})){Be=!1;break}}else if(!(Le===$e||pe(Le,$e,E,H,ee))){Be=!1;break}}return ee.delete(l),ee.delete(_),Be}function Da(l,_,E,H,pe,ee,ge){switch(E){case G:if(l.byteLength!=_.byteLength||l.byteOffset!=_.byteOffset)return!1;l=l.buffer,_=_.buffer;case Z:return!(l.byteLength!=_.byteLength||!ee(new Qr(l),new Qr(_)));case p:case h:case w:return ao(+l,+_);case v:return l.name==_.name&&l.message==_.message;case m:case $:return l==_+"";case x:var _e=ft;case j:var be=H&i;if(_e||(_e=Ot),l.size!=_.size&&!be)return!1;var he=ge.get(l);if(he)return he==_;H|=r,ge.set(l,_);var Pe=io(_e(l),_e(_),H,pe,ee,ge);return ge.delete(l),Pe;case F:if(Un)return Un.call(l)==Un.call(_)}return!1}function ka(l,_,E,H,pe,ee){var ge=E&i,_e=so(l),be=_e.length,he=so(_),Pe=he.length;if(be!=Pe&&!ge)return!1;for(var Be=be;Be--;){var Se=_e[Be];if(!(ge?Se in _:Je.call(_,Se)))return!1}var Le=ee.get(l);if(Le&&ee.get(_))return Le==_;var $e=!0;ee.set(l,_),ee.set(_,l);for(var ct=ge;++Be<be;){Se=_e[Be];var et=l[Se],vt=_[Se];if(H)var fo=ge?H(vt,et,Se,_,l,ee):H(et,vt,Se,l,_,ee);if(!(fo===void 0?et===vt||pe(et,vt,E,H,ee):fo)){$e=!1;break}ct||(ct=Se=="constructor")}if($e&&!ct){var an=l.constructor,cn=_.constructor;an!=cn&&"constructor"in l&&"constructor"in _&&!(typeof an=="function"&&an instanceof an&&typeof cn=="function"&&cn instanceof cn)&&($e=!1)}return ee.delete(l),ee.delete(_),$e}function so(l){return Ra(l,Wa,Ma)}function on(l,_){var E=l.__data__;return La(_)?E[typeof _=="string"?"string":"hash"]:E.map}function St(l,_){var E=Ue(l,_);return Aa(E)?E:void 0}function Fa(l){var _=Je.call(l,ht),E=l[ht];try{l[ht]=void 0;var H=!0}catch{}var pe=Gr.call(l);return H&&(_?l[ht]=E:delete l[ht]),pe}var Ma=to?function(l){return l==null?[]:(l=Object(l),Ne(to(l),function(_){return eo.call(l,_)}))}:Ja,at=Ht;(Ln&&at(new Ln(new ArrayBuffer(1)))!=G||Lt&&at(new Lt)!=x||$n&&at($n.resolve())!=C||Hn&&at(new Hn)!=j||Vn&&at(new Vn)!=B)&&(at=function(l){var _=Ht(l),E=_==I?l.constructor:void 0,H=E?yt(E):"";if(H)switch(H){case ta:return G;case na:return x;case ra:return C;case oa:return j;case ia:return B}return _});function Ka(l,_){return _=_??s,!!_&&(typeof l=="number"||P.test(l))&&l>-1&&l%1==0&&l<_}function La(l){var _=typeof l;return _=="string"||_=="number"||_=="symbol"||_=="boolean"?l!=="__proto__":l===null}function $a(l){return!!Yr&&Yr in l}function Ha(l){var _=l&&l.constructor,E=typeof _=="function"&&_.prototype||je;return l===E}function Va(l){return Gr.call(l)}function yt(l){if(l!=null){try{return en.call(l)}catch{}try{return l+""}catch{}}return""}function ao(l,_){return l===_||l!==l&&_!==_}var Ua=ro(function(){return arguments}())?ro:function(l){return Vt(l)&&Je.call(l,"callee")&&!eo.call(l,"callee")},sn=Array.isArray;function Ba(l){return l!=null&&uo(l.length)&&!co(l)}var Bn=Qs||za;function qa(l,_){return oo(l,_)}function co(l){if(!lo(l))return!1;var _=Ht(l);return _==f||_==g||_==d||_==b}function uo(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=s}function lo(l){var _=typeof l;return l!=null&&(_=="object"||_=="function")}function Vt(l){return l!=null&&typeof l=="object"}var po=L?Ct(L):ja;function Wa(l){return Ba(l)?Na(l):Pa(l)}function Ja(){return[]}function za(){return!1}e.exports=qa})(xn,xn.exports);var Jl=xn.exports;const zl=xr(Jl),xt="other";function Xe(e){return e.mapToName!==void 0}function Xl(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(o=>o.objectName===t))||null}function Yl(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!Xe(n)&&!!n.fieldName))||null}function Gl(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(o=>Xe(o)&&!!o.mapToName))||[]}function Zl(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!Xe(n)&&!!n.fieldName))||null}const gi=(e,t)=>{var n,o,i;return(i=(o=(n=e==null?void 0:e.content)==null?void 0:n.read)==null?void 0:o.objects)==null?void 0:i[t]};function Ql(e){return Xe(e)?e.mapToName:e.fieldName}const yi=(e,t)=>{var o,i,r;const n=[];return(r=(i=(o=t.content)==null?void 0:o.read)==null?void 0:i.objects)==null||r.forEach(s=>{n.push({name:s==null?void 0:s.objectName,completed:e?!!gi(e,s.objectName):!1})}),n},vi=e=>{var n;return{name:xt,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function ed(e,t){var r;const n=yi(e,t),i=!!((r=t==null?void 0:t.content)!=null&&r.write)?vi(e):void 0;return i&&n.push(i),n}function Ii(e,t,n){const o=(e==null?void 0:e.filter(r=>!(t!=null&&t[r==null?void 0:r.mapToName])))||[],i=o.map(r=>r.mapToName);return n(me.MAPPING,i),o!=null&&o.length&&console.error("required fields not met",o.map(r=>r.mapToDisplayName)),{errorList:i}}function _r(e,t){return zl(e,t)}const td=(e,t,n)=>{var f,g,x,w,O,I;if(!e)return null;const o=Xl(e,t),i=o&&Yl(o),r=o&&Zl(o),s=o&&Gl(o),c=(o==null?void 0:o.allFields)||[],u=n==null?void 0:n.content,d=((x=(g=(f=u==null?void 0:u.read)==null?void 0:f.objects)==null?void 0:g[t])==null?void 0:x.selectedFields)||{},p=((I=(O=(w=u==null?void 0:u.read)==null?void 0:w.objects)==null?void 0:O[t])==null?void 0:I.selectedFieldMappings)||{},h={...d},v={...p};return{allFields:c,requiredFields:i,optionalFields:r,requiredMapFields:s,selectedOptionalFields:d,selectedFieldMappings:p,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,savedConfig:{optionalFields:h,requiredMapFields:v}}},nd=(e,t)=>{var s,c;if(!e)return null;const n=(c=(s=t==null?void 0:t.content)==null?void 0:s.write)==null?void 0:c.objects,o=Object.keys(n||{}),i={};o.forEach(u=>{i[u]=!0});const r={...i};return{writeObjects:(e==null?void 0:e.objects)||[],selectedNonConfigurableWriteFields:i,isWriteModified:!1,savedConfig:{selectedNonConfigurableWriteFields:r}}};function wi(e,t,n){var r,s;const o=(r=e==null?void 0:e.content)==null?void 0:r.read,i=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:td(o,t,n),write:nd(i,n)}}const xi=(e,t,n,o)=>{const i=wi(e,n,t);o(n,i)},rd=(e,t,n)=>{const o=ed(t,e),i={};o.forEach(({name:r,completed:s})=>{s&&(i[r]=wi(e,r,t))}),n(i)},_i=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},o=new Set;return t==null||t.forEach(r=>o.add(Ql(r))),{...Array.from(o).reduce((r,s)=>({...r,[s]:!0}),{}),...n||{}}},bi=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},n={};return t&&Object.keys(t).forEach(o=>{t[o]!==void 0?n[o]=t[o]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${o}`)}),n};function Ci(e,t){return t[e]||void 0}async function br({createConfig:e,projectId:t,integrationId:n,groupRef:o,connectionId:i,apiKey:r,setError:s,setInstallation:c,onInstallSuccess:u}){const d={projectIdOrName:t,integrationId:n,installation:{groupRef:o,connectionId:i,config:e}};try{const p=await fe().installationApi.createInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}});c(p),u==null||u(p.id,p.config)}catch(p){Ce(p,s)}}function jn(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const od=(e,t)=>{const n=e.content.read,o=n==null?void 0:n.objects;return o==null?void 0:o.find(i=>i.objectName===t)},id=(e,t,n,o)=>{const i=_i(e),r=bi(e),s=od(n,t);if(!s)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const c={revisionId:n.id,createdBy:`consumer:${o}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:s.schedule,destination:s.destination,selectedFields:i,selectedFieldMappings:r,backfill:s.backfill}}}}};return jn(n)&&(c.content.proxy={enabled:!0}),c},sd=(e,t,n,o,i,r,s,c,u,d,p,h)=>{const v=id(u,r,c,o);return v?br({createConfig:v,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:s,setError:d,setInstallation:p,onInstallSuccess:h}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},Oi=e=>{var r,s;const t={},n=(r=e.write)==null?void 0:r.writeObjects,o=(s=e.write)==null?void 0:s.selectedNonConfigurableWriteFields,i=o?Object.keys(o):[];return n&&n.forEach(c=>{const u=c.objectName;i.includes(u)&&(t[u]={objectName:u})}),t},ad=e=>{const t=e.content.write;return t==null?void 0:t.objects},cd=(e,t,n)=>{if(!ad(t))return console.error("Error when getting write objects from hydratedRevision"),null;const i=Oi(e),r={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:i}}};return jn(t)&&(r.content.proxy={enabled:!0}),r},ud=(e,t,n,o,i,r,s,c,u,d,p)=>{const h=cd(c,s,o);return h?br({createConfig:h,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:r,setError:u,setInstallation:d,onInstallSuccess:p}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ld=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-background").trim()||"#FEF2F2",dd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-border").trim()||"#FECACA",pd=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-error-text").trim()||"#991B1B",fd={backgroundColor:ld,borderColor:dd,color:pd,padding:".5rem 1rem"};function Si({children:e,style:t}){return a.jsx(Dt,{style:{...fd,...t},children:e})}var Ei={exports:{}};/*!
|
|
5
|
+
Copyright (c) 2018 Jed Watson.
|
|
6
|
+
Licensed under the MIT License (MIT), see
|
|
7
|
+
http://jedwatson.github.io/classnames
|
|
8
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",s=0;s<arguments.length;s++){var c=arguments[s];c&&(r=i(r,o(c)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var s="";for(var c in r)t.call(r,c)&&r[c]&&(s=i(s,c));return s}function i(r,s){return s?r?r+" "+s:r+s:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Ei);var hd=Ei.exports;const zt=xr(hd),md="_button_rchgn_1",gd="_buttonError_rchgn_21",yd="_danger_rchgn_40",vd="_ghost_rchgn_50",Jn={button:md,buttonError:gd,danger:yd,ghost:vd};function He({className:e,style:t,type:n,children:o,variant:i,...r}){const s=zt(Jn.button,{[Jn.danger]:i==="danger",[Jn.ghost]:i==="ghost",[e||""]:!!e});return a.jsx("button",{type:n,className:s,style:t,...r,children:o})}function Id(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.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"}),a.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#991B1B",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Ni="uninstall-installation",wd=y.forwardRef(({text:e="Uninstall"},t)=>{const n=S.useTab({ref:t}),o=S.useMultiStyleConfig("Tabs",n);return a.jsxs(S.Button,{__css:o.warningTab,...n,minHeight:15,children:[a.jsxs(S.Box,{as:"span",display:"flex",alignItems:"center",gap:2,my:2,mx:4,children:[Id(),a.jsx(S.Box,{textAlign:"left",children:a.jsx(S.Text,{color:"red.800",children:e})})]}),n.children]})}),Ri=y.createContext({hydratedRevision:null,loading:!1}),Zt=()=>{const e=y.useContext(Ri);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e};function xd({projectId:e,children:t}){var C;const{selectedConnection:n}=kt(),{integrationId:o,integrationObj:i}=Ye(),[r,s]=y.useState(null),[c,u]=y.useState(!0),{isError:d,removeError:p,setError:h}=dt(),v=xe(),f=n==null?void 0:n.id,g=(C=i==null?void 0:i.latestRevision)==null?void 0:C.id,x=(i==null?void 0:i.name)||o;y.useEffect(()=>{e&&o&&g&&f&&v&&fe().revisionApi.getHydratedRevision({projectIdOrName:e,integrationId:o,revisionId:g,connectionId:f},{headers:{"X-Api-Key":v??""}}).then(b=>{s(b),u(!1),p(me.HYDRATED_REVISION,x)}).catch(b=>{console.error(`Error loading integration ${x}.`),Ce(b),u(!1),h(me.HYDRATED_REVISION,x)})},[e,o,g,f,v,p,h,x]);const w=y.useMemo(()=>({hydratedRevision:r,loading:c}),[r,c]),I=`Error retrieving integration details for '${(i==null?void 0:i.name)||o||"unknown integration"}. This is sometimes caused by insufficient permissions with your credentials'`;return a.jsx(Ri.Provider,{value:w,children:d(me.HYDRATED_REVISION,x)?a.jsx(ot,{message:I}):t})}function nt(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}function ne(){return ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},ne.apply(null,arguments)}function ir(e,t){return ir=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},ir(e,t)}function _d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ir(e,t)}var sr={exports:{}},pn={exports:{}},ie={};/** @license React v16.13.1
|
|
9
|
+
* react-is.production.min.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/var wo;function bd(){if(wo)return ie;wo=1;var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,r=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,d=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,g=e?Symbol.for("react.lazy"):60116,x=e?Symbol.for("react.block"):60121,w=e?Symbol.for("react.fundamental"):60117,O=e?Symbol.for("react.responder"):60118,I=e?Symbol.for("react.scope"):60119;function C(m){if(typeof m=="object"&&m!==null){var j=m.$$typeof;switch(j){case t:switch(m=m.type,m){case u:case d:case o:case r:case i:case h:return m;default:switch(m=m&&m.$$typeof,m){case c:case p:case g:case f:case s:return m;default:return j}}case n:return j}}}function b(m){return C(m)===d}return ie.AsyncMode=u,ie.ConcurrentMode=d,ie.ContextConsumer=c,ie.ContextProvider=s,ie.Element=t,ie.ForwardRef=p,ie.Fragment=o,ie.Lazy=g,ie.Memo=f,ie.Portal=n,ie.Profiler=r,ie.StrictMode=i,ie.Suspense=h,ie.isAsyncMode=function(m){return b(m)||C(m)===u},ie.isConcurrentMode=b,ie.isContextConsumer=function(m){return C(m)===c},ie.isContextProvider=function(m){return C(m)===s},ie.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===t},ie.isForwardRef=function(m){return C(m)===p},ie.isFragment=function(m){return C(m)===o},ie.isLazy=function(m){return C(m)===g},ie.isMemo=function(m){return C(m)===f},ie.isPortal=function(m){return C(m)===n},ie.isProfiler=function(m){return C(m)===r},ie.isStrictMode=function(m){return C(m)===i},ie.isSuspense=function(m){return C(m)===h},ie.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===o||m===d||m===r||m===i||m===h||m===v||typeof m=="object"&&m!==null&&(m.$$typeof===g||m.$$typeof===f||m.$$typeof===s||m.$$typeof===c||m.$$typeof===p||m.$$typeof===w||m.$$typeof===O||m.$$typeof===I||m.$$typeof===x)},ie.typeOf=C,ie}var se={};/** @license React v16.13.1
|
|
16
|
+
* react-is.development.js
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/var xo;function Cd(){return xo||(xo=1,process.env.NODE_ENV!=="production"&&function(){var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,r=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,d=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,h=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,g=e?Symbol.for("react.lazy"):60116,x=e?Symbol.for("react.block"):60121,w=e?Symbol.for("react.fundamental"):60117,O=e?Symbol.for("react.responder"):60118,I=e?Symbol.for("react.scope"):60119;function C(A){return typeof A=="string"||typeof A=="function"||A===o||A===d||A===r||A===i||A===h||A===v||typeof A=="object"&&A!==null&&(A.$$typeof===g||A.$$typeof===f||A.$$typeof===s||A.$$typeof===c||A.$$typeof===p||A.$$typeof===w||A.$$typeof===O||A.$$typeof===I||A.$$typeof===x)}function b(A){if(typeof A=="object"&&A!==null){var de=A.$$typeof;switch(de){case t:var L=A.type;switch(L){case u:case d:case o:case r:case i:case h:return L;default:var Ne=L&&L.$$typeof;switch(Ne){case c:case p:case g:case f:case s:return Ne;default:return de}}case n:return de}}}var m=u,j=d,$=c,F=s,V=t,B=p,Z=o,G=g,te=f,Q=n,ue=r,le=i,re=h,Oe=!1;function Ee(A){return Oe||(Oe=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),N(A)||b(A)===u}function N(A){return b(A)===d}function K(A){return b(A)===c}function k(A){return b(A)===s}function D(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function P(A){return b(A)===p}function R(A){return b(A)===o}function q(A){return b(A)===g}function J(A){return b(A)===f}function U(A){return b(A)===n}function z(A){return b(A)===r}function W(A){return b(A)===i}function oe(A){return b(A)===h}se.AsyncMode=m,se.ConcurrentMode=j,se.ContextConsumer=$,se.ContextProvider=F,se.Element=V,se.ForwardRef=B,se.Fragment=Z,se.Lazy=G,se.Memo=te,se.Portal=Q,se.Profiler=ue,se.StrictMode=le,se.Suspense=re,se.isAsyncMode=Ee,se.isConcurrentMode=N,se.isContextConsumer=K,se.isContextProvider=k,se.isElement=D,se.isForwardRef=P,se.isFragment=R,se.isLazy=q,se.isMemo=J,se.isPortal=U,se.isProfiler=z,se.isStrictMode=W,se.isSuspense=oe,se.isValidElementType=C,se.typeOf=b}()),se}var _o;function Ti(){return _o||(_o=1,process.env.NODE_ENV==="production"?pn.exports=bd():pn.exports=Cd()),pn.exports}/*
|
|
23
|
+
object-assign
|
|
24
|
+
(c) Sindre Sorhus
|
|
25
|
+
@license MIT
|
|
26
|
+
*/var zn,bo;function Od(){if(bo)return zn;bo=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function o(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function i(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var s={},c=0;c<10;c++)s["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(s).map(function(p){return s[p]});if(u.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(p){d[p]=p}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return zn=i()?Object.assign:function(r,s){for(var c,u=o(r),d,p=1;p<arguments.length;p++){c=Object(arguments[p]);for(var h in c)t.call(c,h)&&(u[h]=c[h]);if(e){d=e(c);for(var v=0;v<d.length;v++)n.call(c,d[v])&&(u[d[v]]=c[d[v]])}}return u},zn}var Xn,Co;function Cr(){if(Co)return Xn;Co=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Xn=e,Xn}var Yn,Oo;function Ai(){return Oo||(Oo=1,Yn=Function.call.bind(Object.prototype.hasOwnProperty)),Yn}var Gn,So;function Sd(){if(So)return Gn;So=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=Cr(),n={},o=Ai();e=function(r){var s="Warning: "+r;typeof console<"u"&&console.error(s);try{throw new Error(s)}catch{}}}function i(r,s,c,u,d){if(process.env.NODE_ENV!=="production"){for(var p in r)if(o(r,p)){var h;try{if(typeof r[p]!="function"){var v=Error((u||"React class")+": "+c+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}h=r[p](s,p,u,c,null,t)}catch(g){h=g}if(h&&!(h instanceof Error)&&e((u||"React class")+": type specification of "+c+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var f=d?d():"";e("Failed "+c+" type: "+h.message+(f??""))}}}}return i.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Gn=i,Gn}var Zn,Eo;function Ed(){if(Eo)return Zn;Eo=1;var e=Ti(),t=Od(),n=Cr(),o=Ai(),i=Sd(),r=function(){};process.env.NODE_ENV!=="production"&&(r=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function s(){return null}return Zn=function(c,u){var d=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function h(N){var K=N&&(d&&N[d]||N[p]);if(typeof K=="function")return K}var v="<<anonymous>>",f={array:O("array"),bigint:O("bigint"),bool:O("boolean"),func:O("function"),number:O("number"),object:O("object"),string:O("string"),symbol:O("symbol"),any:I(),arrayOf:C,element:b(),elementType:m(),instanceOf:j,node:B(),objectOf:F,oneOf:$,oneOfType:V,shape:G,exact:te};function g(N,K){return N===K?N!==0||1/N===1/K:N!==N&&K!==K}function x(N,K){this.message=N,this.data=K&&typeof K=="object"?K:{},this.stack=""}x.prototype=Error.prototype;function w(N){if(process.env.NODE_ENV!=="production")var K={},k=0;function D(R,q,J,U,z,W,oe){if(U=U||v,W=W||J,oe!==n){if(u){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=U+":"+J;!K[de]&&k<3&&(r("You are manually calling a React.PropTypes validation function for the `"+W+"` prop on `"+U+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),K[de]=!0,k++)}}return q[J]==null?R?q[J]===null?new x("The "+z+" `"+W+"` is marked as required "+("in `"+U+"`, but its value is `null`.")):new x("The "+z+" `"+W+"` is marked as required in "+("`"+U+"`, but its value is `undefined`.")):null:N(q,J,U,z,W)}var P=D.bind(null,!1);return P.isRequired=D.bind(null,!0),P}function O(N){function K(k,D,P,R,q,J){var U=k[D],z=le(U);if(z!==N){var W=re(U);return new x("Invalid "+R+" `"+q+"` of type "+("`"+W+"` supplied to `"+P+"`, expected ")+("`"+N+"`."),{expectedType:N})}return null}return w(K)}function I(){return w(s)}function C(N){function K(k,D,P,R,q){if(typeof N!="function")return new x("Property `"+q+"` of component `"+P+"` has invalid PropType notation inside arrayOf.");var J=k[D];if(!Array.isArray(J)){var U=le(J);return new x("Invalid "+R+" `"+q+"` of type "+("`"+U+"` supplied to `"+P+"`, expected an array."))}for(var z=0;z<J.length;z++){var W=N(J,z,P,R,q+"["+z+"]",n);if(W instanceof Error)return W}return null}return w(K)}function b(){function N(K,k,D,P,R){var q=K[k];if(!c(q)){var J=le(q);return new x("Invalid "+P+" `"+R+"` of type "+("`"+J+"` supplied to `"+D+"`, expected a single ReactElement."))}return null}return w(N)}function m(){function N(K,k,D,P,R){var q=K[k];if(!e.isValidElementType(q)){var J=le(q);return new x("Invalid "+P+" `"+R+"` of type "+("`"+J+"` supplied to `"+D+"`, expected a single ReactElement type."))}return null}return w(N)}function j(N){function K(k,D,P,R,q){if(!(k[D]instanceof N)){var J=N.name||v,U=Ee(k[D]);return new x("Invalid "+R+" `"+q+"` of type "+("`"+U+"` supplied to `"+P+"`, expected ")+("instance of `"+J+"`."))}return null}return w(K)}function $(N){if(!Array.isArray(N))return process.env.NODE_ENV!=="production"&&(arguments.length>1?r("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):r("Invalid argument supplied to oneOf, expected an array.")),s;function K(k,D,P,R,q){for(var J=k[D],U=0;U<N.length;U++)if(g(J,N[U]))return null;var z=JSON.stringify(N,function(oe,A){var de=re(A);return de==="symbol"?String(A):A});return new x("Invalid "+R+" `"+q+"` of value `"+String(J)+"` "+("supplied to `"+P+"`, expected one of "+z+"."))}return w(K)}function F(N){function K(k,D,P,R,q){if(typeof N!="function")return new x("Property `"+q+"` of component `"+P+"` has invalid PropType notation inside objectOf.");var J=k[D],U=le(J);if(U!=="object")return new x("Invalid "+R+" `"+q+"` of type "+("`"+U+"` supplied to `"+P+"`, expected an object."));for(var z in J)if(o(J,z)){var W=N(J,z,P,R,q+"."+z,n);if(W instanceof Error)return W}return null}return w(K)}function V(N){if(!Array.isArray(N))return process.env.NODE_ENV!=="production"&&r("Invalid argument supplied to oneOfType, expected an instance of array."),s;for(var K=0;K<N.length;K++){var k=N[K];if(typeof k!="function")return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Oe(k)+" at index "+K+"."),s}function D(P,R,q,J,U){for(var z=[],W=0;W<N.length;W++){var oe=N[W],A=oe(P,R,q,J,U,n);if(A==null)return null;A.data&&o(A.data,"expectedType")&&z.push(A.data.expectedType)}var de=z.length>0?", expected one of type ["+z.join(", ")+"]":"";return new x("Invalid "+J+" `"+U+"` supplied to "+("`"+q+"`"+de+"."))}return w(D)}function B(){function N(K,k,D,P,R){return Q(K[k])?null:new x("Invalid "+P+" `"+R+"` supplied to "+("`"+D+"`, expected a ReactNode."))}return w(N)}function Z(N,K,k,D,P){return new x((N||"React class")+": "+K+" type `"+k+"."+D+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+P+"`.")}function G(N){function K(k,D,P,R,q){var J=k[D],U=le(J);if(U!=="object")return new x("Invalid "+R+" `"+q+"` of type `"+U+"` "+("supplied to `"+P+"`, expected `object`."));for(var z in N){var W=N[z];if(typeof W!="function")return Z(P,R,q,z,re(W));var oe=W(J,z,P,R,q+"."+z,n);if(oe)return oe}return null}return w(K)}function te(N){function K(k,D,P,R,q){var J=k[D],U=le(J);if(U!=="object")return new x("Invalid "+R+" `"+q+"` of type `"+U+"` "+("supplied to `"+P+"`, expected `object`."));var z=t({},k[D],N);for(var W in z){var oe=N[W];if(o(N,W)&&typeof oe!="function")return Z(P,R,q,W,re(oe));if(!oe)return new x("Invalid "+R+" `"+q+"` key `"+W+"` supplied to `"+P+"`.\nBad object: "+JSON.stringify(k[D],null," ")+`
|
|
27
|
+
Valid keys: `+JSON.stringify(Object.keys(N),null," "));var A=oe(J,W,P,R,q+"."+W,n);if(A)return A}return null}return w(K)}function Q(N){switch(typeof N){case"number":case"string":case"undefined":return!0;case"boolean":return!N;case"object":if(Array.isArray(N))return N.every(Q);if(N===null||c(N))return!0;var K=h(N);if(K){var k=K.call(N),D;if(K!==N.entries){for(;!(D=k.next()).done;)if(!Q(D.value))return!1}else for(;!(D=k.next()).done;){var P=D.value;if(P&&!Q(P[1]))return!1}}else return!1;return!0;default:return!1}}function ue(N,K){return N==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function le(N){var K=typeof N;return Array.isArray(N)?"array":N instanceof RegExp?"object":ue(K,N)?"symbol":K}function re(N){if(typeof N>"u"||N===null)return""+N;var K=le(N);if(K==="object"){if(N instanceof Date)return"date";if(N instanceof RegExp)return"regexp"}return K}function Oe(N){var K=re(N);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function Ee(N){return!N.constructor||!N.constructor.name?v:N.constructor.name}return f.checkPropTypes=i,f.resetWarningCache=i.resetWarningCache,f.PropTypes=f,f},Zn}var Qn,No;function Nd(){if(No)return Qn;No=1;var e=Cr();function t(){}function n(){}return n.resetWarningCache=t,Qn=function(){function o(s,c,u,d,p,h){if(h!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}o.isRequired=o;function i(){return o}var r={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:i,element:o,elementType:o,instanceOf:i,node:o,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r},Qn}if(process.env.NODE_ENV!=="production"){var Rd=Ti(),Td=!0;sr.exports=Ed()(Rd.isElement,Td)}else sr.exports=Nd()();var Ad=sr.exports;const T=xr(Ad);var ar={exports:{}},ae={};/**
|
|
28
|
+
* @license React
|
|
29
|
+
* react-is.production.min.js
|
|
30
|
+
*
|
|
31
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the MIT license found in the
|
|
34
|
+
* LICENSE file in the root directory of this source tree.
|
|
35
|
+
*/var Ro;function jd(){if(Ro)return ae;Ro=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),s=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),g;g=Symbol.for("react.module.reference");function x(w){if(typeof w=="object"&&w!==null){var O=w.$$typeof;switch(O){case e:switch(w=w.type,w){case n:case i:case o:case d:case p:return w;default:switch(w=w&&w.$$typeof,w){case c:case s:case u:case v:case h:case r:return w;default:return O}}case t:return O}}}return ae.ContextConsumer=s,ae.ContextProvider=r,ae.Element=e,ae.ForwardRef=u,ae.Fragment=n,ae.Lazy=v,ae.Memo=h,ae.Portal=t,ae.Profiler=i,ae.StrictMode=o,ae.Suspense=d,ae.SuspenseList=p,ae.isAsyncMode=function(){return!1},ae.isConcurrentMode=function(){return!1},ae.isContextConsumer=function(w){return x(w)===s},ae.isContextProvider=function(w){return x(w)===r},ae.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},ae.isForwardRef=function(w){return x(w)===u},ae.isFragment=function(w){return x(w)===n},ae.isLazy=function(w){return x(w)===v},ae.isMemo=function(w){return x(w)===h},ae.isPortal=function(w){return x(w)===t},ae.isProfiler=function(w){return x(w)===i},ae.isStrictMode=function(w){return x(w)===o},ae.isSuspense=function(w){return x(w)===d},ae.isSuspenseList=function(w){return x(w)===p},ae.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===n||w===i||w===o||w===d||w===p||w===f||typeof w=="object"&&w!==null&&(w.$$typeof===v||w.$$typeof===h||w.$$typeof===r||w.$$typeof===s||w.$$typeof===u||w.$$typeof===g||w.getModuleId!==void 0)},ae.typeOf=x,ae}var ce={};/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-is.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/var To;function Pd(){return To||(To=1,process.env.NODE_ENV!=="production"&&function(){var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),s=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),g=!1,x=!1,w=!1,O=!1,I=!1,C;C=Symbol.for("react.module.reference");function b(L){return!!(typeof L=="string"||typeof L=="function"||L===n||L===i||I||L===o||L===d||L===p||O||L===f||g||x||w||typeof L=="object"&&L!==null&&(L.$$typeof===v||L.$$typeof===h||L.$$typeof===r||L.$$typeof===s||L.$$typeof===u||L.$$typeof===C||L.getModuleId!==void 0))}function m(L){if(typeof L=="object"&&L!==null){var Ne=L.$$typeof;switch(Ne){case e:var Re=L.type;switch(Re){case n:case i:case o:case d:case p:return Re;default:var Ge=Re&&Re.$$typeof;switch(Ge){case c:case s:case u:case v:case h:case r:return Ge;default:return Ne}}case t:return Ne}}}var j=s,$=r,F=e,V=u,B=n,Z=v,G=h,te=t,Q=i,ue=o,le=d,re=p,Oe=!1,Ee=!1;function N(L){return Oe||(Oe=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function K(L){return Ee||(Ee=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function k(L){return m(L)===s}function D(L){return m(L)===r}function P(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function R(L){return m(L)===u}function q(L){return m(L)===n}function J(L){return m(L)===v}function U(L){return m(L)===h}function z(L){return m(L)===t}function W(L){return m(L)===i}function oe(L){return m(L)===o}function A(L){return m(L)===d}function de(L){return m(L)===p}ce.ContextConsumer=j,ce.ContextProvider=$,ce.Element=F,ce.ForwardRef=V,ce.Fragment=B,ce.Lazy=Z,ce.Memo=G,ce.Portal=te,ce.Profiler=Q,ce.StrictMode=ue,ce.Suspense=le,ce.SuspenseList=re,ce.isAsyncMode=N,ce.isConcurrentMode=K,ce.isContextConsumer=k,ce.isContextProvider=D,ce.isElement=P,ce.isForwardRef=R,ce.isFragment=q,ce.isLazy=J,ce.isMemo=U,ce.isPortal=z,ce.isProfiler=W,ce.isStrictMode=oe,ce.isSuspense=A,ce.isSuspenseList=de,ce.isValidElementType=b,ce.typeOf=m}()),ce}process.env.NODE_ENV==="production"?ar.exports=jd():ar.exports=Pd();var Ao=ar.exports;const jo=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Po=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",er=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Po(n.overflowY,t)||Po(n.overflowX,t)||(o=>{const i=(r=>{if(!r.ownerDocument||!r.ownerDocument.defaultView)return null;try{return r.ownerDocument.defaultView.frameElement}catch{return null}})(o);return!!i&&(i.clientHeight<o.scrollHeight||i.clientWidth<o.scrollWidth)})(e)}return!1},fn=(e,t,n,o,i,r,s,c)=>r<e&&s>t||r>e&&s<t?0:r<=e&&c<=n||s>=t&&c>=n?r-e-o:s>t&&c<n||r<e&&c>n?s-t+i:0,Dd=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},kd=(e,t)=>{var n,o,i,r;if(typeof document>"u")return[];const{scrollMode:s,block:c,inline:u,boundary:d,skipOverflowHiddenElements:p}=t,h=typeof d=="function"?d:le=>le!==d;if(!jo(e))throw new TypeError("Invalid target");const v=document.scrollingElement||document.documentElement,f=[];let g=e;for(;jo(g)&&h(g);){if(g=Dd(g),g===v){f.push(g);break}g!=null&&g===document.body&&er(g)&&!er(document.documentElement)||g!=null&&er(g,p)&&f.push(g)}const x=(o=(n=window.visualViewport)==null?void 0:n.width)!=null?o:innerWidth,w=(r=(i=window.visualViewport)==null?void 0:i.height)!=null?r:innerHeight,{scrollX:O,scrollY:I}=window,{height:C,width:b,top:m,right:j,bottom:$,left:F}=e.getBoundingClientRect(),{top:V,right:B,bottom:Z,left:G}=(le=>{const re=window.getComputedStyle(le);return{top:parseFloat(re.scrollMarginTop)||0,right:parseFloat(re.scrollMarginRight)||0,bottom:parseFloat(re.scrollMarginBottom)||0,left:parseFloat(re.scrollMarginLeft)||0}})(e);let te=c==="start"||c==="nearest"?m-V:c==="end"?$+Z:m+C/2-V+Z,Q=u==="center"?F+b/2-G+B:u==="end"?j+B:F-G;const ue=[];for(let le=0;le<f.length;le++){const re=f[le],{height:Oe,width:Ee,top:N,right:K,bottom:k,left:D}=re.getBoundingClientRect();if(s==="if-needed"&&m>=0&&F>=0&&$<=w&&j<=x&&m>=N&&$<=k&&F>=D&&j<=K)return ue;const P=getComputedStyle(re),R=parseInt(P.borderLeftWidth,10),q=parseInt(P.borderTopWidth,10),J=parseInt(P.borderRightWidth,10),U=parseInt(P.borderBottomWidth,10);let z=0,W=0;const oe="offsetWidth"in re?re.offsetWidth-re.clientWidth-R-J:0,A="offsetHeight"in re?re.offsetHeight-re.clientHeight-q-U:0,de="offsetWidth"in re?re.offsetWidth===0?0:Ee/re.offsetWidth:0,L="offsetHeight"in re?re.offsetHeight===0?0:Oe/re.offsetHeight:0;if(v===re)z=c==="start"?te:c==="end"?te-w:c==="nearest"?fn(I,I+w,w,q,U,I+te,I+te+C,C):te-w/2,W=u==="start"?Q:u==="center"?Q-x/2:u==="end"?Q-x:fn(O,O+x,x,R,J,O+Q,O+Q+b,b),z=Math.max(0,z+I),W=Math.max(0,W+O);else{z=c==="start"?te-N-q:c==="end"?te-k+U+A:c==="nearest"?fn(N,k,Oe,q,U+A,te,te+C,C):te-(N+Oe/2)+A/2,W=u==="start"?Q-D-R:u==="center"?Q-(D+Ee/2)+oe/2:u==="end"?Q-K+J+oe:fn(D,K,Ee,R,J+oe,Q,Q+b,b);const{scrollLeft:Ne,scrollTop:Re}=re;z=L===0?0:Math.max(0,Math.min(Re+z/L,re.scrollHeight-Oe/L+A)),W=de===0?0:Math.max(0,Math.min(Ne+W/de,re.scrollWidth-Ee/de+oe)),te+=Re-z,Q+=Ne-W}ue.push({el:re,top:z,left:W})}return ue};var Rt=function(){return Rt=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Rt.apply(this,arguments)};var Fd=0;function Do(e){return typeof e=="function"?e:De}function De(){}function ji(e,t){if(e){var n=kd(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach(function(o){var i=o.el,r=o.top,s=o.left;i.scrollTop=r,i.scrollLeft=s})}}function ko(e,t,n){var o=e===t||t instanceof n.Node&&e.contains&&e.contains(t);return o}function Or(e,t){var n;function o(){n&&clearTimeout(n)}function i(){for(var r=arguments.length,s=new Array(r),c=0;c<r;c++)s[c]=arguments[c];o(),n=setTimeout(function(){n=null,e.apply(void 0,s)},t)}return i.cancel=o,i}function we(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(o){for(var i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];return t.some(function(c){return c&&c.apply(void 0,[o].concat(r)),o.preventDownshiftDefault||o.hasOwnProperty("nativeEvent")&&o.nativeEvent.preventDownshiftDefault})}}function Et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(o){t.forEach(function(i){typeof i=="function"?i(o):i&&(i.current=o)})}}function Pi(){return String(Fd++)}function Md(e){var t=e.isOpen,n=e.resultCount,o=e.previousResultCount;return t?n?n!==o?n+" result"+(n===1?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function Fo(e,t){return e=Array.isArray(e)?e[0]:e,!e&&t?t:e}function Di(e){return typeof e.type=="string"}function ki(e){return e.props}function Kd(e,t){console.error('The property "'+t+'" is required in "'+e+'"')}var Ld=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function hn(e){e===void 0&&(e={});var t={};return Ld.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}function _n(e,t){return!e||!t?e:Object.keys(e).reduce(function(n,o){return n[o]=bn(t,o)?t[o]:e[o],n},{})}function bn(e,t){return e[t]!==void 0}function cr(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf("Arrow")!==0?"Arrow"+t:t}function $d(e){return Object.prototype.toString.call(e)==="[object Object]"}function wt(e,t,n,o,i){var r=n.length;if(r===0)return-1;var s=r-1;(typeof e!="number"||e<0||e>s)&&(e=t>0?-1:s+1);var c=e+t;c<0?c=s:c>s&&(c=0);var u=Tt(c,t<0,n,o,i);return u===-1?e>=r?-1:e:u}function Tt(e,t,n,o,i){i===void 0&&(i=!1);var r=n.length;if(t){for(var s=e;s>=0;s--)if(!o(n[s],s))return s}else for(var c=e;c<r;c++)if(!o(n[c],c))return c;return i?Tt(t?r-1:0,t,n,o):-1}function Cn(e,t,n,o){return o===void 0&&(o=!0),n&&t.some(function(i){return i&&(ko(i,e,n)||o&&ko(i,n.document.activeElement,n))})}var Sr=De;process.env.NODE_ENV!=="production"&&(Sr=function(t,n,o){var i="This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props";Object.keys(t).forEach(function(r){n[r]!==void 0&&o[r]===void 0?console.error('downshift: A component has changed the controlled prop "'+r+'" to be uncontrolled. '+i):n[r]===void 0&&o[r]!==void 0&&console.error('downshift: A component has changed the uncontrolled prop "'+r+'" to be controlled. '+i)})});var Hd=Or(function(e){Fi(e).textContent=""},500);function Fi(e){var t=e.getElementById("a11y-status-message");return t||(t=e.createElement("div"),t.setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}function Mi(e,t){if(!(!e||!t)){var n=Fi(t);n.textContent=e,Hd(t)}}function Vd(e){var t=e==null?void 0:e.getElementById("a11y-status-message");t&&t.remove()}var Ki=process.env.NODE_ENV!=="production"?"__autocomplete_unknown__":0,Li=process.env.NODE_ENV!=="production"?"__autocomplete_mouseup__":1,$i=process.env.NODE_ENV!=="production"?"__autocomplete_item_mouseenter__":2,vn=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_up__":3,In=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_down__":4,Hi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_escape__":5,Vi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_enter__":6,Ui=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_home__":7,Bi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_end__":8,qi=process.env.NODE_ENV!=="production"?"__autocomplete_click_item__":9,Wi=process.env.NODE_ENV!=="production"?"__autocomplete_blur_input__":10,Ji=process.env.NODE_ENV!=="production"?"__autocomplete_change_input__":11,zi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_space_button__":12,ur=process.env.NODE_ENV!=="production"?"__autocomplete_click_button__":13,Xi=process.env.NODE_ENV!=="production"?"__autocomplete_blur_button__":14,Yi=process.env.NODE_ENV!=="production"?"__autocomplete_controlled_prop_updated_selected_item__":15,Gi=process.env.NODE_ENV!=="production"?"__autocomplete_touchend__":16,Ud=Object.freeze({__proto__:null,blurButton:Xi,blurInput:Wi,changeInput:Ji,clickButton:ur,clickItem:qi,controlledPropUpdatedSelectedItem:Yi,itemMouseEnter:$i,keyDownArrowDown:In,keyDownArrowUp:vn,keyDownEnd:Bi,keyDownEnter:Vi,keyDownEscape:Hi,keyDownHome:Ui,keyDownSpaceButton:zi,mouseUp:Li,touchEnd:Gi,unknown:Ki}),Bd=["refKey","ref"],qd=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],Wd=["onKeyDown","onBlur","onChange","onInput","onChangeText"],Jd=["refKey","ref"],zd=["onMouseMove","onMouseDown","onClick","onPress","index","item"],Xd=function(){var e=function(t){function n(i){var r;r=t.call(this,i)||this,r.id=r.props.id||"downshift-"+Pi(),r.menuId=r.props.menuId||r.id+"-menu",r.labelId=r.props.labelId||r.id+"-label",r.inputId=r.props.inputId||r.id+"-input",r.getItemId=r.props.getItemId||function(I){return r.id+"-item-"+I},r.items=[],r.itemCount=null,r.previousResultCount=0,r.timeoutIds=[],r.internalSetTimeout=function(I,C){var b=setTimeout(function(){r.timeoutIds=r.timeoutIds.filter(function(m){return m!==b}),I()},C);r.timeoutIds.push(b)},r.setItemCount=function(I){r.itemCount=I},r.unsetItemCount=function(){r.itemCount=null},r.isItemDisabled=function(I,C){var b=r.getItemNodeFromIndex(C);return b&&b.hasAttribute("disabled")},r.setHighlightedIndex=function(I,C){I===void 0&&(I=r.props.defaultHighlightedIndex),C===void 0&&(C={}),C=hn(C),r.internalSetState(ne({highlightedIndex:I},C))},r.clearSelection=function(I){r.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen},I)},r.selectItem=function(I,C,b){C=hn(C),r.internalSetState(ne({isOpen:r.props.defaultIsOpen,highlightedIndex:r.props.defaultHighlightedIndex,selectedItem:I,inputValue:r.props.itemToString(I)},C),b)},r.selectItemAtIndex=function(I,C,b){var m=r.items[I];m!=null&&r.selectItem(m,C,b)},r.selectHighlightedItem=function(I,C){return r.selectItemAtIndex(r.getState().highlightedIndex,I,C)},r.internalSetState=function(I,C){var b,m,j={},$=typeof I=="function";return!$&&I.hasOwnProperty("inputValue")&&r.props.onInputValueChange(I.inputValue,ne({},r.getStateAndHelpers(),I)),r.setState(function(F){var V;F=r.getState(F);var B=$?I(F):I;B=r.props.stateReducer(F,B),b=B.hasOwnProperty("selectedItem");var Z={};return b&&B.selectedItem!==F.selectedItem&&(m=B.selectedItem),(V=B).type||(V.type=Ki),Object.keys(B).forEach(function(G){F[G]!==B[G]&&(j[G]=B[G]),G!=="type"&&(B[G],bn(r.props,G)||(Z[G]=B[G]))}),$&&B.hasOwnProperty("inputValue")&&r.props.onInputValueChange(B.inputValue,ne({},r.getStateAndHelpers(),B)),Z},function(){Do(C)();var F=Object.keys(j).length>1;F&&r.props.onStateChange(j,r.getStateAndHelpers()),b&&r.props.onSelect(I.selectedItem,r.getStateAndHelpers()),m!==void 0&&r.props.onChange(m,r.getStateAndHelpers()),r.props.onUserAction(j,r.getStateAndHelpers())})},r.rootRef=function(I){return r._rootNode=I},r.getRootProps=function(I,C){var b,m=I===void 0?{}:I,j=m.refKey,$=j===void 0?"ref":j,F=m.ref,V=nt(m,Bd),B=C===void 0?{}:C,Z=B.suppressRefError,G=Z===void 0?!1:Z;r.getRootProps.called=!0,r.getRootProps.refKey=$,r.getRootProps.suppressRefError=G;var te=r.getState(),Q=te.isOpen;return ne((b={},b[$]=Et(F,r.rootRef),b.role="combobox",b["aria-expanded"]=Q,b["aria-haspopup"]="listbox",b["aria-owns"]=Q?r.menuId:void 0,b["aria-labelledby"]=r.labelId,b),V)},r.keyDownHandlers={ArrowDown:function(C){var b=this;if(C.preventDefault(),this.getState().isOpen){var m=C.shiftKey?5:1;this.moveHighlightedIndex(m,{type:In})}else this.internalSetState({isOpen:!0,type:In},function(){var j=b.getItemCount();if(j>0){var $=b.getState(),F=$.highlightedIndex,V=wt(F,1,{length:j},b.isItemDisabled,!0);b.setHighlightedIndex(V,{type:In})}})},ArrowUp:function(C){var b=this;if(C.preventDefault(),this.getState().isOpen){var m=C.shiftKey?-5:-1;this.moveHighlightedIndex(m,{type:vn})}else this.internalSetState({isOpen:!0,type:vn},function(){var j=b.getItemCount();if(j>0){var $=b.getState(),F=$.highlightedIndex,V=wt(F,-1,{length:j},b.isItemDisabled,!0);b.setHighlightedIndex(V,{type:vn})}})},Enter:function(C){if(C.which!==229){var b=this.getState(),m=b.isOpen,j=b.highlightedIndex;if(m&&j!=null){C.preventDefault();var $=this.items[j],F=this.getItemNodeFromIndex(j);if($==null||F&&F.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Vi})}}},Escape:function(C){C.preventDefault(),this.reset(ne({type:Hi},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},r.buttonKeyDownHandlers=ne({},r.keyDownHandlers,{" ":function(C){C.preventDefault(),this.toggleMenu({type:zi})}}),r.inputKeyDownHandlers=ne({},r.keyDownHandlers,{Home:function(C){var b=this.getState(),m=b.isOpen;if(m){C.preventDefault();var j=this.getItemCount();if(!(j<=0||!m)){var $=Tt(0,!1,{length:j},this.isItemDisabled);this.setHighlightedIndex($,{type:Ui})}}},End:function(C){var b=this.getState(),m=b.isOpen;if(m){C.preventDefault();var j=this.getItemCount();if(!(j<=0||!m)){var $=Tt(j-1,!0,{length:j},this.isItemDisabled);this.setHighlightedIndex($,{type:Bi})}}}}),r.getToggleButtonProps=function(I){var C=I===void 0?{}:I,b=C.onClick;C.onPress;var m=C.onKeyDown,j=C.onKeyUp,$=C.onBlur,F=nt(C,qd),V=r.getState(),B=V.isOpen,Z={onClick:we(b,r.buttonHandleClick),onKeyDown:we(m,r.buttonHandleKeyDown),onKeyUp:we(j,r.buttonHandleKeyUp),onBlur:we($,r.buttonHandleBlur)},G=F.disabled?{}:Z;return ne({type:"button",role:"button","aria-label":B?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},G,F)},r.buttonHandleKeyUp=function(I){I.preventDefault()},r.buttonHandleKeyDown=function(I){var C=cr(I);r.buttonKeyDownHandlers[C]&&r.buttonKeyDownHandlers[C].call(r,I)},r.buttonHandleClick=function(I){if(I.preventDefault(),r.props.environment){var C=r.props.environment.document,b=C.body,m=C.activeElement;b&&b===m&&I.target.focus()}process.env.NODE_ENV==="test"?r.toggleMenu({type:ur}):r.internalSetTimeout(function(){return r.toggleMenu({type:ur})})},r.buttonHandleBlur=function(I){var C=I.target;r.internalSetTimeout(function(){if(!(r.isMouseDown||!r.props.environment)){var b=r.props.environment.document.activeElement;(b==null||b.id!==r.inputId)&&b!==C&&r.reset({type:Xi})}})},r.getLabelProps=function(I){return ne({htmlFor:r.inputId,id:r.labelId},I)},r.getInputProps=function(I){var C=I===void 0?{}:I,b=C.onKeyDown,m=C.onBlur,j=C.onChange,$=C.onInput;C.onChangeText;var F=nt(C,Wd),V,B={};V="onChange";var Z=r.getState(),G=Z.inputValue,te=Z.isOpen,Q=Z.highlightedIndex;if(!F.disabled){var ue;B=(ue={},ue[V]=we(j,$,r.inputHandleChange),ue.onKeyDown=we(b,r.inputHandleKeyDown),ue.onBlur=we(m,r.inputHandleBlur),ue)}return ne({"aria-autocomplete":"list","aria-activedescendant":te&&typeof Q=="number"&&Q>=0?r.getItemId(Q):void 0,"aria-controls":te?r.menuId:void 0,"aria-labelledby":F&&F["aria-label"]?void 0:r.labelId,autoComplete:"off",value:G,id:r.inputId},B,F)},r.inputHandleKeyDown=function(I){var C=cr(I);C&&r.inputKeyDownHandlers[C]&&r.inputKeyDownHandlers[C].call(r,I)},r.inputHandleChange=function(I){r.internalSetState({type:Ji,isOpen:!0,inputValue:I.target.value,highlightedIndex:r.props.defaultHighlightedIndex})},r.inputHandleBlur=function(){r.internalSetTimeout(function(){var I;if(!(r.isMouseDown||!r.props.environment)){var C=r.props.environment.document.activeElement,b=(C==null||(I=C.dataset)==null?void 0:I.toggle)&&r._rootNode&&r._rootNode.contains(C);b||r.reset({type:Wi})}})},r.menuRef=function(I){r._menuNode=I},r.getMenuProps=function(I,C){var b,m=I===void 0?{}:I,j=m.refKey,$=j===void 0?"ref":j,F=m.ref,V=nt(m,Jd),B=C===void 0?{}:C,Z=B.suppressRefError,G=Z===void 0?!1:Z;return r.getMenuProps.called=!0,r.getMenuProps.refKey=$,r.getMenuProps.suppressRefError=G,ne((b={},b[$]=Et(F,r.menuRef),b.role="listbox",b["aria-labelledby"]=V&&V["aria-label"]?void 0:r.labelId,b.id=r.menuId,b),V)},r.getItemProps=function(I){var C,b=I===void 0?{}:I,m=b.onMouseMove,j=b.onMouseDown,$=b.onClick;b.onPress;var F=b.index,V=b.item,B=V===void 0?process.env.NODE_ENV==="production"?void 0:Kd("getItemProps","item"):V,Z=nt(b,zd);F===void 0?(r.items.push(B),F=r.items.indexOf(B)):r.items[F]=B;var G="onClick",te=$,Q=(C={onMouseMove:we(m,function(){F!==r.getState().highlightedIndex&&(r.setHighlightedIndex(F,{type:$i}),r.avoidScrolling=!0,r.internalSetTimeout(function(){return r.avoidScrolling=!1},250))}),onMouseDown:we(j,function(le){le.preventDefault()})},C[G]=we(te,function(){r.selectItemAtIndex(F,{type:qi})}),C),ue=Z.disabled?{onMouseDown:Q.onMouseDown}:Q;return ne({id:r.getItemId(F),role:"option","aria-selected":r.getState().highlightedIndex===F},ue,Z)},r.clearItems=function(){r.items=[]},r.reset=function(I,C){I===void 0&&(I={}),I=hn(I),r.internalSetState(function(b){var m=b.selectedItem;return ne({isOpen:r.props.defaultIsOpen,highlightedIndex:r.props.defaultHighlightedIndex,inputValue:r.props.itemToString(m)},I)},C)},r.toggleMenu=function(I,C){I===void 0&&(I={}),I=hn(I),r.internalSetState(function(b){var m=b.isOpen;return ne({isOpen:!m},m&&{highlightedIndex:r.props.defaultHighlightedIndex},I)},function(){var b=r.getState(),m=b.isOpen,j=b.highlightedIndex;m&&r.getItemCount()>0&&typeof j=="number"&&r.setHighlightedIndex(j,I),Do(C)()})},r.openMenu=function(I){r.internalSetState({isOpen:!0},I)},r.closeMenu=function(I){r.internalSetState({isOpen:!1},I)},r.updateStatus=Or(function(){var I;if((I=r.props)!=null&&(I=I.environment)!=null&&I.document){var C=r.getState(),b=r.items[C.highlightedIndex],m=r.getItemCount(),j=r.props.getA11yStatusMessage(ne({itemToString:r.props.itemToString,previousResultCount:r.previousResultCount,resultCount:m,highlightedItem:b},C));r.previousResultCount=m,Mi(j,r.props.environment.document)}},200);var s=r.props,c=s.defaultHighlightedIndex,u=s.initialHighlightedIndex,d=u===void 0?c:u,p=s.defaultIsOpen,h=s.initialIsOpen,v=h===void 0?p:h,f=s.initialInputValue,g=f===void 0?"":f,x=s.initialSelectedItem,w=x===void 0?null:x,O=r.getState({highlightedIndex:d,isOpen:v,inputValue:g,selectedItem:w});return O.selectedItem!=null&&r.props.initialInputValue===void 0&&(O.inputValue=r.props.itemToString(O.selectedItem)),r.state=O,r}_d(n,t);var o=n.prototype;return o.internalClearTimeouts=function(){this.timeoutIds.forEach(function(r){clearTimeout(r)}),this.timeoutIds=[]},o.getState=function(r){return r===void 0&&(r=this.state),_n(r,this.props)},o.getItemCount=function(){var r=this.items.length;return this.itemCount!=null?r=this.itemCount:this.props.itemCount!==void 0&&(r=this.props.itemCount),r},o.getItemNodeFromIndex=function(r){return this.props.environment?this.props.environment.document.getElementById(this.getItemId(r)):null},o.scrollHighlightedItemIntoView=function(){{var r=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(r,this._menuNode)}},o.moveHighlightedIndex=function(r,s){var c=this.getItemCount(),u=this.getState(),d=u.highlightedIndex;if(c>0){var p=wt(d,r,{length:c},this.isItemDisabled,!0);this.setHighlightedIndex(p,s)}},o.getStateAndHelpers=function(){var r=this.getState(),s=r.highlightedIndex,c=r.inputValue,u=r.selectedItem,d=r.isOpen,p=this.props.itemToString,h=this.id,v=this.getRootProps,f=this.getToggleButtonProps,g=this.getLabelProps,x=this.getMenuProps,w=this.getInputProps,O=this.getItemProps,I=this.openMenu,C=this.closeMenu,b=this.toggleMenu,m=this.selectItem,j=this.selectItemAtIndex,$=this.selectHighlightedItem,F=this.setHighlightedIndex,V=this.clearSelection,B=this.clearItems,Z=this.reset,G=this.setItemCount,te=this.unsetItemCount,Q=this.internalSetState;return{getRootProps:v,getToggleButtonProps:f,getLabelProps:g,getMenuProps:x,getInputProps:w,getItemProps:O,reset:Z,openMenu:I,closeMenu:C,toggleMenu:b,selectItem:m,selectItemAtIndex:j,selectHighlightedItem:$,setHighlightedIndex:F,clearSelection:V,clearItems:B,setItemCount:G,unsetItemCount:te,setState:Q,itemToString:p,id:h,highlightedIndex:s,inputValue:c,isOpen:d,selectedItem:u}},o.componentDidMount=function(){var r=this;if(process.env.NODE_ENV!=="production"&&this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&Mo(this._menuNode,this.getMenuProps),!this.props.environment)this.cleanup=function(){r.internalClearTimeouts()};else{var s=function(){r.isMouseDown=!0},c=function(f){r.isMouseDown=!1;var g=Cn(f.target,[r._rootNode,r._menuNode],r.props.environment);!g&&r.getState().isOpen&&r.reset({type:Li},function(){return r.props.onOuterClick(r.getStateAndHelpers())})},u=function(){r.isTouchMove=!1},d=function(){r.isTouchMove=!0},p=function(f){var g=Cn(f.target,[r._rootNode,r._menuNode],r.props.environment,!1);!r.isTouchMove&&!g&&r.getState().isOpen&&r.reset({type:Gi},function(){return r.props.onOuterClick(r.getStateAndHelpers())})},h=this.props.environment;h.addEventListener("mousedown",s),h.addEventListener("mouseup",c),h.addEventListener("touchstart",u),h.addEventListener("touchmove",d),h.addEventListener("touchend",p),this.cleanup=function(){r.internalClearTimeouts(),r.updateStatus.cancel(),h.removeEventListener("mousedown",s),h.removeEventListener("mouseup",c),h.removeEventListener("touchstart",u),h.removeEventListener("touchmove",d),h.removeEventListener("touchend",p)}}},o.shouldScroll=function(r,s){var c=this.props.highlightedIndex===void 0?this.getState():this.props,u=c.highlightedIndex,d=s.highlightedIndex===void 0?r:s,p=d.highlightedIndex,h=u&&this.getState().isOpen&&!r.isOpen,v=u!==p;return h||v},o.componentDidUpdate=function(r,s){process.env.NODE_ENV!=="production"&&(Sr(this.state,r,this.props),this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&Mo(this._menuNode,this.getMenuProps)),bn(this.props,"selectedItem")&&this.props.selectedItemChanged(r.selectedItem,this.props.selectedItem)&&this.internalSetState({type:Yi,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(s,r)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},o.componentWillUnmount=function(){this.cleanup()},o.render=function(){var r=Fo(this.props.children,De);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var s=Fo(r(this.getStateAndHelpers()));if(!s)return null;if(this.getRootProps.called||this.props.suppressRefError)return process.env.NODE_ENV!=="production"&&!this.getRootProps.suppressRefError&&!this.props.suppressRefError&&Yd(s,this.getRootProps),s;if(Di(s))return y.cloneElement(s,this.getRootProps(ki(s)));if(process.env.NODE_ENV!=="production")throw new Error("downshift: If you return a non-DOM element, you must apply the getRootProps function")},n}(y.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:Md,itemToString:function(n){return n==null?"":(process.env.NODE_ENV!=="production"&&$d(n)&&!n.hasOwnProperty("toString")&&console.warn("downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.","The object that was passed:",n),String(n))},onStateChange:De,onInputValueChange:De,onUserAction:De,onChange:De,onSelect:De,onOuterClick:De,selectedItemChanged:function(n,o){return n!==o},environment:typeof window>"u"?void 0:window,stateReducer:function(n,o){return o},suppressRefError:!1,scrollIntoView:ji},e.stateChangeTypes=Ud,e}();process.env.NODE_ENV!=="production"&&(Xd.propTypes={children:T.func,defaultHighlightedIndex:T.number,defaultIsOpen:T.bool,initialHighlightedIndex:T.number,initialSelectedItem:T.any,initialInputValue:T.string,initialIsOpen:T.bool,getA11yStatusMessage:T.func,itemToString:T.func,onChange:T.func,onSelect:T.func,onStateChange:T.func,onInputValueChange:T.func,onUserAction:T.func,onOuterClick:T.func,selectedItemChanged:T.func,stateReducer:T.func,itemCount:T.number,id:T.string,environment:T.shape({addEventListener:T.func.isRequired,removeEventListener:T.func.isRequired,document:T.shape({createElement:T.func.isRequired,getElementById:T.func.isRequired,activeElement:T.any.isRequired,body:T.any.isRequired}).isRequired,Node:T.func.isRequired}),suppressRefError:T.bool,scrollIntoView:T.func,selectedItem:T.any,isOpen:T.bool,inputValue:T.string,highlightedIndex:T.number,labelId:T.string,inputId:T.string,menuId:T.string,getItemId:T.func});function Mo(e,t){var n=t.refKey;e||console.error('downshift: The ref prop "'+n+'" from getMenuProps was not applied correctly on your menu element.')}function Yd(e,t){var n=t.refKey,o=n!=="ref",i=!Di(e);i&&!o&&!Ao.isForwardRef(e)?console.error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps"):!i&&o&&console.error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"'),!Ao.isForwardRef(e)&&!ki(e)[n]&&console.error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}var Zi={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function Gd(e,t,n){var o=e.props,i=e.type,r={};Object.keys(t).forEach(function(s){Zd(s,e,t,n),n[s]!==t[s]&&(r[s]=n[s])}),o.onStateChange&&Object.keys(r).length&&o.onStateChange(ne({type:i},r))}function Zd(e,t,n,o){var i=t.props,r=t.type,s="on"+Er(e)+"Change";i[s]&&o[e]!==void 0&&o[e]!==n[e]&&i[s](ne({type:r},o))}function Qd(e,t){return t.changes}var Ko=Or(function(e,t){Mi(e,t)},200),ep=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?y.useLayoutEffect:y.useEffect,tp="useId"in y?function(t){var n=t.id,o=t.labelId,i=t.menuId,r=t.getItemId,s=t.toggleButtonId,c=t.inputId,u="downshift-"+y.useId();n||(n=u);var d=y.useRef({labelId:o||n+"-label",menuId:i||n+"-menu",getItemId:r||function(p){return n+"-item-"+p},toggleButtonId:s||n+"-toggle-button",inputId:c||n+"-input"});return d.current}:function(t){var n=t.id,o=n===void 0?"downshift-"+Pi():n,i=t.labelId,r=t.menuId,s=t.getItemId,c=t.toggleButtonId,u=t.inputId,d=y.useRef({labelId:i||o+"-label",menuId:r||o+"-menu",getItemId:s||function(p){return o+"-item-"+p},toggleButtonId:c||o+"-toggle-button",inputId:u||o+"-input"});return d.current};function np(e,t,n,o){var i,r;if(e===void 0){if(t===void 0)throw new Error(o);i=n[t],r=t}else r=t===void 0?n.indexOf(e):t,i=e;return[i,r]}function Er(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function Qi(e){var t=y.useRef(e);return t.current=e,t}function rp(e,t,n,o){var i=y.useRef(),r=y.useRef(),s=y.useCallback(function(f,g){r.current=g,f=_n(f,g.props);var x=e(f,g),w=g.props.stateReducer(f,ne({},g,{changes:x}));return w},[e]),c=y.useReducer(s,t,n),u=c[0],d=c[1],p=Qi(t),h=y.useCallback(function(f){return d(ne({props:p.current},f))},[p]),v=r.current;return y.useEffect(function(){var f=_n(i.current,v==null?void 0:v.props),g=v&&i.current&&!o(f,u);g&&Gd(v,f,u),i.current=u},[u,v,o]),[u,h]}var qt={itemToString:function(t){return t?String(t):""},itemToKey:function(t){return t},stateReducer:Qd,scrollIntoView:ji,environment:typeof window>"u"?void 0:window};function ut(e,t,n){n===void 0&&(n=Zi);var o=e["default"+Er(t)];return o!==void 0?o:n[t]}function Wt(e,t,n){n===void 0&&(n=Zi);var o=e[t];if(o!==void 0)return o;var i=e["initial"+Er(t)];return i!==void 0?i:ut(e,t,n)}function op(e){var t=Wt(e,"selectedItem"),n=Wt(e,"isOpen"),o=up(e),i=Wt(e,"inputValue");return{highlightedIndex:o<0&&t&&n?e.items.findIndex(function(r){return e.itemToKey(r)===e.itemToKey(t)}):o,isOpen:n,selectedItem:t,inputValue:i}}function Jt(e,t,n){var o=e.items,i=e.initialHighlightedIndex,r=e.defaultHighlightedIndex,s=e.isItemDisabled,c=e.itemToKey,u=t.selectedItem,d=t.highlightedIndex;return o.length===0?-1:i!==void 0&&d===i&&!s(o[i],i)?i:r!==void 0&&!s(o[r],r)?r:u?o.findIndex(function(p){return c(u)===c(p)}):n<0&&!s(o[o.length-1],o.length-1)?o.length-1:n>0&&!s(o[0],0)?0:-1}function ip(e,t,n){var o=y.useRef({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return y.useEffect(function(){if(!e)return De;var i=n.map(function(p){return p.current});function r(){o.current.isTouchEnd=!1,o.current.isMouseDown=!0}function s(p){o.current.isMouseDown=!1,Cn(p.target,i,e)||t()}function c(){o.current.isTouchEnd=!1,o.current.isTouchMove=!1}function u(){o.current.isTouchMove=!0}function d(p){o.current.isTouchEnd=!0,!o.current.isTouchMove&&!Cn(p.target,i,e,!1)&&t()}return e.addEventListener("mousedown",r),e.addEventListener("mouseup",s),e.addEventListener("touchstart",c),e.addEventListener("touchmove",u),e.addEventListener("touchend",d),function(){e.removeEventListener("mousedown",r),e.removeEventListener("mouseup",s),e.removeEventListener("touchstart",c),e.removeEventListener("touchmove",u),e.removeEventListener("touchend",d)}},[n,e,t]),o.current}var es=function(){return De};process.env.NODE_ENV!=="production"&&(es=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=y.useRef(n.reduce(function(s,c){return s[c]={},s},{}));y.useEffect(function(){Object.keys(i.current).forEach(function(s){var c=i.current[s];if(!Object.keys(c).length){console.error("downshift: You forgot to call the "+s+" getter function on your component / element.");return}var u=c.suppressRefError,d=c.refKey,p=c.elementRef;u||p!=null&&p.current||console.error('downshift: The ref prop "'+d+'" from '+s+" was not applied correctly on your element.")})},[]);var r=y.useCallback(function(s,c,u,d){i.current[s]={suppressRefError:c,refKey:u,elementRef:d}},[]);return r});function sp(e,t,n,o){o===void 0&&(o={});var i=o.document,r=Pn();y.useEffect(function(){if(!(!e||r||!i)){var s=e(t);Ko(s,i)}},n),y.useEffect(function(){return function(){Ko.cancel(),Vd(i)}},[i])}function ap(e){var t=e.highlightedIndex,n=e.isOpen,o=e.itemRefs,i=e.getItemNodeFromIndex,r=e.menuElement,s=e.scrollIntoView,c=y.useRef(!0);return ep(function(){t<0||!n||!Object.keys(o.current).length||(c.current===!1?c.current=!0:s(i(t),r))},[t]),c}var ts=De;process.env.NODE_ENV!=="production"&&(ts=function(t){var n=t.props,o=t.state,i=y.useRef(n),r=Pn();y.useEffect(function(){r||(Sr(o,i.current,n),i.current=n)},[o,n,r])});function Lo(e,t,n){var o;n===void 0&&(n=!0);var i=((o=e.items)==null?void 0:o.length)&&t>=0;return ne({isOpen:!1,highlightedIndex:-1},i&&ne({selectedItem:e.items[t],isOpen:ut(e,"isOpen"),highlightedIndex:ut(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function cp(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function Pn(){var e=y.useRef(!0);return y.useEffect(function(){return e.current=!1,function(){e.current=!0}},[]),e.current}function lr(e){var t=ut(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}function up(e){var t=Wt(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var wn={environment:T.shape({addEventListener:T.func.isRequired,removeEventListener:T.func.isRequired,document:T.shape({createElement:T.func.isRequired,getElementById:T.func.isRequired,activeElement:T.any.isRequired,body:T.any.isRequired}).isRequired,Node:T.func.isRequired}),itemToString:T.func,itemToKey:T.func,stateReducer:T.func},ns=ne({},wn,{getA11yStatusMessage:T.func,highlightedIndex:T.number,defaultHighlightedIndex:T.number,initialHighlightedIndex:T.number,isOpen:T.bool,defaultIsOpen:T.bool,initialIsOpen:T.bool,selectedItem:T.any,initialSelectedItem:T.any,defaultSelectedItem:T.any,id:T.string,labelId:T.string,menuId:T.string,getItemId:T.func,toggleButtonId:T.string,onSelectedItemChange:T.func,onHighlightedIndexChange:T.func,onStateChange:T.func,onIsOpenChange:T.func,scrollIntoView:T.func});function lp(e,t,n){var o=t.type,i=t.props,r;switch(o){case n.ItemMouseMove:r={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:r={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Jt(i,e,0)};break;case n.FunctionOpenMenu:r={isOpen:!0,highlightedIndex:Jt(i,e,0)};break;case n.FunctionCloseMenu:r={isOpen:!1};break;case n.FunctionSetHighlightedIndex:r={highlightedIndex:i.isItemDisabled(i.items[t.highlightedIndex],t.highlightedIndex)?-1:t.highlightedIndex};break;case n.FunctionSetInputValue:r={inputValue:t.inputValue};break;case n.FunctionReset:r={highlightedIndex:lr(i),isOpen:ut(i,"isOpen"),selectedItem:ut(i,"selectedItem"),inputValue:ut(i,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return ne({},e,r)}Rt(Rt({},ns),{items:T.array.isRequired,isItemDisabled:T.func});Rt(Rt({},qt),{isItemDisabled:function(){return!1}});process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;var Nr=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_down__":0,Rr=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_up__":1,Tr=process.env.NODE_ENV!=="production"?"__input_keydown_escape__":2,Ar=process.env.NODE_ENV!=="production"?"__input_keydown_home__":3,jr=process.env.NODE_ENV!=="production"?"__input_keydown_end__":4,Pr=process.env.NODE_ENV!=="production"?"__input_keydown_page_up__":5,Dr=process.env.NODE_ENV!=="production"?"__input_keydown_page_down__":6,kr=process.env.NODE_ENV!=="production"?"__input_keydown_enter__":7,Fr=process.env.NODE_ENV!=="production"?"__input_change__":8,On=process.env.NODE_ENV!=="production"?"__input_blur__":9,Mr=process.env.NODE_ENV!=="production"?"__input_click__":10,rs=process.env.NODE_ENV!=="production"?"__menu_mouse_leave__":11,os=process.env.NODE_ENV!=="production"?"__item_mouse_move__":12,Kr=process.env.NODE_ENV!=="production"?"__item_click__":13,is=process.env.NODE_ENV!=="production"?"__togglebutton_click__":14,ss=process.env.NODE_ENV!=="production"?"__function_toggle_menu__":15,as=process.env.NODE_ENV!=="production"?"__function_open_menu__":16,cs=process.env.NODE_ENV!=="production"?"__function_close_menu__":17,us=process.env.NODE_ENV!=="production"?"__function_set_highlighted_index__":18,Lr=process.env.NODE_ENV!=="production"?"__function_select_item__":19,ls=process.env.NODE_ENV!=="production"?"__function_set_input_value__":20,ds=process.env.NODE_ENV!=="production"?"__function_reset__":21,$r=process.env.NODE_ENV!=="production"?"__controlled_prop_updated_selected_item__":22,ps=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:$r,FunctionCloseMenu:cs,FunctionOpenMenu:as,FunctionReset:ds,FunctionSelectItem:Lr,FunctionSetHighlightedIndex:us,FunctionSetInputValue:ls,FunctionToggleMenu:ss,InputBlur:On,InputChange:Fr,InputClick:Mr,InputKeyDownArrowDown:Nr,InputKeyDownArrowUp:Rr,InputKeyDownEnd:jr,InputKeyDownEnter:kr,InputKeyDownEscape:Tr,InputKeyDownHome:Ar,InputKeyDownPageDown:Dr,InputKeyDownPageUp:Pr,ItemClick:Kr,ItemMouseMove:os,MenuMouseLeave:rs,ToggleButtonClick:is});function dp(e){var t=op(e),n=t.selectedItem,o=t.inputValue;return o===""&&n&&e.defaultInputValue===void 0&&e.initialInputValue===void 0&&e.inputValue===void 0&&(o=e.itemToString(n)),ne({},t,{inputValue:o})}var pp=ne({},ns,{items:T.array.isRequired,isItemDisabled:T.func,inputValue:T.string,defaultInputValue:T.string,initialInputValue:T.string,inputId:T.string,onInputValueChange:T.func});function fp(e,t,n,o){var i=y.useRef(),r=rp(e,t,n,o),s=r[0],c=r[1],u=Pn();return y.useEffect(function(){if(bn(t,"selectedItem")){if(!u){var d=t.itemToKey(t.selectedItem)!==t.itemToKey(i.current);d&&c({type:$r,inputValue:t.itemToString(t.selectedItem)})}i.current=s.selectedItem===i.current?t.selectedItem:s.selectedItem}},[s.selectedItem,t.selectedItem]),[_n(s,t),c]}var fs=De;process.env.NODE_ENV!=="production"&&(fs=function(t,n){T.checkPropTypes(pp,t,"prop",n.name)});var hp=ne({},qt,{isItemDisabled:function(){return!1}});function mp(e,t){var n,o=t.type,i=t.props,r=t.altKey,s;switch(o){case Kr:s={isOpen:ut(i,"isOpen"),highlightedIndex:lr(i),selectedItem:i.items[t.index],inputValue:i.itemToString(i.items[t.index])};break;case Nr:e.isOpen?s={highlightedIndex:wt(e.highlightedIndex,1,i.items,i.isItemDisabled,!0)}:s={highlightedIndex:r&&e.selectedItem==null?-1:Jt(i,e,1),isOpen:i.items.length>=0};break;case Rr:e.isOpen?r?s=Lo(i,e.highlightedIndex):s={highlightedIndex:wt(e.highlightedIndex,-1,i.items,i.isItemDisabled,!0)}:s={highlightedIndex:Jt(i,e,-1),isOpen:i.items.length>=0};break;case kr:s=Lo(i,e.highlightedIndex);break;case Tr:s=ne({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case Pr:s={highlightedIndex:wt(e.highlightedIndex,-10,i.items,i.isItemDisabled,!0)};break;case Dr:s={highlightedIndex:wt(e.highlightedIndex,10,i.items,i.isItemDisabled,!0)};break;case Ar:s={highlightedIndex:Tt(0,!1,i.items,i.isItemDisabled)};break;case jr:s={highlightedIndex:Tt(i.items.length-1,!0,i.items,i.isItemDisabled)};break;case On:s=ne({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&((n=i.items)==null?void 0:n.length)&&t.selectItem&&{selectedItem:i.items[e.highlightedIndex],inputValue:i.itemToString(i.items[e.highlightedIndex])});break;case Fr:s={isOpen:!0,highlightedIndex:lr(i),inputValue:t.inputValue};break;case Mr:s={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Jt(i,e,0)};break;case Lr:s={selectedItem:t.selectedItem,inputValue:i.itemToString(t.selectedItem)};break;case $r:s={inputValue:t.inputValue};break;default:return lp(e,t,ps)}return ne({},e,s)}var gp=["onMouseLeave","refKey","ref"],yp=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],vp=["onClick","onPress","refKey","ref"],Ip=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];Hr.stateChangeTypes=ps;function Hr(e){e===void 0&&(e={}),fs(e,Hr);var t=ne({},hp,e),n=t.items,o=t.scrollIntoView,i=t.environment,r=t.getA11yStatusMessage,s=fp(mp,t,dp,cp),c=s[0],u=s[1],d=c.isOpen,p=c.highlightedIndex,h=c.selectedItem,v=c.inputValue,f=y.useRef(null),g=y.useRef({}),x=y.useRef(null),w=y.useRef(null),O=Pn(),I=tp(t),C=y.useRef(),b=Qi({state:c,props:t}),m=y.useCallback(function(k){return g.current[I.getItemId(k)]},[I]);sp(r,c,[d,p,h,v],i);var j=ap({menuElement:f.current,highlightedIndex:p,isOpen:d,itemRefs:g,scrollIntoView:o,getItemNodeFromIndex:m});ts({props:t,state:c}),y.useEffect(function(){var k=Wt(t,"isOpen");k&&x.current&&x.current.focus()},[]),y.useEffect(function(){O||(C.current=n.length)});var $=ip(i,y.useCallback(function(){b.current.state.isOpen&&u({type:On,selectItem:!1})},[u,b]),y.useMemo(function(){return[f,w,x]},[f.current,w.current,x.current])),F=es("getInputProps","getMenuProps");y.useEffect(function(){d||(g.current={})},[d]),y.useEffect(function(){var k;!d||!(i!=null&&i.document)||!(x!=null&&(k=x.current)!=null&&k.focus)||i.document.activeElement!==x.current&&x.current.focus()},[d,i]);var V=y.useMemo(function(){return{ArrowDown:function(D){D.preventDefault(),u({type:Nr,altKey:D.altKey})},ArrowUp:function(D){D.preventDefault(),u({type:Rr,altKey:D.altKey})},Home:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:Ar}))},End:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:jr}))},Escape:function(D){var P=b.current.state;(P.isOpen||P.inputValue||P.selectedItem||P.highlightedIndex>-1)&&(D.preventDefault(),u({type:Tr}))},Enter:function(D){var P=b.current.state;!P.isOpen||D.which===229||(D.preventDefault(),u({type:kr}))},PageUp:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:Pr}))},PageDown:function(D){b.current.state.isOpen&&(D.preventDefault(),u({type:Dr}))}}},[u,b]),B=y.useCallback(function(k){return ne({id:I.labelId,htmlFor:I.inputId},k)},[I]),Z=y.useCallback(function(k,D){var P,R=k===void 0?{}:k,q=R.onMouseLeave,J=R.refKey,U=J===void 0?"ref":J,z=R.ref,W=nt(R,gp),oe=D===void 0?{}:D,A=oe.suppressRefError,de=A===void 0?!1:A;return F("getMenuProps",de,U,f),ne((P={},P[U]=Et(z,function(L){f.current=L}),P.id=I.menuId,P.role="listbox",P["aria-labelledby"]=W&&W["aria-label"]?void 0:""+I.labelId,P.onMouseLeave=we(q,function(){u({type:rs})}),P),W)},[u,F,I]),G=y.useCallback(function(k){var D,P,R=k===void 0?{}:k,q=R.item,J=R.index,U=R.refKey,z=U===void 0?"ref":U,W=R.ref,oe=R.onMouseMove,A=R.onMouseDown,de=R.onClick;R.onPress;var L=R.disabled,Ne=nt(R,yp);L!==void 0&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var Re=b.current,Ge=Re.props,Ve=Re.state,Ct=np(q,J,Ge.items,"Pass either item or index to getItemProps!"),Mt=Ct[0],Ue=Ct[1],ft=Ge.isItemDisabled(Mt,Ue),Kt="onClick",Ot=de,We=function(){$.isTouchEnd||Ue===Ve.highlightedIndex||(j.current=!1,u({type:os,index:Ue,disabled:ft}))},Ze=function(){u({type:Kr,index:Ue})},je=function(en){return en.preventDefault()};return ne((D={},D[z]=Et(W,function(Te){Te&&(g.current[I.getItemId(Ue)]=Te)}),D["aria-disabled"]=ft,D["aria-selected"]=Ue===Ve.highlightedIndex,D.id=I.getItemId(Ue),D.role="option",D),!ft&&(P={},P[Kt]=we(Ot,Ze),P),{onMouseMove:we(oe,We),onMouseDown:we(A,je)},Ne)},[u,I,b,$,j]),te=y.useCallback(function(k){var D,P=k===void 0?{}:k,R=P.onClick;P.onPress;var q=P.refKey,J=q===void 0?"ref":q,U=P.ref,z=nt(P,vp),W=b.current.state,oe=function(){u({type:is})};return ne((D={},D[J]=Et(U,function(A){w.current=A}),D["aria-controls"]=I.menuId,D["aria-expanded"]=W.isOpen,D.id=I.toggleButtonId,D.tabIndex=-1,D),!z.disabled&&ne({},{onClick:we(R,oe)}),z)},[u,b,I]),Q=y.useCallback(function(k,D){var P,R=k===void 0?{}:k,q=R.onKeyDown,J=R.onChange,U=R.onInput,z=R.onBlur;R.onChangeText;var W=R.onClick,oe=R.refKey,A=oe===void 0?"ref":oe,de=R.ref,L=nt(R,Ip),Ne=D===void 0?{}:D,Re=Ne.suppressRefError,Ge=Re===void 0?!1:Re;F("getInputProps",Ge,A,x);var Ve=b.current.state,Ct=function(je){var Te=cr(je);Te&&V[Te]&&V[Te](je)},Mt=function(je){u({type:Fr,inputValue:je.target.value})},Ue=function(je){if(i!=null&&i.document&&Ve.isOpen&&!$.isMouseDown){var Te=je.relatedTarget===null&&i.document.activeElement!==i.document.body;u({type:On,selectItem:!Te})}},ft=function(){u({type:Mr})},Kt="onChange",Ot={};if(!L.disabled){var We;Ot=(We={},We[Kt]=we(J,U,Mt),We.onKeyDown=we(q,Ct),We.onBlur=we(z,Ue),We.onClick=we(W,ft),We)}return ne((P={},P[A]=Et(de,function(Ze){x.current=Ze}),P["aria-activedescendant"]=Ve.isOpen&&Ve.highlightedIndex>-1?I.getItemId(Ve.highlightedIndex):"",P["aria-autocomplete"]="list",P["aria-controls"]=I.menuId,P["aria-expanded"]=Ve.isOpen,P["aria-labelledby"]=L&&L["aria-label"]?void 0:I.labelId,P.autoComplete="off",P.id=I.inputId,P.role="combobox",P.value=Ve.inputValue,P),Ot,L)},[u,I,i,V,b,$,F]),ue=y.useCallback(function(){u({type:ss})},[u]),le=y.useCallback(function(){u({type:cs})},[u]),re=y.useCallback(function(){u({type:as})},[u]),Oe=y.useCallback(function(k){u({type:us,highlightedIndex:k})},[u]),Ee=y.useCallback(function(k){u({type:Lr,selectedItem:k})},[u]),N=y.useCallback(function(k){u({type:ls,inputValue:k})},[u]),K=y.useCallback(function(){u({type:ds})},[u]);return{getItemProps:G,getLabelProps:B,getMenuProps:Z,getInputProps:Q,getToggleButtonProps:te,toggleMenu:ue,openMenu:re,closeMenu:le,setHighlightedIndex:Oe,setInputValue:N,selectItem:Ee,reset:K,highlightedIndex:p,isOpen:d,selectedItem:h,inputValue:v}}wn.stateReducer,wn.itemToKey,wn.environment,T.array,T.array,T.array,T.func,T.number,T.number,T.number,T.func,T.func,T.string,T.string;qt.itemToKey,qt.stateReducer,qt.environment;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;const wp="_comboboxContainer_12y8e_1",xp="_label_12y8e_8",_p="_inputContainer_12y8e_12",bp="_input_12y8e_12",Cp="_toggleButton_12y8e_25",Op="_menu_12y8e_30",Sp="_menuItem_12y8e_43",Ep="_highlighted_12y8e_50",Np="_selected_12y8e_54",Rp="_hidden_12y8e_58",tt={comboboxContainer:wp,label:xp,inputContainer:_p,input:bp,toggleButton:Cp,menu:Op,menuItem:Sp,highlighted:Ep,selected:Np,hidden:Rp};function Tp(e){const t=e.toLowerCase();return function(o){return!e||o.label.toLowerCase().includes(t)||o.value.toLowerCase().includes(t)}}function Ap({items:e,selectedValue:t,onSelectedItemChange:n,placeholder:o}){const[i,r]=y.useState(e),s=f=>{r(e.filter(Tp(f)))},{isOpen:c,getToggleButtonProps:u,getMenuProps:d,getInputProps:p,highlightedIndex:h,getItemProps:v}=Hr({items:i,selectedItem:t?e.find(f=>f.value===t):null,itemToString:f=>(f==null?void 0:f.label)||"",onInputValueChange:({inputValue:f})=>s(f),onSelectedItemChange:({selectedItem:f})=>n(f)});return a.jsxs("div",{children:[a.jsx("div",{className:tt.comboboxContainer,children:a.jsxs("div",{className:tt.inputContainer,children:[a.jsx("input",{placeholder:o,className:tt.input,...p()}),a.jsx("button",{"aria-label":"toggle menu",className:tt.toggleButton,type:"button",...u(),children:c?a.jsx(a.Fragment,{children:"↑"}):a.jsx(a.Fragment,{children:"↓"})})]})}),a.jsx("ul",{className:`${tt.menu} ${c&&e.length?"":tt.hidden}`,...d(),children:c&&i.map((f,g)=>a.jsx("li",{className:`${tt.menuItem} ${h===g?tt.highlighted:""} ${t===(f==null?void 0:f.value)?tt.selected:""}`,...v({item:f,index:g}),children:a.jsx("span",{children:f.label})},f.id))})]})}const hs=y.createContext(null);function ms(){const e=y.useContext(hs);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const gs=y.createContext(()=>{});function jp(){const e=y.useContext(gs);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var ys=Symbol.for("immer-nothing"),$o=Symbol.for("immer-draftable"),ke=Symbol.for("immer-state"),Pp=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 Ae(e,...t){if(process.env.NODE_ENV!=="production"){const n=Pp[e],o=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var At=Object.getPrototypeOf;function jt(e){return!!e&&!!e[ke]}function _t(e){var t;return e?vs(e)||Array.isArray(e)||!!e[$o]||!!((t=e.constructor)!=null&&t[$o])||kn(e)||Fn(e):!1}var Dp=Object.prototype.constructor.toString();function vs(e){if(!e||typeof e!="object")return!1;const t=At(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Dp}function Sn(e,t){Dn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function Dn(e){const t=e[ke];return t?t.type_:Array.isArray(e)?1:kn(e)?2:Fn(e)?3:0}function dr(e,t){return Dn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Is(e,t,n){const o=Dn(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function kp(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function kn(e){return e instanceof Map}function Fn(e){return e instanceof Set}function It(e){return e.copy_||e.base_}function pr(e,t){if(kn(e))return new Map(e);if(Fn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=vs(e);if(t===!0||t==="class_only"&&!n){const o=Object.getOwnPropertyDescriptors(e);delete o[ke];let i=Reflect.ownKeys(o);for(let r=0;r<i.length;r++){const s=i[r],c=o[s];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(o[s]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[s]})}return Object.create(At(e),o)}else{const o=At(e);if(o!==null&&n)return{...e};const i=Object.create(o);return Object.assign(i,e)}}function Vr(e,t=!1){return Mn(e)||jt(e)||!_t(e)||(Dn(e)>1&&(e.set=e.add=e.clear=e.delete=Fp),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Vr(o,!0))),e}function Fp(){Ae(2)}function Mn(e){return Object.isFrozen(e)}var Mp={};function bt(e){const t=Mp[e];return t||Ae(0,e),t}var Xt;function ws(){return Xt}function Kp(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ho(e,t){t&&(bt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function fr(e){hr(e),e.drafts_.forEach(Lp),e.drafts_=null}function hr(e){e===Xt&&(Xt=e.parent_)}function Vo(e){return Xt=Kp(Xt,e)}function Lp(e){const t=e[ke];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Uo(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ke].modified_&&(fr(t),Ae(4)),_t(e)&&(e=En(t,e),t.parent_||Nn(t,e)),t.patches_&&bt("Patches").generateReplacementPatches_(n[ke].base_,e,t.patches_,t.inversePatches_)):e=En(t,n,[]),fr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ys?e:void 0}function En(e,t,n){if(Mn(t))return t;const o=t[ke];if(!o)return Sn(t,(i,r)=>Bo(e,o,t,i,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return Nn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const i=o.copy_;let r=i,s=!1;o.type_===3&&(r=new Set(i),i.clear(),s=!0),Sn(r,(c,u)=>Bo(e,o,i,c,u,n,s)),Nn(e,i,!1),n&&e.patches_&&bt("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Bo(e,t,n,o,i,r,s){if(process.env.NODE_ENV!=="production"&&i===n&&Ae(5),jt(i)){const c=r&&t&&t.type_!==3&&!dr(t.assigned_,o)?r.concat(o):void 0,u=En(e,i,c);if(Is(n,o,u),jt(u))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(_t(i)&&!Mn(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;En(e,i),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&Nn(e,i)}}function Nn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Vr(t,n)}function $p(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:ws(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=Ur;n&&(i=[o],r=Yt);const{revoke:s,proxy:c}=Proxy.revocable(i,r);return o.draft_=c,o.revoke_=s,c}var Ur={get(e,t){if(t===ke)return e;const n=It(e);if(!dr(n,t))return Hp(e,n,t);const o=n[t];return e.finalized_||!_t(o)?o:o===tr(e.base_,t)?(nr(e),e.copy_[t]=gr(o,e)):o},has(e,t){return t in It(e)},ownKeys(e){return Reflect.ownKeys(It(e))},set(e,t,n){const o=xs(It(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const i=tr(It(e),t),r=i==null?void 0:i[ke];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(kp(n,i)&&(n!==void 0||dr(e.base_,t)))return!0;nr(e),mr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return tr(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,nr(e),mr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=It(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){Ae(11)},getPrototypeOf(e){return At(e.base_)},setPrototypeOf(){Ae(12)}},Yt={};Sn(Ur,(e,t)=>{Yt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Yt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ae(13),Yt.set.call(this,e,t,void 0)};Yt.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ae(14),Ur.set.call(this,e[0],t,n,e[0])};function tr(e,t){const n=e[ke];return(n?It(n):e)[t]}function Hp(e,t,n){var i;const o=xs(t,n);return o?"value"in o?o.value:(i=o.get)==null?void 0:i.call(e.draft_):void 0}function xs(e,t){if(!(t in e))return;let n=At(e);for(;n;){const o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=At(n)}}function mr(e){e.modified_||(e.modified_=!0,e.parent_&&mr(e.parent_))}function nr(e){e.copy_||(e.copy_=pr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Vp=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){const r=n;n=t;const s=this;return function(u=r,...d){return s.produce(u,p=>n.call(this,p,...d))}}typeof n!="function"&&Ae(6),o!==void 0&&typeof o!="function"&&Ae(7);let i;if(_t(t)){const r=Vo(this),s=gr(t,void 0);let c=!0;try{i=n(s),c=!1}finally{c?fr(r):hr(r)}return Ho(r,o),Uo(i,r)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===ys&&(i=void 0),this.autoFreeze_&&Vr(i,!0),o){const r=[],s=[];bt("Patches").generateReplacementPatches_(t,i,r,s),o(r,s)}return i}else Ae(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...c)=>this.produceWithPatches(s,u=>t(u,...c));let o,i;return[this.produce(t,n,(s,c)=>{o=s,i=c}),o,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){_t(e)||Ae(8),jt(e)&&(e=Up(e));const t=Vo(this),n=gr(e,void 0);return n[ke].isManual_=!0,hr(t),n}finishDraft(e,t){const n=e&&e[ke];(!n||!n.isManual_)&&Ae(9);const{scope_:o}=n;return Ho(o,t),Uo(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const o=bt("Patches").applyPatches_;return jt(e)?o(e,t):this.produce(e,i=>o(i,t))}};function gr(e,t){const n=kn(e)?bt("MapSet").proxyMap_(e,t):Fn(e)?bt("MapSet").proxySet_(e,t):$p(e,t);return(t?t.scope_:ws()).drafts_.push(n),n}function Up(e){return jt(e)||Ae(10,e),_s(e)}function _s(e){if(!_t(e)||Mn(e))return e;const t=e[ke];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=pr(e,t.scope_.immer_.useStrictShallowCopy_)}else n=pr(e,!0);return Sn(n,(o,i)=>{Is(n,o,_s(i))}),t&&(t.finalized_=!1),n}var Fe=new Vp,Bt=Fe.produce;Fe.produceWithPatches.bind(Fe);Fe.setAutoFreeze.bind(Fe);Fe.setUseStrictShallowCopy.bind(Fe);Fe.applyPatches.bind(Fe);Fe.createDraft.bind(Fe);Fe.finishDraft.bind(Fe);const bs=y.createContext(void 0),Bp={};function Br(){const e=y.useContext(bs);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function qp({children:e}){const{installation:t}=Ye(),{hydratedRevision:n,loading:o}=Zt(),[i,r]=y.useState(Bp),s=t==null?void 0:t.config;y.useEffect(()=>{n!=null&&n.content&&!o&&s&&!(Object.entries(i).length>0)&&rd(n,s,r)},[n,o,s,i]);const c=y.useCallback((f,g)=>{r(x=>Bt(x,w=>{w[f]=Bt(w[f],g)}))},[r]),u=y.useCallback((f,g)=>{r(x=>Bt(x,w=>{w[f]=g}))},[r]),d=y.useCallback(()=>{r(Bt(f=>{const g=f.other.write;g&&(g.isWriteModified=!1)}))},[r]),p=y.useCallback(f=>{r(Bt(g=>{var w;const x=(w=g[f])==null?void 0:w.read;x&&(x.isOptionalFieldsModified=!1,x.isRequiredMapFieldsModified=!1)}))},[r]),h=y.useCallback(f=>{f===xt?d():p(f)},[p,d]),v=y.useMemo(()=>({objectConfigurationsState:i,setObjectConfigurationsState:r,setConfigureState:c,resetConfigureState:u,resetPendingConfigurationState:h}),[i,u,h,c]);return a.jsx(bs.Provider,{value:v,children:e})}const pt=()=>{const{appName:e}=Ie(),{objectConfigurationsState:t,setConfigureState:n}=Br(),{selectedObjectName:o}=ms(),i=Ci(o||"",t);return{appName:e,configureState:i,setConfigureState:n,selectedObjectName:o}};function Wp(e,t,n){var i;const o=((i=e==null?void 0:e.read)==null?void 0:i.selectedFieldMappings)||{};if(o[t]=n,e!=null&&e.read){const r=e.read.savedConfig.requiredMapFields,c=!_r(r,o);e.read.isRequiredMapFieldsModified=c}}function Cs(e,t,n,o){t(e,i=>Wp(i,n,o))}function Jp({field:e,onSelectChange:t,allFields:n}){var f;const{configureState:o,selectedObjectName:i,setConfigureState:r}=pt(),[s,c]=y.useState(!0),u=(f=o==null?void 0:o.read)==null?void 0:f.selectedFieldMappings,d=u==null?void 0:u[e.mapToName];y.useEffect(()=>{e._default&&!d&&i&&o&&Cs(i,r,e.mapToName,e._default),c(!1)},[e,r,i,d,o]);const p=y.useMemo(()=>n==null?void 0:n.map(g=>a.jsx("option",{value:g.fieldName,children:g.displayName},g.fieldName)),[n]),h=y.useMemo(()=>n.map(g=>({id:g.fieldName,label:g.displayName,value:g.fieldName})),[n]),v=ve?a.jsx(Ap,{items:h,selectedValue:d||null,onSelectedItemChange:g=>{t({target:{name:e.mapToName,value:g==null?void 0:g.value}})},placeholder:"Please select one"}):a.jsx(S.Select,{name:e.mapToName,variant:"flushed",value:d||void 0,onChange:t,placeholder:d?void 0:"Please select one",disabled:s,children:p});return a.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[a.jsx("h3",{style:{fontWeight:500},children:e.mapToDisplayName}),a.jsx("p",{style:{paddingBottom:"1rem"},children:e==null?void 0:e.prompt}),v]},e.mapToName)}const zp="_divider_j6suu_1",qo={divider:zp};function qr({className:e,style:t}){return ve?a.jsx("hr",{className:e?`${qo.divider} ${e}`:qo.divider,style:t}):a.jsx(S.Divider,{className:e,style:t})}const Xp=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-text-secondary").trim()||"#737373";function Ft({string:e}){return a.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"2rem",paddingBottom:"1rem"},children:[a.jsx("h3",{style:{color:Xp,fontSize:"1rem",fontWeight:"500"},children:e}),a.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:a.jsx(qr,{style:{marginLeft:"1rem"}})})]})}function Yp(){const{selectedObjectName:e,configureState:t,setConfigureState:n}=pt(),{isError:o,removeError:i}=dt(),r=c=>{const{value:u,name:d}=c.target;u&&(e&&Cs(e,n,d,u),o(me.MAPPING,d)&&i(me.MAPPING,d))},s=y.useMemo(()=>{var c,u;return((u=(c=t==null?void 0:t.read)==null?void 0:c.requiredMapFields)==null?void 0:u.filter(Xe))||[]},[t]);return s.length?a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:"Map the following fields (required)"}),a.jsx("div",{style:{display:"flex",gap:"2rem",flexDirection:"column"},children:s.map(c=>{var u;return a.jsxs(S.FormControl,{isInvalid:o(me.MAPPING,c.mapToName),children:[a.jsx(Jp,{allFields:((u=t.read)==null?void 0:u.allFields)||[],field:c,onSelectChange:r}),a.jsx(S.FormErrorMessage,{children:" * required"})]},c.mapToName)})})]}):null}function Gp(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Os(...e){return t=>e.forEach(n=>Gp(n,t))}function Ss(...e){return X.useCallback(Os(...e),e)}function Zp(e,t=[]){let n=[];function o(r,s){const c=X.createContext(s),u=n.length;n=[...n,s];const d=h=>{var O;const{scope:v,children:f,...g}=h,x=((O=v==null?void 0:v[e])==null?void 0:O[u])||c,w=X.useMemo(()=>g,Object.values(g));return a.jsx(x.Provider,{value:w,children:f})};d.displayName=r+"Provider";function p(h,v){var x;const f=((x=v==null?void 0:v[e])==null?void 0:x[u])||c,g=X.useContext(f);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${r}\``)}return[d,p]}const i=()=>{const r=n.map(s=>X.createContext(s));return function(c){const u=(c==null?void 0:c[e])||r;return X.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return i.scopeName=e,[o,Qp(i,...t)]}function Qp(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(r){const s=o.reduce((c,{useScope:u,scopeName:d})=>{const h=u(r)[`__scope${d}`];return{...c,...h}},{});return X.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Wo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function Es(e){const t=X.useRef(e);return X.useEffect(()=>{t.current=e}),X.useMemo(()=>(...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])}function ef({prop:e,defaultProp:t,onChange:n=()=>{}}){const[o,i]=tf({defaultProp:t,onChange:n}),r=e!==void 0,s=r?e:o,c=Es(n),u=X.useCallback(d=>{if(r){const h=typeof d=="function"?d(e):d;h!==e&&c(h)}else i(d)},[r,e,i,c]);return[s,u]}function tf({defaultProp:e,onChange:t}){const n=X.useState(e),[o]=n,i=X.useRef(o),r=Es(t);return X.useEffect(()=>{i.current!==o&&(r(o),i.current=o)},[o,i,r]),n}function nf(e){const t=X.useRef({value:e,previous:e});return X.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var yr=globalThis!=null&&globalThis.document?X.useLayoutEffect:()=>{};function rf(e){const[t,n]=X.useState(void 0);return yr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const r=i[0];let s,c;if("borderBoxSize"in r){const u=r.borderBoxSize,d=Array.isArray(u)?u[0]:u;s=d.inlineSize,c=d.blockSize}else s=e.offsetWidth,c=e.offsetHeight;n({width:s,height:c})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}function of(e,t){return X.useReducer((n,o)=>t[n][o]??n,e)}var Ns=e=>{const{present:t,children:n}=e,o=sf(t),i=typeof n=="function"?n({present:o.isPresent}):X.Children.only(n),r=Ss(o.ref,af(i));return typeof n=="function"||o.isPresent?X.cloneElement(i,{ref:r}):null};Ns.displayName="Presence";function sf(e){const[t,n]=X.useState(),o=X.useRef({}),i=X.useRef(e),r=X.useRef("none"),s=e?"mounted":"unmounted",[c,u]=of(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return X.useEffect(()=>{const d=mn(o.current);r.current=c==="mounted"?d:"none"},[c]),yr(()=>{const d=o.current,p=i.current;if(p!==e){const v=r.current,f=mn(d);e?u("MOUNT"):f==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(p&&v!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),yr(()=>{if(t){let d;const p=t.ownerDocument.defaultView??window,h=f=>{const x=mn(o.current).includes(f.animationName);if(f.target===t&&x&&(u("ANIMATION_END"),!i.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",d=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},v=f=>{f.target===t&&(r.current=mn(o.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{p.clearTimeout(d),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:X.useCallback(d=>{d&&(o.current=getComputedStyle(d)),n(d)},[])}}function mn(e){return(e==null?void 0:e.animationName)||"none"}function af(e){var o,i;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Rs=X.forwardRef((e,t)=>{const{children:n,...o}=e,i=X.Children.toArray(n),r=i.find(uf);if(r){const s=r.props.children,c=i.map(u=>u===r?X.Children.count(s)>1?X.Children.only(null):X.isValidElement(s)?s.props.children:null:u);return a.jsx(vr,{...o,ref:t,children:X.isValidElement(s)?X.cloneElement(s,void 0,c):null})}return a.jsx(vr,{...o,ref:t,children:n})});Rs.displayName="Slot";var vr=X.forwardRef((e,t)=>{const{children:n,...o}=e;if(X.isValidElement(n)){const i=df(n);return X.cloneElement(n,{...lf(o,n.props),ref:t?Os(t,i):i})}return X.Children.count(n)>1?X.Children.only(null):null});vr.displayName="SlotClone";var cf=({children:e})=>a.jsx(a.Fragment,{children:e});function uf(e){return X.isValidElement(e)&&e.type===cf}function lf(e,t){const n={...t};for(const o in t){const i=e[o],r=t[o];/^on[A-Z]/.test(o)?i&&r?n[o]=(...c)=>{r(...c),i(...c)}:i&&(n[o]=i):o==="style"?n[o]={...i,...r}:o==="className"&&(n[o]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}function df(e){var o,i;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ts=pf.reduce((e,t)=>{const n=X.forwardRef((o,i)=>{const{asChild:r,...s}=o,c=r?Rs:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...s,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Wr="Checkbox",[ff,pm]=Zp(Wr),[hf,mf]=ff(Wr),As=X.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:s,disabled:c,value:u="on",onCheckedChange:d,form:p,...h}=e,[v,f]=X.useState(null),g=Ss(t,b=>f(b)),x=X.useRef(!1),w=v?p||!!v.closest("form"):!0,[O=!1,I]=ef({prop:i,defaultProp:r,onChange:d}),C=X.useRef(O);return X.useEffect(()=>{const b=v==null?void 0:v.form;if(b){const m=()=>I(C.current);return b.addEventListener("reset",m),()=>b.removeEventListener("reset",m)}},[v,I]),a.jsxs(hf,{scope:n,state:O,disabled:c,children:[a.jsx(Ts.button,{type:"button",role:"checkbox","aria-checked":lt(O)?"mixed":O,"aria-required":s,"data-state":Ds(O),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:g,onKeyDown:Wo(e.onKeyDown,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Wo(e.onClick,b=>{I(m=>lt(m)?!0:!m),w&&(x.current=b.isPropagationStopped(),x.current||b.stopPropagation())})}),w&&a.jsx(gf,{control:v,bubbles:!x.current,name:o,value:u,checked:O,required:s,disabled:c,form:p,style:{transform:"translateX(-100%)"},defaultChecked:lt(r)?!1:r})]})});As.displayName=Wr;var js="CheckboxIndicator",Ps=X.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:o,...i}=e,r=mf(js,n);return a.jsx(Ns,{present:o||lt(r.state)||r.state===!0,children:a.jsx(Ts.span,{"data-state":Ds(r.state),"data-disabled":r.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});Ps.displayName=js;var gf=e=>{const{control:t,checked:n,bubbles:o=!0,defaultChecked:i,...r}=e,s=X.useRef(null),c=nf(n),u=rf(t);X.useEffect(()=>{const p=s.current,h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==n&&f){const g=new Event("click",{bubbles:o});p.indeterminate=lt(n),f.call(p,lt(n)?!1:n),p.dispatchEvent(g)}},[c,n,o]);const d=X.useRef(lt(n)?!1:n);return a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i??d.current,...r,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function lt(e){return e==="indeterminate"}function Ds(e){return lt(e)?"indeterminate":e?"checked":"unchecked"}var ks=As,Fs=Ps;function Ms(e,t){if(e==null)return{};var n={},o=Object.keys(e),i,r;for(r=0;r<o.length;r++)i=o[r],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var yf=["color"],Ks=y.forwardRef(function(e,t){var n=e.color,o=n===void 0?"currentColor":n,i=Ms(e,yf);return y.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),y.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:o,fillRule:"evenodd",clipRule:"evenodd"}))}),vf=["color"],If=y.forwardRef(function(e,t){var n=e.color,o=n===void 0?"currentColor":n,i=Ms(e,vf);return y.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),y.createElement("path",{d:"M2 7.5C2 7.22386 2.22386 7 2.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H2.5C2.22386 8 2 7.77614 2 7.5Z",fill:o,fillRule:"evenodd",clipRule:"evenodd"}))});const wf="_checkboxGroupContainer_j54z7_1",xf="_stack_j54z7_6",_f="_selectAllContainer_j54z7_11",bf="_fieldContainer_j54z7_18",Cf="_checkbox_j54z7_1",Pt={checkboxGroupContainer:wf,stack:xf,selectAllContainer:_f,fieldContainer:bf,checkbox:Cf};function Ls({id:e,isChecked:t,label:n,onCheckedChange:o}){return a.jsxs("div",{className:Pt.fieldContainer,children:[a.jsx(ks,{className:Pt.checkbox,id:e,onCheckedChange:o,checked:t,children:a.jsx(Fs,{children:a.jsx(Ks,{})})}),a.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function $s({id:e,isChecked:t,label:n,onCheckedChange:o,isIndeterminate:i}){return a.jsxs("div",{className:Pt.selectAllContainer,children:[a.jsx(ks,{className:Pt.checkbox,id:e,onCheckedChange:o,children:a.jsxs(Fs,{children:[i&&a.jsx(If,{}),t===!0&&a.jsx(Ks,{})]})}),a.jsx("label",{htmlFor:e,children:n})]})}function Hs({children:e}){return a.jsx("div",{className:Pt.checkboxGroupContainer,children:e})}function Vs({children:e}){return a.jsx("div",{className:Pt.stack,children:e})}function Of(e,t,n){var i,r;const o=((i=e==null?void 0:e.read)==null?void 0:i.selectedOptionalFields)||{};if(o[t]=n,n||delete o[t],(r=e.read)!=null&&r.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,u=!_r(s,o);e.read.isOptionalFieldsModified=u}else console.warn("read.savedConfig.optionalFields is undefined")}function Rn(e,t,n,o){t(e,i=>Of(i,n,o))}function Sf(){var h,v;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:o}=pt(),i=(h=t==null?void 0:t.read)==null?void 0:h.selectedOptionalFields,r=(f,g)=>{f!=="indeterminate"&&o&&t&&Rn(o,n,g,f)},s=(v=t==null?void 0:t.read)==null?void 0:v.optionalFields,c=f=>{o&&s&&s.forEach(g=>{Xe(g)||Rn(o,n,g.fieldName,f)})},u=!!(s&&s.length>0),d=Object.keys(i||{}).length===(s==null?void 0:s.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`${e} reads the following optional fields`}),a.jsxs(Hs,{children:[((s==null?void 0:s.length)||0)>=2&&a.jsx($s,{id:"select-all-fields",isChecked:d,label:"Select all",onCheckedChange:c,isIndeterminate:p}),a.jsx(Vs,{children:s.map(f=>Xe(f)?null:a.jsx(Ls,{id:f.fieldName,isChecked:!!(i!=null&&i[f==null?void 0:f.fieldName]),label:f.displayName,onCheckedChange:g=>r(g,f.fieldName)},f.fieldName))})]})]})}function Ef(){var h,v;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:o}=pt(),i=(h=t==null?void 0:t.read)==null?void 0:h.selectedOptionalFields,r=f=>{const{name:g,checked:x}=f.target;o&&t&&Rn(o,n,g,x)},s=(v=t==null?void 0:t.read)==null?void 0:v.optionalFields,c=f=>{const{checked:g}=f.target;o&&s&&s.forEach(x=>{Xe(x)||Rn(o,n,x.fieldName,g)})},u=!!(s&&s.length>0),d=Object.keys(i||{}).length===(s==null?void 0:s.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`${e} reads the following optional fields`}),a.jsxs(S.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((s==null?void 0:s.length)||0)>=2&&a.jsx(S.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:a.jsx(S.Checkbox,{name:"selectAll",id:"selectAll",onChange:c,isIndeterminate:p,isChecked:d,children:"Select all"})}),s.map(f=>Xe(f)?null:a.jsx(S.Box,{paddingX:4,paddingY:2,borderBottom:"1px",borderColor:"gray.100",children:a.jsx(S.Checkbox,{name:f.fieldName,id:f.fieldName,isChecked:!!(i!=null&&i[f==null?void 0:f.fieldName]),onChange:r,children:a.jsx("p",{style:{overflowWrap:"anywhere"},children:f.displayName})})},f.fieldName))]})]})}function Nf(){return ve?a.jsx(Sf,{}):a.jsx(Ef,{})}const Rf=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-badge").trim()||"#e5e5e5",Tf=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-badge-text").trim()||"#404040",Af={color:Tf,backgroundColor:Rf,borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function jf({children:e,style:t,...n}){return a.jsx("span",{style:{...Af,...t},...n,children:e})}function Pf(){var o,i,r;const{configureState:e,selectedObjectName:t}=pt(),{appName:n}=Ie();return a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`${n} reads the following ${t} fields`}),a.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:"2rem"},children:(i=(o=e==null?void 0:e.read)==null?void 0:o.requiredFields)!=null&&i.length?(r=e.read)==null?void 0:r.requiredFields.map(s=>Xe(s)?null:a.jsx(jf,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function Df(){return a.jsxs(a.Fragment,{children:[a.jsx(Pf,{}),a.jsx(Yp,{}),a.jsx(Nf,{})]})}function kf(e,t,n){var o,i,r;if(((o=e==null?void 0:e.write)==null?void 0:o.selectedNonConfigurableWriteFields)===null&&(e.write.selectedNonConfigurableWriteFields={}),e!=null&&e.write){const s=e.write.selectedNonConfigurableWriteFields;if(s[t]=n,n||delete s[t],(r=(i=e==null?void 0:e.write)==null?void 0:i.savedConfig)!=null&&r.selectedNonConfigurableWriteFields){const c=e.write.savedConfig.selectedNonConfigurableWriteFields,d=!_r(c,s);e.write.isWriteModified=d}}}function Tn(e,t,n,o){t(e,i=>{kf(i,n,o)})}function Ff(){var h,v,f,g;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:o}=pt(),i=(h=n==null?void 0:n.write)==null?void 0:h.selectedNonConfigurableWriteFields,r=(v=n==null?void 0:n.write)==null?void 0:v.writeObjects,s=(x,w)=>{x!=="indeterminate"&&t&&n&&Tn(t,o,w,x)},c=x=>{var w,O;t&&n&&((O=(w=n==null?void 0:n.write)==null?void 0:w.writeObjects)==null||O.forEach(I=>{Tn(t,o,I.objectName,x)}))},u=!!r,d=Object.keys(i||{}).length===((g=(f=n==null?void 0:n.write)==null?void 0:f.writeObjects)==null?void 0:g.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`Allow ${e} to write to these object`}),a.jsxs(Hs,{children:[((r==null?void 0:r.length)||0)>=2&&a.jsx($s,{id:"select-all-fields",onCheckedChange:c,isIndeterminate:p,isChecked:d,label:"Select all"}),a.jsx(Vs,{children:r.map(x=>a.jsx(Ls,{id:x.objectName,onCheckedChange:w=>s(w,x.objectName),isChecked:!!(i!=null&&i[x.objectName]),label:x.displayName},x.objectName))})]})]})}function Mf(){var h,v,f,g;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:o}=pt(),i=(h=n==null?void 0:n.write)==null?void 0:h.selectedNonConfigurableWriteFields,r=(v=n==null?void 0:n.write)==null?void 0:v.writeObjects,s=x=>{const{name:w,checked:O}=x.target;t&&n&&Tn(t,o,w,O)},c=x=>{var O,I;const{checked:w}=x.target;t&&n&&((I=(O=n==null?void 0:n.write)==null?void 0:O.writeObjects)==null||I.forEach(C=>{Tn(t,o,C.objectName,w)}))},u=!!r,d=Object.keys(i||{}).length===((g=(f=n==null?void 0:n.write)==null?void 0:f.writeObjects)==null?void 0:g.length),p=!d&&Object.keys(i||{}).length>0;return u&&a.jsxs(a.Fragment,{children:[a.jsx(Ft,{string:`Allow ${e} to write to these object`}),a.jsxs(S.Stack,{marginBottom:10,maxHeight:300,overflowY:"scroll",border:"2px solid #EFEFEF",borderRadius:8,gap:0,children:[((r==null?void 0:r.length)||0)>=2&&a.jsx(S.Box,{backgroundColor:"gray.50",paddingX:4,paddingY:2,children:a.jsx(S.Checkbox,{name:"selectAll",id:"selectAll",onChange:c,isIndeterminate:p,isChecked:d,children:"Select all"})}),r.map(x=>a.jsx(S.Box,{display:"flex",alignItems:"center",borderBottom:"1px",borderColor:"gray.100",paddingX:4,paddingY:2,children:a.jsx(S.Checkbox,{name:x.objectName,id:x.objectName,onChange:s,isChecked:!!(i!=null&&i[x.objectName]),children:a.jsx("p",{style:{overflowWrap:"anywhere"},children:x.displayName})})},x.objectName))]})]})}function Kf(){return ve?a.jsx(Ff,{}):a.jsx(Mf,{})}function Lf(){const e=xe(),{projectId:t,appName:n}=Ie(),{integrationId:o,installation:i,resetInstallations:r,setIntegrationDeleted:s,onUninstallSuccess:c}=Ye(),[u,d]=y.useState(!1),p=!t||!o||!(i!=null&&i.id)||u,h=async()=>{if(!p){d(!0),console.warn("uninstalling installation",{projectId:t,integrationId:o,installationId:i.id});try{await fe().installationApi.deleteInstallation({projectIdOrName:t,integrationId:o,installationId:i.id},{headers:{"X-Api-Key":e,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation: ",i.id),c==null||c(i==null?void 0:i.id),r(),s()}catch(x){console.error("Error uninstalling installation."),Ce(x)}finally{d(!1)}}},v=u?"Uninstalling...":"Yes, uninstall",f=i!=null&&i.id?`Once you uninstall this integration, all your configuration will be lost, and "${n}" may stop working.`:"You've successfully uninstalled the integration.",g=ve?a.jsx(He,{type:"button",onClick:h,disabled:p,variant:"danger",children:v}):a.jsx(S.Button,{onClick:h,variant:"warning",isDisabled:p,children:v});return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[a.jsx("p",{children:f}),(i==null?void 0:i.id)&&g]})}const $f=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-neutral-100").trim()||"#f5f5f5",Hf=getComputedStyle(document.documentElement).getPropertyValue("--amp-shadows-sm").trim()||"0 1px 2px 0 rgba(0, 0, 0, 0.05)";function Us({onSave:e,onReset:t,isLoading:n,isCreateMode:o=!1,errorMsg:i}){var j,$,F;const{installation:r}=Ye(),{hydratedRevision:s,loading:c}=Zt(),{configureState:u,selectedObjectName:d}=pt(),p=r==null?void 0:r.config,h=p&&d&&!!gi(p,d)||!1,v=((j=u==null?void 0:u.read)==null?void 0:j.isOptionalFieldsModified)||(($=u==null?void 0:u.read)==null?void 0:$.isRequiredMapFieldsModified),f=(F=u==null?void 0:u.write)==null?void 0:F.isWriteModified,O=c||n||!u||!d||!(v||f||o||d!==xt&&!h),I=d===xt,C=d===Ni,b=ve?a.jsx(He,{type:"submit",disabled:O,children:o?"Install":"Save"}):a.jsx(S.Button,{type:"submit",variant:"primary",isDisabled:O,children:o?"Install":"Save"}),m=ve?a.jsx(He,{type:"button",onClick:t,disabled:O,variant:"ghost",children:"Reset"}):a.jsx(S.Button,{isDisabled:O,onClick:t,children:"Reset"});return n?a.jsx(qe,{}):a.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[a.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:"1rem",marginBottom:"2rem"},children:[b,m]}),a.jsxs(Dt,{style:{padding:"2rem",minHeight:"300px",backgroundColor:"white",borderColor:$f,boxShadow:Hf},children:[i&&a.jsx(Si,{children:typeof i=="string"?i:"Installation Failed."}),c&&a.jsx(qe,{}),s&&!C&&!I&&a.jsx(Df,{}),s&&!C&&I&&a.jsx(Kf,{}),!c&&C&&a.jsx(Lf,{})]})]})}const Bs=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:o,onInstallSuccess:i,onUpdateSuccess:r}=Ye(),{hydratedRevision:s,loading:c}=Zt(),{selectedObjectName:u}=ms(),{selectedConnection:d}=kt(),p=xe(),{projectId:h}=Ie(),{resetBoundary:v,setErrors:f,setError:g,getError:x}=dt(),{resetConfigureState:w,objectConfigurationsState:O,resetPendingConfigurationState:I}=Br(),C=Ci(u||"",O),{onNextIncompleteTab:b}=jp(),m=y.useCallback(()=>{v(me.INSTALLATION_MUTATION)},[v]),j=y.useCallback(F=>F?V=>{g(me.INSTALLATION_MUTATION,F,V)}:V=>{console.error("objectName is required to set installation error: ",V)},[g]),$=y.useCallback(F=>F?x(me.INSTALLATION_MUTATION,F):"",[x]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:o,hydratedRevision:s,loading:c,selectedObjectName:u,selectedConnection:d,apiKey:p,projectId:h,resetBoundary:v,setErrors:f,setMutateInstallationError:j,getMutateInstallationError:$,resetMutateInstallationErrorState:m,resetConfigureState:w,objectConfigurationsState:O,resetPendingConfigurationState:I,configureState:C,onInstallSuccess:i,onUpdateSuccess:r,onNextIncompleteTab:b}},Vf=void 0;function Uf(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:o,hydratedRevision:i,loading:r,selectedObjectName:s,selectedConnection:c,apiKey:u,projectId:d,resetBoundary:p,setErrors:h,setMutateInstallationError:v,getMutateInstallationError:f,resetMutateInstallationErrorState:g,resetConfigureState:x,objectConfigurationsState:w,resetPendingConfigurationState:O,configureState:I,onInstallSuccess:C,onNextIncompleteTab:b}=Bs(),[m,j]=y.useState(!1),$=s===xt,F=f(s),V=y.useCallback(()=>{p(me.MAPPING),i!=null&&i.content&&!r&&s&&xi(i,Vf,s,x)},[p,i,r,s,x]);y.useEffect(()=>{!I&&(i!=null&&i.content)&&!r&&V()},[I,w,i,r,V]);const B=()=>{g();const{requiredMapFields:te,selectedFieldMappings:Q}=(I==null?void 0:I.read)||{},{errorList:ue}=Ii(te,Q,h);ue.length>0||(s&&(c!=null&&c.id)&&u&&d&&e&&t&&n&&i?(j(!0),sd(d,e,t,n,c.id,s,u,i,I,v(s),o,C).finally(()=>{j(!1),O(s),b()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},Z=()=>{g(),s&&(c!=null&&c.id)&&u&&d&&e&&t&&n&&i?(j(!0),ud(d,e,t,n,c.id,u,i,I,v(s),o,C).finally(()=>{j(!1),O(s),b()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},G=te=>{te.preventDefault(),$?Z():B()};return a.jsx(Us,{errorMsg:F,isCreateMode:!0,isLoading:m,onSave:G,onReset:V})}function Bf({updateConfig:e,projectId:t,integrationId:n,installationId:o,apiKey:i,selectedObjectName:r,setInstallation:s,onUpdateSuccess:c,setError:u}){const d={projectIdOrName:t,installationId:o,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${r}`],installation:{config:e}}};return fe().installationApi.updateInstallation(d,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}).then(p=>{s(p),c==null||c(p.id,p.config)}).catch(p=>{Ce(p,u)})}const qf=(e,t,n,o,i,r)=>{const s=_i(e),c=bi(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:o,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:c,backfill:r}}}}};return jn(i)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},Wf=(e,t,n,o,i,r,s,c,u,d,p)=>{const h=qf(r,o||"",c,c.schedule,u,c.backfill);return h?Bf({updateConfig:h,projectId:e,integrationId:t,installationId:n,apiKey:i,selectedObjectName:o,setError:d,setInstallation:s,onUpdateSuccess:p}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Jf=(e,t)=>{const o={content:{write:{objects:Oi(e)}}};return jn(t)&&(o.content||(o.content={}),o.content.proxy={enabled:!0}),o},zf=(e,t,n,o,i,r,s,c,u)=>{const d=Jf(i,r);if(!d)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const p={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:d}}};return fe().installationApi.updateInstallation(p,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(h=>{c(h),u==null||u(h.id,h.config)}).catch(h=>{Ce(h,s)})};function Xf({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:o,loading:i,selectedObjectName:r,apiKey:s,projectId:c,resetBoundary:u,setErrors:d,setMutateInstallationError:p,getMutateInstallationError:h,resetConfigureState:v,resetPendingConfigurationState:f,configureState:g,onUpdateSuccess:x,onNextIncompleteTab:w}=Bs(),[O,I]=y.useState(!1),C=r===xt,b=h(r),{config:m}=e,j=y.useCallback(()=>{u(me.MAPPING),o!=null&&o.content&&!i&&r&&xi(o,m,r,v)},[u,o,i,r,m,v]);y.useEffect(()=>{g||j()},[g,j]),y.useEffect(()=>{e&&j()},[e,j]);const $=y.useMemo(()=>{var G,te,Q;return(Q=(te=(G=o==null?void 0:o.content)==null?void 0:G.read)==null?void 0:te.objects)==null?void 0:Q.find(ue=>(ue==null?void 0:ue.objectName)===r)},[o,r]),F=()=>{const{requiredMapFields:Z,selectedFieldMappings:G}=(g==null?void 0:g.read)||{},{errorList:te}=Ii(Z,G,d);te.length>0||(o&&e&&r&&s&&c&&$?(I(!0),Wf(c,t.id,e.id,r,s,g,n,$,o,p(r),x).finally(()=>{I(!1),f(r),w()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},V=()=>{e&&r&&s&&c&&o?(I(!0),zf(c,t.id,e.id,s,g,o,p(r),n,x).finally(()=>{I(!1),f(r),w()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},B=Z=>{Z.preventDefault(),C?V():F()};return a.jsx(Us,{errorMsg:b,onSave:B,onReset:j,isLoading:O})}function Yf(){const{integrationObj:e,installation:t}=Ye();return e?t&&e?a.jsx(Xf,{installation:t,integrationObj:e}):a.jsx(Uf,{}):a.jsx(ot,{message:"We can't load the integration"})}function Gf(){return a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),a.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Jr({text:e,children:t}){return a.jsx(Gt,{children:a.jsxs(Dt,{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:[a.jsx(Gf,{}),a.jsx("p",{children:e}),t]})})}const Zf=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function Qf({projectId:e,integrationId:t,groupRef:n,consumerRef:o,connectionId:i,apiKey:r,hydratedRevision:s,setError:c,setInstallation:u,onInstallSuccess:d}){const p=Zf(s,o);return p?br({createConfig:p,projectId:e,integrationId:t,groupRef:n,connectionId:i,apiKey:r,setError:c,setInstallation:u,onInstallSuccess:d}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function eh({provider:e}){const t=`You have successfully installed your ${it(e)} integration.`;return a.jsx(Jr,{text:t})}const th=e=>{const{read:t,write:n,proxy:o}=(e==null?void 0:e.content)??{};return!t&&!n&&(o==null?void 0:o.enabled)||!1};function nh({children:e,resetComponent:t}){var b;const{projectId:n}=Ie(),o=xe(),{hydratedRevision:i,loading:r}=Zt(),{integrationObj:s,installation:c,groupRef:u,consumerRef:d,setInstallation:p,onInstallSuccess:h,isIntegrationDeleted:v}=Ye(),{selectedConnection:f}=kt(),[g,x]=y.useState(!1),w=r||g,O=(b=i==null?void 0:i.content)==null?void 0:b.provider,I=th(i),C=m=>{console.error("Error when creating proxy installation:",m)};return y.useEffect(()=>{!w&&i&&I&&!c&&f&&o&&(s!=null&&s.id)&&(x(!0),Qf({apiKey:o,projectId:n,integrationId:s==null?void 0:s.id,groupRef:u,consumerRef:d,connectionId:f==null?void 0:f.id,hydratedRevision:i,setError:C,setInstallation:p,onInstallSuccess:h}).then(()=>{x(!1)}).catch(m=>{x(!1),console.error("Error when creating proxy installation:",m)}))},[i,I,c,f,o,n,s==null?void 0:s.id,u,d,p,w,h]),s?w?a.jsx(qe,{}):I&&O&&c?a.jsx(eh,{provider:O}):v?a.jsx(Jr,{text:"Integration successfully uninstalled.",children:ve&&a.jsx(He,{type:"button",onClick:t,style:{width:"100%"},children:"Reinstall Integration"})}):a.jsx("div",{children:e}):a.jsx(ot,{message:"We can't load the integration"})}function qs(){return a.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:[a.jsx("p",{children:"Secured by"}),a.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:a.jsx("img",{style:{height:".8em"},src:"https://ampersand-website.vercel.app/logo-black.svg",alt:"Ampersand"})})]})}function Me({children:e}){return a.jsx(Gt,{children:a.jsxs(Dt,{children:[a.jsx("div",{style:{padding:"3rem 2rem"},children:e}),a.jsx(qs,{})]})})}function Qt({children:e}){return a.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function Ke({error:e}){return e?a.jsx(Si,{style:{marginTop:"2em"},children:e}):null}function zr({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o,children:i,title:r}){if(!r&&!o)throw new Error("Either title or providerName is required");return a.jsxs(Me,{children:[a.jsx(Qt,{children:r||`Set up ${o} integration`}),a.jsx(Ke,{error:t}),i,a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}const rh="_link_oo2kv_1",oh={link:rh};function Xr({href:e,className:t,style:n,label:o,children:i,newTab:r=!1}){return ve?a.jsx("a",{className:oh.link,style:n,href:e,"aria-label":o||void 0,target:r?"_blank":"_self",rel:r?"noopener noreferrer":void 0,children:i}):a.jsx(S.Link,{href:e,className:t,style:n,"aria-label":o||void 0,target:r?"_blank":"_self",rel:r?"noopener noreferrer":void 0,color:"#737373",children:i})}const ih=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-text-secondary").trim()||"#737373";function Kn({url:e,providerDisplayName:t,credentialName:n}){return a.jsxs("p",{style:{color:ih},children:[a.jsx(Xr,{href:e,newTab:!0,children:a.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}const sh="_input_19woe_1",ah="_inputError_19woe_17",ch="_error_19woe_31",rr={input:sh,inputError:ah,error:ch};function uh({id:e,type:t,className:n,isError:o=!1,...i}){const r=o?zt(rr.inputError,rr.input):rr.input;return a.jsx("input",{id:e,type:t,className:zt(r,n),...i})}const lh="_textarea_1efhx_1",dh="_textareaError_1efhx_13",ph="_error_1efhx_27",or={textarea:lh,textareaError:dh,error:ph};function fh({className:e,isError:t=!1,...n}){const o=t?zt(or.textareaError,or.textarea):or.textarea;return a.jsx("textarea",{className:zt(e,o),...n})}const rt={Input:uh,Textarea:fh};function hh({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var x;const[r,s]=y.useState(!1),c=()=>s(!r),[u,d]=y.useState(""),p=w=>d(w.currentTarget.value),h=u.length>0,v=i||!h,f=it(e,t),g=(x=t.apiKeyOpts)==null?void 0:x.docsURL;return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{my:"6",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${f} integration`})}),a.jsx(Ke,{error:o}),a.jsxs(S.Stack,{spacing:4,children:[g&&a.jsx(Kn,{url:g,providerDisplayName:f,credentialName:"API key"}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:p,pr:"4.5rem",type:r?"text":"password",placeholder:"API Key"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:c,children:r?"Hide":"Show"})})]})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:v,width:"100%",type:"submit",onClick:()=>{n({apiKey:u})},children:"Next"})]})})}function mh({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var x;const[r,s]=y.useState(!1),c=()=>s(w=>!w),[u,d]=y.useState(""),p=w=>d(w.currentTarget.value),h=u.length>0,v=i||!h,f=it(e,t),g=(x=t.apiKeyOpts)==null?void 0:x.docsURL;return a.jsx(zr,{providerName:f,handleSubmit:()=>{n({apiKey:u})},error:o,isButtonDisabled:v,children:a.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[g&&a.jsx(Kn,{url:g,providerDisplayName:f,credentialName:"API key"}),a.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[a.jsx(rt.Input,{id:"password",name:"password",type:r?"text":"password",placeholder:"Password",onChange:w=>p(w)}),a.jsx(He,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:c,children:r?"Hide":"Show"})]})]})})}function gh({...e}){return ve?a.jsx(mh,{...e}):a.jsx(hh,{...e})}function yh({provider:e,providerInfo:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,children:s,selectedConnection:c,setSelectedConnection:u}){const d=Ie(),[p,h]=y.useState(!1),[v,f]=y.useState(null),g=xe();y.useEffect(()=>{if(e&&fe&&p&&v!=null){const w={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,apiKey:v};fe().connectionApi.generateConnection({projectIdOrName:d.projectId,generateConnectionParams:w},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O)})}},[g,e,p,o,n,r,i,d,u,v]);const x=w=>{f(w.apiKey),h(!0)};return c===null?a.jsx(gh,{provider:e,providerInfo:t,handleSubmit:x,error:null}):s}function vh({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var I;const[r,s]=y.useState(!1),c=()=>s(!r),[u,d]=y.useState(""),[p,h]=y.useState(""),v=C=>d(C.currentTarget.value),f=C=>h(C.currentTarget.value),g=it(e,t),x=(I=t.basicOpts)==null?void 0:I.docsURL,w=u.length>0,O=i||!w;return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${g} integration`})}),a.jsx(Ke,{error:o}),a.jsx("br",{}),a.jsxs(S.Stack,{spacing:4,children:[x&&a.jsx(Kn,{url:x,providerDisplayName:g,credentialName:"credentials"}),a.jsx(S.Input,{placeholder:"Username",onChange:v}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:f,pr:"4.5rem",type:r?"text":"password",placeholder:"Password"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:c,children:r?"Hide":"Show"})})]})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:O,width:"100%",type:"submit",onClick:()=>{n({user:u,pass:p})},children:"Next"})]})})}function Ih({provider:e,providerInfo:t,handleSubmit:n,error:o,isButtonDisabled:i}){var O;const[r,s]=y.useState(!1),c=()=>s(I=>!I),[u,d]=y.useState({username:"",password:""}),{username:p,password:h}=u,v=it(e,t),f=(O=t.basicOpts)==null?void 0:O.docsURL,g=p.length>0,x=i||!g,w=I=>{const{name:C,value:b}=I.currentTarget;d(m=>({...m,[C]:b}))};return a.jsx(zr,{providerName:v,handleSubmit:()=>{n({user:p,pass:h})},error:o,isButtonDisabled:x,children:a.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[f&&a.jsx(Kn,{url:f,providerDisplayName:v,credentialName:"credentials"}),a.jsx(rt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:I=>w(I)}),a.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[a.jsx(rt.Input,{id:"password",name:"password",type:r?"text":"password",placeholder:"Password",onChange:I=>w(I)}),a.jsx(He,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:c,children:r?"Hide":"Show"})]})]})})}function wh({...e}){return ve?a.jsx(Ih,{...e}):a.jsx(vh,{...e})}function xh({provider:e,providerInfo:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,children:s,selectedConnection:c,setSelectedConnection:u}){const d=Ie(),[p,h]=y.useState(!1),[v,f]=y.useState(null),g=xe();y.useEffect(()=>{if(e&&fe&&p&&v!=null){const w={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,basicAuth:{username:v.user,password:v.pass}};fe().connectionApi.generateConnection({projectIdOrName:d.projectId,generateConnectionParams:w},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(O=>{u(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O)})}},[g,e,p,o,n,r,i,d,v,u]);const x=w=>{const{user:O,pass:I}=w;f({user:O,pass:I}),h(!0)};return c===null?a.jsx(wh,{provider:e,providerInfo:t,handleSubmit:x,error:null}):s}function _h({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${o} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function bh({...e}){return ve?a.jsx(zr,{...e}):a.jsx(_h,{...e})}function Ch({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,children:r,selectedConnection:s,setSelectedConnection:c,providerName:u}){const d=Ie(),p=xe(),[h,v]=y.useState(!1);y.useEffect(()=>{if(e&&fe&&h){const g={groupName:i,groupRef:o,consumerName:n,consumerRef:t,provider:e};fe().connectionApi.generateConnection({projectIdOrName:d.projectId,generateConnectionParams:g},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info."),Ce(x)})}},[p,e,h,n,t,i,o,c,d]);const f=()=>{v(!0)};return s===null?a.jsx(bh,{handleSubmit:f,error:null,providerName:u}):r}const Ws=async(e,t,n,o,i,r,s,c)=>{var d;const u=await fe().providerApi.getProvider({provider:i},{headers:{"X-Api-Key":o??""}});if(!u)throw new Error(`Provider ${i} not found`);if(u.authType==="oauth2"&&((d=u.oauth2Opts)==null?void 0:d.grantType)==="authorizationCode"){const h=(await fe().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":o??""}})).find(x=>x.provider===i),v=it(i,u);if(!h)throw new Error(`You must first set up a ${v} Provider App using the Ampersand Console.`);const f={connectOAuthParams:{providerWorkspaceRef:r,projectId:e,groupRef:n,groupName:c,consumerRef:t,consumerName:s,providerAppId:h.id,provider:i}};return await fe().oAuthApi.oauthConnect(f)}throw new Error(`Provider ${i} does not support an OAuth2 web flow.`)},Jo=600,zo=600,Oh="AUTHORIZATION_SUCCEEDED",Sh="AUTHORIZATION_FAILED";function Eh(e,t,n){return y.useCallback(async o=>{const i=await fe().connectionApi.getConnection({projectIdOrName:e,connectionId:o},{headers:{"X-Api-Key":t??""}});n(i)},[e,t,n])}function Nh(e,t,n,o){return y.useCallback(()=>{if(!o)return;const i=window.screenX+(window.outerWidth-Jo)/2,r=window.screenY+(window.outerHeight-zo)/2.5,s=`width=${Jo},height=${zo},left=${i},top=${r}`,c=window.open(o,e,s);t(c),window.addEventListener("message",n,!1)},[o,e,t,n])}function Rh(e,t){return y.useCallback(n=>{var o,i;if(n.origin===Tl){if(n.data.eventType===Oh){const r=(o=n.data.data)==null?void 0:o.connection;r?e(r):console.error("Connection ID not found in event data: ",{event:n})}n.data.eventType===Sh&&(console.error("OAuth failed: ",{event:n}),t==null||t(((i=n==null?void 0:n.data)==null?void 0:i.message)??"OAuth failed. Please try again."))}},[t,e])}function Js({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:o,error:i}){const r=xe(),{projectId:s}=Ie(),[c,u]=y.useState(null),[d,p]=y.useState(null),{setSelectedConnection:h}=kt(),v=Rh(u,o),f=Nh(n,p,v,t),g=Eh(s,r,h);y.useEffect(()=>{t&&!d&&f()},[t,d,f,v,n]),y.useEffect(()=>{c&&g(c).then(()=>{d==null||d.close()}).catch(w=>{console.error("Error refreshing connection: ",w),o==null||o(w.message??"Unexpected error: not able to refresh connection")})},[c,r,h,g,d,o]);const x=d&&setInterval(()=>{(d!=null&&d.closed||!d)&&x&&(clearInterval(x),window.removeEventListener("message",v),p(null),!c&&!i?(console.error("OAuth failed. Please try again."),o==null||o("OAuth failed. Please try again.")):c&&o&&(o==null||o(null)))},500);return a.jsx("div",{children:e})}function Th({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${o} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:n,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Ah({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o}){return ve?a.jsxs(Me,{children:[a.jsx(Qt,{children:`Set up ${o} integration`}),a.jsx(Ke,{error:t}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]}):a.jsx(Th,{handleSubmit:e,error:t,isButtonDisabled:n,providerName:o})}function jh({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,providerName:r}){const{projectId:s}=Ie(),c=xe(),[u,d]=y.useState(null),[p,h]=y.useState(null),v=async()=>{h(null);try{const g=await Ws(s,t,o,c,e,void 0,n,i);d(g)}catch(g){console.error("Could not fetch OAuth popup URL."),Ce(g),h(g.message??"Unexpected error")}},f=y.useCallback(g=>{h(g),d(null)},[]);return a.jsx(Js,{windowTitle:`Connect to ${r}`,oauthUrl:u,onError:f,children:a.jsx(Ah,{handleSubmit:v,error:p,providerName:r})})}const Ph=S.createIcon({displayName:"ExternalLinkIcon",path:a.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",children:[a.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),a.jsx("path",{d:"M15 3h6v6"}),a.jsx("path",{d:"M10 14L21 3"})]})}),zs="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function Dh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{children:a.jsx(S.Heading,{as:"h4",size:"md",children:"Enter your Salesforce subdomain"})}),a.jsxs(Xr,{href:zs,newTab:!0,children:["What is my Salesforce subdomain? ",a.jsx(Ph,{})]}),a.jsx(Ke,{error:n}),a.jsxs("div",{style:{display:"flex",marginTop:"1em"},children:[a.jsx(S.Input,{placeholder:"my-domain",onChange:i=>t(i.currentTarget.value)}),a.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:o,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function kh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o}){const i={handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o};return ve?a.jsxs(Me,{children:[a.jsx(Qt,{children:"Enter your Salesforce subdomain"}),a.jsx(Xr,{href:zs,newTab:!0,children:"What is my Salesforce subdomain?"}),a.jsx(Ke,{error:n}),a.jsxs("div",{style:{display:"flex",marginTop:"1em"},children:[a.jsx(rt.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:r=>t(r.currentTarget.value)}),a.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:o,type:"submit",onClick:e,children:"Next"})]}):a.jsx(Dh,{...i})}function Fh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o,providerName:i}){return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsxs(S.Heading,{as:"h4",size:"md",children:["Enter your ",i," workspace"]})}),a.jsx(Ke,{error:n}),a.jsx(S.Flex,{marginTop:"1em",children:a.jsx(S.Input,{placeholder:"MyWorkspace",onChange:r=>t(r.currentTarget.value)})}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:o,width:"100%",type:"submit",onClick:e,children:"Next"})]})})}function Mh({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o,providerName:i}){if(!ve){const r={handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:o,providerName:i};return a.jsx(Fh,{...r})}return a.jsxs(Me,{children:[a.jsxs(Qt,{children:["Enter your ",i," workspace"]}),a.jsx(Ke,{error:n}),a.jsx("br",{}),a.jsx(rt.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:r=>t(r.currentTarget.value)}),a.jsx("br",{}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:o,type:"submit",onClick:e,children:"Next"})]})}const Kh="salesforce";function Lh({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,providerName:r}){const{projectId:s}=Ie(),c=xe(),[u,d]=y.useState(""),[p,h]=y.useState(null),[v,f]=y.useState(null),g=async()=>{if(f(null),!u){f("Workspace is required");return}try{const O=await Ws(s,t,o,c,e,u,n,i);h(O)}catch(O){console.error(O),f((O==null?void 0:O.message)??"Unexpected error")}},x=y.useCallback(O=>{f(O),h(null)},[]),w=e===Kh?a.jsx(kh,{handleSubmit:g,setWorkspace:d,error:v,isButtonDisabled:u.length===0}):a.jsx(Mh,{handleSubmit:g,setWorkspace:d,error:v,isButtonDisabled:u.length===0,providerName:r});return a.jsx(Js,{windowTitle:`Connect to ${r}`,oauthUrl:p,onError:x,children:w})}function $h({handleSubmit:e,error:t,explicitScopesRequired:n,isButtonDisabled:o,providerName:i}){const[r,s]=y.useState(!1),[c,u]=y.useState(""),[d,p]=y.useState(""),[h,v]=y.useState(""),f=()=>s(!r),g=m=>u(m.currentTarget.value),x=m=>p(m.currentTarget.value),w=m=>v(m.currentTarget.value),O=c.length>0,I=d.length>0,C=o||!O||!I,b=()=>{const m={clientId:d,clientSecret:c};n&&h.length>0&&(m.scopes=Ir(h)),e(m)};return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${i} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsxs(S.Stack,{spacing:4,children:[a.jsx(S.Input,{placeholder:"Client ID",onChange:x}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:g,pr:"4.5rem",type:r?"text":"password",placeholder:"Client Secret"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:f,children:r?"Hide":"Show"})})]}),n&&a.jsx(S.Textarea,{placeholder:"Scopes separated by new line",onChange:w})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:C,width:"100%",type:"submit",onClick:b,children:"Next"})]})})}function Hh({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,explicitScopesRequired:r,providerName:s,selectedConnection:c,setSelectedConnection:u}){const{projectId:d}=Ie(),p=xe(),[h,v]=y.useState(null),f=async g=>{v(null);const x={groupName:i,groupRef:o,consumerName:n,consumerRef:t,provider:e,oauth2ClientCredentials:{clientId:g.clientId,clientSecret:g.clientSecret,scopes:g.scopes}};fe().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:x},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(w=>{u(w)}).catch(w=>{console.error("Error loading provider info."),Ce(w),v("Error loading provider info")})};return c===null?a.jsx($h,{providerName:s,handleSubmit:f,error:h,explicitScopesRequired:r}):a.jsx(qe,{})}function Vh({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o,explicitScopesRequired:i}){const[r,s]=y.useState(!1),[c,u]=y.useState(""),[d,p]=y.useState(""),[h,v]=y.useState(""),[f,g]=y.useState(""),x=()=>s(!r),w=V=>u(V.currentTarget.value),O=V=>p(V.currentTarget.value),I=V=>v(V.currentTarget.value),C=V=>g(V.currentTarget.value),b=c.length>0,m=d.length>0,j=h.length>0,$=n||!b||!m||!j,F=()=>{const V={workspace:h,clientId:d,clientSecret:c};i&&f.length>0&&(V.scopes=Ir(f)),e(V)};return a.jsx(Me,{children:a.jsxs(S.FormControl,{children:[a.jsx(S.FormLabel,{marginTop:"16",marginBottom:"0",children:a.jsx(S.Heading,{as:"h4",size:"md",children:`Set up ${o} integration`})}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsxs(S.Stack,{spacing:4,children:[a.jsx(S.Input,{placeholder:"MyWorkspace",onChange:I}),a.jsx(S.Input,{placeholder:"Client ID",onChange:O}),a.jsxs(S.InputGroup,{size:"md",children:[a.jsx(S.Input,{onChange:w,pr:"4.5rem",type:r?"text":"password",placeholder:"Client Secret"}),a.jsx(S.InputRightElement,{width:"4.5rem",children:a.jsx(S.Button,{h:"1.75rem",size:"sm",onClick:x,children:r?"Hide":"Show"})})]}),i&&a.jsx(S.Textarea,{placeholder:"Scopes separated by new line",onChange:C})]}),a.jsx("br",{}),a.jsx(S.Button,{variant:"primary",isDisabled:$,width:"100%",type:"submit",onClick:F,children:"Next"})]})})}function Uh({provider:e,providerName:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,explicitScopesRequired:s,selectedConnection:c,setSelectedConnection:u}){const{projectId:d}=Ie(),p=xe(),[h,v]=y.useState(null),f=async g=>{v(null);const x={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,providerWorkspaceRef:g.workspace,oauth2ClientCredentials:{clientId:g.clientId,clientSecret:g.clientSecret,scopes:g.scopes}};fe().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:x},{headers:{"X-Api-Key":p??"","Content-Type":"application/json"}}).then(w=>{u(w)}).catch(w=>{console.error("Error loading provider info."),Ce(w),v("Error loading provider info")})};return c===null?a.jsx(Vh,{providerName:t,handleSubmit:f,error:h,explicitScopesRequired:s}):a.jsx(qe,{})}function Bh({handleSubmit:e,error:t,isButtonDisabled:n,providerName:o,explicitScopesRequired:i,explicitWorkspaceRequired:r}){const[s,c]=y.useState(!1),[u,d]=y.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),p=()=>c(m=>!m),h=m=>{const{name:j,value:$}=m.currentTarget;d(F=>({...F,[j]:$}))},{clientSecret:v,clientId:f,workspace:g,scopes:x}=u,w=v.length>0,O=f.length>0,I=r?g.length>0:!0,C=n||!w||!O||!I,b=()=>{const m={clientId:f,clientSecret:v};r&&(m.workspace=g),i&&x.length>0&&(m.scopes=Ir(x)),e(m)};return a.jsxs(Me,{children:[a.jsx(Qt,{children:`Set up ${o} integration`}),a.jsx(Ke,{error:t}),a.jsx("br",{}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[r&&a.jsx(rt.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:m=>h(m)}),a.jsx(rt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:m=>h(m)}),a.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[a.jsx(rt.Input,{id:"clientSecret",name:"clientSecret",type:s?"text":"password",placeholder:"Client Secret",onChange:m=>h(m)}),a.jsx(He,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:p,children:s?"Hide":"Show"})]}),i&&a.jsx(rt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:m=>h(m)})]}),a.jsx("br",{}),a.jsx(He,{style:{marginTop:"1em",width:"100%"},disabled:C,type:"submit",onClick:b,children:"Next"})]})}function qh({provider:e,providerName:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,explicitScopesRequired:s,explicitWorkspaceRequired:c,selectedConnection:u,setSelectedConnection:d}){const{projectId:p}=Ie(),h=xe(),[v,f]=y.useState(null),g=async x=>{f(null);const w={groupName:r,groupRef:i,consumerName:o,consumerRef:n,provider:e,providerWorkspaceRef:x.workspace,oauth2ClientCredentials:{clientId:x.clientId,clientSecret:x.clientSecret,scopes:x.scopes}};fe().connectionApi.generateConnection({projectIdOrName:p,generateConnectionParams:w},{headers:{"X-Api-Key":h??"","Content-Type":"application/json"}}).then(O=>{d(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O),f("Error loading provider info")})};return u===null?a.jsx(Bh,{providerName:t,handleSubmit:g,error:v,explicitScopesRequired:s,explicitWorkspaceRequired:c}):a.jsx(qe,{})}function Wh({...e}){return ve?a.jsx(qh,{...e}):e.explicitWorkspaceRequired?a.jsx(Uh,{...e}):a.jsx(Hh,{...e})}const Jh="authorizationCode",zh="clientCredentials";function Xh({provider:e,providerInfo:t,consumerRef:n,consumerName:o,groupRef:i,groupName:r,selectedConnection:s,setSelectedConnection:c}){if(t.oauth2Opts===void 0)return a.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:u,explicitScopesRequired:d,explicitWorkspaceRequired:p}=t.oauth2Opts,h=it(e,t),v={provider:e,consumerRef:n,consumerName:o,groupRef:i,groupName:r,providerName:h};return u===Jh?p?a.jsx(Lh,{...v}):a.jsx(jh,{...v}):u===zh?a.jsx(Wh,{...v,explicitWorkspaceRequired:p,explicitScopesRequired:d,selectedConnection:s,setSelectedConnection:c}):u==="password"?a.jsx("em",{children:"Password flow not supported yet"}):u==="PKCE"?a.jsx("em",{children:"PKCE flow not supported yet"}):a.jsxs("em",{children:["Unsupported grant type: ",u]})}function Yh(e){const{selectedConnection:t}=kt();y.useEffect(()=>{e&&t&&e(t.id)},[e,t])}function Gh({onSuccess:e}){Yh(e)}const Zh=async(e,t)=>{const n=await fe().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!n)throw new Error(`Provider ${t} not found`);return n};function Xs({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,children:r,onSuccess:s}){const c=xe(),[u,d]=y.useState(null),{provider:p}=Ye(),{selectedConnection:h,setSelectedConnection:v,connections:f}=kt();Gh({onSuccess:s});const g=e||p,x=(u==null?void 0:u.displayName)??Go(g);if(y.useEffect(()=>{if(!h&&f&&f.length>0){const[O]=f;v(O)}Zh(c,g).then(O=>{d(O)}).catch(O=>{console.error("Error loading provider info."),Ce(O)})},[f,h,v,c,g]),!e&&!p)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(h)return r;if(u==null)return a.jsx("strong",{children:"Provider not found"});const w={provider:g,consumerRef:t,consumerName:n,groupRef:o,groupName:i,selectedConnection:h,setSelectedConnection:v,providerName:x,providerInfo:u};return u.authType==="none"?a.jsx(Ch,{...w,children:r}):u.authType==="basic"?a.jsx(xh,{...w,children:r}):u.authType==="apiKey"?a.jsx(yh,{...w,children:r}):a.jsx(Xh,{...w})}const Qh=a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[a.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),a.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function em(e,t){return t?y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},y.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?Qh:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:a.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}const Ys=y.forwardRef(({objectName:e,completed:t,pending:n,displayName:o},i)=>{const r=S.useTab({ref:i}),s=S.useMultiStyleConfig("Tabs",r);return a.jsxs(S.Button,{__css:s.tab,...r,variant:"outline",minHeight:15,children:[a.jsxs(S.Box,{as:"span",display:"flex",alignItems:"center",gap:2,mr:"3",children:[em(t,n),a.jsxs(S.Box,{textAlign:"left",children:[a.jsx(S.Text,{children:o||e}),n&&a.jsx(S.Text,{fontSize:10,fontStyle:"italic",children:"pending"})]})]}),r.children]})});function tm({pending:e,completed:t,displayName:n}){return a.jsxs(a.Fragment,{children:[a.jsx(qr,{style:{margin:"1rem 0"}}),a.jsx(Ys,{objectName:xt,completed:t,pending:e,displayName:n},"other-write")]})}function nm(e,t){return e!=null&&e[t]?e[t]:{name:Ni,completed:!1}}const rm=getComputedStyle(document.documentElement).getPropertyValue("--amp-colors-background-secondary").trim()||"#FCFCFC";function om({children:e}){var O,I,C;const{project:t}=Ie(),{installation:n,provider:o}=Ye(),{hydratedRevision:i}=Zt(),{objectConfigurationsState:r}=Br(),[s,c]=y.useState(0),u=(t==null?void 0:t.appName)||"",d=n==null?void 0:n.config,p=i&&yi(d,i),h=p!==null,v=!!((O=i==null?void 0:i.content)!=null&&O.write),f=v?vi(d):void 0,g=y.useMemo(()=>{const b=[...p||[]];return f&&v&&b.push(f),b},[p,f,v]),x=nm(g,s),w=y.useCallback(()=>{const b=g.find(m=>x!==m&&!m.completed);b&&c(g.indexOf(b))},[g,x]);return a.jsx(gs.Provider,{value:w,children:a.jsx(hs.Provider,{value:x==null?void 0:x.name,children:a.jsxs(Gt,{style:{maxWidth:"55rem"},children:[a.jsxs(Dt,{style:{display:"flex",gap:"1rem",padding:"3rem",backgroundColor:rm},children:[a.jsxs("div",{style:{width:"20rem"},children:[a.jsxs(S.Text,{children:[it(o)," integration"]}),a.jsx(S.Text,{marginBottom:"20px",fontSize:"1.125rem",fontWeight:"500",children:u}),h&&a.jsxs(S.Tabs,{index:s,onChange:c,orientation:"horizontal",children:[p.map(b=>{var m,j,$,F;return a.jsx(Ys,{objectName:b.name,completed:b.completed,pending:((j=(m=r[b.name])==null?void 0:m.read)==null?void 0:j.isOptionalFieldsModified)||((F=($=r[b.name])==null?void 0:$.read)==null?void 0:F.isRequiredMapFieldsModified)},b.name)}),v&&f&&a.jsx(tm,{completed:f.completed,pending:(C=(I=r==null?void 0:r.other)==null?void 0:I.write)==null?void 0:C.isWriteModified,displayName:p!=null&&p.length?"other":"write"}),n&&a.jsxs(a.Fragment,{children:[a.jsx(qr,{style:{margin:"3rem 0 1rem 0"}}),a.jsx(wd,{text:"Uninstall"},"uninstall-installation")]})]})]}),e]}),a.jsx(qs,{})]})})})}function im(){const[e,t]=y.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}function sm({integration:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,onInstallSuccess:r,onUpdateSuccess:s,onUninstallSuccess:c}){var v;const{projectId:u}=Ie(),{errorState:d}=dt(),{seed:p,reset:h}=im();return(v=d[me.INTEGRATION_LIST])!=null&&v.apiError?a.jsx(ot,{message:"Something went wrong, couldn't find integration information"}):a.jsx(Wl,{integration:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,onInstallSuccess:r,onUpdateSuccess:s,onUninstallSuccess:c,children:a.jsx(mi,{groupRef:o,children:a.jsx(Xs,{consumerRef:t,consumerName:n,groupRef:o,groupName:i,children:a.jsx(xd,{projectId:u,children:a.jsx(nh,{resetComponent:h,children:a.jsx(qp,{children:a.jsx(om,{children:a.jsx(Yf,{})})})})})})})},p)}function am(){return a.jsxs(Gt,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[a.jsx(qe,{}),a.jsx("p",{children:"Redirecting"})]})}function cm({redirectURL:e,children:t}){return y.useEffect(()=>{e&&window.location.replace(e)},[e]),e?a.jsx(am,{}):t}function um({provider:e}){const{appName:t}=Ie(),n=`You have successfully connected your ${it(e)} account to ${t}.`;return a.jsx(Jr,{text:n})}function lm({provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,redirectUrl:r,onSuccess:s}){return a.jsx(mi,{provider:e,groupRef:o,children:a.jsx(Xs,{provider:e,consumerRef:t,consumerName:n,groupRef:o,groupName:i,onSuccess:s,children:a.jsx(cm,{redirectURL:r,children:a.jsx(um,{provider:e})})})})}const dm=(e,t)=>{const n=xe(),{projectId:o}=Ie(),{integrations:i}=li(),[r,s]=y.useState(!1),[c,u]=y.useState(null);if(!n||!o)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 d=y.useMemo(()=>i==null?void 0:i.reduce((p,h)=>(h==null?void 0:h.name)===e?h:p,{}),[i,e]);return y.useEffect(()=>{d&&fe().installationApi.listInstallations({projectIdOrName:o,integrationId:d.id,groupRef:t},{headers:{"x-api-key":n}}).then(p=>{s(!0),u(p.length>0)}).catch(p=>{console.error("Error listing installations."),Ce(p),s(!0)})},[t,n,o,d]),{isLoaded:r,isIntegrationInstalled:c}};exports.AmpersandContext=pi;exports.AmpersandProvider=Ul;exports.ConnectProvider=lm;exports.InstallIntegration=sm;exports.useAmpersandProvider=Bl;exports.useIsIntegrationInstalled=dm;
|